@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
|
@@ -2,7 +2,7 @@ import { isIP } from 'node:net';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { stdin, stderr } from 'node:process';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
|
-
import {
|
|
5
|
+
import { checkSetupHost, checkHostTools, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment, } from './local-environment.js';
|
|
6
6
|
import { runLocalSmoke } from './local-setup-smoke.js';
|
|
7
7
|
import { prepareWorkerImage } from './local-setup-worker.js';
|
|
8
8
|
import { selectExecutorDriver } from '../src/core/sandbox/executor-driver.js';
|
|
@@ -12,7 +12,7 @@ import { resolveFilePolicy } from '../src/core/file-policy.js';
|
|
|
12
12
|
import { claimOpenSandboxBackend, createSandbox } from '../src/core/sandbox/opensandbox-backend.js';
|
|
13
13
|
import { snapshotModel } from '../src/core/model/model-access.js';
|
|
14
14
|
import { modelClientProtocol } from '../src/core/model/model-transport.js';
|
|
15
|
-
import { loadAnySwarmConfig, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
15
|
+
import { loadAnySwarmConfig, loopbackLifecycle, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
16
16
|
function modelState(config, executor) {
|
|
17
17
|
if (config.models === undefined)
|
|
18
18
|
return { configuration: 'missing', verification: 'not-verified' };
|
|
@@ -87,10 +87,12 @@ function reportedHost(value) {
|
|
|
87
87
|
if (value && (/^[a-zA-Z0-9._-]+$/.test(value) || isIP(value)))
|
|
88
88
|
return value;
|
|
89
89
|
}
|
|
90
|
-
function installNextStep(command) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
function installNextStep(command, mode) {
|
|
91
|
+
if (command.command !== 'setup')
|
|
92
|
+
return 'Run your Harness with the same environment.';
|
|
93
|
+
return mode === 'local'
|
|
94
|
+
? 'Run your Harness with the same environment, or repeat the probe with anyswarm doctor --smoke.'
|
|
95
|
+
: 'Run your Harness with the same environment, or check the existing service with anyswarm doctor --mode existing --smoke.';
|
|
94
96
|
}
|
|
95
97
|
const phaseLabels = {
|
|
96
98
|
host: 'Check local Docker',
|
|
@@ -99,43 +101,68 @@ const phaseLabels = {
|
|
|
99
101
|
worker: 'Prepare Worker image',
|
|
100
102
|
smoke: 'Start Worker and check Bridge, controlled Gateway, files and deletion',
|
|
101
103
|
};
|
|
104
|
+
async function probeBackend(selection, signal) {
|
|
105
|
+
try {
|
|
106
|
+
return { selection, version: await checkLocalExecutor(selection, signal) };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
signal.throwIfAborted();
|
|
110
|
+
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
111
|
+
throw error;
|
|
112
|
+
return { selection, error: error.message };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function backendOnPath(kind, version, signal) {
|
|
116
|
+
let firstFailure;
|
|
117
|
+
let available;
|
|
118
|
+
await findExecutorEntry(kind, async (entry) => {
|
|
119
|
+
const candidate = await probeBackend({ kind, entry, version }, signal);
|
|
120
|
+
if ('version' in candidate) {
|
|
121
|
+
available = candidate;
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
firstFailure ??= candidate;
|
|
125
|
+
return false;
|
|
126
|
+
});
|
|
127
|
+
return available ?? firstFailure;
|
|
128
|
+
}
|
|
102
129
|
async function chooseBackend(command, saved, configured, signal) {
|
|
103
130
|
const explicit = command.command === 'setup' ? command.backend : undefined;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
return;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
const driver = explicit || configured === undefined ? undefined : selectExecutorDriver(configured);
|
|
132
|
+
const preferred = explicit ?? driver?.kind ?? saved?.kind;
|
|
133
|
+
const version = explicit && command.command === 'setup' ? command.backendVersion : driver?.version;
|
|
134
|
+
if (command.command === 'setup' && command.backendPath && explicit) {
|
|
135
|
+
return probeBackend({ kind: explicit, entry: resolve(command.backendPath), version }, signal);
|
|
136
|
+
}
|
|
137
|
+
if (preferred === 'pi' || preferred === 'codex') {
|
|
138
|
+
if (saved?.kind === preferred && !explicit)
|
|
139
|
+
return probeBackend({ ...saved, version: version ?? saved.version }, signal);
|
|
140
|
+
if (saved?.kind === preferred && version !== undefined) {
|
|
141
|
+
const candidate = await probeBackend({ ...saved, version }, signal);
|
|
142
|
+
if ('version' in candidate)
|
|
143
|
+
return candidate;
|
|
144
|
+
}
|
|
145
|
+
return await backendOnPath(preferred, version, signal) ??
|
|
146
|
+
{ issue: `Could not find the selected ${preferred} executable on PATH.` };
|
|
115
147
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
148
|
+
const detected = await Promise.all(['pi', 'codex'].map(kind => backendOnPath(kind, undefined, signal)));
|
|
149
|
+
const compatible = detected.filter(candidate => candidate !== undefined && 'version' in candidate);
|
|
150
|
+
if (compatible.length === 0) {
|
|
151
|
+
const errors = detected.filter(candidate => candidate !== undefined && 'error' in candidate).map(candidate => candidate.error);
|
|
152
|
+
return { issue: errors.length ? errors.join(' ') : 'Neither Pi nor Codex was found on PATH.' };
|
|
153
|
+
}
|
|
154
|
+
if (compatible.length === 1)
|
|
155
|
+
return compatible[0];
|
|
156
|
+
const selectBackend = { issue: 'Both Pi and Codex have compatible installations. Choose a backend to use.', ambiguous: true };
|
|
122
157
|
if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY)
|
|
123
|
-
return;
|
|
158
|
+
return selectBackend;
|
|
124
159
|
const input = createInterface({ input: stdin, output: stderr });
|
|
125
160
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
? `${kind} ${probe.value} (${entry}) is compatible.\n`
|
|
132
|
-
: `${probe.reason instanceof Error ? probe.reason.message : `Could not verify ${kind} at ${entry}.`}\n`);
|
|
133
|
-
return probe.status === 'fulfilled';
|
|
134
|
-
});
|
|
135
|
-
if (choices.length <= 1)
|
|
136
|
-
return choices[0];
|
|
137
|
-
const answer = (await input.question(`Select a local backend [${choices.map(({ kind }) => kind).join(', ')}] (pi): `, { signal })).trim() || 'pi';
|
|
138
|
-
return choices.find(candidate => candidate.kind === answer);
|
|
161
|
+
for (const { selection, version } of compatible) {
|
|
162
|
+
stderr.write(`${selection.kind} ${version} (${selection.entry}) is compatible.\n`);
|
|
163
|
+
}
|
|
164
|
+
const answer = (await input.question('Select a local backend [pi, codex] (pi): ', { signal })).trim() || 'pi';
|
|
165
|
+
return compatible.find(candidate => candidate.selection.kind === answer) ?? selectBackend;
|
|
139
166
|
}
|
|
140
167
|
finally {
|
|
141
168
|
input.close();
|
|
@@ -170,11 +197,15 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
170
197
|
let provider;
|
|
171
198
|
let rootlessDocker = false;
|
|
172
199
|
let stage = 'config';
|
|
200
|
+
progress?.('Detect host system and AnySwarm configuration…');
|
|
173
201
|
try {
|
|
202
|
+
checks.push(...checkSetupHost());
|
|
203
|
+
report.tooling = await checkHostTools(signal);
|
|
174
204
|
const config = command.configPath
|
|
175
205
|
? await loadAnySwarmConfig(command.configPath) : undefined;
|
|
176
206
|
const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR);
|
|
177
|
-
let executor =
|
|
207
|
+
let executor = command.command === 'setup' && command.backend
|
|
208
|
+
? { kind: command.backend, version: command.backendVersion } : configured;
|
|
178
209
|
const install = command.command === 'setup';
|
|
179
210
|
let localExecutor;
|
|
180
211
|
let driver;
|
|
@@ -192,38 +223,74 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
192
223
|
image: config?.image,
|
|
193
224
|
advertiseHost: config?.connection?.advertiseHost ?? config?.connection?.modelGateway?.advertiseHost,
|
|
194
225
|
});
|
|
195
|
-
const
|
|
226
|
+
const hostname = new URL(environment.lifecycleBaseUrl).hostname;
|
|
227
|
+
const loopback = hostname === 'localhost' || hostname === '[::1]' || hostname.startsWith('127.') && isIP(hostname) === 4;
|
|
228
|
+
const reuseExisting = loopback && (environment.management === 'existing' ||
|
|
229
|
+
(!install && environment.mode === 'existing'));
|
|
230
|
+
const mode = command.mode ?? (reuseExisting ? 'existing' : 'local');
|
|
196
231
|
const smoke = install ? mode === 'local' : command.smoke;
|
|
232
|
+
report.mode = mode;
|
|
233
|
+
report.lifecycleSource = environment.endpointSource;
|
|
234
|
+
if (mode === 'local' && (!loopback || !loopbackLifecycle(environment.lifecycleBaseUrl))) {
|
|
235
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'The selected Lifecycle configuration is outside the managed local HTTP loopback profile.',
|
|
236
|
+
remedy: environment.endpointSource === 'saved'
|
|
237
|
+
? 'Use --mode existing to check the saved service, or run anyswarm setup --mode local --endpoint http://127.0.0.1:8080 to replace it after a successful local probe.'
|
|
238
|
+
: 'For local setup, remove the Lifecycle URL override or set it to http://127.0.0.1:8080. Use --mode existing only to connect to a service you explicitly select.' });
|
|
239
|
+
return report;
|
|
240
|
+
}
|
|
241
|
+
if (mode === 'existing' && environment.endpointSource === 'default') {
|
|
242
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'No existing Lifecycle service was configured.',
|
|
243
|
+
remedy: 'Run anyswarm setup for local OpenSandbox, or configure the existing Lifecycle URL and credentials explicitly.' });
|
|
244
|
+
return report;
|
|
245
|
+
}
|
|
197
246
|
if (command.command === 'setup' && command.backend && mode !== 'local') {
|
|
198
|
-
|
|
199
|
-
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local on the same Linux host.',
|
|
247
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
|
|
200
248
|
remedy: 'For an existing deployment, use its prepared Worker image.' });
|
|
201
249
|
return report;
|
|
202
250
|
}
|
|
251
|
+
if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
|
|
252
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
|
|
253
|
+
remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
|
|
254
|
+
return report;
|
|
255
|
+
}
|
|
203
256
|
if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
|
|
204
|
-
report.mode = mode;
|
|
205
257
|
checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
|
|
206
258
|
remedy: 'Set ANYSWARM_WORKER_IMAGE to the image provided by the operator.' });
|
|
207
259
|
return report;
|
|
208
260
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
261
|
+
let localVersion;
|
|
262
|
+
if (mode === 'local' && !environment.image && !driver.adapter) {
|
|
263
|
+
progress?.('Detect an installed Pi or Codex executable…');
|
|
264
|
+
const detected = await chooseBackend(command, environment.localExecutor, configured, signal);
|
|
265
|
+
if ('issue' in detected) {
|
|
266
|
+
const remedy = detected.ambiguous
|
|
267
|
+
? 'Run anyswarm setup --backend pi or anyswarm setup --backend codex.'
|
|
268
|
+
: 'For Pi, run npm install -g @earendil-works/pi-coding-agent, then run anyswarm setup --backend pi. For Codex, run npm install -g @openai/codex, then run anyswarm setup --backend codex.';
|
|
269
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.issue, remedy });
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
localExecutor = detected.selection;
|
|
273
|
+
executor = { kind: localExecutor.kind, version: localExecutor.version };
|
|
274
|
+
driver = selectExecutorDriver(executor);
|
|
275
|
+
if ('error' in detected) {
|
|
276
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.error,
|
|
277
|
+
remedy: 'Restore the saved executable or select a supported installation with anyswarm setup --backend pi or anyswarm setup --backend codex.' });
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
localVersion = detected.version;
|
|
281
|
+
const detail = `Detected ${localExecutor.kind} ${localVersion} at ${localExecutor.entry}.`;
|
|
282
|
+
checks.push({ id: 'config.executor', ok: true, detail });
|
|
283
|
+
progress?.(detail);
|
|
284
|
+
}
|
|
218
285
|
}
|
|
219
|
-
executor = localExecutor.kind;
|
|
220
|
-
driver = selectExecutorDriver(executor);
|
|
221
286
|
}
|
|
222
|
-
|
|
287
|
+
const modelUrl = process.env.ANYSWARM_MODEL_URL || process.env.ANYSWARM_SUBAGENTS_MODEL_URL;
|
|
288
|
+
const modelId = process.env.ANYSWARM_MODEL_ID || process.env.ANYSWARM_SUBAGENTS_MODEL_ID;
|
|
289
|
+
if (!config && modelUrl && (modelId || driver.kind !== 'codex')) {
|
|
223
290
|
const route = {
|
|
224
|
-
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
|
|
225
|
-
model:
|
|
226
|
-
upstream: { url:
|
|
291
|
+
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai',
|
|
292
|
+
model: modelId || 'gpt-5.4', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
|
|
293
|
+
upstream: { url: modelUrl, headers: {} },
|
|
227
294
|
};
|
|
228
295
|
try {
|
|
229
296
|
snapshotModel(route, driver.kind);
|
|
@@ -236,29 +303,28 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
236
303
|
else {
|
|
237
304
|
report.model = config ? modelState(config, driver.kind) : { configuration: 'missing', verification: 'not-verified' };
|
|
238
305
|
}
|
|
306
|
+
if (report.model.configuration === 'missing') {
|
|
307
|
+
report.model.remedy = config ? 'Set an upstream endpoint for each active model route in the trusted configuration.'
|
|
308
|
+
: 'Before running the Quickstart Harness, set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID. Set ANYSWARM_MODEL_TOKEN if the endpoint requires authentication.';
|
|
309
|
+
}
|
|
239
310
|
if (report.model?.configuration === 'invalid')
|
|
240
311
|
checks.push({
|
|
241
312
|
id: 'config.models', ok: false, detail: 'An active model alias, capability declaration or protocol endpoint is invalid for the selected executor.',
|
|
242
313
|
remedy: 'Use a supported executor and protocol combination, and configure an HTTP(S) endpoint without embedded credentials for each active model alias.',
|
|
243
314
|
});
|
|
244
|
-
if (
|
|
245
|
-
return report;
|
|
246
|
-
if (config) {
|
|
315
|
+
if (config && report.model.configuration !== 'invalid') {
|
|
247
316
|
const { lifecycleBaseUrl, apiKey, endpointHost } = environment;
|
|
248
317
|
checks.push(checkProjectRuntime({
|
|
249
318
|
...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl },
|
|
250
319
|
}, { ...config.sandbox, endpoint: undefined, lifecycleBaseUrl, apiKey, endpointHost }));
|
|
251
320
|
}
|
|
252
|
-
if (checks.some(check => !check.ok))
|
|
253
|
-
return report;
|
|
254
321
|
report.configuration = {
|
|
255
|
-
executor: { id: driver.kind, version: driver.version,
|
|
322
|
+
executor: { id: driver.kind, version: localVersion ?? driver.version, entry: localExecutor?.entry,
|
|
323
|
+
compatibleVersions: driver.adapter?.compatibleVersions },
|
|
256
324
|
image: environment.image ?? workerImageFor(executor),
|
|
257
325
|
filePolicy: resolveFilePolicy(config?.filePolicy),
|
|
258
326
|
};
|
|
259
327
|
const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
|
|
260
|
-
report.mode = mode;
|
|
261
|
-
report.lifecycleSource = environment.endpointSource;
|
|
262
328
|
report.connection = {
|
|
263
329
|
lifecycleBaseUrl: reportedEndpoint(environment.lifecycleBaseUrl),
|
|
264
330
|
advertiseHost: reportedHost(environment.advertiseHost),
|
|
@@ -269,22 +335,21 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
269
335
|
resolveWith: 'resolveSandboxConnection',
|
|
270
336
|
};
|
|
271
337
|
stage = 'host';
|
|
272
|
-
|
|
273
|
-
if (checks.some(check => !check.ok))
|
|
274
|
-
return report;
|
|
338
|
+
const darwin = process.platform === 'darwin';
|
|
275
339
|
let advertiseHost = environment.advertiseHost;
|
|
276
|
-
|
|
340
|
+
let advertiseHostDiscovery = environment.advertiseHostDiscovery;
|
|
341
|
+
if (mode === 'local' && checks.find(check => check.id === 'host.platform')?.ok) {
|
|
277
342
|
const docker = await timed('host', checkLocalDocker);
|
|
278
343
|
checks.push(docker.diagnostic);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
rootlessDocker = docker.docker.rootless;
|
|
282
|
-
if (advertiseHost === undefined && docker.docker.advertiseHost !== undefined) {
|
|
344
|
+
rootlessDocker = docker.docker?.rootless ?? false;
|
|
345
|
+
if (advertiseHost === undefined && docker.docker?.advertiseHost !== undefined) {
|
|
283
346
|
advertiseHost = docker.docker.advertiseHost;
|
|
284
347
|
report.connection.advertiseHost = reportedHost(advertiseHost);
|
|
285
348
|
report.connection.sources.advertiseHost = 'docker-network';
|
|
286
349
|
}
|
|
287
350
|
}
|
|
351
|
+
if (checks.some(check => !check.ok))
|
|
352
|
+
return report;
|
|
288
353
|
let image = report.configuration.image;
|
|
289
354
|
if (mode === 'local' && smoke) {
|
|
290
355
|
stage = 'worker';
|
|
@@ -300,8 +365,8 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
300
365
|
report.connection.image = worker.image.reference;
|
|
301
366
|
report.connection.sources.image = worker.source;
|
|
302
367
|
report.configuration.image = worker.image.reference;
|
|
303
|
-
if (
|
|
304
|
-
executor = { kind:
|
|
368
|
+
if (!driver.adapter && (worker.image.executor === 'pi' || worker.image.executor === 'codex')) {
|
|
369
|
+
executor = { kind: worker.image.executor, version: worker.image.version };
|
|
305
370
|
report.configuration.executor.version = worker.image.version;
|
|
306
371
|
}
|
|
307
372
|
progress?.(`Worker image source: ${worker.source}`);
|
|
@@ -313,12 +378,26 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
313
378
|
progress?.(provider.created ? 'Started managed OpenSandbox' : 'Reused managed OpenSandbox');
|
|
314
379
|
}
|
|
315
380
|
const active = provider?.config ?? environment;
|
|
316
|
-
checks.push(...await timed('provider', () => checkLocalProvider(active)));
|
|
381
|
+
checks.push(...await timed('provider', () => checkLocalProvider(active, { managed: mode === 'local' })));
|
|
317
382
|
if (checks.some(check => !check.ok))
|
|
318
383
|
return report;
|
|
319
384
|
report.infrastructure = 'preflight-passed';
|
|
320
385
|
if (smoke) {
|
|
321
386
|
stage = 'smoke';
|
|
387
|
+
if (darwin && mode === 'local' && publicUrl === undefined &&
|
|
388
|
+
(advertiseHost === undefined || advertiseHostDiscovery === 'docker-network')) {
|
|
389
|
+
const discovered = await discoverMacCallback(image, signal);
|
|
390
|
+
if (!install && discovered !== advertiseHost) {
|
|
391
|
+
checks.push({ id: 'config.callback', ok: false, detail: 'The saved Runtime callback needs to be refreshed.',
|
|
392
|
+
remedy: 'Run anyswarm setup to save and verify the current Docker callback.' });
|
|
393
|
+
report.infrastructure = 'failed';
|
|
394
|
+
return report;
|
|
395
|
+
}
|
|
396
|
+
advertiseHost = discovered;
|
|
397
|
+
advertiseHostDiscovery = 'docker-network';
|
|
398
|
+
report.connection.advertiseHost = advertiseHost;
|
|
399
|
+
report.connection.sources.advertiseHost = 'docker-network';
|
|
400
|
+
}
|
|
322
401
|
report.smoke = await timed('smoke', () => runLocalSmoke({
|
|
323
402
|
...active, image, sandbox: config?.sandbox, connection: {
|
|
324
403
|
...config?.connection, publicUrl: environment.publicUrl,
|
|
@@ -336,7 +415,7 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
336
415
|
signal.throwIfAborted();
|
|
337
416
|
if (install) {
|
|
338
417
|
await saveSandboxConnection({ ...active, publicUrl: environment.publicUrl,
|
|
339
|
-
advertiseHost, image: environment.image, localExecutor,
|
|
418
|
+
advertiseHost, advertiseHostDiscovery, image: environment.image, localExecutor,
|
|
340
419
|
management: mode, providerId: provider?.id, preparedImage: report.worker?.id,
|
|
341
420
|
egressMode: mode === 'local' ? 'dns+nft' : environment.egressMode });
|
|
342
421
|
checks.push({ id: 'connection.saved', ok: true, detail: 'OpenSandbox connection saved in the owner-only user configuration.' });
|
|
@@ -354,7 +433,11 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
354
433
|
};
|
|
355
434
|
let [detail, remedy] = failure[stage];
|
|
356
435
|
const code = error?.code;
|
|
357
|
-
if (
|
|
436
|
+
if (code === 'DOCKER_CALLBACK_UNAVAILABLE') {
|
|
437
|
+
detail = 'The Docker container could not resolve a unique Mac callback IPv4 address.';
|
|
438
|
+
remedy = 'Check host.docker.internal from the selected local engine, or configure a Runtime publicUrl reachable from the Sandbox.';
|
|
439
|
+
}
|
|
440
|
+
else if (stage === 'provider' && ['PROVIDER_EXECD_PULL_FAILED', 'PROVIDER_SERVER_PULL_FAILED', 'PROVIDER_EGRESS_PULL_FAILED'].includes(code ?? '')) {
|
|
358
441
|
const execd = code === 'PROVIDER_EXECD_PULL_FAILED';
|
|
359
442
|
const egress = code === 'PROVIDER_EGRESS_PULL_FAILED';
|
|
360
443
|
detail = `Docker could not pull the pinned OpenSandbox ${execd ? 'Execd' : egress ? 'egress' : 'server'} image.`;
|
|
@@ -418,8 +501,13 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
418
501
|
progress?.(`Probe evidence: ${report.smoke.outputDir}`);
|
|
419
502
|
progress?.('Controlled smoke completed. The configured model upstream was not contacted.');
|
|
420
503
|
}
|
|
504
|
+
for (const tool of report.tooling?.filter(check => !check.ok) ?? []) {
|
|
505
|
+
progress?.([tool.detail, tool.remedy].filter(Boolean).join(' '));
|
|
506
|
+
}
|
|
507
|
+
if (report.model?.remedy)
|
|
508
|
+
progress?.(report.model.remedy);
|
|
421
509
|
if (report.ok)
|
|
422
|
-
progress?.(installNextStep(command));
|
|
510
|
+
progress?.(installNextStep(command, report.mode));
|
|
423
511
|
}
|
|
424
512
|
return report;
|
|
425
513
|
}
|
|
@@ -336,8 +336,8 @@ async function startAgent(input) {
|
|
|
336
336
|
}
|
|
337
337
|
else if (executorKind === 'codex') {
|
|
338
338
|
const version = spawnSync('setpriv', [...unprivileged, 'codex', '--version'], { cwd, env: agentEnvironment, timeout: 5_000, encoding: 'utf8' });
|
|
339
|
-
executorVersion = input.executor_version ??
|
|
340
|
-
if (version.status !== 0 || version.stdout.trim() !== `codex-cli ${executorVersion}`) {
|
|
339
|
+
executorVersion = input.executor_version ?? input.codex.version;
|
|
340
|
+
if (typeof executorVersion !== 'string' || version.status !== 0 || version.stdout.trim() !== `codex-cli ${executorVersion}`) {
|
|
341
341
|
throw startupContractError('Codex CLI version differs from the Runtime selection');
|
|
342
342
|
}
|
|
343
343
|
const configuration = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { execFile, spawnSync } from 'node:child_process';
|
|
2
|
+
import { chmod, mkdir, mkdtemp, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
const [destination, ...options] = process.argv.slice(2);
|
|
7
|
+
if (!destination || (options.length && options.join(' ') !== '--skip-build')) {
|
|
8
|
+
throw new Error('Usage: npm run pack:release -- <output-directory> [--skip-build]');
|
|
9
|
+
}
|
|
10
|
+
// Keep the build and staging umask independent of the caller.
|
|
11
|
+
process.umask(0o022);
|
|
12
|
+
const run = promisify(execFile);
|
|
13
|
+
const repository = resolve(import.meta.dirname, '..');
|
|
14
|
+
const output = resolve(destination);
|
|
15
|
+
if (!options.length) {
|
|
16
|
+
const build = spawnSync('npm', ['run', 'build'], { cwd: repository, stdio: ['ignore', 2, 2] });
|
|
17
|
+
if (build.error)
|
|
18
|
+
throw build.error;
|
|
19
|
+
if (build.status !== 0)
|
|
20
|
+
process.exit(build.status ?? 1);
|
|
21
|
+
}
|
|
22
|
+
async function pack(directory, destination) {
|
|
23
|
+
const { stdout } = await run('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', destination], {
|
|
24
|
+
cwd: directory, maxBuffer: 4 * 1024 ** 2,
|
|
25
|
+
});
|
|
26
|
+
return JSON.parse(stdout)[0].filename;
|
|
27
|
+
}
|
|
28
|
+
const temporary = await mkdtemp(join(tmpdir(), 'anyswarm-pack-release-'));
|
|
29
|
+
try {
|
|
30
|
+
// Start from npm's allowlist so private checkout files never enter staging.
|
|
31
|
+
const sourceArchive = await pack(repository, temporary);
|
|
32
|
+
await run('tar', ['-xzf', join(temporary, sourceArchive), '-C', temporary]);
|
|
33
|
+
const staged = join(temporary, 'package');
|
|
34
|
+
const manifestPath = join(staged, 'package.json');
|
|
35
|
+
const lockPath = join(staged, 'npm-shrinkwrap.json');
|
|
36
|
+
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
37
|
+
// Service images compile TypeScript. The Pi installation belongs to the executor.
|
|
38
|
+
delete manifest.devDependencies?.['@earendil-works/pi-coding-agent'];
|
|
39
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
40
|
+
await run('npm', ['install', '--package-lock-only', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], { cwd: staged });
|
|
41
|
+
const lock = JSON.parse(await readFile(lockPath, 'utf8'));
|
|
42
|
+
if (lock.lockfileVersion !== 3 || !lock.packages?.['']) {
|
|
43
|
+
throw new Error('Release packaging requires a v3 npm shrinkwrap with root package metadata');
|
|
44
|
+
}
|
|
45
|
+
await rename(manifestPath, join(staged, 'package.development.json'));
|
|
46
|
+
await rename(lockPath, join(staged, 'npm-shrinkwrap.development.json'));
|
|
47
|
+
delete manifest.private;
|
|
48
|
+
delete manifest.devDependencies;
|
|
49
|
+
delete lock.packages[''].devDependencies;
|
|
50
|
+
lock.packages = Object.fromEntries(Object.entries(lock.packages).filter(([, entry]) => !entry.dev));
|
|
51
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
52
|
+
await writeFile(lockPath, JSON.stringify(lock, null, 2) + '\n');
|
|
53
|
+
// npm records existing file modes, which can also depend on the checkout umask.
|
|
54
|
+
for (const entry of await readdir(staged, { recursive: true, withFileTypes: true })) {
|
|
55
|
+
if (!entry.isFile())
|
|
56
|
+
continue;
|
|
57
|
+
const path = join(entry.parentPath, entry.name);
|
|
58
|
+
const { mode } = await stat(path);
|
|
59
|
+
await chmod(path, mode & 0o111 ? 0o755 : 0o644);
|
|
60
|
+
}
|
|
61
|
+
await mkdir(output, { recursive: true });
|
|
62
|
+
console.log(join(output, await pack(staged, output)));
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
await rm(temporary, { recursive: true, force: true });
|
|
66
|
+
}
|
|
@@ -6,6 +6,7 @@ import { createHash } from 'node:crypto';
|
|
|
6
6
|
import { createInterface } from 'node:readline';
|
|
7
7
|
import { assertPiThinkingLevel, createPiSessionController, PI_SESSION_CAPABILITIES } from './pi-session-controller.js';
|
|
8
8
|
import { createPiServiceTools } from './pi-service-tools.js';
|
|
9
|
+
import { executorVersion } from '../src/core/executor-adapter.js';
|
|
9
10
|
import { PI_SESSION_OUTPUT_LIMIT as maximumOutputBytes } from './pi-session-diagnostics.js';
|
|
10
11
|
// This module is a Guest executable. Core never imports the Pi runtime.
|
|
11
12
|
async function loadPi() {
|
|
@@ -19,12 +20,19 @@ async function loadPi() {
|
|
|
19
20
|
const sdk = await import(entry);
|
|
20
21
|
const packagePath = new URL('../package.json', entry);
|
|
21
22
|
const metadata = JSON.parse(await readFile(packagePath, 'utf8'));
|
|
22
|
-
if (!
|
|
23
|
-
|
|
23
|
+
if (!executorVersion(metadata.version) || [
|
|
24
|
+
sdk.SettingsManager?.inMemory, sdk.DefaultResourceLoader, sdk.ModelRuntime?.create,
|
|
25
|
+
sdk.SessionManager?.create, sdk.SessionManager?.open,
|
|
26
|
+
sdk.createAgentSession, sdk.createCodemodeExtension, sdk.createToolSearchExtension,
|
|
27
|
+
].some(required => typeof required !== 'function')) {
|
|
28
|
+
throw new Error('The installed Pi package does not expose the required Session Bridge API');
|
|
29
|
+
}
|
|
24
30
|
return { sdk, version: metadata.version };
|
|
25
31
|
}
|
|
26
|
-
const options = JSON.parse(await readFile(process.argv[2], 'utf8'));
|
|
27
32
|
const { sdk, version } = await loadPi();
|
|
33
|
+
if (process.argv[2] === '--check-sdk')
|
|
34
|
+
process.exit(0);
|
|
35
|
+
const options = JSON.parse(await readFile(process.argv[2], 'utf8'));
|
|
28
36
|
const args = options.args ?? [];
|
|
29
37
|
const argument = (name) => { const index = args.indexOf(name); return index < 0 ? undefined : args[index + 1]; };
|
|
30
38
|
const cwd = process.cwd();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
-
|
|
4
|
+
import { installSourceLoader } from '../src/harness/typescript-loader.js';
|
|
5
|
+
const usage = 'node dist/scripts/run-harness.js --config <host-module.ts>';
|
|
5
6
|
const args = process.argv.slice(2);
|
|
6
7
|
const lifetime = new AbortController();
|
|
7
8
|
const stop = () => lifetime.abort();
|
|
@@ -45,6 +46,7 @@ try {
|
|
|
45
46
|
else {
|
|
46
47
|
if (args.length !== 2 || args[0] !== '--config' || !args[1] || args[1].startsWith('--'))
|
|
47
48
|
throw Object.assign(new Error(), { code: 'HOST_ARGUMENTS_INVALID' });
|
|
49
|
+
installSourceLoader();
|
|
48
50
|
const { default: configuration } = await import(pathToFileURL(resolve(args[1])).href);
|
|
49
51
|
const { keepsForegroundCommandsOpen, runForegroundHarness } = await import('../src/cli/foreground-harnesses.js');
|
|
50
52
|
const { runForegroundCommands } = await import('../src/harness/foreground-commands.js');
|
|
@@ -86,6 +86,37 @@ async function lockedSetup(startedAt, options) {
|
|
|
86
86
|
bootstrap.timings.push({ id: 'build', elapsedMs: Math.round(performance.now() - start), cached: buildCached });
|
|
87
87
|
return child(process.execPath, [cli, 'setup', ...options], { ...process.env, ANYSWARM_SETUP_BOOTSTRAP: JSON.stringify(bootstrap) }, true);
|
|
88
88
|
}
|
|
89
|
+
async function macCheckoutSetup(startedAt, options) {
|
|
90
|
+
signal.throwIfAborted();
|
|
91
|
+
const lock = spawn('/usr/bin/lockf', ['-kn', '-t', '180', root, process.execPath, '-e',
|
|
92
|
+
'console.log("locked"); process.stdin.resume()'], { stdio: ['pipe', 'pipe', 'inherit'] });
|
|
93
|
+
lock.stdin.on('error', () => { });
|
|
94
|
+
const cancel = () => lock.kill('SIGTERM');
|
|
95
|
+
signal.addEventListener('abort', cancel, { once: true });
|
|
96
|
+
try {
|
|
97
|
+
const acquired = await new Promise((ready, reject) => {
|
|
98
|
+
lock.once('error', reject);
|
|
99
|
+
lock.once('exit', code => {
|
|
100
|
+
if (code === 75)
|
|
101
|
+
ready(false);
|
|
102
|
+
else
|
|
103
|
+
reject(new Error('Could not lock the checkout.'));
|
|
104
|
+
});
|
|
105
|
+
lock.stdout.once('data', () => ready(true));
|
|
106
|
+
});
|
|
107
|
+
signal.removeEventListener('abort', cancel);
|
|
108
|
+
signal.throwIfAborted();
|
|
109
|
+
if (!acquired) {
|
|
110
|
+
failure('checkout-lock', 'Another setup still holds the checkout lock.', 'Wait for the other invocation and rerun setup.');
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
return await lockedSetup(startedAt, options);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
signal.removeEventListener('abort', cancel);
|
|
117
|
+
lock.stdin.end();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
89
120
|
const args = process.argv.slice(2);
|
|
90
121
|
const lockInvocation = args[0] === '--under-checkout-lock';
|
|
91
122
|
try {
|
|
@@ -99,18 +130,24 @@ try {
|
|
|
99
130
|
console.log(command.help);
|
|
100
131
|
}
|
|
101
132
|
else {
|
|
102
|
-
if (process.platform !== 'linux') {
|
|
103
|
-
failure('host.
|
|
133
|
+
if (process.platform !== 'linux' && process.platform !== 'darwin') {
|
|
134
|
+
failure('host.platform', 'Setup requires Linux or macOS.', 'Run this command on Linux or macOS.');
|
|
104
135
|
process.exitCode = 1;
|
|
105
136
|
}
|
|
106
137
|
else if (command.command === 'setup') {
|
|
107
138
|
const options = [
|
|
108
139
|
...(command.mode ? ['--mode', command.mode] : []),
|
|
140
|
+
...(command.endpoint ? ['--endpoint', command.endpoint] : []),
|
|
141
|
+
...(command.publicUrl ? ['--public-url', command.publicUrl] : []),
|
|
142
|
+
...(command.backend ? ['--backend', command.backend] : []),
|
|
143
|
+
...(command.backendVersion ? ['--backend-version', command.backendVersion] : []),
|
|
144
|
+
...(command.backendPath ? ['--backend-path', resolve(command.backendPath)] : []),
|
|
109
145
|
...(command.configPath ? ['--config', resolve(command.configPath)] : []),
|
|
110
146
|
];
|
|
111
|
-
process.exitCode =
|
|
112
|
-
|
|
113
|
-
|
|
147
|
+
process.exitCode = process.platform === 'darwin' ? await macCheckoutSetup(startedAt, options)
|
|
148
|
+
: await child('flock', ['--no-fork', '--exclusive', '--timeout', '180', '--conflict-exit-code', '73',
|
|
149
|
+
root, process.execPath, '--disable-warning=ExperimentalWarning', script, '--under-checkout-lock',
|
|
150
|
+
String(startedAt), ...options], process.env, true);
|
|
114
151
|
if (process.exitCode === 73) {
|
|
115
152
|
failure('checkout-lock', 'Another setup still holds the checkout lock.', 'Wait for the other invocation and rerun setup.');
|
|
116
153
|
process.exitCode = 1;
|
|
@@ -129,7 +166,7 @@ catch (error) {
|
|
|
129
166
|
process.exitCode = 2;
|
|
130
167
|
}
|
|
131
168
|
else {
|
|
132
|
-
failure('bootstrap', 'The checkout could not be prepared.', 'Check Node.js, npm,
|
|
169
|
+
failure('bootstrap', 'The checkout could not be prepared.', 'Check Node.js, npm, platform lock tools and permissions on this checkout.');
|
|
133
170
|
process.exitCode = 1;
|
|
134
171
|
}
|
|
135
172
|
}
|
|
@@ -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
|
function fault(code, message) {
|
|
7
8
|
return Object.assign(new Error(message), { code, allocationLedger: true });
|
|
8
9
|
}
|
|
@@ -40,12 +41,12 @@ function currentHostIdentity() {
|
|
|
40
41
|
const node = process.env.ANYSWARM_RUNTIME_NODE_NAME;
|
|
41
42
|
const identities = [node ? 'kubernetes' : 'host', node || hostname()];
|
|
42
43
|
try {
|
|
43
|
-
identities.push(readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim());
|
|
44
|
+
identities.push(process.platform === 'darwin' ? darwinBootSession() : readFileSync('/proc/sys/kernel/random/boot_id', 'utf8').trim());
|
|
44
45
|
}
|
|
45
46
|
catch {
|
|
46
|
-
throw fault('NOT_ALLOWED', 'Durable Runtime requires
|
|
47
|
+
throw fault('NOT_ALLOWED', 'Durable Runtime requires a verified kernel boot identity');
|
|
47
48
|
}
|
|
48
|
-
if (!node) {
|
|
49
|
+
if (!node && process.platform !== 'darwin') {
|
|
49
50
|
try {
|
|
50
51
|
identities.push(readFileSync('/etc/machine-id', 'utf8').trim());
|
|
51
52
|
}
|