claude_swarm 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/Rakefile +4 -4
- data/docs/v2/CHANGELOG.swarm_cli.md +19 -0
- data/docs/v2/CHANGELOG.swarm_memory.md +19 -0
- data/docs/v2/CHANGELOG.swarm_sdk.md +92 -0
- data/docs/v2/README.md +56 -22
- data/docs/v2/guides/MEMORY_DEFRAG_GUIDE.md +811 -0
- data/docs/v2/guides/complete-tutorial.md +115 -3
- data/docs/v2/guides/getting-started.md +6 -6
- data/docs/v2/guides/rails-integration.md +6 -6
- data/docs/v2/reference/architecture-flow.md +407 -0
- data/docs/v2/reference/event_payload_structures.md +471 -0
- data/docs/v2/reference/execution-flow.md +600 -0
- data/docs/v2/reference/ruby-dsl.md +138 -5
- data/docs/v2/reference/swarm_memory_technical_details.md +2090 -0
- data/examples/v2/swarm_with_hooks.yml +1 -1
- data/lib/claude_swarm/cli.rb +9 -11
- data/lib/claude_swarm/commands/ps.rb +1 -2
- data/lib/claude_swarm/configuration.rb +2 -3
- data/lib/claude_swarm/mcp_generator.rb +4 -10
- data/lib/claude_swarm/orchestrator.rb +43 -44
- data/lib/claude_swarm/system_utils.rb +4 -4
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/claude_swarm.rb +4 -9
- data/lib/swarm_cli/commands/mcp_serve.rb +2 -2
- data/lib/swarm_cli/commands/mcp_tools.rb +3 -3
- data/lib/swarm_cli/config_loader.rb +14 -13
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_cli.rb +2 -0
- data/lib/swarm_memory/adapters/base.rb +4 -4
- data/lib/swarm_memory/adapters/filesystem_adapter.rb +0 -12
- data/lib/swarm_memory/core/storage.rb +66 -6
- data/lib/swarm_memory/integration/sdk_plugin.rb +14 -0
- data/lib/swarm_memory/optimization/defragmenter.rb +4 -0
- data/lib/swarm_memory/tools/memory_edit.rb +1 -0
- data/lib/swarm_memory/tools/memory_glob.rb +24 -1
- data/lib/swarm_memory/tools/memory_write.rb +2 -2
- data/lib/swarm_memory/version.rb +1 -1
- data/lib/swarm_memory.rb +2 -0
- data/lib/swarm_sdk/agent/chat.rb +1 -1
- data/lib/swarm_sdk/agent/definition.rb +18 -21
- data/lib/swarm_sdk/configuration.rb +34 -10
- data/lib/swarm_sdk/mcp.rb +16 -0
- data/lib/swarm_sdk/node/agent_config.rb +7 -2
- data/lib/swarm_sdk/node/builder.rb +130 -35
- data/lib/swarm_sdk/node_context.rb +75 -0
- data/lib/swarm_sdk/node_orchestrator.rb +219 -12
- data/lib/swarm_sdk/plugin.rb +73 -1
- data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +0 -126
- data/lib/swarm_sdk/result.rb +32 -6
- data/lib/swarm_sdk/swarm/builder.rb +1 -0
- data/lib/swarm_sdk/swarm.rb +32 -50
- data/lib/swarm_sdk/tools/delegate.rb +2 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_list.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_read.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_write.rb +21 -4
- data/lib/swarm_sdk/tools/stores/storage.rb +4 -4
- data/lib/swarm_sdk/tools/think.rb +4 -1
- data/lib/swarm_sdk/tools/todo_write.rb +20 -8
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +332 -27
- data/swarm_sdk.gemspec +1 -1
- metadata +9 -3
|
@@ -1382,23 +1382,40 @@ Configure an agent for this node (returns fluent config object).
|
|
|
1382
1382
|
|
|
1383
1383
|
**Signature:**
|
|
1384
1384
|
```ruby
|
|
1385
|
-
agent(name) → AgentConfig
|
|
1385
|
+
agent(name, reset_context: true) → AgentConfig
|
|
1386
1386
|
```
|
|
1387
1387
|
|
|
1388
1388
|
**Parameters:**
|
|
1389
1389
|
- `name` (Symbol, required): Agent name
|
|
1390
|
+
- `reset_context` (Boolean, keyword, optional): Whether to reset conversation context
|
|
1391
|
+
- `true` (default): Fresh context for each node execution
|
|
1392
|
+
- `false`: Preserve conversation history from previous nodes
|
|
1390
1393
|
|
|
1391
1394
|
**Returns:** `AgentConfig` with `.delegates_to(*names)` method
|
|
1392
1395
|
|
|
1393
1396
|
**Example:**
|
|
1394
1397
|
```ruby
|
|
1395
|
-
#
|
|
1396
|
-
agent(:backend)
|
|
1398
|
+
# Fresh context (default)
|
|
1399
|
+
agent(:backend)
|
|
1397
1400
|
|
|
1398
|
-
#
|
|
1399
|
-
agent(:
|
|
1401
|
+
# Preserve context from previous nodes
|
|
1402
|
+
agent(:backend, reset_context: false).delegates_to(:tester)
|
|
1403
|
+
|
|
1404
|
+
# Without delegation, preserving context
|
|
1405
|
+
agent(:planner, reset_context: false)
|
|
1400
1406
|
```
|
|
1401
1407
|
|
|
1408
|
+
**When to use `reset_context: false`:**
|
|
1409
|
+
- Iterative refinement workflows
|
|
1410
|
+
- Agent needs to remember previous node conversations
|
|
1411
|
+
- Chain of thought reasoning across stages
|
|
1412
|
+
- Self-reflection or debate loops
|
|
1413
|
+
|
|
1414
|
+
**When to use `reset_context: true` (default):**
|
|
1415
|
+
- Independent validation or fresh perspective
|
|
1416
|
+
- Memory management in long workflows
|
|
1417
|
+
- Different roles for same agent in different stages
|
|
1418
|
+
|
|
1402
1419
|
---
|
|
1403
1420
|
|
|
1404
1421
|
### depends_on
|
|
@@ -2044,6 +2061,122 @@ Success status from previous_result or result.
|
|
|
2044
2061
|
|
|
2045
2062
|
---
|
|
2046
2063
|
|
|
2064
|
+
### Control Flow Methods
|
|
2065
|
+
|
|
2066
|
+
Methods for dynamic workflow control (loops, conditional branching, early termination).
|
|
2067
|
+
|
|
2068
|
+
**goto_node**
|
|
2069
|
+
```ruby
|
|
2070
|
+
ctx.goto_node(node_name, content:) → Hash
|
|
2071
|
+
```
|
|
2072
|
+
Jump to a different node with custom content, bypassing normal dependency order.
|
|
2073
|
+
|
|
2074
|
+
**Parameters:**
|
|
2075
|
+
- `node_name` (Symbol, required): Target node name
|
|
2076
|
+
- `content` (String, required): Content to pass to target node (validated non-nil)
|
|
2077
|
+
|
|
2078
|
+
**Returns:** Control hash (processed by NodeOrchestrator)
|
|
2079
|
+
|
|
2080
|
+
**Valid in:** Both input and output transformers
|
|
2081
|
+
|
|
2082
|
+
**Example:**
|
|
2083
|
+
```ruby
|
|
2084
|
+
output do |ctx|
|
|
2085
|
+
if needs_revision?(ctx.content)
|
|
2086
|
+
# Jump back to revision node
|
|
2087
|
+
ctx.goto_node(:revision, content: ctx.content)
|
|
2088
|
+
else
|
|
2089
|
+
ctx.content # Continue to next node normally
|
|
2090
|
+
end
|
|
2091
|
+
end
|
|
2092
|
+
```
|
|
2093
|
+
|
|
2094
|
+
**Use cases:**
|
|
2095
|
+
- Implementing loops in workflows
|
|
2096
|
+
- Conditional branching based on results
|
|
2097
|
+
- Dynamic workflow routing
|
|
2098
|
+
- Retry logic
|
|
2099
|
+
|
|
2100
|
+
**halt_workflow**
|
|
2101
|
+
```ruby
|
|
2102
|
+
ctx.halt_workflow(content:) → Hash
|
|
2103
|
+
```
|
|
2104
|
+
Stop entire workflow execution immediately and return content as final result.
|
|
2105
|
+
|
|
2106
|
+
**Parameters:**
|
|
2107
|
+
- `content` (String, required): Final content to return (validated non-nil)
|
|
2108
|
+
|
|
2109
|
+
**Returns:** Control hash (processed by NodeOrchestrator)
|
|
2110
|
+
|
|
2111
|
+
**Valid in:** Both input and output transformers
|
|
2112
|
+
|
|
2113
|
+
**Example:**
|
|
2114
|
+
```ruby
|
|
2115
|
+
output do |ctx|
|
|
2116
|
+
if converged?(ctx.content)
|
|
2117
|
+
# Stop workflow early
|
|
2118
|
+
ctx.halt_workflow(content: ctx.content)
|
|
2119
|
+
else
|
|
2120
|
+
ctx.content # Continue to next node
|
|
2121
|
+
end
|
|
2122
|
+
end
|
|
2123
|
+
```
|
|
2124
|
+
|
|
2125
|
+
**Use cases:**
|
|
2126
|
+
- Early termination on success
|
|
2127
|
+
- Error handling and bailout
|
|
2128
|
+
- Loop termination conditions
|
|
2129
|
+
- Convergence checks
|
|
2130
|
+
|
|
2131
|
+
**skip_execution**
|
|
2132
|
+
```ruby
|
|
2133
|
+
ctx.skip_execution(content:) → Hash
|
|
2134
|
+
```
|
|
2135
|
+
Skip LLM execution for current node and use provided content instead.
|
|
2136
|
+
|
|
2137
|
+
**Parameters:**
|
|
2138
|
+
- `content` (String, required): Content to use instead of LLM execution (validated non-nil)
|
|
2139
|
+
|
|
2140
|
+
**Returns:** Control hash (processed by NodeOrchestrator)
|
|
2141
|
+
|
|
2142
|
+
**Valid in:** Input transformers only
|
|
2143
|
+
|
|
2144
|
+
**Example:**
|
|
2145
|
+
```ruby
|
|
2146
|
+
input do |ctx|
|
|
2147
|
+
cached = check_cache(ctx.content)
|
|
2148
|
+
if cached
|
|
2149
|
+
# Skip expensive LLM call
|
|
2150
|
+
ctx.skip_execution(content: cached)
|
|
2151
|
+
else
|
|
2152
|
+
ctx.content # Execute node normally
|
|
2153
|
+
end
|
|
2154
|
+
end
|
|
2155
|
+
```
|
|
2156
|
+
|
|
2157
|
+
**Use cases:**
|
|
2158
|
+
- Caching node results
|
|
2159
|
+
- Conditional execution
|
|
2160
|
+
- Performance optimization
|
|
2161
|
+
- Validation checks
|
|
2162
|
+
|
|
2163
|
+
**Error Handling with Control Flow:**
|
|
2164
|
+
|
|
2165
|
+
All control flow methods validate that content is not nil. If a node fails, check for errors:
|
|
2166
|
+
|
|
2167
|
+
```ruby
|
|
2168
|
+
output do |ctx|
|
|
2169
|
+
if ctx.error
|
|
2170
|
+
# Don't try to continue with nil content
|
|
2171
|
+
ctx.halt_workflow(content: "Error: #{ctx.error.message}")
|
|
2172
|
+
else
|
|
2173
|
+
ctx.goto_node(:next_node, content: ctx.content)
|
|
2174
|
+
end
|
|
2175
|
+
end
|
|
2176
|
+
```
|
|
2177
|
+
|
|
2178
|
+
---
|
|
2179
|
+
|
|
2047
2180
|
## Complete Example
|
|
2048
2181
|
|
|
2049
2182
|
```ruby
|