@anyswarm/core 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +21 -13
  3. package/deploy/worker/Dockerfile +12 -4
  4. package/dist/deploy/worker/Dockerfile +12 -4
  5. package/dist/examples/README.md +35 -12
  6. package/dist/examples/authoring/README.md +24 -0
  7. package/dist/examples/authoring/business.d.ts +2 -0
  8. package/dist/examples/authoring/business.js +4 -0
  9. package/dist/examples/authoring/config.d.ts +5 -0
  10. package/dist/examples/authoring/config.js +2 -0
  11. package/dist/examples/authoring/eject.json +5 -0
  12. package/dist/examples/authoring/harness.d.ts +4 -0
  13. package/dist/examples/authoring/harness.js +19 -0
  14. package/dist/examples/autoresearch/README.md +40 -0
  15. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
  16. package/dist/examples/autoresearch/config.d.ts +51 -0
  17. package/dist/examples/autoresearch/config.js +57 -0
  18. package/dist/examples/autoresearch/demo.d.ts +11 -0
  19. package/dist/examples/autoresearch/demo.js +52 -0
  20. package/dist/examples/autoresearch/eject.json +17 -0
  21. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
  22. package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
  23. package/dist/examples/autoresearch/frontiercs2.d.ts +87 -0
  24. package/dist/examples/autoresearch/frontiercs2.js +211 -0
  25. package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
  26. package/dist/examples/autoresearch/prepare-demo.js +15 -0
  27. package/dist/examples/autoresearch/prepare.d.ts +95 -0
  28. package/dist/examples/autoresearch/prepare.js +257 -0
  29. package/dist/examples/autoresearch/process.d.ts +13 -0
  30. package/dist/examples/autoresearch/process.js +48 -0
  31. package/dist/examples/autoresearch/project.d.ts +21 -0
  32. package/dist/examples/autoresearch/project.js +392 -0
  33. package/dist/examples/autoresearch/research-service.d.ts +106 -0
  34. package/dist/examples/autoresearch/research-service.js +255 -0
  35. package/dist/examples/code/README.md +33 -0
  36. package/dist/examples/code/REQUIREMENTS.zh.md +11 -0
  37. package/dist/examples/code/candidate.d.ts +19 -0
  38. package/dist/examples/code/candidate.js +80 -0
  39. package/dist/examples/code/config.d.ts +32 -0
  40. package/dist/examples/code/config.js +18 -0
  41. package/dist/examples/code/eject.json +5 -0
  42. package/dist/examples/code/project.d.ts +3 -0
  43. package/dist/examples/code/project.js +605 -0
  44. package/dist/examples/code/prompts.d.ts +5 -0
  45. package/dist/examples/code/prompts.js +12 -0
  46. package/dist/examples/code/verification.d.ts +19 -0
  47. package/dist/examples/code/verification.js +268 -0
  48. package/dist/examples/code/worktree.d.ts +17 -0
  49. package/dist/examples/code/worktree.js +233 -0
  50. package/dist/examples/harness-session/README.md +3 -6
  51. package/dist/examples/lead-worker/harness/dynamic-scheduler.d.ts +2 -1
  52. package/dist/examples/lead-worker/harness/dynamic-scheduler.js +5 -2
  53. package/dist/examples/lead-worker/harness/index.d.ts +60 -0
  54. package/dist/examples/lead-worker/harness/index.js +77 -6
  55. package/dist/examples/lead-worker/project.js +2 -2
  56. package/dist/examples/lead-worker/services/board.d.ts +5 -0
  57. package/dist/examples/lead-worker/services/board.js +19 -1
  58. package/dist/examples/messages/README.md +5 -5
  59. package/dist/examples/messages/handoff.d.ts +2 -0
  60. package/dist/examples/messages/handoff.js +5 -1
  61. package/dist/examples/messages/project.js +52 -2
  62. package/dist/examples/notes/README.md +13 -18
  63. package/dist/examples/notes/project.js +67 -6
  64. package/dist/examples/peermesh/harness/router.js +3 -1
  65. package/dist/examples/peermesh/harness/team.d.ts +8 -0
  66. package/dist/examples/peermesh/harness/team.js +13 -0
  67. package/dist/examples/peermesh/project.js +22 -4
  68. package/dist/examples/services/agent-control/README.md +3 -3
  69. package/dist/examples/services/mathlib-search/Dockerfile +4 -2
  70. package/dist/examples/services/mathlib-search/README.md +1 -1
  71. package/dist/examples/services/mcp-managed/README.md +2 -2
  72. package/dist/examples/services/persistent-board/README.md +16 -3
  73. package/dist/examples/services/persistent-board/business.d.ts +7 -0
  74. package/dist/examples/services/persistent-board/business.js +7 -0
  75. package/dist/examples/services/persistent-board/index.js +10 -0
  76. package/dist/examples/services/persistent-board/live.d.ts +3 -0
  77. package/dist/examples/services/persistent-board/live.js +58 -0
  78. package/dist/examples/subagents/README.md +5 -5
  79. package/dist/examples/subagents/business.js +3 -1
  80. package/dist/examples/subagents/config.js +3 -3
  81. package/dist/examples/subagents/harness/controller.d.ts +15 -0
  82. package/dist/examples/subagents/harness/controller.js +181 -32
  83. package/dist/examples/subagents/project.d.ts +2 -0
  84. package/dist/examples/subagents/project.js +43 -34
  85. package/dist/examples/subagents/prompts/prompts.d.ts +1 -0
  86. package/dist/examples/subagents/prompts/prompts.js +3 -0
  87. package/dist/examples/subagents/services/collaboration-service.d.ts +3 -2
  88. package/dist/examples/subagents/services/collaboration-service.js +14 -2
  89. package/dist/examples/substrate/README.md +2 -2
  90. package/dist/examples/substrate/harness/index.d.ts +1 -1
  91. package/dist/examples/substrate/harness/index.js +77 -12
  92. package/dist/examples/substrate/project.js +4 -1
  93. package/dist/examples/super/README.md +52 -0
  94. package/dist/examples/super/actions.d.ts +95 -0
  95. package/dist/examples/super/actions.js +230 -0
  96. package/dist/examples/super/artifact.d.ts +4 -0
  97. package/dist/examples/super/artifact.js +51 -0
  98. package/dist/examples/super/config.d.ts +80 -0
  99. package/dist/examples/super/config.js +83 -0
  100. package/dist/examples/super/coordinator.d.ts +33 -0
  101. package/dist/examples/super/coordinator.js +151 -0
  102. package/dist/examples/super/daemon.d.ts +11 -0
  103. package/dist/examples/super/daemon.js +109 -0
  104. package/dist/examples/super/decisions.d.ts +8 -0
  105. package/dist/examples/super/decisions.js +52 -0
  106. package/dist/examples/super/eject.json +5 -0
  107. package/dist/examples/super/execution.d.ts +11 -0
  108. package/dist/examples/super/execution.js +136 -0
  109. package/dist/examples/super/github.d.ts +62 -0
  110. package/dist/examples/super/github.js +269 -0
  111. package/dist/examples/super/inbox.d.ts +162 -0
  112. package/dist/examples/super/inbox.js +284 -0
  113. package/dist/examples/super/location.d.ts +5 -0
  114. package/dist/examples/super/location.js +64 -0
  115. package/dist/examples/super/operator.d.ts +1 -0
  116. package/dist/examples/super/operator.js +31 -0
  117. package/dist/examples/super/outbox.d.ts +5 -0
  118. package/dist/examples/super/outbox.js +103 -0
  119. package/dist/examples/super/project.d.ts +4 -0
  120. package/dist/examples/super/project.js +251 -0
  121. package/dist/examples/super/prompts.d.ts +3 -0
  122. package/dist/examples/super/prompts.js +25 -0
  123. package/dist/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
  124. package/dist/examples/taskpool/harness/controller.d.ts +35 -6
  125. package/dist/examples/taskpool/harness/controller.js +73 -7
  126. package/dist/examples/taskpool/project.js +18 -2
  127. package/dist/scripts/anyswarm-arguments.d.ts +18 -6
  128. package/dist/scripts/anyswarm-arguments.js +88 -52
  129. package/dist/scripts/anyswarm-author.d.ts +5 -0
  130. package/dist/scripts/anyswarm-author.js +24 -0
  131. package/dist/scripts/anyswarm-eject.d.ts +11 -0
  132. package/dist/scripts/anyswarm-eject.js +164 -0
  133. package/dist/scripts/anyswarm-harnesses.d.ts +1 -0
  134. package/dist/scripts/anyswarm-harnesses.js +10 -0
  135. package/dist/scripts/anyswarm-installation.d.ts +7 -40
  136. package/dist/scripts/anyswarm-installation.js +17 -285
  137. package/dist/scripts/anyswarm-launch.d.ts +7 -0
  138. package/dist/scripts/anyswarm-launch.js +37 -0
  139. package/dist/scripts/anyswarm-progress.d.ts +6 -0
  140. package/dist/scripts/anyswarm-progress.js +102 -0
  141. package/dist/scripts/anyswarm-project.d.ts +3 -1
  142. package/dist/scripts/anyswarm-project.js +49 -35
  143. package/dist/scripts/anyswarm-source-runner.d.ts +1 -0
  144. package/dist/scripts/anyswarm-source-runner.js +200 -0
  145. package/dist/scripts/anyswarm.js +28 -3
  146. package/dist/scripts/build-provenance.json +1 -0
  147. package/dist/scripts/build.js +7 -1
  148. package/dist/scripts/generate-architecture-api.js +2 -0
  149. package/dist/scripts/generate-architecture-prompts.js +24 -2
  150. package/dist/scripts/local-environment.d.ts +13 -2
  151. package/dist/scripts/local-environment.js +111 -28
  152. package/dist/scripts/local-setup-smoke.js +3 -2
  153. package/dist/scripts/local-setup-worker.d.ts +1 -1
  154. package/dist/scripts/local-setup-worker.js +15 -6
  155. package/dist/scripts/local-setup.d.ts +5 -2
  156. package/dist/scripts/local-setup.js +167 -79
  157. package/dist/scripts/opensandbox-agent-worker.js +2 -2
  158. package/dist/scripts/pack-release.d.ts +1 -0
  159. package/dist/scripts/pack-release.js +66 -0
  160. package/dist/scripts/pi-session-bridge.js +11 -3
  161. package/dist/scripts/run-harness.js +3 -1
  162. package/dist/scripts/setup-bootstrap.js +43 -6
  163. package/dist/src/core/allocation-ledger.js +4 -3
  164. package/dist/src/core/host-identity.d.ts +2 -0
  165. package/dist/src/core/host-identity.js +11 -0
  166. package/dist/src/core/index.d.ts +4 -2
  167. package/dist/src/core/index.js +12 -4
  168. package/dist/src/core/mcp-service.js +2 -2
  169. package/dist/src/core/runtime-management.d.ts +6 -0
  170. package/dist/src/core/runtime-management.js +24 -0
  171. package/dist/src/core/sandbox/executor-driver.d.ts +4 -2
  172. package/dist/src/core/sandbox/executor-driver.js +12 -14
  173. package/dist/src/core/sandbox/local-executor.d.ts +13 -1
  174. package/dist/src/core/sandbox/local-executor.js +69 -19
  175. package/dist/src/core/sandbox/local-worker.js +32 -21
  176. package/dist/src/core/sandbox/opensandbox-backend.d.ts +2 -0
  177. package/dist/src/core/sandbox/opensandbox-backend.js +36 -11
  178. package/dist/src/core/sandbox/sandbox-connection.d.ts +2 -0
  179. package/dist/src/core/sandbox/sandbox-connection.js +14 -6
  180. package/dist/src/core/service-live-state.d.ts +14 -0
  181. package/dist/src/core/service-live-state.js +161 -0
  182. package/dist/src/core/service-observation-types.d.ts +21 -1
  183. package/dist/src/core/service-process.d.ts +1 -1
  184. package/dist/src/core/service-process.js +45 -4
  185. package/dist/src/core/service-types.d.ts +5 -1
  186. package/dist/src/core/services.d.ts +1 -1
  187. package/dist/src/core/services.js +8 -3
  188. package/dist/src/core/types.d.ts +3 -0
  189. package/dist/src/core/worker-image.js +3 -3
  190. package/dist/src/harness/harness-session-types.d.ts +10 -0
  191. package/dist/src/harness/harness-session.js +42 -5
  192. package/dist/src/harness/project-harness.d.ts +14 -1
  193. package/dist/src/harness/project-harness.js +38 -12
  194. package/dist/src/harness/project-input.js +81 -15
  195. package/dist/src/harness/project-rpc-client.d.ts +1 -0
  196. package/dist/src/harness/project-rpc-client.js +5 -0
  197. package/dist/src/harness/project-rpc.d.ts +8 -2
  198. package/dist/src/harness/project-rpc.js +31 -7
  199. package/dist/src/harness/project-runtime.js +6 -2
  200. package/dist/src/harness/typescript-loader.d.ts +2 -0
  201. package/dist/src/harness/typescript-loader.js +41 -0
  202. package/dist/src/trace-viewer/public/app.js +6 -5
  203. package/dist/src/trace-viewer/reader.mjs +42 -2
  204. package/docs/INDEX.md +5 -2
  205. package/docs/architecture/00-overview.md +1 -1
  206. package/docs/architecture/01-agent-core.md +1 -1
  207. package/docs/architecture/04-services.md +1 -1
  208. package/docs/architecture/06-observability-experiments.md +1 -1
  209. package/docs/architecture/07-run-configuration.md +38 -18
  210. package/docs/architecture/08-prompts.md +22 -0
  211. package/docs/architecture/10-service-api-reference.md +53 -18
  212. package/docs/architecture/11-storage-reference.md +18 -1
  213. package/docs/architecture/12-code-coverage.md +152 -89
  214. package/docs/architecture/15-core-runtime.md +8 -0
  215. package/docs/architecture/16-pi-opensandbox-backend.md +5 -5
  216. package/docs/architecture/17-harness-reporting.md +1 -1
  217. package/docs/architecture/19-substrate-harness.md +28 -1
  218. package/docs/architecture/20-lead-worker-harness.md +34 -1
  219. package/docs/architecture/22-website.md +5 -6
  220. package/docs/architecture/23-project-harness.md +152 -8
  221. package/docs/architecture/24-runtime-recovery.md +10 -3
  222. package/docs/architecture/26-code.md +54 -0
  223. package/docs/architecture/27-personal.md +58 -0
  224. package/docs/architecture/28-autoresearch.md +43 -0
  225. package/docs/architecture/INDEX.md +3 -0
  226. package/docs/architecture/prompts/08-lead-worker-harness.md +4 -2
  227. package/docs/architecture/prompts/08-subagents-harness.md +21 -0
  228. package/docs/architecture/prompts/21-personal.md +44 -0
  229. package/docs/architecture/prompts/22-autoresearch.md +63 -0
  230. package/docs/architecture/prompts/26-code.md +55 -0
  231. package/docs/architecture/prompts/source-manifest.json +152 -33
  232. package/docs/architecture/source-map.json +473 -25
  233. package/docs/designs/core-harness/01-core.md +2 -2
  234. package/docs/designs/core-harness/06-project-harness.md +13 -2
  235. package/docs/designs/core-harness/README.md +7 -2
  236. package/docs/en/agents.md +1 -1
  237. package/docs/en/build-your-harness.md +3 -5
  238. package/docs/en/changelog.md +20 -4
  239. package/docs/en/first-harness.md +9 -12
  240. package/docs/en/harnesses/lead-worker.md +1 -1
  241. package/docs/en/harnesses/peermesh.md +2 -2
  242. package/docs/en/harnesses/subagents.md +2 -2
  243. package/docs/en/harnesses/substrate.md +4 -4
  244. package/docs/en/harnesses/taskpool.md +2 -2
  245. package/docs/en/latest.md +14 -121
  246. package/docs/en/overview.md +1 -1
  247. package/docs/en/quickstart.md +42 -39
  248. package/docs/en/reference/api.md +14 -4
  249. package/docs/en/reference/cli.md +53 -47
  250. package/docs/en/runtime.md +2 -2
  251. package/docs/en/sandbox.md +3 -3
  252. package/docs/en/services.md +4 -0
  253. package/docs/operations/trace-viewer.md +1 -1
  254. package/docs/workflows/development.md +28 -21
  255. package/docs/workflows/release-and-docs-versioning.md +77 -0
  256. package/docs/workflows/release-cli-acceptance.md +85 -0
  257. package/docs/zh/agents.md +1 -1
  258. package/docs/zh/build-your-harness.md +3 -5
  259. package/docs/zh/changelog.md +20 -4
  260. package/docs/zh/first-harness.md +9 -12
  261. package/docs/zh/harnesses/lead-worker.md +1 -1
  262. package/docs/zh/harnesses/peermesh.md +2 -2
  263. package/docs/zh/harnesses/subagents.md +2 -2
  264. package/docs/zh/harnesses/substrate.md +4 -4
  265. package/docs/zh/harnesses/taskpool.md +2 -2
  266. package/docs/zh/latest.md +15 -122
  267. package/docs/zh/overview.md +1 -1
  268. package/docs/zh/quickstart.md +42 -39
  269. package/docs/zh/reference/api.md +14 -4
  270. package/docs/zh/reference/cli.md +24 -40
  271. package/docs/zh/runtime.md +2 -2
  272. package/docs/zh/sandbox.md +3 -3
  273. package/docs/zh/services.md +4 -0
  274. package/examples/README.md +35 -12
  275. package/examples/authoring/README.md +24 -0
  276. package/examples/authoring/business.ts +4 -0
  277. package/examples/authoring/config.ts +2 -0
  278. package/examples/authoring/eject.json +5 -0
  279. package/examples/authoring/harness.ts +21 -0
  280. package/examples/autoresearch/README.md +40 -0
  281. package/examples/autoresearch/REQUIREMENTS.zh.md +11 -0
  282. package/examples/autoresearch/config.ts +90 -0
  283. package/examples/autoresearch/demo.ts +55 -0
  284. package/examples/autoresearch/eject.json +17 -0
  285. package/examples/autoresearch/frontiercs2-config.ts +4 -0
  286. package/examples/autoresearch/frontiercs2.ts +237 -0
  287. package/examples/autoresearch/prepare-demo.ts +15 -0
  288. package/examples/autoresearch/prepare.ts +267 -0
  289. package/examples/autoresearch/process.ts +50 -0
  290. package/examples/autoresearch/project.ts +380 -0
  291. package/examples/autoresearch/research-service.ts +302 -0
  292. package/examples/code/README.md +33 -0
  293. package/examples/code/REQUIREMENTS.zh.md +11 -0
  294. package/examples/code/candidate.ts +89 -0
  295. package/examples/code/config.ts +19 -0
  296. package/examples/code/eject.json +5 -0
  297. package/examples/code/project.ts +581 -0
  298. package/examples/code/prompts.ts +16 -0
  299. package/examples/code/verification.ts +239 -0
  300. package/examples/code/worktree.ts +188 -0
  301. package/examples/harness-session/README.md +3 -6
  302. package/examples/lead-worker/harness/dynamic-scheduler.ts +6 -3
  303. package/examples/lead-worker/harness/index.ts +61 -6
  304. package/examples/lead-worker/project.ts +2 -2
  305. package/examples/lead-worker/services/board.ts +14 -1
  306. package/examples/messages/README.md +5 -5
  307. package/examples/messages/handoff.ts +6 -2
  308. package/examples/messages/project.ts +47 -2
  309. package/examples/notes/README.md +13 -18
  310. package/examples/notes/project.ts +57 -9
  311. package/examples/peermesh/harness/router.ts +2 -2
  312. package/examples/peermesh/harness/team.ts +11 -0
  313. package/examples/peermesh/project.ts +19 -4
  314. package/examples/services/agent-control/README.md +3 -3
  315. package/examples/services/mathlib-search/Dockerfile +4 -2
  316. package/examples/services/mathlib-search/README.md +1 -1
  317. package/examples/services/mcp-managed/README.md +2 -2
  318. package/examples/services/persistent-board/README.md +16 -3
  319. package/examples/services/persistent-board/business.ts +10 -0
  320. package/examples/services/persistent-board/index.ts +10 -0
  321. package/examples/services/persistent-board/live.ts +54 -0
  322. package/examples/subagents/README.md +5 -5
  323. package/examples/subagents/business.ts +3 -1
  324. package/examples/subagents/config.ts +4 -3
  325. package/examples/subagents/harness/controller.ts +161 -29
  326. package/examples/subagents/project.ts +47 -33
  327. package/examples/subagents/prompts/prompts.ts +4 -0
  328. package/examples/subagents/services/collaboration-service.ts +14 -2
  329. package/examples/substrate/README.md +2 -2
  330. package/examples/substrate/harness/index.ts +67 -11
  331. package/examples/substrate/project.ts +5 -1
  332. package/examples/super/README.md +52 -0
  333. package/examples/super/actions.ts +196 -0
  334. package/examples/super/artifact.ts +56 -0
  335. package/examples/super/config.ts +95 -0
  336. package/examples/super/coordinator.ts +158 -0
  337. package/examples/super/daemon.ts +84 -0
  338. package/examples/super/decisions.ts +46 -0
  339. package/examples/super/eject.json +5 -0
  340. package/examples/super/execution.ts +131 -0
  341. package/examples/super/github.ts +242 -0
  342. package/examples/super/inbox.ts +306 -0
  343. package/examples/super/location.ts +54 -0
  344. package/examples/super/operator.ts +28 -0
  345. package/examples/super/outbox.ts +97 -0
  346. package/examples/super/project.ts +225 -0
  347. package/examples/super/prompts.ts +27 -0
  348. package/examples/taskpool/deploy/service-hosts/Dockerfile +4 -2
  349. package/examples/taskpool/harness/controller.ts +59 -7
  350. package/examples/taskpool/project.ts +18 -2
  351. package/npm-shrinkwrap.development.json +700 -0
  352. package/npm-shrinkwrap.json +95 -1969
  353. package/package.development.json +88 -0
  354. package/package.json +11 -8
  355. package/scripts/anyswarm-arguments.ts +91 -54
  356. package/scripts/anyswarm-author.ts +25 -0
  357. package/scripts/anyswarm-eject.ts +145 -0
  358. package/scripts/anyswarm-harnesses.ts +10 -0
  359. package/scripts/anyswarm-installation.ts +18 -288
  360. package/scripts/anyswarm-launch.ts +36 -0
  361. package/scripts/anyswarm-progress.ts +95 -0
  362. package/scripts/anyswarm-project.ts +35 -34
  363. package/scripts/anyswarm-source-runner.ts +176 -0
  364. package/scripts/anyswarm.ts +24 -3
  365. package/scripts/build.ts +8 -1
  366. package/scripts/generate-architecture-api.ts +2 -0
  367. package/scripts/generate-architecture-prompts.ts +35 -2
  368. package/scripts/local-environment.ts +117 -28
  369. package/scripts/local-setup-smoke.ts +3 -2
  370. package/scripts/local-setup-worker.ts +17 -7
  371. package/scripts/local-setup.ts +166 -73
  372. package/scripts/opensandbox-agent-worker.ts +2 -2
  373. package/scripts/pack-release.ts +70 -0
  374. package/scripts/pi-session-bridge.ts +10 -2
  375. package/scripts/run-harness.ts +3 -1
  376. package/scripts/setup-bootstrap.ts +41 -6
  377. package/src/core/allocation-ledger.ts +5 -3
  378. package/src/core/host-identity.ts +11 -0
  379. package/src/core/index.ts +12 -6
  380. package/src/core/mcp-service.ts +2 -2
  381. package/src/core/runtime-management.ts +22 -0
  382. package/src/core/sandbox/executor-driver.ts +15 -18
  383. package/src/core/sandbox/local-executor.ts +65 -19
  384. package/src/core/sandbox/local-worker.ts +29 -21
  385. package/src/core/sandbox/opensandbox-backend.ts +36 -11
  386. package/src/core/sandbox/sandbox-connection.ts +14 -5
  387. package/src/core/service-live-state.ts +156 -0
  388. package/src/core/service-observation-types.ts +23 -1
  389. package/src/core/service-process.ts +36 -3
  390. package/src/core/service-types.ts +3 -1
  391. package/src/core/services.ts +8 -3
  392. package/src/core/types.ts +3 -0
  393. package/src/core/worker-image.ts +3 -3
  394. package/src/harness/harness-session-types.ts +13 -1
  395. package/src/harness/harness-session.ts +40 -7
  396. package/src/harness/project-harness.ts +38 -12
  397. package/src/harness/project-input.ts +73 -15
  398. package/src/harness/project-rpc-client.ts +5 -0
  399. package/src/harness/project-rpc.ts +29 -8
  400. package/src/harness/project-runtime.ts +4 -2
  401. package/src/harness/typescript-loader.ts +37 -0
  402. package/src/trace-viewer/public/app.js +6 -5
  403. package/src/trace-viewer/reader.mjs +42 -2
package/AGENTS.md CHANGED
@@ -6,7 +6,7 @@ These instructions apply to **Coding Agents developing AnySwarm**, not research
6
6
 
7
7
  The [architecture manual](docs/architecture/INDEX.md) is the maintained description of the current implementation. The [SDK and user guides](docs/INDEX.md) describe its supported public surface and are also the website's content source. Current code and schemas establish exact behavior; tests and experiments establish what has been verified. Keep these sources aligned in the same PR.
8
8
 
9
- The [Core / Harness design](docs/designs/core-harness/README.md) and its linked extensions record reviewed product requirements and acceptance. Read them together with the relevant Issue and the owner's later explicit decisions; a later explicit decision supersedes an older conflicting clause without changing unrelated acceptance or resource limits. When an authorized change updates the design, include the design, implementation, migration, tests and documentation in the same PR. The design index links the [dynamic Lead-Worker extension](docs/designs/dynamic-lead-worker.md) and the open CLI/TUI work; current implemented behavior belongs in Architecture.
9
+ The [Core / Harness design](docs/designs/core-harness/README.md) and its linked extensions record reviewed product requirements and acceptance. Read them together with the relevant Issue and the owner's later explicit decisions; a later explicit decision supersedes an older conflicting clause without changing unrelated acceptance or resource limits. When an authorized change updates the design, include the design, implementation, migration, tests and documentation in the same PR. The design index links the [dynamic Lead-Worker extension](docs/designs/dynamic-lead-worker.md) and the scoped CLI work in [#351](https://github.com/AnySwarm/anyswarm/issues/351); current implemented behavior belongs in Architecture.
10
10
 
11
11
  Human-approved GitHub Issues and explicit user instructions define work requirements, scope, acceptance and resources. Read the full relevant Issue, linked tickets, comments and accepted Agent Brief. Cite the exact revision of any reviewed design and preserve its acceptance. Superseded phase plans remain in Git history and linked Issues. Resource, research, merge and publication permissions follow the project rules below.
12
12
 
package/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
  <p>
23
23
  <a href="https://anyswarm.github.io/anyswarm/">Website</a> ·
24
24
  <a href="docs/en/quickstart.md">Quickstart</a> ·
25
- <a href="docs/en/latest.md">Releases and main updates</a> ·
25
+ <a href="docs/en/latest.md">Releases</a> ·
26
26
  <a href="docs/en/changelog.md">Changelog</a> ·
27
27
  <a href="docs/en/build-your-harness.md">Build a Swarm Harness</a> ·
28
28
  <a href="docs/zh/overview.md">中文文档</a>
@@ -37,22 +37,21 @@ AnySwarm separates **how Agents collaborate** from **how Agents are isolated and
37
37
  ## Why AnySwarm
38
38
 
39
39
  - **One Runtime, any topology** — Swap between recursive Subagents, leased TaskPool, PeerMesh, Substrate, or Lead-Worker without modifying the Runtime.
40
- - **Sandbox Provider interface** — Run `anyswarm setup --mode local`, or save an existing OpenSandbox endpoint and one Runtime callback with `anyswarm setup --mode existing`. Supply a custom Provider through the root SDK when you need a different Sandbox integration. Model API keys and external Service tokens stay on the trusted Controller.
41
- - **Configurable executors, models and file budgets** — Select Pi 1.3.0 or 1.4.0, Codex 0.172.0, or an image-installed adapter. Use Responses with Pi or Codex, Chat Completions with Pi, or a trusted Host transport. Configure import, live file operations and export separately.
42
- - **Single unified package** — `@anyswarm/core` bundles the TypeScript SDK, `anyswarm` CLI, `swarm` container CLI, built-in Harnesses, and the zero-dependency browser Trace Viewer (`anyswarm trace`).
40
+ - **Sandbox Provider interface** — Run `anyswarm setup` to prepare OpenSandbox on your machine. Supply a custom Provider through the root SDK when you need a different Sandbox integration. Model API keys and external Service tokens stay on the trusted Controller.
41
+ - **Configurable executors, models and file budgets** — Use an installed Pi or Codex, optionally pin its exact version, or select an image-installed adapter. Use Responses with Pi or Codex, Chat Completions with Pi, or a trusted Host transport. Configure import, live file operations and export separately.
42
+ - **Single unified package** — `@anyswarm/core` bundles the TypeScript SDK, `anyswarm` host CLI, internal Worker tooling, built-in Harnesses, and the zero-dependency browser Trace Viewer (`anyswarm trace`).
43
43
 
44
44
  ## Quick start
45
45
 
46
- Use Node.js 22.19+ and Git on Linux, with Docker Engine and a supported npm-installed Pi or Codex for local OpenSandbox. The [Quickstart](docs/en/quickstart.md) covers prerequisites and connecting to an existing service. The steps below install the current stable CLI. For v0.4.0, see the [upgrade guide](docs/en/latest.md#upgrade-from-v040-to-the-managed-installer).
46
+ Install the CLI with Node.js 22.19+ and npm. Setup checks the host and looks for a local Docker engine and an installed Pi or Codex. On macOS, start [Docker Desktop or your local container engine](docs/en/quickstart.md#docker-on-macos) before setup.
47
47
 
48
48
  ```sh
49
49
  # 1. Install the released CLI
50
- curl -fsSL https://anyswarm.github.io/anyswarm/install.sh | sh
51
- # Apply the installer’s PATH command if needed.
50
+ npm install -g @anyswarm/core
52
51
  anyswarm --version
53
52
 
54
53
  # 2. Prepare OpenSandbox and save its connection
55
- anyswarm setup --backend pi
54
+ anyswarm setup
56
55
 
57
56
  # 3. Point AnySwarm at any streaming OpenAI Responses-compatible endpoint
58
57
  export ANYSWARM_MODEL_URL="https://api.openai.com/v1/responses"
@@ -69,22 +68,31 @@ anyswarm --harness subagents --prompt 'Read README.md and report its heading.' -
69
68
  anyswarm trace --root ./runs --port 8787
70
69
  ```
71
70
 
72
- The installed SDK builds the local Worker using its bundled materials and the selected host executor. `anyswarm update` updates the managed global CLI independently of project SDK dependencies. Set `ANYSWARM_WORKER_IMAGE` when using a custom Worker image. Use `--harness` to select any built-in (`subagents`, `taskpool`, `peermesh`, `substrate`, `lead-worker`, `notes`, `messages`), a local ESM module, or an installed package. In `--mode rpc`, tasks arrive over JSONL with live `status` and `stop` control.
71
+ For npm prefix and PATH help, see the [Quickstart](docs/en/quickstart.md#1-install-anyswarm). Update with `npm install -g @anyswarm/core@latest`.
72
+
73
+ The installed SDK builds the local Worker using its bundled materials and the selected host executor. Set `ANYSWARM_WORKER_IMAGE` when using a custom Worker image. Use `--harness` to select any built-in (`subagents`, `autoresearch`, `taskpool`, `peermesh`, `substrate`, `lead-worker`, `notes`, `messages`), a local ESM module, or an installed package. In `--mode rpc`, tasks arrive over JSONL with live `status` and `stop` control.
73
74
 
74
75
  ## Build with the TypeScript SDK
75
76
 
76
- Use `@anyswarm/core` for the v0.5.0 SDK:
77
+ Install the TypeScript SDK in your Node.js project.
77
78
 
78
79
  ```sh
79
- npm install @anyswarm/core@0.5.0
80
+ npm install @anyswarm/core
80
81
  ```
81
82
 
82
- Import Runtime, Service and Sandbox Provider APIs from `@anyswarm/core`. The [SDK reference](docs/en/reference/api.md#install-the-sdk) also covers verified source archives. The [First Harness tutorial](docs/en/first-harness.md) copies examples from the installed SDK. Projects staying on v0.4.1 use [`@anyswarm/anyswarm@0.4.1`](https://www.npmjs.com/package/@anyswarm/anyswarm/v/0.4.1).
83
+ [v0.5.0](docs/en/latest.md#v050) is the first supported release of `@anyswarm/core`. Import Runtime, Service and Sandbox Provider APIs from this package. The [SDK reference](docs/en/reference/api.md#install-the-sdk) also covers verified source archives. The [First Harness tutorial](docs/en/first-harness.md) copies examples from the installed SDK.
83
84
 
84
85
  - Core building blocks & Swarm tutorial: [Sandboxes](docs/en/sandbox.md) · [Runtime](docs/en/runtime.md) · [Agents](docs/en/agents.md) · [Host Gateway](docs/en/gateway.md) · [Services](docs/en/services.md) · [Build a Swarm Harness](docs/en/build-your-harness.md)
85
86
  - Minimal runnable two-Agent script: [`examples/messages/handoff.ts`](examples/messages/handoff.ts)
86
87
  - Exact signatures, CLI flags, and types: [API Reference](docs/en/reference/api.md) · [CLI Reference](docs/en/reference/cli.md) · [Types & Source Map](docs/en/reference/types.md)
87
88
 
89
+ ## AutoResearch showcase
90
+
91
+ [AutoResearch](examples/autoresearch/README.md) runs a team of equal peers on
92
+ a finite research task. They share findings, review candidates and submit
93
+ patches to a trusted evaluator. The guide includes the pinned FrontierCS-2
94
+ demo, a custom evaluator path and the Trace records to inspect.
95
+
88
96
  ## Built-in Harnesses
89
97
 
90
98
  The repository includes five substantial Harnesses sharing the same Runtime with different collaboration policies:
@@ -117,7 +125,7 @@ When started inside an SSH session, `anyswarm trace` prints the matching `ssh -N
117
125
 
118
126
  ## Releases & documentation
119
127
 
120
- - **Releases and main updates**: [What's New](docs/en/latest.md) · [版本与主线更新 (中文)](docs/zh/latest.md) · [GitHub Releases](https://github.com/AnySwarm/anyswarm/releases)
128
+ - **Releases**: [Current release](docs/en/latest.md) · [发行版本 (中文)](docs/zh/latest.md) · [GitHub Releases](https://github.com/AnySwarm/anyswarm/releases)
121
129
  - **Changelog**: [CHANGELOG.md](CHANGELOG.md) · [Website Changelog](docs/en/changelog.md) · [更新日志 (中文)](docs/zh/changelog.md)
122
130
  - **Architecture & research**: [Architecture Manual](docs/architecture/INDEX.md) · [Research Context](docs/PROJECT.md) · [ProgramBench Pastel](benchmarks/programbench-pastel/README.md) · [PutnamBench TaskPool](benchmarks/putnambench-taskpool/README.md)
123
131
 
@@ -15,9 +15,13 @@ ARG WORKER_EXECUTOR
15
15
  LABEL org.opencontainers.image.source="https://github.com/AnySwarm/anyswarm" \
16
16
  org.opencontainers.image.description="AnySwarm OpenSandbox Worker with the selected local executor"
17
17
 
18
- RUN apt-get update \
19
- && apt-get install --no-install-recommends --yes bash ca-certificates curl git jq python3 python-is-python3 ripgrep util-linux \
20
- && rm -rf /var/lib/apt/lists/*
18
+ # The slim base has Node's bundled CA roots but not the OS CA bundle yet.
19
+ RUN node -e 'console.log(require("node:tls").rootCertificates.join("\n"))' > /tmp/apt-bootstrap-ca.pem \
20
+ && sed -i 's@http://deb.debian.org/@https://deb.debian.org/@g' /etc/apt/sources.list.d/debian.sources \
21
+ && apt-get -o Acquire::https::CaInfo=/tmp/apt-bootstrap-ca.pem -o Acquire::https::Timeout=30 update \
22
+ && apt-get -o Acquire::https::CaInfo=/tmp/apt-bootstrap-ca.pem -o Acquire::https::Timeout=30 \
23
+ install --no-install-recommends --yes bash ca-certificates curl git jq python3 python-is-python3 ripgrep util-linux \
24
+ && rm -rf /var/lib/apt/lists/* /tmp/apt-bootstrap-ca.pem
21
25
 
22
26
  WORKDIR /opt/anyswarm
23
27
  COPY --chown=0:0 package.json npm-shrinkwrap.json ./
@@ -57,7 +61,11 @@ RUN chmod 0755 /opt/anyswarm \
57
61
  && ln -s /opt/anyswarm/dist/scripts/swarm.js /usr/local/bin/swarm \
58
62
  && ln -s /opt/anyswarm/dist/scripts/opensandbox-agent-worker.js /opt/anyswarm/agent-worker.mjs \
59
63
  && ln -s /opt/anyswarm/dist/scripts/sandbox-project.js /opt/anyswarm/sandbox-project.mjs \
60
- && mkdir -p /workspace /opt/anyswarm/pi-agent
64
+ && mkdir -p /workspace /opt/anyswarm/pi-agent \
65
+ && case "$WORKER_EXECUTOR" in \
66
+ pi) node /opt/anyswarm/dist/scripts/pi-session-bridge.js --check-sdk ;; \
67
+ codex) /opt/anyswarm/executor/node_modules/.bin/codex app-server --help >/dev/null ;; \
68
+ esac
61
69
 
62
70
  ENV PATH="/opt/anyswarm/executor/node_modules/.bin:/opt/anyswarm/node_modules/.bin:${PATH}" \
63
71
  PI_CODING_AGENT_DIR="/opt/anyswarm/pi-agent" \
@@ -15,9 +15,13 @@ ARG WORKER_EXECUTOR
15
15
  LABEL org.opencontainers.image.source="https://github.com/AnySwarm/anyswarm" \
16
16
  org.opencontainers.image.description="AnySwarm OpenSandbox Worker with the selected local executor"
17
17
 
18
- RUN apt-get update \
19
- && apt-get install --no-install-recommends --yes bash ca-certificates curl git jq python3 python-is-python3 ripgrep util-linux \
20
- && rm -rf /var/lib/apt/lists/*
18
+ # The slim base has Node's bundled CA roots but not the OS CA bundle yet.
19
+ RUN node -e 'console.log(require("node:tls").rootCertificates.join("\n"))' > /tmp/apt-bootstrap-ca.pem \
20
+ && sed -i 's@http://deb.debian.org/@https://deb.debian.org/@g' /etc/apt/sources.list.d/debian.sources \
21
+ && apt-get -o Acquire::https::CaInfo=/tmp/apt-bootstrap-ca.pem -o Acquire::https::Timeout=30 update \
22
+ && apt-get -o Acquire::https::CaInfo=/tmp/apt-bootstrap-ca.pem -o Acquire::https::Timeout=30 \
23
+ install --no-install-recommends --yes bash ca-certificates curl git jq python3 python-is-python3 ripgrep util-linux \
24
+ && rm -rf /var/lib/apt/lists/* /tmp/apt-bootstrap-ca.pem
21
25
 
22
26
  WORKDIR /opt/anyswarm
23
27
  COPY --chown=0:0 package.json npm-shrinkwrap.json ./
@@ -57,7 +61,11 @@ RUN chmod 0755 /opt/anyswarm \
57
61
  && ln -s /opt/anyswarm/dist/scripts/swarm.js /usr/local/bin/swarm \
58
62
  && ln -s /opt/anyswarm/dist/scripts/opensandbox-agent-worker.js /opt/anyswarm/agent-worker.mjs \
59
63
  && ln -s /opt/anyswarm/dist/scripts/sandbox-project.js /opt/anyswarm/sandbox-project.mjs \
60
- && mkdir -p /workspace /opt/anyswarm/pi-agent
64
+ && mkdir -p /workspace /opt/anyswarm/pi-agent \
65
+ && case "$WORKER_EXECUTOR" in \
66
+ pi) node /opt/anyswarm/dist/scripts/pi-session-bridge.js --check-sdk ;; \
67
+ codex) /opt/anyswarm/executor/node_modules/.bin/codex app-server --help >/dev/null ;; \
68
+ esac
61
69
 
62
70
  ENV PATH="/opt/anyswarm/executor/node_modules/.bin:/opt/anyswarm/node_modules/.bin:${PATH}" \
63
71
  PI_CODING_AGENT_DIR="/opt/anyswarm/pi-agent" \
@@ -12,6 +12,16 @@ artifact export. Its same default definition is used by SDK, foreground and
12
12
  RPC. [HarnessSession clients](harness-session/README.md) exercise the public
13
13
  protocol with a zero-Runtime fixture.
14
14
 
15
+ ## AutoResearch showcase
16
+
17
+ [AutoResearch](autoresearch/README.md) runs equal peers through a finite
18
+ research task with shared budgets, a trusted evaluator and browser Trace
19
+ records. The guide includes the pinned FrontierCS-2 demo and a configurable
20
+ evaluator path.
21
+
22
+ [Code](code/README.md), [Personal](super/README.md), and
23
+ [HarnessSession](harness-session/README.md) are advanced SDK examples.
24
+
15
25
  ## Choose a collaboration example
16
26
 
17
27
  | Directory | Coordination | Services created by the example | Facilities you supply |
@@ -39,18 +49,15 @@ number.
39
49
  ```sh
40
50
  npm init -y
41
51
  npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
42
- npm install --save-dev typescript @types/node
43
52
  sdk=node_modules/@anyswarm/core
44
53
  cp -R "$sdk"/examples/subagents demo
45
54
  cd demo
46
- npm run check
47
- npm run build
48
- npm run start -- --cwd /absolute/path/to/project --prompt 'Implement and verify the requested change'
55
+ ../node_modules/.bin/anyswarm run ./project.ts --cwd /absolute/path/to/project --prompt 'Implement and verify the requested change'
49
56
  ```
50
57
 
51
58
  For another collaboration mechanism, replace `subagents` in the copy command
52
59
  with `taskpool`, `peermesh`, `lead-worker` or `substrate`. The copied project
53
- resolves the SDK and compiler from its parent installation.
60
+ resolves the SDK from its parent installation. The CLI loads TS directly, including multi-file imports and TS configuration.
54
61
 
55
62
  For current repository sources, build the matching SDK archive from that
56
63
  checkout's root first. Record its commit and SHA-256, and set the absolute
@@ -59,27 +66,43 @@ archive path before running the commands above.
59
66
  ```sh
60
67
  npm ci --ignore-scripts
61
68
  pack_dir=$(mktemp -d)
62
- archive=$(npm pack --pack-destination "$pack_dir" --silent)
63
- sha256sum "$pack_dir/$archive"
64
- export ANYSWARM_SDK_ARCHIVE="$pack_dir/$archive"
69
+ archive=$(npm run --silent pack:release -- "$pack_dir")
70
+ sha256sum "$archive"
71
+ export ANYSWARM_SDK_ARCHIVE="$archive"
65
72
  ```
66
73
 
67
74
  When editing an existing example directly in this checkout, install this
68
75
  archive with `npm install --no-save "$ANYSWARM_SDK_ARCHIVE"` in that example's
69
- directory before its check and build commands.
76
+ directory before running its TypeScript entry.
70
77
 
71
78
  Use the example's README for its configuration and external facilities.
72
- Run `anyswarm --harness /absolute/path/to/example/dist/project.js --prompt '…'` from
79
+ Run `anyswarm run /absolute/path/to/example/project.ts --prompt '…'` from
73
80
  the input project to use the same editable example from elsewhere. The
74
81
  CLI also includes each example's built-in name as a convenience. The host
75
82
  captures the initial directory and writes outputs outside it by default.
76
- Use `--config` for trusted JavaScript run configuration.
83
+ Use `--config ./config.ts` for trusted TypeScript run configuration.
77
84
 
78
85
  The model, executor and Sandbox environment variables are documented in
79
86
  [Quickstart](../docs/en/quickstart.md). Existing scoped variables remain
80
87
  fallbacks. Separate benchmarks take explicit configuration and fixtures.
81
88
  See [FATE](../benchmarks/fate/README.md) and [Lead–Worker Orders](../benchmarks/lead-worker-orders/README.md).
82
89
 
90
+ ## Export an editable Harness
91
+
92
+ ```sh
93
+ anyswarm eject example --dir ./my-harness
94
+ cd my-harness
95
+ npm install
96
+ npm run start
97
+ ```
98
+
99
+ Edit `business.ts` and run it again to see your own result. Export includes the
100
+ complete source and an SDK archive dependency bound to that package's contents.
101
+ Run `npm install` to install that local archive when moving the export to another
102
+ machine. `anyswarm-source.json` records source revision, SDK source, content and
103
+ archive digests. Application teams register the same source manifest for
104
+ `anyswarm eject code`, `anyswarm eject autoresearch` and `anyswarm eject super`.
105
+
83
106
  ## Smaller SDK tutorials
84
107
 
85
108
  | Example | Host entry | What to verify |
@@ -98,7 +121,7 @@ The [Service examples index](services/README.md) also links the optional
98
121
 
99
122
  Read the Host entry for Worker settings, the named registrations and each
100
123
  Profile’s grants. Follow the runner for Agent input, business checks and the
101
- close receipt. Each example's README gives its build, launch and evidence paths.
124
+ close receipt. Each example's README gives its launch and evidence paths.
102
125
 
103
126
  ## Repository boundaries
104
127
 
@@ -0,0 +1,24 @@
1
+ # Editable TypeScript Harness
2
+
3
+ Run this complete example with the installed AnySwarm CLI.
4
+
5
+ ```sh
6
+ anyswarm run ./harness.ts
7
+ anyswarm run ./harness.ts --config ./config.ts --prompt 'Create a greeting'
8
+ ```
9
+
10
+ Edit `business.ts` and run the command again to change the result. `harness.ts`
11
+ defines the Harness lifecycle, `business.ts` contains its rule, and `config.ts`
12
+ provides its default public configuration. This example uses no model or Sandbox.
13
+
14
+ `anyswarm eject example --dir ./my-harness` exports these sources and a local SDK
15
+ archive. The generated package depends on that archive, so `npm install` retains
16
+ the exact candidate SDK. Direct `anyswarm run` can also resolve the invoking CLI's SDK.
17
+ Use the same candidate CLI recorded in `anyswarm-source.json`.
18
+
19
+ Application authors use the same export mechanism by providing `eject.json` in
20
+ `examples/code`, `examples/autoresearch`, or `examples/super`. Its `apiVersion`
21
+ is `1`, `entry` names the runnable TS entry, and `files` explicitly lists every
22
+ relative source, prompt, Service, public config and README needed by that app.
23
+ Credentials, `.env`, runtime records, dependencies and build directories are
24
+ excluded by the engine. Exporting into a nonempty directory fails.
@@ -0,0 +1,2 @@
1
+ /** Edit this business rule and run harness.ts again. */
2
+ export declare function greeting(name: string): string;
@@ -0,0 +1,4 @@
1
+ /** Edit this business rule and run harness.ts again. */
2
+ export function greeting(name) {
3
+ return name ? `Hello, ${name}` : 'Hello from your TypeScript Harness';
4
+ }
@@ -0,0 +1,5 @@
1
+ /** Optional public author configuration. Keep credentials outside exported files. */
2
+ declare const _default: {
3
+ name: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ /** Optional public author configuration. Keep credentials outside exported files. */
2
+ export default { name: '' };
@@ -0,0 +1,5 @@
1
+ {
2
+ "apiVersion": 1,
3
+ "entry": "harness.ts",
4
+ "files": ["harness.ts", "business.ts", "config.ts", "README.md"]
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { Harness } from '@anyswarm/core';
2
+ /** A complete finite Harness with editable business logic and no external resources. */
3
+ declare const harness: Harness;
4
+ export default harness;
@@ -0,0 +1,19 @@
1
+ import { greeting } from './business.js';
2
+ import defaults from './config.js';
3
+ /** A complete finite Harness with editable business logic and no external resources. */
4
+ const harness = {
5
+ apiVersion: 1,
6
+ id: 'editable-typescript-example',
7
+ lifetimes: ['task'],
8
+ async run(context) {
9
+ context.markRunning();
10
+ const config = (context.configuration ?? defaults);
11
+ const message = greeting(config.name);
12
+ context.updateStatus({ business: { message } });
13
+ return {
14
+ outcome: 'completed', reason: 'greeting-created', result: { message }, artifacts: [],
15
+ export: { status: 'complete' }, cleanup: { status: 'complete' },
16
+ };
17
+ },
18
+ };
19
+ export default harness;
@@ -0,0 +1,40 @@
1
+ # AutoResearch
2
+
3
+ An AutoResearch Run starts equal peers in separate AnySwarm Sandboxes. Each peer chooses a direction, writes a patch, and can read, review and build on another peer's patch. The Harness provides the shared research Service and enforces the team's budget. A trusted evaluator decides whether a candidate is valid and returns the score used for selection.
4
+
5
+ ## FrontierCS-2 quickstart
6
+
7
+ Use a Linux x86-64 machine with Git LFS, Python 3, a local Docker daemon and an existing authenticated OpenSandbox deployment with `dns+nft` egress. Prepare a supported Pi Worker using the normal AnySwarm setup flow. Configure the existing Kimi K3 Responses route using `ANYSWARM_MODEL_URL`, `ANYSWARM_MODEL_TOKEN`, `ANYSWARM_MODEL_PROVIDER=kimi_proxy` and `ANYSWARM_MODEL_ID=k3`. Keep the token in trusted host configuration if your proxy requires one.
8
+
9
+ ```sh
10
+ anyswarm eject autoresearch --dir ./research-demo
11
+ cd ./research-demo
12
+ npm install
13
+ npm exec -- anyswarm run ./prepare-demo.ts
14
+ npm run start -- --config ./frontiercs2-config.ts --prompt "Run the prepared FrontierCS-2 task." --output-dir ./runs
15
+ ```
16
+
17
+ Preparation prints prerequisite checks and the resource plan. It reports K3 configuration and HTTP route reachability separately, and reports inference as not attempted. It fetches only the pinned task and shared dependencies, checks the Pumpkin release hash, builds images, completes an independent no-model reference run and checks the authorized submission role. Initial image builds can take several minutes. Rerunning preparation reuses verified materials and images. Reference records are environment evidence. The model receives a clean starter and only public train feedback.
18
+
19
+ The demo configuration selects the clean pinned starter and trusted FrontierCS-2 evaluator. The
20
+ terminal prints Run and Agent milestones. Use `anyswarm trace --root ./runs`
21
+ during or after the Run for peer claims, patches, reviews, train scores and final
22
+ records. For a remote controller, forward the Trace port over SSH.
23
+
24
+ The default smoke budget is four Kimi K3 peers, a shared twelve-minute work window and eight train admissions. The demo records actual model usage without capping the request count. The application reserves additional time for final and cleanup. The result includes every frozen candidate, its hash and author, best candidate, Pumpkin record, final result and cleanup receipt. A valid candidate with a low score is a completed evaluation. A run without a valid candidate returns failure, even when it records an official zero for a selected invalid candidate.
25
+
26
+ ## Run your own project
27
+
28
+ ```sh
29
+ anyswarm --harness autoresearch --config ./research.ts --prompt "Your objective" --output-dir ./runs
30
+ anyswarm eject autoresearch --dir ./my-research
31
+ ```
32
+
33
+ The trusted TypeScript configuration exports a `ResearchConfiguration` object. Set `targetPath` relative to the invocation directory, `goal`, `direction` (`max` or `min`), optional `targetScore`, shared `budget` with an optional `maxModelRequests`, `model`, `executor`, `image`, `sandbox` and `connection`. The evaluator receives an immutable copy of the patch. Its `train(patch, signal, admitted)` returns `{valid, score, feedback}`. Call `admitted` with the trusted job identifier when one exists. `final(patch, signal)` returns the result of the independent final evaluation. The optional `start` and `close` own evaluator resources. All callbacks run as trusted host code. Run candidate code only inside an evaluator-owned isolated environment. Apply the patch to a fresh copy of the baseline, keep evaluator rules inaccessible to it and honor each supplied abort signal.
34
+
35
+ The exported `project.ts` is the editable Harness. Run `npm install` in the export directory
36
+ to install the pinned SDK, then run
37
+ `npm run start -- --cwd /path/to/project --config ./research.ts --prompt "Your objective"`.
38
+ The export includes the FrontierCS-2 preparation and adapter sources.
39
+
40
+ See [the requirements](REQUIREMENTS.zh.md).
@@ -0,0 +1,11 @@
1
+ # AutoResearch 需求
2
+
3
+ 用户配置目标、可信评测和总预算后,团队自动研究、评测、选择候选并收尾。单次命令显示运行阶段和清理结果。Trace 提供认领方向、候选、train 反馈、消息、复核和回执,可在运行中查看,结束后回放。SDK 和 RPC 客户端可以向成员发送建议、中断当前轮次或停止成员。
4
+
5
+ FrontierCS-2 demo 固定 `7e48965c7cef2a567c2669c8e2f10b06386289c9` 的 `binary_fuse_filter` 和该版本的 Pumpkin。团队至少四名平级 AnySwarm Worker,同一次 Run 使用真实 `kimi_proxy/k3`,没有统一 Lead。成员自行认领研究方向、交流和选择沿用的成果。Harness 管理资源、共享预算与可信评测。demo 的研究窗口为 12 分钟,官方 train 额度为 8 次,记录模型请求数但不限制次数。官方 train 公开反馈进入看板,final 结果只写入用户记录。
6
+
7
+ 参照[快速上手](README.md)准备并运行。
8
+
9
+ 验收从候选包开始。独立 reference 完成无模型 train/final。实际 demo 从干净 starter 开始,保存四路真实 K3 活动重叠的证据、至少一次可关联到具体候选的同行复核或采用,以及 Worker 候选、官方 train、最终保存、final 和资源回收的关联记录。记录全队的资源、模型用量与费用。未知回执和待清理资源保留可核对的标识。官方零分作为求解结果记录。
10
+
11
+ 研究范围以 [#337](https://github.com/AnySwarm/anyswarm/issues/337) 和随后确认的四成员、Agensh 式扁平协作、实时 Trace 为准。宿主入口遵循 [#351](https://github.com/AnySwarm/anyswarm/issues/351)。
@@ -0,0 +1,51 @@
1
+ import { type ExecutorSelection, type ModelConfig, type RuntimeConnectionOptions, type SandboxConfig } from '@anyswarm/core';
2
+ import type { Evaluator } from './research-service.js';
3
+ export interface ResearchBudget {
4
+ workers: number;
5
+ workMs: number;
6
+ maxModelRequests?: number;
7
+ maxEvaluations: number;
8
+ }
9
+ export interface ResearchConfiguration {
10
+ targetPath?: string;
11
+ requiredFiles?: readonly string[];
12
+ goal: string;
13
+ direction: 'max' | 'min';
14
+ targetScore?: number;
15
+ budget: ResearchBudget;
16
+ evaluator: Evaluator;
17
+ executor: ExecutorSelection;
18
+ image: string;
19
+ model: ModelConfig;
20
+ sandbox: SandboxConfig;
21
+ connection: RuntimeConnectionOptions;
22
+ evaluationTimeoutMs?: number;
23
+ closeTimeoutMs?: number;
24
+ restrictNetwork?: boolean;
25
+ }
26
+ export declare const demoBudget: Readonly<ResearchBudget>;
27
+ export declare function frontierBudget(saved?: ResearchBudget): ResearchBudget;
28
+ export declare const demoGoal = "Solve the official FrontierCS-2 binary_fuse_filter task described in README.md. The 8-bit and 16-bit population routines in include/binaryfusefilter.h are stubs. Implement both routines and send a complete first patch to public train promptly. If a local C compiler is unavailable, use train for compile and correctness feedback. Then explore memory, construction or lookup performance. Change only include/, coordinate directly and review peers\u2019 patches against the official public train feedback.";
29
+ export declare const demoCloseTimeoutMs = 365000;
30
+ export declare function frontierHome(): string;
31
+ export declare function defaultResearchConnection(): {
32
+ executor: import("@anyswarm/core").ExecutorKind;
33
+ image: string;
34
+ sandbox: {
35
+ lifecycleBaseUrl: string;
36
+ apiKey: string | undefined;
37
+ useServerProxy: boolean | undefined;
38
+ egressMode: "dns+nft" | undefined;
39
+ resourceLimits: {
40
+ cpu: string;
41
+ memory: string;
42
+ };
43
+ };
44
+ connection: {
45
+ publicUrl: string | undefined;
46
+ advertiseHost: string | undefined;
47
+ };
48
+ };
49
+ export declare function kimiModel(): ModelConfig;
50
+ export declare function checkBudget(budget: ResearchBudget, minimum?: number): ResearchBudget;
51
+ export default undefined;
@@ -0,0 +1,57 @@
1
+ import { ProjectPreflightError, resolveSandboxConnection, workerImageFor } from '@anyswarm/core';
2
+ import { homedir } from 'node:os';
3
+ import { join, resolve } from 'node:path';
4
+ export const demoBudget = Object.freeze({
5
+ workers: 4, workMs: 720_000, maxEvaluations: 8,
6
+ });
7
+ export function frontierBudget(saved = demoBudget) {
8
+ const { workers, workMs, maxEvaluations } = saved;
9
+ return checkBudget({ workers, workMs, maxEvaluations }, 4);
10
+ }
11
+ export const demoGoal = 'Solve the official FrontierCS-2 binary_fuse_filter task described in README.md. The 8-bit and 16-bit population routines in include/binaryfusefilter.h are stubs. Implement both routines and send a complete first patch to public train promptly. If a local C compiler is unavailable, use train for compile and correctness feedback. Then explore memory, construction or lookup performance. Change only include/, coordinate directly and review peers’ patches against the official public train feedback.';
12
+ export const demoCloseTimeoutMs = 365_000;
13
+ export function frontierHome() {
14
+ return resolve(process.env.ANYSWARM_AUTORESEARCH_STATE_DIR ??
15
+ join(process.env.XDG_STATE_HOME ?? join(homedir(), '.local', 'state'), 'anyswarm', 'autoresearch', 'frontiercs2'));
16
+ }
17
+ export function defaultResearchConnection() {
18
+ const saved = resolveSandboxConnection({}, 'AUTORESEARCH');
19
+ return {
20
+ executor: saved.executor ?? 'pi',
21
+ image: saved.image ?? workerImageFor(saved.executor ?? 'pi'),
22
+ sandbox: {
23
+ lifecycleBaseUrl: saved.lifecycleBaseUrl, apiKey: saved.apiKey,
24
+ useServerProxy: saved.useServerProxy, egressMode: saved.egressMode,
25
+ resourceLimits: { cpu: '2', memory: '4Gi' },
26
+ },
27
+ connection: { publicUrl: saved.publicUrl, advertiseHost: saved.advertiseHost },
28
+ };
29
+ }
30
+ export function kimiModel() {
31
+ const url = process.env.ANYSWARM_MODEL_URL;
32
+ if (!url)
33
+ throw new ProjectPreflightError('AUTORESEARCH_MODEL_REQUIRED', 'Set ANYSWARM_MODEL_URL for the Kimi K3 route and ANYSWARM_MODEL_TOKEN if required by your proxy.');
34
+ const provider = process.env.ANYSWARM_MODEL_PROVIDER ?? 'kimi_proxy';
35
+ const model = process.env.ANYSWARM_MODEL_ID ?? 'k3';
36
+ if (provider !== 'kimi_proxy' || model !== 'k3') {
37
+ throw new ProjectPreflightError('AUTORESEARCH_K3_REQUIRED', 'Select the kimi_proxy/k3 model for the FrontierCS-2 demo.');
38
+ }
39
+ const endpoint = URL.canParse(url) ? new URL(url) : undefined;
40
+ if (!endpoint || !['http:', 'https:'].includes(endpoint.protocol) || endpoint.username || endpoint.password ||
41
+ endpoint.search || endpoint.hash || !endpoint.pathname.endsWith('/v1/responses')) {
42
+ throw new ProjectPreflightError('AUTORESEARCH_MODEL_URL_INVALID', 'Set ANYSWARM_MODEL_URL to a fixed HTTP(S) /v1/responses endpoint without credentials, query or fragment.');
43
+ }
44
+ const token = process.env.ANYSWARM_MODEL_TOKEN;
45
+ return { provider, model, upstream: { url: endpoint.href, headers: token ? { authorization: `Bearer ${token}` } : {} } };
46
+ }
47
+ export function checkBudget(budget, minimum = 1) {
48
+ const bounded = (value, min, max) => Number.isSafeInteger(value) && value >= min && value <= max;
49
+ if (!budget || !bounded(budget.workers, minimum, 8) || !bounded(budget.workMs, 10_000, 18_000_000) ||
50
+ !bounded(budget.maxEvaluations, 1, 100) ||
51
+ (budget.maxModelRequests !== undefined && !bounded(budget.maxModelRequests, budget.workers, 10_000))) {
52
+ throw new ProjectPreflightError('AUTORESEARCH_BUDGET_INVALID', 'Set a valid shared worker, time and evaluation budget, and a valid model-request cap if supplied.');
53
+ }
54
+ const { workers, workMs, maxEvaluations, maxModelRequests } = budget;
55
+ return { workers, workMs, maxEvaluations, ...(maxModelRequests === undefined ? {} : { maxModelRequests }) };
56
+ }
57
+ export default undefined;
@@ -0,0 +1,11 @@
1
+ import type { JsonValue } from '@anyswarm/core';
2
+ import { type ResearchConfiguration } from './config.js';
3
+ export declare function frontierTrainEvaluation(returned: Record<string, unknown>): {
4
+ valid: boolean;
5
+ score: number | null;
6
+ feedback: JsonValue;
7
+ };
8
+ export declare function frontierDemo(): Promise<{
9
+ configuration: ResearchConfiguration;
10
+ starter: string;
11
+ }>;
@@ -0,0 +1,52 @@
1
+ import { join } from 'node:path';
2
+ import { defaultResearchConnection, demoCloseTimeoutMs, demoGoal, kimiModel } from './config.js';
3
+ import { FrontierRun, frontierFinalTimeMs, frontierSubmission, judgeTimeMs } from './frontiercs2.js';
4
+ import { loadPrepared, resourcePlan } from './prepare.js';
5
+ export function frontierTrainEvaluation(returned) {
6
+ const observed = returned.raw_score;
7
+ const score = typeof observed === 'number' && Number.isFinite(observed) ? observed : null;
8
+ return {
9
+ // This task's valid benchmark score is strictly positive. Some construction
10
+ // failures return only a zero score and omit both failure and rejected.
11
+ valid: score !== null && score > 0 && !returned.rejected && !returned.failure,
12
+ score,
13
+ feedback: returned,
14
+ };
15
+ }
16
+ export async function frontierDemo() {
17
+ const ready = await loadPrepared().catch(() => { throw new Error('Prepare the pinned demo first with anyswarm run ./prepare-demo.ts.'); });
18
+ const { budget, paths, saved, starter } = ready;
19
+ const defaults = defaultResearchConnection();
20
+ const model = kimiModel();
21
+ let frontier;
22
+ const configuration = {
23
+ ...defaults, model, restrictNetwork: true, goal: demoGoal, direction: 'max', budget,
24
+ sandbox: { ...defaults.sandbox, timeoutSeconds: Math.ceil((budget.workMs + demoCloseTimeoutMs) / 1000) + 60 },
25
+ targetPath: starter,
26
+ requiredFiles: ['README.md', 'include/binaryfusefilter.h'],
27
+ evaluationTimeoutMs: judgeTimeMs + 25_000,
28
+ closeTimeoutMs: demoCloseTimeoutMs,
29
+ evaluator: {
30
+ async start(directory, signal) {
31
+ frontier = new FrontierRun(paths, join(directory, 'pumpkin'));
32
+ await frontier.start(Math.ceil((budget.workMs + frontierFinalTimeMs) / 1000), signal);
33
+ if (frontier.imageId !== saved.bridgeImage || JSON.stringify(frontier.judges) !== JSON.stringify(saved.judges)) {
34
+ throw new Error('Pumpkin image identity changed after preparation');
35
+ }
36
+ },
37
+ async train(patch, signal, admitted) {
38
+ const receipt = await frontier.train(frontierSubmission(patch), signal, admitted);
39
+ return frontierTrainEvaluation(receipt.returned);
40
+ },
41
+ async final(patch, signal) {
42
+ return await frontier.finish(frontierSubmission(patch), signal);
43
+ },
44
+ async close() { return frontier ? await frontier.close() : 'complete'; },
45
+ evidence() {
46
+ return { reference: saved.referenceRecord, record: frontier?.record ?? null, bridgeImage: frontier?.imageId ?? null, judges: frontier?.judges ?? null,
47
+ benchmark: saved.revision, pumpkin: saved.pumpkin, resources: resourcePlan(budget) };
48
+ },
49
+ },
50
+ };
51
+ return { configuration, starter };
52
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "apiVersion": 1,
3
+ "entry": "project.ts",
4
+ "files": [
5
+ "README.md",
6
+ "REQUIREMENTS.zh.md",
7
+ "project.ts",
8
+ "config.ts",
9
+ "research-service.ts",
10
+ "demo.ts",
11
+ "prepare.ts",
12
+ "prepare-demo.ts",
13
+ "frontiercs2-config.ts",
14
+ "frontiercs2.ts",
15
+ "process.ts"
16
+ ]
17
+ }
@@ -0,0 +1,2 @@
1
+ declare const configuration: import("./config.js").ResearchConfiguration;
2
+ export default configuration;
@@ -0,0 +1,3 @@
1
+ import { frontierDemo } from './demo.js';
2
+ const { configuration } = await frontierDemo();
3
+ export default configuration;