@robzilla1738/agentswarm 0.5.0 → 0.6.0
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 +29 -12
- package/dist/agent.js +2 -1
- package/dist/cli.js +21 -4
- package/dist/config.js +27 -1
- package/dist/executor.js +243 -43
- package/dist/hub.js +69 -3
- package/dist/memory.js +5 -4
- package/dist/pdftext.js +211 -0
- package/dist/prompts.js +23 -15
- package/dist/report.js +37 -0
- package/dist/run.js +8 -0
- package/dist/sandbox.js +11 -0
- package/dist/searchcore.js +55 -2
- package/dist/state.js +34 -6
- package/dist/tools.js +196 -19
- package/dist/util.js +85 -0
- package/dist/webtools.js +145 -15
- package/package.json +1 -1
- package/ui/out/404/index.html +1 -1
- package/ui/out/404.html +1 -1
- package/ui/out/_next/static/chunks/677-721ce1c8b7a6a317.js +1 -0
- package/ui/out/_next/static/chunks/app/run/page-3674e103981703a2.js +1 -0
- package/ui/out/_next/static/chunks/app/settings/page-41a5d8ba43ecfd4a.js +1 -0
- package/ui/out/_next/static/css/{9f7bd82b8e4c762c.css → d95c2ba395730031.css} +1 -1
- package/ui/out/index.html +1 -1
- package/ui/out/index.txt +3 -3
- package/ui/out/run/index.html +1 -1
- package/ui/out/run/index.txt +3 -3
- package/ui/out/settings/index.html +1 -1
- package/ui/out/settings/index.txt +3 -3
- package/ui/out/_next/static/chunks/677-859e8d42add1806b.js +0 -1
- package/ui/out/_next/static/chunks/app/run/page-2420c9e4c963d9b3.js +0 -1
- package/ui/out/_next/static/chunks/app/settings/page-092a6bf42dfde57d.js +0 -1
- /package/ui/out/_next/static/{errjtBR_bKoee8ogLp8xk → 7_pihFubDGD40BCy2ynlr}/_buildManifest.js +0 -0
- /package/ui/out/_next/static/{errjtBR_bKoee8ogLp8xk → 7_pihFubDGD40BCy2ynlr}/_ssgManifest.js +0 -0
package/README.md
CHANGED
|
@@ -95,25 +95,32 @@ swarm run "Research the best open-source vector DBs in 2026 and write a recommen
|
|
|
95
95
|
| `swarm cancel <id>` | Stop a run. It still synthesizes a report from completed work. |
|
|
96
96
|
| `swarm config [list\|get\|set …]` | Manage `~/.agentswarm/config.json`. |
|
|
97
97
|
| `swarm models` | List models from the active provider. |
|
|
98
|
+
| `swarm config unset <key>` | Remove a setting (e.g., `swarm config unset firecrawlApiKey`). |
|
|
98
99
|
| `swarm demo` | Run a self-contained demo mission in an isolated workspace. |
|
|
99
100
|
|
|
100
101
|
Run options (also on the UI launch form under Options): `--workers N` (parallelism), `--tasks N`, `--steps N` (tool steps per task), `--budget N` (token cap), `--model`, `--conductor`, `--verify off|normal|strict`, `--effort low|medium|high|max`, `--no-thinking`, `--sandbox host|docker|e2b|modal|vercel|auto` (shell runtime for this run), `--cwd <path>` (run against a real directory instead of an isolated workspace), `--fg` (foreground in this process).
|
|
101
102
|
|
|
102
103
|
## How it works
|
|
103
104
|
|
|
104
|
-
The conductor is a model with six tools: `spawn_tasks`, `set_phase`, `update_plan`, `read_report`, `wait`, and `finish`. It reads the mission, spawns self-contained tasks (each with an objective, success criteria, a role, optional dependencies, and an optional `verify` flag), then reacts as reports come back. On long missions it declares phases (`set_phase`) whose goals and exit criteria are pinned into every update — so the plan survives even when old history is trimmed and replaced by a mission ledger (settled tasks, decisions, current phase).
|
|
105
|
+
The conductor is a model with six tools: `spawn_tasks`, `set_phase`, `update_plan`, `read_report`, `wait`, and `finish`. It reads the mission, spawns self-contained tasks (each with an objective, success criteria, a role, optional dependencies, and an optional `verify` flag), then reacts as reports come back. On long missions it declares phases (`set_phase`) whose goals and exit criteria are pinned into every update — so the plan survives even when old history is trimmed and replaced by a mission ledger (settled tasks, decisions, current phase). On resume, the conductor is re-seeded with this ledger so it picks up where it left off without losing context.
|
|
105
106
|
|
|
106
|
-
Each task becomes an autonomous agent with a tool budget. It works in small steps, posts durable findings to the blackboard (decisions are never trimmed from digests; `search_notes`
|
|
107
|
+
Each task becomes an autonomous agent with a tool budget. It works in small steps, posts durable findings to the blackboard (decisions are never trimmed from digests; `search_notes` now supports `kind` filters to find decisions, context, or source links without noise), journals progress checkpoints on long tasks, saves artifacts, and ends by reporting back with structured handoff fields (`key_facts`, `open_questions`, `files_touched`) plus any sources discovered. Sources flow through to the final report as numbered citations — every source is deduplicated, attributed, and linked inline (`[1]`) with a full bibliography at the end. Dependent tasks receive report excerpts plus those fields, and can pull full text with `read_report`.
|
|
107
108
|
|
|
108
|
-
**
|
|
109
|
+
**Search & research.** Web search now includes engine rate-limit cooldowns (on a 429, the engine skips it for a while and re-plans); queries reformulate themselves down to keywords if they get zero results (lifting recall without noise); results are freshness-ranked so recent content bubbles up. For academic queries, agents can use `academic_search` to query arXiv and Crossref directly — no API key needed. Fetches from the web pull plain text via `fetch_url`, which extracts text from PDFs (zero runtime dependencies, zlib only), decodes non-UTF-8 charsets, and flags paywall shells so agents know when they hit a wall.
|
|
109
110
|
|
|
110
|
-
**
|
|
111
|
+
**Scale.** A global AIMD limiter (`maxConcurrentCalls`) bounds concurrent model calls per endpoint — a 429 halves the ceiling, successes recover it, and conductor calls always jump the queue, so a 100-agent swarm degrades gracefully instead of melting down. Settles are debounced before waking the conductor; on big runs the task table collapses settled waves (failures stay itemized) and excess reports become one-liners the conductor can expand with `read_report`. Spawn specs take a `model` tier (`cheap` for scouts, `strong` for leads/verifiers via `cheapModel`/`strongModel` config) and `team:true` to run a task as a full sub-swarm — its own conductor decomposes it in parallel and reports one consolidated result, with all activity journaled under its `teamId`. Context windows are configurable per model via `contextWindows` config; the engine respects each model's actual limit and compacts agent context accordingly.
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
**Worker tools.** The toolbelt gained `grep_files` for structured content search and `replace_in_file` with atomic multi-edit batches — both portable across sandboxes (Docker, E2B, Modal, Vercel).
|
|
114
|
+
|
|
115
|
+
**Verification & quality.** Tasks pass a mechanical format pre-check (JSON/CSV/HTML structure), then a blind LLM verifier with its own tools. Failed verifications retry with structured feedback (problem/evidence/fix). The verifier gets copies of all dependencies' reports for context. In `--verify strict` mode, the verifier must back verdicts with tool-gathered evidence (not just a pass statement), a completeness critic reviews the whole run for gaps before synthesis, and the final report is checked for faithfulness against the task reports.
|
|
116
|
+
|
|
117
|
+
**Long horizon.** The conductor maintains a living `mission-plan.md` (`update_plan`) pinned into every update and restored on resume; every 25 settled tasks a progress snapshot lands in `artifacts/` so multi-day runs always have a partial deliverable; and real-directory runs leave a memory (`~/.agentswarm/memory/`) of missions, outcomes, and decisions that seeds the next swarm in the same workspace. When tasks fail, the cascade carries the root cause transitively — blocked tasks know why rather than just "dependency did not complete". Failed tasks surface their last failing tool call as diagnostics.
|
|
118
|
+
|
|
119
|
+
**Planning & steering.** The UI now includes a Plan tab showing the living `mission-plan.md`, and the conductor can update it from an agent note (`swarm note <id> "update the plan: ..."`). The budget sparkline in the run dashboard shows at-a-glance how much token budget remains.
|
|
113
120
|
|
|
114
121
|
The scheduler starts a task as soon as its dependencies are done, up to the parallelism cap. Tasks whose dependencies failed are blocked and surfaced to the conductor for re-planning.
|
|
115
122
|
|
|
116
|
-
When the conductor finishes (or the budget forces it), a synthesizer composes the final deliverable from every task report. Deliverables ship in the format the mission calls for — code, `.csv`/`.json` data, styled documents — alongside `final-report.md` and a self-contained `final-report.html` rendering (open it with `swarm report <id> --open`).
|
|
123
|
+
When the conductor finishes (or the budget forces it), a synthesizer composes the final deliverable from every task report. Deliverables ship in the format the mission calls for — code, `.csv`/`.json` data, styled documents — alongside `final-report.md` and a self-contained `final-report.html` rendering (open it with `swarm report <id> --open`). The final report includes an inline-cited Sources section and all findings are preserved.
|
|
117
124
|
|
|
118
125
|
The journal is the source of truth. Every run is an append-only `events.jsonl`; the terminal dashboard, the web UI, and `swarm ls` all reduce the same file. That's why runs survive crashes and can be resumed or replayed. Runs live under `~/.agentswarm/runs/<id>/`.
|
|
119
126
|
|
|
@@ -137,15 +144,24 @@ src/ TypeScript engine (zero runtime deps)
|
|
|
137
144
|
sandbox.ts sandbox runtimes: host, docker, E2B, Modal, Vercel
|
|
138
145
|
agent.ts the agent loop: stream → tool calls → results → repeat, with compaction
|
|
139
146
|
executor.ts the orchestrator: conductor loop, parallel scheduler, verify, synth, budget
|
|
140
|
-
tools.ts worker toolbelt (shell, files, web, blackboard, artifacts) + safety
|
|
141
|
-
webtools.ts web search/fetch: SearchKit → TinyFish → DuckDuckGo fallback chain
|
|
147
|
+
tools.ts worker toolbelt (shell, files, web, blackboard, artifacts) + safety + grep/replace
|
|
148
|
+
webtools.ts web search/fetch: SearchKit → TinyFish → DuckDuckGo fallback chain, with cooldowns + reformulation
|
|
149
|
+
searchcore.ts search ranking (freshness boost, academic intent detection) + academic_search (arXiv/Crossref)
|
|
150
|
+
pdftext.ts PDF text extraction (zero deps, zlib only)
|
|
151
|
+
crawltools.ts crawl backend resolver (firecrawl/context.dev/deepcrawl)
|
|
142
152
|
journal.ts append-only crash-safe event log (single source of truth)
|
|
143
|
-
state.ts pure reducer: events → live run state
|
|
144
|
-
hub.ts localhost HTTP API + SSE + static UI server
|
|
153
|
+
state.ts pure reducer: events → live run state (with budgetSeries sampling)
|
|
154
|
+
hub.ts localhost HTTP API + SSE + static UI server (CORS locked to localhost)
|
|
145
155
|
terminal.ts live TTY dashboard
|
|
146
156
|
cli.ts command-line interface
|
|
157
|
+
memory.ts atomic runId-keyed cross-run memory + interim snapshots
|
|
147
158
|
ui/ Next.js 15 + Tailwind 4 web app (static-exported, served by the hub)
|
|
159
|
+
components/SideRail Plan tab showing mission-plan.md
|
|
160
|
+
app/run/page.tsx Blackboard search with kind filters + budget sparkline
|
|
161
|
+
app/settings/page.tsx Test buttons for crawl/search backends, key management
|
|
148
162
|
test/ end-to-end test with a scripted mock model (no API key needed)
|
|
163
|
+
e2e.js 21 phases covering the full pipeline, including citations + force + resume + budget + verify + teams
|
|
164
|
+
unit/*.test.js individual suites for tools, crawl, memory, pdftext, webtools, searchcore, citations
|
|
149
165
|
```
|
|
150
166
|
|
|
151
167
|
## Testing
|
|
@@ -158,11 +174,12 @@ Boots a mock model server and drives real missions through the engine, offline,
|
|
|
158
174
|
|
|
159
175
|
## Safety notes
|
|
160
176
|
|
|
161
|
-
- Safe mode is on by default. It blocks obviously destructive shell commands and confines writes to the working directory. `--no-safe` turns it off for a run; only do that when you trust the mission.
|
|
177
|
+
- Safe mode is on by default. It blocks obviously destructive shell commands and confines writes to the working directory, plus symlink escapes to parent directories. `--no-safe` turns it off for a run; only do that when you trust the mission.
|
|
178
|
+
- The hub API (started by `swarm serve`) only accepts requests from localhost origins (`http://localhost:*` and `127.0.0.1:*`). The web UI runs in your browser locally and never phones home.
|
|
162
179
|
- Runs default to an isolated per-run workspace on this machine. That's a private directory, not a container. Agents still execute with your user's permissions; the engine strips API keys and sandbox credentials from their environment, and safe mode constrains commands and writes. For untrusted or risky missions, use `--sandbox docker` or a cloud runtime.
|
|
163
180
|
- Use `--cwd <path>` (or Workspace → "A directory on disk" in the UI) to let agents touch a real project. Those runs always execute on the host, since touching your real files is the point.
|
|
164
181
|
- Costs are estimates based on list prices and the token counts the API reports. Models without pricing data show $0. Set a `--budget` either way.
|
|
165
|
-
- Keys are stored in `~/.agentswarm/config.json` (chmod 600) and are only sent to the APIs you configured.
|
|
182
|
+
- Keys are stored in `~/.agentswarm/config.json` (chmod 600) and are only sent to the APIs you configured. Use `swarm config unset <key>` to remove a key, or the Settings UI for test buttons on crawl/search backends.
|
|
166
183
|
|
|
167
184
|
## Author
|
|
168
185
|
|
package/dist/agent.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runAgent = runAgent;
|
|
4
4
|
exports.estimateMessages = estimateMessages;
|
|
5
|
+
const config_1 = require("./config");
|
|
5
6
|
const deepseek_1 = require("./deepseek");
|
|
6
7
|
const prompts_1 = require("./prompts");
|
|
7
8
|
const types_1 = require("./types");
|
|
@@ -142,7 +143,7 @@ async function runAgent(p) {
|
|
|
142
143
|
messages.push({ role: "tool", tool_call_id: call.id, content: result });
|
|
143
144
|
}
|
|
144
145
|
hooks.onTranscript?.(messages);
|
|
145
|
-
if (estimateMessages(messages) > cfg.
|
|
146
|
+
if (estimateMessages(messages) > (0, config_1.contextLimitFor)(cfg, p.model)) {
|
|
146
147
|
messages = await compact(p, messages);
|
|
147
148
|
hooks.onTranscript?.(messages);
|
|
148
149
|
hooks.onLog?.("info", `${p.agentId}: context compacted`);
|
package/dist/cli.js
CHANGED
|
@@ -524,15 +524,18 @@ async function cmdConfig(rest, flags) {
|
|
|
524
524
|
const cfg = (0, config_1.loadConfig)();
|
|
525
525
|
if (sub === "get" && rest[1]) {
|
|
526
526
|
const key = rest[1];
|
|
527
|
-
const v = key
|
|
527
|
+
const v = /apikey|token|secret/i.test(key) ? (0, config_1.maskKey)(String(cfg[key] ?? "")) : cfg[key];
|
|
528
528
|
console.log(typeof v === "object" ? JSON.stringify(v, null, 2) : String(v));
|
|
529
529
|
return;
|
|
530
530
|
}
|
|
531
531
|
console.log(util_1.ansi.bold("config") + util_1.ansi.gray(` (${(0, config_1.configPath)()})`));
|
|
532
532
|
for (const k of config_1.SETTABLE_KEYS) {
|
|
533
533
|
let v = cfg[k];
|
|
534
|
-
|
|
535
|
-
|
|
534
|
+
// Every secret-bearing key prints masked — `config list` output ends up
|
|
535
|
+
// in terminal scrollback and pasted bug reports.
|
|
536
|
+
if (/apikey|token|secret/i.test(k)) {
|
|
537
|
+
v = v ? (0, config_1.maskKey)(String(v)) : k === "apiKey" ? util_1.ansi.red("(not set)") : "(not set)";
|
|
538
|
+
}
|
|
536
539
|
console.log(` ${k.padEnd(18)} ${util_1.ansi.gray(String(v))}`);
|
|
537
540
|
}
|
|
538
541
|
return;
|
|
@@ -559,11 +562,25 @@ async function cmdConfig(rest, flags) {
|
|
|
559
562
|
console.log(util_1.ansi.gray(" verify it works: ") + "swarm models");
|
|
560
563
|
return;
|
|
561
564
|
}
|
|
565
|
+
if (sub === "unset") {
|
|
566
|
+
const key = rest[1];
|
|
567
|
+
if (!key)
|
|
568
|
+
throw new Error("usage: swarm config unset <key>");
|
|
569
|
+
// Only string-valued keys can sensibly clear to "" — numbers/enums keep
|
|
570
|
+
// their defaults via `set`.
|
|
571
|
+
const clearable = config_1.SETTABLE_KEYS.filter((k) => /apikey|token|secret|url|model/i.test(k));
|
|
572
|
+
if (!clearable.includes(key)) {
|
|
573
|
+
throw new Error(`not clearable. Clearable keys: ${clearable.join(", ")}`);
|
|
574
|
+
}
|
|
575
|
+
(0, config_1.saveConfig)({ [key]: "" });
|
|
576
|
+
console.log(util_1.ansi.green("✓ ") + `cleared ${key}`);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
562
579
|
if (sub === "path") {
|
|
563
580
|
console.log((0, config_1.configPath)());
|
|
564
581
|
return;
|
|
565
582
|
}
|
|
566
|
-
throw new Error("usage: swarm config [list|get <key>|set <key> <value>|path]");
|
|
583
|
+
throw new Error("usage: swarm config [list|get <key>|set <key> <value>|unset <key>|path]");
|
|
567
584
|
}
|
|
568
585
|
async function cmdModels() {
|
|
569
586
|
const cfg = (0, config_1.loadConfig)();
|
package/dist/config.js
CHANGED
|
@@ -33,7 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SETTABLE_KEYS = exports.SECRET_ENV_KEYS = exports.DEFAULTS = exports.DEFAULT_PRICING = void 0;
|
|
36
|
+
exports.SETTABLE_KEYS = exports.SECRET_ENV_KEYS = exports.DEFAULTS = exports.DEFAULT_WINDOWS = exports.DEFAULT_PRICING = void 0;
|
|
37
|
+
exports.contextLimitFor = contextLimitFor;
|
|
37
38
|
exports.home = home;
|
|
38
39
|
exports.runsDir = runsDir;
|
|
39
40
|
exports.runDir = runDir;
|
|
@@ -63,6 +64,20 @@ exports.DEFAULT_PRICING = {
|
|
|
63
64
|
"MiniMax-M2.1": { inMiss: 0.3, inHit: 0.03, out: 1.2 },
|
|
64
65
|
"MiniMax-M2": { inMiss: 0.3, inHit: 0.03, out: 1.2 },
|
|
65
66
|
};
|
|
67
|
+
exports.DEFAULT_WINDOWS = {
|
|
68
|
+
// tokens (June 2026 published limits; conservative where ranges exist)
|
|
69
|
+
"deepseek-v4-flash": 128_000,
|
|
70
|
+
"deepseek-v4-pro": 128_000,
|
|
71
|
+
"deepseek-chat": 128_000,
|
|
72
|
+
"deepseek-reasoner": 128_000,
|
|
73
|
+
"gpt-5.1": 272_000,
|
|
74
|
+
"gpt-5.1-mini": 272_000,
|
|
75
|
+
"claude-opus-4-8": 200_000,
|
|
76
|
+
"claude-sonnet-4-6": 200_000,
|
|
77
|
+
"claude-haiku-4-5": 200_000,
|
|
78
|
+
"MiniMax-M2.1": 192_000,
|
|
79
|
+
"MiniMax-M2": 192_000,
|
|
80
|
+
};
|
|
66
81
|
exports.DEFAULTS = {
|
|
67
82
|
provider: "deepseek",
|
|
68
83
|
providers: {},
|
|
@@ -105,7 +120,17 @@ exports.DEFAULTS = {
|
|
|
105
120
|
hubPort: 7777,
|
|
106
121
|
uiPort: 7780,
|
|
107
122
|
pricing: exports.DEFAULT_PRICING,
|
|
123
|
+
contextWindows: exports.DEFAULT_WINDOWS,
|
|
108
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* Effective compaction/trim threshold for a model: the configured limit,
|
|
127
|
+
* hard-capped by the model's known context window (15% headroom for output
|
|
128
|
+
* and estimation error). Models we don't know keep the configured limit.
|
|
129
|
+
*/
|
|
130
|
+
function contextLimitFor(cfg, model) {
|
|
131
|
+
const win = cfg.contextWindows[model];
|
|
132
|
+
return win ? Math.min(cfg.contextTokenLimit, Math.floor(win * 0.85)) : cfg.contextTokenLimit;
|
|
133
|
+
}
|
|
109
134
|
/**
|
|
110
135
|
* Env vars that must never leak into agent shell commands when they execute
|
|
111
136
|
* directly on the host: every provider key env plus the search/sandbox
|
|
@@ -163,6 +188,7 @@ function loadConfig() {
|
|
|
163
188
|
provider,
|
|
164
189
|
providers: file.providers || {},
|
|
165
190
|
pricing: { ...exports.DEFAULT_PRICING, ...(file.pricing || {}) },
|
|
191
|
+
contextWindows: { ...exports.DEFAULT_WINDOWS, ...(file.contextWindows || {}) },
|
|
166
192
|
apiKey: cred.apiKey || "",
|
|
167
193
|
baseUrl: cred.baseUrl || info.baseUrl,
|
|
168
194
|
};
|