@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,5 +1,6 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
- import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ import { mkdir, open, readFile, readdir, writeFile } from 'node:fs/promises';
3
4
  import { join } from 'node:path';
4
5
  import { setTimeout as delay } from 'node:timers/promises';
5
6
  import { command, requireSuccess } from './process.js';
@@ -7,8 +8,31 @@ export const frontierRevision = '7e48965c7cef2a567c2669c8e2f10b06386289c9';
7
8
  export const pumpkinPin = '2026-11-30 ca3ce7ae0da5616464b00ee7962aecac0fc0b38d a1bb9c633f1f700ea42bceb9cd9512f684e9063d3a8ae6c9485526a1dd68016f';
8
9
  export const frontierTask = 'tasks/binary_fuse_filter/task.star';
9
10
  export const submissionLimit = 1024 * 1024;
11
+ const officialJudgeSeconds = 180;
12
+ const grantCallTimeoutSeconds = 181;
10
13
  export const judgeTimeMs = 190_000;
11
14
  export const frontierFinalTimeMs = 250_000;
15
+ export async function preparePumpkin(source, cache, signal) {
16
+ await mkdir(cache, { recursive: true, mode: 0o700 });
17
+ // The pinned launcher extracts with the caller's umask. Only the bootstrap
18
+ // needs 022; prepare and the official evaluation keep the operator's umask.
19
+ requireSuccess(await command('/bin/sh', ['-c', 'umask 022; exec ./pumpkin --version'], {
20
+ cwd: source, env: { ...process.env, XDG_CACHE_HOME: cache }, timeoutMs: 240_000, signal,
21
+ }), 'Initialize pinned Pumpkin tools');
22
+ // Repair a cache populated by an earlier prepare under a restrictive umask.
23
+ const checksum = pumpkinPin.split(' ')[2];
24
+ const binary = await open(join(cache, 'pumpkin', checksum, 'bin', 'sandboxd'), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
25
+ try {
26
+ const info = await binary.stat();
27
+ if (!info.isFile())
28
+ throw new Error('The pinned Pumpkin sandboxd is not a regular file');
29
+ if ((info.mode & 0o111) !== 0o111)
30
+ await binary.chmod((info.mode & 0o777) | 0o111);
31
+ }
32
+ finally {
33
+ await binary.close();
34
+ }
35
+ }
12
36
  export function digest(bytes) {
13
37
  return createHash('sha256').update(bytes).digest('hex');
14
38
  }
@@ -74,6 +98,8 @@ export class FrontierRun {
74
98
  container;
75
99
  imageId;
76
100
  judges;
101
+ grants;
102
+ cleanupEvidence = { status: 'pending', runIds: [], pendingContainers: [] };
77
103
  closed = false;
78
104
  constructor(paths, runs) {
79
105
  this.paths = paths;
@@ -86,7 +112,7 @@ export class FrontierRun {
86
112
  return command('docker', ['--context', this.paths.dockerContext, ...args], { timeoutMs, signal, input });
87
113
  }
88
114
  get record() { return this.id ? join(this.runs, this.id) : undefined; }
89
- async start(seconds, signal, timeoutMs = 360_000) {
115
+ async start(seconds, signal, timeoutMs = 360_000, maxEvaluations = 1) {
90
116
  await mkdir(this.runs, { recursive: true, mode: 0o700 });
91
117
  const start = await this.pumpkin(['run', frontierTask, '--arg', 'agent=anyswarm', '--arg', `deadline_seconds=${seconds}`,
92
118
  '--config', this.paths.config, '--runs', this.runs], timeoutMs, signal);
@@ -112,11 +138,14 @@ export class FrontierRun {
112
138
  const role = ir.roles?.find((role) => role.name === 'agent');
113
139
  const grantTrain = role?.runtime?.agent?.grants?.find((grant) => grant.name === 'train');
114
140
  const grantFinal = role?.runtime?.agent?.grants?.find((grant) => grant.name === 'final');
115
- if (grantTrain?.job?.target !== 'train_judge' || !(grantTrain.job.calls >= 8) ||
141
+ if (grantTrain?.job?.target !== 'train_judge' || !(grantTrain.job.calls >= maxEvaluations) ||
142
+ grantTrain.job.cumulative_seconds !== 12_000 || grantTrain.job.call_timeout_seconds !== grantCallTimeoutSeconds ||
116
143
  grantTrain.job.payload_max_bytes !== submissionLimit || grantFinal?.now?.payload_max_bytes !== submissionLimit ||
117
144
  grantFinal.now.body?.arguments?.finalize?.type !== 'bool' || ir.final?.target !== undefined && ir.final.target !== 'final_judge') {
118
- throw new Error('The Pumpkin role does not have the pinned train and final grants');
145
+ throw new Error('The Pumpkin role does not authorize the requested train budget or the pinned judge limits');
119
146
  }
147
+ this.grants = { trainCalls: grantTrain.job.calls, trainCumulativeSeconds: grantTrain.job.cumulative_seconds,
148
+ judgeSeconds: officialJudgeSeconds, callTimeoutSeconds: grantTrain.job.call_timeout_seconds, maxBytes: grantTrain.job.payload_max_bytes };
120
149
  const grants = await this.docker(['exec', this.container, '/bin/sh', '-eu', '-c',
121
150
  'test -w /pumpkin; exec /.pumpkin/bin/sandboxctl ops'], 5_000, started);
122
151
  const ops = JSON.parse(requireSuccess(grants, 'Check official Pumpkin grants and submission scratch space'));
@@ -148,8 +177,26 @@ export class FrontierRun {
148
177
  const state = JSON.parse(reply.stdout);
149
178
  if (state.kind !== 'status' || state.job !== job)
150
179
  throw new Error('Official train status is unknown');
151
- if (state.state === 'completed' && state.returned)
152
- return { job, returned: state.returned };
180
+ if (state.state === 'completed' && state.returned) {
181
+ const payload = { digest: `sha256:${digest(bytes)}`, size: bytes.byteLength };
182
+ // A score can be available while Pumpkin is still releasing the job's
183
+ // sandbox. The next admission is safe only after the recorded teardown.
184
+ while (true) {
185
+ const log = await readFile(join(this.record, 'log.jsonl'), { encoding: 'utf8', signal: deadline });
186
+ const lines = log.split('\n');
187
+ lines.pop(); // The last line may still be in flight.
188
+ const entries = lines.map(line => JSON.parse(line));
189
+ const action = entries.flatMap(entry => entry.actions ?? [])
190
+ .find(entry => entry.kind === 'start_call' && entry.grant === 'train' && entry.job === job);
191
+ if (action?.payload?.digest !== payload.digest || action.payload.size !== payload.size) {
192
+ throw new Error('Official train result does not match the submitted payload');
193
+ }
194
+ if (entries.some(({ event }) => event?.kind === 'call_torn_down' && event.job === job)) {
195
+ return { job, returned: state.returned, payload };
196
+ }
197
+ await delay(250, undefined, { signal: deadline });
198
+ }
199
+ }
153
200
  if (state.state === 'errored')
154
201
  throw new Error(`Official train job ${job} failed`);
155
202
  if (state.state !== 'queued' && state.state !== 'running')
@@ -182,19 +229,29 @@ export class FrontierRun {
182
229
  return { outcome, record };
183
230
  }
184
231
  async close() {
232
+ this.cleanupEvidence = { status: 'pending', runIds: [], pendingContainers: [] };
185
233
  try {
186
- const ids = this.id ? [this.id] : (await readdir(this.runs, { withFileTypes: true }).catch(() => []))
187
- .filter(entry => entry.isDirectory() && runId.test(entry.name)).map(entry => entry.name);
234
+ const ids = this.id ? [this.id] : (await readdir(this.runs, { withFileTypes: true }).catch(error => {
235
+ if (error.code === 'ENOENT')
236
+ return [];
237
+ throw error;
238
+ })).filter(entry => entry.isDirectory() && runId.test(entry.name)).map(entry => entry.name);
239
+ this.cleanupEvidence.runIds = ids;
240
+ let confirmed = true;
188
241
  for (const id of ids) {
189
242
  const finished = this.closed || await readFile(join(this.runs, id, 'outcome.json'), 'utf8')
190
243
  .then(raw => JSON.parse(raw).state === 'finished').catch(() => false);
191
- if (!finished)
192
- await this.pumpkin(['cancel', '--runs', this.runs, id], 20_000).catch(() => { });
193
- const remaining = await this.docker(['container', 'ls', '-a', '--filter', `label=pumpkin.run=${id}`, '--format', '{{.ID}}'], 5_000);
194
- if (remaining.code !== 0 || remaining.stdout.trim())
195
- return 'pending';
244
+ const cancelled = finished || (await this.pumpkin(['cancel', '--runs', this.runs, id], 20_000).catch(() => undefined))?.code === 0;
245
+ const remaining = await this.docker(['container', 'ls', '-a', '--no-trunc', '--filter', `label=pumpkin.run=${id}`, '--format', '{{.ID}}'], 5_000)
246
+ .catch(() => undefined);
247
+ if (!cancelled || remaining?.code !== 0)
248
+ confirmed = false;
249
+ if (remaining?.code === 0)
250
+ this.cleanupEvidence.pendingContainers.push(...remaining.stdout.trim().split('\n').filter(Boolean));
196
251
  }
197
- return 'complete';
252
+ if (confirmed && !this.cleanupEvidence.pendingContainers.length)
253
+ this.cleanupEvidence.status = 'complete';
254
+ return this.cleanupEvidence.status;
198
255
  }
199
256
  catch {
200
257
  return 'pending';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { resolve } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { parseArgs } from 'node:util';
4
+ import { prepareFrontier } from './prepare.js';
5
+ const controller = new AbortController();
6
+ const interrupt = (signal) => {
7
+ process.exitCode = signal === 'SIGINT' ? 130 : 143;
8
+ controller.abort();
9
+ };
10
+ process.on('SIGINT', interrupt).on('SIGTERM', interrupt);
11
+ try {
12
+ const { values } = parseArgs({ options: {
13
+ config: { type: 'string', default: './frontiercs2-config.ts' },
14
+ check: { type: 'boolean' },
15
+ help: { type: 'boolean' },
16
+ } });
17
+ if (values.help) {
18
+ console.log('Usage: anyswarm run ./prepare-demo.ts [--config ./frontiercs2-config.ts] [--check]');
19
+ console.log('Choose an executor with anyswarm setup, then set a model and a team budget in the shared configuration. --check reports prerequisites without preparing the pinned task or calling a model.');
20
+ }
21
+ else {
22
+ const { default: configuration } = await import(pathToFileURL(resolve(values.config)).href);
23
+ if (!configuration?.frontierStateDir || !configuration.budget || !configuration.sandbox || !configuration.connection) {
24
+ throw new Error('The configuration must default-export frontierDemo({ model, budget, ... }). See frontiercs2-config.ts.');
25
+ }
26
+ const report = await prepareFrontier({ configuration, checkOnly: values.check, signal: controller.signal, progress: console.error });
27
+ for (const row of report.checks)
28
+ console.error(`${row.ok ? 'OK' : 'ACTION'} ${row.name}: ${row.detail}`);
29
+ console.error('Model inference was not attempted.');
30
+ if (report.ok && !values.check) {
31
+ console.error('Prepared. Use the same configuration with anyswarm run ./project.ts --config <your-config> --prompt "Run the FrontierCS-2 task." --output-dir ./runs');
32
+ }
33
+ console.log(JSON.stringify(report, null, 2));
34
+ process.exitCode ??= report.ok ? 0 : 2;
35
+ }
36
+ }
37
+ catch (error) {
38
+ if (!controller.signal.aborted) {
39
+ console.error(error instanceof Error ? error.message : 'Could not load the FrontierCS-2 configuration.');
40
+ console.error('Check the exported frontiercs2-config.ts and run anyswarm setup or anyswarm doctor for your backend.');
41
+ process.exitCode = 2;
42
+ }
43
+ }
44
+ finally {
45
+ process.off('SIGINT', interrupt).off('SIGTERM', interrupt);
46
+ }
@@ -1,95 +1,147 @@
1
+ import type { ModelConfig, SandboxConfig } from '@anyswarm/core';
2
+ import type { FrontierConfiguration } from './demo.js';
1
3
  import { type ResearchBudget } from './config.js';
2
4
  import { type FrontierPaths, type JudgeImages } from './frontiercs2.js';
3
- export declare function resourcePlan(budget: ResearchBudget): {
4
- roles: {
5
- role: string;
6
- count: number;
5
+ export declare function resourcePlan(budget: ResearchBudget, sandbox: SandboxConfig): {
6
+ prepare: {
7
+ roles: {
8
+ role: string;
9
+ count: number;
10
+ cpu: number;
11
+ memoryGiB: number;
12
+ placement: string;
13
+ }[];
14
+ cpu: number;
15
+ memoryGiB: number;
16
+ diskGiB: number;
17
+ gpu: number;
18
+ };
19
+ run: {
20
+ roles: {
21
+ role: string;
22
+ count: number;
23
+ cpu: number;
24
+ memoryGiB: number;
25
+ placement: string;
26
+ }[];
7
27
  cpu: number;
8
28
  memoryGiB: number;
9
- }[];
10
- cpu: number;
11
- memoryGiB: number;
12
- diskGiB: number;
13
- gpu: number;
29
+ diskGiB: number;
30
+ gpu: number;
31
+ };
32
+ localWorkers: boolean;
14
33
  };
15
34
  export interface Check {
16
35
  name: string;
17
36
  ok: boolean;
18
37
  detail: string;
19
38
  }
20
- export declare function checkKimiRoute(signal: AbortSignal): Promise<Check[]>;
39
+ export declare function checkModelRoute(model: ModelConfig, executor: FrontierConfiguration['executor'], signal: AbortSignal): Promise<Check[]>;
40
+ interface Prepared {
41
+ version: 2;
42
+ revision: string;
43
+ pumpkin: string;
44
+ sourceDigest: string;
45
+ bridgeDigest: string;
46
+ bridgeImage: string;
47
+ judges: JudgeImages;
48
+ dockerContext: string;
49
+ referenceRecord: string;
50
+ }
51
+ export declare const starterPath: (home: string) => string;
21
52
  export declare function loadPrepared(home?: string): Promise<{
22
- saved: {
23
- version: 2;
24
- revision: string;
25
- pumpkin: string;
26
- sourceDigest: string;
27
- bridgeDigest: string;
28
- bridgeImage: string;
29
- judges: JudgeImages;
30
- dockerContext: string;
31
- referenceRecord: string;
32
- budget: ResearchBudget;
33
- };
53
+ saved: Prepared;
34
54
  paths: FrontierPaths;
35
- budget: ResearchBudget;
36
55
  starter: string;
37
56
  }>;
38
- export declare function prepareFrontier({ signal, progress, home }: {
57
+ export declare function prepareFrontier({ signal, progress, configuration, checkOnly }: {
39
58
  signal: AbortSignal;
40
59
  progress: (message: string) => void;
41
- home?: string;
60
+ configuration: FrontierConfiguration;
61
+ checkOnly?: boolean;
42
62
  }): Promise<{
43
63
  ok: boolean;
44
64
  benchmark: string;
45
65
  pumpkin: string;
46
66
  budget: ResearchBudget;
47
67
  resources: {
48
- roles: {
49
- role: string;
50
- count: number;
68
+ prepare: {
69
+ roles: {
70
+ role: string;
71
+ count: number;
72
+ cpu: number;
73
+ memoryGiB: number;
74
+ placement: string;
75
+ }[];
51
76
  cpu: number;
52
77
  memoryGiB: number;
53
- }[];
54
- cpu: number;
55
- memoryGiB: number;
56
- diskGiB: number;
57
- gpu: number;
78
+ diskGiB: number;
79
+ gpu: number;
80
+ };
81
+ run: {
82
+ roles: {
83
+ role: string;
84
+ count: number;
85
+ cpu: number;
86
+ memoryGiB: number;
87
+ placement: string;
88
+ }[];
89
+ cpu: number;
90
+ memoryGiB: number;
91
+ diskGiB: number;
92
+ gpu: number;
93
+ };
94
+ localWorkers: boolean;
58
95
  };
59
96
  checks: Check[];
60
97
  home: string;
98
+ model: {
99
+ provider: string | null;
100
+ id: string | null;
101
+ };
61
102
  modelInference: 'not-attempted';
62
103
  } | {
63
104
  benchmark: string;
64
105
  pumpkin: string;
65
106
  budget: ResearchBudget;
66
107
  resources: {
67
- roles: {
68
- role: string;
69
- count: number;
108
+ prepare: {
109
+ roles: {
110
+ role: string;
111
+ count: number;
112
+ cpu: number;
113
+ memoryGiB: number;
114
+ placement: string;
115
+ }[];
70
116
  cpu: number;
71
117
  memoryGiB: number;
72
- }[];
73
- cpu: number;
74
- memoryGiB: number;
75
- diskGiB: number;
76
- gpu: number;
118
+ diskGiB: number;
119
+ gpu: number;
120
+ };
121
+ run: {
122
+ roles: {
123
+ role: string;
124
+ count: number;
125
+ cpu: number;
126
+ memoryGiB: number;
127
+ placement: string;
128
+ }[];
129
+ cpu: number;
130
+ memoryGiB: number;
131
+ diskGiB: number;
132
+ gpu: number;
133
+ };
134
+ localWorkers: boolean;
77
135
  };
78
136
  checks: Check[];
79
137
  home: string;
138
+ model: {
139
+ provider: string | null;
140
+ id: string | null;
141
+ };
80
142
  modelInference: 'not-attempted';
81
143
  ok: boolean;
82
144
  reused: boolean;
83
- prepared: {
84
- version: 2;
85
- revision: string;
86
- pumpkin: string;
87
- sourceDigest: string;
88
- bridgeDigest: string;
89
- bridgeImage: string;
90
- judges: JudgeImages;
91
- dockerContext: string;
92
- referenceRecord: string;
93
- budget: ResearchBudget;
94
- };
145
+ prepared: Prepared;
95
146
  }>;
147
+ export {};