claude_swarm 1.0.9 → 1.0.11
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 → CHANGELOG.claude-swarm.md} +10 -0
- data/CLAUDE.md +346 -191
- data/decisions/2025-11-22-001-global-agent-registry.md +172 -0
- data/docs/v2/CHANGELOG.swarm_cli.md +20 -0
- data/docs/v2/CHANGELOG.swarm_memory.md +146 -1
- data/docs/v2/CHANGELOG.swarm_sdk.md +433 -10
- data/docs/v2/README.md +20 -5
- data/docs/v2/guides/complete-tutorial.md +95 -9
- data/docs/v2/guides/getting-started.md +10 -8
- data/docs/v2/guides/memory-adapters.md +41 -0
- data/docs/v2/guides/migrating-to-2.x.md +746 -0
- data/docs/v2/guides/plugins.md +52 -5
- data/docs/v2/guides/rails-integration.md +6 -0
- data/docs/v2/guides/snapshots.md +14 -14
- data/docs/v2/guides/swarm-memory.md +2 -13
- data/docs/v2/reference/architecture-flow.md +3 -3
- data/docs/v2/reference/cli.md +0 -1
- data/docs/v2/reference/configuration_reference.md +300 -0
- data/docs/v2/reference/event_payload_structures.md +27 -5
- data/docs/v2/reference/ruby-dsl.md +614 -18
- data/docs/v2/reference/swarm_memory_technical_details.md +7 -29
- data/docs/v2/reference/yaml.md +172 -54
- data/examples/snapshot_demo.rb +2 -2
- data/lib/claude_swarm/mcp_generator.rb +8 -21
- data/lib/claude_swarm/orchestrator.rb +8 -1
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/swarm_cli/commands/run.rb +2 -2
- data/lib/swarm_cli/config_loader.rb +11 -11
- data/lib/swarm_cli/formatters/human_formatter.rb +0 -33
- data/lib/swarm_cli/interactive_repl.rb +2 -2
- data/lib/swarm_cli/ui/icons.rb +0 -23
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_memory/adapters/filesystem_adapter.rb +11 -34
- data/lib/swarm_memory/core/semantic_index.rb +10 -2
- data/lib/swarm_memory/core/storage.rb +7 -2
- data/lib/swarm_memory/dsl/memory_config.rb +37 -0
- data/lib/swarm_memory/integration/sdk_plugin.rb +201 -28
- data/lib/swarm_memory/optimization/defragmenter.rb +1 -1
- data/lib/swarm_memory/prompts/memory_researcher.md.erb +0 -1
- data/lib/swarm_memory/tools/load_skill.rb +0 -1
- data/lib/swarm_memory/tools/memory_edit.rb +2 -1
- data/lib/swarm_memory/tools/memory_read.rb +1 -1
- data/lib/swarm_memory/version.rb +1 -1
- data/lib/swarm_memory.rb +8 -6
- data/lib/swarm_sdk/agent/builder.rb +58 -0
- data/lib/swarm_sdk/agent/chat.rb +527 -1061
- data/lib/swarm_sdk/agent/{chat → chat_helpers}/context_tracker.rb +13 -88
- data/lib/swarm_sdk/agent/chat_helpers/event_emitter.rb +204 -0
- data/lib/swarm_sdk/agent/{chat → chat_helpers}/hook_integration.rb +108 -46
- data/lib/swarm_sdk/agent/chat_helpers/instrumentation.rb +78 -0
- data/lib/swarm_sdk/agent/chat_helpers/llm_configuration.rb +267 -0
- data/lib/swarm_sdk/agent/{chat → chat_helpers}/logging_helpers.rb +3 -3
- data/lib/swarm_sdk/agent/chat_helpers/serialization.rb +83 -0
- data/lib/swarm_sdk/agent/{chat → chat_helpers}/system_reminder_injector.rb +11 -13
- data/lib/swarm_sdk/agent/chat_helpers/system_reminders.rb +79 -0
- data/lib/swarm_sdk/agent/chat_helpers/token_tracking.rb +146 -0
- data/lib/swarm_sdk/agent/context.rb +1 -2
- data/lib/swarm_sdk/agent/definition.rb +66 -154
- data/lib/swarm_sdk/agent/llm_instrumentation_middleware.rb +4 -2
- data/lib/swarm_sdk/agent/system_prompt_builder.rb +161 -0
- data/lib/swarm_sdk/agent_registry.rb +146 -0
- data/lib/swarm_sdk/builders/base_builder.rb +488 -0
- data/lib/swarm_sdk/concerns/cleanupable.rb +39 -0
- data/lib/swarm_sdk/concerns/snapshotable.rb +67 -0
- data/lib/swarm_sdk/concerns/validatable.rb +55 -0
- data/lib/swarm_sdk/config.rb +302 -0
- data/lib/swarm_sdk/configuration/parser.rb +373 -0
- data/lib/swarm_sdk/configuration/translator.rb +255 -0
- data/lib/swarm_sdk/configuration.rb +77 -546
- data/lib/swarm_sdk/context_compactor/token_counter.rb +2 -6
- data/lib/swarm_sdk/context_compactor.rb +6 -11
- data/lib/swarm_sdk/context_management/builder.rb +128 -0
- data/lib/swarm_sdk/context_management/context.rb +328 -0
- data/lib/swarm_sdk/custom_tool_registry.rb +226 -0
- data/lib/swarm_sdk/defaults.rb +196 -0
- data/lib/swarm_sdk/events_to_messages.rb +18 -0
- data/lib/swarm_sdk/hooks/adapter.rb +3 -3
- data/lib/swarm_sdk/hooks/shell_executor.rb +4 -2
- data/lib/swarm_sdk/log_collector.rb +179 -29
- data/lib/swarm_sdk/log_stream.rb +29 -0
- data/lib/swarm_sdk/models.json +4333 -1
- data/lib/swarm_sdk/models.rb +43 -2
- data/lib/swarm_sdk/node_context.rb +1 -1
- data/lib/swarm_sdk/observer/builder.rb +81 -0
- data/lib/swarm_sdk/observer/config.rb +45 -0
- data/lib/swarm_sdk/observer/manager.rb +236 -0
- data/lib/swarm_sdk/patterns/agent_observer.rb +160 -0
- data/lib/swarm_sdk/plugin.rb +95 -5
- data/lib/swarm_sdk/result.rb +52 -0
- data/lib/swarm_sdk/snapshot.rb +6 -6
- data/lib/swarm_sdk/snapshot_from_events.rb +13 -2
- data/lib/swarm_sdk/state_restorer.rb +136 -151
- data/lib/swarm_sdk/state_snapshot.rb +65 -100
- data/lib/swarm_sdk/swarm/agent_initializer.rb +181 -137
- data/lib/swarm_sdk/swarm/builder.rb +44 -578
- data/lib/swarm_sdk/swarm/executor.rb +213 -0
- data/lib/swarm_sdk/swarm/hook_triggers.rb +151 -0
- data/lib/swarm_sdk/swarm/logging_callbacks.rb +341 -0
- data/lib/swarm_sdk/swarm/mcp_configurator.rb +7 -4
- data/lib/swarm_sdk/swarm/tool_configurator.rb +58 -140
- data/lib/swarm_sdk/swarm.rb +203 -683
- data/lib/swarm_sdk/tools/bash.rb +14 -8
- data/lib/swarm_sdk/tools/delegate.rb +61 -43
- data/lib/swarm_sdk/tools/edit.rb +8 -13
- data/lib/swarm_sdk/tools/glob.rb +12 -4
- data/lib/swarm_sdk/tools/grep.rb +7 -0
- data/lib/swarm_sdk/tools/multi_edit.rb +15 -11
- data/lib/swarm_sdk/tools/path_resolver.rb +51 -2
- data/lib/swarm_sdk/tools/read.rb +16 -18
- data/lib/swarm_sdk/tools/registry.rb +122 -10
- data/lib/swarm_sdk/tools/stores/scratchpad_storage.rb +9 -5
- data/lib/swarm_sdk/tools/stores/storage.rb +0 -6
- data/lib/swarm_sdk/tools/todo_write.rb +7 -0
- data/lib/swarm_sdk/tools/web_fetch.rb +20 -17
- data/lib/swarm_sdk/tools/write.rb +8 -13
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk/{node → workflow}/agent_config.rb +1 -1
- data/lib/swarm_sdk/workflow/builder.rb +192 -0
- data/lib/swarm_sdk/workflow/executor.rb +497 -0
- data/lib/swarm_sdk/{node/builder.rb → workflow/node_builder.rb} +7 -5
- data/lib/swarm_sdk/{node → workflow}/transformer_executor.rb +5 -3
- data/lib/swarm_sdk/{node_orchestrator.rb → workflow.rb} +152 -456
- data/lib/swarm_sdk.rb +294 -108
- data/rubocop/cop/security/no_reflection_methods.rb +1 -1
- data/swarm_cli.gemspec +1 -1
- data/swarm_memory.gemspec +8 -3
- data/swarm_sdk.gemspec +6 -4
- data/team_full.yml +124 -320
- metadata +42 -14
- data/lib/swarm_memory/chat_extension.rb +0 -34
- data/lib/swarm_memory/tools/memory_multi_edit.rb +0 -281
- data/lib/swarm_sdk/providers/openai_with_responses.rb +0 -589
- /data/lib/swarm_memory/{errors.rb → error.rb} +0 -0
|
@@ -855,28 +855,7 @@ end
|
|
|
855
855
|
|
|
856
856
|
---
|
|
857
857
|
|
|
858
|
-
### 4.
|
|
859
|
-
|
|
860
|
-
**File:** `lib/swarm_memory/tools/memory_multi_edit.rb`
|
|
861
|
-
|
|
862
|
-
Apply multiple edits sequentially to one entry.
|
|
863
|
-
|
|
864
|
-
**Input (JSON array):**
|
|
865
|
-
```json
|
|
866
|
-
[
|
|
867
|
-
{"old_string": "status: pending", "new_string": "status: resolved"},
|
|
868
|
-
{"old_string": "confidence: medium", "new_string": "confidence: high"}
|
|
869
|
-
]
|
|
870
|
-
```
|
|
871
|
-
|
|
872
|
-
**Behavior:**
|
|
873
|
-
- Edits applied **sequentially** (each sees previous results)
|
|
874
|
-
- **All-or-nothing** - if any edit fails, NO changes saved
|
|
875
|
-
- Shows which edits succeeded before failure
|
|
876
|
-
|
|
877
|
-
---
|
|
878
|
-
|
|
879
|
-
### 5. MemoryGlob
|
|
858
|
+
### 4. MemoryGlob
|
|
880
859
|
|
|
881
860
|
**File:** `lib/swarm_memory/tools/memory_glob.rb`
|
|
882
861
|
|
|
@@ -915,7 +894,7 @@ MAX_RESULTS = 500 # Truncates with system reminder if exceeded
|
|
|
915
894
|
|
|
916
895
|
---
|
|
917
896
|
|
|
918
|
-
###
|
|
897
|
+
### 5. MemoryGrep
|
|
919
898
|
|
|
920
899
|
**File:** `lib/swarm_memory/tools/memory_grep.rb`
|
|
921
900
|
|
|
@@ -949,7 +928,7 @@ path: "skill/debug.md" # Just that file
|
|
|
949
928
|
|
|
950
929
|
---
|
|
951
930
|
|
|
952
|
-
###
|
|
931
|
+
### 6. MemoryDelete
|
|
953
932
|
|
|
954
933
|
**File:** `lib/swarm_memory/tools/memory_delete.rb`
|
|
955
934
|
|
|
@@ -964,7 +943,7 @@ MemoryDelete(file_path: "experience/temp-experiment.md")
|
|
|
964
943
|
|
|
965
944
|
---
|
|
966
945
|
|
|
967
|
-
###
|
|
946
|
+
### 7. MemoryDefrag
|
|
968
947
|
|
|
969
948
|
**File:** `lib/swarm_memory/tools/memory_defrag.rb`
|
|
970
949
|
|
|
@@ -1035,7 +1014,7 @@ MemoryDefrag(action: "full", dry_run: true) # Preview all
|
|
|
1035
1014
|
|
|
1036
1015
|
---
|
|
1037
1016
|
|
|
1038
|
-
###
|
|
1017
|
+
### 8. LoadSkill
|
|
1039
1018
|
|
|
1040
1019
|
**File:** `lib/swarm_memory/tools/load_skill.rb`
|
|
1041
1020
|
|
|
@@ -1079,7 +1058,7 @@ sequenceDiagram
|
|
|
1079
1058
|
**Immutable Tools:**
|
|
1080
1059
|
```ruby
|
|
1081
1060
|
# These tools NEVER removed during skill loading:
|
|
1082
|
-
- MemoryWrite, MemoryRead, MemoryEdit
|
|
1061
|
+
- MemoryWrite, MemoryRead, MemoryEdit
|
|
1083
1062
|
- MemoryDelete, MemoryGlob, MemoryGrep, MemoryDefrag
|
|
1084
1063
|
- LoadSkill (self)
|
|
1085
1064
|
```
|
|
@@ -1243,7 +1222,7 @@ class SDKPlugin < SwarmSDK::Plugin
|
|
|
1243
1222
|
# Return memory prompt based on mode
|
|
1244
1223
|
end
|
|
1245
1224
|
|
|
1246
|
-
def
|
|
1225
|
+
def memory_configured?(agent_definition)
|
|
1247
1226
|
agent_definition.memory_enabled?
|
|
1248
1227
|
end
|
|
1249
1228
|
end
|
|
@@ -2025,7 +2004,6 @@ lib/swarm_memory/
|
|
|
2025
2004
|
│ ├── memory_write.rb
|
|
2026
2005
|
│ ├── memory_read.rb
|
|
2027
2006
|
│ ├── memory_edit.rb
|
|
2028
|
-
│ ├── memory_multi_edit.rb
|
|
2029
2007
|
│ ├── memory_delete.rb
|
|
2030
2008
|
│ ├── memory_glob.rb
|
|
2031
2009
|
│ ├── memory_grep.rb
|
data/docs/v2/reference/yaml.md
CHANGED
|
@@ -6,25 +6,55 @@ Complete YAML configuration reference for SwarmSDK v2.
|
|
|
6
6
|
|
|
7
7
|
## Document Structure
|
|
8
8
|
|
|
9
|
-
SwarmSDK v2 configurations
|
|
9
|
+
SwarmSDK v2 configurations support two types, distinguished by the root key:
|
|
10
|
+
|
|
11
|
+
### Simple Swarm (Multi-Agent Collaboration)
|
|
10
12
|
|
|
11
13
|
```yaml
|
|
12
14
|
version: 2
|
|
13
|
-
swarm:
|
|
14
|
-
name: "
|
|
15
|
-
lead:
|
|
15
|
+
swarm: # Use 'swarm:' key for swarms
|
|
16
|
+
name: "Development Team"
|
|
17
|
+
lead: backend # Required for swarms
|
|
16
18
|
agents:
|
|
17
|
-
|
|
19
|
+
backend:
|
|
18
20
|
# Agent configuration
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
tester:
|
|
22
|
+
# Agent configuration
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Returns:** `SwarmSDK::Swarm` when loaded with `SwarmSDK.load_file`
|
|
26
|
+
|
|
27
|
+
### Workflow (Multi-Stage Pipeline)
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
version: 2
|
|
31
|
+
workflow: # Use 'workflow:' key for workflows
|
|
32
|
+
name: "Build Pipeline"
|
|
33
|
+
start_node: planning # Required for workflows
|
|
34
|
+
agents:
|
|
35
|
+
architect:
|
|
36
|
+
# Agent configuration
|
|
37
|
+
coder:
|
|
38
|
+
# Agent configuration
|
|
39
|
+
nodes: # Required for workflows
|
|
40
|
+
planning:
|
|
41
|
+
agents:
|
|
42
|
+
- agent: architect
|
|
43
|
+
implementation:
|
|
44
|
+
agents:
|
|
45
|
+
- agent: coder
|
|
46
|
+
dependencies:
|
|
47
|
+
- planning
|
|
26
48
|
```
|
|
27
49
|
|
|
50
|
+
**Returns:** `SwarmSDK::Workflow` when loaded with `SwarmSDK.load_file`
|
|
51
|
+
|
|
52
|
+
**Type Detection:**
|
|
53
|
+
- `swarm:` key → Creates `SwarmSDK::Swarm` (requires `lead:`, cannot have `nodes:`)
|
|
54
|
+
- `workflow:` key → Creates `SwarmSDK::Workflow` (requires `start_node:` and `nodes:`)
|
|
55
|
+
- Cannot have both `swarm:` and `workflow:` keys in same file
|
|
56
|
+
- Same `SwarmSDK.load_file` API works for both types!
|
|
57
|
+
|
|
28
58
|
---
|
|
29
59
|
|
|
30
60
|
## Top-Level Fields
|
|
@@ -43,8 +73,10 @@ version: 2
|
|
|
43
73
|
|
|
44
74
|
### swarm
|
|
45
75
|
|
|
46
|
-
**Type:** Object (required)
|
|
47
|
-
**Description:** Root configuration object
|
|
76
|
+
**Type:** Object (required for Swarm type)
|
|
77
|
+
**Description:** Root configuration object for multi-agent collaboration swarms. Use this key when you want agents to collaborate through delegation.
|
|
78
|
+
|
|
79
|
+
**Mutually exclusive with:** `workflow:`
|
|
48
80
|
|
|
49
81
|
```yaml
|
|
50
82
|
swarm:
|
|
@@ -56,9 +88,28 @@ swarm:
|
|
|
56
88
|
|
|
57
89
|
---
|
|
58
90
|
|
|
91
|
+
### workflow
|
|
92
|
+
|
|
93
|
+
**Type:** Object (required for Workflow type)
|
|
94
|
+
**Description:** Root configuration object for multi-stage pipeline workflows. Use this key when you want to orchestrate agents through sequential or parallel nodes.
|
|
95
|
+
|
|
96
|
+
**Mutually exclusive with:** `swarm:`
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
workflow:
|
|
100
|
+
name: "Build Pipeline"
|
|
101
|
+
start_node: planning
|
|
102
|
+
agents:
|
|
103
|
+
# ...
|
|
104
|
+
nodes:
|
|
105
|
+
# ...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
59
110
|
## Swarm Configuration
|
|
60
111
|
|
|
61
|
-
Fields under the `swarm` key.
|
|
112
|
+
Fields under the `swarm` key (for Swarm type configurations).
|
|
62
113
|
|
|
63
114
|
### id
|
|
64
115
|
|
|
@@ -224,25 +275,21 @@ swarm:
|
|
|
224
275
|
scratchpad: enabled # enable scratchpad
|
|
225
276
|
scratchpad: disabled # no scratchpad (default)
|
|
226
277
|
|
|
227
|
-
#
|
|
228
|
-
|
|
278
|
+
# Workflow - shared across all nodes
|
|
279
|
+
workflow:
|
|
229
280
|
scratchpad: enabled
|
|
230
|
-
|
|
281
|
+
start_node: planning
|
|
231
282
|
nodes:
|
|
232
283
|
planning: { ... }
|
|
233
284
|
implementation: { ... }
|
|
234
285
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
# With nodes - isolated per node
|
|
238
|
-
swarm:
|
|
286
|
+
# Workflow - isolated per node
|
|
287
|
+
workflow:
|
|
239
288
|
scratchpad: per_node
|
|
240
|
-
|
|
289
|
+
start_node: planning
|
|
241
290
|
nodes:
|
|
242
291
|
planning: { ... }
|
|
243
292
|
implementation: { ... }
|
|
244
|
-
|
|
245
|
-
start_node: planning
|
|
246
293
|
```
|
|
247
294
|
|
|
248
295
|
---
|
|
@@ -313,33 +360,44 @@ swarm:
|
|
|
313
360
|
|
|
314
361
|
### nodes
|
|
315
362
|
|
|
316
|
-
**Type:** Object (
|
|
363
|
+
**Type:** Object (required for Workflow type)
|
|
317
364
|
**Description:** Map of node names to node configurations. Enables multi-stage workflows with multiple execution stages.
|
|
318
365
|
**Format:** `{ node_name: node_config }`
|
|
319
366
|
|
|
367
|
+
**Important:** This field is only valid under the `workflow:` key, not `swarm:`.
|
|
368
|
+
|
|
320
369
|
Nodes allow you to create workflows where different agent teams collaborate in sequence. Each node is an independent swarm execution that can receive input from previous nodes and pass output to subsequent nodes.
|
|
321
370
|
|
|
322
371
|
**Example:**
|
|
323
372
|
```yaml
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
373
|
+
workflow:
|
|
374
|
+
name: "Build Pipeline"
|
|
375
|
+
start_node: planning
|
|
376
|
+
agents:
|
|
377
|
+
architect: { ... }
|
|
378
|
+
backend: { ... }
|
|
379
|
+
tester: { ... }
|
|
380
|
+
reviewer: { ... }
|
|
329
381
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
- agent: tester
|
|
336
|
-
dependencies: [planning]
|
|
337
|
-
input_command: "cat plan.txt"
|
|
382
|
+
nodes:
|
|
383
|
+
planning:
|
|
384
|
+
agents:
|
|
385
|
+
- agent: architect
|
|
386
|
+
output_command: "tee plan.txt"
|
|
338
387
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
388
|
+
implementation:
|
|
389
|
+
agents:
|
|
390
|
+
- agent: backend
|
|
391
|
+
delegates_to: [tester]
|
|
392
|
+
tools: [Read, Edit, Write] # Override tools for this node
|
|
393
|
+
- agent: tester
|
|
394
|
+
dependencies: [planning]
|
|
395
|
+
input_command: "cat plan.txt"
|
|
396
|
+
|
|
397
|
+
review:
|
|
398
|
+
agents:
|
|
399
|
+
- agent: reviewer
|
|
400
|
+
dependencies: [implementation]
|
|
343
401
|
```
|
|
344
402
|
|
|
345
403
|
**Node configuration fields:**
|
|
@@ -376,14 +434,16 @@ nodes:
|
|
|
376
434
|
|
|
377
435
|
### start_node
|
|
378
436
|
|
|
379
|
-
**Type:** String (required
|
|
437
|
+
**Type:** String (required for Workflow type)
|
|
380
438
|
**Description:** Name of the starting node for workflow execution.
|
|
381
439
|
|
|
440
|
+
**Important:** This field is only valid under the `workflow:` key, not `swarm:`.
|
|
441
|
+
|
|
382
442
|
**Example:**
|
|
383
443
|
```yaml
|
|
384
|
-
|
|
444
|
+
workflow:
|
|
385
445
|
name: "Dev Workflow"
|
|
386
|
-
|
|
446
|
+
start_node: planning # Required: Start with planning node
|
|
387
447
|
agents:
|
|
388
448
|
coordinator:
|
|
389
449
|
description: "Coordinator"
|
|
@@ -399,7 +459,6 @@ swarm:
|
|
|
399
459
|
agents:
|
|
400
460
|
- agent: backend
|
|
401
461
|
dependencies: [planning]
|
|
402
|
-
start_node: planning # Start with planning node
|
|
403
462
|
```
|
|
404
463
|
|
|
405
464
|
---
|
|
@@ -590,7 +649,7 @@ agents:
|
|
|
590
649
|
- `ScratchpadWrite`, `ScratchpadRead`, `ScratchpadList`
|
|
591
650
|
|
|
592
651
|
**Memory tools** (added if agent has `memory` configured):
|
|
593
|
-
- `MemoryWrite`, `MemoryRead`, `MemoryEdit`, `
|
|
652
|
+
- `MemoryWrite`, `MemoryRead`, `MemoryEdit`, `MemoryGlob`, `MemoryGrep`, `MemoryDelete`
|
|
594
653
|
|
|
595
654
|
**Additional tools:**
|
|
596
655
|
- `Write`, `Edit`, `MultiEdit`, `Bash`
|
|
@@ -702,7 +761,7 @@ Plugin storage (like SwarmMemory) is always shared by base agent name:
|
|
|
702
761
|
**Default:** `null` (memory disabled)
|
|
703
762
|
**Description:** Configure persistent memory storage for this agent.
|
|
704
763
|
|
|
705
|
-
When configured, the agent automatically gets all
|
|
764
|
+
When configured, the agent automatically gets all 6 memory tools (MemoryWrite, MemoryRead, MemoryEdit, MemoryGlob, MemoryGrep, MemoryDelete) and a memory system prompt is appended.
|
|
706
765
|
|
|
707
766
|
Memory is per-agent (isolated) and persistent (survives across sessions).
|
|
708
767
|
|
|
@@ -1583,7 +1642,7 @@ agents:
|
|
|
1583
1642
|
|
|
1584
1643
|
## Node Configuration
|
|
1585
1644
|
|
|
1586
|
-
Fields under each node in `
|
|
1645
|
+
Fields under each node in `workflow.nodes`.
|
|
1587
1646
|
|
|
1588
1647
|
### agents
|
|
1589
1648
|
|
|
@@ -1904,7 +1963,11 @@ permissions:
|
|
|
1904
1963
|
|
|
1905
1964
|
---
|
|
1906
1965
|
|
|
1907
|
-
## Complete
|
|
1966
|
+
## Complete Examples
|
|
1967
|
+
|
|
1968
|
+
### Complete Swarm Example
|
|
1969
|
+
|
|
1970
|
+
A multi-agent collaboration swarm where agents delegate tasks to each other:
|
|
1908
1971
|
|
|
1909
1972
|
```yaml
|
|
1910
1973
|
version: 2
|
|
@@ -2043,8 +2106,65 @@ swarm:
|
|
|
2043
2106
|
|
|
2044
2107
|
parameters:
|
|
2045
2108
|
temperature: 0.2
|
|
2109
|
+
```
|
|
2110
|
+
|
|
2111
|
+
---
|
|
2112
|
+
|
|
2113
|
+
### Complete Workflow Example
|
|
2114
|
+
|
|
2115
|
+
A multi-stage pipeline workflow with sequential and parallel node execution:
|
|
2116
|
+
|
|
2117
|
+
```yaml
|
|
2118
|
+
version: 2
|
|
2119
|
+
|
|
2120
|
+
workflow:
|
|
2121
|
+
name: "Development Pipeline"
|
|
2122
|
+
start_node: planning
|
|
2123
|
+
|
|
2124
|
+
# Global configuration for all agents
|
|
2125
|
+
all_agents:
|
|
2126
|
+
provider: openai
|
|
2127
|
+
timeout: 180
|
|
2128
|
+
coding_agent: true
|
|
2129
|
+
|
|
2130
|
+
# Agent definitions (shared across nodes)
|
|
2131
|
+
agents:
|
|
2132
|
+
coordinator:
|
|
2133
|
+
description: "Lead coordinator for planning"
|
|
2134
|
+
model: gpt-5
|
|
2135
|
+
system_prompt: "You create detailed project plans"
|
|
2136
|
+
tools: [Read, TodoWrite]
|
|
2137
|
+
|
|
2138
|
+
backend:
|
|
2139
|
+
description: "Backend developer specializing in Ruby on Rails"
|
|
2140
|
+
model: claude-sonnet-4
|
|
2141
|
+
provider: anthropic
|
|
2142
|
+
directory: "backend"
|
|
2143
|
+
system_prompt: "You build clean, testable backend APIs"
|
|
2144
|
+
tools: [Read, Write, Edit, Bash]
|
|
2145
|
+
delegates_to: [database]
|
|
2046
2146
|
|
|
2047
|
-
|
|
2147
|
+
frontend:
|
|
2148
|
+
description: "Frontend developer specializing in React"
|
|
2149
|
+
model: gpt-5
|
|
2150
|
+
directory: "frontend"
|
|
2151
|
+
system_prompt: "You build modern, accessible frontends"
|
|
2152
|
+
tools: [Read, Write, Edit, Bash]
|
|
2153
|
+
|
|
2154
|
+
database:
|
|
2155
|
+
description: "Database expert for schema design"
|
|
2156
|
+
model: gpt-5
|
|
2157
|
+
directory: "backend"
|
|
2158
|
+
system_prompt: "You design efficient database schemas"
|
|
2159
|
+
tools: [Read, Write, Bash]
|
|
2160
|
+
|
|
2161
|
+
reviewer:
|
|
2162
|
+
description: "Code reviewer checking for bugs"
|
|
2163
|
+
model: o4
|
|
2164
|
+
system_prompt: "You review code for quality and security"
|
|
2165
|
+
tools: [Read, Grep, Glob]
|
|
2166
|
+
|
|
2167
|
+
# Multi-stage workflow nodes
|
|
2048
2168
|
nodes:
|
|
2049
2169
|
planning:
|
|
2050
2170
|
agents:
|
|
@@ -2072,8 +2192,6 @@ swarm:
|
|
|
2072
2192
|
dependencies: [backend_implementation, frontend_implementation]
|
|
2073
2193
|
input_command: "scripts/gather-changes.sh"
|
|
2074
2194
|
output_command: "scripts/format-review.sh"
|
|
2075
|
-
|
|
2076
|
-
start_node: planning
|
|
2077
2195
|
```
|
|
2078
2196
|
|
|
2079
2197
|
---
|
data/examples/snapshot_demo.rb
CHANGED
|
@@ -27,7 +27,7 @@ swarm = SwarmSDK.build do
|
|
|
27
27
|
agent(:assistant) do
|
|
28
28
|
provider("openai")
|
|
29
29
|
model("claude-haiku-4-5")
|
|
30
|
-
base_url("https://
|
|
30
|
+
base_url("https://api.example.com/v1")
|
|
31
31
|
description("Helpful assistant")
|
|
32
32
|
system_prompt("You are a helpful assistant")
|
|
33
33
|
tools(:Think)
|
|
@@ -77,7 +77,7 @@ swarm2 = SwarmSDK.build do
|
|
|
77
77
|
agent(:assistant) do
|
|
78
78
|
provider("openai")
|
|
79
79
|
model("claude-haiku-4-5")
|
|
80
|
-
base_url("https://
|
|
80
|
+
base_url("https://api.example.com/v1")
|
|
81
81
|
description("Helpful assistant")
|
|
82
82
|
system_prompt("You are a helpful assistant")
|
|
83
83
|
tools(:Think)
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module ClaudeSwarm
|
|
4
4
|
class McpGenerator
|
|
5
|
+
CLAUDE_MCP_SERVER_CONFIG = {
|
|
6
|
+
"type" => "stdio",
|
|
7
|
+
"command" => "claude",
|
|
8
|
+
"args" => ["mcp", "serve"],
|
|
9
|
+
}.freeze
|
|
10
|
+
|
|
5
11
|
def initialize(configuration, vibe: false, restore_session_path: nil)
|
|
6
12
|
@config = configuration
|
|
7
13
|
@vibe = vibe
|
|
@@ -65,7 +71,7 @@ module ClaudeSwarm
|
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
# Add Claude tools MCP server for OpenAI instances
|
|
68
|
-
mcp_servers["claude_tools"] =
|
|
74
|
+
mcp_servers["claude_tools"] = CLAUDE_MCP_SERVER_CONFIG.dup if instance[:provider] == "openai"
|
|
69
75
|
|
|
70
76
|
config = {
|
|
71
77
|
"instance_id" => @instance_ids[name],
|
|
@@ -96,25 +102,6 @@ module ClaudeSwarm
|
|
|
96
102
|
end
|
|
97
103
|
end
|
|
98
104
|
|
|
99
|
-
def build_claude_tools_mcp_config
|
|
100
|
-
# Build environment for claude mcp serve by excluding Ruby/Bundler-specific variables
|
|
101
|
-
# This preserves all system variables while removing Ruby contamination
|
|
102
|
-
clean_env = ENV.to_h.reject do |key, _|
|
|
103
|
-
key.start_with?("BUNDLE_") ||
|
|
104
|
-
key.start_with?("RUBY") ||
|
|
105
|
-
key.start_with?("GEM_") ||
|
|
106
|
-
key == "RUBYOPT" ||
|
|
107
|
-
key == "RUBYLIB"
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
"type" => "stdio",
|
|
112
|
-
"command" => "claude",
|
|
113
|
-
"args" => ["mcp", "serve"],
|
|
114
|
-
"env" => clean_env,
|
|
115
|
-
}
|
|
116
|
-
end
|
|
117
|
-
|
|
118
105
|
def build_instance_mcp_config(name, instance, calling_instance:, calling_instance_id:)
|
|
119
106
|
# Get the path to the claude-swarm executable
|
|
120
107
|
exe_path = "claude-swarm"
|
|
@@ -136,7 +123,7 @@ module ClaudeSwarm
|
|
|
136
123
|
# Add optional arguments
|
|
137
124
|
# Handle prompt_file by reading the file contents
|
|
138
125
|
if instance[:prompt_file]
|
|
139
|
-
prompt_file_path = File.join(@config.
|
|
126
|
+
prompt_file_path = File.join(@config.base_dir, instance[:prompt_file])
|
|
140
127
|
if File.exist?(prompt_file_path)
|
|
141
128
|
prompt_content = File.read(prompt_file_path)
|
|
142
129
|
args.push("--prompt", prompt_content)
|
|
@@ -568,7 +568,14 @@ module ClaudeSwarm
|
|
|
568
568
|
end
|
|
569
569
|
|
|
570
570
|
# Always add instance prompt if it exists
|
|
571
|
-
if instance[:
|
|
571
|
+
if instance[:prompt_file]
|
|
572
|
+
prompt_file_path = File.join(@config.base_dir, instance[:prompt_file])
|
|
573
|
+
if File.exist?(prompt_file_path)
|
|
574
|
+
prompt_content = File.read(prompt_file_path)
|
|
575
|
+
parts << "--append-system-prompt"
|
|
576
|
+
parts << prompt_content
|
|
577
|
+
end
|
|
578
|
+
elsif instance[:prompt]
|
|
572
579
|
parts << "--append-system-prompt"
|
|
573
580
|
parts << instance[:prompt]
|
|
574
581
|
end
|
data/lib/claude_swarm/version.rb
CHANGED
|
@@ -134,8 +134,8 @@ module SwarmCLI
|
|
|
134
134
|
|
|
135
135
|
def emit_validation_warnings(swarm, formatter)
|
|
136
136
|
# Setup temporary logging to capture and emit warnings
|
|
137
|
-
SwarmSDK::LogCollector.
|
|
138
|
-
formatter.on_log(log_entry)
|
|
137
|
+
SwarmSDK::LogCollector.subscribe(filter: { type: "model_lookup_warning" }) do |log_entry|
|
|
138
|
+
formatter.on_log(log_entry)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
SwarmSDK::LogStream.emitter = SwarmSDK::LogCollector
|
|
@@ -5,7 +5,7 @@ module SwarmCLI
|
|
|
5
5
|
#
|
|
6
6
|
# Supports:
|
|
7
7
|
# - YAML files (.yml, .yaml) - loaded via SwarmSDK.load_file
|
|
8
|
-
# - Ruby DSL files (.rb) - executed and expected to return a SwarmSDK::Swarm or SwarmSDK::
|
|
8
|
+
# - Ruby DSL files (.rb) - executed and expected to return a SwarmSDK::Swarm or SwarmSDK::Workflow instance
|
|
9
9
|
#
|
|
10
10
|
# @example Load YAML config
|
|
11
11
|
# swarm = ConfigLoader.load("config.yml")
|
|
@@ -19,10 +19,10 @@ module SwarmCLI
|
|
|
19
19
|
#
|
|
20
20
|
# Detects file type by extension:
|
|
21
21
|
# - .yml, .yaml -> Load as YAML using SwarmSDK.load_file
|
|
22
|
-
# - .rb -> Execute as Ruby DSL and expect SwarmSDK::Swarm or SwarmSDK::
|
|
22
|
+
# - .rb -> Execute as Ruby DSL and expect SwarmSDK::Swarm or SwarmSDK::Workflow instance
|
|
23
23
|
#
|
|
24
24
|
# @param path [String, Pathname] Path to configuration file
|
|
25
|
-
# @return [SwarmSDK::Swarm, SwarmSDK::
|
|
25
|
+
# @return [SwarmSDK::Swarm, SwarmSDK::Workflow] Configured swarm or workflow instance
|
|
26
26
|
# @raise [SwarmCLI::ConfigurationError] If file not found or invalid format
|
|
27
27
|
def load(path)
|
|
28
28
|
path = Pathname.new(path).expand_path
|
|
@@ -59,27 +59,27 @@ module SwarmCLI
|
|
|
59
59
|
# Load Ruby DSL configuration file
|
|
60
60
|
#
|
|
61
61
|
# Executes the Ruby file in a clean binding and expects it to return
|
|
62
|
-
# a SwarmSDK::Swarm or SwarmSDK::
|
|
63
|
-
# use SwarmSDK.build or create a Swarm/
|
|
62
|
+
# a SwarmSDK::Swarm or SwarmSDK::Workflow instance. The file should
|
|
63
|
+
# use SwarmSDK.build or SwarmSDK.workflow or create a Swarm/Workflow instance directly.
|
|
64
64
|
#
|
|
65
65
|
# @param path [Pathname] Path to Ruby DSL file
|
|
66
|
-
# @return [SwarmSDK::Swarm, SwarmSDK::
|
|
66
|
+
# @return [SwarmSDK::Swarm, SwarmSDK::Workflow] Configured swarm or workflow instance
|
|
67
67
|
# @raise [ConfigurationError] If file doesn't return a valid instance
|
|
68
68
|
def load_ruby_dsl(path)
|
|
69
69
|
# Read the file content
|
|
70
70
|
content = path.read
|
|
71
71
|
|
|
72
72
|
# Execute in a clean binding with SwarmSDK available
|
|
73
|
-
# This allows the DSL file to use SwarmSDK.build directly
|
|
73
|
+
# This allows the DSL file to use SwarmSDK.build or SwarmSDK.workflow directly
|
|
74
74
|
result = eval(content, binding, path.to_s, 1) # rubocop:disable Security/Eval
|
|
75
75
|
|
|
76
|
-
# Validate result is a Swarm or
|
|
76
|
+
# Validate result is a Swarm or Workflow instance
|
|
77
77
|
# Both have the same execute(prompt) interface
|
|
78
|
-
unless result.is_a?(SwarmSDK::Swarm) || result.is_a?(SwarmSDK::
|
|
78
|
+
unless result.is_a?(SwarmSDK::Swarm) || result.is_a?(SwarmSDK::Workflow)
|
|
79
79
|
raise ConfigurationError,
|
|
80
|
-
"Ruby DSL file must return a SwarmSDK::Swarm or SwarmSDK::
|
|
80
|
+
"Ruby DSL file must return a SwarmSDK::Swarm or SwarmSDK::Workflow instance. " \
|
|
81
81
|
"Got: #{result.class}. " \
|
|
82
|
-
"Use: SwarmSDK.build { ... } or
|
|
82
|
+
"Use: SwarmSDK.build { ... } or SwarmSDK.workflow { ... }"
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
result
|
|
@@ -99,8 +99,6 @@ module SwarmCLI
|
|
|
99
99
|
handle_llm_retry_attempt(entry)
|
|
100
100
|
when "llm_retry_exhausted"
|
|
101
101
|
handle_llm_retry_exhausted(entry)
|
|
102
|
-
when "response_parse_error"
|
|
103
|
-
handle_response_parse_error(entry)
|
|
104
102
|
end
|
|
105
103
|
end
|
|
106
104
|
|
|
@@ -647,37 +645,6 @@ module SwarmCLI
|
|
|
647
645
|
)
|
|
648
646
|
end
|
|
649
647
|
|
|
650
|
-
def handle_response_parse_error(entry)
|
|
651
|
-
agent = entry[:agent]
|
|
652
|
-
error_class = entry[:error_class]
|
|
653
|
-
error_message = entry[:error_message]
|
|
654
|
-
|
|
655
|
-
# Stop agent thinking spinner (if active)
|
|
656
|
-
unless @quiet
|
|
657
|
-
spinner_key = "agent_#{agent}".to_sym
|
|
658
|
-
@spinner_manager.stop(spinner_key) if @spinner_manager.active?(spinner_key)
|
|
659
|
-
end
|
|
660
|
-
|
|
661
|
-
lines = [
|
|
662
|
-
@pastel.red("Failed to parse LLM API response"),
|
|
663
|
-
@pastel.dim("Error: #{error_class}: #{error_message}"),
|
|
664
|
-
]
|
|
665
|
-
|
|
666
|
-
# Add response body preview if available (truncated)
|
|
667
|
-
if entry[:response_body]
|
|
668
|
-
body_preview = entry[:response_body].to_s[0..200]
|
|
669
|
-
body_preview += "..." if entry[:response_body].to_s.length > 200
|
|
670
|
-
lines << @pastel.dim("Response: #{body_preview}")
|
|
671
|
-
end
|
|
672
|
-
|
|
673
|
-
@output.puts @panel.render(
|
|
674
|
-
type: :error,
|
|
675
|
-
title: "PARSE ERROR #{@agent_badge.render(agent)}",
|
|
676
|
-
lines: lines,
|
|
677
|
-
indent: @depth_tracker.get(agent),
|
|
678
|
-
)
|
|
679
|
-
end
|
|
680
|
-
|
|
681
648
|
def display_todo_list(agent, timestamp)
|
|
682
649
|
todos = SwarmSDK::Tools::Stores::TodoManager.get_todos(agent.to_sym)
|
|
683
650
|
indent = @depth_tracker.indent(agent)
|
|
@@ -534,7 +534,7 @@ module SwarmCLI
|
|
|
534
534
|
lead = @swarm.agent(@swarm.lead_agent)
|
|
535
535
|
|
|
536
536
|
# Clear the agent's conversation history
|
|
537
|
-
lead.
|
|
537
|
+
lead.replace_messages([])
|
|
538
538
|
|
|
539
539
|
# Clear REPL conversation history
|
|
540
540
|
@conversation_history.clear
|
|
@@ -575,7 +575,7 @@ module SwarmCLI
|
|
|
575
575
|
case tool_name
|
|
576
576
|
when /^Memory/, "LoadSkill"
|
|
577
577
|
memory_tools << tool_name
|
|
578
|
-
when /^
|
|
578
|
+
when /^WorkWith/
|
|
579
579
|
delegation_tools << tool_name
|
|
580
580
|
when /^mcp__/
|
|
581
581
|
mcp_tools << tool_name
|