@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
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import { startedWith } from "./adapters.js";
14
14
  import { REPEAT_MS, stopOnSignals } from "./stop-signals.js";
15
15
  import { canOpen } from "./host.js";
16
16
  import { resetPassword } from "./owner.js";
17
- import { banner, boxImageLine } from "./print.js";
17
+ import { banner } from "./print.js";
18
18
  import { DEFAULT_PORT, fauxEnvOf, startServe } from "./server.js";
19
19
  import { besideRunnerOptions, besideStopping, runnerBeside } from "./runner/beside.js";
20
20
  import { apiOnlyFrom } from "./api-only.js";
@@ -22,7 +22,7 @@ import { surviveClosedPipes } from "./closed-pipes.js";
22
22
  // A stdout or stderr its reader closed loses the lines written after, never the process (closed-pipes.ts): for every
23
23
  // command, the server and the runner alike.
24
24
  surviveClosedPipes();
25
- const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--learning-budget BYTES] [--grade-model MODEL] [--no-runner]
25
+ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--learning-budget BYTES] [--grade-model MODEL] [--no-runner]
26
26
  agentrun-serve reset-password [--data DIR]
27
27
  agentrun-serve validate-template DIR
28
28
  agentrun-serve eval-template DIR [--case NAME ...] [--runs N] [--server URL] [--grader-model PROVIDER/MODEL] [--report FILE] [--faux MODULE]
@@ -40,6 +40,9 @@ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--
40
40
  --faux-browser MODULE
41
41
  with --faux only: the browser tool's provider and driver from MODULE's default export (a fake
42
42
  browser, no vendor, no key), for the console's real-browser tests
43
+ --faux-github with --faux only: a fake GitHub App, connected at the start and answered in this process, so
44
+ GitHub triggers run with nothing sent to GitHub; its webhook secret is in DIR/faux-github.json.
45
+ On a scratch data directory: refused where another GitHub App is connected
43
46
  --allow-host NAME another Host name to accept (repeatable)
44
47
  --max-runs N the most runs the runner beside the server holds at once, the rest waiting queued (default
45
48
  AGENTRUN_MAX_RUNS, else as many pi runs as this host's memory holds); the capabilities'
@@ -73,8 +76,9 @@ published port, or a proxy's URL), and the link printed uses it; with none, Rend
73
76
  end, and per refused credential; AGENTRUN_LOG=quiet leaves out the request lines.
74
77
 
75
78
  AGENTRUN_API_ONLY=1 serves the run routes alone, for a server behind its caller's backend: a run's launch, read, list,
76
- timeline, messages, stop, cancel, kill and cap raise, its files and uploads, capabilities, health and usage. Every other
77
- address (the page, sign-in, setup, settings, MCP, triggers and their hooks, agents) is a 404, and there are no accounts.
79
+ timeline, messages, stop, cancel, kill and cap raise, its files and uploads, an agent's Archil disk, capabilities, health
80
+ and usage. Every other address (the page, sign-in, setup, settings, MCP, triggers and their hooks, the rest of agents)
81
+ is a 404, and there are no accounts.
78
82
 
79
83
  The page is for one person, who signs in with a password (AGENTRUN_ACCOUNTS=0 turns this off; the token works for
80
84
  scripts and the CLI either way). With no AGENTRUN_PUBLIC_URL, listening on loopback, the first visit to the page sets the
@@ -249,6 +253,7 @@ try {
249
253
  open: { type: "boolean", default: false },
250
254
  faux: { type: "string" },
251
255
  "faux-browser": { type: "string" },
256
+ "faux-github": { type: "boolean", default: false },
252
257
  "allow-host": { type: "string", multiple: true, default: [] },
253
258
  "max-runs": { type: "string" },
254
259
  "drain-timeout": { type: "string" },
@@ -291,6 +296,10 @@ if (values["faux-browser"] && !values.faux) {
291
296
  console.error(`--faux-browser goes with --faux\n\n${USAGE}`);
292
297
  process.exit(2);
293
298
  }
299
+ if (values["faux-github"] && !values.faux) {
300
+ console.error(`--faux-github goes with --faux\n\n${USAGE}`);
301
+ process.exit(2);
302
+ }
294
303
  const budget = values["learning-budget"];
295
304
  if (budget !== undefined && !/^\d+$/.test(budget)) {
296
305
  console.error(`--learning-budget takes a whole number of bytes\n\n${USAGE}`);
@@ -298,6 +307,22 @@ if (budget !== undefined && !/^\d+$/.test(budget)) {
298
307
  }
299
308
  const data = values.data ?? defaultData();
300
309
  const given = secret("AGENTRUN_TOKEN") || undefined;
310
+ // The stop is listened for before anything starts: a SIGTERM or SIGINT during the start (a platform's redeploy, the
311
+ // moment the banner shows) is kept, never the default end by signal that cuts what the start began. Once the start has
312
+ // what a stop closes, the stop below takes over (stopOnSignals), and a stop asked meanwhile runs it, through the same
313
+ // drain. A second signal a while after the first, still during the start, is a person who wants out now: exit 130.
314
+ let stopping;
315
+ let askedAt;
316
+ const signalled = () => {
317
+ if (stopping)
318
+ return stopping();
319
+ if (askedAt === undefined)
320
+ askedAt = Date.now();
321
+ else if (Date.now() - askedAt >= REPEAT_MS)
322
+ process.exit(130);
323
+ };
324
+ process.on("SIGINT", signalled);
325
+ process.on("SIGTERM", signalled);
301
326
  // AGENTRUN_API_ONLY=1: the run routes alone (api-only.ts), and no owner; a value that is neither on nor off stops here.
302
327
  let apiOnly;
303
328
  try {
@@ -308,21 +333,6 @@ catch (error) {
308
333
  process.exit(2);
309
334
  }
310
335
  const accounts = !apiOnly && process.env.AGENTRUN_ACCOUNTS !== "0";
311
- // The Docker box image's first build said in words, as it starts and as it ends (print.ts boxImageLine); a line told
312
- // before the banner is printed waits for it.
313
- let imageSaid = false;
314
- let bannered = false;
315
- const early = [];
316
- const onBoxImage = (state) => {
317
- const line = boxImageLine(state, imageSaid);
318
- if (line === undefined)
319
- return;
320
- imageSaid = true;
321
- if (bannered)
322
- console.log(line);
323
- else
324
- early.push(line);
325
- };
326
336
  // How it was started, for the hints that start it again (adapters.ts npxLine): itself and its runs read it.
327
337
  Object.assign(process.env, startedWith({ ...(values.port !== undefined ? { port: values.port } : {}), open: values.open === true }));
328
338
  let serve;
@@ -330,14 +340,13 @@ let serveOptions;
330
340
  const trustedProxies = (process.env.AGENTRUN_TRUSTED_PROXIES ?? "").split(",").map((entry) => entry.trim()).filter(Boolean);
331
341
  try {
332
342
  serve = await startServe(serveOptions = {
333
- onBoxImage,
334
343
  // The owner lock on a Postgres store lost for good: this server can serve nothing more, so it exits non-zero and its
335
344
  // platform starts it again, rather than answer 503 for as long as it runs.
336
345
  onStoreLost: (error) => {
337
346
  console.error(`agentrun-serve: ${error.message}`);
338
347
  process.exit(1);
339
348
  },
340
- data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), allowHosts: values["allow-host"],
349
+ data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
341
350
  ...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
342
351
  ...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), ...(values["grade-model"] ? { gradeModel: values["grade-model"] } : {}), ...(budget !== undefined ? { learningBudget: Number(budget) } : {}), log: (line) => void process.stdout.write(`${line}\n`),
343
352
  // The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
@@ -358,7 +367,8 @@ catch (error) {
358
367
  // its turn for up to --drain-timeout.
359
368
  let runnerProc;
360
369
  const { loops, drainMs } = besideRunnerOptions(serveOptions, process.env);
361
- if (!values["no-runner"]) {
370
+ // A stop asked during the server's start starts no runner: nothing is claimed for the stop to cut.
371
+ if (!values["no-runner"] && askedAt === undefined) {
362
372
  try {
363
373
  // The beside-runner sees the server's test switches (server.ts fauxEnvOf: --faux and its modules), which the CLI hands
364
374
  // the server as options, never through this process's environment: without them a --faux start's runner looks its faux
@@ -382,9 +392,6 @@ for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token:
382
392
  // setup link with its code as the code was made (owner.ts).
383
393
  if (serve.setupUrl && serve.setupOpen)
384
394
  console.log(`Set your password: ${serve.setupUrl} (the first visit sets it)`);
385
- bannered = true;
386
- for (const line of early.splice(0))
387
- console.log(line);
388
395
  // The console's page, once the server listens: never its sign-in link, whose token would sit in the opener's arguments
389
396
  // and the browser's history.
390
397
  // API-only: there is no console, so nothing to open.
@@ -410,9 +417,11 @@ const stop = stopOnSignals({
410
417
  done: (code) => (removeOwnRecord(record), process.exit(code)),
411
418
  say: (line) => console.error(line),
412
419
  });
413
- process.on("SIGINT", stop);
414
- process.on("SIGTERM", stop);
420
+ stopping = stop;
415
421
  // Written whole under a name of its own, then renamed into place: a reader in another process (the npx command, a test
416
422
  // waiting for this server) that finds the record reads all of it, never a file made but not yet filled.
417
423
  writeDurableSync(record, `${JSON.stringify({ base_url: serve.baseUrl, pid: process.pid, ...(serve.tokenFile ? { token_file: serve.tokenFile } : {}) })}\n`);
418
424
  chmodSync(record, 0o600);
425
+ // A stop asked during the start runs now, as one asked from here on would.
426
+ if (askedAt !== undefined)
427
+ stop(askedAt);
@@ -1,17 +1,18 @@
1
- /** One key a provider takes: its name in the kind registry, the create() option it fills, and whether it is needed. */
1
+ import { type ProviderEntry } from "@parcha/agentrun-computer";
2
+ /** One key a provider takes: its name in its descriptor, the create() option it fills, and whether it is needed. */
2
3
  export interface ProviderKey {
3
4
  readonly name: string;
4
5
  readonly option: string;
5
6
  readonly required: boolean;
6
7
  }
7
- /** Each provider's keys, by the registry's names, and the option each fills. Docker takes none (its host is local). */
8
- export declare const PROVIDER_KEYS: Readonly<Record<string, readonly ProviderKey[]>>;
9
- /** The Modal app a server's computers live in when its settings name none (serve's box app until now). */
10
- export declare const DEFAULT_MODAL_APP = "agentrun";
11
- /** Settings that are no key but go to a provider's options: the Modal app. */
12
- export interface ProviderSettings {
13
- readonly modalApp?: string;
8
+ /** A setting that is no key but fills a create() option: its name in the server's settings, and its default. */
9
+ export interface ProviderSetting {
10
+ readonly name: string;
11
+ readonly option: string;
12
+ readonly default?: string;
14
13
  }
14
+ /** The server's settings that are no key, by their names in the descriptors (modalApp): what fills each setting. */
15
+ export type ProviderSettings = Readonly<Record<string, string | undefined>>;
15
16
  /** An answer in the registry's shape: a value, or an error with its code and words. */
16
17
  export type KeyResult<T> = {
17
18
  ok: true;
@@ -48,13 +49,22 @@ export interface TestableProvider {
48
49
  }
49
50
  /** A provider module's create(), by provider id: the computer package's, or a test's stand-in. */
50
51
  export type ProviderFactories = Readonly<Partial<Record<string, (options: Record<string, string>) => TestableProvider | Promise<TestableProvider>>>>;
51
- /** The table the map reads: each provider's keys and its name in words. Serve's own (KEY_TABLE), or --faux's. */
52
+ /** The table the map reads: each provider's keys, settings and name in words, by id. Serve's own (KEY_TABLE, the
53
+ * computer package's descriptors), or --faux's (keyTableOf its entries). */
52
54
  export interface KeyTable {
53
55
  readonly keys: Readonly<Record<string, readonly ProviderKey[]>>;
54
56
  readonly labels: Readonly<Record<string, string>>;
57
+ readonly settings?: Readonly<Record<string, readonly ProviderSetting[]>>;
55
58
  }
59
+ /** The key table of `entries` (the kind registry's PROVIDERS, each from its descriptor). */
60
+ export declare function keyTableOf(entries: readonly Pick<ProviderEntry, "id" | "label" | "keys" | "settings">[]): KeyTable;
61
+ /** Serve's table: every provider the computer package declares. */
56
62
  export declare const KEY_TABLE: KeyTable;
57
- /** Provider `providerId`'s create() options from its saved keys (by the registry's names) and the server's settings. */
63
+ /**
64
+ * Provider `providerId`'s create() options from its saved keys (by its descriptor's names) and the server's settings
65
+ * (each of its descriptor's settings, by name, else its default). An id the table does not list is refused, naming the
66
+ * providers it does.
67
+ */
58
68
  export declare function providerOptions(providerId: string, keys: Readonly<Record<string, string>>, settings?: ProviderSettings, table?: KeyTable): OptionsAnswer;
59
69
  /**
60
70
  * Settings' "test connection" for `providerId` (the kind registry's TestConnection, and serve's ComputerRegistry.test):
@@ -1,57 +1,36 @@
1
- // Settings → Computers' keys, serve side: a provider's saved keys, by the names the computer package's kind registry
2
- // declares for it (kinds.ts PROVIDERS), as that provider's create() options, and Settings' "test connection" over them
3
- // (the registry's TestConnection: one account-level read that never makes a computer), its coded errors in plain words.
1
+ // Settings → Computers' keys, serve side: a provider's saved keys, by the names its descriptor declares (the computer
2
+ // package's PROVIDERS, derived from each provider's descriptor), as that provider's create() options, and Settings' "test
3
+ // connection" over them (the registry's TestConnection: one account-level read that never makes a computer), its coded
4
+ // errors in plain words.
4
5
  //
5
- // The map from a key's name to the option it fills is serve's, and lives here: E2B_API_KEY is E2B's apiKey, the Modal
6
- // token pair is the Modal client's tokenId and tokenSecret, and so on. A name a provider does not declare is never passed
7
- // on; an empty optional key is left out; a required one not saved refuses in words naming what to save, before anything
8
- // is made. The provider modules themselves (each one's create()) are passed in (workspace/computer-providers.ts makes the
9
- // computer package's; a test gives stand-ins): a provider with no module here answers that its test is not available.
10
- // No key is ever in an answer: each value is scrubbed from the provider's words, and the words this module adds name keys
11
- // only by their names.
12
- /** Each provider's keys, by the registry's names, and the option each fills. Docker takes none (its host is local). */
13
- export const PROVIDER_KEYS = {
14
- docker: [],
15
- daytona: [
16
- { name: "DAYTONA_API_KEY", option: "apiKey", required: true },
17
- { name: "DAYTONA_API_URL", option: "apiUrl", required: false },
18
- { name: "DAYTONA_TARGET", option: "target", required: false },
19
- ],
20
- modal: [
21
- { name: "MODAL_TOKEN_ID", option: "tokenId", required: true },
22
- { name: "MODAL_TOKEN_SECRET", option: "tokenSecret", required: true },
23
- ],
24
- e2b: [{ name: "E2B_API_KEY", option: "apiKey", required: true }],
25
- orgo: [{ name: "ORGO_API_KEY", option: "apiKey", required: true }],
26
- "phone-harness": [{ name: "PHONE_HARNESS_API_KEY", option: "apiKey", required: true }],
27
- browserbase: [
28
- { name: "BROWSERBASE_API_KEY", option: "apiKey", required: true },
29
- { name: "BROWSERBASE_PROJECT_ID", option: "projectId", required: true },
30
- ],
31
- kernel: [{ name: "KERNEL_API_KEY", option: "apiKey", required: true }],
32
- // This machine's Chrome: no key.
33
- local: [],
34
- };
35
- /** Each provider's name in words (the registry's labels). */
36
- const LABELS = {
37
- docker: "Docker",
38
- daytona: "Daytona",
39
- modal: "Modal",
40
- e2b: "E2B",
41
- orgo: "Orgo",
42
- "phone-harness": "Phone harness",
43
- browserbase: "Browserbase",
44
- kernel: "Kernel",
45
- local: "Local Chrome",
46
- };
47
- /** The Modal app a server's computers live in when its settings name none (serve's box app until now). */
48
- export const DEFAULT_MODAL_APP = "agentrun";
49
- export const KEY_TABLE = { keys: PROVIDER_KEYS, labels: LABELS };
6
+ // Serve knows no vendor here: each key's name and the option it fills, each setting that is no key (its name in the
7
+ // server's settings, its option and its default), and each provider's label all come from the descriptor. A name a
8
+ // provider does not declare is never passed on; an empty optional key is left out; a required one not saved refuses in
9
+ // words naming what to save, before anything is made. The provider modules themselves (each one's create()) are passed
10
+ // in (workspace/computer-providers.ts makes the computer package's; a test gives stand-ins): a provider with no module
11
+ // here answers that its test is not available. No key is ever in an answer: each value is scrubbed from the provider's
12
+ // words, and the words this module adds name keys only by their names.
13
+ import { PROVIDERS } from "@parcha/agentrun-computer";
14
+ /** The key table of `entries` (the kind registry's PROVIDERS, each from its descriptor). */
15
+ export function keyTableOf(entries) {
16
+ return {
17
+ keys: Object.fromEntries(entries.map((entry) => [entry.id, entry.keys.map(({ name, option, required }) => ({ name, option, required }))])),
18
+ labels: Object.fromEntries(entries.map((entry) => [entry.id, entry.label])),
19
+ settings: Object.fromEntries(entries.map((entry) => [entry.id, (entry.settings ?? []).map(({ name, option, default: fallback }) => ({ name, option, ...(fallback === undefined ? {} : { default: fallback }) }))])),
20
+ };
21
+ }
22
+ /** Serve's table: every provider the computer package declares. */
23
+ export const KEY_TABLE = keyTableOf(PROVIDERS);
50
24
  const has = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
51
25
  const labelOf = (providerId, table) => (has(table.labels, providerId) ? table.labels[providerId] : providerId);
52
26
  const refused = (code, message) => ({ ok: false, error: { code, message } });
53
- /** Provider `providerId`'s create() options from its saved keys (by the registry's names) and the server's settings. */
27
+ /**
28
+ * Provider `providerId`'s create() options from its saved keys (by its descriptor's names) and the server's settings
29
+ * (each of its descriptor's settings, by name, else its default). An id the table does not list is refused, naming the
30
+ * providers it does.
31
+ */
54
32
  export function providerOptions(providerId, keys, settings = {}, table = KEY_TABLE) {
33
+ // The table is every descriptor's (keyTableOf(PROVIDERS)), so an id it does not list is no provider at all.
55
34
  if (!has(table.keys, providerId))
56
35
  return refused("unsupported", `${providerId} is not a computer provider: ${Object.keys(table.keys).join(", ")}`);
57
36
  const label = labelOf(providerId, table);
@@ -67,8 +46,12 @@ export function providerOptions(providerId, keys, settings = {}, table = KEY_TAB
67
46
  if (missing.length > 0) {
68
47
  return refused("missing_key", `${label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers (PUT /v2/computers/${providerId}/keys)`);
69
48
  }
70
- if (providerId === "modal")
71
- options.app = settings.modalApp?.trim() || DEFAULT_MODAL_APP;
49
+ for (const setting of table.settings && has(table.settings, providerId) ? table.settings[providerId] : []) {
50
+ const given = has(settings, setting.name) ? settings[setting.name]?.trim() : undefined;
51
+ const value = given || setting.default;
52
+ if (value !== undefined && value !== "")
53
+ options[setting.option] = value;
54
+ }
72
55
  return { ok: true, options };
73
56
  }
74
57
  /** `text` with every key value in `values` replaced by "[the key]". */
@@ -101,12 +84,8 @@ function wordsFor(code, providerId, said, table) {
101
84
  return `${label}'s settings are not valid.${vendor}`;
102
85
  case "unsupported":
103
86
  return `${label} can't be tested here.${vendor}`;
104
- case "docker":
105
- case "daytona":
106
- case "modal":
107
- case "e2b":
108
- case "orgo":
109
- case "phone":
87
+ // The computer package's one code for a vendor's own failure (ComputerErrorCode "vendor"), whatever the vendor.
88
+ case "vendor":
110
89
  return `${label} answered with an error.${vendor}`;
111
90
  default:
112
91
  return `The test of ${label} failed.${vendor}`;
@@ -1,4 +1,4 @@
1
- import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer, holdShown, type JournalEntry, runViewedKind, takeOverComputer, type ViewedKind } from "./computer-commands.js";
1
+ import { type ComputerHoldAnswer, type ComputerCallOptions, type ComputerCallStore, computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer, type ViewedKind } from "./computer-commands.js";
2
2
  import { type HoldState } from "./workspace/computer-hold.js";
3
3
  export type { ViewedKind } from "./computer-commands.js";
4
4
  export { computerAsk, computerHoldOf, handBackComputer, runViewedKind, takeOverComputer };
@@ -18,9 +18,6 @@ export declare const COMPUTER_ROUTES: ReadonlySet<string>;
18
18
  export declare const TAKE_OVER_MINUTES: number;
19
19
  /** Run `runId`'s desktop or phone, from the store: its kind, whether it is up, and who drives it. */
20
20
  export declare function computerViewOf(store: ComputerCallStore, runId: string, options?: ComputerCallOptions): Promise<ComputerViewRead>;
21
- /** Whether the run's computer is taken over now, for the run read's computer field (run-computer.ts ComputerStateOf):
22
- * from the run's journal and its rows. */
23
- export declare const takenOverIn: (entries: readonly JournalEntry[], commands: Parameters<typeof holdShown>[1]) => boolean;
24
21
  /** How a request to one of the routes came: by the owner's signed-in page, or with a token; whether this server has
25
22
  * accounts (for the refusal's words); its body. */
26
23
  export type ComputerRequest = {
@@ -1,7 +1,8 @@
1
1
  // A run's desktop or phone, as its owner takes it: POST /v2/runs/{id}/computer/take-over and POST .../computer/hand-back
2
2
  // (the hand-back for every kind: a browser's answers its agent's ask, as POST .../browser/hand-back does). Owner-only, as
3
- // a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer and the live
4
- // viewer are tl-browser's; computerViewOf is the store-backed read of the run's computer it can build on.
3
+ // a run's browser is: the owner's password session in the console, never a token. GET /v2/runs/{id}/computer is answered by
4
+ // server.ts from computerView (computer-view.ts) over computerHoldOf; computerViewOf is the store-backed read of the run's
5
+ // computer the take-over tests check against.
5
6
  //
6
7
  // Everything is read from the one store (computer-commands.ts): the run's computer is up, and who drives it, as the run's
7
8
  // runner committed them to the run's journal; a take-over or hand-back is a command row the runner applies to the run's
@@ -26,9 +27,6 @@ export async function computerViewOf(store, runId, options = {}) {
26
27
  return { kind, state: "none", hold: "agent", why: `this run's ${kind} is not up now` };
27
28
  return { kind, state: "live", hold: holdShown(hold, await store.commands(runId, 0)).state };
28
29
  }
29
- /** Whether the run's computer is taken over now, for the run read's computer field (run-computer.ts ComputerStateOf):
30
- * from the run's journal and its rows. */
31
- export const takenOverIn = (entries, commands) => holdShown(holdIn(entries), commands).state === "person";
32
30
  /**
33
31
  * One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`: { hold, outcome? }, or an
34
32
  * ApiError. A token is refused (forbidden): a take-over drives the computer, so it takes the owner's signed-in page, as a
@@ -7,16 +7,21 @@ export type GpuSetting = {
7
7
  readonly type: string;
8
8
  readonly count: number;
9
9
  };
10
- /** The setting as a revision keeps it. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. */
10
+ /** The setting as a revision keeps it. `image`: one the provider's descriptor offers for the kind (Orgo's `windows`);
11
+ * absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. */
11
12
  export type ComputerSetting = {
12
13
  readonly kind: "none";
13
14
  } | {
14
15
  readonly kind: "sandbox";
15
16
  readonly provider: string;
17
+ readonly image?: string;
16
18
  readonly gpu?: GpuSetting;
19
+ readonly persistent?: boolean;
17
20
  } | {
18
21
  readonly kind: Exclude<ComputerKind, "none" | "sandbox">;
19
22
  readonly provider: string;
23
+ readonly image?: string;
24
+ readonly persistent?: boolean;
20
25
  };
21
26
  /** The GPUs a setting asks for, or undefined. */
22
27
  export declare const gpuOf: (computer: {
@@ -34,11 +39,9 @@ export type PlaceView = {
34
39
  export declare const placeOfComputer: (computer: ComputerSetting) => PlaceView;
35
40
  /** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
36
41
  export declare const computerOfPlace: (place: PlaceView) => ComputerSetting;
37
- /** Whether two settings are the one setting: the kind and the provider (a place says no GPUs, so they are not compared). */
42
+ /** Whether two settings are the one setting: the same kind and provider, and the same of each optional field. */
38
43
  export declare const sameComputer: (a: ComputerSetting, b: ComputerSetting) => boolean;
39
- /** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). A
40
- * sandbox's gpu is { type, count } in the words the computer package's checkGpu uses; whether its provider offers that
41
- * type and count is the readiness check's and the claim's (resolve-computer.ts), in checkGpu's own words. */
44
+ /** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). */
42
45
  export declare function computerIssues(value: unknown, field: string): InputIssue[];
43
46
  /** The setting and its place a definition says, from `computer` or `place` (both: they must agree), or undefined when
44
47
  * it says neither. Each is checked already (computerIssues, placeIssues). */
@@ -1,3 +1,12 @@
1
+ // An agent's computer, its one setting for where its tools run (Settings → Computers): `computer: { kind, provider?,
2
+ // image?, gpu?, persistent? }` on its revision. kind is none, sandbox, desktop, phone or browser; provider names one of
3
+ // the computer providers (the computer package's kind registry), and is absent for none; image names one the provider
4
+ // offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count }; persistent: true keeps the
5
+ // agent's own computer between its runs, where the configuration declares persistence. The v2 API's `place` is this
6
+ // setting's view, one to one where it can say it: {mode: "runner"} is {kind: "none"}, and {mode: "sandbox", box: X} is
7
+ // {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
8
+ // on the runner, so its place reads runner.
9
+ import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
1
10
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2
11
  /** The kinds of computer an agent can be given. */
3
12
  export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"];
@@ -6,42 +15,96 @@ export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"]
6
15
  const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
7
16
  /** The GPUs a setting asks for, or undefined. */
8
17
  export const gpuOf = (computer) => (computer.kind === "sandbox" ? computer.gpu : undefined);
18
+ /**
19
+ * What a computer of a kind other than none may say beside its kind and provider: the kinds that take it (absent: any),
20
+ * and its own rule, the issues of a value that is wrong at `field`. The providers' offers are the server's, so only the
21
+ * shape is checked here. A sandbox's gpu is { type, count } in the words the computer package's checkGpu uses; whether
22
+ * its provider offers that type and count is the readiness check's and the claim's (resolve-computer.ts).
23
+ */
24
+ const OPTIONAL = {
25
+ image: {
26
+ check: (value, field) => (typeof value === "string" && value.trim() !== "" && value === value.trim() ? [] : [{ field, reason: "invalid", message: `${field} is the name of an image the provider offers for the kind (GET /computers lists them), with no spaces around it` }]),
27
+ },
28
+ // An agent's own computer, kept between its runs (workspace/agent-computer.ts): true asks for it, where the provider's
29
+ // configuration keeps one (persistenceIssues); false or absent is a fresh computer for each run.
30
+ persistent: {
31
+ check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is true (this agent keeps its own computer between runs) or false (a fresh one for each run)` }]),
32
+ },
33
+ gpu: {
34
+ kinds: ["sandbox"],
35
+ check: (gpu, field) => {
36
+ if (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count"))
37
+ return [{ field, reason: "wrong_type", message: "gpu is { type, count }: a GPU type this provider declares, and how many" }];
38
+ if (typeof gpu.type !== "string" || gpu.type === "")
39
+ return [{ field: `${field}.type`, reason: "missing", message: "gpu.type is a GPU type the provider declares (GET /v2/computers lists each provider's)" }];
40
+ if (!GPU_TYPE.test(gpu.type))
41
+ return [{ field: `${field}.type`, reason: "wrong_type", message: `gpu.type ${JSON.stringify(gpu.type)} is not a GPU type name: letters, digits, dots, underscores and dashes, as GET /v2/computers lists each provider's` }];
42
+ if (!Number.isSafeInteger(gpu.count) || gpu.count < 1)
43
+ return [{ field: `${field}.count`, reason: "wrong_type", message: `gpu.count ${JSON.stringify(gpu.count)} is not a whole number from 1` }];
44
+ return [];
45
+ },
46
+ },
47
+ };
9
48
  /** The place the setting reads as: sandbox on its provider, else the runner (no computer holds the run's folder). */
10
49
  export const placeOfComputer = (computer) => (computer.kind === "sandbox" ? { mode: "sandbox", box: computer.provider } : { mode: "runner" });
11
50
  /** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
12
51
  export const computerOfPlace = (place) => (place.mode === "sandbox" ? { kind: "sandbox", provider: place.box } : { kind: "none" });
13
- /** Whether two settings are the one setting: the kind and the provider (a place says no GPUs, so they are not compared). */
14
- export const sameComputer = (a, b) => a.kind === b.kind && (a.kind === "none" || a.provider === b.provider);
15
- /** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). A
16
- * sandbox's gpu is { type, count } in the words the computer package's checkGpu uses; whether its provider offers that
17
- * type and count is the readiness check's and the claim's (resolve-computer.ts), in checkGpu's own words. */
52
+ /** Whether two settings are the one setting: the same kind and provider, and the same of each optional field. */
53
+ export const sameComputer = (a, b) => {
54
+ if (a.kind !== b.kind)
55
+ return false;
56
+ if (a.kind === "none" || b.kind === "none")
57
+ return true;
58
+ const one = a;
59
+ const other = b;
60
+ return a.provider === b.provider && Object.keys(OPTIONAL).every((key) => JSON.stringify(one[key]) === JSON.stringify(other[key]));
61
+ };
62
+ /** What is wrong with `value` as a computer setting, at `field`: its shape only (the providers are the server's). */
18
63
  export function computerIssues(value, field) {
19
64
  const bad = (reason, message, fix) => [{ field, reason, message, ...(fix ? { fix } : {}) }];
65
+ const keeps = ["kind", "provider", ...Object.keys(OPTIONAL)];
20
66
  if (!isObject(value))
21
- return bad("wrong_type", `${field} is an object: {kind}, or {kind, provider}, and a sandbox's optional gpu`);
22
- const extra = Object.keys(value).filter((key) => key !== "kind" && key !== "provider" && key !== "gpu");
67
+ return bad("wrong_type", `${field} is an object: {kind}, or {kind, provider}, with ${Object.keys(OPTIONAL).join(" and ")} where its kind takes them`);
68
+ const extra = Object.keys(value).filter((key) => !keeps.includes(key));
23
69
  if (extra.length)
24
- return bad("not_allowed", `${field} keeps only kind, provider and a sandbox's gpu, not ${extra.join(" or ")}`, `Remove ${extra.map((key) => `${field}.${key}`).join(" and ")}.`);
70
+ return bad("not_allowed", `${field} keeps only ${keeps.join(", ")}, not ${extra.join(" or ")}`, `Remove ${extra.map((key) => `${field}.${key}`).join(" and ")}.`);
25
71
  if (typeof value.kind !== "string" || !COMPUTER_KINDS.includes(value.kind))
26
72
  return bad(value.kind === undefined ? "missing" : "not_an_option", `${field}.kind is one of ${COMPUTER_KINDS.join(", ")}`);
27
- if (value.gpu !== undefined && value.kind !== "sandbox")
28
- return bad("not_allowed", `only a sandbox computer takes a gpu, not a ${value.kind} one`, `Remove ${field}.gpu.`);
29
- if (value.kind === "none")
30
- return value.provider === undefined ? [] : bad("not_allowed", "no computer names no provider", `Remove ${field}.provider.`);
31
- if (typeof value.provider !== "string" || value.provider === "")
32
- return bad("missing", `a ${value.kind} computer names its provider (Settings → Computers lists them)`);
33
- if (value.gpu !== undefined) {
34
- const gpu = value.gpu;
35
- if (!isObject(gpu) || Object.keys(gpu).some((key) => key !== "type" && key !== "count"))
36
- return [{ field: `${field}.gpu`, reason: "wrong_type", message: "gpu is { type, count }: a GPU type this provider declares, and how many" }];
37
- if (typeof gpu.type !== "string" || gpu.type === "")
38
- return [{ field: `${field}.gpu.type`, reason: "missing", message: "gpu.type is a GPU type the provider declares (GET /v2/computers lists each provider's)" }];
39
- if (!GPU_TYPE.test(gpu.type))
40
- return [{ field: `${field}.gpu.type`, reason: "wrong_type", message: `gpu.type ${JSON.stringify(gpu.type)} is not a GPU type name: letters, digits, dots, underscores and dashes, as GET /v2/computers lists each provider's` }];
41
- if (!Number.isSafeInteger(gpu.count) || gpu.count < 1)
42
- return [{ field: `${field}.gpu.count`, reason: "wrong_type", message: `gpu.count ${JSON.stringify(gpu.count)} is not a whole number from 1` }];
73
+ const kind = value.kind;
74
+ for (const [key, { kinds }] of Object.entries(OPTIONAL)) {
75
+ if (value[key] !== undefined && kinds !== undefined && !kinds.includes(kind))
76
+ return bad("not_allowed", `only a ${kinds.join(" or ")} computer takes a ${key}, not a ${kind} one`, `Remove ${field}.${key}.`);
77
+ }
78
+ if (kind === "none") {
79
+ const named = keeps.filter((key) => key !== "kind" && value[key] !== undefined);
80
+ return named.length === 0 ? [] : bad("not_allowed", `no computer names no ${named.join(" or ")}`, `Remove ${named.map((key) => `${field}.${key}`).join(" and ")}.`);
43
81
  }
44
- return [];
82
+ if (typeof value.provider !== "string" || value.provider === "")
83
+ return bad("missing", `a ${kind} computer names its provider (Settings → Computers lists them)`);
84
+ const issues = Object.entries(OPTIONAL).flatMap(([key, { check }]) => (value[key] === undefined ? [] : check(value[key], `${field}.${key}`)));
85
+ if (issues.length > 0 || value.persistent !== true)
86
+ return issues;
87
+ return persistenceIssues(kind, value.provider, typeof value.image === "string" ? value.image : undefined, `${field}.persistent`);
88
+ }
89
+ /**
90
+ * Why `persistent: true` is refused, at `field`: the configuration the setting selects keeps no computer for an agent.
91
+ * Read from the computer package's registry, each configuration's declared persistence (kinds.test holds it equal to the
92
+ * built provider's), so a save needs no vendor call. A provider the registry does not list (a --faux one, or one the
93
+ * readiness check names as unknown) is left to the claim's refusal.
94
+ */
95
+ function persistenceIssues(kind, provider, image, field) {
96
+ const entry = PROVIDERS.find((one) => one.id === provider);
97
+ if (!entry)
98
+ return [];
99
+ const configuration = configurationOf(entry.capabilities.filter((one) => serves(one, kind)), image, entry.defaultImage?.[kind]);
100
+ if (!configuration || configuration.persistence !== undefined)
101
+ return [];
102
+ return [{
103
+ field,
104
+ reason: "not_allowed",
105
+ message: `${entry.label}'s ${image === undefined ? "default" : JSON.stringify(image)} ${kind} keeps no computer for an agent between runs: it declares no persistence`,
106
+ fix: `Remove ${field}, or pick a computer that keeps one (GET /v2/computers shows which do).`,
107
+ }];
45
108
  }
46
109
  /** The setting and its place a definition says, from `computer` or `place` (both: they must agree), or undefined when
47
110
  * it says neither. Each is checked already (computerIssues, placeIssues). */
@@ -60,8 +123,10 @@ export function settingOfDefinition(definition) {
60
123
  export function settingConflict(computer, place, field) {
61
124
  if (!isObject(computer) || !isObject(place) || computerIssues(computer, `${field}.computer`).length)
62
125
  return [];
126
+ // A place says a kind and a provider only: a computer's image or GPUs are not ones it can contradict.
63
127
  const said = computerOfPlace(place);
64
- if (sameComputer(computer, said))
128
+ const { kind, provider } = computer;
129
+ if (sameComputer((kind === "none" ? { kind } : { kind, provider }), said))
65
130
  return [];
66
131
  return [{ field: `${field}.place`, reason: "invalid", message: "computer and place say two settings: give one (place is computer's v2 view)", fix: `Remove ${field}.place, or make it ${JSON.stringify(placeOfComputer(computer))}.` }];
67
132
  }
@@ -18,6 +18,10 @@ export type ComputerAnswer = {
18
18
  state: "none";
19
19
  kind: ComputerKind;
20
20
  hold: ComputerHold;
21
+ ended?: {
22
+ at: string;
23
+ why: string;
24
+ };
21
25
  } | {
22
26
  state: "live";
23
27
  kind: ComputerKind;
@@ -32,7 +36,12 @@ export declare function computerView(deps: {
32
36
  } | undefined>;
33
37
  /** The run's computer, read only when no viewer is open. */
34
38
  computer(): ComputerOf;
35
- /** Who drives now. TODO: hold from computerHoldOf(store, runId), the store-backed take-over; until then the agent
36
- * drives, as no seam answers. */
39
+ /** Who drives now. */
37
40
  hold?(): ComputerHold;
41
+ /** Why the run's browser is not up, read only for a `none` browser: let go while the run waited for its person, and none
42
+ * opened since (browser-wait-ended.ts), with when; undefined otherwise. */
43
+ ended?(): Promise<{
44
+ at: string;
45
+ why: string;
46
+ } | undefined>;
38
47
  }): Promise<ComputerAnswer>;
@@ -10,5 +10,6 @@ export async function computerView(deps) {
10
10
  const computer = deps.computer();
11
11
  if ("off" in computer)
12
12
  return { state: "off", hold: "agent", why: computer.off };
13
- return { state: "none", kind: computer.kind, hold };
13
+ const ended = computer.kind === "browser" ? await deps.ended?.() : undefined;
14
+ return ended ? { state: "none", kind: computer.kind, hold, ended } : { state: "none", kind: computer.kind, hold };
14
15
  }