@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
@@ -1,91 +1,92 @@
1
- import { createHash } from 'node:crypto';
2
- import { readFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- import { createRuntime, createSandbox, resolveSandboxConnection, runInput, ServiceRegistry, workerImageFor, } from '@anyswarm/core';
1
+ import { createRuntime, createSandbox, projectConfiguration, ProjectPreflightError, runInput, ServiceRegistry, } from '@anyswarm/core';
5
2
  import { FindingsBoard } from './board.js';
6
3
  import { boardService } from './board-service.js';
7
- const researcherPrompt = 'Inspect the workspace. Publish concrete findings with swarm service invoke board publish. Read peer findings with swarm service invoke board search.';
8
- const synthesizerPrompt = 'Use swarm service invoke board search to read the findings and citations. Write a concise report.md in your workspace.';
9
- const reviewInput = 'Read the other researchers’ findings and publish a follow-up addressing a gap or disagreement. Cite the entries you relied on.';
10
- const synthesisInput = 'Summarize the board findings and citations in report.md.';
4
+ import { checkReportExport } from './report.js';
5
+ const researcherPrompt = 'Investigate the user\'s question in the captured local repository. Publish concrete findings with swarm service invoke board publish. Each finding needs evidence: relative path, 1-based startLine/endLine, and an exact short excerpt (1–40 lines, at most 4096 bytes; omit the final newline). Distinguish facts, inferences and unverified questions in the summary. Do not modify source files or invent a defect. Read peer findings with swarm service invoke board search.';
6
+ const synthesizerPrompt = 'Use swarm service invoke board search to read the research and reviews. Answer the user\'s question in report.md: give conclusions, relative source paths and line numbers, finding IDs, disagreements and unverified items. Separate facts from inference. The host checks the Board\'s source locations and the report export; it does not establish that your conclusions are correct. Do not modify other project files.';
7
+ const researchFocuses = ['Entry points, configuration and how to run the relevant behavior.', 'Core modules, data flow and dependencies relevant to the question.', 'Existing tests, observable guarantees and checks still needed.'];
8
+ const reviewInput = 'Read the other researchers\' first-round findings. Check their source evidence and publish at least one NEW follow-up addressing a gap, disagreement or corroboration relevant to the user\'s question. Include your own exact source evidence and cite at least one first-round finding by ANOTHER author in cites. A first-round publication does not count as this review.';
9
+ const synthesisInput = 'Read the Board, integrate the research and cross-author reviews, and write report.md for the task below. Cite source paths, line numbers and finding IDs; mark anything not verified.';
11
10
  const parallelSwarm = {
12
11
  id: 'parallel-swarm', apiVersion: 1,
13
12
  async run(context) {
14
- const url = process.env.ANYSWARM_MODEL_URL;
15
- if (!url)
16
- throw new Error('Set ANYSWARM_MODEL_URL to a streaming Responses endpoint before running.');
17
- const board = new FindingsBoard();
13
+ const config = await projectConfiguration(context, () => import('./config.js'));
14
+ const { image, model = 'default', turnTimeoutMs = 120_000, closeTimeoutMs = 60_000 } = config;
15
+ if (!image || ![turnTimeoutMs, closeTimeoutMs].every(ms => Number.isSafeInteger(ms) && ms > 0 && ms <= 2_147_483_647)) {
16
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Parallel Swarm needs an image and finite positive turn/close time limits.');
17
+ }
18
+ const board = new FindingsBoard(context.initial.files);
18
19
  const services = new ServiceRegistry();
19
20
  services.register('board', boardService(board), { toolMode: 'cli' });
20
- const { image: configuredImage, advertiseHost, publicUrl, executor: setupExecutor, endpointSource: _source, ...sandbox } = resolveSandboxConnection();
21
- const executor = process.env.ANYSWARM_EXECUTOR ?? setupExecutor ?? 'pi';
22
- if (executor !== undefined && executor !== 'pi' && executor !== 'codex')
23
- throw new Error('Select pi or codex with ANYSWARM_EXECUTOR.');
24
- const image = configuredImage ?? workerImageFor(executor);
25
- const token = process.env.ANYSWARM_MODEL_TOKEN;
26
- const runtime = await createRuntime({
27
- sandbox: createSandbox(sandbox), connection: { advertiseHost, publicUrl }, executor, services, maxAgents: 4, outputDir: context.outputDir,
28
- models: { default: {
29
- provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
30
- model: process.env.ANYSWARM_MODEL_ID ?? 'gpt-5-mini',
31
- upstream: { url, headers: token ? { authorization: `Bearer ${token}` } : {} },
32
- } },
33
- profiles: {
34
- researcher: { addedSystemPrompt: researcherPrompt, model: 'default', image, writable: false,
35
- services: { board: ['publish', 'search'] } },
36
- synthesizer: { addedSystemPrompt: synthesizerPrompt, model: 'default', image, writable: true,
37
- services: { board: ['search'] },
38
- collect: { paths: ['report.md'], includeGit: false, maxBytes: 1_048_576, required: true } },
39
- },
40
- });
41
- const turn = { signal: context.signal, timeoutMs: 120_000 };
42
- let synthId;
43
- let failure;
44
- let cleanup;
45
21
  let unobserve;
22
+ let synthId;
23
+ let researchChecked = false;
24
+ let reviewChecked = false;
25
+ const checks = {
26
+ report: { status: 'not-run', reason: 'SYNTHESIZER_NOT_STARTED' },
27
+ };
46
28
  try {
47
- unobserve = context.registerAgentControls({ runtime });
48
- context.markRunning();
49
- const peers = await Promise.all([1, 2, 3].map(index => runtime.spawn({ requestId: `spawn-r${index}`, profile: 'researcher', files: context.initial.files })));
50
- await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, context.input.prompt, { ...turn, requestId: `research-${index + 1}` })));
51
- const firstRound = board.search().length;
52
- if (firstRound === 0)
53
- throw new Error('The first round published no findings.');
54
- await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, reviewInput, { ...turn, requestId: `review-${index + 1}` })));
55
- if (board.search().length <= firstRound)
56
- throw new Error('The review round published no follow-up findings.');
57
- await Promise.all(peers.map(peer => runtime.stop(peer.id)));
58
- const synth = await runtime.spawn({ requestId: 'spawn-synthesizer', profile: 'synthesizer', files: context.initial.files });
59
- synthId = synth.id;
60
- await runInput(runtime, synth.id, synthesisInput, { ...turn, requestId: 'synthesize' });
61
- }
62
- catch (error) {
63
- failure = error.code ?? 'SWARM_FAILED';
29
+ const result = await context.runWithRuntime({
30
+ closeTimeoutMs,
31
+ createRuntime: () => createRuntime({
32
+ sandbox: createSandbox(config.sandbox), connection: config.connection, executor: config.executor,
33
+ models: config.models, filePolicy: config.filePolicy, services, maxAgents: 4, outputDir: context.outputDir,
34
+ profiles: {
35
+ researcher: { addedSystemPrompt: researcherPrompt, model, image, writable: false,
36
+ services: { board: ['publish', 'search'] } },
37
+ synthesizer: { addedSystemPrompt: synthesizerPrompt, model, image, writable: true,
38
+ services: { board: ['search'] },
39
+ collect: { paths: ['report.md'], includeGit: false, maxBytes: 1_048_576, required: true } },
40
+ },
41
+ }),
42
+ async run(runtime) {
43
+ unobserve = context.registerAgentControls({ runtime });
44
+ context.markRunning();
45
+ const turn = { signal: context.signal, timeoutMs: turnTimeoutMs };
46
+ context.signal.throwIfAborted();
47
+ const peers = await Promise.all(researchFocuses.map((_, index) => runtime.spawn({ requestId: `spawn-r${index + 1}`, profile: 'researcher', files: context.initial.files })));
48
+ board.beginResearch(peers.map(peer => peer.id));
49
+ await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, `${context.input.prompt}\n\nYour focus: ${researchFocuses[index]}\nPublish at least one source-backed finding.`, { ...turn, requestId: `research-${index + 1}` })));
50
+ board.beginReview();
51
+ researchChecked = true;
52
+ await Promise.all(peers.map((peer, index) => runInput(runtime, peer.id, reviewInput, { ...turn, requestId: `review-${index + 1}` })));
53
+ board.finishReview();
54
+ reviewChecked = true;
55
+ await Promise.all(peers.map(peer => runtime.stop(peer.id, { timeoutMs: closeTimeoutMs })));
56
+ context.signal.throwIfAborted();
57
+ const synth = await runtime.spawn({ requestId: 'spawn-synthesizer', profile: 'synthesizer', files: context.initial.files });
58
+ synthId = synth.id;
59
+ checks.report = { status: 'pending', reason: 'REPORT_EXPORT_PENDING' };
60
+ await runInput(runtime, synth.id, `${synthesisInput}\n\n${context.input.prompt}`, { ...turn, requestId: 'synthesize' });
61
+ return { synthesizerId: synthId, contributions: board.contributions() };
62
+ },
63
+ // A failed report check is business evidence, not a thrown cleanup error.
64
+ afterClose: async (receipt) => { checks.report = await checkReportExport(receipt, synthId, context.initial.files); },
65
+ detail: () => {
66
+ // Keep the final projection stable if a post-close read outlives its wait.
67
+ checks.finalized = { ...checks.report };
68
+ return { board: board.exportState(), report: checks.finalized };
69
+ },
70
+ });
71
+ const report = checks.finalized;
72
+ const reportFailed = report.status === 'unverified';
73
+ return {
74
+ ...result,
75
+ ...(result.outcome === 'completed' && reportFailed ? { outcome: 'failed', reason: report.reason } : {}),
76
+ acceptance: {
77
+ status: researchChecked && reviewChecked && report.status === 'verified' ? 'verified' : report.status === 'pending' ? 'pending' : 'unverified',
78
+ scope: 'participant-contributions, cross-author-reviews, Board-source-references, report-export',
79
+ research: researchChecked ? 'verified' : 'unverified', review: reviewChecked ? 'verified' : 'unverified',
80
+ sourceReferences: board.search().length ? 'verified' : 'not-run', report: { ...report }, semanticCorrectness: 'not-run',
81
+ },
82
+ artifacts: [...result.artifacts, ...(report.status === 'verified' ? [{ agentId: synthId, kind: 'report', ...report }] : [])],
83
+ ...(synthId ? { export: { ...result.export, status: result.export?.status === 'pending' || report.status === 'pending'
84
+ ? 'pending' : report.status === 'verified' ? 'complete' : 'failed' } } : {}),
85
+ };
64
86
  }
65
87
  finally {
66
- try {
67
- cleanup = await runtime.close({ timeoutMs: 60_000 });
68
- }
69
- finally {
70
- unobserve?.();
71
- }
88
+ unobserve?.();
72
89
  }
73
- const directory = cleanup.agents.find(agent => agent.agentId === synthId)?.artifacts.find(path => path.endsWith('/artifacts/files'));
74
- const file = directory && join(directory, 'report.md');
75
- const bytes = file ? await readFile(file).catch(() => undefined) : undefined;
76
- const artifact = file && bytes && bytes.toString('utf8').trim() ? {
77
- path: file, sha256: createHash('sha256').update(bytes).digest('hex'),
78
- } : undefined;
79
- const findings = board.search();
80
- return {
81
- outcome: context.signal.aborted ? 'cancelled' : failure || !artifact ? 'failed' : 'completed',
82
- reason: failure ?? (artifact ? 'report-verified' : 'report-missing'),
83
- result: { runtimeId: runtime.id, findings: findings.length, citedFindings: findings.filter(finding => finding.cites.length > 0).length },
84
- acceptance: { status: artifact ? 'verified' : 'unverified' },
85
- artifacts: artifact ? [artifact] : [],
86
- ...(synthId ? { export: { status: artifact ? 'complete' : 'failed' } } : {}),
87
- cleanup: { status: cleanup.cleanup, pending: cleanup.pending.map(({ id, kind, action }) => ({ id, kind, action })) },
88
- };
89
90
  },
90
91
  };
91
92
  export default parallelSwarm;
@@ -0,0 +1,12 @@
1
+ import type { CloseReceipt, FileTree } from '@anyswarm/core';
2
+ export type ReportCheck = {
3
+ status: 'not-run' | 'pending' | 'unverified';
4
+ reason: string;
5
+ } | {
6
+ status: 'verified';
7
+ path: string;
8
+ sha256: string;
9
+ bytes: number;
10
+ };
11
+ /** A readable, newly written report is an export check, not a semantic review. */
12
+ export declare function checkReportExport(receipt: CloseReceipt, agentId: string | undefined, initial: FileTree): Promise<ReportCheck>;
@@ -0,0 +1,30 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ /** A readable, newly written report is an export check, not a semantic review. */
5
+ export async function checkReportExport(receipt, agentId, initial) {
6
+ if (!agentId)
7
+ return { status: 'not-run', reason: 'SYNTHESIZER_NOT_STARTED' };
8
+ const agent = receipt.agents.find(agent => agent.agentId === agentId);
9
+ const directory = agent?.artifacts.find(path => path.endsWith(join('artifacts', 'files')));
10
+ if (!directory) {
11
+ const pending = !agent || agent.execution !== 'stopped' || agent.cleanup === 'pending' ||
12
+ receipt.pending.some(entry => entry.kind === 'agent' && entry.id === agentId);
13
+ return { status: pending ? 'pending' : 'unverified', reason: pending ? 'REPORT_EXPORT_PENDING' : 'REPORT_MISSING' };
14
+ }
15
+ const path = join(directory, 'report.md');
16
+ try {
17
+ const bytes = await readFile(path);
18
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
19
+ if (!text.trim())
20
+ return { status: 'unverified', reason: 'REPORT_EMPTY' };
21
+ const before = initial['report.md'];
22
+ if (before && bytes.equals(Buffer.from(before.data, before.encoding === 'base64' ? 'base64' : 'utf8'))) {
23
+ return { status: 'unverified', reason: 'REPORT_UNCHANGED' };
24
+ }
25
+ return { status: 'verified', path, sha256: createHash('sha256').update(bytes).digest('hex'), bytes: bytes.length };
26
+ }
27
+ catch {
28
+ return { status: 'unverified', reason: 'REPORT_UNREADABLE' };
29
+ }
30
+ }
@@ -70,7 +70,7 @@ repository sources.
70
70
 
71
71
  ```sh
72
72
  npm init -y
73
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
73
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
74
74
  npm install --save-dev typescript @types/node
75
75
  sdk=node_modules/@anyswarm/core
76
76
  cp -R "$sdk"/examples/peermesh demo
@@ -7,6 +7,7 @@ export declare function peerMeshConfig(durationMs?: number): {
7
7
  useServerProxy: boolean | undefined;
8
8
  egressMode: "dns+nft" | undefined;
9
9
  endpointHost: undefined;
10
+ preparedImage?: string | undefined;
10
11
  timeoutSeconds: number;
11
12
  resourceLimits: {
12
13
  cpu: string;
@@ -10,7 +10,7 @@ Run these commands in an empty directory. To use a source build, set `ANYSWARM_S
10
10
 
11
11
  ```sh
12
12
  npm init -y
13
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
13
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
14
14
  npm install --save-dev typescript @types/node
15
15
  cp -R node_modules/@anyswarm/core/examples/services/agent-control demo
16
16
  cd demo
@@ -39,7 +39,7 @@ process. See the maintained [Mathlib service implementation](../../../docs/archi
39
39
 
40
40
  To run the host without a container after building the checkout, use
41
41
  `npm run service:mathlib-search` from the root, or
42
- `../../../node_modules/.bin/anys run ./main.ts` from this directory.
42
+ `node ../../../dist/scripts/anyswarm.js run ./main.ts` from this directory.
43
43
  The caller supplies the host token with `MATHLIB_SEARCH_TOKEN`, and configures
44
44
  the endpoint in its own service adapter. The application/operator owns the
45
45
  external provider's lifecycle and persistent data; Runtime close does not remove it.
@@ -10,7 +10,7 @@ Use Linux with Node 24 or later. Run these commands in an empty directory. To us
10
10
 
11
11
  ```sh
12
12
  npm init -y
13
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
13
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
14
14
  npm install --save-dev typescript @types/node
15
15
  cp -R node_modules/@anyswarm/core/examples/services/mcp-managed demo
16
16
  cd demo
@@ -10,7 +10,7 @@ Use Node 24 or later. The HTTP variant also needs Python 3. Run these commands i
10
10
 
11
11
  ```sh
12
12
  npm init -y
13
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
13
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
14
14
  npm install --save-dev typescript @types/node
15
15
  cp -R node_modules/@anyswarm/core/examples/services/persistent-board demo
16
16
  cd demo
@@ -56,10 +56,13 @@ Open the completed Run, expand **Service states**, and inspect the Board export.
56
56
  Copy this example from the installed SDK as shown above. Configure OpenSandbox and select an installed Worker with setup or `ANYSWARM_WORKER_IMAGE`. Open the example in a regular terminal and run:
57
57
 
58
58
  ```sh
59
- anys -u ./live.ts 'Watch the persistent Board'
59
+ anyswarm --harness ./live.ts --mode rpc --lifetime interactive
60
60
  ```
61
61
 
62
- Enter two short findings in the composer. Each commit appears in the stream with its row ID, and the status header updates the committed count. Use `/stop` to finish and `/trace` to inspect the saved Run. The example uses SQLite and does not spawn an Agent or call a model. SDK and RPC clients can read the live count, recent IDs and commit times through the Service observation hook. The final export remains available to Trace Viewer after the Harness closes.
62
+ Use a [Harness RPC client](../../harness-session/README.md) to start the Run
63
+ and submit two short findings with its input operation. Each commit emits the
64
+ row ID and updates the committed count. Stop the Session, then inspect its saved
65
+ records with `anyswarm trace`.
63
66
 
64
67
  ## Author a different Service
65
68
 
@@ -0,0 +1,35 @@
1
+ # Customize this Subagents Harness
2
+
3
+ This file is for a Coding Agent editing an exported application. Start by reading
4
+ `README.md`, `project.ts`, `business.ts`, and `config.ts`. Read the installed
5
+ `@anyswarm/core` package-root TypeScript declarations for exact SDK signatures.
6
+
7
+ - Keep the application in ordinary TypeScript. `project.ts` exports the public
8
+ `Harness`; one Runtime owns Root and its children. Do not create a Runtime for
9
+ every Agent or add a second session/workflow abstraction.
10
+ - `config.ts` owns model, executor, Sandbox, capacity and deadlines. Respect the
11
+ user's saved setup and explicit configuration. Keep tokens in the host
12
+ environment; never put credentials in prompts, seed files or reports.
13
+ - `business.ts` assembles Profiles and Services. The controller in
14
+ `harness/controller.ts` owns named children, messages, follow-up and closure.
15
+ The Service adapter gets the caller from the authenticated Bridge; never trust
16
+ an author or parent supplied in Agent text.
17
+ - Initial project files are captured once and passed to separate private
18
+ Sandboxes. A child message does not synchronize files. Root must integrate
19
+ contributions and write the requested deliverable in its own directory.
20
+ - Preserve accepted/unknown input receipts, cancellation, bounded close and raw
21
+ export/cleanup receipts. An unknown write is reconciled with its original
22
+ request ID. Do not silently retry it with a new identity.
23
+ - Define the application's actual output and business checks before editing.
24
+ Agent settlement and file presence do not establish correctness. Generic
25
+ Subagents returns `acceptance: not-run`; add a domain check only when its
26
+ contract is explicit. Keep business failure separate from cleanup failure.
27
+ - Read `anyswarm-source.json` for the SDK identity. Install with `npm install`
28
+ and run with the local `npm start` so source and SDK stay matched. Change the
29
+ visible source here, rather than wrapping an inaccessible bundled Harness.
30
+
31
+ Use a real input directory and question for manual acceptance. Verify the
32
+ requested members contributed, inspect citations against the captured input,
33
+ read the exported result, and check cleanup. Deterministic test fixtures verify
34
+ protocol and failure handling; they are not evidence of model quality. Report
35
+ which checks ran and any remaining real-model acceptance separately.
@@ -1,109 +1,145 @@
1
- # Subagents Harness
1
+ # Subagents: a repository handoff with delegated investigation
2
2
 
3
- ## Run the project example
3
+ Give Root a real local repository and an engineering question. It can delegate
4
+ independent reading to named children in private Sandboxes, receive their
5
+ findings through the host collaboration Service, and integrate the result.
6
+ The same general Harness supports other tasks; it does not hardcode a team size
7
+ or a report format.
4
8
 
5
- Use Node.js 22.19 or newer on Linux. Follow [SDK preparation](../README.md#run-an-example-from-its-directory)
6
- for Sandbox and model configuration. In an empty directory outside the checkout,
7
- install the SDK and copy its matching example sources. Set `ANYSWARM_SDK_ARCHIVE`
8
- to a verified archive's absolute path to use a candidate built from current
9
- repository sources.
9
+ ## Run on your repository
10
10
 
11
- ```sh
12
- npm init -y
13
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
14
- npm install --save-dev typescript @types/node
15
- sdk=node_modules/@anyswarm/core
16
- cp -R "$sdk"/examples/subagents demo
17
- cd demo
18
- npm run check
19
- npm run build
20
- npm run start -- --cwd /absolute/path/to/project \
21
- --prompt 'Inspect the project, delegate an independent check and integrate the result'
22
- ```
23
-
24
- Root receives the prompt and can delegate to children with separate Sandbox
25
- directories. Each child starts with the captured project tree. The example
26
- starts its own in-process collaboration Service. Read `project-run.json` for
27
- the result and its report paths. The captured input project stays writable outside the run and the host does not write to it. The host exports files and releases its Sandbox resources on
28
- close. See the [mechanism guide](../../docs/en/harnesses/subagents.md).
29
-
30
- ## Fixed and interactive host demonstration
31
-
32
- Use Node.js 22.19 or newer and npm on the Linux Controller. If you have a compatible Worker image and an OpenSandbox provider, build from the checkout root.
11
+ Install the CLI and complete `anyswarm setup` first. Set the host model route
12
+ (`ANYSWARM_MODEL_URL`, `ANYSWARM_MODEL_ID` and, when needed,
13
+ `ANYSWARM_MODEL_TOKEN`). The model must support tool calls and the selected
14
+ executor's protocol. Setup supplies the saved Sandbox connection and executor;
15
+ an explicit environment setting takes precedence. No separate collaboration
16
+ server, Git forge, database or chat service is required.
33
17
 
34
18
  ```sh
35
- npm ci
36
- npm run build
37
- cd examples/subagents
38
- ```
39
-
40
- If you need to prepare the host, run `./scripts/setup` from the checkout root in place of the install and build commands. It builds the checkout, prepares the Worker and OpenSandbox, and verifies them with a local Responses endpoint. The setup JSON reports the image ID as `worker.id`. [Host requirements and diagnostics](../../docs/architecture/07-run-configuration.md#local-setup-and-doctor)
41
-
42
- Create `examples/subagents/.env` with your Worker image ID and a streaming `/v1/responses` endpoint that accepts `k3` and supports tool calls. Fill in the token if the endpoint requires bearer authentication.
19
+ anyswarm --harness subagents \
20
+ --cwd /absolute/path/to/repository \
21
+ --prompt 'Prepare an engineering handoff for this repository. Delegate entry points, running and configuration to one child, and modules, data flow and tests to another. Review their findings against the source and integrate report.md. Cite relative file paths and line ranges for important claims. Separate observed facts, inferences and checks not performed. Only produce the report; do not modify project source.' \
22
+ --output-dir /absolute/path/to/runs
43
23
 
44
- ```sh
45
- ANYSWARM_SUBAGENTS_IMAGE="sha256:<your-worker-image-id>"
46
- ANYSWARM_SUBAGENTS_MODEL_URL="https://your-gateway.example/v1/responses"
47
- ANYSWARM_SUBAGENTS_MODEL_TOKEN=""
24
+ anyswarm trace --root /absolute/path/to/runs --open
48
25
  ```
49
26
 
50
- The example defaults to a local OpenSandbox lifecycle URL of `http://127.0.0.1:8080/v1`. Set `ANYSWARM_SUBAGENTS_LIFECYCLE_URL` for another port and `ANYSWARM_SUBAGENTS_LIFECYCLE_TOKEN` if your provider requires authentication.
51
-
52
- From `examples/subagents/`, run one task.
53
-
54
- ```sh
55
- ../../node_modules/.bin/anys run ./main.ts \
56
- ./config.ts \
57
- 'Suggest two checks to make before merging a pull request.'
58
- ```
59
-
60
- The entry waits for Root's reply, closes the team, and writes the task result and cleanup receipts to `subagents-runs/<runtimeId>/harness-report.json`. Edit `config.ts` or `main.ts` here and run the TS entry again to try changes.
61
-
62
- ## Fixed or interactive host entry
63
-
64
- The `main.ts` command above is the direct host demonstration. For a captured
65
- project, use `anyswarm --harness subagents --cwd /path/to/project --prompt '...'`.
66
- The collaboration Service is in-process and needs no separate deployment.
67
-
68
- ## Interactive mode
69
-
70
- Pass `--interactive` in place of the task to keep the example open.
71
-
72
- In interactive mode, enter a task or a follow-up as a line, use `/status` to inspect the team, and use `/exit` to close the whole run. A Root reply leaves the team available for further input. End of input and host cancellation also close the team. A host can instead supply `config.goal` or use the exported input, reply, status and close methods.
73
-
74
- The example config defaults to four live Agents including Root, with a maximum depth of three child edges from Root. Set `ANYSWARM_SUBAGENTS_MAX_AGENTS` and `ANYSWARM_SUBAGENTS_MAX_DEPTH` to adjust the limits. Models can be configured as `rootModel` and `childModel` on the host. The default work limit is 120 seconds and cleanup has its own 30-second limit. Set `files` to seed Root, and use a required `collect` specification for files that must be exported. Work directories are private by default. Set `workspace.root` and `workspace.child` to supported Core workspace mounts to enable sharing. Private children can send patches as text to Root.
75
-
76
- ## Use the packaged example with Codex
77
-
78
- Install the published SDK or a matching source archive as described above. The example defaults to Pi. To use Codex from that consumer project, set `ANYSWARM_EXECUTOR=codex` (or `ANYSWARM_SUBAGENTS_EXECUTOR=codex`), `ANYSWARM_MODEL_ID`, and `ANYSWARM_MODEL_URL` in the host shell. The installed SDK builds or reuses a local Worker for the selected executor. To use a prepared image, set `ANYSWARM_WORKER_IMAGE` or `ANYSWARM_SUBAGENTS_IMAGE`. Supply any required model or lifecycle token through the host environment.
27
+ This asks for two child contributions because the question has two useful
28
+ investigation areas. Root chooses how to delegate through its normal tools.
29
+ For a change investigation, replace the prompt with the actual planned change,
30
+ the behavior that must remain compatible, and the questions you need answered.
31
+ A Git diff or a specially prepared repository is not required.
32
+
33
+ ### Input, output and checks
34
+
35
+ - The host captures a fixed input tree and records its paths, modes and SHA-256
36
+ values in `initial-files.json`. Root and children receive private copies of
37
+ that tree. Subsequent local edits are not synchronized into this Run.
38
+ - Child work is communicated through messages. A child-written file is not
39
+ automatically present in Root's directory. Root must write `report.md` in its
40
+ own directory for this task.
41
+ - The default project entry requires collection of Root's tree, excluding Git,
42
+ with a 16 MiB limit. Read the actual artifact paths in `project-run.json` or
43
+ the Trace Viewer; `report.md` is inside Root's exported `artifacts/files/`
44
+ directory. Export does not overwrite the user's local repository.
45
+ - Agent completion, required file export, business acceptance and cleanup are
46
+ separate. The generic Harness returns **`acceptance: not-run`**. It does not
47
+ automatically prove source citations, architectural explanations or test
48
+ claims. Compare the report with the captured source and the child records.
49
+ - A required export that cannot be confirmed or a Sandbox that cannot be
50
+ released stays pending in its original receipt. A final Root reply is not
51
+ proof that cleanup completed.
52
+
53
+ The default limits are four live Agents including Root, depth three, 120 seconds
54
+ of work and a separate 30-second close allowance. These are limits, not a promise
55
+ that every repository can be investigated in that time. Use a focused directory
56
+ or increase the explicit configuration budget for a larger investigation.
57
+
58
+ ## Export and customize the full source
59
+
60
+ The `subagents` source export is introduced by the examples update in #335; use
61
+ a candidate containing this directory's `eject.json`. The released 0.5.2 CLI
62
+ already supports the built-in run above, but does not contain this new manifest.
79
63
 
80
64
  ```sh
81
- sdk=node_modules/@anyswarm/core
82
- example="$sdk"/examples/subagents
83
- node_modules/.bin/anys run "$example/main.ts" "$example/config.ts" --interactive
65
+ anyswarm eject subagents --dir ./my-subagents
66
+ cd my-subagents
67
+ npm install
68
+ npm start -- --cwd /absolute/path/to/repository \
69
+ --prompt 'Investigate the impact of changing our configuration loading order. Delegate independent checks, cite the source and write report.md.' \
70
+ --output-dir /absolute/path/to/runs
84
71
  ```
85
72
 
86
- The configured `doctor --smoke` path covers Pi projects. The installed Codex example runs through the same local OpenSandbox provider and its own executor. [Codex startup and capabilities](../../docs/architecture/16-pi-opensandbox-backend.md#codex-app-server)
87
-
88
- Use `--fork-turns none` when delegating with Codex. Use `swarm service view collaboration` to see the authenticated operations and arguments. A typical pair of calls looks like this.
73
+ Read the exported `AGENTS.md` with your Coding Agent. All collaboration source is
74
+ local and editable; the export does not call a hidden bundled application.
75
+ `anyswarm-source.json` and `.anyswarm-sdk/core.tgz` bind the source to the SDK
76
+ candidate that exported it. Run the local `npm start` after installing that
77
+ archive, including when moving the project to another machine.
78
+
79
+ For a report-only investigation, append `--config ./handoff-config.ts` to the
80
+ exported project's command. The included configuration matches the deadlines in
81
+ the real p-limit acceptance: 360 seconds of work, 70 seconds per model request
82
+ and 60 seconds for close. It limits the team to Root and two direct children and
83
+ requires a `report.md` of up to 1 MiB. The report's source claims remain subject
84
+ to review. To change the budgets, edit that file. `--config` loads a complete
85
+ configuration rather than merging arbitrary partial objects.
86
+
87
+ [Recorded VM run](https://github.com/AnySwarm/anyswarm/issues/358#issuecomment-7385075753)
88
+
89
+ | File | Responsibility |
90
+ | --- | --- |
91
+ | `project.ts` | Public Harness, captured input, user input controls, lifecycle and result projection. |
92
+ | `business.ts` | One Runtime, Root/child Profiles, Service registration and final collection. |
93
+ | `config.ts`, `model.ts` | Sandbox connection, model route, executor, image, capacity and deadlines. |
94
+ | `handoff-config.ts` | Reproducible repository handoff budgets and required report collection. |
95
+ | `harness/controller.ts` | Named members, parent relationships, messaging, follow-up, waits and bounded close. |
96
+ | `services/collaboration-service.ts` | Authenticated operations, authorization and observable collaboration state. |
97
+ | `prompts/prompts.ts` | Root and child instructions; no prewritten answer to the user's task. |
98
+ | `main.ts` | Direct host demonstration for embedding and explicit interactive clients. |
99
+
100
+ Common `ANYSWARM_MODEL_*`, `ANYSWARM_EXECUTOR` and connection settings take
101
+ precedence over the corresponding `ANYSWARM_SUBAGENTS_*` fallbacks. Without an
102
+ explicit image, `workerImageFor(executor)` selects the matching Worker. Codex
103
+ requires Responses and an explicit model ID and uses `fork_turns: none`; Pi also supports
104
+ copying parent context and a streaming Chat Completions endpoint via
105
+ `ANYSWARM_MODEL_PROTOCOL=chat-completions`. Files remain private in either case.
106
+
107
+ ## Advanced host and session example
108
+
109
+ `main.ts` demonstrates direct hosting. From the exported project after
110
+ `npm install`, run:
89
111
 
90
112
  ```sh
91
- swarm collaboration spawn_agent --task-name reviewer --message 'Check the implementation plan' --fork-turns none --request-id reviewer-start
92
- swarm collaboration wait_agent --request-id reviewer-result
113
+ npm exec -- anyswarm run ./main.ts ./config.ts 'Investigate the supplied question'
93
114
  ```
94
115
 
95
- Pi supports copying parent context with `fork_turns: all`; Codex currently advertises only fresh conversations with `fork_turns: none`. Files remain private unless the host explicitly supplies supported shared-workspace mounts.
96
-
97
- A plain notice or child result can reach active work or be taken through a wait. Idle members keep the notice for later. Explicit follow-up can start work on the same Agent. Closing exports the configured files and time-stamped Sessions, model requests and Service calls to the private run directory. `harness-report.json` records task and cleanup outcomes.
98
-
99
- ## Embed the example
100
-
101
- Import `createSubagentsHarness` from the local example module after building. The returned handle provides `input`, `status`, `onReply`, `lastReply`, `waitForReply` and `close`. Check the input receipt, then check the reply outcome. For repeated inputs, pass the preceding reply sequence as `waitForReply({ after, signal })`. Supply a bounded host signal and call `close` in a `finally` block; inspect its execution and cleanup receipts. The [mechanism guide](../../docs/en/harnesses/subagents.md) shows a complete host call.
102
-
103
- ## Verification
104
-
105
- The [Subagents verification guide](../../test/README.md#subagents-verification) describes the regression and native OpenSandbox checks. The [ProgramBench fd experiment](https://github.com/AnySwarm/anyswarm/blob/207be6356c16e5fb60c4b3c5b236d7a98383f991/docs/experiments/EXP-20261125-10-issue199-fd.md) records a real three-Agent run, including the file handoff, follow-up and independent score.
106
-
107
- ## Host assembly
108
-
109
- Open [`business.ts`](business.ts) for Service registration, role permissions and the main scheduling and cleanup flow. [`config.ts`](config.ts) resolves the Worker image once for the selected executor and shares it across Profiles. [`services/collaboration-service.ts`](services/collaboration-service.ts) owns the Service adapter. The Host explicitly registers `collaboration` and the optional `user-interaction` definition before creating the Runtime. Root and child Profiles declare their collaboration grants in CLI mode.
116
+ This direct script seeds `config.files`; it does not automatically capture a
117
+ repository from `--cwd`. Use the project entry (`npm start`) or the built-in
118
+ `--harness subagents` command for the captured repository task above.
119
+
120
+ Its optional `--interactive` mode keeps the same Root available after a reply.
121
+ The host accepts a follow-up line, `/status` and `/exit`; EOF and cancellation
122
+ close the team. This direct host demonstration is separate from the foreground
123
+ task CLI. Use the SDK or JSONL RPC for a client that needs questions or ongoing
124
+ Run controls.
125
+
126
+ The exported `createSubagentsHarness` handle provides `input`, `status`,
127
+ `onReply`, `lastReply`, `waitForReply` and `close`. Check admission and execution
128
+ separately; for repeated inputs pass the preceding reply sequence in
129
+ `waitForReply({ after, signal })`. Bound work with a signal and close in
130
+ `finally`, preserving the full receipt. Service member paths such as
131
+ `/root/reviewer` are human-readable addresses, separate from the Runtime IDs.
132
+
133
+ ## Verification and remaining acceptance
134
+
135
+ Package tests verify public imports, complete source export, editable local
136
+ entry points and configuration failure before allocation. The collaboration
137
+ tests verify caller identities, named members, message/follow-up semantics,
138
+ cancellation, collection and pending cleanup using controlled backends.
139
+
140
+ The new repository-handoff recipe still requires real-model acceptance: run it
141
+ on a real repository, inspect at least two actual child contributions and Root's
142
+ report, check its citations, then change the question or input directory and
143
+ repeat. Record model/executor, input identity, output paths and cleanup. These
144
+ runs are not replaced by fixtures or by the older
145
+ [ProgramBench experiment](https://github.com/AnySwarm/anyswarm/blob/207be6356c16e5fb60c4b3c5b236d7a98383f991/docs/experiments/EXP-20261125-10-issue199-fd.md).
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  useServerProxy: boolean | undefined;
14
14
  egressMode: "dns+nft" | undefined;
15
15
  endpointHost: undefined;
16
+ preparedImage?: string | undefined;
16
17
  resourceLimits: {
17
18
  cpu: string;
18
19
  memory: string;
@@ -28,16 +29,7 @@ declare const _default: {
28
29
  };
29
30
  };
30
31
  models: {
31
- default: {
32
- provider: string;
33
- model: string;
34
- upstream: {
35
- url: string;
36
- headers: {
37
- authorization: string;
38
- } | {};
39
- };
40
- };
32
+ default: import("@anyswarm/core").ModelConfig;
41
33
  };
42
34
  };
43
35
  export default _default;