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

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 (466) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +341 -208
  3. package/dist/adapters.d.ts +3 -4
  4. package/dist/adapters.js +18 -15
  5. package/dist/agent-rows.d.ts +99 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +75 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/archil-settings.d.ts +11 -1
  16. package/dist/archil-settings.js +10 -0
  17. package/dist/bash-read-only.d.ts +35 -0
  18. package/dist/bash-read-only.js +778 -0
  19. package/dist/box-settings.d.ts +3 -23
  20. package/dist/box-settings.js +7 -51
  21. package/dist/boxes.d.ts +17 -0
  22. package/dist/boxes.js +27 -20
  23. package/dist/browser-commands.d.ts +5 -2
  24. package/dist/browser-commands.js +4 -4
  25. package/dist/browser-computer.d.ts +5 -0
  26. package/dist/browser-computer.js +21 -0
  27. package/dist/browser-cost.d.ts +9 -6
  28. package/dist/browser-cost.js +95 -51
  29. package/dist/browser-live.d.ts +7 -20
  30. package/dist/browser-live.js +15 -93
  31. package/dist/browser-person.d.ts +18 -51
  32. package/dist/browser-person.js +94 -277
  33. package/dist/budget.d.ts +0 -5
  34. package/dist/budget.js +0 -5
  35. package/dist/cap.d.ts +14 -8
  36. package/dist/cap.js +19 -9
  37. package/dist/cli.js +71 -18
  38. package/dist/closed-pipes.d.ts +2 -0
  39. package/dist/closed-pipes.js +13 -0
  40. package/dist/computer-commands.d.ts +2 -0
  41. package/dist/computer-commands.js +2 -0
  42. package/dist/computer-keys.d.ts +20 -10
  43. package/dist/computer-keys.js +36 -54
  44. package/dist/computer-setting.d.ts +20 -3
  45. package/dist/computer-setting.js +58 -10
  46. package/dist/computers.d.ts +35 -2
  47. package/dist/computers.js +72 -11
  48. package/dist/confine.d.ts +120 -0
  49. package/dist/confine.js +436 -0
  50. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  51. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  52. package/dist/console/index.html +2 -2
  53. package/dist/content-filter.d.ts +7 -0
  54. package/dist/content-filter.js +23 -0
  55. package/dist/decision-cap.d.ts +7 -29
  56. package/dist/decision-cap.js +3 -94
  57. package/dist/decision-rows.d.ts +1 -1
  58. package/dist/decision-rows.js +1 -1
  59. package/dist/docker-daemon.d.ts +31 -0
  60. package/dist/docker-daemon.js +56 -0
  61. package/dist/effort-guidance.js +4 -3
  62. package/dist/environment.d.ts +0 -3
  63. package/dist/environment.js +3 -5
  64. package/dist/errors.d.ts +1 -2
  65. package/dist/errors.js +9 -9
  66. package/dist/explain.js +3 -1
  67. package/dist/filed-answer.d.ts +32 -0
  68. package/dist/filed-answer.js +160 -0
  69. package/dist/files.d.ts +1 -3
  70. package/dist/files.js +2 -4
  71. package/dist/github-connection.d.ts +1 -1
  72. package/dist/github-connection.js +25 -7
  73. package/dist/github-faux.d.ts +26 -0
  74. package/dist/github-faux.js +76 -0
  75. package/dist/github.d.ts +6 -2
  76. package/dist/github.js +5 -3
  77. package/dist/graph-served.d.ts +5 -3
  78. package/dist/graph-served.js +14 -6
  79. package/dist/graph-view.d.ts +3 -5
  80. package/dist/graph-view.js +9 -16
  81. package/dist/handed-values.d.ts +9 -0
  82. package/dist/handed-values.js +26 -0
  83. package/dist/harness-install.d.ts +1 -7
  84. package/dist/harness-install.js +1 -18
  85. package/dist/harness-opencode/adapter.d.ts +7 -0
  86. package/dist/harness-opencode/adapter.js +23 -6
  87. package/dist/harness-opencode/harness.js +0 -1
  88. package/dist/harness-opencode/host/policy.js +2 -2
  89. package/dist/harness-opencode/index.d.ts +1 -1
  90. package/dist/harness-opencode/index.js +1 -1
  91. package/dist/harness-opencode/verify.d.ts +17 -0
  92. package/dist/harness-opencode/verify.js +30 -10
  93. package/dist/harness-table.js +6 -1
  94. package/dist/heard.js +1 -1
  95. package/dist/held-fd.d.ts +5 -0
  96. package/dist/held-fd.js +14 -0
  97. package/dist/host-calls.d.ts +20 -0
  98. package/dist/host-calls.js +12 -0
  99. package/dist/host-tools.d.ts +4 -21
  100. package/dist/host-tools.js +4 -61
  101. package/dist/host.d.ts +2 -4
  102. package/dist/host.js +2 -7
  103. package/dist/import-summary.d.ts +1 -5
  104. package/dist/import-summary.js +0 -21
  105. package/dist/import.d.ts +6 -6
  106. package/dist/import.js +14 -15
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +1 -0
  109. package/dist/key-refusal.d.ts +5 -1
  110. package/dist/key-refusal.js +19 -4
  111. package/dist/learn/check.d.ts +8 -2
  112. package/dist/learn/check.js +85 -31
  113. package/dist/learn/folder.d.ts +11 -4
  114. package/dist/learn/folder.js +17 -19
  115. package/dist/learn/grade.d.ts +18 -1
  116. package/dist/learn/grade.js +108 -14
  117. package/dist/learn/index.d.ts +5 -5
  118. package/dist/learn/index.js +5 -5
  119. package/dist/learn/learning.sh +1 -14
  120. package/dist/learn/notes.d.ts +14 -3
  121. package/dist/learn/notes.js +16 -6
  122. package/dist/learn/reflect.d.ts +31 -2
  123. package/dist/learn/reflect.js +83 -6
  124. package/dist/learn/relevance.d.ts +24 -0
  125. package/dist/learn/relevance.js +91 -0
  126. package/dist/learn/secrets.d.ts +7 -1
  127. package/dist/learn/secrets.js +86 -19
  128. package/dist/learn/skills.d.ts +159 -18
  129. package/dist/learn/skills.js +644 -64
  130. package/dist/learned-nodes.d.ts +14 -0
  131. package/dist/learned-nodes.js +8 -0
  132. package/dist/learned-workflow.d.ts +41 -6
  133. package/dist/learned-workflow.js +153 -18
  134. package/dist/learning-routes.d.ts +49 -4
  135. package/dist/learning-routes.js +113 -31
  136. package/dist/learning-run.d.ts +16 -31
  137. package/dist/learning-run.js +31 -38
  138. package/dist/learning-words.d.ts +12 -5
  139. package/dist/learning-words.js +18 -9
  140. package/dist/learning.d.ts +91 -97
  141. package/dist/learning.js +176 -320
  142. package/dist/live/stream.js +1 -1
  143. package/dist/live/translate.js +12 -2
  144. package/dist/llm.d.ts +4 -1
  145. package/dist/llm.js +4 -2
  146. package/dist/local-models.d.ts +11 -5
  147. package/dist/local-models.js +13 -8
  148. package/dist/mcp-gateway.d.ts +17 -49
  149. package/dist/mcp-gateway.js +55 -136
  150. package/dist/mcp-oauth.d.ts +10 -14
  151. package/dist/mcp-oauth.js +14 -32
  152. package/dist/mcp-probe.d.ts +0 -7
  153. package/dist/mcp-probe.js +4 -10
  154. package/dist/mcp-servers-store.d.ts +18 -18
  155. package/dist/mcp-servers-store.js +12 -14
  156. package/dist/mcp-store.js +3 -4
  157. package/dist/mcp.js +4 -3
  158. package/dist/model.d.ts +9 -7
  159. package/dist/model.js +51 -27
  160. package/dist/monid.d.ts +0 -2
  161. package/dist/monid.js +3 -6
  162. package/dist/openapi.d.ts +8 -1
  163. package/dist/openapi.js +156 -58
  164. package/dist/page.d.ts +1 -3
  165. package/dist/page.js +6 -18
  166. package/dist/paid-calls.d.ts +21 -27
  167. package/dist/paid-calls.js +26 -61
  168. package/dist/pause.d.ts +2 -19
  169. package/dist/pause.js +5 -74
  170. package/dist/port-models.d.ts +10 -3
  171. package/dist/port-models.js +26 -6
  172. package/dist/propose.d.ts +2 -0
  173. package/dist/propose.js +80 -45
  174. package/dist/push-handler.d.ts +1 -1
  175. package/dist/reflect-range.d.ts +25 -0
  176. package/dist/reflect-range.js +30 -0
  177. package/dist/refusal-words.d.ts +5 -1
  178. package/dist/refusal-words.js +5 -1
  179. package/dist/rows.d.ts +1 -1
  180. package/dist/run-cut.d.ts +0 -6
  181. package/dist/run-cut.js +0 -6
  182. package/dist/run-db.d.ts +2 -11
  183. package/dist/run-db.js +2 -37
  184. package/dist/run-launch.d.ts +21 -2
  185. package/dist/run-launch.js +14 -5
  186. package/dist/run-learning-served.d.ts +21 -4
  187. package/dist/run-learning-served.js +23 -13
  188. package/dist/run-reads-over-store.d.ts +5 -3
  189. package/dist/run-reads-over-store.js +25 -14
  190. package/dist/run-secrets.d.ts +1 -1
  191. package/dist/run-timeline-served.d.ts +5 -1
  192. package/dist/run-timeline-served.js +27 -6
  193. package/dist/run-view.d.ts +37 -22
  194. package/dist/run-view.js +85 -38
  195. package/dist/runnable.d.ts +21 -10
  196. package/dist/runnable.js +35 -12
  197. package/dist/runner/adapter-loop.d.ts +36 -5
  198. package/dist/runner/adapter-loop.js +663 -69
  199. package/dist/runner/adapter-run-spec.d.ts +42 -8
  200. package/dist/runner/adapter-run-spec.js +186 -52
  201. package/dist/runner/adapters/index.js +11 -1
  202. package/dist/runner/adapters/pi.d.ts +40 -2
  203. package/dist/runner/adapters/pi.js +110 -27
  204. package/dist/runner/beside.d.ts +38 -3
  205. package/dist/runner/beside.js +54 -5
  206. package/dist/runner/claim-secrets.d.ts +16 -1
  207. package/dist/runner/claim-secrets.js +62 -14
  208. package/dist/runner/cli-run-spec.d.ts +5 -0
  209. package/dist/runner/cli-run-spec.js +159 -41
  210. package/dist/runner/commands.js +1 -1
  211. package/dist/runner/computer-journal.d.ts +15 -2
  212. package/dist/runner/computer-journal.js +41 -5
  213. package/dist/runner/conformance/harness.d.ts +1 -0
  214. package/dist/runner/conformance/harness.js +123 -13
  215. package/dist/runner/conformance/subject.d.ts +4 -1
  216. package/dist/runner/dispatch.d.ts +8 -1
  217. package/dist/runner/dispatch.js +81 -7
  218. package/dist/runner/end-of-run.d.ts +8 -2
  219. package/dist/runner/end-of-run.js +10 -4
  220. package/dist/runner/github-app.d.ts +7 -2
  221. package/dist/runner/github-app.js +47 -16
  222. package/dist/runner/harness-loops.d.ts +15 -2
  223. package/dist/runner/harness-loops.js +38 -2
  224. package/dist/runner/journal-kinds.d.ts +60 -6
  225. package/dist/runner/journal-kinds.js +43 -5
  226. package/dist/runner/journal-reader.d.ts +1 -1
  227. package/dist/runner/journal-reader.js +2 -2
  228. package/dist/runner/learning-ask.d.ts +4 -0
  229. package/dist/runner/learning-ask.js +15 -1
  230. package/dist/runner/learning-end.d.ts +18 -3
  231. package/dist/runner/learning-end.js +194 -20
  232. package/dist/runner/learning-loop.d.ts +7 -0
  233. package/dist/runner/learning-loop.js +36 -8
  234. package/dist/runner/learning-seed.d.ts +6 -0
  235. package/dist/runner/learning-seed.js +6 -0
  236. package/dist/runner/loop-contract.d.ts +4 -0
  237. package/dist/runner/main.d.ts +61 -9
  238. package/dist/runner/main.js +144 -20
  239. package/dist/runner/mcp-claim.d.ts +3 -0
  240. package/dist/runner/mcp-claim.js +7 -3
  241. package/dist/runner/mcp-github.d.ts +11 -2
  242. package/dist/runner/mcp-github.js +55 -4
  243. package/dist/runner/mcp-run.d.ts +2 -0
  244. package/dist/runner/mcp-run.js +16 -5
  245. package/dist/runner/memory-claim.d.ts +9 -0
  246. package/dist/runner/memory-claim.js +25 -0
  247. package/dist/runner/metrics.d.ts +46 -1
  248. package/dist/runner/metrics.js +156 -1
  249. package/dist/runner/model-route.d.ts +16 -0
  250. package/dist/runner/model-route.js +134 -10
  251. package/dist/runner/reflect-hook.d.ts +12 -1
  252. package/dist/runner/reflect-hook.js +33 -3
  253. package/dist/runner/runner.d.ts +20 -0
  254. package/dist/runner/runner.js +146 -18
  255. package/dist/runner/spec-holds.d.ts +7 -2
  256. package/dist/runner/spec-holds.js +4 -3
  257. package/dist/runner/store-port.d.ts +1 -1
  258. package/dist/runner/store-secrets.d.ts +3 -3
  259. package/dist/runner/store-secrets.js +8 -12
  260. package/dist/runner/text-tools.d.ts +44 -0
  261. package/dist/runner/text-tools.js +237 -0
  262. package/dist/runner/workflow-host.d.ts +7 -2
  263. package/dist/runner/workflow-host.js +3 -1
  264. package/dist/runner/workflow-loop.d.ts +10 -1
  265. package/dist/runner/workflow-loop.js +14 -6
  266. package/dist/runner/workflow-spec.d.ts +21 -0
  267. package/dist/runner/workflow-spec.js +217 -93
  268. package/dist/runs-over-store.d.ts +14 -3
  269. package/dist/runs-over-store.js +100 -23
  270. package/dist/seal-key.d.ts +0 -2
  271. package/dist/seal-key.js +5 -45
  272. package/dist/sealed-settings-store.d.ts +19 -4
  273. package/dist/sealed-settings-store.js +9 -9
  274. package/dist/sealing.d.ts +4 -0
  275. package/dist/sealing.js +20 -0
  276. package/dist/secret-cut.d.ts +1 -1
  277. package/dist/secret-cut.js +1 -1
  278. package/dist/secret-name.d.ts +9 -0
  279. package/dist/secret-name.js +15 -0
  280. package/dist/secret-writes.d.ts +0 -1
  281. package/dist/secret-writes.js +0 -1
  282. package/dist/server-fs.d.ts +4 -0
  283. package/dist/server-fs.js +8 -2
  284. package/dist/server-lock.d.ts +0 -24
  285. package/dist/server-lock.js +5 -85
  286. package/dist/server-secrets-store.d.ts +4 -4
  287. package/dist/server-secrets-store.js +9 -31
  288. package/dist/server-secrets.d.ts +4 -9
  289. package/dist/server-secrets.js +12 -36
  290. package/dist/server.d.ts +37 -56
  291. package/dist/server.js +322 -134
  292. package/dist/sign-ins-store.d.ts +34 -36
  293. package/dist/sign-ins-store.js +27 -38
  294. package/dist/sign-ins.d.ts +2 -119
  295. package/dist/sign-ins.js +5 -311
  296. package/dist/standard-webhooks.d.ts +1 -1
  297. package/dist/standard-webhooks.js +1 -1
  298. package/dist/stats.d.ts +3 -2
  299. package/dist/stats.js +1 -1
  300. package/dist/stop-signals.d.ts +4 -2
  301. package/dist/stop-signals.js +5 -3
  302. package/dist/store/agent-body.d.ts +12 -2
  303. package/dist/store/agent-body.js +22 -4
  304. package/dist/store/deadline.d.ts +18 -0
  305. package/dist/store/deadline.js +45 -0
  306. package/dist/store/index.d.ts +2 -2
  307. package/dist/store/index.js +2 -2
  308. package/dist/store/open.d.ts +6 -3
  309. package/dist/store/open.js +2 -2
  310. package/dist/store/postgres/connection.d.ts +22 -2
  311. package/dist/store/postgres/connection.js +211 -41
  312. package/dist/store/postgres/migrate.d.ts +4 -0
  313. package/dist/store/postgres/migrate.js +9 -2
  314. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  315. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  316. package/dist/store/postgres/store.d.ts +9 -2
  317. package/dist/store/postgres/store.js +9 -0
  318. package/dist/store/schema.js +1 -1
  319. package/dist/store/seal.js +2 -2
  320. package/dist/store/sqlite/connection.js +14 -5
  321. package/dist/store/sqlite/run-patch.d.ts +3 -0
  322. package/dist/store/sqlite/run-patch.js +3 -0
  323. package/dist/store/sqlite/store.js +41 -12
  324. package/dist/store/store.d.ts +35 -6
  325. package/dist/store/store.js +12 -2
  326. package/dist/store-reads/cap.d.ts +1 -1
  327. package/dist/store-reads/cap.js +22 -4
  328. package/dist/store-reads/journal.d.ts +9 -6
  329. package/dist/store-reads/journal.js +129 -18
  330. package/dist/store-reads/learning.d.ts +82 -8
  331. package/dist/store-reads/learning.js +184 -11
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-reads/workflow.js +1 -1
  334. package/dist/store-view.d.ts +19 -1
  335. package/dist/store-view.js +95 -27
  336. package/dist/template-eval.d.ts +60 -4
  337. package/dist/template-eval.js +120 -54
  338. package/dist/templates.d.ts +33 -14
  339. package/dist/templates.js +82 -46
  340. package/dist/timeline/group.d.ts +33 -0
  341. package/dist/timeline/group.js +77 -0
  342. package/dist/timeline/index.d.ts +7 -0
  343. package/dist/timeline/index.js +7 -0
  344. package/dist/timeline/labels.d.ts +79 -0
  345. package/dist/timeline/labels.js +150 -0
  346. package/dist/timeline/origin.d.ts +56 -0
  347. package/dist/timeline/origin.js +92 -0
  348. package/dist/timeline/render-text.d.ts +11 -0
  349. package/dist/timeline/render-text.js +62 -0
  350. package/dist/timeline/timeline.d.ts +282 -0
  351. package/dist/timeline/timeline.js +1308 -0
  352. package/dist/timeline/util.d.ts +17 -0
  353. package/dist/timeline/util.js +49 -0
  354. package/dist/tool-budget.d.ts +18 -0
  355. package/dist/tool-budget.js +50 -0
  356. package/dist/tool-gate.d.ts +47 -218
  357. package/dist/tool-gate.js +87 -545
  358. package/dist/tool-keys-store.d.ts +11 -12
  359. package/dist/tool-keys-store.js +24 -31
  360. package/dist/tool-keys.d.ts +5 -101
  361. package/dist/tool-keys.js +8 -267
  362. package/dist/tool-plane.d.ts +23 -52
  363. package/dist/tool-plane.js +23 -81
  364. package/dist/tool-settings-store.d.ts +1 -2
  365. package/dist/tool-settings-store.js +5 -8
  366. package/dist/tools.d.ts +67 -25
  367. package/dist/tools.js +170 -119
  368. package/dist/trigger-adapter.d.ts +2 -2
  369. package/dist/trigger-targets.d.ts +13 -1
  370. package/dist/trigger-targets.js +31 -1
  371. package/dist/triggers.d.ts +2 -2
  372. package/dist/triggers.js +3 -3
  373. package/dist/turn-end.d.ts +1 -1
  374. package/dist/turn-end.js +1 -1
  375. package/dist/turns.d.ts +0 -6
  376. package/dist/turns.js +0 -19
  377. package/dist/uploads.d.ts +28 -5
  378. package/dist/uploads.js +83 -10
  379. package/dist/usage.d.ts +1 -49
  380. package/dist/usage.js +3 -84
  381. package/dist/validate.d.ts +4 -0
  382. package/dist/validate.js +33 -14
  383. package/dist/webhooks.d.ts +102 -76
  384. package/dist/webhooks.js +266 -233
  385. package/dist/workflow-run.d.ts +114 -0
  386. package/dist/workflow-run.js +144 -0
  387. package/dist/workspace/archil-claim.d.ts +2 -2
  388. package/dist/workspace/archil-claim.js +4 -3
  389. package/dist/workspace/archil-disk.d.ts +10 -1
  390. package/dist/workspace/archil-disk.js +4 -0
  391. package/dist/workspace/archil-exec.d.ts +12 -2
  392. package/dist/workspace/archil-exec.js +16 -0
  393. package/dist/workspace/archil.d.ts +2 -2
  394. package/dist/workspace/archil.js +25 -5
  395. package/dist/workspace/attach.js +2 -0
  396. package/dist/workspace/beneath.d.ts +19 -0
  397. package/dist/workspace/beneath.js +106 -0
  398. package/dist/workspace/computer-deps.d.ts +26 -9
  399. package/dist/workspace/computer-deps.js +144 -43
  400. package/dist/workspace/computer-for-claim.d.ts +17 -14
  401. package/dist/workspace/computer-for-claim.js +99 -26
  402. package/dist/workspace/computer-hold.d.ts +6 -1
  403. package/dist/workspace/computer-hold.js +6 -1
  404. package/dist/workspace/computer-janitor.d.ts +47 -0
  405. package/dist/workspace/computer-janitor.js +182 -0
  406. package/dist/workspace/computer-ledger.d.ts +1 -8
  407. package/dist/workspace/computer-ledger.js +0 -3
  408. package/dist/workspace/computer-providers.d.ts +5 -3
  409. package/dist/workspace/computer-providers.js +11 -9
  410. package/dist/workspace/grep-worker.d.ts +5 -0
  411. package/dist/workspace/grep-worker.js +9 -6
  412. package/dist/workspace/hands.d.ts +5 -2
  413. package/dist/workspace/hands.js +4 -3
  414. package/dist/workspace/index.d.ts +6 -5
  415. package/dist/workspace/index.js +4 -4
  416. package/dist/workspace/local.d.ts +14 -2
  417. package/dist/workspace/local.js +170 -43
  418. package/dist/workspace/paths.js +3 -2
  419. package/dist/workspace/pi-env.d.ts +4 -0
  420. package/dist/workspace/pi-env.js +3 -2
  421. package/dist/workspace/resolve-computer.d.ts +55 -10
  422. package/dist/workspace/resolve-computer.js +66 -14
  423. package/dist/workspace/run-tools.d.ts +15 -31
  424. package/dist/workspace/run-tools.js +19 -30
  425. package/dist/workspace/workspace.d.ts +5 -0
  426. package/dist/workspace-paths.d.ts +0 -17
  427. package/dist/workspace-paths.js +1 -41
  428. package/dist/workspace.d.ts +0 -17
  429. package/dist/workspace.js +4 -110
  430. package/package.json +14 -14
  431. package/skills/agentrun-serve/SKILL.md +1 -1
  432. package/templates/README.md +11 -5
  433. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  434. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  435. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  436. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  437. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  438. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  439. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  440. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  441. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  442. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  443. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  444. package/templates/market-monitor/agent.md +2 -2
  445. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  446. package/templates/release-notes/agent.md +11 -0
  447. package/dist/bound-files.d.ts +0 -4
  448. package/dist/bound-files.js +0 -164
  449. package/dist/coding-tools.d.ts +0 -47
  450. package/dist/coding-tools.js +0 -189
  451. package/dist/computer-adb.d.ts +0 -12
  452. package/dist/computer-adb.js +0 -14
  453. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  454. package/dist/console/assets/index-DvW6Aled.css +0 -1
  455. package/dist/grade.d.ts +0 -63
  456. package/dist/grade.js +0 -150
  457. package/dist/mcp-servers.d.ts +0 -269
  458. package/dist/mcp-servers.js +0 -456
  459. package/dist/packs.d.ts +0 -71
  460. package/dist/packs.js +0 -180
  461. package/dist/sealed-settings.d.ts +0 -60
  462. package/dist/sealed-settings.js +0 -171
  463. package/dist/sessions.d.ts +0 -6
  464. package/dist/sessions.js +0 -109
  465. package/dist/workspace/computer-serves.d.ts +0 -12
  466. package/dist/workspace/computer-serves.js +0 -15
@@ -1,4 +1,4 @@
1
- import { type DockerVolume } from "@parcha/agentrun-computer";
1
+ import { type ComputerSpec, type DockerVolume } from "@parcha/agentrun-computer";
2
2
  import type { DockerPaths } from "../box-paths.js";
3
3
  import { type HostRead } from "../docker-host-addresses.js";
4
4
  import type { ProviderFactories } from "../computer-keys.js";
@@ -7,10 +7,22 @@ import { type KeyEnv } from "../key-meta.js";
7
7
  import type { Store } from "../store/index.js";
8
8
  import { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type OpenComputerView } from "./computer-for-claim.js";
9
9
  import { type ProviderLoad } from "./computer-providers.js";
10
- import type { KindRegistry } from "./resolve-computer.js";
10
+ import { type KindRegistry } from "./resolve-computer.js";
11
11
  /** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
12
12
  * box's lifetime). The clean end is the run's release. */
13
13
  export declare const COMPUTER_LIFETIME_MS: number;
14
+ /** The settings that size a Docker computer (a sandbox or a desktop): its CPUs, its memory (swap included) and how many
15
+ * processes and threads it may hold at once. Unset, the Docker provider's own defaults hold. A vendor's computer sizes
16
+ * itself and is never given them. */
17
+ export declare const BOX_CPUS_ENV = "AGENTRUN_BOX_CPUS";
18
+ export declare const BOX_MEMORY_ENV = "AGENTRUN_BOX_MEMORY";
19
+ export declare const BOX_PIDS_ENV = "AGENTRUN_BOX_PIDS";
20
+ /** A Docker computer's size, as the Docker provider takes it on its spec. */
21
+ export type DockerLimits = Pick<ComputerSpec, "cpus" | "memoryMb" | "pids">;
22
+ /** A Docker computer's size from `env`'s AGENTRUN_BOX_CPUS, _MEMORY and _PIDS: each one set, as its spec field; none set,
23
+ * none, so the provider's defaults hold. A value the Docker provider would refuse at every create throws, in its own
24
+ * words, naming the setting and what it takes: the server's start reads them (startServe), so no run meets one. */
25
+ export declare function dockerLimitsOf(env: KeyEnv): DockerLimits;
14
26
  /** The Docker host's own addresses, for a Docker provider whose interfaces aren't that host's (the server in a
15
27
  * container): a comma list of IP addresses. The Docker provider's egress proxy refuses them as the host's, so a
16
28
  * computer's allow-list never reaches the host itself; without them it refuses any allow-list there. */
@@ -53,19 +65,24 @@ export interface ComputerDepsOptions {
53
65
  readonly hostAddresses?: () => Promise<HostRead>;
54
66
  /** Whether a provider that binds a folder of this machine answers here now (Docker), for the Mode 1 default. */
55
67
  readonly answers?: ComputerForClaimDeps["answers"];
68
+ /** This machine's Docker daemon, asked when a Docker launch fails (docker-daemon.ts dockerDaemonCheck over `env`
69
+ * unless given; none under --faux, whose launch is its own). */
70
+ readonly daemon?: ComputerForClaimDeps["daemon"];
56
71
  /** The live view's registration for a desktop or a phone (proxy-only): absent, no view is opened. */
57
72
  readonly openComputerView?: OpenComputerView;
58
73
  /** --faux's computers (faux-computers.ts), in place of the computer package's: their kind registry, key table, launch
59
74
  * and factories. */
60
75
  readonly faux?: FauxComputers;
61
76
  }
62
- /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (Docker's: the
63
- * owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox the package's recipe; any other provider's: its registry
64
- * entry's defaultImage for the kind, the computer package's PROVIDERS[].defaultImage; a kind with none refused in
65
- * words, a Docker desktop's saying it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its network. box_allow is a
66
- * sandbox's egress list: a sandbox with none, or "none", has no network; a browser, desktop or phone with none has its
67
- * provider's own ("open"); an explicit list or "none" applies to any kind, narrowed to "none" for a provider that makes
68
- * no other (networkOf). No key and no environment. */
77
+ /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (a provider that
78
+ * prepares its own image, its descriptor's prepareImage: the owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox
79
+ * the package's recipe, which its prepareImage() builds; any other provider's: its descriptor's defaultImage for the
80
+ * kind, the computer package's PROVIDERS[].defaultImage; a kind with none refused in words, a prepared desktop's saying
81
+ * it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the
82
+ * run's release), and its network (networkOf): the run's box_allow, or this server's own (AGENTRUN_BOX_ALLOW, read
83
+ * from `env`) for a launch that names none; and the size of a computer on this machine's container engine (its
84
+ * descriptor's `local`), AGENTRUN_BOX_CPUS, _MEMORY and _PIDS (dockerLimitsOf, read once here): a vendor's computer
85
+ * sizes itself. No key and no environment. */
69
86
  export declare function computerSpecOf(env: KeyEnv): ComputerForClaimDeps["spec"];
70
87
  /** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
71
88
  * image row, the computer's noun for the box's. */
@@ -17,18 +17,70 @@
17
17
  import { isIP } from "node:net";
18
18
  import { posix } from "node:path";
19
19
  import { DEFAULT_DOCKER_IMAGE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, PROVIDERS, providerFor, readBackOf, servingRefusals, SETTING_KINDS } from "@parcha/agentrun-computer";
20
+ // The local container engine's provider, for its check() of the operator's size settings at the start (dockerLimitsOf).
21
+ import { DockerProvider } from "@parcha/agentrun-computer/docker";
20
22
  import { DOCKER_IMAGE_ENV } from "../box-image.js";
23
+ import { dockerDaemonCheck } from "../docker-daemon.js";
21
24
  import { unionOf } from "../docker-host-addresses.js";
22
25
  import { envValue, keyReader } from "../key-meta.js";
26
+ import { boxAllowOf, boxAllowSetIn } from "../box-settings.js";
23
27
  import { readLaunchBody } from "../run-launch.js";
24
28
  import { computerForClaim } from "./computer-for-claim.js";
25
29
  import { storeLedger } from "./computer-ledger.js";
26
30
  import { computerProviderFactories, computerProviderMakers } from "./computer-providers.js";
31
+ import { needsNetwork, noNetworkRefusal, vendorNetworkOnly } from "./resolve-computer.js";
27
32
  /** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
28
33
  * box's lifetime). The clean end is the run's release. */
29
34
  export const COMPUTER_LIFETIME_MS = 24 * 60 * 60_000;
30
35
  /** A computer this server cannot make here, with the code the run fails with and its words. */
31
36
  const refused = (words) => Object.assign(new Error(words), { code: "computer_unavailable" });
37
+ /** The settings that size a Docker computer (a sandbox or a desktop): its CPUs, its memory (swap included) and how many
38
+ * processes and threads it may hold at once. Unset, the Docker provider's own defaults hold. A vendor's computer sizes
39
+ * itself and is never given them. */
40
+ export const BOX_CPUS_ENV = "AGENTRUN_BOX_CPUS";
41
+ export const BOX_MEMORY_ENV = "AGENTRUN_BOX_MEMORY";
42
+ export const BOX_PIDS_ENV = "AGENTRUN_BOX_PIDS";
43
+ /** Each setting's spec field and what it takes, in an operator's words. */
44
+ const LIMIT_SETTINGS = [
45
+ { name: BOX_CPUS_ENV, field: "cpus", form: "a number of CPUs, such as 2 or 1.5" },
46
+ { name: BOX_MEMORY_ENV, field: "memoryMb", form: "a size with its unit (b, k, m or g), such as 512m or 4g" },
47
+ { name: BOX_PIDS_ENV, field: "pids", form: "a whole number of processes and threads, such as 1024" },
48
+ ];
49
+ /** A size's units as Docker reads them, each 1024 of the one before, in MiB. */
50
+ const SIZE_MIB = { b: 1 / (1024 * 1024), k: 1 / 1024, m: 1, g: 1024 };
51
+ /** One setting's value as its spec field: a number where it reads as one, else NaN, which the provider's check refuses. */
52
+ const LIMIT_VALUE = {
53
+ cpus: (value) => (/^\d+(\.\d+)?$/.test(value) ? Number(value) : Number.NaN),
54
+ // Its MiB, the fraction dropped, as Docker reads a size: 0.5g is 512, 6.5m is 6.
55
+ memoryMb: (value) => {
56
+ const size = /^(\d+(?:\.\d+)?)([bkmg])$/i.exec(value);
57
+ return size ? Math.floor(Number(size[1]) * SIZE_MIB[size[2].toLowerCase()]) : Number.NaN;
58
+ },
59
+ pids: (value) => (/^\d+$/.test(value) ? Number(value) : Number.NaN),
60
+ };
61
+ /** Asked only check(): its constructor runs nothing and reads no Docker, and check() reads only the spec. */
62
+ let checker;
63
+ /** A Docker computer's size from `env`'s AGENTRUN_BOX_CPUS, _MEMORY and _PIDS: each one set, as its spec field; none set,
64
+ * none, so the provider's defaults hold. A value the Docker provider would refuse at every create throws, in its own
65
+ * words, naming the setting and what it takes: the server's start reads them (startServe), so no run meets one. */
66
+ export function dockerLimitsOf(env) {
67
+ const limits = {};
68
+ for (const { name, field } of LIMIT_SETTINGS) {
69
+ const value = envValue(env, name)?.trim();
70
+ if (value !== undefined)
71
+ limits[field] = LIMIT_VALUE[field](value);
72
+ }
73
+ if (Object.keys(limits).length === 0)
74
+ return {};
75
+ checker ??= new DockerProvider({ daemonPath: "computerd" });
76
+ const refusals = checker.check({ image: DEFAULT_DOCKER_IMAGE, lifetimeMs: COMPUTER_LIFETIME_MS, network: "none", ...limits });
77
+ for (const { name, field, form } of LIMIT_SETTINGS) {
78
+ const refusal = refusals.find((one) => one.field === field);
79
+ if (refusal)
80
+ throw new Error(`${name} ${JSON.stringify(envValue(env, name).trim())} is refused by the Docker provider: ${refusal.message} (${name} is ${form})`);
81
+ }
82
+ return limits;
83
+ }
32
84
  /** The Docker host's own addresses, for a Docker provider whose interfaces aren't that host's (the server in a
33
85
  * container): a comma list of IP addresses. The Docker provider's egress proxy refuses them as the host's, so a
34
86
  * computer's allow-list never reaches the host itself; without them it refuses any allow-list there. */
@@ -54,46 +106,69 @@ export function dockerVolumeOf(paths) {
54
106
  const root = paths.paths.at;
55
107
  return { volume: { name: paths.paths.volume, root }, daemonCache: posix.join(root, DAEMON_CACHE_IN_VOLUME) };
56
108
  }
57
- /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (Docker's: the
58
- * owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox the package's recipe; any other provider's: its registry
59
- * entry's defaultImage for the kind, the computer package's PROVIDERS[].defaultImage; a kind with none refused in
60
- * words, a Docker desktop's saying it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its network. box_allow is a
61
- * sandbox's egress list: a sandbox with none, or "none", has no network; a browser, desktop or phone with none has its
62
- * provider's own ("open"); an explicit list or "none" applies to any kind, narrowed to "none" for a provider that makes
63
- * no other (networkOf). No key and no environment. */
109
+ /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (a provider that
110
+ * prepares its own image, its descriptor's prepareImage: the owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox
111
+ * the package's recipe, which its prepareImage() builds; any other provider's: its descriptor's defaultImage for the
112
+ * kind, the computer package's PROVIDERS[].defaultImage; a kind with none refused in words, a prepared desktop's saying
113
+ * it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the
114
+ * run's release), and its network (networkOf): the run's box_allow, or this server's own (AGENTRUN_BOX_ALLOW, read
115
+ * from `env`) for a launch that names none; and the size of a computer on this machine's container engine (its
116
+ * descriptor's `local`), AGENTRUN_BOX_CPUS, _MEMORY and _PIDS (dockerLimitsOf, read once here): a vendor's computer
117
+ * sizes itself. No key and no environment. */
64
118
  export function computerSpecOf(env) {
65
119
  const named = envValue(env, DOCKER_IMAGE_ENV);
120
+ // This server's allow setting, as a launch is stamped with it (box-settings.ts boxAllowOf; its start checks the setting).
121
+ const current = () => boxAllowOf(env);
122
+ const currentSet = () => boxAllowSetIn(env);
66
123
  const imageOf = (entry, kind) => {
67
- if (entry.id === "docker" && named !== undefined)
124
+ if (entry.prepareImage && named !== undefined)
68
125
  return named;
69
- // Docker's sandbox: the package's own recipe, which serve builds (the registry gives Docker no default).
70
- if (entry.id === "docker" && kind === "sandbox")
126
+ // A sandbox whose provider prepares its image: the package's own recipe, which its prepareImage() builds (the
127
+ // descriptor gives it no default).
128
+ if (entry.prepareImage && kind === "sandbox")
71
129
  return DEFAULT_DOCKER_IMAGE;
72
130
  const image = entry.defaultImage?.[kind];
73
131
  if (image !== undefined)
74
132
  return image;
75
- if (entry.id === "docker" && kind === "desktop")
76
- throw refused("A Docker desktop needs an image with an X server; set one for desktops.");
133
+ if (entry.prepareImage && kind === "desktop")
134
+ throw refused(`A ${entry.label} desktop needs an image with an X server; set one for desktops.`);
77
135
  throw refused(`${entry.label} has no image for a ${kind} computer here: pick another provider for this agent's computer in Settings → Computers.`);
78
136
  };
79
- return (entry, kind, run) => ({
80
- image: imageOf(entry, kind),
137
+ const limits = dockerLimitsOf(env);
138
+ return (entry, kind, run, image) => ({
139
+ // The setting's configuration's image (Orgo's `windows`), else the kind's.
140
+ image: image ?? imageOf(entry, kind),
81
141
  // The leak bound, within the longest the provider makes (E2B's is an hour): a longer one it refuses at create.
82
142
  lifetimeMs: Math.min(COMPUTER_LIFETIME_MS, run.maxLifetimeMs ?? COMPUTER_LIFETIME_MS),
83
- network: networkOf(kind, run),
143
+ network: networkOf(entry, kind, run, current, currentSet),
144
+ // The size of a computer on this machine's container engine, the operator's (dockerLimitsOf); a vendor's sizes itself.
145
+ ...(entry.local ? limits : {}),
84
146
  });
85
147
  }
86
- /** The network a computer of `kind` asks for: as the run allows (box_allow), narrowed to "none" when its provider makes
87
- * "none" but not what the run allows. A remote computer (Daytona's or E2B's, each one whose capabilities' network is
88
- * ["none"]) runs its programs in a network of their own, so an open or listed network is one it refuses at create;
89
- * "none" reaches less than the run allows, never more. The one exception is a vendor-hosted computer that runs only on
90
- * the vendor's own network (its capabilities' network is ["open"]: a cloud phone, a hosted browser): it is "open"
91
- * whatever the run allows, since this server's allow-list can't reach it, and it is never refused for a list. */
92
- function networkOf(kind, run) {
93
- if (run.networks && run.networks.length > 0 && run.networks.every((one) => one === "open"))
148
+ /** The network a computer of `kind` on `entry` asks for: what the run allows (its box_allow), narrowed to "none" when its
149
+ * provider makes "none" but not what the run allows. A launch that names no box_allow (a row from before every launch
150
+ * was stamped with it) allows what this server allows now (`current`), never "open"; a sandbox with none still has no
151
+ * network, as it always had. A remote computer (Daytona's or E2B's, each one whose capabilities' network is ["none"])
152
+ * runs its programs in a network of their own, so an open or listed network is one it refuses at create; "none" reaches
153
+ * less than the run allows, never more. Under "none", the operator's word for no network at all, a computer whose
154
+ * provider makes no "none" (a cloud phone, a hosted browser, Local Chrome) is refused in words (noNetworkRefusal), as
155
+ * the run's start refuses it (resolve-computer.ts computerReadiness). A vendor-hosted computer that runs only on the
156
+ * vendor's own network (its capabilities' network is ["open"]) is "open" under a list, the default or the operator's,
157
+ * since this server's list can't reach it, and Settings says so (computers.ts networkWords). A browser whose provider
158
+ * makes both "open" and "allow" (Local Chrome, behind its own egress proxy) is held to the operator's list
159
+ * (`boxAllowSet`, the launch's, or this server's now for a launch that names no box_allow) and is "open" under the
160
+ * default list, which is a sandbox's package-install list and no browsing policy. */
161
+ function networkOf(entry, kind, run, current, currentSet) {
162
+ const boxAllow = run.boxAllow ?? (kind === "sandbox" ? "none" : current());
163
+ const set = run.boxAllow !== undefined ? run.boxAllowSet === true : currentSet();
164
+ if (boxAllow === "none" && needsNetwork(run.networks))
165
+ throw refused(noNetworkRefusal(entry.label, kind));
166
+ if (vendorNetworkOnly(run.networks))
94
167
  return "open";
95
- const allowed = run.boxAllow === undefined ? (kind === "sandbox" ? "none" : "open") : run.boxAllow === "none" ? "none" : { allow: [...run.boxAllow] };
96
- const form = allowed === "none" || allowed === "open" ? allowed : "allow";
168
+ if (kind === "browser" && boxAllow !== "none" && run.networks?.includes("open") && run.networks.includes("allow"))
169
+ return set ? { allow: [...boxAllow] } : "open";
170
+ const allowed = boxAllow === "none" ? "none" : { allow: [...boxAllow] };
171
+ const form = allowed === "none" ? "none" : "allow";
97
172
  return run.networks && !run.networks.includes(form) && run.networks.includes("none") ? "none" : allowed;
98
173
  }
99
174
  /** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
@@ -104,8 +179,9 @@ export const imageWaitWords = (making, image) => making === "build" ? `Preparing
104
179
  export const claimComputer = async (launch, store, deps) => {
105
180
  if (launch.boxAllow !== undefined || !store.runs)
106
181
  return computerForClaim(launch, store, deps);
107
- const boxAllow = readLaunchBody((await store.runs.launch(launch.runId)).body)?.boxAllow;
108
- return computerForClaim(boxAllow === undefined ? launch : { ...launch, boxAllow }, store, deps);
182
+ const body = readLaunchBody((await store.runs.launch(launch.runId)).body);
183
+ const boxAllow = body?.boxAllow;
184
+ return computerForClaim(boxAllow === undefined ? launch : { ...launch, boxAllow, ...(body?.boxAllowSet ? { boxAllowSet: true } : {}) }, store, deps);
109
185
  };
110
186
  /** The kind registry a claim composed with `options` resolves a setting against: --faux's when it is given faux, else a
111
187
  * test's own, else the computer package's. The one choice: computerDepsFrom makes it, and the server's start check
@@ -114,36 +190,60 @@ export function claimKinds(options) {
114
190
  // The faux registry is Settings' shape (computers.ts); the claim reads the same data as resolve-computer.ts's.
115
191
  return options.faux?.kinds ?? options.kinds ?? { SETTING_KINDS, PROVIDERS, servingRefusals };
116
192
  }
193
+ /** This machine's Docker daemon as the claim asks it once a Docker launch fails: one check per process (its answer
194
+ * kept a while, docker-daemon.ts), in `env`. */
195
+ const dockerDaemonOf = (env) => {
196
+ const check = dockerDaemonCheck({ env: { ...env } });
197
+ return () => check();
198
+ };
117
199
  /** computerForClaim and its process-wide deps, composed once; and Settings → Computers' factories from the same makers. */
118
200
  export function computerDepsFrom(options) {
119
201
  const { env, store, sealKey, faux } = options;
120
202
  const kinds = claimKinds(options);
121
- // The Docker provider is given its image's source, which it makes ready itself (its image(): built from the recipe
122
- // when Docker lacks it, or pulled by name): the owner's AGENTRUN_DOCKER_IMAGE, else the package's recipe. Never the
123
- // recipe's bare tag, which no registry has.
203
+ // A provider that prepares its own image (its descriptor's prepareImage) is given that image's source, which its
204
+ // prepareImage() makes ready (built from the recipe when the engine lacks it, or pulled by name): the owner's
205
+ // AGENTRUN_DOCKER_IMAGE, else the package's recipe. Never the recipe's bare tag, which no registry has.
124
206
  const named = envValue(env, DOCKER_IMAGE_ENV);
125
- const dockerImage = named !== undefined ? { image: named } : { recipe: DOCKER_RECIPE };
207
+ const preparedImage = named !== undefined ? { image: named } : { recipe: DOCKER_RECIPE };
126
208
  // The operator's Docker host addresses (AGENTRUN_DOCKER_HOST_ADDRESSES), checked once here.
127
209
  const namedAddresses = dockerHostAddressesOf(env);
128
210
  // Where this process's Docker has the data, read once, when a Docker provider is first built.
129
211
  let paths;
130
- /** The Docker provider's options beside its image: for a server in a container of its Docker's, the named volume that
131
- * holds its data and the daemon copy's place under it (dockerVolumeOf), and the Docker host's own addresses for its
132
- * egress proxy, the union of the read through the socket (`hostAddresses`) and the operator's; on a host, the
133
- * operator's alone (the provider reads its own interfaces). With none, none are given, and the provider refuses an
134
- * allow-list where it isn't on the Docker host, in its words. The read is made only for a claim whose run's computer
135
- * has an allow-list (`boxAllow`, the claim's own launch's box_allow, a list): a run launched under a list keeps it
136
- * across a restart, whatever this process's AGENTRUN_BOX_ALLOW says now; one with none, or no claim, reads nothing.
137
- * The read itself is once per process (`hostAddresses`). */
138
- const dockerOptions = async (boxAllow) => {
212
+ /** A local provider's host options (its descriptor's `local`: its computers run on this machine's container engine):
213
+ * for a server in a container of that engine's, the named volume that holds its data and the daemon copy's place
214
+ * under it (dockerVolumeOf), and the host's own addresses for its egress proxy, the union of the read through the
215
+ * socket (`hostAddresses`) and the operator's; on a host, the operator's alone (the provider reads its own
216
+ * interfaces). With none, none are given, and the provider refuses an allow-list where it isn't on the host, in its
217
+ * words. The read is made only for a claim whose run's computer has an allow-list (`boxAllow`, the claim's own
218
+ * launch's box_allow, a list): a run launched under a list keeps it across a restart, whatever this process's
219
+ * AGENTRUN_BOX_ALLOW says now; one with none, or no claim, reads nothing. The read itself is once per process
220
+ * (`hostAddresses`). */
221
+ const localHostOptions = async (boxAllow) => {
139
222
  const where = options.dockerPaths ? await (paths ??= options.dockerPaths()) : { here: true };
140
223
  const volume = dockerVolumeOf(where);
141
- const read = volume && Array.isArray(boxAllow) && options.hostAddresses ? await options.hostAddresses() : undefined;
224
+ // A launch that names no box_allow (a row from before every launch was stamped) allows what this server allows now,
225
+ // as its computer's network does (networkOf), so the provider's options follow the same setting.
226
+ const allow = boxAllow ?? boxAllowOf(env);
227
+ const read = volume && Array.isArray(allow) && options.hostAddresses ? await options.hostAddresses() : undefined;
142
228
  const addresses = read ? unionOf(read, namedAddresses).addresses : (namedAddresses ?? []);
143
- return { image: dockerImage, ...(volume ?? {}), ...(addresses.length > 0 ? { egress: { hostAddresses: addresses } } : {}) };
229
+ return { ...(volume ?? {}), ...(addresses.length > 0 ? { egress: { hostAddresses: addresses } } : {}) };
230
+ };
231
+ /** The server's own values of the environment variables a provider declares it reads on this machine (hostEnv: Local
232
+ * Chrome's, where it finds Chrome), and no other variable of the server's. */
233
+ const hostEnvOf = (names) => Object.fromEntries(names.flatMap((name) => (env[name] === undefined ? [] : [[name, String(env[name])]])));
234
+ /** The options a provider takes beside its keys, by what its descriptor declares, never by its id: the image source
235
+ * for one that prepares its image, the host options for a local one, the host environment it reads. */
236
+ const declaredOptions = async (id, boxAllow) => {
237
+ const entry = kinds.PROVIDERS.find((one) => one.id === id);
238
+ return {
239
+ ...(entry?.prepareImage ? { image: preparedImage } : {}),
240
+ ...(entry?.local ? await localHostOptions(boxAllow) : {}),
241
+ ...(entry?.hostEnv ? { env: hostEnvOf(entry.hostEnv) } : {}),
242
+ };
144
243
  };
145
244
  const load = options.load ?? providerFor;
146
- const providers = computerProviderMakers({ load: async (id, given, claim) => load(id, id === "docker" ? { ...given, ...(await dockerOptions(claim?.boxAllow)) } : given) });
245
+ // The claim and Settings → Computers' test alike.
246
+ const providers = computerProviderMakers({ load: async (id, given, claim) => load(id, { ...given, ...(await declaredOptions(id, claim?.boxAllow)) }) });
147
247
  const computerDeps = {
148
248
  kinds,
149
249
  providers,
@@ -153,6 +253,7 @@ export function computerDepsFrom(options) {
153
253
  // Under --faux, its launch makes the computer, with its key table: no provider of the package is built.
154
254
  ...(faux ? { keyTable: faux.keyTable, launch: (entry, spec) => faux.launch(entry, spec) } : {}),
155
255
  ...(options.answers ? { answers: options.answers } : {}),
256
+ ...(options.daemon ? { daemon: options.daemon } : faux ? {} : { daemon: dockerDaemonOf(env) }),
156
257
  ...(options.openComputerView ? { openComputerView: options.openComputerView } : {}),
157
258
  };
158
259
  const factories = faux?.factories ?? computerProviderFactories(providers, (id) => storeLedger(store.computerLedger, id));
@@ -1,4 +1,4 @@
1
- import type { ComputerProvider, ComputerSpec, Result, Swept } from "@parcha/agentrun-computer";
1
+ import type { ComputerProvider, ComputerSpec } from "@parcha/agentrun-computer";
2
2
  import { type PlaceView } from "../computer-setting.js";
3
3
  import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
4
4
  import type { Store } from "../store/index.js";
@@ -20,19 +20,22 @@ export interface ClaimLaunch {
20
20
  /** What the run's computer may reach, as its launch resolved it (run-launch.ts boxAllow): "none" or absent is no
21
21
  * network, a list an allow-list. The computer's spec takes it. */
22
22
  readonly boxAllow?: readonly string[] | "none";
23
+ /** The operator set that (run-launch.ts boxAllowSet), not the default. */
24
+ readonly boxAllowSet?: true;
23
25
  }
24
- /** What of the run a computer's spec is made from, besides its kind and provider: what it may reach; and what the
25
- * provider declares it makes (its capabilities()): its networks and its longest lifetime. Absent, the spec asks as the
26
- * run allows. */
26
+ /** What of the run a computer's spec is made from, besides its kind and provider: what it may reach, and whether the
27
+ * operator set that; and what the provider declares it makes (its capabilities()): its networks and its longest
28
+ * lifetime. Absent, the spec asks as the run allows. */
27
29
  export interface ComputerRun {
28
30
  readonly boxAllow?: readonly string[] | "none";
31
+ readonly boxAllowSet?: true;
29
32
  readonly networks?: readonly ("none" | "open" | "allow")[];
30
33
  readonly maxLifetimeMs?: number;
31
34
  }
32
35
  /** A provider module's create(), by provider id: its options from the saved keys, and the store's ledger for a provider
33
36
  * that keeps one (the phone's `ledger` option); for a claim, what its run's computer may reach (`boxAllow`, the
34
37
  * launch's box_allow), which no provider option carries. The computer package's providers, or a test's stand-in. */
35
- export type ProviderMakers = Readonly<Partial<Record<string, (options: Record<string, string>, extras: ProviderExtras) => ComputerProvider | Promise<ComputerProvider>>>>;
38
+ export type ProviderMakers = Readonly<Partial<Record<string, (options: Readonly<Record<string, unknown>>, extras: ProviderExtras) => ComputerProvider | Promise<ComputerProvider>>>>;
36
39
  /** What a provider is made with beside its options: the store's ledger, and the claim's box_allow when a claim makes it. */
37
40
  export type ProviderExtras = {
38
41
  readonly ledger: ProviderLedger;
@@ -71,8 +74,9 @@ export interface ComputerForClaimDeps {
71
74
  /** The server's seal key: absent, no key is opened, so a provider that needs one is refused in words. */
72
75
  readonly sealKey: Buffer | undefined;
73
76
  readonly providers: ProviderMakers;
74
- /** What a computer of `kind` is made with, besides its labels and its mount: image, lifetime, network (from `run`). */
75
- readonly spec: (entry: ProviderEntry, kind: Exclude<ComputerSettingKind, "none">, run: ComputerRun) => Omit<ComputerSpec, "labels" | "mount">;
77
+ /** What a computer of `kind` is made with, besides its labels and its mount: image, lifetime, network (from `run`).
78
+ * `image`: the one the setting's configuration names, over the kind's default. */
79
+ readonly spec: (entry: ProviderEntry, kind: Exclude<ComputerSettingKind, "none">, run: ComputerRun, image?: string) => Omit<ComputerSpec, "labels" | "mount">;
76
80
  /** A provider key's value by its name, as the server reads it (key-meta.ts keyReader: the environment's, else the
77
81
  * saved one). Absent: the saved one alone, opened with `sealKey`. */
78
82
  readonly keyOf?: (name: string) => Promise<string | undefined>;
@@ -81,6 +85,8 @@ export interface ComputerForClaimDeps {
81
85
  readonly settings?: ProviderSettings;
82
86
  /** Whether a provider that binds a folder of this machine answers here now (Docker): the Mode 1 default asks it. */
83
87
  readonly answers?: (provider: string) => Promise<boolean>;
88
+ /** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails (ClaimSide.daemon). */
89
+ readonly daemon?: ClaimSide["daemon"];
84
90
  /** A launch of the server's own in place of the providers' (--faux's desktop). */
85
91
  readonly launch?: ClaimSide["launch"];
86
92
  /** The run's folder (mounted only where the provider mounts it) and the mount check attach runs. */
@@ -95,6 +101,9 @@ export interface ComputerForClaimDeps {
95
101
  * a host that lacks it, or a named image pulled); never when the host has it. The run's caller says it on the run's
96
102
  * timeline. Absent: nothing is said. */
97
103
  readonly onImageWait?: ImageWait;
104
+ /** Why this run's harness takes no computer of `kind`, in words (a CLI harness's of a browser), or undefined: a kind
105
+ * it refuses is refused with code computer_unavailable before anything is made. Absent: every kind. */
106
+ readonly refuseKind?: (kind: Exclude<ComputerSettingKind, "none">) => string | undefined;
98
107
  readonly signal?: AbortSignal;
99
108
  }
100
109
  /** The run's computer at its claim: what runTools takes, the person's hold on a desktop's or phone's ports, and its
@@ -105,15 +114,9 @@ export interface ClaimComputer {
105
114
  readonly hold?: RunHold;
106
115
  release(why?: ViewEnd): Promise<void>;
107
116
  }
117
+ /** The provider's watch of a computer's screen (ComputerProvider.watch), where it has one. */
108
118
  /** Told once, before the claim waits on its computer's image being built or pulled; never when the host has it. */
109
119
  export type ImageWait = (making: "build" | "pull", tag: string) => void;
110
- /** The runner's start: every computer of `providers` with all of `labels` whose deadline (its agentrun.computer.deadline
111
- * label) has passed is ended, once (the janitor's sweep), each provider apart. A provider whose vendor ends its own
112
- * computers answers its refusal in words; nothing throws. */
113
- export declare function sweepComputers(providers: readonly ComputerProvider[], labels: Readonly<Record<string, string>>, now?: Date): Promise<{
114
- readonly provider: string;
115
- readonly swept: Result<Swept>;
116
- }[]>;
117
120
  /** The run's computer for this claim, started and registered; `{ computer: undefined }` for none. Throws with code
118
121
  * computer_unavailable and the server's words when the agent's computer cannot be had here. */
119
122
  export declare function computerForClaim(launch: ClaimLaunch, store: Pick<Store, "agents" | "sealedKeys" | "computerLedger">, deps: ComputerForClaimDeps): Promise<ClaimComputer>;
@@ -1,4 +1,4 @@
1
- import { releaseOlder, runLabels, sweep } from "@parcha/agentrun-computer";
1
+ import { releaseOlder, runLabels } from "@parcha/agentrun-computer";
2
2
  import { computerOfPlace } from "../computer-setting.js";
3
3
  import { KEY_TABLE, providerOptions } from "../computer-keys.js";
4
4
  import { getSealedKey } from "../server-keys.js";
@@ -27,18 +27,82 @@ function phonePlatform(machine, entry) {
27
27
  const said = machine ?? entry?.capabilities.find((one) => one.kind === "android" || one.kind === "ios")?.kind;
28
28
  return said === "ios" ? "ios" : "android";
29
29
  }
30
- /** The image `provider` made ready, when it makes its own; undefined for one that does not. A failure is the provider's
31
- * words. `onWait`: told once if the claim waits on a build or a pull. */
32
- async function readyImage(provider, signal, onWait) {
33
- const maker = provider;
34
- if (typeof maker.image !== "function")
30
+ /** The image `provider` made ready, when its descriptor declares it prepares its image (`entry.prepareImage`): its
31
+ * prepareImage(), its recipe built when the engine lacks it or its image by name pulled, answering the tag to start
32
+ * from; undefined for any other provider, which starts from its spec's image. A provider whose descriptor declares it
33
+ * and that has none breaks the contract, in words. A failure is the provider's words. `onWait`: told once if the claim
34
+ * waits on a build or a pull. */
35
+ async function readyImage(entry, provider, signal, onWait) {
36
+ if (!entry.prepareImage)
35
37
  return undefined;
36
- const ready = await maker.image({ ...(signal ? { signal } : {}), ...(onWait ? { onWait } : {}) });
38
+ if (provider.prepareImage === undefined)
39
+ throw new Error(`${entry.label}'s descriptor says it prepares its image, but its provider has no prepareImage()`);
40
+ const ready = await provider.prepareImage({ ...(signal ? { signal } : {}), ...(onWait ? { onWait } : {}) });
37
41
  if (!ready.ok)
38
42
  throw new Error(ready.error.message);
39
43
  return ready.value;
40
44
  }
41
45
  const watching = (provider) => typeof provider.watch === "function" ? provider : undefined;
46
+ /** The browser computer `ref`'s CDP URL now: the provider's connect (its signed URL), its words and code when the session
47
+ * has ended. The connection itself is let go once read. */
48
+ async function cdpUrlOf(provider, ref) {
49
+ const connected = await provider.connect(ref);
50
+ if (!connected.ok)
51
+ throw Object.assign(new Error(connected.error.message), { code: connected.error.code });
52
+ const url = connected.value.cdp?.url;
53
+ await connected.value.close().catch(() => undefined);
54
+ if (!url)
55
+ throw new Error(`the ${provider.id} computer ${ref.id} gave no CDP connection`);
56
+ return url;
57
+ }
58
+ /** The label a browser session's computer carries its browser tool's tag in. */
59
+ const SESSION_TAG = "agentrun.session";
60
+ /** A label value of letters, digits and `_.:-` alone, as every provider takes one. */
61
+ const labelValue = (value) => value.replace(/[^A-Za-z0-9_.:-]+/g, "_").slice(0, 63);
62
+ /** A provider failure as an error with the provider's words and code. */
63
+ const failed = (error) => Object.assign(new Error(error.message), { code: error.code });
64
+ /** A browser computer's provider as the run's browser tool opens its sessions through it (ClaimBrowser): nothing is made
65
+ * at the claim. A session's computer is made at the tool's call, under the run's labels (`spec`'s) and the tool's tag;
66
+ * its release lets go of every one the tool left open. */
67
+ function claimBrowser(provider, spec) {
68
+ // A run's browser: the claim's spec always carries its lifetime (computerSpecOf); an agent's computer (owner) has none.
69
+ const lifetime = spec.lifetimeMs;
70
+ if (lifetime === undefined)
71
+ throw new TypeError("a run's browser needs lifetimeMs: the claim's spec carries none");
72
+ const open = new Set();
73
+ const release = async (id) => {
74
+ const released = await provider.release({ id, name: id }, "delete");
75
+ if (!released.ok)
76
+ throw failed(released.error);
77
+ open.delete(id);
78
+ };
79
+ return {
80
+ browser: {
81
+ provider: provider.id,
82
+ maxLifetimeS: Math.floor(lifetime / 1000),
83
+ async open(tag, lifetimeS, signal) {
84
+ const lifetimeMs = Math.min(lifetime, Math.max(1, Math.round(lifetimeS)) * 1000);
85
+ const created = await provider.create({ ...spec, lifetimeMs, labels: { ...spec.labels, [SESSION_TAG]: labelValue(tag) } }, signal ? { signal } : {});
86
+ if (!created.ok)
87
+ throw failed(created.error);
88
+ open.add(created.value.id);
89
+ return created.value.id;
90
+ },
91
+ async find(tag) {
92
+ const listed = await provider.list({ ...spec.labels, [SESSION_TAG]: labelValue(tag) });
93
+ if (!listed.ok)
94
+ throw failed(listed.error);
95
+ return listed.value.map((one) => one.ref.id);
96
+ },
97
+ url: (id) => cdpUrlOf(provider, { id, name: id }),
98
+ close: release,
99
+ },
100
+ async release() {
101
+ for (const id of [...open])
102
+ await release(id).catch(() => undefined);
103
+ },
104
+ };
105
+ }
42
106
  /** `entry`'s computer started through its provider: the run's computers of a lower claim epoch released first (the
43
107
  * janitor's releaseOlder: one claim's computer at a time), then made with the run's labels (and the run's folder, when
44
108
  * it mounts), connected, its groups from its hello; its read-back is the provider's own; its release deletes it. */
@@ -81,17 +145,6 @@ async function providerLaunch(provider, claim, spec, signal) {
81
145
  },
82
146
  };
83
147
  }
84
- /** The runner's start: every computer of `providers` with all of `labels` whose deadline (its agentrun.computer.deadline
85
- * label) has passed is ended, once (the janitor's sweep), each provider apart. A provider whose vendor ends its own
86
- * computers answers its refusal in words; nothing throws. */
87
- export async function sweepComputers(providers, labels, now = new Date()) {
88
- const out = [];
89
- for (const provider of providers) {
90
- const swept = await sweep(provider, { labels: { ...labels }, now }).catch((error) => ({ ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } }));
91
- out.push({ provider: provider.id, swept });
92
- }
93
- return out;
94
- }
95
148
  /** The run's computer for this claim, started and registered; `{ computer: undefined }` for none. Throws with code
96
149
  * computer_unavailable and the server's words when the agent's computer cannot be had here. */
97
150
  export async function computerForClaim(launch, store, deps) {
@@ -103,9 +156,10 @@ export async function computerForClaim(launch, store, deps) {
103
156
  const side = {
104
157
  keysOf: providerKeys(deps.kinds, deps.keyOf ?? (async (name) => (deps.sealKey ? await getSealedKey(store, deps.sealKey, name) : undefined))),
105
158
  answers: deps.answers ?? (async () => false),
106
- async launch(entry, { kind, keys, mount, signal }) {
159
+ ...(deps.daemon ? { daemon: deps.daemon } : {}),
160
+ async launch(entry, { kind, keys, configuration, mount, gpu, signal }) {
107
161
  if (deps.launch) {
108
- const own = await deps.launch(entry, { kind, keys, ...(mount ? { mount } : {}), ...(signal ? { signal } : {}) });
162
+ const own = await deps.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}), ...(signal ? { signal } : {}) });
109
163
  const ownWatch = own.watch;
110
164
  made = { id: own.id, ...(ownWatch ? { watch: ownWatch } : {}) };
111
165
  madeBy = entry;
@@ -117,20 +171,36 @@ export async function computerForClaim(launch, store, deps) {
117
171
  const options = providerOptions(entry.id, keys, deps.settings ?? {}, table);
118
172
  if (!options.ok)
119
173
  throw new Error(options.error.message);
120
- const provider = await make(options.options, { ledger: storeLedger(store.computerLedger, entry.id), ...(launch.boxAllow === undefined ? {} : { boxAllow: launch.boxAllow }) });
174
+ // The configuration the setting selected is built by its own create() options (Orgo's Windows: { os: "windows" }),
175
+ // beside the keys'.
176
+ const provider = await make({ ...options.options, ...configuration.options }, { ledger: storeLedger(store.computerLedger, entry.id), ...(launch.boxAllow === undefined ? {} : { boxAllow: launch.boxAllow }) });
121
177
  // What this provider makes, as it declares it: the spec asks for one of its networks, within its lifetime
122
178
  // (computer-deps.ts computerSpecOf).
123
179
  const { network: networks, maxLifetimeMs } = provider.capabilities();
124
180
  const run = {
125
181
  ...(launch.boxAllow === undefined ? {} : { boxAllow: launch.boxAllow }),
182
+ ...(launch.boxAllowSet ? { boxAllowSet: true } : {}),
126
183
  ...(networks ? { networks } : {}),
127
184
  ...(typeof maxLifetimeMs === "number" ? { maxLifetimeMs } : {}),
128
185
  };
129
- // A provider that makes its own image ready (Docker's image(): its recipe built when Docker lacks it, an image by name
130
- // pulled) does so first, and the computer starts from the tag it answers: the recipe's tag is in no registry, so a
131
- // run of it unbuilt would be refused.
132
- const ready = await readyImage(provider, signal, deps.onImageWait);
133
- const spec = { ...deps.spec(entry, kind, run), ...(ready ? { image: ready } : {}), labels: runLabels(launch.runId, launch.epoch), ...(mount ? { mount } : {}) };
186
+ // A provider that declares it prepares its own image (its prepareImage(): its recipe built when the engine lacks it,
187
+ // an image by name pulled) does so first, and the computer starts from the tag it answers: the recipe's tag is in no
188
+ // registry, so a run of it unbuilt would be refused. The spec comes first, so a setting it refuses builds nothing. A
189
+ // configuration that names its image starts from it, else the kind's default.
190
+ const asked = deps.spec(entry, kind, run, configuration.image);
191
+ const ready = await readyImage(entry, provider, signal, deps.onImageWait);
192
+ const spec = { ...asked, ...(ready ? { image: ready } : {}), labels: runLabels(launch.runId, launch.epoch), ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}) };
193
+ // A browser makes nothing here: the run's browser tool opens each session through it, so a session lives (and is
194
+ // booked) only while the tool holds it.
195
+ if (kind === "browser") {
196
+ // The run's sessions of a lower claim epoch go first, as a computer's do (the janitor's releaseOlder).
197
+ const older = await releaseOlder(provider, launch.runId, launch.epoch, signal ? { signal } : {});
198
+ if (!older.ok)
199
+ throw new Error(older.error.message);
200
+ const opened = claimBrowser(provider, spec);
201
+ madeBy = entry;
202
+ return { id: entry.id, groups: ["cdp"], browser: opened.browser, release: opened.release };
203
+ }
134
204
  const launched = await providerLaunch(provider, launch, spec, signal);
135
205
  made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch } : {}) };
136
206
  madeBy = entry;
@@ -142,6 +212,9 @@ export async function computerForClaim(launch, store, deps) {
142
212
  throw unavailable(resolved.refused);
143
213
  if (resolved.kind === "none")
144
214
  return { computer: undefined, release: noop };
215
+ const refusedKind = deps.refuseKind?.(resolved.kind);
216
+ if (refusedKind)
217
+ throw unavailable(refusedKind);
145
218
  // The run's mount credential (Mode 2), minted when the mount was made: removed with the computer, or at once when the
146
219
  // start fails after it was minted.
147
220
  const revoke = async () => { await deps.revokeMount?.(); };