@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
|
@@ -68,6 +68,7 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
68
68
|
const profile = dynamic ? member?.profile : state.team && roles.find((name: any) => state.team[name] === caller.agentId);
|
|
69
69
|
const role: 'lead' | 'helper' = (dynamic ? member?.role : profile) === 'lead' ? 'lead' : 'helper';
|
|
70
70
|
if (!profile || dynamic && !member.ready || state.runtimeId !== caller.runtimeId || caller.profile !== profile || caller.binding !== `${runId}:board` || !permissions[role].includes(operation)) throw error('NOT_ALLOWED');
|
|
71
|
+
if (state.userInterventions?.[caller.agentId]?.kind === 'stop' && !['read', 'list_subtasks'].includes(operation)) throw error('MEMBER_STOPPED');
|
|
71
72
|
if ((memoryFenced || state.fenced) && !['read', 'list_subtasks'].includes(operation)) throw error('BOARD_FENCED');
|
|
72
73
|
return role;
|
|
73
74
|
}
|
|
@@ -85,7 +86,7 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
85
86
|
}
|
|
86
87
|
const registration: any = { manifest: { id: 'board', title: 'Lead-Worker Board', purpose: 'Durable direction, exclusive ownership and verified delivery', provider_version: 'lead-worker-board-1', contract_version: '2', endpoint: { transport: 'in-process' },
|
|
87
88
|
capabilities: Object.entries(capabilities as Record<string, any>).map(([operation, input_schema]: any) => ({ name: operation, operation, description: `Public Board ${operation}`, help: { when: 'Read direction before claiming or completing work; never reclaim an owner' }, side_effect: ['read', 'list_subtasks'].includes(operation) ? 'read' : 'write', idempotent: true, input_schema,
|
|
88
|
-
output_schema: { type: 'object', additionalProperties: true }, errors: ['NOT_ALLOWED', 'CONFLICT', 'NOT_FOUND', 'BOARD_FENCED', 'BOARD_LIMIT', 'FEEDBACK_NOT_READ', 'DIRECTION_NOT_READ', 'DELIVERY_INVALID'].map((code: any) => ({ code, retryable: false })) })) },
|
|
89
|
+
output_schema: { type: 'object', additionalProperties: true }, errors: ['NOT_ALLOWED', 'CONFLICT', 'NOT_FOUND', 'BOARD_FENCED', 'BOARD_LIMIT', 'FEEDBACK_NOT_READ', 'DIRECTION_NOT_READ', 'DELIVERY_INVALID', 'MEMBER_STOPPED'].map((code: any) => ({ code, retryable: false })) })) },
|
|
89
90
|
adapter: { async invoke({ capability, input, envelope, caller, signal, assertAuthorized }: any) {
|
|
90
91
|
const operation = capability.operation; const state = load(); const role = authorize(state, caller, operation);
|
|
91
92
|
if (signal?.aborted) throw error('BOARD_FENCED');
|
|
@@ -180,6 +181,18 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
180
181
|
event(state, 'member_ready', agentId, { profile: member.profile, requestId: member.requestId });
|
|
181
182
|
});
|
|
182
183
|
},
|
|
184
|
+
interveneMember({ agentId, kind, requestId }: { agentId: string; kind: 'interrupt' | 'stop'; requestId: string }) {
|
|
185
|
+
transaction((state: any) => {
|
|
186
|
+
if (!state.team || !Object.values(state.team).includes(agentId)) throw error('NOT_ALLOWED');
|
|
187
|
+
state.userInterventions ??= {};
|
|
188
|
+
const previous = state.userInterventions[agentId];
|
|
189
|
+
if (previous?.kind === 'stop') return;
|
|
190
|
+
const intervention = { kind, requestId };
|
|
191
|
+
state.userInterventions[agentId] = intervention;
|
|
192
|
+
for (const task of state.subtasks) if (task.owner === agentId && task.state !== 'complete') task.intervention = intervention;
|
|
193
|
+
event(state, 'user_control', agentId, intervention);
|
|
194
|
+
});
|
|
195
|
+
},
|
|
183
196
|
subscribe(listener: () => void) { listeners.add(listener); return () => listeners.delete(listener); },
|
|
184
197
|
registerUserInput(requestId: any, input: any) { transaction((state: any) => { if (state.fenced || typeof requestId !== 'string' || !/^[A-Za-z0-9_.:-]{1,128}$/.test(requestId) || typeof input !== 'string' || Buffer.byteLength(input) > 16384 || state.userInputs.length >= 5 || state.userInputs.some((row: any) => row.requestId === requestId)) throw error('NOT_ALLOWED'); state.userInputs.push({ requestId, sha256: createHash('sha256').update(input).digest('hex') }); }); },
|
|
185
198
|
fence({ agentId, code, execution = 'unknown' }: any = {}) { memoryFenced = true; transaction((state: any) => { state.fenced = true; if (agentId) { const failure: any = { code: /^[A-Za-z0-9_:-]{1,80}$/.test(code ?? '') ? code : 'AGENT_FAILED', execution: execution === 'stopped' ? 'stopped' : 'unknown' }; state.failures ??= {}; state.failures[agentId] = failure; for (const row of state.subtasks) if (row.owner === agentId && row.state !== 'complete') row.failure = failure; if (state.history.length < 512) event(state, 'failure', agentId, failure); } }); },
|
|
@@ -36,13 +36,13 @@ directory and returns its report path; `--output-dir` chooses another location.
|
|
|
36
36
|
|
|
37
37
|
## Install and build matching sources
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Run these commands in an empty directory. To use a source build, set
|
|
40
|
+
`ANYSWARM_SDK_ARCHIVE` to the absolute path of its verified archive. Copy the
|
|
41
|
+
example sources from the SDK you installed.
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
44
|
npm init -y
|
|
45
|
-
npm install --ignore-scripts "$ANYSWARM_SDK_ARCHIVE"
|
|
45
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
|
|
46
46
|
npm install --save-dev typescript @types/node
|
|
47
47
|
cp -R node_modules/@anyswarm/core/examples/messages demo
|
|
48
48
|
cd demo
|
|
@@ -116,7 +116,7 @@ The external Service remains running after the Harness closes.
|
|
|
116
116
|
|
|
117
117
|
[`project.ts`](project.ts) consumes the user's directory and prompt.
|
|
118
118
|
[`handoff.ts`](handoff.ts) is a separate fixed-payload diagnostic, invoked from
|
|
119
|
-
the checkout root with `
|
|
119
|
+
the checkout root with `anys run ./examples/messages/handoff.ts`. It seeds a
|
|
120
120
|
value in the writer's files, then compares the reader's exported `received.txt`
|
|
121
121
|
byte for byte. Its report goes under `handoff-runs/` unless `ANYSWARM_SDK_OUTPUT`
|
|
122
122
|
overrides it. The common project runner has its own input and report handling.
|
|
@@ -16,7 +16,7 @@ export async function runMessageHandoff(
|
|
|
16
16
|
config: HandoffConfig,
|
|
17
17
|
abort: AbortSignal,
|
|
18
18
|
onEvent: (event: RuntimeEvent) => void = () => {},
|
|
19
|
-
project?: { files: FileTree; prompt: string; artifact: string; ready(): void; observe(runtime: Runtime): () => void; progress?(state: unknown): void },
|
|
19
|
+
project?: { files: FileTree; prompt: string; artifact: string; ready(): void; observe(runtime: Runtime): () => void; progress?(state: unknown): void; inputSignal?(agentId: string): AbortSignal; assertMember?(agentId: string): void },
|
|
20
20
|
) {
|
|
21
21
|
abort.throwIfAborted();
|
|
22
22
|
const signal = AbortSignal.any([abort, AbortSignal.timeout(config.workTimeoutMs)]);
|
|
@@ -89,9 +89,12 @@ export async function runMessageHandoff(
|
|
|
89
89
|
submissions.push(submission);
|
|
90
90
|
project?.progress?.({ stage: operation, key, agentId, operationId, requestId });
|
|
91
91
|
try {
|
|
92
|
-
const
|
|
92
|
+
const local = project?.inputSignal?.(agentId);
|
|
93
|
+
const turn = await runInput(runtime, agentId, input, { requestId, signal: local ? AbortSignal.any([signal, local]) : signal,
|
|
94
|
+
timeoutMs: config.workTimeoutMs, beforeSend: () => project?.assertMember?.(agentId) });
|
|
93
95
|
submission.inputId = turn.inputId;
|
|
94
96
|
} catch (error) {
|
|
97
|
+
project?.assertMember?.(agentId);
|
|
95
98
|
const turn = error as { code?: string; inputId?: string };
|
|
96
99
|
submission.inputId = turn.inputId;
|
|
97
100
|
if (turn.code === 'agent_exited' || turn.code === 'agent_failed') throw failure('HANDOFF_EXECUTION_UNCONFIRMED');
|
|
@@ -101,6 +104,7 @@ export async function runMessageHandoff(
|
|
|
101
104
|
throw error;
|
|
102
105
|
}
|
|
103
106
|
signal.throwIfAborted();
|
|
107
|
+
project?.assertMember?.(agentId);
|
|
104
108
|
const call = calls.get(callKey(agentId, operation, operationId));
|
|
105
109
|
if (!call || (operation === 'put' ? call.author !== agentId : call.text !== writtenText)) throw failure('HANDOFF_SERVICE_UNCONFIRMED');
|
|
106
110
|
return call.text;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { observeProjectRuntime, projectConfiguration, ProjectPreflightError, type Harness } from '@anyswarm/core';
|
|
1
|
+
import { AnySwarmError, getExecutorCapabilities, observeProjectRuntime, projectConfiguration, ProjectPreflightError, type Harness, type SendOptions } from '@anyswarm/core';
|
|
2
2
|
import { runMessageHandoff } from './handoff.js';
|
|
3
3
|
import { handoffConfig, type HandoffConfig } from './handoff-config.js';
|
|
4
4
|
|
|
@@ -11,6 +11,12 @@ const messages = {
|
|
|
11
11
|
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Messages requires finite work and cleanup time limits');
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
const interventions: { agentId: string; operation: string; requestId: string }[] = [];
|
|
15
|
+
const blocked = new Set<string>();
|
|
16
|
+
const waits = new Map<string, AbortController>();
|
|
17
|
+
const assertMember = (agentId: string) => {
|
|
18
|
+
if (blocked.has(agentId)) throw new AnySwarmError('MEMBER_WORK_CANCELLED', 'The owner intervened in this member’s work');
|
|
19
|
+
};
|
|
14
20
|
let business: unknown = { stage: 'put' };
|
|
15
21
|
let observation: ReturnType<typeof observeProjectRuntime> | undefined;
|
|
16
22
|
const { report, submissions } = await runMessageHandoff({ ...config, outputDir: context.outputDir },
|
|
@@ -18,9 +24,48 @@ const messages = {
|
|
|
18
24
|
files: context.initial.files, prompt: context.input.prompt,
|
|
19
25
|
artifact: `anyswarm-message-${context.runId}.txt`, ready: context.markRunning,
|
|
20
26
|
observe(runtime) {
|
|
21
|
-
|
|
27
|
+
const native = getExecutorCapabilities(config.executor ?? 'pi');
|
|
28
|
+
const controlEffects = (core: unknown) => ({ core, harnessEffects: { memberWork: 'cancelled', status: 'complete' } });
|
|
29
|
+
const intervene = async (operation: 'interrupt' | 'stop', agentId: string, requestId: string) => {
|
|
30
|
+
blocked.add(agentId);
|
|
31
|
+
interventions.push({ agentId, operation, requestId });
|
|
32
|
+
context.emit({ kind: 'user-intervention', agentId, operation, requestId });
|
|
33
|
+
void observation?.refresh();
|
|
34
|
+
try {
|
|
35
|
+
const core = operation === 'interrupt' ? await runtime.interrupt(agentId, { requestId })
|
|
36
|
+
: await runtime.stop(agentId, { timeoutMs: config.cleanupTimeoutMs });
|
|
37
|
+
return controlEffects(core);
|
|
38
|
+
} finally { waits.get(agentId)?.abort(); }
|
|
39
|
+
};
|
|
40
|
+
observation = observeProjectRuntime(runtime, context, () => Object.assign({}, business, { interventions }), {
|
|
41
|
+
capabilities: {
|
|
42
|
+
send: { supported: native.activeSteer, text: true, modes: ['steer'] },
|
|
43
|
+
interrupt: { supported: native.queuedInputCancellation }, stop: { supported: true },
|
|
44
|
+
},
|
|
45
|
+
handlers: {
|
|
46
|
+
send(agentId, payload, request) {
|
|
47
|
+
assertMember(agentId);
|
|
48
|
+
const { input, options } = payload as { input: string; options: SendOptions };
|
|
49
|
+
return runtime.send(agentId, input, { ...options, mode: 'steer', wakeIfIdle: false, requestId: request.operationId });
|
|
50
|
+
},
|
|
51
|
+
interrupt: (agentId, _payload, request) => intervene('interrupt', agentId, request.operationId),
|
|
52
|
+
stop: (agentId, _payload, request) => intervene('stop', agentId, request.operationId),
|
|
53
|
+
},
|
|
54
|
+
async reconcile(operation, agentId, request) {
|
|
55
|
+
if (operation === 'stop') return controlEffects(await runtime.stop(agentId, { timeoutMs: config.cleanupTimeoutMs }));
|
|
56
|
+
const core = await observation!.reconcile(agentId, operation, request.operationId);
|
|
57
|
+
return operation === 'interrupt' ? controlEffects(core) : core;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
22
60
|
return observation.close;
|
|
23
61
|
},
|
|
62
|
+
inputSignal(agentId) {
|
|
63
|
+
assertMember(agentId);
|
|
64
|
+
const wait = new AbortController();
|
|
65
|
+
waits.set(agentId, wait);
|
|
66
|
+
return wait.signal;
|
|
67
|
+
},
|
|
68
|
+
assertMember,
|
|
24
69
|
progress(state) {
|
|
25
70
|
business = state;
|
|
26
71
|
void observation?.refresh();
|
package/examples/notes/README.md
CHANGED
|
@@ -9,12 +9,12 @@ anyswarm --harness notes --prompt "Inspect this project and explain how to verif
|
|
|
9
9
|
|
|
10
10
|
The writer and reader use the same captured project to publish and use a task observation. The reader exports an artifact that includes the retrieved note.
|
|
11
11
|
|
|
12
|
-
After installing the
|
|
12
|
+
After installing the SDK, configure the model route, compatible Worker image and other runtime resources described below. A JavaScript config can also be supplied with `--config`. The common command saves its outputs outside the input directory by default.
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
The host imports only from `@anyswarm/core` for Runtime, Sandbox and Service author APIs. See the [Runtime guide](../../docs/en/runtime.md) for configuration and resource ownership.
|
|
16
16
|
|
|
17
|
-
Install a release using [Quickstart](../../docs/en/quickstart.md), or build a checkout tarball. Install checkout dependencies with `npm ci --ignore-scripts` first.
|
|
17
|
+
Install a release using [Quickstart](../../docs/en/quickstart.md), or build a checkout tarball. Install checkout dependencies with `npm ci --ignore-scripts` first. Use `npm run pack:release -- /path/to/output-directory` to build and pack the candidate.
|
|
18
18
|
|
|
19
19
|
Two independent Agents hand off one supplied source fact through a custom Notes Service. The writer publishes the exact seeded text using `swarm notes put --input note-request.json --request-id notes-put`. The host seeds this request with a string `text` field containing `review-input.json`; passing that JSON text through `--text` would coerce it to an object and fail schema validation. The reader checks it and saves `review.md`, then copies that file to `followup.md` in a second turn. The host checks the Service author and read record and opens both files from the archive after stopping the reader.
|
|
20
20
|
|
|
@@ -28,51 +28,46 @@ from your prompt. Both use the same custom Notes Service.
|
|
|
28
28
|
|
|
29
29
|
## Install and configure
|
|
30
30
|
|
|
31
|
-
This example requires Node.js 22.19 or newer, an authenticated OpenSandbox service reachable from the Controller, and a compatible worker image containing the selected executor. The repository Worker image ships Pi 1.3.0 and Codex CLI 0.172.0.
|
|
31
|
+
This example requires Node.js 22.19 or newer, an authenticated OpenSandbox service reachable from the Controller, and a compatible worker image containing the selected executor. The repository Worker image ships Pi 1.3.0 and Codex CLI 0.172.0. Run these commands in an empty directory. To use a source build, set `ANYSWARM_SDK_ARCHIVE` to the absolute path of its verified archive.
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
repo=/absolute/path/to/anyswarm
|
|
35
|
-
example_dir=$(mktemp -d)
|
|
36
|
-
archive=$(npm pack "$repo" --pack-destination "$example_dir" --silent)
|
|
37
|
-
cd "$example_dir"
|
|
38
34
|
npm init -y
|
|
39
|
-
npm
|
|
40
|
-
|
|
41
|
-
example=node_modules/@anyswarm/core/dist/examples/notes
|
|
35
|
+
npm install --omit=dev --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
|
|
36
|
+
example=node_modules/@anyswarm/core/examples/notes
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
Set `ANYSWARM_NOTES_IMAGE` to your compatible worker image ID and `ANYSWARM_NOTES_MODEL_URL` to the trusted Responses endpoint, including the exact `/v1/responses` path. Set `ANYSWARM_NOTES_MODEL_TOKEN` if the endpoint requires a bearer token. Configure `ANYSWARM_NOTES_ADVERTISE_HOST` to the host's guest-reachable IPv4 address if it differs from `172.17.0.1`. The sample `config.
|
|
39
|
+
Set `ANYSWARM_NOTES_IMAGE` to your compatible worker image ID and `ANYSWARM_NOTES_MODEL_URL` to the trusted Responses endpoint, including the exact `/v1/responses` path. Set `ANYSWARM_NOTES_MODEL_TOKEN` if the endpoint requires a bearer token. Configure `ANYSWARM_NOTES_ADVERTISE_HOST` to the host's guest-reachable IPv4 address if it differs from `172.17.0.1`. The sample `config.ts` also reads optional lifecycle host, endpoint host and token variables. Model and lifecycle secrets stay on the host.
|
|
45
40
|
|
|
46
41
|
The sample uses Pi and the configured common model route by default (`openai` / `gpt-5.4` when model labels are omitted). Common `ANYSWARM_MODEL_*` and `ANYSWARM_EXECUTOR` variables take precedence over scoped Notes variables. To run Codex, set `ANYSWARM_NOTES_EXECUTOR=codex` and `ANYSWARM_NOTES_MODEL_ID` to the model served by your endpoint. `ANYSWARM_NOTES_MODEL_PROVIDER` labels the model and defaults to `openai` for Codex. For a custom configuration module, set `executor` and its `models` mapping. The same Reader thread handles both reader inputs. See the [backend guide](../../docs/architecture/16-pi-opensandbox-backend.md#codex-app-server) for the credential and trace contract.
|
|
47
42
|
|
|
48
43
|
```sh
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
node_modules/.bin/anys run "$example/main.ts" --help
|
|
45
|
+
node_modules/.bin/anys run "$example/main.ts" "$example/config.ts" > notes-result.json
|
|
51
46
|
```
|
|
52
47
|
|
|
53
|
-
`main.
|
|
48
|
+
`main.ts` imports Runtime, Service Registry and the configurable OpenSandbox backend from the public package exports. `run-input.ts`, `run-report.ts` and `read-result.ts` are editable host modules. The Harness owns the turn order, the Notes manifest and adapter, the role grants and verification. It uses `followUp` on an idle Agent after subscribing, with one input source and a fresh ID. An unknown or queued submission remains explicit and sends no replacement.
|
|
54
49
|
|
|
55
50
|
## Run and inspect the handoff
|
|
56
51
|
|
|
57
|
-
The example runs one fixed writer turn and two reader turns, then closes. The seeded `fact` is its project input. The host exclusively owns these inputs and their request IDs. To change a later reader turn, edit its input in `main.
|
|
52
|
+
The example runs one fixed writer turn and two reader turns, then closes. The seeded `fact` is its project input. The host exclusively owns these inputs and their request IDs. To change a later reader turn, edit its input in `main.ts` before starting a new run. The example accepts no interactive directed input while the handoff is in progress. Ctrl+C or SIGTERM ends the current business wait and then enters the configured bounded cleanup. Check the returned per-Agent execution and cleanup receipts after either signal.
|
|
58
53
|
|
|
59
54
|
Read the final CLI report from `notes-result.json`. It contains the Runtime identity and saved report location, including when the command returned a business or cleanup failure. The shell commands below select that same identity and inspect its saved receipts.
|
|
60
55
|
|
|
61
56
|
```sh
|
|
62
57
|
runtime_id=$(node -e 'const fs=require("node:fs"); console.log(JSON.parse(fs.readFileSync("notes-result.json","utf8")).runtimeId)')
|
|
63
58
|
run_dir=$(node -e 'const fs=require("node:fs"),path=require("node:path"); console.log(path.dirname(JSON.parse(fs.readFileSync("notes-result.json","utf8")).reportPath))')
|
|
64
|
-
|
|
59
|
+
node_modules/.bin/anys run "$example/main.ts" --result "$run_dir" --runtime-id "$runtime_id"
|
|
65
60
|
```
|
|
66
61
|
|
|
67
62
|
Result inspection reads `harness-report.json` and `runtime.json`, checks both recorded identities, and projects business failure, recorded Core status, per-Agent execution/cleanup, pending count and artifact availability. It reports the Harness result's location without printing its content or interpreting business acceptance. Open the indicated Harness report's `result.verifiedFiles` and reader archive to inspect the actual checked deliverables. A pending receipt remains pending even if another recorded receipt later reports complete. This command reads saved files and does not contact or control a running Runtime.
|
|
68
63
|
|
|
69
|
-
The running command exits 0 when its business function returned and cleanup and report save succeeded, and exits 1 when any of those failed. Result inspection exits 0 when both correctly identified reports were readable, including a recorded business failure, and exits 1 for missing, invalid, unreadable or foreign records. Invalid command arguments exit 2. Configuration import and startup failures emit a safe error code on stderr and exit 1. Run inspection with only its arguments; it does not load `config.
|
|
64
|
+
The running command exits 0 when its business function returned and cleanup and report save succeeded, and exits 1 when any of those failed. Result inspection exits 0 when both correctly identified reports were readable, including a recorded business failure, and exits 1 for missing, invalid, unreadable or foreign records. Invalid command arguments exit 2. Configuration import and startup failures emit a safe error code on stderr and exit 1. Run inspection with only its arguments; it does not load `config.ts` or require provider credentials.
|
|
70
65
|
|
|
71
66
|
With the default configuration, each fresh Runtime writes its own directory under `notes-runs`. Read `harness-report.json` for the business result, input receipts, Notes state, cleanup and any save failure. Core writes `runtime.json`, the ordered evidence file and, on successful collection, the reader's artifacts and manifest. A required collection failure can leave a sandbox and Slot pending. Inspect the reported Agent/provider identity and original error. Handle pending ownership in the same host process if embedding the example. The one-shot CLI has no cross-process recovery command.
|
|
72
67
|
|
|
73
68
|
## Change the collaboration
|
|
74
69
|
|
|
75
|
-
To use a different source observation, set `fact` in `config.
|
|
70
|
+
To use a different source observation, set `fact` in `config.ts` to an object with `baseline`, `source` and `finding`. Edit `createNotes` and its manifest to change the business Service and adjust Profile grants as needed. The example has no Mission, Task or Execution records. It demonstrates explicit Service handoff and continuity for one reader. Model quality and automated source review are outside its scope.
|
|
76
71
|
|
|
77
72
|
## Host assembly
|
|
78
73
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServiceRegistry, createRuntime, createSandbox, AnySwarmError, ProjectPreflightError, observeProjectRuntime, projectConfiguration,
|
|
2
|
-
runInput, type CreateRuntimeOptions, type Harness, type SandboxConfig } from '@anyswarm/core';
|
|
1
|
+
import { ServiceRegistry, createRuntime, getExecutorCapabilities, createSandbox, AnySwarmError, ProjectPreflightError, observeProjectRuntime, projectConfiguration,
|
|
2
|
+
runInput, type SendOptions, type CreateRuntimeOptions, type Harness, type SandboxConfig } from '@anyswarm/core';
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { createNotes } from './notes.js';
|
|
@@ -34,7 +34,13 @@ const notesHarness = {
|
|
|
34
34
|
services.register('notes', notes.service, { toolMode: 'cli' });
|
|
35
35
|
const common = { image, model, writable: true };
|
|
36
36
|
let observation: ReturnType<typeof observeProjectRuntime> | undefined;
|
|
37
|
-
const
|
|
37
|
+
const interventions: { agentId: string; operation: string; requestId: string }[] = [];
|
|
38
|
+
const blocked = new Set<string>();
|
|
39
|
+
const waits = new Map<string, AbortController>();
|
|
40
|
+
const assertMember = (agentId: string) => {
|
|
41
|
+
if (blocked.has(agentId)) throw new AnySwarmError('MEMBER_WORK_CANCELLED', 'The owner intervened in this member’s work');
|
|
42
|
+
};
|
|
43
|
+
const state: { stage: string; writerId?: string; readerId?: string; handoffObserved?: boolean; artifact?: string; interventions: typeof interventions } = { stage: 'writer', interventions };
|
|
38
44
|
try {
|
|
39
45
|
const result = await context.runWithRuntime({ closeTimeoutMs,
|
|
40
46
|
async createRuntime() {
|
|
@@ -45,17 +51,61 @@ const notesHarness = {
|
|
|
45
51
|
reader: { ...common, addedSystemPrompt: projectNotesReaderPrompt, services: { notes: ['get'] },
|
|
46
52
|
collect: { paths: [artifact, followup], includeGit: false, maxBytes: 64 * 1024, required: true } },
|
|
47
53
|
} });
|
|
48
|
-
|
|
54
|
+
const native = getExecutorCapabilities(config.executor ?? 'pi');
|
|
55
|
+
const controlEffects = (core: unknown) => ({ core, harnessEffects: { memberWork: 'cancelled', status: 'complete' } });
|
|
56
|
+
const intervene = async (operation: 'interrupt' | 'stop', agentId: string, requestId: string) => {
|
|
57
|
+
blocked.add(agentId);
|
|
58
|
+
interventions.push({ agentId, operation, requestId });
|
|
59
|
+
context.emit({ kind: 'user-intervention', agentId, operation, requestId });
|
|
60
|
+
void observation?.refresh();
|
|
61
|
+
try {
|
|
62
|
+
const core = operation === 'interrupt' ? await runtime.interrupt(agentId, { requestId })
|
|
63
|
+
: await runtime.stop(agentId, { timeoutMs: closeTimeoutMs });
|
|
64
|
+
return controlEffects(core);
|
|
65
|
+
} finally { waits.get(agentId)?.abort(); }
|
|
66
|
+
};
|
|
67
|
+
observation = observeProjectRuntime(runtime, context, () => state, {
|
|
68
|
+
capabilities: {
|
|
69
|
+
send: { supported: native.activeSteer, text: true, modes: ['steer'] },
|
|
70
|
+
interrupt: { supported: native.queuedInputCancellation }, stop: { supported: true },
|
|
71
|
+
},
|
|
72
|
+
handlers: {
|
|
73
|
+
send(agentId, payload, request) {
|
|
74
|
+
assertMember(agentId);
|
|
75
|
+
const { input, options } = payload as { input: string; options: SendOptions };
|
|
76
|
+
return runtime.send(agentId, input, { ...options, mode: 'steer', wakeIfIdle: false, requestId: request.operationId });
|
|
77
|
+
},
|
|
78
|
+
interrupt: (agentId, _payload, request) => intervene('interrupt', agentId, request.operationId),
|
|
79
|
+
stop: (agentId, _payload, request) => intervene('stop', agentId, request.operationId),
|
|
80
|
+
},
|
|
81
|
+
async reconcile(operation, agentId, request) {
|
|
82
|
+
if (operation === 'stop') return controlEffects(await runtime.stop(agentId, { timeoutMs: closeTimeoutMs }));
|
|
83
|
+
const core = await observation!.reconcile(agentId, operation, request.operationId);
|
|
84
|
+
return operation === 'interrupt' ? controlEffects(core) : core;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
49
87
|
return runtime;
|
|
50
88
|
},
|
|
51
89
|
async run(runtime: Awaited<ReturnType<typeof createRuntime>>) {
|
|
52
90
|
const { signal, initial, input } = context;
|
|
91
|
+
const runMember = async (agentId: string, text: string, requestId: string) => {
|
|
92
|
+
assertMember(agentId);
|
|
93
|
+
const wait = new AbortController();
|
|
94
|
+
waits.set(agentId, wait);
|
|
95
|
+
try {
|
|
96
|
+
const result = await runInput(runtime, agentId, text, { requestId, timeoutMs: turnTimeoutMs,
|
|
97
|
+
signal: AbortSignal.any([signal, wait.signal]), beforeSend: () => assertMember(agentId) });
|
|
98
|
+
assertMember(agentId);
|
|
99
|
+
return result;
|
|
100
|
+
} catch (error) { assertMember(agentId); throw error; }
|
|
101
|
+
finally { waits.delete(agentId); }
|
|
102
|
+
};
|
|
53
103
|
signal.throwIfAborted();
|
|
54
104
|
const writer = await runtime.spawn({ requestId: 'notes-writer', profile: 'writer', files: initial.files });
|
|
55
105
|
signal.throwIfAborted();
|
|
56
106
|
state.writerId = writer.id;
|
|
57
107
|
context.markRunning();
|
|
58
|
-
await
|
|
108
|
+
await runMember(writer.id, input.prompt, 'notes-write');
|
|
59
109
|
const published = notes.records.get(key);
|
|
60
110
|
if (published?.author !== writer.id) throw new AnySwarmError('NOTES_PUBLICATION_UNCONFIRMED', 'The writer did not publish its project observation');
|
|
61
111
|
signal.throwIfAborted();
|
|
@@ -65,16 +115,14 @@ const notesHarness = {
|
|
|
65
115
|
const reader = await runtime.spawn({ requestId: 'notes-reader', profile: 'reader', files: initial.files });
|
|
66
116
|
signal.throwIfAborted();
|
|
67
117
|
state.readerId = reader.id;
|
|
68
|
-
await
|
|
69
|
-
{ requestId: 'notes-read', timeoutMs: turnTimeoutMs, signal });
|
|
118
|
+
await runMember(reader.id, JSON.stringify({ task: input.prompt, artifact }), 'notes-read');
|
|
70
119
|
if (!notes.reads.some((read: { agentId: string; key: string; found: boolean }) => read.agentId === reader.id && read.key === key && read.found)) {
|
|
71
120
|
throw new AnySwarmError('NOTES_HANDOFF_UNCONFIRMED', 'The reader did not retrieve the writer’s note');
|
|
72
121
|
}
|
|
73
122
|
signal.throwIfAborted();
|
|
74
123
|
state.stage = 'followup';
|
|
75
124
|
void observation?.refresh();
|
|
76
|
-
await
|
|
77
|
-
{ requestId: 'notes-followup', timeoutMs: turnTimeoutMs, signal });
|
|
125
|
+
await runMember(reader.id, JSON.stringify({ task: input.prompt, instruction: projectNotesFollowupPrompt, artifact, followup }), 'notes-followup');
|
|
78
126
|
signal.throwIfAborted();
|
|
79
127
|
state.stage = 'verification';
|
|
80
128
|
void observation?.refresh();
|
|
@@ -33,7 +33,7 @@ export function createPeerMeshRouter({ mapping, runInput, readContext, steerInpu
|
|
|
33
33
|
if (row === active) activeContext?.abort();
|
|
34
34
|
}
|
|
35
35
|
function stop(reason: any = 'ROUTER_STOPPING') {
|
|
36
|
-
accepting = false; steerOpen = false; clearTimeout(nudgeTimer);
|
|
36
|
+
accepting = false; steerOpen = false; clearTimeout(nudgeTimer); clearTimeout(timer);
|
|
37
37
|
for (const row of queue.splice(0)) cancelUnsubmitted(row, reason);
|
|
38
38
|
if (active?.state === 'context') cancelUnsubmitted(active, reason);
|
|
39
39
|
notify();
|
|
@@ -133,7 +133,7 @@ export function createPeerMeshRouter({ mapping, runInput, readContext, steerInpu
|
|
|
133
133
|
const uncertain = row.state === 'submitted' && !['input_failed', 'input_aborted', 'input_handled_without_model_run', 'wait_requires_idle_agent'].includes(error.code);
|
|
134
134
|
Object.assign(row, { state: uncertain ? 'uncertain' : 'failed', code: error.code ?? 'ROUTER_BATCH_FAILED',
|
|
135
135
|
...(error.inputId ? { inputId: error.inputId } : {}), ...(error.receipt ? { receipt: clone(error.receipt) } : {}), ...(error.event ? { event: clone(error.event), ...(error.event.type === 'settled' ? { settled: clone(error.event) } : {}) } : {}) });
|
|
136
|
-
fence(row.code);
|
|
136
|
+
if (accepting) fence(row.code);
|
|
137
137
|
} finally {
|
|
138
138
|
steerOpen = false;
|
|
139
139
|
await steering;
|
|
@@ -174,6 +174,17 @@ export async function createPeerMeshTeam(options: any) {
|
|
|
174
174
|
halt: () => stop(fail('HARNESS_STOP_REQUESTED')),
|
|
175
175
|
currentPeers: () => ({ closing, peers: peerStates() }),
|
|
176
176
|
hasPeer: (key: string) => peers.has(key),
|
|
177
|
+
async interruptPeer(key: string, requestId: string) {
|
|
178
|
+
if (closing || !peers.has(key) || stoppedPeers.has(key)) throw fail('UNKNOWN_RECIPIENT');
|
|
179
|
+
routers.get(key).stop('USER_INTERRUPT');
|
|
180
|
+
const core = await runtime.interrupt(peers.get(key).id, { requestId });
|
|
181
|
+
return { core, harnessEffects: { status: core.status === 'interrupted' ? 'complete' : 'unknown', routerStopped: true } };
|
|
182
|
+
},
|
|
183
|
+
sendOwnerInput(key: string, input: string, requestId: string) {
|
|
184
|
+
if (closing || !peers.has(key) || stoppedPeers.has(key)) throw fail('UNKNOWN_RECIPIENT');
|
|
185
|
+
return runtime.send(peers.get(key).id, input, { requestId, mode: 'steer', source: 'user',
|
|
186
|
+
wakeIfIdle: !routers.get(key).snapshot().accepting });
|
|
187
|
+
},
|
|
177
188
|
async stopPeer(key: any, { timeoutMs = 60_000 }: any = {}) {
|
|
178
189
|
if (closing || !peers.has(key)) throw fail('UNKNOWN_RECIPIENT');
|
|
179
190
|
if (!finite(timeoutMs)) throw new TypeError('Peer stop requires a finite wait');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSandbox, type CreateRuntimeOptions, type SandboxConfig, type HarnessJson, type Harness,
|
|
3
|
-
ProjectPreflightError, checkGitProject, observeProjectRuntime, projectConfiguration,
|
|
3
|
+
ProjectPreflightError, checkGitProject, observeProjectRuntime, projectConfiguration, getExecutorCapabilities,
|
|
4
4
|
} from '@anyswarm/core';
|
|
5
5
|
import { addAbortListener } from 'node:events';
|
|
6
6
|
import { peerBatchReceipt, runPeerMeshTeam, type createPeerMeshTeam } from './harness/team.js';
|
|
@@ -54,9 +54,10 @@ const peerMesh = {
|
|
|
54
54
|
onRuntime: (runtime: Parameters<typeof observeProjectRuntime>[0], snapshot: () => unknown) => {
|
|
55
55
|
observation = observeProjectRuntime(runtime, context, snapshot, {
|
|
56
56
|
fence: () => team?.halt(),
|
|
57
|
-
async reconcile(operation, agentId) {
|
|
57
|
+
async reconcile(operation, agentId, request) {
|
|
58
58
|
const peer = team?.currentPeers().peers.find((entry: { agentId: string }) => entry.agentId === agentId);
|
|
59
|
-
if (
|
|
59
|
+
if (!peer) return { status: 'unknown' };
|
|
60
|
+
if (operation !== 'stop') return observation!.reconcile(agentId, operation, request.operationId);
|
|
60
61
|
try {
|
|
61
62
|
const core = await team!.stopPeer(peer.key);
|
|
62
63
|
return { core, harnessEffects: { status: core.cleanup === 'complete' ? 'complete' : 'pending',
|
|
@@ -68,9 +69,23 @@ const peerMesh = {
|
|
|
68
69
|
},
|
|
69
70
|
capabilities: agentId => {
|
|
70
71
|
const peer = team?.currentPeers().peers.find((entry: { agentId: string }) => entry.agentId === agentId);
|
|
71
|
-
|
|
72
|
+
const native = getExecutorCapabilities(config.executor ?? 'pi');
|
|
73
|
+
const available = !!peer && !peer.stopped;
|
|
74
|
+
return { stop: { supported: true, available, reason: peer?.stopped ? 'peer-closed' : undefined },
|
|
75
|
+
send: { supported: native.activeSteer, available, text: true, modes: ['steer'] },
|
|
76
|
+
interrupt: { supported: native.queuedInputCancellation, available } };
|
|
72
77
|
},
|
|
73
78
|
handlers: {
|
|
79
|
+
async send(agentId, payload, request) {
|
|
80
|
+
const peer = team?.currentPeers().peers.find((entry: { agentId: string }) => entry.agentId === agentId);
|
|
81
|
+
if (!peer) throw Object.assign(new Error('Unknown peer Agent'), { code: 'UNKNOWN_RECIPIENT' });
|
|
82
|
+
return team!.sendOwnerInput(peer.key, (payload as { input: string }).input, request.operationId);
|
|
83
|
+
},
|
|
84
|
+
async interrupt(agentId, _payload, request) {
|
|
85
|
+
const peer = team?.currentPeers().peers.find((entry: { agentId: string }) => entry.agentId === agentId);
|
|
86
|
+
if (!peer) throw Object.assign(new Error('Unknown peer Agent'), { code: 'UNKNOWN_RECIPIENT' });
|
|
87
|
+
return team!.interruptPeer(peer.key, request.operationId);
|
|
88
|
+
},
|
|
74
89
|
async stop(agentId, _payload, { signal }) {
|
|
75
90
|
signal.throwIfAborted();
|
|
76
91
|
const peer = team?.currentPeers().peers.find((entry: { agentId: string }) => entry.agentId === agentId);
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
[The script](flow.sh) reads the real child ID from the spawn receipt, gets that child, sends a follow-up input and stops the child. The send receipt confirms that the input was accepted. A caller that needs to wait for the child's work should observe its settled event before stopping it.
|
|
6
6
|
|
|
7
|
-
## Run from
|
|
7
|
+
## Run from the installed SDK
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Run these commands in an empty directory. To use a source build, set `ANYSWARM_SDK_ARCHIVE` to the absolute path of its verified archive. The build puts `flow.sh` beside the compiled runner so the lead can receive it as an initial file.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "$ANYSWARM_SDK_ARCHIVE"
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/agent-control demo
|
|
16
16
|
cd demo
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
FROM node:22.19.0-bookworm-slim AS typescript-build
|
|
2
2
|
WORKDIR /build
|
|
3
|
-
COPY package
|
|
4
|
-
RUN
|
|
3
|
+
COPY package*.json npm-shrinkwrap*.json tsconfig.json ./
|
|
4
|
+
RUN if [ -f package.development.json ]; then \
|
|
5
|
+
cp package.development.json package.json && cp npm-shrinkwrap.development.json npm-shrinkwrap.json; \
|
|
6
|
+
fi && npm ci --include=dev --ignore-scripts --no-audit --no-fund
|
|
5
7
|
COPY src ./src
|
|
6
8
|
COPY scripts ./scripts
|
|
7
9
|
COPY examples/taskpool ./examples/taskpool
|
|
@@ -39,7 +39,7 @@ process. See the maintained [Mathlib service implementation](../../../docs/archi
|
|
|
39
39
|
|
|
40
40
|
To run the host without a container after building the checkout, use
|
|
41
41
|
`npm run service:mathlib-search` from the root, or
|
|
42
|
-
|
|
42
|
+
`../../../node_modules/.bin/anys run ./main.ts` from this directory.
|
|
43
43
|
The caller supplies the host token with `MATHLIB_SEARCH_TOKEN`, and configures
|
|
44
44
|
the endpoint in its own service adapter. The application/operator owns the
|
|
45
45
|
external provider's lifecycle and persistent data; Runtime close does not remove it.
|
|
@@ -6,11 +6,11 @@ This example registers an MCP stdio provider with `mcpService()` and an ordinary
|
|
|
6
6
|
|
|
7
7
|
## Install and build outside the checkout
|
|
8
8
|
|
|
9
|
-
Use Linux with Node 24 or later.
|
|
9
|
+
Use Linux with Node 24 or later. Run these commands in an empty directory. To use a source build, set `ANYSWARM_SDK_ARCHIVE` to the absolute path of its verified archive.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "$ANYSWARM_SDK_ARCHIVE"
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/mcp-managed demo
|
|
16
16
|
cd demo
|
|
@@ -4,13 +4,13 @@ Two Agents share a SQLite Board. A replacement Agent reads the committed finding
|
|
|
4
4
|
|
|
5
5
|
`business.ts` is an independent SQLite library with publish/list operations. `interface.ts` describes the public operations. `index.ts` binds authenticated callers and supplies lifecycle and observation hooks. `python/board.py` implements the same business operations in Python. `python/server.py` exposes ordinary GET/POST `/entries` REST routes using Python's standard library.
|
|
6
6
|
|
|
7
|
-
## Run from
|
|
7
|
+
## Run from the installed SDK
|
|
8
8
|
|
|
9
|
-
Use Node 24 or later. The HTTP variant also needs Python 3.
|
|
9
|
+
Use Node 24 or later. The HTTP variant also needs Python 3. Run these commands in an empty directory. To use a source build, set `ANYSWARM_SDK_ARCHIVE` to the absolute path of its verified archive.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm init -y
|
|
13
|
-
npm install --ignore-scripts "$ANYSWARM_SDK_ARCHIVE"
|
|
13
|
+
npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
|
|
14
14
|
npm install --save-dev typescript @types/node
|
|
15
15
|
cp -R node_modules/@anyswarm/core/examples/services/persistent-board demo
|
|
16
16
|
cd demo
|
|
@@ -51,6 +51,16 @@ npx anyswarm trace --root ./runs
|
|
|
51
51
|
|
|
52
52
|
Open the completed Run, expand **Service states**, and inspect the Board export. A publish call also links the Board state and original JSON. Export start/end times describe the framework's export work. The Board supplies its capture time and last committed entry ID as a business revision. These close/retirement observations have their own timestamps. The Viewer retains the individual publish call evidence alongside them.
|
|
53
53
|
|
|
54
|
+
## Watch a live Board
|
|
55
|
+
|
|
56
|
+
Copy this example from the installed SDK as shown above. Configure OpenSandbox and select an installed Worker with setup or `ANYSWARM_WORKER_IMAGE`. Open the example in a regular terminal and run:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
anys -u ./live.ts 'Watch the persistent Board'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Enter two short findings in the composer. Each commit appears in the stream with its row ID, and the status header updates the committed count. Use `/stop` to finish and `/trace` to inspect the saved Run. The example uses SQLite and does not spawn an Agent or call a model. SDK and RPC clients can read the live count, recent IDs and commit times through the Service observation hook. The final export remains available to Trace Viewer after the Harness closes.
|
|
63
|
+
|
|
54
64
|
## Author a different Service
|
|
55
65
|
|
|
56
66
|
Register the adapter and grant its operations explicitly.
|
|
@@ -58,6 +58,16 @@ export class Board {
|
|
|
58
58
|
return rows.map(row => ({ id: Number(row.id), authorId: String(row.authorId), text: String(row.text), createdAt: String(row.createdAt) }));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
observation() {
|
|
62
|
+
const recent = this.database.prepare(
|
|
63
|
+
'SELECT id, created_at AS createdAt, (SELECT COUNT(*) FROM entries) AS count FROM entries ORDER BY id DESC LIMIT 20',
|
|
64
|
+
).all();
|
|
65
|
+
return {
|
|
66
|
+
count: Number(recent[0]?.count ?? 0),
|
|
67
|
+
entries: recent.map(row => ({ id: Number(row.id), createdAt: String(row.createdAt) })),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
close(): void {
|
|
62
72
|
this.database.close();
|
|
63
73
|
}
|
|
@@ -35,6 +35,16 @@ export function boardService({ storagePath }: { storagePath?: string } = {}): Se
|
|
|
35
35
|
}
|
|
36
36
|
return current().list() as unknown as JsonValue;
|
|
37
37
|
},
|
|
38
|
+
readState() {
|
|
39
|
+
const state = current().observation();
|
|
40
|
+
return { state, capturedAt: new Date().toISOString(), revision: String(state.entries[0]?.id ?? 0),
|
|
41
|
+
presentation: {
|
|
42
|
+
summary: [{ label: 'Committed entries', path: '/count' }],
|
|
43
|
+
tables: [{ title: 'Recent entries', path: '/entries', columns: [
|
|
44
|
+
{ label: 'ID', path: '/id' }, { label: 'Committed at', path: '/createdAt' },
|
|
45
|
+
] }],
|
|
46
|
+
} };
|
|
47
|
+
},
|
|
38
48
|
exportState() {
|
|
39
49
|
const entries = current().list();
|
|
40
50
|
return { entries: entries as unknown as JsonValue, count: entries.length, capturedAt: new Date().toISOString(),
|