@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
@@ -1,5 +1,28 @@
1
- import { checkGpu, configurationOf, imagesOf } from "@parcha/agentrun-computer";
1
+ // The claim's resolver: an agent's computer setting {kind, provider, image?, gpu?}, in the server's mode, read against the computer
2
+ // module's kind registry (its setting kinds and provider entries), gives how to start the computer for the run, whether
3
+ // it mounts the run's folder, and which of the kernel's ports it fills; or a refusal in words that name the setting
4
+ // (Settings → Computers). The runner's harness start calls it at the claim, starts the computer, and hands it to
5
+ // runTools (run-tools.ts), which follows the mount decided here. Pure until start: the registry, the saved keys and the
6
+ // launch of a vendor's computer are passed in, so a new provider is one entry in the registry and changes nothing here.
7
+ //
8
+ // The run's folder is mounted only when the kind has files and exec AND the provider mounts the mode's folder: Mode 1's
9
+ // is a folder of this machine (a bind), Mode 2's is on Archil (an archil mount). A sandbox must mount it: Mode 1 refuses
10
+ // a sandbox that is not Docker's (only a bind reaches this machine), Mode 2 refuses Docker's (it cannot mount Archil). A
11
+ // desktop, a phone and a browser are allowed in both modes: a desktop mounts only where its provider mounts the mode's
12
+ // folder and it offers files and exec; a phone and a browser never do. A provider whose required keys are not all saved
13
+ // is refused here, before anything starts; start hands the provider its declared keys alone. A sandbox's GPUs are held
14
+ // to what its provider declares, with the mode's folder as their mount, in the computer package's checkGpu words (a GPU
15
+ // with an Archil mount is refused where the provider has not proven it), and go into the computer's spec.
16
+ //
17
+ // Where the run's shell is follows the mount (shellPlaceOf): in the computer that mounts the folder; with none, Archil's
18
+ // serverless exec in Mode 2 (bash only); in Mode 1 none at all, since the folder is one of this server's own and a
19
+ // command there would run on the server itself. runShellOf reads it off a setting before anything starts (the tool
20
+ // plane shows bash unavailable by it), and the claim's runTools takes the same rule over the computer it started.
21
+ import { hostToolDefs } from "@parcha/agentrun-kernel/kernel";
22
+ import { configurationOf, imagesOf } from "@parcha/agentrun-computer";
2
23
  import { noDockerWords } from "../docker-daemon.js";
24
+ import { gpuRefused } from "../gpu-words.js";
25
+ import { recordedClient } from "../computer-calls.js";
3
26
  /** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
4
27
  * key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
5
28
  export const providerKeys = (registry, keyOf) => async (provider) => {
@@ -31,8 +54,11 @@ export const noNetworkRefusal = (label, kind) => `This agent's computer is a ${l
31
54
  * claim launches it, and asks only once its launch fails (ClaimSide.daemon). Absent: not asked.
32
55
  *
33
56
  * `boxAllow`: this server's allow setting (box-settings.ts boxAllowOf). Under "none", a computer whose provider makes no
34
- * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked. */
35
- export async function computerReadiness(setting, mode, registry, keyOf, answers, boxAllow) {
57
+ * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked.
58
+ *
59
+ * `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
60
+ * hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
61
+ export async function computerReadiness(setting, mode, registry, keyOf, answers, boxAllow, hostWhy) {
36
62
  const resolved = await resolveComputer(setting, mode, registry, {
37
63
  keysOf: providerKeys(registry, keyOf),
38
64
  // A setting is given, so the Mode 1 default (the only asker) is never read; and nothing is launched.
@@ -50,6 +76,9 @@ export async function computerReadiness(setting, mode, registry, keyOf, answers,
50
76
  if (!said.up)
51
77
  return { refused: `This agent's computer is a ${entry.label} ${resolved.kind}, and this server cannot run it: ${said.reason.replace(/[.!?]+$/, "")}.`, box: entry.id };
52
78
  }
79
+ const host = entry ? hostWhy?.(entry.id) : undefined;
80
+ if (host)
81
+ return { refused: `This agent's computer is a ${entry.label} ${resolved.kind}, and this server cannot run it: ${host.replace(/[.!?]+$/, "")}.` };
53
82
  if (boxAllow === "none" && entry && needsNetwork(entry.network))
54
83
  return { refused: noNetworkRefusal(entry.label, resolved.kind) };
55
84
  return { ok: true };
@@ -114,6 +143,21 @@ export function runShellOf(setting, mode, registry) {
114
143
  return "none";
115
144
  return shellPlaceOf(mounts, mode);
116
145
  }
146
+ /** What a choice of computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note) and
147
+ * said by the save's refusal of a tool it leaves out. A computer that mounts the folder leaves nothing out. */
148
+ export const SHELL_NOTES = Object.freeze({
149
+ local: "No computer: bash runs in a fresh container on the folder's own storage; background commands need a computer.",
150
+ none: "No computer on this server: the agent gets the file tools only, no shell. Pick a computer to run commands.",
151
+ });
152
+ /** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
153
+ * second one: the file tools always, bash with a shell, the five background tools on a computer. */
154
+ export const hostToolsOf = (shell) => hostToolDefs({ maxExecS: 600, shell }).map((def) => def.name);
155
+ /** A computer choice as an agent's settings show it: where its runs have their shell (runShellOf), the host tools that
156
+ * gives, and what it leaves out, in words (none for a computer that mounts the folder). */
157
+ export function shellChoiceOf(setting, mode, registry) {
158
+ const shell = runShellOf(setting, mode, registry);
159
+ return { shell, host_tools: hostToolsOf(shell), ...(shell === "computer" ? {} : { shell_note: SHELL_NOTES[shell] }) };
160
+ }
117
161
  /** The server's default where an agent has no computer setting: in Mode 1 a sandbox on the first provider that binds a
118
162
  * folder of this machine and answers here (Docker), else none; in Mode 2 none. */
119
163
  async function defaultSetting(mode, registry, side) {
@@ -148,6 +192,9 @@ export async function resolveComputer(given, mode, registry, side) {
148
192
  // The configurations of the provider that serve the kind; none, and the registry says why, by its closest one.
149
193
  const serving = servingOf(registry, entry, kind);
150
194
  if (serving.length === 0) {
195
+ const own = registry.unservedWhy?.(entry, kind);
196
+ if (own !== undefined)
197
+ return { refused: `${own}, or pick ${pick}` };
151
198
  const why = entry.capabilities.map((one) => registry.servingRefusals(one, kind)).sort((a, b) => a.length - b.length)[0] ?? [];
152
199
  return { refused: `${entry.label} gives no ${kind} computer${why.length > 0 ? `: ${why.join("; ")}` : ""}. Pick ${pick}` };
153
200
  }
@@ -173,14 +220,24 @@ export async function resolveComputer(given, mode, registry, side) {
173
220
  return { refused: `Mode 2 keeps workspaces on Archil; a local Docker computer can't mount them. Pick a remote sandbox for this agent's computer in ${SETTINGS}, or no computer.` };
174
221
  return { refused: `A ${entry.label} sandbox can't mount the run's folder from Archil: pick another sandbox for this agent's computer in ${SETTINGS}.` };
175
222
  }
176
- // Its GPUs, a sandbox's alone: in checkGpu's words, against what the configuration the setting selected declares, with
177
- // the mode's folder as the mount it takes (a sandbox here always mounts it).
223
+ // Its GPUs, a sandbox's alone: in gpuRefused's words, against what the configuration the setting selected declares,
224
+ // with the mode's folder as the mount it takes (a sandbox here always mounts it). A GPU computer that can't mount the
225
+ // folder is told so, and what to use instead.
178
226
  const gpu = kind === "sandbox" && setting.gpu ? setting.gpu : undefined;
179
227
  if (gpu) {
180
- const [refusal] = checkGpu(gpu, configuration, { kind: mode === 1 ? "bind" : "archil" });
181
- if (refusal)
182
- return { refused: `A ${entry.label} sandbox can't have this agent's GPUs: ${refusal.message}. Change the GPUs or the provider for this agent's computer in ${SETTINGS}.` };
228
+ const refused = gpuRefused(gpu, configuration.gpu, { kind: mode === 1 ? "bind" : "archil" }, entry.label);
229
+ if (refused?.folder)
230
+ return { refused: refused.words };
231
+ if (refused)
232
+ return { refused: `A ${entry.label} sandbox can't have this agent's GPUs: ${refused.words}. Change the GPUs or the provider for this agent's computer in ${SETTINGS}.` };
183
233
  }
234
+ // The agent's own computer, kept between its runs: only where the configuration keeps one, and never one that mounts
235
+ // the run's folder (a later run would find an earlier run's folder in it).
236
+ const persistent = setting.persistent === true;
237
+ if (persistent && configuration.persistence === undefined)
238
+ return { refused: `A ${entry.label} ${kind} keeps no computer for an agent between runs (it declares no persistence): turn persistent off, or pick a computer that keeps one, for this agent's computer in ${SETTINGS}.` };
239
+ if (persistent && mounts)
240
+ return { refused: `A ${entry.label} ${kind} mounts each run's folder, so it can't be kept between runs: turn persistent off for this agent's computer in ${SETTINGS}.` };
184
241
  // Its keys: every required one saved, before anything starts; only declared names go to the provider.
185
242
  const saved = await side.keysOf(entry.id);
186
243
  const has = (name) => typeof saved[name] === "string" && saved[name] !== "";
@@ -201,7 +258,7 @@ export async function resolveComputer(given, mode, registry, side) {
201
258
  const mount = mounts ? await workspace.mountSpec() : undefined;
202
259
  let launched;
203
260
  try {
204
- launched = await side.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(signal ? { signal } : {}) });
261
+ launched = await side.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(persistent ? { persistent: true } : {}), ...(signal ? { signal } : {}) });
205
262
  }
206
263
  catch (error) {
207
264
  // A provider that binds a folder of this machine (Docker) whose daemon does not answer: the one wording.
@@ -221,20 +278,21 @@ export async function resolveComputer(given, mode, registry, side) {
221
278
  }
222
279
  /** The started computer as runTools takes it, or what it lacks, in words. */
223
280
  function runComputerOf(kind, launched, check) {
224
- const groups = launched.groups;
225
281
  // The run's browser tool opens a browser's sessions through its provider.
226
282
  if (kind === "browser")
227
283
  return launched.browser ? { kind, browser: launched.browser } : "it gave no CDP connection";
228
- const { client } = launched;
229
- if (!client)
284
+ const { hello } = launched;
285
+ if (!launched.client)
230
286
  return "it gave no computer protocol client";
287
+ // Each call the agent's tools make is recorded on the tool call's row (computer-calls.ts): the run's one client.
288
+ const client = recordedClient(launched.client);
231
289
  if (kind === "phone")
232
- return { kind, computer: { client }, groups };
290
+ return hello ? { kind, computer: { client }, hello } : "it gave no hello";
233
291
  if (check && !launched.readBack)
234
292
  return "it gave no read-back of its mount";
235
293
  const readBack = launched.readBack ? () => launched.readBack() : async () => ({ ok: false, error: { code: "unsupported", message: "nothing is mounted in this computer" } });
236
294
  const computer = { id: launched.id, client, readBack };
237
295
  if (kind === "sandbox")
238
296
  return check ? { kind, computer, check } : "a sandbox mounts the run's folder";
239
- return { kind, computer, groups, ...(check ? { check } : {}) };
297
+ return hello ? { kind, computer, hello, ...(check ? { check } : {}) } : "it gave no hello";
240
298
  }
@@ -0,0 +1,34 @@
1
+ import type { Settings } from "../store/index.js";
2
+ import type { LaunchDisk } from "../run-launch.js";
3
+ import type { ArchilControlOptions } from "./archil-mount-credential.js";
4
+ /** The disk a run uses, and whose it is: the launch's (a customer's) or its agent's. */
5
+ export interface RunDisk {
6
+ readonly diskId: string;
7
+ readonly kind: "launch" | "agent";
8
+ }
9
+ export interface RunDiskOptions {
10
+ /** The store's settings: the agent's stored disk and the server's id. */
11
+ readonly store: {
12
+ readonly settings: Pick<Settings, "get" | "put" | "putIfAbsent">;
13
+ };
14
+ readonly agentId: string;
15
+ /** The run, when the claim is a run's: the agent's disk it first resolves to is kept for it (a reopened run mounts that one). */
16
+ readonly runId?: string;
17
+ /** The disk the run's launch record names, when it names one. */
18
+ readonly launch?: LaunchDisk;
19
+ /** The control plane of the account key's region, with the key. */
20
+ readonly control: ArchilControlOptions;
21
+ readonly signal?: AbortSignal;
22
+ /** How long a disk just made may read `creating` before the run is refused (default 120 s). */
23
+ readonly availableMs?: number;
24
+ }
25
+ /** The words of the plan's disk limit, its number when Archil said it. */
26
+ export declare const diskLimitWords: (limit: number | undefined) => string;
27
+ /** Why disk `diskId`, named by a launch, can't hold a run here, in words naming the region; undefined when it can. A call
28
+ * that fails (Archil not reached, or refusing the key) throws its ArchilDiskError. */
29
+ export declare function launchDiskProblem(control: ArchilControlOptions, diskId: string, context?: {
30
+ readonly signal?: AbortSignal;
31
+ }): Promise<string | undefined>;
32
+ /** The run's disk: the launch's, checked again to be in the key's region; else the agent's, made now when it has none.
33
+ * Refused in words (ArchilClaimRefused) naming the disk or the region, never a key. */
34
+ export declare function runDiskOf(options: RunDiskOptions): Promise<RunDisk>;
@@ -0,0 +1,91 @@
1
+ // The disk a run keeps its folder on, in Archil mode: the one its launch names (a disk per customer, run-launch.ts
2
+ // archilDisk kind "launch"), else its agent's own. The claim resolves it before its mount credential is minted, so the
3
+ // token is minted, mounted, revoked and reclaimed on that disk alone, and Archil refuses it on any other.
4
+ // - A launch's disk is not agentrun's: it is read (GET /api/disks/{id}) to check it is in the account key's region, and
5
+ // never made, renamed or removed. The server reads it at the launch (a 422 before any run is made) and the claim
6
+ // again, for a disk removed in between; one in another region, or none of that id, is refused in words naming the
7
+ // region.
8
+ // - The agent's disk is stored on the agent (archil-settings.ts agentDiskOf). An agent with none yet has it made now, on
9
+ // its first run that uses it (never at the agent's creation: an agent whose runs all name a disk never has one), named
10
+ // agentrun-<server id>-i-<agent id> (diskNameOf), idempotent by that name. The plan's disk limit refuses the run in words.
11
+ import { agentDiskOf, diskNameOf, keepRunDisk, runDiskKept, serverIdOf, storeAgentDisk } from "../archil-settings.js";
12
+ import { ArchilClaimRefused } from "./archil-claim.js";
13
+ import { ArchilDiskLimit, availableDisk, ensureDisk, getDisk } from "./archil-disks.js";
14
+ /** The words of the plan's disk limit, its number when Archil said it. */
15
+ export const diskLimitWords = (limit) => limit === undefined ? "your Archil plan's disk limit is reached; upgrade or delete an agent" : `your Archil plan allows ${limit} disks; upgrade or delete an agent`;
16
+ /** Why disk `diskId`, named by a launch, can't hold a run here, in words naming the region; undefined when it can. A call
17
+ * that fails (Archil not reached, or refusing the key) throws its ArchilDiskError. */
18
+ export async function launchDiskProblem(control, diskId, context = {}) {
19
+ const region = control.region;
20
+ const disk = await getDisk(control, diskId, context);
21
+ if (disk === undefined)
22
+ return `Archil has no disk ${diskId} in region ${region}, the region of this server's Archil key: name a disk in ${region}.`;
23
+ if (disk.region !== "" && disk.region !== region)
24
+ return `The disk ${diskId} is in region ${disk.region}, and this server's Archil key is for region ${region}: name a disk in ${region}.`;
25
+ return undefined;
26
+ }
27
+ /** The run's disk: the launch's, checked again to be in the key's region; else the agent's, made now when it has none.
28
+ * Refused in words (ArchilClaimRefused) naming the disk or the region, never a key. */
29
+ export async function runDiskOf(options) {
30
+ const { launch, control, signal } = options;
31
+ const region = control.region;
32
+ if (launch?.kind === "launch") {
33
+ const problem = await launchDiskProblem(control, launch.diskId, signal ? { signal } : {}).catch((error) => {
34
+ throw new ArchilClaimRefused(`This run's Archil disk ${launch.diskId} could not be read: ${error.message}`, { cause: error });
35
+ });
36
+ if (problem !== undefined)
37
+ throw new ArchilClaimRefused(problem);
38
+ return { diskId: launch.diskId, kind: "launch" };
39
+ }
40
+ const stored = await agentDiskOf(options.store, options.agentId);
41
+ /** Waits for a pending disk to read available, then clears its pending mark (unless it was removed or replaced meanwhile). */
42
+ const ready = async (diskId) => {
43
+ await availableDisk(control, diskId, { ...(options.availableMs !== undefined ? { timeoutMs: options.availableMs } : {}), ...(signal ? { signal } : {}) });
44
+ const now = await agentDiskOf(options.store, options.agentId);
45
+ if (now?.diskId === diskId && !now.removing)
46
+ await storeAgentDisk(options.store, options.agentId, { diskId });
47
+ };
48
+ const readyReused = (diskId) => ready(diskId).catch((error) => {
49
+ throw new ArchilClaimRefused(`This agent's Archil disk ${diskId} is not ready in region ${region}: ${error.message}`, { cause: error });
50
+ });
51
+ // A launch that names no disk resolved to its agent's on its first claim, and that disk was kept for the run: a later
52
+ // claim of the same run (a reopened one) mounts it or is refused, never another disk.
53
+ const kept = launch === undefined && options.runId !== undefined ? await runDiskKept(options.store, options.runId) : undefined;
54
+ const bound = launch?.kind === "agent" ? launch.diskId : kept;
55
+ // The agent's disk as its launch recorded it is mounted only while it is still the agent's and not being removed: a
56
+ // run launched while DELETE /v2/agents/{id}/archil ran is refused, never started on a disk being deleted.
57
+ if (bound !== undefined) {
58
+ if (stored?.diskId !== bound || stored.removing)
59
+ throw new ArchilClaimRefused(`This run's Archil disk ${bound} was its agent's, and it ${stored?.diskId === bound ? "is being" : "has been"} removed: start a new run, and it gets the agent's new disk.`);
60
+ if (stored.pending)
61
+ await readyReused(bound);
62
+ return { diskId: bound, kind: "agent" };
63
+ }
64
+ const keep = async (diskId) => {
65
+ if (options.runId !== undefined)
66
+ await keepRunDisk(options.store, options.runId, diskId);
67
+ return { diskId, kind: "agent" };
68
+ };
69
+ if (stored?.removing)
70
+ throw new ArchilClaimRefused(`This agent's Archil disk ${stored.diskId} is being removed: start a new run once that is done, and it gets a new disk.`);
71
+ if (stored !== undefined) {
72
+ if (stored.pending)
73
+ await readyReused(stored.diskId);
74
+ return keep(stored.diskId);
75
+ }
76
+ const name = diskNameOf(await serverIdOf(options.store), options.agentId);
77
+ let id;
78
+ try {
79
+ id = (await ensureDisk(control, name, signal ? { signal } : {})).id;
80
+ // Stored before the wait, as pending, so a disk that never becomes available is still the agent's (DELETE
81
+ // /v2/agents/{id}/archil finds it, and the plan's slot it takes is never lost) and a claim that finds it waits.
82
+ await storeAgentDisk(options.store, options.agentId, { diskId: id, pending: true });
83
+ await ready(id);
84
+ }
85
+ catch (error) {
86
+ if (error instanceof ArchilDiskLimit)
87
+ throw new ArchilClaimRefused(`This agent's Archil disk can't be made: ${diskLimitWords(error.limit)}.`, { cause: error });
88
+ throw new ArchilClaimRefused(`This agent's Archil disk ${name} can't be made in region ${region}: ${error.message}`, { cause: error });
89
+ }
90
+ return keep(id);
91
+ }
@@ -1,8 +1,10 @@
1
- import type { Context } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
2
  import type { HostTool } from "@parcha/agentrun-kernel";
3
- import { type CapabilityKind, type Registry } from "@parcha/agentrun-kernel/kernel";
4
- import type { ComputerClient, Group } from "@parcha/agentrun-computer";
3
+ import { type CapabilityKind, type ComputerPort, type Executor, type Registry } from "@parcha/agentrun-kernel/kernel";
4
+ import type { ComputerClient, HelloResult } from "@parcha/agentrun-computer";
5
+ import { type Card } from "@parcha/agentrun-computer/surface";
5
6
  import type { AttachableComputer, MountCheck } from "./attach.js";
7
+ import { ScriptGuard } from "./computer-script.js";
6
8
  import { type PiAnswer, type PiExecutor } from "./executors.js";
7
9
  import { type Hands } from "./hands.js";
8
10
  import { type ClaimBrowser, type ShellPlace } from "./resolve-computer.js";
@@ -11,12 +13,13 @@ import type { Workspace } from "./workspace.js";
11
13
  * The run's computer, as runTools takes it, by its kind:
12
14
  * - sandbox: the run's folder is mounted in it, always; `check` is the mount check attach runs (the claim's epoch bound
13
15
  * in);
14
- * - desktop: a screen and input; the folder is attached only when its provider mounts it (`check` given) and it offers
15
- * files and exec;
16
- * - phone: a screen, touch and apps; never attached;
16
+ * - desktop: the computer's tools; the folder is attached only when its provider mounts it (`check` given) and it
17
+ * offers files and exec;
18
+ * - phone: the computer's tools; never attached;
17
19
  * - browser: what the run's browser tool drives it by (its CDP URL through its provider); no tools of the registry's,
18
20
  * never attached.
19
- * `groups`: what the computer offers (its hello's groups), which fill its kind's ports.
21
+ * `hello`: what a desktop or a phone said it is when the claim connected it; its groups say which of the computer's
22
+ * tools it has, and its surface is made from it.
20
23
  */
21
24
  export type RunComputer = {
22
25
  readonly kind: "sandbox";
@@ -25,22 +28,29 @@ export type RunComputer = {
25
28
  } | {
26
29
  readonly kind: "desktop";
27
30
  readonly computer: AttachableComputer;
28
- readonly groups: readonly Group[];
31
+ readonly hello: HelloResult;
29
32
  readonly check?: MountCheck;
30
33
  } | {
31
34
  readonly kind: "phone";
32
35
  readonly computer: {
33
36
  readonly client: ComputerClient;
34
37
  };
35
- readonly groups: readonly Group[];
38
+ readonly hello: HelloResult;
36
39
  } | {
37
40
  readonly kind: "browser";
38
41
  readonly browser: ClaimBrowser;
39
42
  };
40
- /** A desktop's or a phone's ports as a person's hold on the computer gives them back: each call made while the person
41
- * holds it waits for hand-back; a read then runs, an action then is refused (the take-over's own words). With them, the
42
- * agent's ask for the person (`handoff`, computer_request_handoff's port), through the same hold. */
43
- export type RunHold = (ports: Pick<Hands, "screen" | "input" | "phone">) => Pick<Hands, "screen" | "input" | "phone" | "handoff">;
43
+ /** A desktop's or a phone's port as a person's hold on the computer gives it back: each look or act made while the
44
+ * person holds it waits for hand-back; a look then runs, an act then is refused (the take-over's own words). With it,
45
+ * the agent's ask for the person (`handoff`, computer_request_handoff's port), through the same hold. */
46
+ export type RunHold = (ports: Pick<Hands, "computer">) => Pick<Hands, "computer" | "handoff">;
47
+ /** A desktop's or a phone's surface as a harness's own script runtime binds it (pi's code mode): its card, which the
48
+ * script prelude builds `computer` from, and the run's port, held by the person's take-over as the tools' is. */
49
+ export type ScriptComputer = {
50
+ readonly card: Card;
51
+ readonly port: ComputerPort; /** What the script's shell and files are held to (computer-script.ts ScriptGuard). */
52
+ readonly guard: ScriptGuard;
53
+ };
44
54
  /** The run's scratch in its own folder: bash's TMPDIR. */
45
55
  export declare const TMP_DIR = ".agentrun/tmp";
46
56
  /** What runHands binds for a run. */
@@ -52,8 +62,8 @@ export type RunHands = {
52
62
  readonly shell: ShellPlace;
53
63
  /** The computer's kinds whose tools the run gets, past files and a shell. */
54
64
  readonly kinds: readonly CapabilityKind[];
55
- /** The kinds' tools the computer does not offer (its groups lack them), not listed to the model. */
56
- readonly without: readonly string[];
65
+ /** What the computer offers (its groups): which of the computer's tools are listed to the model. */
66
+ readonly groups: readonly string[];
57
67
  readonly maxExecS: number;
58
68
  /** The name the model knows the run's folder by: /workspace in a computer, the folder's own path otherwise. */
59
69
  readonly cwd: string;
@@ -65,8 +75,11 @@ export type RunHands = {
65
75
  readonly read: PiExecutor;
66
76
  readonly write: PiExecutor;
67
77
  readonly edit: PiExecutor;
68
- readonly bash?: PiExecutor;
78
+ readonly bash?: PiExecutor; /** computer_script's run in serve's isolate, with a desktop or a phone. */
79
+ readonly computer_script?: Executor;
69
80
  };
81
+ /** A desktop's or a phone's surface for a harness's own script runtime; none for any other computer. */
82
+ readonly computer?: ScriptComputer;
70
83
  /** The run's end, after its background processes are ended and before the computer is let go: bash's full outputs
71
84
  * and its TMPDIR swept. */
72
85
  sweep(): Promise<void>;
@@ -123,14 +136,18 @@ export type RunTools = {
123
136
  readonly hands: Hands;
124
137
  /** Where the run's shell is (runHands' shell): its gate reads its defaults by it (tool-gate.ts defaultPermission). */
125
138
  readonly shell: ShellPlace;
126
- /** The tools the claimed computer brings by its kind, as its groups offer them: a desktop's (desktop_screen,
127
- * desktop_input, computer_request_handoff) or a phone's, by the kernel registry's own list. None with no computer, for
139
+ /** The tools the claimed computer brings by its kind, as its groups offer them: a desktop's or a phone's
140
+ * (computer_observe, computer_act, computer_screenshot, computer_script, computer_request_handoff), by the kernel
141
+ * registry's own list. None with no computer, for
128
142
  * a sandbox, or for a browser (its own binding lists its tools). An agent names its computer, never these tools
129
143
  * (definition.tools refuses them), so a run binds them beside what it was granted (withKindTools). */
130
144
  readonly kindTools: readonly string[];
131
145
  /** The registry's tools `names` names, as the kernel's HostTool an adapter's session takes, each call through the
132
146
  * run's gate decided before its intent, each answer kept in `results` (bindTools). */
133
147
  hostTools(names: readonly string[], results?: ToolResults): HostTool[];
148
+ /** A desktop's or a phone's surface for a harness's own script runtime (pi's code mode binds `computer` over it); none
149
+ * for any other computer. */
150
+ readonly computer?: ScriptComputer;
134
151
  /** The run's end, before the computer is let go: its background processes ended (TERM, then KILL 3 s later; none with
135
152
  * no computer), then bash's full outputs and TMPDIR swept. */
136
153
  end(): Promise<void>;
@@ -1,5 +1,7 @@
1
- import { capabilityToolDefs, createRegistry, endBackground } from "@parcha/agentrun-kernel/kernel";
2
- import { inputOf, phoneOf, screenOf } from "./computer-ports.js";
1
+ import { COMPUTER_TOOLS, createRegistry, endBackground } from "@parcha/agentrun-kernel/kernel";
2
+ import { createSurface } from "@parcha/agentrun-computer/surface";
3
+ import { portOf } from "./computer-ports.js";
4
+ import { computerScriptExecutor, ScriptGuard } from "./computer-script.js";
3
5
  import { answerText, piExecutor } from "./executors.js";
4
6
  import { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, shellEnv } from "./hands.js";
5
7
  import { policyEnv, policyPrelude } from "../bash-read-only.js";
@@ -11,28 +13,17 @@ import { shellPlaceOf } from "./resolve-computer.js";
11
13
  function mountedIn(computer) {
12
14
  if (computer?.kind === "sandbox")
13
15
  return computer;
14
- if (computer?.kind === "desktop" && computer.check && computer.groups.includes("files") && computer.groups.includes("exec"))
16
+ if (computer?.kind === "desktop" && computer.check && computer.hello.groups.includes("files") && computer.hello.groups.includes("exec"))
15
17
  return { computer: computer.computer, check: computer.check };
16
18
  return undefined;
17
19
  }
18
- /** The kind's ports, as the computer's groups offer them, the kinds whose tools the run gets (a desktop's with a screen
19
- * and input, a phone's with a screen and touch; a browser's none), and the kind's tools its groups do not offer: a
20
- * phone's tree without apps.ui_tree, its keys without input.keys (an iPhone's today). */
21
- function portsOf(computer) {
22
- if (computer?.kind === "desktop") {
23
- const { client } = computer.computer;
24
- const screen = computer.groups.includes("screen");
25
- const input = computer.groups.includes("input.pointer") || computer.groups.includes("input.keys");
26
- return screen && input ? { ports: { screen: screenOf(client), input: inputOf(client) }, kinds: ["desktop"], without: [] } : { ports: {}, kinds: [], without: [] };
27
- }
28
- if (computer?.kind === "phone") {
29
- if (!computer.groups.includes("screen") || !computer.groups.includes("input.touch"))
30
- return { ports: {}, kinds: [], without: [] };
31
- const tree = computer.groups.includes("apps.ui_tree");
32
- const keys = computer.groups.includes("input.keys");
33
- return { ports: { phone: phoneOf(computer.computer.client, { tree, keys }) }, kinds: ["phone"], without: [...(tree ? [] : ["phone_tree"]), ...(keys ? [] : ["phone_key"])] };
34
- }
35
- return { ports: {}, kinds: [], without: [] };
20
+ /** A desktop's or a phone's port, over its surface, the kind whose tools the run gets, its groups, and the script's
21
+ * executor for its card; none for any other computer. */
22
+ async function portsOf(computer, guard) {
23
+ if (computer?.kind !== "desktop" && computer?.kind !== "phone")
24
+ return { ports: {}, kinds: [], groups: [] };
25
+ const surface = createSurface(computer.computer.client, computer.hello);
26
+ return { ports: { computer: portOf(surface) }, kinds: [computer.kind], groups: surface.card.groups, script: computerScriptExecutor(surface.card, guard), card: surface.card };
36
27
  }
37
28
  /** The run's scratch in its own folder: bash's TMPDIR. */
38
29
  export const TMP_DIR = ".agentrun/tmp";
@@ -64,9 +55,9 @@ export async function runHands(workspace, computer, options) {
64
55
  const tools = Object.fromEntries([...fileTools(), bashTool()].map((tool) => [tool.name, tool]));
65
56
  const read = mounted === undefined ? tools.read : readAnywhereInComputer(tools.read, attached, names, env);
66
57
  const executor = (tool) => piExecutor(tool, fileEnv, options.context);
67
- const own = portsOf(computer);
68
- const held = options.hold !== undefined && (computer?.kind === "desktop" || computer?.kind === "phone") && own.kinds.length > 0;
69
- const { ports, kinds, without } = held ? { ...own, ports: options.hold(own.ports) } : own;
58
+ const guard = new ScriptGuard({ env: policyEnv(options.bashPolicy), prelude });
59
+ const own = await portsOf(computer, guard);
60
+ const { ports, kinds, groups, script, card } = options.hold !== undefined && own.ports.computer ? { ...own, ports: options.hold(own.ports) } : own;
70
61
  return {
71
62
  workspace: attached,
72
63
  // The computer's processes, for the five background tools: the attached Workspace's own; none when the folder is not
@@ -74,11 +65,12 @@ export async function runHands(workspace, computer, options) {
74
65
  hands: { ...handsOf(attached, { maxExecS, env, ...(prelude ? { prelude } : {}), ...network, ...(mounted === undefined ? {} : { processes: attached.process }) }), ...ports },
75
66
  shell,
76
67
  kinds,
77
- without,
68
+ groups,
78
69
  maxExecS,
79
70
  cwd,
80
71
  names,
81
- executors: { read: executor(read), write: executor(tools.write), edit: executor(tools.edit), ...(shell === "none" ? {} : { bash: executor(tools.bash) }) },
72
+ executors: { read: executor(read), write: executor(tools.write), edit: executor(tools.edit), ...(shell === "none" ? {} : { bash: executor(tools.bash) }), ...(script ? { computer_script: script } : {}) },
73
+ ...(card && ports.computer ? { computer: { card, port: ports.computer, guard } } : {}),
82
74
  async sweep() {
83
75
  // Through the run's own Workspace, not the computer's: the sweep holds whether or not the computer still answers.
84
76
  for (const dir of [OUTPUT_DIR, TMP_DIR])
@@ -122,7 +114,9 @@ export function bindTools(run, registry, names, options = {}) {
122
114
  const isError = given.isError === true || given.error !== undefined;
123
115
  const answer = { text: isError || SAYS_PATH.has(name) ? workspaceRelative(said, works) : said, isError };
124
116
  options.results?.set(callId, answer);
125
- return given.images?.length ? { ...answer, images: given.images } : answer;
117
+ // A computer tool's value beside its words: what a script's nested call reads (Codex's code mode), and an MCP
118
+ // client's structuredContent.
119
+ return { ...answer, ...(given.images?.length ? { images: given.images } : {}), ...(given.structured !== undefined && !isError ? { structured: given.structured } : {}) };
126
120
  },
127
121
  }];
128
122
  });
@@ -138,8 +132,8 @@ export function bindTools(run, registry, names, options = {}) {
138
132
  */
139
133
  export async function runTools(workspace, computer, options) {
140
134
  const run = await runHands(workspace, computer, options);
141
- const registry = createRegistry({ maxExecS: run.maxExecS, shell: run.shell, kinds: run.kinds, without: run.without, executors: run.executors });
142
- const brought = new Set(run.kinds.flatMap((kind) => capabilityToolDefs(kind).map((def) => def.name)));
135
+ const registry = createRegistry({ maxExecS: run.maxExecS, shell: run.shell, kinds: run.kinds, groups: run.groups, executors: run.executors });
136
+ const brought = new Set(COMPUTER_TOOLS);
143
137
  return {
144
138
  workspace: run.workspace,
145
139
  registry,
@@ -147,6 +141,7 @@ export async function runTools(workspace, computer, options) {
147
141
  shell: run.shell,
148
142
  kindTools: registry.list().map((def) => def.name).filter((name) => brought.has(name)),
149
143
  hostTools: (names, results) => bindTools(run, registry, names, results ? { results } : {}),
144
+ ...(run.computer ? { computer: run.computer } : {}),
150
145
  async end() {
151
146
  await endBackground(run.hands);
152
147
  await run.sweep();
@@ -1,4 +1,4 @@
1
- import type { Store } from "../store/index.js";
1
+ import { type Store } from "../store/index.js";
2
2
  import type { KeyEnv } from "../key-meta.js";
3
3
  import { type ArchilDisk, type ArchilDiskOptions } from "./archil-disk.js";
4
4
  import { type Workspace } from "./workspace.js";
@@ -11,7 +11,8 @@ export interface ServerRunWorkspaceOptions {
11
11
  readonly sealKey: Buffer | undefined;
12
12
  /** Makes the Archil disk (default archilDisk): a test's fake. */
13
13
  readonly makeDisk?: (options: ArchilDiskOptions) => ArchilDisk;
14
- /** The server's environment: an ARCHIL_API_KEY there is the account key, over a saved one. */
14
+ /** The server's environment: an ARCHIL_API_KEY there is the account key, over a saved one, and the Archil settings
15
+ * there (ARCHIL_SETTINGS_ENV) the region and S3 URL, over the saved row. */
15
16
  readonly env?: KeyEnv;
16
17
  }
17
18
  /** `workspace` with its reads only: read, list, stat and grep pass through; everything else is refused. */
@@ -1,13 +1,16 @@
1
1
  // The server's read-only view of a run's folder: what the server reads a run's files through (its file routes), with no
2
2
  // runner claim. Mode 1: the run's local folder (runFolder). Mode 2 (the server's Archil settings present): the run's
3
- // folder on the server's Archil disk (runKey), its account key by the one resolver (archil-key.ts: the server's
3
+ // folder on the run's Archil disk (runKey; the disk its launch record names, else its agent's), its account key by the
4
+ // one resolver (archil-key.ts: the server's
4
5
  // ARCHIL_API_KEY, else the sealed row), with no claim around it: no exec, no spill sweep, no mount credential, no mount.
5
6
  //
6
7
  // Read-only: read, list, stat and grep work as the run's own Workspace answers them (a link is never followed). Every
7
8
  // call that would change the folder, run something in it, or put it in a computer is refused with REFUSED in plain words:
8
9
  // only the run's runner writes its folder.
9
10
  import { lstat } from "node:fs/promises";
10
- import { loadArchilSettings } from "../archil-settings.js";
11
+ import { agentDiskOf, loadArchilSettings } from "../archil-settings.js";
12
+ import { readLaunchBody } from "../run-launch.js";
13
+ import { StoreLaunchMissing } from "../store/index.js";
11
14
  import { ArchilClaimRefused } from "./archil-claim.js";
12
15
  import { archilDisk } from "./archil-disk.js";
13
16
  import { archilApiKey } from "./archil-key.js";
@@ -38,6 +41,11 @@ export function readOnlyWorkspace(workspace) {
38
41
  attach: refuse,
39
42
  };
40
43
  }
44
+ /** The disk run `runId` keeps its folder on: its launch record's, else its agent's, or undefined when it has none yet. */
45
+ async function runDiskIdOf(store, runId, agentId) {
46
+ const named = await store.runs.launch(runId).then((row) => readLaunchBody(row.body)?.archilDisk, (error) => (error instanceof StoreLaunchMissing ? undefined : Promise.reject(error)));
47
+ return named?.diskId ?? (await agentDiskOf(store, agentId))?.diskId;
48
+ }
41
49
  /**
42
50
  * Run `runId`'s folder as the server reads it, read-only; null when there is no such run, or its folder is not there yet.
43
51
  * In Mode 2, an Archil account key that is not saved, or a server with no seal key, is UNAVAILABLE in words that name
@@ -47,7 +55,12 @@ export async function serverRunWorkspace(store, runId, options) {
47
55
  const run = await store.runs.get(runId);
48
56
  if (run === undefined)
49
57
  return null;
50
- const settings = await loadArchilSettings(store);
58
+ const settings = await loadArchilSettings(store, options.env);
59
+ // The run's disk (Mode 2): the one its launch record names, else its agent's; none yet when its agent has no disk (its
60
+ // first run was not claimed), so it has no folder.
61
+ const diskId = settings === undefined ? undefined : await runDiskIdOf(store, runId, run.agentId);
62
+ if (settings !== undefined && diskId === undefined)
63
+ return null;
51
64
  let workspace;
52
65
  if (settings === undefined) {
53
66
  const folder = runFolder(options.data, run.agentId, runId);
@@ -66,7 +79,7 @@ export async function serverRunWorkspace(store, runId, options) {
66
79
  let disk;
67
80
  try {
68
81
  const { value } = await archilApiKey({ env: options.env ?? {}, keys: store.sealedKeys, sealKey: options.sealKey });
69
- disk = (options.makeDisk ?? archilDisk)({ disk: settings.diskId, region: settings.region, s3BaseUrl: settings.s3Url, key: () => value });
82
+ disk = (options.makeDisk ?? archilDisk)({ disk: diskId, region: settings.region, s3BaseUrl: settings.s3Url, key: () => value });
70
83
  }
71
84
  catch (error) {
72
85
  if (error instanceof ArchilClaimRefused)
package/dist/workspace.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // A run's work/ as this server reads it (the console's file view and listing, a skill's SKILL.md), and an agent's home as
2
- // it reads and writes it: never through a link. Each read and write goes through pi-durable-disk's confinement, which
2
+ // it reads and writes it: never through a link. Each read and write goes through the confinement (confine.ts), which
3
3
  // walks down from the root on held directory handles without following, so a component swapped for a link between a
4
4
  // check and the open is refused, not followed. On top of it: the path must be the root joined with its own names (a link
5
5
  // anywhere on the way, even one pointing inside the root, is refused), only regular files and directories are read, and a