@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
|
@@ -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
|
|
@@ -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).
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { workerImageFor, resolveSandboxConnection, ProjectPreflightError } from '@anyswarm/core';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
for (const name of names) {
|
|
5
|
-
const value = process.env[name];
|
|
6
|
-
if (value) return value;
|
|
7
|
-
}
|
|
8
|
-
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION',
|
|
9
|
-
`Set ${names.join(' or ')} before running the Subagents Harness.`);
|
|
10
|
-
}
|
|
3
|
+
import { readSubagentsModel } from './model.js';
|
|
11
4
|
|
|
12
5
|
const { image, advertiseHost, publicUrl, endpointSource: _endpointSource, executor: setupExecutor, ...sandbox } = resolveSandboxConnection({}, 'SUBAGENTS');
|
|
13
|
-
const upstream = required('ANYSWARM_MODEL_URL', 'ANYSWARM_SUBAGENTS_MODEL_URL');
|
|
14
|
-
const token = process.env.ANYSWARM_MODEL_TOKEN ?? process.env.ANYSWARM_SUBAGENTS_MODEL_TOKEN;
|
|
15
6
|
const executor = process.env.ANYSWARM_EXECUTOR ?? process.env.ANYSWARM_SUBAGENTS_EXECUTOR ?? setupExecutor ?? 'pi';
|
|
16
|
-
const
|
|
17
|
-
|
|
7
|
+
const route = readSubagentsModel(executor);
|
|
8
|
+
if (!route) {
|
|
9
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', executor === 'codex'
|
|
10
|
+
? 'Set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID (or their ANYSWARM_SUBAGENTS_ equivalents) before running the Subagents Harness with Codex.'
|
|
11
|
+
: 'Set ANYSWARM_MODEL_URL or ANYSWARM_SUBAGENTS_MODEL_URL before running the Subagents Harness.');
|
|
12
|
+
}
|
|
18
13
|
|
|
19
14
|
export default {
|
|
20
15
|
model: 'default',
|
|
@@ -33,7 +28,5 @@ export default {
|
|
|
33
28
|
connection: { publicUrl, advertiseHost,
|
|
34
29
|
modelGateway: { requestTimeoutMs: 25_000, maxOutputTokens: executor === 'codex' ? null : 2048 },
|
|
35
30
|
},
|
|
36
|
-
models: { default:
|
|
37
|
-
url: upstream, headers: token ? { authorization: `Bearer ${token}` } : {},
|
|
38
|
-
} } },
|
|
31
|
+
models: { default: route },
|
|
39
32
|
};
|
|
@@ -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,14 @@
|
|
|
1
|
+
import defaults from './config.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...defaults,
|
|
5
|
+
maxAgents: 3,
|
|
6
|
+
maxDepth: 1,
|
|
7
|
+
workTimeoutMs: 360_000,
|
|
8
|
+
closeTimeoutMs: 60_000,
|
|
9
|
+
connection: {
|
|
10
|
+
...defaults.connection,
|
|
11
|
+
modelGateway: { ...defaults.connection.modelGateway, requestTimeoutMs: 70_000 },
|
|
12
|
+
},
|
|
13
|
+
collect: { paths: ['report.md'], includeGit: false, maxBytes: 1024 * 1024, required: true },
|
|
14
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProjectPreflightError, type ModelConfig } from '@anyswarm/core';
|
|
2
|
+
|
|
3
|
+
/** Read the built-in Subagents route without reading Sandbox state or contacting a provider. */
|
|
4
|
+
export function readSubagentsModel(executor: string): ModelConfig | undefined {
|
|
5
|
+
const env = process.env;
|
|
6
|
+
const setting = (name: string) => env[`ANYSWARM_${name}`] ?? env[`ANYSWARM_SUBAGENTS_${name}`];
|
|
7
|
+
const url = env.ANYSWARM_MODEL_URL || env.ANYSWARM_SUBAGENTS_MODEL_URL;
|
|
8
|
+
const model = env.ANYSWARM_MODEL_ID || env.ANYSWARM_SUBAGENTS_MODEL_ID || (executor === 'codex' ? undefined : 'gpt-5.4');
|
|
9
|
+
if (!url || !model) return undefined;
|
|
10
|
+
const protocol = setting('MODEL_PROTOCOL') ?? 'responses';
|
|
11
|
+
if (protocol !== 'responses' && protocol !== 'chat-completions') {
|
|
12
|
+
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION',
|
|
13
|
+
'Set ANYSWARM_MODEL_PROTOCOL or ANYSWARM_SUBAGENTS_MODEL_PROTOCOL to responses or chat-completions.');
|
|
14
|
+
}
|
|
15
|
+
const token = setting('MODEL_TOKEN');
|
|
16
|
+
return {
|
|
17
|
+
provider: setting('MODEL_PROVIDER') ?? 'openai', model, protocol,
|
|
18
|
+
upstream: { url, headers: token ? { authorization: `Bearer ${token}` } : {} },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -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
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyswarm/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@anyswarm/core",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.6.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@alibaba-group/opensandbox": "1.2.1",
|
|
13
13
|
"@modelcontextprotocol/client": "2.4.0",
|
|
14
|
+
"@swc/wasm": "1.16.22",
|
|
14
15
|
"ajv": "8.20.0",
|
|
15
16
|
"es-module-lexer": "3.0.5",
|
|
16
17
|
"js-tiktoken": "1.0.21"
|
|
@@ -102,6 +103,12 @@
|
|
|
102
103
|
"node": ">=8.0.0"
|
|
103
104
|
}
|
|
104
105
|
},
|
|
106
|
+
"node_modules/@swc/wasm": {
|
|
107
|
+
"version": "1.16.22",
|
|
108
|
+
"resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.16.22.tgz",
|
|
109
|
+
"integrity": "sha512-7wFC6rBgXXiNElVvrBokCD7xgNF6QOMyiEDeQyhcvPgIBc+jWW99FU/E4KScd+NPZBAxwEkj3/a7N9xnu1RI+A==",
|
|
110
|
+
"license": "Apache-2.0"
|
|
111
|
+
},
|
|
105
112
|
"node_modules/@types/node": {
|
|
106
113
|
"version": "26.6.5",
|
|
107
114
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.5.tgz",
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyswarm/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@anyswarm/core",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.6.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@alibaba-group/opensandbox": "1.2.1",
|
|
13
13
|
"@modelcontextprotocol/client": "2.4.0",
|
|
14
|
+
"@swc/wasm": "1.16.22",
|
|
14
15
|
"ajv": "8.20.0",
|
|
15
16
|
"es-module-lexer": "3.0.5",
|
|
16
17
|
"js-tiktoken": "1.0.21"
|
|
@@ -98,6 +99,12 @@
|
|
|
98
99
|
"node": ">=8.0.0"
|
|
99
100
|
}
|
|
100
101
|
},
|
|
102
|
+
"node_modules/@swc/wasm": {
|
|
103
|
+
"version": "1.16.22",
|
|
104
|
+
"resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.16.22.tgz",
|
|
105
|
+
"integrity": "sha512-7wFC6rBgXXiNElVvrBokCD7xgNF6QOMyiEDeQyhcvPgIBc+jWW99FU/E4KScd+NPZBAxwEkj3/a7N9xnu1RI+A==",
|
|
106
|
+
"license": "Apache-2.0"
|
|
107
|
+
},
|
|
101
108
|
"node_modules/ajv": {
|
|
102
109
|
"version": "8.20.0",
|
|
103
110
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
|
package/package.development.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyswarm/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@alibaba-group/opensandbox": "1.2.1",
|
|
71
71
|
"@modelcontextprotocol/client": "2.4.0",
|
|
72
|
+
"@swc/wasm": "1.16.22",
|
|
72
73
|
"ajv": "8.20.0",
|
|
73
74
|
"es-module-lexer": "3.0.5",
|
|
74
75
|
"js-tiktoken": "1.0.21"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyswarm/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@alibaba-group/opensandbox": "1.2.1",
|
|
70
70
|
"@modelcontextprotocol/client": "2.4.0",
|
|
71
|
+
"@swc/wasm": "1.16.22",
|
|
71
72
|
"ajv": "8.20.0",
|
|
72
73
|
"es-module-lexer": "3.0.5",
|
|
73
74
|
"js-tiktoken": "1.0.21"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { dirname,
|
|
2
|
-
import { homedir } from 'node:os';
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
3
2
|
import type { HarnessEvent, HarnessResult, HarnessSession } from '../src/harness/harness-session-types.js';
|
|
3
|
+
import { defaultRunRoot } from '../src/trace-viewer/run-root.mjs';
|
|
4
4
|
|
|
5
5
|
function object(value: unknown): Record<string, unknown> {
|
|
6
6
|
return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
@@ -12,12 +12,36 @@ function shellPath(path: string) {
|
|
|
12
12
|
|
|
13
13
|
const serviceActions = new Set(['service.register', 'service.start', 'service.restart', 'service.stop', 'service.retire']);
|
|
14
14
|
|
|
15
|
+
function terminalText(message: string, multiline = false) {
|
|
16
|
+
return (multiline ? message.replace(/\r\n/g, '\n') : message).replace(/[\p{Cc}\p{Cf}]/gu, character =>
|
|
17
|
+
multiline && (character === '\n' || character === '\t') ? character
|
|
18
|
+
: '\\u' + character.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function terminalResult(message: string, saved: boolean) {
|
|
22
|
+
const bytes = Buffer.from(terminalText(message, true));
|
|
23
|
+
const limit = 64 * 1024;
|
|
24
|
+
if (bytes.length <= limit) return bytes.toString('utf8');
|
|
25
|
+
let end = limit;
|
|
26
|
+
while ((bytes[end] & 0xc0) === 0x80) end--;
|
|
27
|
+
return bytes.subarray(0, end).toString('utf8') + (saved
|
|
28
|
+
? '\n[Terminal result truncated. Read the full result in the Run report.]'
|
|
29
|
+
: '\n[Terminal result truncated. No saved Run report is available.]');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function finalResult(value: unknown): string | undefined {
|
|
33
|
+
if (value === undefined) return;
|
|
34
|
+
const business = object(value).business;
|
|
35
|
+
const output = typeof business === 'string' ? business : object(business).output;
|
|
36
|
+
const result = typeof output === 'string' ? output : value;
|
|
37
|
+
return typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
38
|
+
}
|
|
39
|
+
|
|
15
40
|
export function foregroundProgress(session: HarnessSession, harnessId: string, launchDirectory: string,
|
|
16
41
|
outputRoot: string | undefined, write: (message: string) => Promise<void>) {
|
|
17
42
|
const root = outputRoot ? resolve(launchDirectory, outputRoot)
|
|
18
|
-
:
|
|
19
|
-
const report = (message: string) => write(message
|
|
20
|
-
'\\u' + character.charCodeAt(0).toString(16).padStart(4, '0')));
|
|
43
|
+
: defaultRunRoot();
|
|
44
|
+
const report = (message: string) => write(terminalText(message));
|
|
21
45
|
const trace = (directory: string) => report('Trace anyswarm trace --root ' + shellPath(directory));
|
|
22
46
|
void report('Starting ' + harnessId);
|
|
23
47
|
void trace(root);
|
|
@@ -70,10 +94,16 @@ export function foregroundProgress(session: HarnessSession, harnessId: string, l
|
|
|
70
94
|
return {
|
|
71
95
|
observe,
|
|
72
96
|
async finish(result: HarnessResult) {
|
|
73
|
-
|
|
97
|
+
if (closed) return;
|
|
74
98
|
closed = true;
|
|
99
|
+
await services;
|
|
75
100
|
const message = result.failure?.message ?? result.reportSaveFailure?.message;
|
|
76
101
|
void report('Run ' + result.outcome + ' ' + result.reason + (message ? ' (' + message + ')' : ''));
|
|
102
|
+
const output = finalResult(result.result);
|
|
103
|
+
if (output !== undefined) {
|
|
104
|
+
void report('Result');
|
|
105
|
+
await write(terminalResult(output, Boolean(result.reportPath) && !result.reportSaveFailure));
|
|
106
|
+
}
|
|
77
107
|
for (const artifact of result.artifacts.slice(0, 5)) {
|
|
78
108
|
const path = typeof artifact === 'string' ? artifact : object(artifact).path;
|
|
79
109
|
if (typeof path === 'string') void report('Artifact ' + path);
|