@anyswarm/core 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -10
- package/deploy/worker/Dockerfile +12 -4
- package/dist/deploy/worker/Dockerfile +12 -4
- package/dist/examples/README.md +24 -12
- package/dist/examples/authoring/README.md +24 -0
- package/dist/examples/authoring/business.d.ts +2 -0
- package/dist/examples/authoring/business.js +4 -0
- package/dist/examples/authoring/config.d.ts +5 -0
- package/dist/examples/authoring/config.js +2 -0
- package/dist/examples/authoring/eject.json +5 -0
- package/dist/examples/authoring/harness.d.ts +4 -0
- package/dist/examples/authoring/harness.js +19 -0
- package/dist/examples/autoresearch/README.md +33 -0
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +18 -0
- package/dist/examples/autoresearch/config.d.ts +51 -0
- package/dist/examples/autoresearch/config.js +57 -0
- package/dist/examples/autoresearch/demo.d.ts +11 -0
- package/dist/examples/autoresearch/demo.js +52 -0
- package/dist/examples/autoresearch/eject.json +15 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
- package/dist/examples/autoresearch/frontiercs2.js +211 -0
- package/dist/examples/autoresearch/prepare.d.ts +95 -0
- package/dist/examples/autoresearch/prepare.js +257 -0
- package/dist/examples/autoresearch/process.d.ts +13 -0
- package/dist/examples/autoresearch/process.js +48 -0
- package/dist/examples/autoresearch/project.d.ts +115 -0
- package/dist/examples/autoresearch/project.js +410 -0
- package/dist/examples/autoresearch/research-service.d.ts +106 -0
- package/dist/examples/autoresearch/research-service.js +255 -0
- package/dist/examples/code/README.md +25 -0
- package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/code/candidate.d.ts +19 -0
- package/dist/examples/code/candidate.js +80 -0
- package/dist/examples/code/config.d.ts +32 -0
- package/dist/examples/code/config.js +18 -0
- package/dist/examples/code/eject.json +5 -0
- package/dist/examples/code/project.d.ts +3 -0
- package/dist/examples/code/project.js +605 -0
- package/dist/examples/code/prompts.d.ts +5 -0
- package/dist/examples/code/prompts.js +12 -0
- package/dist/examples/code/verification.d.ts +19 -0
- package/dist/examples/code/verification.js +268 -0
- package/dist/examples/code/worktree.d.ts +17 -0
- package/dist/examples/code/worktree.js +233 -0
- package/dist/examples/harness-session/README.md +3 -6
- package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
- package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
- package/dist/examples/lead-worker/harness/index.d.ts +60 -0
- package/dist/examples/lead-worker/harness/index.js +77 -6
- package/dist/examples/lead-worker/project.js +2 -2
- package/dist/examples/lead-worker/services/board.d.ts +5 -0
- package/dist/examples/lead-worker/services/board.js +19 -1
- package/dist/examples/messages/README.md +5 -5
- package/dist/examples/messages/handoff.d.ts +2 -0
- package/dist/examples/messages/handoff.js +5 -1
- package/dist/examples/messages/project.js +52 -2
- package/dist/examples/notes/README.md +13 -18
- package/dist/examples/notes/project.js +67 -6
- package/dist/examples/peermesh/harness/router.js +3 -1
- package/dist/examples/peermesh/harness/team.d.ts +8 -0
- package/dist/examples/peermesh/harness/team.js +13 -0
- package/dist/examples/peermesh/project.js +22 -4
- package/dist/examples/services/agent-control/README.md +3 -3
- package/dist/examples/services/mathlib-search/Dockerfile +4 -2
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +2 -2
- package/dist/examples/services/persistent-board/README.md +13 -3
- package/dist/examples/services/persistent-board/business.d.ts +7 -0
- package/dist/examples/services/persistent-board/business.js +7 -0
- package/dist/examples/services/persistent-board/index.js +10 -0
- package/dist/examples/services/persistent-board/live.d.ts +3 -0
- package/dist/examples/services/persistent-board/live.js +58 -0
- package/dist/examples/subagents/README.md +5 -5
- package/dist/examples/subagents/business.js +3 -1
- package/dist/examples/subagents/harness/controller.d.ts +15 -0
- package/dist/examples/subagents/harness/controller.js +181 -32
- package/dist/examples/subagents/project.d.ts +2 -0
- package/dist/examples/subagents/project.js +43 -34
- package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
- package/dist/examples/subagents/prompts/prompts.js +3 -0
- package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
- package/dist/examples/subagents/services/collaboration-service.js +14 -2
- package/dist/examples/substrate/README.md +2 -2
- package/dist/examples/substrate/harness/index.d.ts +1 -1
- package/dist/examples/substrate/harness/index.js +77 -12
- package/dist/examples/substrate/project.js +4 -1
- package/dist/examples/super/README.md +40 -0
- package/dist/examples/super/actions.d.ts +95 -0
- package/dist/examples/super/actions.js +230 -0
- package/dist/examples/super/artifact.d.ts +4 -0
- package/dist/examples/super/artifact.js +51 -0
- package/dist/examples/super/config.d.ts +80 -0
- package/dist/examples/super/config.js +83 -0
- package/dist/examples/super/coordinator.d.ts +33 -0
- package/dist/examples/super/coordinator.js +151 -0
- package/dist/examples/super/daemon.d.ts +11 -0
- package/dist/examples/super/daemon.js +109 -0
- package/dist/examples/super/decisions.d.ts +8 -0
- package/dist/examples/super/decisions.js +52 -0
- package/dist/examples/super/eject.json +5 -0
- package/dist/examples/super/execution.d.ts +11 -0
- package/dist/examples/super/execution.js +136 -0
- package/dist/examples/super/github.d.ts +62 -0
- package/dist/examples/super/github.js +269 -0
- package/dist/examples/super/inbox.d.ts +162 -0
- package/dist/examples/super/inbox.js +284 -0
- package/dist/examples/super/location.d.ts +5 -0
- package/dist/examples/super/location.js +64 -0
- package/dist/examples/super/outbox.d.ts +5 -0
- package/dist/examples/super/outbox.js +103 -0
- package/dist/examples/super/project.d.ts +111 -0
- package/dist/examples/super/project.js +253 -0
- package/dist/examples/super/prompts.d.ts +3 -0
- package/dist/examples/super/prompts.js +25 -0
- package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/dist/examples/taskpool/harness/controller.d.ts +35 -6
- package/dist/examples/taskpool/harness/controller.js +73 -7
- package/dist/examples/taskpool/project.js +18 -2
- package/dist/scripts/anyswarm-applications.d.ts +19 -0
- package/dist/scripts/anyswarm-applications.js +19 -0
- package/dist/scripts/anyswarm-arguments.d.ts +35 -5
- package/dist/scripts/anyswarm-arguments.js +87 -23
- package/dist/scripts/anyswarm-author.d.ts +5 -0
- package/dist/scripts/anyswarm-author.js +24 -0
- package/dist/scripts/anyswarm-eject.d.ts +11 -0
- package/dist/scripts/anyswarm-eject.js +164 -0
- package/dist/scripts/anyswarm-harnesses.d.ts +2 -0
- package/dist/scripts/anyswarm-harnesses.js +31 -0
- package/dist/scripts/anyswarm-installation.js +19 -13
- package/dist/scripts/anyswarm-launch.d.ts +37 -0
- package/dist/scripts/anyswarm-launch.js +86 -0
- package/dist/scripts/anyswarm-project.d.ts +12 -2
- package/dist/scripts/anyswarm-project.js +121 -20
- package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
- package/dist/scripts/anyswarm-source-runner.js +232 -0
- package/dist/scripts/anyswarm-tui-config.d.ts +36 -0
- package/dist/scripts/anyswarm-tui-config.js +189 -0
- package/dist/scripts/anyswarm-tui-session.d.ts +66 -0
- package/dist/scripts/anyswarm-tui-session.js +304 -0
- package/dist/scripts/anyswarm-tui-terminal.d.ts +41 -0
- package/dist/scripts/anyswarm-tui-terminal.js +154 -0
- package/dist/scripts/anyswarm-tui.d.ts +2 -0
- package/dist/scripts/anyswarm-tui.js +1012 -0
- package/dist/scripts/anyswarm.js +47 -2
- package/dist/scripts/build-provenance.json +1 -0
- package/dist/scripts/build.js +7 -1
- package/dist/scripts/generate-architecture-api.js +2 -0
- package/dist/scripts/generate-architecture-prompts.js +24 -2
- package/dist/scripts/local-environment.d.ts +6 -1
- package/dist/scripts/local-environment.js +52 -16
- package/dist/scripts/local-setup-smoke.js +3 -2
- package/dist/scripts/local-setup-worker.d.ts +1 -1
- package/dist/scripts/local-setup-worker.js +15 -6
- package/dist/scripts/local-setup.d.ts +2 -2
- package/dist/scripts/local-setup.js +72 -12
- package/dist/scripts/opensandbox-agent-worker.js +2 -2
- package/dist/scripts/pack-release.d.ts +1 -0
- package/dist/scripts/pack-release.js +63 -0
- package/dist/scripts/pi-session-bridge.js +11 -3
- package/dist/scripts/run-harness.js +3 -1
- package/dist/scripts/setup-bootstrap.js +43 -6
- package/dist/src/core/allocation-ledger.js +4 -3
- package/dist/src/core/host-identity.d.ts +2 -0
- package/dist/src/core/host-identity.js +11 -0
- package/dist/src/core/index.d.ts +4 -2
- package/dist/src/core/index.js +12 -4
- package/dist/src/core/mcp-service.js +2 -2
- package/dist/src/core/runtime-management.d.ts +6 -0
- package/dist/src/core/runtime-management.js +24 -0
- package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
- package/dist/src/core/sandbox/executor-driver.js +12 -14
- package/dist/src/core/sandbox/local-executor.d.ts +13 -1
- package/dist/src/core/sandbox/local-executor.js +69 -19
- package/dist/src/core/sandbox/local-worker.js +32 -21
- package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
- package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
- package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
- package/dist/src/core/sandbox/sandbox-connection.js +14 -6
- package/dist/src/core/service-live-state.d.ts +14 -0
- package/dist/src/core/service-live-state.js +161 -0
- package/dist/src/core/service-observation-types.d.ts +21 -1
- package/dist/src/core/service-process.d.ts +1 -1
- package/dist/src/core/service-process.js +45 -4
- package/dist/src/core/service-types.d.ts +5 -1
- package/dist/src/core/services.d.ts +1 -1
- package/dist/src/core/services.js +8 -3
- package/dist/src/core/types.d.ts +3 -0
- package/dist/src/core/worker-image.js +3 -3
- package/dist/src/harness/harness-session-types.d.ts +10 -0
- package/dist/src/harness/harness-session.js +42 -5
- package/dist/src/harness/project-harness.d.ts +13 -1
- package/dist/src/harness/project-harness.js +36 -10
- package/dist/src/harness/project-input.js +81 -15
- package/dist/src/harness/project-rpc-client.d.ts +1 -0
- package/dist/src/harness/project-rpc-client.js +5 -0
- package/dist/src/harness/project-rpc.d.ts +8 -2
- package/dist/src/harness/project-rpc.js +31 -7
- package/dist/src/harness/project-runtime.js +3 -1
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +41 -0
- package/dist/src/trace-viewer/public/app.js +6 -5
- package/dist/src/trace-viewer/reader.mjs +42 -2
- package/docs/INDEX.md +3 -1
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-agent-core.md +1 -1
- package/docs/architecture/06-observability-experiments.md +1 -1
- package/docs/architecture/07-run-configuration.md +18 -12
- package/docs/architecture/08-prompts.md +22 -0
- package/docs/architecture/10-service-api-reference.md +53 -18
- package/docs/architecture/11-storage-reference.md +18 -1
- package/docs/architecture/12-code-coverage.md +148 -84
- package/docs/architecture/15-core-runtime.md +8 -0
- package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/19-substrate-harness.md +28 -1
- package/docs/architecture/20-lead-worker-harness.md +34 -1
- package/docs/architecture/22-website.md +5 -3
- package/docs/architecture/23-project-harness.md +124 -5
- package/docs/architecture/24-runtime-recovery.md +10 -3
- package/docs/architecture/25-foreground-tui.md +51 -0
- package/docs/architecture/26-code.md +39 -0
- package/docs/architecture/27-personal.md +43 -0
- package/docs/architecture/28-autoresearch.md +31 -0
- package/docs/architecture/INDEX.md +4 -0
- package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
- package/docs/architecture/prompts/08-subagents-harness.md +21 -0
- package/docs/architecture/prompts/21-personal.md +44 -0
- package/docs/architecture/prompts/22-autoresearch.md +63 -0
- package/docs/architecture/prompts/26-code.md +55 -0
- package/docs/architecture/prompts/source-manifest.json +152 -33
- package/docs/architecture/source-map.json +489 -21
- package/docs/designs/core-harness/06-project-harness.md +13 -2
- package/docs/designs/core-harness/README.md +5 -0
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +3 -5
- package/docs/en/changelog.md +13 -4
- package/docs/en/first-harness.md +8 -11
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +12 -123
- package/docs/en/overview.md +1 -1
- package/docs/en/quickstart.md +40 -16
- package/docs/en/reference/api.md +14 -4
- package/docs/en/reference/cli.md +58 -14
- package/docs/en/runtime.md +2 -2
- package/docs/en/services.md +4 -0
- package/docs/third-party-notices.md +1 -0
- package/docs/workflows/development.md +17 -12
- package/docs/workflows/release-and-docs-versioning.md +76 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +3 -5
- package/docs/zh/changelog.md +13 -4
- package/docs/zh/first-harness.md +8 -11
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +13 -124
- package/docs/zh/overview.md +1 -1
- package/docs/zh/quickstart.md +40 -16
- package/docs/zh/reference/api.md +14 -4
- package/docs/zh/reference/cli.md +58 -14
- package/docs/zh/runtime.md +2 -2
- package/docs/zh/services.md +4 -0
- package/examples/README.md +24 -12
- package/examples/authoring/README.md +24 -0
- package/examples/authoring/business.ts +4 -0
- package/examples/authoring/config.ts +2 -0
- package/examples/authoring/eject.json +5 -0
- package/examples/authoring/harness.ts +21 -0
- package/examples/autoresearch/README.md +33 -0
- package/examples/autoresearch/REQUIREMENTS.zh.md +18 -0
- package/examples/autoresearch/config.ts +90 -0
- package/examples/autoresearch/demo.ts +55 -0
- package/examples/autoresearch/eject.json +15 -0
- package/examples/autoresearch/frontiercs2.ts +237 -0
- package/examples/autoresearch/prepare.ts +267 -0
- package/examples/autoresearch/process.ts +50 -0
- package/examples/autoresearch/project.ts +397 -0
- package/examples/autoresearch/research-service.ts +302 -0
- package/examples/code/README.md +25 -0
- package/examples/code/REQUIREMENTS.zh.md +11 -0
- package/examples/code/candidate.ts +89 -0
- package/examples/code/config.ts +19 -0
- package/examples/code/eject.json +5 -0
- package/examples/code/project.ts +581 -0
- package/examples/code/prompts.ts +16 -0
- package/examples/code/verification.ts +239 -0
- package/examples/code/worktree.ts +188 -0
- package/examples/harness-session/README.md +3 -6
- package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
- package/examples/lead-worker/harness/index.ts +61 -6
- package/examples/lead-worker/project.ts +2 -2
- package/examples/lead-worker/services/board.ts +14 -1
- package/examples/messages/README.md +5 -5
- package/examples/messages/handoff.ts +6 -2
- package/examples/messages/project.ts +47 -2
- package/examples/notes/README.md +13 -18
- package/examples/notes/project.ts +57 -9
- package/examples/peermesh/harness/router.ts +2 -2
- package/examples/peermesh/harness/team.ts +11 -0
- package/examples/peermesh/project.ts +19 -4
- package/examples/services/agent-control/README.md +3 -3
- package/examples/services/mathlib-search/Dockerfile +4 -2
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +2 -2
- package/examples/services/persistent-board/README.md +13 -3
- package/examples/services/persistent-board/business.ts +10 -0
- package/examples/services/persistent-board/index.ts +10 -0
- package/examples/services/persistent-board/live.ts +54 -0
- package/examples/subagents/README.md +5 -5
- package/examples/subagents/business.ts +3 -1
- package/examples/subagents/harness/controller.ts +161 -29
- package/examples/subagents/project.ts +47 -33
- package/examples/subagents/prompts/prompts.ts +4 -0
- package/examples/subagents/services/collaboration-service.ts +14 -2
- package/examples/substrate/README.md +2 -2
- package/examples/substrate/harness/index.ts +67 -11
- package/examples/substrate/project.ts +5 -1
- package/examples/super/README.md +40 -0
- package/examples/super/actions.ts +196 -0
- package/examples/super/artifact.ts +56 -0
- package/examples/super/config.ts +95 -0
- package/examples/super/coordinator.ts +158 -0
- package/examples/super/daemon.ts +84 -0
- package/examples/super/decisions.ts +46 -0
- package/examples/super/eject.json +5 -0
- package/examples/super/execution.ts +131 -0
- package/examples/super/github.ts +242 -0
- package/examples/super/inbox.ts +306 -0
- package/examples/super/location.ts +54 -0
- package/examples/super/outbox.ts +97 -0
- package/examples/super/project.ts +227 -0
- package/examples/super/prompts.ts +27 -0
- package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/examples/taskpool/harness/controller.ts +59 -7
- package/examples/taskpool/project.ts +18 -2
- package/npm-shrinkwrap.development.json +2199 -0
- package/npm-shrinkwrap.json +86 -1920
- package/package.development.json +92 -0
- package/package.json +13 -7
- package/scripts/anyswarm-applications.ts +39 -0
- package/scripts/anyswarm-arguments.ts +94 -28
- package/scripts/anyswarm-author.ts +25 -0
- package/scripts/anyswarm-eject.ts +145 -0
- package/scripts/anyswarm-harnesses.ts +27 -0
- package/scripts/anyswarm-installation.ts +19 -13
- package/scripts/anyswarm-launch.ts +108 -0
- package/scripts/anyswarm-project.ts +114 -21
- package/scripts/anyswarm-source-runner.ts +203 -0
- package/scripts/anyswarm-tui-config.ts +174 -0
- package/scripts/anyswarm-tui-session.ts +295 -0
- package/scripts/anyswarm-tui-terminal.ts +147 -0
- package/scripts/anyswarm-tui.ts +912 -0
- package/scripts/anyswarm.ts +43 -2
- package/scripts/build.ts +8 -1
- package/scripts/generate-architecture-api.ts +2 -0
- package/scripts/generate-architecture-prompts.ts +35 -2
- package/scripts/local-environment.ts +55 -17
- package/scripts/local-setup-smoke.ts +3 -2
- package/scripts/local-setup-worker.ts +17 -7
- package/scripts/local-setup.ts +66 -13
- package/scripts/opensandbox-agent-worker.ts +2 -2
- package/scripts/pack-release.ts +67 -0
- package/scripts/pi-session-bridge.ts +10 -2
- package/scripts/run-harness.ts +3 -1
- package/scripts/setup-bootstrap.ts +41 -6
- package/src/core/allocation-ledger.ts +5 -3
- package/src/core/host-identity.ts +11 -0
- package/src/core/index.ts +12 -6
- package/src/core/mcp-service.ts +2 -2
- package/src/core/runtime-management.ts +22 -0
- package/src/core/sandbox/executor-driver.ts +15 -18
- package/src/core/sandbox/local-executor.ts +65 -19
- package/src/core/sandbox/local-worker.ts +29 -21
- package/src/core/sandbox/opensandbox-backend.ts +36 -11
- package/src/core/sandbox/sandbox-connection.ts +14 -5
- package/src/core/service-live-state.ts +156 -0
- package/src/core/service-observation-types.ts +23 -1
- package/src/core/service-process.ts +36 -3
- package/src/core/service-types.ts +3 -1
- package/src/core/services.ts +8 -3
- package/src/core/types.ts +3 -0
- package/src/core/worker-image.ts +3 -3
- package/src/harness/harness-session-types.ts +13 -1
- package/src/harness/harness-session.ts +40 -7
- package/src/harness/project-harness.ts +36 -10
- package/src/harness/project-input.ts +73 -15
- package/src/harness/project-rpc-client.ts +5 -0
- package/src/harness/project-rpc.ts +29 -8
- package/src/harness/project-runtime.ts +2 -1
- package/src/harness/typescript-loader.ts +37 -0
- package/src/trace-viewer/public/app.js +6 -5
- package/src/trace-viewer/reader.mjs +42 -2
|
@@ -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, 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';
|
|
@@ -101,8 +101,9 @@ const phaseLabels = {
|
|
|
101
101
|
};
|
|
102
102
|
async function chooseBackend(command, saved, configured, signal) {
|
|
103
103
|
const explicit = command.command === 'setup' ? command.backend : undefined;
|
|
104
|
+
const version = command.command === 'setup' ? command.backendVersion : undefined;
|
|
104
105
|
if (command.command === 'setup' && command.backendPath && explicit)
|
|
105
|
-
return { kind: explicit, entry: resolve(command.backendPath) };
|
|
106
|
+
return { kind: explicit, entry: resolve(command.backendPath), version };
|
|
106
107
|
const preferred = explicit ?? (configured ? selectExecutorDriver(configured).kind : saved?.kind);
|
|
107
108
|
if (preferred && preferred !== 'pi' && preferred !== 'codex')
|
|
108
109
|
return;
|
|
@@ -110,6 +111,24 @@ async function chooseBackend(command, saved, configured, signal) {
|
|
|
110
111
|
return saved;
|
|
111
112
|
if (preferred) {
|
|
112
113
|
const kind = preferred;
|
|
114
|
+
if (version !== undefined) {
|
|
115
|
+
const matches = async (entry) => {
|
|
116
|
+
try {
|
|
117
|
+
await checkLocalExecutor({ kind, entry, version }, signal);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
signal.throwIfAborted();
|
|
122
|
+
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
123
|
+
throw error;
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
if (saved?.kind === kind && await matches(saved.entry))
|
|
128
|
+
return { kind, entry: saved.entry, version };
|
|
129
|
+
const entry = await findExecutorEntry(kind, matches) ?? await findExecutorEntry(kind);
|
|
130
|
+
return entry ? { kind, entry, version } : undefined;
|
|
131
|
+
}
|
|
113
132
|
const entry = await findExecutorEntry(kind);
|
|
114
133
|
return entry ? { kind, entry } : undefined;
|
|
115
134
|
}
|
|
@@ -174,7 +193,8 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
174
193
|
const config = command.configPath
|
|
175
194
|
? await loadAnySwarmConfig(command.configPath) : undefined;
|
|
176
195
|
const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR);
|
|
177
|
-
let executor =
|
|
196
|
+
let executor = command.command === 'setup' && command.backend
|
|
197
|
+
? { kind: command.backend, version: command.backendVersion } : configured;
|
|
178
198
|
const install = command.command === 'setup';
|
|
179
199
|
let localExecutor;
|
|
180
200
|
let driver;
|
|
@@ -196,10 +216,16 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
196
216
|
const smoke = install ? mode === 'local' : command.smoke;
|
|
197
217
|
if (command.command === 'setup' && command.backend && mode !== 'local') {
|
|
198
218
|
report.mode = mode;
|
|
199
|
-
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local
|
|
219
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
|
|
200
220
|
remedy: 'For an existing deployment, use its prepared Worker image.' });
|
|
201
221
|
return report;
|
|
202
222
|
}
|
|
223
|
+
if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
|
|
224
|
+
report.mode = mode;
|
|
225
|
+
checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
|
|
226
|
+
remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
|
|
227
|
+
return report;
|
|
228
|
+
}
|
|
203
229
|
if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
|
|
204
230
|
report.mode = mode;
|
|
205
231
|
checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
|
|
@@ -216,7 +242,9 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
216
242
|
});
|
|
217
243
|
return report;
|
|
218
244
|
}
|
|
219
|
-
|
|
245
|
+
if (driver.version !== undefined)
|
|
246
|
+
localExecutor = { ...localExecutor, version: driver.version };
|
|
247
|
+
executor = { kind: localExecutor.kind, version: localExecutor.version };
|
|
220
248
|
driver = selectExecutorDriver(executor);
|
|
221
249
|
}
|
|
222
250
|
if (!config && process.env.ANYSWARM_MODEL_URL) {
|
|
@@ -252,10 +280,22 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
252
280
|
if (checks.some(check => !check.ok))
|
|
253
281
|
return report;
|
|
254
282
|
report.configuration = {
|
|
255
|
-
executor: { id: driver.kind, version: driver.version, compatibleVersions: driver.compatibleVersions },
|
|
283
|
+
executor: { id: driver.kind, version: driver.version, compatibleVersions: driver.adapter?.compatibleVersions },
|
|
256
284
|
image: environment.image ?? workerImageFor(executor),
|
|
257
285
|
filePolicy: resolveFilePolicy(config?.filePolicy),
|
|
258
286
|
};
|
|
287
|
+
if (localExecutor && !smoke) {
|
|
288
|
+
try {
|
|
289
|
+
report.configuration.executor.version = await checkLocalExecutor(localExecutor, signal);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
signal.throwIfAborted();
|
|
293
|
+
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
294
|
+
throw error;
|
|
295
|
+
checks.push({ id: 'config.executor', ok: false, detail: error.message });
|
|
296
|
+
return report;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
259
299
|
const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
|
|
260
300
|
report.mode = mode;
|
|
261
301
|
report.lifecycleSource = environment.endpointSource;
|
|
@@ -269,11 +309,13 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
269
309
|
resolveWith: 'resolveSandboxConnection',
|
|
270
310
|
};
|
|
271
311
|
stage = 'host';
|
|
272
|
-
|
|
312
|
+
const darwin = process.platform === 'darwin';
|
|
313
|
+
checks.push(...checkSetupHost({ requiresLinux: !darwin }));
|
|
273
314
|
if (checks.some(check => !check.ok))
|
|
274
315
|
return report;
|
|
275
316
|
let advertiseHost = environment.advertiseHost;
|
|
276
|
-
|
|
317
|
+
let advertiseHostDiscovery = environment.advertiseHostDiscovery;
|
|
318
|
+
if (mode === 'local' && (smoke || darwin)) {
|
|
277
319
|
const docker = await timed('host', checkLocalDocker);
|
|
278
320
|
checks.push(docker.diagnostic);
|
|
279
321
|
if (!docker.docker)
|
|
@@ -300,8 +342,8 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
300
342
|
report.connection.image = worker.image.reference;
|
|
301
343
|
report.connection.sources.image = worker.source;
|
|
302
344
|
report.configuration.image = worker.image.reference;
|
|
303
|
-
if (
|
|
304
|
-
executor = { kind:
|
|
345
|
+
if (!driver.adapter && (worker.image.executor === 'pi' || worker.image.executor === 'codex')) {
|
|
346
|
+
executor = { kind: worker.image.executor, version: worker.image.version };
|
|
305
347
|
report.configuration.executor.version = worker.image.version;
|
|
306
348
|
}
|
|
307
349
|
progress?.(`Worker image source: ${worker.source}`);
|
|
@@ -319,6 +361,20 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
319
361
|
report.infrastructure = 'preflight-passed';
|
|
320
362
|
if (smoke) {
|
|
321
363
|
stage = 'smoke';
|
|
364
|
+
if (darwin && mode === 'local' && publicUrl === undefined &&
|
|
365
|
+
(advertiseHost === undefined || advertiseHostDiscovery === 'docker-network')) {
|
|
366
|
+
const discovered = await discoverMacCallback(image, signal);
|
|
367
|
+
if (!install && discovered !== advertiseHost) {
|
|
368
|
+
checks.push({ id: 'config.callback', ok: false, detail: 'The saved Runtime callback needs to be refreshed.',
|
|
369
|
+
remedy: 'Run anyswarm setup to save and verify the current Docker callback.' });
|
|
370
|
+
report.infrastructure = 'failed';
|
|
371
|
+
return report;
|
|
372
|
+
}
|
|
373
|
+
advertiseHost = discovered;
|
|
374
|
+
advertiseHostDiscovery = 'docker-network';
|
|
375
|
+
report.connection.advertiseHost = advertiseHost;
|
|
376
|
+
report.connection.sources.advertiseHost = 'docker-network';
|
|
377
|
+
}
|
|
322
378
|
report.smoke = await timed('smoke', () => runLocalSmoke({
|
|
323
379
|
...active, image, sandbox: config?.sandbox, connection: {
|
|
324
380
|
...config?.connection, publicUrl: environment.publicUrl,
|
|
@@ -336,7 +392,7 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
336
392
|
signal.throwIfAborted();
|
|
337
393
|
if (install) {
|
|
338
394
|
await saveSandboxConnection({ ...active, publicUrl: environment.publicUrl,
|
|
339
|
-
advertiseHost, image: environment.image, localExecutor,
|
|
395
|
+
advertiseHost, advertiseHostDiscovery, image: environment.image, localExecutor,
|
|
340
396
|
management: mode, providerId: provider?.id, preparedImage: report.worker?.id,
|
|
341
397
|
egressMode: mode === 'local' ? 'dns+nft' : environment.egressMode });
|
|
342
398
|
checks.push({ id: 'connection.saved', ok: true, detail: 'OpenSandbox connection saved in the owner-only user configuration.' });
|
|
@@ -354,7 +410,11 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
354
410
|
};
|
|
355
411
|
let [detail, remedy] = failure[stage];
|
|
356
412
|
const code = error?.code;
|
|
357
|
-
if (
|
|
413
|
+
if (code === 'DOCKER_CALLBACK_UNAVAILABLE') {
|
|
414
|
+
detail = 'The Docker container could not resolve a unique Mac callback IPv4 address.';
|
|
415
|
+
remedy = 'Check host.docker.internal from the selected local engine, or configure a Runtime publicUrl reachable from the Sandbox.';
|
|
416
|
+
}
|
|
417
|
+
else if (stage === 'provider' && ['PROVIDER_EXECD_PULL_FAILED', 'PROVIDER_SERVER_PULL_FAILED', 'PROVIDER_EGRESS_PULL_FAILED'].includes(code ?? '')) {
|
|
358
418
|
const execd = code === 'PROVIDER_EXECD_PULL_FAILED';
|
|
359
419
|
const egress = code === 'PROVIDER_EGRESS_PULL_FAILED';
|
|
360
420
|
detail = `Docker could not pull the pinned OpenSandbox ${execd ? 'Execd' : egress ? 'egress' : 'server'} image.`;
|
|
@@ -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,63 @@
|
|
|
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
|
+
const lock = JSON.parse(await readFile(lockPath, 'utf8'));
|
|
38
|
+
if (lock.lockfileVersion !== 3 || !lock.packages?.['']) {
|
|
39
|
+
throw new Error('Release packaging requires a v3 npm shrinkwrap with root package metadata');
|
|
40
|
+
}
|
|
41
|
+
// Only the service-image build stages use the development inputs.
|
|
42
|
+
await rename(manifestPath, join(staged, 'package.development.json'));
|
|
43
|
+
await rename(lockPath, join(staged, 'npm-shrinkwrap.development.json'));
|
|
44
|
+
delete manifest.private;
|
|
45
|
+
delete manifest.devDependencies;
|
|
46
|
+
delete lock.packages[''].devDependencies;
|
|
47
|
+
lock.packages = Object.fromEntries(Object.entries(lock.packages).filter(([, entry]) => !entry.dev));
|
|
48
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
49
|
+
await writeFile(lockPath, JSON.stringify(lock, null, 2) + '\n');
|
|
50
|
+
// npm records existing file modes, which can also depend on the checkout umask.
|
|
51
|
+
for (const entry of await readdir(staged, { recursive: true, withFileTypes: true })) {
|
|
52
|
+
if (!entry.isFile())
|
|
53
|
+
continue;
|
|
54
|
+
const path = join(entry.parentPath, entry.name);
|
|
55
|
+
const { mode } = await stat(path);
|
|
56
|
+
await chmod(path, mode & 0o111 ? 0o755 : 0o644);
|
|
57
|
+
}
|
|
58
|
+
await mkdir(output, { recursive: true });
|
|
59
|
+
console.log(join(output, await pack(staged, output)));
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await rm(temporary, { recursive: true, force: true });
|
|
63
|
+
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
let bootSession;
|
|
3
|
+
/** Cache only a verified UUID: a running Controller cannot survive a reboot. */
|
|
4
|
+
export function darwinBootSession() {
|
|
5
|
+
if (bootSession)
|
|
6
|
+
return bootSession;
|
|
7
|
+
const uuid = execFileSync('/usr/sbin/sysctl', ['-n', 'kern.bootsessionuuid'], { encoding: 'utf8', timeout: 2_000 }).trim();
|
|
8
|
+
if (!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(uuid))
|
|
9
|
+
throw new Error('Invalid Darwin boot session UUID');
|
|
10
|
+
return bootSession = `darwin:${uuid.toLowerCase()}`;
|
|
11
|
+
}
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { CreateRuntimeOptions, RecoverRuntimeOptions, Runtime } from './typ
|
|
|
2
2
|
export type * from './session-types.js';
|
|
3
3
|
export { createHarnessSession } from '../harness/project-harness.js';
|
|
4
4
|
export type { Harness, HarnessContext, HarnessInput, HarnessInputHandler, HarnessInputPreparation, HarnessJson, HarnessStatusInfo, ProjectHarness, ProjectHarnessContext, ProjectHarnessResult, } from '../harness/project-harness.js';
|
|
5
|
-
export type { HarnessAgentHandler, HarnessAgentReceipt, HarnessAgentRegistration, HarnessAgents, HarnessAnswer, HarnessAnswerReceipt, HarnessCapability, HarnessDescriptor, HarnessEvent, HarnessInputDescriptor, HarnessInputReceipt, HarnessLifetime, HarnessOperation, HarnessPhase, HarnessQuestion, HarnessQuestionKind, HarnessQuestionRequest, HarnessQuestionSource, HarnessRequest, HarnessDispatchRequest, HarnessResult, HarnessSession, HarnessSessionOptions, HarnessStartReceipt, HarnessState, HarnessStopReceipt, HarnessSubscriptionOptions, } from '../harness/harness-session-types.js';
|
|
5
|
+
export type { HarnessAgentHandler, HarnessAgentReceipt, HarnessAgentRegistration, HarnessAgents, HarnessAnswer, HarnessAnswerReceipt, HarnessCapability, HarnessDescriptor, HarnessEvent, HarnessInputDescriptor, HarnessInputReceipt, HarnessLifetime, HarnessOperation, HarnessPhase, HarnessQuestion, HarnessQuestionKind, HarnessQuestionRequest, HarnessQuestionSource, HarnessRequest, HarnessDispatchRequest, HarnessResult, HarnessSession, HarnessServices, HarnessSessionOptions, HarnessStartReceipt, HarnessState, HarnessStopReceipt, HarnessSubscriptionOptions, } from '../harness/harness-session-types.js';
|
|
6
6
|
export { ProjectPreflightError } from '../harness/project-input.js';
|
|
7
7
|
export { HarnessRpcClient } from '../harness/project-rpc-client.js';
|
|
8
|
+
export { runProjectRpc } from '../harness/project-rpc.js';
|
|
8
9
|
export type { HarnessRpcClientOptions, HarnessRpcReady, HarnessRpcTransport } from '../harness/project-rpc-client.js';
|
|
9
10
|
export { observeProjectRuntime, projectConfiguration, projectResult } from '../harness/project-runtime.js';
|
|
10
11
|
export { runInput, type RunInputResult } from '../harness/run-input.js';
|
|
@@ -16,6 +17,7 @@ export { httpClient } from '../harness/http.js';
|
|
|
16
17
|
export { checkGitProject, seedTeamRepository, seededCheckoutInstruction } from '../harness/project-git.js';
|
|
17
18
|
export { initializeGitRepository, importGitTree, commitGitTree, isGitTreePath } from '../harness/git-tree.js';
|
|
18
19
|
export { decodeFileSeed as decodeFileTree, snapshotFileSeed as snapshotFileTree, completeDigest as completeFileTreeDigest } from './files/core-file-seed.js';
|
|
20
|
+
export { resolveFilePolicy } from './file-policy.js';
|
|
19
21
|
export { AnySwarmError } from '../errors.js';
|
|
20
22
|
export { requestHttp } from '../protocol/http-request.js';
|
|
21
23
|
export { stableStringify } from '../protocol/stable-json.js';
|
|
@@ -28,7 +30,7 @@ export { DEFAULT_WORKER_IMAGE, workerImageFor } from './worker-image.js';
|
|
|
28
30
|
export { ServiceRegistry, serviceFromManifest, inProcessService, httpService, createInProcessAdapter, createHttpJsonAdapter, createServiceReplyAdapter } from './services.js';
|
|
29
31
|
export { mcpService } from './mcp-service.js';
|
|
30
32
|
export type { McpServiceOptions, McpHttpServiceOptions, McpStdioServiceOptions } from './mcp-service.js';
|
|
31
|
-
export type { ServiceStateMetadata, ServiceStatePresentation } from './service-observation-types.js';
|
|
33
|
+
export type { ServiceLiveState, ServiceStateMetadata, ServiceStatePresentation, ServiceStateRead, ServiceStateSource } from './service-observation-types.js';
|
|
32
34
|
export { managedProcessLifecycle } from './service-process.js';
|
|
33
35
|
export type { ManagedProcessOptions } from './service-process.js';
|
|
34
36
|
export type { ServiceLifecycle, ServiceLifecycleContext, ServiceStorage, ServiceResources } from './service-lifecycle-types.js';
|
package/dist/src/core/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { createRedactor, createRunRecords, runtimeConfiguration } from './run-re
|
|
|
20
20
|
import { createRuntimeManagement } from './runtime-management.js';
|
|
21
21
|
import { claimOpenSandboxBackend, openOpenSandboxBackend } from './sandbox/opensandbox-backend.js';
|
|
22
22
|
import { isOfficialWorkerImage, localWorkerSelector } from './worker-image.js';
|
|
23
|
-
import { selectExecutorDriver } from './sandbox/executor-driver.js';
|
|
23
|
+
import { legacyImageExecutorVersion, selectExecutorDriver } from './sandbox/executor-driver.js';
|
|
24
24
|
import { findExecutorEntry, executorFailure } from './sandbox/local-executor.js';
|
|
25
25
|
import { prepareLocalWorker, workerFailure } from './sandbox/local-worker.js';
|
|
26
26
|
import { loopbackLifecycle, resolveSandboxConnectionWithSources } from './sandbox/sandbox-connection.js';
|
|
@@ -30,6 +30,7 @@ import { registerServicePrivateValues, snapshotServiceRegistry } from './service
|
|
|
30
30
|
export { createHarnessSession } from '../harness/project-harness.js';
|
|
31
31
|
export { ProjectPreflightError } from '../harness/project-input.js';
|
|
32
32
|
export { HarnessRpcClient } from '../harness/project-rpc-client.js';
|
|
33
|
+
export { runProjectRpc } from '../harness/project-rpc.js';
|
|
33
34
|
export { observeProjectRuntime, projectConfiguration, projectResult } from '../harness/project-runtime.js';
|
|
34
35
|
export { runInput } from '../harness/run-input.js';
|
|
35
36
|
export { runWithReport } from '../harness/run-report.js';
|
|
@@ -40,6 +41,7 @@ export { httpClient } from '../harness/http.js';
|
|
|
40
41
|
export { checkGitProject, seedTeamRepository, seededCheckoutInstruction } from '../harness/project-git.js';
|
|
41
42
|
export { initializeGitRepository, importGitTree, commitGitTree, isGitTreePath } from '../harness/git-tree.js';
|
|
42
43
|
export { decodeFileSeed as decodeFileTree, snapshotFileSeed as snapshotFileTree, completeDigest as completeFileTreeDigest } from './files/core-file-seed.js';
|
|
44
|
+
export { resolveFilePolicy } from './file-policy.js';
|
|
43
45
|
export { AnySwarmError } from '../errors.js';
|
|
44
46
|
export { requestHttp } from '../protocol/http-request.js';
|
|
45
47
|
export { stableStringify } from '../protocol/stable-json.js';
|
|
@@ -137,7 +139,7 @@ function planRuntimeWorker(options, config, profiles, recoveryDirectory) {
|
|
|
137
139
|
const configuredEntry = options.localWorker?.backendPath
|
|
138
140
|
? resolve(options.localWorker.backendPath) : localExecutor?.kind === kind ? localExecutor.entry : undefined;
|
|
139
141
|
const requiredVersions = new Set(selectors.flatMap(selector => selector.version ? [selector.version] : []));
|
|
140
|
-
if (
|
|
142
|
+
if (config.driver.version !== undefined)
|
|
141
143
|
requiredVersions.add(config.driver.version);
|
|
142
144
|
if (requiredVersions.size > 1)
|
|
143
145
|
throw executorFailure('All local Worker selectors must match the selected installation version.');
|
|
@@ -147,7 +149,7 @@ function planRuntimeWorker(options, config, profiles, recoveryDirectory) {
|
|
|
147
149
|
const entry = configuredEntry ?? await findExecutorEntry(kind);
|
|
148
150
|
if (!entry)
|
|
149
151
|
throw executorFailure(`No local ${kind} executable was found. Install it with npm and run the CLI from this SDK package with setup --backend ${kind}.`);
|
|
150
|
-
return prepareLocalWorker({ kind, entry }, { progress, requiredVersion });
|
|
152
|
+
return prepareLocalWorker({ kind, entry }, { progress, requiredVersion: requiredVersion ?? (configuredEntry === localExecutor?.entry ? localExecutor?.version : undefined) });
|
|
151
153
|
} };
|
|
152
154
|
}
|
|
153
155
|
function freezeProfileWorker(profile, config, worker) {
|
|
@@ -244,6 +246,11 @@ async function assembleRuntime(options, recovery) {
|
|
|
244
246
|
for (const [id, profile] of profiles)
|
|
245
247
|
profiles.set(id, freezeProfileWorker(profile, config, localWorker));
|
|
246
248
|
}
|
|
249
|
+
else if (config.driver.version === undefined) {
|
|
250
|
+
const version = legacyImageExecutorVersion(config.driver.kind);
|
|
251
|
+
if (version !== undefined)
|
|
252
|
+
config = Object.freeze({ ...config, driver: selectExecutorDriver({ kind: config.driver.kind, version }) });
|
|
253
|
+
}
|
|
247
254
|
if (options.persistence) {
|
|
248
255
|
const { deploymentId, contract, retainForMs: duration = 900_000 } = options.persistence;
|
|
249
256
|
if (!validId(deploymentId) || !validId(contract) || !Number.isSafeInteger(duration) || duration < 300_000 || duration > 3_600_000 ||
|
|
@@ -259,7 +266,7 @@ async function assembleRuntime(options, recovery) {
|
|
|
259
266
|
}));
|
|
260
267
|
const fingerprintInput = { contract, connectionFingerprint, callback: config.callback, limits, retainForMs,
|
|
261
268
|
...(options.hooks?.beforeCompact ? { beforeCompactTimeoutMs: options.hooks.beforeCompact.timeoutMs ?? 10_000 } : {}),
|
|
262
|
-
models: modelConfig, modelGateway: config.modelGateway, executor: [config.driver.kind, config.driver.version],
|
|
269
|
+
models: modelConfig, modelGateway: config.modelGateway, executor: [config.driver.kind, config.driver.version ?? legacyImageExecutorVersion(config.driver.kind)],
|
|
263
270
|
profiles: Object.fromEntries(profiles), services: [...registrations.values()].map(registration => registration.manifest).sort((a, b) => a.id.localeCompare(b.id)),
|
|
264
271
|
files: config.filePolicy, requests: config.sandbox.resourceRequests, limitsSandbox: config.sandbox.resourceLimits };
|
|
265
272
|
const configFingerprint = fingerprint(fingerprintInput);
|
|
@@ -1312,6 +1319,7 @@ async function assembleRuntime(options, recovery) {
|
|
|
1312
1319
|
const wasClosing = closing;
|
|
1313
1320
|
durable(owner => owner.beginClose());
|
|
1314
1321
|
closing = true;
|
|
1322
|
+
management.cancelServiceStateReads();
|
|
1315
1323
|
if (!closeWork) {
|
|
1316
1324
|
for (const agent of agents.values())
|
|
1317
1325
|
revoke(agent.info.id);
|
|
@@ -64,11 +64,11 @@ function mcpEndpoint(options) {
|
|
|
64
64
|
} }),
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
if (process.platform
|
|
67
|
+
if (!['linux', 'darwin'].includes(process.platform) || !isAbsolute(options.command) ||
|
|
68
68
|
(options.args !== undefined && (!Array.isArray(options.args) || options.args.some(argument => typeof argument !== 'string'))) ||
|
|
69
69
|
(options.cwd !== undefined && !isAbsolute(options.cwd)) ||
|
|
70
70
|
(options.env !== undefined && Object.values(options.env).some(value => typeof value !== 'string'))) {
|
|
71
|
-
throw new AnySwarmError('INVALID_CONTRACT', 'Managed MCP stdio requires Linux, an absolute executable and typed argv/environment');
|
|
71
|
+
throw new AnySwarmError('INVALID_CONTRACT', 'Managed MCP stdio requires Linux or macOS, an absolute executable and typed argv/environment');
|
|
72
72
|
}
|
|
73
73
|
const parameters = { command: options.command, args: [...options.args ?? []], cwd: options.cwd,
|
|
74
74
|
env: Object.fromEntries(Object.entries(options.env ?? {}).sort(([a], [b]) => a.localeCompare(b))) };
|
|
@@ -38,6 +38,11 @@ export declare function createRuntimeManagement({ profiles, registrations, runti
|
|
|
38
38
|
register: (input: RuntimeServiceRegistration) => Promise<RuntimeServiceDefinition>;
|
|
39
39
|
get: (id: string) => RuntimeServiceDefinition | null;
|
|
40
40
|
list: () => RuntimeServiceDefinition[];
|
|
41
|
+
listState: () => {
|
|
42
|
+
name: string;
|
|
43
|
+
supported: boolean;
|
|
44
|
+
}[];
|
|
45
|
+
readState: (name: string) => Promise<import("./service-observation-types.js").ServiceStateRead>;
|
|
41
46
|
start: (input: ServiceRetirement) => Promise<RuntimeServiceDefinition>;
|
|
42
47
|
stop: (input: ServiceRetirement) => Promise<RuntimeServiceDefinition>;
|
|
43
48
|
restart: (input: ServiceRetirement) => Promise<RuntimeServiceDefinition>;
|
|
@@ -168,6 +173,7 @@ export declare function createRuntimeManagement({ profiles, registrations, runti
|
|
|
168
173
|
retireAll: (timeoutMs: number) => Promise<void>;
|
|
169
174
|
pendingServices: () => PendingCleanup[];
|
|
170
175
|
knowsService: (id: string) => boolean;
|
|
176
|
+
cancelServiceStateReads: () => void;
|
|
171
177
|
retiredExports: () => {
|
|
172
178
|
path?: string;
|
|
173
179
|
error?: ErrorInfo;
|