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

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 (399) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +155 -92
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/browser-cost.js +52 -93
  11. package/dist/cap.d.ts +0 -390
  12. package/dist/cap.js +4 -937
  13. package/dist/catalog.js +1 -1
  14. package/dist/composio-preset.d.ts +17 -0
  15. package/dist/composio-preset.js +43 -1
  16. package/dist/computer-calls.d.ts +36 -24
  17. package/dist/computer-calls.js +110 -27
  18. package/dist/computer-live.d.ts +5 -0
  19. package/dist/computer-live.js +12 -0
  20. package/dist/computer-setting.d.ts +15 -2
  21. package/dist/computer-setting.js +20 -4
  22. package/dist/computer-view.d.ts +3 -2
  23. package/dist/computer-view.js +5 -4
  24. package/dist/computer-viewer.js +26 -12
  25. package/dist/computers.d.ts +4 -1
  26. package/dist/computers.js +12 -6
  27. package/dist/console/assets/index-CjqQirbo.css +1 -0
  28. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  29. package/dist/console/index.html +2 -2
  30. package/dist/console-links.d.ts +2 -0
  31. package/dist/console-links.js +3 -0
  32. package/dist/decisions.js +4 -0
  33. package/dist/faux-computers.js +4 -2
  34. package/dist/harness-opencode/adapter.js +7 -3
  35. package/dist/harness-opencode/facts.js +0 -2
  36. package/dist/harness-opencode/host/policy.d.ts +2 -5
  37. package/dist/harness-opencode/host/policy.js +8 -32
  38. package/dist/harness-table.d.ts +0 -2
  39. package/dist/harness-table.js +0 -2
  40. package/dist/host-tools.d.ts +1 -5
  41. package/dist/host-tools.js +7 -10
  42. package/dist/hosted-search.d.ts +0 -2
  43. package/dist/hosted-search.js +0 -21
  44. package/dist/key-words.d.ts +3 -2
  45. package/dist/key-words.js +4 -2
  46. package/dist/learn/check.d.ts +6 -1
  47. package/dist/learn/check.js +12 -4
  48. package/dist/learn/commit.d.ts +10 -0
  49. package/dist/learn/commit.js +18 -4
  50. package/dist/learn/compile.d.ts +243 -0
  51. package/dist/learn/compile.js +471 -0
  52. package/dist/learn/general.d.ts +3 -0
  53. package/dist/learn/general.js +4 -2
  54. package/dist/learn/grade.d.ts +1 -1
  55. package/dist/learn/grade.js +7 -6
  56. package/dist/learn/notes.d.ts +8 -0
  57. package/dist/learn/notes.js +18 -0
  58. package/dist/learn/promote.d.ts +253 -0
  59. package/dist/learn/promote.js +428 -0
  60. package/dist/learn/refit.d.ts +39 -0
  61. package/dist/learn/refit.js +236 -0
  62. package/dist/learn/reflect.d.ts +5 -25
  63. package/dist/learn/reflect.js +14 -131
  64. package/dist/learn/replay-calls.d.ts +63 -0
  65. package/dist/learn/replay-calls.js +158 -0
  66. package/dist/learn/skills.d.ts +17 -9
  67. package/dist/learn/skills.js +132 -42
  68. package/dist/learn/workflow-nodes.d.ts +15 -0
  69. package/dist/learn/workflow-nodes.js +44 -0
  70. package/dist/learned-nodes.d.ts +50 -2
  71. package/dist/learned-nodes.js +41 -2
  72. package/dist/learned-workflow.d.ts +19 -3
  73. package/dist/learned-workflow.js +105 -26
  74. package/dist/learning-batch.d.ts +2 -2
  75. package/dist/learning-batch.js +1 -1
  76. package/dist/learning-cost.d.ts +18 -6
  77. package/dist/learning-cost.js +15 -7
  78. package/dist/learning-routes.d.ts +14 -2
  79. package/dist/learning-routes.js +14 -3
  80. package/dist/learning-words.d.ts +7 -0
  81. package/dist/learning-words.js +7 -0
  82. package/dist/learning.d.ts +31 -6
  83. package/dist/learning.js +7 -4
  84. package/dist/llm.js +0 -3
  85. package/dist/mcp-gateway.d.ts +12 -20
  86. package/dist/mcp-gateway.js +16 -44
  87. package/dist/mcp-oauth.d.ts +5 -0
  88. package/dist/mcp-oauth.js +1 -1
  89. package/dist/mcp-pin-first.d.ts +37 -0
  90. package/dist/mcp-pin-first.js +107 -0
  91. package/dist/mcp-probe.d.ts +8 -9
  92. package/dist/mcp-probe.js +16 -33
  93. package/dist/mcp-servers-store.d.ts +89 -22
  94. package/dist/mcp-servers-store.js +131 -25
  95. package/dist/mcp-sources.d.ts +39 -0
  96. package/dist/mcp-sources.js +74 -0
  97. package/dist/mcp-store.d.ts +11 -0
  98. package/dist/mcp-store.js +16 -2
  99. package/dist/mcp-wire.d.ts +22 -0
  100. package/dist/mcp-wire.js +36 -0
  101. package/dist/mcp.js +3 -3
  102. package/dist/meta-tool-names.d.ts +1 -0
  103. package/dist/meta-tool-names.js +3 -0
  104. package/dist/model.d.ts +13 -0
  105. package/dist/model.js +46 -15
  106. package/dist/monid.d.ts +51 -25
  107. package/dist/monid.js +226 -140
  108. package/dist/openapi.js +336 -66
  109. package/dist/paid-calls.d.ts +26 -29
  110. package/dist/paid-calls.js +46 -102
  111. package/dist/propose.d.ts +7 -1
  112. package/dist/propose.js +18 -6
  113. package/dist/provider.js +9 -2
  114. package/dist/reflect-range.js +2 -1
  115. package/dist/rows.d.ts +5 -3
  116. package/dist/rows.js +15 -4
  117. package/dist/run-launch.d.ts +13 -0
  118. package/dist/run-launch.js +6 -0
  119. package/dist/run-learning-served.d.ts +13 -2
  120. package/dist/run-manifest.d.ts +5 -0
  121. package/dist/run-manifest.js +20 -0
  122. package/dist/run-secrets.js +2 -3
  123. package/dist/run-timeline-served.js +5 -2
  124. package/dist/run-view.d.ts +17 -6
  125. package/dist/run-view.js +51 -22
  126. package/dist/runnable.d.ts +0 -3
  127. package/dist/runnable.js +37 -29
  128. package/dist/runner/adapter-loop.d.ts +24 -10
  129. package/dist/runner/adapter-loop.js +852 -314
  130. package/dist/runner/adapter-run-spec.d.ts +12 -6
  131. package/dist/runner/adapter-run-spec.js +97 -46
  132. package/dist/runner/adapters/pi-computer.d.ts +3 -1
  133. package/dist/runner/adapters/pi-computer.js +13 -5
  134. package/dist/runner/adapters/pi.d.ts +16 -7
  135. package/dist/runner/adapters/pi.js +94 -33
  136. package/dist/runner/cli-run-spec.js +67 -27
  137. package/dist/runner/computer-channel.js +2 -1
  138. package/dist/runner/conformance/harness.d.ts +3 -0
  139. package/dist/runner/conformance/harness.js +145 -4
  140. package/dist/runner/conformance/subject.d.ts +11 -4
  141. package/dist/runner/end-of-run.d.ts +6 -5
  142. package/dist/runner/end-of-run.js +9 -6
  143. package/dist/runner/feedback-round.d.ts +52 -0
  144. package/dist/runner/feedback-round.js +79 -0
  145. package/dist/runner/journal-kinds.d.ts +24 -6
  146. package/dist/runner/journal-kinds.js +15 -0
  147. package/dist/runner/learning-end.d.ts +54 -19
  148. package/dist/runner/learning-end.js +272 -99
  149. package/dist/runner/learning-loop.d.ts +19 -1
  150. package/dist/runner/learning-loop.js +5 -2
  151. package/dist/runner/learning-seed.d.ts +4 -0
  152. package/dist/runner/learning-seed.js +14 -0
  153. package/dist/runner/loop-contract.d.ts +19 -3
  154. package/dist/runner/loop.d.ts +16 -1
  155. package/dist/runner/loop.js +21 -1
  156. package/dist/runner/mcp-claim.d.ts +5 -1
  157. package/dist/runner/mcp-claim.js +66 -50
  158. package/dist/runner/mcp-run.d.ts +16 -52
  159. package/dist/runner/mcp-run.js +12 -84
  160. package/dist/runner/meta-tools.d.ts +37 -0
  161. package/dist/runner/meta-tools.js +268 -0
  162. package/dist/runner/metrics.js +14 -3
  163. package/dist/runner/model-route.js +12 -3
  164. package/dist/runner/monid-run.d.ts +16 -0
  165. package/dist/runner/monid-run.js +96 -0
  166. package/dist/runner/promotion.d.ts +80 -0
  167. package/dist/runner/promotion.js +562 -0
  168. package/dist/runner/reflect-hook.d.ts +36 -21
  169. package/dist/runner/reflect-hook.js +138 -49
  170. package/dist/runner/runner.js +26 -4
  171. package/dist/runner/sessions.d.ts +8 -3
  172. package/dist/runner/sessions.js +5 -1
  173. package/dist/runner/step-guard.d.ts +62 -0
  174. package/dist/runner/step-guard.js +93 -0
  175. package/dist/runner/subagent.d.ts +0 -3
  176. package/dist/runner/subagent.js +7 -12
  177. package/dist/runner/workflow-first.d.ts +216 -0
  178. package/dist/runner/workflow-first.js +303 -0
  179. package/dist/runner/workflow-loop.js +17 -10
  180. package/dist/runner/workflow-spec.d.ts +1 -0
  181. package/dist/runner/workflow-spec.js +7 -3
  182. package/dist/runs-over-store.d.ts +11 -2
  183. package/dist/runs-over-store.js +21 -11
  184. package/dist/server.d.ts +88 -16
  185. package/dist/server.js +380 -87
  186. package/dist/settings-wake.d.ts +8 -6
  187. package/dist/settings-wake.js +13 -7
  188. package/dist/store/agent-body.d.ts +14 -3
  189. package/dist/store/agent-body.js +14 -10
  190. package/dist/store/command-wake.d.ts +3 -2
  191. package/dist/store/command-wake.js +4 -4
  192. package/dist/store/postgres/connection.js +3 -1
  193. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  194. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  195. package/dist/store/schema.d.ts +9 -0
  196. package/dist/store/schema.js +28 -8
  197. package/dist/store/sqlite/connection.d.ts +2 -2
  198. package/dist/store/sqlite/connection.js +2 -2
  199. package/dist/store/sqlite/run-patch.js +19 -7
  200. package/dist/store/sqlite/store.js +59 -18
  201. package/dist/store/store.d.ts +46 -14
  202. package/dist/store-reads/journal.d.ts +25 -1
  203. package/dist/store-reads/journal.js +63 -49
  204. package/dist/store-reads/learning.d.ts +101 -15
  205. package/dist/store-reads/learning.js +195 -61
  206. package/dist/store-reads/loop.d.ts +61 -0
  207. package/dist/store-reads/loop.js +111 -0
  208. package/dist/store-view.d.ts +3 -2
  209. package/dist/store-view.js +35 -17
  210. package/dist/template-eval.d.ts +18 -9
  211. package/dist/template-eval.js +91 -66
  212. package/dist/template-github-permissions.d.ts +2 -2
  213. package/dist/template-github-permissions.js +2 -1
  214. package/dist/template-import.d.ts +31 -0
  215. package/dist/template-import.js +121 -0
  216. package/dist/template-source.d.ts +51 -0
  217. package/dist/template-source.js +371 -0
  218. package/dist/templates.d.ts +218 -46
  219. package/dist/templates.js +493 -181
  220. package/dist/timeline/computer.d.ts +48 -0
  221. package/dist/timeline/computer.js +169 -0
  222. package/dist/timeline/index.d.ts +4 -3
  223. package/dist/timeline/index.js +4 -3
  224. package/dist/timeline/labels.d.ts +6 -2
  225. package/dist/timeline/labels.js +93 -2
  226. package/dist/timeline/origin.d.ts +19 -5
  227. package/dist/timeline/origin.js +11 -4
  228. package/dist/timeline/timeline.d.ts +11 -17
  229. package/dist/timeline/timeline.js +24 -9
  230. package/dist/tool-gate.d.ts +73 -46
  231. package/dist/tool-gate.js +133 -66
  232. package/dist/tool-keys.d.ts +4 -1
  233. package/dist/tool-keys.js +8 -3
  234. package/dist/tool-list.d.ts +26 -0
  235. package/dist/tool-list.js +43 -0
  236. package/dist/tool-names.d.ts +71 -0
  237. package/dist/tool-names.js +99 -0
  238. package/dist/tool-plane.d.ts +29 -27
  239. package/dist/tool-plane.js +65 -37
  240. package/dist/tools.d.ts +22 -6
  241. package/dist/tools.js +24 -20
  242. package/dist/validate.d.ts +15 -7
  243. package/dist/validate.js +91 -44
  244. package/dist/web-fetch.d.ts +1 -7
  245. package/dist/web-fetch.js +2 -22
  246. package/dist/workspace/computer-deps.d.ts +3 -0
  247. package/dist/workspace/computer-deps.js +5 -2
  248. package/dist/workspace/computer-for-claim.d.ts +6 -0
  249. package/dist/workspace/computer-for-claim.js +32 -14
  250. package/dist/workspace/computer-hold.js +7 -1
  251. package/dist/workspace/computer-script.d.ts +23 -7
  252. package/dist/workspace/computer-script.js +48 -14
  253. package/dist/workspace/index.d.ts +2 -2
  254. package/dist/workspace/index.js +1 -1
  255. package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
  256. package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
  257. package/dist/workspace/local.js +2 -2
  258. package/dist/workspace/resolve-computer.d.ts +21 -1
  259. package/dist/workspace/resolve-computer.js +32 -14
  260. package/dist/workspace/run-tools.d.ts +28 -10
  261. package/dist/workspace/run-tools.js +39 -11
  262. package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
  263. package/dist/wrap-up.js +21 -0
  264. package/launcher/agentrun-serve +4 -2
  265. package/package.json +9 -9
  266. package/templates/README.md +111 -45
  267. package/templates/code-review/agent.md +30 -14
  268. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  269. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  270. package/templates/code-review/evals/injection/case.yaml +2 -1
  271. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  272. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  273. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  274. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  275. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  276. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  277. package/templates/code-review/evals/null-name/case.yaml +2 -1
  278. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  279. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  280. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  281. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  282. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  283. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  284. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  285. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  286. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  287. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  288. package/templates/code-review/evals/re-review/case.yaml +2 -1
  289. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  290. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  291. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  292. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  293. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  294. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  295. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  296. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  297. package/templates/code-review/skills/review/DEEP.md +3 -2
  298. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  299. package/templates/code-review/skills/review/SKILL.md +4 -3
  300. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  301. package/templates/inbound-lead/agent.md +26 -16
  302. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  303. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  304. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  305. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  306. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  307. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  308. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  309. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  310. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  311. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  312. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  313. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  314. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  315. package/templates/kyb/agent.md +15 -5
  316. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  317. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  318. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  319. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  320. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  321. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  322. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  323. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  324. package/templates/kyb/kyb.schema.json +8 -7
  325. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  326. package/templates/market-monitor/agent.md +19 -12
  327. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  328. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  329. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  330. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  331. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  332. package/templates/release-notes/agent.md +32 -10
  333. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  334. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  335. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  336. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  337. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  338. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  339. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  340. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  341. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  342. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  343. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  344. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  345. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  346. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  347. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  348. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  349. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  350. package/templates/release-notes/notes.schema.json +1 -1
  351. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  352. package/dist/console/assets/index-Cn6JX1uH.js +0 -563
  353. package/dist/console/assets/index-DRN62V5v.css +0 -1
  354. package/dist/tool-blurbs.d.ts +0 -4
  355. package/dist/tool-blurbs.js +0 -28
  356. package/dist/tool-budget.js +0 -62
  357. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  358. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  359. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  360. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  361. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  362. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  363. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  364. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  365. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  366. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  367. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  368. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  369. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  370. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  371. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  372. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  373. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  374. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  375. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  376. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  377. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  378. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  379. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  380. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  381. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  382. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  383. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  384. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  385. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  386. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  387. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  388. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  389. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  390. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  391. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  392. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  393. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  394. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  395. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  396. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  397. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  398. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  399. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/catalog.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // The tool catalog's names, and the one mapping between a catalog name and the wire name a harness calls. A catalog name
2
- // is what a revision writes (`read`, later `monid.discover`, `mcp:<server>/<tool>`); the wire name is what a CLI adapter
2
+ // is what a revision writes (`read`, `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`); the wire name is what a CLI adapter
3
3
  // registers and the model API sees, and both adapters refuse anything outside /^[A-Za-z0-9_-]{1,64}$/. The map is one
4
4
  // deterministic function here, never in an adapter, so every harness gets the same wire name; the journal records the
5
5
  // wire name (recovery matches a call by it), and a reader maps it back to the catalog name by a lookup, never a parse.
@@ -29,8 +29,25 @@ export declare function composioSave<T extends {
29
29
  type: "headers";
30
30
  headers: Record<string, string>;
31
31
  };
32
+ }, made: {
33
+ source: "composio";
34
+ toolkit: string | null;
32
35
  }) => Promise<T>, name: string, signal?: AbortSignal, savedUrl?: () => Promise<string | undefined>): Promise<{
33
36
  server: T;
34
37
  connect_url?: string;
35
38
  not_served?: string[];
36
39
  }>;
40
+ /** The Composio MCP server a saved preset address names (`/v3/mcp/<id>/mcp`, composioAddress): its id, or undefined. */
41
+ export declare const composioServerId: (address: string) => string | undefined;
42
+ /** What the answer to a delete says when the Composio MCP server could not be removed: where to remove it by hand. */
43
+ export declare const composioNote: (name: string) => {
44
+ removed: false;
45
+ note: string;
46
+ };
47
+ /** Deleting a preset server: the Composio MCP server `id` it made is deleted as `key` (the saved credential, held for this
48
+ * call only). Composio's 404 is "already gone"; a refusal, or no answer, is `removed: false` with what to do by hand, for
49
+ * the delete of our own row to go on regardless. */
50
+ export declare function composioForget(control: ComposioControl, key: string, id: string, name: string, signal?: AbortSignal): Promise<{
51
+ removed: boolean;
52
+ note?: string;
53
+ }>;
@@ -7,6 +7,7 @@
7
7
  // is never logged, echoed or put in an error.
8
8
  import { randomBytes } from "node:crypto";
9
9
  import { ApiError, invalid } from "./errors.js";
10
+ import { MCP_SERVER_NAME } from "./tool-names.js";
10
11
  import { isObject } from "./validate.js";
11
12
  const BASE = "https://backend.composio.dev";
12
13
  /** The one Composio user a server's actions run as, unless the owner names another. */
@@ -47,6 +48,9 @@ function asking(control, key, signal) {
47
48
  if (res.ok) {
48
49
  if (isObject(json))
49
50
  return json;
51
+ // A delete may answer nothing at all.
52
+ if (!raw.trim())
53
+ return {};
50
54
  throw new ApiError("upstream_failed", `Composio's answer while ${step} was not JSON: nothing was saved.`);
51
55
  }
52
56
  const said = isObject(json) && isObject(json.error) ? text(json.error.message) : isObject(json) ? text(json.message) : "";
@@ -163,7 +167,16 @@ export async function composioSave(body, control, save, name, signal, savedUrl)
163
167
  }
164
168
  }
165
169
  url = composioAddress(address);
166
- const server = await save({ url, auth: { type: "headers", headers: { "x-api-key": key } } });
170
+ // Saved as what it is, a Composio server of this toolkit: a template that needs the toolkit maps to it, whatever its
171
+ // name. A slug no template can name (mcp:<toolkit>/<tool>: no `_`) is saved as a Composio server of no toolkit.
172
+ // Composio leaves out an action it does not serve, and a server that serves none of the picked ones lists no tools at
173
+ // all: its MCP answers the listing "Method not found" (JSON-RPC -32601). Only that answer says "none served", in words
174
+ // naming the picked actions; any other failure (no DNS, a timeout, an HTTP 500) stays the 424 it is.
175
+ const server = await save({ url, auth: { type: "headers", headers: { "x-api-key": key } } }, { source: "composio", toolkit: MCP_SERVER_NAME.test(toolkit) ? toolkit : null }).catch((error) => {
176
+ if (!(error instanceof ApiError) || error.code !== "upstream_failed" || error.extra.details?.rpc_code !== METHOD_NOT_FOUND)
177
+ throw error;
178
+ throw invalid([issue("tools", "not_served", `Composio's ${toolkit} server doesn't serve ${tools.join(", ")}: pick another action.`)]);
179
+ });
167
180
  // Composio's server can leave out an action it was allowed (HACKERNEWS_GET_FRONTPAGE, live 11-13): say which, so a grant
168
181
  // doesn't vanish without a word. A toolkit with no account yet still lists its actions, so this holds before the connect.
169
182
  const listed = new Set((server.tools ?? []).map((tool) => tool.name));
@@ -177,3 +190,32 @@ export async function composioSave(body, control, save, name, signal, savedUrl)
177
190
  throw error;
178
191
  }
179
192
  }
193
+ /** JSON-RPC's "Method not found": what a Composio MCP server with none of the picked actions answers a tool listing. */
194
+ const METHOD_NOT_FOUND = -32601;
195
+ /** Where the owner removes a Composio MCP server by hand, said when this server could not. */
196
+ const DASHBOARD = "https://platform.composio.dev";
197
+ /** The Composio MCP server a saved preset address names (`/v3/mcp/<id>/mcp`, composioAddress): its id, or undefined. */
198
+ export const composioServerId = (address) => {
199
+ try {
200
+ return /^\/v3\/mcp\/([^/]+)\/mcp$/.exec(new URL(address).pathname)?.[1];
201
+ }
202
+ catch {
203
+ return undefined;
204
+ }
205
+ };
206
+ /** What the answer to a delete says when the Composio MCP server could not be removed: where to remove it by hand. */
207
+ export const composioNote = (name) => ({ removed: false, note: `Remove ${name} in Composio yourself: ${DASHBOARD}` });
208
+ /** Deleting a preset server: the Composio MCP server `id` it made is deleted as `key` (the saved credential, held for this
209
+ * call only). Composio's 404 is "already gone"; a refusal, or no answer, is `removed: false` with what to do by hand, for
210
+ * the delete of our own row to go on regardless. */
211
+ export async function composioForget(control, key, id, name, signal) {
212
+ try {
213
+ await asking(control, key, signal)("deleting the MCP server it made", "DELETE", `/api/v3.1/mcp/${encodeURIComponent(id)}`, undefined, "gone");
214
+ return { removed: true };
215
+ }
216
+ catch (error) {
217
+ if (error instanceof ApiError && error.extra.fields?.[0]?.reason === "not_found")
218
+ return { removed: true };
219
+ return composioNote(name);
220
+ }
221
+ }
@@ -1,24 +1,16 @@
1
1
  import type { ComputerClient } from "@parcha/agentrun-computer";
2
- /** One step of a ui.act call: its kind (press, set, click, type, key, ...), and how it ran (its route, and whether a
3
- * readback showed it took) or the kind of error that refused it. */
4
- export type ComputerStepRecord = {
5
- readonly do: string;
6
- readonly route?: string;
7
- readonly verified?: boolean;
8
- readonly error?: string;
9
- };
10
- /** One computer call, as a run's record keeps it. */
11
- export type ComputerCallRecord = {
12
- readonly method: string;
13
- readonly ok: boolean;
14
- readonly ms: number;
15
- /** The error's code, when the call failed. */
16
- readonly code?: string;
17
- /** ui.act: its steps, in order. */
18
- readonly steps?: readonly ComputerStepRecord[];
19
- /** ui.act: whether its expect held. */
20
- readonly expect?: "met" | "unmet";
21
- };
2
+ import { type ComputerCallRow, type ComputerStepRow } from "./timeline/computer.js";
3
+ /** The element a step acted on, as the run's ui.observe answers named it: its role, and its name when it has one. */
4
+ export type ComputerTarget = NonNullable<ComputerStepRow["on"]>;
5
+ /** One step of a ui.act call: its kind (press, set, click, type, key, ...), what it acted on (`on`, a key step's `keys`,
6
+ * a nav step's `nav`), and how it ran (its route, and whether a readback showed it took) or the kind of error that
7
+ * refused it. */
8
+ export type ComputerStepRecord = ComputerStepRow;
9
+ /** One computer call, as a run's record keeps it: its method, when it started (`started_at`, ISO, so a reader places each
10
+ * call of a tool call on the run's own clock), the app it named (apps.launch's and apps.terminate's id, a ui call's
11
+ * target app; for a ui.observe that named none, the app its answer showed), whether it answered and in how long, the error's code when it failed, and a ui.act's steps and whether
12
+ * its expect held. */
13
+ export type ComputerCallRecord = ComputerCallRow;
22
14
  /** The most calls one tool call's record keeps (a code-mode script may make many); past it, `dropped` counts the rest. */
23
15
  export declare const MAX_RECORDED_CALLS = 200;
24
16
  /** The journal entry kind of one tool call's computer calls, kept beside the call on the run's root: `{ call, calls,
@@ -33,9 +25,28 @@ export declare function computerCallsOf(entries: readonly {
33
25
  readonly calls: readonly ComputerCallRecord[];
34
26
  readonly dropped: number;
35
27
  }>;
36
- /** The record of a call of `method` with `params` that answered `answer` (`{ ok, value }` or `{ ok: false, error }`)
37
- * after `ms`. Reads the params only for a ui.act's step kinds; keeps none of their values. */
38
- export declare function callRecordOf(method: string, params: unknown, answer: unknown, ms: number): ComputerCallRecord;
28
+ /** The longest element name a row shows: past it, cut with "…" (shownName), after the run's redaction read it whole. */
29
+ export declare const MAX_TARGET_NAME = 60;
30
+ /** The longest element name a record keeps, whole. A longer one (no control's name on a screen is that long) is kept as
31
+ * no name at all: a part of it could hold part of a secret the redaction no longer recognizes. */
32
+ export declare const MAX_KEPT_NAME = 1000;
33
+ /** An element's name as a row shows it: through the run's redaction whole, then cut at MAX_TARGET_NAME. Cut first, a
34
+ * held secret across the cut would show its first part. */
35
+ export declare function shownName(name: string, redact?: (text: string) => string): string;
36
+ /** What a ui.act step's ref names, as the run's ui.observe answers showed it. */
37
+ export type TargetNames = (ref: string) => ComputerTarget | undefined;
38
+ /** The record of a call of `method` with `params`, started at `startedAt` (ms since the epoch), that answered `answer`
39
+ * (`{ ok, value }` or `{ ok: false, error }`) after `ms`. Reads the params only for the app they name and a ui.act's
40
+ * steps (each step's element by `names`); keeps no typed or set value. */
41
+ export declare function callRecordOf(method: string, params: unknown, answer: unknown, ms: number, startedAt: number, names?: TargetNames): ComputerCallRecord;
42
+ /** The names a client's ui.observe answers gave each ref: role and name (never a value), the name whole up to
43
+ * MAX_KEPT_NAME (the row cuts it, after the redaction: shownName).
44
+ * Each observe's nodes are learned again (a ref's element keeps its ref across states, so its newest name wins). */
45
+ export declare class RefNames {
46
+ #private;
47
+ learn(answer: unknown): void;
48
+ readonly of: TargetNames;
49
+ }
39
50
  /** Runs `work` with every call a recordedClient makes inside it recorded, in the order the calls were made, and hands
40
51
  * the records (with how many past MAX_RECORDED_CALLS were dropped) to `keep` once it settled, thrown or not, when it
41
52
  * made any. `keep` is waited for and never fails the work. A scope inside another records into the inner one only. */
@@ -44,5 +55,6 @@ export declare function recordingCalls<T>(work: () => Promise<T>, keep: (calls:
44
55
  * channel, which the runner writes a record of its own for). */
45
56
  export declare function unrecorded<T>(work: () => T): T;
46
57
  /** `client`, with each call made inside a recordingCalls scope recorded there when it settles. A call outside any scope
47
- * (the owner's, through the channel, or the runner's own) is recorded nowhere and costs nothing more. */
58
+ * (the owner's, through the channel, or the runner's own) is recorded nowhere; its ui.observe answer still names the
59
+ * refs a later recorded step acts on. */
48
60
  export declare function recordedClient(client: ComputerClient): ComputerClient;
@@ -1,12 +1,18 @@
1
- // A computer protocol call as a run's record keeps it: its method, whether it answered, how long it took, its error's
2
- // code, and for ui.act each step's kind, the route it ran by and whether a readback showed it took. Never a param's value
3
- // and never an answer's bytes: no screenshot is in it, and no text a step set or typed (a secure field's included).
1
+ // A computer protocol call as a run's record keeps it: its method, when it started, whether it answered, how long it
2
+ // took, its error's code, the app it named, and for ui.act each step's kind, what it acted on as a person reads it, the
3
+ // route it ran by and whether a readback showed it took. Never a typed or set value and never an answer's bytes: no
4
+ // screenshot is in it, and no text a step set or typed (a secure field's included). What a step acted on is the element's
5
+ // role and name as the run's own ui.observe answers showed them (the words on the screen, never a field's value), a key
6
+ // step's chord (one with a modifier, or a named key: never a lone character, which may be a password's), a nav step's
7
+ // place.
4
8
  //
5
9
  // The record has two homes. The owner's calls (the computer call channel, computer-channel.ts) are `computer.call`
6
10
  // entries on the run's journal. The agent's calls are the `computer_calls` of the tool call that made them, on its
7
- // tool_result row (timeline/timeline.ts): the adapter loop runs each tool call inside recordingCalls, and the run's
8
- // computer client (recordedClient, made at the claim) records each call made inside one.
11
+ // tool_result row (timeline/timeline.ts): the adapter loop runs each tool call inside recordingCalls (a pi-native tool's,
12
+ // code mode's among them, through the session's io: pi.ts), and the run's computer client (recordedClient, made at the
13
+ // claim) records each call made inside one.
9
14
  import { AsyncLocalStorage } from "node:async_hooks";
15
+ import { stepOf } from "./timeline/computer.js";
10
16
  /** The most calls one tool call's record keeps (a code-mode script may make many); past it, `dropped` counts the rest. */
11
17
  export const MAX_RECORDED_CALLS = 200;
12
18
  /** The journal entry kind of one tool call's computer calls, kept beside the call on the run's root: `{ call, calls,
@@ -18,14 +24,25 @@ function recordOf(value) {
18
24
  const one = obj(value);
19
25
  if (!one || typeof one.method !== "string" || typeof one.ok !== "boolean" || typeof one.ms !== "number")
20
26
  return undefined;
27
+ if (typeof one.started_at !== "string")
28
+ return undefined;
21
29
  const steps = Array.isArray(one.steps) ? one.steps.flatMap((step) => {
22
30
  const s = obj(step);
23
31
  if (!s || typeof s.do !== "string")
24
32
  return [];
25
- return [{ do: s.do, ...(typeof s.route === "string" ? { route: s.route } : {}), ...(typeof s.verified === "boolean" ? { verified: s.verified } : {}), ...(typeof s.error === "string" ? { error: s.error } : {}) }];
33
+ const on = targetOf(s.on);
34
+ return [{
35
+ do: s.do,
36
+ ...(on ? { on } : {}),
37
+ ...(typeof s.keys === "string" ? { keys: s.keys } : {}),
38
+ ...(typeof s.nav === "string" ? { nav: s.nav } : {}),
39
+ ...(typeof s.route === "string" ? { route: s.route } : {}),
40
+ ...(typeof s.verified === "boolean" ? { verified: s.verified } : {}),
41
+ ...(typeof s.error === "string" ? { error: s.error } : {}),
42
+ }];
26
43
  }) : undefined;
27
44
  return {
28
- method: one.method, ok: one.ok, ms: one.ms,
45
+ method: one.method, started_at: one.started_at, ...(typeof one.app === "string" ? { app: one.app } : {}), ok: one.ok, ms: one.ms,
29
46
  ...(typeof one.code === "string" ? { code: one.code } : {}),
30
47
  ...(steps ? { steps } : {}),
31
48
  ...(one.expect === "met" || one.expect === "unmet" ? { expect: one.expect } : {}),
@@ -46,24 +63,50 @@ export function computerCallsOf(entries) {
46
63
  }
47
64
  return out;
48
65
  }
49
- /** The step kinds a ui.act step may name (the protocol's UiStep keys). */
50
- const STEP_KINDS = ["press", "set", "perform", "click", "type", "key", "nav", "scroll", "drag"];
51
- /** A ui.act step's record: its kind from its params, how it ran from its result. */
52
- function stepRecord(step, result) {
53
- const given = obj(step) ?? {};
54
- const kind = STEP_KINDS.find((name) => name in given) ?? "step";
66
+ /** A ComputerTarget as an entry kept it. */
67
+ function targetOf(value) {
68
+ const one = obj(value);
69
+ if (!one || typeof one.role !== "string")
70
+ return undefined;
71
+ return { role: one.role, ...(typeof one.name === "string" ? { name: one.name } : {}) };
72
+ }
73
+ /** The longest element name a row shows: past it, cut with "…" (shownName), after the run's redaction read it whole. */
74
+ export const MAX_TARGET_NAME = 60;
75
+ /** The longest element name a record keeps, whole. A longer one (no control's name on a screen is that long) is kept as
76
+ * no name at all: a part of it could hold part of a secret the redaction no longer recognizes. */
77
+ export const MAX_KEPT_NAME = 1000;
78
+ /** An element's name as a row shows it: through the run's redaction whole, then cut at MAX_TARGET_NAME. Cut first, a
79
+ * held secret across the cut would show its first part. */
80
+ export function shownName(name, redact) {
81
+ const said = redact ? redact(name) : name;
82
+ return said.length > MAX_TARGET_NAME ? `${said.slice(0, MAX_TARGET_NAME - 1)}…` : said;
83
+ }
84
+ /** A ui.act step's record: what it acted on from its params (stepOf, the element by `names`), how it ran from its
85
+ * result. */
86
+ function stepRecord(step, result, names) {
87
+ const what = stepOf(step, names);
55
88
  const ran = obj(result);
56
89
  const error = obj(ran?.error);
57
90
  if (error)
58
- return { do: kind, error: typeof error.kind === "string" ? error.kind : "error" };
59
- return { do: kind, ...(typeof ran?.route === "string" ? { route: ran.route } : {}), ...(typeof ran?.verified === "boolean" ? { verified: ran.verified } : {}) };
91
+ return { ...what, error: typeof error.kind === "string" ? error.kind : "error" };
92
+ return { ...what, ...(typeof ran?.route === "string" ? { route: ran.route } : {}), ...(typeof ran?.verified === "boolean" ? { verified: ran.verified } : {}) };
93
+ }
94
+ /** The app a call of `method` names: apps.launch's and apps.terminate's id, a ui call's target app. */
95
+ function appOf(method, params) {
96
+ const given = obj(params);
97
+ const app = method.startsWith("apps.") ? given?.id : method.startsWith("ui.") ? obj(given?.target)?.app : undefined;
98
+ return typeof app === "string" && app ? app : undefined;
60
99
  }
61
- /** The record of a call of `method` with `params` that answered `answer` (`{ ok, value }` or `{ ok: false, error }`)
62
- * after `ms`. Reads the params only for a ui.act's step kinds; keeps none of their values. */
63
- export function callRecordOf(method, params, answer, ms) {
100
+ /** The record of a call of `method` with `params`, started at `startedAt` (ms since the epoch), that answered `answer`
101
+ * (`{ ok, value }` or `{ ok: false, error }`) after `ms`. Reads the params only for the app they name and a ui.act's
102
+ * steps (each step's element by `names`); keeps no typed or set value. */
103
+ export function callRecordOf(method, params, answer, ms, startedAt, names = () => undefined) {
64
104
  const said = obj(answer);
65
105
  const ok = said?.ok === true;
66
- const base = { method, ok, ms: Math.max(0, Math.round(ms)) };
106
+ // A look that names no app looks at the one in front: the answer names it.
107
+ const shown = method === "ui.observe" && ok ? obj(obj(said?.value)?.app)?.id : undefined;
108
+ const app = appOf(method, params) ?? (typeof shown === "string" && shown ? shown : undefined);
109
+ const base = { method, started_at: new Date(startedAt).toISOString(), ...(app ? { app } : {}), ok, ms: Math.max(0, Math.round(ms)) };
67
110
  if (!ok) {
68
111
  const code = obj(said?.error)?.code;
69
112
  return { ...base, code: typeof code === "string" ? code : "error" };
@@ -75,10 +118,37 @@ export function callRecordOf(method, params, answer, ms) {
75
118
  const asked = Array.isArray(obj(params)?.steps) ? obj(params).steps : [];
76
119
  return {
77
120
  ...base,
78
- steps: results.map((result, index) => stepRecord(asked[index], result)),
121
+ steps: results.map((result, index) => stepRecord(asked[index], result, names)),
79
122
  ...(value?.expect === "met" || value?.expect === "unmet" ? { expect: value.expect } : {}),
80
123
  };
81
124
  }
125
+ /** The most refs a client keeps the names of: past it, the ones learned first go. */
126
+ const MAX_NAMED_REFS = 10_000;
127
+ /** The names a client's ui.observe answers gave each ref: role and name (never a value), the name whole up to
128
+ * MAX_KEPT_NAME (the row cuts it, after the redaction: shownName).
129
+ * Each observe's nodes are learned again (a ref's element keeps its ref across states, so its newest name wins). */
130
+ export class RefNames {
131
+ #byRef = new Map();
132
+ learn(answer) {
133
+ const nodes = obj(obj(answer)?.value)?.nodes;
134
+ if (!Array.isArray(nodes))
135
+ return;
136
+ for (const node of nodes) {
137
+ const one = obj(node);
138
+ if (typeof one?.ref !== "string" || typeof one.role !== "string")
139
+ continue;
140
+ const name = typeof one.name === "string" ? one.name.replace(/\s+/g, " ").trim() : "";
141
+ this.#byRef.delete(one.ref);
142
+ this.#byRef.set(one.ref, { role: one.role, ...(name && name.length <= MAX_KEPT_NAME ? { name } : {}) });
143
+ }
144
+ for (const ref of this.#byRef.keys()) {
145
+ if (this.#byRef.size <= MAX_NAMED_REFS)
146
+ break;
147
+ this.#byRef.delete(ref);
148
+ }
149
+ }
150
+ of = (ref) => this.#byRef.get(ref);
151
+ }
82
152
  const scope = new AsyncLocalStorage();
83
153
  /** Runs `work` with every call a recordedClient makes inside it recorded, in the order the calls were made, and hands
84
154
  * the records (with how many past MAX_RECORDED_CALLS were dropped) to `keep` once it settled, thrown or not, when it
@@ -99,26 +169,39 @@ export function unrecorded(work) {
99
169
  return scope.exit(work);
100
170
  }
101
171
  /** `client`, with each call made inside a recordingCalls scope recorded there when it settles. A call outside any scope
102
- * (the owner's, through the channel, or the runner's own) is recorded nowhere and costs nothing more. */
172
+ * (the owner's, through the channel, or the runner's own) is recorded nowhere; its ui.observe answer still names the
173
+ * refs a later recorded step acts on. */
103
174
  export function recordedClient(client) {
175
+ const names = new RefNames();
176
+ // Bound: a provider's DaemonClient reads its own fields through `this`.
177
+ const send = client.call.bind(client);
104
178
  return {
105
179
  call: (async (method, params, options) => {
106
180
  const into = scope.getStore();
107
- if (!into)
108
- return client.call(method, params, options);
181
+ if (!into) {
182
+ const answer = await send(method, params, options);
183
+ if (method === "ui.observe")
184
+ names.learn(answer);
185
+ return answer;
186
+ }
109
187
  // Its place is kept when it starts, so calls made together read in the order they were made, and the bound keeps
110
188
  // the first ones made. A call still going when its tool call ended reads unfinished.
111
- const slot = into.calls.length < MAX_RECORDED_CALLS ? into.calls.push({ method, ok: false, ms: 0, code: "unfinished" }) - 1 : undefined;
189
+ const startedAt = Date.now();
190
+ const app = appOf(method, params);
191
+ const open = { method, started_at: new Date(startedAt).toISOString(), ...(app ? { app } : {}), ok: false };
192
+ const slot = into.calls.length < MAX_RECORDED_CALLS ? into.calls.push({ ...open, ms: 0, code: "unfinished" }) - 1 : undefined;
112
193
  if (slot === undefined)
113
194
  into.dropped += 1;
114
195
  const started = performance.now();
115
- const answer = await client.call(method, params, options).catch((error) => {
196
+ const answer = await send(method, params, options).catch((error) => {
116
197
  if (slot !== undefined)
117
- into.calls[slot] = { method, ok: false, ms: Math.round(performance.now() - started), code: "gone" };
198
+ into.calls[slot] = { ...open, ms: Math.round(performance.now() - started), code: "gone" };
118
199
  throw error;
119
200
  });
201
+ if (method === "ui.observe")
202
+ names.learn(answer);
120
203
  if (slot !== undefined)
121
- into.calls[slot] = callRecordOf(method, params, answer, performance.now() - started);
204
+ into.calls[slot] = callRecordOf(method, params, answer, performance.now() - started, startedAt, names.of);
122
205
  return answer;
123
206
  }),
124
207
  close: () => client.close(),
@@ -89,6 +89,10 @@ export type OpenComputerView = {
89
89
  tag: string;
90
90
  watch: ComputerWatchOf;
91
91
  hold: ViewerHold;
92
+ /** Whether the computer is gone now: its provider no longer has it. Asked when its watch ends gone or does not start
93
+ * for want of the computer (not found, gone); a gone one's view closes "released", so the run's Screen reads it
94
+ * released. A stream that ended with the computer still there keeps its view. Absent: never asked. */
95
+ gone?: () => Promise<boolean>;
92
96
  /** The frames' width at most, and their JPEG quality (the computer's defaults when absent). */
93
97
  maxWidth?: number;
94
98
  quality?: number;
@@ -127,6 +131,7 @@ export type ClaimViewArgs = {
127
131
  readonly tag: string;
128
132
  readonly watch: ComputerWatchOf;
129
133
  readonly hold: unknown;
134
+ readonly gone?: () => Promise<boolean>;
130
135
  };
131
136
  /** The runner's opener for computerForClaim's openComputerView dep (runner/main.ts runnerComputers): the view of a run's
132
137
  * desktop or phone under its claim, on the store the claim was given, held through viewerHoldOf over tl-places' calls on
@@ -81,6 +81,7 @@ export const claimViewOpener = (at) => (args) => {
81
81
  return openComputerView({
82
82
  store, sealKey: args.sealKey, claim, kind: args.kind, input: args.input, tag: args.tag, watch: args.watch,
83
83
  hold: viewerHoldOf(PLACES, store, claim.runId, args.hold),
84
+ ...(args.gone ? { gone: args.gone } : {}),
84
85
  ...(at ? { at } : {}),
85
86
  });
86
87
  };
@@ -379,6 +380,13 @@ async function openOne(input, key) {
379
380
  void Promise.resolve().then(() => hold.away()).catch(() => undefined);
380
381
  }
381
382
  };
383
+ /** The watch ended (or never started) for want of its computer: a computer its provider no longer has (deleted under
384
+ * the run) is released, and its view closes; one still there (its stream ended) keeps its view. */
385
+ const goneAsked = () => {
386
+ if (!input.gone || closed)
387
+ return;
388
+ void input.gone().then((gone) => (gone ? view.close("released") : undefined), () => undefined);
389
+ };
382
390
  const startWatch = async (conn) => {
383
391
  const current = viewer;
384
392
  const handlers = {
@@ -390,6 +398,8 @@ async function openOne(input, key) {
390
398
  return;
391
399
  send(conn, { type: "ended", reason: error.code, message: redactWords(error.message) });
392
400
  conn.close(CLOSE_CODES.browser_closed, "ended");
401
+ if (error.code === "gone")
402
+ goneAsked();
393
403
  },
394
404
  };
395
405
  const started = await watch(handlers, { signal: current.abort.signal, ...(input.maxWidth ? { maxWidth: input.maxWidth } : {}), ...(input.quality ? { quality: input.quality } : {}) }).catch((error) => ({ ok: false, error: { code: "unreachable", message: error?.message ?? String(error) } }));
@@ -398,6 +408,8 @@ async function openOne(input, key) {
398
408
  const code = started.error.code === "gone" || started.error.code === "unsupported" || started.error.code === "refused" ? started.error.code : "unreachable";
399
409
  send(conn, { type: "ended", reason: code, message: redactWords(started.error.message) });
400
410
  conn.close(CLOSE_CODES.browser_closed, "ended");
411
+ if (started.error.code === "gone" || started.error.code === "not_found")
412
+ goneAsked();
401
413
  }
402
414
  return;
403
415
  }
@@ -7,8 +7,14 @@ export type GpuSetting = {
7
7
  readonly type: string;
8
8
  readonly count: number;
9
9
  };
10
+ /** How an agent drives a desktop or a phone: "code", by scripts alone (its harness's code mode, else computer_script);
11
+ * "tools", by the per-step tools alone (computer_observe, computer_act, computer_screenshot). The hand-over is in both;
12
+ * absent, both (run-tools.ts surfaceKeeps). */
13
+ export declare const COMPUTER_SURFACES: readonly ["code", "tools"];
14
+ export type ComputerSurface = (typeof COMPUTER_SURFACES)[number];
10
15
  /** The setting as a revision keeps it. `image`: one the provider's descriptor offers for the kind (Orgo's `windows`);
11
- * absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. */
16
+ * absent, the kind's default. A sandbox may ask for GPUs; whether its provider gives them is the claim's check. A
17
+ * desktop or a phone may say its surface, and `exec: false`: the agent gets no shell and starts no program on it. */
12
18
  export type ComputerSetting = {
13
19
  readonly kind: "none";
14
20
  } | {
@@ -18,7 +24,14 @@ export type ComputerSetting = {
18
24
  readonly gpu?: GpuSetting;
19
25
  readonly persistent?: boolean;
20
26
  } | {
21
- readonly kind: Exclude<ComputerKind, "none" | "sandbox">;
27
+ readonly kind: "desktop" | "phone";
28
+ readonly provider: string;
29
+ readonly image?: string;
30
+ readonly persistent?: boolean;
31
+ readonly surface?: ComputerSurface;
32
+ readonly exec?: boolean;
33
+ } | {
34
+ readonly kind: "browser";
22
35
  readonly provider: string;
23
36
  readonly image?: string;
24
37
  readonly persistent?: boolean;
@@ -1,8 +1,10 @@
1
1
  // An agent's computer, its one setting for where its tools run (Settings → Computers): `computer: { kind, provider?,
2
- // image?, gpu?, persistent? }` on its revision. kind is none, sandbox, desktop, phone or browser; provider names one of
3
- // the computer providers (the computer package's kind registry), and is absent for none; image names one the provider
4
- // offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count }; persistent: true keeps the
5
- // agent's own computer between its runs, where the configuration declares persistence. The v2 API's `place` is this
2
+ // image?, gpu?, persistent?, surface?, exec? }` on its revision. kind is none, sandbox, desktop, phone or browser;
3
+ // provider names one of the computer providers (the computer package's kind registry), and is absent for none; image
4
+ // names one the provider offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count };
5
+ // persistent: true keeps the agent's own computer between its runs, where the configuration declares persistence. A
6
+ // desktop's or a phone's surface ("code" or "tools") is how the agent drives it, and exec: false gives the agent no
7
+ // shell and no program start on it (run-tools.ts); the owner's own computer calls keep everything. The v2 API's `place` is this
6
8
  // setting's view, one to one where it can say it: {mode: "runner"} is {kind: "none"}, and {mode: "sandbox", box: X} is
7
9
  // {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
8
10
  // on the runner, so its place reads runner.
@@ -10,6 +12,10 @@ import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
10
12
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
11
13
  /** The kinds of computer an agent can be given. */
12
14
  export const COMPUTER_KINDS = ["none", "sandbox", "desktop", "phone", "browser"];
15
+ /** How an agent drives a desktop or a phone: "code", by scripts alone (its harness's code mode, else computer_script);
16
+ * "tools", by the per-step tools alone (computer_observe, computer_act, computer_screenshot). The hand-over is in both;
17
+ * absent, both (run-tools.ts surfaceKeeps). */
18
+ export const COMPUTER_SURFACES = ["code", "tools"];
13
19
  /** A GPU type's name as a setting keeps it: the vendor's own ("T4", "A100-80GB", "RTX-PRO-6000"); store/agent-body.ts
14
20
  * keeps the same. */
15
21
  const GPU_TYPE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
@@ -30,6 +36,16 @@ const OPTIONAL = {
30
36
  persistent: {
31
37
  check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is true (this agent keeps its own computer between runs) or false (a fresh one for each run)` }]),
32
38
  },
39
+ // How the agent drives its desktop or phone (run-tools.ts surfaceKeeps): by scripts alone, or by the step tools alone.
40
+ surface: {
41
+ kinds: ["desktop", "phone"],
42
+ check: (value, field) => (COMPUTER_SURFACES.includes(value) ? [] : [{ field, reason: "not_an_option", message: `${field} is "code" (the agent drives the computer by scripts alone) or "tools" (by its step tools alone); absent, both` }]),
43
+ },
44
+ // false: the agent's computer runs no program of its own (run-tools.ts runHands): no shell, no processes, no bash.
45
+ exec: {
46
+ kinds: ["desktop", "phone"],
47
+ check: (value, field) => (typeof value === "boolean" ? [] : [{ field, reason: "wrong_type", message: `${field} is false (the agent gets no shell and starts no program on its computer) or true (as absent)` }]),
48
+ },
33
49
  gpu: {
34
50
  kinds: ["sandbox"],
35
51
  check: (gpu, field) => {
@@ -56,5 +56,6 @@ export declare function computerView(deps: {
56
56
  /** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
57
57
  * open. A desktop or a phone is opened by the run's claim at its start and held to its end: opening until its viewer
58
58
  * answers. A browser is opened by the agent's browser steps (OPENS): unopened with no such call in the run; opening
59
- * while one has no result yet; closed otherwise (released, or let go with its process). */
60
- export declare function sessionIn(kind: ComputerKind, entries: readonly JournalEntry[]): ComputerSession;
59
+ * while one has no result yet; closed otherwise (released, or let go with its process). An `ended` run's computer is
60
+ * opening nothing: a desktop or a phone closed with the run, and a browser step it ended under is closed. */
61
+ export declare function sessionIn(kind: ComputerKind, entries: readonly JournalEntry[], ended?: boolean): ComputerSession;
@@ -29,10 +29,11 @@ const messageOf = (entry) => {
29
29
  /** Where the run's computer of `kind` is, read from the run's journal `entries` (in order), for a run with no viewer
30
30
  * open. A desktop or a phone is opened by the run's claim at its start and held to its end: opening until its viewer
31
31
  * answers. A browser is opened by the agent's browser steps (OPENS): unopened with no such call in the run; opening
32
- * while one has no result yet; closed otherwise (released, or let go with its process). */
33
- export function sessionIn(kind, entries) {
32
+ * while one has no result yet; closed otherwise (released, or let go with its process). An `ended` run's computer is
33
+ * opening nothing: a desktop or a phone closed with the run, and a browser step it ended under is closed. */
34
+ export function sessionIn(kind, entries, ended = false) {
34
35
  if (kind !== "browser")
35
- return "opening";
36
+ return ended ? "closed" : "opening";
36
37
  let asked = false;
37
38
  const waiting = new Set();
38
39
  const called = (id, name) => {
@@ -58,5 +59,5 @@ export function sessionIn(kind, entries) {
58
59
  else if (entry.kind === KINDS.callEnd && typeof data?.callId === "string")
59
60
  waiting.delete(data.callId);
60
61
  }
61
- return !asked ? "unopened" : waiting.size ? "opening" : "closed";
62
+ return !asked ? "unopened" : waiting.size && !ended ? "opening" : "closed";
62
63
  }