@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
package/dist/tools.js CHANGED
@@ -29,6 +29,7 @@ import { searchFor, WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
29
29
  import { browserNeeds, explainsView, isUnavailable, NO_PARALLEL_KEY, PICKABLE, planeOf, PROVIDERS, serverGate, whyUnavailable, withDefaults } from "./tool-plane.js";
30
30
  import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
31
31
  import { keyNeeded } from "./key-words.js";
32
+ import { unattachable } from "./attach-images.js";
32
33
  import { handedSignIn } from "./secrets.js";
33
34
  import { redactedAnswer } from "./key-refusal.js";
34
35
  import { SIGN_IN_KEY, vendorsOver } from "./sign-ins.js";
@@ -36,11 +37,14 @@ import { answerIn, answerOnce } from "./runner/hand-back.js";
36
37
  import { waitingAsk } from "./browser-commands.js";
37
38
  import { runnerSecrets } from "./runner/redact.js";
38
39
  import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
40
+ import { provenFor } from "./live-reach.js";
41
+ import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
39
42
  import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
40
43
  export const ASK_TOOL = "ask_person";
41
- /** Under `--faux` only: a module whose default export gives the browser's `{ provider, driver }` for the run's
42
- * environment, the vendor its plane names (`browserbase`, `kernel`) and the saved sign-in it was handed for that
43
- * vendor (`{ provider, ref, save }`, or undefined), in place of that vendor's (the tests' fake backend). */
44
+ /** Under `--faux` only: a module whose default export gives the browser's `{ computer, driver }` for the run's
45
+ * environment, the vendor its plane names and the saved sign-in it was handed for that vendor (`{ provider, ref, save }`,
46
+ * or undefined): a browser computer provider and a driver in place of the vendor's and the raw-CDP driver (the tests'
47
+ * fake backend). */
44
48
  export const FAUX_BROWSER_ENV = "AGENTRUN_SERVE_FAUX_BROWSER";
45
49
  /** Under `--faux` only: a module whose default export is the fetch a run's first saved sign-in is made with on the runner,
46
50
  * in place of the browser vendors' REST APIs (the tests' fake). Absent under --faux, none is made: no network. */
@@ -177,24 +181,28 @@ export const uploadsFrom = (work, maxBytes, mime) => ({
177
181
  }
178
182
  },
179
183
  });
180
- /** The Browserbase contexts a run's browser may open: its agent's saved sign-in's alone, by its profile name, never one
181
- * made here (nothing a run makes is kept for its agent). */
182
- export const keptContexts = (ref) => ({
183
- clear: false,
184
- resolve: async (key) => {
185
- if (ref && key.endsWith(`|profile:${SIGN_IN_KEY}`))
186
- return ref;
187
- throw new Error("this run's browser has no saved sign-in to open");
188
- },
189
- });
190
- /** Every string in `value` (a tool's answer: its content, its details) passed through `cut`; anything else as it is. */
191
- function cutStrings(value, cut) {
184
+ /** An image block's `data` kept whole by the cut: its base64 is an image a model can be sent (attach-images.ts
185
+ * unattachable: a PNG, JPEG, GIF or WebP whose bytes are the type it names and whose header says its size), and its
186
+ * decoded bytes, read as text, hold nothing the cut takes out (a held value written after a valid header). */
187
+ const wholeImage = (block, cut) => {
188
+ if (unattachable(block) !== undefined)
189
+ return false;
190
+ const bytes = Buffer.from(block.data, "base64").toString("latin1");
191
+ return cut(bytes) === bytes;
192
+ };
193
+ /** Every string in `value` (a tool's answer: its content, its details) passed through `cut`; anything else as it is. An
194
+ * image block's `data` that is an image (wholeImage) is its pixels' base64, not text, and is kept whole: the cut reads a
195
+ * run of more than 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), which no model
196
+ * takes as an image. Any other `data`, on a block of any type, is cut like every other string. */
197
+ export function cutAnswer(value, cut) {
192
198
  if (typeof value === "string")
193
199
  return cut(value);
194
200
  if (Array.isArray(value))
195
- return value.map((item) => cutStrings(item, cut));
201
+ return value.map((item) => cutAnswer(item, cut));
196
202
  if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
197
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cutStrings(item, cut)]));
203
+ const block = value;
204
+ const keep = block.type === "image" && wholeImage(block, cut);
205
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, keep && key === "data" ? item : cutAnswer(item, cut)]));
198
206
  }
199
207
  return value;
200
208
  }
@@ -205,7 +213,7 @@ function answersCutInside(tool, cut) {
205
213
  ...tool,
206
214
  execute: (async (...args) => {
207
215
  try {
208
- return cutStrings(await tool.execute(...args), cut);
216
+ return cutAnswer(await tool.execute(...args), cut);
209
217
  }
210
218
  catch (error) {
211
219
  if (error instanceof Error) {
@@ -218,12 +226,6 @@ function answersCutInside(tool, cut) {
218
226
  }),
219
227
  };
220
228
  }
221
- /** Kernel's provider, opening the agent's saved profile (`ref`, its name at Kernel) where a session asks for the
222
- * profile `default`: the policy, the session's record and the model see only that name. */
223
- export const keptProfile = (provider, ref) => ({
224
- ...provider,
225
- create: (spec, signal) => provider.create(spec.profile?.name === SIGN_IN_KEY ? { ...spec, profile: { ...spec.profile, name: ref } } : spec, signal),
226
- });
227
229
  /** `provider`, its sessions' profile as this launch was handed it, whatever the policy a conversation was made with (a
228
230
  * follow-up's was made under an earlier launch, which may have had no sign-in, or another lease): with a sign-in, every
229
231
  * session opens on the profile `default`, saving only as `kept.save` says; without one, none asks for a profile. */
@@ -244,15 +246,17 @@ export const runSignInSaved = (store, sealKey, claim, kept) => async (row, chang
244
246
  const ended = row.session.endedAt ? Date.parse(row.session.endedAt) : Number.NaN;
245
247
  return verifyRunSignIn(store, sealKey, claim, kept, Number.isFinite(ended) ? ended : Date.now());
246
248
  };
247
- /** A hosted browser driven through Stagehand, on pi-browser's durable adapter: Browserbase or Kernel (headless), the one
248
- * the run's plane names (tool-plane.ts: picked, else Browserbase where the server holds its keys, else Kernel), kept
249
- * for the run's life; a plane that names none (a run kept from before the pick) is Browserbase. Its sessions' custody
250
- * lives in the run's own store. No recording; the owner watches it live, takes it over and hands it back, and the agent
251
- * may ask them to (browser-live.ts, browser-person.ts). A session the run still holds is released when the run is let
252
- * go. Where the plane says unavailable (its vendor's key gone since), each call is refused, saying why.
253
- * Its session time is the run's spend, held under its cap before it runs (browser-cost.ts). A run handed its agent's
254
- * saved sign-in for that vendor (sign-ins.ts, over its pipe) opens every session on it, as the profile `default`,
255
- * saving only where it holds the agent's save lease; one that saved says so in its run directory. */
249
+ /** A browser on pi-browser's durable adapter, its sessions a browser computer provider's of the computer registry
250
+ * (browser-computer.ts), each driven over its CDP URL by pi-browser's raw-CDP driver: the agent's computer, where it is
251
+ * a browser (the claim's, computer-for-claim.ts), else the one the run's plane names (tool-plane.ts: picked, else
252
+ * Browserbase where the server holds its keys, else Kernel), kept for the run's life; a plane that names none (a run kept
253
+ * from before the pick) is Browserbase. Its sessions' custody lives in the run's own store. No recording; the owner
254
+ * watches it live, takes it over and hands it back, and the agent may ask them to (browser-live.ts, browser-person.ts).
255
+ * A session the run still holds is released when the run is let go. Where the plane says unavailable (its vendor's key
256
+ * gone since), each call is refused, saying why. Its session time is the run's spend, held under its cap before it runs
257
+ * (browser-cost.ts). A run on the plane's vendor handed its agent's saved sign-in for that vendor (sign-ins.ts) opens
258
+ * every session on it, as the profile `default`, saving only where it holds the agent's save lease; one that saved says
259
+ * so in its run directory. */
256
260
  const browserTool = {
257
261
  summary: "Drive a hosted browser, Browserbase's or Kernel's (picked in tool settings, else whichever's key the server holds): open pages, read and screenshot them, and act on them.",
258
262
  // Which vendor's keys it needs is the plane's to say (tool-plane.ts BROWSER_KEYS): neither alone is required.
@@ -264,42 +268,59 @@ const browserTool = {
264
268
  // Its downloads go into work/ by path (pi-browser), which a box's command could turn through a link.
265
269
  runnerOnly: true,
266
270
  bind: async (host) => {
267
- const [{ BACKGROUND_CONTEXT: context }, { createBrowserExtension }, { DEFAULT_BROWSER_POLICY, BrowserFailureError, browserFailure, MAX_UPLOAD_BYTES, uploadMime }, { createDrivingGates, createLiveView, liveViewProvider }, live, person] = await Promise.all([
271
+ const [{ BACKGROUND_CONTEXT: context }, { createBrowserExtension }, { DEFAULT_BROWSER_POLICY, BrowserFailureError, browserFailure, MAX_UPLOAD_BYTES, uploadMime }, { createDrivingGates, createLiveView, liveViewProvider }, live, person, { claimBrowserProvider, closeHeldSockets, planeBrowser, planeComputer, releaseOlderBrowsers }, { cdpDriver }] = await Promise.all([
268
272
  import("@earendil-works/chord/context"),
269
273
  import("@parcha/pi-browser/durable"),
270
274
  import("@parcha/pi-browser"),
271
275
  import("@parcha/pi-browser/live-view"),
272
276
  import("./browser-live.js"),
273
277
  import("./browser-person.js"),
278
+ import("./browser-computer.js"),
279
+ import("@parcha/pi-browser/driver/cdp"),
274
280
  ]);
275
281
  // The agent's computer, where it is a browser, wins over the plane's pick: the run's sessions are that provider's,
276
- // opened through the claim and driven over their CDP URL by the raw-CDP driver, with no pi-browser vendor provider,
277
- // saved sign-in or plane check of their own.
282
+ // opened through the claim, with no saved sign-in or plane check of their own.
278
283
  const computer = host.browserComputer;
279
284
  const planeVendor = planeOf(host.env).browser ?? "browserbase";
280
285
  const vendor = computer?.provider ?? planeVendor;
281
- const refused = !computer && isUnavailable(planeVendor) ? new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${whyUnavailable(planeVendor)}.`)) : undefined;
286
+ const planeRefused = !computer && isUnavailable(planeVendor) ? new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${whyUnavailable(planeVendor)}.`)) : undefined;
282
287
  // The run's saved sign-in: on the runner (one process, many claims) read from the store under this run's own claim
283
288
  // (sign-ins-store.ts runSignIn), never from the process; on the old per-run process, over its own secrets' pipe.
284
289
  // An agent with none saved has its first made at the vendor now, over this run's own claim keys (host.env), as main's
285
290
  // launch makes it: never the process's environment, so one run's keys never make another's.
286
291
  const runLog = (line) => void process.stderr.write(`agentrun-serve: run ${host.where.ref.id}: ${line}\n`);
287
292
  const vendorFetch = async () => (host.env[FAUX_ENV] ? fauxFetch(host.env, FAUX_VENDOR_API_ENV) : fetch);
288
- const handed = computer ? undefined : host.claim ? (refused || !host.store || !host.sealKey ? undefined : await runSignIn(host.store, host.sealKey, host.claim, vendor, { vendors: vendorsOver(() => host.env, vendorFetch), log: runLog })) : handedSignIn();
289
- const kept = !refused && handed?.provider === vendor ? handed : undefined;
290
- const faux = host.env[FAUX_ENV] ? host.env[FAUX_BROWSER_ENV] : undefined;
291
- const parts = computer
292
- ? { provider: (await import("./browser-computer.js")).claimBrowserProvider(computer), driver: (await import("@parcha/pi-browser/driver/cdp")).cdpDriver() }
293
- : faux
294
- ? (await import(pathToFileURL(faux).href)).default(host.env, vendor, kept)
295
- : {
296
- provider: refused
297
- ? undefined
298
- : vendor === "kernel"
299
- ? ((kernel) => (kept ? keptProfile(kernel, kept.ref) : kernel))((await import("@parcha/pi-browser/providers/kernel")).kernelProvider({ env: host.env, headless: true }))
300
- : (await import("@parcha/pi-browser/providers/browserbase")).browserbaseProvider({ env: host.env, profiles: keptContexts(kept?.ref) }),
301
- driver: (await import("@parcha/pi-browser/driver/stagehand")).stagehandDriver(),
302
- };
293
+ const handed = computer ? undefined : host.claim ? (planeRefused || !host.store || !host.sealKey ? undefined : await runSignIn(host.store, host.sealKey, host.claim, vendor, { vendors: vendorsOver(() => host.env, vendorFetch), log: runLog })) : handedSignIn();
294
+ const kept = !planeRefused && handed?.provider === vendor ? handed : undefined;
295
+ // Tests only (--faux): the faux browser's computer provider and driver stand in for the plane vendor's and the raw-CDP
296
+ // driver. The agent's browser computer is still the claim's, so a test hands the claim a faux provider of its own.
297
+ const faux = !computer && host.env[FAUX_ENV] ? host.env[FAUX_BROWSER_ENV] : undefined;
298
+ const stand = faux ? (await import(pathToFileURL(faux).href)).default(host.env, vendor, kept) : undefined;
299
+ // The session's browser: the claim's (the agent's computer), else the plane's vendor on the run's tool keys, opened
300
+ // the same way under the run's labels. One that cannot be made refuses each call, in its words.
301
+ const made = planeRefused
302
+ ? { refused: planeRefused }
303
+ : await (async () => {
304
+ try {
305
+ if (computer)
306
+ return { browser: computer };
307
+ const provider = stand ? stand.computer : await planeComputer(vendor, host.env);
308
+ const plane = planeBrowser(provider, host.claim);
309
+ if (host.claim && !stand)
310
+ await releaseOlderBrowsers(provider, host.claim);
311
+ return { browser: plane };
312
+ }
313
+ catch (error) {
314
+ if (error instanceof BrowserFailureError)
315
+ return { refused: error };
316
+ return { refused: new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${error instanceof Error ? error.message : String(error)}.`)) };
317
+ }
318
+ })();
319
+ const refused = "refused" in made ? made.refused : undefined;
320
+ const parts = {
321
+ provider: "browser" in made ? claimBrowserProvider(made.browser, { headless: true, ...(host.env.BROWSERBASE_CONNECT_BASE_URL ? { connectBaseUrl: host.env.BROWSERBASE_CONNECT_BASE_URL } : {}), ...(kept ? { signIn: { name: SIGN_IN_KEY, pointer: kept.ref } } : {}) }) : undefined,
322
+ driver: stand ? stand.driver : cdpDriver(),
323
+ };
303
324
  // The save flag every session carries is this launch's (asHanded), never the one stored with its conversation.
304
325
  const handedProvider = parts.provider ? asHanded(parts.provider, kept) : undefined;
305
326
  // The owner's live view (browser-live.ts): pi-browser's own viewer on a loopback port of this process's, over every
@@ -331,6 +352,12 @@ const browserTool = {
331
352
  // the run's own cut on the runner (host.redact: the claim's keys too, every tool's, in every form), and the secrets
332
353
  // its env holds (runnerSecrets: hostSecrets and every launcher name's value) with its sign-in's pointer.
333
354
  redact: (text) => redactedAnswer(host.redact ? host.redact(text) : text, [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])]),
355
+ // The Screen tab's ended state, one settings row the server reads per poll (browser-wait-ended.ts); cleared as a
356
+ // session opens (onSessions, below).
357
+ waitEnded: (at, why) => {
358
+ if (host.store && host.claim)
359
+ void markWaitEnded(host.store.settings, host.claim.runId, { at: new Date(at).toISOString(), why }, host.claim.epoch).catch(() => undefined);
360
+ },
334
361
  note: async (kind, data) => {
335
362
  // A hand-over's waiting entry, on the runner: the row says the run waits on the person in its browser from that
336
363
  // commit (the server tells run.needs_input by it), and no more from its answer's, whoever writes it.
@@ -361,7 +388,14 @@ const browserTool = {
361
388
  return { outcome: stood.state, at: stood.at, ...(stood.reason !== undefined ? { reason: stood.reason } : {}) };
362
389
  },
363
390
  });
364
- const view = createLiveView({ hostOrigin: "'self'", gates, takeOver: { take: (tag) => hands.take(tag) } });
391
+ // On a runner on another host than its server, the viewer listens on the runner's live address and takes no page or
392
+ // socket without the server's proof for its own path id (live-reach.ts).
393
+ const at = host.liveAt;
394
+ const admit = at ? (req) => {
395
+ const id = /^\/v\/([A-Za-z0-9_-]{22})(?:\/ws)?(?:\?|$)/.exec(req.url ?? "")?.[1];
396
+ return id !== undefined && provenFor(req, at, id);
397
+ } : undefined;
398
+ const view = createLiveView({ hostOrigin: "'self'", gates, takeOver: { take: (tag) => hands.take(tag) }, ...(at ? { listen: { bind: at.bind, host: at.host }, admit: admit } : {}) });
365
399
  const watched = handedProvider ? liveViewProvider(handedProvider, view) : undefined;
366
400
  const provider = () => {
367
401
  if (refused)
@@ -370,7 +404,7 @@ const browserTool = {
370
404
  };
371
405
  // Each session's viewer reaches the server as it launches, and goes as it ends: through the store, under the run's claim
372
406
  // (host.liveViewers); never a file in the run's folder, which is the agent's workspace.
373
- const viewers = live.sessionHandovers(host.liveViewers);
407
+ const viewers = live.sessionHandovers(host.liveViewers, at?.host);
374
408
  const onSession = (row, change) => viewers.changed(row, change);
375
409
  // Its session time is the run's spend, at its provider's price, and held under the run's cap (browser-cost.ts).
376
410
  const providerName = parts.provider?.name ?? vendor;
@@ -400,6 +434,9 @@ const browserTool = {
400
434
  // A session let go ends a wait on the person's answer that kept it open (personWait, below): the run parks.
401
435
  if (change === "released")
402
436
  hands.sessionEnded(row.session.tag);
437
+ // A session that opens, whatever let the last one go: the Screen tab's ended state goes (browser-wait-ended.ts).
438
+ if (change === "launched" && host.store && host.claim)
439
+ await clearWaitEnded(host.store.settings, host.claim.runId, host.claim.epoch).catch(() => undefined);
403
440
  await saved?.(row, change);
404
441
  await onSession(row, change);
405
442
  };
@@ -469,7 +506,9 @@ const browserTool = {
469
506
  // (live, or held for a hand-over), the run waits for the answer in its claim, so the session, its live viewer and its
470
507
  // page stay for the person and for the agent's next turn, as main's process kept them; the person's time on each such
471
508
  // session is held under the run's cap the way a hand-over's is (personHands.wait). With none open, or no room under
472
- // the cap for that time, the run parks (its release lets the browser go).
509
+ // the cap for that time, the run parks (its release lets the browser go). While it waits, pi-browser's idle release
510
+ // keeps its hands off those sessions (keepForPerson): the person's window (AGENTRUN_BROWSER_PERSON_WAIT_MIN), not the
511
+ // browser's few-minute idle window, decides when the browser goes.
473
512
  host.personWait?.(async (harness, callId, since) => {
474
513
  if (refused)
475
514
  return undefined;
@@ -477,8 +516,15 @@ const browserTool = {
477
516
  const open = rows.filter((row) => (row.state === "live" || row.state === "held") && row.resourceId !== null).map((row) => row.tag);
478
517
  if (!open.length)
479
518
  return undefined;
519
+ const keeps = open.map((tag) => browser.keepForPerson(tag));
520
+ const letGo = () => { for (const keep of keeps.splice(0))
521
+ keep(); };
480
522
  const waited = await hands.wait(callId, open, since);
481
- return "refused" in waited ? undefined : waited;
523
+ if ("refused" in waited) {
524
+ letGo();
525
+ return undefined;
526
+ }
527
+ return { lapsed: waited.lapsed, confirmed: waited.confirmed, drop: () => { waited.drop(); letGo(); } };
482
528
  });
483
529
  host.beforeRelease(async (harness) => {
484
530
  try {
@@ -501,6 +547,10 @@ const browserTool = {
501
547
  await view.close();
502
548
  hands.close();
503
549
  await viewers.released();
550
+ // The download sockets this run's sessions hold go with it, released or left to the next claim (whose attach
551
+ // opens its own): one left open would keep the process from exiting.
552
+ if ("browser" in made)
553
+ await closeHeldSockets(made.browser);
504
554
  }
505
555
  });
506
556
  return { tools, extensions: [extension] };
@@ -528,14 +578,23 @@ export const TOOLS = Object.freeze({
528
578
  summary: "Search the web: codex's own search (claude-agent's where it is picked), on pi the model provider's hosted search (Anthropic, OpenAI), with none of those Parallel's Search API where the server holds its key, else Exa's keyless search; or the provider picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
529
579
  needs: [],
530
580
  nodes: true,
531
- bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env))),
532
- effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal)),
581
+ // On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
582
+ bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env, host.search))),
583
+ effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal, run.search)),
533
584
  },
534
585
  browser: browserTool,
535
586
  // monid's catalog on one key (monid.ts): every harness calls each by its wire name, `monid_discover` and the rest.
536
587
  "monid.discover": monidTool("discover"),
537
588
  "monid.inspect": monidTool("inspect"),
538
589
  "monid.run": monidTool("run"),
590
+ // A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
591
+ // (adapter-run-spec.ts), never by this table; not a host tool (host-tools.ts REPLAY), so another harness refuses it.
592
+ subagent: {
593
+ summary: "Run a subagent: a fresh conversation with only the call's prompt, on the agent's own model (or one of its model tiers, fast or strong, when the call names one), with a subset of the agent's own tools (bash among them, under the agent's bash policy), under the run's permissions and cap; answers with its final text. A call may narrow its child's tool-call budget (max_tool_calls) and set its effort (low, medium, high). Several calls in a turn run at once, at most 4 at a time; a subagent starts none of its own. pi only.",
594
+ needs: [],
595
+ nodes: false,
596
+ bind: async () => ({ tools: [], extensions: [] }),
597
+ },
539
598
  [PDF_PAGES_TOOL]: callOnly("A workflow call: { path, maxPages?, dpi? } -> { name, pageCount, dpi, pages: [{ page, image }], text }; the document's first pages drawn as PNGs under work/pages/<stem>/<dpi>/ (the dpi lowered so a page's long side is at most 1568 px), from the server's documents (--documents) or the run's work directory.", (args, run) => pdfPages(args, { work: localWorkspace(run.work), documents: run.env[DOCUMENTS_ENV], signal: run.signal })),
540
599
  [LLM_TOOL]: callOnly("A workflow call: { prompt, system?, maxTokens?, tier? } -> { text, model, usage, cost_usd }; one completion on the model of the tier (default), no tools and no loop.", (args, run) => {
541
600
  if (!run.complete)
@@ -635,22 +694,6 @@ export async function toolingOf(revision) {
635
694
  }
636
695
  /** The variables `entry` needs that `env` does not set, by name. */
637
696
  export const missingEnv = (entry, env) => entry.needs.filter((name) => !env[name]);
638
- /** What keeps `names` from being bound here: names outside the table (or, for a workflow's model nodes, that a node may
639
- * not name), and the variables each tool in it needs that `env` does not set. Undefined when nothing does. */
640
- export function toolRefusal(names, env, where = "agent") {
641
- const allowed = where === "nodes" ? NODE_TOOLS : where === "calls" ? CALL_TOOLS : BOUND_TOOLS;
642
- const unbound = names.filter((name) => !allows(allowed, name));
643
- if (unbound.length) {
644
- const said = { agent: "agentrun-serve binds the tools", nodes: "A workflow's model nodes get the tools", calls: "A workflow's call nodes run the tools" }[where];
645
- return { message: `${said} ${allowed.join(", ")}; this ${where === "agent" ? "revision" : "workflow"} also ${where === "calls" ? "calls" : "names"} ${unbound.join(", ")}.`, unbound, missing: {} };
646
- }
647
- const missing = Object.fromEntries(names.map((name) => [name, missingEnv(toolOf(name), env)]).filter(([, vars]) => vars.length));
648
- const lacking = Object.entries(missing);
649
- if (!lacking.length)
650
- return undefined;
651
- const said = lacking.map(([name, vars]) => `The tool ${name} needs ${keyNeeded(vars)}.`).join(" ");
652
- return { message: `This server holds no key for what the revision's tools need. ${said}`, unbound: [], missing };
653
- }
654
697
  /** Every tool as capabilities show it, the server's one tool catalog: available here, or the variables it is missing
655
698
  * (names only), and the harnesses that run it (another harness than pi runs only the host tools, host-tools.ts). A tool
656
699
  * a user picks a provider for (tool-plane.ts) gives the providers offered, the server's (`provider`, the default where it
@@ -28,6 +28,10 @@ export type TriggerAdapter = {
28
28
  /** What it keeps sealed (sealed-settings-store.ts), for the server or for each trigger: a field it mints (a signing secret)
29
29
  * is made at a trigger's create and at a rotation, shown once, and goes with the trigger. */
30
30
  settings?: SettingsSpec;
31
+ /** Whether a trigger of this source keeps a secret its sender gave (a create's and a rotation's `secret`, Composio's)
32
+ * instead of one this server mints: then the secret is required there, sealed as a minted one is, and never made
33
+ * here. Default: it mints. */
34
+ givesSecret?(source: Source): boolean;
31
35
  /** Its shapes as a create's error names them: `{kind: "..."}` with its fields. */
32
36
  describe: string;
33
37
  /** When it fires, for the OpenAPI document's source description. */
@@ -14,9 +14,9 @@ export declare const triggerSecretMeta: (id: string, set: boolean, changedAt?: s
14
14
  * trigger's view. */
15
15
  export declare function triggerMade(made: Record<string, unknown>, minted: string | undefined, mayHold: boolean, at: string): Record<string, unknown>;
16
16
  /** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
17
- export declare const triggerRotated: (id: string, minted: string, at: string) => {
17
+ export declare const triggerRotated: (id: string, minted: string | undefined, at: string) => {
18
+ signing_secret?: string | undefined;
18
19
  secret: SecretMeta;
19
- signing_secret: string;
20
20
  };
21
21
  /** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
22
22
  * record would keep it), so the person gets it from the console. */
@@ -30,7 +30,7 @@ export function triggerMade(made, minted, mayHold, at) {
30
30
  return mayHold ? { ...made, secret, signing_secret: minted } : { ...made, secret, secret_set: true, note: TRIGGER_SECRET_WORDS };
31
31
  }
32
32
  /** POST /triggers/{id}/secret's answer (the owner's session alone reaches it): the new value, and its metadata. */
33
- export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), signing_secret: minted });
33
+ export const triggerRotated = (id, minted, at) => ({ secret: triggerSecretMeta(id, true, at), ...(minted !== undefined ? { signing_secret: minted } : {}) });
34
34
  /** A template's apply answer's warning for its webhook trigger `i`: its secret is in no apply answer (the Idempotency-Key
35
35
  * record would keep it), so the person gets it from the console. */
36
36
  export const templateTriggerSecret = (i) => ({ field: `triggers.${i}.secret`, reason: "not_allowed", message: `This webhook trigger's signing secret is not in an apply answer. ${TRIGGER_SECRET_WORDS}` });
@@ -1,8 +1,11 @@
1
- import { headersRefusal, verify as verifyStandard } from "./standard-webhooks.js";
1
+ import { headersRefusal } from "./standard-webhooks.js";
2
2
  type Headers = Record<string, string | string[] | undefined>;
3
3
  export type Scheme = {
4
- /** The header its signature comes in: a request that carries it, and no other scheme's, is checked by this one. */
4
+ /** The header its signature comes in: a request that carries it, and no other header's, is checked by a scheme that
5
+ * names it; where several do (`composio` shares `webhook-signature` with `standard`) the trigger's own `signature` picks. */
5
6
  signatureHeader: string;
7
+ /** Its secret is the sender's own, given at the trigger's create and rotation, never one this server mints. */
8
+ givenSecret?: true;
6
9
  /** How a sender signs under it, for the OpenAPI document. */
7
10
  describe: string;
8
11
  /** Why the headers alone are refused, before a byte of the body is read. */
@@ -26,7 +29,7 @@ export declare const SIGNATURE_SCHEMES: {
26
29
  signatureHeader: string;
27
30
  describe: string;
28
31
  precheck: typeof headersRefusal;
29
- verify: typeof verifyStandard;
32
+ verify: (secret: string, headers: Record<string, string | string[] | undefined>, body: Buffer, nowMs: number) => string | undefined;
30
33
  firingKeyOf: (headers: Headers) => string;
31
34
  eventOf: (_headers: Headers, json: unknown) => string | undefined;
32
35
  };
@@ -39,17 +42,34 @@ export declare const SIGNATURE_SCHEMES: {
39
42
  deliveryIdOf: (headers: Headers) => string;
40
43
  eventOf: (headers: Headers) => string;
41
44
  attrsOf(json: unknown): {
45
+ base_sha?: string | undefined;
42
46
  head_sha?: string | undefined;
43
47
  number?: string | undefined;
44
48
  };
45
49
  };
50
+ composio: {
51
+ signatureHeader: string;
52
+ givenSecret: true;
53
+ describe: string;
54
+ precheck: typeof headersRefusal;
55
+ verify: (key: string, headers: Headers, body: Buffer<ArrayBufferLike>, nowMs: number) => string | undefined;
56
+ firingKeyOf: (headers: Headers) => string;
57
+ eventOf(_headers: Headers, json: unknown): string | undefined;
58
+ attrsOf(json: unknown): {
59
+ user_id?: string | undefined;
60
+ trigger_id?: string | undefined;
61
+ };
62
+ };
46
63
  };
47
64
  export type SchemeName = keyof typeof SIGNATURE_SCHEMES;
48
65
  export declare const SCHEME_NAMES: SchemeName[];
49
66
  export declare const DEFAULT_SCHEME: SchemeName;
50
- /** The scheme a request asks for: the one whose signature header it carries. `refusal` when it carries none, or more
51
- * than one (a request is checked one way only). */
52
- export declare function schemeOf(headers: Headers): {
67
+ /** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
68
+ * `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
69
+ * scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
70
+ * read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
71
+ * signature header, or the headers of more than one. */
72
+ export declare function schemeOf(headers: Headers, wanted?: string): {
53
73
  name: SchemeName;
54
74
  scheme: Scheme;
55
75
  } | {
@@ -5,10 +5,12 @@
5
5
  // scheme whose signature header it carries; a trigger's `signature` names the scheme it takes. A new scheme is one entry
6
6
  // here: the source's schema and its check read the table's keys.
7
7
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
8
- import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard } from "./standard-webhooks.js";
8
+ import { HOOK_TOLERANCE_S, headersRefusal, HOOK_ID, MIN_KEY_BYTES, verify as verifyStandard, verifyWithKey } from "./standard-webhooks.js";
9
9
  import { isObject } from "./validate.js";
10
10
  /** An event's name in a header: printable ASCII with no space (`pull_request`, `ping`). */
11
11
  const EVENT = /^[\x21-\x7e]{1,200}$/;
12
+ /** An id a payload's tag may name: short printable ASCII with no space, quote or bracket. */
13
+ const ID_ATTR = /^[A-Za-z0-9_.:@-]{1,100}$/;
12
14
  const GITHUB_SIGNATURE = /^sha256=([0-9a-f]{64})$/i;
13
15
  const githubHmac = (secret, body) => createHmac("sha256", Buffer.from(secret, "utf8")).update(body).digest();
14
16
  function githubPrecheck(headers) {
@@ -53,27 +55,61 @@ export const SIGNATURE_SCHEMES = {
53
55
  deliveryIdOf: (headers) => headers["x-github-delivery"],
54
56
  eventOf: (headers) => headers["x-github-event"],
55
57
  // The pull request or issue's number (an issue_comment on a pull request is its issue's), and a pull request's head
56
- // sha, which a long description pushes past the payload's cut. A comment event has no head: none is guessed.
58
+ // and base shas, which a long description pushes past the payload's cut. A comment event has no head: none is guessed.
57
59
  attrsOf(json) {
58
60
  const doc = isObject(json) ? json : {};
59
61
  const pr = isObject(doc.pull_request) ? doc.pull_request : undefined;
60
62
  const issue = isObject(doc.issue) ? doc.issue : undefined;
61
63
  const number = pr?.number ?? issue?.number;
62
64
  const sha = isObject(pr?.head) ? pr.head.sha : undefined;
65
+ const base = isObject(pr?.base) ? pr.base.sha : undefined;
63
66
  return {
64
67
  ...(Number.isSafeInteger(number) && number > 0 ? { number: String(number) } : {}),
65
68
  ...(typeof sha === "string" && /^[0-9a-f]{40}$/.test(sha) ? { head_sha: sha } : {}),
69
+ ...(typeof base === "string" && /^[0-9a-f]{40}$/.test(base) ? { base_sha: base } : {}),
66
70
  };
67
71
  },
68
72
  },
73
+ // Composio's (docs.composio.dev webhooks, @composio/core's verifyWebhook): the Standard Webhooks headers and message
74
+ // ("{id}.{timestamp}.{body}", `v1,<base64 HMAC-SHA256>`), but keyed by the UTF-8 bytes of the whole secret string
75
+ // Composio minted, not by a base64-decoded `whsec_` key. Every trigger of its project comes to the one webhook URL, so
76
+ // the event is the body's metadata.trigger_slug, and `where` reads the trigger's own data under /data.
77
+ composio: {
78
+ signatureHeader: "webhook-signature",
79
+ givenSecret: true,
80
+ describe: `\`composio\` takes a Composio trigger's delivery (the webhook subscription whose URL is the trigger's hook_url): the Standard Webhooks headers and message, \`v1,<base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}">\`, keyed by the UTF-8 bytes of the whole secret string Composio gave the subscription (make the trigger first, register its hook_url as Composio's webhook subscription, then \`POST /v2/triggers/{id}/secret\` with \`{secret}\`; until then every request is refused, and this server never makes one), with the same ${HOOK_TOLERANCE_S} s window and firing key (\`webhook-id\`). Its event is the body's \`metadata.trigger_slug\` (\`GITHUB_ISSUE_ADDED_EVENT\`), else its top-level \`type\` (the subscription's account events, \`composio.connected_account.expired\`), and \`where\` pointers read the payload under \`/data\`.`,
81
+ precheck: headersRefusal,
82
+ verify: (key, headers, body, nowMs) => verifyWithKey(Buffer.from(key, "utf8"), headers, body, nowMs),
83
+ firingKeyOf: (headers) => headers["webhook-id"],
84
+ // A trigger message names its slug; the subscription's account events (composio.connected_account.expired) have no
85
+ // metadata, so their event is the body's own type.
86
+ eventOf(_headers, json) {
87
+ if (!isObject(json))
88
+ return undefined;
89
+ if (isObject(json.metadata) && typeof json.metadata.trigger_slug === "string")
90
+ return json.metadata.trigger_slug;
91
+ return typeof json.type === "string" ? json.type : undefined;
92
+ },
93
+ attrsOf(json) {
94
+ const meta = isObject(json) && isObject(json.metadata) ? json.metadata : {};
95
+ const short = (value) => (typeof value === "string" && ID_ATTR.test(value) ? value : undefined);
96
+ const [triggerId, userId] = [short(meta.trigger_id), short(meta.user_id)];
97
+ return { ...(triggerId ? { trigger_id: triggerId } : {}), ...(userId ? { user_id: userId } : {}) };
98
+ },
99
+ },
69
100
  };
70
101
  export const SCHEME_NAMES = Object.keys(SIGNATURE_SCHEMES);
71
102
  export const DEFAULT_SCHEME = "standard";
72
- /** The scheme a request asks for: the one whose signature header it carries. `refusal` when it carries none, or more
73
- * than one (a request is checked one way only). */
74
- export function schemeOf(headers) {
103
+ /** The scheme a request asks for: the one whose signature header it carries. Schemes that share a header (`standard` and
104
+ * `composio`) are told apart by the trigger's own (`wanted`, its `signature`): a request is verified under the trigger's
105
+ * scheme, so one signed for the other fails its check as any bad signature does. With no `wanted` (before the trigger is
106
+ * read, where the headers' check is the same for both) the first of them stands in. `refusal` when it carries no
107
+ * signature header, or the headers of more than one. */
108
+ export function schemeOf(headers, wanted) {
75
109
  const carried = SCHEME_NAMES.filter((name) => headers[SIGNATURE_SCHEMES[name].signatureHeader] !== undefined);
76
- if (carried.length === 1)
77
- return { name: carried[0], scheme: SIGNATURE_SCHEMES[carried[0]] };
78
- return { refusal: carried.length ? "ambiguous_signature" : "missing_headers" };
110
+ const byHeader = new Set(carried.map((name) => SIGNATURE_SCHEMES[name].signatureHeader));
111
+ if (byHeader.size !== 1)
112
+ return { refusal: byHeader.size ? "ambiguous_signature" : "missing_headers" };
113
+ const name = carried.find((one) => one === wanted) ?? carried[0];
114
+ return { name, scheme: SIGNATURE_SCHEMES[name] };
79
115
  }
@@ -8,6 +8,8 @@ import type { RunTrigger, Target } from "./triggers.js";
8
8
  /** What the trigger target policy needs that lives elsewhere: the run-start leaves (StartDeps, shared with the create
9
9
  * route), the agent reads, and the run view that gives a run's live moment and its v2 status. */
10
10
  export interface TriggerTargetDeps {
11
+ /** A test's seam (ServeOptions.beforeSubmit): awaited by a firing's message after its checks, before its row is written. */
12
+ readonly beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
11
13
  /** The run-start leaves, shared with the create route (runs-over-store.StartDeps). */
12
14
  readonly start: StartDeps;
13
15
  /** The agent an id names, with its current revision; undefined when unknown (the agent store's getAgent). */
@@ -96,6 +96,7 @@ export function triggerTargets(store, deps) {
96
96
  answers: false,
97
97
  origin: from,
98
98
  requestId: key,
99
+ ...(deps.beforeSubmit ? { beforeSubmit: deps.beforeSubmit } : {}),
99
100
  queue: async (command) => {
100
101
  const done = await store.triggers.message({ triggerId, key }, run.id, command, bound);
101
102
  return done && "skipped" in done ? { skipped: done.skipped } : undefined;
@@ -12,6 +12,8 @@ import { isObject } from "./validate.js";
12
12
  const ATTR_CHARS = 200;
13
13
  /** The scheme a trigger's source takes. */
14
14
  const schemeName = (source) => (typeof source.signature === "string" ? source.signature : DEFAULT_SCHEME);
15
+ /** Whether a source's secret is the sender's own (Composio's): given, not minted. */
16
+ const givesSecret = (source) => SIGNATURE_SCHEMES[schemeName(source)]?.givenSecret === true;
15
17
  /** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
16
18
  function fieldsOf(value, bad) {
17
19
  let failed = false;
@@ -38,6 +40,7 @@ export const webhook = {
38
40
  delivery: "push",
39
41
  owner: false,
40
42
  settings: { scope: "trigger", fields: { secret: { mint: true, minBytes: MIN_KEY_BYTES } } },
43
+ givesSecret,
41
44
  describe: `{kind: "webhook", signature?: ${SCHEME_NAMES.map((name) => `"${name}"`).join(" | ")}, accept?: [{event, actions?, where?}]}`,
42
45
  fires: "a signed request to /hooks/{trigger_id} (`webhook`) that its `accept` takes",
43
46
  firedBy: "`webhook`: a signed request to /hooks/{trigger_id}, its key from the trigger and what the request's signature covers: its `webhook-id` (`standard`), or the SHA-256 of its body (`github`).",
@@ -61,7 +64,7 @@ export const webhook = {
61
64
  return "refusal" in asked ? asked.refusal : asked.scheme.precheck(headers, nowMs);
62
65
  },
63
66
  verify(key, headers, body, nowMs, source) {
64
- const asked = schemeOf(headers);
67
+ const asked = schemeOf(headers, source && schemeName(source));
65
68
  if ("refusal" in asked)
66
69
  return asked.refusal;
67
70
  const refusal = asked.scheme.verify(key, headers, body, nowMs);
@@ -71,7 +74,7 @@ export const webhook = {
71
74
  // The request is the firing: its scheme's firing key keys it, and its body, whatever it holds, is what the run is
72
75
  // given, with its scheme, event, action and unsigned delivery id named on the payload's tag. A trigger with `accept` takes only the events it names.
73
76
  parse(headers, body, source) {
74
- const asked = schemeOf(headers);
77
+ const asked = schemeOf(headers, source && schemeName(source));
75
78
  if ("refusal" in asked)
76
79
  return [];
77
80
  const text = body.toString("utf8");