@anyswarm/core 0.5.0 → 0.5.2
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 +1 -1
- package/README.md +21 -13
- package/deploy/worker/Dockerfile +12 -4
- package/dist/deploy/worker/Dockerfile +12 -4
- package/dist/examples/README.md +35 -12
- package/dist/examples/authoring/README.md +24 -0
- package/dist/examples/authoring/business.d.ts +2 -0
- package/dist/examples/authoring/business.js +4 -0
- package/dist/examples/authoring/config.d.ts +5 -0
- package/dist/examples/authoring/config.js +2 -0
- package/dist/examples/authoring/eject.json +5 -0
- package/dist/examples/authoring/harness.d.ts +4 -0
- package/dist/examples/authoring/harness.js +19 -0
- package/dist/examples/autoresearch/README.md +40 -0
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/autoresearch/config.d.ts +51 -0
- package/dist/examples/autoresearch/config.js +57 -0
- package/dist/examples/autoresearch/demo.d.ts +11 -0
- package/dist/examples/autoresearch/demo.js +52 -0
- package/dist/examples/autoresearch/eject.json +17 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
- package/dist/examples/autoresearch/frontiercs2.js +211 -0
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +15 -0
- package/dist/examples/autoresearch/prepare.d.ts +95 -0
- package/dist/examples/autoresearch/prepare.js +257 -0
- package/dist/examples/autoresearch/process.d.ts +13 -0
- package/dist/examples/autoresearch/process.js +48 -0
- package/dist/examples/autoresearch/project.d.ts +21 -0
- package/dist/examples/autoresearch/project.js +392 -0
- package/dist/examples/autoresearch/research-service.d.ts +106 -0
- package/dist/examples/autoresearch/research-service.js +255 -0
- package/dist/examples/code/README.md +33 -0
- package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/code/candidate.d.ts +19 -0
- package/dist/examples/code/candidate.js +80 -0
- package/dist/examples/code/config.d.ts +32 -0
- package/dist/examples/code/config.js +18 -0
- package/dist/examples/code/eject.json +5 -0
- package/dist/examples/code/project.d.ts +3 -0
- package/dist/examples/code/project.js +605 -0
- package/dist/examples/code/prompts.d.ts +5 -0
- package/dist/examples/code/prompts.js +12 -0
- package/dist/examples/code/verification.d.ts +19 -0
- package/dist/examples/code/verification.js +268 -0
- package/dist/examples/code/worktree.d.ts +17 -0
- package/dist/examples/code/worktree.js +233 -0
- package/dist/examples/harness-session/README.md +3 -6
- package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
- package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
- package/dist/examples/lead-worker/harness/index.d.ts +60 -0
- package/dist/examples/lead-worker/harness/index.js +77 -6
- package/dist/examples/lead-worker/project.js +2 -2
- package/dist/examples/lead-worker/services/board.d.ts +5 -0
- package/dist/examples/lead-worker/services/board.js +19 -1
- package/dist/examples/messages/README.md +5 -5
- package/dist/examples/messages/handoff.d.ts +2 -0
- package/dist/examples/messages/handoff.js +5 -1
- package/dist/examples/messages/project.js +52 -2
- package/dist/examples/notes/README.md +13 -18
- package/dist/examples/notes/project.js +67 -6
- package/dist/examples/peermesh/harness/router.js +3 -1
- package/dist/examples/peermesh/harness/team.d.ts +8 -0
- package/dist/examples/peermesh/harness/team.js +13 -0
- package/dist/examples/peermesh/project.js +22 -4
- package/dist/examples/services/agent-control/README.md +3 -3
- package/dist/examples/services/mathlib-search/Dockerfile +4 -2
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +2 -2
- package/dist/examples/services/persistent-board/README.md +16 -3
- package/dist/examples/services/persistent-board/business.d.ts +7 -0
- package/dist/examples/services/persistent-board/business.js +7 -0
- package/dist/examples/services/persistent-board/index.js +10 -0
- package/dist/examples/services/persistent-board/live.d.ts +3 -0
- package/dist/examples/services/persistent-board/live.js +58 -0
- package/dist/examples/subagents/README.md +5 -5
- package/dist/examples/subagents/business.js +3 -1
- package/dist/examples/subagents/config.js +3 -3
- package/dist/examples/subagents/harness/controller.d.ts +15 -0
- package/dist/examples/subagents/harness/controller.js +181 -32
- package/dist/examples/subagents/project.d.ts +2 -0
- package/dist/examples/subagents/project.js +43 -34
- package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
- package/dist/examples/subagents/prompts/prompts.js +3 -0
- package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
- package/dist/examples/subagents/services/collaboration-service.js +14 -2
- package/dist/examples/substrate/README.md +2 -2
- package/dist/examples/substrate/harness/index.d.ts +1 -1
- package/dist/examples/substrate/harness/index.js +77 -12
- package/dist/examples/substrate/project.js +4 -1
- package/dist/examples/super/README.md +52 -0
- package/dist/examples/super/actions.d.ts +95 -0
- package/dist/examples/super/actions.js +230 -0
- package/dist/examples/super/artifact.d.ts +4 -0
- package/dist/examples/super/artifact.js +51 -0
- package/dist/examples/super/config.d.ts +80 -0
- package/dist/examples/super/config.js +83 -0
- package/dist/examples/super/coordinator.d.ts +33 -0
- package/dist/examples/super/coordinator.js +151 -0
- package/dist/examples/super/daemon.d.ts +11 -0
- package/dist/examples/super/daemon.js +109 -0
- package/dist/examples/super/decisions.d.ts +8 -0
- package/dist/examples/super/decisions.js +52 -0
- package/dist/examples/super/eject.json +5 -0
- package/dist/examples/super/execution.d.ts +11 -0
- package/dist/examples/super/execution.js +136 -0
- package/dist/examples/super/github.d.ts +62 -0
- package/dist/examples/super/github.js +269 -0
- package/dist/examples/super/inbox.d.ts +162 -0
- package/dist/examples/super/inbox.js +284 -0
- package/dist/examples/super/location.d.ts +5 -0
- package/dist/examples/super/location.js +64 -0
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/outbox.d.ts +5 -0
- package/dist/examples/super/outbox.js +103 -0
- package/dist/examples/super/project.d.ts +4 -0
- package/dist/examples/super/project.js +251 -0
- package/dist/examples/super/prompts.d.ts +3 -0
- package/dist/examples/super/prompts.js +25 -0
- package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/dist/examples/taskpool/harness/controller.d.ts +35 -6
- package/dist/examples/taskpool/harness/controller.js +73 -7
- package/dist/examples/taskpool/project.js +18 -2
- package/dist/scripts/anyswarm-arguments.d.ts +18 -6
- package/dist/scripts/anyswarm-arguments.js +88 -52
- package/dist/scripts/anyswarm-author.d.ts +5 -0
- package/dist/scripts/anyswarm-author.js +24 -0
- package/dist/scripts/anyswarm-eject.d.ts +11 -0
- package/dist/scripts/anyswarm-eject.js +164 -0
- package/dist/scripts/anyswarm-harnesses.d.ts +1 -0
- package/dist/scripts/anyswarm-harnesses.js +10 -0
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -285
- package/dist/scripts/anyswarm-launch.d.ts +7 -0
- package/dist/scripts/anyswarm-launch.js +37 -0
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +102 -0
- package/dist/scripts/anyswarm-project.d.ts +3 -1
- package/dist/scripts/anyswarm-project.js +49 -35
- package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
- package/dist/scripts/anyswarm-source-runner.js +200 -0
- package/dist/scripts/anyswarm.js +28 -3
- package/dist/scripts/build-provenance.json +1 -0
- package/dist/scripts/build.js +7 -1
- package/dist/scripts/generate-architecture-api.js +2 -0
- package/dist/scripts/generate-architecture-prompts.js +24 -2
- package/dist/scripts/local-environment.d.ts +13 -2
- package/dist/scripts/local-environment.js +111 -28
- package/dist/scripts/local-setup-smoke.js +3 -2
- package/dist/scripts/local-setup-worker.d.ts +1 -1
- package/dist/scripts/local-setup-worker.js +15 -6
- package/dist/scripts/local-setup.d.ts +5 -2
- package/dist/scripts/local-setup.js +167 -79
- package/dist/scripts/opensandbox-agent-worker.js +2 -2
- package/dist/scripts/pack-release.d.ts +1 -0
- package/dist/scripts/pack-release.js +66 -0
- package/dist/scripts/pi-session-bridge.js +11 -3
- package/dist/scripts/run-harness.js +3 -1
- package/dist/scripts/setup-bootstrap.js +43 -6
- package/dist/src/core/allocation-ledger.js +4 -3
- package/dist/src/core/host-identity.d.ts +2 -0
- package/dist/src/core/host-identity.js +11 -0
- package/dist/src/core/index.d.ts +4 -2
- package/dist/src/core/index.js +12 -4
- package/dist/src/core/mcp-service.js +2 -2
- package/dist/src/core/runtime-management.d.ts +6 -0
- package/dist/src/core/runtime-management.js +24 -0
- package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
- package/dist/src/core/sandbox/executor-driver.js +12 -14
- package/dist/src/core/sandbox/local-executor.d.ts +13 -1
- package/dist/src/core/sandbox/local-executor.js +69 -19
- package/dist/src/core/sandbox/local-worker.js +32 -21
- package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
- package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
- package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
- package/dist/src/core/sandbox/sandbox-connection.js +14 -6
- package/dist/src/core/service-live-state.d.ts +14 -0
- package/dist/src/core/service-live-state.js +161 -0
- package/dist/src/core/service-observation-types.d.ts +21 -1
- package/dist/src/core/service-process.d.ts +1 -1
- package/dist/src/core/service-process.js +45 -4
- package/dist/src/core/service-types.d.ts +5 -1
- package/dist/src/core/services.d.ts +1 -1
- package/dist/src/core/services.js +8 -3
- package/dist/src/core/types.d.ts +3 -0
- package/dist/src/core/worker-image.js +3 -3
- package/dist/src/harness/harness-session-types.d.ts +10 -0
- package/dist/src/harness/harness-session.js +42 -5
- package/dist/src/harness/project-harness.d.ts +14 -1
- package/dist/src/harness/project-harness.js +38 -12
- package/dist/src/harness/project-input.js +81 -15
- package/dist/src/harness/project-rpc-client.d.ts +1 -0
- package/dist/src/harness/project-rpc-client.js +5 -0
- package/dist/src/harness/project-rpc.d.ts +8 -2
- package/dist/src/harness/project-rpc.js +31 -7
- package/dist/src/harness/project-runtime.js +6 -2
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +41 -0
- package/dist/src/trace-viewer/public/app.js +6 -5
- package/dist/src/trace-viewer/reader.mjs +42 -2
- package/docs/INDEX.md +5 -2
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-agent-core.md +1 -1
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/06-observability-experiments.md +1 -1
- package/docs/architecture/07-run-configuration.md +38 -18
- package/docs/architecture/08-prompts.md +22 -0
- package/docs/architecture/10-service-api-reference.md +53 -18
- package/docs/architecture/11-storage-reference.md +18 -1
- package/docs/architecture/12-code-coverage.md +152 -89
- package/docs/architecture/15-core-runtime.md +8 -0
- package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/19-substrate-harness.md +28 -1
- package/docs/architecture/20-lead-worker-harness.md +34 -1
- package/docs/architecture/22-website.md +5 -6
- package/docs/architecture/23-project-harness.md +152 -8
- package/docs/architecture/24-runtime-recovery.md +10 -3
- package/docs/architecture/26-code.md +54 -0
- package/docs/architecture/27-personal.md +58 -0
- package/docs/architecture/28-autoresearch.md +43 -0
- package/docs/architecture/INDEX.md +3 -0
- package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
- package/docs/architecture/prompts/08-subagents-harness.md +21 -0
- package/docs/architecture/prompts/21-personal.md +44 -0
- package/docs/architecture/prompts/22-autoresearch.md +63 -0
- package/docs/architecture/prompts/26-code.md +55 -0
- package/docs/architecture/prompts/source-manifest.json +152 -33
- package/docs/architecture/source-map.json +473 -25
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +13 -2
- package/docs/designs/core-harness/README.md +7 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +3 -5
- package/docs/en/changelog.md +20 -4
- package/docs/en/first-harness.md +9 -12
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +14 -121
- package/docs/en/overview.md +1 -1
- package/docs/en/quickstart.md +42 -39
- package/docs/en/reference/api.md +14 -4
- package/docs/en/reference/cli.md +53 -47
- package/docs/en/runtime.md +2 -2
- package/docs/en/sandbox.md +3 -3
- package/docs/en/services.md +4 -0
- package/docs/operations/trace-viewer.md +1 -1
- package/docs/workflows/development.md +28 -21
- package/docs/workflows/release-and-docs-versioning.md +77 -0
- package/docs/workflows/release-cli-acceptance.md +85 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +3 -5
- package/docs/zh/changelog.md +20 -4
- package/docs/zh/first-harness.md +9 -12
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +15 -122
- package/docs/zh/overview.md +1 -1
- package/docs/zh/quickstart.md +42 -39
- package/docs/zh/reference/api.md +14 -4
- package/docs/zh/reference/cli.md +24 -40
- package/docs/zh/runtime.md +2 -2
- package/docs/zh/sandbox.md +3 -3
- package/docs/zh/services.md +4 -0
- package/examples/README.md +35 -12
- package/examples/authoring/README.md +24 -0
- package/examples/authoring/business.ts +4 -0
- package/examples/authoring/config.ts +2 -0
- package/examples/authoring/eject.json +5 -0
- package/examples/authoring/harness.ts +21 -0
- package/examples/autoresearch/README.md +40 -0
- package/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/examples/autoresearch/config.ts +90 -0
- package/examples/autoresearch/demo.ts +55 -0
- package/examples/autoresearch/eject.json +17 -0
- package/examples/autoresearch/frontiercs2-config.ts +4 -0
- package/examples/autoresearch/frontiercs2.ts +237 -0
- package/examples/autoresearch/prepare-demo.ts +15 -0
- package/examples/autoresearch/prepare.ts +267 -0
- package/examples/autoresearch/process.ts +50 -0
- package/examples/autoresearch/project.ts +380 -0
- package/examples/autoresearch/research-service.ts +302 -0
- package/examples/code/README.md +33 -0
- package/examples/code/REQUIREMENTS.zh.md +11 -0
- package/examples/code/candidate.ts +89 -0
- package/examples/code/config.ts +19 -0
- package/examples/code/eject.json +5 -0
- package/examples/code/project.ts +581 -0
- package/examples/code/prompts.ts +16 -0
- package/examples/code/verification.ts +239 -0
- package/examples/code/worktree.ts +188 -0
- package/examples/harness-session/README.md +3 -6
- package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
- package/examples/lead-worker/harness/index.ts +61 -6
- package/examples/lead-worker/project.ts +2 -2
- package/examples/lead-worker/services/board.ts +14 -1
- package/examples/messages/README.md +5 -5
- package/examples/messages/handoff.ts +6 -2
- package/examples/messages/project.ts +47 -2
- package/examples/notes/README.md +13 -18
- package/examples/notes/project.ts +57 -9
- package/examples/peermesh/harness/router.ts +2 -2
- package/examples/peermesh/harness/team.ts +11 -0
- package/examples/peermesh/project.ts +19 -4
- package/examples/services/agent-control/README.md +3 -3
- package/examples/services/mathlib-search/Dockerfile +4 -2
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +2 -2
- package/examples/services/persistent-board/README.md +16 -3
- package/examples/services/persistent-board/business.ts +10 -0
- package/examples/services/persistent-board/index.ts +10 -0
- package/examples/services/persistent-board/live.ts +54 -0
- package/examples/subagents/README.md +5 -5
- package/examples/subagents/business.ts +3 -1
- package/examples/subagents/config.ts +4 -3
- package/examples/subagents/harness/controller.ts +161 -29
- package/examples/subagents/project.ts +47 -33
- package/examples/subagents/prompts/prompts.ts +4 -0
- package/examples/subagents/services/collaboration-service.ts +14 -2
- package/examples/substrate/README.md +2 -2
- package/examples/substrate/harness/index.ts +67 -11
- package/examples/substrate/project.ts +5 -1
- package/examples/super/README.md +52 -0
- package/examples/super/actions.ts +196 -0
- package/examples/super/artifact.ts +56 -0
- package/examples/super/config.ts +95 -0
- package/examples/super/coordinator.ts +158 -0
- package/examples/super/daemon.ts +84 -0
- package/examples/super/decisions.ts +46 -0
- package/examples/super/eject.json +5 -0
- package/examples/super/execution.ts +131 -0
- package/examples/super/github.ts +242 -0
- package/examples/super/inbox.ts +306 -0
- package/examples/super/location.ts +54 -0
- package/examples/super/operator.ts +28 -0
- package/examples/super/outbox.ts +97 -0
- package/examples/super/project.ts +225 -0
- package/examples/super/prompts.ts +27 -0
- package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/examples/taskpool/harness/controller.ts +59 -7
- package/examples/taskpool/project.ts +18 -2
- package/npm-shrinkwrap.development.json +700 -0
- package/npm-shrinkwrap.json +95 -1969
- package/package.development.json +88 -0
- package/package.json +11 -8
- package/scripts/anyswarm-arguments.ts +91 -54
- package/scripts/anyswarm-author.ts +25 -0
- package/scripts/anyswarm-eject.ts +145 -0
- package/scripts/anyswarm-harnesses.ts +10 -0
- package/scripts/anyswarm-installation.ts +18 -288
- package/scripts/anyswarm-launch.ts +36 -0
- package/scripts/anyswarm-progress.ts +95 -0
- package/scripts/anyswarm-project.ts +35 -34
- package/scripts/anyswarm-source-runner.ts +176 -0
- package/scripts/anyswarm.ts +24 -3
- package/scripts/build.ts +8 -1
- package/scripts/generate-architecture-api.ts +2 -0
- package/scripts/generate-architecture-prompts.ts +35 -2
- package/scripts/local-environment.ts +117 -28
- package/scripts/local-setup-smoke.ts +3 -2
- package/scripts/local-setup-worker.ts +17 -7
- package/scripts/local-setup.ts +166 -73
- package/scripts/opensandbox-agent-worker.ts +2 -2
- package/scripts/pack-release.ts +70 -0
- package/scripts/pi-session-bridge.ts +10 -2
- package/scripts/run-harness.ts +3 -1
- package/scripts/setup-bootstrap.ts +41 -6
- package/src/core/allocation-ledger.ts +5 -3
- package/src/core/host-identity.ts +11 -0
- package/src/core/index.ts +12 -6
- package/src/core/mcp-service.ts +2 -2
- package/src/core/runtime-management.ts +22 -0
- package/src/core/sandbox/executor-driver.ts +15 -18
- package/src/core/sandbox/local-executor.ts +65 -19
- package/src/core/sandbox/local-worker.ts +29 -21
- package/src/core/sandbox/opensandbox-backend.ts +36 -11
- package/src/core/sandbox/sandbox-connection.ts +14 -5
- package/src/core/service-live-state.ts +156 -0
- package/src/core/service-observation-types.ts +23 -1
- package/src/core/service-process.ts +36 -3
- package/src/core/service-types.ts +3 -1
- package/src/core/services.ts +8 -3
- package/src/core/types.ts +3 -0
- package/src/core/worker-image.ts +3 -3
- package/src/harness/harness-session-types.ts +13 -1
- package/src/harness/harness-session.ts +40 -7
- package/src/harness/project-harness.ts +38 -12
- package/src/harness/project-input.ts +73 -15
- package/src/harness/project-rpc-client.ts +5 -0
- package/src/harness/project-rpc.ts +29 -8
- package/src/harness/project-runtime.ts +4 -2
- package/src/harness/typescript-loader.ts +37 -0
- package/src/trace-viewer/public/app.js +6 -5
- package/src/trace-viewer/reader.mjs +42 -2
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { registerHooks } from 'node:module';
|
|
4
|
+
import { closeSync, mkdtempSync, openSync, readSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { verifyExportedSdk } from './anyswarm-eject.js';
|
|
7
|
+
import type { Harness } from '../src/harness/project-harness.js';
|
|
8
|
+
import { installSourceLoader } from '../src/harness/typescript-loader.js';
|
|
9
|
+
import { parseSourceHarnessCommand } from './anyswarm-arguments.js';
|
|
10
|
+
|
|
11
|
+
const [, , entry, ...args] = process.argv;
|
|
12
|
+
if (!entry) throw new TypeError('A TypeScript or JavaScript entry file is required');
|
|
13
|
+
const filename = resolve(entry);
|
|
14
|
+
const entryUrl = pathToFileURL(filename).href;
|
|
15
|
+
process.argv = [process.execPath, filename, ...args];
|
|
16
|
+
installSourceLoader();
|
|
17
|
+
|
|
18
|
+
const hasPrompt = args.some(arg => /^--prompt(?:=|$)/.test(arg));
|
|
19
|
+
const hasMode = args.some(arg => /^--mode(?:=|$)/.test(arg));
|
|
20
|
+
|
|
21
|
+
type SourceModule = { default?: Harness };
|
|
22
|
+
const isHarness = (source: SourceModule): source is { default: Harness } =>
|
|
23
|
+
source.default?.apiVersion === 1 && typeof source.default.run === 'function';
|
|
24
|
+
|
|
25
|
+
async function importWithDiagnostics<T>(load: () => Promise<T>, useStderr = true): Promise<T> {
|
|
26
|
+
if (!useStderr) return load();
|
|
27
|
+
const stdout = process.stdout.write;
|
|
28
|
+
process.stdout.write = process.stderr.write.bind(process.stderr);
|
|
29
|
+
try { return await load(); } finally { process.stdout.write = stdout; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function importImplicitSource(load: () => Promise<SourceModule>) {
|
|
33
|
+
const { init, parse } = await import('es-module-lexer');
|
|
34
|
+
await init;
|
|
35
|
+
const stdout = process.stdout.write;
|
|
36
|
+
let pending: number | undefined;
|
|
37
|
+
let position = 0;
|
|
38
|
+
let streaming = false;
|
|
39
|
+
let interactiveOutput = false;
|
|
40
|
+
let inputReplay: Promise<void> | undefined;
|
|
41
|
+
const hook = registerHooks({ load(url, context, nextLoad) {
|
|
42
|
+
const loaded = nextLoad(url, context);
|
|
43
|
+
if (url === entryUrl && loaded.format === 'module' && loaded.source !== undefined) {
|
|
44
|
+
try {
|
|
45
|
+
const code = typeof loaded.source === 'string' ? loaded.source : new TextDecoder().decode(loaded.source);
|
|
46
|
+
const hasDefault = parse(code)[1].some(entry => 'name' in entry && entry.name === 'default' && !entry.typeOnly);
|
|
47
|
+
if (!hasDefault) {
|
|
48
|
+
streaming = true;
|
|
49
|
+
process.stdout.write = stdout;
|
|
50
|
+
}
|
|
51
|
+
} catch { /* Let Node diagnose the source if the lexer cannot classify it. */ }
|
|
52
|
+
}
|
|
53
|
+
return loaded;
|
|
54
|
+
} });
|
|
55
|
+
type WriteCallback = (error?: Error | null) => void;
|
|
56
|
+
process.stdout.write = (chunk: string | Uint8Array, encoding?: BufferEncoding | WriteCallback, callback?: WriteCallback) => {
|
|
57
|
+
const charset = typeof encoding === 'string' ? encoding : undefined;
|
|
58
|
+
const done = typeof encoding === 'function' ? encoding : callback;
|
|
59
|
+
if (streaming && pending === undefined) {
|
|
60
|
+
interactiveOutput = true;
|
|
61
|
+
return stdout.call(process.stdout, chunk, charset, done);
|
|
62
|
+
}
|
|
63
|
+
if (pending === undefined) {
|
|
64
|
+
const directory = mkdtempSync(join(tmpdir(), 'anys-source-output-'));
|
|
65
|
+
const path = join(directory, 'stdout');
|
|
66
|
+
try {
|
|
67
|
+
pending = openSync(path, 'wx+', 0o600);
|
|
68
|
+
unlinkSync(path);
|
|
69
|
+
} finally { rmdirSync(directory); }
|
|
70
|
+
}
|
|
71
|
+
writeFileSync(pending, chunk, charset);
|
|
72
|
+
if (done) process.nextTick(done);
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
async function replay(destination: NodeJS.WriteStream) {
|
|
76
|
+
const fd = pending;
|
|
77
|
+
const write = destination === process.stdout ? stdout : destination.write;
|
|
78
|
+
try {
|
|
79
|
+
if (fd === undefined) return;
|
|
80
|
+
const chunk = Buffer.alloc(64 * 1024);
|
|
81
|
+
for (;;) {
|
|
82
|
+
const size = readSync(fd, chunk, 0, chunk.length, position);
|
|
83
|
+
if (!size) break;
|
|
84
|
+
position += size;
|
|
85
|
+
await new Promise<void>((done, reject) =>
|
|
86
|
+
write.call(destination, chunk.subarray(0, size), undefined, error => error ? reject(error) : done()));
|
|
87
|
+
}
|
|
88
|
+
} finally {
|
|
89
|
+
pending = undefined;
|
|
90
|
+
if (fd !== undefined) closeSync(fd);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const streamForInput = () => {
|
|
94
|
+
if (streaming) return;
|
|
95
|
+
streaming = true;
|
|
96
|
+
interactiveOutput = pending !== undefined;
|
|
97
|
+
inputReplay = replay(process.stdout);
|
|
98
|
+
void inputReplay.catch(() => {});
|
|
99
|
+
};
|
|
100
|
+
const stdin = process.stdin;
|
|
101
|
+
const read = stdin.read;
|
|
102
|
+
const ownRead = Object.getOwnPropertyDescriptor(stdin, 'read');
|
|
103
|
+
function readForInput(this: typeof stdin, size?: number) {
|
|
104
|
+
// Readable also calls read(0) internally to prepare its buffer.
|
|
105
|
+
if (size !== 0) streamForInput();
|
|
106
|
+
return read.call(this, size);
|
|
107
|
+
}
|
|
108
|
+
const watchInput = (event: string | symbol) => {
|
|
109
|
+
if (event === 'data' || event === 'readable' || event === 'keypress') streamForInput();
|
|
110
|
+
};
|
|
111
|
+
stdin.read = readForInput;
|
|
112
|
+
stdin.on('newListener', watchInput).on('resume', streamForInput);
|
|
113
|
+
// Explicit exit cannot wait on queued pipe writes. Keep stdout's normal
|
|
114
|
+
// backpressure and leave any queued replay writes in their original order.
|
|
115
|
+
const flushOnExit = () => {
|
|
116
|
+
if (pending === undefined || position > 0) return;
|
|
117
|
+
try {
|
|
118
|
+
for (;;) {
|
|
119
|
+
const chunk = Buffer.alloc(64 * 1024);
|
|
120
|
+
const size = readSync(pending, chunk, 0, chunk.length, position);
|
|
121
|
+
if (!size || !stdout.call(process.stdout, chunk.subarray(0, size))) return;
|
|
122
|
+
position += size;
|
|
123
|
+
}
|
|
124
|
+
} catch { /* Preserve the explicit exit code if output can no longer be written. */ }
|
|
125
|
+
};
|
|
126
|
+
process.once('exit', flushOnExit);
|
|
127
|
+
let destination: NodeJS.WriteStream = process.stderr;
|
|
128
|
+
try {
|
|
129
|
+
const source = await load();
|
|
130
|
+
if (!isHarness(source)) destination = process.stdout;
|
|
131
|
+
else if (interactiveOutput) {
|
|
132
|
+
throw new Error('Use an explicit --prompt for a task Harness that writes to stdout while reading stdin during import.');
|
|
133
|
+
}
|
|
134
|
+
return source;
|
|
135
|
+
} finally {
|
|
136
|
+
hook.deregister();
|
|
137
|
+
stdin.off('newListener', watchInput).off('resume', streamForInput);
|
|
138
|
+
if (stdin.read === readForInput) {
|
|
139
|
+
if (ownRead) Object.defineProperty(stdin, 'read', ownRead);
|
|
140
|
+
else Reflect.deleteProperty(stdin, 'read');
|
|
141
|
+
}
|
|
142
|
+
try { await (inputReplay ?? replay(destination)); }
|
|
143
|
+
finally {
|
|
144
|
+
process.stdout.write = stdout;
|
|
145
|
+
process.off('exit', flushOnExit);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
const verifySdk = await verifyExportedSdk(filename);
|
|
152
|
+
if (verifySdk) {
|
|
153
|
+
const sdk = '@anyswarm/core';
|
|
154
|
+
let checkingEntry = true;
|
|
155
|
+
registerHooks({ resolve(specifier, context, nextResolve) {
|
|
156
|
+
if (specifier !== sdk) return nextResolve(specifier, context);
|
|
157
|
+
const resolved = nextResolve(specifier, checkingEntry ? { ...context, parentURL: entryUrl } : context);
|
|
158
|
+
verifySdk(resolved.url);
|
|
159
|
+
return resolved;
|
|
160
|
+
} });
|
|
161
|
+
// Use Node's ESM conditions with the same parent and fallback as the entry.
|
|
162
|
+
try { import.meta.resolve(sdk); } finally { checkingEntry = false; }
|
|
163
|
+
}
|
|
164
|
+
const load = (): Promise<SourceModule> => import(entryUrl);
|
|
165
|
+
const source = await (hasPrompt || hasMode ? importWithDiagnostics(load) : importImplicitSource(load));
|
|
166
|
+
if (isHarness(source)) {
|
|
167
|
+
const command = parseSourceHarnessCommand(args, filename);
|
|
168
|
+
const diagnostics = { onSourceError(error: unknown) { console.error(error instanceof Error ? error.stack : String(error)); } };
|
|
169
|
+
const { runProjectCommand } = await import('./anyswarm-project.js');
|
|
170
|
+
const code = await runProjectCommand(command, process.cwd(), diagnostics);
|
|
171
|
+
process.stdout.write('', () => process.exit(code));
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error(error instanceof Error ? error.stack : String(error));
|
|
175
|
+
process.exitCode = 1;
|
|
176
|
+
}
|
package/scripts/anyswarm.ts
CHANGED
|
@@ -34,6 +34,24 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
34
34
|
process.exitCode = 2;
|
|
35
35
|
}
|
|
36
36
|
if (command && 'help' in command) console.log(command.help);
|
|
37
|
+
if (command && 'command' in command && command.command === 'run') {
|
|
38
|
+
try {
|
|
39
|
+
const { runSourceCommand } = await import('./anyswarm-author.js');
|
|
40
|
+
process.exitCode = await runSourceCommand(command, process.cwd());
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(error instanceof Error ? error.message : 'Could not run the TypeScript Harness.');
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (command && 'command' in command && command.command === 'eject') {
|
|
47
|
+
try {
|
|
48
|
+
const { ejectSourceCommand } = await import('./anyswarm-author.js');
|
|
49
|
+
console.log(JSON.stringify(await ejectSourceCommand(command, process.cwd())));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(error instanceof Error ? error.message : 'Could not export the application.');
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
37
55
|
if (command && 'command' in command && command.command === 'harness') {
|
|
38
56
|
const { runProjectCommand } = await import('./anyswarm-project.js');
|
|
39
57
|
process.exit(await runProjectCommand(command, process.cwd()));
|
|
@@ -43,6 +61,8 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
43
61
|
let report: unknown;
|
|
44
62
|
try {
|
|
45
63
|
const { recoverRuntime } = await import('../src/core/index.js');
|
|
64
|
+
const { installSourceLoader } = await import('../src/harness/typescript-loader.js');
|
|
65
|
+
installSourceLoader();
|
|
46
66
|
const module = await import(pathToFileURL(await realpath(resolve(command.configPath))).href);
|
|
47
67
|
const config = typeof module.default === 'function' ? await module.default() : module.default;
|
|
48
68
|
const runtime = await recoverRuntime({ ...config, runDirectory: command.directory, cleanupOnly: true });
|
|
@@ -58,7 +78,7 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
58
78
|
// Pending cleanup can still own open sockets and renewable resources. The
|
|
59
79
|
// one-shot command hands those back to the durable record on process exit.
|
|
60
80
|
process.stdout.write(JSON.stringify(report, null, 2) + '\n', () => process.exit(exitCode));
|
|
61
|
-
} else if (command && 'command' in command) {
|
|
81
|
+
} else if (command && 'command' in command && (command.command === 'setup' || command.command === 'doctor' || command.command === 'update')) {
|
|
62
82
|
const controller = new AbortController();
|
|
63
83
|
let signalCode: number | undefined;
|
|
64
84
|
const interrupt = (signal: NodeJS.Signals) => {
|
|
@@ -69,10 +89,11 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
69
89
|
process.on('SIGTERM', interrupt);
|
|
70
90
|
try {
|
|
71
91
|
const report = command.command === 'update'
|
|
72
|
-
? await (await import('./anyswarm-installation.js')).updateAnySwarm(
|
|
92
|
+
? await (await import('./anyswarm-installation.js')).updateAnySwarm(controller.signal)
|
|
73
93
|
: await (await import('./local-setup.js')).runLocalCommand(command, controller.signal,
|
|
74
94
|
command.command === 'setup' || process.stderr.isTTY ? message => console.error(message) : undefined);
|
|
75
|
-
console.log(
|
|
95
|
+
if (command.command === 'update' && process.stdout.isTTY) console.log((report as { detail: string }).detail);
|
|
96
|
+
else console.log(JSON.stringify(report, null, 2));
|
|
76
97
|
process.exitCode = signalCode ?? (report.ok ? 0 : 1);
|
|
77
98
|
} catch {
|
|
78
99
|
console.error(JSON.stringify({ ok: false, error: 'The requested AnySwarm command could not start. Rebuild or reinstall @anyswarm/core.' }));
|
package/scripts/build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { chmod, cp, readdir, rm, stat } from 'node:fs/promises';
|
|
2
|
+
import { chmod, cp, readdir, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
|
|
@@ -55,3 +55,10 @@ if (await stat(traceViewerSource).catch(error => {
|
|
|
55
55
|
for (const name of ['anyswarm', 'swarm']) {
|
|
56
56
|
await chmod(resolve(dist, `scripts/${name}.js`), 0o755);
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
const revision = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' });
|
|
60
|
+
const status = spawnSync('git', ['status', '--porcelain'], { cwd: root, encoding: 'utf8' });
|
|
61
|
+
await writeFile(resolve(dist, 'scripts/build-provenance.json'), JSON.stringify({
|
|
62
|
+
commit: revision.status === 0 ? revision.stdout.trim() : null,
|
|
63
|
+
dirty: status.status === 0 ? Boolean(status.stdout.trim()) : null,
|
|
64
|
+
}) + '\n');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { PERSONAL_SCHEMA_SQL } from '../examples/super/inbox.js';
|
|
2
3
|
import { SERVICE_COMMIT_SCHEMA_SQL, CONTEXT_PEER_SCHEMA_SQL, JUDGE_PEER_SCHEMA_SQL } from '../examples/taskpool/persistence/service-peer-schema.js';
|
|
3
4
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
5
|
import { createHash } from 'node:crypto';
|
|
@@ -63,6 +64,7 @@ for (const source of sourcePaths.filter((path: any) => path.startsWith('src/core
|
|
|
63
64
|
|
|
64
65
|
const { ALLOCATION_SCHEMA_SQL } = await import('../src/core/allocation-ledger.js');
|
|
65
66
|
const schemas = [
|
|
67
|
+
['Personal inbox, work and delivery', 'examples/super/inbox.ts', PERSONAL_SCHEMA_SQL],
|
|
66
68
|
['Core Runtime allocation ownership', 'src/core/allocation-ledger.ts', ALLOCATION_SCHEMA_SQL],
|
|
67
69
|
['Automatic service history', 'examples/taskpool/persistence/service-history.ts', SERVICE_HISTORY_SCHEMA_SQL],
|
|
68
70
|
['Task-owned independent service commit gates', 'examples/taskpool/persistence/service-peer-schema.ts', SERVICE_COMMIT_SCHEMA_SQL],
|
|
@@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
9
9
|
import vm from 'node:vm';
|
|
10
10
|
import { SETUP_PROFILE_PROMPT, SETUP_FOLLOW_UP } from './local-setup-smoke.js';
|
|
11
11
|
import { SETUP_BASH, SETUP_READ, SETUP_RESULT } from './local-setup-upstream.js';
|
|
12
|
-
import { rootPrompt, childPrompt } from '../examples/subagents/prompts/prompts.js';
|
|
12
|
+
import { rootPrompt, childPrompt, ownerInterventionText } from '../examples/subagents/prompts/prompts.js';
|
|
13
13
|
import { parentPromptFor, initialGoalFor } from '../test-support/subagents/communication-fixture-prompts.js';
|
|
14
14
|
import { AGENT_ROLES, buildCapabilityProfile } from '../test-support/taskpool-legacy/capability-profile.js';
|
|
15
15
|
import { AGENT_CONTINUATION_MESSAGE, AGENT_SOFT_CLOSEOUT_MESSAGE, AGENT_MATERIAL_CONTINUATION_MESSAGE, AGENT_MATERIAL_SOFT_CLOSEOUT_MESSAGE, buildAgentSoftCloseoutNotice, buildAgentNotification, agentServiceDirectory } from '../examples/taskpool/prompts/agent-contract.js';
|
|
@@ -32,7 +32,9 @@ assert.ok(args.length === 0 || (args.length === 1 && args[0] === '--check'), 'Us
|
|
|
32
32
|
const check = args[0] === '--check';
|
|
33
33
|
const sha256 = (text: string) => createHash('sha256').update(text).digest('hex');
|
|
34
34
|
const sourcePaths = [
|
|
35
|
+
'examples/super/prompts.ts', 'examples/super/execution.ts', 'examples/super/coordinator.ts',
|
|
35
36
|
'examples/taskpool/prompts/agent-contract.ts',
|
|
37
|
+
'examples/autoresearch/project.ts', 'examples/autoresearch/config.ts',
|
|
36
38
|
'examples/services/agent-control/run.ts', 'examples/services/agent-control/flow.sh', 'examples/services/persistent-board/run.ts',
|
|
37
39
|
'examples/services/mcp-managed/run.ts', 'examples/first-harness/harness.ts', 'examples/first-harness/handoff.ts',
|
|
38
40
|
'examples/parallel-swarm/harness.ts', 'examples/parallel-swarm/board-service.ts',
|
|
@@ -43,6 +45,7 @@ const sourcePaths = [
|
|
|
43
45
|
'scripts/local-setup-smoke.ts', 'scripts/local-setup-upstream.ts',
|
|
44
46
|
'examples/messages/handoff.ts',
|
|
45
47
|
'examples/notes/main.ts', 'examples/notes/notes.ts', 'examples/notes/project.ts', 'examples/taskpool/project.ts', 'src/harness/project-git.ts', 'src/harness/run-input.ts', 'examples/substrate/harness/index.ts', 'examples/substrate/services/substrate.ts',
|
|
48
|
+
'examples/code/prompts.ts',
|
|
46
49
|
'examples/taskpool/harness/controller.ts', 'examples/taskpool/harness/harness.ts',
|
|
47
50
|
'benchmarks/fate/fate-run.ts', 'benchmarks/fate/fate-service.ts', 'benchmarks/fate/paper-substrate.ts',
|
|
48
51
|
'benchmarks/putnambench-taskpool/run.ts',
|
|
@@ -93,6 +96,17 @@ function header(title: string, description: string) {
|
|
|
93
96
|
const outputs = new Map<string, string>();
|
|
94
97
|
function output(file: string, text: string) { outputs.set(`${outputDir}/${file}`, `${text.trimEnd()}\n`); }
|
|
95
98
|
|
|
99
|
+
const researchSource = 'examples/autoresearch/project.ts';
|
|
100
|
+
let researchDoc = header('AutoResearch peer instructions', 'All peers receive the same Profile instructions. Their first native input uses the peer label, trusted configuration goal and the Run input. Each later turn uses a fixed nudge. An immutable patch can trigger a review notice by active steer or in the next regular input. The demo objective is also the default Run input.');
|
|
101
|
+
researchDoc += block('Shared Profile instruction', evaluate('`' + between(researchSource, 'const instructions = `', '`;') + '`', { candidatePath: '.anyswarm-candidate.patch' }));
|
|
102
|
+
researchDoc += block('Initial peer input', evaluate('`' + between(researchSource, '? `', '`\n', 'const prompt = turn === 0') + '`',
|
|
103
|
+
{ label: '<PEER_LABEL>', config: { goal: '<RESEARCH_GOAL>' }, context: { input: { prompt: '<RUN_INPUT>' } } }));
|
|
104
|
+
researchDoc += block('Follow-up peer input', between(researchSource, ": '", "';", "? `You are "));
|
|
105
|
+
researchDoc += block('Candidate review notice', evaluate('`' + between(researchSource, 'return `', '`;', 'function reviewNotice') + '`',
|
|
106
|
+
{ candidate: '<CANDIDATE_ID>', sha256: '<CANDIDATE_SHA256>' }));
|
|
107
|
+
researchDoc += block('FrontierCS-2 demo objective', between('examples/autoresearch/config.ts', "export const demoGoal = '", "';"));
|
|
108
|
+
output('22-autoresearch.md', researchDoc);
|
|
109
|
+
|
|
96
110
|
const registry = createBuiltinServiceRegistry();
|
|
97
111
|
const profile = buildCapabilityProfile({ registry, role: AGENT_ROLES.BOUND });
|
|
98
112
|
const mathlibBundle = await loadServiceBundle(resolve(root, 'examples/services/mathlib-search'));
|
|
@@ -173,6 +187,17 @@ output('10-local-setup-probe.md', header('Complete local setup probe texts',
|
|
|
173
187
|
+ block('Controlled final text', SETUP_RESULT));
|
|
174
188
|
|
|
175
189
|
const notesPath = 'examples/notes/main.ts';
|
|
190
|
+
const codePrompts = 'examples/code/prompts.ts';
|
|
191
|
+
output('26-code.md', header('Code application prompts',
|
|
192
|
+
'The installed Code Harness stages a role prompt for the writable Root and each delegated editor. User inputs go to Root via runInput. The task property in the authenticated spawn_agent request supplies the child input. Starting with the second task, both receive the previous turn envelope. Root receives child results through wait_agent. The host sends the verification question only for a suggested command and an interactive owner client.')
|
|
193
|
+
+ block('Code Root Profile prompt', between(codePrompts, 'export const codeRootPrompt = `', '`;'))
|
|
194
|
+
+ block('Code editor Profile prompt', between(codePrompts, 'export const codeEditorPrompt = `', '`;'))
|
|
195
|
+
+ block('CLI Service hint', between(codePrompts, 'export const codeCliHint = `', '`;'),
|
|
196
|
+
'Appended to the role prompt when Service tools use the CLI, including Codex.')
|
|
197
|
+
+ block('Later Root and editor input', between(codePrompts, 'task: string) => `', '`;'),
|
|
198
|
+
'The host builds summary from the last recorded outcome, reason, affected paths and verification evidence, with limits on paths, command and output. The user task or delegate assignment supplies task.')
|
|
199
|
+
+ block('Verification confirmation', 'Run ' + between(codePrompts, '=> `Run ', '`;'),
|
|
200
|
+
'The interpolation is the suggested argv from the pre-edit local package.json or Makefile, joined for display.'));
|
|
176
201
|
const notesKey = between(notesPath, "const key = '", "';\n");
|
|
177
202
|
const notesInput = evaluate(between(notesPath, 'const inputText = Object.freeze(', ');\n'), { key: notesKey });
|
|
178
203
|
output('07-notes-harness.md', header('Installed Notes Harness prompts',
|
|
@@ -203,6 +228,7 @@ output('08-subagents-harness.md', header('Subagents Harness prompts',
|
|
|
203
228
|
'The ordinary Harness stages the Root and Child Profile prompts verbatim and sends user or model-authored task text through the collaboration controller. The separate communication fixture stages its own Profile prompts. It sends the default goal or configured goal and supplements through explicit followUp. Child round results are JSON snapshots composed in communication-fixture-controller.ts with childId, eventSeq, outcome, optional output/error and a terminal failure source. These variable fields originate in the accepted Core event, never latestOutput. Parent-created child and followup inputs are model-authored through Bash Agent Service requests.')
|
|
204
229
|
+ block('Root Profile prompt', rootPrompt)
|
|
205
230
|
+ block('Recursive Child Profile prompt', childPrompt)
|
|
231
|
+
+ (['steer', 'interrupt', 'stop'] as const).map(operation => block(`Owner ${operation} notification`, ownerInterventionText(operation))).join('')
|
|
206
232
|
+ block('Pastel example initial task', evaluate(between('benchmarks/programbench-pastel/subagents-example.ts', 'const initial = ', ';\nconst supplement')))
|
|
207
233
|
+ block('Pastel example HSL supplement', evaluate(between('benchmarks/programbench-pastel/subagents-example.ts', 'const supplement = ', ';\nconst probes')))
|
|
208
234
|
+ block('Fixture Parent Profile prompt', evaluate(between(subagentsPath, 'export const parentPrompt = ', ';\n')))
|
|
@@ -382,7 +408,14 @@ const managedMcp = 'examples/services/mcp-managed/run.ts';
|
|
|
382
408
|
output('19-managed-mcp.md', header('Managed MCP and process example prompt',
|
|
383
409
|
'The Host creates the reader and sends one task through runInput. The reader receives only the two granted direct Service tools and no local tools.')
|
|
384
410
|
+ block('Reader task', between(managedMcp, "runInput(runtime, reader.id,\n '", "',")));
|
|
385
|
-
|
|
411
|
+
const personalPrompts = 'examples/super/prompts.ts';
|
|
412
|
+
output('21-personal.md', header('Personal Router and worker prompts',
|
|
413
|
+
'Personal uses a per-work Router Session. The Host sends the validated inbound request or a member result to the Router. Each member turn carries the assignment selected by the Router and the authorized paths.')
|
|
414
|
+
+ ['router', 'worker', 'reviewer'].map(role => block(
|
|
415
|
+
role + ' Profile system prompt',
|
|
416
|
+
evaluate(between(personalPrompts, `export const ${role}Prompt = `, ';\n')),
|
|
417
|
+
)).join(''));
|
|
418
|
+
for (const path of [candidateFirstHarnessPath, parallelHost, durableBoardPath, agentControl, managedMcp, 'examples/super/execution.ts']) {
|
|
386
419
|
for (const [index, line] of sources.get(path)!.split('\n').entries()) {
|
|
387
420
|
if (line.includes('runInput(runtime,')) sendSites.push({ path, line: index + 1, expression: line.trim() });
|
|
388
421
|
}
|
|
@@ -2,7 +2,7 @@ import { execFile, spawn } from 'node:child_process';
|
|
|
2
2
|
import { randomBytes, randomUUID } from 'node:crypto';
|
|
3
3
|
import { access, lstat, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { createConnection, isIP } from 'node:net';
|
|
5
|
-
import { homedir, platform } from 'node:os';
|
|
5
|
+
import { homedir, platform, release } from 'node:os';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
8
8
|
import { fileURLToPath } from 'node:url';
|
|
@@ -16,7 +16,9 @@ const execute = promisify(execFile);
|
|
|
16
16
|
export const localProviderImage = 'opensandbox/server:release-1.2.1@sha256:07f9b39adb8cadf68357dd1b86367068210e960fc4cb50e11b75176387557ea7';
|
|
17
17
|
export const localExecdImage = 'opensandbox/execd:release-1.2.1@sha256:6b12d17844ac7167271488302c71934e47f76abb9ddab19ec8529bd1c1c56b23';
|
|
18
18
|
export const localEgressImage = 'opensandbox/egress:release-1.2.1@sha256:84b98d3b5989a87389c977f6433f8cd3c7998d03aa15aaae41ebcb15b7eb8000';
|
|
19
|
-
const
|
|
19
|
+
const darwin = platform() === 'darwin';
|
|
20
|
+
const nativeArchitecture = process.arch === 'x64' ? 'amd64' : process.arch;
|
|
21
|
+
const profileVersion = darwin ? 'anyswarm-local-darwin-sdk-v1' : 'anyswarm-local-linux-sdk-v3';
|
|
20
22
|
const providerStartupMs = 90_000;
|
|
21
23
|
const sourceRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
22
24
|
const root = sourceRoot.endsWith('/dist/') ? fileURLToPath(new URL('../../', import.meta.url)) : sourceRoot;
|
|
@@ -73,14 +75,35 @@ export function resolveSubagentsEnvironment(config: Partial<LocalEnvironmentConf
|
|
|
73
75
|
return resolveLocalEnvironment(config, 'SUBAGENTS');
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
export function
|
|
78
|
+
export function checkSetupHost(): DiagnosticCheck[] {
|
|
77
79
|
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
80
|
+
const os = platform();
|
|
78
81
|
return [
|
|
79
|
-
check('host.
|
|
80
|
-
|
|
82
|
+
check('host.platform', os === 'linux' || os === 'darwin',
|
|
83
|
+
`Host operating system ${os} ${release()} (${process.arch})`, 'Run this command on Linux or macOS.'),
|
|
84
|
+
check('host.node', major > 22 || major === 22 && minor >= 19, `Node.js ${process.versions.node} (${process.execPath})`, 'Install Node.js 22.19 or newer.'),
|
|
81
85
|
];
|
|
82
86
|
}
|
|
83
87
|
|
|
88
|
+
export async function checkHostTools(signal: AbortSignal) {
|
|
89
|
+
return Promise.all((['npm', 'git'] as const).map(async tool => {
|
|
90
|
+
const id = `host.${tool}`;
|
|
91
|
+
const remedy = tool === 'npm' ? 'Install Node.js with npm and use that installation on PATH.'
|
|
92
|
+
: 'Install Git before running a project Harness that captures local files.';
|
|
93
|
+
const options = { signal, timeout: 5_000 };
|
|
94
|
+
let path: string | undefined;
|
|
95
|
+
try {
|
|
96
|
+
path = (await execute('/bin/sh', ['-c', 'command -v "$1"', 'anyswarm', tool], options)).stdout.trim();
|
|
97
|
+
const version = (await execute(tool, ['--version'], options)).stdout.trim();
|
|
98
|
+
return check(id, true, `${tool === 'git' ? version : 'npm ' + version} (${path})`);
|
|
99
|
+
} catch {
|
|
100
|
+
signal.throwIfAborted();
|
|
101
|
+
const detail = path ? `Could not verify ${tool} at ${path}.` : `${tool} was not found on PATH.`;
|
|
102
|
+
return check(id, false, detail, remedy);
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
|
|
84
107
|
async function dockerInstallRemedy(): Promise<string> {
|
|
85
108
|
const release = await readFile('/etc/os-release', 'utf8').catch(() => '');
|
|
86
109
|
const id = /^ID="?([a-z0-9_-]+)/m.exec(release)?.[1];
|
|
@@ -101,31 +124,81 @@ async function dockerInstallRemedy(): Promise<string> {
|
|
|
101
124
|
export async function resolveLocalDocker() {
|
|
102
125
|
const socket = await localDockerSocket();
|
|
103
126
|
const info = JSON.parse(await run('docker', ['info', '--format', '{{json .}}']));
|
|
104
|
-
if (info.OSType !== 'linux')
|
|
105
|
-
|
|
127
|
+
if (info.OSType !== 'linux') {
|
|
128
|
+
throw Object.assign(new Error('Local setup needs a Linux Docker Engine.'), { code: 'DOCKER_OS' });
|
|
129
|
+
}
|
|
130
|
+
if (darwin && ![nativeArchitecture, ...(nativeArchitecture === 'arm64' ? ['aarch64'] : ['x86_64'])].includes(info.Architecture)) {
|
|
131
|
+
throw Object.assign(new Error('The Docker daemon does not match the native Mac architecture.'), { code: 'DOCKER_ARCHITECTURE' });
|
|
132
|
+
}
|
|
133
|
+
const bridge = darwin ? undefined : JSON.parse(await run('docker', ['network', 'inspect', 'bridge']).catch(() => '[]'))[0];
|
|
106
134
|
const advertiseHost: string | undefined = bridge?.IPAM?.Config?.find((entry: { Gateway?: string }) => isIP(entry.Gateway ?? '') === 4)?.Gateway;
|
|
107
|
-
return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value: string) => value.includes('rootless')) === true
|
|
135
|
+
return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value: string) => value.includes('rootless')) === true,
|
|
136
|
+
clientVersion: info.ClientInfo?.Version as string | undefined, context: info.ClientInfo?.Context as string | undefined,
|
|
137
|
+
engineVersion: info.ServerVersion as string | undefined };
|
|
108
138
|
}
|
|
109
139
|
|
|
110
140
|
export async function checkLocalDocker() {
|
|
111
141
|
try {
|
|
112
142
|
const docker = await resolveLocalDocker();
|
|
113
|
-
|
|
143
|
+
const engine = [`Linux Docker Engine`, docker.engineVersion, `(${docker.rootless ? 'rootless' : 'rootful'})`].filter(Boolean).join(' ');
|
|
144
|
+
const client = docker.clientVersion ? `Docker CLI ${docker.clientVersion}` : '';
|
|
145
|
+
const context = docker.context ? `context ${docker.context}` : '';
|
|
146
|
+
return { docker, diagnostic: check('host.docker-engine', true, [engine, client, context].filter(Boolean).join(', ')) };
|
|
114
147
|
} catch (error) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
148
|
+
if ((error as NodeJS.ErrnoException).code === 'DOCKER_ARCHITECTURE') {
|
|
149
|
+
return { diagnostic: check('host.docker-engine', false, 'The Docker daemon does not match the native Mac architecture.',
|
|
150
|
+
'Select a native local Docker engine for this Mac and run docker info. AnySwarm does not fall back to emulation.') };
|
|
151
|
+
}
|
|
152
|
+
const { code, syscall, stderr = '' } = error as NodeJS.ErrnoException & { stderr?: string };
|
|
153
|
+
const missing = code === 'ENOENT' && syscall === 'spawn docker';
|
|
154
|
+
const contextRemedy = 'Run docker context show and docker info. If needed, run docker context ls and docker context use <local-context>. Check DOCKER_CONTEXT and DOCKER_HOST overrides.';
|
|
155
|
+
if (code === 'LOCAL_WORKER_UNAVAILABLE') {
|
|
156
|
+
return { diagnostic: check('host.docker-engine', false, 'The selected Docker context does not use a local Unix socket.', contextRemedy) };
|
|
157
|
+
}
|
|
158
|
+
if (code === 'DOCKER_OS') {
|
|
159
|
+
return { diagnostic: check('host.docker-engine', false, 'The selected Docker daemon is not a Linux engine.', contextRemedy) };
|
|
160
|
+
}
|
|
161
|
+
if (code === 'EACCES' || code === 'EPERM' || /permission denied.*(?:socket|docker daemon)|(?:socket|docker daemon).*permission denied/i.test(stderr)) {
|
|
162
|
+
return { diagnostic: check('host.docker-engine', false, 'Permission denied while accessing the local Docker engine.',
|
|
163
|
+
'Ask the host administrator to grant socket access. Sign in again after any group change and run docker info as your login user.') };
|
|
164
|
+
}
|
|
165
|
+
let desktopRemedy = 'Install Docker Desktop for Mac (https://docs.docker.com/desktop/setup/install/mac-install/), open it, and wait for the engine to start.';
|
|
166
|
+
if (darwin) {
|
|
167
|
+
const app = 'Docker.app/Contents/Info.plist';
|
|
168
|
+
const installed = await Promise.all(['/Applications', join(homedir(), 'Applications')]
|
|
169
|
+
.map(directory => access(join(directory, app)).then(() => true, () => false)));
|
|
170
|
+
if (installed.some(Boolean)) {
|
|
171
|
+
desktopRemedy = 'Docker Desktop is installed. Open Docker Desktop or wait for its engine to finish starting, then check that its CLI is on PATH.';
|
|
172
|
+
}
|
|
173
|
+
desktopRemedy += ' If you already use another local Linux engine such as OrbStack, start that instead.';
|
|
174
|
+
}
|
|
175
|
+
if (missing) {
|
|
176
|
+
return { diagnostic: check('host.docker-engine', false, 'The Docker CLI was not found on PATH.',
|
|
177
|
+
darwin ? desktopRemedy + ' ' + contextRemedy : await dockerInstallRemedy()) };
|
|
178
|
+
}
|
|
179
|
+
const unavailable = code === 'ENOENT' || /cannot connect|connection refused|daemon running/i.test(stderr);
|
|
180
|
+
const detail = unavailable ? 'The Docker CLI is installed, but the local daemon or its Unix socket is unavailable.'
|
|
181
|
+
: 'Could not verify the selected local Docker engine.';
|
|
182
|
+
return { diagnostic: check('host.docker-engine', false, detail,
|
|
183
|
+
(darwin ? desktopRemedy : 'Start the local Docker engine, then verify access as your login user.') + ' ' + contextRemedy) };
|
|
120
184
|
}
|
|
121
185
|
}
|
|
122
186
|
|
|
187
|
+
export async function discoverMacCallback(image: string, signal?: AbortSignal) {
|
|
188
|
+
const output = await run('docker', ['run', '--rm', '--platform', `linux/${nativeArchitecture}`, '--entrypoint', 'getent', image, 'ahostsv4', 'host.docker.internal'], signal).catch(() => '');
|
|
189
|
+
signal?.throwIfAborted();
|
|
190
|
+
const addresses = [...new Set(output.split('\n').map(line => line.split(/\s+/, 1)[0])
|
|
191
|
+
.filter(value => isIP(value) === 4 && value !== '0.0.0.0' && !value.startsWith('127.')))];
|
|
192
|
+
if (addresses.length !== 1) throw Object.assign(new Error('Could not resolve the native Mac callback in Docker'), { code: 'DOCKER_CALLBACK_UNAVAILABLE' });
|
|
193
|
+
return addresses[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
123
196
|
interface ProviderInfo {
|
|
124
197
|
Id: string;
|
|
125
198
|
Image: string;
|
|
126
199
|
Config: { Image: string; Cmd?: string[]; Env?: string[]; Labels?: Record<string, string> };
|
|
127
200
|
State: { Running: boolean };
|
|
128
|
-
HostConfig: { NetworkMode: string; Binds?: string[] };
|
|
201
|
+
HostConfig: { NetworkMode: string; Binds?: string[]; PortBindings?: Record<string, { HostIp: string; HostPort: string }[]> };
|
|
129
202
|
}
|
|
130
203
|
|
|
131
204
|
function lifecycleUrl(config: LocalEnvironmentConfig) {
|
|
@@ -149,8 +222,15 @@ async function ownedProvider(config: LocalEnvironmentConfig, provider: ProviderI
|
|
|
149
222
|
if (!token || !/^[a-f0-9-]{36}$/.test(token) || labels?.['org.anyswarm.setup.profile'] !== profileVersion ||
|
|
150
223
|
(config.providerId && config.providerId !== provider.Id)) return false;
|
|
151
224
|
const state = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
152
|
-
|
|
153
|
-
|
|
225
|
+
const port = String(lifecycleUrl(config)?.port || 80);
|
|
226
|
+
const ports = provider.HostConfig?.PortBindings;
|
|
227
|
+
const publication = ports?.[`${port}/tcp`];
|
|
228
|
+
const networkMatches = darwin
|
|
229
|
+
? provider.HostConfig?.NetworkMode === 'bridge' && Object.keys(ports ?? {}).length === 1 &&
|
|
230
|
+
publication?.length === 1 && publication[0].HostIp === '127.0.0.1' && publication[0].HostPort === port &&
|
|
231
|
+
provider.HostConfig.Binds?.includes('/var/run/docker.sock:/var/run/docker.sock')
|
|
232
|
+
: provider.HostConfig?.NetworkMode === 'host';
|
|
233
|
+
if (labels['org.anyswarm.setup.state'] !== state || provider.Config.Image !== localProviderImage || !networkMatches ||
|
|
154
234
|
!provider.HostConfig.Binds?.includes(`${join(state, 'config.toml')}:/config/config.toml:ro`) ||
|
|
155
235
|
!provider.HostConfig.Binds.includes(`${join(state, 'data')}:/root/.opensandbox`)) return false;
|
|
156
236
|
const privatePath = (path: string, directory: boolean) => lstat(path)
|
|
@@ -213,14 +293,16 @@ async function authenticatedHealth(config: LocalEnvironmentConfig, budget?: Abor
|
|
|
213
293
|
}
|
|
214
294
|
}
|
|
215
295
|
|
|
216
|
-
export async function checkLocalProvider(config: LocalEnvironmentConfig, { requireAuth = true } = {}): Promise<DiagnosticCheck[]> {
|
|
296
|
+
export async function checkLocalProvider(config: LocalEnvironmentConfig, { requireAuth = true, managed = false } = {}): Promise<DiagnosticCheck[]> {
|
|
217
297
|
const [healthy, denied] = await Promise.all([providerHealthy(config, true), requireAuth ? providerHealthy(config, false) : true]);
|
|
218
298
|
return [
|
|
219
299
|
check('provider.health', healthy, healthy ? 'OpenSandbox lifecycle listing is reachable with the configured credentials.' : 'OpenSandbox lifecycle listing failed.',
|
|
220
|
-
|
|
300
|
+
managed ? 'Run anyswarm setup to start or restore the managed OpenSandbox service.'
|
|
301
|
+
: 'Check ANYSWARM_LIFECYCLE_URL (or sandbox.lifecycleBaseUrl in --config), TLS trust, and the lifecycle API key. Rerun the same command.'),
|
|
221
302
|
...(requireAuth ? [check('provider.authentication', denied && !!config.apiKey,
|
|
222
303
|
denied && config.apiKey ? 'Lifecycle rejects requests without the configured API key.' : 'Lifecycle authentication could not be confirmed.',
|
|
223
|
-
|
|
304
|
+
managed ? 'Run anyswarm setup to check the managed service and its local credentials.'
|
|
305
|
+
: 'Configure a lifecycle API key on OpenSandbox and pass it through trusted anyswarm configuration.')] : []),
|
|
224
306
|
];
|
|
225
307
|
}
|
|
226
308
|
|
|
@@ -230,7 +312,8 @@ async function withProviderLock<T>(config: LocalEnvironmentConfig, action: () =>
|
|
|
230
312
|
signal?.throwIfAborted();
|
|
231
313
|
const directory = join(homedir(), '.cache/anyswarm/opensandbox');
|
|
232
314
|
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
233
|
-
const
|
|
315
|
+
const flags = darwin ? ['-k', '-t', '180'] : ['--exclusive', '--timeout', '180'];
|
|
316
|
+
const child = spawn(darwin ? '/usr/bin/lockf' : 'flock', [...flags, join(directory, `port-${url.port || 80}.lock`),
|
|
234
317
|
process.execPath, '-e', 'console.log("locked"); process.stdin.resume()'],
|
|
235
318
|
{ stdio: ['pipe', 'pipe', 'pipe'] });
|
|
236
319
|
child.stdin.on('error', () => {});
|
|
@@ -274,12 +357,13 @@ function localPortInUse(url: URL) {
|
|
|
274
357
|
|
|
275
358
|
async function prepareProviderImage(image: string, code: string, signal?: AbortSignal) {
|
|
276
359
|
try {
|
|
277
|
-
await run('docker', ['image', 'inspect', image], signal);
|
|
360
|
+
const architecture = await run('docker', ['image', 'inspect', ...(darwin ? ['--format', '{{.Os}}/{{.Architecture}}'] : []), image], signal);
|
|
361
|
+
if (darwin && architecture !== `linux/${nativeArchitecture}`) throw new Error('Pinned image is not installed for the native architecture.');
|
|
278
362
|
} catch {
|
|
279
363
|
signal?.throwIfAborted();
|
|
280
364
|
console.error(`anyswarm setup: pulling ${image}`);
|
|
281
365
|
try {
|
|
282
|
-
await run('docker', ['pull', image], signal);
|
|
366
|
+
await run('docker', ['pull', ...(darwin ? ['--platform', `linux/${nativeArchitecture}`] : []), image], signal);
|
|
283
367
|
} catch {
|
|
284
368
|
signal?.throwIfAborted();
|
|
285
369
|
throw Object.assign(new Error('Docker could not pull the pinned OpenSandbox image'), { code });
|
|
@@ -291,7 +375,9 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
291
375
|
const url = lifecycleUrl(config);
|
|
292
376
|
if (!url) throw Object.assign(new Error('Local loopback OpenSandbox /v1 URL required'), { code: 'PROVIDER_CONFIGURATION_INVALID' });
|
|
293
377
|
signal?.throwIfAborted();
|
|
294
|
-
const
|
|
378
|
+
const docker = await resolveLocalDocker();
|
|
379
|
+
const socket = darwin ? '/var/run/docker.sock' : docker.socket;
|
|
380
|
+
const activeConfig = (): LocalEnvironmentConfig => ({ ...config, egressMode: 'dns+nft', ...(darwin ? { useServerProxy: true } : {}) });
|
|
295
381
|
const existing = await inspectProvider(config, signal);
|
|
296
382
|
if (existing && !await ownedProvider(config, existing)) {
|
|
297
383
|
throw Object.assign(new Error('A different container owns the local service name'), { code: 'PROVIDER_NAME_IN_USE' });
|
|
@@ -330,8 +416,10 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
330
416
|
const token = randomUUID();
|
|
331
417
|
const stateDir = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
332
418
|
const name = `anyswarm-opensandbox-${url.port || 80}`;
|
|
419
|
+
const port = Number(url.port || 80);
|
|
333
420
|
const recipe = (await readFile(join(root, 'deploy/opensandbox/config.toml'), 'utf8')).replace('port = 8080',
|
|
334
|
-
`port = ${
|
|
421
|
+
`port = ${port}\napi_key = ${JSON.stringify(config.apiKey)}`).replace('host = "127.0.0.1"',
|
|
422
|
+
darwin ? 'host = "0.0.0.0"' : 'host = "127.0.0.1"');
|
|
335
423
|
try {
|
|
336
424
|
await mkdir(join(stateDir, 'data'), { recursive: true, mode: 0o700 });
|
|
337
425
|
await writeFile(join(stateDir, 'config.toml'), recipe, { mode: 0o600, flag: 'wx' });
|
|
@@ -384,7 +472,8 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
384
472
|
await prepareProviderImage(localEgressImage, 'PROVIDER_EGRESS_PULL_FAILED', signal);
|
|
385
473
|
await prepareProviderImage(localProviderImage, 'PROVIDER_SERVER_PULL_FAILED', signal);
|
|
386
474
|
try {
|
|
387
|
-
|
|
475
|
+
const network = darwin ? ['--platform', `linux/${nativeArchitecture}`, '--network', 'bridge', '--publish', `127.0.0.1:${port}:${port}`] : ['--network', 'host'];
|
|
476
|
+
id = await run('docker', ['run', '-d', '--name', name, ...network, '--restart', 'unless-stopped', '--label', `org.anyswarm.setup.profile=${profileVersion}`, '--label', `org.anyswarm.setup.owner=${token}`, '--label', `org.anyswarm.setup.state=${stateDir}`, '-v', `${socket}:/var/run/docker.sock`, '-v', `${join(stateDir, 'config.toml')}:/config/config.toml:ro`, '-v', `${join(stateDir, 'data')}:/root/.opensandbox`, localProviderImage, '--config', '/config/config.toml'], signal);
|
|
388
477
|
created = true;
|
|
389
478
|
} catch {
|
|
390
479
|
// Docker atomically reserves the name, allowing simultaneous setup calls to converge.
|
|
@@ -395,7 +484,7 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
395
484
|
const provider = await waitForProvider({ ...config, providerId: id || undefined }, signal);
|
|
396
485
|
if (created) {
|
|
397
486
|
providerReady = true;
|
|
398
|
-
return { ...handle, config:
|
|
487
|
+
return { ...handle, config: activeConfig(), created: true, id, images: await imageIds(provider) };
|
|
399
488
|
}
|
|
400
489
|
await rm(stateDir, { recursive: true, force: true });
|
|
401
490
|
return reuse(provider);
|
|
@@ -407,7 +496,7 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
407
496
|
async function reuse(provider: ProviderInfo): Promise<LocalProviderHandle> {
|
|
408
497
|
const path = provider.Config.Labels?.['org.anyswarm.setup.state'];
|
|
409
498
|
if (provider.Config.Labels?.['org.anyswarm.setup.profile'] === profileVersion && path?.startsWith(join(homedir(), '.cache/anyswarm/opensandbox/'))) await writeFile(join(path, 'adopted'), '', { mode: 0o600 });
|
|
410
|
-
return { config:
|
|
499
|
+
return { config: activeConfig(), id: provider.Id, images: await imageIds(provider), created: false, retain: async () => {
|
|
411
500
|
const current = await inspectProvider(config);
|
|
412
501
|
if (current?.Id !== provider.Id) throw new Error('Provider identity changed');
|
|
413
502
|
}, cleanup: async () => ({ status: 'complete', id: provider.Id, retained: true }) };
|