@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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anyswarm/core",
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"description": "Build and run custom multi-agent collaboration with isolated coding agents.",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/AnySwarm/anyswarm.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/AnySwarm/anyswarm/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://anyswarm.github.io/anyswarm/",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/src/core/index.d.ts",
|
|
22
|
+
"default": "./dist/src/core/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/src/",
|
|
27
|
+
"dist/scripts/",
|
|
28
|
+
"dist/deploy/",
|
|
29
|
+
"dist/examples/",
|
|
30
|
+
"dist/test-support/*.js",
|
|
31
|
+
"dist/test-support/subagents/",
|
|
32
|
+
"tsconfig.json",
|
|
33
|
+
".dockerignore",
|
|
34
|
+
"src/",
|
|
35
|
+
"scripts/",
|
|
36
|
+
"deploy/",
|
|
37
|
+
"examples/",
|
|
38
|
+
"!examples/**/__pycache__/**",
|
|
39
|
+
"docs/",
|
|
40
|
+
"test-support/*.ts",
|
|
41
|
+
"test-support/subagents/",
|
|
42
|
+
"AGENTS.md",
|
|
43
|
+
"GLOSSARY.md",
|
|
44
|
+
"npm-shrinkwrap.json",
|
|
45
|
+
"package.development.json",
|
|
46
|
+
"npm-shrinkwrap.development.json",
|
|
47
|
+
".env.example",
|
|
48
|
+
".gitmodules"
|
|
49
|
+
],
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22.19.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "node scripts/build.ts",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"prepack": "npm run build",
|
|
57
|
+
"pack:release": "node scripts/pack-release.ts",
|
|
58
|
+
"swarm": "node dist/scripts/swarm.js",
|
|
59
|
+
"test": "node --test --test-concurrency=1 'dist/test/**/*.test.js'",
|
|
60
|
+
"pretest": "npm run docs:check",
|
|
61
|
+
"test:focus": "node scripts/test-focused.ts",
|
|
62
|
+
"service:mathlib-search": "node dist/examples/services/mathlib-search/main.js",
|
|
63
|
+
"service:builtin": "node dist/examples/taskpool/deploy/service-hosts/start-service-host.js",
|
|
64
|
+
"docs:generate": "node dist/scripts/generate-architecture-prompts.js && node dist/scripts/generate-architecture-api.js && node dist/scripts/generate-architecture-coverage.js",
|
|
65
|
+
"docs:check": "node dist/scripts/check-architecture.js",
|
|
66
|
+
"predocs:generate": "npm run build",
|
|
67
|
+
"predocs:check": "npm run build"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@alibaba-group/opensandbox": "1.2.1",
|
|
71
|
+
"@earendil-works/pi-tui": "1.3.0",
|
|
72
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
73
|
+
"ajv": "8.20.0",
|
|
74
|
+
"es-module-lexer": "3.0.5",
|
|
75
|
+
"js-tiktoken": "1.0.21"
|
|
76
|
+
},
|
|
77
|
+
"overrides": {
|
|
78
|
+
"@modelcontextprotocol/client": {
|
|
79
|
+
"cross-spawn": "7.1.2"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"bin": {
|
|
83
|
+
"anyswarm": "dist/scripts/anyswarm.js",
|
|
84
|
+
"swarm": "dist/scripts/swarm.js",
|
|
85
|
+
"anys": "dist/scripts/anyswarm.js"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
89
|
+
"@types/node": "26.6.5",
|
|
90
|
+
"typescript": "^7.0.2"
|
|
91
|
+
}
|
|
92
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anyswarm/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"AGENTS.md",
|
|
42
42
|
"GLOSSARY.md",
|
|
43
43
|
"npm-shrinkwrap.json",
|
|
44
|
+
"package.development.json",
|
|
45
|
+
"npm-shrinkwrap.development.json",
|
|
44
46
|
".env.example",
|
|
45
47
|
".gitmodules"
|
|
46
48
|
],
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"build": "node scripts/build.ts",
|
|
52
54
|
"typecheck": "tsc --noEmit",
|
|
53
55
|
"prepack": "npm run build",
|
|
56
|
+
"pack:release": "node scripts/pack-release.ts",
|
|
54
57
|
"swarm": "node dist/scripts/swarm.js",
|
|
55
58
|
"test": "node --test --test-concurrency=1 'dist/test/**/*.test.js'",
|
|
56
59
|
"pretest": "npm run docs:check",
|
|
@@ -64,17 +67,20 @@
|
|
|
64
67
|
},
|
|
65
68
|
"dependencies": {
|
|
66
69
|
"@alibaba-group/opensandbox": "1.2.1",
|
|
70
|
+
"@earendil-works/pi-tui": "1.3.0",
|
|
67
71
|
"@modelcontextprotocol/client": "2.4.0",
|
|
68
72
|
"ajv": "8.20.0",
|
|
73
|
+
"es-module-lexer": "3.0.5",
|
|
69
74
|
"js-tiktoken": "1.0.21"
|
|
70
75
|
},
|
|
76
|
+
"overrides": {
|
|
77
|
+
"@modelcontextprotocol/client": {
|
|
78
|
+
"cross-spawn": "7.1.2"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
71
81
|
"bin": {
|
|
72
82
|
"anyswarm": "dist/scripts/anyswarm.js",
|
|
73
|
-
"swarm": "dist/scripts/swarm.js"
|
|
74
|
-
|
|
75
|
-
"devDependencies": {
|
|
76
|
-
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
77
|
-
"@types/node": "26.6.5",
|
|
78
|
-
"typescript": "^7.0.2"
|
|
83
|
+
"swarm": "dist/scripts/swarm.js",
|
|
84
|
+
"anys": "dist/scripts/anyswarm.js"
|
|
79
85
|
}
|
|
80
86
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import type { HarnessSession } from '../src/harness/project-harness.js';
|
|
3
|
+
|
|
4
|
+
export interface ApplicationObservation {
|
|
5
|
+
session: HarnessSession;
|
|
6
|
+
/** Local records owned by the observed application. */
|
|
7
|
+
traceRoot?: string;
|
|
8
|
+
/** Disconnects the observer while the application retains background ownership. */
|
|
9
|
+
close(): void | Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface ApplicationDescriptor {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
harness: string;
|
|
15
|
+
lifetime: 'task' | 'interactive';
|
|
16
|
+
available: boolean;
|
|
17
|
+
}
|
|
18
|
+
const applications = [
|
|
19
|
+
{ id: 'code', title: 'Code', lifetime: 'interactive' },
|
|
20
|
+
{ id: 'autoresearch', title: 'AutoResearch', lifetime: 'task' },
|
|
21
|
+
{ id: 'super', title: 'Personal', lifetime: 'interactive' },
|
|
22
|
+
] as const;
|
|
23
|
+
|
|
24
|
+
export function applicationDescriptors(): readonly ApplicationDescriptor[] {
|
|
25
|
+
return applications.map(application => {
|
|
26
|
+
const entry = new URL(`../examples/${application.id}/project.js`, import.meta.url);
|
|
27
|
+
return { ...application, harness: entry.href, available: existsSync(entry) };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function findApplication(id: string): ApplicationDescriptor | undefined {
|
|
32
|
+
return applicationDescriptors().find(application => application.id === id);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const applicationAliases = applications.map(application => application.id);
|
|
36
|
+
|
|
37
|
+
export function preferredTerminalLifetime(id: string) {
|
|
38
|
+
return findApplication(id)?.lifetime ?? (id === 'subagents' ? 'interactive' : undefined);
|
|
39
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
2
|
|
|
3
3
|
export const setupUsage = [
|
|
4
|
-
'Usage: anyswarm setup [--mode existing|local] [--endpoint <url>] [--public-url <url>] [--backend pi|codex] [--backend-path <executable>] [--config <module>]',
|
|
4
|
+
'Usage: anyswarm setup [--mode existing|local] [--endpoint <url>] [--public-url <url>] [--backend pi|codex] [--backend-path <executable>] [--backend-version <version>] [--config <module>]',
|
|
5
5
|
'Without --mode, reuse a saved managed local service or a configured connection. With no connection, prepare local OpenSandbox.',
|
|
6
6
|
'Existing mode saves the authenticated connection. Run anyswarm doctor --smoke to verify Worker and Runtime callbacks.',
|
|
7
7
|
].join('\n');
|
|
@@ -15,70 +15,135 @@ const projectUsage = [
|
|
|
15
15
|
'Usage: anyswarm --harness <module> --prompt <text> [--cwd <directory>] [--config <module>] [--output-dir <directory>] [--lifetime task|interactive] [--interaction none|questions]',
|
|
16
16
|
' anyswarm --harness <module> --mode rpc [--config <module>] [--output-dir <directory>] [--lifetime task|interactive] [--interaction none|questions]',
|
|
17
17
|
'Built-in Harnesses: subagents, taskpool, peermesh, substrate, lead-worker, notes, messages',
|
|
18
|
-
'Use a built-in name, an explicit
|
|
18
|
+
'Use a built-in name, an explicit TypeScript or ESM file, or a package installed from the invocation directory.',
|
|
19
19
|
'An explicit interactive lifetime or questions in foreground mode uses JSONL for subsequent commands.',
|
|
20
20
|
'The project directory defaults to the invocation directory. In RPC mode send cwd and prompt in the run request.',
|
|
21
21
|
].join('\n');
|
|
22
22
|
export const anyswarmUsage = [
|
|
23
|
-
'Usage: anyswarm
|
|
23
|
+
'Usage: anyswarm | anys Open the streaming TUI',
|
|
24
|
+
'Usage: anys -u <harness> [prompt] [--headless | --rpc]',
|
|
25
|
+
' anys -u <harness> --cmd "/action [arguments]"',
|
|
26
|
+
'Harness options: --config <module>, --cwd <directory>, --output-dir <directory>, --lifetime task|interactive',
|
|
27
|
+
' anys run <harness> [prompt] Local source files can also accept script arguments',
|
|
28
|
+
'Usage: anys eject <application> --dir <directory>',
|
|
24
29
|
'Usage: anyswarm --version',
|
|
25
30
|
projectUsage, setupUsage, updateUsage, doctorUsage, recoverUsage,
|
|
26
31
|
'Usage: anyswarm trace --root <runs-dir> [--port 8787] [--open]',
|
|
27
32
|
].join('\n');
|
|
28
33
|
|
|
29
34
|
export type LocalCommand =
|
|
30
|
-
| { command: 'setup'; mode?: 'existing' | 'local'; endpoint?: string; publicUrl?: string; configPath?: string; backend?: 'pi' | 'codex'; backendPath?: string }
|
|
35
|
+
| { command: 'setup'; mode?: 'existing' | 'local'; endpoint?: string; publicUrl?: string; configPath?: string; backend?: 'pi' | 'codex'; backendPath?: string; backendVersion?: string }
|
|
31
36
|
| { command: 'doctor'; configPath?: string; smoke: boolean };
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
command: 'harness';
|
|
38
|
+
type HarnessOptions = {
|
|
35
39
|
harness: string;
|
|
36
40
|
configPath?: string;
|
|
37
41
|
outputRoot?: string;
|
|
38
42
|
lifetime?: 'task' | 'interactive';
|
|
39
43
|
interaction?: 'none' | 'questions';
|
|
40
|
-
}
|
|
44
|
+
};
|
|
41
45
|
|
|
42
|
-
type
|
|
46
|
+
export type ProjectCommand = HarnessOptions & { command: 'harness'; defaults?: boolean } &
|
|
47
|
+
({ mode: 'foreground' | 'headless'; cwd?: string; prompt: string } | { mode: 'rpc' });
|
|
48
|
+
export type TuiCommand = Partial<HarnessOptions> & { command: 'tui'; cwd?: string; prompt?: string };
|
|
49
|
+
export type HarnessCommand = HarnessOptions & { command: 'use'; cwd?: string; prompt?: string } &
|
|
50
|
+
({ mode: 'auto' | 'tui' | 'headless' | 'foreground' | 'rpc' } | { mode: 'action'; slash: string });
|
|
43
51
|
|
|
44
|
-
|
|
52
|
+
type AnySwarmCommand = TuiCommand | HarnessCommand | { command: 'run'; entryPath: string; args: string[] } |
|
|
53
|
+
{ command: 'eject'; application: string; directory: string } | LocalCommand |
|
|
54
|
+
{ command: 'update'; archive?: string; sha256?: string } | ProjectCommand | { command: 'recover'; directory: string; configPath: string };
|
|
55
|
+
|
|
56
|
+
export function isLocalHarness(specifier: string) {
|
|
57
|
+
return specifier.startsWith('./') || specifier.startsWith('../') || specifier.startsWith('/');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isHarnessName(specifier: string) {
|
|
61
|
+
return /^(?:@[a-z0-9_.-]+\/)?[a-z0-9][a-z0-9_.-]*$/i.test(specifier);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function parseHarnessOptions(args: string[], allowPositionals: boolean) {
|
|
65
|
+
const { values, positionals } = parseArgs({ args, allowPositionals, options: {
|
|
66
|
+
use: { type: 'string', short: 'u' }, harness: { type: 'string' }, prompt: { type: 'string' },
|
|
67
|
+
cwd: { type: 'string' }, mode: { type: 'string' }, config: { type: 'string' }, 'output-dir': { type: 'string' },
|
|
68
|
+
lifetime: { type: 'string' }, interaction: { type: 'string' },
|
|
69
|
+
headless: { type: 'boolean' }, rpc: { type: 'boolean' }, cmd: { type: 'string' },
|
|
70
|
+
} });
|
|
71
|
+
const { lifetime, interaction } = values;
|
|
72
|
+
if ([values.use, values.harness, values.cwd, values.config, values['output-dir']].includes('') ||
|
|
73
|
+
(lifetime !== undefined && lifetime !== 'task' && lifetime !== 'interactive') ||
|
|
74
|
+
(interaction !== undefined && interaction !== 'none' && interaction !== 'questions')) throw new Error();
|
|
75
|
+
return { values, positionals, options: { configPath: values.config, outputRoot: values['output-dir'], lifetime, interaction } as Omit<HarnessOptions, 'harness'> };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function parseHarnessSelection(args: string[], selected?: string): HarnessCommand {
|
|
79
|
+
const { values, positionals, options } = parseHarnessOptions(args, true);
|
|
80
|
+
const harness = selected ?? values.use;
|
|
81
|
+
if (!harness || values.harness !== undefined || (selected && values.use !== undefined) ||
|
|
82
|
+
(positionals.length && values.prompt !== undefined)) throw new Error(anyswarmUsage);
|
|
83
|
+
const prompt = values.prompt ?? (positionals.length ? positionals.join(' ') : undefined);
|
|
84
|
+
if (prompt !== undefined && !prompt.trim()) throw new Error(anyswarmUsage);
|
|
85
|
+
const project = { command: 'use' as const, harness, ...options, prompt, cwd: values.cwd };
|
|
86
|
+
if ([values.mode, values.headless, values.rpc, values.cmd].filter(value => value !== undefined).length > 1) throw new Error(anyswarmUsage);
|
|
87
|
+
const mode = values.mode ?? (values.headless ? 'headless' : values.rpc ? 'rpc' : 'auto');
|
|
88
|
+
if (values.cmd !== undefined) {
|
|
89
|
+
if (prompt !== undefined || !/^\/[a-z][\w-]*(?:\s|$)/i.test(values.cmd.trim())) throw new Error(anyswarmUsage);
|
|
90
|
+
return { ...project, mode: 'action', slash: values.cmd.trim() };
|
|
91
|
+
}
|
|
92
|
+
if (mode === 'rpc' && (prompt !== undefined || values.cwd !== undefined)) throw new Error(anyswarmUsage);
|
|
93
|
+
if (mode === 'auto' || mode === 'tui' || mode === 'headless' || mode === 'foreground' || mode === 'rpc') return { ...project, mode };
|
|
94
|
+
throw new Error(anyswarmUsage);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function parseAnySwarmCommand(args: string[], registered: Readonly<Record<string, string>> = {}): AnySwarmCommand | { help: string } {
|
|
45
98
|
const [command, ...options] = args;
|
|
46
|
-
if (command === undefined) return {
|
|
99
|
+
if (command === undefined) return { command: 'tui' };
|
|
47
100
|
if (command === '--help' && options.length === 0) return { help: anyswarmUsage };
|
|
48
|
-
const usages = { setup: setupUsage, update: updateUsage, doctor: doctorUsage, recover: recoverUsage };
|
|
101
|
+
const usages = { run: 'Usage: anys run <harness> [prompt or source arguments]', eject: 'Usage: anys eject <application> --dir <directory>', setup: setupUsage, update: updateUsage, doctor: doctorUsage, recover: recoverUsage };
|
|
49
102
|
const usage = Object.hasOwn(usages, command) ? usages[command as keyof typeof usages] : anyswarmUsage;
|
|
50
|
-
if (options.length === 1 && options[0] === '--help' &&
|
|
103
|
+
if (options.length === 1 && options[0] === '--help' && Object.hasOwn(usages, command)) return { help: usage };
|
|
51
104
|
try {
|
|
105
|
+
if (command === 'run') {
|
|
106
|
+
if (!options[0] || options[0].startsWith('-')) throw new Error();
|
|
107
|
+
return isLocalHarness(options[0]) || /^[^@]+\.(?:[cm]?[jt]s)$/.test(options[0])
|
|
108
|
+
? { command, entryPath: options[0], args: options.slice(1) }
|
|
109
|
+
: parseHarnessSelection(options.slice(1), options[0]);
|
|
110
|
+
}
|
|
111
|
+
if (command === 'eject') {
|
|
112
|
+
const { values, positionals } = parseArgs({ args: options, allowPositionals: true, options: { dir: { type: 'string' } } });
|
|
113
|
+
if (positionals.length === 1 && isHarnessName(positionals[0]) && !positionals[0].includes('/') && values.dir) {
|
|
114
|
+
return { command, application: positionals[0], directory: values.dir };
|
|
115
|
+
}
|
|
116
|
+
throw new Error();
|
|
117
|
+
}
|
|
118
|
+
if (command === '-u' || command.startsWith('-u=') || command === '--use' || command.startsWith('--use=')) {
|
|
119
|
+
return parseHarnessSelection(args);
|
|
120
|
+
}
|
|
52
121
|
if (command.startsWith('--')) {
|
|
53
|
-
const { values } =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if ((lifetime !== undefined && lifetime !== 'task' && lifetime !== 'interactive') ||
|
|
61
|
-
(interaction !== undefined && interaction !== 'none' && interaction !== 'questions')) throw new Error();
|
|
62
|
-
const project = { command: 'harness' as const, harness: values.harness, configPath: values.config,
|
|
63
|
-
outputRoot: values['output-dir'],
|
|
64
|
-
lifetime: lifetime as ProjectCommand['lifetime'], interaction: interaction as ProjectCommand['interaction'] };
|
|
122
|
+
const { values, options: selection } = parseHarnessOptions(args, false);
|
|
123
|
+
if (values.cmd !== undefined || values.headless !== undefined || values.rpc !== undefined || values.use !== undefined) throw new Error();
|
|
124
|
+
const project = { command: 'harness' as const, harness: values.harness!, ...selection };
|
|
125
|
+
if (values.mode === 'tui' || (values.mode === undefined && values.prompt === undefined)) {
|
|
126
|
+
return { ...project, command: 'tui', harness: values.harness, cwd: values.cwd, prompt: values.prompt };
|
|
127
|
+
}
|
|
128
|
+
if (!project.harness) throw new Error();
|
|
65
129
|
if (values.mode === 'rpc' && values.prompt === undefined && values.cwd === undefined) return { ...project, mode: 'rpc' };
|
|
66
|
-
if (values.mode === undefined
|
|
130
|
+
if ((values.mode === undefined || values.mode === 'foreground') && values.prompt?.trim()) {
|
|
67
131
|
return { ...project, mode: 'foreground', cwd: values.cwd, prompt: values.prompt };
|
|
68
132
|
}
|
|
69
133
|
}
|
|
70
134
|
if (command === 'setup') {
|
|
71
135
|
const { values } = parseArgs({ args: options, options: {
|
|
72
136
|
mode: { type: 'string' }, endpoint: { type: 'string' }, 'public-url': { type: 'string' }, config: { type: 'string' },
|
|
73
|
-
backend: { type: 'string' }, 'backend-path': { type: 'string' },
|
|
137
|
+
backend: { type: 'string' }, 'backend-path': { type: 'string' }, 'backend-version': { type: 'string' },
|
|
74
138
|
} });
|
|
75
139
|
const { backend, mode } = values;
|
|
76
140
|
if (values.config !== '' && values.endpoint !== '' && values['public-url'] !== '' &&
|
|
77
141
|
(mode === undefined || mode === 'existing' || mode === 'local') &&
|
|
78
142
|
(backend === undefined || backend === 'pi' || backend === 'codex') &&
|
|
79
|
-
(values['backend-path'] === undefined || (backend && values['backend-path']))
|
|
143
|
+
(values['backend-path'] === undefined || (backend && values['backend-path'])) &&
|
|
144
|
+
(values['backend-version'] === undefined || (backend && values['backend-version']))) {
|
|
80
145
|
return { command, mode, endpoint: values.endpoint, publicUrl: values['public-url'], configPath: values.config,
|
|
81
|
-
backend, backendPath: values['backend-path'] };
|
|
146
|
+
backend, backendPath: values['backend-path'], backendVersion: values['backend-version'] };
|
|
82
147
|
}
|
|
83
148
|
}
|
|
84
149
|
if (command === 'update') {
|
|
@@ -97,6 +162,7 @@ export function parseAnySwarmCommand(args: string[]): AnySwarmCommand | { help:
|
|
|
97
162
|
});
|
|
98
163
|
if (values.config !== '') return { command, configPath: values.config, smoke: values.smoke === true };
|
|
99
164
|
}
|
|
165
|
+
if (Object.hasOwn(registered, command)) return parseHarnessSelection(options, command);
|
|
100
166
|
} catch {
|
|
101
167
|
// Argument errors can contain untrusted input. Print only the command usage.
|
|
102
168
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { realpath } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
export async function runSourceCommand(command: { entryPath: string; args: readonly string[] }, cwd: string): Promise<number> {
|
|
7
|
+
const entry = await realpath(resolve(cwd, command.entryPath));
|
|
8
|
+
const runner = fileURLToPath(new URL('./anyswarm-source-runner.js', import.meta.url));
|
|
9
|
+
const child = spawn(process.execPath, ['--enable-source-maps', runner, entry, ...command.args], { cwd, stdio: 'inherit' });
|
|
10
|
+
const interrupt = () => { child.kill('SIGINT'); };
|
|
11
|
+
const terminate = () => { child.kill('SIGTERM'); };
|
|
12
|
+
process.on('SIGINT', interrupt);
|
|
13
|
+
process.on('SIGTERM', terminate);
|
|
14
|
+
try {
|
|
15
|
+
return await new Promise<number>((done, reject) => {
|
|
16
|
+
child.once('error', reject);
|
|
17
|
+
child.once('exit', (code, signal) => done(code ?? (signal === 'SIGINT' ? 130 : signal === 'SIGTERM' ? 143 : 1)));
|
|
18
|
+
});
|
|
19
|
+
} finally {
|
|
20
|
+
process.off('SIGINT', interrupt);
|
|
21
|
+
process.off('SIGTERM', terminate);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { ejectSourceCommand } from './anyswarm-eject.js';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { findPackageJSON } from 'node:module';
|
|
6
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
|
|
10
|
+
const execute = promisify(execFile);
|
|
11
|
+
const packageRoot = fileURLToPath(new URL('../..', import.meta.url));
|
|
12
|
+
const forbidden = /(?:^|\/)(?:\.env(?:\..*)?|node_modules|dist|runs?|experiments|\.git|\.anyswarm(?:-sdk)?)(?:\/|$)|\.(?:db|sqlite|sqlite3|log|ndjson|pem|key)$/i;
|
|
13
|
+
const reserved = new Set(['package.json', 'anyswarm-source.json']);
|
|
14
|
+
const packageSpecifier = /^(?:@[a-z0-9_.-]+\/)?[a-z0-9_.-]+$/;
|
|
15
|
+
|
|
16
|
+
function digestFiles(directory: string, files: readonly string[]) {
|
|
17
|
+
const hash = createHash('sha256');
|
|
18
|
+
for (const file of [...files].sort((left, right) => left.localeCompare(right, 'en'))) {
|
|
19
|
+
const data = readFileSync(join(directory, file));
|
|
20
|
+
hash.update(file).update('\0').update(String(data.length)).update('\0').update(data);
|
|
21
|
+
}
|
|
22
|
+
return hash.digest('hex');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function installationSource() {
|
|
26
|
+
const lock = await readFile(resolve(packageRoot, '../../.package-lock.json'), 'utf8').then(JSON.parse).catch(() => undefined);
|
|
27
|
+
const installed = lock?.packages?.['node_modules/@anyswarm/core'];
|
|
28
|
+
return { source: typeof installed?.resolved === 'string' ? installed.resolved : 'installed-package-content',
|
|
29
|
+
integrity: typeof installed?.integrity === 'string' ? installed.integrity : null };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Export an application's explicit source allowlist and its installed SDK identity. */
|
|
33
|
+
export async function ejectSourceCommand(command: { application: string; directory: string }, cwd: string) {
|
|
34
|
+
if (!/^[a-z0-9][a-z0-9_.-]*$/i.test(command.application)) throw new TypeError('Expected a bundled application name');
|
|
35
|
+
const application = command.application === 'example' ? 'authoring' : command.application;
|
|
36
|
+
const sourceRoot = join(packageRoot, 'examples', application);
|
|
37
|
+
const manifest = await readFile(join(sourceRoot, 'eject.json'), 'utf8').then(JSON.parse).catch(error => {
|
|
38
|
+
if (error.code === 'ENOENT') throw new Error(`The ${command.application} application has no source export in this package. Install a package containing its application manifest.`);
|
|
39
|
+
throw error;
|
|
40
|
+
});
|
|
41
|
+
if (manifest.apiVersion !== 1 || typeof manifest.entry !== 'string' ||
|
|
42
|
+
!/^(?:[\w.-]+\/)*[\w.-]+\.(?:ts|mts)$/.test(manifest.entry) ||
|
|
43
|
+
!Array.isArray(manifest.files) || !manifest.files.includes(manifest.entry)) {
|
|
44
|
+
throw new TypeError('Application source manifest requires apiVersion 1, an entry, and an explicit files list containing the entry');
|
|
45
|
+
}
|
|
46
|
+
const dependencies: unknown = manifest.dependencies ?? {};
|
|
47
|
+
if (!dependencies || typeof dependencies !== 'object' || Array.isArray(dependencies) ||
|
|
48
|
+
Object.entries(dependencies).some(([name, version]) =>
|
|
49
|
+
name === '@anyswarm/core' || !packageSpecifier.test(name) || typeof version !== 'string' || !version.trim())) {
|
|
50
|
+
throw new TypeError('Application source dependencies must be package specs. The SDK source is supplied by eject.');
|
|
51
|
+
}
|
|
52
|
+
const target = resolve(cwd, command.directory);
|
|
53
|
+
const targetInfo = await lstat(target).catch(error => { if (error.code === 'ENOENT') return null; throw error; });
|
|
54
|
+
if (targetInfo && (!targetInfo.isDirectory() || (await readdir(target)).length)) throw new Error('The export target must be an empty directory');
|
|
55
|
+
await mkdir(dirname(target), { recursive: true });
|
|
56
|
+
const staging = await mkdtemp(join(dirname(target), `.${basename(target)}-eject-`));
|
|
57
|
+
try {
|
|
58
|
+
for (const file of manifest.files) {
|
|
59
|
+
if (typeof file !== 'string' || !file || isAbsolute(file) || file.includes('\\') || file.split('/').some(part => part === '..' || part === '.' || !part) || reserved.has(file) || forbidden.test(file)) {
|
|
60
|
+
throw new TypeError('Application source manifest contains an unsafe or private path');
|
|
61
|
+
}
|
|
62
|
+
const source = join(sourceRoot, file);
|
|
63
|
+
const info = await lstat(source);
|
|
64
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new TypeError('Application source exports must be regular files');
|
|
65
|
+
// Each parent must also be a directory rather than a symlink to private state.
|
|
66
|
+
let parent = dirname(source);
|
|
67
|
+
while (parent !== sourceRoot) {
|
|
68
|
+
if ((await lstat(parent)).isSymbolicLink()) throw new TypeError('Application source exports cannot traverse symlinks');
|
|
69
|
+
parent = dirname(parent);
|
|
70
|
+
}
|
|
71
|
+
await mkdir(dirname(join(staging, file)), { recursive: true });
|
|
72
|
+
await cp(source, join(staging, file), { errorOnExist: true, force: false });
|
|
73
|
+
}
|
|
74
|
+
const sdkDirectory = join(staging, '.anyswarm-sdk');
|
|
75
|
+
await mkdir(sdkDirectory);
|
|
76
|
+
const packed = await execute('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', sdkDirectory], {
|
|
77
|
+
cwd: packageRoot, timeout: 60_000, maxBuffer: 4 * 1024 * 1024,
|
|
78
|
+
});
|
|
79
|
+
const packedPackage = JSON.parse(packed.stdout)[0];
|
|
80
|
+
if (packedPackage.files.some((file: { path: string }) => file.path !== '.env.example' &&
|
|
81
|
+
/(?:^|\/)(?:\.env(?:\..*)?|runs|experiments|[^/]+-runs)(?:\/|$)|\.(?:db|sqlite|sqlite3|pem|key|ndjson|jsonl)$/i.test(file.path))) {
|
|
82
|
+
throw new Error('The installed SDK package contains private or runtime files and cannot be exported');
|
|
83
|
+
}
|
|
84
|
+
const archive = join(sdkDirectory, packedPackage.filename);
|
|
85
|
+
const archiveSha256 = createHash('sha256').update(await readFile(archive)).digest('hex');
|
|
86
|
+
await rename(archive, join(sdkDirectory, 'core.tgz'));
|
|
87
|
+
const sdk = JSON.parse(await readFile(join(packageRoot, 'package.json'), 'utf8'));
|
|
88
|
+
const source = await readFile(join(packageRoot, 'dist/scripts/build-provenance.json'), 'utf8').then(JSON.parse).catch(() => null);
|
|
89
|
+
const files: string[] = packedPackage.files.map((file: { path: string }) => file.path);
|
|
90
|
+
const provenance = { schema: 2, application: command.application, source,
|
|
91
|
+
sdk: { name: sdk.name, version: sdk.version, ...await installationSource(),
|
|
92
|
+
archiveSha256, content: { sha256: digestFiles(packageRoot, files), files } } };
|
|
93
|
+
await writeFile(join(staging, 'anyswarm-source.json'), JSON.stringify(provenance, null, 2) + '\n');
|
|
94
|
+
await writeFile(join(staging, 'package.json'), JSON.stringify({ name: `anyswarm-${command.application}-source`, private: true,
|
|
95
|
+
scripts: { start: `anys run ./${manifest.entry}` }, dependencies: { ...dependencies, '@anyswarm/core': 'file:./.anyswarm-sdk/core.tgz' },
|
|
96
|
+
}, null, 2) + '\n');
|
|
97
|
+
if (targetInfo) await rmdir(target);
|
|
98
|
+
await rename(staging, target);
|
|
99
|
+
return { directory: target, entryPath: join(target, manifest.entry), provenancePath: join(target, 'anyswarm-source.json') };
|
|
100
|
+
} finally {
|
|
101
|
+
await rm(staging, { recursive: true, force: true });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Verify the executing host and return a guard for SDK resolutions inside a source export. */
|
|
106
|
+
export async function verifyExportedSdk(entry: string) {
|
|
107
|
+
let directory = dirname(entry);
|
|
108
|
+
for (;;) {
|
|
109
|
+
const manifest = await readFile(join(directory, 'anyswarm-source.json'), 'utf8').then(JSON.parse).catch(error => {
|
|
110
|
+
if (error.code === 'ENOENT') return undefined;
|
|
111
|
+
throw error;
|
|
112
|
+
});
|
|
113
|
+
if (manifest) {
|
|
114
|
+
const content = manifest.schema === 1 ? { sha256: manifest.sdk?.contentSha256, files: manifest.sdk?.files } :
|
|
115
|
+
manifest.schema === 2 ? manifest.sdk?.content : undefined;
|
|
116
|
+
const files = content?.files;
|
|
117
|
+
if (typeof content?.sha256 !== 'string' || !/^[a-f0-9]{64}$/.test(content.sha256) ||
|
|
118
|
+
!Array.isArray(files) || !files.length || files.some(file => typeof file !== 'string' || !file || isAbsolute(file) ||
|
|
119
|
+
file.includes('\\') || file.split('/').some(part => !part || part === '.' || part === '..'))) {
|
|
120
|
+
throw new Error('Invalid exported SDK provenance');
|
|
121
|
+
}
|
|
122
|
+
const mismatch = () => new Error('The source export requires its recorded SDK candidate. Run npm install in the exported directory and start it with npm run start.');
|
|
123
|
+
const checked = new Set<string>();
|
|
124
|
+
const verifyRoot = (root: string) => {
|
|
125
|
+
if (checked.has(root)) return;
|
|
126
|
+
let digest: string;
|
|
127
|
+
try { digest = digestFiles(root, files); } catch { throw mismatch(); }
|
|
128
|
+
if (digest !== content.sha256) throw mismatch();
|
|
129
|
+
checked.add(root);
|
|
130
|
+
};
|
|
131
|
+
verifyRoot(resolve(packageRoot));
|
|
132
|
+
return (url: string) => {
|
|
133
|
+
let manifestPath: string | undefined;
|
|
134
|
+
try { if (url.startsWith('file:')) manifestPath = findPackageJSON(url); } catch { throw mismatch(); }
|
|
135
|
+
if (!manifestPath) throw mismatch();
|
|
136
|
+
const root = dirname(manifestPath);
|
|
137
|
+
if (!files.includes(relative(root, fileURLToPath(url)).split(sep).join('/'))) throw mismatch();
|
|
138
|
+
verifyRoot(root);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const parent = dirname(directory);
|
|
142
|
+
if (parent === directory) return;
|
|
143
|
+
directory = parent;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { applicationDescriptors, findApplication } from './anyswarm-applications.js';
|
|
3
|
+
export const builtins: Record<string, string> = {
|
|
4
|
+
...Object.fromEntries(applicationDescriptors().map(app => [app.id, app.harness])),
|
|
5
|
+
'lead-worker': new URL('../examples/lead-worker/project.js', import.meta.url).href,
|
|
6
|
+
peermesh: new URL('../examples/peermesh/project.js', import.meta.url).href,
|
|
7
|
+
notes: new URL('../examples/notes/project.js', import.meta.url).href,
|
|
8
|
+
messages: new URL('../examples/messages/project.js', import.meta.url).href,
|
|
9
|
+
taskpool: new URL('../examples/taskpool/project.js', import.meta.url).href,
|
|
10
|
+
substrate: new URL('../examples/substrate/project.js', import.meta.url).href,
|
|
11
|
+
subagents: new URL('../examples/subagents/project.js', import.meta.url).href,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function builtinConfiguration(name: string) {
|
|
15
|
+
if (name === 'messages') return (await import('../examples/messages/handoff-config.js')).handoffConfig();
|
|
16
|
+
if (name === 'peermesh') return (await import('../examples/peermesh/project-config.js')).peerMeshConfig();
|
|
17
|
+
if (name === 'substrate') return (await import('../examples/substrate/project-config.js')).substrateConfiguration();
|
|
18
|
+
if (name === 'lead-worker') return {
|
|
19
|
+
...(await import('../examples/lead-worker/project-config.js')).leadWorkerConfig(),
|
|
20
|
+
team: process.env.ANYSWARM_LEAD_WORKER_TEAM,
|
|
21
|
+
checkingImage: process.env.ANYSWARM_LEAD_WORKER_CHECKING_IMAGE,
|
|
22
|
+
};
|
|
23
|
+
const path = new URL('../examples/' + name + '/config.js', import.meta.url);
|
|
24
|
+
if (findApplication(name) && !existsSync(path)) return undefined;
|
|
25
|
+
path.search = 'launcher=' + Date.now();
|
|
26
|
+
return (await import(path.href)).default;
|
|
27
|
+
}
|
|
@@ -13,7 +13,7 @@ const previousPackageNames = ['@anyswarm/anyswarm', '@luna-shi/anyswarm'];
|
|
|
13
13
|
const packageRoot = resolve(fileURLToPath(new URL('../..', import.meta.url)));
|
|
14
14
|
const releaseRoot = 'https://github.com/AnySwarm/anyswarm/releases/download';
|
|
15
15
|
const stableVersion = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
16
|
-
const bins = ['anyswarm', 'swarm'] as const;
|
|
16
|
+
const bins = ['anyswarm', 'anys', 'swarm'] as const;
|
|
17
17
|
const installDirectory = (prefix: string) => join(prefix, 'lib', 'anyswarm');
|
|
18
18
|
const installedPackage = (stage: string) => join(stage, 'node_modules', packageName);
|
|
19
19
|
const installBin = (prefix: string, name: typeof bins[number]) => join(prefix, 'bin', name);
|
|
@@ -66,7 +66,10 @@ function binTarget(prefix: string, name: typeof bins[number]) {
|
|
|
66
66
|
async function lockActivation<T>(prefix: string, action: () => Promise<T>, signal?: AbortSignal) {
|
|
67
67
|
signal?.throwIfAborted();
|
|
68
68
|
const lock = join(installDirectory(prefix), 'activation-flock');
|
|
69
|
-
const
|
|
69
|
+
const darwin = process.platform === 'darwin';
|
|
70
|
+
// Keep the inode stable so waiting and newly arriving processes lock the same file.
|
|
71
|
+
const flags = darwin ? ['-k', '-t', '15'] : ['--exclusive', '--timeout', '15'];
|
|
72
|
+
const child = spawn(darwin ? '/usr/bin/lockf' : 'flock', [...flags, lock, process.execPath, '-e',
|
|
70
73
|
'console.log("locked"); process.stdin.resume()'], { stdio: ['pipe', 'pipe', 'ignore'] });
|
|
71
74
|
child.stdin.on('error', () => {});
|
|
72
75
|
const cancelled = () => child.kill();
|
|
@@ -91,19 +94,19 @@ async function activate(prefix: string, stage: string, source: string, sha256: s
|
|
|
91
94
|
const root = installedPackage(stage);
|
|
92
95
|
const { name, version } = await manifest(root);
|
|
93
96
|
if (name !== packageName || !stableVersion.test(version)) throw new Error('The archive does not contain a stable AnySwarm distribution.');
|
|
94
|
-
|
|
95
|
-
signal, timeout: 10_000, env: { ...process.env, NODE_OPTIONS: '' },
|
|
96
|
-
});
|
|
97
|
-
if (stdout.trim() !== version) throw new Error('The staged CLI did not report the package version.');
|
|
98
|
-
await writeFile(join(stage, 'install.json'), JSON.stringify({ schema: 1, prefix, version, source, sha256 } satisfies Installation), { mode: 0o600 });
|
|
99
|
-
await mkdir(join(prefix, 'bin'), { recursive: true });
|
|
100
|
-
for (const bin of bins) {
|
|
97
|
+
for (const bin of ['anyswarm', 'swarm']) {
|
|
101
98
|
const path = join(stage, 'node_modules', '.bin', bin);
|
|
102
99
|
if (await realpath(path) !== join(root, 'dist', 'scripts', `${bin}.js`)) {
|
|
103
100
|
throw new Error(`The staged ${bin} entry does not belong to the package.`);
|
|
104
101
|
}
|
|
105
102
|
await access(path, constants.X_OK);
|
|
106
103
|
}
|
|
104
|
+
const { stdout } = await execute(join(stage, 'node_modules', '.bin', 'anyswarm'), ['--version'], {
|
|
105
|
+
signal, timeout: 10_000, env: { ...process.env, NODE_OPTIONS: '' },
|
|
106
|
+
});
|
|
107
|
+
if (stdout.trim() !== version) throw new Error('The staged CLI did not report the package version.');
|
|
108
|
+
await writeFile(join(stage, 'install.json'), JSON.stringify({ schema: 1, prefix, version, source, sha256 } satisfies Installation), { mode: 0o600 });
|
|
109
|
+
await mkdir(join(prefix, 'bin'), { recursive: true });
|
|
107
110
|
return lockActivation(prefix, async () => {
|
|
108
111
|
const changed: { path: string; previous?: string }[] = [];
|
|
109
112
|
try {
|
|
@@ -113,12 +116,15 @@ async function activate(prefix: string, stage: string, source: string, sha256: s
|
|
|
113
116
|
}
|
|
114
117
|
for (const bin of bins) {
|
|
115
118
|
const path = installBin(prefix, bin);
|
|
116
|
-
const
|
|
119
|
+
const host = bin === 'anys' ? 'anyswarm' : bin;
|
|
120
|
+
const target = binTarget(prefix, host);
|
|
117
121
|
const previous = await inspectLink(path);
|
|
118
122
|
if (previous === target) continue;
|
|
119
123
|
const npmTargets = [packageName, ...previousPackageNames].map(name =>
|
|
120
|
-
join(prefix, 'lib', 'node_modules', name, 'dist', 'scripts', `${
|
|
121
|
-
|
|
124
|
+
join(prefix, 'lib', 'node_modules', name, 'dist', 'scripts', `${host}.js`));
|
|
125
|
+
const legacyAlias = bin === 'anys' && previous === binTarget(prefix, 'anys') && oldCurrent &&
|
|
126
|
+
dirname(resolve(installDirectory(prefix), oldCurrent)) === join(installDirectory(prefix), 'versions');
|
|
127
|
+
if (previous && !legacyAlias && !npmTargets.includes(resolve(dirname(path), previous))) {
|
|
122
128
|
throw new Error(`The link at ${path} belongs to another installation.`);
|
|
123
129
|
}
|
|
124
130
|
await replaceLink(path, target);
|
|
@@ -222,7 +228,7 @@ export async function updateAnySwarm(
|
|
|
222
228
|
if (npmPrefix) return {
|
|
223
229
|
ok: false, before, after: before, path: invocation, packageRoot, source: 'npm global',
|
|
224
230
|
result: 'preserved', environment: 'separate',
|
|
225
|
-
detail: `
|
|
231
|
+
detail: `This CLI was installed with npm. Update it with \`npm install -g --prefix ${quoted(npmPrefix)} ${packageName}@latest\`.`,
|
|
226
232
|
};
|
|
227
233
|
return {
|
|
228
234
|
ok: false, before, path: invocation, packageRoot, source: 'other',
|