Skip to content

Commit 95b100c

Browse files
committed
feat(tools): expand SharedTools with calculator, weather, and workflow capabilities
Add new gem dependencies (ffi, fiddle, macos, watir, webdrivers, selenium‑webdriver, rubyzip, watir, websocket, etc.) to Gemfile.lock, update the README to list 13 + production tools, and introduce CalculatorTool, WeatherTool, and WorkflowManagerTool. Update example usage and tool collection definitions accordingly.
1 parent 1f60127 commit 95b100c

20 files changed

Lines changed: 2461 additions & 1696 deletions

Gemfile.lock

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ GEM
3636
net-http (>= 0.5.0)
3737
faraday-retry (2.3.2)
3838
faraday (~> 2.0)
39+
ffi (1.17.2-arm64-darwin)
40+
fiddle (1.1.8)
3941
hashery (2.1.2)
4042
http-2 (1.1.1)
4143
httpx (1.6.3)
@@ -45,6 +47,10 @@ GEM
4547
addressable (~> 2.8)
4648
bigdecimal (~> 3.1)
4749
logger (1.7.0)
50+
macos (0.1.8)
51+
ffi
52+
fiddle
53+
zeitwerk
4854
marcel (1.1.0)
4955
minitest (5.26.0)
5056
multipart-post (2.4.1)
@@ -62,6 +68,8 @@ GEM
6268
public_suffix (6.0.2)
6369
racc (1.8.1)
6470
rake (13.3.1)
71+
regexp_parser (2.11.3)
72+
rexml (3.4.4)
6573
ruby-rc4 (0.1.5)
6674
ruby_llm (1.9.1)
6775
base64
@@ -79,6 +87,11 @@ GEM
7987
ruby_llm (~> 1.9)
8088
zeitwerk (~> 2)
8189
ruby_llm-schema (0.2.1)
90+
rubyzip (2.4.1)
91+
selenium-webdriver (4.10.0)
92+
rexml (~> 3.2, >= 3.2.5)
93+
rubyzip (>= 1.2.2, < 3.0)
94+
websocket (~> 1.0)
8295
sequel (5.98.0)
8396
bigdecimal
8497
simplecov (0.22.0)
@@ -91,6 +104,14 @@ GEM
91104
ttfunk (1.8.0)
92105
bigdecimal (~> 3.1)
93106
uri (1.1.1)
107+
watir (7.3.0)
108+
regexp_parser (>= 1.2, < 3)
109+
selenium-webdriver (~> 4.2)
110+
webdrivers (5.3.1)
111+
nokogiri (~> 1.6)
112+
rubyzip (>= 1.3.0)
113+
selenium-webdriver (~> 4.0, < 4.11)
114+
websocket (1.2.11)
94115
zeitwerk (2.7.3)
95116

96117
PLATFORMS
@@ -100,13 +121,15 @@ PLATFORMS
100121
DEPENDENCIES
101122
bundler
102123
debug_me
124+
macos
103125
minitest
104-
openweathermap
105126
pdf-reader
106127
rake
107128
shared_tools!
108129
simplecov
109130
sqlite3
131+
watir
132+
webdrivers
110133

111134
BUNDLED WITH
112135
2.7.2

README.md

Lines changed: 209 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SharedTools is a comprehensive collection of production-ready tools designed for
1616

1717
### Key Features
1818

19-
- 🔧 **6 Tool Collections** - Browser automation, file operations, database queries, code evaluation, PDF processing, and system control
19+
- 🔧 **13+ Production Tools** - Browser automation, file operations, database queries, code evaluation, PDF processing, system control, mathematical calculations, weather data, workflow management, data analysis, Docker integration, and more
2020
- 🔒 **Human-in-the-Loop Authorization** - Built-in safety system for sensitive operations
2121
- 🎯 **Facade Pattern** - Simplified interfaces with complex capabilities under the hood
2222
- 🔌 **Pluggable Drivers** - Swap implementations for testing or different backends
@@ -47,11 +47,17 @@ Depending on which tools you use, you may need additional gems:
4747
gem 'watir'
4848
gem 'webdrivers'
4949

50-
# For DatabaseTool
50+
# For DatabaseTool and DatabaseQueryTool
5151
gem 'sqlite3' # or pg, mysql2, etc.
5252

5353
# For DocTool
54-
gem 'pdf-reader' # included in SharedTools dependencies
54+
gem 'pdf-reader'
55+
56+
# Core dependencies (automatically installed)
57+
gem 'dentaku' # For CalculatorTool
58+
gem 'openweathermap' # For WeatherTool
59+
gem 'sequel' # For DatabaseQueryTool
60+
gem 'nokogiri' # For various tools
5561
```
5662

5763
## Quick Start
@@ -65,7 +71,10 @@ agent = RubyLLM::Agent.new(
6571
tools: [
6672
SharedTools::Tools::BrowserTool.new,
6773
SharedTools::Tools::DiskTool.new,
68-
SharedTools::Tools::DatabaseTool.new
74+
SharedTools::Tools::DatabaseTool.new,
75+
SharedTools::Tools::CalculatorTool.new,
76+
SharedTools::Tools::WeatherTool.new,
77+
SharedTools::Tools::WorkflowManagerTool.new
6978
]
7079
)
7180

@@ -75,7 +84,7 @@ agent.process("Visit example.com and save the page title to title.txt")
7584

7685
# Or enable auto-execution for automated workflows
7786
SharedTools.auto_execute(true)
78-
agent.process("Read all .rb files in the current directory")
87+
agent.process("Calculate the square root of 144 and tell me the weather in London")
7988
```
8089

8190
## Tool Collections
@@ -240,6 +249,189 @@ computer.execute(action: "key", text: "Return")
240249

241250
---
242251

252+
### 🧮 Calculator Tool
253+
254+
Safe mathematical calculations without code execution risks.
255+
256+
**Features:**
257+
- Safe expression evaluation using Dentaku parser
258+
- Basic arithmetic: +, -, *, /, %, ^
259+
- Mathematical functions: sqrt, round, abs
260+
- Trigonometric functions: sin, cos, tan
261+
- Configurable precision (0-10 decimal places)
262+
- Comprehensive error handling
263+
264+
**Example:**
265+
```ruby
266+
calculator = SharedTools::Tools::CalculatorTool.new
267+
268+
calculator.execute(expression: "2 + 2")
269+
# => {success: true, result: 4.0, precision: 2}
270+
271+
calculator.execute(expression: "sqrt(16) * 2", precision: 4)
272+
# => {success: true, result: 8.0, precision: 4}
273+
```
274+
275+
---
276+
277+
### 🌤️ Weather Tool
278+
279+
Real-time weather data from OpenWeatherMap API.
280+
281+
**Features:**
282+
- Current weather conditions for any city worldwide
283+
- Multiple temperature units (metric, imperial, kelvin)
284+
- Optional 3-day forecast data
285+
- Comprehensive atmospheric data (humidity, pressure, wind)
286+
- Requires OPENWEATHER_API_KEY environment variable
287+
288+
**Example:**
289+
```ruby
290+
weather = SharedTools::Tools::WeatherTool.new
291+
292+
weather.execute(city: "London,UK", units: "metric")
293+
# => {success: true, current: {temperature: 15.5, ...}}
294+
295+
weather.execute(city: "New York,US", units: "imperial", include_forecast: true)
296+
# => Includes current weather and 3-day forecast
297+
```
298+
299+
---
300+
301+
### 🔄 Workflow Manager Tool
302+
303+
Manage complex multi-step workflows with persistent state.
304+
305+
**Features:**
306+
- Create and track stateful workflows
307+
- Step-by-step execution with state persistence
308+
- Status monitoring and progress tracking
309+
- Workflow completion and cleanup
310+
- Survives process restarts
311+
312+
**Example:**
313+
```ruby
314+
workflow = SharedTools::Tools::WorkflowManagerTool.new
315+
316+
# Start a workflow
317+
result = workflow.execute(action: "start", step_data: {project: "demo"})
318+
workflow_id = result[:workflow_id]
319+
320+
# Execute steps
321+
workflow.execute(action: "step", workflow_id: workflow_id, step_data: {task: "compile"})
322+
workflow.execute(action: "step", workflow_id: workflow_id, step_data: {task: "test"})
323+
324+
# Check status
325+
workflow.execute(action: "status", workflow_id: workflow_id)
326+
327+
# Complete
328+
workflow.execute(action: "complete", workflow_id: workflow_id)
329+
```
330+
331+
---
332+
333+
### 📊 Composite Analysis Tool
334+
335+
Multi-stage data analysis orchestration.
336+
337+
**Features:**
338+
- Automatic data source detection (files or URLs)
339+
- Data structure analysis
340+
- Statistical insights generation
341+
- Visualization suggestions
342+
- Correlation analysis
343+
- Supports CSV, JSON, and text formats
344+
345+
**Example:**
346+
```ruby
347+
analyzer = SharedTools::Tools::CompositeAnalysisTool.new
348+
349+
analyzer.execute(
350+
data_source: "./sales_data.csv",
351+
analysis_type: "comprehensive",
352+
options: {include_correlations: true, visualization_limit: 5}
353+
)
354+
# => Complete analysis with structure, insights, and visualizations
355+
```
356+
357+
---
358+
359+
### 🗄️ Database Query Tool
360+
361+
Safe, read-only database query execution.
362+
363+
**Features:**
364+
- SELECT-only queries for security
365+
- Automatic LIMIT clause enforcement
366+
- Query timeout protection
367+
- Prepared statement support
368+
- Connection pooling
369+
- Supports PostgreSQL, MySQL, SQLite, and more
370+
371+
**Example:**
372+
```ruby
373+
db_query = SharedTools::Tools::DatabaseQueryTool.new
374+
375+
db_query.execute(
376+
query: "SELECT * FROM users WHERE active = ?",
377+
params: [true],
378+
limit: 50,
379+
timeout: 10
380+
)
381+
# => {success: true, row_count: 50, data: [...]}
382+
```
383+
384+
---
385+
386+
### 🐳 Docker Compose Tool
387+
388+
Execute Docker Compose commands safely.
389+
390+
**Features:**
391+
- Run commands in Docker containers
392+
- Service specification
393+
- Automatic container cleanup
394+
- Build and run in one step
395+
396+
**Example:**
397+
```ruby
398+
docker = SharedTools::Tools::Docker::ComposeRunTool.new
399+
400+
docker.execute(
401+
service: "app",
402+
command: "rspec",
403+
args: ["spec/main_spec.rb"]
404+
)
405+
```
406+
407+
---
408+
409+
### 🛠️ Error Handling Tool
410+
411+
Reference implementation for robust error handling patterns.
412+
413+
**Features:**
414+
- Multiple error type handling
415+
- Retry mechanisms with exponential backoff
416+
- Input/output validation
417+
- Resource cleanup patterns
418+
- Detailed error categorization
419+
- Support reference IDs for debugging
420+
421+
**Example:**
422+
```ruby
423+
error_tool = SharedTools::Tools::ErrorHandlingTool.new
424+
425+
error_tool.execute(
426+
operation: "process",
427+
data: {name: "test", value: 42},
428+
max_retries: 3
429+
)
430+
# => Demonstrates comprehensive error handling patterns
431+
```
432+
433+
---
434+
243435
## Authorization System
244436

245437
SharedTools includes a human-in-the-loop authorization system for safety:
@@ -375,13 +567,24 @@ Found a bug or have a feature request? Please [open an issue](https://github.com
375567

376568
See the [Changelog](https://madbomber.github.io/shared_tools/development/changelog/) for version history and upcoming features.
377569

570+
### Recent Additions (v0.12+)
571+
572+
- ✅ Calculator Tool - Safe mathematical calculations with Dentaku
573+
- ✅ Weather Tool - Real-time weather data via OpenWeatherMap API
574+
- ✅ Workflow Manager Tool - Stateful multi-step workflow orchestration
575+
- ✅ Composite Analysis Tool - Multi-stage data analysis
576+
- ✅ Database Query Tool - Safe read-only database queries
577+
- ✅ Docker Compose Tool - Container command execution
578+
- ✅ Error Handling Tool - Reference implementation for robust patterns
579+
378580
### Future Enhancements
379581

380582
- Additional browser drivers (Selenium, Playwright)
381-
- More database adapters
583+
- More database adapters and query builders
382584
- Enhanced PDF processing capabilities
383585
- Additional document formats (Word, Excel)
384586
- Video and image processing tools
587+
- Extended data science and analytics capabilities
385588

386589
## Requirements
387590

0 commit comments

Comments
 (0)