@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.36

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 (450) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +339 -179
  3. package/dist/adapters.d.ts +15 -2
  4. package/dist/adapters.js +34 -2
  5. package/dist/agent-rows.d.ts +3 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +25 -5
  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 +90 -8
  13. package/dist/archil-settings.js +150 -14
  14. package/dist/attach-images.d.ts +15 -0
  15. package/dist/attach-images.js +59 -0
  16. package/dist/background.d.ts +0 -6
  17. package/dist/background.js +0 -28
  18. package/dist/bash-read-only.d.ts +13 -0
  19. package/dist/bash-read-only.js +77 -0
  20. package/dist/box-image.d.ts +1 -97
  21. package/dist/box-image.js +4 -284
  22. package/dist/box-paths.d.ts +2 -7
  23. package/dist/box-paths.js +7 -13
  24. package/dist/box-settings.d.ts +0 -11
  25. package/dist/box-settings.js +4 -29
  26. package/dist/browser-commands.js +1 -1
  27. package/dist/browser-computer.d.ts +47 -3
  28. package/dist/browser-computer.js +286 -18
  29. package/dist/browser-cost.d.ts +2 -2
  30. package/dist/browser-cost.js +6 -4
  31. package/dist/browser-person.d.ts +19 -2
  32. package/dist/browser-person.js +55 -6
  33. package/dist/browser-wait-ended.d.ts +23 -0
  34. package/dist/browser-wait-ended.js +42 -0
  35. package/dist/cap.d.ts +19 -44
  36. package/dist/cap.js +31 -77
  37. package/dist/cli.js +36 -27
  38. package/dist/computer-keys.d.ts +20 -10
  39. package/dist/computer-keys.js +36 -57
  40. package/dist/computer-routes.d.ts +1 -4
  41. package/dist/computer-routes.js +3 -5
  42. package/dist/computer-setting.d.ts +8 -5
  43. package/dist/computer-setting.js +91 -26
  44. package/dist/computer-view.d.ts +11 -2
  45. package/dist/computer-view.js +2 -1
  46. package/dist/computers.d.ts +54 -8
  47. package/dist/computers.js +101 -22
  48. package/dist/console/assets/index-BI4Byidu.js +550 -0
  49. package/dist/console/assets/index-C19gUF2n.css +1 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/content-filter.d.ts +7 -0
  52. package/dist/content-filter.js +23 -0
  53. package/dist/decision-cap.d.ts +7 -29
  54. package/dist/decision-cap.js +3 -94
  55. package/dist/docker-daemon.d.ts +2 -2
  56. package/dist/docker-daemon.js +2 -2
  57. package/dist/errors.d.ts +1 -0
  58. package/dist/errors.js +8 -5
  59. package/dist/explain.js +3 -1
  60. package/dist/faux-computers.js +4 -0
  61. package/dist/files.d.ts +1 -9
  62. package/dist/files.js +1 -9
  63. package/dist/github-connection.js +25 -7
  64. package/dist/github-faux.d.ts +26 -0
  65. package/dist/github-faux.js +76 -0
  66. package/dist/github.d.ts +28 -4
  67. package/dist/github.js +46 -10
  68. package/dist/gpu-words.d.ts +14 -0
  69. package/dist/gpu-words.js +21 -0
  70. package/dist/graph-served.d.ts +5 -3
  71. package/dist/graph-served.js +14 -6
  72. package/dist/graph-view.d.ts +2 -0
  73. package/dist/graph-view.js +29 -2
  74. package/dist/handed-values.d.ts +1 -1
  75. package/dist/handed-values.js +1 -1
  76. package/dist/harness-install.d.ts +60 -3
  77. package/dist/harness-install.js +322 -34
  78. package/dist/harness-opencode/harness.js +0 -1
  79. package/dist/harness-opencode/host/policy.js +2 -2
  80. package/dist/harness.js +1 -1
  81. package/dist/host-tools.d.ts +8 -9
  82. package/dist/host-tools.js +7 -7
  83. package/dist/index.d.ts +2 -3
  84. package/dist/index.js +2 -2
  85. package/dist/key-refusal.d.ts +1 -1
  86. package/dist/key-refusal.js +2 -2
  87. package/dist/learn/check.d.ts +10 -2
  88. package/dist/learn/check.js +126 -8
  89. package/dist/learn/commit.d.ts +40 -6
  90. package/dist/learn/commit.js +164 -20
  91. package/dist/learn/folder.d.ts +11 -3
  92. package/dist/learn/folder.js +40 -16
  93. package/dist/learn/grade.d.ts +22 -2
  94. package/dist/learn/grade.js +127 -19
  95. package/dist/learn/index.d.ts +2 -2
  96. package/dist/learn/index.js +2 -2
  97. package/dist/learn/learning.sh +11 -13
  98. package/dist/learn/notes.d.ts +17 -3
  99. package/dist/learn/notes.js +19 -6
  100. package/dist/learn/reflect.d.ts +5 -2
  101. package/dist/learn/reflect.js +48 -32
  102. package/dist/learn/skills.d.ts +52 -5
  103. package/dist/learn/skills.js +104 -21
  104. package/dist/learned-nodes.d.ts +18 -0
  105. package/dist/learned-nodes.js +8 -0
  106. package/dist/learned-workflow.d.ts +27 -13
  107. package/dist/learned-workflow.js +110 -38
  108. package/dist/learning-cost.d.ts +79 -0
  109. package/dist/learning-cost.js +69 -0
  110. package/dist/learning-routes.d.ts +48 -2
  111. package/dist/learning-routes.js +99 -28
  112. package/dist/learning-run.d.ts +7 -5
  113. package/dist/learning-run.js +9 -6
  114. package/dist/learning-words.d.ts +3 -0
  115. package/dist/learning-words.js +6 -2
  116. package/dist/learning.d.ts +13 -28
  117. package/dist/learning.js +4 -18
  118. package/dist/llm.d.ts +4 -1
  119. package/dist/llm.js +4 -2
  120. package/dist/mcp-gateway.d.ts +6 -0
  121. package/dist/mcp-gateway.js +11 -1
  122. package/dist/mcp-probe.d.ts +8 -1
  123. package/dist/mcp-probe.js +62 -20
  124. package/dist/mcp-secret-writes.js +4 -0
  125. package/dist/mcp-servers-store.d.ts +12 -12
  126. package/dist/mcp-servers-store.js +8 -3
  127. package/dist/model.d.ts +8 -5
  128. package/dist/model.js +14 -6
  129. package/dist/openapi.d.ts +2 -0
  130. package/dist/openapi.js +236 -55
  131. package/dist/owner.d.ts +0 -1
  132. package/dist/owner.js +0 -2
  133. package/dist/pause.d.ts +2 -19
  134. package/dist/pause.js +5 -74
  135. package/dist/place-offers.d.ts +97 -0
  136. package/dist/place-offers.js +206 -0
  137. package/dist/place.d.ts +9 -13
  138. package/dist/place.js +22 -32
  139. package/dist/port-models.d.ts +12 -4
  140. package/dist/port-models.js +31 -9
  141. package/dist/print.d.ts +1 -8
  142. package/dist/print.js +1 -14
  143. package/dist/propose.d.ts +3 -0
  144. package/dist/propose.js +25 -19
  145. package/dist/run-cut.d.ts +5 -0
  146. package/dist/run-cut.js +19 -0
  147. package/dist/run-db.js +3 -3
  148. package/dist/run-launch.d.ts +18 -3
  149. package/dist/run-launch.js +11 -5
  150. package/dist/run-learning-served.d.ts +12 -1
  151. package/dist/run-manifest.d.ts +2 -2
  152. package/dist/run-manifest.js +2 -2
  153. package/dist/run-reads-over-store.d.ts +4 -2
  154. package/dist/run-reads-over-store.js +10 -8
  155. package/dist/run-secrets.js +3 -3
  156. package/dist/run-timeline-served.js +60 -38
  157. package/dist/run-view.d.ts +35 -16
  158. package/dist/run-view.js +64 -35
  159. package/dist/runnable.d.ts +6 -3
  160. package/dist/runnable.js +20 -4
  161. package/dist/runner/adapter-loop.d.ts +46 -5
  162. package/dist/runner/adapter-loop.js +381 -56
  163. package/dist/runner/adapter-run-spec.d.ts +46 -4
  164. package/dist/runner/adapter-run-spec.js +200 -45
  165. package/dist/runner/adapters/pi.d.ts +39 -3
  166. package/dist/runner/adapters/pi.js +124 -29
  167. package/dist/runner/beside.d.ts +8 -0
  168. package/dist/runner/beside.js +24 -2
  169. package/dist/runner/claim-secrets.d.ts +6 -0
  170. package/dist/runner/claim-secrets.js +15 -1
  171. package/dist/runner/cli-run-spec.d.ts +10 -0
  172. package/dist/runner/cli-run-spec.js +207 -64
  173. package/dist/runner/commands.d.ts +5 -1
  174. package/dist/runner/commands.js +3 -3
  175. package/dist/runner/conformance/harness.d.ts +1 -1
  176. package/dist/runner/conformance/harness.js +13 -10
  177. package/dist/runner/github-app.d.ts +7 -2
  178. package/dist/runner/github-app.js +46 -15
  179. package/dist/runner/harness-loops.d.ts +6 -1
  180. package/dist/runner/harness-loops.js +24 -1
  181. package/dist/runner/journal-kinds.d.ts +53 -7
  182. package/dist/runner/journal-kinds.js +29 -1
  183. package/dist/runner/learning-end.d.ts +15 -0
  184. package/dist/runner/learning-end.js +113 -20
  185. package/dist/runner/learning-factory.js +6 -2
  186. package/dist/runner/learning-loop.d.ts +75 -1
  187. package/dist/runner/learning-loop.js +215 -22
  188. package/dist/runner/learning-seed.d.ts +8 -0
  189. package/dist/runner/learning-seed.js +7 -1
  190. package/dist/runner/loop-contract.d.ts +12 -0
  191. package/dist/runner/loop-contract.js +6 -0
  192. package/dist/runner/loop.d.ts +5 -1
  193. package/dist/runner/loop.js +20 -0
  194. package/dist/runner/main.d.ts +9 -4
  195. package/dist/runner/main.js +38 -13
  196. package/dist/runner/mcp-claim.d.ts +7 -0
  197. package/dist/runner/mcp-claim.js +35 -2
  198. package/dist/runner/mcp-github.d.ts +15 -4
  199. package/dist/runner/mcp-github.js +55 -11
  200. package/dist/runner/mcp-run.d.ts +2 -0
  201. package/dist/runner/mcp-run.js +2 -0
  202. package/dist/runner/metrics.d.ts +18 -1
  203. package/dist/runner/metrics.js +81 -1
  204. package/dist/runner/model-route.d.ts +6 -0
  205. package/dist/runner/model-route.js +5 -2
  206. package/dist/runner/pr-checkout.d.ts +59 -0
  207. package/dist/runner/pr-checkout.js +176 -0
  208. package/dist/runner/reflect-hook.d.ts +1 -0
  209. package/dist/runner/reflect-hook.js +3 -3
  210. package/dist/runner/runner.js +136 -19
  211. package/dist/runner/spec-holds.d.ts +13 -3
  212. package/dist/runner/spec-holds.js +13 -10
  213. package/dist/runner/store-port.d.ts +4 -1
  214. package/dist/runner/store-secrets.js +17 -1
  215. package/dist/runner/subagent.d.ts +44 -0
  216. package/dist/runner/subagent.js +188 -0
  217. package/dist/runner/workflow-host.d.ts +25 -4
  218. package/dist/runner/workflow-host.js +26 -4
  219. package/dist/runner/workflow-loop.d.ts +9 -3
  220. package/dist/runner/workflow-loop.js +17 -10
  221. package/dist/runner/workflow-spec.d.ts +28 -13
  222. package/dist/runner/workflow-spec.js +247 -102
  223. package/dist/runs-over-store.d.ts +18 -7
  224. package/dist/runs-over-store.js +149 -31
  225. package/dist/seal-key.d.ts +0 -2
  226. package/dist/seal-key.js +0 -2
  227. package/dist/sealing.js +1 -2
  228. package/dist/secret-cut.d.ts +1 -1
  229. package/dist/secret-cut.js +1 -1
  230. package/dist/server-lock.js +4 -5
  231. package/dist/server.d.ts +49 -63
  232. package/dist/server.js +429 -230
  233. package/dist/stop-signals.d.ts +4 -2
  234. package/dist/stop-signals.js +5 -3
  235. package/dist/store/agent-body.d.ts +14 -3
  236. package/dist/store/agent-body.js +22 -8
  237. package/dist/store/deadline.d.ts +18 -0
  238. package/dist/store/deadline.js +49 -0
  239. package/dist/store/index.d.ts +3 -3
  240. package/dist/store/index.js +2 -2
  241. package/dist/store/journal/storage.js +2 -1
  242. package/dist/store/postgres/connection.d.ts +4 -0
  243. package/dist/store/postgres/connection.js +64 -13
  244. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  245. package/dist/store/schema.d.ts +2 -1
  246. package/dist/store/schema.js +11 -8
  247. package/dist/store/seal.d.ts +13 -0
  248. package/dist/store/seal.js +19 -0
  249. package/dist/store/sqlite/connection.d.ts +5 -0
  250. package/dist/store/sqlite/connection.js +88 -82
  251. package/dist/store/sqlite/run-patch.d.ts +18 -2
  252. package/dist/store/sqlite/run-patch.js +31 -2
  253. package/dist/store/sqlite/store.js +65 -11
  254. package/dist/store/store.d.ts +62 -12
  255. package/dist/store/store.js +22 -1
  256. package/dist/store-reads/analytics.js +3 -2
  257. package/dist/store-reads/cap.d.ts +1 -3
  258. package/dist/store-reads/cap.js +8 -6
  259. package/dist/store-reads/decisions.d.ts +2 -2
  260. package/dist/store-reads/decisions.js +3 -6
  261. package/dist/store-reads/journal.js +83 -15
  262. package/dist/store-reads/learning.d.ts +73 -3
  263. package/dist/store-reads/learning.js +232 -9
  264. package/dist/store-reads/runs.d.ts +6 -4
  265. package/dist/store-reads/runs.js +17 -10
  266. package/dist/store-reads/stats.js +5 -1
  267. package/dist/store-view.d.ts +15 -1
  268. package/dist/store-view.js +88 -29
  269. package/dist/template-eval.js +2 -1
  270. package/dist/templates.d.ts +73 -4
  271. package/dist/templates.js +113 -23
  272. package/dist/timeline/timeline.d.ts +11 -1
  273. package/dist/timeline/timeline.js +19 -4
  274. package/dist/tool-blurbs.js +1 -0
  275. package/dist/tool-budget.d.ts +26 -0
  276. package/dist/tool-budget.js +56 -0
  277. package/dist/tool-gate.d.ts +13 -3
  278. package/dist/tool-gate.js +15 -7
  279. package/dist/tool-plane.d.ts +42 -29
  280. package/dist/tool-plane.js +64 -27
  281. package/dist/tools.d.ts +53 -39
  282. package/dist/tools.js +174 -79
  283. package/dist/trigger-signatures.d.ts +1 -0
  284. package/dist/trigger-signatures.js +3 -1
  285. package/dist/triggers.d.ts +3 -3
  286. package/dist/triggers.js +2 -2
  287. package/dist/turn-end.d.ts +0 -3
  288. package/dist/turn-end.js +0 -3
  289. package/dist/uploads.d.ts +28 -5
  290. package/dist/uploads.js +82 -9
  291. package/dist/usage-lines.d.ts +1 -1
  292. package/dist/usage.d.ts +1 -47
  293. package/dist/usage.js +3 -82
  294. package/dist/validate.d.ts +8 -0
  295. package/dist/validate.js +40 -3
  296. package/dist/webhooks.d.ts +2 -1
  297. package/dist/webhooks.js +5 -2
  298. package/dist/workflow/decision-recovery.d.ts +23 -0
  299. package/dist/workflow/decision-recovery.js +80 -0
  300. package/dist/workflow/decisions.d.ts +134 -0
  301. package/dist/workflow/decisions.js +46 -0
  302. package/dist/workflow/host-session.d.ts +5 -0
  303. package/dist/workflow/host-session.js +85 -0
  304. package/dist/workflow/host-tools.d.ts +3 -0
  305. package/dist/workflow/host-tools.js +3 -0
  306. package/dist/workflow/node-runner.d.ts +112 -0
  307. package/dist/workflow/node-runner.js +270 -0
  308. package/dist/workflow/node.d.ts +88 -0
  309. package/dist/workflow/node.js +99 -0
  310. package/dist/workflow/operator-error.d.ts +4 -0
  311. package/dist/workflow/operator-error.js +4 -0
  312. package/dist/workflow/pi-versions.d.ts +9 -0
  313. package/dist/workflow/pi-versions.js +8 -0
  314. package/dist/workflow/readers.d.ts +36 -0
  315. package/dist/workflow/readers.js +145 -0
  316. package/dist/workflow/record-file.d.ts +10 -0
  317. package/dist/workflow/record-file.js +56 -0
  318. package/dist/workflow/record-tool.d.ts +76 -0
  319. package/dist/workflow/record-tool.js +126 -0
  320. package/dist/workflow/record.d.ts +151 -0
  321. package/dist/workflow/record.js +401 -0
  322. package/dist/workflow/run-error.d.ts +16 -0
  323. package/dist/workflow/run-error.js +26 -0
  324. package/dist/workflow/runner.d.ts +6 -0
  325. package/dist/workflow/runner.js +240 -0
  326. package/dist/workflow/store.d.ts +23 -0
  327. package/dist/workflow/store.js +242 -0
  328. package/dist/workflow/task.d.ts +133 -0
  329. package/dist/workflow/task.js +411 -0
  330. package/dist/workflow/thinking.d.ts +3 -0
  331. package/dist/workflow/thinking.js +7 -0
  332. package/dist/workflow/tool-context.d.ts +21 -0
  333. package/dist/workflow/tool-context.js +13 -0
  334. package/dist/workflow/types.d.ts +126 -0
  335. package/dist/workflow/types.js +1 -0
  336. package/dist/workflow/wal.d.ts +11 -0
  337. package/dist/workflow/wal.js +106 -0
  338. package/dist/workflow-run.d.ts +1 -1
  339. package/dist/workspace/agent-computer.d.ts +137 -0
  340. package/dist/workspace/agent-computer.js +292 -0
  341. package/dist/workspace/archil-claim.d.ts +13 -2
  342. package/dist/workspace/archil-claim.js +22 -13
  343. package/dist/workspace/archil-disk.d.ts +10 -1
  344. package/dist/workspace/archil-disk.js +4 -0
  345. package/dist/workspace/archil-disks.d.ts +49 -0
  346. package/dist/workspace/archil-disks.js +185 -0
  347. package/dist/workspace/archil-exec.d.ts +12 -2
  348. package/dist/workspace/archil-exec.js +18 -3
  349. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  350. package/dist/workspace/archil-mount-credential.js +13 -4
  351. package/dist/workspace/archil.d.ts +2 -2
  352. package/dist/workspace/archil.js +25 -5
  353. package/dist/workspace/attach.js +2 -0
  354. package/dist/workspace/computer-deps.d.ts +18 -11
  355. package/dist/workspace/computer-deps.js +64 -40
  356. package/dist/workspace/computer-for-claim.d.ts +47 -9
  357. package/dist/workspace/computer-for-claim.js +236 -24
  358. package/dist/workspace/computer-janitor.d.ts +3 -2
  359. package/dist/workspace/computer-janitor.js +43 -9
  360. package/dist/workspace/computer-ledger.d.ts +3 -8
  361. package/dist/workspace/computer-ledger.js +7 -3
  362. package/dist/workspace/computer-providers.d.ts +5 -3
  363. package/dist/workspace/computer-providers.js +11 -9
  364. package/dist/workspace/hands.d.ts +5 -2
  365. package/dist/workspace/hands.js +4 -3
  366. package/dist/workspace/index.d.ts +5 -4
  367. package/dist/workspace/index.js +2 -1
  368. package/dist/workspace/local.d.ts +3 -0
  369. package/dist/workspace/local.js +9 -0
  370. package/dist/workspace/paths.js +3 -2
  371. package/dist/workspace/pi-env.d.ts +4 -0
  372. package/dist/workspace/pi-env.js +3 -2
  373. package/dist/workspace/resolve-computer.d.ts +48 -12
  374. package/dist/workspace/resolve-computer.js +88 -19
  375. package/dist/workspace/run-disk.d.ts +34 -0
  376. package/dist/workspace/run-disk.js +91 -0
  377. package/dist/workspace/run-tools.d.ts +6 -4
  378. package/dist/workspace/run-tools.js +17 -9
  379. package/dist/workspace/server-run-workspace.d.ts +3 -2
  380. package/dist/workspace/server-run-workspace.js +17 -4
  381. package/dist/workspace/workspace.d.ts +5 -0
  382. package/dist/workspace.d.ts +0 -3
  383. package/dist/workspace.js +2 -15
  384. package/package.json +11 -16
  385. package/skills/agentrun-serve/SKILL.md +1 -1
  386. package/templates/README.md +11 -8
  387. package/templates/code-review/agent.md +27 -11
  388. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  389. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  390. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  391. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  392. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  393. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  394. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  395. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  396. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  397. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  398. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  399. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  400. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  401. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  402. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  404. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  405. package/templates/code-review/evals/re-review/prompt.md +1 -1
  406. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  407. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  408. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  409. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  410. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  411. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  412. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  413. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  414. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  415. package/templates/code-review/findings.schema.json +131 -27
  416. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  417. package/templates/code-review/skills/review/DEEP.md +130 -0
  418. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  419. package/templates/code-review/skills/review/SKILL.md +104 -154
  420. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  421. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  422. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  423. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  424. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  425. package/templates/release-notes/agent.md +11 -0
  426. package/dist/box/record.d.ts +0 -6
  427. package/dist/box/record.js +0 -41
  428. package/dist/box/sweep.d.ts +0 -53
  429. package/dist/box/sweep.js +0 -193
  430. package/dist/box-egress-vm.d.ts +0 -118
  431. package/dist/box-egress-vm.js +0 -354
  432. package/dist/box-egress.d.ts +0 -105
  433. package/dist/box-egress.js +0 -256
  434. package/dist/box-relay-vm.d.ts +0 -84
  435. package/dist/box-relay-vm.js +0 -437
  436. package/dist/box-relay.d.ts +0 -36
  437. package/dist/box-relay.js +0 -207
  438. package/dist/boxes.d.ts +0 -109
  439. package/dist/boxes.js +0 -249
  440. package/dist/budget.d.ts +0 -76
  441. package/dist/budget.js +0 -204
  442. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  443. package/dist/console/assets/index-opTN5Naq.css +0 -1
  444. package/dist/daytona-api.d.ts +0 -10
  445. package/dist/daytona-api.js +0 -20
  446. package/dist/egress-proxy.d.ts +0 -45
  447. package/dist/egress-proxy.js +0 -416
  448. package/dist/egress-table.d.ts +0 -24
  449. package/dist/egress-table.js +0 -165
  450. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -10,15 +10,16 @@ export { ARCHIL_CONTROL_URLS, type ArchilMountCredentialOptions, ArchilMountCred
10
10
  export { ARCHIL_API_KEY_ENV, archilApiKey, type ArchilKeyOptions } from "./archil-key.js";
11
11
  export { openRunWorkspace, type RunWorkspace, type RunWorkspaceOptions } from "./run-workspace.js";
12
12
  export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace, type ServerRunWorkspaceOptions } from "./server-run-workspace.js";
13
- export { type LedgerEntry, type PhoneLedger, type PhoneLedgerEntry, phoneLedger, type ProviderLedger, storeLedger } from "./computer-ledger.js";
13
+ export { type LedgerEntry, type ProviderLedger, storeLedger } from "./computer-ledger.js";
14
14
  export { type LearningPlace, type LearningWorkspace, learningWorkspace, type LearningWorkspaceOptions } from "./learning-workspace.js";
15
- export { ARCHIL_MAX_EXEC_S, type Hands, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
15
+ export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
16
16
  export { type RunComputer, type RunHold, runTools, type RunTools, withKindTools } from "./run-tools.js";
17
17
  export { inputOf, phoneOf, screenOf } from "./computer-ports.js";
18
- export { type ClaimSide, computerReadiness, type ComputerSetting, type ComputerSettingKind, type KindCapabilities, type KindRegistry, type LaunchedComputer, type Port, type ProviderEntry, resolveComputer, type ResolvedComputer, runShellOf, type ShellPlace, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
18
+ export { type ClaimSide, computerReadiness, type ComputerSetting, type KindRegistry, type LaunchedComputer, type Port, resolveComputer, type ResolvedComputer, runShellOf, type ShellPlace, shellPlaceOf, type StartedComputer, } from "./resolve-computer.js";
19
19
  export { computerProviderFactories, computerProviderMakers, type ProviderLoad } from "./computer-providers.js";
20
20
  export { claimComputer, claimKinds, type ComputerDeps, computerDepsFrom, type ComputerDepsOptions, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, type DockerComputerOptions, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
21
- export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerRun, type ImageWait, type OpenComputerView, type ProviderMakers, type ViewEnd } from "./computer-for-claim.js";
21
+ export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerRun, type ComputerSaid, type ImageWait, type OpenComputerView, type ProviderMakers, type ViewEnd } from "./computer-for-claim.js";
22
22
  export { JANITOR_EVERY_MS, type JanitorDeps, type ProviderSweep, startJanitor, sweepServerComputers } from "./computer-janitor.js";
23
+ export { agentComputerOf, agentComputerView, ownerGoneOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
23
24
  export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
24
25
  export { KIND_SKILLS, type KindSkill, kindSkillOf, type SkillKind } from "./kind-skills.js";
@@ -11,7 +11,7 @@ export { ARCHIL_CONTROL_URLS, ArchilMountCredentialError, listTokenUsers, mintMo
11
11
  export { ARCHIL_API_KEY_ENV, archilApiKey } from "./archil-key.js";
12
12
  export { openRunWorkspace } from "./run-workspace.js";
13
13
  export { readOnlyWorkspace, SERVER_READS_ONLY, serverRunWorkspace } from "./server-run-workspace.js";
14
- export { phoneLedger, storeLedger } from "./computer-ledger.js";
14
+ export { storeLedger } from "./computer-ledger.js";
15
15
  export { learningWorkspace } from "./learning-workspace.js";
16
16
  export { ARCHIL_MAX_EXEC_S, handsOf, MAX_EXEC_S, processesOf, shellEnv } from "./hands.js";
17
17
  export { runTools, withKindTools } from "./run-tools.js";
@@ -21,5 +21,6 @@ export { computerProviderFactories, computerProviderMakers } from "./computer-pr
21
21
  export { claimComputer, claimKinds, computerDepsFrom, computerSpecOf, DAEMON_CACHE_IN_VOLUME, DOCKER_HOST_ADDRESSES_ENV, dockerHostAddressesOf, dockerVolumeOf, } from "./computer-deps.js";
22
22
  export { computerForClaim } from "./computer-for-claim.js";
23
23
  export { JANITOR_EVERY_MS, startJanitor, sweepServerComputers } from "./computer-janitor.js";
24
+ export { agentComputerOf, agentComputerView, ownerGoneOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
24
25
  export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
25
26
  export { KIND_SKILLS, kindSkillOf } from "./kind-skills.js";
@@ -10,6 +10,9 @@ export type LocalWorkspaceOptions = {
10
10
  /** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
11
11
  * `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
12
12
  export declare const localWorkspace: (root: string, options?: LocalWorkspaceOptions) => Workspace;
13
+ /** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
14
+ * Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
15
+ export declare const localFolderOf: (work: Workspace) => string | undefined;
13
16
  /** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
14
17
  * hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
15
18
  export declare const workspaceAt: (work: string | Workspace) => Workspace;
@@ -223,6 +223,10 @@ class LocalWorkspace {
223
223
  this.#root = root;
224
224
  this.#options = options;
225
225
  }
226
+ /** The folder `work` is over, by its path, when it is a LocalWorkspace; undefined for any other Workspace. */
227
+ static folderOf(work) {
228
+ return work instanceof LocalWorkspace ? work.#root : undefined;
229
+ }
226
230
  /** The root, its links resolved once (the root itself is trusted; nothing below it is), held open. */
227
231
  async #openRoot() {
228
232
  try {
@@ -601,6 +605,8 @@ class LocalWorkspace {
601
605
  const cap = options.maxOutput ?? EXEC_OUTPUT_MAX;
602
606
  if (!Number.isSafeInteger(cap) || cap < 0)
603
607
  throw new WorkspaceError("REFUSED", "exec's maxOutput is a whole number, 0 or more");
608
+ if (options.network !== undefined)
609
+ throw new WorkspaceError("REFUSED", "a command here runs on this machine, which cannot deny its network: nothing ran");
604
610
  const cwd = options.cwd ?? "";
605
611
  const segments = relativeSegments(cwd);
606
612
  const { signal } = options;
@@ -745,6 +751,9 @@ class LocalWorkspace {
745
751
  /** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
746
752
  * `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
747
753
  export const localWorkspace = (root, options = {}) => new LocalWorkspace(root, options);
754
+ /** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
755
+ * Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
756
+ export const localFolderOf = (work) => LocalWorkspace.folderOf(work);
748
757
  /** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
749
758
  * hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
750
759
  export const workspaceAt = (work) => (typeof work === "string" ? localWorkspace(work) : work);
@@ -8,8 +8,9 @@
8
8
  // for it
9
9
  // and on this machine alone:
10
10
  // <data>/scratch/<agent>/<run> a run's scratch folder (scratchFolder): never on the disk above, so in
11
- // no Workspace: a harness's private files and working directory, swept
12
- // at the run's end
11
+ // no Workspace: a harness's working directory, and its private files
12
+ // in harness/<claim's epoch>, swept at that claim's end
13
+ // (runner/cli-run-spec.ts)
13
14
  // <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
14
15
  // share a folder on a disk that folds case.
15
16
  //
@@ -15,8 +15,12 @@ export type PiEnvOptions = {
15
15
  readonly aliases?: readonly string[];
16
16
  /** bash's whole environment: nothing of this process's is passed. */
17
17
  readonly env: Readonly<Record<string, string>>;
18
+ /** Shell text bash runs before each command string (a bash policy's, bash-read-only.ts policyPrelude). */
19
+ readonly prelude?: string;
18
20
  /** bash's deadline when a call names none, in seconds. */
19
21
  readonly defaultTimeoutS: number;
22
+ /** Each command's network (a bash policy's on Archil's exec: run-tools.ts). */
23
+ readonly network?: "deny";
20
24
  };
21
25
  /** pi's ExecutionEnv over `workspace`, the run's folder named `options.cwd`. */
22
26
  export declare function piEnv(workspace: Workspace, options: PiEnvOptions): ExecutionEnv;
@@ -203,13 +203,14 @@ export function piEnv(workspace, options) {
203
203
  };
204
204
  const run = (argv) => workspace.exec(argv, {
205
205
  cwd: where.value, env: { ...options.env, ...(given?.env ?? {}) }, timeoutMs: Math.max(1, Math.round(timeoutS * 1000)), maxOutput: 0,
206
- ...(context.abortSignal ? { signal: context.abortSignal } : {}),
206
+ ...(context.abortSignal ? { signal: context.abortSignal } : {}), ...(options.network ? { network: options.network } : {}),
207
207
  onOutput: ({ stream, data }) => {
208
208
  emit(decoders[stream].decode(data), stream);
209
209
  keep(data);
210
210
  },
211
211
  });
212
- const argvs = typeof command === "string" ? [["bash", "-c", command], ["sh", "-c", command]] : [[...command]];
212
+ const line = typeof command === "string" ? `${options.prelude ?? ""}${command}` : undefined;
213
+ const argvs = line !== undefined ? [["bash", "-c", line], ["sh", "-c", line]] : [[...command]];
213
214
  let ran;
214
215
  try {
215
216
  for (const argv of argvs) {
@@ -1,5 +1,5 @@
1
- import type { ShellPlace } from "@parcha/agentrun-kernel/kernel";
2
- import { type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type KindCapabilities, type MountReadBack, type MountSpec, type ProviderEntry, type Result } from "@parcha/agentrun-computer";
1
+ import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
2
+ import { type BrowserFeatures, type BrowserFile, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountReadBack, type MountSpec, type ProviderEntry, type Result } from "@parcha/agentrun-computer";
3
3
  import { type DockerDaemon } from "../docker-daemon.js";
4
4
  import type { MountCheck } from "./attach.js";
5
5
  import type { RunComputer } from "./run-tools.js";
@@ -7,11 +7,14 @@ import type { Workspace } from "./workspace.js";
7
7
  /** The setting kind (what an agent is given, not a computer's capabilities().kind), a machine's kind and groups, and one
8
8
  * provider of the kind registry: the computer module's own types. Where a run's shell is: the kernel registry's. */
9
9
  export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace };
10
- /** An agent's computer setting: a sandbox's may ask for GPUs. */
10
+ /** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
11
+ * sandbox's may ask for GPUs. `persistent`: the agent keeps its own computer between runs (agent-computer.ts). */
11
12
  export type ComputerSetting = {
12
13
  readonly kind: string;
13
14
  readonly provider?: string | null;
15
+ readonly image?: string;
14
16
  readonly gpu?: GpuSpec;
17
+ readonly persistent?: boolean;
15
18
  };
16
19
  /** The computer module's kind registry (src/kinds.ts), by its own names: the setting kinds, why a machine does not serve
17
20
  * one (servingRefusals, whose words a refusal here carries), and the providers. */
@@ -21,13 +24,15 @@ export type KindRegistry = {
21
24
  readonly PROVIDERS: readonly ProviderEntry[];
22
25
  };
23
26
  /** A computer a provider started for the run: its ref, its computerd client and what it offers (sandbox, desktop,
24
- * phone), the read-back of its mount (when mounted), and its release. A browser is started by none: the claim gives
25
- * the run's browser tool its provider (`browser`), which opens each session at the tool's first call, and the release
26
- * lets go of any the tool left open. */
27
+ * phone), the hello it answered when the claim connected it (a desktop's or a phone's ports read its groups), the
28
+ * read-back of its mount (when mounted), and its release. A browser is started by none: the claim gives the run's
29
+ * browser tool its provider (`browser`), which opens each session at the tool's first call, and the release lets go
30
+ * of any the tool left open. */
27
31
  export type LaunchedComputer = {
28
32
  readonly id: string;
29
33
  readonly groups: readonly (Group | string)[];
30
34
  readonly client?: ComputerClient;
35
+ readonly hello?: HelloResult;
31
36
  readBack?(): Promise<Result<MountReadBack>>;
32
37
  readonly browser?: ClaimBrowser;
33
38
  release(): Promise<void>;
@@ -42,14 +47,24 @@ export type ClaimBrowser = {
42
47
  readonly provider: string;
43
48
  /** The longest a session lives, in seconds. */
44
49
  readonly maxLifetimeS: number;
45
- /** Makes a session for `tag`, to live at most `lifetimeS`: its computer's id. */
46
- open(tag: string, lifetimeS: number, signal?: AbortSignal): Promise<string>;
50
+ /** What its sessions offer beyond the protocol (the provider's capabilities().browser), which `open` may ask for. */
51
+ readonly features: BrowserFeatures;
52
+ /** Makes a session for `tag`, to live at most `lifetimeS`, with its own options (spec.browser): its computer's id. */
53
+ open(tag: string, lifetimeS: number, browser?: BrowserSpec, signal?: AbortSignal): Promise<string>;
47
54
  /** The sessions made for `tag`, by id. */
48
55
  find(tag: string, signal?: AbortSignal): Promise<string[]>;
56
+ /** Whether the session runs: false once it has ended or its provider no longer knows it. */
57
+ running(id: string, signal?: AbortSignal): Promise<boolean>;
49
58
  /** The session's CDP URL now. */
50
59
  url(id: string): Promise<string>;
51
60
  /** Ends the session; one already gone is ended. */
52
61
  close(id: string): Promise<void>;
62
+ /** The files a session downloaded, kept by the provider: where its features declare downloads. */
63
+ readonly downloads?: {
64
+ list(id: string): Promise<BrowserFile[]>;
65
+ /** The file's bytes, streamed; the stream fails in words once it passes maxBytes. */
66
+ read(id: string, name: string, maxBytes: number): Promise<AsyncIterable<Uint8Array>>;
67
+ };
53
68
  };
54
69
  /** The claim's side: the keys saved for a provider (Settings → Computers; values, never shown), and the launch of one
55
70
  * computer of the kind, with the run's folder as its mount when it mounts it. A launch that fails throws its words. */
@@ -60,11 +75,16 @@ export type ClaimSide = {
60
75
  /** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails: none answering is refused in
61
76
  * the one wording a run's start and Settings → Computers say (noDockerWords). Absent: the launch's own words. */
62
77
  daemon?(provider: string): Promise<DockerDaemon>;
78
+ /** `configuration`: the provider's configuration the setting selected; its options go to the provider with the keys,
79
+ * and its image, when it names one, is the computer's. `gpu`: a sandbox's GPUs, held to that configuration.
80
+ * `persistent`: the agent's own computer, which that configuration keeps (and which mounts no run's folder). */
63
81
  launch(entry: ProviderEntry, spec: {
64
82
  readonly kind: ComputerSettingKind;
65
83
  readonly keys: Readonly<Record<string, string>>;
84
+ readonly configuration: KindCapabilities;
66
85
  readonly mount?: MountSpec;
67
86
  readonly gpu?: GpuSpec;
87
+ readonly persistent?: true;
68
88
  readonly signal?: AbortSignal;
69
89
  }): Promise<LaunchedComputer>;
70
90
  };
@@ -74,8 +94,8 @@ export type Port = "files" | "exec" | "processes" | "screen" | "input" | "phone"
74
94
  /** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
75
95
  * key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
76
96
  export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, keyOf: (name: string) => Promise<string | undefined>) => ClaimSide["keysOf"];
77
- /** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its module's
78
- * NETWORK, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
97
+ /** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
98
+ * descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
79
99
  export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
80
100
  /** Whether a provider's computers can't have no network: it declares its network forms and "none" isn't one (a cloud
81
101
  * phone, a hosted browser, Local Chrome). */
@@ -94,8 +114,11 @@ export declare const noNetworkRefusal: (label: string, kind: string) => string;
94
114
  * claim launches it, and asks only once its launch fails (ClaimSide.daemon). Absent: not asked.
95
115
  *
96
116
  * `boxAllow`: this server's allow setting (box-settings.ts boxAllowOf). Under "none", a computer whose provider makes no
97
- * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked. */
98
- export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, registry: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => DockerDaemon | Promise<DockerDaemon>, boxAllow?: readonly string[] | "none"): Promise<{
117
+ * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked.
118
+ *
119
+ * `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
120
+ * hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
121
+ export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, registry: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => DockerDaemon | Promise<DockerDaemon>, boxAllow?: readonly string[] | "none", hostWhy?: (provider: string) => string | undefined): Promise<{
99
122
  readonly ok: true;
100
123
  } | {
101
124
  readonly refused: string;
@@ -139,6 +162,19 @@ export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2): ShellPlace;
139
162
  * runs nothing: "none". The setting is the agent's as saved; where it has none, the caller gives the server's default.
140
163
  */
141
164
  export declare function runShellOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): ShellPlace;
165
+ /** What a choice of computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note) and
166
+ * said by the save's refusal of a tool it leaves out. A computer that mounts the folder leaves nothing out. */
167
+ export declare const SHELL_NOTES: Readonly<Record<Exclude<ShellPlace, "computer">, string>>;
168
+ /** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
169
+ * second one: the file tools always, bash with a shell, the five background tools on a computer. */
170
+ export declare const hostToolsOf: (shell: ShellPlace) => string[];
171
+ /** A computer choice as an agent's settings show it: where its runs have their shell (runShellOf), the host tools that
172
+ * gives, and what it leaves out, in words (none for a computer that mounts the folder). */
173
+ export declare function shellChoiceOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): {
174
+ shell: ShellPlace;
175
+ host_tools: string[];
176
+ shell_note?: string;
177
+ };
142
178
  /** The setting resolved for `mode` (none given: the server's default), or a refusal in words that name the setting. A
143
179
  * workflow runs with no computer: its caller gives kind none. */
144
180
  export declare function resolveComputer(given: ComputerSetting | undefined, mode: 1 | 2, registry: KindRegistry, side: ClaimSide): Promise<ResolvedComputer | {
@@ -1,5 +1,27 @@
1
- import { checkGpu } 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";
3
25
  /** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
4
26
  * key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
5
27
  export const providerKeys = (registry, keyOf) => async (provider) => {
@@ -11,8 +33,8 @@ export const providerKeys = (registry, keyOf) => async (provider) => {
11
33
  }
12
34
  return keys;
13
35
  };
14
- /** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its module's
15
- * NETWORK, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
36
+ /** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
37
+ * descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
16
38
  export const vendorNetworkOnly = (network) => network !== undefined && network.length > 0 && network.every((one) => one === "open");
17
39
  /** Whether a provider's computers can't have no network: it declares its network forms and "none" isn't one (a cloud
18
40
  * phone, a hosted browser, Local Chrome). */
@@ -31,8 +53,11 @@ export const noNetworkRefusal = (label, kind) => `This agent's computer is a ${l
31
53
  * claim launches it, and asks only once its launch fails (ClaimSide.daemon). Absent: not asked.
32
54
  *
33
55
  * `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) {
56
+ * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked.
57
+ *
58
+ * `hostWhy`: why this machine cannot run a provider's computers, in words that say how to fix it (computers.ts
59
+ * hostCommandRefusals, read at the server's start: the phone's adb not on PATH), or undefined. Absent: not asked. */
60
+ export async function computerReadiness(setting, mode, registry, keyOf, answers, boxAllow, hostWhy) {
36
61
  const resolved = await resolveComputer(setting, mode, registry, {
37
62
  keysOf: providerKeys(registry, keyOf),
38
63
  // A setting is given, so the Mode 1 default (the only asker) is never read; and nothing is launched.
@@ -50,6 +75,9 @@ export async function computerReadiness(setting, mode, registry, keyOf, answers,
50
75
  if (!said.up)
51
76
  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
77
  }
78
+ const host = entry ? hostWhy?.(entry.id) : undefined;
79
+ if (host)
80
+ return { refused: `This agent's computer is a ${entry.label} ${resolved.kind}, and this server cannot run it: ${host.replace(/[.!?]+$/, "")}.` };
53
81
  if (boxAllow === "none" && entry && needsNetwork(entry.network))
54
82
  return { refused: noNetworkRefusal(entry.label, resolved.kind) };
55
83
  return { ok: true };
@@ -82,6 +110,11 @@ function mountsFolder(kind, entry, serving, mode) {
82
110
  }
83
111
  /** The configurations of `entry` that serve `kind`. */
84
112
  const servingOf = (registry, entry, kind) => entry.capabilities.filter((one) => registry.servingRefusals(one, kind).length === 0);
113
+ /** The one configuration of `serving` the setting selects (configurationOf), as a list: [] when its image names none. */
114
+ const selectedOf = (serving, setting, entry, kind) => {
115
+ const one = configurationOf(serving, setting.image, entry.defaultImage?.[kind]);
116
+ return one ? [one] : [];
117
+ };
85
118
  /**
86
119
  * Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
87
120
  * kind registry before anything starts: what the claim's runTools gives the run once its computer is started. "computer"
@@ -101,7 +134,7 @@ export function runShellOf(setting, mode, registry) {
101
134
  const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
102
135
  if (!entry)
103
136
  return "none";
104
- const serving = servingOf(registry, entry, kind);
137
+ const serving = selectedOf(servingOf(registry, entry, kind), setting, entry, kind);
105
138
  if (serving.length === 0)
106
139
  return "none";
107
140
  const mounts = mountsFolder(kind, entry, serving, mode);
@@ -109,6 +142,21 @@ export function runShellOf(setting, mode, registry) {
109
142
  return "none";
110
143
  return shellPlaceOf(mounts, mode);
111
144
  }
145
+ /** What a choice of computer leaves out of the shell, in plain words: shown beside it (GET /v2/computers shell_note) and
146
+ * said by the save's refusal of a tool it leaves out. A computer that mounts the folder leaves nothing out. */
147
+ export const SHELL_NOTES = Object.freeze({
148
+ local: "No computer: bash runs in a fresh container on the folder's own storage; background commands need a computer.",
149
+ none: "No computer on this server: the agent gets the file tools only, no shell. Pick a computer to run commands.",
150
+ });
151
+ /** The host tools a run with its shell at `shell` gets, by name: the kernel registry's own list (hostToolDefs), never a
152
+ * second one: the file tools always, bash with a shell, the five background tools on a computer. */
153
+ export const hostToolsOf = (shell) => hostToolDefs({ maxExecS: 600, shell }).map((def) => def.name);
154
+ /** A computer choice as an agent's settings show it: where its runs have their shell (runShellOf), the host tools that
155
+ * gives, and what it leaves out, in words (none for a computer that mounts the folder). */
156
+ export function shellChoiceOf(setting, mode, registry) {
157
+ const shell = runShellOf(setting, mode, registry);
158
+ return { shell, host_tools: hostToolsOf(shell), ...(shell === "computer" ? {} : { shell_note: SHELL_NOTES[shell] }) };
159
+ }
112
160
  /** The server's default where an agent has no computer setting: in Mode 1 a sandbox on the first provider that binds a
113
161
  * folder of this machine and answers here (Docker), else none; in Mode 2 none. */
114
162
  async function defaultSetting(mode, registry, side) {
@@ -146,8 +194,21 @@ export async function resolveComputer(given, mode, registry, side) {
146
194
  const why = entry.capabilities.map((one) => registry.servingRefusals(one, kind)).sort((a, b) => a.length - b.length)[0] ?? [];
147
195
  return { refused: `${entry.label} gives no ${kind} computer${why.length > 0 ? `: ${why.join("; ")}` : ""}. Pick ${pick}` };
148
196
  }
149
- // The run's folder: mounted where the kind has files and exec and the provider mounts the mode's folder.
150
- const mounts = mountsFolder(kind, entry, serving, mode);
197
+ // The configuration the setting's image selects: one the provider does not offer for the kind is refused, naming those
198
+ // it does.
199
+ const [configuration] = selectedOf(serving, setting, entry, kind);
200
+ if (!configuration) {
201
+ const images = imagesOf(serving, entry.defaultImage?.[kind]);
202
+ const offers = images.length === 0 ? `offers no ${kind} image to choose: remove the image` : `offers the ${kind} image${images.length === 1 ? "" : "s"} ${images.join(", ")}: pick one`;
203
+ // A configuration its descriptor parks (built, not offered yet): refused saying so, never as an unknown image.
204
+ const parked = entry.parked?.find((one) => one.image === setting.image);
205
+ if (parked)
206
+ return { refused: `${parked.why}, so this agent's ${JSON.stringify(setting.image)} ${kind} is parked. It ${offers} for this agent's computer in ${SETTINGS}.` };
207
+ return { refused: `${entry.label} has no ${kind} image ${JSON.stringify(setting.image)}. It ${offers} for this agent's computer in ${SETTINGS}.` };
208
+ }
209
+ // The run's folder: mounted where the selected configuration has files and exec and the provider mounts the mode's
210
+ // folder.
211
+ const mounts = mountsFolder(kind, entry, [configuration], mode);
151
212
  if (kind === "sandbox" && !mounts) {
152
213
  if (mode === 1)
153
214
  return { refused: `Mode 1 runs a sandbox only on Docker: a ${entry.label} sandbox can't reach the run's folder on this machine. Pick Docker for this agent's computer in ${SETTINGS}, or another kind of computer.` };
@@ -155,15 +216,24 @@ export async function resolveComputer(given, mode, registry, side) {
155
216
  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.` };
156
217
  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}.` };
157
218
  }
158
- // Its GPUs, a sandbox's alone: in checkGpu's words, against what the configuration that serves it declares, with the
159
- // mode's folder as the mount it takes (a sandbox here always mounts it).
219
+ // Its GPUs, a sandbox's alone: in gpuRefused's words, against what the configuration the setting selected declares,
220
+ // with the mode's folder as the mount it takes (a sandbox here always mounts it). A GPU computer that can't mount the
221
+ // folder is told so, and what to use instead.
160
222
  const gpu = kind === "sandbox" && setting.gpu ? setting.gpu : undefined;
161
223
  if (gpu) {
162
- const offered = serving.find((one) => one.gpu !== undefined) ?? serving[0];
163
- const [refusal] = checkGpu(gpu, offered, { kind: mode === 1 ? "bind" : "archil" });
164
- if (refusal)
165
- 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}.` };
224
+ const refused = gpuRefused(gpu, configuration.gpu, { kind: mode === 1 ? "bind" : "archil" }, entry.label);
225
+ if (refused?.folder)
226
+ return { refused: refused.words };
227
+ if (refused)
228
+ 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}.` };
166
229
  }
230
+ // The agent's own computer, kept between its runs: only where the configuration keeps one, and never one that mounts
231
+ // the run's folder (a later run would find an earlier run's folder in it).
232
+ const persistent = setting.persistent === true;
233
+ if (persistent && configuration.persistence === undefined)
234
+ 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}.` };
235
+ if (persistent && mounts)
236
+ 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}.` };
167
237
  // Its keys: every required one saved, before anything starts; only declared names go to the provider.
168
238
  const saved = await side.keysOf(entry.id);
169
239
  const has = (name) => typeof saved[name] === "string" && saved[name] !== "";
@@ -184,7 +254,7 @@ export async function resolveComputer(given, mode, registry, side) {
184
254
  const mount = mounts ? await workspace.mountSpec() : undefined;
185
255
  let launched;
186
256
  try {
187
- launched = await side.launch(entry, { kind, keys, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(signal ? { signal } : {}) });
257
+ launched = await side.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu: { type: gpu.type, count: gpu.count } } : {}), ...(persistent ? { persistent: true } : {}), ...(signal ? { signal } : {}) });
188
258
  }
189
259
  catch (error) {
190
260
  // A provider that binds a folder of this machine (Docker) whose daemon does not answer: the one wording.
@@ -204,20 +274,19 @@ export async function resolveComputer(given, mode, registry, side) {
204
274
  }
205
275
  /** The started computer as runTools takes it, or what it lacks, in words. */
206
276
  function runComputerOf(kind, launched, check) {
207
- const groups = launched.groups;
208
277
  // The run's browser tool opens a browser's sessions through its provider.
209
278
  if (kind === "browser")
210
279
  return launched.browser ? { kind, browser: launched.browser } : "it gave no CDP connection";
211
- const { client } = launched;
280
+ const { client, hello } = launched;
212
281
  if (!client)
213
282
  return "it gave no computer protocol client";
214
283
  if (kind === "phone")
215
- return { kind, computer: { client }, groups };
284
+ return hello ? { kind, computer: { client }, hello } : "it gave no hello";
216
285
  if (check && !launched.readBack)
217
286
  return "it gave no read-back of its mount";
218
287
  const readBack = launched.readBack ? () => launched.readBack() : async () => ({ ok: false, error: { code: "unsupported", message: "nothing is mounted in this computer" } });
219
288
  const computer = { id: launched.id, client, readBack };
220
289
  if (kind === "sandbox")
221
290
  return check ? { kind, computer, check } : "a sandbox mounts the run's folder";
222
- return { kind, computer, groups, ...(check ? { check } : {}) };
291
+ return hello ? { kind, computer, hello, ...(check ? { check } : {}) } : "it gave no hello";
223
292
  }
@@ -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
+ }