@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
|
@@ -111,7 +111,8 @@ export async function runLocalSmoke(options: LocalSmokeOptions): Promise<LocalSm
|
|
|
111
111
|
},
|
|
112
112
|
models: { default: model }, filePolicy: options.filePolicy,
|
|
113
113
|
profiles: { probe: { addedSystemPrompt: SETUP_PROFILE_PROMPT, model: 'default', image: options.image,
|
|
114
|
-
writable: true, services: { 'setup-probe': ['verify'] }
|
|
114
|
+
writable: true, services: { 'setup-probe': ['verify'] },
|
|
115
|
+
...(driver.kind === 'codex' ? { serviceToolMode: 'cli' as const } : {}) } },
|
|
115
116
|
services, maxAgents: 1, outputDir: temporary,
|
|
116
117
|
});
|
|
117
118
|
receipt.runtimeId = runtime.id;
|
|
@@ -122,7 +123,7 @@ export async function runLocalSmoke(options: LocalSmokeOptions): Promise<LocalSm
|
|
|
122
123
|
collect: { paths: ['.'], includeGit: false, maxBytes: 4096, required: true } }), signal);
|
|
123
124
|
signal.throwIfAborted();
|
|
124
125
|
if (agent.status !== 'idle') throw new Error('worker');
|
|
125
|
-
passed(stage, `Controller reached the real Worker and verified ${driver.kind}
|
|
126
|
+
passed(stage, `Controller reached the real Worker and verified ${driver.kind}${driver.version ? ' ' + driver.version : ''}`);
|
|
126
127
|
if (upstream) {
|
|
127
128
|
stage = 'agent-bridge-gateway';
|
|
128
129
|
async function turn(message: string, requestId: string, expected: string) {
|
|
@@ -3,7 +3,7 @@ import { execFile } from 'node:child_process';
|
|
|
3
3
|
import { promisify } from 'node:util';
|
|
4
4
|
import { isOfficialWorkerImage, WORKER_PROTOCOL } from '../src/core/worker-image.js';
|
|
5
5
|
import { selectExecutorDriver } from '../src/core/sandbox/executor-driver.js';
|
|
6
|
-
import type
|
|
6
|
+
import { executorVersion, type ExecutorSelection } from '../src/core/executor-adapter.js';
|
|
7
7
|
import type { DiagnosticCheck } from './local-environment.js';
|
|
8
8
|
import { prepareLocalWorker, type LocalWorker } from '../src/core/sandbox/local-worker.js';
|
|
9
9
|
import type { LocalExecutorSelection } from '../src/core/sandbox/local-executor.js';
|
|
@@ -13,8 +13,12 @@ const protocol = WORKER_PROTOCOL;
|
|
|
13
13
|
const imageIdPattern = /^sha256:[a-f0-9]{64}$/;
|
|
14
14
|
const imageReferencePattern = /^[a-z0-9][a-z0-9._/@:+-]{0,254}$/i;
|
|
15
15
|
|
|
16
|
+
const darwinWorkerPlatform = process.platform === 'darwin' ? `linux/${process.arch === 'x64' ? 'amd64' : process.arch}` : undefined;
|
|
17
|
+
|
|
16
18
|
type Image = {
|
|
17
19
|
Id: string;
|
|
20
|
+
Os?: string;
|
|
21
|
+
Architecture?: string;
|
|
18
22
|
RepoDigests?: string[];
|
|
19
23
|
Config?: { Labels?: Record<string, string>; Env?: string[] };
|
|
20
24
|
};
|
|
@@ -40,6 +44,11 @@ async function inspectWorker(reference: string, driver: ReturnType<typeof select
|
|
|
40
44
|
remedy }], state: absent ? 'missing' : 'unavailable',
|
|
41
45
|
};
|
|
42
46
|
}
|
|
47
|
+
if (darwinWorkerPlatform && `${image.Os}/${image.Architecture}` !== darwinWorkerPlatform) return {
|
|
48
|
+
checks: [{ id: 'worker-platform', ok: false, detail: `The local Worker must be ${darwinWorkerPlatform} on this Mac.`,
|
|
49
|
+
remedy: 'Select a native Linux Worker, or omit the image and build a Worker from the selected executable.' }],
|
|
50
|
+
state: 'unavailable',
|
|
51
|
+
};
|
|
43
52
|
const labels = image.Config?.Labels ?? {};
|
|
44
53
|
const protocolMatches = labels['org.anyswarm.opensandbox.worker-protocol'] === protocol &&
|
|
45
54
|
labels['org.anyswarm.opensandbox.file-protocol'] === fileProtocol;
|
|
@@ -48,7 +57,8 @@ async function inspectWorker(reference: string, driver: ReturnType<typeof select
|
|
|
48
57
|
const actualVersion = labels[`org.anyswarm.opensandbox.${executor}-version`];
|
|
49
58
|
const versionMatches = driver.adapter
|
|
50
59
|
? actualVersion === version && labels[`org.anyswarm.opensandbox.${executor}-protocol`] === driver.adapter.protocol
|
|
51
|
-
: actualVersion
|
|
60
|
+
: executorVersion(actualVersion) && (version === undefined || actualVersion === version) &&
|
|
61
|
+
(installed === undefined || installed === 'both' || installed === executor);
|
|
52
62
|
return {
|
|
53
63
|
checks: [
|
|
54
64
|
{ id: 'worker-image', ok: true, detail: `Docker resolved ${image.Id}.` },
|
|
@@ -56,12 +66,12 @@ async function inspectWorker(reference: string, driver: ReturnType<typeof select
|
|
|
56
66
|
detail: protocolMatches ? `The image declares ${protocol} and ${fileProtocol}.` : `The image does not declare the required Worker protocol ${protocol} and ${fileProtocol}.`,
|
|
57
67
|
...(protocolMatches ? {} : { remedy }) },
|
|
58
68
|
{ id: `worker-${executor}`, ok: versionMatches,
|
|
59
|
-
detail: versionMatches ? `The image declares ${executor} ${
|
|
60
|
-
`Image declares ${executor} ${actualVersion ?? 'unavailable'};
|
|
69
|
+
detail: versionMatches ? `The image declares ${executor} ${actualVersion}.` :
|
|
70
|
+
`Image declares ${executor} ${actualVersion ?? 'unavailable'}; expected ${version ?? 'an exact version'}.`,
|
|
61
71
|
...(versionMatches ? {} : { remedy }) },
|
|
62
72
|
],
|
|
63
|
-
...(protocolMatches && versionMatches ? { image: { reference, id: image.Id,
|
|
64
|
-
digests: (image.RepoDigests ?? []).filter(value => imageReferencePattern.test(value)), protocol, executor, version } } : {}),
|
|
73
|
+
...(protocolMatches && versionMatches && actualVersion !== undefined ? { image: { reference, id: image.Id,
|
|
74
|
+
digests: (image.RepoDigests ?? []).filter(value => imageReferencePattern.test(value)), protocol, executor, version: actualVersion } } : {}),
|
|
65
75
|
state: 'inspected',
|
|
66
76
|
};
|
|
67
77
|
}
|
|
@@ -111,7 +121,7 @@ export async function prepareWorkerImage({ requestedImage, executor = 'pi', loca
|
|
|
111
121
|
}
|
|
112
122
|
progress?.(`Pulling explicitly selected Worker ${reference}`);
|
|
113
123
|
try {
|
|
114
|
-
await exec('docker', ['pull', '--', reference], { signal, timeout: 15 * 60_000, maxBuffer: 12 * 1024 * 1024 });
|
|
124
|
+
await exec('docker', ['pull', ...(darwinWorkerPlatform ? ['--platform', darwinWorkerPlatform] : []), '--', reference], { signal, timeout: 15 * 60_000, maxBuffer: 12 * 1024 * 1024 });
|
|
115
125
|
} catch (error) {
|
|
116
126
|
signal.throwIfAborted();
|
|
117
127
|
return { ...cached, reference, source: 'pull', checks: [pullFailure(reference, error)] };
|
package/scripts/local-setup.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { stdin, stderr } from 'node:process';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
checkSetupHost, checkHostTools, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment,
|
|
7
7
|
type DiagnosticCheck,
|
|
8
8
|
} from './local-environment.js';
|
|
9
9
|
import { runLocalSmoke } from './local-setup-smoke.js';
|
|
@@ -18,14 +18,14 @@ import { claimOpenSandboxBackend, createSandbox } from '../src/core/sandbox/open
|
|
|
18
18
|
import { snapshotModel } from '../src/core/model/model-access.js';
|
|
19
19
|
import { modelClientProtocol } from '../src/core/model/model-transport.js';
|
|
20
20
|
import type { SandboxConfig } from '../src/core/backend-config.js';
|
|
21
|
-
import { loadAnySwarmConfig, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
21
|
+
import { loadAnySwarmConfig, loopbackLifecycle, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
22
22
|
import type { LocalCommand } from './anyswarm-arguments.js';
|
|
23
23
|
|
|
24
24
|
type ProjectConfig = Parameters<typeof createSubagentsHarness>[0];
|
|
25
25
|
type Provider = Awaited<ReturnType<typeof ensureLocalProvider>>;
|
|
26
26
|
type Smoke = Awaited<ReturnType<typeof runLocalSmoke>>;
|
|
27
27
|
type Timing = { id: string; elapsedMs: number; cached?: boolean };
|
|
28
|
-
type Model = { configuration: 'complete' | 'missing' | 'invalid'; verification: 'not-verified' };
|
|
28
|
+
type Model = { configuration: 'complete' | 'missing' | 'invalid'; verification: 'not-verified'; remedy?: string };
|
|
29
29
|
|
|
30
30
|
function modelState(config: ProjectConfig, executor: string): Model {
|
|
31
31
|
if (config.models === undefined) return { configuration: 'missing', verification: 'not-verified' };
|
|
@@ -95,10 +95,11 @@ function reportedHost(value?: string): string | undefined {
|
|
|
95
95
|
if (value && (/^[a-zA-Z0-9._-]+$/.test(value) || isIP(value))) return value;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
function installNextStep(command: LocalCommand): string {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
function installNextStep(command: LocalCommand, mode?: 'existing' | 'local'): string {
|
|
99
|
+
if (command.command !== 'setup') return 'Run your Harness with the same environment.';
|
|
100
|
+
return mode === 'local'
|
|
101
|
+
? 'Run your Harness with the same environment, or repeat the probe with anyswarm doctor --smoke.'
|
|
102
|
+
: 'Run your Harness with the same environment, or check the existing service with anyswarm doctor --mode existing --smoke.';
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
const phaseLabels: Record<string, string> = {
|
|
@@ -109,40 +110,71 @@ const phaseLabels: Record<string, string> = {
|
|
|
109
110
|
smoke: 'Start Worker and check Bridge, controlled Gateway, files and deletion',
|
|
110
111
|
};
|
|
111
112
|
|
|
113
|
+
type BackendProbe = {
|
|
114
|
+
selection: LocalExecutorSelection;
|
|
115
|
+
} & ({ version: string } | { error: string });
|
|
116
|
+
|
|
117
|
+
async function probeBackend(selection: LocalExecutorSelection, signal: AbortSignal): Promise<BackendProbe> {
|
|
118
|
+
try {
|
|
119
|
+
return { selection, version: await checkLocalExecutor(selection, signal) };
|
|
120
|
+
} catch (error) {
|
|
121
|
+
signal.throwIfAborted();
|
|
122
|
+
if ((error as { code?: string }).code !== 'LOCAL_EXECUTOR_UNAVAILABLE') throw error;
|
|
123
|
+
return { selection, error: (error as Error).message };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function backendOnPath(kind: LocalExecutorSelection['kind'], version: string | undefined, signal: AbortSignal) {
|
|
128
|
+
let firstFailure: BackendProbe | undefined;
|
|
129
|
+
let available: BackendProbe | undefined;
|
|
130
|
+
await findExecutorEntry(kind, async entry => {
|
|
131
|
+
const candidate = await probeBackend({ kind, entry, version }, signal);
|
|
132
|
+
if ('version' in candidate) {
|
|
133
|
+
available = candidate;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
firstFailure ??= candidate;
|
|
137
|
+
return false;
|
|
138
|
+
});
|
|
139
|
+
return available ?? firstFailure;
|
|
140
|
+
}
|
|
141
|
+
|
|
112
142
|
async function chooseBackend(
|
|
113
143
|
command: LocalCommand, saved: LocalExecutorSelection | undefined, configured: ExecutorSelection | undefined, signal: AbortSignal,
|
|
114
|
-
): Promise<
|
|
144
|
+
): Promise<BackendProbe | { issue: string; ambiguous?: boolean }> {
|
|
115
145
|
const explicit = command.command === 'setup' ? command.backend : undefined;
|
|
116
|
-
|
|
117
|
-
const preferred = explicit ??
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
const driver = explicit || configured === undefined ? undefined : selectExecutorDriver(configured);
|
|
147
|
+
const preferred = explicit ?? driver?.kind ?? saved?.kind;
|
|
148
|
+
const version = explicit && command.command === 'setup' ? command.backendVersion : driver?.version;
|
|
149
|
+
if (command.command === 'setup' && command.backendPath && explicit) {
|
|
150
|
+
return probeBackend({ kind: explicit, entry: resolve(command.backendPath), version }, signal);
|
|
151
|
+
}
|
|
152
|
+
if (preferred === 'pi' || preferred === 'codex') {
|
|
153
|
+
if (saved?.kind === preferred && !explicit) return probeBackend({ ...saved, version: version ?? saved.version }, signal);
|
|
154
|
+
if (saved?.kind === preferred && version !== undefined) {
|
|
155
|
+
const candidate = await probeBackend({ ...saved, version }, signal);
|
|
156
|
+
if ('version' in candidate) return candidate;
|
|
157
|
+
}
|
|
158
|
+
return await backendOnPath(preferred, version, signal) ??
|
|
159
|
+
{ issue: `Could not find the selected ${preferred} executable on PATH.` };
|
|
124
160
|
}
|
|
125
161
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
const detected = await Promise.all((['pi', 'codex'] as const).map(kind => backendOnPath(kind, undefined, signal)));
|
|
163
|
+
const compatible = detected.filter(candidate => candidate !== undefined && 'version' in candidate);
|
|
164
|
+
if (compatible.length === 0) {
|
|
165
|
+
const errors = detected.filter(candidate => candidate !== undefined && 'error' in candidate).map(candidate => candidate.error);
|
|
166
|
+
return { issue: errors.length ? errors.join(' ') : 'Neither Pi nor Codex was found on PATH.' };
|
|
167
|
+
}
|
|
168
|
+
if (compatible.length === 1) return compatible[0]!;
|
|
169
|
+
const selectBackend = { issue: 'Both Pi and Codex have compatible installations. Choose a backend to use.', ambiguous: true };
|
|
170
|
+
if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY) return selectBackend;
|
|
132
171
|
const input = createInterface({ input: stdin, output: stderr });
|
|
133
172
|
try {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
? `${kind} ${probe.value} (${entry}) is compatible.\n`
|
|
140
|
-
: `${probe.reason instanceof Error ? probe.reason.message : `Could not verify ${kind} at ${entry}.`}\n`);
|
|
141
|
-
return probe.status === 'fulfilled';
|
|
142
|
-
});
|
|
143
|
-
if (choices.length <= 1) return choices[0];
|
|
144
|
-
const answer = (await input.question(`Select a local backend [${choices.map(({ kind }) => kind).join(', ')}] (pi): `, { signal })).trim() || 'pi';
|
|
145
|
-
return choices.find(candidate => candidate.kind === answer);
|
|
173
|
+
for (const { selection, version } of compatible) {
|
|
174
|
+
stderr.write(`${selection.kind} ${version} (${selection.entry}) is compatible.\n`);
|
|
175
|
+
}
|
|
176
|
+
const answer = (await input.question('Select a local backend [pi, codex] (pi): ', { signal })).trim() || 'pi';
|
|
177
|
+
return compatible.find(candidate => candidate.selection.kind === answer) ?? selectBackend;
|
|
146
178
|
} finally {
|
|
147
179
|
input.close();
|
|
148
180
|
}
|
|
@@ -169,11 +201,12 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
169
201
|
model?: Model;
|
|
170
202
|
modelUpstreamVerification: 'not-verified';
|
|
171
203
|
configuration?: {
|
|
172
|
-
executor: { id: string; version
|
|
204
|
+
executor: { id: string; version?: string; entry?: string; compatibleVersions?: readonly string[] };
|
|
173
205
|
image: string;
|
|
174
206
|
filePolicy: ResolvedFilePolicy;
|
|
175
207
|
};
|
|
176
208
|
checks: DiagnosticCheck[];
|
|
209
|
+
tooling?: DiagnosticCheck[];
|
|
177
210
|
timings: Timing[];
|
|
178
211
|
elapsedMs: number;
|
|
179
212
|
interrupted: boolean;
|
|
@@ -206,11 +239,15 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
206
239
|
let provider: Provider | undefined;
|
|
207
240
|
let rootlessDocker = false;
|
|
208
241
|
let stage = 'config';
|
|
242
|
+
progress?.('Detect host system and AnySwarm configuration…');
|
|
209
243
|
try {
|
|
244
|
+
checks.push(...checkSetupHost());
|
|
245
|
+
report.tooling = await checkHostTools(signal);
|
|
210
246
|
const config = command.configPath
|
|
211
247
|
? await loadAnySwarmConfig(command.configPath) as ProjectConfig : undefined;
|
|
212
248
|
const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR) as ExecutorSelection | undefined;
|
|
213
|
-
let executor =
|
|
249
|
+
let executor = command.command === 'setup' && command.backend
|
|
250
|
+
? { kind: command.backend, version: command.backendVersion } : configured;
|
|
214
251
|
const install = command.command === 'setup';
|
|
215
252
|
let localExecutor: LocalExecutorSelection | undefined;
|
|
216
253
|
let driver;
|
|
@@ -226,38 +263,72 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
226
263
|
image: config?.image,
|
|
227
264
|
advertiseHost: config?.connection?.advertiseHost ?? config?.connection?.modelGateway?.advertiseHost,
|
|
228
265
|
});
|
|
229
|
-
const
|
|
266
|
+
const hostname = new URL(environment.lifecycleBaseUrl).hostname;
|
|
267
|
+
const loopback = hostname === 'localhost' || hostname === '[::1]' || hostname.startsWith('127.') && isIP(hostname) === 4;
|
|
268
|
+
const reuseExisting = loopback && (environment.management === 'existing' ||
|
|
269
|
+
(!install && environment.mode === 'existing'));
|
|
270
|
+
const mode = command.mode ?? (reuseExisting ? 'existing' : 'local');
|
|
230
271
|
const smoke = install ? mode === 'local' : command.smoke;
|
|
272
|
+
report.mode = mode;
|
|
273
|
+
report.lifecycleSource = environment.endpointSource;
|
|
274
|
+
if (mode === 'local' && (!loopback || !loopbackLifecycle(environment.lifecycleBaseUrl))) {
|
|
275
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'The selected Lifecycle configuration is outside the managed local HTTP loopback profile.',
|
|
276
|
+
remedy: environment.endpointSource === 'saved'
|
|
277
|
+
? 'Use --mode existing to check the saved service, or run anyswarm setup --mode local --endpoint http://127.0.0.1:8080 to replace it after a successful local probe.'
|
|
278
|
+
: 'For local setup, remove the Lifecycle URL override or set it to http://127.0.0.1:8080. Use --mode existing only to connect to a service you explicitly select.' });
|
|
279
|
+
return report;
|
|
280
|
+
}
|
|
281
|
+
if (mode === 'existing' && environment.endpointSource === 'default') {
|
|
282
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'No existing Lifecycle service was configured.',
|
|
283
|
+
remedy: 'Run anyswarm setup for local OpenSandbox, or configure the existing Lifecycle URL and credentials explicitly.' });
|
|
284
|
+
return report;
|
|
285
|
+
}
|
|
231
286
|
if (command.command === 'setup' && command.backend && mode !== 'local') {
|
|
232
|
-
|
|
233
|
-
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local on the same Linux host.',
|
|
287
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
|
|
234
288
|
remedy: 'For an existing deployment, use its prepared Worker image.' });
|
|
235
289
|
return report;
|
|
236
290
|
}
|
|
291
|
+
if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
|
|
292
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
|
|
293
|
+
remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
|
|
294
|
+
return report;
|
|
295
|
+
}
|
|
237
296
|
if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
|
|
238
|
-
report.mode = mode;
|
|
239
297
|
checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
|
|
240
298
|
remedy: 'Set ANYSWARM_WORKER_IMAGE to the image provided by the operator.' });
|
|
241
299
|
return report;
|
|
242
300
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
301
|
+
let localVersion: string | undefined;
|
|
302
|
+
if (mode === 'local' && !environment.image && !driver.adapter) {
|
|
303
|
+
progress?.('Detect an installed Pi or Codex executable…');
|
|
304
|
+
const detected = await chooseBackend(command, environment.localExecutor, configured, signal);
|
|
305
|
+
if ('issue' in detected) {
|
|
306
|
+
const remedy = detected.ambiguous
|
|
307
|
+
? 'Run anyswarm setup --backend pi or anyswarm setup --backend codex.'
|
|
308
|
+
: 'For Pi, run npm install -g @earendil-works/pi-coding-agent, then run anyswarm setup --backend pi. For Codex, run npm install -g @openai/codex, then run anyswarm setup --backend codex.';
|
|
309
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.issue, remedy });
|
|
310
|
+
} else {
|
|
311
|
+
localExecutor = detected.selection;
|
|
312
|
+
executor = { kind: localExecutor.kind, version: localExecutor.version };
|
|
313
|
+
driver = selectExecutorDriver(executor);
|
|
314
|
+
if ('error' in detected) {
|
|
315
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.error,
|
|
316
|
+
remedy: 'Restore the saved executable or select a supported installation with anyswarm setup --backend pi or anyswarm setup --backend codex.' });
|
|
317
|
+
} else {
|
|
318
|
+
localVersion = detected.version;
|
|
319
|
+
const detail = `Detected ${localExecutor.kind} ${localVersion} at ${localExecutor.entry}.`;
|
|
320
|
+
checks.push({ id: 'config.executor', ok: true, detail });
|
|
321
|
+
progress?.(detail);
|
|
322
|
+
}
|
|
252
323
|
}
|
|
253
|
-
executor = localExecutor.kind;
|
|
254
|
-
driver = selectExecutorDriver(executor);
|
|
255
324
|
}
|
|
256
|
-
|
|
325
|
+
const modelUrl = process.env.ANYSWARM_MODEL_URL || process.env.ANYSWARM_SUBAGENTS_MODEL_URL;
|
|
326
|
+
const modelId = process.env.ANYSWARM_MODEL_ID || process.env.ANYSWARM_SUBAGENTS_MODEL_ID;
|
|
327
|
+
if (!config && modelUrl && (modelId || driver.kind !== 'codex')) {
|
|
257
328
|
const route = {
|
|
258
|
-
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
|
|
259
|
-
model:
|
|
260
|
-
upstream: { url:
|
|
329
|
+
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai',
|
|
330
|
+
model: modelId || 'gpt-5.4', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
|
|
331
|
+
upstream: { url: modelUrl, headers: {} },
|
|
261
332
|
};
|
|
262
333
|
try {
|
|
263
334
|
snapshotModel(route as Parameters<typeof snapshotModel>[0], driver.kind);
|
|
@@ -268,26 +339,27 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
268
339
|
} else {
|
|
269
340
|
report.model = config ? modelState(config, driver.kind) : { configuration: 'missing', verification: 'not-verified' };
|
|
270
341
|
}
|
|
342
|
+
if (report.model.configuration === 'missing') {
|
|
343
|
+
report.model.remedy = config ? 'Set an upstream endpoint for each active model route in the trusted configuration.'
|
|
344
|
+
: 'Before running the Quickstart Harness, set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID. Set ANYSWARM_MODEL_TOKEN if the endpoint requires authentication.';
|
|
345
|
+
}
|
|
271
346
|
if (report.model?.configuration === 'invalid') checks.push({
|
|
272
347
|
id: 'config.models', ok: false, detail: 'An active model alias, capability declaration or protocol endpoint is invalid for the selected executor.',
|
|
273
348
|
remedy: 'Use a supported executor and protocol combination, and configure an HTTP(S) endpoint without embedded credentials for each active model alias.',
|
|
274
349
|
});
|
|
275
|
-
if (
|
|
276
|
-
if (config) {
|
|
350
|
+
if (config && report.model.configuration !== 'invalid') {
|
|
277
351
|
const { lifecycleBaseUrl, apiKey, endpointHost } = environment;
|
|
278
352
|
checks.push(checkProjectRuntime({
|
|
279
353
|
...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl },
|
|
280
354
|
}, { ...config.sandbox, endpoint: undefined, lifecycleBaseUrl, apiKey, endpointHost }));
|
|
281
355
|
}
|
|
282
|
-
if (checks.some(check => !check.ok)) return report;
|
|
283
356
|
report.configuration = {
|
|
284
|
-
executor: { id: driver.kind, version: driver.version,
|
|
357
|
+
executor: { id: driver.kind, version: localVersion ?? driver.version, entry: localExecutor?.entry,
|
|
358
|
+
compatibleVersions: driver.adapter?.compatibleVersions },
|
|
285
359
|
image: environment.image ?? workerImageFor(executor),
|
|
286
360
|
filePolicy: resolveFilePolicy(config?.filePolicy),
|
|
287
361
|
};
|
|
288
362
|
const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
|
|
289
|
-
report.mode = mode;
|
|
290
|
-
report.lifecycleSource = environment.endpointSource;
|
|
291
363
|
report.connection = {
|
|
292
364
|
lifecycleBaseUrl: reportedEndpoint(environment.lifecycleBaseUrl),
|
|
293
365
|
advertiseHost: reportedHost(environment.advertiseHost),
|
|
@@ -298,20 +370,20 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
298
370
|
resolveWith: 'resolveSandboxConnection',
|
|
299
371
|
};
|
|
300
372
|
stage = 'host';
|
|
301
|
-
|
|
302
|
-
if (checks.some(check => !check.ok)) return report;
|
|
373
|
+
const darwin = process.platform === 'darwin';
|
|
303
374
|
let advertiseHost = environment.advertiseHost;
|
|
304
|
-
|
|
375
|
+
let advertiseHostDiscovery = environment.advertiseHostDiscovery;
|
|
376
|
+
if (mode === 'local' && checks.find(check => check.id === 'host.platform')?.ok) {
|
|
305
377
|
const docker = await timed('host', checkLocalDocker);
|
|
306
378
|
checks.push(docker.diagnostic);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (advertiseHost === undefined && docker.docker.advertiseHost !== undefined) {
|
|
379
|
+
rootlessDocker = docker.docker?.rootless ?? false;
|
|
380
|
+
if (advertiseHost === undefined && docker.docker?.advertiseHost !== undefined) {
|
|
310
381
|
advertiseHost = docker.docker.advertiseHost;
|
|
311
382
|
report.connection.advertiseHost = reportedHost(advertiseHost);
|
|
312
383
|
report.connection.sources.advertiseHost = 'docker-network';
|
|
313
384
|
}
|
|
314
385
|
}
|
|
386
|
+
if (checks.some(check => !check.ok)) return report;
|
|
315
387
|
let image = report.configuration.image;
|
|
316
388
|
if (mode === 'local' && smoke) {
|
|
317
389
|
stage = 'worker';
|
|
@@ -326,8 +398,8 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
326
398
|
report.connection.image = worker.image.reference;
|
|
327
399
|
report.connection.sources.image = worker.source;
|
|
328
400
|
report.configuration.image = worker.image.reference;
|
|
329
|
-
if (
|
|
330
|
-
executor = { kind:
|
|
401
|
+
if (!driver.adapter && (worker.image.executor === 'pi' || worker.image.executor === 'codex')) {
|
|
402
|
+
executor = { kind: worker.image.executor, version: worker.image.version };
|
|
331
403
|
report.configuration.executor.version = worker.image.version;
|
|
332
404
|
}
|
|
333
405
|
progress?.(`Worker image source: ${worker.source}`);
|
|
@@ -339,12 +411,26 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
339
411
|
progress?.(provider.created ? 'Started managed OpenSandbox' : 'Reused managed OpenSandbox');
|
|
340
412
|
}
|
|
341
413
|
const active = provider?.config ?? environment;
|
|
342
|
-
checks.push(...await timed('provider', () => checkLocalProvider(active)));
|
|
414
|
+
checks.push(...await timed('provider', () => checkLocalProvider(active, { managed: mode === 'local' })));
|
|
343
415
|
if (checks.some(check => !check.ok)) return report;
|
|
344
416
|
|
|
345
417
|
report.infrastructure = 'preflight-passed';
|
|
346
418
|
if (smoke) {
|
|
347
419
|
stage = 'smoke';
|
|
420
|
+
if (darwin && mode === 'local' && publicUrl === undefined &&
|
|
421
|
+
(advertiseHost === undefined || advertiseHostDiscovery === 'docker-network')) {
|
|
422
|
+
const discovered = await discoverMacCallback(image, signal);
|
|
423
|
+
if (!install && discovered !== advertiseHost) {
|
|
424
|
+
checks.push({ id: 'config.callback', ok: false, detail: 'The saved Runtime callback needs to be refreshed.',
|
|
425
|
+
remedy: 'Run anyswarm setup to save and verify the current Docker callback.' });
|
|
426
|
+
report.infrastructure = 'failed';
|
|
427
|
+
return report;
|
|
428
|
+
}
|
|
429
|
+
advertiseHost = discovered;
|
|
430
|
+
advertiseHostDiscovery = 'docker-network';
|
|
431
|
+
report.connection.advertiseHost = advertiseHost;
|
|
432
|
+
report.connection.sources.advertiseHost = 'docker-network';
|
|
433
|
+
}
|
|
348
434
|
report.smoke = await timed('smoke', () => runLocalSmoke({
|
|
349
435
|
...active, image, sandbox: config?.sandbox, connection: {
|
|
350
436
|
...config?.connection, publicUrl: environment.publicUrl,
|
|
@@ -362,7 +448,7 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
362
448
|
signal.throwIfAborted();
|
|
363
449
|
if (install) {
|
|
364
450
|
await saveSandboxConnection({ ...active, publicUrl: environment.publicUrl,
|
|
365
|
-
advertiseHost, image: environment.image, localExecutor,
|
|
451
|
+
advertiseHost, advertiseHostDiscovery, image: environment.image, localExecutor,
|
|
366
452
|
management: mode, providerId: provider?.id, preparedImage: report.worker?.id,
|
|
367
453
|
egressMode: mode === 'local' ? 'dns+nft' : environment.egressMode });
|
|
368
454
|
checks.push({ id: 'connection.saved', ok: true, detail: 'OpenSandbox connection saved in the owner-only user configuration.' });
|
|
@@ -379,7 +465,10 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
379
465
|
};
|
|
380
466
|
let [detail, remedy] = failure[stage];
|
|
381
467
|
const code = (error as { code?: string })?.code;
|
|
382
|
-
if (
|
|
468
|
+
if (code === 'DOCKER_CALLBACK_UNAVAILABLE') {
|
|
469
|
+
detail = 'The Docker container could not resolve a unique Mac callback IPv4 address.';
|
|
470
|
+
remedy = 'Check host.docker.internal from the selected local engine, or configure a Runtime publicUrl reachable from the Sandbox.';
|
|
471
|
+
} else if (stage === 'provider' && ['PROVIDER_EXECD_PULL_FAILED', 'PROVIDER_SERVER_PULL_FAILED', 'PROVIDER_EGRESS_PULL_FAILED'].includes(code ?? '')) {
|
|
383
472
|
const execd = code === 'PROVIDER_EXECD_PULL_FAILED';
|
|
384
473
|
const egress = code === 'PROVIDER_EGRESS_PULL_FAILED';
|
|
385
474
|
detail = `Docker could not pull the pinned OpenSandbox ${execd ? 'Execd' : egress ? 'egress' : 'server'} image.`;
|
|
@@ -431,7 +520,11 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
|
|
|
431
520
|
if (report.smoke.outputDir) progress?.(`Probe evidence: ${report.smoke.outputDir}`);
|
|
432
521
|
progress?.('Controlled smoke completed. The configured model upstream was not contacted.');
|
|
433
522
|
}
|
|
434
|
-
|
|
523
|
+
for (const tool of report.tooling?.filter(check => !check.ok) ?? []) {
|
|
524
|
+
progress?.([tool.detail, tool.remedy].filter(Boolean).join(' '));
|
|
525
|
+
}
|
|
526
|
+
if (report.model?.remedy) progress?.(report.model.remedy);
|
|
527
|
+
if (report.ok) progress?.(installNextStep(command, report.mode));
|
|
435
528
|
}
|
|
436
529
|
return report;
|
|
437
530
|
}
|
|
@@ -302,8 +302,8 @@ async function startAgent(input: any) {
|
|
|
302
302
|
} else if (executorKind === 'codex') {
|
|
303
303
|
const version = spawnSync('setpriv', [...unprivileged, 'codex', '--version'],
|
|
304
304
|
{ cwd, env: agentEnvironment, timeout: 5_000, encoding: 'utf8' });
|
|
305
|
-
executorVersion = input.executor_version ??
|
|
306
|
-
if (version.status !== 0 || version.stdout.trim() !== `codex-cli ${executorVersion}`) {
|
|
305
|
+
executorVersion = input.executor_version ?? input.codex.version;
|
|
306
|
+
if (typeof executorVersion !== 'string' || version.status !== 0 || version.stdout.trim() !== `codex-cli ${executorVersion}`) {
|
|
307
307
|
throw startupContractError('Codex CLI version differs from the Runtime selection');
|
|
308
308
|
}
|
|
309
309
|
const configuration = [
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { execFile, spawnSync } from 'node:child_process';
|
|
2
|
+
import { chmod, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
|
|
7
|
+
const [destination, ...options] = process.argv.slice(2);
|
|
8
|
+
if (!destination || (options.length && options.join(' ') !== '--skip-build')) {
|
|
9
|
+
throw new Error('Usage: npm run pack:release -- <output-directory> [--skip-build]');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Keep the build and staging umask independent of the caller.
|
|
13
|
+
process.umask(0o022);
|
|
14
|
+
|
|
15
|
+
const run = promisify(execFile);
|
|
16
|
+
const repository = resolve(import.meta.dirname, '..');
|
|
17
|
+
const output = resolve(destination);
|
|
18
|
+
if (!options.length) {
|
|
19
|
+
const build = spawnSync('npm', ['run', 'build'], { cwd: repository, stdio: ['ignore', 2, 2] });
|
|
20
|
+
if (build.error) throw build.error;
|
|
21
|
+
if (build.status !== 0) process.exit(build.status ?? 1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function pack(directory: string, destination: string): Promise<string> {
|
|
25
|
+
const { stdout } = await run('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', destination], {
|
|
26
|
+
cwd: directory, maxBuffer: 4 * 1024 ** 2,
|
|
27
|
+
});
|
|
28
|
+
return JSON.parse(stdout)[0].filename;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const temporary = await mkdtemp(join(tmpdir(), 'anyswarm-pack-release-'));
|
|
32
|
+
try {
|
|
33
|
+
// Start from npm's allowlist so private checkout files never enter staging.
|
|
34
|
+
const sourceArchive = await pack(repository, temporary);
|
|
35
|
+
await run('tar', ['-xzf', join(temporary, sourceArchive), '-C', temporary]);
|
|
36
|
+
const staged = join(temporary, 'package');
|
|
37
|
+
const manifestPath = join(staged, 'package.json');
|
|
38
|
+
const lockPath = join(staged, 'npm-shrinkwrap.json');
|
|
39
|
+
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
40
|
+
// Service images compile TypeScript. The Pi installation belongs to the executor.
|
|
41
|
+
delete manifest.devDependencies?.['@earendil-works/pi-coding-agent'];
|
|
42
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
43
|
+
await run('npm', ['install', '--package-lock-only', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], { cwd: staged });
|
|
44
|
+
const lock = JSON.parse(await readFile(lockPath, 'utf8'));
|
|
45
|
+
if (lock.lockfileVersion !== 3 || !lock.packages?.['']) {
|
|
46
|
+
throw new Error('Release packaging requires a v3 npm shrinkwrap with root package metadata');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await rename(manifestPath, join(staged, 'package.development.json'));
|
|
50
|
+
await rename(lockPath, join(staged, 'npm-shrinkwrap.development.json'));
|
|
51
|
+
delete manifest.private;
|
|
52
|
+
delete manifest.devDependencies;
|
|
53
|
+
delete lock.packages[''].devDependencies;
|
|
54
|
+
lock.packages = Object.fromEntries(
|
|
55
|
+
Object.entries<{ dev?: boolean }>(lock.packages).filter(([, entry]) => !entry.dev),
|
|
56
|
+
);
|
|
57
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
58
|
+
await writeFile(lockPath, JSON.stringify(lock, null, 2) + '\n');
|
|
59
|
+
// npm records existing file modes, which can also depend on the checkout umask.
|
|
60
|
+
for (const entry of await readdir(staged, { recursive: true, withFileTypes: true })) {
|
|
61
|
+
if (!entry.isFile()) continue;
|
|
62
|
+
const path = join(entry.parentPath, entry.name);
|
|
63
|
+
const { mode } = await stat(path);
|
|
64
|
+
await chmod(path, mode & 0o111 ? 0o755 : 0o644);
|
|
65
|
+
}
|
|
66
|
+
await mkdir(output, { recursive: true });
|
|
67
|
+
console.log(join(output, await pack(staged, output)));
|
|
68
|
+
} finally {
|
|
69
|
+
await rm(temporary, { recursive: true, force: true });
|
|
70
|
+
}
|
|
@@ -6,6 +6,7 @@ import { createHash } from 'node:crypto';
|
|
|
6
6
|
import { createInterface } from 'node:readline';
|
|
7
7
|
import { assertPiThinkingLevel, createPiSessionController, PI_SESSION_CAPABILITIES } from './pi-session-controller.js';
|
|
8
8
|
import { createPiServiceTools } from './pi-service-tools.js';
|
|
9
|
+
import { executorVersion } from '../src/core/executor-adapter.js';
|
|
9
10
|
import { PI_SESSION_OUTPUT_LIMIT as maximumOutputBytes } from './pi-session-diagnostics.js';
|
|
10
11
|
|
|
11
12
|
// This module is a Guest executable. Core never imports the Pi runtime.
|
|
@@ -16,11 +17,18 @@ async function loadPi() {
|
|
|
16
17
|
const sdk: any = await import(entry);
|
|
17
18
|
const packagePath = new URL('../package.json', entry);
|
|
18
19
|
const metadata = JSON.parse(await readFile(packagePath, 'utf8'));
|
|
19
|
-
if (!
|
|
20
|
+
if (!executorVersion(metadata.version) || [
|
|
21
|
+
sdk.SettingsManager?.inMemory, sdk.DefaultResourceLoader, sdk.ModelRuntime?.create,
|
|
22
|
+
sdk.SessionManager?.create, sdk.SessionManager?.open,
|
|
23
|
+
sdk.createAgentSession, sdk.createCodemodeExtension, sdk.createToolSearchExtension,
|
|
24
|
+
].some(required => typeof required !== 'function')) {
|
|
25
|
+
throw new Error('The installed Pi package does not expose the required Session Bridge API');
|
|
26
|
+
}
|
|
20
27
|
return { sdk, version: metadata.version };
|
|
21
28
|
}
|
|
22
|
-
const options = JSON.parse(await readFile(process.argv[2], 'utf8'));
|
|
23
29
|
const { sdk, version } = await loadPi();
|
|
30
|
+
if (process.argv[2] === '--check-sdk') process.exit(0);
|
|
31
|
+
const options = JSON.parse(await readFile(process.argv[2], 'utf8'));
|
|
24
32
|
const args: string[] = options.args ?? [];
|
|
25
33
|
const argument = (name: string) => { const index = args.indexOf(name); return index < 0 ? undefined : args[index + 1]; };
|
|
26
34
|
const cwd = process.cwd();
|
package/scripts/run-harness.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { installSourceLoader } from '../src/harness/typescript-loader.js';
|
|
4
5
|
|
|
5
|
-
const usage = 'node dist/scripts/run-harness.js --config <host-module.
|
|
6
|
+
const usage = 'node dist/scripts/run-harness.js --config <host-module.ts>';
|
|
6
7
|
const args = process.argv.slice(2);
|
|
7
8
|
const lifetime = new AbortController();
|
|
8
9
|
const stop = () => lifetime.abort();
|
|
@@ -32,6 +33,7 @@ try {
|
|
|
32
33
|
await writeOutput(`${usage}\nConfiguration default export selects mode (taskpool or peermesh), options and finite timeoutMs. Read JSON-line status, kickoff, input, wait or stop commands from stdin.\n`);
|
|
33
34
|
} else {
|
|
34
35
|
if (args.length !== 2 || args[0] !== '--config' || !args[1] || args[1].startsWith('--')) throw Object.assign(new Error(), { code: 'HOST_ARGUMENTS_INVALID' });
|
|
36
|
+
installSourceLoader();
|
|
35
37
|
const { default: configuration } = await import(pathToFileURL(resolve(args[1])).href);
|
|
36
38
|
const { keepsForegroundCommandsOpen, runForegroundHarness } = await import('../src/cli/foreground-harnesses.js');
|
|
37
39
|
const { runForegroundCommands } = await import('../src/harness/foreground-commands.js');
|