@parcha/agentrun-serve 0.1.0-beta.35 → 0.1.0-beta.37

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 (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/box-image.js CHANGED
@@ -1,285 +1,5 @@
1
- // The image a Docker box starts from, made ready at the server's start, so a run's first tool call is never a silent pull
2
- // or build. By default it is this server's own, built here from BOX_RECIPE (python 3.12 with git, curl, node, npm and rg,
3
- // and socat, the relay to the box's network proxy when it has one: box-egress.ts), tagged
4
- // `agentrun-box:<the recipe's hash>` and labelled with the whole hash (RECIPE_LABEL): built on first use, and again only
5
- // when the recipe changes. AGENTRUN_DOCKER_IMAGE names another image instead, which is pulled when Docker has none.
6
- //
7
- // Once docker answers its probe (boxes.ts), the server asks Docker for the image (`docker image inspect`). When Docker has
8
- // it (the built one with this recipe's hash), the box is ready. When not, the server builds or pulls it once, in the
9
- // background, within BUILD_TIMEOUT_MS or PULL_TIMEOUT_MS: docker is then available and preparing ("building the box
10
- // image (...)", "pulling <image>"), and ready once the image is in. A build or pull that fails is tried once more,
11
- // RETRY_AFTER_MS later, docker preparing meanwhile with why ("trying once more: <the failure>"); one that fails again, or
12
- // does not finish in time, makes docker unavailable with the reason, until a restart tries again. Docker's own output
13
- // is never in a reason, as for the probes: the reason says what kind of failure it was, and what to do. The build
14
- // reaches the network (the base image, apt); a box never does by Docker's network (`--network none`, run-box.ts), only,
15
- // with the server's host list, through its egress proxy (box-egress.ts).
16
- //
17
- // The state is written to IMAGE_STATE_FILE in the data directory at each change, for the run's processes: a run's first
18
- // box create reads it there (awaitImage, from run-box.ts) and, while the image is coming, waits for it, with one row on
19
- // the run's timeline, instead of a `docker run` that pulls inside the tool call. Each record names its writer, the server
20
- // (its pid and start time). A server that went away mid-way (killed, or closed while the image came) leaves the file
21
- // saying preparing: a run that reads it once that writer is gone (the check box/sweep.ts makes of a box record's writer),
22
- // or past its deadline where the writer cannot be told (no /proc), stops waiting and fails its call in words that say to
23
- // restart the server, which builds or pulls the image again; never the `docker run` of an image that is not there.
24
- import { execFile } from "node:child_process";
25
- import { createHash } from "node:crypto";
26
- import { chmod, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
27
- import { tmpdir } from "node:os";
28
- import { join } from "node:path";
29
- import { startTimeOf, writerGone } from "./box/sweep.js";
30
- import { BOX_KEYS } from "./boxes.js";
31
- /** The setting that names another image for Docker boxes than this server's own. */
1
+ // The image a run's Docker computer starts from, when the owner names one: AGENTRUN_DOCKER_IMAGE. Unset, the Docker
2
+ // provider builds its own from the computer package's recipe (DOCKER_RECIPE) on first use, and a run waiting on that
3
+ // build shows it on its timeline (workspace/computer-deps.ts imageWaitWords). Nothing is built or pulled at the start.
4
+ /** The setting that names another image for Docker computers than the computer package's own. */
32
5
  export const DOCKER_IMAGE_ENV = "AGENTRUN_DOCKER_IMAGE";
33
- /** What the default image has, in words. */
34
- export const RECIPE_HAS = "python, git, curl, node, npm, rg";
35
- /** The base the default image builds from: `python:3.12-slim`, pinned to the multi-arch index digest Docker Hub served
36
- * for that tag on 2026-11-03, so a build gets the same base wherever it runs. To move it, read the tag's index digest
37
- * again (an anonymous pull token from auth.docker.io for `repository:library/python:pull`, then a HEAD of
38
- * registry-1.docker.io/v2/library/python/manifests/3.12-slim accepting an OCI index or a manifest list: its
39
- * `docker-content-digest`), and put it here. The recipe's hash changes with it, and so does the image's tag
40
- * (DEFAULT_DOCKER_IMAGE), so every server builds the new one at its next start. */
41
- export const BOX_BASE = "python:3.12-slim@sha256:b18b261e1b4974b4f321451ad5251ded85abb22c2b8b262da527dda1d031ab30";
42
- /** The default image's recipe: a Dockerfile that needs no other file, written alone into a private context directory for
43
- * each build (buildContext). Its hash names the image. */
44
- export const BOX_RECIPE = [
45
- `FROM ${BOX_BASE}`,
46
- "RUN apt-get update \\",
47
- " && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git curl ca-certificates nodejs npm ripgrep socat \\",
48
- " && rm -rf /var/lib/apt/lists/*",
49
- "",
50
- ].join("\n");
51
- /** The label the built image carries: its recipe's sha256. */
52
- export const RECIPE_LABEL = "agentrun.box-image";
53
- export const RECIPE_HASH = createHash("sha256").update(BOX_RECIPE).digest("hex");
54
- /** The default image: this server's own, built from BOX_RECIPE, its tag the recipe's hash. */
55
- export const DEFAULT_DOCKER_IMAGE = `agentrun-box:${RECIPE_HASH.slice(0, 12)}`;
56
- /** The image a Docker box starts from on a server or a run with `env`. */
57
- export const boxImageOf = (env) => env[DOCKER_IMAGE_ENV] || DEFAULT_DOCKER_IMAGE;
58
- /** Where the image's state is kept for the run's processes, in the data directory. */
59
- export const IMAGE_STATE_FILE = "box-image.json";
60
- /** How long the start's pull, or build, may take; past it, it is stopped and docker is unavailable. */
61
- export const PULL_TIMEOUT_MS = 10 * 60_000;
62
- export const BUILD_TIMEOUT_MS = 10 * 60_000;
63
- /** How long Docker may take to say whether it has the image. */
64
- export const INSPECT_TIMEOUT_MS = 5_000;
65
- /** How long past the pull's deadline a run still waits on a file that says preparing: the server's own timer ends the
66
- * pull at the deadline, so only a server that is gone leaves the file saying preparing after it. */
67
- export const STALE_AFTER_MS = 30_000;
68
- /** How long after a failed build or pull it is tried once more. */
69
- export const RETRY_AFTER_MS = 5_000;
70
- /** How long the server's close waits for the image's last record to be saved, so a docker that hangs cannot hold it. */
71
- export const CLOSE_WAIT_MS = 5_000;
72
- /** How often a waiting run reads the file again. */
73
- const POLL_MS = 250;
74
- /** `docker` with `args`, in the server's environment without the boxes' keys, nothing on its stdin, killed after
75
- * `timeoutMs` or on `signal`. */
76
- function docker(env, args, timeoutMs, options = {}) {
77
- const dockerEnv = Object.fromEntries(Object.entries(env).filter(([name]) => !BOX_KEYS.includes(name)));
78
- return new Promise((resolve) => {
79
- const child = execFile("docker", args, { env: dockerEnv, timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 32 * 1024 * 1024, ...(options.signal ? { signal: options.signal } : {}) }, (error, stdout, stderr) => {
80
- const failed = error;
81
- resolve({ code: !failed ? 0 : failed.killed ? "timeout" : typeof failed.code === "number" ? failed.code : (failed.code ?? failed.name), stdout: String(stdout), stderr: String(stderr) });
82
- });
83
- child.stdin?.on("error", () => undefined);
84
- child.stdin?.end();
85
- });
86
- }
87
- /** Seconds or minutes, in words. */
88
- const span = (ms) => (ms >= 60_000 && ms % 60_000 === 0 ? `${ms / 60_000} min` : `${Math.round(ms / 1000)} s`);
89
- const exitOf = (answer) => (typeof answer.code === "number" ? `exit ${answer.code}` : answer.code);
90
- const UNREACHABLE = /dial tcp|no such host|i\/o timeout|connection refused|network is unreachable|TLS handshake timeout|Client\.Timeout|Temporary failure resolving|Could not resolve|Could not connect/i;
91
- const reasonOf = (failure) => `${failure.cause}: ${failure.next}`;
92
- /** Why the build of the default image failed, and the next step. */
93
- function buildFailure(answer, timeoutMs) {
94
- const next = `set ${DOCKER_IMAGE_ENV} to an image this machine has, or restart the server to build it again`;
95
- if (answer.code === "timeout")
96
- return { cause: `the build of the box image did not finish within ${span(timeoutMs)}`, next };
97
- if (/no space left on device/i.test(answer.stderr))
98
- return { cause: "the build of the box image ran out of disk space", next: "free some, then restart the server" };
99
- // A base that could not be fetched for want of a network says so in both ways: the network is the cause.
100
- if (UNREACHABLE.test(answer.stderr))
101
- return { cause: "the build of the box image could not reach the network (it pulls python:3.12-slim and installs git, curl, nodejs, npm, ripgrep and socat with apt)", next };
102
- if (/pull access denied|manifest unknown|not found: manifest|failed to resolve source metadata|failed to fetch anonymous token/i.test(answer.stderr))
103
- return { cause: "the build of the box image could not pull its base, python:3.12-slim", next };
104
- if (/Unable to locate package|has no installation candidate|E: Package/i.test(answer.stderr))
105
- return { cause: "apt could not install what the box image needs (git, curl, nodejs, npm, ripgrep, socat)", next };
106
- return { cause: `docker build of the box image failed (${exitOf(answer)})`, next };
107
- }
108
- /** Why a pull failed, and the next step. */
109
- function pullFailure(image, answer, timeoutMs) {
110
- const see = `run \`docker pull ${image}\` on this machine to see why, then restart the server`;
111
- if (answer.code === "timeout")
112
- return { cause: `the pull of ${image} did not finish within ${span(timeoutMs)}`, next: `run \`docker pull ${image}\` on this machine, then restart the server` };
113
- if (/pull access denied|unauthorized|authentication required|denied:/i.test(answer.stderr))
114
- return { cause: `the registry refused the pull of ${image} (no such repository, or it needs a docker login)`, next: see };
115
- if (/manifest unknown|manifest for .* not found|not found: manifest/i.test(answer.stderr))
116
- return { cause: `the registry has no ${image}`, next: "name an image it has in AGENTRUN_DOCKER_IMAGE, then restart the server" };
117
- if (UNREACHABLE.test(answer.stderr))
118
- return { cause: `the registry could not be reached to pull ${image}`, next: see };
119
- return { cause: `docker pull ${image} failed (${exitOf(answer)})`, next: see };
120
- }
121
- /** This process, as a record names its writer: its pid and start time, where /proc gives that (Linux). */
122
- function self() {
123
- const startTime = startTimeOf(process.pid);
124
- return startTime ? { writer: { pid: process.pid, startTime } } : {};
125
- }
126
- /** Writes the record for the run's processes, whole or not at all, naming this server as its writer. */
127
- async function record(data, value) {
128
- const file = join(data, IMAGE_STATE_FILE);
129
- await writeFile(`${file}.partial`, `${JSON.stringify({ ...value, ...self() })}\n`, { mode: 0o600 });
130
- await rename(`${file}.partial`, file);
131
- }
132
- /** Removes the record: this server has no Docker box, so no run waits on its image. */
133
- export const clearImage = (data) => rm(join(data, IMAGE_STATE_FILE), { force: true });
134
- /** `docker build` of the default image: BOX_RECIPE written alone as `Dockerfile` into a fresh directory of its own (0700,
135
- * under TMPDIR), which is the build's context and is removed when the build ends, however it ends. A file on disk, not
136
- * stdin, so what was built can be read where it was built. */
137
- async function buildContext(env, image, timeoutMs, signal) {
138
- const dir = await mkdtemp(join(env.TMPDIR || tmpdir(), "agentrun-box-"));
139
- try {
140
- await chmod(dir, 0o700);
141
- await writeFile(join(dir, "Dockerfile"), BOX_RECIPE, { mode: 0o600 });
142
- return await docker(env, ["build", "--quiet", "--label", `${RECIPE_LABEL}=${RECIPE_HASH}`, "--tag", image, dir], timeoutMs, { signal });
143
- }
144
- finally {
145
- await rm(dir, { recursive: true, force: true }).catch(() => undefined);
146
- }
147
- }
148
- /** The labels of `image` as `docker image inspect` gives them, or none when it has none. */
149
- const labelsOf = (stdout) => {
150
- try {
151
- const value = JSON.parse(stdout.trim() || "null");
152
- return value && typeof value === "object" ? value : {};
153
- }
154
- catch {
155
- return {};
156
- }
157
- };
158
- /**
159
- * The image's readiness on this server: asked of Docker now (within INSPECT_TIMEOUT_MS), and when Docker has none (or,
160
- * for the default, has one of another recipe), built from BOX_RECIPE or pulled, in the background, within its bound; a
161
- * try that fails, but not for want of time, is made once more, `retryAfterMs` later. `onChange` is told each state after
162
- * the first. The record in the data directory follows the state.
163
- */
164
- export async function dockerImage(env, data, image, options = {}) {
165
- const built = image === DEFAULT_DOCKER_IMAGE;
166
- const timeoutMs = built ? (options.buildTimeoutMs ?? BUILD_TIMEOUT_MS) : (options.pullTimeoutMs ?? PULL_TIMEOUT_MS);
167
- let state;
168
- const write = (extra = {}) => record(data, { image, state: state.state, ...("reason" in state ? { reason: state.reason } : {}), ...extra }).catch(() => undefined);
169
- const inspected = await docker(env, ["image", "inspect", "--format", "{{json .Config.Labels}}", image], options.inspectTimeoutMs ?? INSPECT_TIMEOUT_MS);
170
- const controller = new AbortController();
171
- // Docker says `No such image`; Podman, standing in for it, `image not known`.
172
- const missing = inspected.code !== 0 && /no such image|image not known/i.test(inspected.stderr);
173
- if (inspected.code === 0 && (!built || labelsOf(inspected.stdout)[RECIPE_LABEL] === RECIPE_HASH))
174
- state = { state: "ready" };
175
- else if (inspected.code !== 0 && !missing) {
176
- const why = inspected.code === "timeout" ? `did not answer within ${span(options.inspectTimeoutMs ?? INSPECT_TIMEOUT_MS)}` : `failed (${exitOf(inspected)})`;
177
- state = { state: "unavailable", reason: `docker image inspect ${image} ${why}: run it on this machine as this server's user to see why, then restart the server` };
178
- }
179
- else
180
- state = { state: "preparing", reason: built ? `building the box image (${RECIPE_HAS})` : `pulling ${image}` };
181
- if (state.state !== "preparing") {
182
- await write();
183
- const settled = state;
184
- return { image, state: () => settled, settled: Promise.resolve(settled), close: async () => undefined };
185
- }
186
- const started = Date.now();
187
- const row = built ? `Preparing the box image: building it (${RECIPE_HAS})…` : `Preparing the box image: pulling ${image}…`;
188
- await write({ until: started + timeoutMs, row });
189
- const retryAfterMs = options.retryAfterMs ?? RETRY_AFTER_MS;
190
- // The build's network is Docker's default, for the base image and apt; a box made from it has none of Docker's (run-box.ts).
191
- const attempt = () => built
192
- ? buildContext(env, image, timeoutMs, controller.signal).catch((error) => ({ code: error.code ?? error.name, stdout: "", stderr: "" }))
193
- : docker(env, ["pull", "--quiet", image], timeoutMs, { signal: controller.signal });
194
- const failure = (answer) => (built ? buildFailure(answer, timeoutMs) : pullFailure(image, answer, timeoutMs));
195
- const settled = attempt().then(async (first) => {
196
- let answer = first;
197
- // One try more, after a pause, for a failure that may pass (the network, the registry); not for one that already
198
- // took the whole bound.
199
- if (answer.code !== 0 && answer.code !== "timeout" && !controller.signal.aborted) {
200
- state = { state: "preparing", reason: `trying once more: ${failure(answer).cause}` };
201
- // A record of the retry that cannot be saved leaves the first try's: a run keeps waiting on it, as this server
202
- // that wrote it still runs (a named writer decides, not its deadline). Removed, it would send a waiting run to a
203
- // `docker run` of an image that is not there yet.
204
- await write({ until: Date.now() + retryAfterMs + timeoutMs, row });
205
- options.onChange?.(state, Date.now() - started);
206
- await sleep(retryAfterMs, controller.signal).catch(() => undefined);
207
- if (!controller.signal.aborted)
208
- answer = await attempt();
209
- }
210
- if (controller.signal.aborted)
211
- return state;
212
- state = answer.code === 0 ? { state: "ready" } : { state: "unavailable", reason: reasonOf(failure(answer)) };
213
- // A final state that cannot be written leaves no record: a run then makes its box as it would with none, never
214
- // waiting on the `preparing` the record last said.
215
- await record(data, { image, state: state.state, ...("reason" in state ? { reason: state.reason } : {}) }).catch(async (error) => {
216
- await clearImage(data).catch(() => undefined);
217
- options.warn?.(`the record of the box image's state could not be written (${error.code ?? error.name}), so it was removed: runs make their boxes without waiting on it`);
218
- });
219
- options.onChange?.(state, Date.now() - started);
220
- return state;
221
- });
222
- const close = async () => {
223
- controller.abort();
224
- // A build or pull that ended just before the abort may be saving its last record: that save ends first, within bound.
225
- let timer;
226
- await Promise.race([settled.then(() => undefined, () => undefined), new Promise((resolve) => (timer = setTimeout(resolve, CLOSE_WAIT_MS)))]);
227
- clearTimeout(timer);
228
- };
229
- return { image, state: () => state, settled, close };
230
- }
231
- /** Docker's offer with the image's state on it: available while it is ready or preparing, else unavailable with why. */
232
- export function withImage(offer, image) {
233
- if (!offer.available)
234
- return offer;
235
- if (image.state === "ready")
236
- return { ...offer, state: "ready" };
237
- return { id: offer.id, available: image.state === "preparing", state: image.state, reason: image.reason };
238
- }
239
- /** The record the server left, or undefined when there is none or it is not one. */
240
- async function recordIn(data) {
241
- try {
242
- const value = JSON.parse(await readFile(join(data, IMAGE_STATE_FILE), "utf8"));
243
- return typeof value?.image === "string" && typeof value.state === "string" ? value : undefined;
244
- }
245
- catch {
246
- return undefined;
247
- }
248
- }
249
- const sleep = (ms, signal) => new Promise((resolve, reject) => {
250
- if (signal?.aborted)
251
- return reject(signal.reason ?? new Error("aborted"));
252
- const timer = setTimeout(() => (signal?.removeEventListener("abort", stop), resolve()), ms);
253
- const stop = () => (clearTimeout(timer), reject(signal?.reason ?? new Error("aborted")));
254
- signal?.addEventListener("abort", stop, { once: true });
255
- });
256
- /**
257
- * Before a run's box is made from `image`: returns once the server's record says the image is ready, or says nothing
258
- * of it (no record, another image); waits while it says the image is being built or pulled, telling `note` once, as the
259
- * run's timeline row; and throws, with the server's reason, when that failed, and saying to restart the server when the
260
- * server that was making it is gone (its writer, or where that cannot be told, its deadline). A cancel of `context`
261
- * ends the wait.
262
- */
263
- export async function awaitImage(data, image, context, note) {
264
- let noted = false;
265
- for (;;) {
266
- const at = await recordIn(data);
267
- if (!at || at.image !== image || at.state === "ready")
268
- return;
269
- if (at.state === "unavailable")
270
- throw new Error(`its image ${image} is not ready: ${at.reason ?? "the server could not make it ready"}`);
271
- if (typeof at.until !== "number")
272
- return;
273
- // Its writer named, that decides: a server that runs is still making the image. Only where it cannot be told does
274
- // the deadline.
275
- if (at.writer ? writerGone(at.writer) : Date.now() > at.until + STALE_AFTER_MS) {
276
- const making = image === DEFAULT_DOCKER_IMAGE ? ["building", "build"] : ["pulling", "pull"];
277
- throw new Error(`its image ${image} is not ready: the server stopped while ${making[0]} it: restart the server to ${making[1]} it again`);
278
- }
279
- if (!noted) {
280
- noted = true;
281
- await Promise.resolve(note(at.row ?? `Preparing the box image ${image}…`)).catch(() => undefined);
282
- }
283
- await sleep(POLL_MS, context.abortSignal);
284
- }
285
- }
@@ -1,4 +1,4 @@
1
- /** Where the daemon has the data directory: the named volume mounted at `at`, as pi-transport's Docker `paths` takes it. */
1
+ /** Where the daemon has the data directory: the named volume mounted at `at`. */
2
2
  export type BoxPaths = {
3
3
  at: string;
4
4
  volume: string;
@@ -11,7 +11,7 @@ export type DockerPaths = {
11
11
  } | {
12
12
  reason: string;
13
13
  };
14
- /** The one way a server in a container runs boxes. */
14
+ /** The one way a server in a container runs Docker computers. */
15
15
  export declare const IN_COMPOSE = "run AgentRun in a container with `docker compose up` from compose.yaml (its named data volume is how boxes reach a run's files)";
16
16
  /** An engine that cannot mount a volume's subpath. */
17
17
  export declare const OLD_ENGINE = "Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+";
@@ -42,11 +42,6 @@ export declare function dockerComputerRefusal(paths: DockerPaths, remote: string
42
42
  export declare function dockerPathsForRuns(env: NodeJS.ProcessEnv, data: string, platform?: NodeJS.Platform): Promise<DockerPaths>;
43
43
  /** Under `--faux` only: a file the server reads as its /proc/self/mountinfo (server.ts fauxMountinfo). */
44
44
  export declare const FAUX_MOUNTINFO_ENV = "AGENTRUN_SERVE_FAUX_MOUNTINFO";
45
- /** What the server hands a run's process: the paths, as JSON; empty on a host. */
46
- export declare const RUN_BOX_PATHS_ENV = "AGENTRUN_RUN_BOX_PATHS";
47
- /** The directory the runs' egress proxy sockets are in, for a server in a container: on its data volume, so a box can
48
- * mount its run's (box-egress.ts egressDir). */
49
- export declare const egressParentOf: (data: string) => string;
50
45
  /** Its own container's id, from /proc/self/mountinfo: the source of the /etc/hostname Docker bound in. */
51
46
  export declare function ownContainerOf(mountinfo: string): string | undefined;
52
47
  /** A mount of a container, as `docker inspect` gives it. */
package/dist/box-paths.js CHANGED
@@ -1,20 +1,19 @@
1
- // Where the Docker a server runs boxes on has the server's files. On a host, the server's paths are the daemon's own, and
2
- // a box binds the run's work/ by its path: nothing here is asked. A server in a container of that Docker's own, given its
1
+ // Where the Docker a server runs computers on has the server's files. On a host, the server's paths are the daemon's own,
2
+ // and a computer binds the run's folder by its path: nothing here is asked. A server in a container of that Docker's own, given its
3
3
  // socket (compose.yaml at the repository's root), has paths the daemon does not: the daemon has only what it mounted
4
4
  // into the server's container. One layout is supported: the data directory on a named volume of the server's own
5
5
  // container, as compose.yaml makes it. The server reads its own container's id from /proc/self/mountinfo (Docker binds
6
6
  // /etc/hostname from `<its root>/containers/<id>/hostname`), asks Docker for that container's mounts, and takes the
7
- // named volume that holds the data directory; a box then mounts the run's work/ and its egress directory as that volume's
8
- // subpaths (pi-transport's Docker `paths`, `volume-subpath`: Docker Engine 26 and later), never the volume's root, and a
9
- // run's Docker computer mounts its run's folder and its daemon copy the same way (workspace/computer-deps.ts
10
- // dockerVolumeOf, the Docker provider's `volume`). Any other layout, or an older engine, is a reason, said once at the
11
- // start, and docker is unavailable: a guess would make every box fail at its create.
7
+ // named volume that holds the data directory; a run's Docker computer then mounts its run's folder and its daemon copy as
8
+ // that volume's subpaths (`volume-subpath`: Docker Engine 26 and later), never the volume's root (workspace/
9
+ // computer-deps.ts dockerVolumeOf, the Docker provider's `volume`). Any other layout, or an older engine, is a reason,
10
+ // said once at the start, and docker is unavailable: a guess would make every computer fail at its create.
12
11
  import { execFile } from "node:child_process";
13
12
  import { existsSync } from "node:fs";
14
13
  import { readFile } from "node:fs/promises";
15
14
  import { FAUX_ENV } from "./model.js";
16
15
  import { withoutSecrets } from "./secrets.js";
17
- /** The one way a server in a container runs boxes. */
16
+ /** The one way a server in a container runs Docker computers. */
18
17
  export const IN_COMPOSE = "run AgentRun in a container with `docker compose up` from compose.yaml (its named data volume is how boxes reach a run's files)";
19
18
  /** An engine that cannot mount a volume's subpath. */
20
19
  export const OLD_ENGINE = "Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+";
@@ -96,11 +95,6 @@ export async function dockerPathsForRuns(env, data, platform = process.platform)
96
95
  }
97
96
  /** Under `--faux` only: a file the server reads as its /proc/self/mountinfo (server.ts fauxMountinfo). */
98
97
  export const FAUX_MOUNTINFO_ENV = "AGENTRUN_SERVE_FAUX_MOUNTINFO";
99
- /** What the server hands a run's process: the paths, as JSON; empty on a host. */
100
- export const RUN_BOX_PATHS_ENV = "AGENTRUN_RUN_BOX_PATHS";
101
- /** The directory the runs' egress proxy sockets are in, for a server in a container: on its data volume, so a box can
102
- * mount its run's (box-egress.ts egressDir). */
103
- export const egressParentOf = (data) => `${data}/box-egress`;
104
98
  /** Its own container's id, from /proc/self/mountinfo: the source of the /etc/hostname Docker bound in. */
105
99
  export function ownContainerOf(mountinfo) {
106
100
  for (const line of mountinfo.split("\n")) {
@@ -1,5 +1,3 @@
1
- import type { BoxProvider } from "@parcha/pi-transport";
2
- import { type DockerNetwork, egressBlockedBy } from "./box-egress.js";
3
1
  /** The setting that names the hosts a box may reach: a comma list of hosts, each a name or `*.` and a name, which
4
2
  * replaces the default list; `none` for no network at all. Unset or empty, the default. */
5
3
  export declare const BOX_ALLOW_ENV = "AGENTRUN_BOX_ALLOW";
@@ -15,12 +13,3 @@ export declare const MAX_BOX_ALLOW = 100;
15
13
  * unset or empty; `none` for no network. `*`, an IP address, a CIDR, a port, a URL, or more than 100 hosts throws, saying
16
14
  * what the setting takes: the start checks it (startServe), so no run meets one. */
17
15
  export declare function boxAllowOf(env: NodeJS.ProcessEnv): readonly string[] | "none";
18
- /** What a server's Docker boxes reach, resolved once at its start: the setting's list (boxAllowOf) where egressBlockedBy
19
- * (box-egress.ts) finds the daemon is this Linux machine's own, else none with the reason; `none` from the setting, with
20
- * it as the reason. */
21
- export declare function boxNetworkOf(env: NodeJS.ProcessEnv, options?: Parameters<typeof egressBlockedBy>[1]): Promise<DockerNetwork>;
22
- /** Under `--faux` only: a module whose default export, given the data root, is the provider the tests' faux box comes
23
- * from in place of Docker. */
24
- export declare const FAUX_BOX_ENV = "AGENTRUN_SERVE_FAUX_BOX";
25
- /** The tests' faux box provider, from its module. */
26
- export declare const fauxBoxes: (module: string, root: string) => Promise<BoxProvider>;
@@ -1,10 +1,7 @@
1
- // A box's settings as the server reads them at its start: the hosts a box may reach (AGENTRUN_BOX_ALLOW) and what a
2
- // server's Docker boxes reach from them, and, under `--faux` only, the tests' faux box provider. A setting that is not one
3
- // throws, naming it: the start checks each, so no run meets one. A Docker computer's size (AGENTRUN_BOX_CPUS, _MEMORY,
4
- // _PIDS) is workspace/computer-deps.ts dockerLimitsOf.
5
- import { pathToFileURL } from "node:url";
6
- import { egressBlockedBy } from "./box-egress.js";
7
- import { vmDocker } from "./box-egress-vm.js";
1
+ // The hosts a run's computer may reach (AGENTRUN_BOX_ALLOW), as the server reads them at its start: a run's launch keeps
2
+ // them (box_allow) and its computer is made with them (workspace/computer-deps.ts). A setting that is not one throws,
3
+ // naming it: the start checks it, so no run meets one. A Docker computer's size (AGENTRUN_BOX_CPUS, _MEMORY, _PIDS) is
4
+ // workspace/computer-deps.ts dockerLimitsOf.
8
5
  /** The setting that names the hosts a box may reach: a comma list of hosts, each a name or `*.` and a name, which
9
6
  * replaces the default list; `none` for no network at all. Unset or empty, the default. */
10
7
  export const BOX_ALLOW_ENV = "AGENTRUN_BOX_ALLOW";
@@ -39,25 +36,3 @@ export function boxAllowOf(env) {
39
36
  throw new Error(`${BOX_ALLOW_ENV} names ${hosts.length} hosts; it takes at most ${MAX_BOX_ALLOW}`);
40
37
  return Object.freeze(hosts);
41
38
  }
42
- /** What a server's Docker boxes reach, resolved once at its start: the setting's list (boxAllowOf) where egressBlockedBy
43
- * (box-egress.ts) finds the daemon is this Linux machine's own, else none with the reason; `none` from the setting, with
44
- * it as the reason. */
45
- export async function boxNetworkOf(env, options = {}) {
46
- const allow = boxAllowOf(env);
47
- if (allow === "none")
48
- return { allow: "none", reason: `${BOX_ALLOW_ENV} is none` };
49
- const blocked = await egressBlockedBy(env, options);
50
- if (!blocked)
51
- return { allow };
52
- // On a Mac only: a Docker that docker info names as a VM runtime this server knows gets the proxy container
53
- // (box-egress-vm.ts); any other stays none, saying why.
54
- if ((options.platform ?? process.platform) !== "darwin")
55
- return { allow: "none", reason: blocked };
56
- const vm = await vmDocker(env, { ...(options.platform ? { platform: options.platform } : {}), ...(options.kernel ? { kernel: options.kernel } : {}), ...(options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}) });
57
- return "runtime" in vm ? { allow, vm: vm.runtime } : { allow: "none", reason: vm.reason };
58
- }
59
- /** Under `--faux` only: a module whose default export, given the data root, is the provider the tests' faux box comes
60
- * from in place of Docker. */
61
- export const FAUX_BOX_ENV = "AGENTRUN_SERVE_FAUX_BOX";
62
- /** The tests' faux box provider, from its module. */
63
- export const fauxBoxes = async (module, root) => (await import(pathToFileURL(module).href)).default(root);
@@ -19,7 +19,7 @@ export function waitingAsk(data) {
19
19
  const ok = typeof v.id === "string" && typeof tag === "string" && TAG.test(tag) && typeof v.instruction === "string" && typeof v.completion_condition === "string" && Number.isFinite(Date.parse(String(v.asked_at))) && Number.isFinite(Date.parse(String(v.expires_at)));
20
20
  return ok ? { id: v.id, tag, instruction: v.instruction, completion_condition: v.completion_condition, asked_at: v.asked_at, expires_at: v.expires_at } : undefined;
21
21
  }
22
- /** A valid `at` (ms): a finite epoch millisecond, as a Timeline phase row's time (pi-durable-agent's bound). */
22
+ /** A valid `at` (ms): a finite epoch millisecond, as a Timeline phase row's time. */
23
23
  const atOf = (value) => (typeof value === "number" && Number.isFinite(value) && Math.abs(value) <= 8.64e15 ? value : undefined);
24
24
  /** The ask an answered hand-over entry names, how it ended and when, or undefined when the entry is not one. */
25
25
  function answeredEntry(data) {
@@ -1,5 +1,49 @@
1
1
  import type { BrowserProvider } from "@parcha/pi-browser";
2
+ import { type ComputerProvider } from "@parcha/agentrun-computer";
2
3
  import type { ClaimBrowser } from "./workspace/resolve-computer.js";
3
- /** pi-browser's provider over the claim's browser `computer`. A session its provider says is gone (or not found) is gone;
4
- * any other failure to read it is thrown in its words. */
5
- export declare function claimBrowserProvider(computer: ClaimBrowser): BrowserProvider;
4
+ /** What the adapter opens every session with, beside custody's spec. */
5
+ export interface BrowserComputerOptions {
6
+ /** The run's saved sign-in: the vendor's object a session asking for the profile `name` opens on. */
7
+ readonly signIn?: {
8
+ readonly name: string;
9
+ readonly pointer: string;
10
+ };
11
+ /** A headless browser where the provider offers one. */
12
+ readonly headless?: boolean;
13
+ /** Where a server behind a browser gateway holds the sockets of Browserbase's connect hosts (BROWSERBASE_CONNECT_BASE_URL). */
14
+ readonly connectBaseUrl?: string;
15
+ readonly sleep?: (ms: number) => Promise<void>;
16
+ }
17
+ /** pi-browser's provider over `computer`, a browser computer the claim or the plane opened. */
18
+ export declare function claimBrowserProvider(computer: ClaimBrowser, options?: BrowserComputerOptions): BrowserProvider;
19
+ /** The plane's vendor as a computer provider of the registry, made with the run's tool keys by the registry's names
20
+ * (computer-keys.ts providerOptions): the same provider an agent's browser computer is, on the keys the tool plane
21
+ * resolved it by. */
22
+ export declare function planeComputer(vendor: string, env: NodeJS.ProcessEnv): Promise<ComputerProvider>;
23
+ /** The run's browser sessions of a lower claim epoch released, as a computer's are when a claim starts it (the janitor's
24
+ * releaseOlder): a runner that died after the vendor made a session and before its id was kept left one this claim's
25
+ * labels would never find. One that ended may have been saving to the run's sign-in, and this process holds no saver
26
+ * for it, so when any was ended the provider's settle time is waited out before the plane's browser opens a session. */
27
+ export declare function releaseOlderBrowsers(provider: ComputerProvider, run: {
28
+ readonly runId: string;
29
+ readonly epoch: number;
30
+ }, { signal, sleep }?: {
31
+ readonly signal?: AbortSignal;
32
+ readonly sleep?: (ms: number) => Promise<void>;
33
+ }): Promise<void>;
34
+ /** A Browserbase connect URL moved onto the credential proxy that fronts its sockets: only `*.browserbase.com` hosts, with
35
+ * the signing query kept. */
36
+ export declare function rewriteConnectUrl(connectUrl: string, connectBaseUrl: string | undefined): string;
37
+ /** A run's browser over `provider`, a browser computer provider (the plane's vendor, or a test's stand-in), as the claim
38
+ * opens an agent's browser computer: each session made under the run's labels (`run`, when the run holds a claim, so a
39
+ * sweep finds what it left), for at most the provider's longest lifetime. A provider of another kind is refused. */
40
+ export declare function planeBrowser(provider: ComputerProvider, run: {
41
+ readonly runId: string;
42
+ readonly epoch: number;
43
+ } | undefined): ClaimBrowser;
44
+ /** When the run's process lets the run go: closes the download sockets its browser's sessions hold, released or not (a
45
+ * runner that closes leaves a session to the next claim, whose attach opens its own). An open socket would keep the
46
+ * process from exiting. A socket still opening is closed once it opens. */
47
+ export declare function closeHeldSockets(computer: ClaimBrowser): Promise<void>;
48
+ /** Tests only: forgets every session's socket and saver this process holds. */
49
+ export declare function resetBrowserComputerHoldings(): void;