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

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 (423) hide show
  1. package/CHANGELOG.md +455 -0
  2. package/README.md +376 -125
  3. package/dist/adapters.d.ts +4 -1
  4. package/dist/adapters.js +4 -2
  5. package/dist/agent-rows.d.ts +0 -2
  6. package/dist/agents-store.d.ts +5 -5
  7. package/dist/agents-store.js +14 -14
  8. package/dist/bash-read-only.js +2 -1
  9. package/dist/cap-short.d.ts +12 -0
  10. package/dist/cap-short.js +60 -0
  11. package/dist/cap.d.ts +3 -10
  12. package/dist/cap.js +2 -5
  13. package/dist/catalog.d.ts +0 -5
  14. package/dist/catalog.js +1 -5
  15. package/dist/chatgpt-plan.d.ts +163 -0
  16. package/dist/chatgpt-plan.js +549 -0
  17. package/dist/cli.js +26 -6
  18. package/dist/composio-preset.d.ts +8 -0
  19. package/dist/composio-preset.js +8 -7
  20. package/dist/composio-triggers.d.ts +113 -0
  21. package/dist/composio-triggers.js +411 -0
  22. package/dist/computer-calls.js +2 -2
  23. package/dist/computer-commands.d.ts +2 -0
  24. package/dist/computer-commands.js +7 -3
  25. package/dist/computer-live.d.ts +7 -2
  26. package/dist/computer-live.js +9 -5
  27. package/dist/computer-routes.d.ts +2 -2
  28. package/dist/computer-routes.js +2 -2
  29. package/dist/computer-setting.d.ts +3 -3
  30. package/dist/computer-setting.js +5 -5
  31. package/dist/computer-view.d.ts +15 -0
  32. package/dist/computer-view.js +16 -2
  33. package/dist/computer-viewer.js +14 -1
  34. package/dist/computers.d.ts +5 -2
  35. package/dist/computers.js +9 -5
  36. package/dist/console/assets/index-B8Zn1Iqn.css +1 -0
  37. package/dist/console/assets/index-Jbxjcmdp.js +705 -0
  38. package/dist/console/index.html +2 -2
  39. package/dist/console-links.js +3 -3
  40. package/dist/decision-cap.d.ts +2 -5
  41. package/dist/decision-cap.js +3 -6
  42. package/dist/decision-rows.js +11 -11
  43. package/dist/email/account.d.ts +83 -0
  44. package/dist/email/account.js +159 -0
  45. package/dist/email/answer.d.ts +15 -0
  46. package/dist/email/answer.js +217 -0
  47. package/dist/email/email-faux.d.ts +95 -0
  48. package/dist/email/email-faux.js +849 -0
  49. package/dist/email/labels.d.ts +1 -0
  50. package/dist/email/labels.js +84 -0
  51. package/dist/email/mail.d.ts +186 -0
  52. package/dist/email/mail.js +373 -0
  53. package/dist/email/names.d.ts +50 -0
  54. package/dist/email/names.js +74 -0
  55. package/dist/email/routes.d.ts +10 -0
  56. package/dist/email/routes.js +50 -0
  57. package/dist/email/tools.d.ts +27 -0
  58. package/dist/email/tools.js +562 -0
  59. package/dist/environment.d.ts +17 -2
  60. package/dist/environment.js +36 -8
  61. package/dist/errors.d.ts +6 -0
  62. package/dist/errors.js +12 -0
  63. package/dist/eval-mailbox.d.ts +103 -0
  64. package/dist/eval-mailbox.js +236 -0
  65. package/dist/graph-view.d.ts +9 -2
  66. package/dist/graph-view.js +6 -2
  67. package/dist/harness-install.d.ts +28 -2
  68. package/dist/harness-install.js +147 -59
  69. package/dist/harness-opencode/adapter.js +2 -26
  70. package/dist/harness-opencode/facts.js +5 -2
  71. package/dist/harness-opencode/host/policy.d.ts +2 -0
  72. package/dist/harness-opencode/host/policy.js +10 -5
  73. package/dist/harness-opencode/index.d.ts +1 -1
  74. package/dist/harness-opencode/index.js +1 -1
  75. package/dist/harness-opencode/versions.d.ts +6 -0
  76. package/dist/harness-opencode/versions.js +6 -0
  77. package/dist/harness-table.js +8 -5
  78. package/dist/harness.d.ts +12 -0
  79. package/dist/harness.js +15 -3
  80. package/dist/hosted-search.d.ts +3 -1
  81. package/dist/hosted-search.js +51 -11
  82. package/dist/import-sources.d.ts +1 -1
  83. package/dist/import-sources.js +3 -3
  84. package/dist/import.d.ts +21 -0
  85. package/dist/import.js +186 -1
  86. package/dist/key-check.d.ts +0 -2
  87. package/dist/key-check.js +3 -4
  88. package/dist/key-refusal.d.ts +8 -2
  89. package/dist/key-refusal.js +16 -13
  90. package/dist/learn/check.d.ts +18 -3
  91. package/dist/learn/check.js +328 -3
  92. package/dist/learn/compile.d.ts +12 -4
  93. package/dist/learn/compile.js +57 -20
  94. package/dist/learn/grade.d.ts +4 -0
  95. package/dist/learn/grade.js +4 -1
  96. package/dist/learn/promote.d.ts +130 -64
  97. package/dist/learn/promote.js +113 -202
  98. package/dist/learn/refit.d.ts +21 -12
  99. package/dist/learn/refit.js +51 -23
  100. package/dist/learn/replay-calls.js +1 -1
  101. package/dist/learn/skills.d.ts +2 -7
  102. package/dist/learn/skills.js +28 -14
  103. package/dist/learned-nodes.d.ts +15 -7
  104. package/dist/learned-nodes.js +29 -5
  105. package/dist/learned-workflow.d.ts +41 -31
  106. package/dist/learned-workflow.js +122 -63
  107. package/dist/learning-batch.js +3 -3
  108. package/dist/learning-cost.d.ts +35 -8
  109. package/dist/learning-cost.js +27 -9
  110. package/dist/learning-routes.d.ts +2 -4
  111. package/dist/learning-routes.js +20 -3
  112. package/dist/learning-words.d.ts +1 -1
  113. package/dist/learning-words.js +4 -1
  114. package/dist/learning.d.ts +5 -5
  115. package/dist/link-check.d.ts +27 -0
  116. package/dist/link-check.js +164 -0
  117. package/dist/local-models.d.ts +39 -2
  118. package/dist/local-models.js +49 -5
  119. package/dist/mcp-pin-first.js +6 -0
  120. package/dist/mcp-secret-writes.js +3 -0
  121. package/dist/mcp-servers-store.d.ts +25 -16
  122. package/dist/mcp-servers-store.js +23 -3
  123. package/dist/model-form.d.ts +11 -0
  124. package/dist/model-form.js +17 -1
  125. package/dist/model.d.ts +26 -6
  126. package/dist/model.js +126 -18
  127. package/dist/monid.d.ts +26 -31
  128. package/dist/monid.js +84 -79
  129. package/dist/native/binding.d.ts +13 -0
  130. package/dist/native/binding.js +57 -0
  131. package/dist/native/cli.d.ts +2 -0
  132. package/dist/native/cli.js +48 -0
  133. package/dist/native/connection.d.ts +8 -0
  134. package/dist/native/connection.js +94 -0
  135. package/dist/native/context.d.ts +6 -0
  136. package/dist/native/context.js +22 -0
  137. package/dist/native/discovery.d.ts +27 -0
  138. package/dist/native/discovery.js +404 -0
  139. package/dist/native/environment.d.ts +4 -0
  140. package/dist/native/environment.js +18 -0
  141. package/dist/native/history.d.ts +20 -0
  142. package/dist/native/history.js +147 -0
  143. package/dist/native/instructions.d.ts +21 -0
  144. package/dist/native/instructions.js +173 -0
  145. package/dist/native/remote-worker-bridge.d.ts +3 -0
  146. package/dist/native/remote-worker-bridge.js +278 -0
  147. package/dist/native/remote.d.ts +187 -0
  148. package/dist/native/remote.js +492 -0
  149. package/dist/native/runtime.d.ts +17 -0
  150. package/dist/native/runtime.js +316 -0
  151. package/dist/native/runtimes.d.ts +66 -0
  152. package/dist/native/runtimes.js +41 -0
  153. package/dist/native/schema.d.ts +46 -0
  154. package/dist/native/schema.js +41 -0
  155. package/dist/native/types.d.ts +87 -0
  156. package/dist/native/types.js +1 -0
  157. package/dist/observation/http.d.ts +4 -0
  158. package/dist/observation/http.js +140 -0
  159. package/dist/observation/observer.d.ts +301 -0
  160. package/dist/observation/observer.js +919 -0
  161. package/dist/observation/schema.d.ts +52 -0
  162. package/dist/observation/schema.js +154 -0
  163. package/dist/openapi.d.ts +2 -1
  164. package/dist/openapi.js +404 -93
  165. package/dist/paid-calls.d.ts +8 -3
  166. package/dist/paid-calls.js +6 -2
  167. package/dist/place-offers.d.ts +4 -8
  168. package/dist/place-offers.js +4 -9
  169. package/dist/port-models.d.ts +10 -2
  170. package/dist/port-models.js +6 -2
  171. package/dist/print.d.ts +4 -2
  172. package/dist/print.js +4 -3
  173. package/dist/propose.d.ts +1 -2
  174. package/dist/propose.js +10 -1
  175. package/dist/provider.d.ts +5 -1
  176. package/dist/provider.js +8 -0
  177. package/dist/push-handler.d.ts +3 -2
  178. package/dist/push-handler.js +20 -6
  179. package/dist/refusal-words.d.ts +14 -0
  180. package/dist/refusal-words.js +16 -2
  181. package/dist/run-launch.d.ts +12 -1
  182. package/dist/run-launch.js +13 -4
  183. package/dist/run-learning-served.d.ts +75 -2
  184. package/dist/run-manifest.d.ts +3 -0
  185. package/dist/run-manifest.js +13 -1
  186. package/dist/run-reads-over-store.d.ts +3 -3
  187. package/dist/run-reads-over-store.js +13 -10
  188. package/dist/run-timeline-served.d.ts +3 -2
  189. package/dist/run-timeline-served.js +8 -9
  190. package/dist/run-view.d.ts +44 -38
  191. package/dist/run-view.js +93 -56
  192. package/dist/runnable.d.ts +13 -5
  193. package/dist/runnable.js +69 -60
  194. package/dist/runner/adapter-loop.d.ts +48 -13
  195. package/dist/runner/adapter-loop.js +691 -254
  196. package/dist/runner/adapter-run-spec.d.ts +38 -12
  197. package/dist/runner/adapter-run-spec.js +175 -106
  198. package/dist/runner/adapters/pi.d.ts +24 -0
  199. package/dist/runner/adapters/pi.js +59 -9
  200. package/dist/runner/beside.d.ts +3 -1
  201. package/dist/runner/beside.js +24 -8
  202. package/dist/runner/claim-secrets.d.ts +3 -1
  203. package/dist/runner/claim-secrets.js +28 -4
  204. package/dist/runner/cli-run-spec.d.ts +30 -0
  205. package/dist/runner/cli-run-spec.js +95 -50
  206. package/dist/runner/computer-channel.d.ts +5 -2
  207. package/dist/runner/computer-channel.js +3 -2
  208. package/dist/runner/computer-journal.d.ts +6 -0
  209. package/dist/runner/computer-journal.js +8 -10
  210. package/dist/runner/conformance/harness.js +6 -3
  211. package/dist/runner/end-of-run.d.ts +2 -0
  212. package/dist/runner/end-of-run.js +3 -1
  213. package/dist/runner/feedback-round.d.ts +40 -13
  214. package/dist/runner/feedback-round.js +64 -16
  215. package/dist/runner/harness-loops.js +17 -0
  216. package/dist/runner/journal-kinds.d.ts +59 -13
  217. package/dist/runner/journal-kinds.js +48 -5
  218. package/dist/runner/learning-dispatch.d.ts +3 -2
  219. package/dist/runner/learning-dispatch.js +6 -6
  220. package/dist/runner/learning-end.d.ts +4 -0
  221. package/dist/runner/learning-end.js +64 -36
  222. package/dist/runner/learning-factory.d.ts +3 -0
  223. package/dist/runner/learning-factory.js +8 -2
  224. package/dist/runner/learning-loop.d.ts +2 -0
  225. package/dist/runner/learning-loop.js +19 -4
  226. package/dist/runner/loop.d.ts +18 -0
  227. package/dist/runner/loop.js +34 -0
  228. package/dist/runner/main.d.ts +6 -1
  229. package/dist/runner/main.js +26 -4
  230. package/dist/runner/mcp-run.d.ts +4 -1
  231. package/dist/runner/mcp-run.js +11 -5
  232. package/dist/runner/meta-tools.d.ts +10 -3
  233. package/dist/runner/meta-tools.js +112 -36
  234. package/dist/runner/metrics.d.ts +80 -21
  235. package/dist/runner/metrics.js +114 -39
  236. package/dist/runner/model-route.d.ts +14 -3
  237. package/dist/runner/model-route.js +155 -19
  238. package/dist/runner/monid-run.d.ts +8 -6
  239. package/dist/runner/monid-run.js +117 -43
  240. package/dist/runner/native-loop.d.ts +11 -0
  241. package/dist/runner/native-loop.js +438 -0
  242. package/dist/runner/promotion.d.ts +76 -10
  243. package/dist/runner/promotion.js +476 -154
  244. package/dist/runner/redact.js +3 -0
  245. package/dist/runner/reflect-hook.js +9 -0
  246. package/dist/runner/runner.d.ts +7 -1
  247. package/dist/runner/runner.js +8 -4
  248. package/dist/runner/sdk-loop.d.ts +7 -0
  249. package/dist/runner/sdk-loop.js +470 -0
  250. package/dist/runner/spec-holds.d.ts +16 -2
  251. package/dist/runner/spec-holds.js +42 -14
  252. package/dist/runner/store-secrets.js +17 -2
  253. package/dist/runner/workflow-first.d.ts +30 -20
  254. package/dist/runner/workflow-first.js +22 -32
  255. package/dist/runner/workflow-loop.d.ts +1 -1
  256. package/dist/runner/workflow-loop.js +18 -12
  257. package/dist/runner/workflow-spec.d.ts +4 -1
  258. package/dist/runner/workflow-spec.js +56 -45
  259. package/dist/runs-over-store.d.ts +30 -2
  260. package/dist/runs-over-store.js +46 -14
  261. package/dist/sdk/runs.d.ts +115 -0
  262. package/dist/sdk/runs.js +422 -0
  263. package/dist/sdk/schema.d.ts +175 -0
  264. package/dist/sdk/schema.js +138 -0
  265. package/dist/sdk/workflows.d.ts +22 -0
  266. package/dist/sdk/workflows.js +39 -0
  267. package/dist/secrets.d.ts +2 -0
  268. package/dist/secrets.js +19 -1
  269. package/dist/server.d.ts +48 -32
  270. package/dist/server.js +568 -137
  271. package/dist/skill-route.d.ts +3 -0
  272. package/dist/skill-route.js +16 -0
  273. package/dist/skills/agentrun-serve/SKILL.md +368 -0
  274. package/dist/stats.d.ts +10 -10
  275. package/dist/store/agent-body.d.ts +12 -8
  276. package/dist/store/agent-body.js +9 -4
  277. package/dist/store/dialect.d.ts +3 -0
  278. package/dist/store/dialect.js +1 -0
  279. package/dist/store/index.d.ts +1 -1
  280. package/dist/store/native-command-owner.d.ts +10 -0
  281. package/dist/store/native-command-owner.js +47 -0
  282. package/dist/store/postgres/connection.d.ts +11 -5
  283. package/dist/store/postgres/connection.js +44 -17
  284. package/dist/store/postgres/dialect.js +5 -0
  285. package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
  286. package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
  287. package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
  288. package/dist/store/postgres/store.d.ts +7 -3
  289. package/dist/store/postgres/store.js +4 -0
  290. package/dist/store/schema.d.ts +7 -0
  291. package/dist/store/schema.js +20 -1
  292. package/dist/store/sqlite/connection.js +72 -8
  293. package/dist/store/sqlite/run-launch.d.ts +11 -0
  294. package/dist/store/sqlite/run-launch.js +8 -0
  295. package/dist/store/sqlite/run-patch.d.ts +8 -1
  296. package/dist/store/sqlite/run-patch.js +14 -3
  297. package/dist/store/sqlite/store.js +170 -34
  298. package/dist/store/sqlite/worker.d.ts +2 -0
  299. package/dist/store/sqlite/worker.js +13 -10
  300. package/dist/store/store.d.ts +67 -7
  301. package/dist/store-reads/analytics.d.ts +7 -7
  302. package/dist/store-reads/analytics.js +23 -5
  303. package/dist/store-reads/cap.js +8 -6
  304. package/dist/store-reads/journal.d.ts +5 -0
  305. package/dist/store-reads/journal.js +85 -41
  306. package/dist/store-reads/learning.d.ts +115 -18
  307. package/dist/store-reads/learning.js +170 -68
  308. package/dist/store-reads/runs.d.ts +5 -0
  309. package/dist/store-reads/runs.js +3 -2
  310. package/dist/store-view.js +75 -21
  311. package/dist/template-eval.d.ts +73 -11
  312. package/dist/template-eval.js +535 -75
  313. package/dist/templates.d.ts +84 -21
  314. package/dist/templates.js +254 -47
  315. package/dist/text-urls.d.ts +38 -0
  316. package/dist/text-urls.js +170 -0
  317. package/dist/timeline/index.d.ts +3 -2
  318. package/dist/timeline/index.js +3 -2
  319. package/dist/timeline/labels.d.ts +5 -2
  320. package/dist/timeline/labels.js +29 -6
  321. package/dist/timeline/origin.d.ts +1 -1
  322. package/dist/timeline/origin.js +2 -2
  323. package/dist/timeline/render-text.js +1 -1
  324. package/dist/timeline/timeline.d.ts +66 -4
  325. package/dist/timeline/timeline.js +160 -30
  326. package/dist/timeline/util.d.ts +5 -0
  327. package/dist/timeline/util.js +44 -8
  328. package/dist/timeline/web-calls.d.ts +17 -0
  329. package/dist/timeline/web-calls.js +106 -0
  330. package/dist/tool-gate.d.ts +46 -44
  331. package/dist/tool-gate.js +101 -92
  332. package/dist/tool-list.d.ts +4 -1
  333. package/dist/tool-list.js +8 -1
  334. package/dist/tool-names.d.ts +18 -13
  335. package/dist/tool-names.js +19 -17
  336. package/dist/tool-plane.d.ts +17 -13
  337. package/dist/tool-plane.js +12 -5
  338. package/dist/tools.d.ts +57 -16
  339. package/dist/tools.js +33 -28
  340. package/dist/trigger-adapter.d.ts +56 -5
  341. package/dist/trigger-adapter.js +6 -0
  342. package/dist/trigger-adapters.js +3 -1
  343. package/dist/trigger-composio.d.ts +10 -0
  344. package/dist/trigger-composio.js +122 -0
  345. package/dist/trigger-email.d.ts +4 -0
  346. package/dist/trigger-email.js +181 -0
  347. package/dist/trigger-signatures.d.ts +6 -10
  348. package/dist/trigger-signatures.js +16 -16
  349. package/dist/trigger-targets.d.ts +1 -1
  350. package/dist/trigger-targets.js +4 -3
  351. package/dist/trigger-webhook.js +6 -4
  352. package/dist/triggers.d.ts +105 -8
  353. package/dist/triggers.js +286 -62
  354. package/dist/uploads.d.ts +9 -0
  355. package/dist/uploads.js +27 -0
  356. package/dist/validate.js +1 -7
  357. package/dist/web-fake.d.ts +56 -0
  358. package/dist/web-fake.js +102 -0
  359. package/dist/web-fetch-direct.d.ts +3 -0
  360. package/dist/web-fetch-direct.js +4 -1
  361. package/dist/web-fetch.d.ts +5 -1
  362. package/dist/web-fetch.js +8 -31
  363. package/dist/web-search.d.ts +51 -2
  364. package/dist/web-search.js +116 -18
  365. package/dist/webhooks.d.ts +2 -1
  366. package/dist/webhooks.js +5 -1
  367. package/dist/workflow/decision-recovery.js +5 -2
  368. package/dist/workflow/decisions.d.ts +7 -0
  369. package/dist/workflow/node-runner.js +10 -2
  370. package/dist/workspace/archil-claim.d.ts +3 -0
  371. package/dist/workspace/archil-claim.js +9 -2
  372. package/dist/workspace/computer-deps.d.ts +22 -9
  373. package/dist/workspace/computer-deps.js +78 -37
  374. package/dist/workspace/computer-for-claim.d.ts +54 -4
  375. package/dist/workspace/computer-for-claim.js +179 -39
  376. package/dist/workspace/computer-janitor.d.ts +10 -3
  377. package/dist/workspace/computer-janitor.js +96 -29
  378. package/dist/workspace/computer-kept.d.ts +82 -0
  379. package/dist/workspace/computer-kept.js +147 -0
  380. package/dist/workspace/computer-mcp.js +4 -3
  381. package/dist/workspace/computer-ports.d.ts +23 -3
  382. package/dist/workspace/computer-ports.js +115 -5
  383. package/dist/workspace/index.d.ts +1 -2
  384. package/dist/workspace/index.js +1 -2
  385. package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
  386. package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
  387. package/dist/workspace/resolve-computer.d.ts +15 -3
  388. package/dist/workspace/resolve-computer.js +10 -7
  389. package/dist/workspace/revision-skills.d.ts +6 -2
  390. package/dist/workspace/revision-skills.js +12 -5
  391. package/dist/workspace/run-end-computers.d.ts +30 -0
  392. package/dist/workspace/run-end-computers.js +137 -0
  393. package/dist/workspace/run-tools.d.ts +28 -29
  394. package/dist/workspace/run-tools.js +29 -30
  395. package/dist/wrap-up.d.ts +19 -5
  396. package/dist/wrap-up.js +31 -4
  397. package/package.json +13 -9
  398. package/skills/agentrun-serve/SKILL.md +248 -10
  399. package/templates/README.md +117 -23
  400. package/templates/TOOLS.md +168 -0
  401. package/templates/code-review/agent.md +18 -4
  402. package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
  404. package/templates/code-review/evals/other-repo/case.yaml +1 -1
  405. package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
  406. package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
  407. package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
  408. package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
  409. package/templates/code-review/skills/review/DEEP.md +2 -2
  410. package/templates/code-review/skills/review/REVIEWER.md +2 -2
  411. package/templates/code-review/skills/review/SKILL.md +7 -3
  412. package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
  413. package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
  414. package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
  415. package/templates/release-notes/evals/other-repo/case.yaml +1 -1
  416. package/dist/console/assets/index-CjqQirbo.css +0 -1
  417. package/dist/console/assets/index-b6-XY5A9.js +0 -576
  418. package/dist/host-calls.d.ts +0 -20
  419. package/dist/host-calls.js +0 -12
  420. package/dist/runner/adapters/pi-computer.d.ts +0 -9
  421. package/dist/runner/adapters/pi-computer.js +0 -51
  422. package/dist/workspace/computer-script.d.ts +0 -53
  423. package/dist/workspace/computer-script.js +0 -172
@@ -9,7 +9,13 @@
9
9
  // A monid provider's slug and an endpoint's path are monid's own (its listing, GET /v1/endpoints): a slug is lowercase
10
10
  // letters, digits, `.` and `-` (`apollo`, `api.strale.io`); an endpoint is its path less the leading `/`, in letters,
11
11
  // digits and `-._:{}/` (`people/match`, `people/{id}`). Its wire name is catalog.ts wireName's, hashed when long.
12
- import { WIRE_NAME } from "./catalog.js";
12
+ // It imports nothing (its test holds it to that): the console bundles it from source, as `@agentrun/tool-names`.
13
+ /** A wire name: at most 52 characters, not the adapter's 64. One CLI gives the model the name with a 12-character
14
+ * `mcp__hands__` prefix, and the model API's 64-character limit is on the name the model sees, so 52 is the budget that
15
+ * holds on every harness. The identity branch reads it: a plain 53-64 character name of valid characters must not skip
16
+ * the mapping and come out over budget. An MCP tool whose `mcp__<server>__<tool>` is past it (Composio's 58-character
17
+ * `mcp__slack__SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION`) is granted and called by its hashed name. */
18
+ export const WIRE_NAME = /^[A-Za-z0-9_-]{1,52}$/;
13
19
  const SERVER = "[a-z][a-z0-9-]{0,31}";
14
20
  const TOOL = "[A-Za-z0-9_-]{1,64}";
15
21
  const PROVIDER = "[a-z0-9][a-z0-9.-]{0,63}";
@@ -25,6 +31,8 @@ export const MCP_TOOL_NAME = new RegExp(`^${TOOL}$`);
25
31
  /** A catalog tool's name, as a JSON Schema pattern (openapi.ts): `mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`,
26
32
  * or either's wildcard. */
27
33
  export const CATALOG_KEY_PATTERN = `^(?:mcp:${SERVER}/(?:\\*|${TOOL})|monid:${PROVIDER}/(?:\\*|${ENDPOINT}))$`;
34
+ /** One MCP tool's catalog key, without a server wildcard: the same server/tool grammar as mcpNameOf. */
35
+ export const MCP_TOOL_KEY_PATTERN = `^mcp:${SERVER}/${TOOL}$`;
28
36
  const MCP_NAME = new RegExp(`^mcp:(${SERVER})/(\\*|${TOOL})$`);
29
37
  const MONID_NAME = new RegExp(`^monid:(${PROVIDER})/(\\*|${ENDPOINT})$`);
30
38
  const PLAIN_NAME = new RegExp(`^${PLAIN}$`);
@@ -77,23 +85,17 @@ export function mcpServerOf(name) {
77
85
  const parsed = parseToolName(name);
78
86
  return parsed?.kind === "mcp" || parsed?.kind === "mcp-server" ? parsed.server : undefined;
79
87
  }
80
- /** Whether `name` is an MCP server's wildcard, `mcp:<server>/*`. */
81
- export const isMcpWildcard = (name) => parseToolName(name)?.kind === "mcp-server";
82
88
  /** Why a grant of an MCP server's tool is refused by its name alone, said after the grant (`mcp:<server>/<tool> ...`): the
83
89
  * one place the console's picker and the save's blockers (runnable.ts) both read it. `hands` is the harnesses' own tools'
84
90
  * server. */
85
91
  export const MCP_HANDS_WORDS = "names the MCP server hands, a name the harnesses keep for their own tools: save the server under another name.";
86
- /** Why `mcp__<server>__<tool>`, the name every harness calls the tool by, is not within the budget their names share
87
- * (52 characters of letters, digits, `_` and `-`), or undefined when it is. */
88
- export function mcpWireProblem(server, tool) {
89
- const wire = `mcp__${server}__${tool}`;
90
- return WIRE_NAME.test(wire) ? undefined : `is too long: ${wire} must be at most 52 characters, the budget every harness's tool names share.`;
91
- }
92
- /** MCP_HANDS_WORDS or mcpWireProblem's, whichever refuses the name; undefined when neither does. */
93
- export const mcpGrantNameProblem = (server, tool) => (server === "hands" ? MCP_HANDS_WORDS : mcpWireProblem(server, tool));
94
- /** Why a harness's own MCP client drops or retypes `tool` of `server` (its facts' schemaProblems, `dropped` the first):
95
- * the words a save's blocker and a saved server's read both say. */
96
- export const mcpDroppedWords = (server, tool, harness, dropped) => `The MCP server ${server}'s tool ${tool} cannot be offered on ${harness}: ${dropped.replace(/^mcp__\S+: /, "")}.`;
97
- /** Why the harness drops or retypes the pinned monid endpoint `tool`'s input (its facts' schemaProblems, `dropped` the
98
- * first, under the endpoint's wire name): the words a save refuses its grant with. */
99
- export const monidDroppedWords = (tool, harness, dropped) => `The monid endpoint ${tool} cannot be offered on ${harness}: ${dropped.replace(/^monid__\S+: /, "")}. Grant its provider's other endpoints by name, or pick another harness.`;
92
+ /** MCP_HANDS_WORDS when the grant names the server `hands`; undefined otherwise. A name's length refuses nothing: one whose
93
+ * `mcp__<server>__<tool>` is past the budget every harness's names share is called by its hashed wire name (catalog.ts
94
+ * wireName), and read back by lookup. */
95
+ export const mcpGrantNameProblem = (server, _tool) => (server === "hands" ? MCP_HANDS_WORDS : undefined);
96
+ /** Why two granted catalog tools can't both be granted: the harnesses call both by one wire name (`wire`, catalog.ts
97
+ * wireName), so neither could be told apart. Said after the later grant. */
98
+ export const sameWireWords = (tool, other, wire) => `${tool} and ${other} are called by one name on every harness (${wire}): grant one of them by name.`;
99
+ /** Why `harness` drops or retypes the input of the catalog tool `tool` (its facts' schemaProblems, `dropped` the first,
100
+ * said under the tool's wire name): the words a save's blocker and a saved MCP server's read both say. */
101
+ export const droppedWords = (tool, harness, dropped) => `The tool ${tool} cannot be offered on ${harness}: ${dropped.replace(/^[A-Za-z0-9_-]+: /, "")}.`;
@@ -4,6 +4,9 @@ import { type HarnessId } from "./harness.js";
4
4
  import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
5
5
  import { type Permission, type Pin, type ToolEffect } from "./tool-gate.js";
6
6
  import { type BashPolicy } from "./bash-read-only.js";
7
+ import { EMAIL_SCOPES } from "./email/names.js";
8
+ /** An email read tool's scope (email/names.ts). */
9
+ type EmailScope = (typeof EMAIL_SCOPES)[number];
7
10
  /**
8
11
  * The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
9
12
  * table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
@@ -36,11 +39,11 @@ export declare const permissionsOf: (name: string) => readonly Permission[];
36
39
  * give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
37
40
  * those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
38
41
  export declare const serverGate: (name: string, settings: ToolSettingsMap, effect?: ToolEffect) => {
39
- default_permission: "ask" | "deny" | "allow";
40
- permissions: ("ask" | "deny" | "allow")[];
42
+ default_permission: "allow" | "ask" | "deny";
43
+ permissions: ("allow" | "ask" | "deny")[];
41
44
  fallback_allow_reads?: true | undefined;
42
45
  allow_reads?: true | undefined;
43
- permission: "ask" | "deny" | "allow";
46
+ permission: "allow" | "ask" | "deny";
44
47
  };
45
48
  /** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
46
49
  * workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL), and the host's
@@ -61,7 +64,8 @@ export type ToolSetting = {
61
64
  permission?: Permission;
62
65
  pin?: Pin; /** On an MCP server's wildcard (`mcp:<server>/*`) in the server's settings only: the tools its server marks read-only run with no approval (tool-gate.ts readsLift). Kept only when true. */
63
66
  allow_reads?: true; /** bash's policy, an agent's own only (bash-read-only.ts). */
64
- policy?: BashPolicy; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
67
+ policy?: BashPolicy; /** An email read tool's scope, an agent's own only (email/tools.ts): its email run's thread (the default), or the whole account. */
68
+ scope?: EmailScope; /** Read as a stand-in for a value not offered (checkToolSettings); never shown or written. */
65
69
  fallback?: true; /** The stand-in's value as written in the file, which a save that keeps the stand-in writes back (ToolSettings.put). Never shown. */
66
70
  raw?: unknown; /** A pin in the file that does not read (readToolSettings): the gate refuses every call of the tool, and a save keeps it (ToolSettings.put) until the owner sets a valid pin or removes the tool's setting. Served as `pin_broken: true`. */
67
71
  brokenPin?: true; /** The broken pin as written in the file, which a save that keeps it writes back. Never shown. */
@@ -281,17 +285,17 @@ export declare function shellUnavailable(name: string, shell: ShellPlace): Resol
281
285
  * computer setting); a tool of bash's family that leaves out resolves unavailable, saying why (shellUnavailable). */
282
286
  export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[], shell?: ShellPlace, effectOf?: (name: string) => ToolEffect | undefined): ({
283
287
  resolved: Resolution;
284
- permission: "ask" | "deny" | "allow";
288
+ permission: "allow" | "ask" | "deny";
285
289
  permission_from: import("./refusal-words.js").SettingFrom;
286
- default_permission: "ask" | "deny" | "allow";
287
- permissions: ("ask" | "deny" | "allow")[];
290
+ default_permission: "allow" | "ask" | "deny";
291
+ permissions: ("allow" | "ask" | "deny")[];
288
292
  blurb?: string | undefined;
289
293
  name: string;
290
294
  } | {
291
- permission: "ask" | "deny" | "allow";
295
+ permission: "allow" | "ask" | "deny";
292
296
  permission_from: import("./refusal-words.js").SettingFrom;
293
- default_permission: "ask" | "deny" | "allow";
294
- permissions: ("ask" | "deny" | "allow")[];
297
+ default_permission: "allow" | "ask" | "deny";
298
+ permissions: ("allow" | "ask" | "deny")[];
295
299
  blurb?: string | undefined;
296
300
  name: string;
297
301
  } | {
@@ -299,10 +303,10 @@ export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSetting
299
303
  provider_from: string;
300
304
  default_provider: string;
301
305
  resolved: Resolution;
302
- permission: "ask" | "deny" | "allow";
306
+ permission: "allow" | "ask" | "deny";
303
307
  permission_from: import("./refusal-words.js").SettingFrom;
304
- default_permission: "ask" | "deny" | "allow";
305
- permissions: ("ask" | "deny" | "allow")[];
308
+ default_permission: "allow" | "ask" | "deny";
309
+ permissions: ("allow" | "ask" | "deny")[];
306
310
  blurb?: string | undefined;
307
311
  name: string;
308
312
  })[];
@@ -30,9 +30,10 @@ import { viaOpenRouter, WIRES } from "./provider.js";
30
30
  import { savedIn } from "./secrets.js";
31
31
  import { hostModel } from "./model.js";
32
32
  import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
33
- import { canonicalPin, defaultPermission, isCatalogTool, isPinKeys, MAX_PIN_ARGS, MAX_PIN_CHOICES, PERMISSIONS, permissionFrom, permissionOf, SETTINGS_UNREAD, SHELL_FAMILY } from "./tool-gate.js";
33
+ import { canonicalPin, defaultPermission, isPinKeys, MAX_PIN_ARGS, MAX_PIN_CHOICES, PERMISSIONS, permissionFrom, permissionOf, SETTINGS_UNREAD, SHELL_FAMILY } from "./tool-gate.js";
34
34
  import { BASH_POLICIES } from "./bash-read-only.js";
35
- import { isMcpName, mcpNameOf, parseToolName } from "./tool-names.js";
35
+ import { EMAIL_SCOPES, SCOPED_TOOLS, SCOPED_WORDS } from "./email/names.js";
36
+ import { isCatalogName, isMcpName, mcpNameOf, parseToolName } from "./tool-names.js";
36
37
  /**
37
38
  * The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
38
39
  * table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
@@ -55,7 +56,7 @@ export const PICKABLE = Object.keys(PROVIDERS);
55
56
  /** The permissions `name` may be set to: ask is offered for the tools whose approved call the kernel runs itself, outside
56
57
  * the model's turn (tool-list.ts `askable`) and for catalog tools. Any other (browser, ask_person, the call-only ones) is
57
58
  * allow or deny. */
58
- export const permissionsOf = (name) => (Object.hasOwn(SHELL_FAMILY, name) && SHELL_FAMILY[name] !== name ? permissionsOf(SHELL_FAMILY[name]) : isAskable(name) || isCatalogTool(name) ? PERMISSIONS : ["allow", "deny"]);
59
+ export const permissionsOf = (name) => (Object.hasOwn(SHELL_FAMILY, name) && SHELL_FAMILY[name] !== name ? permissionsOf(SHELL_FAMILY[name]) : isAskable(name) || isCatalogName(name) ? PERMISSIONS : ["allow", "deny"]);
59
60
  /** A tool's permission as this server applies it to an agent that sets none, as capabilities and an MCP server's read
60
61
  * give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
61
62
  * those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
@@ -94,7 +95,7 @@ export const DECISION_PROVIDER_KEYS = ["jev", "parallel", "openrouter"];
94
95
  * decision provider's (DECISION_PROVIDER_KEYS), a
95
96
  * catalog tool (`mcp:<server>/<tool>`, `monid:<provider>/<endpoint>`), or a group's wildcard (`mcp:<server>/*`,
96
97
  * `monid:<provider>/*`), which sets each of its tools. */
97
- const isSettingsKey = (name) => parseToolName(name) !== undefined && (isTableTool(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name) || isCatalogTool(name));
98
+ const isSettingsKey = (name) => parseToolName(name) !== undefined && (isTableTool(name) || SERVE_OWN_TOOLS.includes(name) || KIND_KEYS.includes(name) || DECISION_PROVIDER_KEYS.includes(name) || isCatalogName(name));
98
99
  /** The longest pinned string. */
99
100
  export const MAX_PIN_TEXT = 1024;
100
101
  /** A pinned argument's name: a top-level argument of the tool, as MCP tools name theirs. */
@@ -406,6 +407,12 @@ export function settingsIssues(value, at = "", layer = "server") {
406
407
  return [{ field: field(name, key), reason: "not_allowed", message: `A policy is set on bash in an agent's own tool settings (definition.tool_settings.bash.policy), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
407
408
  return BASH_POLICIES.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${BASH_POLICIES.join(", ")}: read-only refuses, before it runs, any command that could write, run code or read outside the run's folder` }];
408
409
  }
410
+ // An email tool's scope (email/tools.ts): an agent's own, on email_read, email_search and email_file only, set as bash's policy is.
411
+ if (key === "scope") {
412
+ if (layer !== "agent" || !SCOPED_TOOLS.includes(name))
413
+ return [{ field: field(name, key), reason: "not_allowed", message: `A scope is set on ${SCOPED_WORDS} in an agent's own tool settings (definition.tool_settings.email_read.scope), never ${layer === "agent" ? `on ${name}` : "in the server's"}.` }];
414
+ return EMAIL_SCOPES.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${EMAIL_SCOPES.join(", ")}: thread, an email's run reads its thread alone; mailbox, the whole account` }];
415
+ }
409
416
  // The server's own mark of a pin in its file that does not read (withDefaults serves it), which a whole-map save
410
417
  // sends back: it keeps the broken pin, and nothing else. Never an agent's.
411
418
  if (key === "pin_broken") {
@@ -440,7 +447,7 @@ export function canonicalToolSettings(map) {
440
447
  return sorted(Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
441
448
  if (!setting)
442
449
  return [];
443
- const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
450
+ const kept = sorted({ ...(setting.permission ? { permission: setting.permission } : {}), ...(setting.allow_reads === true ? { allow_reads: true } : {}), ...(setting.pin ? { pin: sortedPin(setting.pin) } : {}), ...(setting.policy ? { policy: setting.policy } : {}), ...(setting.scope ? { scope: setting.scope } : {}), ...(setting.provider ? { provider: setting.provider } : {}) });
444
451
  return Object.keys(kept).length ? [[name, kept]] : [];
445
452
  })));
446
453
  }
package/dist/tools.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./email/labels.js";
1
2
  import type { TSchema } from "typebox";
2
3
  import { type Extension, type Harness, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
3
4
  import type { Revision } from "./agent-rows.js";
@@ -8,6 +9,7 @@ import { type Ledger, type PaidBooking } from "./paid-calls.js";
8
9
  import type { Refusal } from "@parcha/agentrun-kernel";
9
10
  import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
10
11
  import { type SearchOn } from "./web-search.js";
12
+ import { type WebFake } from "./web-fake.js";
11
13
  import { type Plane, type Resolution, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
12
14
  import type { DenyFrom, SettingFrom } from "./tool-gate.js";
13
15
  import type { LiveHandover, LiveViewerStore } from "./browser-live.js";
@@ -76,7 +78,19 @@ export type ToolHost = {
76
78
  liveAt?: RunnerLive;
77
79
  /** The one store, for the live-viewer seam above, the run's saved sign-in (its runs and sign-ins, read under `claim`),
78
80
  * the sign-in verify the runner saves, and the Screen tab's ended state (settings: browser-wait-ended.ts). */
79
- store?: LiveViewerStore & Pick<Store, "runs" | "signIns" | "settings">;
81
+ store?: LiveViewerStore & Pick<Store, "runs" | "signIns" | "settings" | "sealedKeys">;
82
+ /** The trigger that started the run, and its source's kind (run-launch.ts trigger, inputOrigin): an email's run reads
83
+ * its thread alone (email/tools.ts). Absent: a person's run, or one no trigger started. */
84
+ startedBy?: {
85
+ readonly trigger: {
86
+ readonly id: string;
87
+ readonly firing_key: string;
88
+ readonly attrs?: Readonly<Record<string, string>>;
89
+ };
90
+ readonly source: string;
91
+ };
92
+ /** The agent's own tool settings (its revision's tool_settings), as its gate reads them: an email read tool's `scope`. */
93
+ toolSettings?: unknown;
80
94
  /** The claim this run is held under: the live-viewer rows are written under it (its epoch fences them), and the run's
81
95
  * saved sign-in is read and its hand kept under it. Present, the run is on the runner: never the process's own pipe. */
82
96
  claim?: Claim;
@@ -107,6 +121,28 @@ export type ToolHost = {
107
121
  /** The run's own models a native web_search goes through (hosted-search.ts), asked as a search runs: on the runner, the
108
122
  * session's port (its proxy, policy, key, price and cap), this run's alone. Absent: a native search has no model. */
109
123
  search?: SearchOn;
124
+ /** A template eval's web fake for this run (web-fake.ts): its web_search and web_fetch answer from it, never the
125
+ * network. Only the eval's own runner sets it (runner/beside.ts evalFakes). Absent: the plane's providers. */
126
+ web?: WebFake;
127
+ /** The run's clock where a template eval case sets one (its `now`): a draft's or a send's Date reads it. Absent: the real
128
+ * clock. */
129
+ now?: Date;
130
+ /** A template eval case's fake mail account (eval-mailbox.ts), the only account the run's email tools open: one saved
131
+ * elsewhere is refused. Only the eval's own runner sets it (runner/beside.ts evalFakes). */
132
+ emailFake?: EmailFake;
133
+ };
134
+ /** A fake mail account's servers, on loopback (email/email-faux.ts), and the kind of server it plays: what email_file's
135
+ * description says, which a loopback account saved as `other` would otherwise read as folders. */
136
+ export type EmailFake = {
137
+ readonly imap: {
138
+ readonly host: string;
139
+ readonly port: number;
140
+ };
141
+ readonly smtp: {
142
+ readonly host: string;
143
+ readonly port: number;
144
+ };
145
+ readonly kind: "gmail" | "folders";
110
146
  };
111
147
  /** What a name stands for in the run: the pi tools it offers, and the extensions a conversation selects for them. */
112
148
  export type ToolBinding = {
@@ -123,6 +159,12 @@ export type EffectRun = {
123
159
  ledger?: Ledger;
124
160
  search?: SearchOn;
125
161
  };
162
+ /** What a tool's own ask (ToolEntry.asks) reads: the run's host, and how many calls of a tool the run has run to a good
163
+ * end, from the run's record (its journal), so a pause and a new host count them all. */
164
+ export type AskContext = {
165
+ readonly host: ToolHost;
166
+ ran(tool: string): Promise<number>;
167
+ };
126
168
  export type ToolEntry = {
127
169
  /** One line, for capabilities. */
128
170
  summary: string;
@@ -142,6 +184,12 @@ export type ToolEntry = {
142
184
  /** No agent whose place is a sandbox may name it: it writes the run's work/ from this machine by paths a box's command
143
185
  * could turn through a link (runnable.ts). */
144
186
  runnerOnly?: true;
187
+ /** On the runner, before the intent of a call its setting allows: why this call asks a person anyway, in words (shown
188
+ * on its approval), or nothing. No setting lifts it; where no one can approve, the call is refused in those words. */
189
+ asks?(args: Record<string, unknown>, ctx: AskContext): Promise<string | undefined>;
190
+ /** What a call waiting on approval does, in a person's words (run-view.ts, the pending approval's `summary`): email_send's
191
+ * to whom and what. Undefined where its arguments do not say. */
192
+ approvalSummary?(args: unknown): string | undefined;
145
193
  };
146
194
  /** Where the browser files what it reads: the run's `evidence/`, through its Workspace, so the run's files show it and
147
195
  * the agent can read it back. A text body follows one line of the read's facts; a capture's bytes go beside its facts.
@@ -222,7 +270,8 @@ export declare const CALL_TOOLS: readonly string[];
222
270
  export declare const allows: (allowed: readonly string[], name: string) => boolean;
223
271
  /** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
224
272
  * agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
225
- * tool-names.ts mcpNameOf: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
273
+ * tool-names.ts mcpNameOf), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name
274
+ * does not run either). A
226
275
  * learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
227
276
  * exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
228
277
  export declare const learnedWorkflowTools: (granted: readonly string[], plane?: Plane, options?: LearnedMcp) => string[];
@@ -235,13 +284,6 @@ export type LearnedMcp = {
235
284
  readonly mcp?: boolean;
236
285
  readonly approvers?: boolean;
237
286
  };
238
- /** `granted` with each MCP server's wildcard (`mcp:<server>/*`) read as the tools its server lists now (`listed`, by the
239
- * server's name: none for a server not saved), each `mcp:<server>/<tool>`, in place; every other name as it is, each
240
- * once. What a revision grants under a wildcard is every tool of its server, so a learned draft may name each one
241
- * (learnedWorkflowTools), its gate holding it as any tool (learnedDraftTools: the wildcard's setting, or the tool's own).
242
- * At proposal time there is no run and no pin: whether the run's pin has the tool is the runtime's to check at the call,
243
- * in the gate's words (learned-workflow.ts). */
244
- export declare function mcpGrantsListed(granted: readonly string[], listed: (server: string) => readonly string[]): string[];
245
287
  /** The tools a learned draft may name (learnedWorkflowTools) that the gate allows: `permission` is what the gate holds a
246
288
  * tool to now (tool-gate.ts permissionOf, or the run's gate's policy), by its settings key. One set to ask or deny is left out of `tools`, so the end-of-run prompt never offers it, and named
247
289
  * in `gated` with its setting, which the checker and a learned workflow's check before it runs refuse a draft for. */
@@ -249,7 +291,6 @@ export declare const learnedDraftTools: (granted: readonly string[], permission:
249
291
  tools: string[];
250
292
  gated: Record<string, string>;
251
293
  deniedBy: Record<string, DenyFrom>;
252
- asked: string[];
253
294
  };
254
295
  /** The tools a workflow names (`nodes` from workflowNodes): on its model nodes (`tools`), and on its `call` nodes
255
296
  * `via: "tool"` (`tool`). */
@@ -291,11 +332,11 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
291
332
  default_provider?: string | undefined;
292
333
  resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", Resolution> | undefined;
293
334
  why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
294
- default_permission: "ask" | "deny" | "allow";
295
- permissions: ("ask" | "deny" | "allow")[];
335
+ default_permission: "allow" | "ask" | "deny";
336
+ permissions: ("allow" | "ask" | "deny")[];
296
337
  fallback_allow_reads?: true | undefined;
297
338
  allow_reads?: true | undefined;
298
- permission: "ask" | "deny" | "allow";
339
+ permission: "allow" | "ask" | "deny";
299
340
  harnesses: ("opencode" | "codex" | "pi" | "claude-agent")[];
300
341
  missing?: string[] | undefined;
301
342
  reason?: string | undefined;
@@ -308,11 +349,11 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
308
349
  name: string;
309
350
  summary: string;
310
351
  } | {
311
- default_permission: "ask" | "deny" | "allow";
312
- permissions: ("ask" | "deny" | "allow")[];
352
+ default_permission: "allow" | "ask" | "deny";
353
+ permissions: ("allow" | "ask" | "deny")[];
313
354
  fallback_allow_reads?: true | undefined;
314
355
  allow_reads?: true | undefined;
315
- permission: "ask" | "deny" | "allow";
356
+ permission: "allow" | "ask" | "deny";
316
357
  name: string;
317
358
  summary: string;
318
359
  blurb: string;
package/dist/tools.js CHANGED
@@ -5,7 +5,10 @@
5
5
  // run's folder or its computer. `bash` and the background tools may be named only by an agent whose place is a box
6
6
  // (runnable.ts).
7
7
  import { blurbOf, isHostTool } from "./tool-list.js";
8
- import { mcpNameOf, mcpToolName, parseToolName } from "./tool-names.js";
8
+ import { EMAIL_DESCRIPTIONS, EMAIL_DRAFT, EMAIL_FILE, EMAIL_READ, EMAIL_SEARCH, EMAIL_SEND, fileSummary, sendSummary } from "./email/names.js";
9
+ // The email tools' timeline lines (registerLabel), registered as this module loads.
10
+ import "./email/labels.js";
11
+ import { mcpNameOf } from "./tool-names.js";
9
12
  import { appendFileSync } from "node:fs";
10
13
  import { pathToFileURL } from "node:url";
11
14
  import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
@@ -25,6 +28,7 @@ import { browserPrice, browserSpend } from "./browser-cost.js";
25
28
  import { forModel } from "./result.js";
26
29
  import { fetchFor, pagesOf, WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
27
30
  import { searchFor, WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
31
+ import { fakeFetch, fakeSearch } from "./web-fake.js";
28
32
  import { browserNeeds, explainsView, isUnavailable, NO_PARALLEL_KEY, PICKABLE, planeOf, PROVIDERS, serverGate, whyUnavailable, withDefaults } from "./tool-plane.js";
29
33
  import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
30
34
  import { keyNeeded } from "./key-words.js";
@@ -80,13 +84,24 @@ const callOnly = (summary, effect) => ({
80
84
  summary, needs: [], nodes: false, callOnly: true, effect,
81
85
  bind: async () => { throw new Error("a call-only tool binds no agent tool"); },
82
86
  });
87
+ /** An email tool, its summary its description (email/names.ts), its binding (email/tools.ts bindEmail) and email_send's
88
+ * own ask (sendAsks) loaded at first use, the mail libraries with them. */
89
+ const emailTool = (name) => ({
90
+ summary: EMAIL_DESCRIPTIONS[name],
91
+ needs: [],
92
+ nodes: false,
93
+ bind: async (host) => (await import("./email/tools.js")).bindEmail(name, host),
94
+ ...(name === EMAIL_SEND ? { approvalSummary: sendSummary, asks: async (args, ctx) => (await import("./email/tools.js")).sendAsks(args, ctx) } : {}),
95
+ ...(name === EMAIL_FILE ? { approvalSummary: fileSummary } : {}),
96
+ });
83
97
  /** web_fetch, bound under `name`. */
84
98
  const webFetchEntry = (name) => ({
85
99
  summary: `Read one public web page from a public host through the guarded direct fetch, or through Parallel's extract where Parallel is picked (falling back to the direct fetch, saying why, when Parallel answers no page), a part at a time (offset, max_chars; the page fetched once a run): { ok, url, status, title, text, chars, truncated?, original_chars?, beyond_read?, offset?, next_offset?, html_chars?, converted?, links, links_omitted?, via, parallel?, refused?, error? }; html_chars, the page's whole length, when its HTML was cut at ${HTML_READ_CHARS.toLocaleString("en-US")} characters before it was read, so its text is only the start of the page; converted: "text" when the text is plain text, its conversion to markdown having run out of time; a private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused, never sent to Parallel.`,
86
100
  needs: [],
87
101
  nodes: true,
88
102
  bind: async (host) => {
89
- const tool = booking(webFetchTool(host.env, name));
103
+ const web = host.web;
104
+ const tool = booking(webFetchTool(host.env, name, web && ((url, part) => fakeFetch(web, url, part))));
90
105
  const extension = defineExtension({ name: name.replaceAll("_", "-"), tools: [tool] });
91
106
  host.install(extension);
92
107
  return { tools: [tool], extensions: [extension] };
@@ -578,9 +593,17 @@ export const TOOLS = Object.freeze({
578
593
  needs: [],
579
594
  nodes: true,
580
595
  // On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
581
- bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env, host.search))),
596
+ // A template eval's web fake (host.web) answers in the provider's place.
597
+ bind: async (host) => installTool(host, "web-search", booking(webSearchTool(host.env, host.search, host.web && ((args, provider) => fakeSearch(host.web, args, provider))))),
582
598
  effect: async (args, run) => bookedIn(run.ledger, () => searchFor(run.env, args, run.signal, run.search)),
583
599
  },
600
+ // The email tools (email/tools.ts) on the server's one email account (Settings → Email), every harness's as web_fetch is;
601
+ // the mail libraries load at the first bind.
602
+ [EMAIL_SEARCH]: emailTool(EMAIL_SEARCH),
603
+ [EMAIL_READ]: emailTool(EMAIL_READ),
604
+ [EMAIL_DRAFT]: emailTool(EMAIL_DRAFT),
605
+ [EMAIL_SEND]: emailTool(EMAIL_SEND),
606
+ [EMAIL_FILE]: emailTool(EMAIL_FILE),
584
607
  browser: browserTool,
585
608
  // A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
586
609
  // (adapter-run-spec.ts), never by this table; not a host tool (tool-list.ts `replay`), so another harness refuses it.
@@ -605,52 +628,34 @@ export const CALL_TOOLS = Object.keys(TOOLS).filter((name) => TOOLS[name].effect
605
628
  export const allows = (allowed, name) => allowed.includes(name);
606
629
  /** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
607
630
  * agent's `granted` tools a workflow's call node runs here (CALL_TOOLS, and each MCP tool granted by its own name,
608
- * tool-names.ts mcpNameOf: a wildcard is read against its server's listing first, mcpGrantsListed), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
631
+ * tool-names.ts mcpNameOf), and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name
632
+ * does not run either). A
609
633
  * learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
610
634
  * exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
611
635
  export const learnedWorkflowTools = (granted, plane, options = {}) => [...new Set(granted.filter((name) => (options.mcp === true && mcpNameOf(name) !== undefined) || (allows(CALL_TOOLS, name) && !isUnavailable(plane?.[name]))))];
612
- /** `granted` with each MCP server's wildcard (`mcp:<server>/*`) read as the tools its server lists now (`listed`, by the
613
- * server's name: none for a server not saved), each `mcp:<server>/<tool>`, in place; every other name as it is, each
614
- * once. What a revision grants under a wildcard is every tool of its server, so a learned draft may name each one
615
- * (learnedWorkflowTools), its gate holding it as any tool (learnedDraftTools: the wildcard's setting, or the tool's own).
616
- * At proposal time there is no run and no pin: whether the run's pin has the tool is the runtime's to check at the call,
617
- * in the gate's words (learned-workflow.ts). */
618
- export function mcpGrantsListed(granted, listed) {
619
- const out = new Set();
620
- for (const name of granted) {
621
- const parsed = parseToolName(name);
622
- if (parsed?.kind !== "mcp-server")
623
- out.add(name);
624
- else
625
- for (const tool of listed(parsed.server))
626
- out.add(mcpToolName(parsed.server, tool));
627
- }
628
- return [...out];
629
- }
630
636
  /** The tools a learned draft may name (learnedWorkflowTools) that the gate allows: `permission` is what the gate holds a
631
637
  * tool to now (tool-gate.ts permissionOf, or the run's gate's policy), by its settings key. One set to ask or deny is left out of `tools`, so the end-of-run prompt never offers it, and named
632
638
  * in `gated` with its setting, which the checker and a learned workflow's check before it runs refuse a draft for. */
633
639
  export const learnedDraftTools = (granted, permission, plane, from, options = {}) => {
634
640
  const gated = {};
635
- // The MCP tools offered because they ask: the ones a learned call's approval card names (#2424).
636
- const asked = [];
637
641
  // Where each deny was set (this agent's settings or this server's), so the refusal names it.
638
642
  const deniedBy = {};
639
643
  const tools = learnedWorkflowTools(granted, plane, options).filter((name) => {
640
644
  const setting = permission(name);
641
- // An MCP tool set to ask is offered where someone can answer: its learned_workflow call asks once, naming its MCP
642
- // tools, before any node runs (#2424). A table tool set to ask is not: its call node can't wait for an approval.
645
+ // An MCP tool set to ask is offered where someone can answer: its learned_workflow call's one card names each of its
646
+ // MCP actions set to ask (learned-workflow.ts learnedAskShown). A table tool set to ask is not: its call node can't
647
+ // wait for an approval.
643
648
  if (setting === "allow")
644
649
  return true;
645
650
  if (setting === "ask" && options.approvers === true && mcpNameOf(name) !== undefined)
646
- return (asked.push(name), true);
651
+ return true;
647
652
  gated[name] = setting;
648
653
  // A deny comes from a layer or the default, never from approvals, which only ever allows.
649
654
  if (setting === "deny" && from)
650
655
  deniedBy[name] = from(name);
651
656
  return false;
652
657
  });
653
- return { tools, gated, deniedBy, asked };
658
+ return { tools, gated, deniedBy };
654
659
  };
655
660
  /** The tools a workflow names (`nodes` from workflowNodes): on its model nodes (`tools`), and on its `call` nodes
656
661
  * `via: "tool"` (`tool`). */
@@ -1,6 +1,12 @@
1
1
  import type { InputIssue } from "./errors.js";
2
2
  import type { SettingsSpec } from "./sealed-settings-store.js";
3
3
  type Json = Record<string, unknown>;
4
+ /** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
5
+ * (its previousResult, by default true). */
6
+ export declare const carriesPrevious: (adapter: Pick<TriggerAdapter, "previousResult">) => boolean;
7
+ /** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
8
+ * source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
9
+ export declare const PAYLOAD_KEPT_BYTES: number;
4
10
  /** A source as the store keeps it: its kind, the adapter's id, and the adapter's own fields. */
5
11
  export type Source = {
6
12
  kind: string;
@@ -19,19 +25,19 @@ export type TriggerAdapter = {
19
25
  id: string;
20
26
  /** How a person names one: `the <label> "<name>"`, in each run's provenance line. */
21
27
  label: string;
22
- /** `clock`: it fires on its own times, read by the engine's timer. `push`: a request delivered to the server fires it,
28
+ /** `clock`: it fires on its own times, read by the engine's timer (a source that polls, on each). `push`: a request delivered to the server fires it,
23
29
  * keyed by the sender's own id, which a retry repeats. */
24
30
  delivery: "clock" | "push";
31
+ /** Whether a run it starts is handed its trigger's last completed result (trigger-targets.ts previousResultOf). Default
32
+ * true: a repeat run (a schedule's weekly digest) leaves out what the last one reported. false: each firing is a
33
+ * different person's (an email's sender), so one run's answer is never handed to the next. */
34
+ previousResult?: boolean;
25
35
  /** Whether its words are its owner's (a run's message origin `owner`): true only when the owner wrote them as they set
26
36
  * it up; never for words that come from outside. */
27
37
  owner: boolean;
28
38
  /** What it keeps sealed (sealed-settings-store.ts), for the server or for each trigger: a field it mints (a signing secret)
29
39
  * is made at a trigger's create and at a rotation, shown once, and goes with the trigger. */
30
40
  settings?: SettingsSpec;
31
- /** Whether a trigger of this source keeps a secret its sender gave (a create's and a rotation's `secret`, Composio's)
32
- * instead of one this server mints: then the secret is required there, sealed as a minted one is, and never made
33
- * here. Default: it mints. */
34
- givesSecret?(source: Source): boolean;
35
41
  /** Its shapes as a create's error names them: `{kind: "..."}` with its fields. */
36
42
  describe: string;
37
43
  /** When it fires, for the OpenAPI document's source description. */
@@ -57,6 +63,9 @@ export type TriggerAdapter = {
57
63
  /** A pushed source's requests (push-handler.ts), served at /v2/hooks/{trigger_id} when its settings are a trigger's,
58
64
  * else at /v2/hooks/{its id}, with no token: the request's check is its credential. */
59
65
  push?: Push;
66
+ /** For a pushed source whose hook is not the one its settings' scope gives (a source that keeps a key per scope, served
67
+ * at /v2/hooks/{its id}/{scope}): the path under /v2/hooks/ a trigger of `source` is delivered at, its `hook_url`. */
68
+ hookOf?(source: Source): string;
60
69
  /** For a pushed source whose settings are the server's: the scope a trigger of it listens on, matched to each event's
61
70
  * `scope` to find the triggers it fires. */
62
71
  scopeOf?(source: Source): string;
@@ -67,6 +76,44 @@ export type TriggerAdapter = {
67
76
  /** Whether each firing of a trigger of `source` starts its own run, its last run active or not (a webhook that takes
68
77
  * only the events it names). Default false: a firing while the last run is active is skipped. */
69
78
  concurrent?(source: Source): boolean;
79
+ /** For a clock source that polls (the email trigger): what it finds when its time comes, read from outside the server.
80
+ * The engine fires each event it returns through the path a pushed event takes (`takes`, `concurrent`,
81
+ * max_active_runs, the day-kept keys, a run per event), records no `missed` row for a time it was not there for, and
82
+ * keeps the poll's cursor once its firings are recorded. A poll with no cursor is where its trigger starts watching:
83
+ * the engine polls at once when the trigger is made, turned on again (its cursor and last check forgotten first) or its
84
+ * source edited (its cursor kept: a poll whose cursor was read elsewhere starts over itself). */
85
+ poll?(source: Source, ctx: PollContext): Promise<PollResult>;
86
+ /** A run's title after its trigger's name, from what its source says of the firing (its attrs): an email's sender and
87
+ * subject. Default: the event and action the attrs name. */
88
+ title?(attrs: Record<string, string>): string | undefined;
89
+ };
90
+ /** What a poll is given: its trigger's own settings (its cursor, public, as the adapter's `settings` names them) and the
91
+ * source's credentials, read now (TriggerDeps.credentials: the email account, opened). */
92
+ export type PollContext = {
93
+ trigger: string;
94
+ setting(field: string): string | undefined;
95
+ credentials(): Promise<unknown>;
96
+ };
97
+ /** One event a poll found: a pushed event's fields; `cursor`, the settings to keep once it and every event before it are
98
+ * recorded; `left`, when it is recorded as skipped and starts nothing, why (in words). */
99
+ export type PolledEvent = PushEvent & {
100
+ cursor: Record<string, string>;
101
+ left?: string;
102
+ };
103
+ /** What a poll found: `check`, said on the trigger as its last check; `refused`, the source's credentials refused (the
104
+ * engine turns the trigger off at the third in a row, `detail` its words); `note`, one history line that starts no run
105
+ * (a first poll's, a reset's); `events`, oldest first; `cursor`, the settings to keep once every event is recorded. */
106
+ export type PollResult = {
107
+ check: {
108
+ ok: boolean;
109
+ message: string;
110
+ };
111
+ refused?: {
112
+ detail: string;
113
+ };
114
+ note?: string;
115
+ events?: PolledEvent[];
116
+ cursor?: Record<string, string>;
70
117
  };
71
118
  /** Request headers, as Node gives them. */
72
119
  export type Headers = Record<string, string | string[] | undefined>;
@@ -77,6 +124,10 @@ export type Push = {
77
124
  maxBodyBytes: number;
78
125
  /** The settings field it checks a request with. */
79
126
  key: string;
127
+ /** For a source whose settings are the server's: it keeps its key per scope (a Composio project's subscription, by its
128
+ * hook), and is served at /v2/hooks/{its id}/{scope} alone, each request checked with that scope's key; its events'
129
+ * `scope` is that scope, for its takes. */
130
+ scoped?: true;
80
131
  /** Why the headers alone are refused, before a byte of the body is read. */
81
132
  headers?(headers: Headers, nowMs: number): string | undefined;
82
133
  /** Why the request is not the sender's under `key`, or undefined when it is (and fits `source`, when given). */
@@ -1,4 +1,10 @@
1
1
  import { unknownFields } from "./validate.js";
2
+ /** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
3
+ * (its previousResult, by default true). */
4
+ export const carriesPrevious = (adapter) => adapter.previousResult ?? true;
5
+ /** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
6
+ * source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
7
+ export const PAYLOAD_KEPT_BYTES = 16 * 1024;
2
8
  /** A closed object schema: every field in `required` is, and `optional`'s may be. */
3
9
  export const closedSchema = (required, optional = {}) => ({ type: "object", additionalProperties: false, required: Object.keys(required), properties: { ...required, ...optional } });
4
10
  /** `value`'s fields past `allowed`, as issues under `source`. */
@@ -1,4 +1,6 @@
1
+ import { composio } from "./trigger-composio.js";
1
2
  import { schedule } from "./trigger-schedule.js";
2
3
  import { github } from "./trigger-github.js";
3
4
  import { webhook } from "./trigger-webhook.js";
4
- export const TRIGGER_ADAPTERS = [schedule, webhook, github];
5
+ import { email } from "./trigger-email.js";
6
+ export const TRIGGER_ADAPTERS = [schedule, webhook, github, composio, email];
@@ -0,0 +1,10 @@
1
+ import { type TriggerAdapter } from "./trigger-adapter.js";
2
+ /** A Composio trigger slug: upper case, digits and `_` (GITHUB_ISSUE_ADDED_EVENT). */
3
+ export declare const COMPOSIO_EVENT: RegExp;
4
+ /** The id of a project's route here, made once when its subscription is made or moved here. */
5
+ export declare const COMPOSIO_HOOK: RegExp;
6
+ /** The source's field the move of a subscription is asked with: at a create alone, never kept. */
7
+ export declare const MOVE_FIELD = "move_subscription";
8
+ /** The settings field the project's subscription secret is sealed under, one scope per hook. */
9
+ export declare const COMPOSIO_SECRET = "secret";
10
+ export declare const composio: TriggerAdapter;