@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/dist/scripts/anyswarm.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFile, realpath } from 'node:fs/promises';
|
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
5
|
import { parseAnySwarmCommand } from './anyswarm-arguments.js';
|
|
6
|
+
import { builtins } from './anyswarm-harnesses.js';
|
|
6
7
|
const args = process.argv.slice(2);
|
|
7
8
|
if (args.length === 1 && args[0] === '--version') {
|
|
8
9
|
const manifest = JSON.parse(await readFile(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
@@ -27,7 +28,7 @@ else if (args[0] === 'trace') {
|
|
|
27
28
|
else {
|
|
28
29
|
let command;
|
|
29
30
|
try {
|
|
30
|
-
command = parseAnySwarmCommand(args);
|
|
31
|
+
command = parseAnySwarmCommand(args, builtins);
|
|
31
32
|
}
|
|
32
33
|
catch (error) {
|
|
33
34
|
console.error(error.message);
|
|
@@ -35,6 +36,48 @@ else {
|
|
|
35
36
|
}
|
|
36
37
|
if (command && 'help' in command)
|
|
37
38
|
console.log(command.help);
|
|
39
|
+
if (command && 'command' in command && command.command === 'tui') {
|
|
40
|
+
let code = 2;
|
|
41
|
+
try {
|
|
42
|
+
const { runAnySwarmTui } = await import('./anyswarm-tui.js');
|
|
43
|
+
code = await runAnySwarmTui(command, process.cwd());
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
console.error('Could not load the TUI. Reinstall @anyswarm/core or use explicit foreground or RPC mode.');
|
|
47
|
+
}
|
|
48
|
+
process.exit(code);
|
|
49
|
+
}
|
|
50
|
+
if (command && 'command' in command && command.command === 'use') {
|
|
51
|
+
try {
|
|
52
|
+
const { runHarnessSelection } = await import('./anyswarm-launch.js');
|
|
53
|
+
const code = await runHarnessSelection(command, process.cwd());
|
|
54
|
+
process.stdout.write('', () => process.exit(code));
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(error instanceof Error ? error.message : 'Could not launch the requested Harness.');
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (command && 'command' in command && command.command === 'run') {
|
|
62
|
+
try {
|
|
63
|
+
const { runSourceCommand } = await import('./anyswarm-author.js');
|
|
64
|
+
process.exitCode = await runSourceCommand(command, process.cwd());
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(error instanceof Error ? error.message : 'Could not run the TypeScript Harness.');
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (command && 'command' in command && command.command === 'eject') {
|
|
72
|
+
try {
|
|
73
|
+
const { ejectSourceCommand } = await import('./anyswarm-author.js');
|
|
74
|
+
console.log(JSON.stringify(await ejectSourceCommand(command, process.cwd())));
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error(error instanceof Error ? error.message : 'Could not export the application.');
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
38
81
|
if (command && 'command' in command && command.command === 'harness') {
|
|
39
82
|
const { runProjectCommand } = await import('./anyswarm-project.js');
|
|
40
83
|
process.exit(await runProjectCommand(command, process.cwd()));
|
|
@@ -44,6 +87,8 @@ else {
|
|
|
44
87
|
let report;
|
|
45
88
|
try {
|
|
46
89
|
const { recoverRuntime } = await import('../src/core/index.js');
|
|
90
|
+
const { installSourceLoader } = await import('../src/harness/typescript-loader.js');
|
|
91
|
+
installSourceLoader();
|
|
47
92
|
const module = await import(pathToFileURL(await realpath(resolve(command.configPath))).href);
|
|
48
93
|
const config = typeof module.default === 'function' ? await module.default() : module.default;
|
|
49
94
|
const runtime = await recoverRuntime({ ...config, runDirectory: command.directory, cleanupOnly: true });
|
|
@@ -61,7 +106,7 @@ else {
|
|
|
61
106
|
// one-shot command hands those back to the durable record on process exit.
|
|
62
107
|
process.stdout.write(JSON.stringify(report, null, 2) + '\n', () => process.exit(exitCode));
|
|
63
108
|
}
|
|
64
|
-
else if (command && 'command' in command) {
|
|
109
|
+
else if (command && 'command' in command && (command.command === 'setup' || command.command === 'doctor' || command.command === 'update')) {
|
|
65
110
|
const controller = new AbortController();
|
|
66
111
|
let signalCode;
|
|
67
112
|
const interrupt = (signal) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"commit":"9856d2ac811c272a0be6f7c44cc5f9a636426132","dirty":false}
|
package/dist/scripts/build.js
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
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
@@ -54,3 +54,9 @@ if (await stat(traceViewerSource).catch(error => {
|
|
|
54
54
|
for (const name of ['anyswarm', 'swarm']) {
|
|
55
55
|
await chmod(resolve(dist, `scripts/${name}.js`), 0o755);
|
|
56
56
|
}
|
|
57
|
+
const revision = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' });
|
|
58
|
+
const status = spawnSync('git', ['status', '--porcelain'], { cwd: root, encoding: 'utf8' });
|
|
59
|
+
await writeFile(resolve(dist, 'scripts/build-provenance.json'), JSON.stringify({
|
|
60
|
+
commit: revision.status === 0 ? revision.stdout.trim() : null,
|
|
61
|
+
dirty: status.status === 0 ? Boolean(status.stdout.trim()) : null,
|
|
62
|
+
}) + '\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';
|
|
@@ -65,6 +66,7 @@ for (const source of sourcePaths.filter((path) => path.startsWith('src/core/')))
|
|
|
65
66
|
}
|
|
66
67
|
const { ALLOCATION_SCHEMA_SQL } = await import('../src/core/allocation-ledger.js');
|
|
67
68
|
const schemas = [
|
|
69
|
+
['Personal inbox, work and delivery', 'examples/super/inbox.ts', PERSONAL_SCHEMA_SQL],
|
|
68
70
|
['Core Runtime allocation ownership', 'src/core/allocation-ledger.ts', ALLOCATION_SCHEMA_SQL],
|
|
69
71
|
['Automatic service history', 'examples/taskpool/persistence/service-history.ts', SERVICE_HISTORY_SCHEMA_SQL],
|
|
70
72
|
['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';
|
|
@@ -30,7 +30,9 @@ assert.ok(args.length === 0 || (args.length === 1 && args[0] === '--check'), 'Us
|
|
|
30
30
|
const check = args[0] === '--check';
|
|
31
31
|
const sha256 = (text) => createHash('sha256').update(text).digest('hex');
|
|
32
32
|
const sourcePaths = [
|
|
33
|
+
'examples/super/prompts.ts', 'examples/super/execution.ts', 'examples/super/coordinator.ts',
|
|
33
34
|
'examples/taskpool/prompts/agent-contract.ts',
|
|
35
|
+
'examples/autoresearch/project.ts', 'examples/autoresearch/config.ts',
|
|
34
36
|
'examples/services/agent-control/run.ts', 'examples/services/agent-control/flow.sh', 'examples/services/persistent-board/run.ts',
|
|
35
37
|
'examples/services/mcp-managed/run.ts', 'examples/first-harness/harness.ts', 'examples/first-harness/handoff.ts',
|
|
36
38
|
'examples/parallel-swarm/harness.ts', 'examples/parallel-swarm/board-service.ts',
|
|
@@ -41,6 +43,7 @@ const sourcePaths = [
|
|
|
41
43
|
'scripts/local-setup-smoke.ts', 'scripts/local-setup-upstream.ts',
|
|
42
44
|
'examples/messages/handoff.ts',
|
|
43
45
|
'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',
|
|
46
|
+
'examples/code/prompts.ts',
|
|
44
47
|
'examples/taskpool/harness/controller.ts', 'examples/taskpool/harness/harness.ts',
|
|
45
48
|
'benchmarks/fate/fate-run.ts', 'benchmarks/fate/fate-service.ts', 'benchmarks/fate/paper-substrate.ts',
|
|
46
49
|
'benchmarks/putnambench-taskpool/run.ts',
|
|
@@ -90,6 +93,14 @@ function header(title, description) {
|
|
|
90
93
|
}
|
|
91
94
|
const outputs = new Map();
|
|
92
95
|
function output(file, text) { outputs.set(`${outputDir}/${file}`, `${text.trimEnd()}\n`); }
|
|
96
|
+
const researchSource = 'examples/autoresearch/project.ts';
|
|
97
|
+
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.');
|
|
98
|
+
researchDoc += block('Shared Profile instruction', evaluate('`' + between(researchSource, 'const instructions = `', '`;') + '`', { candidatePath: '.anyswarm-candidate.patch' }));
|
|
99
|
+
researchDoc += block('Initial peer input', evaluate('`' + between(researchSource, '? `', '`\n', 'const prompt = turn === 0') + '`', { label: '<PEER_LABEL>', config: { goal: '<RESEARCH_GOAL>' }, context: { input: { prompt: '<RUN_INPUT>' } } }));
|
|
100
|
+
researchDoc += block('Follow-up peer input', between(researchSource, ": '", "';", "? `You are "));
|
|
101
|
+
researchDoc += block('Candidate review notice', evaluate('`' + between(researchSource, 'return `', '`;', 'function reviewNotice') + '`', { candidate: '<CANDIDATE_ID>', sha256: '<CANDIDATE_SHA256>' }));
|
|
102
|
+
researchDoc += block('FrontierCS-2 demo objective', between('examples/autoresearch/config.ts', "export const demoGoal = '", "';"));
|
|
103
|
+
output('22-autoresearch.md', researchDoc);
|
|
93
104
|
const registry = createBuiltinServiceRegistry();
|
|
94
105
|
const profile = buildCapabilityProfile({ registry, role: AGENT_ROLES.BOUND });
|
|
95
106
|
const mathlibBundle = await loadServiceBundle(resolve(root, 'examples/services/mathlib-search'));
|
|
@@ -175,6 +186,13 @@ output('10-local-setup-probe.md', header('Complete local setup probe texts', 'Se
|
|
|
175
186
|
+ block('Controlled read arguments', JSON.stringify({ path: SETUP_READ }, null, 2))
|
|
176
187
|
+ block('Controlled final text', SETUP_RESULT));
|
|
177
188
|
const notesPath = 'examples/notes/main.ts';
|
|
189
|
+
const codePrompts = 'examples/code/prompts.ts';
|
|
190
|
+
output('26-code.md', header('Code application prompts', '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.')
|
|
191
|
+
+ block('Code Root Profile prompt', between(codePrompts, 'export const codeRootPrompt = `', '`;'))
|
|
192
|
+
+ block('Code editor Profile prompt', between(codePrompts, 'export const codeEditorPrompt = `', '`;'))
|
|
193
|
+
+ block('CLI Service hint', between(codePrompts, 'export const codeCliHint = `', '`;'), 'Appended to the role prompt when Service tools use the CLI, including Codex.')
|
|
194
|
+
+ block('Later Root and editor input', between(codePrompts, 'task: string) => `', '`;'), '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.')
|
|
195
|
+
+ block('Verification confirmation', 'Run ' + between(codePrompts, '=> `Run ', '`;'), 'The interpolation is the suggested argv from the pre-edit local package.json or Makefile, joined for display.'));
|
|
178
196
|
const notesKey = between(notesPath, "const key = '", "';\n");
|
|
179
197
|
const notesInput = evaluate(between(notesPath, 'const inputText = Object.freeze(', ');\n'), { key: notesKey });
|
|
180
198
|
output('07-notes-harness.md', header('Installed Notes Harness prompts', 'The Writer and Reader use the default Core system prompt with their own Notes grants and an empty Added System Prompt. The host supplies three fixed user inputs through its exclusive input helper. The seeded fact enters the model transcript when a Agent reads its file or receives it in a Service result.')
|
|
@@ -197,6 +215,7 @@ const subagentsPath = 'test-support/subagents/communication-fixture-prompts.ts';
|
|
|
197
215
|
output('08-subagents-harness.md', header('Subagents Harness prompts', '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.')
|
|
198
216
|
+ block('Root Profile prompt', rootPrompt)
|
|
199
217
|
+ block('Recursive Child Profile prompt', childPrompt)
|
|
218
|
+
+ ['steer', 'interrupt', 'stop'].map(operation => block(`Owner ${operation} notification`, ownerInterventionText(operation))).join('')
|
|
200
219
|
+ block('Pastel example initial task', evaluate(between('benchmarks/programbench-pastel/subagents-example.ts', 'const initial = ', ';\nconst supplement')))
|
|
201
220
|
+ block('Pastel example HSL supplement', evaluate(between('benchmarks/programbench-pastel/subagents-example.ts', 'const supplement = ', ';\nconst probes')))
|
|
202
221
|
+ block('Fixture Parent Profile prompt', evaluate(between(subagentsPath, 'export const parentPrompt = ', ';\n')))
|
|
@@ -346,7 +365,10 @@ output('18-agent-control.md', header('Built-in Agent control example prompt', 'T
|
|
|
346
365
|
const managedMcp = 'examples/services/mcp-managed/run.ts';
|
|
347
366
|
output('19-managed-mcp.md', header('Managed MCP and process example prompt', '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.')
|
|
348
367
|
+ block('Reader task', between(managedMcp, "runInput(runtime, reader.id,\n '", "',")));
|
|
349
|
-
|
|
368
|
+
const personalPrompts = 'examples/super/prompts.ts';
|
|
369
|
+
output('21-personal.md', header('Personal Router and worker prompts', '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.')
|
|
370
|
+
+ ['router', 'worker', 'reviewer'].map(role => block(role + ' Profile system prompt', evaluate(between(personalPrompts, `export const ${role}Prompt = `, ';\n')))).join(''));
|
|
371
|
+
for (const path of [candidateFirstHarnessPath, parallelHost, durableBoardPath, agentControl, managedMcp, 'examples/super/execution.ts']) {
|
|
350
372
|
for (const [index, line] of sources.get(path).split('\n').entries()) {
|
|
351
373
|
if (line.includes('runInput(runtime,'))
|
|
352
374
|
sendSites.push({ path, line: index + 1, expression: line.trim() });
|
|
@@ -40,6 +40,7 @@ export declare function resolveLocalEnvironment(partial?: Partial<LocalEnvironme
|
|
|
40
40
|
lifecycleBaseUrl: string;
|
|
41
41
|
apiKey: string | undefined;
|
|
42
42
|
advertiseHost: string | undefined;
|
|
43
|
+
advertiseHostDiscovery: "docker-network" | undefined;
|
|
43
44
|
publicUrl: string | undefined;
|
|
44
45
|
image: string | undefined;
|
|
45
46
|
useServerProxy: boolean | undefined;
|
|
@@ -61,6 +62,7 @@ export declare function resolveSubagentsEnvironment(config?: Partial<LocalEnviro
|
|
|
61
62
|
lifecycleBaseUrl: string;
|
|
62
63
|
apiKey: string | undefined;
|
|
63
64
|
advertiseHost: string | undefined;
|
|
65
|
+
advertiseHostDiscovery: "docker-network" | undefined;
|
|
64
66
|
publicUrl: string | undefined;
|
|
65
67
|
image: string | undefined;
|
|
66
68
|
useServerProxy: boolean | undefined;
|
|
@@ -78,7 +80,9 @@ export declare function resolveSubagentsEnvironment(config?: Partial<LocalEnviro
|
|
|
78
80
|
};
|
|
79
81
|
mode: "existing" | "local";
|
|
80
82
|
}>;
|
|
81
|
-
export declare function
|
|
83
|
+
export declare function checkSetupHost({ requiresLinux }?: {
|
|
84
|
+
requiresLinux?: boolean;
|
|
85
|
+
}): DiagnosticCheck[];
|
|
82
86
|
export declare function resolveLocalDocker(): Promise<{
|
|
83
87
|
socket: string;
|
|
84
88
|
advertiseHost: string | undefined;
|
|
@@ -95,6 +99,7 @@ export declare function checkLocalDocker(): Promise<{
|
|
|
95
99
|
docker?: undefined;
|
|
96
100
|
diagnostic: DiagnosticCheck;
|
|
97
101
|
}>;
|
|
102
|
+
export declare function discoverMacCallback(image: string, signal?: AbortSignal): Promise<string>;
|
|
98
103
|
export declare function checkLocalProvider(config: LocalEnvironmentConfig, { requireAuth }?: {
|
|
99
104
|
requireAuth?: boolean | undefined;
|
|
100
105
|
}): Promise<DiagnosticCheck[]>;
|
|
@@ -15,7 +15,9 @@ const execute = promisify(execFile);
|
|
|
15
15
|
export const localProviderImage = 'opensandbox/server:release-1.2.1@sha256:07f9b39adb8cadf68357dd1b86367068210e960fc4cb50e11b75176387557ea7';
|
|
16
16
|
export const localExecdImage = 'opensandbox/execd:release-1.2.1@sha256:6b12d17844ac7167271488302c71934e47f76abb9ddab19ec8529bd1c1c56b23';
|
|
17
17
|
export const localEgressImage = 'opensandbox/egress:release-1.2.1@sha256:84b98d3b5989a87389c977f6433f8cd3c7998d03aa15aaae41ebcb15b7eb8000';
|
|
18
|
-
const
|
|
18
|
+
const darwin = platform() === 'darwin';
|
|
19
|
+
const nativeArchitecture = process.arch === 'x64' ? 'amd64' : process.arch;
|
|
20
|
+
const profileVersion = darwin ? 'anyswarm-local-darwin-sdk-v1' : 'anyswarm-local-linux-sdk-v3';
|
|
19
21
|
const providerStartupMs = 90_000;
|
|
20
22
|
const sourceRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
21
23
|
const root = sourceRoot.endsWith('/dist/') ? fileURLToPath(new URL('../../', import.meta.url)) : sourceRoot;
|
|
@@ -32,10 +34,13 @@ export async function resolveLocalEnvironment(partial = {}, scope) {
|
|
|
32
34
|
export function resolveSubagentsEnvironment(config = {}) {
|
|
33
35
|
return resolveLocalEnvironment(config, 'SUBAGENTS');
|
|
34
36
|
}
|
|
35
|
-
export function
|
|
37
|
+
export function checkSetupHost({ requiresLinux = true } = {}) {
|
|
36
38
|
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
39
|
+
const os = platform();
|
|
37
40
|
return [
|
|
38
|
-
|
|
41
|
+
requiresLinux
|
|
42
|
+
? check('host.linux', os === 'linux', `Host operating system ${os}`, os === 'darwin' ? 'macOS managed Worker preparation and smoke are not yet available in this build.' : 'Run this command on Linux.')
|
|
43
|
+
: check('host.platform', os === 'linux' || os === 'darwin', `Host operating system ${os}`, 'Run this command on Linux or macOS.'),
|
|
39
44
|
check('host.node', major > 22 || major === 22 && minor >= 19, `Node.js ${process.versions.node}`, 'Install Node.js 22.19 or newer.'),
|
|
40
45
|
];
|
|
41
46
|
}
|
|
@@ -60,7 +65,10 @@ export async function resolveLocalDocker() {
|
|
|
60
65
|
const info = JSON.parse(await run('docker', ['info', '--format', '{{json .}}']));
|
|
61
66
|
if (info.OSType !== 'linux')
|
|
62
67
|
throw new Error('Local setup needs a Linux Docker Engine.');
|
|
63
|
-
|
|
68
|
+
if (darwin && ![nativeArchitecture, ...(nativeArchitecture === 'arm64' ? ['aarch64'] : ['x86_64'])].includes(info.Architecture)) {
|
|
69
|
+
throw Object.assign(new Error('The Docker daemon does not match the native Mac architecture.'), { code: 'DOCKER_ARCHITECTURE' });
|
|
70
|
+
}
|
|
71
|
+
const bridge = darwin ? undefined : JSON.parse(await run('docker', ['network', 'inspect', 'bridge']).catch(() => '[]'))[0];
|
|
64
72
|
const advertiseHost = bridge?.IPAM?.Config?.find((entry) => isIP(entry.Gateway ?? '') === 4)?.Gateway;
|
|
65
73
|
return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value) => value.includes('rootless')) === true };
|
|
66
74
|
}
|
|
@@ -70,13 +78,27 @@ export async function checkLocalDocker() {
|
|
|
70
78
|
return { docker, diagnostic: check('host.docker-engine', true, `Linux Docker Engine (${docker.rootless ? 'rootless' : 'rootful'})`) };
|
|
71
79
|
}
|
|
72
80
|
catch (error) {
|
|
81
|
+
if (error.code === 'DOCKER_ARCHITECTURE') {
|
|
82
|
+
return { diagnostic: check('host.docker-engine', false, 'The Docker daemon does not match the native Mac architecture.', 'Select a native local Docker engine for this Mac and run docker info. AnySwarm does not fall back to emulation.') };
|
|
83
|
+
}
|
|
73
84
|
const missing = error.code === 'ENOENT' &&
|
|
74
85
|
error.syscall === 'spawn docker';
|
|
75
|
-
const remedy =
|
|
76
|
-
'
|
|
86
|
+
const remedy = platform() === 'darwin'
|
|
87
|
+
? '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.'
|
|
88
|
+
: missing ? await dockerInstallRemedy() :
|
|
89
|
+
'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.';
|
|
77
90
|
return { diagnostic: check('host.docker-engine', false, 'Could not access a Linux Docker Engine through the selected local Unix Docker context.', remedy) };
|
|
78
91
|
}
|
|
79
92
|
}
|
|
93
|
+
export async function discoverMacCallback(image, signal) {
|
|
94
|
+
const output = await run('docker', ['run', '--rm', '--platform', `linux/${nativeArchitecture}`, '--entrypoint', 'getent', image, 'ahostsv4', 'host.docker.internal'], signal).catch(() => '');
|
|
95
|
+
signal?.throwIfAborted();
|
|
96
|
+
const addresses = [...new Set(output.split('\n').map(line => line.split(/\s+/, 1)[0])
|
|
97
|
+
.filter(value => isIP(value) === 4 && value !== '0.0.0.0' && !value.startsWith('127.')))];
|
|
98
|
+
if (addresses.length !== 1)
|
|
99
|
+
throw Object.assign(new Error('Could not resolve the native Mac callback in Docker'), { code: 'DOCKER_CALLBACK_UNAVAILABLE' });
|
|
100
|
+
return addresses[0];
|
|
101
|
+
}
|
|
80
102
|
function lifecycleUrl(config) {
|
|
81
103
|
return loopbackLifecycle(config.lifecycleBaseUrl);
|
|
82
104
|
}
|
|
@@ -99,8 +121,15 @@ async function ownedProvider(config, provider) {
|
|
|
99
121
|
(config.providerId && config.providerId !== provider.Id))
|
|
100
122
|
return false;
|
|
101
123
|
const state = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
const port = String(lifecycleUrl(config)?.port || 80);
|
|
125
|
+
const ports = provider.HostConfig?.PortBindings;
|
|
126
|
+
const publication = ports?.[`${port}/tcp`];
|
|
127
|
+
const networkMatches = darwin
|
|
128
|
+
? provider.HostConfig?.NetworkMode === 'bridge' && Object.keys(ports ?? {}).length === 1 &&
|
|
129
|
+
publication?.length === 1 && publication[0].HostIp === '127.0.0.1' && publication[0].HostPort === port &&
|
|
130
|
+
provider.HostConfig.Binds?.includes('/var/run/docker.sock:/var/run/docker.sock')
|
|
131
|
+
: provider.HostConfig?.NetworkMode === 'host';
|
|
132
|
+
if (labels['org.anyswarm.setup.state'] !== state || provider.Config.Image !== localProviderImage || !networkMatches ||
|
|
104
133
|
!provider.HostConfig.Binds?.includes(`${join(state, 'config.toml')}:/config/config.toml:ro`) ||
|
|
105
134
|
!provider.HostConfig.Binds.includes(`${join(state, 'data')}:/root/.opensandbox`))
|
|
106
135
|
return false;
|
|
@@ -183,7 +212,8 @@ async function withProviderLock(config, action, signal) {
|
|
|
183
212
|
signal?.throwIfAborted();
|
|
184
213
|
const directory = join(homedir(), '.cache/anyswarm/opensandbox');
|
|
185
214
|
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
186
|
-
const
|
|
215
|
+
const flags = darwin ? ['-k', '-t', '180'] : ['--exclusive', '--timeout', '180'];
|
|
216
|
+
const child = spawn(darwin ? '/usr/bin/lockf' : 'flock', [...flags, join(directory, `port-${url.port || 80}.lock`),
|
|
187
217
|
process.execPath, '-e', 'console.log("locked"); process.stdin.resume()'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
188
218
|
child.stdin.on('error', () => { });
|
|
189
219
|
const cancel = () => child.kill('SIGTERM');
|
|
@@ -225,13 +255,15 @@ function localPortInUse(url) {
|
|
|
225
255
|
}
|
|
226
256
|
async function prepareProviderImage(image, code, signal) {
|
|
227
257
|
try {
|
|
228
|
-
await run('docker', ['image', 'inspect', image], signal);
|
|
258
|
+
const architecture = await run('docker', ['image', 'inspect', ...(darwin ? ['--format', '{{.Os}}/{{.Architecture}}'] : []), image], signal);
|
|
259
|
+
if (darwin && architecture !== `linux/${nativeArchitecture}`)
|
|
260
|
+
throw new Error('Pinned image is not installed for the native architecture.');
|
|
229
261
|
}
|
|
230
262
|
catch {
|
|
231
263
|
signal?.throwIfAborted();
|
|
232
264
|
console.error(`anyswarm setup: pulling ${image}`);
|
|
233
265
|
try {
|
|
234
|
-
await run('docker', ['pull', image], signal);
|
|
266
|
+
await run('docker', ['pull', ...(darwin ? ['--platform', `linux/${nativeArchitecture}`] : []), image], signal);
|
|
235
267
|
}
|
|
236
268
|
catch {
|
|
237
269
|
signal?.throwIfAborted();
|
|
@@ -244,7 +276,9 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
|
|
|
244
276
|
if (!url)
|
|
245
277
|
throw Object.assign(new Error('Local loopback OpenSandbox /v1 URL required'), { code: 'PROVIDER_CONFIGURATION_INVALID' });
|
|
246
278
|
signal?.throwIfAborted();
|
|
247
|
-
const
|
|
279
|
+
const docker = await resolveLocalDocker();
|
|
280
|
+
const socket = darwin ? '/var/run/docker.sock' : docker.socket;
|
|
281
|
+
const activeConfig = () => ({ ...config, egressMode: 'dns+nft', ...(darwin ? { useServerProxy: true } : {}) });
|
|
248
282
|
const existing = await inspectProvider(config, signal);
|
|
249
283
|
if (existing && !await ownedProvider(config, existing)) {
|
|
250
284
|
throw Object.assign(new Error('A different container owns the local service name'), { code: 'PROVIDER_NAME_IN_USE' });
|
|
@@ -292,7 +326,8 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
|
|
|
292
326
|
const token = randomUUID();
|
|
293
327
|
const stateDir = join(homedir(), '.cache/anyswarm/opensandbox', token);
|
|
294
328
|
const name = `anyswarm-opensandbox-${url.port || 80}`;
|
|
295
|
-
const
|
|
329
|
+
const port = Number(url.port || 80);
|
|
330
|
+
const recipe = (await readFile(join(root, 'deploy/opensandbox/config.toml'), 'utf8')).replace('port = 8080', `port = ${port}\napi_key = ${JSON.stringify(config.apiKey)}`).replace('host = "127.0.0.1"', darwin ? 'host = "0.0.0.0"' : 'host = "127.0.0.1"');
|
|
296
331
|
try {
|
|
297
332
|
await mkdir(join(stateDir, 'data'), { recursive: true, mode: 0o700 });
|
|
298
333
|
await writeFile(join(stateDir, 'config.toml'), recipe, { mode: 0o600, flag: 'wx' });
|
|
@@ -354,7 +389,8 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
|
|
|
354
389
|
await prepareProviderImage(localEgressImage, 'PROVIDER_EGRESS_PULL_FAILED', signal);
|
|
355
390
|
await prepareProviderImage(localProviderImage, 'PROVIDER_SERVER_PULL_FAILED', signal);
|
|
356
391
|
try {
|
|
357
|
-
|
|
392
|
+
const network = darwin ? ['--platform', `linux/${nativeArchitecture}`, '--network', 'bridge', '--publish', `127.0.0.1:${port}:${port}`] : ['--network', 'host'];
|
|
393
|
+
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);
|
|
358
394
|
created = true;
|
|
359
395
|
}
|
|
360
396
|
catch {
|
|
@@ -370,7 +406,7 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
|
|
|
370
406
|
const provider = await waitForProvider({ ...config, providerId: id || undefined }, signal);
|
|
371
407
|
if (created) {
|
|
372
408
|
providerReady = true;
|
|
373
|
-
return { ...handle, config:
|
|
409
|
+
return { ...handle, config: activeConfig(), created: true, id, images: await imageIds(provider) };
|
|
374
410
|
}
|
|
375
411
|
await rm(stateDir, { recursive: true, force: true });
|
|
376
412
|
return reuse(provider);
|
|
@@ -383,7 +419,7 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
|
|
|
383
419
|
const path = provider.Config.Labels?.['org.anyswarm.setup.state'];
|
|
384
420
|
if (provider.Config.Labels?.['org.anyswarm.setup.profile'] === profileVersion && path?.startsWith(join(homedir(), '.cache/anyswarm/opensandbox/')))
|
|
385
421
|
await writeFile(join(path, 'adopted'), '', { mode: 0o600 });
|
|
386
|
-
return { config:
|
|
422
|
+
return { config: activeConfig(), id: provider.Id, images: await imageIds(provider), created: false, retain: async () => {
|
|
387
423
|
const current = await inspectProvider(config);
|
|
388
424
|
if (current?.Id !== provider.Id)
|
|
389
425
|
throw new Error('Provider identity changed');
|
|
@@ -67,7 +67,8 @@ export async function runLocalSmoke(options) {
|
|
|
67
67
|
},
|
|
68
68
|
models: { default: model }, filePolicy: options.filePolicy,
|
|
69
69
|
profiles: { probe: { addedSystemPrompt: SETUP_PROFILE_PROMPT, model: 'default', image: options.image,
|
|
70
|
-
writable: true, services: { 'setup-probe': ['verify'] }
|
|
70
|
+
writable: true, services: { 'setup-probe': ['verify'] },
|
|
71
|
+
...(driver.kind === 'codex' ? { serviceToolMode: 'cli' } : {}) } },
|
|
71
72
|
services, maxAgents: 1, outputDir: temporary,
|
|
72
73
|
});
|
|
73
74
|
receipt.runtimeId = runtime.id;
|
|
@@ -79,7 +80,7 @@ export async function runLocalSmoke(options) {
|
|
|
79
80
|
signal.throwIfAborted();
|
|
80
81
|
if (agent.status !== 'idle')
|
|
81
82
|
throw new Error('worker');
|
|
82
|
-
passed(stage, `Controller reached the real Worker and verified ${driver.kind}
|
|
83
|
+
passed(stage, `Controller reached the real Worker and verified ${driver.kind}${driver.version ? ' ' + driver.version : ''}`);
|
|
83
84
|
if (upstream) {
|
|
84
85
|
stage = 'agent-bridge-gateway';
|
|
85
86
|
async function turn(message, requestId, expected) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExecutorSelection } from '../src/core/executor-adapter.js';
|
|
2
2
|
import type { DiagnosticCheck } from './local-environment.js';
|
|
3
3
|
import { type LocalWorker } from '../src/core/sandbox/local-worker.js';
|
|
4
4
|
import type { LocalExecutorSelection } from '../src/core/sandbox/local-executor.js';
|
|
@@ -3,11 +3,13 @@ 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 { executorVersion } from '../src/core/executor-adapter.js';
|
|
6
7
|
import { prepareLocalWorker } from '../src/core/sandbox/local-worker.js';
|
|
7
8
|
const exec = promisify(execFile);
|
|
8
9
|
const protocol = WORKER_PROTOCOL;
|
|
9
10
|
const imageIdPattern = /^sha256:[a-f0-9]{64}$/;
|
|
10
11
|
const imageReferencePattern = /^[a-z0-9][a-z0-9._/@:+-]{0,254}$/i;
|
|
12
|
+
const darwinWorkerPlatform = process.platform === 'darwin' ? `linux/${process.arch === 'x64' ? 'amd64' : process.arch}` : undefined;
|
|
11
13
|
const remedy = 'Run anyswarm setup to prepare the selected Worker, or set ANYSWARM_WORKER_IMAGE to a compatible image.';
|
|
12
14
|
async function inspectWorker(reference, driver, signal) {
|
|
13
15
|
if (!imageReferencePattern.test(reference))
|
|
@@ -30,6 +32,12 @@ async function inspectWorker(reference, driver, signal) {
|
|
|
30
32
|
remedy }], state: absent ? 'missing' : 'unavailable',
|
|
31
33
|
};
|
|
32
34
|
}
|
|
35
|
+
if (darwinWorkerPlatform && `${image.Os}/${image.Architecture}` !== darwinWorkerPlatform)
|
|
36
|
+
return {
|
|
37
|
+
checks: [{ id: 'worker-platform', ok: false, detail: `The local Worker must be ${darwinWorkerPlatform} on this Mac.`,
|
|
38
|
+
remedy: 'Select a native Linux Worker, or omit the image and build a Worker from the selected executable.' }],
|
|
39
|
+
state: 'unavailable',
|
|
40
|
+
};
|
|
33
41
|
const labels = image.Config?.Labels ?? {};
|
|
34
42
|
const protocolMatches = labels['org.anyswarm.opensandbox.worker-protocol'] === protocol &&
|
|
35
43
|
labels['org.anyswarm.opensandbox.file-protocol'] === fileProtocol;
|
|
@@ -38,7 +46,8 @@ async function inspectWorker(reference, driver, signal) {
|
|
|
38
46
|
const actualVersion = labels[`org.anyswarm.opensandbox.${executor}-version`];
|
|
39
47
|
const versionMatches = driver.adapter
|
|
40
48
|
? actualVersion === version && labels[`org.anyswarm.opensandbox.${executor}-protocol`] === driver.adapter.protocol
|
|
41
|
-
: actualVersion
|
|
49
|
+
: executorVersion(actualVersion) && (version === undefined || actualVersion === version) &&
|
|
50
|
+
(installed === undefined || installed === 'both' || installed === executor);
|
|
42
51
|
return {
|
|
43
52
|
checks: [
|
|
44
53
|
{ id: 'worker-image', ok: true, detail: `Docker resolved ${image.Id}.` },
|
|
@@ -46,12 +55,12 @@ async function inspectWorker(reference, driver, signal) {
|
|
|
46
55
|
detail: protocolMatches ? `The image declares ${protocol} and ${fileProtocol}.` : `The image does not declare the required Worker protocol ${protocol} and ${fileProtocol}.`,
|
|
47
56
|
...(protocolMatches ? {} : { remedy }) },
|
|
48
57
|
{ id: `worker-${executor}`, ok: versionMatches,
|
|
49
|
-
detail: versionMatches ? `The image declares ${executor} ${
|
|
50
|
-
`Image declares ${executor} ${actualVersion ?? 'unavailable'};
|
|
58
|
+
detail: versionMatches ? `The image declares ${executor} ${actualVersion}.` :
|
|
59
|
+
`Image declares ${executor} ${actualVersion ?? 'unavailable'}; expected ${version ?? 'an exact version'}.`,
|
|
51
60
|
...(versionMatches ? {} : { remedy }) },
|
|
52
61
|
],
|
|
53
|
-
...(protocolMatches && versionMatches ? { image: { reference, id: image.Id,
|
|
54
|
-
digests: (image.RepoDigests ?? []).filter(value => imageReferencePattern.test(value)), protocol, executor, version } } : {}),
|
|
62
|
+
...(protocolMatches && versionMatches && actualVersion !== undefined ? { image: { reference, id: image.Id,
|
|
63
|
+
digests: (image.RepoDigests ?? []).filter(value => imageReferencePattern.test(value)), protocol, executor, version: actualVersion } } : {}),
|
|
55
64
|
state: 'inspected',
|
|
56
65
|
};
|
|
57
66
|
}
|
|
@@ -100,7 +109,7 @@ export async function prepareWorkerImage({ requestedImage, executor = 'pi', loca
|
|
|
100
109
|
}
|
|
101
110
|
progress?.(`Pulling explicitly selected Worker ${reference}`);
|
|
102
111
|
try {
|
|
103
|
-
await exec('docker', ['pull', '--', reference], { signal, timeout: 15 * 60_000, maxBuffer: 12 * 1024 * 1024 });
|
|
112
|
+
await exec('docker', ['pull', ...(darwinWorkerPlatform ? ['--platform', darwinWorkerPlatform] : []), '--', reference], { signal, timeout: 15 * 60_000, maxBuffer: 12 * 1024 * 1024 });
|
|
104
113
|
}
|
|
105
114
|
catch (error) {
|
|
106
115
|
signal.throwIfAborted();
|
|
@@ -38,8 +38,8 @@ export declare function runLocalCommand(command: LocalCommand, signal: AbortSign
|
|
|
38
38
|
configuration?: {
|
|
39
39
|
executor: {
|
|
40
40
|
id: string;
|
|
41
|
-
version
|
|
42
|
-
compatibleVersions
|
|
41
|
+
version?: string;
|
|
42
|
+
compatibleVersions?: readonly string[];
|
|
43
43
|
};
|
|
44
44
|
image: string;
|
|
45
45
|
filePolicy: ResolvedFilePolicy;
|