@anyswarm/core 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +21 -13
- package/deploy/worker/Dockerfile +12 -4
- package/dist/deploy/worker/Dockerfile +12 -4
- package/dist/examples/README.md +35 -12
- package/dist/examples/authoring/README.md +24 -0
- package/dist/examples/authoring/business.d.ts +2 -0
- package/dist/examples/authoring/business.js +4 -0
- package/dist/examples/authoring/config.d.ts +5 -0
- package/dist/examples/authoring/config.js +2 -0
- package/dist/examples/authoring/eject.json +5 -0
- package/dist/examples/authoring/harness.d.ts +4 -0
- package/dist/examples/authoring/harness.js +19 -0
- package/dist/examples/autoresearch/README.md +40 -0
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/autoresearch/config.d.ts +51 -0
- package/dist/examples/autoresearch/config.js +57 -0
- package/dist/examples/autoresearch/demo.d.ts +11 -0
- package/dist/examples/autoresearch/demo.js +52 -0
- package/dist/examples/autoresearch/eject.json +17 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
- package/dist/examples/autoresearch/frontiercs2.js +211 -0
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +15 -0
- package/dist/examples/autoresearch/prepare.d.ts +95 -0
- package/dist/examples/autoresearch/prepare.js +257 -0
- package/dist/examples/autoresearch/process.d.ts +13 -0
- package/dist/examples/autoresearch/process.js +48 -0
- package/dist/examples/autoresearch/project.d.ts +21 -0
- package/dist/examples/autoresearch/project.js +392 -0
- package/dist/examples/autoresearch/research-service.d.ts +106 -0
- package/dist/examples/autoresearch/research-service.js +255 -0
- package/dist/examples/code/README.md +33 -0
- package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/code/candidate.d.ts +19 -0
- package/dist/examples/code/candidate.js +80 -0
- package/dist/examples/code/config.d.ts +32 -0
- package/dist/examples/code/config.js +18 -0
- package/dist/examples/code/eject.json +5 -0
- package/dist/examples/code/project.d.ts +3 -0
- package/dist/examples/code/project.js +605 -0
- package/dist/examples/code/prompts.d.ts +5 -0
- package/dist/examples/code/prompts.js +12 -0
- package/dist/examples/code/verification.d.ts +19 -0
- package/dist/examples/code/verification.js +268 -0
- package/dist/examples/code/worktree.d.ts +17 -0
- package/dist/examples/code/worktree.js +233 -0
- package/dist/examples/harness-session/README.md +3 -6
- package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
- package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
- package/dist/examples/lead-worker/harness/index.d.ts +60 -0
- package/dist/examples/lead-worker/harness/index.js +77 -6
- package/dist/examples/lead-worker/project.js +2 -2
- package/dist/examples/lead-worker/services/board.d.ts +5 -0
- package/dist/examples/lead-worker/services/board.js +19 -1
- package/dist/examples/messages/README.md +5 -5
- package/dist/examples/messages/handoff.d.ts +2 -0
- package/dist/examples/messages/handoff.js +5 -1
- package/dist/examples/messages/project.js +52 -2
- package/dist/examples/notes/README.md +13 -18
- package/dist/examples/notes/project.js +67 -6
- package/dist/examples/peermesh/harness/router.js +3 -1
- package/dist/examples/peermesh/harness/team.d.ts +8 -0
- package/dist/examples/peermesh/harness/team.js +13 -0
- package/dist/examples/peermesh/project.js +22 -4
- package/dist/examples/services/agent-control/README.md +3 -3
- package/dist/examples/services/mathlib-search/Dockerfile +4 -2
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +2 -2
- package/dist/examples/services/persistent-board/README.md +16 -3
- package/dist/examples/services/persistent-board/business.d.ts +7 -0
- package/dist/examples/services/persistent-board/business.js +7 -0
- package/dist/examples/services/persistent-board/index.js +10 -0
- package/dist/examples/services/persistent-board/live.d.ts +3 -0
- package/dist/examples/services/persistent-board/live.js +58 -0
- package/dist/examples/subagents/README.md +5 -5
- package/dist/examples/subagents/business.js +3 -1
- package/dist/examples/subagents/config.js +3 -3
- package/dist/examples/subagents/harness/controller.d.ts +15 -0
- package/dist/examples/subagents/harness/controller.js +181 -32
- package/dist/examples/subagents/project.d.ts +2 -0
- package/dist/examples/subagents/project.js +43 -34
- package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
- package/dist/examples/subagents/prompts/prompts.js +3 -0
- package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
- package/dist/examples/subagents/services/collaboration-service.js +14 -2
- package/dist/examples/substrate/README.md +2 -2
- package/dist/examples/substrate/harness/index.d.ts +1 -1
- package/dist/examples/substrate/harness/index.js +77 -12
- package/dist/examples/substrate/project.js +4 -1
- package/dist/examples/super/README.md +52 -0
- package/dist/examples/super/actions.d.ts +95 -0
- package/dist/examples/super/actions.js +230 -0
- package/dist/examples/super/artifact.d.ts +4 -0
- package/dist/examples/super/artifact.js +51 -0
- package/dist/examples/super/config.d.ts +80 -0
- package/dist/examples/super/config.js +83 -0
- package/dist/examples/super/coordinator.d.ts +33 -0
- package/dist/examples/super/coordinator.js +151 -0
- package/dist/examples/super/daemon.d.ts +11 -0
- package/dist/examples/super/daemon.js +109 -0
- package/dist/examples/super/decisions.d.ts +8 -0
- package/dist/examples/super/decisions.js +52 -0
- package/dist/examples/super/eject.json +5 -0
- package/dist/examples/super/execution.d.ts +11 -0
- package/dist/examples/super/execution.js +136 -0
- package/dist/examples/super/github.d.ts +62 -0
- package/dist/examples/super/github.js +269 -0
- package/dist/examples/super/inbox.d.ts +162 -0
- package/dist/examples/super/inbox.js +284 -0
- package/dist/examples/super/location.d.ts +5 -0
- package/dist/examples/super/location.js +64 -0
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/outbox.d.ts +5 -0
- package/dist/examples/super/outbox.js +103 -0
- package/dist/examples/super/project.d.ts +4 -0
- package/dist/examples/super/project.js +251 -0
- package/dist/examples/super/prompts.d.ts +3 -0
- package/dist/examples/super/prompts.js +25 -0
- package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/dist/examples/taskpool/harness/controller.d.ts +35 -6
- package/dist/examples/taskpool/harness/controller.js +73 -7
- package/dist/examples/taskpool/project.js +18 -2
- package/dist/scripts/anyswarm-arguments.d.ts +18 -6
- package/dist/scripts/anyswarm-arguments.js +88 -52
- package/dist/scripts/anyswarm-author.d.ts +5 -0
- package/dist/scripts/anyswarm-author.js +24 -0
- package/dist/scripts/anyswarm-eject.d.ts +11 -0
- package/dist/scripts/anyswarm-eject.js +164 -0
- package/dist/scripts/anyswarm-harnesses.d.ts +1 -0
- package/dist/scripts/anyswarm-harnesses.js +10 -0
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -285
- package/dist/scripts/anyswarm-launch.d.ts +7 -0
- package/dist/scripts/anyswarm-launch.js +37 -0
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +102 -0
- package/dist/scripts/anyswarm-project.d.ts +3 -1
- package/dist/scripts/anyswarm-project.js +49 -35
- package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
- package/dist/scripts/anyswarm-source-runner.js +200 -0
- package/dist/scripts/anyswarm.js +28 -3
- package/dist/scripts/build-provenance.json +1 -0
- package/dist/scripts/build.js +7 -1
- package/dist/scripts/generate-architecture-api.js +2 -0
- package/dist/scripts/generate-architecture-prompts.js +24 -2
- package/dist/scripts/local-environment.d.ts +13 -2
- package/dist/scripts/local-environment.js +111 -28
- package/dist/scripts/local-setup-smoke.js +3 -2
- package/dist/scripts/local-setup-worker.d.ts +1 -1
- package/dist/scripts/local-setup-worker.js +15 -6
- package/dist/scripts/local-setup.d.ts +5 -2
- package/dist/scripts/local-setup.js +167 -79
- package/dist/scripts/opensandbox-agent-worker.js +2 -2
- package/dist/scripts/pack-release.d.ts +1 -0
- package/dist/scripts/pack-release.js +66 -0
- package/dist/scripts/pi-session-bridge.js +11 -3
- package/dist/scripts/run-harness.js +3 -1
- package/dist/scripts/setup-bootstrap.js +43 -6
- package/dist/src/core/allocation-ledger.js +4 -3
- package/dist/src/core/host-identity.d.ts +2 -0
- package/dist/src/core/host-identity.js +11 -0
- package/dist/src/core/index.d.ts +4 -2
- package/dist/src/core/index.js +12 -4
- package/dist/src/core/mcp-service.js +2 -2
- package/dist/src/core/runtime-management.d.ts +6 -0
- package/dist/src/core/runtime-management.js +24 -0
- package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
- package/dist/src/core/sandbox/executor-driver.js +12 -14
- package/dist/src/core/sandbox/local-executor.d.ts +13 -1
- package/dist/src/core/sandbox/local-executor.js +69 -19
- package/dist/src/core/sandbox/local-worker.js +32 -21
- package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
- package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
- package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
- package/dist/src/core/sandbox/sandbox-connection.js +14 -6
- package/dist/src/core/service-live-state.d.ts +14 -0
- package/dist/src/core/service-live-state.js +161 -0
- package/dist/src/core/service-observation-types.d.ts +21 -1
- package/dist/src/core/service-process.d.ts +1 -1
- package/dist/src/core/service-process.js +45 -4
- package/dist/src/core/service-types.d.ts +5 -1
- package/dist/src/core/services.d.ts +1 -1
- package/dist/src/core/services.js +8 -3
- package/dist/src/core/types.d.ts +3 -0
- package/dist/src/core/worker-image.js +3 -3
- package/dist/src/harness/harness-session-types.d.ts +10 -0
- package/dist/src/harness/harness-session.js +42 -5
- package/dist/src/harness/project-harness.d.ts +14 -1
- package/dist/src/harness/project-harness.js +38 -12
- package/dist/src/harness/project-input.js +81 -15
- package/dist/src/harness/project-rpc-client.d.ts +1 -0
- package/dist/src/harness/project-rpc-client.js +5 -0
- package/dist/src/harness/project-rpc.d.ts +8 -2
- package/dist/src/harness/project-rpc.js +31 -7
- package/dist/src/harness/project-runtime.js +6 -2
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +41 -0
- package/dist/src/trace-viewer/public/app.js +6 -5
- package/dist/src/trace-viewer/reader.mjs +42 -2
- package/docs/INDEX.md +5 -2
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-agent-core.md +1 -1
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/06-observability-experiments.md +1 -1
- package/docs/architecture/07-run-configuration.md +38 -18
- package/docs/architecture/08-prompts.md +22 -0
- package/docs/architecture/10-service-api-reference.md +53 -18
- package/docs/architecture/11-storage-reference.md +18 -1
- package/docs/architecture/12-code-coverage.md +152 -89
- package/docs/architecture/15-core-runtime.md +8 -0
- package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/19-substrate-harness.md +28 -1
- package/docs/architecture/20-lead-worker-harness.md +34 -1
- package/docs/architecture/22-website.md +5 -6
- package/docs/architecture/23-project-harness.md +152 -8
- package/docs/architecture/24-runtime-recovery.md +10 -3
- package/docs/architecture/26-code.md +54 -0
- package/docs/architecture/27-personal.md +58 -0
- package/docs/architecture/28-autoresearch.md +43 -0
- package/docs/architecture/INDEX.md +3 -0
- package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
- package/docs/architecture/prompts/08-subagents-harness.md +21 -0
- package/docs/architecture/prompts/21-personal.md +44 -0
- package/docs/architecture/prompts/22-autoresearch.md +63 -0
- package/docs/architecture/prompts/26-code.md +55 -0
- package/docs/architecture/prompts/source-manifest.json +152 -33
- package/docs/architecture/source-map.json +473 -25
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +13 -2
- package/docs/designs/core-harness/README.md +7 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +3 -5
- package/docs/en/changelog.md +20 -4
- package/docs/en/first-harness.md +9 -12
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +14 -121
- package/docs/en/overview.md +1 -1
- package/docs/en/quickstart.md +42 -39
- package/docs/en/reference/api.md +14 -4
- package/docs/en/reference/cli.md +53 -47
- package/docs/en/runtime.md +2 -2
- package/docs/en/sandbox.md +3 -3
- package/docs/en/services.md +4 -0
- package/docs/operations/trace-viewer.md +1 -1
- package/docs/workflows/development.md +28 -21
- package/docs/workflows/release-and-docs-versioning.md +77 -0
- package/docs/workflows/release-cli-acceptance.md +85 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +3 -5
- package/docs/zh/changelog.md +20 -4
- package/docs/zh/first-harness.md +9 -12
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +15 -122
- package/docs/zh/overview.md +1 -1
- package/docs/zh/quickstart.md +42 -39
- package/docs/zh/reference/api.md +14 -4
- package/docs/zh/reference/cli.md +24 -40
- package/docs/zh/runtime.md +2 -2
- package/docs/zh/sandbox.md +3 -3
- package/docs/zh/services.md +4 -0
- package/examples/README.md +35 -12
- package/examples/authoring/README.md +24 -0
- package/examples/authoring/business.ts +4 -0
- package/examples/authoring/config.ts +2 -0
- package/examples/authoring/eject.json +5 -0
- package/examples/authoring/harness.ts +21 -0
- package/examples/autoresearch/README.md +40 -0
- package/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/examples/autoresearch/config.ts +90 -0
- package/examples/autoresearch/demo.ts +55 -0
- package/examples/autoresearch/eject.json +17 -0
- package/examples/autoresearch/frontiercs2-config.ts +4 -0
- package/examples/autoresearch/frontiercs2.ts +237 -0
- package/examples/autoresearch/prepare-demo.ts +15 -0
- package/examples/autoresearch/prepare.ts +267 -0
- package/examples/autoresearch/process.ts +50 -0
- package/examples/autoresearch/project.ts +380 -0
- package/examples/autoresearch/research-service.ts +302 -0
- package/examples/code/README.md +33 -0
- package/examples/code/REQUIREMENTS.zh.md +11 -0
- package/examples/code/candidate.ts +89 -0
- package/examples/code/config.ts +19 -0
- package/examples/code/eject.json +5 -0
- package/examples/code/project.ts +581 -0
- package/examples/code/prompts.ts +16 -0
- package/examples/code/verification.ts +239 -0
- package/examples/code/worktree.ts +188 -0
- package/examples/harness-session/README.md +3 -6
- package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
- package/examples/lead-worker/harness/index.ts +61 -6
- package/examples/lead-worker/project.ts +2 -2
- package/examples/lead-worker/services/board.ts +14 -1
- package/examples/messages/README.md +5 -5
- package/examples/messages/handoff.ts +6 -2
- package/examples/messages/project.ts +47 -2
- package/examples/notes/README.md +13 -18
- package/examples/notes/project.ts +57 -9
- package/examples/peermesh/harness/router.ts +2 -2
- package/examples/peermesh/harness/team.ts +11 -0
- package/examples/peermesh/project.ts +19 -4
- package/examples/services/agent-control/README.md +3 -3
- package/examples/services/mathlib-search/Dockerfile +4 -2
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +2 -2
- package/examples/services/persistent-board/README.md +16 -3
- package/examples/services/persistent-board/business.ts +10 -0
- package/examples/services/persistent-board/index.ts +10 -0
- package/examples/services/persistent-board/live.ts +54 -0
- package/examples/subagents/README.md +5 -5
- package/examples/subagents/business.ts +3 -1
- package/examples/subagents/config.ts +4 -3
- package/examples/subagents/harness/controller.ts +161 -29
- package/examples/subagents/project.ts +47 -33
- package/examples/subagents/prompts/prompts.ts +4 -0
- package/examples/subagents/services/collaboration-service.ts +14 -2
- package/examples/substrate/README.md +2 -2
- package/examples/substrate/harness/index.ts +67 -11
- package/examples/substrate/project.ts +5 -1
- package/examples/super/README.md +52 -0
- package/examples/super/actions.ts +196 -0
- package/examples/super/artifact.ts +56 -0
- package/examples/super/config.ts +95 -0
- package/examples/super/coordinator.ts +158 -0
- package/examples/super/daemon.ts +84 -0
- package/examples/super/decisions.ts +46 -0
- package/examples/super/eject.json +5 -0
- package/examples/super/execution.ts +131 -0
- package/examples/super/github.ts +242 -0
- package/examples/super/inbox.ts +306 -0
- package/examples/super/location.ts +54 -0
- package/examples/super/operator.ts +28 -0
- package/examples/super/outbox.ts +97 -0
- package/examples/super/project.ts +225 -0
- package/examples/super/prompts.ts +27 -0
- package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/examples/taskpool/harness/controller.ts +59 -7
- package/examples/taskpool/project.ts +18 -2
- package/npm-shrinkwrap.development.json +700 -0
- package/npm-shrinkwrap.json +95 -1969
- package/package.development.json +88 -0
- package/package.json +11 -8
- package/scripts/anyswarm-arguments.ts +91 -54
- package/scripts/anyswarm-author.ts +25 -0
- package/scripts/anyswarm-eject.ts +145 -0
- package/scripts/anyswarm-harnesses.ts +10 -0
- package/scripts/anyswarm-installation.ts +18 -288
- package/scripts/anyswarm-launch.ts +36 -0
- package/scripts/anyswarm-progress.ts +95 -0
- package/scripts/anyswarm-project.ts +35 -34
- package/scripts/anyswarm-source-runner.ts +176 -0
- package/scripts/anyswarm.ts +24 -3
- package/scripts/build.ts +8 -1
- package/scripts/generate-architecture-api.ts +2 -0
- package/scripts/generate-architecture-prompts.ts +35 -2
- package/scripts/local-environment.ts +117 -28
- package/scripts/local-setup-smoke.ts +3 -2
- package/scripts/local-setup-worker.ts +17 -7
- package/scripts/local-setup.ts +166 -73
- package/scripts/opensandbox-agent-worker.ts +2 -2
- package/scripts/pack-release.ts +70 -0
- package/scripts/pi-session-bridge.ts +10 -2
- package/scripts/run-harness.ts +3 -1
- package/scripts/setup-bootstrap.ts +41 -6
- package/src/core/allocation-ledger.ts +5 -3
- package/src/core/host-identity.ts +11 -0
- package/src/core/index.ts +12 -6
- package/src/core/mcp-service.ts +2 -2
- package/src/core/runtime-management.ts +22 -0
- package/src/core/sandbox/executor-driver.ts +15 -18
- package/src/core/sandbox/local-executor.ts +65 -19
- package/src/core/sandbox/local-worker.ts +29 -21
- package/src/core/sandbox/opensandbox-backend.ts +36 -11
- package/src/core/sandbox/sandbox-connection.ts +14 -5
- package/src/core/service-live-state.ts +156 -0
- package/src/core/service-observation-types.ts +23 -1
- package/src/core/service-process.ts +36 -3
- package/src/core/service-types.ts +3 -1
- package/src/core/services.ts +8 -3
- package/src/core/types.ts +3 -0
- package/src/core/worker-image.ts +3 -3
- package/src/harness/harness-session-types.ts +13 -1
- package/src/harness/harness-session.ts +40 -7
- package/src/harness/project-harness.ts +38 -12
- package/src/harness/project-input.ts +73 -15
- package/src/harness/project-rpc-client.ts +5 -0
- package/src/harness/project-rpc.ts +29 -8
- package/src/harness/project-runtime.ts +4 -2
- package/src/harness/typescript-loader.ts +37 -0
- package/src/trace-viewer/public/app.js +6 -5
- package/src/trace-viewer/reader.mjs +42 -2
|
@@ -93,6 +93,35 @@ async function lockedSetup(startedAt: number, options: string[]) {
|
|
|
93
93
|
{ ...process.env, ANYSWARM_SETUP_BOOTSTRAP: JSON.stringify(bootstrap) }, true);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
async function macCheckoutSetup(startedAt: number, options: string[]) {
|
|
97
|
+
signal.throwIfAborted();
|
|
98
|
+
const lock = spawn('/usr/bin/lockf', ['-kn', '-t', '180', root, process.execPath, '-e',
|
|
99
|
+
'console.log("locked"); process.stdin.resume()'], { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
100
|
+
lock.stdin.on('error', () => {});
|
|
101
|
+
const cancel = () => lock.kill('SIGTERM');
|
|
102
|
+
signal.addEventListener('abort', cancel, { once: true });
|
|
103
|
+
try {
|
|
104
|
+
const acquired = await new Promise<boolean>((ready, reject) => {
|
|
105
|
+
lock.once('error', reject);
|
|
106
|
+
lock.once('exit', code => {
|
|
107
|
+
if (code === 75) ready(false);
|
|
108
|
+
else reject(new Error('Could not lock the checkout.'));
|
|
109
|
+
});
|
|
110
|
+
lock.stdout.once('data', () => ready(true));
|
|
111
|
+
});
|
|
112
|
+
signal.removeEventListener('abort', cancel);
|
|
113
|
+
signal.throwIfAborted();
|
|
114
|
+
if (!acquired) {
|
|
115
|
+
failure('checkout-lock', 'Another setup still holds the checkout lock.', 'Wait for the other invocation and rerun setup.');
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
return await lockedSetup(startedAt, options);
|
|
119
|
+
} finally {
|
|
120
|
+
signal.removeEventListener('abort', cancel);
|
|
121
|
+
lock.stdin.end();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
const args = process.argv.slice(2);
|
|
97
126
|
const lockInvocation = args[0] === '--under-checkout-lock';
|
|
98
127
|
try {
|
|
@@ -104,17 +133,23 @@ try {
|
|
|
104
133
|
if ('help' in command) {
|
|
105
134
|
console.log(command.help);
|
|
106
135
|
} else {
|
|
107
|
-
if (process.platform !== 'linux') {
|
|
108
|
-
failure('host.
|
|
136
|
+
if (process.platform !== 'linux' && process.platform !== 'darwin') {
|
|
137
|
+
failure('host.platform', 'Setup requires Linux or macOS.', 'Run this command on Linux or macOS.');
|
|
109
138
|
process.exitCode = 1;
|
|
110
139
|
} else if (command.command === 'setup') {
|
|
111
140
|
const options = [
|
|
112
141
|
...(command.mode ? ['--mode', command.mode] : []),
|
|
142
|
+
...(command.endpoint ? ['--endpoint', command.endpoint] : []),
|
|
143
|
+
...(command.publicUrl ? ['--public-url', command.publicUrl] : []),
|
|
144
|
+
...(command.backend ? ['--backend', command.backend] : []),
|
|
145
|
+
...(command.backendVersion ? ['--backend-version', command.backendVersion] : []),
|
|
146
|
+
...(command.backendPath ? ['--backend-path', resolve(command.backendPath)] : []),
|
|
113
147
|
...(command.configPath ? ['--config', resolve(command.configPath)] : []),
|
|
114
148
|
];
|
|
115
|
-
process.exitCode =
|
|
116
|
-
|
|
117
|
-
|
|
149
|
+
process.exitCode = process.platform === 'darwin' ? await macCheckoutSetup(startedAt, options)
|
|
150
|
+
: await child('flock', ['--no-fork', '--exclusive', '--timeout', '180', '--conflict-exit-code', '73',
|
|
151
|
+
root, process.execPath, '--disable-warning=ExperimentalWarning', script, '--under-checkout-lock',
|
|
152
|
+
String(startedAt), ...options], process.env, true);
|
|
118
153
|
if (process.exitCode === 73) {
|
|
119
154
|
failure('checkout-lock', 'Another setup still holds the checkout lock.', 'Wait for the other invocation and rerun setup.');
|
|
120
155
|
process.exitCode = 1;
|
|
@@ -130,7 +165,7 @@ try {
|
|
|
130
165
|
console.error(setupUsage);
|
|
131
166
|
process.exitCode = 2;
|
|
132
167
|
} else {
|
|
133
|
-
failure('bootstrap', 'The checkout could not be prepared.', 'Check Node.js, npm,
|
|
168
|
+
failure('bootstrap', 'The checkout could not be prepared.', 'Check Node.js, npm, platform lock tools and permissions on this checkout.');
|
|
134
169
|
process.exitCode = 1;
|
|
135
170
|
}
|
|
136
171
|
}
|
|
@@ -3,6 +3,7 @@ import { constants, closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFi
|
|
|
3
3
|
import { hostname } from 'node:os';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { DatabaseSync } from 'node:sqlite';
|
|
6
|
+
import { darwinBootSession } from './host-identity.js';
|
|
6
7
|
|
|
7
8
|
export type AllocationState = 'intent' | 'dispatched' | 'created' | 'starting' | 'ready' | 'unknown' | 'stopping' | 'exporting' | 'retained' | 'deleting' | 'deleted' | 'rejected';
|
|
8
9
|
export type AllocationRunState = 'open' | 'closing' | 'closed';
|
|
@@ -126,9 +127,10 @@ function currentHostIdentity() {
|
|
|
126
127
|
// recreated Pod can differ in hostname while retaining the same node boot.
|
|
127
128
|
const node = process.env.ANYSWARM_RUNTIME_NODE_NAME;
|
|
128
129
|
const identities = [node ? 'kubernetes' : 'host', node || hostname()];
|
|
129
|
-
try {
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
try {
|
|
131
|
+
identities.push(process.platform === 'darwin' ? darwinBootSession() : readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim());
|
|
132
|
+
} catch { throw fault('NOT_ALLOWED', 'Durable Runtime requires a verified kernel boot identity'); }
|
|
133
|
+
if (!node && process.platform !== 'darwin') {
|
|
132
134
|
try { identities.push(readFileSync('/etc/machine-id', 'utf8').trim()); } catch { /* hostname and boot ID still identify the owner */ }
|
|
133
135
|
}
|
|
134
136
|
return createHash('sha256').update(identities.join('\n')).digest('hex');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
let bootSession: string | undefined;
|
|
4
|
+
|
|
5
|
+
/** Cache only a verified UUID: a running Controller cannot survive a reboot. */
|
|
6
|
+
export function darwinBootSession() {
|
|
7
|
+
if (bootSession) return bootSession;
|
|
8
|
+
const uuid = execFileSync('/usr/sbin/sysctl', ['-n', 'kern.bootsessionuuid'], { encoding: 'utf8', timeout: 2_000 }).trim();
|
|
9
|
+
if (!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(uuid)) throw new Error('Invalid Darwin boot session UUID');
|
|
10
|
+
return bootSession = `darwin:${uuid.toLowerCase()}`;
|
|
11
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { createRedactor, createRunRecords, runtimeConfiguration } from './run-re
|
|
|
26
26
|
import { createRuntimeManagement } from './runtime-management.js';
|
|
27
27
|
import { claimOpenSandboxBackend, openOpenSandboxBackend } from './sandbox/opensandbox-backend.js';
|
|
28
28
|
import { isOfficialWorkerImage, localWorkerSelector } from './worker-image.js';
|
|
29
|
-
import { selectExecutorDriver } from './sandbox/executor-driver.js';
|
|
29
|
+
import { legacyImageExecutorVersion, selectExecutorDriver } from './sandbox/executor-driver.js';
|
|
30
30
|
import { findExecutorEntry, executorFailure } from './sandbox/local-executor.js';
|
|
31
31
|
import { prepareLocalWorker, workerFailure, type LocalWorker } from './sandbox/local-worker.js';
|
|
32
32
|
import { loopbackLifecycle, resolveSandboxConnectionWithSources } from './sandbox/sandbox-connection.js';
|
|
@@ -45,10 +45,11 @@ export type {
|
|
|
45
45
|
HarnessAnswerReceipt, HarnessCapability, HarnessDescriptor, HarnessEvent, HarnessInputDescriptor,
|
|
46
46
|
HarnessInputReceipt, HarnessLifetime, HarnessOperation, HarnessPhase, HarnessQuestion, HarnessQuestionKind,
|
|
47
47
|
HarnessQuestionRequest, HarnessQuestionSource, HarnessRequest, HarnessDispatchRequest, HarnessResult, HarnessSession,
|
|
48
|
-
HarnessSessionOptions, HarnessStartReceipt, HarnessState, HarnessStopReceipt, HarnessSubscriptionOptions,
|
|
48
|
+
HarnessServices, HarnessSessionOptions, HarnessStartReceipt, HarnessState, HarnessStopReceipt, HarnessSubscriptionOptions,
|
|
49
49
|
} from '../harness/harness-session-types.js';
|
|
50
50
|
export { ProjectPreflightError } from '../harness/project-input.js';
|
|
51
51
|
export { HarnessRpcClient } from '../harness/project-rpc-client.js';
|
|
52
|
+
export { runProjectRpc } from '../harness/project-rpc.js';
|
|
52
53
|
export type { HarnessRpcClientOptions, HarnessRpcReady, HarnessRpcTransport } from '../harness/project-rpc-client.js';
|
|
53
54
|
export { observeProjectRuntime, projectConfiguration, projectResult } from '../harness/project-runtime.js';
|
|
54
55
|
export { runInput, type RunInputResult } from '../harness/run-input.js';
|
|
@@ -60,6 +61,7 @@ export { httpClient } from '../harness/http.js';
|
|
|
60
61
|
export { checkGitProject, seedTeamRepository, seededCheckoutInstruction } from '../harness/project-git.js';
|
|
61
62
|
export { initializeGitRepository, importGitTree, commitGitTree, isGitTreePath } from '../harness/git-tree.js';
|
|
62
63
|
export { decodeFileSeed as decodeFileTree, snapshotFileSeed as snapshotFileTree, completeDigest as completeFileTreeDigest } from './files/core-file-seed.js';
|
|
64
|
+
export { resolveFilePolicy } from './file-policy.js';
|
|
63
65
|
export { AnySwarmError } from '../errors.js';
|
|
64
66
|
export { requestHttp } from '../protocol/http-request.js';
|
|
65
67
|
export { stableStringify } from '../protocol/stable-json.js';
|
|
@@ -73,7 +75,7 @@ export { DEFAULT_WORKER_IMAGE, workerImageFor } from './worker-image.js';
|
|
|
73
75
|
export { ServiceRegistry, serviceFromManifest, inProcessService, httpService, createInProcessAdapter, createHttpJsonAdapter, createServiceReplyAdapter } from './services.js';
|
|
74
76
|
export { mcpService } from './mcp-service.js';
|
|
75
77
|
export type { McpServiceOptions, McpHttpServiceOptions, McpStdioServiceOptions } from './mcp-service.js';
|
|
76
|
-
export type { ServiceStateMetadata, ServiceStatePresentation } from './service-observation-types.js';
|
|
78
|
+
export type { ServiceLiveState, ServiceStateMetadata, ServiceStatePresentation, ServiceStateRead, ServiceStateSource } from './service-observation-types.js';
|
|
77
79
|
export { managedProcessLifecycle } from './service-process.js';
|
|
78
80
|
export type { ManagedProcessOptions } from './service-process.js';
|
|
79
81
|
export type { ServiceLifecycle, ServiceLifecycleContext, ServiceStorage, ServiceResources } from './service-lifecycle-types.js';
|
|
@@ -227,14 +229,14 @@ function planRuntimeWorker(
|
|
|
227
229
|
const configuredEntry = options.localWorker?.backendPath
|
|
228
230
|
? resolve(options.localWorker.backendPath) : localExecutor?.kind === kind ? localExecutor.entry : undefined;
|
|
229
231
|
const requiredVersions = new Set(selectors.flatMap(selector => selector.version ? [selector.version] : []));
|
|
230
|
-
if (
|
|
232
|
+
if (config.driver.version !== undefined) requiredVersions.add(config.driver.version);
|
|
231
233
|
if (requiredVersions.size > 1) throw executorFailure('All local Worker selectors must match the selected installation version.');
|
|
232
234
|
const [requiredVersion] = requiredVersions;
|
|
233
235
|
const progress = options.localWorker?.onProgress;
|
|
234
236
|
return { kind: kind as LocalWorker["executor"], prepare: async () => {
|
|
235
237
|
const entry = configuredEntry ?? await findExecutorEntry(kind);
|
|
236
238
|
if (!entry) throw executorFailure(`No local ${kind} executable was found. Install it with npm and run the CLI from this SDK package with setup --backend ${kind}.`);
|
|
237
|
-
return prepareLocalWorker({ kind, entry }, { progress, requiredVersion });
|
|
239
|
+
return prepareLocalWorker({ kind, entry }, { progress, requiredVersion: requiredVersion ?? (configuredEntry === localExecutor?.entry ? localExecutor?.version : undefined) });
|
|
238
240
|
} };
|
|
239
241
|
}
|
|
240
242
|
|
|
@@ -318,6 +320,9 @@ async function assembleRuntime(options: CreateRuntimeOptions, recovery?: { runti
|
|
|
318
320
|
localWorker = await plan.prepare();
|
|
319
321
|
config = Object.freeze({ ...config, driver: selectExecutorDriver({ kind: localWorker.executor, version: localWorker.version }) });
|
|
320
322
|
for (const [id, profile] of profiles) profiles.set(id, freezeProfileWorker(profile, config, localWorker));
|
|
323
|
+
} else if (config.driver.version === undefined) {
|
|
324
|
+
const version = legacyImageExecutorVersion(config.driver.kind);
|
|
325
|
+
if (version !== undefined) config = Object.freeze({ ...config, driver: selectExecutorDriver({ kind: config.driver.kind, version }) });
|
|
321
326
|
}
|
|
322
327
|
if (options.persistence) {
|
|
323
328
|
const { deploymentId, contract, retainForMs: duration = 900_000 } = options.persistence;
|
|
@@ -334,7 +339,7 @@ async function assembleRuntime(options: CreateRuntimeOptions, recovery?: { runti
|
|
|
334
339
|
}));
|
|
335
340
|
const fingerprintInput = { contract, connectionFingerprint, callback: config.callback, limits, retainForMs,
|
|
336
341
|
...(options.hooks?.beforeCompact ? { beforeCompactTimeoutMs: options.hooks.beforeCompact.timeoutMs ?? 10_000 } : {}),
|
|
337
|
-
models: modelConfig, modelGateway: config.modelGateway, executor: [config.driver.kind, config.driver.version],
|
|
342
|
+
models: modelConfig, modelGateway: config.modelGateway, executor: [config.driver.kind, config.driver.version ?? legacyImageExecutorVersion(config.driver.kind)],
|
|
338
343
|
profiles: Object.fromEntries(profiles), services: [...registrations.values()].map(registration => registration.manifest).sort((a, b) => a.id.localeCompare(b.id)),
|
|
339
344
|
files: config.filePolicy, requests: config.sandbox.resourceRequests, limitsSandbox: config.sandbox.resourceLimits };
|
|
340
345
|
const configFingerprint = fingerprint(fingerprintInput);
|
|
@@ -1318,6 +1323,7 @@ async function assembleRuntime(options: CreateRuntimeOptions, recovery?: { runti
|
|
|
1318
1323
|
const wasClosing = closing;
|
|
1319
1324
|
durable(owner => owner.beginClose());
|
|
1320
1325
|
closing = true;
|
|
1326
|
+
management.cancelServiceStateReads();
|
|
1321
1327
|
if (!closeWork) {
|
|
1322
1328
|
for (const agent of agents.values()) revoke(agent.info.id);
|
|
1323
1329
|
closeWork = Promise.resolve().then(async () => {
|
package/src/core/mcp-service.ts
CHANGED
|
@@ -80,11 +80,11 @@ function mcpEndpoint(options: McpServiceOptions) {
|
|
|
80
80
|
} }),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
if (process.platform
|
|
83
|
+
if (!['linux', 'darwin'].includes(process.platform) || !isAbsolute(options.command) ||
|
|
84
84
|
(options.args !== undefined && (!Array.isArray(options.args) || options.args.some(argument => typeof argument !== 'string'))) ||
|
|
85
85
|
(options.cwd !== undefined && !isAbsolute(options.cwd)) ||
|
|
86
86
|
(options.env !== undefined && Object.values(options.env).some(value => typeof value !== 'string'))) {
|
|
87
|
-
throw new AnySwarmError('INVALID_CONTRACT', 'Managed MCP stdio requires Linux, an absolute executable and typed argv/environment');
|
|
87
|
+
throw new AnySwarmError('INVALID_CONTRACT', 'Managed MCP stdio requires Linux or macOS, an absolute executable and typed argv/environment');
|
|
88
88
|
}
|
|
89
89
|
const parameters = { command: options.command, args: [...options.args ?? []], cwd: options.cwd,
|
|
90
90
|
env: Object.fromEntries(Object.entries(options.env ?? {}).sort(([a], [b]) => a.localeCompare(b))) };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import type { JsonValue } from './service-types.js';
|
|
3
3
|
import type { ServiceLifecycleContext } from './service-lifecycle-types.js';
|
|
4
|
+
import { createServiceStateReader } from './service-live-state.js';
|
|
4
5
|
import { createHash } from 'node:crypto';
|
|
5
6
|
import type {
|
|
6
7
|
AgentAccess, AgentAccessGrant, AgentAccessMutation, ErrorInfo, PendingCleanup, Profile, ProfileDefinition, ProfileRegistration, RuntimeManagementChange,
|
|
@@ -86,6 +87,7 @@ export function createRuntimeManagement({
|
|
|
86
87
|
|
|
87
88
|
const serviceRequests = new Map<string, { digest: string; adapter: ServiceRegistration['adapter']; result: RuntimeServiceDefinition }>();
|
|
88
89
|
const services = new Map<string, RegisteredService>();
|
|
90
|
+
const stateReader = createServiceStateReader(redact);
|
|
89
91
|
const unresolvedServices = new Map<string, RuntimeServiceDefinition>();
|
|
90
92
|
const unresolvedDynamic = new Map<string, boolean>();
|
|
91
93
|
const remoteWrites = new Map<string, { serviceId: string; operation: string; operationId: string; state: 'dispatched' | 'unknown' }>();
|
|
@@ -196,6 +198,7 @@ export function createRuntimeManagement({
|
|
|
196
198
|
changed({ operation: 'service.start', sequence, caller: 'host', requestId: 'directory-change', definition: service.definition });
|
|
197
199
|
} catch (error) {
|
|
198
200
|
registrations.delete(serviceId);
|
|
201
|
+
if (service.definition.instanceId) stateReader.cancel(service.definition.instanceId);
|
|
199
202
|
lifecycleChange(service, 'service.start', 'blocked', 'directory-change', {
|
|
200
203
|
code: 'INVALID_CONTRACT', message: String(redact((error as Error).message)), retryable: false,
|
|
201
204
|
});
|
|
@@ -218,6 +221,7 @@ export function createRuntimeManagement({
|
|
|
218
221
|
const lifecycle = service.registration.lifecycle!;
|
|
219
222
|
lifecycleRequests.set(key, {});
|
|
220
223
|
service.action = 'start';
|
|
224
|
+
if (service.definition.instanceId) stateReader.reset(service.definition.instanceId);
|
|
221
225
|
service.registration = { ...service.registration, instanceId: `${runtimeId}:${input.serviceId}:${randomUUID()}` };
|
|
222
226
|
service.definition = { ...service.definition, instanceId: service.registration.instanceId };
|
|
223
227
|
lifecycleChange(service, 'service.start', 'starting', input.requestId);
|
|
@@ -261,6 +265,7 @@ export function createRuntimeManagement({
|
|
|
261
265
|
if (service.recoveryBlocked) throw problem('RECOVERY_BLOCKED', 'Original Service identity must be reconciled before stop');
|
|
262
266
|
lifecycleRequests.set(key, { instanceId: service.definition.instanceId });
|
|
263
267
|
registrations.delete(input.serviceId);
|
|
268
|
+
if (service.definition.instanceId) stateReader.cancel(service.definition.instanceId);
|
|
264
269
|
service.unwatch?.();
|
|
265
270
|
service.unwatch = undefined;
|
|
266
271
|
service.action = 'stop';
|
|
@@ -368,6 +373,20 @@ export function createRuntimeManagement({
|
|
|
368
373
|
return [...new Set([...services.keys(), ...unresolvedServices.keys()])].map(id => serviceGet(id)!);
|
|
369
374
|
}
|
|
370
375
|
|
|
376
|
+
function listServiceState() {
|
|
377
|
+
return [...services].map(([name, service]) => ({ name, supported: !!service.registration.adapter.readState }));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function readServiceState(name: string) {
|
|
381
|
+
const service = services.get(name);
|
|
382
|
+
const instanceId = service?.definition.instanceId;
|
|
383
|
+
return stateReader.read(service && instanceId ? {
|
|
384
|
+
instanceId,
|
|
385
|
+
readState: service.registration.adapter.readState,
|
|
386
|
+
ready: () => !isClosing() && service.definition.state === 'ready' && service.definition.instanceId === instanceId && registrations.has(name),
|
|
387
|
+
} : undefined);
|
|
388
|
+
}
|
|
389
|
+
|
|
371
390
|
async function registerService(parameters: RuntimeServiceRegistration) {
|
|
372
391
|
const input = parameters && 'name' in parameters ? {
|
|
373
392
|
requestId: parameters.requestId, actorId: parameters.actorId,
|
|
@@ -436,6 +455,7 @@ export function createRuntimeManagement({
|
|
|
436
455
|
if (service.work) await waitForWork(service, timeoutMs);
|
|
437
456
|
if (service.work) return serviceGet(serviceId)!;
|
|
438
457
|
registrations.delete(serviceId);
|
|
458
|
+
if (service.definition.instanceId) stateReader.cancel(service.definition.instanceId);
|
|
439
459
|
service.unwatch?.();
|
|
440
460
|
service.unwatch = undefined;
|
|
441
461
|
service.retirement = { requestId, caller };
|
|
@@ -684,12 +704,14 @@ export function createRuntimeManagement({
|
|
|
684
704
|
return {
|
|
685
705
|
profiles: Object.freeze({ register: (input: ProfileRegistration) => registerProfile(input), get: profileGet, list: profileList }),
|
|
686
706
|
services: Object.freeze({ register: (input: RuntimeServiceRegistration) => registerService(input), get: serviceGet, list: serviceList,
|
|
707
|
+
listState: listServiceState, readState: readServiceState,
|
|
687
708
|
start: startService, stop: stopService, restart: restartService, health: serviceHealth,
|
|
688
709
|
retire: (input: ServiceRetirement) => retireService(input) }),
|
|
689
710
|
access: Object.freeze({ get: accessGet,
|
|
690
711
|
grant: (input: AgentAccessGrant) => mutateAccess('grant', input), revoke: (input: AgentAccessMutation) => mutateAccess('revoke', input) }),
|
|
691
712
|
mutateAccess, initAccess, bridgeAccess, checkpoint, restore,
|
|
692
713
|
recordRemoteWrite, prepareAll, retireAll, pendingServices, knowsService: (id: string) => services.has(id),
|
|
714
|
+
cancelServiceStateReads: () => stateReader.cancel(),
|
|
693
715
|
retiredExports: () => ownedRetirements().flatMap(({ definition, exported }) => exported ? [{ serviceId: definition.id, ...exported }] : []),
|
|
694
716
|
profileDigest: (id: string) => definitions.get(id)?.digest,
|
|
695
717
|
snapshot: () => ({ sequence, profiles: profileList(), services: serviceList(), access: [...access.keys()].map(id => accessGet(id)!) }),
|
|
@@ -9,9 +9,8 @@ type Model = ModelConfig;
|
|
|
9
9
|
export interface ExecutorDriver {
|
|
10
10
|
readonly kind: string;
|
|
11
11
|
readonly name: string;
|
|
12
|
-
readonly version
|
|
12
|
+
readonly version?: string;
|
|
13
13
|
readonly capabilities: ExecutorCapabilities;
|
|
14
|
-
readonly compatibleVersions: readonly string[];
|
|
15
14
|
readonly adapter?: ExecutorAdapter;
|
|
16
15
|
readonly defaultMaxOutputTokens?: null;
|
|
17
16
|
assertEnvironment?(environment: Readonly<Record<string, string>> | undefined): void;
|
|
@@ -20,7 +19,7 @@ export interface ExecutorDriver {
|
|
|
20
19
|
environment: Record<string, string>;
|
|
21
20
|
secretEnvironment: Record<string, string>;
|
|
22
21
|
};
|
|
23
|
-
start(options: { model: Model; baseUrl: string; forkSession: boolean }):
|
|
22
|
+
start(options: { model: Model; baseUrl: string; forkSession: boolean; version: string }):
|
|
24
23
|
| { command: 'pi'; args: string[] }
|
|
25
24
|
| { command: 'codex'; args: string[]; codex: { model: string; baseUrl: string; version: string } }
|
|
26
25
|
| { command: string; args: []; externalExecutor: ExecutorAdapter };
|
|
@@ -36,8 +35,6 @@ const sharedCapabilities = {
|
|
|
36
35
|
const pi: ExecutorDriver = {
|
|
37
36
|
kind: 'pi',
|
|
38
37
|
name: 'Pi',
|
|
39
|
-
version: '1.3.0',
|
|
40
|
-
compatibleVersions: Object.freeze(['1.3.0', '1.4.0']),
|
|
41
38
|
capabilities: Object.freeze({ ...sharedCapabilities, contextFork: true,
|
|
42
39
|
session: Object.freeze({ configure: true, compact: true, abortRetry: true, clearQueue: true,
|
|
43
40
|
state: true, stats: true, messages: true, context: true, beforeCompact: true }),
|
|
@@ -56,12 +53,9 @@ const pi: ExecutorDriver = {
|
|
|
56
53
|
},
|
|
57
54
|
};
|
|
58
55
|
|
|
59
|
-
const codexVersion = '0.172.0';
|
|
60
56
|
const codex: ExecutorDriver = {
|
|
61
57
|
kind: 'codex',
|
|
62
58
|
name: 'Codex',
|
|
63
|
-
version: codexVersion,
|
|
64
|
-
compatibleVersions: Object.freeze([codexVersion]),
|
|
65
59
|
defaultMaxOutputTokens: null,
|
|
66
60
|
capabilities: Object.freeze({ ...sharedCapabilities, contextFork: false, steeringModes: Object.freeze(['all'] as const) }),
|
|
67
61
|
assertEnvironment(environment) {
|
|
@@ -72,30 +66,33 @@ const codex: ExecutorDriver = {
|
|
|
72
66
|
credentials(_model, _baseUrl, token) {
|
|
73
67
|
return { environment: {}, secretEnvironment: { OPENAI_API_KEY: token } };
|
|
74
68
|
},
|
|
75
|
-
start({ model, baseUrl }) {
|
|
76
|
-
return { command: 'codex', args: [], codex: { model: model.model, baseUrl, version
|
|
69
|
+
start({ model, baseUrl, version }) {
|
|
70
|
+
return { command: 'codex', args: [], codex: { model: model.model, baseUrl, version } };
|
|
77
71
|
},
|
|
78
72
|
};
|
|
79
73
|
|
|
80
74
|
const drivers = { pi: Object.freeze(pi), codex: Object.freeze(codex) } satisfies Record<ExecutorKind, ExecutorDriver>;
|
|
81
75
|
|
|
76
|
+
/** Preserve the contract for explicitly prepared deployments without a version pin. */
|
|
77
|
+
export function legacyImageExecutorVersion(kind: string) {
|
|
78
|
+
return kind === 'pi' ? '1.3.0' : kind === 'codex' ? '0.172.0' : undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
82
81
|
function invalid(message: string): never {
|
|
83
82
|
throw Object.assign(new Error(message), { code: 'INVALID_CONTRACT' });
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export function createPiExecutor({ version
|
|
85
|
+
export function createPiExecutor({ version }: { version?: string } = {}): BuiltinExecutorSelection {
|
|
87
86
|
return builtinSelection('pi', version);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
export function createCodexExecutor({ version
|
|
89
|
+
export function createCodexExecutor({ version }: { version?: string } = {}): BuiltinExecutorSelection {
|
|
91
90
|
return builtinSelection('codex', version);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
function builtinSelection(kind: ExecutorKind, version
|
|
95
|
-
if (!
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
return Object.freeze({ kind, version });
|
|
93
|
+
function builtinSelection(kind: ExecutorKind, version?: string) {
|
|
94
|
+
if (version !== undefined && !executorVersion(version)) invalid(`${kind} requires an exact executor version`);
|
|
95
|
+
return Object.freeze({ kind, ...(version === undefined ? {} : { version }) });
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
export function createExecutorAdapter(input: ExecutorAdapter): ExecutorAdapter {
|
|
@@ -118,7 +115,7 @@ export function selectExecutorDriver(executor: unknown = 'pi'): Readonly<Executo
|
|
|
118
115
|
const input = executor as BuiltinExecutorSelection | ExecutorAdapter;
|
|
119
116
|
if (typeof input.kind === 'string' && Object.hasOwn(drivers, input.kind)) {
|
|
120
117
|
const driver = drivers[input.kind as ExecutorKind];
|
|
121
|
-
return Object.freeze({ ...driver, ...builtinSelection(input.kind as ExecutorKind, input.version
|
|
118
|
+
return Object.freeze({ ...driver, ...builtinSelection(input.kind as ExecutorKind, input.version) });
|
|
122
119
|
}
|
|
123
120
|
const adapter = createExecutorAdapter(input as ExecutorAdapter);
|
|
124
121
|
return Object.freeze<ExecutorDriver>({
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import { constants, createReadStream } from 'node:fs';
|
|
4
|
+
import { access, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rm, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { homedir, tmpdir } from 'node:os';
|
|
5
6
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
6
7
|
import { promisify } from 'node:util';
|
|
7
8
|
import type { ExecutorKind } from '../backend-config.js';
|
|
8
|
-
import {
|
|
9
|
+
import { executorVersion } from '../executor-adapter.js';
|
|
9
10
|
|
|
10
11
|
const execute = promisify(execFile);
|
|
11
12
|
const packageNames = { pi: '@earendil-works/pi-coding-agent', codex: '@openai/codex' } as const;
|
|
12
13
|
|
|
13
|
-
export type LocalExecutorSelection = { kind: ExecutorKind; entry: string };
|
|
14
|
+
export type LocalExecutorSelection = { kind: ExecutorKind; entry: string; version?: string };
|
|
14
15
|
type Package = {
|
|
15
16
|
name?: string;
|
|
16
17
|
version?: string;
|
|
@@ -25,11 +26,11 @@ export function executorFailure(message: string) {
|
|
|
25
26
|
return Object.assign(new Error(message), { code: 'LOCAL_EXECUTOR_UNAVAILABLE' });
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export async function findExecutorEntry(kind: ExecutorKind) {
|
|
29
|
+
export async function findExecutorEntry(kind: ExecutorKind, accepts?: (entry: string) => Promise<boolean>) {
|
|
29
30
|
for (const base of (process.env.PATH ?? '').split(':')) {
|
|
30
31
|
if (!isAbsolute(base)) continue;
|
|
31
32
|
const entry = join(base, kind);
|
|
32
|
-
if (await access(entry, constants.X_OK).then(() => true, () => false)) return entry;
|
|
33
|
+
if (await access(entry, constants.X_OK).then(() => true, () => false) && (!accepts || await accepts(entry))) return entry;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -52,16 +53,13 @@ async function locatePackage(selection: LocalExecutorSelection, signal: AbortSig
|
|
|
52
53
|
while (directory !== dirname(directory) && !directory.endsWith(sep + 'node_modules' + sep + name)) {
|
|
53
54
|
directory = dirname(directory);
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
const npm = directory.endsWith(sep + 'node_modules' + sep + name);
|
|
57
|
+
if (!npm && !(process.platform === 'darwin' && kind === 'codex' && basename(executable) === 'codex')) throw notSupported();
|
|
56
58
|
const moduleRoot = dirname(dirname(directory));
|
|
57
|
-
const metadata = await readPackage(directory).catch(() => { throw notSupported(); });
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw notSupported();
|
|
61
|
-
}
|
|
62
|
-
const compatible = selectExecutorDriver(kind).compatibleVersions;
|
|
63
|
-
if (!metadata.version || !compatible.includes(metadata.version)) {
|
|
64
|
-
throw executorFailure(`Selected ${kind} at ${selection.entry} reports package version ${metadata.version ?? 'unknown'}. This SDK supports ${compatible.join(', ')}.`);
|
|
59
|
+
const metadata = npm ? await readPackage(directory).catch(() => { throw notSupported(); }) : undefined;
|
|
60
|
+
if (metadata) {
|
|
61
|
+
const entry = metadata.bin?.[kind];
|
|
62
|
+
if (metadata.name !== name || !entry || !below(directory, executable) || resolve(directory, entry) !== executable) throw notSupported();
|
|
65
63
|
}
|
|
66
64
|
const home = await mkdtemp(join(tmpdir(), 'anyswarm-executor-probe-'));
|
|
67
65
|
try {
|
|
@@ -72,9 +70,15 @@ async function locatePackage(selection: LocalExecutorSelection, signal: AbortSig
|
|
|
72
70
|
signal.throwIfAborted();
|
|
73
71
|
throw executorFailure(`Could not run ${kind} --version at ${selection.entry}. Check the installation and its dependencies.`);
|
|
74
72
|
});
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const reported = stdout.trim();
|
|
74
|
+
const version = kind === 'pi' ? reported : /^codex-cli (.+)$/.exec(reported)?.[1];
|
|
75
|
+
if (!executorVersion(version) || (metadata && version !== metadata.version)) {
|
|
76
|
+
throw executorFailure(`Could not verify the exact version of the selected ${kind} at ${selection.entry}.`);
|
|
77
|
+
}
|
|
78
|
+
if (selection.version !== undefined && selection.version !== version) {
|
|
79
|
+
throw executorFailure(`The selected ${kind} at ${selection.entry} is ${version}, but ${selection.version} was requested.`);
|
|
80
|
+
}
|
|
81
|
+
return { directory, moduleRoot, metadata, version, executable };
|
|
78
82
|
} finally {
|
|
79
83
|
await rm(home, { recursive: true, force: true });
|
|
80
84
|
}
|
|
@@ -100,9 +104,51 @@ async function resolveDependency(directory: string, moduleRoot: string, name: st
|
|
|
100
104
|
|
|
101
105
|
const privateFiles = new Set(['.npmrc', '.ssh', '.git', '.env', 'auth.json']);
|
|
102
106
|
|
|
107
|
+
export async function snapshotLinuxExecutor(selection: LocalExecutorSelection, destination: string,
|
|
108
|
+
{ image, platform, signal }: { image: string; platform: string; signal: AbortSignal }) {
|
|
109
|
+
const { version } = await locatePackage(selection, signal);
|
|
110
|
+
const name = packageNames[selection.kind];
|
|
111
|
+
const container = `anyswarm-executor-${randomUUID()}`;
|
|
112
|
+
const cache = join(homedir(), '.cache', 'anyswarm', 'executor-npm', platform.replace('/', '-'));
|
|
113
|
+
await mkdir(destination, { recursive: true });
|
|
114
|
+
await mkdir(cache, { recursive: true, mode: 0o700 });
|
|
115
|
+
const cacheInfo = await lstat(cache);
|
|
116
|
+
if (!cacheInfo.isDirectory() || cacheInfo.uid !== process.getuid?.() || (cacheInfo.mode & 0o077) !== 0) {
|
|
117
|
+
throw executorFailure('The local executor npm cache must be an owner-only directory.');
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
await execute('docker', ['run', '--rm', '--name', container, '--platform', platform,
|
|
121
|
+
'--mount', `type=bind,source=${await realpath(destination)},target=/out`,
|
|
122
|
+
'--mount', `type=bind,source=${await realpath(cache)},target=/npm-cache`, '--entrypoint', 'sh', image, '-eu', '-c', `
|
|
123
|
+
cd /tmp
|
|
124
|
+
npm install --prefix /tmp/executor --save-exact --omit=dev --ignore-scripts --no-bin-links \\
|
|
125
|
+
--cache /npm-cache --no-audit --no-fund --fetch-retries=1 --fetch-timeout=120000 --registry=https://registry.npmjs.org/ "$1"
|
|
126
|
+
node -e 'const pkg = require(process.argv[1]); const entry = pkg.bin[process.argv[3]]; if (pkg.version !== process.argv[2] || typeof entry !== "string") process.exit(1); process.stdout.write(entry);' "/tmp/executor/node_modules/$2/package.json" "$3" "$4" > /out/entry
|
|
127
|
+
tar --create --file=/out/program.tar --directory=/tmp/executor/node_modules --format=gnu \\
|
|
128
|
+
--sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner --mode=u=rwX,go=rX --hard-dereference \\
|
|
129
|
+
--exclude=.package-lock.json .
|
|
130
|
+
`, 'prepare-executor', `${name}@${version}`, name, version, selection.kind], { signal, timeout: 600_000, killSignal: 'SIGKILL', maxBuffer: 1024 * 1024 });
|
|
131
|
+
} catch {
|
|
132
|
+
signal.throwIfAborted();
|
|
133
|
+
throw executorFailure(`Could not prepare ${name}@${version} for ${platform}. Check registry access from Docker and availability of the exact Linux package.`);
|
|
134
|
+
} finally {
|
|
135
|
+
await execute('docker', ['rm', '-f', container], { timeout: 10_000 }).catch(() => {});
|
|
136
|
+
}
|
|
137
|
+
// Recheck the selected executable after Linux material generation, as on Linux.
|
|
138
|
+
if (await checkLocalExecutor(selection, signal) !== version) throw executorFailure('The selected installation changed during preparation.');
|
|
139
|
+
const hash = createHash('sha256');
|
|
140
|
+
for await (const chunk of createReadStream(join(destination, 'program.tar'), { signal })) hash.update(chunk);
|
|
141
|
+
const digest = hash.digest('hex');
|
|
142
|
+
await writeFile(join(destination, 'SHA256SUMS'), `${digest} program.tar\n`);
|
|
143
|
+
const entry = await readFile(join(destination, 'entry'), 'utf8');
|
|
144
|
+
if (!entry || isAbsolute(entry) || entry.split('/').includes('..')) throw executorFailure('Linux executor package has an invalid executable entry.');
|
|
145
|
+
return { ...selection, version, digest, guestEntry: `node_modules/${name}/${entry}` };
|
|
146
|
+
}
|
|
147
|
+
|
|
103
148
|
export async function snapshotLocalExecutor(selection: LocalExecutorSelection, destination: string, signal: AbortSignal) {
|
|
104
149
|
const installation = await locatePackage(selection, signal);
|
|
105
150
|
const { directory, moduleRoot, metadata, executable, version } = installation;
|
|
151
|
+
if (!metadata) throw executorFailure('This platform requires an npm installation of the selected executor.');
|
|
106
152
|
const packages = new Set<string>();
|
|
107
153
|
const files: string[] = [];
|
|
108
154
|
await mkdir(destination, { recursive: true });
|
|
@@ -8,7 +8,7 @@ import { promisify } from 'node:util';
|
|
|
8
8
|
import { PACKAGE_VERSION, WORKER_PROTOCOL } from '../worker-image.js';
|
|
9
9
|
import { fileProtocol } from '../files/core-file-seed.js';
|
|
10
10
|
import type { ExecutorKind } from '../backend-config.js';
|
|
11
|
-
import { snapshotLocalExecutor, executorFailure, type LocalExecutorSelection } from './local-executor.js';
|
|
11
|
+
import { snapshotLinuxExecutor, snapshotLocalExecutor, executorFailure, type LocalExecutorSelection } from './local-executor.js';
|
|
12
12
|
|
|
13
13
|
const execute = promisify(execFile);
|
|
14
14
|
const sdkRoot = fileURLToPath(new URL('../../../..', import.meta.url));
|
|
@@ -73,14 +73,15 @@ async function stageSdk(context: string, signal: AbortSignal) {
|
|
|
73
73
|
return hash.digest('hex');
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
async function inspect(reference: string, expected: Record<string, string>, signal: AbortSignal) {
|
|
76
|
+
async function inspect(reference: string, expected: Record<string, string>, signal: AbortSignal, platform?: string) {
|
|
77
77
|
const result = await execute('docker', ['image', 'inspect', reference], { signal, timeout: 10_000 }).catch(error => {
|
|
78
78
|
signal.throwIfAborted();
|
|
79
79
|
if (/No such image|not found/i.test(String(error.stderr))) return undefined;
|
|
80
80
|
throw workerFailure('Docker could not inspect a local Worker. Check access to the local Docker engine.');
|
|
81
81
|
});
|
|
82
82
|
if (!result) return;
|
|
83
|
-
const [image] = JSON.parse(result.stdout) as { Id: string; Config?: { Labels?: Record<string, string> } }[];
|
|
83
|
+
const [image] = JSON.parse(result.stdout) as { Id: string; Os: string; Architecture: string; Config?: { Labels?: Record<string, string> } }[];
|
|
84
|
+
if (platform && `${image?.Os}/${image?.Architecture}` !== platform) return;
|
|
84
85
|
const labels = image?.Config?.Labels;
|
|
85
86
|
if (imageId.test(image?.Id) && Object.entries(expected).every(([key, value]) => labels?.[label + key] === value)) return image.Id;
|
|
86
87
|
}
|
|
@@ -89,7 +90,9 @@ export async function prepareLocalWorker(selection: LocalExecutorSelection,
|
|
|
89
90
|
{ signal = AbortSignal.timeout(900_000), build = true, progress, requiredVersion }: {
|
|
90
91
|
signal?: AbortSignal; build?: boolean; requiredVersion?: string; progress?: (message: string) => void;
|
|
91
92
|
} = {}): Promise<LocalWorker> {
|
|
92
|
-
if (
|
|
93
|
+
if (requiredVersion !== undefined) selection = { ...selection, version: requiredVersion };
|
|
94
|
+
const darwin = process.platform === 'darwin';
|
|
95
|
+
if (!darwin && process.platform !== 'linux') throw workerFailure('Local Worker preparation requires Linux or macOS with a local Docker engine.');
|
|
93
96
|
await localDockerSocket(signal).catch(error => {
|
|
94
97
|
signal.throwIfAborted();
|
|
95
98
|
if (error.code === 'LOCAL_WORKER_UNAVAILABLE') throw error;
|
|
@@ -97,24 +100,29 @@ export async function prepareLocalWorker(selection: LocalExecutorSelection,
|
|
|
97
100
|
});
|
|
98
101
|
const context = await mkdtemp(join(tmpdir(), 'anyswarm-worker-'));
|
|
99
102
|
try {
|
|
103
|
+
const reportedPlatform = await execute('docker', ['info', '--format', '{{.OSType}}/{{.Architecture}}'], { signal, timeout: 10_000 })
|
|
104
|
+
.then(({ stdout }) => stdout.trim()).catch(() => {
|
|
105
|
+
signal.throwIfAborted();
|
|
106
|
+
throw workerFailure('Docker is unavailable. Check access to the local Linux Docker engine.');
|
|
107
|
+
});
|
|
108
|
+
const architecture = process.arch === 'x64' ? 'amd64' : process.arch;
|
|
109
|
+
if (!['arm64', 'amd64'].includes(architecture) || ![`linux/${architecture}`,
|
|
110
|
+
`linux/${architecture === 'amd64' ? 'x86_64' : 'aarch64'}`, `linux/${process.arch}`].includes(reportedPlatform)) {
|
|
111
|
+
throw workerFailure(`Docker platform ${reportedPlatform} does not match the native host architecture ${process.arch}.`);
|
|
112
|
+
}
|
|
113
|
+
const platform = darwin ? `linux/${architecture}` : reportedPlatform;
|
|
114
|
+
const sdkDigest = await stageSdk(context, signal);
|
|
115
|
+
const dockerfile = join(context, 'deploy/worker/Dockerfile');
|
|
116
|
+
const nodeImage = /^ARG NODE_IMAGE=(\S+@sha256:[a-f0-9]{64})$/m.exec(await readFile(dockerfile, 'utf8'))?.[1];
|
|
117
|
+
if (darwin && !nodeImage) throw workerFailure('Linux executor preparation requires a pinned Worker Node image.');
|
|
100
118
|
progress?.(`Checking the selected ${selection.kind} installation at ${selection.entry}`);
|
|
101
|
-
const
|
|
119
|
+
const destination = join(context, 'executor');
|
|
120
|
+
const executor = await (darwin ? snapshotLinuxExecutor(selection, destination, { image: nodeImage!, platform, signal })
|
|
121
|
+
: snapshotLocalExecutor(selection, destination, signal)).catch(error => {
|
|
102
122
|
signal.throwIfAborted();
|
|
103
123
|
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE') throw error;
|
|
104
124
|
throw executorFailure(`SDK ${PACKAGE_VERSION}: ${error.message}`);
|
|
105
125
|
});
|
|
106
|
-
if (requiredVersion !== undefined && requiredVersion !== executor.version) {
|
|
107
|
-
throw executorFailure(`This Runtime requests ${executor.kind} ${requiredVersion}, but the selected executable at ${executor.entry} is ${executor.version}.`);
|
|
108
|
-
}
|
|
109
|
-
const sdkDigest = await stageSdk(context, signal);
|
|
110
|
-
const platform = await execute('docker', ['info', '--format', '{{.OSType}}/{{.Architecture}}'], { signal, timeout: 10_000 })
|
|
111
|
-
.then(({ stdout }) => stdout.trim()).catch(() => {
|
|
112
|
-
signal.throwIfAborted();
|
|
113
|
-
throw workerFailure('Docker is unavailable. Check access to the same-host Linux Docker engine.');
|
|
114
|
-
});
|
|
115
|
-
if (!platform.startsWith('linux/') || ![process.arch, process.arch === 'x64' ? 'x86_64' : 'aarch64'].includes(platform.slice(6))) {
|
|
116
|
-
throw workerFailure(`Docker platform ${platform} does not match the Linux host executor architecture ${process.arch}.`);
|
|
117
|
-
}
|
|
118
126
|
const fingerprint = createHash('sha256')
|
|
119
127
|
.update(JSON.stringify([sdkDigest, executor.kind, executor.version, executor.digest, platform])).digest('hex');
|
|
120
128
|
const reference = 'anyswarm-worker-local:' + fingerprint;
|
|
@@ -132,7 +140,7 @@ export async function prepareLocalWorker(selection: LocalExecutorSelection,
|
|
|
132
140
|
executorEntry: executor.entry, executorDigest: executor.digest,
|
|
133
141
|
sdkVersion: PACKAGE_VERSION, sdkDigest, fingerprint,
|
|
134
142
|
};
|
|
135
|
-
const cached = await inspect(reference, verifiedLabels, signal);
|
|
143
|
+
const cached = await inspect(reference, verifiedLabels, signal, darwin ? platform : undefined);
|
|
136
144
|
if (cached) {
|
|
137
145
|
progress?.(`Reusing Worker ${reference} (${cached})`);
|
|
138
146
|
return { ...identity, id: cached, source: 'cache' };
|
|
@@ -142,14 +150,14 @@ export async function prepareLocalWorker(selection: LocalExecutorSelection,
|
|
|
142
150
|
progress?.(`Building Worker ${reference} for SDK ${PACKAGE_VERSION} and ${executor.kind} ${executor.version}`);
|
|
143
151
|
const resultFile = join(context, '.image-id');
|
|
144
152
|
const args = [
|
|
145
|
-
'build', '--
|
|
153
|
+
'build', ...(darwin ? ['--platform', platform] : []), '--file', dockerfile, '--tag', reference, '--iidfile', resultFile,
|
|
146
154
|
'--build-arg', `WORKER_EXECUTOR=${executor.kind}`, '--build-arg', `EXECUTOR_VERSION=${executor.version}`,
|
|
147
155
|
'--build-arg', `EXECUTOR_ENTRY=${executor.guestEntry}`,
|
|
148
156
|
...Object.entries(verifiedLabels).flatMap(([key, value]) => ['--label', `${label}${key}=${value}`]),
|
|
149
157
|
context,
|
|
150
158
|
];
|
|
151
159
|
try {
|
|
152
|
-
await execute('docker', args, { signal, timeout: 900_000, maxBuffer: 16 * 1024 * 1024 });
|
|
160
|
+
await execute('docker', args, { signal, timeout: 900_000, killSignal: 'SIGKILL', maxBuffer: 16 * 1024 * 1024 });
|
|
153
161
|
} catch (error) {
|
|
154
162
|
signal.throwIfAborted();
|
|
155
163
|
const cause = String((error as { stderr?: string }).stderr ?? '');
|
|
@@ -157,7 +165,7 @@ export async function prepareLocalWorker(selection: LocalExecutorSelection,
|
|
|
157
165
|
throw workerFailure(`Docker could not build ${reference}.${diagnostic ? ` ${diagnostic.slice(0, 500)}` : ''} Check build dependencies, Docker access and free disk space, then retry.`);
|
|
158
166
|
}
|
|
159
167
|
const built = (await readFile(resultFile, 'utf8')).trim();
|
|
160
|
-
if (!imageId.test(built) || !await inspect(built, verifiedLabels, signal)) {
|
|
168
|
+
if (!imageId.test(built) || !await inspect(built, verifiedLabels, signal, darwin ? platform : undefined)) {
|
|
161
169
|
throw workerFailure('Docker built a Worker whose identity does not match the SDK and executor materials.');
|
|
162
170
|
}
|
|
163
171
|
return { ...identity, id: built, source: 'build' };
|