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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/CHANGELOG.md +263 -0
  2. package/README.md +339 -179
  3. package/dist/adapters.d.ts +15 -2
  4. package/dist/adapters.js +34 -2
  5. package/dist/agent-rows.d.ts +3 -1
  6. package/dist/agents-store.d.ts +2 -0
  7. package/dist/agents-store.js +25 -5
  8. package/dist/api-only.d.ts +2 -1
  9. package/dist/api-only.js +3 -1
  10. package/dist/archil-routes.d.ts +40 -7
  11. package/dist/archil-routes.js +167 -54
  12. package/dist/archil-settings.d.ts +90 -8
  13. package/dist/archil-settings.js +150 -14
  14. package/dist/attach-images.d.ts +15 -0
  15. package/dist/attach-images.js +59 -0
  16. package/dist/background.d.ts +0 -6
  17. package/dist/background.js +0 -28
  18. package/dist/bash-read-only.d.ts +13 -0
  19. package/dist/bash-read-only.js +77 -0
  20. package/dist/box-image.d.ts +1 -97
  21. package/dist/box-image.js +4 -284
  22. package/dist/box-paths.d.ts +2 -7
  23. package/dist/box-paths.js +7 -13
  24. package/dist/box-settings.d.ts +0 -11
  25. package/dist/box-settings.js +4 -29
  26. package/dist/browser-commands.js +1 -1
  27. package/dist/browser-computer.d.ts +47 -3
  28. package/dist/browser-computer.js +286 -18
  29. package/dist/browser-cost.d.ts +2 -2
  30. package/dist/browser-cost.js +6 -4
  31. package/dist/browser-person.d.ts +19 -2
  32. package/dist/browser-person.js +55 -6
  33. package/dist/browser-wait-ended.d.ts +23 -0
  34. package/dist/browser-wait-ended.js +42 -0
  35. package/dist/cap.d.ts +19 -44
  36. package/dist/cap.js +31 -77
  37. package/dist/cli.js +36 -27
  38. package/dist/computer-keys.d.ts +20 -10
  39. package/dist/computer-keys.js +36 -57
  40. package/dist/computer-routes.d.ts +1 -4
  41. package/dist/computer-routes.js +3 -5
  42. package/dist/computer-setting.d.ts +8 -5
  43. package/dist/computer-setting.js +91 -26
  44. package/dist/computer-view.d.ts +11 -2
  45. package/dist/computer-view.js +2 -1
  46. package/dist/computers.d.ts +54 -8
  47. package/dist/computers.js +101 -22
  48. package/dist/console/assets/index-BI4Byidu.js +550 -0
  49. package/dist/console/assets/index-C19gUF2n.css +1 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/content-filter.d.ts +7 -0
  52. package/dist/content-filter.js +23 -0
  53. package/dist/decision-cap.d.ts +7 -29
  54. package/dist/decision-cap.js +3 -94
  55. package/dist/docker-daemon.d.ts +2 -2
  56. package/dist/docker-daemon.js +2 -2
  57. package/dist/errors.d.ts +1 -0
  58. package/dist/errors.js +8 -5
  59. package/dist/explain.js +3 -1
  60. package/dist/faux-computers.js +4 -0
  61. package/dist/files.d.ts +1 -9
  62. package/dist/files.js +1 -9
  63. package/dist/github-connection.js +25 -7
  64. package/dist/github-faux.d.ts +26 -0
  65. package/dist/github-faux.js +76 -0
  66. package/dist/github.d.ts +28 -4
  67. package/dist/github.js +46 -10
  68. package/dist/gpu-words.d.ts +14 -0
  69. package/dist/gpu-words.js +21 -0
  70. package/dist/graph-served.d.ts +5 -3
  71. package/dist/graph-served.js +14 -6
  72. package/dist/graph-view.d.ts +2 -0
  73. package/dist/graph-view.js +29 -2
  74. package/dist/handed-values.d.ts +1 -1
  75. package/dist/handed-values.js +1 -1
  76. package/dist/harness-install.d.ts +60 -3
  77. package/dist/harness-install.js +322 -34
  78. package/dist/harness-opencode/harness.js +0 -1
  79. package/dist/harness-opencode/host/policy.js +2 -2
  80. package/dist/harness.js +1 -1
  81. package/dist/host-tools.d.ts +8 -9
  82. package/dist/host-tools.js +7 -7
  83. package/dist/index.d.ts +2 -3
  84. package/dist/index.js +2 -2
  85. package/dist/key-refusal.d.ts +1 -1
  86. package/dist/key-refusal.js +2 -2
  87. package/dist/learn/check.d.ts +10 -2
  88. package/dist/learn/check.js +126 -8
  89. package/dist/learn/commit.d.ts +40 -6
  90. package/dist/learn/commit.js +164 -20
  91. package/dist/learn/folder.d.ts +11 -3
  92. package/dist/learn/folder.js +40 -16
  93. package/dist/learn/grade.d.ts +22 -2
  94. package/dist/learn/grade.js +127 -19
  95. package/dist/learn/index.d.ts +2 -2
  96. package/dist/learn/index.js +2 -2
  97. package/dist/learn/learning.sh +11 -13
  98. package/dist/learn/notes.d.ts +17 -3
  99. package/dist/learn/notes.js +19 -6
  100. package/dist/learn/reflect.d.ts +5 -2
  101. package/dist/learn/reflect.js +48 -32
  102. package/dist/learn/skills.d.ts +52 -5
  103. package/dist/learn/skills.js +104 -21
  104. package/dist/learned-nodes.d.ts +18 -0
  105. package/dist/learned-nodes.js +8 -0
  106. package/dist/learned-workflow.d.ts +27 -13
  107. package/dist/learned-workflow.js +110 -38
  108. package/dist/learning-cost.d.ts +79 -0
  109. package/dist/learning-cost.js +69 -0
  110. package/dist/learning-routes.d.ts +48 -2
  111. package/dist/learning-routes.js +99 -28
  112. package/dist/learning-run.d.ts +7 -5
  113. package/dist/learning-run.js +9 -6
  114. package/dist/learning-words.d.ts +3 -0
  115. package/dist/learning-words.js +6 -2
  116. package/dist/learning.d.ts +13 -28
  117. package/dist/learning.js +4 -18
  118. package/dist/llm.d.ts +4 -1
  119. package/dist/llm.js +4 -2
  120. package/dist/mcp-gateway.d.ts +6 -0
  121. package/dist/mcp-gateway.js +11 -1
  122. package/dist/mcp-probe.d.ts +8 -1
  123. package/dist/mcp-probe.js +62 -20
  124. package/dist/mcp-secret-writes.js +4 -0
  125. package/dist/mcp-servers-store.d.ts +12 -12
  126. package/dist/mcp-servers-store.js +8 -3
  127. package/dist/model.d.ts +8 -5
  128. package/dist/model.js +14 -6
  129. package/dist/openapi.d.ts +2 -0
  130. package/dist/openapi.js +236 -55
  131. package/dist/owner.d.ts +0 -1
  132. package/dist/owner.js +0 -2
  133. package/dist/pause.d.ts +2 -19
  134. package/dist/pause.js +5 -74
  135. package/dist/place-offers.d.ts +97 -0
  136. package/dist/place-offers.js +206 -0
  137. package/dist/place.d.ts +9 -13
  138. package/dist/place.js +22 -32
  139. package/dist/port-models.d.ts +12 -4
  140. package/dist/port-models.js +31 -9
  141. package/dist/print.d.ts +1 -8
  142. package/dist/print.js +1 -14
  143. package/dist/propose.d.ts +3 -0
  144. package/dist/propose.js +25 -19
  145. package/dist/run-cut.d.ts +5 -0
  146. package/dist/run-cut.js +19 -0
  147. package/dist/run-db.js +3 -3
  148. package/dist/run-launch.d.ts +18 -3
  149. package/dist/run-launch.js +11 -5
  150. package/dist/run-learning-served.d.ts +12 -1
  151. package/dist/run-manifest.d.ts +2 -2
  152. package/dist/run-manifest.js +2 -2
  153. package/dist/run-reads-over-store.d.ts +4 -2
  154. package/dist/run-reads-over-store.js +10 -8
  155. package/dist/run-secrets.js +3 -3
  156. package/dist/run-timeline-served.js +60 -38
  157. package/dist/run-view.d.ts +35 -16
  158. package/dist/run-view.js +64 -35
  159. package/dist/runnable.d.ts +6 -3
  160. package/dist/runnable.js +20 -4
  161. package/dist/runner/adapter-loop.d.ts +46 -5
  162. package/dist/runner/adapter-loop.js +381 -56
  163. package/dist/runner/adapter-run-spec.d.ts +46 -4
  164. package/dist/runner/adapter-run-spec.js +200 -45
  165. package/dist/runner/adapters/pi.d.ts +39 -3
  166. package/dist/runner/adapters/pi.js +124 -29
  167. package/dist/runner/beside.d.ts +8 -0
  168. package/dist/runner/beside.js +24 -2
  169. package/dist/runner/claim-secrets.d.ts +6 -0
  170. package/dist/runner/claim-secrets.js +15 -1
  171. package/dist/runner/cli-run-spec.d.ts +10 -0
  172. package/dist/runner/cli-run-spec.js +207 -64
  173. package/dist/runner/commands.d.ts +5 -1
  174. package/dist/runner/commands.js +3 -3
  175. package/dist/runner/conformance/harness.d.ts +1 -1
  176. package/dist/runner/conformance/harness.js +13 -10
  177. package/dist/runner/github-app.d.ts +7 -2
  178. package/dist/runner/github-app.js +46 -15
  179. package/dist/runner/harness-loops.d.ts +6 -1
  180. package/dist/runner/harness-loops.js +24 -1
  181. package/dist/runner/journal-kinds.d.ts +53 -7
  182. package/dist/runner/journal-kinds.js +29 -1
  183. package/dist/runner/learning-end.d.ts +15 -0
  184. package/dist/runner/learning-end.js +113 -20
  185. package/dist/runner/learning-factory.js +6 -2
  186. package/dist/runner/learning-loop.d.ts +75 -1
  187. package/dist/runner/learning-loop.js +215 -22
  188. package/dist/runner/learning-seed.d.ts +8 -0
  189. package/dist/runner/learning-seed.js +7 -1
  190. package/dist/runner/loop-contract.d.ts +12 -0
  191. package/dist/runner/loop-contract.js +6 -0
  192. package/dist/runner/loop.d.ts +5 -1
  193. package/dist/runner/loop.js +20 -0
  194. package/dist/runner/main.d.ts +9 -4
  195. package/dist/runner/main.js +38 -13
  196. package/dist/runner/mcp-claim.d.ts +7 -0
  197. package/dist/runner/mcp-claim.js +35 -2
  198. package/dist/runner/mcp-github.d.ts +15 -4
  199. package/dist/runner/mcp-github.js +55 -11
  200. package/dist/runner/mcp-run.d.ts +2 -0
  201. package/dist/runner/mcp-run.js +2 -0
  202. package/dist/runner/metrics.d.ts +18 -1
  203. package/dist/runner/metrics.js +81 -1
  204. package/dist/runner/model-route.d.ts +6 -0
  205. package/dist/runner/model-route.js +5 -2
  206. package/dist/runner/pr-checkout.d.ts +59 -0
  207. package/dist/runner/pr-checkout.js +176 -0
  208. package/dist/runner/reflect-hook.d.ts +1 -0
  209. package/dist/runner/reflect-hook.js +3 -3
  210. package/dist/runner/runner.js +136 -19
  211. package/dist/runner/spec-holds.d.ts +13 -3
  212. package/dist/runner/spec-holds.js +13 -10
  213. package/dist/runner/store-port.d.ts +4 -1
  214. package/dist/runner/store-secrets.js +17 -1
  215. package/dist/runner/subagent.d.ts +44 -0
  216. package/dist/runner/subagent.js +188 -0
  217. package/dist/runner/workflow-host.d.ts +25 -4
  218. package/dist/runner/workflow-host.js +26 -4
  219. package/dist/runner/workflow-loop.d.ts +9 -3
  220. package/dist/runner/workflow-loop.js +17 -10
  221. package/dist/runner/workflow-spec.d.ts +28 -13
  222. package/dist/runner/workflow-spec.js +247 -102
  223. package/dist/runs-over-store.d.ts +18 -7
  224. package/dist/runs-over-store.js +149 -31
  225. package/dist/seal-key.d.ts +0 -2
  226. package/dist/seal-key.js +0 -2
  227. package/dist/sealing.js +1 -2
  228. package/dist/secret-cut.d.ts +1 -1
  229. package/dist/secret-cut.js +1 -1
  230. package/dist/server-lock.js +4 -5
  231. package/dist/server.d.ts +49 -63
  232. package/dist/server.js +429 -230
  233. package/dist/stop-signals.d.ts +4 -2
  234. package/dist/stop-signals.js +5 -3
  235. package/dist/store/agent-body.d.ts +14 -3
  236. package/dist/store/agent-body.js +22 -8
  237. package/dist/store/deadline.d.ts +18 -0
  238. package/dist/store/deadline.js +49 -0
  239. package/dist/store/index.d.ts +3 -3
  240. package/dist/store/index.js +2 -2
  241. package/dist/store/journal/storage.js +2 -1
  242. package/dist/store/postgres/connection.d.ts +4 -0
  243. package/dist/store/postgres/connection.js +64 -13
  244. package/dist/store/postgres/migrations/0004_runs_outcome_stop_or_cancel.sql +11 -0
  245. package/dist/store/schema.d.ts +2 -1
  246. package/dist/store/schema.js +11 -8
  247. package/dist/store/seal.d.ts +13 -0
  248. package/dist/store/seal.js +19 -0
  249. package/dist/store/sqlite/connection.d.ts +5 -0
  250. package/dist/store/sqlite/connection.js +88 -82
  251. package/dist/store/sqlite/run-patch.d.ts +18 -2
  252. package/dist/store/sqlite/run-patch.js +31 -2
  253. package/dist/store/sqlite/store.js +65 -11
  254. package/dist/store/store.d.ts +62 -12
  255. package/dist/store/store.js +22 -1
  256. package/dist/store-reads/analytics.js +3 -2
  257. package/dist/store-reads/cap.d.ts +1 -3
  258. package/dist/store-reads/cap.js +8 -6
  259. package/dist/store-reads/decisions.d.ts +2 -2
  260. package/dist/store-reads/decisions.js +3 -6
  261. package/dist/store-reads/journal.js +83 -15
  262. package/dist/store-reads/learning.d.ts +73 -3
  263. package/dist/store-reads/learning.js +232 -9
  264. package/dist/store-reads/runs.d.ts +6 -4
  265. package/dist/store-reads/runs.js +17 -10
  266. package/dist/store-reads/stats.js +5 -1
  267. package/dist/store-view.d.ts +15 -1
  268. package/dist/store-view.js +88 -29
  269. package/dist/template-eval.js +2 -1
  270. package/dist/templates.d.ts +73 -4
  271. package/dist/templates.js +113 -23
  272. package/dist/timeline/timeline.d.ts +11 -1
  273. package/dist/timeline/timeline.js +19 -4
  274. package/dist/tool-blurbs.js +1 -0
  275. package/dist/tool-budget.d.ts +26 -0
  276. package/dist/tool-budget.js +56 -0
  277. package/dist/tool-gate.d.ts +13 -3
  278. package/dist/tool-gate.js +15 -7
  279. package/dist/tool-plane.d.ts +42 -29
  280. package/dist/tool-plane.js +64 -27
  281. package/dist/tools.d.ts +53 -39
  282. package/dist/tools.js +174 -79
  283. package/dist/trigger-signatures.d.ts +1 -0
  284. package/dist/trigger-signatures.js +3 -1
  285. package/dist/triggers.d.ts +3 -3
  286. package/dist/triggers.js +2 -2
  287. package/dist/turn-end.d.ts +0 -3
  288. package/dist/turn-end.js +0 -3
  289. package/dist/uploads.d.ts +28 -5
  290. package/dist/uploads.js +82 -9
  291. package/dist/usage-lines.d.ts +1 -1
  292. package/dist/usage.d.ts +1 -47
  293. package/dist/usage.js +3 -82
  294. package/dist/validate.d.ts +8 -0
  295. package/dist/validate.js +40 -3
  296. package/dist/webhooks.d.ts +2 -1
  297. package/dist/webhooks.js +5 -2
  298. package/dist/workflow/decision-recovery.d.ts +23 -0
  299. package/dist/workflow/decision-recovery.js +80 -0
  300. package/dist/workflow/decisions.d.ts +134 -0
  301. package/dist/workflow/decisions.js +46 -0
  302. package/dist/workflow/host-session.d.ts +5 -0
  303. package/dist/workflow/host-session.js +85 -0
  304. package/dist/workflow/host-tools.d.ts +3 -0
  305. package/dist/workflow/host-tools.js +3 -0
  306. package/dist/workflow/node-runner.d.ts +112 -0
  307. package/dist/workflow/node-runner.js +270 -0
  308. package/dist/workflow/node.d.ts +88 -0
  309. package/dist/workflow/node.js +99 -0
  310. package/dist/workflow/operator-error.d.ts +4 -0
  311. package/dist/workflow/operator-error.js +4 -0
  312. package/dist/workflow/pi-versions.d.ts +9 -0
  313. package/dist/workflow/pi-versions.js +8 -0
  314. package/dist/workflow/readers.d.ts +36 -0
  315. package/dist/workflow/readers.js +145 -0
  316. package/dist/workflow/record-file.d.ts +10 -0
  317. package/dist/workflow/record-file.js +56 -0
  318. package/dist/workflow/record-tool.d.ts +76 -0
  319. package/dist/workflow/record-tool.js +126 -0
  320. package/dist/workflow/record.d.ts +151 -0
  321. package/dist/workflow/record.js +401 -0
  322. package/dist/workflow/run-error.d.ts +16 -0
  323. package/dist/workflow/run-error.js +26 -0
  324. package/dist/workflow/runner.d.ts +6 -0
  325. package/dist/workflow/runner.js +240 -0
  326. package/dist/workflow/store.d.ts +23 -0
  327. package/dist/workflow/store.js +242 -0
  328. package/dist/workflow/task.d.ts +133 -0
  329. package/dist/workflow/task.js +411 -0
  330. package/dist/workflow/thinking.d.ts +3 -0
  331. package/dist/workflow/thinking.js +7 -0
  332. package/dist/workflow/tool-context.d.ts +21 -0
  333. package/dist/workflow/tool-context.js +13 -0
  334. package/dist/workflow/types.d.ts +126 -0
  335. package/dist/workflow/types.js +1 -0
  336. package/dist/workflow/wal.d.ts +11 -0
  337. package/dist/workflow/wal.js +106 -0
  338. package/dist/workflow-run.d.ts +1 -1
  339. package/dist/workspace/agent-computer.d.ts +137 -0
  340. package/dist/workspace/agent-computer.js +292 -0
  341. package/dist/workspace/archil-claim.d.ts +13 -2
  342. package/dist/workspace/archil-claim.js +22 -13
  343. package/dist/workspace/archil-disk.d.ts +10 -1
  344. package/dist/workspace/archil-disk.js +4 -0
  345. package/dist/workspace/archil-disks.d.ts +49 -0
  346. package/dist/workspace/archil-disks.js +185 -0
  347. package/dist/workspace/archil-exec.d.ts +12 -2
  348. package/dist/workspace/archil-exec.js +18 -3
  349. package/dist/workspace/archil-mount-credential.d.ts +20 -4
  350. package/dist/workspace/archil-mount-credential.js +13 -4
  351. package/dist/workspace/archil.d.ts +2 -2
  352. package/dist/workspace/archil.js +25 -5
  353. package/dist/workspace/attach.js +2 -0
  354. package/dist/workspace/computer-deps.d.ts +18 -11
  355. package/dist/workspace/computer-deps.js +64 -40
  356. package/dist/workspace/computer-for-claim.d.ts +47 -9
  357. package/dist/workspace/computer-for-claim.js +236 -24
  358. package/dist/workspace/computer-janitor.d.ts +3 -2
  359. package/dist/workspace/computer-janitor.js +43 -9
  360. package/dist/workspace/computer-ledger.d.ts +3 -8
  361. package/dist/workspace/computer-ledger.js +7 -3
  362. package/dist/workspace/computer-providers.d.ts +5 -3
  363. package/dist/workspace/computer-providers.js +11 -9
  364. package/dist/workspace/hands.d.ts +5 -2
  365. package/dist/workspace/hands.js +4 -3
  366. package/dist/workspace/index.d.ts +5 -4
  367. package/dist/workspace/index.js +2 -1
  368. package/dist/workspace/local.d.ts +3 -0
  369. package/dist/workspace/local.js +9 -0
  370. package/dist/workspace/paths.js +3 -2
  371. package/dist/workspace/pi-env.d.ts +4 -0
  372. package/dist/workspace/pi-env.js +3 -2
  373. package/dist/workspace/resolve-computer.d.ts +48 -12
  374. package/dist/workspace/resolve-computer.js +88 -19
  375. package/dist/workspace/run-disk.d.ts +34 -0
  376. package/dist/workspace/run-disk.js +91 -0
  377. package/dist/workspace/run-tools.d.ts +6 -4
  378. package/dist/workspace/run-tools.js +17 -9
  379. package/dist/workspace/server-run-workspace.d.ts +3 -2
  380. package/dist/workspace/server-run-workspace.js +17 -4
  381. package/dist/workspace/workspace.d.ts +5 -0
  382. package/dist/workspace.d.ts +0 -3
  383. package/dist/workspace.js +2 -15
  384. package/package.json +11 -16
  385. package/skills/agentrun-serve/SKILL.md +1 -1
  386. package/templates/README.md +11 -8
  387. package/templates/code-review/agent.md +27 -11
  388. package/templates/code-review/evals/clean-refactor/graders/coverage.md +4 -0
  389. package/templates/code-review/evals/clean-refactor/graders/risk.md +5 -0
  390. package/templates/code-review/evals/injection/graders/ignores.md +1 -1
  391. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  392. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  393. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  394. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  395. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  396. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  397. package/templates/code-review/evals/never-flag/case.yaml +3 -0
  398. package/templates/code-review/evals/never-flag/graders/only-p0.md +4 -0
  399. package/templates/code-review/evals/never-flag/graders/schema.md +5 -0
  400. package/templates/code-review/evals/never-flag/prompt.md +30 -0
  401. package/templates/code-review/evals/null-name/graders/finds.md +1 -1
  402. package/templates/code-review/evals/off-by-one/graders/finds.md +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +6 -5
  404. package/templates/code-review/evals/re-review/graders/resolves.md +1 -1
  405. package/templates/code-review/evals/re-review/prompt.md +1 -1
  406. package/templates/code-review/evals/re-review-open/case.yaml +3 -0
  407. package/templates/code-review/evals/re-review-open/graders/schema.md +5 -0
  408. package/templates/code-review/evals/re-review-open/graders/stays-open.md +4 -0
  409. package/templates/code-review/evals/re-review-open/prompt.md +27 -0
  410. package/templates/code-review/evals/repo-rule/graders/cites.md +1 -1
  411. package/templates/code-review/evals/two-defects/case.yaml +3 -0
  412. package/templates/code-review/evals/two-defects/graders/both.md +4 -0
  413. package/templates/code-review/evals/two-defects/graders/schema.md +5 -0
  414. package/templates/code-review/evals/two-defects/prompt.md +25 -0
  415. package/templates/code-review/findings.schema.json +131 -27
  416. package/templates/code-review/rules/CODEREVIEW.md +76 -0
  417. package/templates/code-review/skills/review/DEEP.md +130 -0
  418. package/templates/code-review/skills/review/REVIEWER.md +116 -0
  419. package/templates/code-review/skills/review/SKILL.md +104 -154
  420. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  421. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  422. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  423. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  424. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  425. package/templates/release-notes/agent.md +11 -0
  426. package/dist/box/record.d.ts +0 -6
  427. package/dist/box/record.js +0 -41
  428. package/dist/box/sweep.d.ts +0 -53
  429. package/dist/box/sweep.js +0 -193
  430. package/dist/box-egress-vm.d.ts +0 -118
  431. package/dist/box-egress-vm.js +0 -354
  432. package/dist/box-egress.d.ts +0 -105
  433. package/dist/box-egress.js +0 -256
  434. package/dist/box-relay-vm.d.ts +0 -84
  435. package/dist/box-relay-vm.js +0 -437
  436. package/dist/box-relay.d.ts +0 -36
  437. package/dist/box-relay.js +0 -207
  438. package/dist/boxes.d.ts +0 -109
  439. package/dist/boxes.js +0 -249
  440. package/dist/budget.d.ts +0 -76
  441. package/dist/budget.js +0 -204
  442. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  443. package/dist/console/assets/index-opTN5Naq.css +0 -1
  444. package/dist/daytona-api.d.ts +0 -10
  445. package/dist/daytona-api.js +0 -20
  446. package/dist/egress-proxy.d.ts +0 -45
  447. package/dist/egress-proxy.js +0 -416
  448. package/dist/egress-table.d.ts +0 -24
  449. package/dist/egress-table.js +0 -165
  450. package/templates/code-review/rules/REVIEW.md +0 -41
package/dist/tools.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // run's folder or its computer. `bash` and the background tools may be named only by an agent whose place is a box
6
6
  // (runnable.ts).
7
7
  import { blurbOf } from "./tool-blurbs.js";
8
+ import { LEARNED_MCP_TOOL } from "./learn/skills.js";
8
9
  import { appendFileSync } from "node:fs";
9
10
  import { pathToFileURL } from "node:url";
10
11
  import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
@@ -14,6 +15,7 @@ import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
14
15
  import { fetchOptions, HTML_READ_CHARS, TEXT_CAP } from "./web-fetch-direct.js";
15
16
  import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
16
17
  import { REPLAY } from "./host-tools.js";
18
+ import { localFolderOf } from "./workspace/local.js";
17
19
  import { LLM_TOOL } from "./llm.js";
18
20
  import { DOCUMENTS_ENV, PDF_PAGES_TOOL, pdfPages } from "./pdf-pages.js";
19
21
  import { monidTool } from "./monid.js";
@@ -27,6 +29,7 @@ import { searchFor, WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
27
29
  import { browserNeeds, explainsView, isUnavailable, NO_PARALLEL_KEY, PICKABLE, planeOf, PROVIDERS, serverGate, whyUnavailable, withDefaults } from "./tool-plane.js";
28
30
  import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
29
31
  import { keyNeeded } from "./key-words.js";
32
+ import { unattachable } from "./attach-images.js";
30
33
  import { handedSignIn } from "./secrets.js";
31
34
  import { redactedAnswer } from "./key-refusal.js";
32
35
  import { SIGN_IN_KEY, vendorsOver } from "./sign-ins.js";
@@ -34,11 +37,13 @@ import { answerIn, answerOnce } from "./runner/hand-back.js";
34
37
  import { waitingAsk } from "./browser-commands.js";
35
38
  import { runnerSecrets } from "./runner/redact.js";
36
39
  import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
40
+ import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
37
41
  import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
38
42
  export const ASK_TOOL = "ask_person";
39
- /** Under `--faux` only: a module whose default export gives the browser's `{ provider, driver }` for the run's
40
- * environment, the vendor its plane names (`browserbase`, `kernel`) and the saved sign-in it was handed for that
41
- * vendor (`{ provider, ref, save }`, or undefined), in place of that vendor's (the tests' fake backend). */
43
+ /** Under `--faux` only: a module whose default export gives the browser's `{ computer, driver }` for the run's
44
+ * environment, the vendor its plane names and the saved sign-in it was handed for that vendor (`{ provider, ref, save }`,
45
+ * or undefined): a browser computer provider and a driver in place of the vendor's and the raw-CDP driver (the tests'
46
+ * fake backend). */
42
47
  export const FAUX_BROWSER_ENV = "AGENTRUN_SERVE_FAUX_BROWSER";
43
48
  /** Under `--faux` only: a module whose default export is the fetch a run's first saved sign-in is made with on the runner,
44
49
  * in place of the browser vendors' REST APIs (the tests' fake). Absent under --faux, none is made: no network. */
@@ -146,24 +151,57 @@ export const evidenceIn = (work) => {
146
151
  },
147
152
  };
148
153
  };
149
- /** The Browserbase contexts a run's browser may open: its agent's saved sign-in's alone, by its profile name, never one
150
- * made here (nothing a run makes is kept for its agent). */
151
- export const keptContexts = (ref) => ({
152
- clear: false,
153
- resolve: async (key) => {
154
- if (ref && key.endsWith(`|profile:${SIGN_IN_KEY}`))
155
- return ref;
156
- throw new Error("this run's browser has no saved sign-in to open");
154
+ /** What browser_upload may choose: a file of the run's Workspace, the one its read opens, by a path relative to it. The
155
+ * Workspace refuses a path that would leave it (absolute, "..", a link anywhere on the way), so nothing outside the run's
156
+ * folder is ever read; a file must be a regular one of at most `maxBytes`. `mime` names its media type by its name. */
157
+ export const uploadsFrom = (work, maxBytes, mime) => ({
158
+ async resolve(rel) {
159
+ if (typeof rel !== "string" || !rel.trim())
160
+ return { refused: "path must name a file in the workspace" };
161
+ const refusal = (error) => (isWorkspaceError(error, "ESCAPE") ? `${rel} resolves outside the workspace` : isWorkspaceError(error, "NOT_FOUND") ? `no file at ${rel} in the workspace` : `${rel} cannot be opened`);
162
+ try {
163
+ const info = await work.stat(rel);
164
+ if (!info)
165
+ return { refused: `no file at ${rel} in the workspace` };
166
+ if (info.kind !== "file")
167
+ return { refused: `${rel} is not a regular file` };
168
+ if (info.size > maxBytes)
169
+ return { refused: `${rel} is ${info.size} bytes, over the ${maxBytes}-byte limit` };
170
+ // The file as its stat sized it, and nothing past that: one that shrank, or grew before or while it was read, is
171
+ // refused, never chosen in part.
172
+ const bytes = await work.read(rel, { length: info.size });
173
+ if (bytes.byteLength !== info.size || (await work.read(rel, { offset: info.size, length: 1 })).byteLength > 0)
174
+ return { refused: `${rel} changed while it was read; try again` };
175
+ const name = rel.split("/").at(-1) ?? rel;
176
+ return { bytes, name, mime: mime(name) };
177
+ }
178
+ catch (error) {
179
+ return { refused: refusal(error) };
180
+ }
157
181
  },
158
182
  });
159
- /** Every string in `value` (a tool's answer: its content, its details) passed through `cut`; anything else as it is. */
160
- function cutStrings(value, cut) {
183
+ /** An image block's `data` kept whole by the cut: its base64 is an image a model can be sent (attach-images.ts
184
+ * unattachable: a PNG, JPEG, GIF or WebP whose bytes are the type it names and whose header says its size), and its
185
+ * decoded bytes, read as text, hold nothing the cut takes out (a held value written after a valid header). */
186
+ const wholeImage = (block, cut) => {
187
+ if (unattachable(block) !== undefined)
188
+ return false;
189
+ const bytes = Buffer.from(block.data, "base64").toString("latin1");
190
+ return cut(bytes) === bytes;
191
+ };
192
+ /** Every string in `value` (a tool's answer: its content, its details) passed through `cut`; anything else as it is. An
193
+ * image block's `data` that is an image (wholeImage) is its pixels' base64, not text, and is kept whole: the cut reads a
194
+ * run of more than 8,192 characters with no whitespace as "[redacted]" (key-refusal.ts redactedAnswer), which no model
195
+ * takes as an image. Any other `data`, on a block of any type, is cut like every other string. */
196
+ export function cutAnswer(value, cut) {
161
197
  if (typeof value === "string")
162
198
  return cut(value);
163
199
  if (Array.isArray(value))
164
- return value.map((item) => cutStrings(item, cut));
200
+ return value.map((item) => cutAnswer(item, cut));
165
201
  if (value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
166
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cutStrings(item, cut)]));
202
+ const block = value;
203
+ const keep = block.type === "image" && wholeImage(block, cut);
204
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, keep && key === "data" ? item : cutAnswer(item, cut)]));
167
205
  }
168
206
  return value;
169
207
  }
@@ -174,7 +212,7 @@ function answersCutInside(tool, cut) {
174
212
  ...tool,
175
213
  execute: (async (...args) => {
176
214
  try {
177
- return cutStrings(await tool.execute(...args), cut);
215
+ return cutAnswer(await tool.execute(...args), cut);
178
216
  }
179
217
  catch (error) {
180
218
  if (error instanceof Error) {
@@ -187,12 +225,6 @@ function answersCutInside(tool, cut) {
187
225
  }),
188
226
  };
189
227
  }
190
- /** Kernel's provider, opening the agent's saved profile (`ref`, its name at Kernel) where a session asks for the
191
- * profile `default`: the policy, the session's record and the model see only that name. */
192
- export const keptProfile = (provider, ref) => ({
193
- ...provider,
194
- create: (spec, signal) => provider.create(spec.profile?.name === SIGN_IN_KEY ? { ...spec, profile: { ...spec.profile, name: ref } } : spec, signal),
195
- });
196
228
  /** `provider`, its sessions' profile as this launch was handed it, whatever the policy a conversation was made with (a
197
229
  * follow-up's was made under an earlier launch, which may have had no sign-in, or another lease): with a sign-in, every
198
230
  * session opens on the profile `default`, saving only as `kept.save` says; without one, none asks for a profile. */
@@ -213,15 +245,17 @@ export const runSignInSaved = (store, sealKey, claim, kept) => async (row, chang
213
245
  const ended = row.session.endedAt ? Date.parse(row.session.endedAt) : Number.NaN;
214
246
  return verifyRunSignIn(store, sealKey, claim, kept, Number.isFinite(ended) ? ended : Date.now());
215
247
  };
216
- /** A hosted browser driven through Stagehand, on pi-browser's durable adapter: Browserbase or Kernel (headless), the one
217
- * the run's plane names (tool-plane.ts: picked, else Browserbase where the server holds its keys, else Kernel), kept
218
- * for the run's life; a plane that names none (a run kept from before the pick) is Browserbase. Its sessions' custody
219
- * lives in the run's own store. No recording; the owner watches it live, takes it over and hands it back, and the agent
220
- * may ask them to (browser-live.ts, browser-person.ts). A session the run still holds is released when the run is let
221
- * go. Where the plane says unavailable (its vendor's key gone since), each call is refused, saying why.
222
- * Its session time is the run's spend, held under its cap before it runs (browser-cost.ts). A run handed its agent's
223
- * saved sign-in for that vendor (sign-ins.ts, over its pipe) opens every session on it, as the profile `default`,
224
- * saving only where it holds the agent's save lease; one that saved says so in its run directory. */
248
+ /** A browser on pi-browser's durable adapter, its sessions a browser computer provider's of the computer registry
249
+ * (browser-computer.ts), each driven over its CDP URL by pi-browser's raw-CDP driver: the agent's computer, where it is
250
+ * a browser (the claim's, computer-for-claim.ts), else the one the run's plane names (tool-plane.ts: picked, else
251
+ * Browserbase where the server holds its keys, else Kernel), kept for the run's life; a plane that names none (a run kept
252
+ * from before the pick) is Browserbase. Its sessions' custody lives in the run's own store. No recording; the owner
253
+ * watches it live, takes it over and hands it back, and the agent may ask them to (browser-live.ts, browser-person.ts).
254
+ * A session the run still holds is released when the run is let go. Where the plane says unavailable (its vendor's key
255
+ * gone since), each call is refused, saying why. Its session time is the run's spend, held under its cap before it runs
256
+ * (browser-cost.ts). A run on the plane's vendor handed its agent's saved sign-in for that vendor (sign-ins.ts) opens
257
+ * every session on it, as the profile `default`, saving only where it holds the agent's save lease; one that saved says
258
+ * so in its run directory. */
225
259
  const browserTool = {
226
260
  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.",
227
261
  // Which vendor's keys it needs is the plane's to say (tool-plane.ts BROWSER_KEYS): neither alone is required.
@@ -230,45 +264,62 @@ const browserTool = {
230
264
  // (its reconcile, its release and drain, its live view hang off that run's lifecycle). A node naming it is refused when
231
265
  // its definition is saved (runnable.ts), never accepted and then failed at its run.
232
266
  nodes: false,
233
- // Its downloads and uploads go through work/ by path (pi-browser), which a box's command could turn through a link.
267
+ // Its downloads go into work/ by path (pi-browser), which a box's command could turn through a link.
234
268
  runnerOnly: true,
235
269
  bind: async (host) => {
236
- const [{ BACKGROUND_CONTEXT: context }, { createBrowserExtension }, { DEFAULT_BROWSER_POLICY, BrowserFailureError, browserFailure, workspaceFiles }, { createDrivingGates, createLiveView, liveViewProvider }, live, person] = await Promise.all([
270
+ 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([
237
271
  import("@earendil-works/chord/context"),
238
272
  import("@parcha/pi-browser/durable"),
239
273
  import("@parcha/pi-browser"),
240
274
  import("@parcha/pi-browser/live-view"),
241
275
  import("./browser-live.js"),
242
276
  import("./browser-person.js"),
277
+ import("./browser-computer.js"),
278
+ import("@parcha/pi-browser/driver/cdp"),
243
279
  ]);
244
280
  // The agent's computer, where it is a browser, wins over the plane's pick: the run's sessions are that provider's,
245
- // opened through the claim and driven over their CDP URL by the raw-CDP driver, with no pi-browser vendor provider,
246
- // saved sign-in or plane check of their own.
281
+ // opened through the claim, with no saved sign-in or plane check of their own.
247
282
  const computer = host.browserComputer;
248
283
  const planeVendor = planeOf(host.env).browser ?? "browserbase";
249
284
  const vendor = computer?.provider ?? planeVendor;
250
- const refused = !computer && isUnavailable(planeVendor) ? new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${whyUnavailable(planeVendor)}.`)) : undefined;
285
+ const planeRefused = !computer && isUnavailable(planeVendor) ? new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${whyUnavailable(planeVendor)}.`)) : undefined;
251
286
  // The run's saved sign-in: on the runner (one process, many claims) read from the store under this run's own claim
252
287
  // (sign-ins-store.ts runSignIn), never from the process; on the old per-run process, over its own secrets' pipe.
253
288
  // 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
254
289
  // launch makes it: never the process's environment, so one run's keys never make another's.
255
290
  const runLog = (line) => void process.stderr.write(`agentrun-serve: run ${host.where.ref.id}: ${line}\n`);
256
291
  const vendorFetch = async () => (host.env[FAUX_ENV] ? fauxFetch(host.env, FAUX_VENDOR_API_ENV) : fetch);
257
- 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();
258
- const kept = !refused && handed?.provider === vendor ? handed : undefined;
259
- const faux = host.env[FAUX_ENV] ? host.env[FAUX_BROWSER_ENV] : undefined;
260
- const parts = computer
261
- ? { provider: (await import("./browser-computer.js")).claimBrowserProvider(computer), driver: (await import("@parcha/pi-browser/driver/cdp")).cdpDriver() }
262
- : faux
263
- ? (await import(pathToFileURL(faux).href)).default(host.env, vendor, kept)
264
- : {
265
- provider: refused
266
- ? undefined
267
- : vendor === "kernel"
268
- ? ((kernel) => (kept ? keptProfile(kernel, kept.ref) : kernel))((await import("@parcha/pi-browser/providers/kernel")).kernelProvider({ env: host.env, headless: true }))
269
- : (await import("@parcha/pi-browser/providers/browserbase")).browserbaseProvider({ env: host.env, profiles: keptContexts(kept?.ref) }),
270
- driver: (await import("@parcha/pi-browser/driver/stagehand")).stagehandDriver(),
271
- };
292
+ 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();
293
+ const kept = !planeRefused && handed?.provider === vendor ? handed : undefined;
294
+ // Tests only (--faux): the faux browser's computer provider and driver stand in for the plane vendor's and the raw-CDP
295
+ // driver. The agent's browser computer is still the claim's, so a test hands the claim a faux provider of its own.
296
+ const faux = !computer && host.env[FAUX_ENV] ? host.env[FAUX_BROWSER_ENV] : undefined;
297
+ const stand = faux ? (await import(pathToFileURL(faux).href)).default(host.env, vendor, kept) : undefined;
298
+ // The session's browser: the claim's (the agent's computer), else the plane's vendor on the run's tool keys, opened
299
+ // the same way under the run's labels. One that cannot be made refuses each call, in its words.
300
+ const made = planeRefused
301
+ ? { refused: planeRefused }
302
+ : await (async () => {
303
+ try {
304
+ if (computer)
305
+ return { browser: computer };
306
+ const provider = stand ? stand.computer : await planeComputer(vendor, host.env);
307
+ const plane = planeBrowser(provider, host.claim);
308
+ if (host.claim && !stand)
309
+ await releaseOlderBrowsers(provider, host.claim);
310
+ return { browser: plane };
311
+ }
312
+ catch (error) {
313
+ if (error instanceof BrowserFailureError)
314
+ return { refused: error };
315
+ return { refused: new BrowserFailureError(browserFailure("browser_unavailable", `The browser does not run here: ${error instanceof Error ? error.message : String(error)}.`)) };
316
+ }
317
+ })();
318
+ const refused = "refused" in made ? made.refused : undefined;
319
+ const parts = {
320
+ 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,
321
+ driver: stand ? stand.driver : cdpDriver(),
322
+ };
272
323
  // The save flag every session carries is this launch's (asHanded), never the one stored with its conversation.
273
324
  const handedProvider = parts.provider ? asHanded(parts.provider, kept) : undefined;
274
325
  // The owner's live view (browser-live.ts): pi-browser's own viewer on a loopback port of this process's, over every
@@ -300,6 +351,12 @@ const browserTool = {
300
351
  // the run's own cut on the runner (host.redact: the claim's keys too, every tool's, in every form), and the secrets
301
352
  // its env holds (runnerSecrets: hostSecrets and every launcher name's value) with its sign-in's pointer.
302
353
  redact: (text) => redactedAnswer(host.redact ? host.redact(text) : text, [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])]),
354
+ // The Screen tab's ended state, one settings row the server reads per poll (browser-wait-ended.ts); cleared as a
355
+ // session opens (onSessions, below).
356
+ waitEnded: (at, why) => {
357
+ if (host.store && host.claim)
358
+ void markWaitEnded(host.store.settings, host.claim.runId, { at: new Date(at).toISOString(), why }, host.claim.epoch).catch(() => undefined);
359
+ },
303
360
  note: async (kind, data) => {
304
361
  // A hand-over's waiting entry, on the runner: the row says the run waits on the person in its browser from that
305
362
  // commit (the server tells run.needs_input by it), and no more from its answer's, whoever writes it.
@@ -347,10 +404,15 @@ const browserTool = {
347
404
  // On the runner, the run's ledger (host.ledger): each call held and settled on its booking, and a session's release one
348
405
  // more request there, never this process's own spend. Undefined on the old per-run process: browserSpend's own then.
349
406
  const spend = browserSpend(providerName, price, DEFAULT_BROWSER_POLICY.idleReleaseS, (conversation, at) => browser.release(conversation, "close", at), undefined, { paid: host.ledger?.paid, pause: host.ledger?.pause, flush: host.ledger?.flush });
350
- // browser_downloads is listed only with a workspace to copy into, and only a provider that keeps a session's downloads
351
- // (Browserbase's; Kernel's keeps none) has any: without one, uploads still read the run's work/, through `files`.
352
- const downloads = typeof parts.provider?.downloads === "object";
353
- const files = downloads ? { workspace: () => host.where.work } : { files: workspaceFiles(host.where.work) };
407
+ // The run's own Workspace, the one its read opens (on the runner: Mode 1's local folder, Mode 2's folder on the run's
408
+ // disk): the browser files its evidence there, and browser_upload chooses from it.
409
+ const work = host.workspace ?? localWorkspace(host.where.work);
410
+ // browser_downloads copies into a folder by its local path (pi-browser fetchDownloads), so it is listed only where the
411
+ // run's Workspace is a folder of this machine (never on Mode 2's disk, where the run's read would not find what it
412
+ // copied), and only for a provider that keeps a session's downloads (Browserbase's; Kernel's keeps none).
413
+ const folder = localFolderOf(work);
414
+ const keepsDownloads = typeof parts.provider?.downloads === "object";
415
+ const files = { files: uploadsFrom(work, MAX_UPLOAD_BYTES, uploadMime), ...(folder !== undefined && keepsDownloads ? { workspace: () => folder } : {}) };
354
416
  // A session that saved to the sign-in, let go: its time, for the sign-in's verified_at when the run's lease ends.
355
417
  // On the runner, the store's verified_at under the run's claim (runSignInSaved), never a mark in the run's directory.
356
418
  const verify = kept?.save && host.claim && host.store && host.sealKey ? runSignInSaved(host.store, host.sealKey, host.claim, kept) : undefined;
@@ -364,6 +426,9 @@ const browserTool = {
364
426
  // A session let go ends a wait on the person's answer that kept it open (personWait, below): the run parks.
365
427
  if (change === "released")
366
428
  hands.sessionEnded(row.session.tag);
429
+ // A session that opens, whatever let the last one go: the Screen tab's ended state goes (browser-wait-ended.ts).
430
+ if (change === "launched" && host.store && host.claim)
431
+ await clearWaitEnded(host.store.settings, host.claim.runId, host.claim.epoch).catch(() => undefined);
367
432
  await saved?.(row, change);
368
433
  await onSession(row, change);
369
434
  };
@@ -371,7 +436,7 @@ const browserTool = {
371
436
  // vendor's refusal can quote it, as pi-browser's one-saver rule names Kernel's profile.
372
437
  // A run handed its agent's sign-in tells the model its browser keeps it (`run`'s description): one with none claims
373
438
  // cookies across pages only.
374
- const browser = createBrowserExtension({ provider, driver: parts.driver, evidence: evidenceIn(localWorkspace(host.where.work)), ...files, gates, handoff: hands.handoff, onSession: onSessions, signIns: kept !== undefined, beforeCreate: spend.opening, redact: { values: () => [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])] }, prices: { sessionUsdPerHour: price.usdPerHour, sessionMinimumS: price.minimumS }, onCharge: spend.onCharge });
439
+ const browser = createBrowserExtension({ provider, driver: parts.driver, evidence: evidenceIn(work), ...files, gates, handoff: hands.handoff, onSession: onSessions, signIns: kept !== undefined, beforeCreate: spend.opening, redact: { values: () => [...runnerSecrets(host.env), ...(kept ? [kept.ref] : [])] }, prices: { sessionUsdPerHour: price.usdPerHour, sessionMinimumS: price.minimumS }, onCharge: spend.onCharge });
375
440
  // On the runner, every answer the browser's tools give passes the run's one redactor inside the call, so what pi stores
376
441
  // (its result record) and what the model reads hold no value the runner or the claim holds.
377
442
  const tools = browser.tools.map(spend.capped).map((tool) => (host.redact ? answersCutInside(tool, host.redact) : tool));
@@ -433,7 +498,9 @@ const browserTool = {
433
498
  // (live, or held for a hand-over), the run waits for the answer in its claim, so the session, its live viewer and its
434
499
  // 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
435
500
  // session is held under the run's cap the way a hand-over's is (personHands.wait). With none open, or no room under
436
- // the cap for that time, the run parks (its release lets the browser go).
501
+ // the cap for that time, the run parks (its release lets the browser go). While it waits, pi-browser's idle release
502
+ // keeps its hands off those sessions (keepForPerson): the person's window (AGENTRUN_BROWSER_PERSON_WAIT_MIN), not the
503
+ // browser's few-minute idle window, decides when the browser goes.
437
504
  host.personWait?.(async (harness, callId, since) => {
438
505
  if (refused)
439
506
  return undefined;
@@ -441,8 +508,15 @@ const browserTool = {
441
508
  const open = rows.filter((row) => (row.state === "live" || row.state === "held") && row.resourceId !== null).map((row) => row.tag);
442
509
  if (!open.length)
443
510
  return undefined;
511
+ const keeps = open.map((tag) => browser.keepForPerson(tag));
512
+ const letGo = () => { for (const keep of keeps.splice(0))
513
+ keep(); };
444
514
  const waited = await hands.wait(callId, open, since);
445
- return "refused" in waited ? undefined : waited;
515
+ if ("refused" in waited) {
516
+ letGo();
517
+ return undefined;
518
+ }
519
+ return { lapsed: waited.lapsed, confirmed: waited.confirmed, drop: () => { waited.drop(); letGo(); } };
446
520
  });
447
521
  host.beforeRelease(async (harness) => {
448
522
  try {
@@ -465,6 +539,10 @@ const browserTool = {
465
539
  await view.close();
466
540
  hands.close();
467
541
  await viewers.released();
542
+ // The download sockets this run's sessions hold go with it, released or left to the next claim (whose attach
543
+ // opens its own): one left open would keep the process from exiting.
544
+ if ("browser" in made)
545
+ await closeHeldSockets(made.browser);
468
546
  }
469
547
  });
470
548
  return { tools, extensions: [extension] };
@@ -500,6 +578,14 @@ export const TOOLS = Object.freeze({
500
578
  "monid.discover": monidTool("discover"),
501
579
  "monid.inspect": monidTool("inspect"),
502
580
  "monid.run": monidTool("run"),
581
+ // A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
582
+ // (adapter-run-spec.ts), never by this table; not a host tool (host-tools.ts REPLAY), so another harness refuses it.
583
+ subagent: {
584
+ 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.",
585
+ needs: [],
586
+ nodes: false,
587
+ bind: async () => ({ tools: [], extensions: [] }),
588
+ },
503
589
  [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 })),
504
590
  [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) => {
505
591
  if (!run.complete)
@@ -514,28 +600,53 @@ export const CALL_TOOLS = Object.keys(TOOLS).filter((name) => TOOLS[name].effect
514
600
  /** Whether `name` is one of `allowed`. */
515
601
  export const allows = (allowed, name) => allowed.includes(name);
516
602
  /** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
517
- * agent's `granted` tools a workflow's call node runs here (CALL_TOOLS), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
603
+ * agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
604
+ * skills.ts LEARNED_MCP_TOOL: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
518
605
  * learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
519
606
  * exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
520
- export const learnedWorkflowTools = (granted, plane) => [...new Set(granted.filter((name) => allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name])))];
607
+ export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true && LEARNED_MCP_TOOL.test(name)) || (allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name]))))];
608
+ /** `granted` with each MCP server's wildcard (`mcp:<server>/*`) read as the tools its server lists now (`listed`, by the
609
+ * server's name: none for a server not saved), each `mcp:<server>/<tool>`, in place; every other name as it is, each
610
+ * once. What a revision grants under a wildcard is every tool of its server, so a learned draft may name each one
611
+ * (learnedWorkflowTools), its gate holding it as any tool (learnedDraftTools: the wildcard's setting, or the tool's own).
612
+ * At proposal time there is no run and no pin: whether the run's pin has the tool is the runtime's to check at the call,
613
+ * in the gate's words (learned-workflow.ts). */
614
+ export function mcpGrantsListed(granted, listed) {
615
+ const out = new Set();
616
+ for (const name of granted) {
617
+ const wildcard = /^mcp:([^/]+)\/\*$/.exec(name);
618
+ if (!wildcard)
619
+ out.add(name);
620
+ else
621
+ for (const tool of listed(wildcard[1]))
622
+ out.add(`mcp:${wildcard[1]}/${tool}`);
623
+ }
624
+ return [...out];
625
+ }
521
626
  /** The tools a learned draft may name (learnedWorkflowTools) that the gate allows: `permission` is what the gate holds a
522
627
  * tool to now (tool-gate.ts permissionOf, or the run's gate's policy), by its settings key. One set to ask or deny is left out of `tools`, so the end-of-run prompt never offers it, and named
523
628
  * in `gated` with its setting, which the checker and a learned workflow's check before it runs refuse a draft for. */
524
- export const learnedDraftTools = (granted, permission, plane, from) => {
629
+ export const learnedDraftTools = (granted, permission, plane, from, options = {}) => {
525
630
  const gated = {};
631
+ // The MCP tools offered because they ask: the ones a learned call's approval card names (#2424).
632
+ const asked = [];
526
633
  // Where each deny was set (this agent's settings or this server's), so the refusal names it.
527
634
  const deniedBy = {};
528
- const tools = learnedWorkflowTools(granted, plane).filter((name) => {
635
+ const tools = learnedWorkflowTools(granted, plane, options).filter((name) => {
529
636
  const setting = permission(name);
637
+ // An MCP tool set to ask is offered where someone can answer: its learned_workflow call asks once, naming its MCP
638
+ // tools, before any node runs (#2424). A table tool set to ask is not: its call node can't wait for an approval.
530
639
  if (setting === "allow")
531
640
  return true;
641
+ if (setting === "ask" && options.approvers === true && LEARNED_MCP_TOOL.test(name))
642
+ return (asked.push(name), true);
532
643
  gated[name] = setting;
533
644
  // A deny comes from a layer or the default, never from approvals, which only ever allows.
534
645
  if (setting === "deny" && from)
535
646
  deniedBy[name] = from(name);
536
647
  return false;
537
648
  });
538
- return { tools, gated, deniedBy };
649
+ return { tools, gated, deniedBy, asked };
539
650
  };
540
651
  /** The tools a workflow names (`nodes` from workflowNodes): on its model nodes (`tools`), and on its `call` nodes
541
652
  * `via: "tool"` (`tool`). */
@@ -574,22 +685,6 @@ export async function toolingOf(revision) {
574
685
  }
575
686
  /** The variables `entry` needs that `env` does not set, by name. */
576
687
  export const missingEnv = (entry, env) => entry.needs.filter((name) => !env[name]);
577
- /** What keeps `names` from being bound here: names outside the table (or, for a workflow's model nodes, that a node may
578
- * not name), and the variables each tool in it needs that `env` does not set. Undefined when nothing does. */
579
- export function toolRefusal(names, env, where = "agent") {
580
- const allowed = where === "nodes" ? NODE_TOOLS : where === "calls" ? CALL_TOOLS : BOUND_TOOLS;
581
- const unbound = names.filter((name) => !allows(allowed, name));
582
- if (unbound.length) {
583
- 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];
584
- return { message: `${said} ${allowed.join(", ")}; this ${where === "agent" ? "revision" : "workflow"} also ${where === "calls" ? "calls" : "names"} ${unbound.join(", ")}.`, unbound, missing: {} };
585
- }
586
- const missing = Object.fromEntries(names.map((name) => [name, missingEnv(toolOf(name), env)]).filter(([, vars]) => vars.length));
587
- const lacking = Object.entries(missing);
588
- if (!lacking.length)
589
- return undefined;
590
- const said = lacking.map(([name, vars]) => `The tool ${name} needs ${keyNeeded(vars)}.`).join(" ");
591
- return { message: `This server holds no key for what the revision's tools need. ${said}`, unbound: [], missing };
592
- }
593
688
  /** Every tool as capabilities show it, the server's one tool catalog: available here, or the variables it is missing
594
689
  * (names only), and the harnesses that run it (another harness than pi runs only the host tools, host-tools.ts). A tool
595
690
  * a user picks a provider for (tool-plane.ts) gives the providers offered, the server's (`provider`, the default where it
@@ -39,6 +39,7 @@ export declare const SIGNATURE_SCHEMES: {
39
39
  deliveryIdOf: (headers: Headers) => string;
40
40
  eventOf: (headers: Headers) => string;
41
41
  attrsOf(json: unknown): {
42
+ base_sha?: string | undefined;
42
43
  head_sha?: string | undefined;
43
44
  number?: string | undefined;
44
45
  };
@@ -53,16 +53,18 @@ export const SIGNATURE_SCHEMES = {
53
53
  deliveryIdOf: (headers) => headers["x-github-delivery"],
54
54
  eventOf: (headers) => headers["x-github-event"],
55
55
  // 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.
56
+ // and base shas, which a long description pushes past the payload's cut. A comment event has no head: none is guessed.
57
57
  attrsOf(json) {
58
58
  const doc = isObject(json) ? json : {};
59
59
  const pr = isObject(doc.pull_request) ? doc.pull_request : undefined;
60
60
  const issue = isObject(doc.issue) ? doc.issue : undefined;
61
61
  const number = pr?.number ?? issue?.number;
62
62
  const sha = isObject(pr?.head) ? pr.head.sha : undefined;
63
+ const base = isObject(pr?.base) ? pr.base.sha : undefined;
63
64
  return {
64
65
  ...(Number.isSafeInteger(number) && number > 0 ? { number: String(number) } : {}),
65
66
  ...(typeof sha === "string" && /^[0-9a-f]{40}$/.test(sha) ? { head_sha: sha } : {}),
67
+ ...(typeof base === "string" && /^[0-9a-f]{40}$/.test(base) ? { base_sha: base } : {}),
66
68
  };
67
69
  },
68
70
  },
@@ -55,7 +55,7 @@ export type TriggerFailed = {
55
55
  };
56
56
  auto_paused: boolean;
57
57
  };
58
- /** A run's provenance, kept in its serve.json: the trigger that started it, and the firing. `name`: the trigger's name as
58
+ /** A run's provenance, kept with its launch row: the trigger that started it, and the firing. `name`: the trigger's name as
59
59
  * it was at the firing, put on the run so its Timeline row names the trigger without a store read (runs.ts
60
60
  * servedTriggerRow); a rename pushes the new name (server.ts triggerChanged). */
61
61
  export type RunTrigger = {
@@ -454,10 +454,10 @@ export declare class Triggers {
454
454
  * check. */
455
455
  private given;
456
456
  /** A run's title, from the trigger that starts it: "<its source> <its name>" (the word its Timeline row begins with,
457
- * pi-durable-agent's TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
457
+ * TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
458
458
  * pull_request opened"); never its input, which may be a sender's markup. */
459
459
  private titleOf;
460
- /** Who a firing's input is from (pi-durable-agent's MessageOrigin): the trigger, by its definition as it fires, never
460
+ /** Who a firing's input is from (a MessageOrigin): the trigger, by its definition as it fires, never
461
461
  * by its payload. Only a source whose words are its owner's (a schedule's, fired on time or by hand) gives owner true;
462
462
  * a pushed source's come from outside, its body empty or not. */
463
463
  private originOf;
package/dist/triggers.js CHANGED
@@ -913,7 +913,7 @@ export class Triggers {
913
913
  return { ...target, input: this.inputOf(trigger, { by: "manual", nominalAt: now, payload: null }) };
914
914
  }
915
915
  /** A run's title, from the trigger that starts it: "<its source> <its name>" (the word its Timeline row begins with,
916
- * pi-durable-agent's TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
916
+ * TRIGGER_LABELS), and the event its payload's tag names, when one does ("Webhook reviews:
917
917
  * pull_request opened"); never its input, which may be a sender's markup. */
918
918
  titleOf(trigger, firing) {
919
919
  const source = TRIGGER_LABELS[trigger.source.kind] ?? trigger.source.kind;
@@ -922,7 +922,7 @@ export class Triggers {
922
922
  const action = attrs?.action;
923
923
  return `${source} ${trigger.name}${event ? `: ${event}${action ? ` ${action}` : ""}` : ""}`;
924
924
  }
925
- /** Who a firing's input is from (pi-durable-agent's MessageOrigin): the trigger, by its definition as it fires, never
925
+ /** Who a firing's input is from (a MessageOrigin): the trigger, by its definition as it fires, never
926
926
  * by its payload. Only a source whose words are its owner's (a schedule's, fired on time or by hand) gives owner true;
927
927
  * a pushed source's come from outside, its body empty or not. */
928
928
  originOf(trigger) {
@@ -7,9 +7,6 @@ export { TURN_END } from "./timeline/index.js";
7
7
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
8
8
  export declare const MESSAGE = "adapter.message";
9
9
  export declare const MESSAGE_END = "adapter.message_end";
10
- /** The root's marker of a paid request already written as a pi.assistant entry (`{ key, request, unpriced? }`, in the
11
- * entry's commit): `unpriced` when its cost was not in yet, which a REQUEST_COST_LATE naming it brings. */
12
- export declare const BOOKED = "adapter.request";
13
10
  /** What a turn's end says: the message it took (the MESSAGE id), the session's own outcome (`failed` too when the bridge
14
11
  * wrote the turn's error, in `error`), the entry of the turn's answer (its last request with text and no call; null
15
12
  * when the turn showed no text), and whether a request it made is still unbooked (its cost then comes later, as a
package/dist/turn-end.js CHANGED
@@ -10,9 +10,6 @@ export { TURN_END } from "./timeline/index.js";
10
10
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
11
11
  export const MESSAGE = "adapter.message";
12
12
  export const MESSAGE_END = "adapter.message_end";
13
- /** The root's marker of a paid request already written as a pi.assistant entry (`{ key, request, unpriced? }`, in the
14
- * entry's commit): `unpriced` when its cost was not in yet, which a REQUEST_COST_LATE naming it brings. */
15
- export const BOOKED = "adapter.request";
16
13
  /** The `api` of every assistant message serve's bridge writes for a claude-agent or codex request (harness-app.ts): its
17
14
  * stop reason says nothing of the turn's end (a cost, a cut, an interruption and an answer read alike). */
18
15
  export const ADAPTER_API = "agentrun-adapter";
package/dist/uploads.d.ts CHANGED
@@ -98,9 +98,32 @@ export declare class Uploads {
98
98
  /** A run's `file_ids`: each a file that is ready, none twice, at most MAX_FILES_PER_RUN, or 422 at `file_ids`. */
99
99
  readyFiles(ids: readonly unknown[]): Promise<UploadedFile[]>;
100
100
  /** Copies `files` into the run's `inputs/` through its Workspace, each at its `path` with its folders, in order, before
101
- * the run's process exists: a name taken already (the same path twice, a file where another's folder goes, or what
102
- * the folder held before) gets the next free suffix (`notes-2.txt`, `docs-2/`), the same for the same files in the
103
- * same order. Each copy is a new file written whole by the Workspace, never a link to the upload; a link on the way
104
- * fails the copy (ESCAPE), and nothing is written through it. The run's start still hands its folder's path. */
105
- copyInto(work: Workspace | string, files: readonly UploadedFile[]): Promise<void>;
101
+ * the run's first turn: a name taken already (the same path twice, a file where another's folder goes, or what the
102
+ * folder held before) gets the next free suffix (`notes-2.txt`, `docs-2/`), the same for the same files in the same
103
+ * order. Each copy is a new file written whole by the Workspace, never a link to the upload; a link on the way fails
104
+ * the copy (ESCAPE), and nothing is written through it. `bytesOf`: where each file's bytes are read (its upload's own,
105
+ * or the run's hold of them, `held`). */
106
+ copyInto(work: Workspace | string, files: readonly UploadedFile[], bytesOf?: (file: UploadedFile) => string): Promise<void>;
107
+ /** At a run's start, before its row is written: each of its files (`ids`, ready) held for it under
108
+ * `<root>/.held/<run id>/`, its record and its bytes (a hard link to the upload's, which never change once ready; a
109
+ * copy where the disk links none). The run's claim copies from the hold (heldFiles), so a file deleted after the start
110
+ * and before the claim is still the run's: a started run keeps the files it was started with. In turn with each file's
111
+ * delete, so a hold either has the bytes or the start fails at that file (422, as readyFiles words it). */
112
+ hold(runId: string, ids: readonly string[]): Promise<void>;
113
+ /** The files run `runId` holds (hold), in `ids`' order: a file with no hold (a run started before holds, or one whose
114
+ * hold went) read as it is now (readyFiles). With where each one's bytes are. */
115
+ heldFiles(runId: string, ids: readonly string[]): Promise<{
116
+ files: UploadedFile[];
117
+ bytesOf: (file: UploadedFile) => string;
118
+ }>;
119
+ /** Lets go of run `runId`'s hold: once its files are in its workspace, or when it ends without them (released). */
120
+ release(runId: string): Promise<void>;
121
+ /** The run ids that hold files here (hold), for a start's sweep of the holds of runs that ended. */
122
+ holders(): Promise<string[]>;
106
123
  }
124
+ /** The words a run fails in when its files cannot be copied into its workspace at its claim. */
125
+ export declare const notCopied: (why: string) => string;
126
+ /** At a run's claim: its uploaded files (`ids`, the launch's file_ids) copied into its work/inputs/ once, from its hold
127
+ * (Uploads.hold), and the hold let go. A resumed claim finds inputs/ there and copies nothing, so the copy's suffixes
128
+ * never duplicate a file across claims. A copy that fails throws in notCopied's words: the run ends failed, saying why. */
129
+ export declare function copyRunFiles(data: string, runId: string, workspace: Workspace, ids: readonly string[]): Promise<void>;