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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (522) hide show
  1. package/CHANGELOG.md +298 -0
  2. package/README.md +417 -219
  3. package/dist/adapters.d.ts +12 -2
  4. package/dist/adapters.js +27 -2
  5. package/dist/agent-rows.d.ts +2 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +9 -4
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +79 -7
  13. package/dist/archil-settings.js +140 -14
  14. package/dist/attach-conformance-cli.d.ts +1 -0
  15. package/dist/attach-conformance-cli.js +18 -0
  16. package/dist/attach-conformance.d.ts +25 -0
  17. package/dist/attach-conformance.js +343 -0
  18. package/dist/attach-images.d.ts +15 -0
  19. package/dist/attach-images.js +59 -0
  20. package/dist/background.d.ts +0 -6
  21. package/dist/background.js +0 -28
  22. package/dist/box-image.d.ts +1 -97
  23. package/dist/box-image.js +4 -284
  24. package/dist/box-paths.d.ts +2 -7
  25. package/dist/box-paths.js +7 -13
  26. package/dist/box-settings.d.ts +0 -11
  27. package/dist/box-settings.js +4 -29
  28. package/dist/browser-commands.js +1 -1
  29. package/dist/browser-computer.d.ts +47 -3
  30. package/dist/browser-computer.js +286 -18
  31. package/dist/browser-cost.d.ts +1 -1
  32. package/dist/browser-live.d.ts +20 -8
  33. package/dist/browser-live.js +50 -27
  34. package/dist/browser-person.d.ts +19 -2
  35. package/dist/browser-person.js +55 -6
  36. package/dist/browser-wait-ended.d.ts +23 -0
  37. package/dist/browser-wait-ended.js +42 -0
  38. package/dist/cap.d.ts +12 -57
  39. package/dist/cap.js +20 -160
  40. package/dist/catalog.d.ts +1 -12
  41. package/dist/catalog.js +3 -33
  42. package/dist/cli.js +17 -26
  43. package/dist/composio-preset.d.ts +36 -0
  44. package/dist/composio-preset.js +179 -0
  45. package/dist/computer-attach.d.ts +125 -0
  46. package/dist/computer-attach.js +330 -0
  47. package/dist/computer-calls.d.ts +48 -0
  48. package/dist/computer-calls.js +126 -0
  49. package/dist/computer-channel.d.ts +57 -0
  50. package/dist/computer-channel.js +115 -0
  51. package/dist/computer-commands.d.ts +1 -1
  52. package/dist/computer-held-routes.d.ts +35 -0
  53. package/dist/computer-held-routes.js +106 -0
  54. package/dist/computer-held.d.ts +48 -0
  55. package/dist/computer-held.js +87 -0
  56. package/dist/computer-keys.d.ts +21 -1
  57. package/dist/computer-keys.js +53 -11
  58. package/dist/computer-live.d.ts +160 -0
  59. package/dist/computer-live.js +643 -0
  60. package/dist/computer-routes.d.ts +1 -4
  61. package/dist/computer-routes.js +3 -5
  62. package/dist/computer-setting.d.ts +2 -0
  63. package/dist/computer-setting.js +38 -1
  64. package/dist/computer-view.d.ts +24 -2
  65. package/dist/computer-view.js +51 -3
  66. package/dist/computer-viewer.d.ts +6 -0
  67. package/dist/computer-viewer.js +297 -0
  68. package/dist/computers.d.ts +79 -12
  69. package/dist/computers.js +147 -28
  70. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  71. package/dist/console/assets/index-DRN62V5v.css +1 -0
  72. package/dist/console/index.html +2 -2
  73. package/dist/docker-daemon.d.ts +2 -2
  74. package/dist/docker-daemon.js +2 -2
  75. package/dist/errors.js +5 -5
  76. package/dist/faux-computers.d.ts +9 -20
  77. package/dist/faux-computers.js +56 -24
  78. package/dist/files.d.ts +1 -9
  79. package/dist/files.js +1 -9
  80. package/dist/github-connection.d.ts +10 -2
  81. package/dist/github-connection.js +65 -2
  82. package/dist/github-faux.js +1 -1
  83. package/dist/github.d.ts +22 -2
  84. package/dist/github.js +42 -8
  85. package/dist/gpu-words.d.ts +14 -0
  86. package/dist/gpu-words.js +21 -0
  87. package/dist/graph-view.d.ts +3 -1
  88. package/dist/graph-view.js +25 -1
  89. package/dist/handed-values.d.ts +1 -1
  90. package/dist/handed-values.js +1 -1
  91. package/dist/harness-install.d.ts +60 -3
  92. package/dist/harness-install.js +322 -34
  93. package/dist/harness.d.ts +1 -0
  94. package/dist/harness.js +36 -2
  95. package/dist/host-tools.d.ts +9 -10
  96. package/dist/host-tools.js +7 -7
  97. package/dist/hosted-search.d.ts +5 -4
  98. package/dist/hosted-search.js +2 -7
  99. package/dist/import-sources.d.ts +10 -0
  100. package/dist/import-sources.js +44 -2
  101. package/dist/import.d.ts +3 -3
  102. package/dist/import.js +37 -6
  103. package/dist/index.d.ts +1 -3
  104. package/dist/index.js +1 -2
  105. package/dist/key-refusal.d.ts +1 -1
  106. package/dist/key-refusal.js +2 -2
  107. package/dist/learn/check.d.ts +11 -2
  108. package/dist/learn/check.js +124 -6
  109. package/dist/learn/commit.d.ts +43 -7
  110. package/dist/learn/commit.js +166 -22
  111. package/dist/learn/folder.d.ts +11 -0
  112. package/dist/learn/folder.js +37 -1
  113. package/dist/learn/general.d.ts +66 -0
  114. package/dist/learn/general.js +73 -0
  115. package/dist/learn/grade.d.ts +22 -1
  116. package/dist/learn/grade.js +107 -16
  117. package/dist/learn/index.d.ts +1 -1
  118. package/dist/learn/index.js +1 -1
  119. package/dist/learn/learning.sh +12 -1
  120. package/dist/learn/notes.d.ts +3 -0
  121. package/dist/learn/notes.js +3 -0
  122. package/dist/learn/reflect.d.ts +14 -2
  123. package/dist/learn/reflect.js +54 -30
  124. package/dist/learn/skills.d.ts +37 -5
  125. package/dist/learn/skills.js +60 -7
  126. package/dist/learned-nodes.d.ts +6 -2
  127. package/dist/learned-workflow.d.ts +43 -9
  128. package/dist/learned-workflow.js +128 -37
  129. package/dist/learning-batch.d.ts +283 -0
  130. package/dist/learning-batch.js +574 -0
  131. package/dist/learning-cost.d.ts +79 -0
  132. package/dist/learning-cost.js +69 -0
  133. package/dist/learning-evals.d.ts +33 -0
  134. package/dist/learning-evals.js +98 -0
  135. package/dist/learning-routes.d.ts +32 -4
  136. package/dist/learning-routes.js +48 -12
  137. package/dist/learning-words.d.ts +9 -0
  138. package/dist/learning-words.js +12 -2
  139. package/dist/learning.d.ts +39 -19
  140. package/dist/learning.js +88 -46
  141. package/dist/live/stream.js +6 -3
  142. package/dist/live/translate.d.ts +4 -3
  143. package/dist/live/translate.js +8 -4
  144. package/dist/live-reach.d.ts +37 -0
  145. package/dist/live-reach.js +62 -0
  146. package/dist/mcp-gateway.d.ts +9 -0
  147. package/dist/mcp-gateway.js +60 -11
  148. package/dist/mcp-oauth.d.ts +57 -7
  149. package/dist/mcp-oauth.js +133 -18
  150. package/dist/mcp-private-hosts.d.ts +4 -4
  151. package/dist/mcp-private-hosts.js +20 -12
  152. package/dist/mcp-probe.d.ts +27 -3
  153. package/dist/mcp-probe.js +106 -29
  154. package/dist/mcp-secret-writes.js +8 -0
  155. package/dist/mcp-servers-store.d.ts +38 -15
  156. package/dist/mcp-servers-store.js +120 -23
  157. package/dist/mcp-store.d.ts +10 -4
  158. package/dist/mcp-store.js +17 -6
  159. package/dist/model-form.d.ts +26 -0
  160. package/dist/model-form.js +80 -0
  161. package/dist/model.d.ts +5 -5
  162. package/dist/model.js +29 -16
  163. package/dist/openapi.d.ts +2 -0
  164. package/dist/openapi.js +586 -64
  165. package/dist/owner.d.ts +0 -1
  166. package/dist/owner.js +0 -2
  167. package/dist/page.d.ts +18 -0
  168. package/dist/page.js +48 -20
  169. package/dist/paid-calls.d.ts +1 -1
  170. package/dist/paid-calls.js +1 -1
  171. package/dist/place-offers.d.ts +96 -0
  172. package/dist/place-offers.js +202 -0
  173. package/dist/place.d.ts +9 -13
  174. package/dist/place.js +21 -32
  175. package/dist/port-models.d.ts +2 -1
  176. package/dist/port-models.js +5 -3
  177. package/dist/print.d.ts +16 -9
  178. package/dist/print.js +15 -17
  179. package/dist/propose.d.ts +4 -0
  180. package/dist/propose.js +34 -11
  181. package/dist/provider.js +3 -2
  182. package/dist/reflect-range.d.ts +8 -1
  183. package/dist/reflect-range.js +1 -1
  184. package/dist/run-cut.d.ts +5 -0
  185. package/dist/run-cut.js +19 -0
  186. package/dist/run-launch.d.ts +28 -3
  187. package/dist/run-launch.js +14 -4
  188. package/dist/run-learning-served.d.ts +2 -2
  189. package/dist/run-manifest.d.ts +2 -2
  190. package/dist/run-manifest.js +2 -2
  191. package/dist/run-reads-over-store.d.ts +1 -1
  192. package/dist/run-repo.d.ts +20 -0
  193. package/dist/run-repo.js +63 -0
  194. package/dist/run-secrets.js +3 -3
  195. package/dist/run-timeline-served.d.ts +1 -1
  196. package/dist/run-timeline-served.js +56 -44
  197. package/dist/run-view.d.ts +8 -5
  198. package/dist/run-view.js +18 -10
  199. package/dist/runnable.d.ts +2 -2
  200. package/dist/runnable.js +6 -2
  201. package/dist/runner/adapter-loop.d.ts +39 -8
  202. package/dist/runner/adapter-loop.js +770 -83
  203. package/dist/runner/adapter-run-spec.d.ts +36 -7
  204. package/dist/runner/adapter-run-spec.js +171 -37
  205. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  206. package/dist/runner/adapters/pi-computer.js +43 -0
  207. package/dist/runner/adapters/pi.d.ts +20 -7
  208. package/dist/runner/adapters/pi.js +111 -26
  209. package/dist/runner/beside.d.ts +7 -3
  210. package/dist/runner/beside.js +26 -12
  211. package/dist/runner/claim-secrets.d.ts +4 -0
  212. package/dist/runner/claim-secrets.js +6 -1
  213. package/dist/runner/cli-run-spec.d.ts +27 -3
  214. package/dist/runner/cli-run-spec.js +198 -74
  215. package/dist/runner/commands.d.ts +8 -2
  216. package/dist/runner/commands.js +31 -6
  217. package/dist/runner/computer-channel.d.ts +34 -0
  218. package/dist/runner/computer-channel.js +61 -0
  219. package/dist/runner/conformance/harness.d.ts +0 -1
  220. package/dist/runner/conformance/harness.js +87 -18
  221. package/dist/runner/conformance/subject.d.ts +1 -1
  222. package/dist/runner/dispatch.js +3 -0
  223. package/dist/runner/end-of-run.d.ts +22 -12
  224. package/dist/runner/end-of-run.js +38 -16
  225. package/dist/runner/github-app.d.ts +2 -1
  226. package/dist/runner/github-app.js +6 -4
  227. package/dist/runner/harness-loops.js +16 -2
  228. package/dist/runner/held-run.d.ts +65 -0
  229. package/dist/runner/held-run.js +158 -0
  230. package/dist/runner/journal-kinds.d.ts +35 -6
  231. package/dist/runner/journal-kinds.js +20 -1
  232. package/dist/runner/journal-reader.d.ts +5 -4
  233. package/dist/runner/journal-reader.js +12 -10
  234. package/dist/runner/learning-ask.d.ts +7 -1
  235. package/dist/runner/learning-ask.js +21 -6
  236. package/dist/runner/learning-dispatch.d.ts +22 -0
  237. package/dist/runner/learning-dispatch.js +77 -10
  238. package/dist/runner/learning-end.d.ts +37 -1
  239. package/dist/runner/learning-end.js +115 -14
  240. package/dist/runner/learning-factory.d.ts +1 -1
  241. package/dist/runner/learning-factory.js +15 -5
  242. package/dist/runner/learning-loop.d.ts +139 -7
  243. package/dist/runner/learning-loop.js +369 -32
  244. package/dist/runner/learning-seed.d.ts +9 -0
  245. package/dist/runner/learning-seed.js +14 -1
  246. package/dist/runner/live-ticker.js +1 -0
  247. package/dist/runner/loop-contract.d.ts +16 -1
  248. package/dist/runner/loop-contract.js +6 -0
  249. package/dist/runner/loop.d.ts +10 -2
  250. package/dist/runner/loop.js +22 -1
  251. package/dist/runner/main.d.ts +13 -1
  252. package/dist/runner/main.js +38 -6
  253. package/dist/runner/mcp-claim.d.ts +11 -4
  254. package/dist/runner/mcp-claim.js +140 -23
  255. package/dist/runner/mcp-github.d.ts +4 -2
  256. package/dist/runner/mcp-github.js +1 -8
  257. package/dist/runner/mcp-run.d.ts +6 -4
  258. package/dist/runner/mcp-run.js +16 -3
  259. package/dist/runner/metrics.d.ts +15 -2
  260. package/dist/runner/metrics.js +21 -2
  261. package/dist/runner/model-route.d.ts +3 -0
  262. package/dist/runner/model-route.js +5 -2
  263. package/dist/runner/pr-checkout.d.ts +60 -0
  264. package/dist/runner/pr-checkout.js +176 -0
  265. package/dist/runner/reflect-hook.d.ts +19 -0
  266. package/dist/runner/reflect-hook.js +20 -8
  267. package/dist/runner/runner.d.ts +26 -0
  268. package/dist/runner/runner.js +231 -27
  269. package/dist/runner/scratch-sweep.d.ts +13 -0
  270. package/dist/runner/scratch-sweep.js +62 -0
  271. package/dist/runner/sessions.d.ts +1 -1
  272. package/dist/runner/spec-holds.d.ts +8 -3
  273. package/dist/runner/spec-holds.js +12 -10
  274. package/dist/runner/store-port.d.ts +7 -2
  275. package/dist/runner/store-secrets.js +21 -4
  276. package/dist/runner/subagent.d.ts +44 -0
  277. package/dist/runner/subagent.js +190 -0
  278. package/dist/runner/workflow-host.d.ts +24 -3
  279. package/dist/runner/workflow-host.js +24 -4
  280. package/dist/runner/workflow-loop.d.ts +6 -3
  281. package/dist/runner/workflow-loop.js +9 -8
  282. package/dist/runner/workflow-spec.d.ts +39 -15
  283. package/dist/runner/workflow-spec.js +143 -40
  284. package/dist/runs-over-store.d.ts +16 -6
  285. package/dist/runs-over-store.js +145 -29
  286. package/dist/seal-key.js +3 -3
  287. package/dist/sealed-settings-store.d.ts +5 -2
  288. package/dist/sealed-settings-store.js +10 -4
  289. package/dist/sealing.js +1 -2
  290. package/dist/secret-cut.d.ts +1 -1
  291. package/dist/secret-cut.js +1 -1
  292. package/dist/secret-writes.d.ts +5 -4
  293. package/dist/secret-writes.js +5 -4
  294. package/dist/server-secrets-store.d.ts +4 -3
  295. package/dist/server-secrets-store.js +15 -9
  296. package/dist/server-secrets.js +3 -2
  297. package/dist/server.d.ts +75 -63
  298. package/dist/server.js +712 -316
  299. package/dist/settings-wake.d.ts +21 -0
  300. package/dist/settings-wake.js +59 -0
  301. package/dist/standard-webhooks.d.ts +4 -1
  302. package/dist/standard-webhooks.js +8 -4
  303. package/dist/store/agent-body.d.ts +9 -2
  304. package/dist/store/agent-body.js +16 -8
  305. package/dist/store/command-wake.d.ts +12 -0
  306. package/dist/store/command-wake.js +37 -0
  307. package/dist/store/deadline.js +9 -5
  308. package/dist/store/dialect.d.ts +6 -0
  309. package/dist/store/dialect.js +5 -0
  310. package/dist/store/index.d.ts +4 -4
  311. package/dist/store/index.js +2 -2
  312. package/dist/store/journal/storage.d.ts +3 -2
  313. package/dist/store/journal/storage.js +15 -6
  314. package/dist/store/postgres/connection.js +9 -4
  315. package/dist/store/postgres/dialect.js +4 -0
  316. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  317. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  318. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  319. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  320. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  321. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  322. package/dist/store/schema.d.ts +2 -1
  323. package/dist/store/schema.js +85 -13
  324. package/dist/store/seal.d.ts +13 -0
  325. package/dist/store/seal.js +19 -0
  326. package/dist/store/sqlite/connection.d.ts +5 -0
  327. package/dist/store/sqlite/connection.js +88 -47
  328. package/dist/store/sqlite/run-patch.d.ts +25 -7
  329. package/dist/store/sqlite/run-patch.js +58 -14
  330. package/dist/store/sqlite/store.js +331 -59
  331. package/dist/store/store.d.ts +330 -21
  332. package/dist/store/store.js +34 -2
  333. package/dist/store-reads/analytics.js +3 -2
  334. package/dist/store-reads/cap.d.ts +2 -4
  335. package/dist/store-reads/cap.js +16 -7
  336. package/dist/store-reads/decisions.d.ts +3 -3
  337. package/dist/store-reads/decisions.js +3 -6
  338. package/dist/store-reads/import-summary.d.ts +1 -1
  339. package/dist/store-reads/journal.d.ts +5 -4
  340. package/dist/store-reads/journal.js +118 -27
  341. package/dist/store-reads/learning.d.ts +34 -4
  342. package/dist/store-reads/learning.js +137 -23
  343. package/dist/store-reads/runs.d.ts +7 -5
  344. package/dist/store-reads/runs.js +17 -10
  345. package/dist/store-reads/stats.js +5 -1
  346. package/dist/store-reads/workflow.d.ts +1 -1
  347. package/dist/store-view.d.ts +5 -0
  348. package/dist/store-view.js +70 -29
  349. package/dist/template-eval.js +8 -5
  350. package/dist/template-github-permissions.d.ts +22 -8
  351. package/dist/template-github-permissions.js +35 -15
  352. package/dist/templates.d.ts +64 -0
  353. package/dist/templates.js +101 -16
  354. package/dist/timeline/timeline.d.ts +30 -1
  355. package/dist/timeline/timeline.js +29 -13
  356. package/dist/timeline/util.d.ts +4 -0
  357. package/dist/timeline/util.js +14 -0
  358. package/dist/tool-blurbs.js +1 -0
  359. package/dist/tool-budget.d.ts +27 -7
  360. package/dist/tool-budget.js +21 -9
  361. package/dist/tool-gate.d.ts +23 -10
  362. package/dist/tool-gate.js +60 -44
  363. package/dist/tool-plane.d.ts +46 -28
  364. package/dist/tool-plane.js +73 -31
  365. package/dist/tools.d.ts +31 -38
  366. package/dist/tools.js +117 -74
  367. package/dist/trigger-adapter.d.ts +4 -0
  368. package/dist/trigger-secrets-shown.d.ts +2 -2
  369. package/dist/trigger-secrets-shown.js +1 -1
  370. package/dist/trigger-signatures.d.ts +26 -6
  371. package/dist/trigger-signatures.js +44 -8
  372. package/dist/trigger-targets.d.ts +2 -0
  373. package/dist/trigger-targets.js +1 -0
  374. package/dist/trigger-webhook.js +5 -2
  375. package/dist/triggers.d.ts +10 -6
  376. package/dist/triggers.js +37 -7
  377. package/dist/turn-end.d.ts +0 -3
  378. package/dist/turn-end.js +0 -3
  379. package/dist/turns.js +16 -1
  380. package/dist/usage-lines.d.ts +1 -1
  381. package/dist/validate.d.ts +6 -0
  382. package/dist/validate.js +41 -4
  383. package/dist/web-fetch.d.ts +1 -1
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +147 -103
  387. package/dist/webhooks.js +564 -324
  388. package/dist/workflow/decision-recovery.d.ts +23 -0
  389. package/dist/workflow/decision-recovery.js +80 -0
  390. package/dist/workflow/decisions.d.ts +134 -0
  391. package/dist/workflow/decisions.js +46 -0
  392. package/dist/workflow/host-session.d.ts +5 -0
  393. package/dist/workflow/host-session.js +85 -0
  394. package/dist/workflow/host-tools.d.ts +3 -0
  395. package/dist/workflow/host-tools.js +3 -0
  396. package/dist/workflow/node-runner.d.ts +113 -0
  397. package/dist/workflow/node-runner.js +270 -0
  398. package/dist/workflow/node.d.ts +89 -0
  399. package/dist/workflow/node.js +101 -0
  400. package/dist/workflow/operator-error.d.ts +4 -0
  401. package/dist/workflow/operator-error.js +4 -0
  402. package/dist/workflow/pi-versions.d.ts +32 -0
  403. package/dist/workflow/pi-versions.js +65 -0
  404. package/dist/workflow/record-file.d.ts +10 -0
  405. package/dist/workflow/record-file.js +56 -0
  406. package/dist/workflow/record-tool.d.ts +77 -0
  407. package/dist/workflow/record-tool.js +126 -0
  408. package/dist/workflow/record.d.ts +151 -0
  409. package/dist/workflow/record.js +401 -0
  410. package/dist/workflow/run-error.d.ts +16 -0
  411. package/dist/workflow/run-error.js +26 -0
  412. package/dist/workflow/runner.d.ts +6 -0
  413. package/dist/workflow/runner.js +240 -0
  414. package/dist/workflow/store.d.ts +23 -0
  415. package/dist/workflow/store.js +242 -0
  416. package/dist/workflow/task.d.ts +133 -0
  417. package/dist/workflow/task.js +412 -0
  418. package/dist/workflow/thinking.d.ts +3 -0
  419. package/dist/workflow/thinking.js +7 -0
  420. package/dist/workflow/tool-context.d.ts +21 -0
  421. package/dist/workflow/tool-context.js +13 -0
  422. package/dist/workflow/types.d.ts +126 -0
  423. package/dist/workflow/types.js +1 -0
  424. package/dist/workflow-run.d.ts +2 -2
  425. package/dist/workspace/agent-computer.d.ts +137 -0
  426. package/dist/workspace/agent-computer.js +292 -0
  427. package/dist/workspace/archil-claim.d.ts +11 -0
  428. package/dist/workspace/archil-claim.js +18 -10
  429. package/dist/workspace/archil-disks.d.ts +49 -0
  430. package/dist/workspace/archil-disks.js +185 -0
  431. package/dist/workspace/archil-exec.js +2 -3
  432. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  433. package/dist/workspace/archil-mount-credential.js +13 -4
  434. package/dist/workspace/attached-computers.d.ts +41 -0
  435. package/dist/workspace/attached-computers.js +114 -0
  436. package/dist/workspace/computer-deps.d.ts +32 -17
  437. package/dist/workspace/computer-deps.js +37 -14
  438. package/dist/workspace/computer-for-claim.d.ts +58 -13
  439. package/dist/workspace/computer-for-claim.js +267 -26
  440. package/dist/workspace/computer-hold.d.ts +11 -27
  441. package/dist/workspace/computer-hold.js +36 -56
  442. package/dist/workspace/computer-janitor.d.ts +3 -2
  443. package/dist/workspace/computer-janitor.js +43 -9
  444. package/dist/workspace/computer-ledger.d.ts +5 -1
  445. package/dist/workspace/computer-ledger.js +11 -0
  446. package/dist/workspace/computer-mcp.d.ts +25 -0
  447. package/dist/workspace/computer-mcp.js +41 -0
  448. package/dist/workspace/computer-ports.d.ts +4 -13
  449. package/dist/workspace/computer-ports.js +4 -107
  450. package/dist/workspace/computer-script.d.ts +37 -0
  451. package/dist/workspace/computer-script.js +138 -0
  452. package/dist/workspace/executors.d.ts +1 -1
  453. package/dist/workspace/index.d.ts +7 -4
  454. package/dist/workspace/index.js +4 -1
  455. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  456. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  457. package/dist/workspace/resolve-computer.d.ts +45 -11
  458. package/dist/workspace/resolve-computer.js +72 -14
  459. package/dist/workspace/run-disk.d.ts +34 -0
  460. package/dist/workspace/run-disk.js +91 -0
  461. package/dist/workspace/run-tools.d.ts +35 -18
  462. package/dist/workspace/run-tools.js +24 -29
  463. package/dist/workspace/server-run-workspace.d.ts +3 -2
  464. package/dist/workspace/server-run-workspace.js +17 -4
  465. package/dist/workspace.js +1 -1
  466. package/package.json +19 -21
  467. package/templates/README.md +9 -6
  468. package/templates/code-review/agent.md +27 -11
  469. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  470. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  471. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  472. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  473. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  474. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  475. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  476. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  477. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  478. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  479. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  480. package/templates/code-review/evals/re-review/prompt.md +1 -1
  481. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  482. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  483. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  484. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  485. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  486. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  487. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  488. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  489. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  490. package/templates/code-review/findings.schema.json +131 -27
  491. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  492. package/templates/code-review/skills/review/DEEP.md +130 -0
  493. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  494. package/templates/code-review/skills/review/SKILL.md +104 -154
  495. package/templates/market-monitor/agent.md +1 -1
  496. package/dist/box/record.d.ts +0 -6
  497. package/dist/box/record.js +0 -41
  498. package/dist/box/sweep.d.ts +0 -53
  499. package/dist/box/sweep.js +0 -193
  500. package/dist/box-egress-vm.d.ts +0 -118
  501. package/dist/box-egress-vm.js +0 -354
  502. package/dist/box-egress.d.ts +0 -105
  503. package/dist/box-egress.js +0 -256
  504. package/dist/box-relay-vm.d.ts +0 -84
  505. package/dist/box-relay-vm.js +0 -437
  506. package/dist/box-relay.d.ts +0 -36
  507. package/dist/box-relay.js +0 -207
  508. package/dist/boxes.d.ts +0 -109
  509. package/dist/boxes.js +0 -249
  510. package/dist/budget.d.ts +0 -71
  511. package/dist/budget.js +0 -199
  512. package/dist/console/assets/index-B7NKTU8E.css +0 -1
  513. package/dist/console/assets/index-CXZMgJE7.js +0 -550
  514. package/dist/daytona-api.d.ts +0 -10
  515. package/dist/daytona-api.js +0 -20
  516. package/dist/egress-proxy.d.ts +0 -45
  517. package/dist/egress-proxy.js +0 -416
  518. package/dist/egress-table.d.ts +0 -24
  519. package/dist/egress-table.js +0 -165
  520. package/dist/run-db.d.ts +0 -53
  521. package/dist/run-db.js +0 -116
  522. package/templates/code-review/rules/REVIEW.md +0 -41
@@ -1,7 +1,32 @@
1
- import { releaseOlder, runLabels } from "@parcha/agentrun-computer";
1
+ // The run's computer at its claim, the one call both runner specs make (the adapter loop's and the CLI's): the agent's
2
+ // computer setting, resolved in the server's mode against the computer module's kind registry (resolveComputer), started
3
+ // for this run under this claim (labels agentrun.run and agentrun.epoch, the run's folder mounted only where the provider
4
+ // mounts it), with a hold and its live view when it is a desktop or a phone, and released once at the run's end. The hold
5
+ // goes back to the spec (`held`), whose adapter loop journals it and applies the owner's take-over and hand-back rows to it
6
+ // (runner/computer-journal.ts); the live view (computer-live.ts openClaimView) drives the same hold. A computer that cannot
7
+ // be had is refused in words with code computer_unavailable; kind none, or no setting where the server's default is none,
8
+ // is no computer.
9
+ //
10
+ // A provider is made with its keys (the server's environment's, else the store's sealed keys, through the composer's
11
+ // keyOf: computer-deps.ts), by the names the registry declares, through serve's own
12
+ // map of key names to options (computer-keys.ts providerOptions); a provider that keeps sessions with no labels of their
13
+ // own (the phone's) is given the store's computer ledger. Nothing here knows a vendor: the registry, the providers' create
14
+ // and a test's stand-ins are passed in.
15
+ //
16
+ // A paired computer (a person's own, attached-computers.ts) is one more provider of the registry for the claim, by its
17
+ // id: claimed through the hub of the server's process (the computer package's attachedProvider), released by ending the
18
+ // run's hold, never made or deleted.
19
+ //
20
+ // A persistent setting (the agent's own computer, agent-computer.ts) is made once under the agent's owner (this server's
21
+ // id and the agent's), found again by its owner at each later claim and attached under the new claim, and detached, not
22
+ // deleted, at the run's end. A run that finds it held by another run still going is refused, naming that run.
23
+ import { randomUUID } from "node:crypto";
24
+ import { isBrowserProvider, ownerFilter, releaseOlder, RUN_LABEL, runLabels } from "@parcha/agentrun-computer";
2
25
  import { computerOfPlace } from "../computer-setting.js";
3
26
  import { KEY_TABLE, providerOptions } from "../computer-keys.js";
4
27
  import { getSealedKey } from "../server-keys.js";
28
+ import { agentComputerOf, forgetAgentComputer, holdAgentComputer, keepAgentComputer, liveHolderOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
29
+ import { pairedProvider, withPaired } from "./attached-computers.js";
5
30
  import { computerHold, heldHands } from "./computer-hold.js";
6
31
  import { storeLedger } from "./computer-ledger.js";
7
32
  import { providerKeys, resolveComputer } from "./resolve-computer.js";
@@ -11,6 +36,8 @@ const unavailable = (words) => Object.assign(new Error(words), { code: "computer
11
36
  const claimLost = (words) => Object.assign(new Error(words), { code: "claim_lost" });
12
37
  const noop = async () => { };
13
38
  /** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. */
39
+ /** A claim's create request: the run and its claim epoch, so a retry of the claim's create finds the computer it made. */
40
+ const claimRequestId = (claim) => `${claim.runId}#${claim.epoch}`;
14
41
  async function settingOf(launch, store) {
15
42
  if (launch.computer)
16
43
  return launch.computer;
@@ -42,7 +69,8 @@ async function readyImage(entry, provider, signal, onWait) {
42
69
  throw new Error(ready.error.message);
43
70
  return ready.value;
44
71
  }
45
- const watching = (provider) => typeof provider.watch === "function" ? provider : undefined;
72
+ /** The provider's watch of a computer's screen on `ref` (ComputerProvider.watch), where it has one. */
73
+ const watchOf = (provider, ref) => typeof provider.watch === "function" ? (handlers, options) => provider.watch(ref, handlers, options) : undefined;
46
74
  /** The browser computer `ref`'s CDP URL now: the provider's connect (its signed URL), its words and code when the session
47
75
  * has ended. The connection itself is let go once read. */
48
76
  async function cdpUrlOf(provider, ref) {
@@ -62,13 +90,19 @@ const labelValue = (value) => value.replace(/[^A-Za-z0-9_.:-]+/g, "_").slice(0,
62
90
  /** A provider failure as an error with the provider's words and code. */
63
91
  const failed = (error) => Object.assign(new Error(error.message), { code: error.code });
64
92
  /** 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) {
93
+ * 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,
94
+ * with the session's own options (spec.browser) where the provider declares them (capabilities().browser); its release
95
+ * lets go of every one the tool left open. The claim's browser (the agent's computer) and the tool plane's vendor's
96
+ * (browser-computer.ts planeBrowser) are each one of these. */
97
+ export function claimBrowser(provider, spec) {
68
98
  // A run's browser: the claim's spec always carries its lifetime (computerSpecOf); an agent's computer (owner) has none.
69
99
  const lifetime = spec.lifetimeMs;
70
100
  if (lifetime === undefined)
71
101
  throw new TypeError("a run's browser needs lifetimeMs: the claim's spec carries none");
102
+ // A provider of kind browser that declares no session features is opened as one that ends its sessions on a wall clock
103
+ // and takes no option but a viewport.
104
+ const features = provider.capabilities().browser ?? { timeout: "wall-clock" };
105
+ const kept = isBrowserProvider(provider) ? provider.downloads : undefined;
72
106
  const open = new Set();
73
107
  const release = async (id) => {
74
108
  const released = await provider.release({ id, name: id }, "delete");
@@ -76,13 +110,21 @@ function claimBrowser(provider, spec) {
76
110
  throw failed(released.error);
77
111
  open.delete(id);
78
112
  };
113
+ const valueOf = async (result) => {
114
+ const answered = await result;
115
+ if (!answered.ok)
116
+ throw failed(answered.error);
117
+ return answered.value;
118
+ };
79
119
  return {
80
120
  browser: {
81
121
  provider: provider.id,
82
122
  maxLifetimeS: Math.floor(lifetime / 1000),
83
- async open(tag, lifetimeS, signal) {
123
+ features: structuredClone(features),
124
+ async open(tag, lifetimeS, browser, signal) {
84
125
  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 } : {});
126
+ // Each open is its own request: a session closed and opened again under one tag is a new one.
127
+ const created = await provider.create({ ...spec, lifetimeMs, labels: { ...spec.labels, [SESSION_TAG]: labelValue(tag) }, ...(browser ? { browser } : {}) }, { requestId: randomUUID(), ...(signal ? { signal } : {}) });
86
128
  if (!created.ok)
87
129
  throw failed(created.error);
88
130
  open.add(created.value.id);
@@ -94,8 +136,24 @@ function claimBrowser(provider, spec) {
94
136
  throw failed(listed.error);
95
137
  return listed.value.map((one) => one.ref.id);
96
138
  },
139
+ async running(id, signal) {
140
+ const found = await provider.attach({ id }, signal ? { signal } : {});
141
+ if (found.ok)
142
+ return true;
143
+ if (found.error.code === "not_found" || found.error.code === "gone")
144
+ return false;
145
+ throw failed(found.error);
146
+ },
97
147
  url: (id) => cdpUrlOf(provider, { id, name: id }),
98
148
  close: release,
149
+ ...(kept && features.downloads
150
+ ? {
151
+ downloads: {
152
+ list: (id) => valueOf(kept.list({ id, name: id })),
153
+ read: (id, name, maxBytes) => valueOf(kept.read({ id, name: id }, name, maxBytes)),
154
+ },
155
+ }
156
+ : {}),
99
157
  },
100
158
  async release() {
101
159
  for (const id of [...open])
@@ -110,7 +168,8 @@ async function providerLaunch(provider, claim, spec, signal) {
110
168
  const older = await releaseOlder(provider, claim.runId, claim.epoch, signal ? { signal } : {});
111
169
  if (!older.ok)
112
170
  throw new Error(older.error.message);
113
- const created = await provider.create(spec, signal ? { signal } : {});
171
+ // The claim is the request: a retry of this launch under the same epoch gets the computer it made, never a second.
172
+ const created = await provider.create(spec, { requestId: claimRequestId(claim), ...(signal ? { signal } : {}) });
114
173
  if (!created.ok)
115
174
  throw new Error(created.error.message);
116
175
  const ref = { id: created.value.id, name: created.value.name };
@@ -125,11 +184,13 @@ async function providerLaunch(provider, claim, spec, signal) {
125
184
  throw new Error(connected.error.message);
126
185
  }
127
186
  const { client, hello } = connected.value;
187
+ const watch = watchOf(provider, ref);
128
188
  return {
129
189
  id: ref.id,
130
190
  groups: hello.groups,
131
191
  // What the machine says it is (a phone's android or ios): its live view's input platform.
132
192
  machine: hello.kind,
193
+ hello,
133
194
  client,
134
195
  async readBack() {
135
196
  const attached = await provider.attach({ id: ref.id });
@@ -138,42 +199,197 @@ async function providerLaunch(provider, claim, spec, signal) {
138
199
  return attached.value.spec.mount ? { ok: true, value: attached.value.spec.mount } : { ok: false, error: { code: "not_found", message: "nothing is mounted in this computer" } };
139
200
  },
140
201
  // The provider's watch of the screen (provider.watch), which feeds the run's proxied live view.
141
- ...(watching(provider) ? { watch: (signal) => watching(provider).watch(ref, { signal }) } : {}),
202
+ ...(watch ? { watch } : {}),
142
203
  async release() {
143
204
  await connected.value.close().catch(() => undefined);
144
205
  await release();
145
206
  },
146
207
  };
147
208
  }
209
+ /** A run state in which the run still holds what it claimed. */
210
+ const LIVE_RUN = new Set(["queued", "running", "parked"]);
211
+ /**
212
+ * The agent's own computer for this claim (a persistent setting): the one its owner's listing finds, attached under this
213
+ * claim, else one made with `spec` (its owner, no lifetime). The record this server keeps names it, held by this run. A
214
+ * computer whose listing names another run that is still going is refused in words naming that run; one a run that ended
215
+ * left running is taken over. Its release detaches it (Orgo's suspend, say), keeping its state for the agent's next run;
216
+ * then the agent's record is reconciled, so an agent that was archived or turned persistent off while the run went has
217
+ * its computer deleted.
218
+ */
219
+ async function ownedLaunch(provider, claim, spec, context, signal) {
220
+ const { store, agentId } = context;
221
+ // One run at a time, taken in the store before anything is listed or made (agent-computer.ts holdAgentComputer): two
222
+ // runs of the agent that claim at once never both make a computer. With no run rows to read, a holder is still going.
223
+ // The hold is this claim's (its epoch): a later claim of the run takes it over, and this one's end then does nothing.
224
+ const hold = await holdAgentComputer(store, agentId, claim.runId, liveHolderOf(store), { epoch: claim.epoch });
225
+ let launched;
226
+ try {
227
+ launched = await ownedStart(provider, claim, spec, context, hold, signal);
228
+ }
229
+ catch (error) {
230
+ await hold.letGo().catch(() => undefined);
231
+ throw error;
232
+ }
233
+ return {
234
+ ...launched,
235
+ async release() {
236
+ try {
237
+ await launched.release();
238
+ }
239
+ finally {
240
+ await hold.letGo();
241
+ }
242
+ },
243
+ };
244
+ }
245
+ /** The owned launch once the run holds the agent's computer (ownedLaunch): found and attached, or made; connected. */
246
+ async function ownedStart(provider, claim, spec, context, hold, signal) {
247
+ const call = signal ? { signal } : {};
248
+ const { store, agentId, note } = context;
249
+ const older = await releaseOlder(provider, claim.runId, claim.epoch, call);
250
+ if (!older.ok)
251
+ throw new Error(older.error.message);
252
+ const listed = await provider.list(ownerFilter(context.owner), call);
253
+ if (!listed.ok)
254
+ throw new Error(listed.error.message);
255
+ const record = await agentComputerOf(store, agentId);
256
+ const found = listed.value.find((info) => info.ref.id === record?.id) ?? listed.value[0];
257
+ let ref;
258
+ /** Whether this claim made the computer, or attached the one the agent had. */
259
+ let made;
260
+ if (found) {
261
+ const holder = found.labels[RUN_LABEL];
262
+ if (found.state === "running" && holder !== undefined && holder !== claim.runId) {
263
+ const row = store.runs ? await store.runs.get(holder) : undefined;
264
+ // With no run rows to read, a holder is taken as still going: never two runs on one agent's computer.
265
+ if (!store.runs || (row !== undefined && LIVE_RUN.has(row.state))) {
266
+ throw new Error(`this agent's computer ${found.ref.name} is held by run ${holder}, which is still ${row?.state ?? "going"}: an agent's own computer serves one run at a time. Start this run again once that one ends`);
267
+ }
268
+ }
269
+ const attached = await provider.attach({ id: found.ref.id }, { claim: { run: claim.runId, epoch: claim.epoch }, ...call });
270
+ if (!attached.ok)
271
+ throw new Error(attached.error.message);
272
+ ref = { id: found.ref.id, name: found.ref.name };
273
+ made = false;
274
+ note(`Attached this agent's computer ${ref.name}, kept from its last run.`);
275
+ }
276
+ else {
277
+ const created = await provider.create(spec, { ...call, requestId: claimRequestId(claim) });
278
+ if (!created.ok)
279
+ throw new Error(created.error.message);
280
+ ref = { id: created.value.id, name: created.value.name };
281
+ made = true;
282
+ note(record
283
+ ? `This agent's computer ${record.name} is gone (deleted outside this server): made a new one, ${ref.name}, which later runs get back.`
284
+ : `Made this agent's own computer ${ref.name}: later runs get it back.`);
285
+ }
286
+ // The computer is acquired: its cleanup is in place before anything else is awaited, and whatever fails from here (the
287
+ // hold lost to a later claim included) lets go of exactly what this claim acquired.
288
+ const computer = { provider: context.provider, image: context.image, ...ref };
289
+ // The hold is marked letting go first, so no claim takes it over while the computer is detached. A claim that took it
290
+ // over since (a later claim of this run, resumed, or another run once this one's row ended) has the computer now: it
291
+ // is left as it is.
292
+ const detach = async () => {
293
+ if (!(await hold.releasing()))
294
+ return;
295
+ const released = await provider.release(ref, "detach");
296
+ if (!released.ok)
297
+ throw new Error(released.error.message);
298
+ await keepAgentComputer(store, agentId, computer, "detached");
299
+ await reconcileAgentComputer(store, agentId, async () => provider, hold);
300
+ };
301
+ // A launch that fails: a computer this claim made is deleted under its claim, so one a later claim has taken since (a
302
+ // resume whose owner's listing found it) is left to that claim, and the record goes where it names it; one it attached
303
+ // is detached as at the run's end, where the hold is still this claim's. Throws `error`, with what was let go.
304
+ const abandon = async (error) => {
305
+ const words = error instanceof Error ? error.message : String(error);
306
+ if (!made) {
307
+ const undone = await detach().then(() => undefined, (failed) => (failed instanceof Error ? failed.message : String(failed)));
308
+ throw new Error(undone === undefined ? words : `${words}; and ${ref.name} could not be detached: ${undone}`);
309
+ }
310
+ const deleted = await provider.release(ref, "delete", { claim: { run: claim.runId, epoch: claim.epoch } });
311
+ if (deleted.ok)
312
+ await forgetAgentComputer(store, agentId, ref.id).catch(() => undefined);
313
+ throw new Error(`${words}; ${ref.name}, which this claim made, ${deleted.ok ? "was deleted" : `was not deleted (${deleted.error.message})`}`);
314
+ };
315
+ let connected;
316
+ try {
317
+ // A later claim of this run (or another run, this one's row ended) that took the hold over while this one attached
318
+ // or made the computer has it now: its record is that claim's to write.
319
+ if (!(await hold.holds()))
320
+ throw new Error(`fenced: this agent's computer ${ref.name} was taken over by a later claim while run ${claim.runId}'s claim at epoch ${claim.epoch} ${made ? "made" : "attached"} it; it is left to that claim`);
321
+ await keepAgentComputer(store, agentId, computer, "held", { run: claim.runId });
322
+ const opened = await provider.connect(ref);
323
+ if (!opened.ok)
324
+ throw new Error(opened.error.message);
325
+ connected = opened.value;
326
+ }
327
+ catch (error) {
328
+ return abandon(error);
329
+ }
330
+ const { client, hello } = connected;
331
+ return {
332
+ id: ref.id,
333
+ groups: hello.groups,
334
+ machine: hello.kind,
335
+ hello,
336
+ client,
337
+ // An agent's own computer mounts no run's folder (resolve-computer.ts refuses one that would).
338
+ async readBack() {
339
+ return { ok: false, error: { code: "not_found", message: "an agent's own computer mounts no run's folder" } };
340
+ },
341
+ // The provider's watch of the screen, which feeds the run's proxied live view, as a made computer's.
342
+ ...(watchOf(provider, ref) ? { watch: watchOf(provider, ref) } : {}),
343
+ async release() {
344
+ await connected.close().catch(() => undefined);
345
+ await detach();
346
+ },
347
+ };
348
+ }
148
349
  /** The run's computer for this claim, started and registered; `{ computer: undefined }` for none. Throws with code
149
350
  * computer_unavailable and the server's words when the agent's computer cannot be had here. */
150
- export async function computerForClaim(launch, store, deps) {
351
+ export async function computerForClaim(launch,
352
+ // `settings` and `runs`: the agent's own computer's record and its holder's run row, for a persistent setting alone.
353
+ store, deps) {
151
354
  const table = deps.keyTable ?? KEY_TABLE;
355
+ // The paired computers, each one more provider of the registry (attached-computers.ts): a setting names one by its id.
356
+ const paired = deps.attached ? await deps.attached.rows() : [];
357
+ const kinds = withPaired(deps.kinds, paired);
152
358
  /** The computer this claim started (one per claim): its ref id tags its live view, and its watch feeds it. */
153
359
  let made;
154
360
  /** The provider entry it was started from: a phone's platform where the computer did not say it. */
155
361
  let madeBy;
362
+ /** A vendor's provider (or a local one's), made with the keys and the configuration the setting selected: that
363
+ * configuration is built by its own create() options (Orgo's Windows: { os: "windows" }), beside the keys'. */
364
+ const vendorProvider = async (entry, keys, configuration) => {
365
+ const make = Object.hasOwn(deps.providers, entry.id) ? deps.providers[entry.id] : undefined;
366
+ if (!make)
367
+ throw new Error(`this server has no ${entry.label} provider to start one with`);
368
+ const options = providerOptions(entry.id, keys, deps.settings ?? {}, table);
369
+ if (!options.ok)
370
+ throw new Error(options.error.message);
371
+ return make({ ...options.options, ...configuration.options }, { ledger: storeLedger(store.computerLedger, entry.id), ...(launch.boxAllow === undefined ? {} : { boxAllow: launch.boxAllow }) });
372
+ };
156
373
  const side = {
157
- keysOf: providerKeys(deps.kinds, deps.keyOf ?? (async (name) => (deps.sealKey ? await getSealedKey(store, deps.sealKey, name) : undefined))),
374
+ keysOf: providerKeys(kinds, deps.keyOf ?? (async (name) => (deps.sealKey ? await getSealedKey(store, deps.sealKey, name) : undefined))),
158
375
  answers: deps.answers ?? (async () => false),
159
376
  ...(deps.daemon ? { daemon: deps.daemon } : {}),
160
- async launch(entry, { kind, keys, configuration, mount, gpu, signal }) {
161
- if (deps.launch) {
162
- const own = await deps.launch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}), ...(signal ? { signal } : {}) });
377
+ async launch(entry, { kind, keys, configuration, mount, gpu, persistent, signal }) {
378
+ const ownLaunch = deps.launch && (deps.launches?.(entry.id) ?? true) ? deps.launch : undefined;
379
+ // An agent's own computer needs its agent and the store's record of it; the server's launch (--faux) keeps none.
380
+ if (persistent && (ownLaunch || launch.agentId === undefined || store.settings === undefined))
381
+ throw new Error("this run can't keep its agent's own computer here: start it again with persistent off");
382
+ // A paired computer is claimed through the hub of this process (attachedProvider), never made: --faux's launch,
383
+ // which stands in for the vendors', is not its.
384
+ const pairedRow = paired.find((row) => row.id === entry.id);
385
+ if (ownLaunch && !pairedRow) {
386
+ const own = await ownLaunch(entry, { kind, keys, configuration, ...(mount ? { mount } : {}), ...(gpu ? { gpu } : {}), ...(signal ? { signal } : {}) });
163
387
  const ownWatch = own.watch;
164
388
  made = { id: own.id, ...(ownWatch ? { watch: ownWatch } : {}) };
165
389
  madeBy = entry;
166
390
  return own;
167
391
  }
168
- const make = Object.hasOwn(deps.providers, entry.id) ? deps.providers[entry.id] : undefined;
169
- if (!make)
170
- throw new Error(`this server has no ${entry.label} provider to start one with`);
171
- const options = providerOptions(entry.id, keys, deps.settings ?? {}, table);
172
- if (!options.ok)
173
- throw new Error(options.error.message);
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 }) });
392
+ const provider = pairedRow ? pairedProvider(pairedRow, deps.attached?.hub) : await vendorProvider(entry, keys, configuration);
177
393
  // What this provider makes, as it declares it: the spec asks for one of its networks, within its lifetime
178
394
  // (computer-deps.ts computerSpecOf).
179
395
  const { network: networks, maxLifetimeMs } = provider.capabilities();
@@ -201,13 +417,31 @@ export async function computerForClaim(launch, store, deps) {
201
417
  madeBy = entry;
202
418
  return { id: entry.id, groups: ["cdp"], browser: opened.browser, release: opened.release };
203
419
  }
204
- const launched = await providerLaunch(provider, launch, spec, signal);
420
+ let launched;
421
+ if (persistent) {
422
+ // The agent's own: its owner (this server and the agent), and no run deadline (it outlives the run).
423
+ const owner = { agent: launch.agentId, server: await serverIdOf({ settings: store.settings }) };
424
+ const { lifetimeMs: _, ...owned } = spec;
425
+ launched = await ownedLaunch(provider, launch, { ...owned, owner }, {
426
+ store: { settings: store.settings, agents: store.agents, ...(store.runs ? { runs: store.runs } : {}) },
427
+ agentId: launch.agentId,
428
+ owner,
429
+ provider: entry.id,
430
+ image: configuration.image,
431
+ note: deps.onComputerNote ?? (() => { }),
432
+ }, signal);
433
+ }
434
+ else {
435
+ launched = await providerLaunch(provider, launch, spec, signal);
436
+ }
205
437
  made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch } : {}) };
206
438
  madeBy = entry;
439
+ const { os, osVersion, arch } = launched.hello;
440
+ deps.onConnected?.({ provider: entry.label, kind: kind, hello: { os, ...(osVersion ? { osVersion } : {}), arch } });
207
441
  return launched;
208
442
  },
209
443
  };
210
- const resolved = await resolveComputer(await settingOf(launch, store), deps.mode, deps.kinds, side);
444
+ const resolved = await resolveComputer(await settingOf(launch, store), deps.mode, kinds, side);
211
445
  if ("refused" in resolved)
212
446
  throw unavailable(resolved.refused);
213
447
  if (resolved.kind === "none")
@@ -215,6 +449,10 @@ export async function computerForClaim(launch, store, deps) {
215
449
  const refusedKind = deps.refuseKind?.(resolved.kind);
216
450
  if (refusedKind)
217
451
  throw unavailable(refusedKind);
452
+ // The program its provider runs on this machine (the phone's adb) is checked before anything is rented.
453
+ const hostRefusal = resolved.provider ? deps.hostWhy?.(resolved.provider) : undefined;
454
+ if (hostRefusal)
455
+ throw unavailable(`This agent's computer is a ${resolved.kind} on ${resolved.provider}, and this runner cannot run it: ${hostRefusal.replace(/[.!?]+$/, "")}.`);
218
456
  // The run's mount credential (Mode 2), minted when the mount was made: removed with the computer, or at once when the
219
457
  // start fails after it was minted.
220
458
  const revoke = async () => { await deps.revokeMount?.(); };
@@ -232,13 +470,14 @@ export async function computerForClaim(launch, store, deps) {
232
470
  // vendor's URL reaches a person), opened under this claim. A fenced open is a lost claim. The release ends the hold.
233
471
  let endHold = () => { };
234
472
  let hold;
473
+ let held;
235
474
  let view;
236
475
  if (computer && (computer.kind === "desktop" || computer.kind === "phone")) {
237
476
  const theHold = computerHold();
238
477
  if (deps.openComputerView && made?.watch) {
239
478
  const watch = made.watch;
240
479
  const input = computer.kind === "desktop" ? "desktop" : phonePlatform(made.machine, madeBy);
241
- const opened = await deps.openComputerView({ store, sealKey: deps.sealKey, claim: launch.claim ?? { runId: launch.runId, epoch: launch.epoch }, kind: computer.kind, input, tag: made.id, watch: (signal) => watch(signal), hold: theHold });
480
+ const opened = await deps.openComputerView({ store, sealKey: deps.sealKey, claim: launch.claim ?? { runId: launch.runId, epoch: launch.epoch }, kind: computer.kind, input, tag: made.id, watch, hold: theHold });
242
481
  if (!opened.ok) {
243
482
  await started.release().catch(() => undefined);
244
483
  await revoke().catch(() => undefined);
@@ -252,11 +491,13 @@ export async function computerForClaim(launch, store, deps) {
252
491
  // goes; the composer's `ended` ViewEnd maps onto it), the agent's open ask is let go at once, and nothing is taken after.
253
492
  endHold = () => theHold.close();
254
493
  hold = (ports) => heldHands(ports, theHold);
494
+ held = { kind: computer.kind, hold: theHold };
255
495
  }
256
496
  let released;
257
497
  return {
258
498
  ...(computer ? { computer } : {}),
259
499
  ...(hold ? { hold } : {}),
500
+ ...(held ? { held } : {}),
260
501
  release: (why = "released") => (released ??= (async () => {
261
502
  await Promise.resolve(view?.close(why)).catch(() => undefined);
262
503
  endHold();
@@ -115,36 +115,20 @@ export declare function computerHold(options?: {
115
115
  readonly now?: () => number;
116
116
  }): ComputerHold;
117
117
  /** What the model is told of an act it asked for while the person had the computer: not done, look again. */
118
- export declare const personHadWords: (computer: "desktop" | "phone", act: string) => string;
119
- /** The code a parked act throws, as the kernel's ports throw a refusal: the registry's executors answer it in its words. */
118
+ export declare const personHadWords: (act: string) => string;
119
+ /** The kind a parked act throws, as the computer's port throws a refusal: the registry's executors answer it in its words. */
120
120
  export declare const TAKEN_OVER = "taken_over";
121
- /** The kernel's narrow ports a desktop and a phone have, as heldHands needs them (run-adapters kernel/registry Hands). */
122
- type ScreenPort = {
123
- shot(...args: never[]): Promise<unknown>;
121
+ /** The computer's one port, as heldHands needs it (run-adapters kernel/registry Hands.computer). */
122
+ type Port = {
123
+ readonly groups: readonly string[];
124
+ call(op: string, args: unknown, signal?: AbortSignal): Promise<unknown>;
124
125
  };
125
- type InputPort = {
126
- actions(...args: never[]): Promise<unknown>;
126
+ type WithPort = Partial<Hands> & {
127
+ readonly computer?: Port;
127
128
  };
128
- type PhonePort = {
129
- shot(...args: never[]): Promise<unknown>;
130
- tree?(...args: never[]): Promise<unknown>;
131
- tap(...args: never[]): Promise<unknown>;
132
- swipe(...args: never[]): Promise<unknown>;
133
- type(...args: never[]): Promise<unknown>;
134
- key?(...args: never[]): Promise<unknown>;
135
- apps: {
136
- list(...args: never[]): Promise<unknown>;
137
- open(...args: never[]): Promise<unknown>;
138
- };
139
- };
140
- type WithPorts = Partial<Hands> & {
141
- readonly screen?: ScreenPort;
142
- readonly input?: InputPort;
143
- readonly phone?: PhonePort;
144
- };
145
- /** `hands` with its screen, input and phone ports parked while the person has the computer, and the agent's ask
146
- * (`handoff`) through the hold; everything else as it is. */
147
- export declare function heldHands<H extends WithPorts>(hands: H, hold: ComputerHold): H & {
129
+ /** `hands` with its computer port held while the person has the computer, and the agent's ask (`handoff`) through the
130
+ * hold; everything else as it is. */
131
+ export declare function heldHands<H extends WithPort>(hands: H, hold: ComputerHold): H & {
148
132
  readonly handoff: Handoff;
149
133
  };
150
134
  export {};
@@ -6,9 +6,9 @@
6
6
  // waited out, so the gate never cuts an action in half, and new agent calls are parked); `person` (the owner drives,
7
7
  // and the agent's calls are parked). A take ends in one of five ways: `given` (handed back), `answered` (the agent's ask
8
8
  // was answered while the owner held it), `idle` (no input from the owner for HOLD_IDLE_MS), `away` (the viewer closed or
9
- // lost its socket: back at once) or `released` (the computer's session ended). At the hand-back a parked look (a
10
- // screenshot, the app list) runs on the screen as the person left it; a parked act (input, a tap, a swipe, typing,
11
- // opening an app) is not done: the model is told the person had the computer, and to look again first. exec, files and
9
+ // lost its socket: back at once) or `released` (the computer's session ended). At the hand-back a parked look (an
10
+ // observe, a screenshot, the app list) runs on the screen as the person left it; a parked act (an act's steps, raw
11
+ // input, opening an app) is not done: the model is told the person had the computer, and to look again first. exec, files and
12
12
  // processes are not the person's: they pass through.
13
13
  //
14
14
  // The agent's ask (`ask`): one at a time; it waits until the owner answers (done or cancelled), until it expires
@@ -200,64 +200,44 @@ export function computerHold(options = {}) {
200
200
  };
201
201
  }
202
202
  /** What the model is told of an act it asked for while the person had the computer: not done, look again. */
203
- export const personHadWords = (computer, act) => `The person had this ${computer}: they took it over from the run's view and have handed it back, so this ${act} was not done. The screen may have changed: take a screenshot before you act again.`;
204
- /** The code a parked act throws, as the kernel's ports throw a refusal: the registry's executors answer it in its words. */
203
+ export const personHadWords = (act) => `The person had this computer: they took it over from the run's view and have handed it back, so this ${act} was not done. The screen may have changed: observe again before you act.`;
204
+ /** The kind a parked act throws, as the computer's port throws a refusal: the registry's executors answer it in its words. */
205
205
  export const TAKEN_OVER = "taken_over";
206
- const refusal = (computer, act) => Object.assign(new Error(personHadWords(computer, act)), { code: TAKEN_OVER });
207
- /** The port method `method` of `port`, a look: parked while the person has the computer, then run (as the agent's call
208
- * in flight, which a take waits out). */
209
- function look(port, method, hold) {
210
- const original = port[method];
211
- return (async (...args) => {
212
- const leave = await hold.enter();
213
- try {
214
- return await original.apply(port, args);
215
- }
216
- finally {
217
- leave();
218
- }
219
- });
220
- }
221
- /** The port method `method` of `port`, an act: made with the agent driving, it runs (in flight, so a take waits it out);
222
- * made while the person has the computer, it waits for the hand-back and is not done. */
223
- function act(port, method, hold, computer, what) {
224
- const original = port[method];
225
- return (async (...args) => {
226
- const parked = hold.state() !== "agent";
227
- const leave = await hold.enter();
228
- if (parked) {
229
- leave();
230
- throw refusal(computer, what);
231
- }
232
- try {
233
- return await original.apply(port, args);
234
- }
235
- finally {
236
- leave();
237
- }
238
- });
206
+ /** The surface's ops that look: parked while the person has the computer, then run on the screen as they left it. */
207
+ const LOOKS = new Set(["observe", "screenshot", "apps.list"]);
208
+ /** The ops that act, each by what the model is told was not done: parked, then refused. */
209
+ const ACTS = new Map([["act", "act"], ["input.act", "input"], ["apps.open", "app opening"]]);
210
+ /** `port` held: a look waits while the person has the computer, then runs as the agent's call in flight (which a take
211
+ * waits out); an act made with the agent driving runs (in flight), one made while the person has it waits for the
212
+ * hand-back and is not done; the shell's and the files' ops are not the person's and pass through. */
213
+ function heldPort(port, hold) {
214
+ return {
215
+ ...port,
216
+ async call(op, args, signal) {
217
+ const what = ACTS.get(op);
218
+ if (what === undefined && !LOOKS.has(op))
219
+ return port.call(op, args, signal);
220
+ const parked = hold.state() !== "agent";
221
+ const leave = await hold.enter(signal);
222
+ if (parked && what !== undefined) {
223
+ leave();
224
+ throw Object.assign(new Error(personHadWords(what)), { kind: TAKEN_OVER });
225
+ }
226
+ try {
227
+ return await port.call(op, args, signal);
228
+ }
229
+ finally {
230
+ leave();
231
+ }
232
+ },
233
+ };
239
234
  }
240
- /** `hands` with its screen, input and phone ports parked while the person has the computer, and the agent's ask
241
- * (`handoff`) through the hold; everything else as it is. */
235
+ /** `hands` with its computer port held while the person has the computer, and the agent's ask (`handoff`) through the
236
+ * hold; everything else as it is. */
242
237
  export function heldHands(hands, hold) {
243
- const computer = hands.phone ? "phone" : "desktop";
244
238
  return {
245
239
  ...hands,
246
- ...(hands.screen ? { screen: { ...hands.screen, shot: look(hands.screen, "shot", hold) } } : {}),
247
- ...(hands.input ? { input: { ...hands.input, actions: act(hands.input, "actions", hold, computer, "input") } } : {}),
248
- ...(hands.phone ? {
249
- phone: {
250
- ...hands.phone,
251
- shot: look(hands.phone, "shot", hold),
252
- // A phone that does not offer its tree or its keys keeps none: the tool says so in words.
253
- ...(hands.phone.tree ? { tree: look(hands.phone, "tree", hold) } : {}),
254
- tap: act(hands.phone, "tap", hold, "phone", "tap"),
255
- swipe: act(hands.phone, "swipe", hold, "phone", "swipe"),
256
- type: act(hands.phone, "type", hold, "phone", "typing"),
257
- ...(hands.phone.key ? { key: act(hands.phone, "key", hold, "phone", "key press") } : {}),
258
- apps: { ...hands.phone.apps, list: look(hands.phone.apps, "list", hold), open: act(hands.phone.apps, "open", hold, "phone", "app opening") },
259
- },
260
- } : {}),
240
+ ...(hands.computer ? { computer: heldPort(hands.computer, hold) } : {}),
261
241
  handoff: { ask: (request, signal) => hold.ask(request, signal) },
262
242
  };
263
243
  }
@@ -10,8 +10,9 @@ export declare const JANITOR_CLOSE_MS = 5000;
10
10
  * is swept, so a stuck vendor (a Docker command has no timeout of its own) never stops the others or later sweeps. */
11
11
  export declare const JANITOR_PROVIDER_MS: number;
12
12
  export interface JanitorDeps {
13
- /** The store: whose runs a computer's run label names, and the phone provider's ledger. */
14
- readonly store: Pick<Store, "runs" | "computerLedger">;
13
+ /** The store: whose runs a computer's run label names, and the phone provider's ledger; with `settings` and `agents`,
14
+ * this server's id and its agents, whose own computers it then sweeps by their owner. */
15
+ readonly store: Pick<Store, "runs" | "computerLedger"> & Partial<Pick<Store, "settings" | "agents">>;
15
16
  /** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
16
17
  * makers and the key reader. */
17
18
  readonly computers: Pick<ComputerDeps, "kinds" | "providers" | "keyOf"> & {