@anyswarm/core 0.5.0 → 0.5.1
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/README.md +11 -10
- package/deploy/worker/Dockerfile +12 -4
- package/dist/deploy/worker/Dockerfile +12 -4
- package/dist/examples/README.md +24 -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 +33 -0
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +18 -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 +15 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
- package/dist/examples/autoresearch/frontiercs2.js +211 -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 +115 -0
- package/dist/examples/autoresearch/project.js +410 -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 +25 -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 +13 -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/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 +40 -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/outbox.d.ts +5 -0
- package/dist/examples/super/outbox.js +103 -0
- package/dist/examples/super/project.d.ts +111 -0
- package/dist/examples/super/project.js +253 -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-applications.d.ts +19 -0
- package/dist/scripts/anyswarm-applications.js +19 -0
- package/dist/scripts/anyswarm-arguments.d.ts +35 -5
- package/dist/scripts/anyswarm-arguments.js +87 -23
- 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 +2 -0
- package/dist/scripts/anyswarm-harnesses.js +31 -0
- package/dist/scripts/anyswarm-installation.js +19 -13
- package/dist/scripts/anyswarm-launch.d.ts +37 -0
- package/dist/scripts/anyswarm-launch.js +86 -0
- package/dist/scripts/anyswarm-project.d.ts +12 -2
- package/dist/scripts/anyswarm-project.js +121 -20
- package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
- package/dist/scripts/anyswarm-source-runner.js +232 -0
- package/dist/scripts/anyswarm-tui-config.d.ts +36 -0
- package/dist/scripts/anyswarm-tui-config.js +189 -0
- package/dist/scripts/anyswarm-tui-session.d.ts +66 -0
- package/dist/scripts/anyswarm-tui-session.js +304 -0
- package/dist/scripts/anyswarm-tui-terminal.d.ts +41 -0
- package/dist/scripts/anyswarm-tui-terminal.js +154 -0
- package/dist/scripts/anyswarm-tui.d.ts +2 -0
- package/dist/scripts/anyswarm-tui.js +1012 -0
- package/dist/scripts/anyswarm.js +47 -2
- 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 +6 -1
- package/dist/scripts/local-environment.js +52 -16
- 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 +2 -2
- package/dist/scripts/local-setup.js +72 -12
- package/dist/scripts/opensandbox-agent-worker.js +2 -2
- package/dist/scripts/pack-release.d.ts +1 -0
- package/dist/scripts/pack-release.js +63 -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 +13 -1
- package/dist/src/harness/project-harness.js +36 -10
- 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 +3 -1
- 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 +3 -1
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-agent-core.md +1 -1
- package/docs/architecture/06-observability-experiments.md +1 -1
- package/docs/architecture/07-run-configuration.md +18 -12
- 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 +148 -84
- 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 -3
- package/docs/architecture/23-project-harness.md +124 -5
- package/docs/architecture/24-runtime-recovery.md +10 -3
- package/docs/architecture/25-foreground-tui.md +51 -0
- package/docs/architecture/26-code.md +39 -0
- package/docs/architecture/27-personal.md +43 -0
- package/docs/architecture/28-autoresearch.md +31 -0
- package/docs/architecture/INDEX.md +4 -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 +489 -21
- package/docs/designs/core-harness/06-project-harness.md +13 -2
- package/docs/designs/core-harness/README.md +5 -0
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +3 -5
- package/docs/en/changelog.md +13 -4
- package/docs/en/first-harness.md +8 -11
- 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 +12 -123
- package/docs/en/overview.md +1 -1
- package/docs/en/quickstart.md +40 -16
- package/docs/en/reference/api.md +14 -4
- package/docs/en/reference/cli.md +58 -14
- package/docs/en/runtime.md +2 -2
- package/docs/en/services.md +4 -0
- package/docs/third-party-notices.md +1 -0
- package/docs/workflows/development.md +17 -12
- package/docs/workflows/release-and-docs-versioning.md +76 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +3 -5
- package/docs/zh/changelog.md +13 -4
- package/docs/zh/first-harness.md +8 -11
- 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 +13 -124
- package/docs/zh/overview.md +1 -1
- package/docs/zh/quickstart.md +40 -16
- package/docs/zh/reference/api.md +14 -4
- package/docs/zh/reference/cli.md +58 -14
- package/docs/zh/runtime.md +2 -2
- package/docs/zh/services.md +4 -0
- package/examples/README.md +24 -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 +33 -0
- package/examples/autoresearch/REQUIREMENTS.zh.md +18 -0
- package/examples/autoresearch/config.ts +90 -0
- package/examples/autoresearch/demo.ts +55 -0
- package/examples/autoresearch/eject.json +15 -0
- package/examples/autoresearch/frontiercs2.ts +237 -0
- package/examples/autoresearch/prepare.ts +267 -0
- package/examples/autoresearch/process.ts +50 -0
- package/examples/autoresearch/project.ts +397 -0
- package/examples/autoresearch/research-service.ts +302 -0
- package/examples/code/README.md +25 -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 +13 -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/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 +40 -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/outbox.ts +97 -0
- package/examples/super/project.ts +227 -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 +2199 -0
- package/npm-shrinkwrap.json +86 -1920
- package/package.development.json +92 -0
- package/package.json +13 -7
- package/scripts/anyswarm-applications.ts +39 -0
- package/scripts/anyswarm-arguments.ts +94 -28
- package/scripts/anyswarm-author.ts +25 -0
- package/scripts/anyswarm-eject.ts +145 -0
- package/scripts/anyswarm-harnesses.ts +27 -0
- package/scripts/anyswarm-installation.ts +19 -13
- package/scripts/anyswarm-launch.ts +108 -0
- package/scripts/anyswarm-project.ts +114 -21
- package/scripts/anyswarm-source-runner.ts +203 -0
- package/scripts/anyswarm-tui-config.ts +174 -0
- package/scripts/anyswarm-tui-session.ts +295 -0
- package/scripts/anyswarm-tui-terminal.ts +147 -0
- package/scripts/anyswarm-tui.ts +912 -0
- package/scripts/anyswarm.ts +43 -2
- 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 +55 -17
- package/scripts/local-setup-smoke.ts +3 -2
- package/scripts/local-setup-worker.ts +17 -7
- package/scripts/local-setup.ts +66 -13
- package/scripts/opensandbox-agent-worker.ts +2 -2
- package/scripts/pack-release.ts +67 -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 +36 -10
- 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 +2 -1
- 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
package/scripts/anyswarm.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { readFile, realpath } from 'node:fs/promises';
|
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
6
6
|
import { parseAnySwarmCommand } from './anyswarm-arguments.js';
|
|
7
|
+
import { builtins } from './anyswarm-harnesses.js';
|
|
7
8
|
|
|
8
9
|
const args = process.argv.slice(2);
|
|
9
10
|
if (args.length === 1 && args[0] === '--version') {
|
|
@@ -28,12 +29,50 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
28
29
|
} else {
|
|
29
30
|
let command;
|
|
30
31
|
try {
|
|
31
|
-
command = parseAnySwarmCommand(args);
|
|
32
|
+
command = parseAnySwarmCommand(args, builtins);
|
|
32
33
|
} catch (error) {
|
|
33
34
|
console.error((error as Error).message);
|
|
34
35
|
process.exitCode = 2;
|
|
35
36
|
}
|
|
36
37
|
if (command && 'help' in command) console.log(command.help);
|
|
38
|
+
if (command && 'command' in command && command.command === 'tui') {
|
|
39
|
+
let code = 2;
|
|
40
|
+
try {
|
|
41
|
+
const { runAnySwarmTui } = await import('./anyswarm-tui.js');
|
|
42
|
+
code = await runAnySwarmTui(command, process.cwd());
|
|
43
|
+
} catch {
|
|
44
|
+
console.error('Could not load the TUI. Reinstall @anyswarm/core or use explicit foreground or RPC mode.');
|
|
45
|
+
}
|
|
46
|
+
process.exit(code);
|
|
47
|
+
}
|
|
48
|
+
if (command && 'command' in command && command.command === 'use') {
|
|
49
|
+
try {
|
|
50
|
+
const { runHarnessSelection } = await import('./anyswarm-launch.js');
|
|
51
|
+
const code = await runHarnessSelection(command, process.cwd());
|
|
52
|
+
process.stdout.write('', () => process.exit(code));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error instanceof Error ? error.message : 'Could not launch the requested Harness.');
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (command && 'command' in command && command.command === 'run') {
|
|
59
|
+
try {
|
|
60
|
+
const { runSourceCommand } = await import('./anyswarm-author.js');
|
|
61
|
+
process.exitCode = await runSourceCommand(command, process.cwd());
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error instanceof Error ? error.message : 'Could not run the TypeScript Harness.');
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (command && 'command' in command && command.command === 'eject') {
|
|
68
|
+
try {
|
|
69
|
+
const { ejectSourceCommand } = await import('./anyswarm-author.js');
|
|
70
|
+
console.log(JSON.stringify(await ejectSourceCommand(command, process.cwd())));
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(error instanceof Error ? error.message : 'Could not export the application.');
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
37
76
|
if (command && 'command' in command && command.command === 'harness') {
|
|
38
77
|
const { runProjectCommand } = await import('./anyswarm-project.js');
|
|
39
78
|
process.exit(await runProjectCommand(command, process.cwd()));
|
|
@@ -43,6 +82,8 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
43
82
|
let report: unknown;
|
|
44
83
|
try {
|
|
45
84
|
const { recoverRuntime } = await import('../src/core/index.js');
|
|
85
|
+
const { installSourceLoader } = await import('../src/harness/typescript-loader.js');
|
|
86
|
+
installSourceLoader();
|
|
46
87
|
const module = await import(pathToFileURL(await realpath(resolve(command.configPath))).href);
|
|
47
88
|
const config = typeof module.default === 'function' ? await module.default() : module.default;
|
|
48
89
|
const runtime = await recoverRuntime({ ...config, runDirectory: command.directory, cleanupOnly: true });
|
|
@@ -58,7 +99,7 @@ if (args.length === 1 && args[0] === '--version') {
|
|
|
58
99
|
// Pending cleanup can still own open sockets and renewable resources. The
|
|
59
100
|
// one-shot command hands those back to the durable record on process exit.
|
|
60
101
|
process.stdout.write(JSON.stringify(report, null, 2) + '\n', () => process.exit(exitCode));
|
|
61
|
-
} else if (command && 'command' in command) {
|
|
102
|
+
} else if (command && 'command' in command && (command.command === 'setup' || command.command === 'doctor' || command.command === 'update')) {
|
|
62
103
|
const controller = new AbortController();
|
|
63
104
|
let signalCode: number | undefined;
|
|
64
105
|
const interrupt = (signal: NodeJS.Signals) => {
|
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
|
}
|
|
@@ -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,10 +75,14 @@ export function resolveSubagentsEnvironment(config: Partial<LocalEnvironmentConf
|
|
|
73
75
|
return resolveLocalEnvironment(config, 'SUBAGENTS');
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
export function
|
|
78
|
+
export function checkSetupHost({ requiresLinux = true }: { requiresLinux?: boolean } = {}): DiagnosticCheck[] {
|
|
77
79
|
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
80
|
+
const os = platform();
|
|
78
81
|
return [
|
|
79
|
-
|
|
82
|
+
requiresLinux
|
|
83
|
+
? check('host.linux', os === 'linux', `Host operating system ${os}`,
|
|
84
|
+
os === 'darwin' ? 'macOS managed Worker preparation and smoke are not yet available in this build.' : 'Run this command on Linux.')
|
|
85
|
+
: check('host.platform', os === 'linux' || os === 'darwin', `Host operating system ${os}`, 'Run this command on Linux or macOS.'),
|
|
80
86
|
check('host.node', major > 22 || major === 22 && minor >= 19, `Node.js ${process.versions.node}`, 'Install Node.js 22.19 or newer.'),
|
|
81
87
|
];
|
|
82
88
|
}
|
|
@@ -102,7 +108,10 @@ export async function resolveLocalDocker() {
|
|
|
102
108
|
const socket = await localDockerSocket();
|
|
103
109
|
const info = JSON.parse(await run('docker', ['info', '--format', '{{json .}}']));
|
|
104
110
|
if (info.OSType !== 'linux') throw new Error('Local setup needs a Linux Docker Engine.');
|
|
105
|
-
|
|
111
|
+
if (darwin && ![nativeArchitecture, ...(nativeArchitecture === 'arm64' ? ['aarch64'] : ['x86_64'])].includes(info.Architecture)) {
|
|
112
|
+
throw Object.assign(new Error('The Docker daemon does not match the native Mac architecture.'), { code: 'DOCKER_ARCHITECTURE' });
|
|
113
|
+
}
|
|
114
|
+
const bridge = darwin ? undefined : JSON.parse(await run('docker', ['network', 'inspect', 'bridge']).catch(() => '[]'))[0];
|
|
106
115
|
const advertiseHost: string | undefined = bridge?.IPAM?.Config?.find((entry: { Gateway?: string }) => isIP(entry.Gateway ?? '') === 4)?.Gateway;
|
|
107
116
|
return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value: string) => value.includes('rootless')) === true };
|
|
108
117
|
}
|
|
@@ -112,20 +121,35 @@ export async function checkLocalDocker() {
|
|
|
112
121
|
const docker = await resolveLocalDocker();
|
|
113
122
|
return { docker, diagnostic: check('host.docker-engine', true, `Linux Docker Engine (${docker.rootless ? 'rootless' : 'rootful'})`) };
|
|
114
123
|
} catch (error) {
|
|
124
|
+
if ((error as NodeJS.ErrnoException).code === 'DOCKER_ARCHITECTURE') {
|
|
125
|
+
return { diagnostic: check('host.docker-engine', false, 'The Docker daemon does not match the native Mac architecture.',
|
|
126
|
+
'Select a native local Docker engine for this Mac and run docker info. AnySwarm does not fall back to emulation.') };
|
|
127
|
+
}
|
|
115
128
|
const missing = (error as NodeJS.ErrnoException).code === 'ENOENT' &&
|
|
116
129
|
(error as NodeJS.ErrnoException).syscall === 'spawn docker';
|
|
117
|
-
const remedy =
|
|
118
|
-
'
|
|
130
|
+
const remedy = platform() === 'darwin'
|
|
131
|
+
? 'Install Docker Desktop for Mac (https://docs.docker.com/desktop/setup/install/mac-install/), open it, and wait for the engine to start. If you already use another local Linux engine such as OrbStack, start that instead. The Docker CLI alone is not enough. Run docker context show and docker info. If needed, run docker context ls and docker context use <local-context>. Also check any DOCKER_CONTEXT or DOCKER_HOST override.'
|
|
132
|
+
: missing ? await dockerInstallRemedy() :
|
|
133
|
+
'Run docker context show and docker info. Start the selected engine or use an authorized local Docker context. For a socket permission error, ask the host administrator to grant access and sign in again after any group change. Then rerun the same anyswarm setup command.';
|
|
119
134
|
return { diagnostic: check('host.docker-engine', false, 'Could not access a Linux Docker Engine through the selected local Unix Docker context.', remedy) };
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
|
|
138
|
+
export async function discoverMacCallback(image: string, signal?: AbortSignal) {
|
|
139
|
+
const output = await run('docker', ['run', '--rm', '--platform', `linux/${nativeArchitecture}`, '--entrypoint', 'getent', image, 'ahostsv4', 'host.docker.internal'], signal).catch(() => '');
|
|
140
|
+
signal?.throwIfAborted();
|
|
141
|
+
const addresses = [...new Set(output.split('\n').map(line => line.split(/\s+/, 1)[0])
|
|
142
|
+
.filter(value => isIP(value) === 4 && value !== '0.0.0.0' && !value.startsWith('127.')))];
|
|
143
|
+
if (addresses.length !== 1) throw Object.assign(new Error('Could not resolve the native Mac callback in Docker'), { code: 'DOCKER_CALLBACK_UNAVAILABLE' });
|
|
144
|
+
return addresses[0];
|
|
145
|
+
}
|
|
146
|
+
|
|
123
147
|
interface ProviderInfo {
|
|
124
148
|
Id: string;
|
|
125
149
|
Image: string;
|
|
126
150
|
Config: { Image: string; Cmd?: string[]; Env?: string[]; Labels?: Record<string, string> };
|
|
127
151
|
State: { Running: boolean };
|
|
128
|
-
HostConfig: { NetworkMode: string; Binds?: string[] };
|
|
152
|
+
HostConfig: { NetworkMode: string; Binds?: string[]; PortBindings?: Record<string, { HostIp: string; HostPort: string }[]> };
|
|
129
153
|
}
|
|
130
154
|
|
|
131
155
|
function lifecycleUrl(config: LocalEnvironmentConfig) {
|
|
@@ -149,8 +173,15 @@ async function ownedProvider(config: LocalEnvironmentConfig, provider: ProviderI
|
|
|
149
173
|
if (!token || !/^[a-f0-9-]{36}$/.test(token) || labels?.['org.anyswarm.setup.profile'] !== profileVersion ||
|
|
150
174
|
(config.providerId && config.providerId !== provider.Id)) return false;
|
|
151
175
|
const state = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
152
|
-
|
|
153
|
-
|
|
176
|
+
const port = String(lifecycleUrl(config)?.port || 80);
|
|
177
|
+
const ports = provider.HostConfig?.PortBindings;
|
|
178
|
+
const publication = ports?.[`${port}/tcp`];
|
|
179
|
+
const networkMatches = darwin
|
|
180
|
+
? provider.HostConfig?.NetworkMode === 'bridge' && Object.keys(ports ?? {}).length === 1 &&
|
|
181
|
+
publication?.length === 1 && publication[0].HostIp === '127.0.0.1' && publication[0].HostPort === port &&
|
|
182
|
+
provider.HostConfig.Binds?.includes('/var/run/docker.sock:/var/run/docker.sock')
|
|
183
|
+
: provider.HostConfig?.NetworkMode === 'host';
|
|
184
|
+
if (labels['org.anyswarm.setup.state'] !== state || provider.Config.Image !== localProviderImage || !networkMatches ||
|
|
154
185
|
!provider.HostConfig.Binds?.includes(`${join(state, 'config.toml')}:/config/config.toml:ro`) ||
|
|
155
186
|
!provider.HostConfig.Binds.includes(`${join(state, 'data')}:/root/.opensandbox`)) return false;
|
|
156
187
|
const privatePath = (path: string, directory: boolean) => lstat(path)
|
|
@@ -230,7 +261,8 @@ async function withProviderLock<T>(config: LocalEnvironmentConfig, action: () =>
|
|
|
230
261
|
signal?.throwIfAborted();
|
|
231
262
|
const directory = join(homedir(), '.cache/anyswarm/opensandbox');
|
|
232
263
|
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
233
|
-
const
|
|
264
|
+
const flags = darwin ? ['-k', '-t', '180'] : ['--exclusive', '--timeout', '180'];
|
|
265
|
+
const child = spawn(darwin ? '/usr/bin/lockf' : 'flock', [...flags, join(directory, `port-${url.port || 80}.lock`),
|
|
234
266
|
process.execPath, '-e', 'console.log("locked"); process.stdin.resume()'],
|
|
235
267
|
{ stdio: ['pipe', 'pipe', 'pipe'] });
|
|
236
268
|
child.stdin.on('error', () => {});
|
|
@@ -274,12 +306,13 @@ function localPortInUse(url: URL) {
|
|
|
274
306
|
|
|
275
307
|
async function prepareProviderImage(image: string, code: string, signal?: AbortSignal) {
|
|
276
308
|
try {
|
|
277
|
-
await run('docker', ['image', 'inspect', image], signal);
|
|
309
|
+
const architecture = await run('docker', ['image', 'inspect', ...(darwin ? ['--format', '{{.Os}}/{{.Architecture}}'] : []), image], signal);
|
|
310
|
+
if (darwin && architecture !== `linux/${nativeArchitecture}`) throw new Error('Pinned image is not installed for the native architecture.');
|
|
278
311
|
} catch {
|
|
279
312
|
signal?.throwIfAborted();
|
|
280
313
|
console.error(`anyswarm setup: pulling ${image}`);
|
|
281
314
|
try {
|
|
282
|
-
await run('docker', ['pull', image], signal);
|
|
315
|
+
await run('docker', ['pull', ...(darwin ? ['--platform', `linux/${nativeArchitecture}`] : []), image], signal);
|
|
283
316
|
} catch {
|
|
284
317
|
signal?.throwIfAborted();
|
|
285
318
|
throw Object.assign(new Error('Docker could not pull the pinned OpenSandbox image'), { code });
|
|
@@ -291,7 +324,9 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
291
324
|
const url = lifecycleUrl(config);
|
|
292
325
|
if (!url) throw Object.assign(new Error('Local loopback OpenSandbox /v1 URL required'), { code: 'PROVIDER_CONFIGURATION_INVALID' });
|
|
293
326
|
signal?.throwIfAborted();
|
|
294
|
-
const
|
|
327
|
+
const docker = await resolveLocalDocker();
|
|
328
|
+
const socket = darwin ? '/var/run/docker.sock' : docker.socket;
|
|
329
|
+
const activeConfig = (): LocalEnvironmentConfig => ({ ...config, egressMode: 'dns+nft', ...(darwin ? { useServerProxy: true } : {}) });
|
|
295
330
|
const existing = await inspectProvider(config, signal);
|
|
296
331
|
if (existing && !await ownedProvider(config, existing)) {
|
|
297
332
|
throw Object.assign(new Error('A different container owns the local service name'), { code: 'PROVIDER_NAME_IN_USE' });
|
|
@@ -330,8 +365,10 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
330
365
|
const token = randomUUID();
|
|
331
366
|
const stateDir = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
332
367
|
const name = `anyswarm-opensandbox-${url.port || 80}`;
|
|
368
|
+
const port = Number(url.port || 80);
|
|
333
369
|
const recipe = (await readFile(join(root, 'deploy/opensandbox/config.toml'), 'utf8')).replace('port = 8080',
|
|
334
|
-
`port = ${
|
|
370
|
+
`port = ${port}\napi_key = ${JSON.stringify(config.apiKey)}`).replace('host = "127.0.0.1"',
|
|
371
|
+
darwin ? 'host = "0.0.0.0"' : 'host = "127.0.0.1"');
|
|
335
372
|
try {
|
|
336
373
|
await mkdir(join(stateDir, 'data'), { recursive: true, mode: 0o700 });
|
|
337
374
|
await writeFile(join(stateDir, 'config.toml'), recipe, { mode: 0o600, flag: 'wx' });
|
|
@@ -384,7 +421,8 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
384
421
|
await prepareProviderImage(localEgressImage, 'PROVIDER_EGRESS_PULL_FAILED', signal);
|
|
385
422
|
await prepareProviderImage(localProviderImage, 'PROVIDER_SERVER_PULL_FAILED', signal);
|
|
386
423
|
try {
|
|
387
|
-
|
|
424
|
+
const network = darwin ? ['--platform', `linux/${nativeArchitecture}`, '--network', 'bridge', '--publish', `127.0.0.1:${port}:${port}`] : ['--network', 'host'];
|
|
425
|
+
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
426
|
created = true;
|
|
389
427
|
} catch {
|
|
390
428
|
// Docker atomically reserves the name, allowing simultaneous setup calls to converge.
|
|
@@ -395,7 +433,7 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
395
433
|
const provider = await waitForProvider({ ...config, providerId: id || undefined }, signal);
|
|
396
434
|
if (created) {
|
|
397
435
|
providerReady = true;
|
|
398
|
-
return { ...handle, config:
|
|
436
|
+
return { ...handle, config: activeConfig(), created: true, id, images: await imageIds(provider) };
|
|
399
437
|
}
|
|
400
438
|
await rm(stateDir, { recursive: true, force: true });
|
|
401
439
|
return reuse(provider);
|
|
@@ -407,7 +445,7 @@ async function ensureLocalProviderLocked(config: LocalEnvironmentConfig, { signa
|
|
|
407
445
|
async function reuse(provider: ProviderInfo): Promise<LocalProviderHandle> {
|
|
408
446
|
const path = provider.Config.Labels?.['org.anyswarm.setup.state'];
|
|
409
447
|
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:
|
|
448
|
+
return { config: activeConfig(), id: provider.Id, images: await imageIds(provider), created: false, retain: async () => {
|
|
411
449
|
const current = await inspectProvider(config);
|
|
412
450
|
if (current?.Id !== provider.Id) throw new Error('Provider identity changed');
|
|
413
451
|
}, cleanup: async () => ({ status: 'complete', id: provider.Id, retained: true }) };
|
|
@@ -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)] };
|