@anyswarm/core 0.5.1 → 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/AGENTS.md +20 -5
- package/README.md +69 -55
- package/dist/examples/README.md +138 -77
- package/dist/examples/authoring/README.md +4 -4
- package/dist/examples/autoresearch/README.md +108 -16
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
- package/dist/examples/autoresearch/config.d.ts +48 -5
- package/dist/examples/autoresearch/config.js +57 -23
- package/dist/examples/autoresearch/demo.d.ts +12 -4
- package/dist/examples/autoresearch/demo.js +65 -22
- package/dist/examples/autoresearch/eject.json +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +14 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
- package/dist/examples/autoresearch/frontiercs2.js +71 -14
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +46 -0
- package/dist/examples/autoresearch/prepare.d.ts +105 -53
- package/dist/examples/autoresearch/prepare.js +126 -57
- package/dist/examples/autoresearch/project.d.ts +6 -95
- package/dist/examples/autoresearch/project.js +131 -45
- package/dist/examples/autoresearch/research-service.d.ts +16 -1
- package/dist/examples/autoresearch/research-service.js +84 -44
- package/dist/examples/code/README.md +25 -17
- package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
- package/dist/examples/code/config.d.ts +1 -0
- package/dist/examples/first-harness/AGENTS.md +25 -0
- package/dist/examples/first-harness/README.md +136 -0
- package/dist/examples/first-harness/config.d.ts +9 -8
- package/dist/examples/first-harness/config.js +33 -26
- package/dist/examples/first-harness/eject.json +14 -0
- package/dist/examples/first-harness/handoff.js +3 -3
- package/dist/examples/first-harness/harness.d.ts +14 -18
- package/dist/examples/first-harness/harness.js +102 -77
- package/dist/examples/first-harness/input/README.md +7 -0
- package/dist/examples/first-harness/session.js +2 -1
- package/dist/examples/first-harness/tsconfig.json +2 -1
- package/dist/examples/harness-session/README.md +4 -4
- package/dist/examples/lead-worker/README.md +1 -1
- package/dist/examples/lead-worker/project-config.d.ts +1 -0
- package/dist/examples/messages/README.md +2 -2
- package/dist/examples/notes/README.md +5 -5
- package/dist/examples/notes/config.d.ts +1 -0
- package/dist/examples/parallel-swarm/AGENTS.md +32 -0
- package/dist/examples/parallel-swarm/README.md +136 -0
- package/dist/examples/parallel-swarm/board-service.js +25 -8
- package/dist/examples/parallel-swarm/board.d.ts +31 -1
- package/dist/examples/parallel-swarm/board.js +98 -13
- package/dist/examples/parallel-swarm/config.d.ts +11 -0
- package/dist/examples/parallel-swarm/config.js +39 -0
- package/dist/examples/parallel-swarm/eject.json +5 -0
- package/dist/examples/parallel-swarm/harness.d.ts +26 -20
- package/dist/examples/parallel-swarm/harness.js +77 -76
- package/dist/examples/parallel-swarm/report.d.ts +12 -0
- package/dist/examples/parallel-swarm/report.js +30 -0
- package/dist/examples/peermesh/README.md +1 -1
- package/dist/examples/peermesh/project-config.d.ts +1 -0
- package/dist/examples/services/agent-control/README.md +1 -1
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +1 -1
- package/dist/examples/services/persistent-board/README.md +6 -3
- package/dist/examples/subagents/AGENTS.md +35 -0
- package/dist/examples/subagents/README.md +129 -93
- package/dist/examples/subagents/config.d.ts +2 -10
- package/dist/examples/subagents/config.js +9 -16
- package/dist/examples/subagents/eject.json +17 -0
- package/dist/examples/subagents/handoff-config.d.ts +41 -0
- package/dist/examples/subagents/handoff-config.js +13 -0
- package/dist/examples/subagents/model.d.ts +3 -0
- package/dist/examples/subagents/model.js +19 -0
- package/dist/examples/substrate/README.md +12 -6
- package/dist/examples/substrate/config.d.ts +1 -0
- package/dist/examples/substrate/project-config.d.ts +1 -0
- package/dist/examples/super/README.md +34 -22
- package/dist/examples/super/actions.d.ts +1 -1
- package/dist/examples/super/actions.js +11 -11
- package/dist/examples/super/config.js +3 -3
- package/dist/examples/super/eject.json +1 -1
- package/dist/examples/super/location.js +1 -1
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/project.d.ts +0 -107
- package/dist/examples/super/project.js +1 -3
- package/dist/examples/taskpool/README.md +1 -1
- package/dist/examples/taskpool/config.d.ts +1 -0
- package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
- package/dist/scripts/anyswarm-arguments.d.ts +7 -25
- package/dist/scripts/anyswarm-arguments.js +69 -97
- package/dist/scripts/anyswarm-eject.js +1 -1
- package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
- package/dist/scripts/anyswarm-harnesses.js +1 -22
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -291
- package/dist/scripts/anyswarm-launch.d.ts +6 -36
- package/dist/scripts/anyswarm-launch.js +32 -81
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +133 -0
- package/dist/scripts/anyswarm-project.d.ts +1 -9
- package/dist/scripts/anyswarm-project.js +40 -127
- package/dist/scripts/anyswarm-source-runner.js +9 -41
- package/dist/scripts/anyswarm.js +6 -26
- package/dist/scripts/build-provenance.json +1 -1
- package/dist/scripts/generate-architecture-coverage.js +1 -1
- package/dist/scripts/generate-architecture-prompts.js +18 -10
- package/dist/scripts/local-environment.d.ts +13 -7
- package/dist/scripts/local-environment.js +73 -21
- package/dist/scripts/local-setup.d.ts +3 -0
- package/dist/scripts/local-setup.js +153 -118
- package/dist/scripts/pack-release.js +31 -4
- package/dist/src/core/index.js +1 -1
- package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
- package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
- package/dist/src/core/sandbox/sandbox-connection.js +22 -7
- package/dist/src/core/worker-image.js +1 -1
- package/dist/src/harness/project-harness.d.ts +1 -0
- package/dist/src/harness/project-harness.js +5 -4
- package/dist/src/harness/project-rpc-client.js +19 -0
- package/dist/src/harness/project-runtime.js +3 -1
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +26 -8
- package/dist/src/trace-viewer/command.mjs +6 -3
- package/dist/src/trace-viewer/public/app.js +239 -59
- package/dist/src/trace-viewer/public/index.html +5 -0
- package/dist/src/trace-viewer/public/style.css +22 -0
- package/dist/src/trace-viewer/reader.mjs +242 -26
- package/dist/src/trace-viewer/run-root.d.mts +1 -0
- package/dist/src/trace-viewer/run-root.mjs +7 -0
- package/dist/src/trace-viewer/server.mjs +3 -1
- package/docs/INDEX.md +11 -9
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/06-observability-experiments.md +21 -7
- package/docs/architecture/07-run-configuration.md +118 -19
- package/docs/architecture/08-prompts.md +21 -2
- package/docs/architecture/10-service-api-reference.md +12 -5
- package/docs/architecture/12-code-coverage.md +157 -115
- package/docs/architecture/15-core-runtime.md +1 -1
- package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
- package/docs/architecture/17-harness-reporting.md +79 -1
- package/docs/architecture/22-website.md +52 -20
- package/docs/architecture/23-project-harness.md +109 -37
- package/docs/architecture/26-code.md +20 -5
- package/docs/architecture/27-personal.md +23 -8
- package/docs/architecture/28-autoresearch.md +18 -12
- package/docs/architecture/INDEX.md +1 -2
- package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
- package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
- package/docs/architecture/prompts/22-autoresearch.md +9 -2
- package/docs/architecture/prompts/source-manifest.json +76 -52
- package/docs/architecture/source-map.json +445 -105
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +3 -3
- package/docs/designs/core-harness/README.md +2 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/autoresearch.md +41 -0
- package/docs/en/blog/100b-tokens.md +157 -0
- package/docs/en/build-your-harness.md +47 -22
- package/docs/en/changelog.md +29 -1
- package/docs/en/first-harness.md +40 -32
- package/docs/en/harnesses/index.md +23 -23
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +10 -31
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +30 -5
- package/docs/en/overview.md +22 -22
- package/docs/en/quickstart.md +69 -56
- package/docs/en/reference/api.md +1 -1
- package/docs/en/reference/cli.md +47 -85
- package/docs/en/sandbox.md +3 -3
- package/docs/en/trace-viewer.md +32 -12
- package/docs/operations/trace-viewer.md +26 -11
- package/docs/third-party-notices.md +0 -1
- package/docs/workflows/development.md +160 -118
- package/docs/workflows/release-and-docs-versioning.md +207 -54
- package/docs/workflows/release-cli-acceptance.md +162 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/autoresearch.md +41 -0
- package/docs/zh/blog/100b-tokens.md +102 -0
- package/docs/zh/build-your-harness.md +48 -23
- package/docs/zh/changelog.md +29 -1
- package/docs/zh/first-harness.md +43 -35
- package/docs/zh/harnesses/index.md +23 -23
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +10 -31
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +30 -5
- package/docs/zh/overview.md +23 -23
- package/docs/zh/quickstart.md +66 -57
- package/docs/zh/reference/api.md +1 -1
- package/docs/zh/reference/cli.md +19 -79
- package/docs/zh/sandbox.md +3 -3
- package/docs/zh/trace-viewer.md +32 -12
- package/examples/README.md +138 -77
- package/examples/authoring/README.md +4 -4
- package/examples/autoresearch/README.md +108 -16
- package/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
- package/examples/autoresearch/config.ts +64 -25
- package/examples/autoresearch/demo.ts +75 -22
- package/examples/autoresearch/eject.json +2 -0
- package/examples/autoresearch/frontiercs2-config.ts +15 -0
- package/examples/autoresearch/frontiercs2.ts +64 -11
- package/examples/autoresearch/prepare-demo.ts +44 -0
- package/examples/autoresearch/prepare.ts +134 -60
- package/examples/autoresearch/project.ts +120 -44
- package/examples/autoresearch/research-service.ts +91 -41
- package/examples/code/README.md +25 -17
- package/examples/code/REQUIREMENTS.zh.md +3 -3
- package/examples/first-harness/AGENTS.md +25 -0
- package/examples/first-harness/README.md +136 -0
- package/examples/first-harness/config.ts +41 -27
- package/examples/first-harness/eject.json +14 -0
- package/examples/first-harness/handoff.ts +3 -3
- package/examples/first-harness/harness.ts +104 -72
- package/examples/first-harness/input/README.md +7 -0
- package/examples/first-harness/session.ts +2 -1
- package/examples/first-harness/tsconfig.json +2 -1
- package/examples/harness-session/README.md +4 -4
- package/examples/lead-worker/README.md +1 -1
- package/examples/messages/README.md +2 -2
- package/examples/notes/README.md +5 -5
- package/examples/parallel-swarm/AGENTS.md +32 -0
- package/examples/parallel-swarm/README.md +136 -0
- package/examples/parallel-swarm/board-service.ts +28 -9
- package/examples/parallel-swarm/board.ts +107 -13
- package/examples/parallel-swarm/config.ts +47 -0
- package/examples/parallel-swarm/eject.json +5 -0
- package/examples/parallel-swarm/harness.ts +83 -71
- package/examples/parallel-swarm/report.ts +33 -0
- package/examples/peermesh/README.md +1 -1
- package/examples/services/agent-control/README.md +1 -1
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +1 -1
- package/examples/services/persistent-board/README.md +6 -3
- package/examples/subagents/AGENTS.md +35 -0
- package/examples/subagents/README.md +129 -93
- package/examples/subagents/config.ts +9 -15
- package/examples/subagents/eject.json +17 -0
- package/examples/subagents/handoff-config.ts +14 -0
- package/examples/subagents/model.ts +20 -0
- package/examples/substrate/README.md +12 -6
- package/examples/super/README.md +34 -22
- package/examples/super/actions.ts +11 -11
- package/examples/super/config.ts +3 -3
- package/examples/super/eject.json +1 -1
- package/examples/super/location.ts +1 -1
- package/examples/super/operator.ts +28 -0
- package/examples/super/project.ts +1 -3
- package/examples/taskpool/README.md +1 -1
- package/npm-shrinkwrap.development.json +46 -1538
- package/npm-shrinkwrap.json +10 -43
- package/package.development.json +3 -6
- package/package.json +3 -5
- package/scripts/anyswarm-arguments.ts +67 -96
- package/scripts/anyswarm-eject.ts +1 -1
- package/scripts/anyswarm-harnesses.ts +1 -18
- package/scripts/anyswarm-installation.ts +18 -294
- package/scripts/anyswarm-launch.ts +30 -102
- package/scripts/anyswarm-progress.ts +125 -0
- package/scripts/anyswarm-project.ts +31 -123
- package/scripts/anyswarm-source-runner.ts +9 -36
- package/scripts/anyswarm.ts +4 -24
- package/scripts/generate-architecture-coverage.ts +1 -1
- package/scripts/generate-architecture-prompts.ts +21 -10
- package/scripts/local-environment.ts +79 -21
- package/scripts/local-setup.ts +150 -105
- package/scripts/pack-release.ts +28 -4
- package/src/core/index.ts +1 -1
- package/src/core/sandbox/opensandbox-backend.ts +10 -4
- package/src/core/sandbox/sandbox-connection.ts +22 -7
- package/src/core/worker-image.ts +1 -1
- package/src/harness/project-harness.ts +5 -4
- package/src/harness/project-rpc-client.ts +23 -0
- package/src/harness/project-runtime.ts +2 -1
- package/src/harness/typescript-loader.ts +28 -8
- package/src/trace-viewer/command.mjs +6 -3
- package/src/trace-viewer/public/app.js +239 -59
- package/src/trace-viewer/public/index.html +5 -0
- package/src/trace-viewer/public/style.css +22 -0
- package/src/trace-viewer/reader.mjs +242 -26
- package/src/trace-viewer/run-root.d.mts +1 -0
- package/src/trace-viewer/run-root.mjs +7 -0
- package/src/trace-viewer/server.mjs +3 -1
- package/dist/scripts/anyswarm-applications.d.ts +0 -19
- package/dist/scripts/anyswarm-applications.js +0 -19
- package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
- package/dist/scripts/anyswarm-tui-config.js +0 -189
- package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
- package/dist/scripts/anyswarm-tui-session.js +0 -304
- package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
- package/dist/scripts/anyswarm-tui-terminal.js +0 -154
- package/dist/scripts/anyswarm-tui.d.ts +0 -2
- package/dist/scripts/anyswarm-tui.js +0 -1012
- package/docs/architecture/25-foreground-tui.md +0 -51
- package/scripts/anyswarm-applications.ts +0 -39
- package/scripts/anyswarm-tui-config.ts +0 -174
- package/scripts/anyswarm-tui-session.ts +0 -295
- package/scripts/anyswarm-tui-terminal.ts +0 -147
- package/scripts/anyswarm-tui.ts +0 -912
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { createRuntime, createSandbox, resolveSandboxConnection, runInput, ServiceRegistry, workerImageFor, } from '@anyswarm/core';
|
|
1
|
+
import { createRuntime, createSandbox, projectConfiguration, ProjectPreflightError, runInput, ServiceRegistry, } from '@anyswarm/core';
|
|
5
2
|
import { FindingsBoard } from './board.js';
|
|
6
3
|
import { boardService } from './board-service.js';
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
import { checkReportExport } from './report.js';
|
|
5
|
+
const researcherPrompt = 'Investigate the user\'s question in the captured local repository. Publish concrete findings with swarm service invoke board publish. Each finding needs evidence: relative path, 1-based startLine/endLine, and an exact short excerpt (1–40 lines, at most 4096 bytes; omit the final newline). Distinguish facts, inferences and unverified questions in the summary. Do not modify source files or invent a defect. Read peer findings with swarm service invoke board search.';
|
|
6
|
+
const synthesizerPrompt = 'Use swarm service invoke board search to read the research and reviews. Answer the user\'s question in report.md: give conclusions, relative source paths and line numbers, finding IDs, disagreements and unverified items. Separate facts from inference. The host checks the Board\'s source locations and the report export; it does not establish that your conclusions are correct. Do not modify other project files.';
|
|
7
|
+
const researchFocuses = ['Entry points, configuration and how to run the relevant behavior.', 'Core modules, data flow and dependencies relevant to the question.', 'Existing tests, observable guarantees and checks still needed.'];
|
|
8
|
+
const reviewInput = 'Read the other researchers\' first-round findings. Check their source evidence and publish at least one NEW follow-up addressing a gap, disagreement or corroboration relevant to the user\'s question. Include your own exact source evidence and cite at least one first-round finding by ANOTHER author in cites. A first-round publication does not count as this review.';
|
|
9
|
+
const synthesisInput = 'Read the Board, integrate the research and cross-author reviews, and write report.md for the task below. Cite source paths, line numbers and finding IDs; mark anything not verified.';
|
|
11
10
|
const parallelSwarm = {
|
|
12
11
|
id: 'parallel-swarm', apiVersion: 1,
|
|
13
12
|
async run(context) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const config = await projectConfiguration(context, () => import('./config.js'));
|
|
14
|
+
const { image, model = 'default', turnTimeoutMs = 120_000, closeTimeoutMs = 60_000 } = config;
|
|
15
|
+
if (!image || ![turnTimeoutMs, closeTimeoutMs].every(ms => Number.isSafeInteger(ms) && ms > 0 && ms <= 2_147_483_647)) {
|
|
16
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Parallel Swarm needs an image and finite positive turn/close time limits.');
|
|
17
|
+
}
|
|
18
|
+
const board = new FindingsBoard(context.initial.files);
|
|
18
19
|
const services = new ServiceRegistry();
|
|
19
20
|
services.register('board', boardService(board), { toolMode: 'cli' });
|
|
20
|
-
const { image: configuredImage, advertiseHost, publicUrl, executor: setupExecutor, endpointSource: _source, ...sandbox } = resolveSandboxConnection();
|
|
21
|
-
const executor = process.env.ANYSWARM_EXECUTOR ?? setupExecutor ?? 'pi';
|
|
22
|
-
if (executor !== undefined && executor !== 'pi' && executor !== 'codex')
|
|
23
|
-
throw new Error('Select pi or codex with ANYSWARM_EXECUTOR.');
|
|
24
|
-
const image = configuredImage ?? workerImageFor(executor);
|
|
25
|
-
const token = process.env.ANYSWARM_MODEL_TOKEN;
|
|
26
|
-
const runtime = await createRuntime({
|
|
27
|
-
sandbox: createSandbox(sandbox), connection: { advertiseHost, publicUrl }, executor, services, maxAgents: 4, outputDir: context.outputDir,
|
|
28
|
-
models: { default: {
|
|
29
|
-
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
|
|
30
|
-
model: process.env.ANYSWARM_MODEL_ID ?? 'gpt-5-mini',
|
|
31
|
-
upstream: { url, headers: token ? { authorization: `Bearer ${token}` } : {} },
|
|
32
|
-
} },
|
|
33
|
-
profiles: {
|
|
34
|
-
researcher: { addedSystemPrompt: researcherPrompt, model: 'default', image, writable: false,
|
|
35
|
-
services: { board: ['publish', 'search'] } },
|
|
36
|
-
synthesizer: { addedSystemPrompt: synthesizerPrompt, model: 'default', image, writable: true,
|
|
37
|
-
services: { board: ['search'] },
|
|
38
|
-
collect: { paths: ['report.md'], includeGit: false, maxBytes: 1_048_576, required: true } },
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
const turn = { signal: context.signal, timeoutMs: 120_000 };
|
|
42
|
-
let synthId;
|
|
43
|
-
let failure;
|
|
44
|
-
let cleanup;
|
|
45
21
|
let unobserve;
|
|
22
|
+
let synthId;
|
|
23
|
+
let researchChecked = false;
|
|
24
|
+
let reviewChecked = false;
|
|
25
|
+
const checks = {
|
|
26
|
+
report: { status: 'not-run', reason: 'SYNTHESIZER_NOT_STARTED' },
|
|
27
|
+
};
|
|
46
28
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
const result = await context.runWithRuntime({
|
|
30
|
+
closeTimeoutMs,
|
|
31
|
+
createRuntime: () => createRuntime({
|
|
32
|
+
sandbox: createSandbox(config.sandbox), connection: config.connection, executor: config.executor,
|
|
33
|
+
models: config.models, filePolicy: config.filePolicy, services, maxAgents: 4, outputDir: context.outputDir,
|
|
34
|
+
profiles: {
|
|
35
|
+
researcher: { addedSystemPrompt: researcherPrompt, model, image, writable: false,
|
|
36
|
+
services: { board: ['publish', 'search'] } },
|
|
37
|
+
synthesizer: { addedSystemPrompt: synthesizerPrompt, model, image, writable: true,
|
|
38
|
+
services: { board: ['search'] },
|
|
39
|
+
collect: { paths: ['report.md'], includeGit: false, maxBytes: 1_048_576, required: true } },
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
async run(runtime) {
|
|
43
|
+
unobserve = context.registerAgentControls({ runtime });
|
|
44
|
+
context.markRunning();
|
|
45
|
+
const turn = { signal: context.signal, timeoutMs: turnTimeoutMs };
|
|
46
|
+
context.signal.throwIfAborted();
|
|
47
|
+
const peers = await Promise.all(researchFocuses.map((_, index) => runtime.spawn({ requestId: `spawn-r${index + 1}`, profile: 'researcher', files: context.initial.files })));
|
|
48
|
+
board.beginResearch(peers.map(peer => peer.id));
|
|
49
|
+
await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, `${context.input.prompt}\n\nYour focus: ${researchFocuses[index]}\nPublish at least one source-backed finding.`, { ...turn, requestId: `research-${index + 1}` })));
|
|
50
|
+
board.beginReview();
|
|
51
|
+
researchChecked = true;
|
|
52
|
+
await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, reviewInput, { ...turn, requestId: `review-${index + 1}` })));
|
|
53
|
+
board.finishReview();
|
|
54
|
+
reviewChecked = true;
|
|
55
|
+
await Promise.all(peers.map(peer => runtime.stop(peer.id, { timeoutMs: closeTimeoutMs })));
|
|
56
|
+
context.signal.throwIfAborted();
|
|
57
|
+
const synth = await runtime.spawn({ requestId: 'spawn-synthesizer', profile: 'synthesizer', files: context.initial.files });
|
|
58
|
+
synthId = synth.id;
|
|
59
|
+
checks.report = { status: 'pending', reason: 'REPORT_EXPORT_PENDING' };
|
|
60
|
+
await runInput(runtime, synth.id, `${synthesisInput}\n\n${context.input.prompt}`, { ...turn, requestId: 'synthesize' });
|
|
61
|
+
return { synthesizerId: synthId, contributions: board.contributions() };
|
|
62
|
+
},
|
|
63
|
+
// A failed report check is business evidence, not a thrown cleanup error.
|
|
64
|
+
afterClose: async (receipt) => { checks.report = await checkReportExport(receipt, synthId, context.initial.files); },
|
|
65
|
+
detail: () => {
|
|
66
|
+
// Keep the final projection stable if a post-close read outlives its wait.
|
|
67
|
+
checks.finalized = { ...checks.report };
|
|
68
|
+
return { board: board.exportState(), report: checks.finalized };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const report = checks.finalized;
|
|
72
|
+
const reportFailed = report.status === 'unverified';
|
|
73
|
+
return {
|
|
74
|
+
...result,
|
|
75
|
+
...(result.outcome === 'completed' && reportFailed ? { outcome: 'failed', reason: report.reason } : {}),
|
|
76
|
+
acceptance: {
|
|
77
|
+
status: researchChecked && reviewChecked && report.status === 'verified' ? 'verified' : report.status === 'pending' ? 'pending' : 'unverified',
|
|
78
|
+
scope: 'participant-contributions, cross-author-reviews, Board-source-references, report-export',
|
|
79
|
+
research: researchChecked ? 'verified' : 'unverified', review: reviewChecked ? 'verified' : 'unverified',
|
|
80
|
+
sourceReferences: board.search().length ? 'verified' : 'not-run', report: { ...report }, semanticCorrectness: 'not-run',
|
|
81
|
+
},
|
|
82
|
+
artifacts: [...result.artifacts, ...(report.status === 'verified' ? [{ agentId: synthId, kind: 'report', ...report }] : [])],
|
|
83
|
+
...(synthId ? { export: { ...result.export, status: result.export?.status === 'pending' || report.status === 'pending'
|
|
84
|
+
? 'pending' : report.status === 'verified' ? 'complete' : 'failed' } } : {}),
|
|
85
|
+
};
|
|
64
86
|
}
|
|
65
87
|
finally {
|
|
66
|
-
|
|
67
|
-
cleanup = await runtime.close({ timeoutMs: 60_000 });
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
unobserve?.();
|
|
71
|
-
}
|
|
88
|
+
unobserve?.();
|
|
72
89
|
}
|
|
73
|
-
const directory = cleanup.agents.find(agent => agent.agentId === synthId)?.artifacts.find(path => path.endsWith('/artifacts/files'));
|
|
74
|
-
const file = directory && join(directory, 'report.md');
|
|
75
|
-
const bytes = file ? await readFile(file).catch(() => undefined) : undefined;
|
|
76
|
-
const artifact = file && bytes && bytes.toString('utf8').trim() ? {
|
|
77
|
-
path: file, sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
78
|
-
} : undefined;
|
|
79
|
-
const findings = board.search();
|
|
80
|
-
return {
|
|
81
|
-
outcome: context.signal.aborted ? 'cancelled' : failure || !artifact ? 'failed' : 'completed',
|
|
82
|
-
reason: failure ?? (artifact ? 'report-verified' : 'report-missing'),
|
|
83
|
-
result: { runtimeId: runtime.id, findings: findings.length, citedFindings: findings.filter(finding => finding.cites.length > 0).length },
|
|
84
|
-
acceptance: { status: artifact ? 'verified' : 'unverified' },
|
|
85
|
-
artifacts: artifact ? [artifact] : [],
|
|
86
|
-
...(synthId ? { export: { status: artifact ? 'complete' : 'failed' } } : {}),
|
|
87
|
-
cleanup: { status: cleanup.cleanup, pending: cleanup.pending.map(({ id, kind, action }) => ({ id, kind, action })) },
|
|
88
|
-
};
|
|
89
90
|
},
|
|
90
91
|
};
|
|
91
92
|
export default parallelSwarm;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CloseReceipt, FileTree } from '@anyswarm/core';
|
|
2
|
+
export type ReportCheck = {
|
|
3
|
+
status: 'not-run' | 'pending' | 'unverified';
|
|
4
|
+
reason: string;
|
|
5
|
+
} | {
|
|
6
|
+
status: 'verified';
|
|
7
|
+
path: string;
|
|
8
|
+
sha256: string;
|
|
9
|
+
bytes: number;
|
|
10
|
+
};
|
|
11
|
+
/** A readable, newly written report is an export check, not a semantic review. */
|
|
12
|
+
export declare function checkReportExport(receipt: CloseReceipt, agentId: string | undefined, initial: FileTree): Promise<ReportCheck>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
/** A readable, newly written report is an export check, not a semantic review. */
|
|
5
|
+
export async function checkReportExport(receipt, agentId, initial) {
|
|
6
|
+
if (!agentId)
|
|
7
|
+
return { status: 'not-run', reason: 'SYNTHESIZER_NOT_STARTED' };
|
|
8
|
+
const agent = receipt.agents.find(agent => agent.agentId === agentId);
|
|
9
|
+
const directory = agent?.artifacts.find(path => path.endsWith(join('artifacts', 'files')));
|
|
10
|
+
if (!directory) {
|
|
11
|
+
const pending = !agent || agent.execution !== 'stopped' || agent.cleanup === 'pending' ||
|
|
12
|
+
receipt.pending.some(entry => entry.kind === 'agent' && entry.id === agentId);
|
|
13
|
+
return { status: pending ? 'pending' : 'unverified', reason: pending ? 'REPORT_EXPORT_PENDING' : 'REPORT_MISSING' };
|
|
14
|
+
}
|
|
15
|
+
const path = join(directory, 'report.md');
|
|
16
|
+
try {
|
|
17
|
+
const bytes = await readFile(path);
|
|
18
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
19
|
+
if (!text.trim())
|
|
20
|
+
return { status: 'unverified', reason: 'REPORT_EMPTY' };
|
|
21
|
+
const before = initial['report.md'];
|
|
22
|
+
if (before && bytes.equals(Buffer.from(before.data, before.encoding === 'base64' ? 'base64' : 'utf8'))) {
|
|
23
|
+
return { status: 'unverified', reason: 'REPORT_UNCHANGED' };
|
|
24
|
+
}
|
|
25
|
+
return { status: 'verified', path, sha256: createHash('sha256').update(bytes).digest('hex'), bytes: bytes.length };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { status: 'unverified', reason: 'REPORT_UNREADABLE' };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -70,7 +70,7 @@ repository sources.
|
|
|
70
70
|
|
|
71
71
|
```sh
|
|
72
72
|
npm init -y
|
|
73
|
-
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.
|
|
73
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
|
|
74
74
|
npm install --save-dev typescript @types/node
|
|
75
75
|
sdk=node_modules/@anyswarm/core
|
|
76
76
|
cp -R "$sdk"/examples/peermesh demo
|
|
@@ -7,6 +7,7 @@ export declare function peerMeshConfig(durationMs?: number): {
|
|
|
7
7
|
useServerProxy: boolean | undefined;
|
|
8
8
|
egressMode: "dns+nft" | undefined;
|
|
9
9
|
endpointHost: undefined;
|
|
10
|
+
preparedImage?: string | undefined;
|
|
10
11
|
timeoutSeconds: number;
|
|
11
12
|
resourceLimits: {
|
|
12
13
|
cpu: string;
|
|
@@ -10,7 +10,7 @@ Run these commands in an empty directory. To use a source build, set `ANYSWARM_S
|
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/agent-control demo
|
|
16
16
|
cd demo
|
|
@@ -39,7 +39,7 @@ process. See the maintained [Mathlib service implementation](../../../docs/archi
|
|
|
39
39
|
|
|
40
40
|
To run the host without a container after building the checkout, use
|
|
41
41
|
`npm run service:mathlib-search` from the root, or
|
|
42
|
-
|
|
42
|
+
`node ../../../dist/scripts/anyswarm.js run ./main.ts` from this directory.
|
|
43
43
|
The caller supplies the host token with `MATHLIB_SEARCH_TOKEN`, and configures
|
|
44
44
|
the endpoint in its own service adapter. The application/operator owns the
|
|
45
45
|
external provider's lifecycle and persistent data; Runtime close does not remove it.
|
|
@@ -10,7 +10,7 @@ Use Linux with Node 24 or later. Run these commands in an empty directory. To us
|
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/mcp-managed demo
|
|
16
16
|
cd demo
|
|
@@ -10,7 +10,7 @@ Use Node 24 or later. The HTTP variant also needs Python 3. Run these commands i
|
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/persistent-board demo
|
|
16
16
|
cd demo
|
|
@@ -56,10 +56,13 @@ Open the completed Run, expand **Service states**, and inspect the Board export.
|
|
|
56
56
|
Copy this example from the installed SDK as shown above. Configure OpenSandbox and select an installed Worker with setup or `ANYSWARM_WORKER_IMAGE`. Open the example in a regular terminal and run:
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
|
-
|
|
59
|
+
anyswarm --harness ./live.ts --mode rpc --lifetime interactive
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Use a [Harness RPC client](../../harness-session/README.md) to start the Run
|
|
63
|
+
and submit two short findings with its input operation. Each commit emits the
|
|
64
|
+
row ID and updates the committed count. Stop the Session, then inspect its saved
|
|
65
|
+
records with `anyswarm trace`.
|
|
63
66
|
|
|
64
67
|
## Author a different Service
|
|
65
68
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Customize this Subagents Harness
|
|
2
|
+
|
|
3
|
+
This file is for a Coding Agent editing an exported application. Start by reading
|
|
4
|
+
`README.md`, `project.ts`, `business.ts`, and `config.ts`. Read the installed
|
|
5
|
+
`@anyswarm/core` package-root TypeScript declarations for exact SDK signatures.
|
|
6
|
+
|
|
7
|
+
- Keep the application in ordinary TypeScript. `project.ts` exports the public
|
|
8
|
+
`Harness`; one Runtime owns Root and its children. Do not create a Runtime for
|
|
9
|
+
every Agent or add a second session/workflow abstraction.
|
|
10
|
+
- `config.ts` owns model, executor, Sandbox, capacity and deadlines. Respect the
|
|
11
|
+
user's saved setup and explicit configuration. Keep tokens in the host
|
|
12
|
+
environment; never put credentials in prompts, seed files or reports.
|
|
13
|
+
- `business.ts` assembles Profiles and Services. The controller in
|
|
14
|
+
`harness/controller.ts` owns named children, messages, follow-up and closure.
|
|
15
|
+
The Service adapter gets the caller from the authenticated Bridge; never trust
|
|
16
|
+
an author or parent supplied in Agent text.
|
|
17
|
+
- Initial project files are captured once and passed to separate private
|
|
18
|
+
Sandboxes. A child message does not synchronize files. Root must integrate
|
|
19
|
+
contributions and write the requested deliverable in its own directory.
|
|
20
|
+
- Preserve accepted/unknown input receipts, cancellation, bounded close and raw
|
|
21
|
+
export/cleanup receipts. An unknown write is reconciled with its original
|
|
22
|
+
request ID. Do not silently retry it with a new identity.
|
|
23
|
+
- Define the application's actual output and business checks before editing.
|
|
24
|
+
Agent settlement and file presence do not establish correctness. Generic
|
|
25
|
+
Subagents returns `acceptance: not-run`; add a domain check only when its
|
|
26
|
+
contract is explicit. Keep business failure separate from cleanup failure.
|
|
27
|
+
- Read `anyswarm-source.json` for the SDK identity. Install with `npm install`
|
|
28
|
+
and run with the local `npm start` so source and SDK stay matched. Change the
|
|
29
|
+
visible source here, rather than wrapping an inaccessible bundled Harness.
|
|
30
|
+
|
|
31
|
+
Use a real input directory and question for manual acceptance. Verify the
|
|
32
|
+
requested members contributed, inspect citations against the captured input,
|
|
33
|
+
read the exported result, and check cleanup. Deterministic test fixtures verify
|
|
34
|
+
protocol and failure handling; they are not evidence of model quality. Report
|
|
35
|
+
which checks ran and any remaining real-model acceptance separately.
|
|
@@ -1,109 +1,145 @@
|
|
|
1
|
-
# Subagents
|
|
1
|
+
# Subagents: a repository handoff with delegated investigation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Give Root a real local repository and an engineering question. It can delegate
|
|
4
|
+
independent reading to named children in private Sandboxes, receive their
|
|
5
|
+
findings through the host collaboration Service, and integrate the result.
|
|
6
|
+
The same general Harness supports other tasks; it does not hardcode a team size
|
|
7
|
+
or a report format.
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
for Sandbox and model configuration. In an empty directory outside the checkout,
|
|
7
|
-
install the SDK and copy its matching example sources. Set `ANYSWARM_SDK_ARCHIVE`
|
|
8
|
-
to a verified archive's absolute path to use a candidate built from current
|
|
9
|
-
repository sources.
|
|
9
|
+
## Run on your repository
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
cd demo
|
|
18
|
-
npm run check
|
|
19
|
-
npm run build
|
|
20
|
-
npm run start -- --cwd /absolute/path/to/project \
|
|
21
|
-
--prompt 'Inspect the project, delegate an independent check and integrate the result'
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Root receives the prompt and can delegate to children with separate Sandbox
|
|
25
|
-
directories. Each child starts with the captured project tree. The example
|
|
26
|
-
starts its own in-process collaboration Service. Read `project-run.json` for
|
|
27
|
-
the result and its report paths. The captured input project stays writable outside the run and the host does not write to it. The host exports files and releases its Sandbox resources on
|
|
28
|
-
close. See the [mechanism guide](../../docs/en/harnesses/subagents.md).
|
|
29
|
-
|
|
30
|
-
## Fixed and interactive host demonstration
|
|
31
|
-
|
|
32
|
-
Use Node.js 22.19 or newer and npm on the Linux Controller. If you have a compatible Worker image and an OpenSandbox provider, build from the checkout root.
|
|
11
|
+
Install the CLI and complete `anyswarm setup` first. Set the host model route
|
|
12
|
+
(`ANYSWARM_MODEL_URL`, `ANYSWARM_MODEL_ID` and, when needed,
|
|
13
|
+
`ANYSWARM_MODEL_TOKEN`). The model must support tool calls and the selected
|
|
14
|
+
executor's protocol. Setup supplies the saved Sandbox connection and executor;
|
|
15
|
+
an explicit environment setting takes precedence. No separate collaboration
|
|
16
|
+
server, Git forge, database or chat service is required.
|
|
33
17
|
|
|
34
18
|
```sh
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
If you need to prepare the host, run `./scripts/setup` from the checkout root in place of the install and build commands. It builds the checkout, prepares the Worker and OpenSandbox, and verifies them with a local Responses endpoint. The setup JSON reports the image ID as `worker.id`. [Host requirements and diagnostics](../../docs/architecture/07-run-configuration.md#local-setup-and-doctor)
|
|
41
|
-
|
|
42
|
-
Create `examples/subagents/.env` with your Worker image ID and a streaming `/v1/responses` endpoint that accepts `k3` and supports tool calls. Fill in the token if the endpoint requires bearer authentication.
|
|
19
|
+
anyswarm --harness subagents \
|
|
20
|
+
--cwd /absolute/path/to/repository \
|
|
21
|
+
--prompt 'Prepare an engineering handoff for this repository. Delegate entry points, running and configuration to one child, and modules, data flow and tests to another. Review their findings against the source and integrate report.md. Cite relative file paths and line ranges for important claims. Separate observed facts, inferences and checks not performed. Only produce the report; do not modify project source.' \
|
|
22
|
+
--output-dir /absolute/path/to/runs
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
ANYSWARM_SUBAGENTS_IMAGE="sha256:<your-worker-image-id>"
|
|
46
|
-
ANYSWARM_SUBAGENTS_MODEL_URL="https://your-gateway.example/v1/responses"
|
|
47
|
-
ANYSWARM_SUBAGENTS_MODEL_TOKEN=""
|
|
24
|
+
anyswarm trace --root /absolute/path/to/runs --open
|
|
48
25
|
```
|
|
49
26
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
27
|
+
This asks for two child contributions because the question has two useful
|
|
28
|
+
investigation areas. Root chooses how to delegate through its normal tools.
|
|
29
|
+
For a change investigation, replace the prompt with the actual planned change,
|
|
30
|
+
the behavior that must remain compatible, and the questions you need answered.
|
|
31
|
+
A Git diff or a specially prepared repository is not required.
|
|
32
|
+
|
|
33
|
+
### Input, output and checks
|
|
34
|
+
|
|
35
|
+
- The host captures a fixed input tree and records its paths, modes and SHA-256
|
|
36
|
+
values in `initial-files.json`. Root and children receive private copies of
|
|
37
|
+
that tree. Subsequent local edits are not synchronized into this Run.
|
|
38
|
+
- Child work is communicated through messages. A child-written file is not
|
|
39
|
+
automatically present in Root's directory. Root must write `report.md` in its
|
|
40
|
+
own directory for this task.
|
|
41
|
+
- The default project entry requires collection of Root's tree, excluding Git,
|
|
42
|
+
with a 16 MiB limit. Read the actual artifact paths in `project-run.json` or
|
|
43
|
+
the Trace Viewer; `report.md` is inside Root's exported `artifacts/files/`
|
|
44
|
+
directory. Export does not overwrite the user's local repository.
|
|
45
|
+
- Agent completion, required file export, business acceptance and cleanup are
|
|
46
|
+
separate. The generic Harness returns **`acceptance: not-run`**. It does not
|
|
47
|
+
automatically prove source citations, architectural explanations or test
|
|
48
|
+
claims. Compare the report with the captured source and the child records.
|
|
49
|
+
- A required export that cannot be confirmed or a Sandbox that cannot be
|
|
50
|
+
released stays pending in its original receipt. A final Root reply is not
|
|
51
|
+
proof that cleanup completed.
|
|
52
|
+
|
|
53
|
+
The default limits are four live Agents including Root, depth three, 120 seconds
|
|
54
|
+
of work and a separate 30-second close allowance. These are limits, not a promise
|
|
55
|
+
that every repository can be investigated in that time. Use a focused directory
|
|
56
|
+
or increase the explicit configuration budget for a larger investigation.
|
|
57
|
+
|
|
58
|
+
## Export and customize the full source
|
|
59
|
+
|
|
60
|
+
The `subagents` source export is introduced by the examples update in #335; use
|
|
61
|
+
a candidate containing this directory's `eject.json`. The released 0.5.2 CLI
|
|
62
|
+
already supports the built-in run above, but does not contain this new manifest.
|
|
79
63
|
|
|
80
64
|
```sh
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
anyswarm eject subagents --dir ./my-subagents
|
|
66
|
+
cd my-subagents
|
|
67
|
+
npm install
|
|
68
|
+
npm start -- --cwd /absolute/path/to/repository \
|
|
69
|
+
--prompt 'Investigate the impact of changing our configuration loading order. Delegate independent checks, cite the source and write report.md.' \
|
|
70
|
+
--output-dir /absolute/path/to/runs
|
|
84
71
|
```
|
|
85
72
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
Read the exported `AGENTS.md` with your Coding Agent. All collaboration source is
|
|
74
|
+
local and editable; the export does not call a hidden bundled application.
|
|
75
|
+
`anyswarm-source.json` and `.anyswarm-sdk/core.tgz` bind the source to the SDK
|
|
76
|
+
candidate that exported it. Run the local `npm start` after installing that
|
|
77
|
+
archive, including when moving the project to another machine.
|
|
78
|
+
|
|
79
|
+
For a report-only investigation, append `--config ./handoff-config.ts` to the
|
|
80
|
+
exported project's command. The included configuration matches the deadlines in
|
|
81
|
+
the real p-limit acceptance: 360 seconds of work, 70 seconds per model request
|
|
82
|
+
and 60 seconds for close. It limits the team to Root and two direct children and
|
|
83
|
+
requires a `report.md` of up to 1 MiB. The report's source claims remain subject
|
|
84
|
+
to review. To change the budgets, edit that file. `--config` loads a complete
|
|
85
|
+
configuration rather than merging arbitrary partial objects.
|
|
86
|
+
|
|
87
|
+
[Recorded VM run](https://github.com/AnySwarm/anyswarm/issues/358#issuecomment-7385075753)
|
|
88
|
+
|
|
89
|
+
| File | Responsibility |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `project.ts` | Public Harness, captured input, user input controls, lifecycle and result projection. |
|
|
92
|
+
| `business.ts` | One Runtime, Root/child Profiles, Service registration and final collection. |
|
|
93
|
+
| `config.ts`, `model.ts` | Sandbox connection, model route, executor, image, capacity and deadlines. |
|
|
94
|
+
| `handoff-config.ts` | Reproducible repository handoff budgets and required report collection. |
|
|
95
|
+
| `harness/controller.ts` | Named members, parent relationships, messaging, follow-up, waits and bounded close. |
|
|
96
|
+
| `services/collaboration-service.ts` | Authenticated operations, authorization and observable collaboration state. |
|
|
97
|
+
| `prompts/prompts.ts` | Root and child instructions; no prewritten answer to the user's task. |
|
|
98
|
+
| `main.ts` | Direct host demonstration for embedding and explicit interactive clients. |
|
|
99
|
+
|
|
100
|
+
Common `ANYSWARM_MODEL_*`, `ANYSWARM_EXECUTOR` and connection settings take
|
|
101
|
+
precedence over the corresponding `ANYSWARM_SUBAGENTS_*` fallbacks. Without an
|
|
102
|
+
explicit image, `workerImageFor(executor)` selects the matching Worker. Codex
|
|
103
|
+
requires Responses and an explicit model ID and uses `fork_turns: none`; Pi also supports
|
|
104
|
+
copying parent context and a streaming Chat Completions endpoint via
|
|
105
|
+
`ANYSWARM_MODEL_PROTOCOL=chat-completions`. Files remain private in either case.
|
|
106
|
+
|
|
107
|
+
## Advanced host and session example
|
|
108
|
+
|
|
109
|
+
`main.ts` demonstrates direct hosting. From the exported project after
|
|
110
|
+
`npm install`, run:
|
|
89
111
|
|
|
90
112
|
```sh
|
|
91
|
-
|
|
92
|
-
swarm collaboration wait_agent --request-id reviewer-result
|
|
113
|
+
npm exec -- anyswarm run ./main.ts ./config.ts 'Investigate the supplied question'
|
|
93
114
|
```
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
The
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
This direct script seeds `config.files`; it does not automatically capture a
|
|
117
|
+
repository from `--cwd`. Use the project entry (`npm start`) or the built-in
|
|
118
|
+
`--harness subagents` command for the captured repository task above.
|
|
119
|
+
|
|
120
|
+
Its optional `--interactive` mode keeps the same Root available after a reply.
|
|
121
|
+
The host accepts a follow-up line, `/status` and `/exit`; EOF and cancellation
|
|
122
|
+
close the team. This direct host demonstration is separate from the foreground
|
|
123
|
+
task CLI. Use the SDK or JSONL RPC for a client that needs questions or ongoing
|
|
124
|
+
Run controls.
|
|
125
|
+
|
|
126
|
+
The exported `createSubagentsHarness` handle provides `input`, `status`,
|
|
127
|
+
`onReply`, `lastReply`, `waitForReply` and `close`. Check admission and execution
|
|
128
|
+
separately; for repeated inputs pass the preceding reply sequence in
|
|
129
|
+
`waitForReply({ after, signal })`. Bound work with a signal and close in
|
|
130
|
+
`finally`, preserving the full receipt. Service member paths such as
|
|
131
|
+
`/root/reviewer` are human-readable addresses, separate from the Runtime IDs.
|
|
132
|
+
|
|
133
|
+
## Verification and remaining acceptance
|
|
134
|
+
|
|
135
|
+
Package tests verify public imports, complete source export, editable local
|
|
136
|
+
entry points and configuration failure before allocation. The collaboration
|
|
137
|
+
tests verify caller identities, named members, message/follow-up semantics,
|
|
138
|
+
cancellation, collection and pending cleanup using controlled backends.
|
|
139
|
+
|
|
140
|
+
The new repository-handoff recipe still requires real-model acceptance: run it
|
|
141
|
+
on a real repository, inspect at least two actual child contributions and Root's
|
|
142
|
+
report, check its citations, then change the question or input directory and
|
|
143
|
+
repeat. Record model/executor, input identity, output paths and cleanup. These
|
|
144
|
+
runs are not replaced by fixtures or by the older
|
|
145
|
+
[ProgramBench experiment](https://github.com/AnySwarm/anyswarm/blob/207be6356c16e5fb60c4b3c5b236d7a98383f991/docs/experiments/EXP-20261125-10-issue199-fd.md).
|
|
@@ -13,6 +13,7 @@ declare const _default: {
|
|
|
13
13
|
useServerProxy: boolean | undefined;
|
|
14
14
|
egressMode: "dns+nft" | undefined;
|
|
15
15
|
endpointHost: undefined;
|
|
16
|
+
preparedImage?: string | undefined;
|
|
16
17
|
resourceLimits: {
|
|
17
18
|
cpu: string;
|
|
18
19
|
memory: string;
|
|
@@ -28,16 +29,7 @@ declare const _default: {
|
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
models: {
|
|
31
|
-
default:
|
|
32
|
-
provider: string;
|
|
33
|
-
model: string;
|
|
34
|
-
upstream: {
|
|
35
|
-
url: string;
|
|
36
|
-
headers: {
|
|
37
|
-
authorization: string;
|
|
38
|
-
} | {};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
32
|
+
default: import("@anyswarm/core").ModelConfig;
|
|
41
33
|
};
|
|
42
34
|
};
|
|
43
35
|
export default _default;
|