@anyswarm/core 0.5.2 → 0.6.0

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.
Files changed (210) hide show
  1. package/AGENTS.md +19 -4
  2. package/README.md +68 -61
  3. package/dist/examples/README.md +134 -84
  4. package/dist/examples/autoresearch/README.md +106 -21
  5. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
  6. package/dist/examples/autoresearch/config.d.ts +48 -5
  7. package/dist/examples/autoresearch/config.js +57 -23
  8. package/dist/examples/autoresearch/demo.d.ts +12 -4
  9. package/dist/examples/autoresearch/demo.js +65 -22
  10. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -2
  11. package/dist/examples/autoresearch/frontiercs2-config.js +13 -2
  12. package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
  13. package/dist/examples/autoresearch/frontiercs2.js +71 -14
  14. package/dist/examples/autoresearch/prepare-demo.js +34 -3
  15. package/dist/examples/autoresearch/prepare.d.ts +105 -53
  16. package/dist/examples/autoresearch/prepare.js +126 -57
  17. package/dist/examples/autoresearch/project.d.ts +6 -1
  18. package/dist/examples/autoresearch/project.js +130 -26
  19. package/dist/examples/autoresearch/research-service.d.ts +16 -1
  20. package/dist/examples/autoresearch/research-service.js +84 -44
  21. package/dist/examples/code/config.d.ts +1 -0
  22. package/dist/examples/first-harness/AGENTS.md +25 -0
  23. package/dist/examples/first-harness/README.md +136 -0
  24. package/dist/examples/first-harness/config.d.ts +9 -8
  25. package/dist/examples/first-harness/config.js +33 -26
  26. package/dist/examples/first-harness/eject.json +14 -0
  27. package/dist/examples/first-harness/handoff.js +3 -3
  28. package/dist/examples/first-harness/harness.d.ts +14 -18
  29. package/dist/examples/first-harness/harness.js +102 -77
  30. package/dist/examples/first-harness/input/README.md +7 -0
  31. package/dist/examples/first-harness/session.js +2 -1
  32. package/dist/examples/first-harness/tsconfig.json +2 -1
  33. package/dist/examples/harness-session/README.md +1 -1
  34. package/dist/examples/lead-worker/README.md +1 -1
  35. package/dist/examples/lead-worker/project-config.d.ts +1 -0
  36. package/dist/examples/messages/README.md +2 -2
  37. package/dist/examples/notes/README.md +2 -2
  38. package/dist/examples/notes/config.d.ts +1 -0
  39. package/dist/examples/parallel-swarm/AGENTS.md +32 -0
  40. package/dist/examples/parallel-swarm/README.md +136 -0
  41. package/dist/examples/parallel-swarm/board-service.js +25 -8
  42. package/dist/examples/parallel-swarm/board.d.ts +31 -1
  43. package/dist/examples/parallel-swarm/board.js +98 -13
  44. package/dist/examples/parallel-swarm/config.d.ts +11 -0
  45. package/dist/examples/parallel-swarm/config.js +39 -0
  46. package/dist/examples/parallel-swarm/eject.json +5 -0
  47. package/dist/examples/parallel-swarm/harness.d.ts +26 -20
  48. package/dist/examples/parallel-swarm/harness.js +77 -76
  49. package/dist/examples/parallel-swarm/report.d.ts +12 -0
  50. package/dist/examples/parallel-swarm/report.js +30 -0
  51. package/dist/examples/peermesh/README.md +1 -1
  52. package/dist/examples/peermesh/project-config.d.ts +1 -0
  53. package/dist/examples/services/agent-control/README.md +1 -1
  54. package/dist/examples/services/mathlib-search/README.md +1 -1
  55. package/dist/examples/services/mcp-managed/README.md +1 -1
  56. package/dist/examples/services/persistent-board/README.md +1 -1
  57. package/dist/examples/subagents/AGENTS.md +35 -0
  58. package/dist/examples/subagents/README.md +129 -93
  59. package/dist/examples/subagents/config.d.ts +2 -10
  60. package/dist/examples/subagents/config.js +8 -15
  61. package/dist/examples/subagents/eject.json +17 -0
  62. package/dist/examples/subagents/handoff-config.d.ts +41 -0
  63. package/dist/examples/subagents/handoff-config.js +13 -0
  64. package/dist/examples/subagents/model.d.ts +3 -0
  65. package/dist/examples/subagents/model.js +19 -0
  66. package/dist/examples/substrate/README.md +12 -6
  67. package/dist/examples/substrate/config.d.ts +1 -0
  68. package/dist/examples/substrate/project-config.d.ts +1 -0
  69. package/dist/examples/taskpool/README.md +1 -1
  70. package/dist/examples/taskpool/config.d.ts +1 -0
  71. package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
  72. package/dist/scripts/anyswarm-progress.js +36 -5
  73. package/dist/scripts/build-provenance.json +1 -1
  74. package/dist/scripts/generate-architecture-coverage.js +1 -1
  75. package/dist/scripts/generate-architecture-prompts.js +18 -10
  76. package/dist/scripts/local-environment.d.ts +3 -3
  77. package/dist/scripts/local-environment.js +6 -1
  78. package/dist/scripts/local-setup.js +25 -18
  79. package/dist/scripts/pack-release.js +27 -3
  80. package/dist/src/core/index.js +1 -1
  81. package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
  82. package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
  83. package/dist/src/core/sandbox/sandbox-connection.js +22 -7
  84. package/dist/src/harness/project-harness.js +3 -2
  85. package/dist/src/harness/project-rpc-client.js +19 -0
  86. package/dist/src/harness/typescript-loader.d.ts +2 -0
  87. package/dist/src/harness/typescript-loader.js +26 -8
  88. package/dist/src/trace-viewer/command.mjs +6 -3
  89. package/dist/src/trace-viewer/public/app.js +239 -59
  90. package/dist/src/trace-viewer/public/index.html +5 -0
  91. package/dist/src/trace-viewer/public/style.css +22 -0
  92. package/dist/src/trace-viewer/reader.mjs +242 -26
  93. package/dist/src/trace-viewer/run-root.d.mts +1 -0
  94. package/dist/src/trace-viewer/run-root.mjs +7 -0
  95. package/dist/src/trace-viewer/server.mjs +3 -1
  96. package/docs/INDEX.md +9 -8
  97. package/docs/architecture/06-observability-experiments.md +21 -7
  98. package/docs/architecture/07-run-configuration.md +97 -12
  99. package/docs/architecture/08-prompts.md +21 -2
  100. package/docs/architecture/10-service-api-reference.md +12 -5
  101. package/docs/architecture/12-code-coverage.md +129 -86
  102. package/docs/architecture/15-core-runtime.md +1 -1
  103. package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
  104. package/docs/architecture/17-harness-reporting.md +78 -0
  105. package/docs/architecture/22-website.md +53 -18
  106. package/docs/architecture/23-project-harness.md +63 -16
  107. package/docs/architecture/28-autoresearch.md +16 -22
  108. package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
  109. package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
  110. package/docs/architecture/prompts/22-autoresearch.md +9 -2
  111. package/docs/architecture/prompts/source-manifest.json +78 -54
  112. package/docs/architecture/source-map.json +396 -36
  113. package/docs/designs/core-harness/06-project-harness.md +1 -1
  114. package/docs/en/autoresearch.md +41 -0
  115. package/docs/en/blog/100b-tokens.md +157 -0
  116. package/docs/en/build-your-harness.md +47 -22
  117. package/docs/en/changelog.md +22 -1
  118. package/docs/en/first-harness.md +40 -32
  119. package/docs/en/harnesses/index.md +23 -23
  120. package/docs/en/harnesses/subagents.md +8 -29
  121. package/docs/en/latest.md +26 -5
  122. package/docs/en/overview.md +22 -22
  123. package/docs/en/quickstart.md +55 -21
  124. package/docs/en/reference/api.md +1 -1
  125. package/docs/en/trace-viewer.md +32 -12
  126. package/docs/operations/trace-viewer.md +25 -10
  127. package/docs/workflows/development.md +160 -120
  128. package/docs/workflows/release-and-docs-versioning.md +207 -55
  129. package/docs/workflows/release-cli-acceptance.md +124 -47
  130. package/docs/zh/autoresearch.md +41 -0
  131. package/docs/zh/blog/100b-tokens.md +102 -0
  132. package/docs/zh/build-your-harness.md +48 -23
  133. package/docs/zh/changelog.md +22 -1
  134. package/docs/zh/first-harness.md +43 -35
  135. package/docs/zh/harnesses/index.md +23 -23
  136. package/docs/zh/harnesses/subagents.md +8 -29
  137. package/docs/zh/latest.md +26 -5
  138. package/docs/zh/overview.md +23 -23
  139. package/docs/zh/quickstart.md +51 -21
  140. package/docs/zh/reference/api.md +1 -1
  141. package/docs/zh/trace-viewer.md +32 -12
  142. package/examples/README.md +134 -84
  143. package/examples/autoresearch/README.md +106 -21
  144. package/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
  145. package/examples/autoresearch/config.ts +64 -25
  146. package/examples/autoresearch/demo.ts +75 -22
  147. package/examples/autoresearch/frontiercs2-config.ts +13 -2
  148. package/examples/autoresearch/frontiercs2.ts +64 -11
  149. package/examples/autoresearch/prepare-demo.ts +32 -3
  150. package/examples/autoresearch/prepare.ts +134 -60
  151. package/examples/autoresearch/project.ts +119 -26
  152. package/examples/autoresearch/research-service.ts +91 -41
  153. package/examples/first-harness/AGENTS.md +25 -0
  154. package/examples/first-harness/README.md +136 -0
  155. package/examples/first-harness/config.ts +41 -27
  156. package/examples/first-harness/eject.json +14 -0
  157. package/examples/first-harness/handoff.ts +3 -3
  158. package/examples/first-harness/harness.ts +104 -72
  159. package/examples/first-harness/input/README.md +7 -0
  160. package/examples/first-harness/session.ts +2 -1
  161. package/examples/first-harness/tsconfig.json +2 -1
  162. package/examples/harness-session/README.md +1 -1
  163. package/examples/lead-worker/README.md +1 -1
  164. package/examples/messages/README.md +2 -2
  165. package/examples/notes/README.md +2 -2
  166. package/examples/parallel-swarm/AGENTS.md +32 -0
  167. package/examples/parallel-swarm/README.md +136 -0
  168. package/examples/parallel-swarm/board-service.ts +28 -9
  169. package/examples/parallel-swarm/board.ts +107 -13
  170. package/examples/parallel-swarm/config.ts +47 -0
  171. package/examples/parallel-swarm/eject.json +5 -0
  172. package/examples/parallel-swarm/harness.ts +83 -71
  173. package/examples/parallel-swarm/report.ts +33 -0
  174. package/examples/peermesh/README.md +1 -1
  175. package/examples/services/agent-control/README.md +1 -1
  176. package/examples/services/mathlib-search/README.md +1 -1
  177. package/examples/services/mcp-managed/README.md +1 -1
  178. package/examples/services/persistent-board/README.md +1 -1
  179. package/examples/subagents/AGENTS.md +35 -0
  180. package/examples/subagents/README.md +129 -93
  181. package/examples/subagents/config.ts +8 -15
  182. package/examples/subagents/eject.json +17 -0
  183. package/examples/subagents/handoff-config.ts +14 -0
  184. package/examples/subagents/model.ts +20 -0
  185. package/examples/substrate/README.md +12 -6
  186. package/examples/taskpool/README.md +1 -1
  187. package/npm-shrinkwrap.development.json +9 -2
  188. package/npm-shrinkwrap.json +9 -2
  189. package/package.development.json +2 -1
  190. package/package.json +2 -1
  191. package/scripts/anyswarm-progress.ts +36 -6
  192. package/scripts/generate-architecture-coverage.ts +1 -1
  193. package/scripts/generate-architecture-prompts.ts +21 -10
  194. package/scripts/local-environment.ts +8 -1
  195. package/scripts/local-setup.ts +22 -17
  196. package/scripts/pack-release.ts +24 -3
  197. package/src/core/index.ts +1 -1
  198. package/src/core/sandbox/opensandbox-backend.ts +10 -4
  199. package/src/core/sandbox/sandbox-connection.ts +22 -7
  200. package/src/harness/project-harness.ts +3 -2
  201. package/src/harness/project-rpc-client.ts +23 -0
  202. package/src/harness/typescript-loader.ts +28 -8
  203. package/src/trace-viewer/command.mjs +6 -3
  204. package/src/trace-viewer/public/app.js +239 -59
  205. package/src/trace-viewer/public/index.html +5 -0
  206. package/src/trace-viewer/public/style.css +22 -0
  207. package/src/trace-viewer/reader.mjs +242 -26
  208. package/src/trace-viewer/run-root.d.mts +1 -0
  209. package/src/trace-viewer/run-root.mjs +7 -0
  210. package/src/trace-viewer/server.mjs +3 -1
@@ -0,0 +1,157 @@
1
+ ---
2
+ title: What Burning 100B Tokens on Agent Swarms Taught Us
3
+ description: Why large-scale multi-agent swarms break past hour one — and why AnySwarm separates the minimal Sandbox Runtime from user-space Harnesses, host-governed Services, and Coding-Agent observability.
4
+ section: ESSAYS
5
+ order: 1
6
+ ---
7
+
8
+ > **TL;DR:** Let your Coding Agent write the **Harness**. Never let it improvise the **Runtime**.
9
+
10
+ ## 1. Lessons from Burning 100B Tokens
11
+
12
+ Shortly after the formalization of Fermat's Last Theorem was completed, our team tried to push the frontier further using large-scale agent swarms. The intuition felt obvious at the time: single coding and reasoning agents had already gotten remarkably capable, so if we threw enough parallel compute at hard formalization and engineering problems, a swarm of dozens of agents ought to break through walls a single session never could.
13
+
14
+ We hit wall after wall. By the time we called it, we had burned through **100 billion tokens**—and failed.
15
+
16
+ What broke us wasn't that an individual model couldn't write a proof tactic or edit a module. What broke us was everything that happens *between* agents once a run stretches past the first hour. Three agents would read the same shared state and still independently spend twenty minutes constructing and submitting the exact same flawed approach, byte for byte. One agent would disprove a tempting assumption, yet an hour later, downstream agents were still building on the invalidated premise because stale context lingered alongside new receipts. Containers that timed out during teardown wiped uncommitted work.
17
+
18
+ Worst of all was trying to iterate. Every time we realized our coordination structure was wrong—say, shifting from flat peer claims to explicit decomposition and integration roles—we had to rip up and rewrite the underlying container plumbing, session lifecycles, tool permissions, and state synchronization all over again. And when a multi-hour run plateaued, staring at massive, tangled trace files left both us and our coding agents unable to answer basic questions: *Did the swarm stall because the task model was flawed, or because our queue locked up? Did all that inter-agent chatter produce useful progress, or just burn millions of tokens in circles?*
19
+
20
+ Looking across the open-source ecosystem over the past year, it became clear this wasn't just our pain. Single-agent architecture has largely converged—projects like **Pi** (with its minimal `read / write / edit / bash` core) and **DeepSeek Harness** (with its plugin microkernel) proved you don't need a bloated framework to run one capable agent. Yet the moment you step into **multi-agent swarms**, the ecosystem fractures completely, and everyone goes right back to reinventing infrastructure from scratch.
21
+
22
+ Like early applications written before operating systems existed—where every program had to manage its own memory, disk I/O, and scheduling—today's multi-agent projects keep rebuilding a fragile distributed runtime just to test a new coordination idea.
23
+
24
+ We built **AnySwarm** out of those scars. Instead of proposing yet another "one true orchestration framework," AnySwarm cleanly separates **how you run and isolate a fleet of agents (the Runtime)** from **how you organize them to collaborate (the Harness)**.
25
+
26
+ ![Figure 1. A Harness defines coordination policy, while one Runtime manages isolated agent sessions and governs access to shared Services.](../../../website/public/blog/anyswarm-system-architecture.png)
27
+
28
+ *Figure 1. A Harness defines coordination policy, while one Runtime manages isolated agent sessions and governs access to shared Services. Agent archives and Service state remain independently inspectable; sandbox deletion follows confirmed export.*
29
+
30
+ ---
31
+
32
+ ## 2. Decoupling Runtime from Harness: Looking Beneath Today's Open-Source Systems
33
+
34
+ Why hasn't the community converged on a single multi-agent standard—and how can a minimal foundation unify systems that look nothing alike? Rather than repeating how existing projects describe themselves, it is much more revealing to dissect what they actually do under the hood.
35
+
36
+ Take three of the most compelling multi-agent designs from the past year: **SwarmChat**, **ScaleMAS**, and **DeepSeek's Super-agent**.
37
+
38
+ On the surface, they couldn't be more different. SwarmChat models collaboration as a Slack workspace for agents, complete with channels, threads, and role policies. ScaleMAS (from FAIR and Harvard) throws out peer-to-peer chat and central coordinators altogether: 128 asynchronous agents never speak to each other, interacting solely with a shared citation datastore. DeepSeek's Super-agent optimizes for continuous human interaction across IM and GitHub, pairing a persistent lightweight Router session with silent, isolated background Workers.
39
+
40
+ Strip away the surface abstractions, however, and every one of these systems is built from the exact same two layers.
41
+
42
+ At the bottom sits an identical execution primitive. Whether an agent is waiting in a SwarmChat channel, exploring hypotheses in ScaleMAS, or executing a ticket as a Super-agent Worker, each participant is simply **an isolated, stateful single-agent session equipped with basic local tools**. Every system needs a way to spawn that session on demand, keep its context alive across turns without burning tokens while idle (the exact reason SwarmChat built its blocking `swarmchat wait` command), inject course-corrections or interrupt a runaway turn mid-flight, proxy model requests without leaking credentials, and safely extract files when the work ends.
43
+
44
+ All the magic that makes these systems behave differently lives strictly in the layer above—specifically, in **how shared state is modeled** and **how the outer loop schedules turns**:
45
+
46
+ - **SwarmChat** models shared state as rooms and read cursors, waking agents when matching messages arrive.
47
+ - **ScaleMAS** models shared state as an immutable graph exposing just three operations—`Publish` with explicit citations, `Search` capped at top-*k* results (ranked by relevance and citation count so context reading burden stays bounded as the group grows), and `Visit`—while its outer loop simply drives peers through parallel rounds.
48
+ - **Super-agent** models shared state as event triggers and thread subscriptions, using a persistent Router session for cold-start dispatch while routing follow-up events on subscribed threads directly to Workers.
49
+
50
+ Once you see this seam, the reason everyone keeps reinventing the wheel becomes obvious: existing implementations fuse a thin, task-specific coordination contract together with heavy execution, isolation, bridging, and logging plumbing.
51
+
52
+ AnySwarm splits the stack right along that seam. Everything homogeneous—sandbox lifecycle, persistent non-blocking session control (`spawn`, `send`, `interrupt`, `stop`), credential-free model and tool gateways, and artifact recovery—is pushed down into the **Runtime**. Everything expressive—what shared services exist, who talks to whom, and when a run finishes—stays in user-space as a lightweight **Harness**. Switching from a chat-driven team to a citation substrate no longer means building a new distributed system; it means swapping a few hundred lines of host control code.
53
+
54
+ ---
55
+
56
+ ## 3. Unified Services Over A2A: Future Software Will Be Apps Built for Agents
57
+
58
+ Once agents run in separate sandboxes, how should they coordinate?
59
+
60
+ The most common instinct is to wire up direct **Agent-to-Agent (A2A)** messaging—giving agents a `send_message(peer_id)` tool and letting them negotiate in natural language. In our own long-horizon runs, unstructured A2A was consistently where swarms fell apart. As concurrency grows, peer-to-peer chatter floods context windows, dilutes signal, and leaves the group without a single source of truth. Worse, **natural language cannot enforce deterministic invariants**. When Agent A tells Agent B *"I fixed the parser and tests pass,"* prose alone cannot enforce an atomic lock, validate a schema, check permissions, or verify that the test suite actually ran.
61
+
62
+ This led us to a broader conviction that shapes AnySwarm's core design: **in the future, most software we build will be apps written for agents.**
63
+
64
+ For decades, software like GitHub, Jira, Slack, and internal dashboards was built with humans in the inner loop—clicking buttons, claiming tickets, reviewing diffs, and resolving conflicts. As agents take over execution, humans are moving to the outermost loop: specifying an objective, a budget, or an evaluator. Inside the system, the primary users reading state, coordinating work, and producing artifacts 24/7 are hundreds or thousands of concurrent agents.
65
+
66
+ The interface changes from GUIs to structured calls, **but the classical fundamentals of software engineering matter more than ever**. When hundreds of agents collaborate, they still need transactions, leases, and optimistic concurrency control so they don't overwrite each other's work; they need caching and bounded pagination so shared state doesn't blow up context windows; and they need strict access control and objective verification gates so hallucinations don't poison the mainline.
67
+
68
+ That is why AnySwarm deliberately omits raw A2A messaging from the Runtime core. Instead, **every shared state mechanism and external capability is built as a host-governed Service—essentially a micro-app for agents.**
69
+
70
+ Inside its sandbox, an agent holds only basic local tools (`read`, `write`, `edit`, `bash`) and a unified `swarm` CLI. On the host side, a Harness registers typed Services—whether that's a lease-backed task pool, a citation substrate, an authoritative benchmark leaderboard, or even a Slack-style chat room—defined by a JSON Schema `ServiceManifest` and an adapter.
71
+
72
+ Every call from a sandbox passes through AnySwarm's **Service Bridge**. Before touching business logic, the Bridge authenticates the container's token, validates input/output schemas, enforces per-profile ACLs, and injects an **unforgeable `caller` identity (`agentId`, `profile`, `runtimeId`)**. An agent cannot spoof a teammate's identity, bypass a read-only role, or declare victory by assertion—a submission Service can deterministically run the compiler or test suite on the host and reject broken work at the gate. Even chat becomes just another pluggable Service rather than a privileged runtime backdoor.
73
+
74
+ ---
75
+
76
+ ## 4. Designing for True Scale: Compute, Workspaces, and Why We Chose OpenSandbox
77
+
78
+ Isolating each agent in its own container while keeping API keys and external secrets strictly on the host is table stakes. The far harder systems question is **scale**.
79
+
80
+ If we look slightly ahead, serious engineering and research workloads won't stop at four or eight agents—they will orchestrate tens of thousands, hundreds of thousands, or eventually **millions of agent sessions and sandbox lifecycles**. At that scale, naive container wrappers hit brutal physical walls: *Where does compute run? Where do massive codebases and intermediate workspaces live? How do you schedule, snapshot, and tear down thousands of environments across machines without losing work or choking a central controller?*
81
+
82
+ Answering this requires decoupling control, execution, workspace data, and service state so each scales along its own axis.
83
+
84
+ On the compute plane, rather than maintaining custom Docker shell scripts, we built AnySwarm's execution backend on top of **OpenSandbox**. What made OpenSandbox the right foundation is its clean architectural split between the **Lifecycle Control Plane** and the **Data Plane (`execd`)**. Provisioning, pausing, renewing, and destroying sandboxes go through the lifecycle API; once a sandbox is live, command execution, PTY streaming, and file operations talk directly to a lightweight Go daemon (`execd`) inside the environment, preventing the orchestrator from becoming an I/O bottleneck under heavy concurrency.
85
+
86
+ Local setup provisions OpenSandbox through Docker. Controllers can also use an existing OpenSandbox endpoint, with isolation and egress policy determined by that deployment. The Harness API stays the same when a trusted Sandbox Provider supplies the execution environment.
87
+
88
+ Managing **workspaces and data** across thousands of agents requires equal care. Cloning multi-gigabyte repositories from scratch for every exploratory agent—or mounting one mutable directory across dozens of concurrent writers—collapses quickly. Inside each sandbox, AnySwarm pairs a privileged lightweight supervisor (**Worker**) with the unprivileged **Agent** process to make file state explicit and incremental:
89
+
90
+ - Profiles can start with a read-only workspace (`writable: false`). A Harness can grant a writable mount through `runtime.files.replace` after a host Service has assigned work.
91
+ - Mid-run, the Worker can briefly pause local writers to capture consistent file snapshots.
92
+ - At teardown, AnySwarm strictly decouples **Stop → Export → Delete**: the Worker halts the Agent process first, exports full session transcripts and required artifacts back to the host, and deletes the sandbox *only* after archival is confirmed—preserving failed exports in a `cleanup: pending` state for recovery instead of silently destroying hours of compute.
93
+
94
+ Finally, Service state itself isn't trapped in host memory. Because AnySwarm abstracts Services behind clean adapters, a prototype can run a Service in-process (`inProcessService`) backed by SQLite, and later scale out to standalone HTTP microservices (`httpService`) backed by distributed databases, caches, or message queues—without changing a single line of agent prompt or Runtime code.
95
+
96
+ ---
97
+
98
+ ## 5. Observability Built for Coding Agents
99
+
100
+ There is a blind spot in almost every multi-agent observability tool today: **they assume a human is the one reading the logs.**
101
+
102
+ In practice, as we iterated on swarms day after day, the primary engineer inspecting failed runs, hunting down bottlenecks, and patching Harness code wasn't a human squinting at browser tabs—**it was our Coding Agent**.
103
+
104
+ Once you design observability for a Coding Agent operating at cluster scale, dumping everything into a single flat `events.jsonl` file breaks down immediately. A large swarm run generates tens of thousands of model turns, bash outputs, and state transitions totaling hundreds of megabytes. Handing a monolithic JSONL dump to a Coding Agent blows through its context window before it can even form a hypothesis.
105
+
106
+ To make large-scale swarms genuinely debuggable by Coding Agents, AnySwarm structures every run directory (`outputDir/<runId>/`) into **two decoupled, cross-linked layers**:
107
+
108
+ 1. **Per-Agent Partitioned Execution Archives.** Every agent's complete native session history, tool invocations, and exported workspace artifacts are isolated under its own namespace (`<runtimeId>/<agentId>/`), cross-referenced with sanitized model requests and streaming responses (`model-trace/`). Instead of grepping through gigabytes of interleaved noise, a Coding Agent can inspect high-level run summaries first, pinpoint an anomalous worker, and drill down into that single agent's trajectory on demand.
109
+ 2. **Independent Service records.** Service calls are recorded in `service-calls.jsonl`. A Service adapter can export its own state for inspection in Trace. Recovery of business state depends on the Service and its backing store.
110
+
111
+ Combining **inner per-agent archives** with **outer replayable Service state** unlocks true systems-level diagnostics. Instead of merely checking whether an agent threw a syntax error, a Coding Agent can write a quick script over a run directory to answer structural questions:
112
+
113
+ - *Did throughput flatten because task decomposition was too coarse, leaving the queue starved while agents sat idle—or because a slow worker held onto a critical lease?*
114
+ - *Did the shared Message Board or Substrate Service become a lock-contention bottleneck under bursty writes?*
115
+ - *Agents exchanged ten thousand messages and search queries—did that communication actually get cited in accepted downstream work, or did the swarm just burn tokens talking to itself?*
116
+
117
+ And whenever a human *does* want to inspect a run visually, the exact same directory opens instantly in AnySwarm's zero-dependency browser **[Trace Viewer](../trace-viewer.md)** (`anyswarm trace`), rendering parallel agent swimlanes, Service handoffs, and exported diffs side by side.
118
+
119
+ ![Figure 2. Per-agent archives and independent Service records provide complementary views of a run.](../../../website/public/blog/anyswarm-run-observability.png)
120
+
121
+ *Figure 2. Per-agent archives and independent Service records provide complementary views of a run. This conceptual view shows how an investigation moves from a run overview to a selected agent and its related evidence.*
122
+
123
+ ---
124
+
125
+ ## 6. Putting It Together: Reference Harnesses on One Unmodified Runtime
126
+
127
+ To test how far this separation of Runtime and Harness stretches in practice, we built orthogonal reference Harnesses on top of the exact same, unmodified `@anyswarm/core` Runtime—each targeting a distinct problem shape, topology, and stopping condition, driven through a deterministic CLI, TypeScript SDK, or programmatic JSONL RPC rather than a monolithic terminal UI.
128
+
129
+ **`AutoResearch` (`examples/autoresearch` — Leaderless Metric-Driven Optimization)** lets peers investigate a target, share candidate patches and review each other through the research Service. A trusted evaluator scores candidates. The Harness records the candidate identity and evaluation receipts for later inspection.
130
+
131
+ **`Code` (`examples/code` — Patch Delivery)** runs repository work in an isolated workspace. The Harness can run configured host checks before applying a patch. When checks are disabled or there is no applicable verifier, the result records the verification status separately.
132
+
133
+ **`Personal / Router` (`examples/super` — Least-Privilege Scoped Delegation)** demonstrates how a persistent host Router can delegate background GitHub Issue/PR subtasks to short-lived, isolated sandboxes, granting each sandbox only the narrow Service permissions its subtask requires while keeping raw credentials and the host filesystem strictly outside worker containers.
134
+
135
+ | Reference Harness | Input | Harness Topology | Host responsibilities |
136
+ | --- | --- | --- | --- |
137
+ | **`autoresearch`** | Target Code + Evaluator | Leaderless Peer Swarm Converging on Objective Scores | Candidate ownership, peer review and evaluation |
138
+ | **`code`** | Repo + Task / Spec | Isolated Delegation + Deterministic Host Verification | Workspace capture, configured checks and patch application |
139
+ | **`super`** | Scoped GitHub / Inbox Events | Persistent Host Router + Least-Privilege Sandboxes | Scoped GitHub access and Draft PR approval |
140
+
141
+ Alongside these prototypes, the repository ships five focused reference topologies—[Subagents](../harnesses/subagents.md), [TaskPool](../harnesses/taskpool.md), [PeerMesh](../harnesses/peermesh.md), [Substrate](../harnesses/substrate.md), and [Lead-Worker](../harnesses/lead-worker.md)—all running on the same Runtime.
142
+
143
+ ---
144
+
145
+ ## 7. Open Questions & Getting Started
146
+
147
+ Separating the Runtime from the Harness doesn't magically solve multi-agent intelligence—it clears away the infrastructure rubble so we can finally study the real problems cleanly.
148
+
149
+ Hard open questions remain in the layer above. How should task graphs reshape themselves dynamically when a local discovery invalidates upstream assumptions—the exact failure mode that haunted our 100B-token formalization runs? How should multi-tier storage and cross-swarm authentication work when runs span weeks across distributed clusters? We don't pretend AnySwarm answers those policy questions out of the box; our goal is to make testing a new answer take an afternoon of writing a Harness rather than a month of debugging container glue.
150
+
151
+ As models grow stronger, writing upper-layer coordination logic is becoming cheap enough that your Coding Agent can draft and iterate on a custom Harness directly from `@anyswarm/core` and `AGENTS.md`. What shouldn't be improvised from scratch every time is the runtime underneath.
152
+
153
+ AnySwarm is open-source under the MIT license:
154
+
155
+ - **Quickstart:** [Get Started with `@anyswarm/core`](../quickstart.md)
156
+ - **Interactive Trace Viewer (No Install):** [Try the Live Trace Demo](https://anyswarm.github.io/anyswarm/trace-demo/)
157
+ - **GitHub:** [https://github.com/AnySwarm/anyswarm](https://github.com/AnySwarm/anyswarm)
@@ -1,42 +1,67 @@
1
1
  ---
2
- title: Build a Swarm Harness
3
- description: Build a real parallel multi-agent Research Swarm — 3 researchers explore concurrently over a shared board, cite each other's findings, and hand off to a synthesizer.
2
+ title: Build a parallel Swarm Harness
3
+ description: Three researchers inspect a real repository, review source-backed findings, and hand off to a synthesizer that exports report.md.
4
4
  section: TUTORIALS
5
5
  order: 10
6
6
  ---
7
7
 
8
- This guide uses the same installed SDK and public Harness interface as the [first Harness](first-harness.md). Three Agents review a project in parallel, read and cite one another’s findings, then hand the board to a synthesizer that exports a verified `report.md`.
8
+ This second SDK lesson adds parallel work and peer review to the [First Harness](first-harness.md). Three researchers inspect private copies of a real repository, publish findings to a host Board, and review one another's work. A fourth Agent synthesizes the result into `report.md`. The team shares one Runtime and does not ask mid-run questions.
9
9
 
10
- ## Install the example
10
+ ## Install the complete source project
11
11
 
12
- Follow [first Harness setup](first-harness.md#2-install-and-connect) in an empty directory to install the verified source archive, prepare the Worker and configure a streaming Responses endpoint. Copy the TypeScript sources from that installed SDK.
12
+ Use AnySwarm 0.6.0 or follow [First Harness setup](first-harness.md#1-pick-the-matching-source-package) for a matching source build. That guide also explains Worker and model setup.
13
13
 
14
14
  ```bash
15
- sdk=node_modules/@anyswarm/core
16
- example="$sdk"/examples
17
- cp "$example"/parallel-swarm/{board.ts,board-service.ts,harness.ts} .
15
+ anyswarm eject parallel-swarm --dir ./my-harness
16
+ cd ./my-harness
17
+ npm install
18
18
  ```
19
19
 
20
- Use a separate directory for this Harness if you already copied First Harness sources elsewhere. Keep the installed SDK and its copied TypeScript examples together. To edit current repository sources, install their matching [source archive](../../examples/README.md#run-an-example-from-its-directory) before copying them.
20
+ The export includes the [Harness](../../examples/parallel-swarm/harness.ts), [configuration](../../examples/parallel-swarm/config.ts), [Board](../../examples/parallel-swarm/board.ts), [Service adapter](../../examples/parallel-swarm/board-service.ts), [report check](../../examples/parallel-swarm/report.ts), [README](../../examples/parallel-swarm/README.md) and [author AGENTS.md](../../examples/parallel-swarm/AGENTS.md). Its generated package manifest pins the exact bundled SDK archive. Individual source downloads reflect this site's source build; they are not a standalone dependency installation.
21
21
 
22
- ## Share findings through a Service
22
+ ## Ask a question about your repository
23
23
 
24
- `FindingsBoard` stores each finding, its author and citations. `boardService` exposes `publish` and `search` with schemas, uses the authenticated caller as the author, and provides a state export. Researcher Profiles may post and read. The synthesizer is read-only on the board and can write in its own workspace.
24
+ Keep the model environment from the first lesson, or set `ANYSWARM_MODEL_URL`, `ANYSWARM_MODEL_ID` and any required `ANYSWARM_MODEL_TOKEN`. The configuration inherits the saved setup connection, executor and image. It defaults to Responses; Pi can also use Chat Completions, while Codex requires Responses and an explicit supported model ID.
25
25
 
26
- ## Run two parallel rounds
26
+ ```bash
27
+ npm start -- --cwd /absolute/path/to/your-repository \
28
+ --prompt 'Prepare an engineering handoff for this repository: identify entry points, configuration, main data flow and existing tests. Cite source paths and line numbers. Separate established facts from inferences and checks still needed.' \
29
+ --output-dir ./runs
30
+ npm exec -- anyswarm trace --root ./runs
31
+ ```
27
32
 
28
- The Harness imports the SDK’s `runInput` for both rounds. It sends one input per idle Agent, with a unique request ID and a bounded wait, and waits for the group before starting the next round. The first round uses the user’s prompt. The second asks Agents to read their peers’ output and cite it in a new finding. The Harness checks the board after each round and stops the researchers before starting the synthesizer.
33
+ Use a real question, such as which modules and tests would be affected by a planned configuration change. No known defect, artificial fixture or existing Git diff is required. `--cwd` selects the initial captured files. Researchers receive read-only private copies; the synthesizer writes in its own copy. The host exports only the requested report and never applies those edits to the input directory.
29
34
 
30
- The scheduler must reserve each Agent’s input for the duration of its turn. Independent Agents can run concurrently. If admission or execution becomes unknown, inspect Runtime state and reconcile or close the affected Runtime before submitting another turn to that Agent. Aborting the wait does not abort the Worker. See [Runtime](runtime.md) for the separate interruption and cleanup controls.
35
+ `--config ./my-config.ts` supplies a complete explicit configuration; otherwise the Harness reads its own `config.ts`. Common `ANYSWARM_*` model/executor settings take precedence over `ANYSWARM_PARALLEL_SWARM_*`. Default input waits are bounded at 120 seconds per turn and close at 60 seconds; these are limits, not a promise of duration or cost.
31
36
 
32
- ## Run it and inspect the report
37
+ If your custom Responses endpoint returns reasoning items and you set `ANYSWARM_CONTEXT_WINDOW`, declare `models.default.capabilities.reasoning: true` in `config.ts` or your explicit config. The default capability profile sets it to `false`, which can cause `unsupported_responses_request` when the executor sends the reasoning history in a later request.
33
38
 
34
- ```bash
35
- mkdir -p input
36
- printf 'export const cache = new Map<string, string>();\n' > input/cache.ts
37
- ./node_modules/.bin/anyswarm run ./harness.ts --cwd ./input \
38
- --prompt 'Review cache.ts for resource risks and publish concrete findings.' --output-dir ./runs
39
- ./node_modules/.bin/anyswarm trace --root ./runs
39
+ ## Two rounds and a synthesis
40
+
41
+ | Stage | Agent work | Host check |
42
+ | --- | --- | --- |
43
+ | Research | Three researchers inspect distinct aspects and publish source-backed findings. | Each researcher contributes a first-round finding. The host authenticates the author and checks paths, line ranges and exact excerpts against captured input. |
44
+ | Peer review | The same researchers read peers' findings and publish new reviews. | Each researcher adds a second-round finding citing a first-round finding by another author. Existing publications and self-only citations do not satisfy this step. |
45
+ | Synthesis | Researchers stop; a synthesizer reads the Board and writes `report.md`. | Required export is readable UTF-8, nonblank and within the 1 MiB limit. An unchanged input `report.md` does not pass. |
46
+
47
+ The Board owns round and author identity; Agents cannot override them. Distinct Agents run concurrently within each round, while the Harness waits for all required contributions before continuing. `runInput` reserves each Agent's input during its bounded turn. Cancellation, uncertain execution, export and cleanup retain separate outcomes.
48
+
49
+ ## Read the result precisely
50
+
51
+ The final `artifacts` entry with `kind: "report"` gives the actual exported path. `result.detail.board` and the exported Board Service state preserve authors, rounds, citations and source excerpts. The original close receipt remains available in `cleanup.receipt`.
52
+
53
+ `acceptance.status: "verified"` is scoped to participant contributions, cross-author reviews, Board source references and report export. **`acceptance.semanticCorrectness` remains `"not-run"`.** Matching an excerpt does not prove the conclusion follows from it. The host does not run repository tests or validate every report citation against the Board. Read the report, disagreements and open questions before adopting its recommendations.
54
+
55
+ A failed contribution check stops synthesis. Missing or bad report bytes are a business verification failure; unconfirmed collection remains pending. Cleanup can remain pending even after verified export. Repository contract tests use controlled responses and transport; real-model performance must be recorded separately.
56
+
57
+ <span id="coding-agent-prompt"></span>
58
+
59
+ ## Copy Prompt for Claude Code / Codex / Cursor
60
+
61
+ Use the same prompt as the repository README. It directs your coding agent to the exported project's consumer guide and installed types, not AnySwarm's maintainer instructions.
62
+
63
+ ```text
64
+ Help me adapt AnySwarm to my workflow. First confirm that the installed AnySwarm CLI supports `anyswarm eject parallel-swarm --dir ./my-harness`. Export it if ./my-harness does not already exist. Read ./my-harness/AGENTS.md and README.md, then the installed @anyswarm/core types. Ask me for the business objective, input directory, and acceptance criteria if they are missing. Modify the exported Harness using public SDK APIs, one Runtime for the team, private Agent workspaces, and host Services for shared state. Keep report export, evidence checks, timeouts, and cleanup explicit. Run the available local checks, then explain how to run it and what those checks do and do not verify. Do not overwrite my source project or start a paid model run without my approval.
40
65
  ```
41
66
 
42
- The Harness requires new findings after review and independently checks the exported `report.md`. Read the file and checksum from the final `artifacts` list, and check `cleanup.status` separately. The same default Harness export can be passed to `createHarnessSession` or loaded through RPC.
67
+ Continue with [Services](services.md) for shared state and permissions, [Runtime](runtime.md) for execution and cleanup, or [the example catalog](harnesses/index.md) for other collaboration policies.
@@ -7,6 +7,27 @@ order: 16
7
7
 
8
8
  All notable changes to **AnySwarm** (`@anyswarm/core`) are tracked here and in the repository's [`CHANGELOG.md`](../../CHANGELOG.md). For the current install commands, see [Releases](latest.md).
9
9
 
10
+ ## Unreleased
11
+
12
+ ## v0.6.0
13
+
14
+ - Export complete, editable Subagents, First Harness and Parallel Swarm projects with the matching SDK. Parallel Swarm checks independent contributions, cross-author review, input citations and report delivery. These checks leave semantic correctness for the reader to assess.
15
+ - Run editable TypeScript Harnesses on Node 26, including enums. CI smoke-tests the same installed archive on Node 22.19, 24 and 26.
16
+ - Reproduce the repository handoff using a pinned p-limit input and explicit limits. The free browser replay shows the three Agents, their recorded activity and the original exported report.
17
+ - Trace keeps file previews and Copy usable across pages, makes inspector controls reachable on small screens and filters supported credential fields in static exports.
18
+ - Doctor and Subagents agree on Pi Responses and Chat Completions configuration. Linux managed setup reports incompatible rootless Docker versions before image preparation.
19
+
20
+ - AutoResearch ships an editable two-peer FrontierCS-2 case with backend and model setup checks, shared budgets, official final evidence and candidate hash verification in Trace Viewer.
21
+ - Source Harness RPC resolves missing JavaScript file URLs to their TypeScript author files and keeps recognized startup errors visible to clients. Existing compiled JavaScript retains precedence.
22
+ - One-shot terminals show the final business string or JSON result once, with safe multiline rendering and a bounded preview; piped JSON and saved reports retain their existing contract.
23
+ - Trace defaults to the standard Harness state directory, waits for a missing root, discovers saved Harness reports without Runtime traces, and refreshes the Run list automatically. A uniquely matching Runtime replaces the list row while existing report links and complete recorded results remain readable.
24
+ - `createSandbox()` snapshots connection settings without enumerating host interfaces. Runtime creation applies explicit callback options and that snapshot before automatic discovery. Setup and doctor honor supported callback addresses and report unavailable network inspection separately from configuration import failures.
25
+ - CI and Release verification exercise a preserved candidate archive, including installed CLI and editable-export checks. npm publication also verifies the public download and fresh SDK/CLI installations.
26
+ - Maintainers can publish explicit `next` previews without advancing npm `latest` or changing the checkout's formal version.
27
+ - The default guides are pinned to a verified release; the `next` documentation follows development, with separate navigation, search and example downloads.
28
+ - Contribution and development guides now explain the PR, candidate, preview and formal release workflow.
29
+ - Added a bilingual homepage, standalone Blog and Changelog, and a browser Trace replay entry.
30
+
10
31
  ## v0.5.2
11
32
 
12
33
  - The host CLI opens with Quickstart. Replace terminal aliases with `anyswarm --harness <name> --prompt <text>` for one-shot work or `--mode rpc` for multiple turns. One-shot Runs show milestones and a Trace command on a terminal. Code and Personal are available as editable SDK examples. [CLI reference](reference/cli.md)
@@ -16,7 +37,7 @@ All notable changes to **AnySwarm** (`@anyswarm/core`) are tracked here and in t
16
37
 
17
38
  ## v0.5.1
18
39
 
19
- - AutoResearch runs four equal Kimi K3 peers on the official FrontierCS-2 demo and shows research activity in the terminal stream and in live Trace. Configure a trusted evaluator for your project or export the editable Harness. [CLI reference](reference/cli.md#autoresearch). End-to-end acceptance on the default Kimi K3 route is tracked in [#337](https://github.com/AnySwarm/anyswarm/issues/337).
40
+ - AutoResearch runs four equal Kimi K3 peers on the official FrontierCS-2 demo and shows research activity in the terminal stream and in live Trace. Configure a trusted evaluator for your project or export the editable Harness. [CLI reference](reference/cli.md#autoresearch). See [#337](https://github.com/AnySwarm/anyswarm/issues/337) for real-model acceptance with GPT-6.1 Sol.
20
41
  - Personal receives GitHub requests in a detached Router-led Harness with inline decisions and per-work Draft PR approval.
21
42
  - Native macOS setup with Docker Desktop uses the selected Pi or Codex installation and supports exact version pins.
22
43
  - On Linux, run `anys -u code` to edit the current project with one Agent and delegate in chat when needed. Inspect patches and answer questions in the shared terminal, or export the application with `anys eject code`. [CLI reference](reference/cli.md)
@@ -1,69 +1,77 @@
1
1
  ---
2
2
  title: Build your first SDK Harness
3
- description: Install the AnySwarm SDK from npm and run a two-Agent handoff with a terminal reply, byte verification, and cleanup.
3
+ description: Run a two-Agent Service handoff without questions, verify the exported bytes, then opt into SDK or RPC question handling.
4
4
  section: TUTORIALS
5
5
  order: 9
6
6
  ---
7
7
 
8
- A publisher reads a reference from its workspace and asks you where to send it. You choose the channel in the terminal. A second Agent retrieves the reference through a Service and writes a checked delivery file. Start with the [Linux prerequisites in Quickstart](quickstart.md#prerequisites). Use Node.js 22.19+ with npm and a model endpoint that supports streaming and tool calls.
8
+ A publisher reads a unique reference, passes it through a host Service, and a writer retrieves it to create `delivery.txt`. The host checks the authenticated publisher and the exact bytes before and after export. The default run uses the release channel `preview` and asks no questions.
9
9
 
10
- ## 1. Pick your SDK version
10
+ ## 1. Pick the matching source package
11
11
 
12
- This tutorial uses `anyswarm run` from [AnySwarm v0.5.1](latest.md#v051). Copy the examples from the same SDK package you install below.
12
+ Use AnySwarm 0.6.0 or a [matching source build](quickstart.md#build-and-install-from-source-main). When using a candidate, retain the source commit and archive hash.
13
+
14
+ The [example README](../../examples/first-harness/README.md), [author AGENTS.md](../../examples/first-harness/AGENTS.md), [Harness](../../examples/first-harness/harness.ts), [configuration](../../examples/first-harness/config.ts), [Handoff Service](../../examples/first-harness/handoff.ts), [question client](../../examples/first-harness/session.ts), [TypeScript configuration](../../examples/first-harness/tsconfig.json) and [input README](../../examples/first-harness/input/README.md) are available from this site's matching source build. Eject creates the project manifest and includes the exact SDK archive; downloading an individual source file does not install its dependencies.
13
15
 
14
16
  ## 2. Install and connect
15
17
 
16
- In a fresh directory, install the SDK as a normal dependency and run its own CLI. This works without a global AnySwarm installation.
18
+ After installing the matching CLI, export the complete project into a new directory:
17
19
 
18
20
  ```bash
19
- npm init -y
20
- npm install @anyswarm/core@0.5.1
21
+ anyswarm eject first-harness --dir ./first-harness
22
+ cd ./first-harness
23
+ npm install
21
24
  ```
22
25
 
23
- To prepare a new local OpenSandbox, first [install a supported Pi](quickstart.md#2-prepare-opensandbox-and-the-worker), then run `./node_modules/.bin/anyswarm setup --mode local --backend pi`. With an existing deployment, [configure its endpoint, authentication, callback and Worker image](sandbox.md), then run `./node_modules/.bin/anyswarm setup --mode existing` and `./node_modules/.bin/anyswarm doctor --mode existing --smoke`.
24
-
25
- Wait for `"infrastructure": "ready"` and `"ok": true`. The controlled smoke checks Worker startup, Service calls, Gateway traffic, files, export and deletion. The example uses `resolveSandboxConnection()` to read the connection in the same environment. Its own imported SDK prepares the local image from that package’s build materials if needed.
26
+ Prepare Docker/OpenSandbox and a supported executor as described in [Quickstart](quickstart.md#2-prepare-opensandbox-and-the-worker). Use the project's own CLI so the SDK and Worker build materials agree:
26
27
 
27
- ## 3. Configure the model
28
+ ```bash
29
+ npm exec -- anyswarm setup
30
+ ```
28
31
 
29
- Provide a streaming Responses endpoint that supports tool calls. For Pi with a streaming Chat Completions endpoint, also set `ANYSWARM_MODEL_PROTOCOL=chat-completions` and change the URL to match. Omit the token when your endpoint does not require one.
32
+ The example reads the saved connection, selected executor and Worker image. Explicit `--config` supplies your own configuration; otherwise it uses `config.ts`. `ANYSWARM_EXECUTOR` can override the saved executor. Configure your actual model endpoint:
30
33
 
31
34
  ```bash
32
35
  export ANYSWARM_MODEL_URL='https://api.openai.com/v1/responses'
33
36
  export ANYSWARM_MODEL_ID='gpt-5-mini'
34
- read -rsp 'Model API token: ' ANYSWARM_MODEL_TOKEN && export ANYSWARM_MODEL_TOKEN && printf '\n'
37
+ export ANYSWARM_MODEL_TOKEN='<your-api-key>'
35
38
  ```
36
39
 
37
- ### Add the standard Harness and run it
40
+ Use a model supported by your selected executor. Pi also supports a streaming Chat Completions endpoint with `ANYSWARM_MODEL_PROTOCOL=chat-completions`; Codex requires Responses. The controlled setup smoke verifies the Runtime integration, not these provider credentials.
38
41
 
39
- Copy the TypeScript sources from the SDK you installed. The installed CLI runs them directly.
42
+ ## 3. Run the handoff without questions
40
43
 
41
44
  ```bash
42
- sdk=node_modules/@anyswarm/core
43
- example="$sdk"/examples/first-harness
44
- cp "$example"/{harness.ts,session.ts,handoff.ts,config.ts} .
45
+ npm start -- --cwd ./input --prompt 'Prepare a release handoff.' --output-dir ./runs
46
+ npm exec -- anyswarm trace --root ./runs
45
47
  ```
46
48
 
47
- The module's default export is a `Harness` with `apiVersion: 1`, `id: 'first-harness'` and `run(context)`. The [current repository version](../../examples/first-harness/harness.ts) uses the new Service registration API and pairs with the archive built from that source.
49
+ `input/` is included in the export and keeps capture separate from the project's dependencies and Run outputs. The preset channel is `preview`; set `ANYSWARM_FIRST_CHANNEL=beta-east` to choose another noninteractive channel.
50
+
51
+ The Harness creates one Runtime with publisher and writer Profiles and the Handoff Service. It reserves each Agent's input while `runInput` waits for that turn. The Service records the authenticated publisher; the writer has permission to fetch the reference. The host checks the reference and channel in `delivery.txt`, then requests a required export and checks those exported bytes again. No client question capability is enabled in this default path.
48
52
 
49
- The Harness owns two Profiles and the Handoff Service. The publisher reads the unique reference from its Sandbox and publishes it with a question. `runInput` waits for the exclusive publisher turn. The Harness checks the Service's authenticated publisher, then calls `context.askUser` with that Agent and the Run signal. The writer fetches the same reference with its own permission and uses your answer in `delivery.txt`. The Harness checks the bytes in the Sandbox, requests required export and checks the exported bytes again. The Session manages question identities, answer admission, observation and the final Run report.
53
+ Inspect `outcome`, `acceptance`, `export` and `cleanup` separately. A complete successful result includes `acceptance.status: "verified"`, `export.status: "complete"` and `cleanup.status: "complete"`. The acceptance receipt identifies the actual file and SHA-256. This verifies the handoff and exact bytes, not an open-ended research conclusion. Pending export or cleanup remains pending even if the content check passed.
50
54
 
51
- `session.ts` handles terminal input and passes the reply to `respond`. Run the TypeScript sources with the same definition in process, over RPC, or in one-shot foreground mode.
55
+ ## 4. Opt into SDK or RPC questions
56
+
57
+ The same Harness supports explicit question clients. `session.ts` enables that capability, listens for a question, and sends the terminal answer using its `questionId`. Use these modes when learning the protocol:
52
58
 
53
59
  ```bash
54
- mkdir -p input
55
- ./node_modules/.bin/anyswarm run ./session.ts ./input 'Prepare a release handoff.'
56
- PATH="$PWD/node_modules/.bin:$PATH" ./node_modules/.bin/anyswarm run ./session.ts --rpc ./input 'Prepare a release handoff.'
57
- ANYSWARM_FIRST_CHANNEL=beta-east ./node_modules/.bin/anyswarm run ./harness.ts --cwd ./input --prompt 'Prepare a release handoff.'
60
+ # In-process SDK client
61
+ npm exec -- anyswarm run ./session.ts ./input 'Prepare a release handoff.'
62
+
63
+ # JSONL RPC client
64
+ npm exec -- anyswarm run ./session.ts --rpc ./input 'Prepare a release handoff.'
58
65
  ```
59
66
 
60
- Use a separate input directory so capture excludes the example's dependencies and Run output. Both clients prompt for a channel such as `beta-east`. The one-shot foreground takes its channel from `ANYSWARM_FIRST_CHANNEL` and prints a final JSON record. JSONL clients may run explicit foreground with `--interaction questions` and answer by `questionId`. A successful run has `outcome: "completed"`, `acceptance.status: "verified"`, `export.status: "complete"` and `cleanup.status: "complete"`. Read the file named by the acceptance receipt, check its `channel=` line and compare its SHA‑256. Use the same Run's `reportPath` for the complete Host report.
67
+ These clients ask for the channel, such as `beta-east`, and the exported bytes must reflect that answer. Foreground `harness.ts` does not become interactive by adding a questions flag; JSONL question transport is explicit RPC. See the [RPC and CLI reference](reference/cli.md) and the advanced [harness-session source example](../../examples/harness-session/README.md).
68
+
69
+ The four TypeScript files run through either client without a compile step.
70
+
71
+ Running in a terminal displays the final business result once. For the no-question SDK Run, the default Trace root is the standard Harness state directory. Use the printed replay command or the report directory if the Run selected a different path. The current source Viewer can discover saved reports even if Runtime startup failed.
61
72
 
62
- ## 4. Diagnose and extend
73
+ ## 5. Extend the workflow
63
74
 
64
- - Inside an Agent, `swarm service invoke handoff publish --help` shows the authorized schema. The CLI also lists required fields and shows example calls when a valid example can be derived. Try a number for the reference and then correct it to the 12-character reference. `SERVICE_INPUT_INVALID` and `request_outcome: not_executed` mean the adapter did not run. For an unknown outcome, query or retry with the same request ID and payload. Use a new request ID when you correct the payload. See [Services](services.md).
65
- - Keep writes in the writable Agent workspace. For temporary files there, make a temporary subdirectory and remove it before collection. An image can restrict `/tmp`. For a large input pass a short summary and selected files or ranges. Set `ANYSWARM_CONTEXT_WINDOW` when you know the upstream's actual per-request limit. The Runtime trace can show provider-reported input and output tokens. Treat missing usage as unknown.
66
- - Use `anyswarm trace --root ./runs` and select the runtime ID. The failure summary gives the role, phase, error code, and available Agent and request IDs. Search `evidence.jsonl` and `service-calls.jsonl` in that run directory for those IDs. A closed or settled Agent does not attest business success. If cleanup is pending or unknown, inspect the close report before discarding the run directory.
67
- - Call the SDK’s `runInput` only on idle Agents whose input your application reserves. Distinct Agents can run in parallel. The helper subscribes before sending, requires accepted admission and a successful settlement, and disposes its waiter on completion, error, abort or timeout. If admission or execution was uncertain, inspect `runtime.get` and close the Runtime or explicitly reconcile the request before reusing that Agent. A cancelled wait does not cancel Worker execution. See [Runtime](runtime.md) for `interrupt` and `close`.
75
+ Read the exported author guide before changing the Profiles, permissions or acceptance. Keep shared state in the Service, validate caller identity, and keep host checks independent of the Agent's own success claim. Bound turns and close time, and keep export and cleanup evidence intact on failure.
68
76
 
69
- Continue with the [source-based parallel Swarm tutorial](build-your-harness.md) to add parallel research rounds and synthesis.
77
+ Continue with [Parallel Swarm](build-your-harness.md): three researchers inspect a real repository, review one another's findings, and hand their shared board to a synthesizer.
@@ -1,41 +1,41 @@
1
1
  ---
2
- title: Choose a Harness
3
- description: Compare the five built-in multi-agent patterns in AnySwarm, run them with one command, or adapt them to build your own team.
4
- section: BUILT-IN HARNESSES
2
+ title: Choose an example
3
+ description: Choose a useful first task, SDK tutorial, application, collaboration reference, or advanced integration with explicit prerequisites.
4
+ section: EXAMPLES
5
5
  order: 10
6
6
  ---
7
7
 
8
- A **Harness** defines how a multi-agent team divides work, shares information, and decides when the job is done.
8
+ A **Harness** defines how a team divides work, shares information, checks results and ends. Choose an example by the job you want to do, then read the underlying collaboration policy. The [example catalog](../../../examples/README.md) owns the complete source, dependency and status inventory.
9
9
 
10
- `anyswarm` ships **five reference collaboration patterns** (`Subagents`, `TaskPool`, `PeerMesh`, `Substrate`, and `Lead-Worker`), plus two minimal starters (`notes` and `messages`). All of them share the exact same Sandboxes, Host Gateway, and Trace Viewer — only their Services and orchestration rules differ.
10
+ ## Three tiers
11
11
 
12
- > **How to use them**: after preparing a pattern's prerequisites, run `anyswarm --harness <name>` (each built-in name loads the standard Harness module from `examples/<name>/`). See the [example index](../../../examples/README.md) to run or adapt one; to build your own from scratch, start with [Your First SDK Harness](../first-harness.md) or [Build a Swarm Harness](../build-your-harness.md).
13
-
14
- ## Run in one command
15
-
16
- Once [Quickstart](../quickstart.md) is done, launch against any project folder:
12
+ | Tier | Purpose | Examples |
13
+ | --- | --- | --- |
14
+ | **1 · Start and learn** | Run one useful task; learn the SDK in two steps. | [Repository handoff with Subagents](../quickstart.md); [First Harness](../first-harness.md) → [Parallel Swarm](../build-your-harness.md). The SDK tutorials use 0.6.0 or a matching source build. |
15
+ | **2 · Applications and reference topologies** | Explore an application or adapt a collaboration mechanism. | [AutoResearch](../autoresearch.md), with its current FrontierCS-2 setup; [Subagents](subagents.md), [TaskPool](taskpool.md), [Substrate](substrate.md). |
16
+ | **3 · Advanced source and integrations** | Study a protocol, daemon or external service integration. | `super`, `code`, `harness-session`, focused Service examples; [PeerMesh](peermesh.md) and [Lead-Worker](lead-worker.md). Code development is paused. |
17
17
 
18
- ```bash
19
- cd my-project
20
- anyswarm --harness subagents --prompt "Fix the parser and add tests"
21
- ```
18
+ ## Know the prerequisites before you choose
22
19
 
23
- Built-in names: `subagents`, `taskpool`, `peermesh`, `substrate`, `lead-worker`, `notes`, `messages`. All patterns share OpenSandbox, a compatible Worker image, and model access; each pattern owns its collaboration Services and any extra facilities:
20
+ All live Agent examples need OpenSandbox, a compatible Worker/executor and model access. `anyswarm setup` prepares the common Runtime deployment. It does not deploy each application’s external services.
24
21
 
25
22
  | Examples | Additional facilities |
26
23
  | --- | --- |
27
- | Subagents, TaskPool, Notes, Messages, ordinary Substrate | Their standard entrypoints create the in-process Services and local stores they need — no external service stack required. |
28
- | PeerMesh | Configured Gitea and Mattermost, plus MySQL and the upstream Board process. |
29
- | Lead-Worker | Configured Gitea; its optional dynamic mode also needs a Docker image for the checking Service and candidate verifier. |
30
- | Optional Lean workloads | The TaskPool or Substrate FATE configuration supplies its checker/toolchain and may use [Mathlib Search](../../../examples/services/mathlib-search/README.md). |
24
+ | First Harness, Parallel Swarm, Subagents, TaskPool, ordinary Substrate | Their entrypoints create in-process Services and local stores. No additional business service deployment. |
25
+ | AutoResearch / FrontierCS-2 | Linux x86-64, Git LFS, Python, local Docker, prepared benchmark/checker images and the configured K3 route. See its [current requirements](../autoresearch.md). |
26
+ | PeerMesh | Gitea, Mattermost, MySQL and the upstream Board process. |
27
+ | Lead-Worker | Gitea; optional dynamic mode also needs the checking Service and candidate verifier image. |
28
+ | Optional Lean workloads | Their checker/toolchain and, where configured, [Mathlib Search](../../../examples/services/mathlib-search/README.md). |
29
+
30
+ PeerMesh and Lead-Worker require an OpenSandbox deployment enforcing Git network allowlists with `dns+nft`. See [deployment ownership](../../../deploy/README.md).
31
31
 
32
- Running `anyswarm setup` prepares the common runtime deployment. PeerMesh and Lead-Worker also require an OpenSandbox deployment enforcing Git network allowlists with `dns+nft`. See [deployment ownership](../../../deploy/README.md) for which components `anyswarm setup` manages and which external facilities you bring yourself.
32
+ ## Run or adapt a Harness
33
33
 
34
- ## Where the implementations live
34
+ Follow [Quickstart](../quickstart.md) to produce `report.md` from your repository with the existing `subagents` entrypoint. Built-in names also include `autoresearch`, `taskpool`, `peermesh`, `substrate`, `lead-worker`, `notes` and `messages`; each loads its example’s standard Harness module and still needs its configuration and prerequisites.
35
35
 
36
- The five mechanisms and their collaboration Services live in `examples/subagents`, `examples/taskpool`, `examples/peermesh`, `examples/substrate`, and `examples/lead-worker`. The shared CLI host only handles module loading, project capture, session lifecycle, and RPC framing; a built-in name is simply a convenience loader for the bundled example entry.
36
+ The shared CLI handles loading, initial directory capture, session lifecycle and RPC framing. The example owns its roles, Services and acceptance. Private Sandbox copies do not stay synchronized with the original directory, and exported results do not automatically overwrite it.
37
37
 
38
- Every example can be copied into a standalone directory, installed against `@anyswarm/core`, and built independently using only public package exports. See the [example index](../../../examples/README.md#run-an-example-from-its-directory) for setup commands and external facilities.
38
+ To customize, use the [SDK tutorials and author prompt](../build-your-harness.md), respecting the version boundary documented there. An ordinary team shares one Runtime. Task completion, independent business acceptance, export and cleanup remain separate facts.
39
39
 
40
40
  ## Five collaboration patterns at a glance
41
41
 
@@ -7,46 +7,25 @@ order: 10
7
7
 
8
8
  **Subagents** models a hierarchical team where a lead Agent (`/root`) breaks down work, spawns named child Agents recursively (up to `maxDepth`), steers busy children without waking idle ones, and integrates child results. Source: [examples/subagents](https://github.com/AnySwarm/anyswarm/tree/main/examples/subagents).
9
9
 
10
- ## Quick run (CLI)
10
+ ## Quick run: repository handoff
11
11
 
12
- With `ANYSWARM_MODEL_URL` and `ANYSWARM_MODEL_TOKEN` configured (see [Quickstart](../quickstart.md)), run Subagents directly against any project directory:
12
+ Follow [Quickstart](../quickstart.md) to inspect your own repository and export `report.md`. Root receives your prompt and decides how to delegate. The suggested task asks separate children to inspect entry points and run commands, then modules and tests, before Root checks file references and integrates the findings.
13
13
 
14
- ```bash
15
- cd my-project
16
- anyswarm --harness subagents --prompt "Fix the parser using the project tests"
17
- ```
18
-
19
- Subagents sends your prompt to `/root` and seeds each Sandbox with the captured project tree (separate isolated directories per Agent). In `--mode rpc`, follow-up user inputs route directly to `/root`. See the sections below for its interactive session controls, `collaboration` Service protocol, mailbox controller, and source-level embedding.
14
+ `--cwd` selects the directory captured at Run start. Each Agent receives a private copy; new local edits are not synchronized, and Sandbox changes are not written back. Results are collected into the Run output. Generic Subagents does not independently grade the report (`acceptance.status: "not-run"`). A task-lifetime run closes the team after its final outcome; ongoing client sessions are an advanced SDK/RPC option.
20
15
 
21
- ## Interactive session and controls
16
+ ## Advanced SDK/RPC sessions and controls
22
17
 
23
18
  The Subagents module default-exports a standard `Harness` (see [Your First SDK Harness](../first-harness.md)) shared across SDK `createHarnessSession`, explicit foreground CLI, and JSONL RPC, owning both workflow coordination and resource cleanup:
24
19
 
25
- - **Continuous conversation (`--lifetime interactive`)**: keeps `/root` alive across replies, accepts plain text or `{ text, mode }` inputs, and exposes currently permitted settings and structured context controls via `describe()`.
20
+ - **Continuous RPC conversation (`--mode rpc --lifetime interactive`)**: keeps `/root` alive across replies, accepts plain text or `{ text, mode }` inputs, and exposes currently permitted settings and structured context controls via `describe()`.
26
21
  - **Safe interruption**: interrupting `/root` fences its previous execution while allowing active children to finish; child results arriving after an interrupt stay queued in the inbox until the next explicit user input.
27
- - **User questions (`--interaction questions`)**: when enabled, Agents can invoke `swarm service invoke user-interaction ask` to pose authorized questions to the client.
22
+ - **RPC user questions (`--mode rpc --interaction questions`)**: when enabled, Agents can invoke `swarm service invoke user-interaction ask` to pose authorized questions to the client.
28
23
 
29
24
  ### Verify parent-child delegation
30
25
 
31
- With the same model configuration, run this check in a fresh project directory.
32
- The child spawn Service call allows up to 60 seconds within the default 120-second Run work deadline. For a slower host, set `workTimeoutMs` in your Subagents configuration and pass the file with `anyswarm --config`.
33
-
34
- ```bash
35
- mkdir -p anyswarm-delegation-check && cd anyswarm-delegation-check
36
- printf '# Release checklist\n' > README.md
37
- prompt=$(cat <<'PROMPT'
38
- Delegate the README heading check to one child and report the exact heading the child returns. Let the child read the file. Use the bash tool with a 75 second tool timeout for each command. First run:
39
- swarm collaboration spawn_agent --task-name reviewer --message 'Use the read tool to read README.md and return its exact first heading.' --fork-turns none --request-id reviewer-start --timeout-ms 65000
40
- After spawn succeeds, run:
41
- printf '{"timeout_ms":60000}\n' | swarm collaboration wait_agent --stdin --request-id wait-reviewer --timeout-ms 65000
42
- Wait for the reviewer result before reporting the heading.
43
- PROMPT
44
- )
45
- anyswarm --harness subagents --prompt "$prompt" --output-dir ./runs
46
- anyswarm trace --root ./runs --port 8787 --open
47
- ```
26
+ After the repository task, use Trace Viewer to inspect the actual `collaboration.spawn_agent` calls, distinct child identities and file-read results. Confirm Root received each child's findings, and open the exported `report.md` through its recorded artifact path. Check whether child activity overlapped rather than inferring parallelism from the prompt.
48
27
 
49
- In Trace Viewer, check that `/root` spawned `/root/reviewer` and the child's `read` tool returned `# Release checklist`. Open the root's `wait_agent` Service call to confirm it received the child's result. The CLI should report that heading and `cleanup.status: "complete"`.
28
+ The child spawn Service call allows up to 60 seconds within the default 120-second work deadline. Configure `workTimeoutMs` for a slower model or host. Export and cleanup must be inspected separately from business outcome. The default root collection covers the workspace up to 16 MiB; a focused configuration can require only `report.md`. These checks establish what happened and which bytes were retained, not whether every engineering conclusion is correct.
50
29
 
51
30
  ## 1. Registered Service (`collaboration`)
52
31