@anyswarm/core 0.5.1 → 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 (301) hide show
  1. package/AGENTS.md +20 -5
  2. package/README.md +69 -55
  3. package/dist/examples/README.md +138 -77
  4. package/dist/examples/authoring/README.md +4 -4
  5. package/dist/examples/autoresearch/README.md +108 -16
  6. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
  7. package/dist/examples/autoresearch/config.d.ts +48 -5
  8. package/dist/examples/autoresearch/config.js +57 -23
  9. package/dist/examples/autoresearch/demo.d.ts +12 -4
  10. package/dist/examples/autoresearch/demo.js +65 -22
  11. package/dist/examples/autoresearch/eject.json +2 -0
  12. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
  13. package/dist/examples/autoresearch/frontiercs2-config.js +14 -0
  14. package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
  15. package/dist/examples/autoresearch/frontiercs2.js +71 -14
  16. package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
  17. package/dist/examples/autoresearch/prepare-demo.js +46 -0
  18. package/dist/examples/autoresearch/prepare.d.ts +105 -53
  19. package/dist/examples/autoresearch/prepare.js +126 -57
  20. package/dist/examples/autoresearch/project.d.ts +6 -95
  21. package/dist/examples/autoresearch/project.js +131 -45
  22. package/dist/examples/autoresearch/research-service.d.ts +16 -1
  23. package/dist/examples/autoresearch/research-service.js +84 -44
  24. package/dist/examples/code/README.md +25 -17
  25. package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
  26. package/dist/examples/code/config.d.ts +1 -0
  27. package/dist/examples/first-harness/AGENTS.md +25 -0
  28. package/dist/examples/first-harness/README.md +136 -0
  29. package/dist/examples/first-harness/config.d.ts +9 -8
  30. package/dist/examples/first-harness/config.js +33 -26
  31. package/dist/examples/first-harness/eject.json +14 -0
  32. package/dist/examples/first-harness/handoff.js +3 -3
  33. package/dist/examples/first-harness/harness.d.ts +14 -18
  34. package/dist/examples/first-harness/harness.js +102 -77
  35. package/dist/examples/first-harness/input/README.md +7 -0
  36. package/dist/examples/first-harness/session.js +2 -1
  37. package/dist/examples/first-harness/tsconfig.json +2 -1
  38. package/dist/examples/harness-session/README.md +4 -4
  39. package/dist/examples/lead-worker/README.md +1 -1
  40. package/dist/examples/lead-worker/project-config.d.ts +1 -0
  41. package/dist/examples/messages/README.md +2 -2
  42. package/dist/examples/notes/README.md +5 -5
  43. package/dist/examples/notes/config.d.ts +1 -0
  44. package/dist/examples/parallel-swarm/AGENTS.md +32 -0
  45. package/dist/examples/parallel-swarm/README.md +136 -0
  46. package/dist/examples/parallel-swarm/board-service.js +25 -8
  47. package/dist/examples/parallel-swarm/board.d.ts +31 -1
  48. package/dist/examples/parallel-swarm/board.js +98 -13
  49. package/dist/examples/parallel-swarm/config.d.ts +11 -0
  50. package/dist/examples/parallel-swarm/config.js +39 -0
  51. package/dist/examples/parallel-swarm/eject.json +5 -0
  52. package/dist/examples/parallel-swarm/harness.d.ts +26 -20
  53. package/dist/examples/parallel-swarm/harness.js +77 -76
  54. package/dist/examples/parallel-swarm/report.d.ts +12 -0
  55. package/dist/examples/parallel-swarm/report.js +30 -0
  56. package/dist/examples/peermesh/README.md +1 -1
  57. package/dist/examples/peermesh/project-config.d.ts +1 -0
  58. package/dist/examples/services/agent-control/README.md +1 -1
  59. package/dist/examples/services/mathlib-search/README.md +1 -1
  60. package/dist/examples/services/mcp-managed/README.md +1 -1
  61. package/dist/examples/services/persistent-board/README.md +6 -3
  62. package/dist/examples/subagents/AGENTS.md +35 -0
  63. package/dist/examples/subagents/README.md +129 -93
  64. package/dist/examples/subagents/config.d.ts +2 -10
  65. package/dist/examples/subagents/config.js +9 -16
  66. package/dist/examples/subagents/eject.json +17 -0
  67. package/dist/examples/subagents/handoff-config.d.ts +41 -0
  68. package/dist/examples/subagents/handoff-config.js +13 -0
  69. package/dist/examples/subagents/model.d.ts +3 -0
  70. package/dist/examples/subagents/model.js +19 -0
  71. package/dist/examples/substrate/README.md +12 -6
  72. package/dist/examples/substrate/config.d.ts +1 -0
  73. package/dist/examples/substrate/project-config.d.ts +1 -0
  74. package/dist/examples/super/README.md +34 -22
  75. package/dist/examples/super/actions.d.ts +1 -1
  76. package/dist/examples/super/actions.js +11 -11
  77. package/dist/examples/super/config.js +3 -3
  78. package/dist/examples/super/eject.json +1 -1
  79. package/dist/examples/super/location.js +1 -1
  80. package/dist/examples/super/operator.d.ts +1 -0
  81. package/dist/examples/super/operator.js +31 -0
  82. package/dist/examples/super/project.d.ts +0 -107
  83. package/dist/examples/super/project.js +1 -3
  84. package/dist/examples/taskpool/README.md +1 -1
  85. package/dist/examples/taskpool/config.d.ts +1 -0
  86. package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
  87. package/dist/scripts/anyswarm-arguments.d.ts +7 -25
  88. package/dist/scripts/anyswarm-arguments.js +69 -97
  89. package/dist/scripts/anyswarm-eject.js +1 -1
  90. package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
  91. package/dist/scripts/anyswarm-harnesses.js +1 -22
  92. package/dist/scripts/anyswarm-installation.d.ts +7 -40
  93. package/dist/scripts/anyswarm-installation.js +17 -291
  94. package/dist/scripts/anyswarm-launch.d.ts +6 -36
  95. package/dist/scripts/anyswarm-launch.js +32 -81
  96. package/dist/scripts/anyswarm-progress.d.ts +6 -0
  97. package/dist/scripts/anyswarm-progress.js +133 -0
  98. package/dist/scripts/anyswarm-project.d.ts +1 -9
  99. package/dist/scripts/anyswarm-project.js +40 -127
  100. package/dist/scripts/anyswarm-source-runner.js +9 -41
  101. package/dist/scripts/anyswarm.js +6 -26
  102. package/dist/scripts/build-provenance.json +1 -1
  103. package/dist/scripts/generate-architecture-coverage.js +1 -1
  104. package/dist/scripts/generate-architecture-prompts.js +18 -10
  105. package/dist/scripts/local-environment.d.ts +13 -7
  106. package/dist/scripts/local-environment.js +73 -21
  107. package/dist/scripts/local-setup.d.ts +3 -0
  108. package/dist/scripts/local-setup.js +153 -118
  109. package/dist/scripts/pack-release.js +31 -4
  110. package/dist/src/core/index.js +1 -1
  111. package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
  112. package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
  113. package/dist/src/core/sandbox/sandbox-connection.js +22 -7
  114. package/dist/src/core/worker-image.js +1 -1
  115. package/dist/src/harness/project-harness.d.ts +1 -0
  116. package/dist/src/harness/project-harness.js +5 -4
  117. package/dist/src/harness/project-rpc-client.js +19 -0
  118. package/dist/src/harness/project-runtime.js +3 -1
  119. package/dist/src/harness/typescript-loader.d.ts +2 -0
  120. package/dist/src/harness/typescript-loader.js +26 -8
  121. package/dist/src/trace-viewer/command.mjs +6 -3
  122. package/dist/src/trace-viewer/public/app.js +239 -59
  123. package/dist/src/trace-viewer/public/index.html +5 -0
  124. package/dist/src/trace-viewer/public/style.css +22 -0
  125. package/dist/src/trace-viewer/reader.mjs +242 -26
  126. package/dist/src/trace-viewer/run-root.d.mts +1 -0
  127. package/dist/src/trace-viewer/run-root.mjs +7 -0
  128. package/dist/src/trace-viewer/server.mjs +3 -1
  129. package/docs/INDEX.md +11 -9
  130. package/docs/architecture/04-services.md +1 -1
  131. package/docs/architecture/06-observability-experiments.md +21 -7
  132. package/docs/architecture/07-run-configuration.md +118 -19
  133. package/docs/architecture/08-prompts.md +21 -2
  134. package/docs/architecture/10-service-api-reference.md +12 -5
  135. package/docs/architecture/12-code-coverage.md +157 -115
  136. package/docs/architecture/15-core-runtime.md +1 -1
  137. package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
  138. package/docs/architecture/17-harness-reporting.md +79 -1
  139. package/docs/architecture/22-website.md +52 -20
  140. package/docs/architecture/23-project-harness.md +109 -37
  141. package/docs/architecture/26-code.md +20 -5
  142. package/docs/architecture/27-personal.md +23 -8
  143. package/docs/architecture/28-autoresearch.md +18 -12
  144. package/docs/architecture/INDEX.md +1 -2
  145. package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
  146. package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
  147. package/docs/architecture/prompts/22-autoresearch.md +9 -2
  148. package/docs/architecture/prompts/source-manifest.json +76 -52
  149. package/docs/architecture/source-map.json +445 -105
  150. package/docs/designs/core-harness/01-core.md +2 -2
  151. package/docs/designs/core-harness/06-project-harness.md +3 -3
  152. package/docs/designs/core-harness/README.md +2 -2
  153. package/docs/en/agents.md +1 -1
  154. package/docs/en/autoresearch.md +41 -0
  155. package/docs/en/blog/100b-tokens.md +157 -0
  156. package/docs/en/build-your-harness.md +47 -22
  157. package/docs/en/changelog.md +29 -1
  158. package/docs/en/first-harness.md +40 -32
  159. package/docs/en/harnesses/index.md +23 -23
  160. package/docs/en/harnesses/lead-worker.md +1 -1
  161. package/docs/en/harnesses/peermesh.md +2 -2
  162. package/docs/en/harnesses/subagents.md +10 -31
  163. package/docs/en/harnesses/substrate.md +4 -4
  164. package/docs/en/harnesses/taskpool.md +2 -2
  165. package/docs/en/latest.md +30 -5
  166. package/docs/en/overview.md +22 -22
  167. package/docs/en/quickstart.md +69 -56
  168. package/docs/en/reference/api.md +1 -1
  169. package/docs/en/reference/cli.md +47 -85
  170. package/docs/en/sandbox.md +3 -3
  171. package/docs/en/trace-viewer.md +32 -12
  172. package/docs/operations/trace-viewer.md +26 -11
  173. package/docs/third-party-notices.md +0 -1
  174. package/docs/workflows/development.md +160 -118
  175. package/docs/workflows/release-and-docs-versioning.md +207 -54
  176. package/docs/workflows/release-cli-acceptance.md +162 -0
  177. package/docs/zh/agents.md +1 -1
  178. package/docs/zh/autoresearch.md +41 -0
  179. package/docs/zh/blog/100b-tokens.md +102 -0
  180. package/docs/zh/build-your-harness.md +48 -23
  181. package/docs/zh/changelog.md +29 -1
  182. package/docs/zh/first-harness.md +43 -35
  183. package/docs/zh/harnesses/index.md +23 -23
  184. package/docs/zh/harnesses/lead-worker.md +1 -1
  185. package/docs/zh/harnesses/peermesh.md +2 -2
  186. package/docs/zh/harnesses/subagents.md +10 -31
  187. package/docs/zh/harnesses/substrate.md +4 -4
  188. package/docs/zh/harnesses/taskpool.md +2 -2
  189. package/docs/zh/latest.md +30 -5
  190. package/docs/zh/overview.md +23 -23
  191. package/docs/zh/quickstart.md +66 -57
  192. package/docs/zh/reference/api.md +1 -1
  193. package/docs/zh/reference/cli.md +19 -79
  194. package/docs/zh/sandbox.md +3 -3
  195. package/docs/zh/trace-viewer.md +32 -12
  196. package/examples/README.md +138 -77
  197. package/examples/authoring/README.md +4 -4
  198. package/examples/autoresearch/README.md +108 -16
  199. package/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
  200. package/examples/autoresearch/config.ts +64 -25
  201. package/examples/autoresearch/demo.ts +75 -22
  202. package/examples/autoresearch/eject.json +2 -0
  203. package/examples/autoresearch/frontiercs2-config.ts +15 -0
  204. package/examples/autoresearch/frontiercs2.ts +64 -11
  205. package/examples/autoresearch/prepare-demo.ts +44 -0
  206. package/examples/autoresearch/prepare.ts +134 -60
  207. package/examples/autoresearch/project.ts +120 -44
  208. package/examples/autoresearch/research-service.ts +91 -41
  209. package/examples/code/README.md +25 -17
  210. package/examples/code/REQUIREMENTS.zh.md +3 -3
  211. package/examples/first-harness/AGENTS.md +25 -0
  212. package/examples/first-harness/README.md +136 -0
  213. package/examples/first-harness/config.ts +41 -27
  214. package/examples/first-harness/eject.json +14 -0
  215. package/examples/first-harness/handoff.ts +3 -3
  216. package/examples/first-harness/harness.ts +104 -72
  217. package/examples/first-harness/input/README.md +7 -0
  218. package/examples/first-harness/session.ts +2 -1
  219. package/examples/first-harness/tsconfig.json +2 -1
  220. package/examples/harness-session/README.md +4 -4
  221. package/examples/lead-worker/README.md +1 -1
  222. package/examples/messages/README.md +2 -2
  223. package/examples/notes/README.md +5 -5
  224. package/examples/parallel-swarm/AGENTS.md +32 -0
  225. package/examples/parallel-swarm/README.md +136 -0
  226. package/examples/parallel-swarm/board-service.ts +28 -9
  227. package/examples/parallel-swarm/board.ts +107 -13
  228. package/examples/parallel-swarm/config.ts +47 -0
  229. package/examples/parallel-swarm/eject.json +5 -0
  230. package/examples/parallel-swarm/harness.ts +83 -71
  231. package/examples/parallel-swarm/report.ts +33 -0
  232. package/examples/peermesh/README.md +1 -1
  233. package/examples/services/agent-control/README.md +1 -1
  234. package/examples/services/mathlib-search/README.md +1 -1
  235. package/examples/services/mcp-managed/README.md +1 -1
  236. package/examples/services/persistent-board/README.md +6 -3
  237. package/examples/subagents/AGENTS.md +35 -0
  238. package/examples/subagents/README.md +129 -93
  239. package/examples/subagents/config.ts +9 -15
  240. package/examples/subagents/eject.json +17 -0
  241. package/examples/subagents/handoff-config.ts +14 -0
  242. package/examples/subagents/model.ts +20 -0
  243. package/examples/substrate/README.md +12 -6
  244. package/examples/super/README.md +34 -22
  245. package/examples/super/actions.ts +11 -11
  246. package/examples/super/config.ts +3 -3
  247. package/examples/super/eject.json +1 -1
  248. package/examples/super/location.ts +1 -1
  249. package/examples/super/operator.ts +28 -0
  250. package/examples/super/project.ts +1 -3
  251. package/examples/taskpool/README.md +1 -1
  252. package/npm-shrinkwrap.development.json +46 -1538
  253. package/npm-shrinkwrap.json +10 -43
  254. package/package.development.json +3 -6
  255. package/package.json +3 -5
  256. package/scripts/anyswarm-arguments.ts +67 -96
  257. package/scripts/anyswarm-eject.ts +1 -1
  258. package/scripts/anyswarm-harnesses.ts +1 -18
  259. package/scripts/anyswarm-installation.ts +18 -294
  260. package/scripts/anyswarm-launch.ts +30 -102
  261. package/scripts/anyswarm-progress.ts +125 -0
  262. package/scripts/anyswarm-project.ts +31 -123
  263. package/scripts/anyswarm-source-runner.ts +9 -36
  264. package/scripts/anyswarm.ts +4 -24
  265. package/scripts/generate-architecture-coverage.ts +1 -1
  266. package/scripts/generate-architecture-prompts.ts +21 -10
  267. package/scripts/local-environment.ts +79 -21
  268. package/scripts/local-setup.ts +150 -105
  269. package/scripts/pack-release.ts +28 -4
  270. package/src/core/index.ts +1 -1
  271. package/src/core/sandbox/opensandbox-backend.ts +10 -4
  272. package/src/core/sandbox/sandbox-connection.ts +22 -7
  273. package/src/core/worker-image.ts +1 -1
  274. package/src/harness/project-harness.ts +5 -4
  275. package/src/harness/project-rpc-client.ts +23 -0
  276. package/src/harness/project-runtime.ts +2 -1
  277. package/src/harness/typescript-loader.ts +28 -8
  278. package/src/trace-viewer/command.mjs +6 -3
  279. package/src/trace-viewer/public/app.js +239 -59
  280. package/src/trace-viewer/public/index.html +5 -0
  281. package/src/trace-viewer/public/style.css +22 -0
  282. package/src/trace-viewer/reader.mjs +242 -26
  283. package/src/trace-viewer/run-root.d.mts +1 -0
  284. package/src/trace-viewer/run-root.mjs +7 -0
  285. package/src/trace-viewer/server.mjs +3 -1
  286. package/dist/scripts/anyswarm-applications.d.ts +0 -19
  287. package/dist/scripts/anyswarm-applications.js +0 -19
  288. package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
  289. package/dist/scripts/anyswarm-tui-config.js +0 -189
  290. package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
  291. package/dist/scripts/anyswarm-tui-session.js +0 -304
  292. package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
  293. package/dist/scripts/anyswarm-tui-terminal.js +0 -154
  294. package/dist/scripts/anyswarm-tui.d.ts +0 -2
  295. package/dist/scripts/anyswarm-tui.js +0 -1012
  296. package/docs/architecture/25-foreground-tui.md +0 -51
  297. package/scripts/anyswarm-applications.ts +0 -39
  298. package/scripts/anyswarm-tui-config.ts +0 -174
  299. package/scripts/anyswarm-tui-session.ts +0 -295
  300. package/scripts/anyswarm-tui-terminal.ts +0 -147
  301. package/scripts/anyswarm-tui.ts +0 -912
@@ -40,7 +40,7 @@ const compareTimeline = (left, right) => {
40
40
  const a = timelineStart(left);
41
41
  const b = timelineStart(right);
42
42
  if (!Number.isFinite(a) || !Number.isFinite(b)) return Number(Number.isFinite(a)) - Number(Number.isFinite(b));
43
- return a - b || left.id.localeCompare(right.id);
43
+ return a - b || (left.kind === "research" && right.kind === "research" ? (left.sequence ?? 0) - (right.sequence ?? 0) : 0) || left.id.localeCompare(right.id);
44
44
  };
45
45
  const missing = (error) => error.code === "ENOENT" || error.code === "ENOTDIR";
46
46
  const identity = (record) =>
@@ -140,7 +140,29 @@ async function readVerifiedFile(handle, stat, digest, expectedSize, offset = 0,
140
140
  }
141
141
  if (hash.digest("hex") !== digest ||
142
142
  fileStatSignature(await handle.stat({ bigint: true })) !== fileStatSignature(stat)) return;
143
- return { text: content.toString("utf8"), bytesRead: content.length, total };
143
+ return { content, total };
144
+ }
145
+
146
+ /** The caller supplies up to three lookahead bytes to finish a UTF-8 character. */
147
+ export function utf8FilePage(bytes, limit) {
148
+ let end = Math.min(bytes.length, limit);
149
+ const continuation = byte => (byte & 0xc0) === 0x80;
150
+ if (end < bytes.length && continuation(bytes[end])) {
151
+ let start = end;
152
+ while (start > Math.max(0, end - 3) && continuation(bytes[start])) start--;
153
+ const lead = bytes[start];
154
+ const width = lead >= 0xc2 && lead <= 0xdf ? 2
155
+ : lead >= 0xe0 && lead <= 0xef ? 3
156
+ : lead >= 0xf0 && lead <= 0xf4 ? 4 : 0;
157
+ if (start < end && start + width > end && start + width <= bytes.length &&
158
+ bytes.subarray(start + 1, start + width).every(continuation)) {
159
+ end = start || width;
160
+ }
161
+ }
162
+ return {
163
+ text: new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes.subarray(0, end)),
164
+ bytesRead: end,
165
+ };
144
166
  }
145
167
 
146
168
  function fileSourceIdentity(path, stat) {
@@ -216,6 +238,48 @@ async function readJSON(root, path) {
216
238
  }
217
239
  }
218
240
 
241
+ function validProjectReport(report, directory) {
242
+ return report && report.runId === basename(directory) &&
243
+ report.harness?.apiVersion === 1 && typeof report.harness.id === "string" &&
244
+ report.harness.id.length > 0 && ["completed", "failed", "cancelled"].includes(report.outcome);
245
+ }
246
+
247
+ function projectRuntimeId(report) {
248
+ const values = [report.result?.runtimeId, report.cleanup?.receipt?.runtimeId]
249
+ .filter(value => value !== undefined);
250
+ if (!values.length || values.some(value => typeof value !== "string" || !value)) return undefined;
251
+ return new Set(values).size === 1 ? values[0] : undefined;
252
+ }
253
+
254
+ function projectSummary({ id, report, linkedRuntime, runtimeGap }) {
255
+ const result = report.result;
256
+ const output = typeof result?.business === "string" ? result.business : result?.business?.output;
257
+ const cleanup = ["complete", "pending"].includes(report.cleanup?.status) ? report.cleanup.status : "unknown";
258
+ return {
259
+ id, kind: "harness", runId: report.runId, harness: report.harness.id,
260
+ label: report.harness.id, status: report.outcome, cleanup,
261
+ outcome: {
262
+ status: report.outcome, report: "project-run.json",
263
+ ...(typeof report.reason === "string" ? { reason: report.reason } : {}),
264
+ ...(Object.hasOwn(report, "result") ? { result } : {}),
265
+ ...(Object.hasOwn(report, "failure") ? { failure: report.failure } : {}),
266
+ ...(Object.hasOwn(report, "artifacts") ? { artifacts: report.artifacts } : {}),
267
+ ...(typeof output === "string" ? { output } : {}),
268
+ },
269
+ export: report.export ?? { status: "not-recorded" },
270
+ verification: {
271
+ artifactVerification: result?.artifactVerification ?? result?.report?.artifactVerification ?? { status: "not-recorded" },
272
+ acceptance: report.acceptance ?? { status: "not-recorded" },
273
+ },
274
+ pendingResources: report.cleanup,
275
+ ...(linkedRuntime ? { linkedRuntime } : {}),
276
+ files: [{ path: "project-run.json", kind: "harness", label: "Harness Run report" }],
277
+ // Empty evidence collections preserve API compatibility, not zero-runtime metrics.
278
+ agents: [], members: [], spans: [], points: [], relations: [], serviceStates: [],
279
+ gaps: linkedRuntime ? [] : [{ kind: "runtime-not-associated", message: runtimeGap }],
280
+ };
281
+ }
282
+
219
283
  async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
220
284
  const projectDirectory = dirname(runtimeDirectory);
221
285
  if (!inside(root, projectDirectory) || typeof runtimeId !== "string")
@@ -230,13 +294,9 @@ async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
230
294
  return undefined;
231
295
  throw error;
232
296
  }
233
- if (!report || report.runId !== basename(projectDirectory) ||
234
- report.harness?.apiVersion !== 1 ||
235
- !["completed", "failed", "cancelled"].includes(report.outcome))
236
- return undefined;
297
+ if (!validProjectReport(report, projectDirectory)) return undefined;
237
298
  const result = report.result;
238
- const receipt = report.cleanup?.receipt;
239
- if ((result?.runtimeId ?? receipt?.runtimeId) !== runtimeId) return undefined;
299
+ if (projectRuntimeId(report) !== runtimeId) return undefined;
240
300
 
241
301
  const output = typeof result?.business === "string" ? result.business : result?.business?.output;
242
302
  const businessFailure = result?.businessFailure?.message ?? report.failure?.message;
@@ -249,6 +309,10 @@ async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
249
309
  outcome: {
250
310
  status: report.outcome,
251
311
  report: name,
312
+ ...(typeof report.reason === "string" ? { reason: report.reason } : {}),
313
+ ...(Object.hasOwn(report, "result") ? { result } : {}),
314
+ ...(Object.hasOwn(report, "failure") ? { failure: report.failure } : {}),
315
+ ...(Object.hasOwn(report, "artifacts") ? { artifacts: report.artifacts } : {}),
252
316
  ...(typeof output === "string" ? { output: output.slice(0, 4000) } : {}),
253
317
  ...(typeof businessFailure === "string" ? { businessFailure: businessFailure.slice(0, 1000) } : {}),
254
318
  ...(["complete", "pending"].includes(cleanup) ? { cleanup } : {}),
@@ -368,6 +432,7 @@ class RunIndex {
368
432
  this.gapKeys = new Set();
369
433
  this.spans = [];
370
434
  this.researchPoints = [];
435
+ this.researchCandidates = new Map();
371
436
  this.inputObservations = [];
372
437
  this.sessionToolResults = [];
373
438
  this.relations = [];
@@ -523,11 +588,23 @@ class RunIndex {
523
588
  if (kind === "research") {
524
589
  if (agent && record.operation === "peer.ready" && typeof record.label === "string")
525
590
  agent.label = searchName(record.label) ?? agent.label;
591
+ const sha256 = recordedSha256(record.sha256);
592
+ const candidate = typeof record.candidate === "string" && /^candidate-[1-9][0-9]*$/.test(record.candidate) ? record.candidate : undefined;
593
+ const basedOn = typeof record.basedOn === "string" && /^candidate-[1-9][0-9]*$/.test(record.basedOn) ? record.basedOn : undefined;
594
+ const sequence = Number.isSafeInteger(record.seq) ? record.seq : undefined;
595
+ Object.assign(event, { candidate, sha256, basedOn, basedOnSha256: recordedSha256(record.basedOnSha256), sequence });
596
+ if (/\.(?:unknown|failed)$/.test(record.operation ?? "")) event.status = "failed";
597
+ if (candidate && sha256 && ["candidate.queued", "candidate.built-on"].includes(record.operation) &&
598
+ Number.isSafeInteger(record.bytes) && record.bytes > 0 && record.bytes <= 1024 * 1024) {
599
+ this.researchCandidates.set(candidate, {
600
+ path: `candidates/${candidate}.patch`, kind: "artifact", bytes: record.bytes, sha256, agentId,
601
+ });
602
+ }
526
603
  this.researchPoints.push({
527
- id: event.id, agentId, kind, label: event.label, time: event.time,
528
- detail: [record.candidate, record.sha256, record.basedOn, record.basedOnSha256, record.detail, typeof record.score === "number" ? String(record.score) : undefined]
604
+ id: event.id, agentId, kind, label: event.label, time: event.time, sequence,
605
+ detail: [candidate, sha256, basedOn, record.basedOnSha256, record.detail, typeof record.score === "number" ? String(record.score) : undefined]
529
606
  .filter(value => typeof value === "string").join(" · ").slice(0, 540),
530
- status: record.operation === "train.unknown" ? "failed" : "recorded", evidenceIds: [event.id],
607
+ status: event.status, evidenceIds: [event.id],
531
608
  });
532
609
  }
533
610
  if (record.type === "spawn" && agent) {
@@ -1105,7 +1182,8 @@ class RunIndex {
1105
1182
  const report = await readJSON(this.path, "runtime.json");
1106
1183
  if (!report) throw failure("Run runtime.json is missing", 404);
1107
1184
  this.report = report;
1108
- this.project = await readProjectOutcome(this.root, this.path, report.runtimeId);
1185
+ this.project = this.projectAllowed === false ? undefined :
1186
+ await readProjectOutcome(this.root, this.path, report.runtimeId);
1109
1187
  const schema = report.config?.schemaVersion ?? report.schemaVersion ?? 1;
1110
1188
  if (schema !== 1)
1111
1189
  this.gap(
@@ -1171,6 +1249,7 @@ class RunIndex {
1171
1249
  for (const [path, file] of this.files) {
1172
1250
  if (file.kind === "artifact" || file.kind === "session") this.files.delete(path);
1173
1251
  }
1252
+ for (const file of this.researchCandidates.values()) this.files.set(file.path, { ...file });
1174
1253
  for (const agent of this.agents.values()) {
1175
1254
  for (const kind of ["session", "artifacts"]) {
1176
1255
  const manifestPath = `${agent.id}/${kind}/manifest.json`;
@@ -1358,7 +1437,7 @@ class RunIndex {
1358
1437
  return [event.label, event.kind, event.type, event.agentId, agent?.label,
1359
1438
  agent?.profile, event.requestId, event.inputId, event.operationId,
1360
1439
  event.service && `${event.service}.${event.operation ?? ""}`,
1361
- event.toolName, event.model]
1440
+ event.toolName, event.model, event.candidate, event.sha256, event.basedOn, event.basedOnSha256]
1362
1441
  .map((value) => searchName(value) ?? "").join(" ").toLowerCase().includes(needle);
1363
1442
  };
1364
1443
  }
@@ -1604,21 +1683,62 @@ class RunIndex {
1604
1683
  }
1605
1684
 
1606
1685
  export async function createTraceReader({ root }) {
1607
- const rootPath = await realpath(root);
1686
+ const requestedRoot = resolve(root);
1687
+ let rootPath = requestedRoot;
1688
+ let rootStatus = "missing";
1608
1689
  const runs = new Map();
1690
+ const reports = new Map();
1691
+ const reportDirectories = new Map();
1609
1692
  const indexes = new Map();
1610
- async function discover() {
1693
+ let discovery;
1694
+ async function scan() {
1695
+ try {
1696
+ const canonical = await realpath(requestedRoot);
1697
+ if (!(await lstat(canonical)).isDirectory()) throw failure("Trace root must be a directory");
1698
+ if (canonical !== rootPath) indexes.clear();
1699
+ rootPath = canonical;
1700
+ rootStatus = "ready";
1701
+ } catch (error) {
1702
+ if (error.code === "ENOENT") {
1703
+ rootPath = requestedRoot;
1704
+ rootStatus = "missing";
1705
+ runs.clear(); reports.clear(); reportDirectories.clear(); indexes.clear();
1706
+ return;
1707
+ }
1708
+ if (["EACCES", "EPERM"].includes(error.code)) throw failure("Cannot read the Trace root: " + requestedRoot, 403);
1709
+ throw error;
1710
+ }
1611
1711
  const found = new Map();
1712
+ const foundReports = new Map();
1612
1713
  async function visit(path, depth) {
1613
- if (depth > 5 || found.size >= 10000) return;
1714
+ if (depth > 5 || found.size + foundReports.size >= 10000) return;
1614
1715
  let entries;
1615
1716
  try {
1616
1717
  entries = await readdir(path, { withFileTypes: true });
1617
1718
  } catch (error) {
1719
+ if (path === rootPath) {
1720
+ if (missing(error)) { rootStatus = "missing"; return; }
1721
+ if (["EACCES", "EPERM"].includes(error.code)) throw failure("Cannot read the Trace root: " + rootPath, 403);
1722
+ }
1618
1723
  if (missing(error) || ["EACCES", "EPERM"].includes(error.code)) return;
1619
1724
  throw error;
1620
1725
  }
1726
+ if (entries.some(entry => entry.name === "project-run.json" && entry.isFile())) {
1727
+ try {
1728
+ const report = await readJSON(rootPath, relative(rootPath, join(path, "project-run.json")));
1729
+ if (validProjectReport(report, path)) {
1730
+ // Runtime IDs remain relative paths. A leading slash makes this new
1731
+ // report namespace unambiguous even when names overlap below a root.
1732
+ const location = relative(rootPath, path).split(sep).join("/");
1733
+ const id = location ? "/harness/" + location : "/harness";
1734
+ foundReports.set(id, { id, path, report });
1735
+ }
1736
+ } catch (error) {
1737
+ if (!(error instanceof SyntaxError) && !error.status && !["EACCES", "EPERM"].includes(error.code)) throw error;
1738
+ }
1739
+ }
1621
1740
  if (
1741
+ found.size + foundReports.size < 10000 &&
1622
1742
  entries.some((entry) => entry.name === "runtime.json" && entry.isFile())
1623
1743
  ) {
1624
1744
  found.set(
@@ -1639,21 +1759,71 @@ export async function createTraceReader({ root }) {
1639
1759
  }
1640
1760
  }
1641
1761
  await visit(rootPath, 0);
1762
+ const runtimeIds = new Map();
1763
+ for (const [id, path] of found) {
1764
+ try {
1765
+ const runtimeId = (await readJSON(path, "runtime.json"))?.runtimeId;
1766
+ if (typeof runtimeId === "string") {
1767
+ if (!runtimeIds.has(runtimeId)) runtimeIds.set(runtimeId, []);
1768
+ runtimeIds.get(runtimeId).push({ id, runtimeId, path });
1769
+ }
1770
+ } catch {
1771
+ // Runtime list entries retain their own unreadable status below.
1772
+ }
1773
+ }
1774
+ for (const entry of foundReports.values()) {
1775
+ const runtimeId = projectRuntimeId(entry.report);
1776
+ const matches = runtimeIds.get(runtimeId);
1777
+ if (matches?.length === 1 && dirname(matches[0].path) === entry.path) {
1778
+ const { id, runtimeId } = matches[0];
1779
+ entry.linkedRuntime = { id, runtimeId };
1780
+ } else if (!runtimeId) {
1781
+ const hasIdentity = entry.report.result?.runtimeId !== undefined || entry.report.cleanup?.receipt?.runtimeId !== undefined;
1782
+ entry.runtimeGap = hasIdentity
1783
+ ? "The Harness report contains invalid or conflicting Runtime identities"
1784
+ : "No Runtime identity was recorded in this Harness report";
1785
+ } else if (matches?.length > 1) {
1786
+ entry.runtimeGap = "Multiple Runtime records share the identity recorded in this Harness report";
1787
+ } else if (matches?.length === 1) {
1788
+ entry.runtimeGap = "The matching Runtime is not recorded directly under this Harness Run";
1789
+ } else {
1790
+ entry.runtimeGap = "No Runtime record found for the identity recorded in this Harness report";
1791
+ }
1792
+ }
1642
1793
  runs.clear();
1643
1794
  for (const [id, path] of found) runs.set(id, path);
1795
+ reports.clear(); reportDirectories.clear();
1796
+ for (const [id, entry] of foundReports) {
1797
+ reports.set(id, entry);
1798
+ reportDirectories.set(entry.path, entry);
1799
+ }
1800
+ }
1801
+ function discover() {
1802
+ if (!discovery) discovery = scan().finally(() => { discovery = undefined; });
1803
+ return discovery;
1644
1804
  }
1645
1805
  await discover();
1646
- async function index(id) {
1647
- if (!runs.has(id)) await discover();
1806
+ async function index(id, refreshDiscovery = false) {
1807
+ if (refreshDiscovery || reports.has(id) || !runs.has(id)) await discover();
1808
+ const project = reports.get(id);
1809
+ if (project) return {
1810
+ kind: "harness", path: project.path,
1811
+ summary: () => projectSummary(project),
1812
+ files: new Map([["project-run.json", { path: "project-run.json", kind: "harness" }]]),
1813
+ sources: new Map(),
1814
+ };
1648
1815
  const path = runs.get(id);
1649
1816
  if (!path)
1650
1817
  throw failure("Run was not found under the configured root", 404);
1651
1818
  if (!indexes.has(id)) indexes.set(id, new RunIndex(path, id, rootPath));
1652
1819
  const current = indexes.get(id);
1820
+ current.projectAllowed = reportDirectories.get(dirname(path))?.linkedRuntime?.id === id;
1653
1821
  await current.update();
1654
1822
  return current;
1655
1823
  }
1656
1824
  return {
1825
+ get root() { return rootPath; },
1826
+ get rootStatus() { return rootStatus; },
1657
1827
  async listRuns() {
1658
1828
  await discover();
1659
1829
  const result = [];
@@ -1675,16 +1845,35 @@ export async function createTraceReader({ root }) {
1675
1845
  result.push({ id, status: "unreadable", error: error.message });
1676
1846
  }
1677
1847
  }
1848
+ for (const { id, report, linkedRuntime } of reports.values()) {
1849
+ if (linkedRuntime) continue;
1850
+ result.push({
1851
+ id, kind: "harness", runId: report.runId, harness: report.harness.id,
1852
+ label: report.harness.id, status: report.outcome,
1853
+ cleanup: ["complete", "pending"].includes(report.cleanup?.status) ? report.cleanup.status : "unknown",
1854
+ });
1855
+ }
1678
1856
  return result;
1679
1857
  },
1680
1858
  async summary(id) {
1681
- return (await index(id)).summary();
1859
+ return (await index(id, true)).summary();
1682
1860
  },
1683
1861
  async timeline(id, options = {}) {
1684
- return (await index(id)).timeline(options);
1862
+ const current = await index(id);
1863
+ if (current.kind !== "harness") return current.timeline(options);
1864
+ if (options.focus) throw failure("Record was not found", 404);
1865
+ for (const value of [options.from, options.to]) {
1866
+ if (value !== undefined && !Number.isSafeInteger(value)) throw failure("Invalid timeline time");
1867
+ }
1868
+ if (options.from !== undefined && options.to !== undefined && options.from > options.to) throw failure("Invalid timeline range");
1869
+ return { spans: [], points: [], total: 0, truncated: false, from: options.from ?? null, to: options.to ?? null };
1685
1870
  },
1686
1871
  async events(id, { cursor, limit = 1000, agentId, memberId, type, query, attention = false } = {}) {
1687
1872
  const current = await index(id);
1873
+ if (current.kind === "harness") {
1874
+ if (cursor !== "latest") decodeCursor(cursor);
1875
+ return { events: [], cursor: encodeCursor({}), hasMore: false, total: 0, runTotal: 0 };
1876
+ }
1688
1877
  const filter = current.eventFilter({ agentId, type, query });
1689
1878
  const matches = event => filter(event) && (!attention || needsAttention(event)) &&
1690
1879
  (!memberId || current.agents.get(event.agentId)?.memberId === memberId);
@@ -1755,6 +1944,7 @@ export async function createTraceReader({ root }) {
1755
1944
  },
1756
1945
  async detail(id, eventId, { identity: expectedIdentity } = {}) {
1757
1946
  const current = await index(id);
1947
+ if (current.kind === "harness") throw failure("Record was not found", 404);
1758
1948
  const relation = current.relations.find((item) => item.id === eventId);
1759
1949
  if (relation?.explicit) return { relation };
1760
1950
  const event = current.byId.get(eventId);
@@ -1785,6 +1975,30 @@ export async function createTraceReader({ root }) {
1785
1975
  }
1786
1976
  const files = [];
1787
1977
  const contextMatches = [];
1978
+ let research;
1979
+ if (event.kind === "research") {
1980
+ const versions = new Map([[event.candidate, event.sha256], [event.basedOn, event.basedOnSha256]]
1981
+ .filter(([candidate, hash]) => candidate && hash));
1982
+ const matches = [...current.byId.values()].filter(entry => entry.kind === "research" && entry.id !== event.id &&
1983
+ (versions.has(entry.candidate) && versions.get(entry.candidate) === entry.sha256 ||
1984
+ versions.has(entry.basedOn) && versions.get(entry.basedOn) === entry.basedOnSha256));
1985
+ const candidateEvidence = entry => versions.has(entry.candidate) &&
1986
+ versions.get(entry.candidate) === entry.sha256 && /^(?:candidate|train|final)\./.test(entry.operation);
1987
+ const related = [
1988
+ ...matches.filter(candidateEvidence).sort(compareTimeline),
1989
+ ...matches.filter(entry => !candidateEvidence(entry)).sort(compareTimeline),
1990
+ ].slice(0, 100).sort(compareTimeline);
1991
+ const checked = [];
1992
+ for (const [candidate, sha256] of versions) {
1993
+ const file = current.researchCandidates.get(candidate);
1994
+ const status = file?.sha256 === sha256 ? await current.archivedFileStatus(file, sha256) : "record-mismatch";
1995
+ const entry = { path: file?.path ?? `candidates/${candidate}.patch`, sha256, status,
1996
+ ...(status === "verified" ? { identity: `sha256:${sha256}` } : {}) };
1997
+ if (status === "verified") files.push(entry);
1998
+ checked.push(entry);
1999
+ }
2000
+ research = { related, relatedTotal: matches.length, files: checked };
2001
+ }
1788
2002
  if (relation?.messageId && relation.toAgentId) {
1789
2003
  for (const model of current.modelDirectories.values()) {
1790
2004
  if (model.event.agentId !== relation.toAgentId) continue;
@@ -1852,6 +2066,7 @@ export async function createTraceReader({ root }) {
1852
2066
  serviceStates: current.serviceStates.filter(snapshot => snapshot.serviceId === (record.service ?? record.serviceId)),
1853
2067
  } : {}),
1854
2068
  contextMatches,
2069
+ ...(research ? { research } : {}),
1855
2070
  truncated: event.source.length > maxBodyBytes,
1856
2071
  };
1857
2072
  },
@@ -1904,28 +2119,29 @@ export async function createTraceReader({ root }) {
1904
2119
  throw failure("Shared file source was replaced", 409);
1905
2120
  }
1906
2121
  if (digest) {
1907
- data = await readVerifiedFile(handle, stat, digest, recorded.bytes, offset, limit);
2122
+ data = await readVerifiedFile(handle, stat, digest, recorded.bytes, offset, limit + 3);
1908
2123
  if (!data) throw failure("Archived file version changed", 409);
1909
2124
  } else {
1910
2125
  const total = Number(stat.size);
1911
- const buffer = Buffer.alloc(Math.max(0, Math.min(limit, total - offset)));
2126
+ const buffer = Buffer.alloc(Math.max(0, Math.min(limit + 3, total - offset)));
1912
2127
  const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
1913
2128
  if (fileStatSignature(await handle.stat({ bigint: true })) !== fileStatSignature(stat)) {
1914
2129
  throw failure("File source changed while being read", 409);
1915
2130
  }
1916
- data = { text: buffer.subarray(0, bytesRead).toString("utf8"), bytesRead, total };
2131
+ data = { content: buffer.subarray(0, bytesRead), total };
1917
2132
  }
1918
2133
  } finally {
1919
2134
  await handle.close();
1920
2135
  }
2136
+ const { text, bytesRead } = utf8FilePage(data.content, limit);
1921
2137
  return {
1922
2138
  path,
1923
2139
  identity: fileIdentity,
1924
- text: data.text,
2140
+ text,
1925
2141
  offset,
1926
- nextOffset: offset + data.bytesRead,
2142
+ nextOffset: offset + bytesRead,
1927
2143
  total: data.total,
1928
- truncated: offset + data.bytesRead < data.total,
2144
+ truncated: offset + bytesRead < data.total,
1929
2145
  };
1930
2146
  },
1931
2147
  };
@@ -0,0 +1 @@
1
+ export function defaultRunRoot(env?: NodeJS.ProcessEnv, home?: string): string;
@@ -0,0 +1,7 @@
1
+ import { homedir } from 'node:os';
2
+ import { join, resolve } from 'node:path';
3
+
4
+ /** The shared default; a Harness can still select a private fallback outside its input. */
5
+ export function defaultRunRoot(env = process.env, home = homedir()) {
6
+ return resolve(env.XDG_STATE_HOME || join(home, '.local', 'state'), 'anyswarm', 'runs');
7
+ }
@@ -124,7 +124,8 @@ async function route(request, response, reader) {
124
124
  }
125
125
  const { pathname, searchParams } = new URL(request.url, 'http://' + loopback);
126
126
  if (pathname === '/api/runs') {
127
- return json(response, 200, { runs: await reader.listRuns() });
127
+ const runs = await reader.listRuns();
128
+ return json(response, 200, { runs, root: reader.root, rootStatus: reader.rootStatus });
128
129
  }
129
130
  if (!pathname.startsWith('/api/')) return staticAsset(pathname, response);
130
131
  const match = /^\/api\/runs\/([^/]+)(?:\/(events|timeline|records|files|live)(?:\/([^/]+))?)?$/.exec(pathname);
@@ -183,6 +184,7 @@ export async function startTraceServer({ root, port = 8787 }) {
183
184
  });
184
185
  return {
185
186
  url: 'http://' + loopback + ':' + server.address().port,
187
+ get root() { return reader.root; },
186
188
  close: () => new Promise((resolve, reject) => {
187
189
  server.close(error => error ? reject(error) : resolve());
188
190
  server.closeAllConnections();
package/docs/INDEX.md CHANGED
@@ -1,18 +1,19 @@
1
1
  # AnySwarm documentation
2
2
 
3
- Start with the user guides to run a Harness or build your own. The English and Chinese Markdown files are the website's content source: editing a guide here updates the corresponding published page when the site is rebuilt.
3
+ Start with the user guides to run a Harness or build your own. The English and Chinese Markdown files in this checkout describe its development revision. Website builds publish them in the explicitly unreleased `next` documentation. The default website guides use the released package and compatible documentation revisions recorded in [the documentation release manifest](../website/docs-release.json). Merging a guide change does not advance the stable documentation or publish an npm package.
4
4
 
5
5
  ## Start using AnySwarm
6
6
 
7
7
  | Goal | English | 中文 |
8
8
  | --- | --- | --- |
9
9
  | Understand what AnySwarm provides | [Overview](en/overview.md) | [文档总览](zh/overview.md) |
10
- | Run your first Harness | [Quickstart](en/quickstart.md) | [快速上手](zh/quickstart.md) |
10
+ | Inspect a real repository and export its handoff | [Quickstart](en/quickstart.md) | [快速上手](zh/quickstart.md) |
11
11
  | Build a 2-minute mental model | [Core Concepts](en/concepts.md) | [核心概念](zh/concepts.md) |
12
12
  | Master the 6 core building blocks | [Sandboxes](en/sandbox.md) · [Runtime](en/runtime.md) · [Agents](en/agents.md) · [Gateway](en/gateway.md) · [Services](en/services.md) · [Trace Viewer](en/trace-viewer.md) | [Sandbox](zh/sandbox.md) · [Runtime](zh/runtime.md) · [Agent](zh/agents.md) · [Gateway](zh/gateway.md) · [Services](zh/services.md) · [观测与调试](zh/trace-viewer.md) |
13
- | Build a two-Agent Harness with the npm SDK | [First SDK Harness](en/first-harness.md) | [搭建第一个 SDK Harness](zh/first-harness.md) |
14
- | Build a parallel Swarm step by step | [Build a Swarm Harness](en/build-your-harness.md) | [实战:构建 Swarm Harness](zh/build-your-harness.md) |
15
- | Compare the five collaboration patterns | [Choose a Harness](en/harnesses/index.md) | [选择 Harness](zh/harnesses/index.md) |
13
+ | Learn the two-Agent SDK handoff (source candidate) | [First SDK Harness](en/first-harness.md) | [搭建第一个 SDK Harness](zh/first-harness.md) |
14
+ | Add parallel research, peer review and synthesis | [Build a Swarm Harness](en/build-your-harness.md) | [实战:构建 Swarm Harness](zh/build-your-harness.md) |
15
+ | Choose an application, topology or advanced example | [Choose a Harness](en/harnesses/index.md) | [选择 Harness](zh/harnesses/index.md) |
16
+ | Understand AutoResearch and its current requirements | [AutoResearch](en/autoresearch.md) | [AutoResearch](zh/autoresearch.md) |
16
17
  | Look up SDK exports, CLI flags & types | [API](en/reference/api.md) · [CLI](en/reference/cli.md) · [Types](en/reference/types.md) | [API](zh/reference/api.md) · [CLI](zh/reference/cli.md) · [类型](zh/reference/types.md) |
17
18
  | Track the latest release & changelog | [Releases](en/latest.md) · [Changelog](en/changelog.md) | [最新版本](zh/latest.md) · [更新日志](zh/changelog.md) |
18
19
 
@@ -23,7 +24,8 @@ Start with the user guides to run a Harness or build your own. The English and C
23
24
  | Reference | Purpose |
24
25
  | --- | --- |
25
26
  | [Development](workflows/development.md) | Build, validate and contribute changes. |
26
- | [Release updates and documentation versions](workflows/release-and-docs-versioning.md) | Publish the next release and plan versioned guides. |
27
+ | [Release CLI acceptance](workflows/release-cli-acceptance.md) | Verify the installed CLI, one-shot Runs, Trace, eject and npm upgrades. |
28
+ | [Release updates and documentation versions](workflows/release-and-docs-versioning.md) | Verify candidates, publish npm `next` or a formal release, and advance the stable guides. |
27
29
  | [Coding Agent instructions](../AGENTS.md) | Project-specific work rules, permissions and documentation requirements. |
28
30
  | [Engineering record conventions](../AGENTS.md#engineering-record-conventions) | Issue scope, evidence and triage conventions. |
29
31
  | [AutoResearch](architecture/28-autoresearch.md) | Prepare the FrontierCS-2 demo, watch peer research and inspect official evaluation records. |
@@ -34,11 +36,11 @@ Start with the user guides to run a Harness or build your own. The English and C
34
36
 
35
37
  ## Current behavior and planned changes
36
38
 
37
- The user guides describe the supported public surface. The architecture manual describes how the current tree implements it. Source code and generated references establish exact fields and defaults; tests and experiments establish what was verified. Changes to this baseline need corresponding documentation in their implementation PR.
39
+ The user guides describe the public surface of the source revision they accompany; the default website guides remain bound to the released version. The architecture manual describes how the current tree implements its behavior. Source code and generated references establish exact fields and defaults; tests and experiments establish what was verified. Changes to this baseline need corresponding documentation in their implementation PR.
38
40
 
39
- The [Core / Harness design](designs/core-harness/README.md) retains reviewed, version-bound decisions and acceptance criteria. Read it with the applicable Issue and later explicit owner decisions; older first-release limits do not override those changes. The design index links the [dynamic Lead-Worker contract](designs/dynamic-lead-worker.md) and CLI/TUI work in [#252](https://github.com/AnySwarm/anyswarm/issues/252). Current implementation belongs in Architecture; remaining acceptance stays in the original Issue/PR. Design updates, code, migration, tests and documentation are reviewed together in the implementation PR.
41
+ The [Core / Harness design](designs/core-harness/README.md) retains reviewed, version-bound decisions and acceptance criteria. Read it with the applicable Issue and later explicit owner decisions; older first-release limits do not override those changes. The design index links the [dynamic Lead-Worker contract](designs/dynamic-lead-worker.md) and CLI scope in [#351](https://github.com/AnySwarm/anyswarm/issues/351). Current implementation belongs in Architecture; remaining acceptance stays in the original Issue/PR. Design updates, code, migration, tests and documentation are reviewed together in the implementation PR.
40
42
 
41
- The five collaboration projects own their Harnesses and Services under `examples/`. TaskPool also owns its domain stores and compatibility hosts. The [example index](../examples/README.md) explains how to install and build them with the published SDK or a source build. The [repository migration](designs/repository-layout.md) records the audit and verification scope, and the [deployment guide](../deploy/README.md) describes common infrastructure.
43
+ The examples are organized into three tiers: a real repository CLI task and SDK teaching path; AutoResearch and local collaboration references; advanced source and heavy integrations. Their Harnesses and Services live under `examples/`. TaskPool also owns its domain stores and compatibility hosts. The [example index](../examples/README.md) explains how to install and build them with the published SDK or a source build. The [repository migration](designs/repository-layout.md) records the audit and verification scope, and the [deployment guide](../deploy/README.md) describes common infrastructure.
42
44
 
43
45
  Superseded plans from earlier phases, migration inventories and superseded ADRs remain in [Git history before this cleanup](https://github.com/AnySwarm/anyswarm/tree/fb457bbfc8fc038ac8f2cfbbcfd1ab4a4e655b02/docs).
44
46
 
@@ -148,7 +148,7 @@ Sources: [bundle loader](../../examples/taskpool/deploy/service-hosts/service-bu
148
148
 
149
149
  Offline help at the root and Task group lists Task commands, including `create`. `swarm task create --help` supplies the required flags, accepted priorities, the JSON shape for completion conditions, a complete command and the returned Task ID. The live Bridge manifest from `swarm service view task --json` shows which commands the host actually enabled. The normal Task adapter binds Mission and Workspace from its own trusted state when an Agent sends a proposal.
150
150
 
151
- `dist/scripts/swarm.js` is the non-interactive Bash entry point and delegates parsing/invocation to `src/cli/swarm-cli.ts`. Registered Agents use its protected Bridge mode described under [Agent CLI routing](#agent-cli-routing); the direct endpoint/explicit-envelope description here applies to trusted operator calls. swarm --help, swarm service --help, and each domain's --help are offline and explain endpoint variables, JSON/file/stdin input, actor identity and command families. swarm service list reads the configured service manifests; service view reads one manifest. Each built-in CLI command resolves one registered operation, compose a typed operation envelope, send a JSON envelope/input/role request to the HTTP route and print one JSON result on stdout. Command-level help describes required flags and input/output shape. Requests have a bounded timeout (default 30 seconds, maximum 2,147,483,647 milliseconds). Diagnostics and structured failures go to stderr; invalid usage exits 2, HTTP/provider failures or timeouts exit 1, and a successful Judge request whose business verdict is FAIL/source_failure/mathematical_failure/incorrect exits 3 while still printing the authoritative result.
151
+ The Worker image links `/usr/local/bin/swarm` to the bundled `dist/scripts/swarm.js` independently of the public npm executable. This non-interactive entry point delegates parsing/invocation to `src/cli/swarm-cli.ts`. Registered Agents use its protected Bridge mode described under [Agent CLI routing](#agent-cli-routing); the direct endpoint/explicit-envelope description here applies to trusted operator calls. swarm --help, swarm service --help, and each domain's --help are offline and explain endpoint variables, JSON/file/stdin input, actor identity and command families. swarm service list reads the configured service manifests; service view reads one manifest. Each built-in CLI command resolves one registered operation, compose a typed operation envelope, send a JSON envelope/input/role request to the HTTP route and print one JSON result on stdout. Command-level help describes required flags and input/output shape. Requests have a bounded timeout (default 30 seconds, maximum 2,147,483,647 milliseconds). Diagnostics and structured failures go to stderr; invalid usage exits 2, HTTP/provider failures or timeouts exit 1, and a successful Judge request whose business verdict is FAIL/source_failure/mathematical_failure/incorrect exits 3 while still printing the authoritative result.
152
152
 
153
153
  The CLI is a client of an already hosted service. It does not construct a domain service, open a service database, or keep long-running work in the Agent sandbox. ANYSWARM_<SERVICE>_SERVICE_URL and the optional bearer token identify the endpoint; ANYSWARM_SERVICE_ENDPOINTS can supply a JSON discovery list for service list. The CLI's request ID is an idempotency key only when the receiving Service honors the envelope operation identity; the CLI does not retry a write after a lost response.
154
154