@anyswarm/core 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +21 -13
- package/deploy/worker/Dockerfile +12 -4
- package/dist/deploy/worker/Dockerfile +12 -4
- package/dist/examples/README.md +35 -12
- package/dist/examples/authoring/README.md +24 -0
- package/dist/examples/authoring/business.d.ts +2 -0
- package/dist/examples/authoring/business.js +4 -0
- package/dist/examples/authoring/config.d.ts +5 -0
- package/dist/examples/authoring/config.js +2 -0
- package/dist/examples/authoring/eject.json +5 -0
- package/dist/examples/authoring/harness.d.ts +4 -0
- package/dist/examples/authoring/harness.js +19 -0
- package/dist/examples/autoresearch/README.md +40 -0
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/autoresearch/config.d.ts +51 -0
- package/dist/examples/autoresearch/config.js +57 -0
- package/dist/examples/autoresearch/demo.d.ts +11 -0
- package/dist/examples/autoresearch/demo.js +52 -0
- package/dist/examples/autoresearch/eject.json +17 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
- package/dist/examples/autoresearch/frontiercs2.js +211 -0
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +15 -0
- package/dist/examples/autoresearch/prepare.d.ts +95 -0
- package/dist/examples/autoresearch/prepare.js +257 -0
- package/dist/examples/autoresearch/process.d.ts +13 -0
- package/dist/examples/autoresearch/process.js +48 -0
- package/dist/examples/autoresearch/project.d.ts +21 -0
- package/dist/examples/autoresearch/project.js +392 -0
- package/dist/examples/autoresearch/research-service.d.ts +106 -0
- package/dist/examples/autoresearch/research-service.js +255 -0
- package/dist/examples/code/README.md +33 -0
- package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
- package/dist/examples/code/candidate.d.ts +19 -0
- package/dist/examples/code/candidate.js +80 -0
- package/dist/examples/code/config.d.ts +32 -0
- package/dist/examples/code/config.js +18 -0
- package/dist/examples/code/eject.json +5 -0
- package/dist/examples/code/project.d.ts +3 -0
- package/dist/examples/code/project.js +605 -0
- package/dist/examples/code/prompts.d.ts +5 -0
- package/dist/examples/code/prompts.js +12 -0
- package/dist/examples/code/verification.d.ts +19 -0
- package/dist/examples/code/verification.js +268 -0
- package/dist/examples/code/worktree.d.ts +17 -0
- package/dist/examples/code/worktree.js +233 -0
- package/dist/examples/harness-session/README.md +3 -6
- package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
- package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
- package/dist/examples/lead-worker/harness/index.d.ts +60 -0
- package/dist/examples/lead-worker/harness/index.js +77 -6
- package/dist/examples/lead-worker/project.js +2 -2
- package/dist/examples/lead-worker/services/board.d.ts +5 -0
- package/dist/examples/lead-worker/services/board.js +19 -1
- package/dist/examples/messages/README.md +5 -5
- package/dist/examples/messages/handoff.d.ts +2 -0
- package/dist/examples/messages/handoff.js +5 -1
- package/dist/examples/messages/project.js +52 -2
- package/dist/examples/notes/README.md +13 -18
- package/dist/examples/notes/project.js +67 -6
- package/dist/examples/peermesh/harness/router.js +3 -1
- package/dist/examples/peermesh/harness/team.d.ts +8 -0
- package/dist/examples/peermesh/harness/team.js +13 -0
- package/dist/examples/peermesh/project.js +22 -4
- package/dist/examples/services/agent-control/README.md +3 -3
- package/dist/examples/services/mathlib-search/Dockerfile +4 -2
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +2 -2
- package/dist/examples/services/persistent-board/README.md +16 -3
- package/dist/examples/services/persistent-board/business.d.ts +7 -0
- package/dist/examples/services/persistent-board/business.js +7 -0
- package/dist/examples/services/persistent-board/index.js +10 -0
- package/dist/examples/services/persistent-board/live.d.ts +3 -0
- package/dist/examples/services/persistent-board/live.js +58 -0
- package/dist/examples/subagents/README.md +5 -5
- package/dist/examples/subagents/business.js +3 -1
- package/dist/examples/subagents/config.js +3 -3
- package/dist/examples/subagents/harness/controller.d.ts +15 -0
- package/dist/examples/subagents/harness/controller.js +181 -32
- package/dist/examples/subagents/project.d.ts +2 -0
- package/dist/examples/subagents/project.js +43 -34
- package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
- package/dist/examples/subagents/prompts/prompts.js +3 -0
- package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
- package/dist/examples/subagents/services/collaboration-service.js +14 -2
- package/dist/examples/substrate/README.md +2 -2
- package/dist/examples/substrate/harness/index.d.ts +1 -1
- package/dist/examples/substrate/harness/index.js +77 -12
- package/dist/examples/substrate/project.js +4 -1
- package/dist/examples/super/README.md +52 -0
- package/dist/examples/super/actions.d.ts +95 -0
- package/dist/examples/super/actions.js +230 -0
- package/dist/examples/super/artifact.d.ts +4 -0
- package/dist/examples/super/artifact.js +51 -0
- package/dist/examples/super/config.d.ts +80 -0
- package/dist/examples/super/config.js +83 -0
- package/dist/examples/super/coordinator.d.ts +33 -0
- package/dist/examples/super/coordinator.js +151 -0
- package/dist/examples/super/daemon.d.ts +11 -0
- package/dist/examples/super/daemon.js +109 -0
- package/dist/examples/super/decisions.d.ts +8 -0
- package/dist/examples/super/decisions.js +52 -0
- package/dist/examples/super/eject.json +5 -0
- package/dist/examples/super/execution.d.ts +11 -0
- package/dist/examples/super/execution.js +136 -0
- package/dist/examples/super/github.d.ts +62 -0
- package/dist/examples/super/github.js +269 -0
- package/dist/examples/super/inbox.d.ts +162 -0
- package/dist/examples/super/inbox.js +284 -0
- package/dist/examples/super/location.d.ts +5 -0
- package/dist/examples/super/location.js +64 -0
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/outbox.d.ts +5 -0
- package/dist/examples/super/outbox.js +103 -0
- package/dist/examples/super/project.d.ts +4 -0
- package/dist/examples/super/project.js +251 -0
- package/dist/examples/super/prompts.d.ts +3 -0
- package/dist/examples/super/prompts.js +25 -0
- package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/dist/examples/taskpool/harness/controller.d.ts +35 -6
- package/dist/examples/taskpool/harness/controller.js +73 -7
- package/dist/examples/taskpool/project.js +18 -2
- package/dist/scripts/anyswarm-arguments.d.ts +18 -6
- package/dist/scripts/anyswarm-arguments.js +88 -52
- package/dist/scripts/anyswarm-author.d.ts +5 -0
- package/dist/scripts/anyswarm-author.js +24 -0
- package/dist/scripts/anyswarm-eject.d.ts +11 -0
- package/dist/scripts/anyswarm-eject.js +164 -0
- package/dist/scripts/anyswarm-harnesses.d.ts +1 -0
- package/dist/scripts/anyswarm-harnesses.js +10 -0
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -285
- package/dist/scripts/anyswarm-launch.d.ts +7 -0
- package/dist/scripts/anyswarm-launch.js +37 -0
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +102 -0
- package/dist/scripts/anyswarm-project.d.ts +3 -1
- package/dist/scripts/anyswarm-project.js +49 -35
- package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
- package/dist/scripts/anyswarm-source-runner.js +200 -0
- package/dist/scripts/anyswarm.js +28 -3
- package/dist/scripts/build-provenance.json +1 -0
- package/dist/scripts/build.js +7 -1
- package/dist/scripts/generate-architecture-api.js +2 -0
- package/dist/scripts/generate-architecture-prompts.js +24 -2
- package/dist/scripts/local-environment.d.ts +13 -2
- package/dist/scripts/local-environment.js +111 -28
- package/dist/scripts/local-setup-smoke.js +3 -2
- package/dist/scripts/local-setup-worker.d.ts +1 -1
- package/dist/scripts/local-setup-worker.js +15 -6
- package/dist/scripts/local-setup.d.ts +5 -2
- package/dist/scripts/local-setup.js +167 -79
- package/dist/scripts/opensandbox-agent-worker.js +2 -2
- package/dist/scripts/pack-release.d.ts +1 -0
- package/dist/scripts/pack-release.js +66 -0
- package/dist/scripts/pi-session-bridge.js +11 -3
- package/dist/scripts/run-harness.js +3 -1
- package/dist/scripts/setup-bootstrap.js +43 -6
- package/dist/src/core/allocation-ledger.js +4 -3
- package/dist/src/core/host-identity.d.ts +2 -0
- package/dist/src/core/host-identity.js +11 -0
- package/dist/src/core/index.d.ts +4 -2
- package/dist/src/core/index.js +12 -4
- package/dist/src/core/mcp-service.js +2 -2
- package/dist/src/core/runtime-management.d.ts +6 -0
- package/dist/src/core/runtime-management.js +24 -0
- package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
- package/dist/src/core/sandbox/executor-driver.js +12 -14
- package/dist/src/core/sandbox/local-executor.d.ts +13 -1
- package/dist/src/core/sandbox/local-executor.js +69 -19
- package/dist/src/core/sandbox/local-worker.js +32 -21
- package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
- package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
- package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
- package/dist/src/core/sandbox/sandbox-connection.js +14 -6
- package/dist/src/core/service-live-state.d.ts +14 -0
- package/dist/src/core/service-live-state.js +161 -0
- package/dist/src/core/service-observation-types.d.ts +21 -1
- package/dist/src/core/service-process.d.ts +1 -1
- package/dist/src/core/service-process.js +45 -4
- package/dist/src/core/service-types.d.ts +5 -1
- package/dist/src/core/services.d.ts +1 -1
- package/dist/src/core/services.js +8 -3
- package/dist/src/core/types.d.ts +3 -0
- package/dist/src/core/worker-image.js +3 -3
- package/dist/src/harness/harness-session-types.d.ts +10 -0
- package/dist/src/harness/harness-session.js +42 -5
- package/dist/src/harness/project-harness.d.ts +14 -1
- package/dist/src/harness/project-harness.js +38 -12
- package/dist/src/harness/project-input.js +81 -15
- package/dist/src/harness/project-rpc-client.d.ts +1 -0
- package/dist/src/harness/project-rpc-client.js +5 -0
- package/dist/src/harness/project-rpc.d.ts +8 -2
- package/dist/src/harness/project-rpc.js +31 -7
- package/dist/src/harness/project-runtime.js +6 -2
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +41 -0
- package/dist/src/trace-viewer/public/app.js +6 -5
- package/dist/src/trace-viewer/reader.mjs +42 -2
- package/docs/INDEX.md +5 -2
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-agent-core.md +1 -1
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/06-observability-experiments.md +1 -1
- package/docs/architecture/07-run-configuration.md +38 -18
- package/docs/architecture/08-prompts.md +22 -0
- package/docs/architecture/10-service-api-reference.md +53 -18
- package/docs/architecture/11-storage-reference.md +18 -1
- package/docs/architecture/12-code-coverage.md +152 -89
- package/docs/architecture/15-core-runtime.md +8 -0
- package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/19-substrate-harness.md +28 -1
- package/docs/architecture/20-lead-worker-harness.md +34 -1
- package/docs/architecture/22-website.md +5 -6
- package/docs/architecture/23-project-harness.md +152 -8
- package/docs/architecture/24-runtime-recovery.md +10 -3
- package/docs/architecture/26-code.md +54 -0
- package/docs/architecture/27-personal.md +58 -0
- package/docs/architecture/28-autoresearch.md +43 -0
- package/docs/architecture/INDEX.md +3 -0
- package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
- package/docs/architecture/prompts/08-subagents-harness.md +21 -0
- package/docs/architecture/prompts/21-personal.md +44 -0
- package/docs/architecture/prompts/22-autoresearch.md +63 -0
- package/docs/architecture/prompts/26-code.md +55 -0
- package/docs/architecture/prompts/source-manifest.json +152 -33
- package/docs/architecture/source-map.json +473 -25
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +13 -2
- package/docs/designs/core-harness/README.md +7 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/build-your-harness.md +3 -5
- package/docs/en/changelog.md +20 -4
- package/docs/en/first-harness.md +9 -12
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +14 -121
- package/docs/en/overview.md +1 -1
- package/docs/en/quickstart.md +42 -39
- package/docs/en/reference/api.md +14 -4
- package/docs/en/reference/cli.md +53 -47
- package/docs/en/runtime.md +2 -2
- package/docs/en/sandbox.md +3 -3
- package/docs/en/services.md +4 -0
- package/docs/operations/trace-viewer.md +1 -1
- package/docs/workflows/development.md +28 -21
- package/docs/workflows/release-and-docs-versioning.md +77 -0
- package/docs/workflows/release-cli-acceptance.md +85 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +3 -5
- package/docs/zh/changelog.md +20 -4
- package/docs/zh/first-harness.md +9 -12
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +15 -122
- package/docs/zh/overview.md +1 -1
- package/docs/zh/quickstart.md +42 -39
- package/docs/zh/reference/api.md +14 -4
- package/docs/zh/reference/cli.md +24 -40
- package/docs/zh/runtime.md +2 -2
- package/docs/zh/sandbox.md +3 -3
- package/docs/zh/services.md +4 -0
- package/examples/README.md +35 -12
- package/examples/authoring/README.md +24 -0
- package/examples/authoring/business.ts +4 -0
- package/examples/authoring/config.ts +2 -0
- package/examples/authoring/eject.json +5 -0
- package/examples/authoring/harness.ts +21 -0
- package/examples/autoresearch/README.md +40 -0
- package/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
- package/examples/autoresearch/config.ts +90 -0
- package/examples/autoresearch/demo.ts +55 -0
- package/examples/autoresearch/eject.json +17 -0
- package/examples/autoresearch/frontiercs2-config.ts +4 -0
- package/examples/autoresearch/frontiercs2.ts +237 -0
- package/examples/autoresearch/prepare-demo.ts +15 -0
- package/examples/autoresearch/prepare.ts +267 -0
- package/examples/autoresearch/process.ts +50 -0
- package/examples/autoresearch/project.ts +380 -0
- package/examples/autoresearch/research-service.ts +302 -0
- package/examples/code/README.md +33 -0
- package/examples/code/REQUIREMENTS.zh.md +11 -0
- package/examples/code/candidate.ts +89 -0
- package/examples/code/config.ts +19 -0
- package/examples/code/eject.json +5 -0
- package/examples/code/project.ts +581 -0
- package/examples/code/prompts.ts +16 -0
- package/examples/code/verification.ts +239 -0
- package/examples/code/worktree.ts +188 -0
- package/examples/harness-session/README.md +3 -6
- package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
- package/examples/lead-worker/harness/index.ts +61 -6
- package/examples/lead-worker/project.ts +2 -2
- package/examples/lead-worker/services/board.ts +14 -1
- package/examples/messages/README.md +5 -5
- package/examples/messages/handoff.ts +6 -2
- package/examples/messages/project.ts +47 -2
- package/examples/notes/README.md +13 -18
- package/examples/notes/project.ts +57 -9
- package/examples/peermesh/harness/router.ts +2 -2
- package/examples/peermesh/harness/team.ts +11 -0
- package/examples/peermesh/project.ts +19 -4
- package/examples/services/agent-control/README.md +3 -3
- package/examples/services/mathlib-search/Dockerfile +4 -2
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +2 -2
- package/examples/services/persistent-board/README.md +16 -3
- package/examples/services/persistent-board/business.ts +10 -0
- package/examples/services/persistent-board/index.ts +10 -0
- package/examples/services/persistent-board/live.ts +54 -0
- package/examples/subagents/README.md +5 -5
- package/examples/subagents/business.ts +3 -1
- package/examples/subagents/config.ts +4 -3
- package/examples/subagents/harness/controller.ts +161 -29
- package/examples/subagents/project.ts +47 -33
- package/examples/subagents/prompts/prompts.ts +4 -0
- package/examples/subagents/services/collaboration-service.ts +14 -2
- package/examples/substrate/README.md +2 -2
- package/examples/substrate/harness/index.ts +67 -11
- package/examples/substrate/project.ts +5 -1
- package/examples/super/README.md +52 -0
- package/examples/super/actions.ts +196 -0
- package/examples/super/artifact.ts +56 -0
- package/examples/super/config.ts +95 -0
- package/examples/super/coordinator.ts +158 -0
- package/examples/super/daemon.ts +84 -0
- package/examples/super/decisions.ts +46 -0
- package/examples/super/eject.json +5 -0
- package/examples/super/execution.ts +131 -0
- package/examples/super/github.ts +242 -0
- package/examples/super/inbox.ts +306 -0
- package/examples/super/location.ts +54 -0
- package/examples/super/operator.ts +28 -0
- package/examples/super/outbox.ts +97 -0
- package/examples/super/project.ts +225 -0
- package/examples/super/prompts.ts +27 -0
- package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
- package/examples/taskpool/harness/controller.ts +59 -7
- package/examples/taskpool/project.ts +18 -2
- package/npm-shrinkwrap.development.json +700 -0
- package/npm-shrinkwrap.json +95 -1969
- package/package.development.json +88 -0
- package/package.json +11 -8
- package/scripts/anyswarm-arguments.ts +91 -54
- package/scripts/anyswarm-author.ts +25 -0
- package/scripts/anyswarm-eject.ts +145 -0
- package/scripts/anyswarm-harnesses.ts +10 -0
- package/scripts/anyswarm-installation.ts +18 -288
- package/scripts/anyswarm-launch.ts +36 -0
- package/scripts/anyswarm-progress.ts +95 -0
- package/scripts/anyswarm-project.ts +35 -34
- package/scripts/anyswarm-source-runner.ts +176 -0
- package/scripts/anyswarm.ts +24 -3
- package/scripts/build.ts +8 -1
- package/scripts/generate-architecture-api.ts +2 -0
- package/scripts/generate-architecture-prompts.ts +35 -2
- package/scripts/local-environment.ts +117 -28
- package/scripts/local-setup-smoke.ts +3 -2
- package/scripts/local-setup-worker.ts +17 -7
- package/scripts/local-setup.ts +166 -73
- package/scripts/opensandbox-agent-worker.ts +2 -2
- package/scripts/pack-release.ts +70 -0
- package/scripts/pi-session-bridge.ts +10 -2
- package/scripts/run-harness.ts +3 -1
- package/scripts/setup-bootstrap.ts +41 -6
- package/src/core/allocation-ledger.ts +5 -3
- package/src/core/host-identity.ts +11 -0
- package/src/core/index.ts +12 -6
- package/src/core/mcp-service.ts +2 -2
- package/src/core/runtime-management.ts +22 -0
- package/src/core/sandbox/executor-driver.ts +15 -18
- package/src/core/sandbox/local-executor.ts +65 -19
- package/src/core/sandbox/local-worker.ts +29 -21
- package/src/core/sandbox/opensandbox-backend.ts +36 -11
- package/src/core/sandbox/sandbox-connection.ts +14 -5
- package/src/core/service-live-state.ts +156 -0
- package/src/core/service-observation-types.ts +23 -1
- package/src/core/service-process.ts +36 -3
- package/src/core/service-types.ts +3 -1
- package/src/core/services.ts +8 -3
- package/src/core/types.ts +3 -0
- package/src/core/worker-image.ts +3 -3
- package/src/harness/harness-session-types.ts +13 -1
- package/src/harness/harness-session.ts +40 -7
- package/src/harness/project-harness.ts +38 -12
- package/src/harness/project-input.ts +73 -15
- package/src/harness/project-rpc-client.ts +5 -0
- package/src/harness/project-rpc.ts +29 -8
- package/src/harness/project-runtime.ts +4 -2
- package/src/harness/typescript-loader.ts +37 -0
- package/src/trace-viewer/public/app.js +6 -5
- package/src/trace-viewer/reader.mjs +42 -2
|
@@ -2,6 +2,18 @@ import { runWithReport } from '@anyswarm/core';
|
|
|
2
2
|
export declare function createLeadWorkerHarness(options: any): Promise<Readonly<{
|
|
3
3
|
id: any;
|
|
4
4
|
snapshot: () => {
|
|
5
|
+
userControls: {
|
|
6
|
+
[k: string]: {
|
|
7
|
+
kind: 'interrupt' | 'stop';
|
|
8
|
+
requestId: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
pendingMemberControls: {
|
|
12
|
+
[k: string]: {
|
|
13
|
+
kind: 'interrupt' | 'stop';
|
|
14
|
+
requestId: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
5
17
|
runId: any;
|
|
6
18
|
runtimeId: any;
|
|
7
19
|
initialCommit: string | undefined;
|
|
@@ -50,6 +62,18 @@ export declare function createLeadWorkerHarness(options: any): Promise<Readonly<
|
|
|
50
62
|
}): Promise<{
|
|
51
63
|
submitted: any;
|
|
52
64
|
harness: {
|
|
65
|
+
userControls: {
|
|
66
|
+
[k: string]: {
|
|
67
|
+
kind: 'interrupt' | 'stop';
|
|
68
|
+
requestId: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
pendingMemberControls: {
|
|
72
|
+
[k: string]: {
|
|
73
|
+
kind: 'interrupt' | 'stop';
|
|
74
|
+
requestId: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
53
77
|
runId: any;
|
|
54
78
|
runtimeId: any;
|
|
55
79
|
initialCommit: string | undefined;
|
|
@@ -98,6 +122,18 @@ export declare function createLeadWorkerHarness(options: any): Promise<Readonly<
|
|
|
98
122
|
ok: boolean;
|
|
99
123
|
};
|
|
100
124
|
harness: {
|
|
125
|
+
userControls: {
|
|
126
|
+
[k: string]: {
|
|
127
|
+
kind: 'interrupt' | 'stop';
|
|
128
|
+
requestId: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
pendingMemberControls: {
|
|
132
|
+
[k: string]: {
|
|
133
|
+
kind: 'interrupt' | 'stop';
|
|
134
|
+
requestId: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
101
137
|
runId: any;
|
|
102
138
|
runtimeId: any;
|
|
103
139
|
initialCommit: string | undefined;
|
|
@@ -145,6 +181,18 @@ export declare function createLeadWorkerHarness(options: any): Promise<Readonly<
|
|
|
145
181
|
direction: any;
|
|
146
182
|
submitted: any;
|
|
147
183
|
harness: {
|
|
184
|
+
userControls: {
|
|
185
|
+
[k: string]: {
|
|
186
|
+
kind: 'interrupt' | 'stop';
|
|
187
|
+
requestId: string;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
pendingMemberControls: {
|
|
191
|
+
[k: string]: {
|
|
192
|
+
kind: 'interrupt' | 'stop';
|
|
193
|
+
requestId: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
148
196
|
runId: any;
|
|
149
197
|
runtimeId: any;
|
|
150
198
|
initialCommit: string | undefined;
|
|
@@ -193,6 +241,18 @@ export declare function createLeadWorkerHarness(options: any): Promise<Readonly<
|
|
|
193
241
|
originalDirection: any;
|
|
194
242
|
adjustedDirection: any;
|
|
195
243
|
harness: {
|
|
244
|
+
userControls: {
|
|
245
|
+
[k: string]: {
|
|
246
|
+
kind: 'interrupt' | 'stop';
|
|
247
|
+
requestId: string;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
pendingMemberControls: {
|
|
251
|
+
[k: string]: {
|
|
252
|
+
kind: 'interrupt' | 'stop';
|
|
253
|
+
requestId: string;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
196
256
|
runId: any;
|
|
197
257
|
runtimeId: any;
|
|
198
258
|
initialCommit: string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir } from 'node:fs/promises';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
|
-
import { createRuntime, ServiceRegistry, createOwnedResources, seededCheckoutInstruction, runInput, runWithReport } from '@anyswarm/core';
|
|
3
|
+
import { createRuntime, getExecutorCapabilities, ServiceRegistry, createOwnedResources, seededCheckoutInstruction, runInput, runWithReport } from '@anyswarm/core';
|
|
4
4
|
import { createBoard, boardPermissions, projectBoardPermissions } from '../services/board.js';
|
|
5
5
|
import { leadWorkerRoles } from './team.js';
|
|
6
6
|
import { createDynamicLeadWorker, dynamicServices } from './dynamic.js';
|
|
@@ -46,6 +46,62 @@ export async function createLeadWorkerHarness(options) {
|
|
|
46
46
|
let boardFenceFailure;
|
|
47
47
|
const pendingFences = new Map();
|
|
48
48
|
const activeInputs = new Set();
|
|
49
|
+
const pendingMemberControls = new Map();
|
|
50
|
+
function recordMemberControl(agentId, control) {
|
|
51
|
+
try {
|
|
52
|
+
board.interveneMember({ agentId, ...control });
|
|
53
|
+
pendingMemberControls.delete(agentId);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
pendingMemberControls.set(agentId, control);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const userControls = new Map();
|
|
60
|
+
const heldMembers = new Map();
|
|
61
|
+
async function waitForMember(agentId, signal) {
|
|
62
|
+
if (userControls.get(agentId)?.kind !== 'interrupt')
|
|
63
|
+
return;
|
|
64
|
+
let waiting = heldMembers.get(agentId);
|
|
65
|
+
if (!waiting)
|
|
66
|
+
heldMembers.set(agentId, waiting = Promise.withResolvers());
|
|
67
|
+
const abort = () => waiting.reject(fail('WORKFLOW_STOPPED'));
|
|
68
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
69
|
+
try {
|
|
70
|
+
signal.throwIfAborted();
|
|
71
|
+
await waiting.promise;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
signal.removeEventListener('abort', abort);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const memberControls = {
|
|
78
|
+
capabilities: {
|
|
79
|
+
send: { supported: getExecutorCapabilities(executor ?? 'pi').activeSteer, text: true, modes: ['steer'] },
|
|
80
|
+
interrupt: { supported: getExecutorCapabilities(executor ?? 'pi').queuedInputCancellation },
|
|
81
|
+
stop: { supported: true },
|
|
82
|
+
},
|
|
83
|
+
handlers: {
|
|
84
|
+
send(agentId, payload, request) {
|
|
85
|
+
const { input, options } = payload;
|
|
86
|
+
return runtime.send(agentId, input, { ...options, requestId: request.operationId });
|
|
87
|
+
},
|
|
88
|
+
async interrupt(agentId, _payload, request) {
|
|
89
|
+
const control = { kind: 'interrupt', requestId: request.requestId };
|
|
90
|
+
userControls.set(agentId, control);
|
|
91
|
+
recordMemberControl(agentId, control);
|
|
92
|
+
const core = await runtime.interrupt(agentId, { requestId: request.operationId });
|
|
93
|
+
return { core, harnessEffects: { held: true, rescheduled: false, boardRecorded: !pendingMemberControls.has(agentId) } };
|
|
94
|
+
},
|
|
95
|
+
async stop(agentId, payload, request) {
|
|
96
|
+
const control = { kind: 'stop', requestId: request.requestId };
|
|
97
|
+
userControls.set(agentId, control);
|
|
98
|
+
recordMemberControl(agentId, control);
|
|
99
|
+
heldMembers.get(agentId)?.resolve();
|
|
100
|
+
const core = await runtime.stop(agentId, { requestId: request.operationId, reason: payload?.reason });
|
|
101
|
+
return { core, harnessEffects: { stopped: true, rescheduled: false, boardRecorded: !pendingMemberControls.has(agentId) } };
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
49
105
|
const team = {};
|
|
50
106
|
const inputs = [];
|
|
51
107
|
const events = [];
|
|
@@ -64,7 +120,7 @@ export async function createLeadWorkerHarness(options) {
|
|
|
64
120
|
catch {
|
|
65
121
|
boardReadFailure = { code: 'BOARD_READ_FAILED' };
|
|
66
122
|
}
|
|
67
|
-
return { runId, runtimeId: runtime?.id, initialCommit, initialDigest: options.initialDigest, boardPath, team: { ...team }, stages: structuredClone(stages), rejections: structuredClone(rejections), preparation: structuredClone(preparedStages ?? null), git: git?.identities(), board: publicBoard, ...(boardReadFailure ? { boardReadFailure } : {}), inputs: structuredClone(inputs), events: structuredClone(events),
|
|
123
|
+
return { userControls: Object.fromEntries(userControls), pendingMemberControls: Object.fromEntries(pendingMemberControls), runId, runtimeId: runtime?.id, initialCommit, initialDigest: options.initialDigest, boardPath, team: { ...team }, stages: structuredClone(stages), rejections: structuredClone(rejections), preparation: structuredClone(preparedStages ?? null), git: git?.identities(), board: publicBoard, ...(boardReadFailure ? { boardReadFailure } : {}), inputs: structuredClone(inputs), events: structuredClone(events),
|
|
68
124
|
delivered: publicBoard?.subtasks.filter((row) => row.delivery?.verified) ?? [], unfinished: publicBoard?.subtasks.filter((row) => row.state !== 'complete') ?? [], inputUnknown: inputs.filter((row) => row.uncertain).map((row) => ({ agentId: row.agentId, requestId: row.requestId, inputId: row.inputId, code: row.code })), resources: resources.snapshot(),
|
|
69
125
|
...(boardFenceFailure ? { boardFenceFailure, pendingBoardFailures: [...pendingFences.values()] } : {}), ...(dynamicControl ? { dynamic: dynamicControl.snapshot() } : {}),
|
|
70
126
|
limitations: ['Local SQLite Board and exclusive turn controller', dynamic ? 'One dynamic member and no claim reclamation' : 'Fixed preconfigured team; no replacement or claim reclamation', 'Upstream scale and performance not verified'] };
|
|
@@ -112,7 +168,9 @@ export async function createLeadWorkerHarness(options) {
|
|
|
112
168
|
recordFence({ agentId, code: failure.code, execution: core.agents?.find((row) => row.agentId === agentId)?.execution === 'stopped' ? 'stopped' : 'unknown' });
|
|
113
169
|
if (boardFenceFailure)
|
|
114
170
|
recordFence();
|
|
115
|
-
|
|
171
|
+
for (const [agentId, control] of pendingMemberControls)
|
|
172
|
+
recordMemberControl(agentId, control);
|
|
173
|
+
if (boardReadFailed || boardFenceFailure || pendingFences.size || pendingMemberControls.size)
|
|
116
174
|
return { ...core, cleanup: 'pending', harness: { cleanup: 'pending', pending: [{ kind: 'board-evidence', id: boardPath, action: 'persist-failure', error: { code: 'BOARD_FENCE_FAILED' } }], resources: resources.snapshot() } };
|
|
117
175
|
if (core.cleanup !== 'complete' || core.agents.some((row) => row.execution !== 'stopped' || row.cleanup !== 'complete'))
|
|
118
176
|
return { ...core, harness: { cleanup: 'pending', pending: resources.snapshot().filter((row) => !['closed', 'retained'].includes(row.state)) } };
|
|
@@ -133,6 +191,9 @@ export async function createLeadWorkerHarness(options) {
|
|
|
133
191
|
const dispatch = async (role, requestId, payload, workSignal, deadlineAtMs) => {
|
|
134
192
|
if (workSignal.aborted || closing)
|
|
135
193
|
throw fail('WORKFLOW_STOPPED');
|
|
194
|
+
await waitForMember(team[role], workSignal);
|
|
195
|
+
if (userControls.get(team[role])?.kind === 'stop')
|
|
196
|
+
return { status: 'user-stopped' };
|
|
136
197
|
const timeoutMs = deadlineAtMs === undefined ? turnTimeoutMs : Math.ceil(deadlineAtMs - performance.now());
|
|
137
198
|
if (timeoutMs < 1)
|
|
138
199
|
throw fail('WORKFLOW_STOPPED');
|
|
@@ -141,12 +202,20 @@ export async function createLeadWorkerHarness(options) {
|
|
|
141
202
|
inputs.push(row);
|
|
142
203
|
activeInputs.add(team[role]);
|
|
143
204
|
try {
|
|
144
|
-
const result = await runInput(runtime, team[role], JSON.stringify(payload), { requestId, timeoutMs, signal: workSignal
|
|
205
|
+
const result = await runInput(runtime, team[role], JSON.stringify(payload), { requestId, timeoutMs, signal: workSignal,
|
|
206
|
+
beforeSend() { if (userControls.has(team[role]))
|
|
207
|
+
throw fail('MEMBER_HELD'); },
|
|
208
|
+
});
|
|
145
209
|
Object.assign(row, { inputId: result.inputId, receipt: result.receipt, state: 'completed', settled: { agentId: result.settled.agentId, outcome: result.settled.outcome } });
|
|
146
210
|
return result;
|
|
147
211
|
}
|
|
148
212
|
catch (error) {
|
|
149
213
|
Object.assign(row, { inputId: error.inputId, receipt: error.receipt, state: 'failed', code: error.code ?? 'INPUT_FAILED', uncertain: !['input_failed', 'input_aborted'].includes(error.code) });
|
|
214
|
+
if (userControls.has(team[role])) {
|
|
215
|
+
row.state = userControls.get(team[role]).kind === 'stop' ? 'user-stopped' : 'user-interrupted';
|
|
216
|
+
await waitForMember(team[role], workSignal);
|
|
217
|
+
return { status: row.state };
|
|
218
|
+
}
|
|
150
219
|
if (dynamic && error.code === 'input_unknown') {
|
|
151
220
|
const recorded = runtime.send(team[role], JSON.stringify(payload), { requestId, mode: 'followUp' });
|
|
152
221
|
try {
|
|
@@ -209,12 +278,14 @@ export async function createLeadWorkerHarness(options) {
|
|
|
209
278
|
runtime = await createRuntime({ sandbox, executor, models, connection, filePolicy, services, profiles, maxAgents: roles.length + (dynamic ? 1 : 0), outputDir, ...(dynamicControl ? { agentAccessPolicy: dynamicControl.agentAccessPolicy } : {}) });
|
|
210
279
|
if (startup.aborted)
|
|
211
280
|
throw fail('HARNESS_START_ABORTED');
|
|
212
|
-
options.onRuntime?.(runtime, snapshot, board.subscribe);
|
|
281
|
+
options.onRuntime?.(runtime, snapshot, board.subscribe, memberControls);
|
|
213
282
|
unsubscribe = runtime.onEvent((event) => {
|
|
214
283
|
if (event.type === 'session')
|
|
215
284
|
return;
|
|
216
285
|
if (events.length < (dynamic ? 2048 : 256))
|
|
217
286
|
events.push({ agentId: event.agentId, seq: events.length + 1, type: event.type, ...(event.outcome ? { outcome: event.outcome } : {}) });
|
|
287
|
+
if (userControls.has(event.agentId) && (event.type === 'settled' && event.outcome === 'aborted' || event.type === 'exit'))
|
|
288
|
+
return;
|
|
218
289
|
if (!dynamic && events.length >= 256 || event.type === 'error' && event.fatal || event.type === 'settled' && event.outcome !== 'completed' || event.type === 'exit' && !event.expected) {
|
|
219
290
|
if (!closing) {
|
|
220
291
|
recordFence({ agentId: event.agentId, code: 'AGENT_FAILED' });
|
|
@@ -246,7 +317,7 @@ export async function createLeadWorkerHarness(options) {
|
|
|
246
317
|
const workSignal = AbortSignal.any([lifetime.signal, AbortSignal.timeout(workTimeoutMs), ...(signal ? [signal] : [])]);
|
|
247
318
|
try {
|
|
248
319
|
workSignal.throwIfAborted();
|
|
249
|
-
const submitted = await runDynamicSchedule({ board, team, goal: dynamic.goal, signal: workSignal, dispatch: dispatchWork });
|
|
320
|
+
const submitted = await runDynamicSchedule({ board, team, goal: dynamic.goal, signal: workSignal, dispatch: dispatchWork, canDispatch: agentId => !userControls.has(agentId) });
|
|
250
321
|
if (!dynamic.verifyFinal)
|
|
251
322
|
return { submitted, harness: snapshot() };
|
|
252
323
|
const verdict = await dynamic.verifyFinal({ repositoryUrl: facilities.repositoryUrl, token: facilities.actors.lead.token,
|
|
@@ -40,8 +40,8 @@ const leadWorker = {
|
|
|
40
40
|
...config, sandbox, runId: context.runId.replaceAll('-', '').slice(0, 24), outputDir: context.outputDir,
|
|
41
41
|
signal: context.signal, projectFiles: context.initial.files, initialDigest: context.initial.digest,
|
|
42
42
|
dynamic: deploy ? { goal: context.input.prompt, projectFiles: context.initial.files, deploy } : undefined,
|
|
43
|
-
onRuntime: (runtime, snapshot, subscribeBoard) => {
|
|
44
|
-
observation = observeProjectRuntime(runtime, context, snapshot);
|
|
43
|
+
onRuntime: (runtime, snapshot, subscribeBoard, controls) => {
|
|
44
|
+
observation = observeProjectRuntime(runtime, context, snapshot, controls);
|
|
45
45
|
unsubscribeBoard = subscribeBoard(() => { void observation?.refresh(); });
|
|
46
46
|
},
|
|
47
47
|
beforeInitialDispatch: () => context.markRunning(),
|
|
@@ -25,6 +25,11 @@ export declare function createBoard({ path: databasePath, runId, helperCount, ve
|
|
|
25
25
|
};
|
|
26
26
|
}): void;
|
|
27
27
|
readyMember(agentId: string): void;
|
|
28
|
+
interveneMember({ agentId, kind, requestId }: {
|
|
29
|
+
agentId: string;
|
|
30
|
+
kind: 'interrupt' | 'stop';
|
|
31
|
+
requestId: string;
|
|
32
|
+
}): void;
|
|
28
33
|
subscribe(listener: () => void): () => boolean;
|
|
29
34
|
registerUserInput(requestId: any, input: any): void;
|
|
30
35
|
fence({ agentId, code, execution }?: any): void;
|
|
@@ -80,6 +80,8 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
80
80
|
const role = (dynamic ? member?.role : profile) === 'lead' ? 'lead' : 'helper';
|
|
81
81
|
if (!profile || dynamic && !member.ready || state.runtimeId !== caller.runtimeId || caller.profile !== profile || caller.binding !== `${runId}:board` || !permissions[role].includes(operation))
|
|
82
82
|
throw error('NOT_ALLOWED');
|
|
83
|
+
if (state.userInterventions?.[caller.agentId]?.kind === 'stop' && !['read', 'list_subtasks'].includes(operation))
|
|
84
|
+
throw error('MEMBER_STOPPED');
|
|
83
85
|
if ((memoryFenced || state.fenced) && !['read', 'list_subtasks'].includes(operation))
|
|
84
86
|
throw error('BOARD_FENCED');
|
|
85
87
|
return role;
|
|
@@ -104,7 +106,7 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
104
106
|
}
|
|
105
107
|
const registration = { 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' },
|
|
106
108
|
capabilities: Object.entries(capabilities).map(([operation, input_schema]) => ({ 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,
|
|
107
|
-
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) => ({ code, retryable: false })) })) },
|
|
109
|
+
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) => ({ code, retryable: false })) })) },
|
|
108
110
|
adapter: { async invoke({ capability, input, envelope, caller, signal, assertAuthorized }) {
|
|
109
111
|
const operation = capability.operation;
|
|
110
112
|
const state = load();
|
|
@@ -261,6 +263,22 @@ export function createBoard({ path: databasePath, runId, helperCount, verifyDeli
|
|
|
261
263
|
event(state, 'member_ready', agentId, { profile: member.profile, requestId: member.requestId });
|
|
262
264
|
});
|
|
263
265
|
},
|
|
266
|
+
interveneMember({ agentId, kind, requestId }) {
|
|
267
|
+
transaction((state) => {
|
|
268
|
+
if (!state.team || !Object.values(state.team).includes(agentId))
|
|
269
|
+
throw error('NOT_ALLOWED');
|
|
270
|
+
state.userInterventions ??= {};
|
|
271
|
+
const previous = state.userInterventions[agentId];
|
|
272
|
+
if (previous?.kind === 'stop')
|
|
273
|
+
return;
|
|
274
|
+
const intervention = { kind, requestId };
|
|
275
|
+
state.userInterventions[agentId] = intervention;
|
|
276
|
+
for (const task of state.subtasks)
|
|
277
|
+
if (task.owner === agentId && task.state !== 'complete')
|
|
278
|
+
task.intervention = intervention;
|
|
279
|
+
event(state, 'user_control', agentId, intervention);
|
|
280
|
+
});
|
|
281
|
+
},
|
|
264
282
|
subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); },
|
|
265
283
|
registerUserInput(requestId, input) { transaction((state) => { 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) => row.requestId === requestId))
|
|
266
284
|
throw error('NOT_ALLOWED'); state.userInputs.push({ requestId, sha256: createHash('sha256').update(input).digest('hex') }); }); },
|
|
@@ -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 `anyswarm 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.
|
|
@@ -7,6 +7,8 @@ export declare function runMessageHandoff(config: HandoffConfig, abort: AbortSig
|
|
|
7
7
|
ready(): void;
|
|
8
8
|
observe(runtime: Runtime): () => void;
|
|
9
9
|
progress?(state: unknown): void;
|
|
10
|
+
inputSignal?(agentId: string): AbortSignal;
|
|
11
|
+
assertMember?(agentId: string): void;
|
|
10
12
|
}): Promise<{
|
|
11
13
|
report: {
|
|
12
14
|
runtimeId: string;
|
|
@@ -61,10 +61,13 @@ export async function runMessageHandoff(config, abort, onEvent = () => { }, proj
|
|
|
61
61
|
submissions.push(submission);
|
|
62
62
|
project?.progress?.({ stage: operation, key, agentId, operationId, requestId });
|
|
63
63
|
try {
|
|
64
|
-
const
|
|
64
|
+
const local = project?.inputSignal?.(agentId);
|
|
65
|
+
const turn = await runInput(runtime, agentId, input, { requestId, signal: local ? AbortSignal.any([signal, local]) : signal,
|
|
66
|
+
timeoutMs: config.workTimeoutMs, beforeSend: () => project?.assertMember?.(agentId) });
|
|
65
67
|
submission.inputId = turn.inputId;
|
|
66
68
|
}
|
|
67
69
|
catch (error) {
|
|
70
|
+
project?.assertMember?.(agentId);
|
|
68
71
|
const turn = error;
|
|
69
72
|
submission.inputId = turn.inputId;
|
|
70
73
|
if (turn.code === 'agent_exited' || turn.code === 'agent_failed')
|
|
@@ -77,6 +80,7 @@ export async function runMessageHandoff(config, abort, onEvent = () => { }, proj
|
|
|
77
80
|
throw error;
|
|
78
81
|
}
|
|
79
82
|
signal.throwIfAborted();
|
|
83
|
+
project?.assertMember?.(agentId);
|
|
80
84
|
const call = calls.get(callKey(agentId, operation, operationId));
|
|
81
85
|
if (!call || (operation === 'put' ? call.author !== agentId : call.text !== writtenText))
|
|
82
86
|
throw failure('HANDOFF_SERVICE_UNCONFIRMED');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { observeProjectRuntime, projectConfiguration, ProjectPreflightError } from '@anyswarm/core';
|
|
1
|
+
import { AnySwarmError, getExecutorCapabilities, observeProjectRuntime, projectConfiguration, ProjectPreflightError } from '@anyswarm/core';
|
|
2
2
|
import { runMessageHandoff } from './handoff.js';
|
|
3
3
|
import { handoffConfig } from './handoff-config.js';
|
|
4
4
|
const messages = {
|
|
@@ -10,15 +10,65 @@ const messages = {
|
|
|
10
10
|
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Messages requires finite work and cleanup time limits');
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
const interventions = [];
|
|
14
|
+
const blocked = new Set();
|
|
15
|
+
const waits = new Map();
|
|
16
|
+
const assertMember = (agentId) => {
|
|
17
|
+
if (blocked.has(agentId))
|
|
18
|
+
throw new AnySwarmError('MEMBER_WORK_CANCELLED', 'The owner intervened in this member’s work');
|
|
19
|
+
};
|
|
13
20
|
let business = { stage: 'put' };
|
|
14
21
|
let observation;
|
|
15
22
|
const { report, submissions } = await runMessageHandoff({ ...config, outputDir: context.outputDir }, context.signal, undefined, {
|
|
16
23
|
files: context.initial.files, prompt: context.input.prompt,
|
|
17
24
|
artifact: `anyswarm-message-${context.runId}.txt`, ready: context.markRunning,
|
|
18
25
|
observe(runtime) {
|
|
19
|
-
|
|
26
|
+
const native = getExecutorCapabilities(config.executor ?? 'pi');
|
|
27
|
+
const controlEffects = (core) => ({ core, harnessEffects: { memberWork: 'cancelled', status: 'complete' } });
|
|
28
|
+
const intervene = async (operation, agentId, requestId) => {
|
|
29
|
+
blocked.add(agentId);
|
|
30
|
+
interventions.push({ agentId, operation, requestId });
|
|
31
|
+
context.emit({ kind: 'user-intervention', agentId, operation, requestId });
|
|
32
|
+
void observation?.refresh();
|
|
33
|
+
try {
|
|
34
|
+
const core = operation === 'interrupt' ? await runtime.interrupt(agentId, { requestId })
|
|
35
|
+
: await runtime.stop(agentId, { timeoutMs: config.cleanupTimeoutMs });
|
|
36
|
+
return controlEffects(core);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
waits.get(agentId)?.abort();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
observation = observeProjectRuntime(runtime, context, () => Object.assign({}, business, { interventions }), {
|
|
43
|
+
capabilities: {
|
|
44
|
+
send: { supported: native.activeSteer, text: true, modes: ['steer'] },
|
|
45
|
+
interrupt: { supported: native.queuedInputCancellation }, stop: { supported: true },
|
|
46
|
+
},
|
|
47
|
+
handlers: {
|
|
48
|
+
send(agentId, payload, request) {
|
|
49
|
+
assertMember(agentId);
|
|
50
|
+
const { input, options } = payload;
|
|
51
|
+
return runtime.send(agentId, input, { ...options, mode: 'steer', wakeIfIdle: false, requestId: request.operationId });
|
|
52
|
+
},
|
|
53
|
+
interrupt: (agentId, _payload, request) => intervene('interrupt', agentId, request.operationId),
|
|
54
|
+
stop: (agentId, _payload, request) => intervene('stop', agentId, request.operationId),
|
|
55
|
+
},
|
|
56
|
+
async reconcile(operation, agentId, request) {
|
|
57
|
+
if (operation === 'stop')
|
|
58
|
+
return controlEffects(await runtime.stop(agentId, { timeoutMs: config.cleanupTimeoutMs }));
|
|
59
|
+
const core = await observation.reconcile(agentId, operation, request.operationId);
|
|
60
|
+
return operation === 'interrupt' ? controlEffects(core) : core;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
20
63
|
return observation.close;
|
|
21
64
|
},
|
|
65
|
+
inputSignal(agentId) {
|
|
66
|
+
assertMember(agentId);
|
|
67
|
+
const wait = new AbortController();
|
|
68
|
+
waits.set(agentId, wait);
|
|
69
|
+
return wait.signal;
|
|
70
|
+
},
|
|
71
|
+
assertMember,
|
|
22
72
|
progress(state) {
|
|
23
73
|
business = state;
|
|
24
74
|
void observation?.refresh();
|
|
@@ -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/anyswarm run "$example/main.ts" --help
|
|
45
|
+
node_modules/.bin/anyswarm 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/anyswarm 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
|
|