@anyswarm/core 0.5.2 → 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 +19 -4
- package/README.md +68 -61
- package/dist/examples/README.md +134 -84
- package/dist/examples/autoresearch/README.md +106 -21
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
- 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/frontiercs2-config.d.ts +2 -2
- package/dist/examples/autoresearch/frontiercs2-config.js +13 -2
- package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
- package/dist/examples/autoresearch/frontiercs2.js +71 -14
- package/dist/examples/autoresearch/prepare-demo.js +34 -3
- 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 -1
- package/dist/examples/autoresearch/project.js +130 -26
- package/dist/examples/autoresearch/research-service.d.ts +16 -1
- package/dist/examples/autoresearch/research-service.js +84 -44
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- 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 +8 -15
- 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/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-progress.js +36 -5
- 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 +3 -3
- package/dist/scripts/local-environment.js +6 -1
- package/dist/scripts/local-setup.js +25 -18
- package/dist/scripts/pack-release.js +27 -3
- 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/harness/project-harness.js +3 -2
- package/dist/src/harness/project-rpc-client.js +19 -0
- 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 +9 -8
- package/docs/architecture/06-observability-experiments.md +21 -7
- package/docs/architecture/07-run-configuration.md +97 -12
- 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 +129 -86
- 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 +78 -0
- package/docs/architecture/22-website.md +53 -18
- package/docs/architecture/23-project-harness.md +63 -16
- package/docs/architecture/28-autoresearch.md +16 -22
- 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 +78 -54
- package/docs/architecture/source-map.json +396 -36
- package/docs/designs/core-harness/06-project-harness.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 +22 -1
- package/docs/en/first-harness.md +40 -32
- package/docs/en/harnesses/index.md +23 -23
- package/docs/en/harnesses/subagents.md +8 -29
- package/docs/en/latest.md +26 -5
- package/docs/en/overview.md +22 -22
- package/docs/en/quickstart.md +55 -21
- package/docs/en/reference/api.md +1 -1
- package/docs/en/trace-viewer.md +32 -12
- package/docs/operations/trace-viewer.md +25 -10
- package/docs/workflows/development.md +160 -120
- package/docs/workflows/release-and-docs-versioning.md +207 -55
- package/docs/workflows/release-cli-acceptance.md +124 -47
- 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 +22 -1
- package/docs/zh/first-harness.md +43 -35
- package/docs/zh/harnesses/index.md +23 -23
- package/docs/zh/harnesses/subagents.md +8 -29
- package/docs/zh/latest.md +26 -5
- package/docs/zh/overview.md +23 -23
- package/docs/zh/quickstart.md +51 -21
- package/docs/zh/reference/api.md +1 -1
- package/docs/zh/trace-viewer.md +32 -12
- package/examples/README.md +134 -84
- package/examples/autoresearch/README.md +106 -21
- package/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
- package/examples/autoresearch/config.ts +64 -25
- package/examples/autoresearch/demo.ts +75 -22
- package/examples/autoresearch/frontiercs2-config.ts +13 -2
- package/examples/autoresearch/frontiercs2.ts +64 -11
- package/examples/autoresearch/prepare-demo.ts +32 -3
- package/examples/autoresearch/prepare.ts +134 -60
- package/examples/autoresearch/project.ts +119 -26
- package/examples/autoresearch/research-service.ts +91 -41
- 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 +1 -1
- package/examples/lead-worker/README.md +1 -1
- package/examples/messages/README.md +2 -2
- package/examples/notes/README.md +2 -2
- 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 +1 -1
- package/examples/subagents/AGENTS.md +35 -0
- package/examples/subagents/README.md +129 -93
- package/examples/subagents/config.ts +8 -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/taskpool/README.md +1 -1
- package/npm-shrinkwrap.development.json +9 -2
- package/npm-shrinkwrap.json +9 -2
- package/package.development.json +2 -1
- package/package.json +2 -1
- package/scripts/anyswarm-progress.ts +36 -6
- package/scripts/generate-architecture-coverage.ts +1 -1
- package/scripts/generate-architecture-prompts.ts +21 -10
- package/scripts/local-environment.ts +8 -1
- package/scripts/local-setup.ts +22 -17
- package/scripts/pack-release.ts +24 -3
- 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/harness/project-harness.ts +3 -2
- package/src/harness/project-rpc-client.ts +23 -0
- 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
|
@@ -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;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { workerImageFor, resolveSandboxConnection, ProjectPreflightError } from '@anyswarm/core';
|
|
2
|
-
|
|
3
|
-
for (const name of names) {
|
|
4
|
-
const value = process.env[name];
|
|
5
|
-
if (value)
|
|
6
|
-
return value;
|
|
7
|
-
}
|
|
8
|
-
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', `Set ${names.join(' or ')} before running the Subagents Harness.`);
|
|
9
|
-
}
|
|
2
|
+
import { readSubagentsModel } from './model.js';
|
|
10
3
|
const { image, advertiseHost, publicUrl, endpointSource: _endpointSource, executor: setupExecutor, ...sandbox } = resolveSandboxConnection({}, 'SUBAGENTS');
|
|
11
|
-
const upstream = required('ANYSWARM_MODEL_URL', 'ANYSWARM_SUBAGENTS_MODEL_URL');
|
|
12
|
-
const token = process.env.ANYSWARM_MODEL_TOKEN ?? process.env.ANYSWARM_SUBAGENTS_MODEL_TOKEN;
|
|
13
4
|
const executor = process.env.ANYSWARM_EXECUTOR ?? process.env.ANYSWARM_SUBAGENTS_EXECUTOR ?? setupExecutor ?? 'pi';
|
|
14
|
-
const
|
|
15
|
-
|
|
5
|
+
const route = readSubagentsModel(executor);
|
|
6
|
+
if (!route) {
|
|
7
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', executor === 'codex'
|
|
8
|
+
? 'Set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID (or their ANYSWARM_SUBAGENTS_ equivalents) before running the Subagents Harness with Codex.'
|
|
9
|
+
: 'Set ANYSWARM_MODEL_URL or ANYSWARM_SUBAGENTS_MODEL_URL before running the Subagents Harness.');
|
|
10
|
+
}
|
|
16
11
|
export default {
|
|
17
12
|
model: 'default',
|
|
18
13
|
maxAgents: Number(process.env.ANYSWARM_SUBAGENTS_MAX_AGENTS ?? 4),
|
|
@@ -30,7 +25,5 @@ export default {
|
|
|
30
25
|
connection: { publicUrl, advertiseHost,
|
|
31
26
|
modelGateway: { requestTimeoutMs: 25_000, maxOutputTokens: executor === 'codex' ? null : 2048 },
|
|
32
27
|
},
|
|
33
|
-
models: { default:
|
|
34
|
-
url: upstream, headers: token ? { authorization: `Bearer ${token}` } : {},
|
|
35
|
-
} } },
|
|
28
|
+
models: { default: route },
|
|
36
29
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiVersion": 1,
|
|
3
|
+
"entry": "project.ts",
|
|
4
|
+
"files": [
|
|
5
|
+
"project.ts",
|
|
6
|
+
"business.ts",
|
|
7
|
+
"config.ts",
|
|
8
|
+
"model.ts",
|
|
9
|
+
"handoff-config.ts",
|
|
10
|
+
"main.ts",
|
|
11
|
+
"harness/controller.ts",
|
|
12
|
+
"services/collaboration-service.ts",
|
|
13
|
+
"prompts/prompts.ts",
|
|
14
|
+
"README.md",
|
|
15
|
+
"AGENTS.md"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
model: string;
|
|
3
|
+
image: string;
|
|
4
|
+
outputDir: string;
|
|
5
|
+
executor: string;
|
|
6
|
+
sandbox: {
|
|
7
|
+
lifecycleBaseUrl: string;
|
|
8
|
+
apiKey: string | undefined;
|
|
9
|
+
useServerProxy: boolean | undefined;
|
|
10
|
+
egressMode: "dns+nft" | undefined;
|
|
11
|
+
endpointHost: undefined;
|
|
12
|
+
preparedImage?: string | undefined;
|
|
13
|
+
resourceLimits: {
|
|
14
|
+
cpu: string;
|
|
15
|
+
memory: string;
|
|
16
|
+
};
|
|
17
|
+
commandTimeoutMs: number;
|
|
18
|
+
};
|
|
19
|
+
models: {
|
|
20
|
+
default: import("@anyswarm/core").ModelConfig;
|
|
21
|
+
};
|
|
22
|
+
maxAgents: number;
|
|
23
|
+
maxDepth: number;
|
|
24
|
+
workTimeoutMs: number;
|
|
25
|
+
closeTimeoutMs: number;
|
|
26
|
+
connection: {
|
|
27
|
+
publicUrl: string | undefined;
|
|
28
|
+
advertiseHost: string | undefined;
|
|
29
|
+
modelGateway: {
|
|
30
|
+
maxOutputTokens: number | null;
|
|
31
|
+
requestTimeoutMs: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
collect: {
|
|
35
|
+
paths: string[];
|
|
36
|
+
includeGit: boolean;
|
|
37
|
+
maxBytes: number;
|
|
38
|
+
required: boolean;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import defaults from './config.js';
|
|
2
|
+
export default {
|
|
3
|
+
...defaults,
|
|
4
|
+
maxAgents: 3,
|
|
5
|
+
maxDepth: 1,
|
|
6
|
+
workTimeoutMs: 360_000,
|
|
7
|
+
closeTimeoutMs: 60_000,
|
|
8
|
+
connection: {
|
|
9
|
+
...defaults.connection,
|
|
10
|
+
modelGateway: { ...defaults.connection.modelGateway, requestTimeoutMs: 70_000 },
|
|
11
|
+
},
|
|
12
|
+
collect: { paths: ['report.md'], includeGit: false, maxBytes: 1024 * 1024, required: true },
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProjectPreflightError } from '@anyswarm/core';
|
|
2
|
+
/** Read the built-in Subagents route without reading Sandbox state or contacting a provider. */
|
|
3
|
+
export function readSubagentsModel(executor) {
|
|
4
|
+
const env = process.env;
|
|
5
|
+
const setting = (name) => env[`ANYSWARM_${name}`] ?? env[`ANYSWARM_SUBAGENTS_${name}`];
|
|
6
|
+
const url = env.ANYSWARM_MODEL_URL || env.ANYSWARM_SUBAGENTS_MODEL_URL;
|
|
7
|
+
const model = env.ANYSWARM_MODEL_ID || env.ANYSWARM_SUBAGENTS_MODEL_ID || (executor === 'codex' ? undefined : 'gpt-5.4');
|
|
8
|
+
if (!url || !model)
|
|
9
|
+
return undefined;
|
|
10
|
+
const protocol = setting('MODEL_PROTOCOL') ?? 'responses';
|
|
11
|
+
if (protocol !== 'responses' && protocol !== 'chat-completions') {
|
|
12
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Set ANYSWARM_MODEL_PROTOCOL or ANYSWARM_SUBAGENTS_MODEL_PROTOCOL to responses or chat-completions.');
|
|
13
|
+
}
|
|
14
|
+
const token = setting('MODEL_TOKEN');
|
|
15
|
+
return {
|
|
16
|
+
provider: setting('MODEL_PROVIDER') ?? 'openai', model, protocol,
|
|
17
|
+
upstream: { url, headers: token ? { authorization: `Bearer ${token}` } : {} },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -21,7 +21,7 @@ repository sources.
|
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
23
|
npm init -y
|
|
24
|
-
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.
|
|
24
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
|
|
25
25
|
npm install --save-dev typescript @types/node
|
|
26
26
|
sdk=node_modules/@anyswarm/core
|
|
27
27
|
cp -R "$sdk"/examples/substrate demo
|
|
@@ -62,15 +62,21 @@ substrate Service owns publication permissions, ranking and persistence. See the
|
|
|
62
62
|
`main.ts` remains the entry for fixed-question fixtures, saved-result inspection
|
|
63
63
|
for ordinary Substrate. `config.ts` is its fixed-question configuration and
|
|
64
64
|
requires `ANYSWARM_SUBSTRATE_RUN`; it is not the input to the normal project command.
|
|
65
|
-
From
|
|
65
|
+
From `examples/substrate` in the source checkout after building the root:
|
|
66
66
|
|
|
67
67
|
```sh
|
|
68
|
-
../../
|
|
69
|
-
../../
|
|
68
|
+
node ../../dist/scripts/anyswarm.js run ./main.ts --help
|
|
69
|
+
node ../../dist/scripts/anyswarm.js run ./main.ts ./config.ts
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For an installed package, run its CLI from the consumer project and use the
|
|
73
|
+
matching source files in that package:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
node_modules/.bin/anyswarm run node_modules/@anyswarm/core/examples/substrate/main.ts \
|
|
77
|
+
node_modules/@anyswarm/core/examples/substrate/config.ts
|
|
70
78
|
```
|
|
71
79
|
|
|
72
|
-
For an installed package, replace `../../dist/examples/substrate` with
|
|
73
|
-
the `dist/examples/substrate` directory inside the SDK you installed.
|
|
74
80
|
Keep the shipped modules in their installed location because their relative
|
|
75
81
|
imports are part of the package. `--result <run-directory> --runtime-id <id>`
|
|
76
82
|
reads saved reports without loading model credentials.
|
|
@@ -10,7 +10,7 @@ repository sources.
|
|
|
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
|
sdk=node_modules/@anyswarm/core
|
|
16
16
|
cp -R "$sdk"/examples/taskpool demo
|
|
@@ -24,8 +24,8 @@ export declare function captureServiceAuthority(tasks: any, envelope?: any, { mi
|
|
|
24
24
|
};
|
|
25
25
|
links: any;
|
|
26
26
|
scope: {
|
|
27
|
-
error?: undefined;
|
|
28
27
|
value: any;
|
|
28
|
+
error?: undefined;
|
|
29
29
|
} | {
|
|
30
30
|
value?: undefined;
|
|
31
31
|
error: {
|
|
@@ -34,8 +34,8 @@ export declare function captureServiceAuthority(tasks: any, envelope?: any, { mi
|
|
|
34
34
|
};
|
|
35
35
|
} | null;
|
|
36
36
|
write_scope: {
|
|
37
|
-
error?: undefined;
|
|
38
37
|
value: any;
|
|
38
|
+
error?: undefined;
|
|
39
39
|
} | {
|
|
40
40
|
value?: undefined;
|
|
41
41
|
error: {
|
|
@@ -44,8 +44,8 @@ export declare function captureServiceAuthority(tasks: any, envelope?: any, { mi
|
|
|
44
44
|
};
|
|
45
45
|
} | null;
|
|
46
46
|
mission_open: {
|
|
47
|
-
error?: undefined;
|
|
48
47
|
value: any;
|
|
48
|
+
error?: undefined;
|
|
49
49
|
} | {
|
|
50
50
|
value?: undefined;
|
|
51
51
|
error: {
|
|
@@ -54,8 +54,8 @@ export declare function captureServiceAuthority(tasks: any, envelope?: any, { mi
|
|
|
54
54
|
};
|
|
55
55
|
} | null;
|
|
56
56
|
correction_scope: {
|
|
57
|
-
error?: undefined;
|
|
58
57
|
value: any;
|
|
58
|
+
error?: undefined;
|
|
59
59
|
} | {
|
|
60
60
|
value?: undefined;
|
|
61
61
|
error: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dirname,
|
|
2
|
-
import {
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { defaultRunRoot } from '../src/trace-viewer/run-root.mjs';
|
|
3
3
|
function object(value) {
|
|
4
4
|
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
5
5
|
}
|
|
@@ -7,10 +7,34 @@ function shellPath(path) {
|
|
|
7
7
|
return /^[\w./-]+$/.test(path) ? path : "'" + path.replaceAll("'", "'\\''") + "'";
|
|
8
8
|
}
|
|
9
9
|
const serviceActions = new Set(['service.register', 'service.start', 'service.restart', 'service.stop', 'service.retire']);
|
|
10
|
+
function terminalText(message, multiline = false) {
|
|
11
|
+
return (multiline ? message.replace(/\r\n/g, '\n') : message).replace(/[\p{Cc}\p{Cf}]/gu, character => multiline && (character === '\n' || character === '\t') ? character
|
|
12
|
+
: '\\u' + character.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
13
|
+
}
|
|
14
|
+
function terminalResult(message, saved) {
|
|
15
|
+
const bytes = Buffer.from(terminalText(message, true));
|
|
16
|
+
const limit = 64 * 1024;
|
|
17
|
+
if (bytes.length <= limit)
|
|
18
|
+
return bytes.toString('utf8');
|
|
19
|
+
let end = limit;
|
|
20
|
+
while ((bytes[end] & 0xc0) === 0x80)
|
|
21
|
+
end--;
|
|
22
|
+
return bytes.subarray(0, end).toString('utf8') + (saved
|
|
23
|
+
? '\n[Terminal result truncated. Read the full result in the Run report.]'
|
|
24
|
+
: '\n[Terminal result truncated. No saved Run report is available.]');
|
|
25
|
+
}
|
|
26
|
+
function finalResult(value) {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return;
|
|
29
|
+
const business = object(value).business;
|
|
30
|
+
const output = typeof business === 'string' ? business : object(business).output;
|
|
31
|
+
const result = typeof output === 'string' ? output : value;
|
|
32
|
+
return typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
33
|
+
}
|
|
10
34
|
export function foregroundProgress(session, harnessId, launchDirectory, outputRoot, write) {
|
|
11
35
|
const root = outputRoot ? resolve(launchDirectory, outputRoot)
|
|
12
|
-
:
|
|
13
|
-
const report = (message) => write(message
|
|
36
|
+
: defaultRunRoot();
|
|
37
|
+
const report = (message) => write(terminalText(message));
|
|
14
38
|
const trace = (directory) => report('Trace anyswarm trace --root ' + shellPath(directory));
|
|
15
39
|
void report('Starting ' + harnessId);
|
|
16
40
|
void trace(root);
|
|
@@ -73,10 +97,17 @@ export function foregroundProgress(session, harnessId, launchDirectory, outputRo
|
|
|
73
97
|
return {
|
|
74
98
|
observe,
|
|
75
99
|
async finish(result) {
|
|
76
|
-
|
|
100
|
+
if (closed)
|
|
101
|
+
return;
|
|
77
102
|
closed = true;
|
|
103
|
+
await services;
|
|
78
104
|
const message = result.failure?.message ?? result.reportSaveFailure?.message;
|
|
79
105
|
void report('Run ' + result.outcome + ' ' + result.reason + (message ? ' (' + message + ')' : ''));
|
|
106
|
+
const output = finalResult(result.result);
|
|
107
|
+
if (output !== undefined) {
|
|
108
|
+
void report('Result');
|
|
109
|
+
await write(terminalResult(output, Boolean(result.reportPath) && !result.reportSaveFailure));
|
|
110
|
+
}
|
|
80
111
|
for (const artifact of result.artifacts.slice(0, 5)) {
|
|
81
112
|
const path = typeof artifact === 'string' ? artifact : object(artifact).path;
|
|
82
113
|
if (typeof path === 'string')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commit":"
|
|
1
|
+
{"commit":"15e26a33422cec62f67d038eeb10a418df484522","dirty":false}
|
|
@@ -16,7 +16,7 @@ const safe = (path) => typeof path === 'string' && path !== '' && !path.startsWi
|
|
|
16
16
|
// runtime inputs. They can contain dependency symlinks and must never affect
|
|
17
17
|
// the tracked source inventory.
|
|
18
18
|
const skipRoots = new Set(['.git', '.worktree', '.worktrees', '.claude', 'node_modules', 'dist', '.codex', 'docs', 'test', 'test-support', 'experiments', 'reports']);
|
|
19
|
-
const skipPaths = new Set(['third_party/agensh', 'website/.astro', 'website/dist', 'website/node_modules']);
|
|
19
|
+
const skipPaths = new Set(['third_party/agensh', 'website/.astro', 'website/.generated', 'website/dist', 'website/node_modules']);
|
|
20
20
|
async function walk(directory, prefix = '') {
|
|
21
21
|
const files = [];
|
|
22
22
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|