@swarmify/agents-mcp 0.2.6 → 0.2.7
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.
- package/README.md +72 -173
- package/dist/agents.d.ts +6 -4
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +134 -50
- package/dist/agents.js.map +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/hello-world.js +1 -1
- package/dist/hello-world.js.map +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +264 -0
- package/dist/parsers.js.map +1 -1
- package/dist/persistence.d.ts +21 -5
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +212 -48
- package/dist/persistence.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +8 -4
- package/dist/server.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -3
- package/dist/version.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
# @swarmify/agents-mcp
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Spawn CLI agents in parallel so your main agent stays focused. Each subagent runs in its own context and can be polled for progress.
|
|
3
|
+
Turn any agent into a tech lead. Spawn sub-agents from Claude, Codex, Gemini, or any MCP client.
|
|
6
4
|
|
|
7
5
|
Homepage: https://swarmify.co
|
|
8
6
|
NPM: https://www.npmjs.com/package/@swarmify/agents-mcp
|
|
9
|
-
VS Code Extension: https://marketplace.visualstudio.com/items?itemName=swarmify.swarm-ext
|
|
10
|
-
|
|
11
|
-
## Why This Exists
|
|
7
|
+
VS Code Extension: [Agents](https://marketplace.visualstudio.com/items?itemName=swarmify.swarm-ext) - full-screen agent terminals in your editor
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
## What you get
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
A single agent handles one thing at a time - like a junior developer. Add this MCP server, and your agent becomes a tech lead: it can spawn sub-agents, assign them specific files, give them project context, and synthesize their results.
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- The `/swarm` command to teach an orchestrator how to distribute work
|
|
21
|
-
- Plan vs edit modes that control file access per agent
|
|
22
|
-
- Local logs and durable processes that survive IDE restarts
|
|
13
|
+
**4 tools:** `Spawn`, `Status`, `Stop`, `Tasks`
|
|
14
|
+
**3 modes:** `plan` (read-only), `edit` (can write), `ralph` (autonomous)
|
|
15
|
+
**Background processes:** Sub-agents run headless, survive IDE restarts
|
|
23
16
|
|
|
24
17
|
## Quick Start
|
|
25
18
|
|
|
@@ -33,87 +26,51 @@ codex mcp add swarm -- npx -y @swarmify/agents-mcp@latest
|
|
|
33
26
|
# Gemini CLI
|
|
34
27
|
gemini mcp add Swarm -- npx -y @swarmify/agents-mcp
|
|
35
28
|
|
|
36
|
-
# OpenCode
|
|
29
|
+
# OpenCode
|
|
37
30
|
opencode mcp add
|
|
38
|
-
# Name: swarmify-
|
|
39
|
-
# Type: Local
|
|
40
|
-
# Command: npx -y @swarmify/agents-mcp
|
|
31
|
+
# Name: Swarm, Command: npx -y @swarmify/agents-mcp
|
|
41
32
|
```
|
|
42
33
|
|
|
43
34
|
The server auto-discovers which agent CLIs you have installed.
|
|
44
35
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
- Parallelize tasks across Claude, Codex, Gemini, and Cursor
|
|
48
|
-
- Keep long-running loops responsive by offloading work to subagents
|
|
49
|
-
- Integrate with MCP registries and gateways without changing your workflow
|
|
50
|
-
- Run Ralph Wiggum loops inside spawned Claude Code agents when the plugin is installed
|
|
51
|
-
|
|
52
|
-
## Under the Hood
|
|
53
|
-
|
|
54
|
-
Headless CLI agents run as background processes. Output streams to `~/.swarmify/agents/{id}/stdout.log`.
|
|
55
|
-
|
|
56
|
-
Plan mode is read-only:
|
|
57
|
-
|
|
58
|
-
- Claude: `--permission-mode plan`
|
|
59
|
-
- Codex: sandboxed (no `--full-auto`)
|
|
60
|
-
- Gemini and Cursor: no auto-approve flags
|
|
61
|
-
|
|
62
|
-
Edit mode unlocks writes:
|
|
63
|
-
|
|
64
|
-
- Codex: `--full-auto`
|
|
65
|
-
- Claude: `acceptEdits`
|
|
66
|
-
- Gemini: `--yolo`
|
|
67
|
-
- Cursor: `-f`
|
|
68
|
-
|
|
69
|
-
Agents are detached from the MCP server process. Close your IDE and reopen it, then reconnect with `Status` and `Tasks`.
|
|
70
|
-
|
|
71
|
-
## Common Questions
|
|
36
|
+
## What it costs
|
|
72
37
|
|
|
73
|
-
|
|
38
|
+
This server is free and open source.
|
|
74
39
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
**"How do I monitor what's happening?**"Use the Swarm `Status` tool to see what each agent is doing: files changed, commands run, last messages. No black box—full visibility into the swarm.
|
|
40
|
+
Each sub-agent uses your own API keys. Spawning 3 Claude agents means 3x your normal Claude API cost. No hidden fees.
|
|
78
41
|
|
|
79
42
|
## API Reference
|
|
80
43
|
|
|
81
|
-
### Tools
|
|
82
|
-
|
|
83
|
-
| Tool | Description |
|
|
84
|
-
| --- | --- |
|
|
85
|
-
| `Spawn` | Start an agent on a task. Returns immediately with agent ID. |
|
|
86
|
-
| `Status` | Get agent progress: files changed, commands run, last messages. |
|
|
87
|
-
| `Stop` | Stop one agent or all agents in a task. |
|
|
88
|
-
| `Tasks` | List all tasks with their agents and activity. |
|
|
89
|
-
|
|
90
44
|
### Spawn
|
|
91
45
|
|
|
92
46
|
```
|
|
93
47
|
Spawn(task_name, agent_type, prompt, mode?, cwd?, effort?)
|
|
94
48
|
```
|
|
95
49
|
|
|
50
|
+
Start an agent on a task. Returns immediately with agent ID.
|
|
51
|
+
|
|
96
52
|
| Parameter | Required | Description |
|
|
97
53
|
| --- | --- | --- |
|
|
98
54
|
| `task_name` | Yes | Groups related agents (e.g., "auth-feature") |
|
|
99
55
|
| `agent_type` | Yes | `claude`, `codex`, `gemini`, or `cursor` |
|
|
100
56
|
| `prompt` | Yes | The task for the agent |
|
|
101
|
-
| `mode` | No | `plan` (
|
|
102
|
-
| `cwd` | No | Working directory
|
|
103
|
-
| `effort` | No | `fast`, `default
|
|
57
|
+
| `mode` | No | `plan` (default), `edit`, or `ralph` |
|
|
58
|
+
| `cwd` | No | Working directory |
|
|
59
|
+
| `effort` | No | `fast`, `default`, or `detailed` |
|
|
104
60
|
|
|
105
61
|
### Status
|
|
106
62
|
|
|
107
63
|
```
|
|
108
|
-
Status(task_name, filter?)
|
|
64
|
+
Status(task_name, filter?, since?)
|
|
109
65
|
```
|
|
110
66
|
|
|
67
|
+
Get agent progress: files changed, commands run, last messages.
|
|
68
|
+
|
|
111
69
|
| Parameter | Required | Description |
|
|
112
70
|
| --- | --- | --- |
|
|
113
71
|
| `task_name` | Yes | Task to check |
|
|
114
|
-
| `filter` | No | `running` (default), `completed`, `failed`, `stopped`,
|
|
115
|
-
|
|
116
|
-
Returns files created/modified/read/deleted, bash commands executed, and last messages.
|
|
72
|
+
| `filter` | No | `running` (default), `completed`, `failed`, `stopped`, `all` |
|
|
73
|
+
| `since` | No | ISO timestamp for delta updates |
|
|
117
74
|
|
|
118
75
|
### Stop
|
|
119
76
|
|
|
@@ -129,156 +86,98 @@ Stop all agents in a task, or a specific agent by ID.
|
|
|
129
86
|
Tasks(limit?)
|
|
130
87
|
```
|
|
131
88
|
|
|
132
|
-
List all tasks sorted by most recent activity. Defaults to 10
|
|
133
|
-
|
|
134
|
-
## Token Optimization
|
|
135
|
-
|
|
136
|
-
This server is designed to minimize token usage for the calling agent:
|
|
137
|
-
|
|
138
|
-
| Optimization | Benefit |
|
|
139
|
-
| --- | --- |
|
|
140
|
-
| Status defaults to `filter='running'` | Only shows active agents, not completed history |
|
|
141
|
-
| Bash commands truncated to 120 chars | Heredocs collapsed to `cat <<EOF > path` |
|
|
142
|
-
| Last 5 messages only | Not full conversation history |
|
|
143
|
-
| File operations deduplicated | Sets of created/modified/read/deleted paths |
|
|
144
|
-
| Spawn returns immediately | No blocking, poll with Status later |
|
|
145
|
-
|
|
146
|
-
## Supported Agents
|
|
147
|
-
|
|
148
|
-
The server auto-discovers installed CLIs at startup:
|
|
149
|
-
|
|
150
|
-
| Agent | CLI | Best For |
|
|
151
|
-
| --- | --- | --- |
|
|
152
|
-
| Claude | `claude` | Best for complex research and open-ended exploration |
|
|
153
|
-
| Codex | `codex` | Fast, cheap. Self-contained features |
|
|
154
|
-
| Gemini | `gemini` | Complex multi-system features, architectural changes |
|
|
155
|
-
| Cursor | `cursor-agent` | Debugging, bug fixes, tracing through codebases |
|
|
89
|
+
List all tasks sorted by most recent activity. Defaults to 10.
|
|
156
90
|
|
|
157
91
|
## Modes
|
|
158
92
|
|
|
159
|
-
| Mode | File Access | Auto-
|
|
93
|
+
| Mode | File Access | Auto-loop? | Use Case |
|
|
160
94
|
| --- | --- | --- | --- |
|
|
161
|
-
| `plan` | Read-only | No | Research,
|
|
162
|
-
| `edit` | Read + Write | No | Implementation,
|
|
163
|
-
| `ralph` | Full
|
|
95
|
+
| `plan` | Read-only | No | Research, code review |
|
|
96
|
+
| `edit` | Read + Write | No | Implementation, fixes |
|
|
97
|
+
| `ralph` | Full | Yes | Autonomous via RALPH.md |
|
|
164
98
|
|
|
165
99
|
Default is `plan` for safety. Pass `mode='edit'` when agents need to modify files.
|
|
166
100
|
|
|
167
101
|
### Ralph Mode
|
|
168
102
|
|
|
169
|
-
Ralph mode spawns
|
|
170
|
-
|
|
171
|
-
**RALPH.md format:**
|
|
103
|
+
Ralph mode spawns one agent with full permissions to autonomously work through tasks in a `RALPH.md` file. The agent reads the file, picks tasks logically, marks them complete, and continues until done.
|
|
172
104
|
|
|
173
105
|
```markdown
|
|
174
106
|
## [ ] Implement user authentication
|
|
175
107
|
|
|
176
|
-
Add JWT-based auth to the backend
|
|
108
|
+
Add JWT-based auth to the backend.
|
|
177
109
|
|
|
178
110
|
### Updates
|
|
179
111
|
|
|
180
112
|
---
|
|
181
113
|
|
|
182
|
-
## [x] Add rate limiting
|
|
114
|
+
## [x] Add rate limiting
|
|
183
115
|
|
|
184
|
-
Protect API endpoints
|
|
116
|
+
Protect API endpoints.
|
|
185
117
|
|
|
186
118
|
### Updates
|
|
187
|
-
- Added
|
|
188
|
-
|
|
119
|
+
- Added sliding window counter
|
|
120
|
+
```
|
|
189
121
|
|
|
190
|
-
|
|
122
|
+
```
|
|
123
|
+
Spawn(mode='ralph', cwd='./my-project', prompt='Build the auth system')
|
|
124
|
+
```
|
|
191
125
|
|
|
192
|
-
##
|
|
126
|
+
## What This Server Does NOT Do
|
|
193
127
|
|
|
194
|
-
|
|
128
|
+
| Not This | That's The Orchestrator's Job |
|
|
129
|
+
|----------|-------------------------------|
|
|
130
|
+
| Scheduling | Decides when to spawn which agents |
|
|
131
|
+
| Task assignment | Writes prompts, defines what to do |
|
|
132
|
+
| Conflict resolution | Assigns non-overlapping files to agents |
|
|
133
|
+
| Intelligence | Pure infrastructure - no decision-making |
|
|
195
134
|
|
|
196
|
-
|
|
197
|
-
```
|
|
135
|
+
The server is a tool. Your orchestrating agent (Claude, etc.) decides how to use it.
|
|
198
136
|
|
|
199
|
-
|
|
137
|
+
## Supported Agents
|
|
200
138
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
139
|
+
| Agent | CLI | Best For |
|
|
140
|
+
| --- | --- | --- |
|
|
141
|
+
| Claude | `claude` | Complex research, orchestration |
|
|
142
|
+
| Codex | `codex` | Fast implementation |
|
|
143
|
+
| Gemini | `gemini` | Multi-system changes |
|
|
144
|
+
| Cursor | `cursor-agent` | Debugging, tracing |
|
|
145
|
+
| OpenCode | `opencode` | Provider-agnostic, open source |
|
|
207
146
|
|
|
208
|
-
|
|
147
|
+
## Under the Hood
|
|
209
148
|
|
|
210
|
-
|
|
149
|
+
Sub-agents run as detached background processes. Output streams to `~/.agents/agents/{id}/stdout.log`.
|
|
211
150
|
|
|
212
|
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
-
|
|
151
|
+
**Plan mode** is read-only:
|
|
152
|
+
- Claude: `--permission-mode plan`
|
|
153
|
+
- Codex: sandboxed
|
|
154
|
+
- Gemini/Cursor: no auto-approve
|
|
216
155
|
|
|
217
|
-
|
|
156
|
+
**Edit mode** unlocks writes:
|
|
157
|
+
- Claude: `acceptEdits`
|
|
158
|
+
- Codex: `--full-auto`
|
|
159
|
+
- Gemini: `--yolo`
|
|
160
|
+
- Cursor: `-f`
|
|
218
161
|
|
|
219
|
-
|
|
220
|
-
| --- | --- |
|
|
221
|
-
| `fast` | codex: gpt-5.2-codex, claude: claude-haiku-4-5, gemini: gemini-3-flash, cursor: composer-1 |
|
|
222
|
-
| `default` | codex: gpt-5.2-codex, claude: claude-sonnet-4-5, gemini: gemini-3-flash, cursor: composer-1 |
|
|
223
|
-
| `detailed` | codex: gpt-5.1-codex-max, claude: claude-opus-4-5, gemini: gemini-3-pro, cursor: composer-1 |
|
|
224
|
-
|
|
225
|
-
## Config
|
|
226
|
-
|
|
227
|
-
Config lives at `~/.swarmify/config.json`.
|
|
228
|
-
|
|
229
|
-
Example with per-agent swarm selection and effort model overrides:
|
|
230
|
-
|
|
231
|
-
```json
|
|
232
|
-
{
|
|
233
|
-
"agents": {
|
|
234
|
-
"claude": {
|
|
235
|
-
"swarm": true,
|
|
236
|
-
"effort": {
|
|
237
|
-
"models": {
|
|
238
|
-
"fast": "claude-haiku-4-5-20251001",
|
|
239
|
-
"default": "claude-sonnet-4-5",
|
|
240
|
-
"detailed": "claude-opus-4-5"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
"codex": { "swarm": true },
|
|
245
|
-
"gemini": { "swarm": true },
|
|
246
|
-
"cursor": { "swarm": false }
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
```
|
|
162
|
+
## Configuration
|
|
250
163
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
```json
|
|
254
|
-
{
|
|
255
|
-
"agents": {
|
|
256
|
-
"claude": {
|
|
257
|
-
"swarm": true,
|
|
258
|
-
"effort": {
|
|
259
|
-
"level": "fast",
|
|
260
|
-
"model": "claude-haiku-4-5-20251001"
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
```
|
|
164
|
+
Config lives at `~/.agents/config.json`. See [AGENTS.md](./AGENTS.md) for full config reference.
|
|
266
165
|
|
|
267
166
|
## Environment Variables
|
|
268
167
|
|
|
269
168
|
| Variable | Description |
|
|
270
169
|
| --- | --- |
|
|
271
|
-
| `AGENTS_MCP_DEFAULT_MODE` |
|
|
272
|
-
| `AGENTS_MCP_RALPH_FILE` | Task file name
|
|
273
|
-
| `AGENTS_MCP_DISABLE_RALPH` | Set
|
|
170
|
+
| `AGENTS_MCP_DEFAULT_MODE` | Default mode (`plan` or `edit`) |
|
|
171
|
+
| `AGENTS_MCP_RALPH_FILE` | Task file name (default: `RALPH.md`) |
|
|
172
|
+
| `AGENTS_MCP_DISABLE_RALPH` | Set `true` to disable ralph mode |
|
|
274
173
|
|
|
275
|
-
##
|
|
174
|
+
## Works great with the extension
|
|
276
175
|
|
|
277
|
-
|
|
176
|
+
This MCP server works standalone with any MCP client. For the best experience - full-screen agent terminals, session persistence, fast navigation - install the [Agents extension](https://marketplace.visualstudio.com/items?itemName=swarmify.swarm-ext) for VS Code/Cursor.
|
|
278
177
|
|
|
279
|
-
##
|
|
178
|
+
## Storage
|
|
280
179
|
|
|
281
|
-
|
|
180
|
+
Data at `~/.agents/`. Requires Node.js >= 18.17.
|
|
282
181
|
|
|
283
182
|
## License
|
|
284
183
|
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AgentConfig } from './persistence.js';
|
|
2
2
|
import { AgentType } from './parsers.js';
|
|
3
3
|
/**
|
|
4
4
|
* Compute the Lowest Common Ancestor (LCA) of multiple file paths.
|
|
@@ -16,8 +16,8 @@ export type { AgentType } from './parsers.js';
|
|
|
16
16
|
export declare const AGENT_COMMANDS: Record<AgentType, string[]>;
|
|
17
17
|
export type EffortLevel = 'fast' | 'default' | 'detailed';
|
|
18
18
|
export type EffortModelMap = Record<EffortLevel, Record<AgentType, string>>;
|
|
19
|
+
export declare function resolveEffortModelMap(baseOrAgentConfigs: EffortModelMap | Record<AgentType, AgentConfig>, overrides?: Partial<Record<AgentType, Partial<Record<EffortLevel, string>>>>): EffortModelMap;
|
|
19
20
|
export declare const EFFORT_MODEL_MAP: EffortModelMap;
|
|
20
|
-
export declare function resolveEffortModelMap(base: EffortModelMap, overrides: ModelOverrides | null | undefined): EffortModelMap;
|
|
21
21
|
declare const VALID_MODES: readonly ["plan", "edit", "ralph"];
|
|
22
22
|
type Mode = typeof VALID_MODES[number];
|
|
23
23
|
export declare function resolveMode(requestedMode: string | null | undefined, defaultMode?: Mode): Mode;
|
|
@@ -73,11 +73,13 @@ export declare class AgentManager {
|
|
|
73
73
|
private cleanupAgeDays;
|
|
74
74
|
private defaultMode;
|
|
75
75
|
private effortModelMap;
|
|
76
|
+
private agentConfigs;
|
|
77
|
+
private constructorAgentConfigs;
|
|
76
78
|
private constructorAgentsDir;
|
|
77
|
-
constructor(maxAgents?: number, maxConcurrent?: number, agentsDir?: string | null, defaultMode?: Mode | null, filterByCwd?: string | null, cleanupAgeDays?: number,
|
|
79
|
+
constructor(maxAgents?: number, maxConcurrent?: number, agentsDir?: string | null, defaultMode?: Mode | null, filterByCwd?: string | null, cleanupAgeDays?: number, agentConfigs?: Record<AgentType, AgentConfig> | null);
|
|
78
80
|
private initialize;
|
|
79
81
|
getDefaultMode(): Mode;
|
|
80
|
-
setModelOverrides(
|
|
82
|
+
setModelOverrides(agentConfigs: Record<AgentType, AgentConfig>): void;
|
|
81
83
|
private loadExistingAgents;
|
|
82
84
|
spawn(taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode | null, effort?: EffortLevel, parentSessionId?: string | null, workspaceDir?: string | null): Promise<AgentProcess>;
|
|
83
85
|
private buildCommand;
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyC,KAAK,WAAW,EAAuD,MAAM,kBAAkB,CAAC;AAChJ,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAgC7D;AAED,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAOtD,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAG5E,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,cAAc,GAAG,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,EACnE,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAC3E,cAAc,CA6ChB;AAuED,eAAO,MAAM,gBAAgB,EAAE,cAAiE,CAAC;AAejG,QAAA,MAAM,WAAW,oCAAqC,CAA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E,CAAC;IAmBtF,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YA8B/B,mBAAmB;YAUnB,gBAAgB;CAmB/B"}
|
package/dist/agents.js
CHANGED
|
@@ -55,57 +55,121 @@ export const AGENT_COMMANDS = {
|
|
|
55
55
|
cursor: ['cursor-agent', '-p', '--output-format', 'stream-json', '{prompt}'],
|
|
56
56
|
gemini: ['gemini', '{prompt}', '--output-format', 'stream-json'],
|
|
57
57
|
claude: ['claude', '-p', '--verbose', '{prompt}', '--output-format', 'stream-json', '--permission-mode', 'plan'],
|
|
58
|
+
trae: ['trae-cli', 'run', '{prompt}'],
|
|
59
|
+
opencode: ['opencode', 'run', '--format', 'json', '{prompt}'],
|
|
58
60
|
};
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
export function resolveEffortModelMap(base, overrides) {
|
|
84
|
-
const resolved = {
|
|
85
|
-
fast: { ...base.fast },
|
|
86
|
-
default: { ...base.default },
|
|
87
|
-
detailed: { ...base.detailed },
|
|
88
|
-
};
|
|
89
|
-
if (!overrides)
|
|
90
|
-
return resolved;
|
|
91
|
-
for (const [agentType, effortOverrides] of Object.entries(overrides)) {
|
|
92
|
-
if (!effortOverrides)
|
|
93
|
-
continue;
|
|
94
|
-
if (!['codex', 'gemini', 'cursor', 'claude'].includes(agentType))
|
|
95
|
-
continue;
|
|
96
|
-
const typedAgent = agentType;
|
|
97
|
-
for (const level of ['fast', 'default', 'detailed']) {
|
|
98
|
-
const model = effortOverrides[level];
|
|
99
|
-
if (typeof model === 'string') {
|
|
100
|
-
const trimmed = model.trim();
|
|
101
|
-
if (trimmed) {
|
|
102
|
-
resolved[level][typedAgent] = trimmed;
|
|
61
|
+
// Build effort model map from agent configs
|
|
62
|
+
export function resolveEffortModelMap(baseOrAgentConfigs, overrides) {
|
|
63
|
+
// Check if first arg is base EffortModelMap (old API) or agent configs (new API)
|
|
64
|
+
const hasBaseOverrides = arguments.length > 1;
|
|
65
|
+
if (hasBaseOverrides && overrides) {
|
|
66
|
+
// Old API: resolveEffortModelMap(base, overrides)
|
|
67
|
+
const base = baseOrAgentConfigs;
|
|
68
|
+
const resolved = {
|
|
69
|
+
fast: { ...base.fast },
|
|
70
|
+
default: { ...base.default },
|
|
71
|
+
detailed: { ...base.detailed }
|
|
72
|
+
};
|
|
73
|
+
for (const [agentType, effortOverrides] of Object.entries(overrides)) {
|
|
74
|
+
if (!effortOverrides)
|
|
75
|
+
continue;
|
|
76
|
+
const typedAgent = agentType;
|
|
77
|
+
for (const level of ['fast', 'default', 'detailed']) {
|
|
78
|
+
const model = effortOverrides[level];
|
|
79
|
+
if (typeof model === 'string') {
|
|
80
|
+
const trimmed = model.trim();
|
|
81
|
+
if (trimmed) {
|
|
82
|
+
resolved[level][typedAgent] = trimmed;
|
|
83
|
+
}
|
|
103
84
|
}
|
|
104
85
|
}
|
|
105
86
|
}
|
|
87
|
+
return resolved;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// New API: resolveEffortModelMap(agentConfigs)
|
|
91
|
+
const agentConfigs = baseOrAgentConfigs;
|
|
92
|
+
const resolved = {
|
|
93
|
+
fast: {},
|
|
94
|
+
default: {},
|
|
95
|
+
detailed: {}
|
|
96
|
+
};
|
|
97
|
+
for (const [agentType, agentConfig] of Object.entries(agentConfigs)) {
|
|
98
|
+
resolved.fast[agentType] = agentConfig.models.fast;
|
|
99
|
+
resolved.default[agentType] = agentConfig.models.default;
|
|
100
|
+
resolved.detailed[agentType] = agentConfig.models.detailed;
|
|
101
|
+
}
|
|
102
|
+
return resolved;
|
|
106
103
|
}
|
|
107
|
-
return resolved;
|
|
108
104
|
}
|
|
105
|
+
// Load default agent configs from persistence
|
|
106
|
+
function loadDefaultAgentConfigs() {
|
|
107
|
+
// Use hardcoded defaults for backward compatibility with synchronous initialization
|
|
108
|
+
return {
|
|
109
|
+
claude: {
|
|
110
|
+
command: 'claude -p \'{prompt}\' --output-format stream-json --json',
|
|
111
|
+
enabled: true,
|
|
112
|
+
models: {
|
|
113
|
+
fast: 'claude-haiku-4-5-20251001',
|
|
114
|
+
default: 'claude-sonnet-4-5',
|
|
115
|
+
detailed: 'claude-opus-4-5'
|
|
116
|
+
},
|
|
117
|
+
provider: 'anthropic'
|
|
118
|
+
},
|
|
119
|
+
codex: {
|
|
120
|
+
command: 'codex exec --sandbox workspace-write \'{prompt}\' --json',
|
|
121
|
+
enabled: true,
|
|
122
|
+
models: {
|
|
123
|
+
fast: 'gpt-4o-mini',
|
|
124
|
+
default: 'gpt-5.2-codex',
|
|
125
|
+
detailed: 'gpt-5.1-codex-max'
|
|
126
|
+
},
|
|
127
|
+
provider: 'openai'
|
|
128
|
+
},
|
|
129
|
+
gemini: {
|
|
130
|
+
command: 'gemini \'{prompt}\' --output-format stream-json',
|
|
131
|
+
enabled: true,
|
|
132
|
+
models: {
|
|
133
|
+
fast: 'gemini-3-flash-preview',
|
|
134
|
+
default: 'gemini-3-flash-preview',
|
|
135
|
+
detailed: 'gemini-3-pro-preview'
|
|
136
|
+
},
|
|
137
|
+
provider: 'google'
|
|
138
|
+
},
|
|
139
|
+
cursor: {
|
|
140
|
+
command: 'cursor-agent -p --output-format stream-json \'{prompt}\'',
|
|
141
|
+
enabled: false,
|
|
142
|
+
models: {
|
|
143
|
+
fast: 'composer-1',
|
|
144
|
+
default: 'composer-1',
|
|
145
|
+
detailed: 'composer-1'
|
|
146
|
+
},
|
|
147
|
+
provider: 'custom'
|
|
148
|
+
},
|
|
149
|
+
opencode: {
|
|
150
|
+
command: 'opencode run --format json \'{prompt}\'',
|
|
151
|
+
enabled: false,
|
|
152
|
+
models: {
|
|
153
|
+
fast: 'zai-coding-plan/glm-4.7-flash',
|
|
154
|
+
default: 'zai-coding-plan/glm-4.7',
|
|
155
|
+
detailed: 'zai-coding-plan/glm-4.7'
|
|
156
|
+
},
|
|
157
|
+
provider: 'custom'
|
|
158
|
+
},
|
|
159
|
+
trae: {
|
|
160
|
+
command: 'trae-cli run \'{prompt}\'',
|
|
161
|
+
enabled: false,
|
|
162
|
+
models: {
|
|
163
|
+
fast: 'gpt-4o-mini',
|
|
164
|
+
default: 'gpt-4o',
|
|
165
|
+
detailed: 'claude-sonnet-4-20250514'
|
|
166
|
+
},
|
|
167
|
+
provider: 'custom'
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// Default effort model map (for backward compatibility with tests)
|
|
172
|
+
export const EFFORT_MODEL_MAP = resolveEffortModelMap(loadDefaultAgentConfigs());
|
|
109
173
|
// Suffix appended to all prompts to ensure agents provide a summary
|
|
110
174
|
const PROMPT_SUFFIX = `
|
|
111
175
|
|
|
@@ -479,9 +543,11 @@ export class AgentManager {
|
|
|
479
543
|
filterByCwd;
|
|
480
544
|
cleanupAgeDays;
|
|
481
545
|
defaultMode;
|
|
482
|
-
effortModelMap
|
|
546
|
+
effortModelMap;
|
|
547
|
+
agentConfigs;
|
|
548
|
+
constructorAgentConfigs = null;
|
|
483
549
|
constructorAgentsDir = null;
|
|
484
|
-
constructor(maxAgents = 50, maxConcurrent = 10, agentsDir = null, defaultMode = null, filterByCwd = null, cleanupAgeDays = 7,
|
|
550
|
+
constructor(maxAgents = 50, maxConcurrent = 10, agentsDir = null, defaultMode = null, filterByCwd = null, cleanupAgeDays = 7, agentConfigs = null) {
|
|
485
551
|
this.maxAgents = maxAgents;
|
|
486
552
|
this.maxConcurrent = maxConcurrent;
|
|
487
553
|
this.constructorAgentsDir = agentsDir;
|
|
@@ -492,19 +558,28 @@ export class AgentManager {
|
|
|
492
558
|
throw new Error(`Invalid default_mode '${defaultMode}'. Use 'plan' or 'edit'.`);
|
|
493
559
|
}
|
|
494
560
|
this.defaultMode = resolvedDefaultMode;
|
|
495
|
-
this.
|
|
561
|
+
this.constructorAgentConfigs = agentConfigs;
|
|
496
562
|
this.initialize();
|
|
497
563
|
}
|
|
498
564
|
async initialize() {
|
|
499
565
|
this.agentsDir = this.constructorAgentsDir || await getAgentsDir();
|
|
500
566
|
await fs.mkdir(this.agentsDir, { recursive: true });
|
|
567
|
+
// Set defaults if no config provided
|
|
568
|
+
if (!this.constructorAgentConfigs) {
|
|
569
|
+
this.agentConfigs = loadDefaultAgentConfigs();
|
|
570
|
+
this.effortModelMap = resolveEffortModelMap(this.agentConfigs);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
this.effortModelMap = resolveEffortModelMap(this.constructorAgentConfigs);
|
|
574
|
+
}
|
|
501
575
|
await this.loadExistingAgents();
|
|
502
576
|
}
|
|
503
577
|
getDefaultMode() {
|
|
504
578
|
return this.defaultMode;
|
|
505
579
|
}
|
|
506
|
-
setModelOverrides(
|
|
507
|
-
this.
|
|
580
|
+
setModelOverrides(agentConfigs) {
|
|
581
|
+
this.agentConfigs = agentConfigs;
|
|
582
|
+
this.effortModelMap = resolveEffortModelMap(agentConfigs);
|
|
508
583
|
}
|
|
509
584
|
async loadExistingAgents() {
|
|
510
585
|
try {
|
|
@@ -652,6 +727,15 @@ export class AgentManager {
|
|
|
652
727
|
else if (agentType === 'gemini' || agentType === 'claude') {
|
|
653
728
|
cmd.push('--model', model);
|
|
654
729
|
}
|
|
730
|
+
else if (agentType === 'opencode') {
|
|
731
|
+
const opencodeAgent = mode === 'edit' || mode === 'ralph' ? 'build' : 'plan';
|
|
732
|
+
// Insert --agent flag after the prompt
|
|
733
|
+
const promptIndex = cmd.indexOf(fullPrompt);
|
|
734
|
+
if (promptIndex !== -1) {
|
|
735
|
+
cmd.splice(promptIndex + 1, 0, '--agent', opencodeAgent);
|
|
736
|
+
}
|
|
737
|
+
cmd.push('--model', model);
|
|
738
|
+
}
|
|
655
739
|
if (mode === 'ralph') {
|
|
656
740
|
cmd = this.applyRalphMode(agentType, cmd);
|
|
657
741
|
}
|