@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/tool-gate.js CHANGED
@@ -4,7 +4,10 @@
4
4
  // host tools on claude-agent, codex and OpenCode, and the MCP gateway's calls alike.
5
5
  //
6
6
  // An MCP tool's setting may also carry a pin (pinRefusal): top-level arguments its calls must carry, each a JSON scalar
7
- // or one of a list. A pin adds to a setting and is never a permission: the gate checks it after a deny and before an
7
+ // or one of a list, or an object argument's keys (`{keys: [...]}`: given, it holds those keys alone, any values). A
8
+ // pinned tool takes only the arguments its listing in the run's pin declares, beside its pinned ones, so no alias the
9
+ // server takes for a pinned argument goes around it.
10
+ // A pin adds to a setting and is never a permission: the gate checks it after a deny and before an
8
11
  // allow or an ask, so an allowed call not as pinned is refused unsent, and one under ask is refused before anyone is
9
12
  // asked; an approved call is checked again before it runs. The agent's pin and the server's both hold.
10
13
  //
@@ -13,10 +16,9 @@
13
16
  // run's folder, after a deny and a pin and before an allow or an ask, so approvals "never" lifts none of it; an approved
14
17
  // call is decided again before it runs.
15
18
  //
16
- // An ask has one way to wait, every tool's alike (the owner's ruling of 11-04): it PARKS. The runner's loop answers the
17
- // call with waitingText and ends the turn, as ask_person's does; the run goes needs_input with the pending approval. On
18
- // an answer the loop runs the approved call once, through the journal, and resumes the session with a message naming the
19
- // call (resumeText). One call waits at a time: another asked meanwhile is refused.
19
+ // An ask has one way to wait, every tool's alike (the owner's ruling of 11-04): it PARKS. The runner's loop holds the
20
+ // call and the run goes needs_input with the pending approval. On an answer the loop runs the approved call once, through
21
+ // the journal, and the session goes on with its result. One call waits at a time: another asked meanwhile is refused.
20
22
  //
21
23
  // The answer: POST /v2/runs/{id}/approvals/{approval_id} { decision: "allow" | "deny", note? } -> 204. The first answer
22
24
  // wins; the same answer again is 204, a conflicting one 409. Only the owner's password session answers (server.ts), never
@@ -28,29 +30,34 @@ import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
28
30
  import { LEARNED_DIR } from "./learning.js";
29
31
  import { COMPUTER_ROOT, portPath } from "./workspace/paths.js";
30
32
  import { builtinHarness } from "./harness-table.js";
33
+ import { META_TOOLS } from "./meta-tool-names.js";
31
34
  import { DEFAULT_HARNESS } from "./harness.js";
32
35
  import { SHELL_TOOLS } from "./background.js";
33
- import { DECISION_PROVIDER_KEYS, SERVE_OWN_TOOLS, TABLE_TOOLS } from "./tool-plane.js";
36
+ import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
37
+ import { isToolRow, tableTools } from "./tool-list.js";
34
38
  import { deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
35
39
  import { approvalsOf } from "./approvals.js";
36
40
  import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
41
+ import { formatToolName, isCatalogName, mcpNameOf, mcpServerOf, mcpToolName, monidNameOf } from "./tool-names.js";
37
42
  /** What the gate does with a tool's calls. */
38
43
  export const PERMISSIONS = ["allow", "ask", "deny"];
39
- /** An MCP tool's gate name: `mcp:<server>/<tool>`. */
40
- export const mcpToolName = (server, tool) => `mcp:${server}/${tool}`;
41
- /** Whether `name` is an MCP tool's gate name. */
42
- export const isMcpTool = (name) => /^mcp:[^/]+\/.+$/.test(name);
44
+ // An MCP tool's gate name is its catalog name, `mcp:<server>/<tool>` (tool-names.ts).
45
+ export { mcpToolName };
43
46
  /** The MCP servers a revision grants tools of, by their catalog names (`mcp:<server>/<tool>`, a server's wildcard too), each
44
47
  * once: what a harness that names a session's MCP tool its own way (its facts' toolAlias: OpenCode's `<server>_<tool>`) is
45
48
  * matched against, so its call is held to that tool's settings and never to a table tool's of the same shape. */
46
- export const mcpServersOf = (granted) => [...new Set(granted.flatMap((name) => /^mcp:([^/]+)\//.exec(name)?.[1] ?? []))];
47
- /** A third-party catalog tool, by its name: monid's (`monid.<tool>`) or an MCP server's (`mcp:<server>/<tool>`). */
48
- export const isCatalogTool = (name) => name.startsWith("monid.") || isMcpTool(name);
49
- /** The owner's defaults (11-01): a built-in kernel tool allow; a third-party catalog tool ask. On a run with no computer,
49
+ export const mcpServersOf = (granted) => [...new Set(granted.flatMap((name) => mcpServerOf(name) ?? []))];
50
+ /** A third-party catalog tool, by its name: any in MCP's namespace (`mcp:<server>/<tool>`) or monid's
51
+ * (`monid:<provider>/<endpoint>`), a group's wildcard too; one that does not parse too, so the default for it is a
52
+ * catalog tool's ask. */
53
+ export const isCatalogTool = isCatalogName;
54
+ const isBuiltin = (name) => isToolRow(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name);
55
+ /** The owner's defaults: a built-in of this server (a row of the tool list, its own tools, a computer kind's key, a
56
+ * decision provider's) allows; anything else asks, so a new source never defaults to allow. On a run with no computer,
50
57
  * the kernel's ruled rule (defaultPermissionOf): bash asks first, and the background tools, which need a computer, are
51
58
  * refused. */
52
59
  export const defaultPermission = (name, where = {}) => {
53
- if (isCatalogTool(name))
60
+ if (isCatalogTool(name) || !isBuiltin(name))
54
61
  return "ask";
55
62
  return where.computer === false ? defaultPermissionOf(name, { computer: false }) : "allow";
56
63
  };
@@ -71,11 +78,13 @@ export const SHELL_WATCHERS = new Set(["bash_output", "bash_list", "bash_signal"
71
78
  /** Shell tool `name`'s permission, given bash's: a watcher's ask is allow; any other keeps bash's. */
72
79
  const shellPermission = (name, bash) => (bash === "ask" && SHELL_WATCHERS.has(name) ? "allow" : bash);
73
80
  /** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
74
- * tool, its server's wildcard `mcp:<server>/*`. */
81
+ * tool, its server's wildcard `mcp:<server>/*`, and for a monid endpoint, its provider's `monid:<provider>/*`. */
75
82
  export function permissionKeys(name) {
76
- if (!isMcpTool(name))
77
- return [name];
78
- return [name, `${name.slice(0, name.indexOf("/"))}/*`];
83
+ const mcp = mcpNameOf(name);
84
+ if (mcp)
85
+ return [name, formatToolName({ kind: "mcp-server", server: mcp.server })];
86
+ const monid = monidNameOf(name);
87
+ return monid ? [name, formatToolName({ kind: "monid-provider", provider: monid.provider })] : [name];
79
88
  }
80
89
  /** The browser's registrations on pi (pi-browser's BROWSER_TOOL_NAMES, which a test holds this list to): each is a call
81
90
  * of the table's `browser`. */
@@ -104,7 +113,8 @@ export function nameMapOf(harness, mcpServers = []) {
104
113
  const name = (own, key) => void (names.has(own) || names.set(own, key));
105
114
  for (const [own, key] of Object.entries(SHELL_FAMILY))
106
115
  name(own, key);
107
- for (const own of [...TABLE_TOOLS, ...SERVE_OWN_TOOLS, ...DECISION_PROVIDER_KEYS])
116
+ // pi's code mode (`codemode`) is the computer kind's (KIND_TOOLS); the host's own is read by its own key (RunGate.hostMeta).
117
+ for (const own of [...tableTools(), ...SERVE_OWN_TOOLS.filter((one) => one !== CODEMODE_TOOL_NAME), ...DECISION_PROVIDER_KEYS])
108
118
  name(own, own);
109
119
  const alias = facts?.toolAlias?.exec(READ_SKILL_FILE) ?? null;
110
120
  name(READ_SKILL_FILE, alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : "read");
@@ -120,8 +130,9 @@ export function nameMapOf(harness, mcpServers = []) {
120
130
  return names;
121
131
  }
122
132
  /** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
123
- * families no list holds (`monid.<tool>`, `mcp:<server>/<tool>`, `mcp__<server>__<tool>`, `monid_<kind>`, and a harness's
124
- * own `<server>_<tool>` for a server of `mcpServers` only). Undefined: nothing maps it, and the gate asks. */
133
+ * families no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`, `mcp__<server>__<tool>`,
134
+ * and a harness's own `<server>_<tool>` for a server of `mcpServers` only). Undefined: nothing maps it, and the gate asks
135
+ * (a monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf, before the gate is asked). */
125
136
  export function settingsKeyOf(harness, name, mcpServers = [], names = nameMapOf(harness, mcpServers)) {
126
137
  const own = names.get(name);
127
138
  if (own !== undefined)
@@ -131,18 +142,19 @@ export function settingsKeyOf(harness, name, mcpServers = [], names = nameMapOf(
131
142
  const mcp = /^mcp__([a-z][a-z0-9-]*)__(.+)$/.exec(name);
132
143
  if (mcp)
133
144
  return mcp[1] === HOST_TOOLS_SERVER ? settingsKeyOf(harness, mcp[2], mcpServers, names) : mcpToolName(mcp[1], mcp[2]);
134
- const monid = /^monid_([a-z]+)$/.exec(name);
135
- if (monid)
136
- return `monid.${monid[1]}`;
137
145
  const alias = builtinHarness(harness)?.facts?.toolAlias?.exec(name) ?? null;
138
146
  return alias && mcpServers.includes(alias[1]) ? mcpToolName(alias[1], alias[2]) : undefined;
139
147
  }
148
+ /** Whether a pin's value is a keys pin: the one form that is an object. */
149
+ export const isPinKeys = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
140
150
  /** The most arguments one setting pins, and the most values a one-of list holds. */
141
151
  export const MAX_PIN_ARGS = 8;
142
152
  export const MAX_PIN_CHOICES = 16;
143
- /** A one-of list in its one form: each value once, null first, then by its JSON text; any other value as it is. The
144
- * same meaning is the same text (a revision's id) and the same words (a refusal). */
153
+ /** A one-of list in its one form: each value once, null first, then by its JSON text; a keys pin's keys each once,
154
+ * sorted; a scalar as it is. The same meaning is the same text (a revision's id) and the same words (a refusal). */
145
155
  export const canonicalChoices = (value) => {
156
+ if (isPinKeys(value))
157
+ return { keys: [...new Set(value.keys)].sort() };
146
158
  if (!Array.isArray(value))
147
159
  return value;
148
160
  const texts = [...new Set(value.filter((one) => one !== null).map((one) => JSON.stringify(one)))].sort();
@@ -153,18 +165,36 @@ export const canonicalPin = (pin) => Object.fromEntries(Object.keys(pin).sort().
153
165
  /** Whether a call's argument `given` is the pinned scalar `one`: the same JSON scalar (strict equality), or, for null,
154
166
  * left out or null. */
155
167
  const isOne = (given, one) => (one === null ? given === undefined || given === null : given === one);
156
- /** Whether `given` holds pinned `value`: its scalar, or one of its list. */
157
- const holds = (given, value) => (Array.isArray(value) ? value.some((one) => isOne(given, one)) : isOne(given, value));
168
+ /** Whether a call's argument `given` holds a keys pin's `keys`: left out, null, or an object (never a list) whose own keys
169
+ * are all among them. */
170
+ const keysHold = (given, keys) => given === undefined || given === null || (typeof given === "object" && !Array.isArray(given) && Object.keys(given).every((key) => keys.includes(key)));
171
+ /** Whether `given` holds pinned `value`: its scalar, one of its list, or its keys. */
172
+ const holds = (given, value) => (isPinKeys(value) ? keysHold(given, value.keys) : Array.isArray(value) ? value.some((one) => isOne(given, one)) : isOne(given, value));
158
173
  /** A scalar in a refusal's words: text as it is, null as `absent`, any other as JSON. */
159
174
  const scalarWords = (one) => (one === null ? "absent" : typeof one === "string" ? one : JSON.stringify(one));
160
175
  /** A pin in words, as the refusal says it, in its one form (canonicalPin): `channel_id = C0123`, `cc absent` for a null,
161
- * `event in (absent | COMMENT)` for a list. */
162
- export const pinWords = (pin) => Object.entries(canonicalPin(pin)).map(([arg, value]) => (Array.isArray(value) ? `${arg} in (${value.map(scalarWords).join(" | ")})` : value === null ? `${arg} absent` : `${arg} = ${scalarWords(value)}`)).join(", ");
176
+ * `event in (absent | COMMENT)` for a list, `properties keys in (hs_lead_score)` for a keys pin. */
177
+ export const pinWords = (pin) => Object.entries(canonicalPin(pin)).map(([arg, value]) => (isPinKeys(value) ? `${arg} keys in (${value.keys.join(" | ")})` : Array.isArray(value) ? `${arg} in (${value.map(scalarWords).join(" | ")})` : value === null ? `${arg} absent` : `${arg} = ${scalarWords(value)}`)).join(", ");
178
+ /** Names in words: `a`, `a and b`, `a, b and c`. */
179
+ const listWords = (names) => (names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`);
180
+ /** The arguments a call of `tool` carries that its listing does not declare, in words: "`to` is not an argument of X". */
181
+ const undeclaredWords = (args, tool) => `${listWords(args.map((arg) => `\`${arg}\``))} ${args.length === 1 ? "is not an argument" : "are not arguments"} of ${tool}`;
163
182
  /** What holds both of two layers' pins of one argument (`own`, the agent's, and `theirs`, the server's): a scalar where
164
- * either is one and the other holds it, else the agent's list kept to the server's, in the agent's order; undefined when
165
- * nothing holds both. */
183
+ * either is one and the other holds it, else the agent's list kept to the server's, in the agent's order; two keys pins,
184
+ * the agent's keys the server's has too; a keys pin and a scalar or list, what of the scalars the keys pin holds (null:
185
+ * left out). Undefined when nothing holds both, two keys pins with no key in both among them: no call writes a field
186
+ * each layer means. */
166
187
  function bothOf(own, theirs) {
167
188
  const list = (value) => (Array.isArray(value) ? value : [value]);
189
+ if (isPinKeys(own) && isPinKeys(theirs)) {
190
+ const kept = own.keys.filter((key) => theirs.keys.includes(key));
191
+ return kept.length ? { keys: kept } : undefined;
192
+ }
193
+ if (isPinKeys(own) || isPinKeys(theirs)) {
194
+ const [keys, other] = isPinKeys(own) ? [own, theirs] : [theirs, own];
195
+ const kept = list(other).filter((one) => holds(one, keys));
196
+ return !kept.length ? undefined : Array.isArray(other) ? kept : kept[0];
197
+ }
168
198
  if (!Array.isArray(own))
169
199
  return list(theirs).some((one) => one === own) ? own : undefined;
170
200
  if (!Array.isArray(theirs))
@@ -174,11 +204,16 @@ function bothOf(own, theirs) {
174
204
  }
175
205
  /** Why the call of MCP tool `name` with `args` is refused by a pin, or undefined when no pin refuses it. A pin is an
176
206
  * addition to a setting, never a permission: each layer's pin on the tool's own key holds (the agent's and the
177
- * server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value, or one of
178
- * its list. An argument both layers pin takes what holds both; where nothing does, every call is refused. `ran`: whether an earlier attempt of
179
- * the call may have been sent (deniedText's). `mismatched`: the arguments that do not hold, for the gate's log line. */
180
- export function pinRefusal(name, args, server, agent = {}, ran = "no") {
181
- if (!isMcpTool(name))
207
+ * server's both, whatever the permission), and a call must carry every pinned argument as pinned: its value, one of
208
+ * its list, or (a keys pin) an object of its keys alone, null or the argument left out. An argument both layers pin
209
+ * takes what holds both; where nothing does, every call is refused. `declared`: the top-level arguments the tool's
210
+ * listing in the run's pin declares (its inputSchema's `properties`): a pinned tool takes only those and its pinned
211
+ * ones, so an alias the server takes beside a pinned argument (`to` beside `recipient_email`) is refused, with no
212
+ * table of aliases; undefined (a listing with no `properties` object, or none known), no argument is closed. `ran`:
213
+ * whether an earlier attempt of the call may have been sent (deniedText's). `mismatched`: the arguments that do not
214
+ * hold, for the gate's log line. */
215
+ export function pinRefusal(name, args, server, agent = {}, ran = "no", declared) {
216
+ if (!mcpNameOf(name))
182
217
  return undefined;
183
218
  const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
184
219
  if (server[name]?.brokenPin)
@@ -191,6 +226,9 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no") {
191
226
  return { text: `${name} can't be called: this agent's settings fix ${pinWords(Object.fromEntries(clash.map((arg) => [arg, own[arg]])))} and this server's fix ${pinWords(Object.fromEntries(clash.map((arg) => [arg, theirs[arg]])))}, so no call can satisfy both. ${what} Don't retry it: the owner makes the two agree.`, mismatched: clash };
192
227
  const pin = { ...theirs, ...Object.fromEntries(Object.entries(own).map(([arg, value]) => [arg, Object.hasOwn(theirs, arg) ? bothOf(value, theirs[arg]) : value])) };
193
228
  const given = typeof args === "object" && args !== null && !Array.isArray(args) ? args : {};
229
+ const undeclared = declared && Object.keys(pin).length ? Object.keys(given).filter((arg) => !declared.has(arg) && !Object.hasOwn(pin, arg)) : [];
230
+ if (undeclared.length)
231
+ return { text: `${undeclaredWords(undeclared, mcpNameOf(name).tool)}; a pinned tool takes only its listed arguments (${listWords(Object.keys(pin).sort())} ${Object.keys(pin).length === 1 ? "is" : "are"} pinned). ${what}`, mismatched: undeclared };
194
232
  const mismatched = Object.keys(pin).filter((arg) => !holds(Object.hasOwn(given, arg) ? given[arg] : undefined, pin[arg]));
195
233
  if (!mismatched.length)
196
234
  return undefined;
@@ -206,12 +244,42 @@ export function pinRefusal(name, args, server, agent = {}, ran = "no") {
206
244
  * layer, nor an ask that stands in for a setting that does not read. Nor is anything RunGate.enter refuses before it
207
245
  * decides between running and parking ever lifted (a template's pin, among them). Without never, the answer is as it
208
246
  * always was. */
209
- export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}) {
247
+ export function permissionFrom(name, server, agent = {}, approvals = "ask", where = {}, effect) {
210
248
  const { permission, from } = settingOf(name, server, agent, where);
249
+ if (permission === "ask" && effect === "read" && readsLift(name, server, agent, from))
250
+ return { permission: "allow", from: "server" };
211
251
  if (approvals !== "never" || permission !== "ask" || standsBehind(name, server, agent))
212
252
  return { permission, from };
213
253
  return { permission: "allow", from: "unattended" };
214
254
  }
255
+ export function toolEffect(annotations) {
256
+ const hints = typeof annotations === "object" && annotations !== null ? annotations : {};
257
+ if (hints.readOnlyHint === true)
258
+ return "read";
259
+ return hints.destructiveHint === true ? "destructive" : "write";
260
+ }
261
+ /** MCP tool `name`'s (`mcp:<server>/<tool>`) effect as a run's pin holds it (its annotations then, toolEffect): what the
262
+ * run's gate (ClaimMcp.effectOf) and a settings save's wake (settings-wake.ts) read, never a live listing. Undefined for a
263
+ * tool the pin does not hold. */
264
+ export function pinnedEffect(pin, name) {
265
+ const parsed = /^mcp:([^/]+)\/(.+)$/.exec(name);
266
+ const pinned = parsed && Object.hasOwn(pin, parsed[1]) ? pin[parsed[1]] : undefined;
267
+ const tool = pinned?.tools.find((one) => one.name === parsed[2]);
268
+ return tool ? toolEffect(tool.annotations) : undefined;
269
+ }
270
+ /** Whether "allow reads" lifts the ask of MCP tool `name`, one its run's pin marks read-only (permissionFrom's `effect`):
271
+ * its server's wildcard in this server's settings carries `allow_reads`, the ask came from the server's settings or
272
+ * the default (an agent's own ask holds), the tool's own key sets no permission on this server (an explicit setting
273
+ * beats the rule), and nothing stands behind the ask (standsBehind: a deny in any layer, a value that does not read,
274
+ * settings unread). A pin's refusal is RunGate.decide's, after this, so the rule never lifts one. */
275
+ function readsLift(name, server, agent, from) {
276
+ if (!mcpNameOf(name) || from === "agent")
277
+ return false;
278
+ const [own, wildcard] = permissionKeys(name);
279
+ if (server[own]?.permission !== undefined || server[wildcard]?.allow_reads !== true)
280
+ return false;
281
+ return !standsBehind(name, server, agent);
282
+ }
215
283
  /** Marks the server's settings map when its stored value does not read (tool-plane.ts loadToolSettings): every
216
284
  * tool then takes its defaults, and a deny it may hold can't be seen, so nothing lifts an ask over it. A symbol:
217
285
  * carried by a spread, never by JSON (it is never served) nor by Object.entries (no reader takes it for a tool). */
@@ -274,14 +342,12 @@ function settingFrom(name, server, agent, where = {}) {
274
342
  }
275
343
  /** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
276
344
  * workflow's call nodes'. */
277
- export const permissionOf = (name, server, agent = {}, approvals = "ask") => permissionFrom(name, server, agent, approvals).permission;
345
+ export const permissionOf = (name, server, agent = {}, approvals = "ask", effect) => permissionFrom(name, server, agent, approvals, {}, effect).permission;
278
346
  // The refusal words (SettingFrom, DenyFrom, NOT_RUN, RAN_UNKNOWN, denyPlace, deniedText, refusedText) live in
279
347
  // refusal-words.ts, shared with the runner's loops.
280
348
  export { deniedText, denyPlace, NOT_RUN, RAN_UNKNOWN, refusedText } from "./refusal-words.js";
281
349
  /** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
282
350
  export const noApproverText = (tool, ran = "no") => `Permission denied: ${tool} needs the owner's approval, and this server has accounts off (AGENTRUN_ACCOUNTS=0), so no one can give it: set the tool to allow or deny in the agent's Tools. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}`;
283
- /** A parked call's answer: the run pauses here. */
284
- export const waitingText = (tool) => `This ${tool} call waits for a person's approval; the run pauses here and continues with the result when they answer.`;
285
351
  /** The Timeline row of a call that waits for an approval. */
286
352
  export const APPROVAL_ROW = "tool_approval_requested";
287
353
  /** A call's arguments shown on its approval, at most this many bytes. */
@@ -305,33 +371,13 @@ export function previewOf(text) {
305
371
  const bytes = Buffer.from(text, "utf8");
306
372
  return bytes.length <= ARGS_PREVIEW_BYTES ? bytes.toString("utf8") : `${bytes.subarray(0, ARGS_PREVIEW_BYTES - 3).toString("utf8").replace(/\uFFFD+$/, "")}…`;
307
373
  }
308
- /** `args` as JSON, at most ARGS_PREVIEW_BYTES: the request's own record of them, never shown as it is. */
309
- export const argsPreview = (args) => previewOf(JSON.stringify(args ?? {}) ?? "");
310
- /** How the gate's resume message starts: the server knows its row by it, and redacts the row whole (runs.ts). */
311
- export const RESUME_PREFIX = "[tool approval] ";
312
- /** The one message that resumes a session once a person answered: it names the call it answers (its tool, call id and
313
- * arguments), so the model tells it from a person's new input, and carries the call's result, or the refusal. */
314
- /** The head of the gate's resume message: the call it answers, its arguments as shown (`shown`, redacted whole then cut,
315
- * runs.ts) cut again at 300 characters, and the words that say it is not the person's. The one source of it: the resume
316
- * writes it, and the Timeline strips exactly it from the row a person opens (runs.ts resumeShows). */
317
- export function resumeHead(request, shown) {
318
- const args = shown.length > 300 ? `${shown.slice(0, 299)}…` : shown;
319
- return `${RESUME_PREFIX}This answers your ${request.tool} call ${request.call_id} (arguments ${args}), which waited for a person's approval; it is not a new message from them.`;
320
- }
321
- /** The last line of a CLI's resume message (one, after every call it answers): the message arrives as a new turn, and a
322
- * model that reads only results there answers about the approval, not the person's request (Claude Code, live). */
323
- export const RESUME_GO_ON = "Go on with the person's request from where you stopped, using these results; don't call these tools again for them.";
324
- export function resumeText(request, shown, decision, result) {
325
- const head = resumeHead(request, shown);
326
- return decision === "allow" ? `${head} They allowed it, and it ran${result.isError ? " and failed" : ""}. Its result:\n${result.text}` : `${head}\n${result.text}`;
327
- }
328
374
  /** The gate of the run `runId` whose folder is `where`, on its pinned revision. `serverSettings`: the server's tool
329
375
  * settings as the runner read them from the one store at the claim (tool-plane.ts loadToolSettings), read at each call as
330
376
  * the gate reads them. `approvers`: whether anyone can answer an ask here, the store's (server-approvers.ts, read at each
331
377
  * claim). The gate reads nothing of the run's own files: they are the agent's to write. `mcpServers`: the run's MCP
332
378
  * servers (mcpServersOf its grants), so a harness's own name for an MCP tool is held to that tool's settings. */
333
379
  export function runGate(where, runId, revision, serverSettings, approvers) {
334
- return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(where.mcpServers ? { mcpServers: where.mcpServers } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
380
+ return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(where.mcpServers ? { mcpServers: where.mcpServers } : {}), ...(where.computerCodemode ? { computerCodemode: true } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
335
381
  }
336
382
  /** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
337
383
  export class RunGate {
@@ -343,6 +389,8 @@ export class RunGate {
343
389
  /** `readServerSettings`: the server's tool settings, read at each call; `overrides`: the pinned revision's own;
344
390
  * `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on); `approvals`: the
345
391
  * pinned revision's (definition.approvals): "never" runs the agent unattended, an ask allowed (permissionFrom). */
392
+ /** `where.effectOf`: an MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf), what "allow reads" reads;
393
+ * never a live listing, so a server can't widen a run's access mid-run. */
346
394
  constructor(where, readServerSettings, overrides = {}, approvers = true, approvals = "ask") {
347
395
  this.where = where;
348
396
  this.readServerSettings = readServerSettings;
@@ -363,6 +411,16 @@ export class RunGate {
363
411
  * the call is run again after an earlier attempt that may have been sent (a replay-safe call rerun after a crash), so a
364
412
  * refusal says whether it took effect is not known, never that nothing was sent. */
365
413
  async decide(name, args, options = {}) {
414
+ // tools_search, tools_call and the host's codemode (runner/meta-tools.ts) run: each call they make is asked about here
415
+ // as its own tool, by its own name. pi's code mode on a run with a desktop or a phone is not the host's: its scripts
416
+ // reach the computer themselves, so it is held to the kind's setting (KIND_TOOLS).
417
+ const own = name.replace(/^mcp__hands__/, "");
418
+ // Each has a settings key of its own (allow unless an owner sets deny: a denied one is not offered, and a call to it is
419
+ // refused here).
420
+ if (this.hostMeta(own)) {
421
+ const setting = this.setting(name);
422
+ return setting.permission === "deny" ? { deny: deniedText(own, own, setting.from, options.replayed ? "unknown" : "no") } : "allow";
423
+ }
366
424
  const key = this.keyOf(name) ?? name;
367
425
  const tool = this.askedAs(name);
368
426
  const ran = options.replayed ? "unknown" : "no";
@@ -391,7 +449,15 @@ export class RunGate {
391
449
  /** Where the permission `policy` gives `tool` was set: the agent's own tool settings, the server's, or the default; or
392
450
  * "unattended", an ask the agent's approvals allowed. */
393
451
  denyFrom = (tool) => this.setting(tool).from;
452
+ /** Whether `bare` (a name without claude-agent's `mcp__hands__`) is one of the host's three, not pi's own code mode on a
453
+ * desktop or a phone (which is held to the kind's keys). */
454
+ hostMeta(bare) {
455
+ return META_TOOLS.has(bare) && !(bare === CODEMODE_TOOL_NAME && this.where.computerCodemode);
456
+ }
394
457
  setting(tool) {
458
+ const bare = tool.replace(/^mcp__hands__/, "");
459
+ if (this.hostMeta(bare))
460
+ return this.settingOf(tool, bare);
395
461
  // A tool the desktop and the phone both have (every computer tool): the gate knows not the run's kind, so it is held to the
396
462
  // stricter of both keys' settings, never more permissive than the run's own kind's.
397
463
  const shared = KIND_TOOLS.get(tool.replace(/^mcp__hands__/, ""));
@@ -417,12 +483,13 @@ export class RunGate {
417
483
  }
418
484
  // A shell tool under every harness's name for it is read as its own name, by bash's key (permissionFrom): a watcher's
419
485
  // ask is allow only where bash's ask is set as written. Its default is where the run's shell is (defaultPermission).
420
- return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where);
486
+ return permissionFrom(shellToolOf(tool) ?? key, server, this.overrides, this.approvals, where, mcpNameOf(key) ? this.where.effectOf?.(key) : undefined);
421
487
  }
422
488
  /** Why a pin refuses the call of `key` with `args` now (pinRefusal): the revision's own pins and the server's, read at
423
- * each call as its permission is, so a pin set or changed reaches a live run at its next call. */
489
+ * each call as its permission is, so a pin set or changed reaches a live run at its next call; a pinned tool held to
490
+ * the arguments its listing in the run's pin declares (where.argumentsOf). */
424
491
  pinned(key, args, ran = "no") {
425
- return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran);
492
+ return pinRefusal(key, args, this.serverSettings() ?? {}, this.overrides, ran, this.where.argumentsOf?.(key));
426
493
  }
427
494
  /** Why bash's policy refuses the call `name` (held to `key`) with `args` now, or undefined: the revision's own setting
428
495
  * (an agent's tool_settings.bash.policy), so every shell tool under every harness's name for it is held to it. A policy
@@ -18,7 +18,7 @@ export declare const TOOL_KEYS: readonly [{
18
18
  readonly kind: "tool";
19
19
  readonly label: "Monid";
20
20
  readonly fields: readonly ["MONID_API_KEY"];
21
- readonly unlocks: readonly ["monid.discover", "monid.inspect", "monid.run"];
21
+ readonly unlocks: readonly ["monid:*"];
22
22
  }, {
23
23
  readonly id: "browserbase";
24
24
  readonly kind: "tool";
@@ -79,6 +79,9 @@ export declare function rowUnlocks(row: {
79
79
  unlocks: string[];
80
80
  harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
81
81
  };
82
+ /** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
83
+ * (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
84
+ export declare const unlocksTool: (unlock: string, name: string) => boolean;
82
85
  /** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
83
86
  export declare const keyOf: (name: string) => string | undefined;
84
87
  /** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
package/dist/tool-keys.js CHANGED
@@ -32,9 +32,11 @@ export const TOOL_FIELDS = TOOL_KEYS.filter((row) => row.kind === "tool").flatMa
32
32
  * that run those tools. A name neither holds is left out; a key that unlocks none of its names lists nothing. */
33
33
  export function unlockedBy(candidates, tools, providers) {
34
34
  const bound = new Set([...tools.map((tool) => tool.name), ...providers.map((provider) => `decisions.${provider.id}`)]);
35
- const unlocks = candidates.filter((name) => bound.has(name));
35
+ // A catalog source's tools (`monid:*`) are granted by name, never listed: the source is shown as it is, and its tools are
36
+ // host tools, run on every harness.
37
+ const unlocks = candidates.filter((name) => bound.has(name) || name.endsWith(":*"));
36
38
  const run = new Set(tools.filter((tool) => unlocks.includes(tool.name)).flatMap((tool) => tool.harnesses));
37
- return { unlocks, harnesses: HARNESSES.filter((harness) => run.has(harness)) };
39
+ return { unlocks, harnesses: HARNESSES.filter((harness) => run.has(harness) || unlocks.some((name) => name.endsWith(":*"))) };
38
40
  }
39
41
  /** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
40
42
  * kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
@@ -51,8 +53,11 @@ export function rowUnlocks(row, tools, providers, offers) {
51
53
  const runs = (harness) => offers.some((offer) => offer.id === harness && (offer.keys ? key !== undefined && offer.keys.includes(key) : offer.available));
52
54
  return { unlocks: [], harnesses: HARNESSES.filter((harness) => (row.harnesses ?? HARNESSES).includes(harness) && runs(harness)) };
53
55
  }
56
+ /** Whether a key row's `unlock` unlocks the tool `name`: by its name, or `<source>:*` for every tool of a catalog source
57
+ * (`monid:*`: `monid:apollo/people/match`, `monid:apollo/*`). */
58
+ export const unlocksTool = (unlock, name) => unlock === name || (unlock.endsWith(":*") && name.startsWith(unlock.slice(0, -1)));
54
59
  /** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
55
- export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.includes(name))?.id;
60
+ export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.some((unlock) => unlocksTool(unlock, name)))?.id;
56
61
  /** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
57
62
  * its row damaged. */
58
63
  export const UNREADABLE = ["seal_key_changed", "file_unreadable"];
@@ -0,0 +1,26 @@
1
+ export type ToolRow = {
2
+ readonly table?: true;
3
+ readonly askable?: true;
4
+ readonly replay?: "safe" | "never";
5
+ readonly blurb?: string;
6
+ readonly host?: true;
7
+ };
8
+ export declare const TOOL_LIST: Readonly<Record<string, ToolRow>>;
9
+ /** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
10
+ export declare const tableTools: () => string[];
11
+ /** Whether `name` has a row: a built-in this server registers (table tool, background tool, learned workflow). */
12
+ export declare const isToolRow: (name: string) => boolean;
13
+ /** Whether `name` is a tool of the table. */
14
+ export declare const isTableTool: (name: string) => boolean;
15
+ /** Whether ask is offered for `name`: the kernel runs its approved call itself. */
16
+ export declare const isAskable: (name: string) => boolean;
17
+ /** Whether a host runs `name` on a harness other than pi: it has a replay class. */
18
+ export declare const isHostTool: (name: string) => boolean;
19
+ /** `name`'s replay class as a host runs it, or none. */
20
+ export declare const replayOf: (name: string) => "safe" | "never" | undefined;
21
+ /** The tools a host runs on a harness other than pi, by name. */
22
+ export declare const hostToolNames: () => string[];
23
+ /** Whether `name` is a web tool every harness binds as a host tool (web_fetch, web_search). */
24
+ export declare const isWebHostTool: (name: string) => boolean;
25
+ /** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
26
+ export declare const blurbOf: (name: string) => string | undefined;
@@ -0,0 +1,43 @@
1
+ export const TOOL_LIST = Object.freeze({
2
+ read: { table: true, askable: true, replay: "safe", blurb: "Read files in the run's folder" },
3
+ write: { table: true, askable: true, replay: "never", blurb: "Write files in the run's folder" },
4
+ edit: { table: true, askable: true, replay: "never", blurb: "Edit files in the run's folder" },
5
+ bash: { table: true, askable: true, replay: "never", blurb: "Run shell commands in the sandbox" },
6
+ ask_person: { table: true, replay: "safe", blurb: "Ask you a question mid-run" },
7
+ web_fetch: { table: true, askable: true, replay: "safe", host: true, blurb: "Read a public web page" },
8
+ web_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the web" },
9
+ browser: { table: true, blurb: "Browse websites in a hosted browser" },
10
+ subagent: { table: true, blurb: "Run a task in a fresh helper conversation" },
11
+ pdf_pages: { table: true, blurb: "Turn a PDF's pages into images" },
12
+ llm: { table: true, blurb: "Ask the model once, with no tools" },
13
+ bash_background: { replay: "never", blurb: "Start a long-running command in the sandbox" },
14
+ bash_output: { replay: "safe", blurb: "Read a background command's output" },
15
+ bash_input: { replay: "never", blurb: "Send input to a background command" },
16
+ bash_signal: { replay: "never", blurb: "Stop a background command" },
17
+ bash_list: { replay: "safe", blurb: "List the background commands" },
18
+ learned_workflow: { askable: true, replay: "never", blurb: "Run a workflow this agent learned" },
19
+ // The host tools over a run's own tools (runner/meta-tools.ts): no table entry and never granted, a settings key each.
20
+ tools_search: { blurb: "Find a tool by what it does, in a long list" },
21
+ tools_call: { blurb: "Call a tool the run does not list" },
22
+ codemode: { blurb: "Run a script that calls the run's tools" },
23
+ });
24
+ const rowOf = (name) => (Object.hasOwn(TOOL_LIST, name) ? TOOL_LIST[name] : undefined);
25
+ const namesWith = (field) => Object.keys(TOOL_LIST).filter((name) => TOOL_LIST[name][field] !== undefined);
26
+ /** Every tool of serve's table (tools.ts), by name: a test holds this and the table as one. */
27
+ export const tableTools = () => namesWith("table");
28
+ /** Whether `name` has a row: a built-in this server registers (table tool, background tool, learned workflow). */
29
+ export const isToolRow = (name) => rowOf(name) !== undefined;
30
+ /** Whether `name` is a tool of the table. */
31
+ export const isTableTool = (name) => rowOf(name)?.table === true;
32
+ /** Whether ask is offered for `name`: the kernel runs its approved call itself. */
33
+ export const isAskable = (name) => rowOf(name)?.askable === true;
34
+ /** Whether a host runs `name` on a harness other than pi: it has a replay class. */
35
+ export const isHostTool = (name) => rowOf(name)?.replay !== undefined;
36
+ /** `name`'s replay class as a host runs it, or none. */
37
+ export const replayOf = (name) => rowOf(name)?.replay;
38
+ /** The tools a host runs on a harness other than pi, by name. */
39
+ export const hostToolNames = () => namesWith("replay");
40
+ /** Whether `name` is a web tool every harness binds as a host tool (web_fetch, web_search). */
41
+ export const isWebHostTool = (name) => rowOf(name)?.host === true;
42
+ /** `name`'s blurb, or none (an MCP server's tool, a name this server does not register). */
43
+ export const blurbOf = (name) => rowOf(name)?.blurb;
@@ -0,0 +1,71 @@
1
+ /** An MCP server's name. */
2
+ export declare const MCP_SERVER_NAME: RegExp;
3
+ /** An MCP tool's own name, as its server lists it. */
4
+ export declare const MCP_TOOL_NAME: RegExp;
5
+ /** A catalog tool's name, as a JSON Schema pattern (openapi.ts): `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`,
6
+ * or either's wildcard. */
7
+ export declare const CATALOG_KEY_PATTERN = "^(?:mcp:[a-z][a-z0-9-]{0,31}/(?:\\*|[A-Za-z0-9_-]{1,64})|monid:[a-z0-9][a-z0-9.-]{0,63}/(?:\\*|[A-Za-z0-9_.:{}-][A-Za-z0-9_.:{}/-]{0,199}))$";
8
+ /** A catalog name, read: a plain tool's, one MCP tool's or one monid endpoint's, or a group's wildcard (an MCP server's
9
+ * tools, a monid provider's endpoints). */
10
+ export type ToolName = {
11
+ kind: "plain";
12
+ name: string;
13
+ } | {
14
+ kind: "mcp";
15
+ server: string;
16
+ tool: string;
17
+ } | {
18
+ kind: "mcp-server";
19
+ server: string;
20
+ } | {
21
+ kind: "monid";
22
+ provider: string;
23
+ endpoint: string;
24
+ } | {
25
+ kind: "monid-provider";
26
+ provider: string;
27
+ };
28
+ /** Catalog name `name` read, or undefined for one outside the grammar. */
29
+ export declare function parseToolName(name: string): ToolName | undefined;
30
+ /** The catalog name of `name`: parseToolName's inverse. */
31
+ export declare function formatToolName(name: ToolName): string;
32
+ /** Whether `name` is in monid's namespace (`monid:`), well formed or not, as isMcpName is for MCP's. */
33
+ export declare const isMonidName: (name: string) => boolean;
34
+ /** Whether `name` is a third-party catalog's (MCP's or monid's), well formed or not: its default is ask. */
35
+ export declare const isCatalogName: (name: string) => boolean;
36
+ /** Why `name`, in monid's namespace, is refused as a grant by its name alone. */
37
+ export declare const MONID_NAME_WORDS: (name: string) => string;
38
+ /** One monid endpoint's catalog name read (`monid:<provider>/<endpoint>`), or undefined for any other name. */
39
+ export declare function monidNameOf(name: string): {
40
+ provider: string;
41
+ endpoint: string;
42
+ } | undefined;
43
+ /** One MCP tool's catalog name, `mcp:<server>/<tool>`: what the gate, the pin and the timeline key its calls by. */
44
+ export declare const mcpToolName: (server: string, tool: string) => string;
45
+ /** Whether `name` is in MCP's namespace (`mcp:`), well formed or not: a name MCP's checks answer for, so one that does
46
+ * not parse is refused in MCP's words, and the gate's default for it is MCP's (ask), never a built-in's. */
47
+ export declare const isMcpName: (name: string) => boolean;
48
+ /** One MCP tool's catalog name read (`mcp:<server>/<tool>`), or undefined for any other name, a server's wildcard too. */
49
+ export declare function mcpNameOf(name: string): {
50
+ server: string;
51
+ tool: string;
52
+ } | undefined;
53
+ /** The MCP server `name` names, one of its tools or its wildcard; undefined for any other name. */
54
+ export declare function mcpServerOf(name: string): string | undefined;
55
+ /** Whether `name` is an MCP server's wildcard, `mcp:<server>/*`. */
56
+ export declare const isMcpWildcard: (name: string) => boolean;
57
+ /** Why a grant of an MCP server's tool is refused by its name alone, said after the grant (`mcp:<server>/<tool> ...`): the
58
+ * one place the console's picker and the save's blockers (runnable.ts) both read it. `hands` is the harnesses' own tools'
59
+ * server. */
60
+ export declare const MCP_HANDS_WORDS = "names the MCP server hands, a name the harnesses keep for their own tools: save the server under another name.";
61
+ /** Why `mcp__<server>__<tool>`, the name every harness calls the tool by, is not within the budget their names share
62
+ * (52 characters of letters, digits, `_` and `-`), or undefined when it is. */
63
+ export declare function mcpWireProblem(server: string, tool: string): string | undefined;
64
+ /** MCP_HANDS_WORDS or mcpWireProblem's, whichever refuses the name; undefined when neither does. */
65
+ export declare const mcpGrantNameProblem: (server: string, tool: string) => string | undefined;
66
+ /** Why a harness's own MCP client drops or retypes `tool` of `server` (its facts' schemaProblems, `dropped` the first):
67
+ * the words a save's blocker and a saved server's read both say. */
68
+ export declare const mcpDroppedWords: (server: string, tool: string, harness: string, dropped: string) => string;
69
+ /** Why the harness drops or retypes the pinned monid endpoint `tool`'s input (its facts' schemaProblems, `dropped` the
70
+ * first, under the endpoint's wire name): the words a save refuses its grant with. */
71
+ export declare const monidDroppedWords: (tool: string, harness: string, dropped: string) => string;