@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35

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 (466) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +341 -208
  3. package/dist/adapters.d.ts +3 -4
  4. package/dist/adapters.js +18 -15
  5. package/dist/agent-rows.d.ts +99 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +75 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/archil-settings.d.ts +11 -1
  16. package/dist/archil-settings.js +10 -0
  17. package/dist/bash-read-only.d.ts +35 -0
  18. package/dist/bash-read-only.js +778 -0
  19. package/dist/box-settings.d.ts +3 -23
  20. package/dist/box-settings.js +7 -51
  21. package/dist/boxes.d.ts +17 -0
  22. package/dist/boxes.js +27 -20
  23. package/dist/browser-commands.d.ts +5 -2
  24. package/dist/browser-commands.js +4 -4
  25. package/dist/browser-computer.d.ts +5 -0
  26. package/dist/browser-computer.js +21 -0
  27. package/dist/browser-cost.d.ts +9 -6
  28. package/dist/browser-cost.js +95 -51
  29. package/dist/browser-live.d.ts +7 -20
  30. package/dist/browser-live.js +15 -93
  31. package/dist/browser-person.d.ts +18 -51
  32. package/dist/browser-person.js +94 -277
  33. package/dist/budget.d.ts +0 -5
  34. package/dist/budget.js +0 -5
  35. package/dist/cap.d.ts +14 -8
  36. package/dist/cap.js +19 -9
  37. package/dist/cli.js +71 -18
  38. package/dist/closed-pipes.d.ts +2 -0
  39. package/dist/closed-pipes.js +13 -0
  40. package/dist/computer-commands.d.ts +2 -0
  41. package/dist/computer-commands.js +2 -0
  42. package/dist/computer-keys.d.ts +20 -10
  43. package/dist/computer-keys.js +36 -54
  44. package/dist/computer-setting.d.ts +20 -3
  45. package/dist/computer-setting.js +58 -10
  46. package/dist/computers.d.ts +35 -2
  47. package/dist/computers.js +72 -11
  48. package/dist/confine.d.ts +120 -0
  49. package/dist/confine.js +436 -0
  50. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  51. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  52. package/dist/console/index.html +2 -2
  53. package/dist/content-filter.d.ts +7 -0
  54. package/dist/content-filter.js +23 -0
  55. package/dist/decision-cap.d.ts +7 -29
  56. package/dist/decision-cap.js +3 -94
  57. package/dist/decision-rows.d.ts +1 -1
  58. package/dist/decision-rows.js +1 -1
  59. package/dist/docker-daemon.d.ts +31 -0
  60. package/dist/docker-daemon.js +56 -0
  61. package/dist/effort-guidance.js +4 -3
  62. package/dist/environment.d.ts +0 -3
  63. package/dist/environment.js +3 -5
  64. package/dist/errors.d.ts +1 -2
  65. package/dist/errors.js +9 -9
  66. package/dist/explain.js +3 -1
  67. package/dist/filed-answer.d.ts +32 -0
  68. package/dist/filed-answer.js +160 -0
  69. package/dist/files.d.ts +1 -3
  70. package/dist/files.js +2 -4
  71. package/dist/github-connection.d.ts +1 -1
  72. package/dist/github-connection.js +25 -7
  73. package/dist/github-faux.d.ts +26 -0
  74. package/dist/github-faux.js +76 -0
  75. package/dist/github.d.ts +6 -2
  76. package/dist/github.js +5 -3
  77. package/dist/graph-served.d.ts +5 -3
  78. package/dist/graph-served.js +14 -6
  79. package/dist/graph-view.d.ts +3 -5
  80. package/dist/graph-view.js +9 -16
  81. package/dist/handed-values.d.ts +9 -0
  82. package/dist/handed-values.js +26 -0
  83. package/dist/harness-install.d.ts +1 -7
  84. package/dist/harness-install.js +1 -18
  85. package/dist/harness-opencode/adapter.d.ts +7 -0
  86. package/dist/harness-opencode/adapter.js +23 -6
  87. package/dist/harness-opencode/harness.js +0 -1
  88. package/dist/harness-opencode/host/policy.js +2 -2
  89. package/dist/harness-opencode/index.d.ts +1 -1
  90. package/dist/harness-opencode/index.js +1 -1
  91. package/dist/harness-opencode/verify.d.ts +17 -0
  92. package/dist/harness-opencode/verify.js +30 -10
  93. package/dist/harness-table.js +6 -1
  94. package/dist/heard.js +1 -1
  95. package/dist/held-fd.d.ts +5 -0
  96. package/dist/held-fd.js +14 -0
  97. package/dist/host-calls.d.ts +20 -0
  98. package/dist/host-calls.js +12 -0
  99. package/dist/host-tools.d.ts +4 -21
  100. package/dist/host-tools.js +4 -61
  101. package/dist/host.d.ts +2 -4
  102. package/dist/host.js +2 -7
  103. package/dist/import-summary.d.ts +1 -5
  104. package/dist/import-summary.js +0 -21
  105. package/dist/import.d.ts +6 -6
  106. package/dist/import.js +14 -15
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +1 -0
  109. package/dist/key-refusal.d.ts +5 -1
  110. package/dist/key-refusal.js +19 -4
  111. package/dist/learn/check.d.ts +8 -2
  112. package/dist/learn/check.js +85 -31
  113. package/dist/learn/folder.d.ts +11 -4
  114. package/dist/learn/folder.js +17 -19
  115. package/dist/learn/grade.d.ts +18 -1
  116. package/dist/learn/grade.js +108 -14
  117. package/dist/learn/index.d.ts +5 -5
  118. package/dist/learn/index.js +5 -5
  119. package/dist/learn/learning.sh +1 -14
  120. package/dist/learn/notes.d.ts +14 -3
  121. package/dist/learn/notes.js +16 -6
  122. package/dist/learn/reflect.d.ts +31 -2
  123. package/dist/learn/reflect.js +83 -6
  124. package/dist/learn/relevance.d.ts +24 -0
  125. package/dist/learn/relevance.js +91 -0
  126. package/dist/learn/secrets.d.ts +7 -1
  127. package/dist/learn/secrets.js +86 -19
  128. package/dist/learn/skills.d.ts +159 -18
  129. package/dist/learn/skills.js +644 -64
  130. package/dist/learned-nodes.d.ts +14 -0
  131. package/dist/learned-nodes.js +8 -0
  132. package/dist/learned-workflow.d.ts +41 -6
  133. package/dist/learned-workflow.js +153 -18
  134. package/dist/learning-routes.d.ts +49 -4
  135. package/dist/learning-routes.js +113 -31
  136. package/dist/learning-run.d.ts +16 -31
  137. package/dist/learning-run.js +31 -38
  138. package/dist/learning-words.d.ts +12 -5
  139. package/dist/learning-words.js +18 -9
  140. package/dist/learning.d.ts +91 -97
  141. package/dist/learning.js +176 -320
  142. package/dist/live/stream.js +1 -1
  143. package/dist/live/translate.js +12 -2
  144. package/dist/llm.d.ts +4 -1
  145. package/dist/llm.js +4 -2
  146. package/dist/local-models.d.ts +11 -5
  147. package/dist/local-models.js +13 -8
  148. package/dist/mcp-gateway.d.ts +17 -49
  149. package/dist/mcp-gateway.js +55 -136
  150. package/dist/mcp-oauth.d.ts +10 -14
  151. package/dist/mcp-oauth.js +14 -32
  152. package/dist/mcp-probe.d.ts +0 -7
  153. package/dist/mcp-probe.js +4 -10
  154. package/dist/mcp-servers-store.d.ts +18 -18
  155. package/dist/mcp-servers-store.js +12 -14
  156. package/dist/mcp-store.js +3 -4
  157. package/dist/mcp.js +4 -3
  158. package/dist/model.d.ts +9 -7
  159. package/dist/model.js +51 -27
  160. package/dist/monid.d.ts +0 -2
  161. package/dist/monid.js +3 -6
  162. package/dist/openapi.d.ts +8 -1
  163. package/dist/openapi.js +156 -58
  164. package/dist/page.d.ts +1 -3
  165. package/dist/page.js +6 -18
  166. package/dist/paid-calls.d.ts +21 -27
  167. package/dist/paid-calls.js +26 -61
  168. package/dist/pause.d.ts +2 -19
  169. package/dist/pause.js +5 -74
  170. package/dist/port-models.d.ts +10 -3
  171. package/dist/port-models.js +26 -6
  172. package/dist/propose.d.ts +2 -0
  173. package/dist/propose.js +80 -45
  174. package/dist/push-handler.d.ts +1 -1
  175. package/dist/reflect-range.d.ts +25 -0
  176. package/dist/reflect-range.js +30 -0
  177. package/dist/refusal-words.d.ts +5 -1
  178. package/dist/refusal-words.js +5 -1
  179. package/dist/rows.d.ts +1 -1
  180. package/dist/run-cut.d.ts +0 -6
  181. package/dist/run-cut.js +0 -6
  182. package/dist/run-db.d.ts +2 -11
  183. package/dist/run-db.js +2 -37
  184. package/dist/run-launch.d.ts +21 -2
  185. package/dist/run-launch.js +14 -5
  186. package/dist/run-learning-served.d.ts +21 -4
  187. package/dist/run-learning-served.js +23 -13
  188. package/dist/run-reads-over-store.d.ts +5 -3
  189. package/dist/run-reads-over-store.js +25 -14
  190. package/dist/run-secrets.d.ts +1 -1
  191. package/dist/run-timeline-served.d.ts +5 -1
  192. package/dist/run-timeline-served.js +27 -6
  193. package/dist/run-view.d.ts +37 -22
  194. package/dist/run-view.js +85 -38
  195. package/dist/runnable.d.ts +21 -10
  196. package/dist/runnable.js +35 -12
  197. package/dist/runner/adapter-loop.d.ts +36 -5
  198. package/dist/runner/adapter-loop.js +663 -69
  199. package/dist/runner/adapter-run-spec.d.ts +42 -8
  200. package/dist/runner/adapter-run-spec.js +186 -52
  201. package/dist/runner/adapters/index.js +11 -1
  202. package/dist/runner/adapters/pi.d.ts +40 -2
  203. package/dist/runner/adapters/pi.js +110 -27
  204. package/dist/runner/beside.d.ts +38 -3
  205. package/dist/runner/beside.js +54 -5
  206. package/dist/runner/claim-secrets.d.ts +16 -1
  207. package/dist/runner/claim-secrets.js +62 -14
  208. package/dist/runner/cli-run-spec.d.ts +5 -0
  209. package/dist/runner/cli-run-spec.js +159 -41
  210. package/dist/runner/commands.js +1 -1
  211. package/dist/runner/computer-journal.d.ts +15 -2
  212. package/dist/runner/computer-journal.js +41 -5
  213. package/dist/runner/conformance/harness.d.ts +1 -0
  214. package/dist/runner/conformance/harness.js +123 -13
  215. package/dist/runner/conformance/subject.d.ts +4 -1
  216. package/dist/runner/dispatch.d.ts +8 -1
  217. package/dist/runner/dispatch.js +81 -7
  218. package/dist/runner/end-of-run.d.ts +8 -2
  219. package/dist/runner/end-of-run.js +10 -4
  220. package/dist/runner/github-app.d.ts +7 -2
  221. package/dist/runner/github-app.js +47 -16
  222. package/dist/runner/harness-loops.d.ts +15 -2
  223. package/dist/runner/harness-loops.js +38 -2
  224. package/dist/runner/journal-kinds.d.ts +60 -6
  225. package/dist/runner/journal-kinds.js +43 -5
  226. package/dist/runner/journal-reader.d.ts +1 -1
  227. package/dist/runner/journal-reader.js +2 -2
  228. package/dist/runner/learning-ask.d.ts +4 -0
  229. package/dist/runner/learning-ask.js +15 -1
  230. package/dist/runner/learning-end.d.ts +18 -3
  231. package/dist/runner/learning-end.js +194 -20
  232. package/dist/runner/learning-loop.d.ts +7 -0
  233. package/dist/runner/learning-loop.js +36 -8
  234. package/dist/runner/learning-seed.d.ts +6 -0
  235. package/dist/runner/learning-seed.js +6 -0
  236. package/dist/runner/loop-contract.d.ts +4 -0
  237. package/dist/runner/main.d.ts +61 -9
  238. package/dist/runner/main.js +144 -20
  239. package/dist/runner/mcp-claim.d.ts +3 -0
  240. package/dist/runner/mcp-claim.js +7 -3
  241. package/dist/runner/mcp-github.d.ts +11 -2
  242. package/dist/runner/mcp-github.js +55 -4
  243. package/dist/runner/mcp-run.d.ts +2 -0
  244. package/dist/runner/mcp-run.js +16 -5
  245. package/dist/runner/memory-claim.d.ts +9 -0
  246. package/dist/runner/memory-claim.js +25 -0
  247. package/dist/runner/metrics.d.ts +46 -1
  248. package/dist/runner/metrics.js +156 -1
  249. package/dist/runner/model-route.d.ts +16 -0
  250. package/dist/runner/model-route.js +134 -10
  251. package/dist/runner/reflect-hook.d.ts +12 -1
  252. package/dist/runner/reflect-hook.js +33 -3
  253. package/dist/runner/runner.d.ts +20 -0
  254. package/dist/runner/runner.js +146 -18
  255. package/dist/runner/spec-holds.d.ts +7 -2
  256. package/dist/runner/spec-holds.js +4 -3
  257. package/dist/runner/store-port.d.ts +1 -1
  258. package/dist/runner/store-secrets.d.ts +3 -3
  259. package/dist/runner/store-secrets.js +8 -12
  260. package/dist/runner/text-tools.d.ts +44 -0
  261. package/dist/runner/text-tools.js +237 -0
  262. package/dist/runner/workflow-host.d.ts +7 -2
  263. package/dist/runner/workflow-host.js +3 -1
  264. package/dist/runner/workflow-loop.d.ts +10 -1
  265. package/dist/runner/workflow-loop.js +14 -6
  266. package/dist/runner/workflow-spec.d.ts +21 -0
  267. package/dist/runner/workflow-spec.js +217 -93
  268. package/dist/runs-over-store.d.ts +14 -3
  269. package/dist/runs-over-store.js +100 -23
  270. package/dist/seal-key.d.ts +0 -2
  271. package/dist/seal-key.js +5 -45
  272. package/dist/sealed-settings-store.d.ts +19 -4
  273. package/dist/sealed-settings-store.js +9 -9
  274. package/dist/sealing.d.ts +4 -0
  275. package/dist/sealing.js +20 -0
  276. package/dist/secret-cut.d.ts +1 -1
  277. package/dist/secret-cut.js +1 -1
  278. package/dist/secret-name.d.ts +9 -0
  279. package/dist/secret-name.js +15 -0
  280. package/dist/secret-writes.d.ts +0 -1
  281. package/dist/secret-writes.js +0 -1
  282. package/dist/server-fs.d.ts +4 -0
  283. package/dist/server-fs.js +8 -2
  284. package/dist/server-lock.d.ts +0 -24
  285. package/dist/server-lock.js +5 -85
  286. package/dist/server-secrets-store.d.ts +4 -4
  287. package/dist/server-secrets-store.js +9 -31
  288. package/dist/server-secrets.d.ts +4 -9
  289. package/dist/server-secrets.js +12 -36
  290. package/dist/server.d.ts +37 -56
  291. package/dist/server.js +322 -134
  292. package/dist/sign-ins-store.d.ts +34 -36
  293. package/dist/sign-ins-store.js +27 -38
  294. package/dist/sign-ins.d.ts +2 -119
  295. package/dist/sign-ins.js +5 -311
  296. package/dist/standard-webhooks.d.ts +1 -1
  297. package/dist/standard-webhooks.js +1 -1
  298. package/dist/stats.d.ts +3 -2
  299. package/dist/stats.js +1 -1
  300. package/dist/stop-signals.d.ts +4 -2
  301. package/dist/stop-signals.js +5 -3
  302. package/dist/store/agent-body.d.ts +12 -2
  303. package/dist/store/agent-body.js +22 -4
  304. package/dist/store/deadline.d.ts +18 -0
  305. package/dist/store/deadline.js +45 -0
  306. package/dist/store/index.d.ts +2 -2
  307. package/dist/store/index.js +2 -2
  308. package/dist/store/open.d.ts +6 -3
  309. package/dist/store/open.js +2 -2
  310. package/dist/store/postgres/connection.d.ts +22 -2
  311. package/dist/store/postgres/connection.js +211 -41
  312. package/dist/store/postgres/migrate.d.ts +4 -0
  313. package/dist/store/postgres/migrate.js +9 -2
  314. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  315. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  316. package/dist/store/postgres/store.d.ts +9 -2
  317. package/dist/store/postgres/store.js +9 -0
  318. package/dist/store/schema.js +1 -1
  319. package/dist/store/seal.js +2 -2
  320. package/dist/store/sqlite/connection.js +14 -5
  321. package/dist/store/sqlite/run-patch.d.ts +3 -0
  322. package/dist/store/sqlite/run-patch.js +3 -0
  323. package/dist/store/sqlite/store.js +41 -12
  324. package/dist/store/store.d.ts +35 -6
  325. package/dist/store/store.js +12 -2
  326. package/dist/store-reads/cap.d.ts +1 -1
  327. package/dist/store-reads/cap.js +22 -4
  328. package/dist/store-reads/journal.d.ts +9 -6
  329. package/dist/store-reads/journal.js +129 -18
  330. package/dist/store-reads/learning.d.ts +82 -8
  331. package/dist/store-reads/learning.js +184 -11
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-reads/workflow.js +1 -1
  334. package/dist/store-view.d.ts +19 -1
  335. package/dist/store-view.js +95 -27
  336. package/dist/template-eval.d.ts +60 -4
  337. package/dist/template-eval.js +120 -54
  338. package/dist/templates.d.ts +33 -14
  339. package/dist/templates.js +82 -46
  340. package/dist/timeline/group.d.ts +33 -0
  341. package/dist/timeline/group.js +77 -0
  342. package/dist/timeline/index.d.ts +7 -0
  343. package/dist/timeline/index.js +7 -0
  344. package/dist/timeline/labels.d.ts +79 -0
  345. package/dist/timeline/labels.js +150 -0
  346. package/dist/timeline/origin.d.ts +56 -0
  347. package/dist/timeline/origin.js +92 -0
  348. package/dist/timeline/render-text.d.ts +11 -0
  349. package/dist/timeline/render-text.js +62 -0
  350. package/dist/timeline/timeline.d.ts +282 -0
  351. package/dist/timeline/timeline.js +1308 -0
  352. package/dist/timeline/util.d.ts +17 -0
  353. package/dist/timeline/util.js +49 -0
  354. package/dist/tool-budget.d.ts +18 -0
  355. package/dist/tool-budget.js +50 -0
  356. package/dist/tool-gate.d.ts +47 -218
  357. package/dist/tool-gate.js +87 -545
  358. package/dist/tool-keys-store.d.ts +11 -12
  359. package/dist/tool-keys-store.js +24 -31
  360. package/dist/tool-keys.d.ts +5 -101
  361. package/dist/tool-keys.js +8 -267
  362. package/dist/tool-plane.d.ts +23 -52
  363. package/dist/tool-plane.js +23 -81
  364. package/dist/tool-settings-store.d.ts +1 -2
  365. package/dist/tool-settings-store.js +5 -8
  366. package/dist/tools.d.ts +67 -25
  367. package/dist/tools.js +170 -119
  368. package/dist/trigger-adapter.d.ts +2 -2
  369. package/dist/trigger-targets.d.ts +13 -1
  370. package/dist/trigger-targets.js +31 -1
  371. package/dist/triggers.d.ts +2 -2
  372. package/dist/triggers.js +3 -3
  373. package/dist/turn-end.d.ts +1 -1
  374. package/dist/turn-end.js +1 -1
  375. package/dist/turns.d.ts +0 -6
  376. package/dist/turns.js +0 -19
  377. package/dist/uploads.d.ts +28 -5
  378. package/dist/uploads.js +83 -10
  379. package/dist/usage.d.ts +1 -49
  380. package/dist/usage.js +3 -84
  381. package/dist/validate.d.ts +4 -0
  382. package/dist/validate.js +33 -14
  383. package/dist/webhooks.d.ts +102 -76
  384. package/dist/webhooks.js +266 -233
  385. package/dist/workflow-run.d.ts +114 -0
  386. package/dist/workflow-run.js +144 -0
  387. package/dist/workspace/archil-claim.d.ts +2 -2
  388. package/dist/workspace/archil-claim.js +4 -3
  389. package/dist/workspace/archil-disk.d.ts +10 -1
  390. package/dist/workspace/archil-disk.js +4 -0
  391. package/dist/workspace/archil-exec.d.ts +12 -2
  392. package/dist/workspace/archil-exec.js +16 -0
  393. package/dist/workspace/archil.d.ts +2 -2
  394. package/dist/workspace/archil.js +25 -5
  395. package/dist/workspace/attach.js +2 -0
  396. package/dist/workspace/beneath.d.ts +19 -0
  397. package/dist/workspace/beneath.js +106 -0
  398. package/dist/workspace/computer-deps.d.ts +26 -9
  399. package/dist/workspace/computer-deps.js +144 -43
  400. package/dist/workspace/computer-for-claim.d.ts +17 -14
  401. package/dist/workspace/computer-for-claim.js +99 -26
  402. package/dist/workspace/computer-hold.d.ts +6 -1
  403. package/dist/workspace/computer-hold.js +6 -1
  404. package/dist/workspace/computer-janitor.d.ts +47 -0
  405. package/dist/workspace/computer-janitor.js +182 -0
  406. package/dist/workspace/computer-ledger.d.ts +1 -8
  407. package/dist/workspace/computer-ledger.js +0 -3
  408. package/dist/workspace/computer-providers.d.ts +5 -3
  409. package/dist/workspace/computer-providers.js +11 -9
  410. package/dist/workspace/grep-worker.d.ts +5 -0
  411. package/dist/workspace/grep-worker.js +9 -6
  412. package/dist/workspace/hands.d.ts +5 -2
  413. package/dist/workspace/hands.js +4 -3
  414. package/dist/workspace/index.d.ts +6 -5
  415. package/dist/workspace/index.js +4 -4
  416. package/dist/workspace/local.d.ts +14 -2
  417. package/dist/workspace/local.js +170 -43
  418. package/dist/workspace/paths.js +3 -2
  419. package/dist/workspace/pi-env.d.ts +4 -0
  420. package/dist/workspace/pi-env.js +3 -2
  421. package/dist/workspace/resolve-computer.d.ts +55 -10
  422. package/dist/workspace/resolve-computer.js +66 -14
  423. package/dist/workspace/run-tools.d.ts +15 -31
  424. package/dist/workspace/run-tools.js +19 -30
  425. package/dist/workspace/workspace.d.ts +5 -0
  426. package/dist/workspace-paths.d.ts +0 -17
  427. package/dist/workspace-paths.js +1 -41
  428. package/dist/workspace.d.ts +0 -17
  429. package/dist/workspace.js +4 -110
  430. package/package.json +14 -14
  431. package/skills/agentrun-serve/SKILL.md +1 -1
  432. package/templates/README.md +11 -5
  433. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  434. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  435. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  436. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  437. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  438. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  439. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  440. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  441. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  442. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  443. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  444. package/templates/market-monitor/agent.md +2 -2
  445. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  446. package/templates/release-notes/agent.md +11 -0
  447. package/dist/bound-files.d.ts +0 -4
  448. package/dist/bound-files.js +0 -164
  449. package/dist/coding-tools.d.ts +0 -47
  450. package/dist/coding-tools.js +0 -189
  451. package/dist/computer-adb.d.ts +0 -12
  452. package/dist/computer-adb.js +0 -14
  453. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  454. package/dist/console/assets/index-DvW6Aled.css +0 -1
  455. package/dist/grade.d.ts +0 -63
  456. package/dist/grade.js +0 -150
  457. package/dist/mcp-servers.d.ts +0 -269
  458. package/dist/mcp-servers.js +0 -456
  459. package/dist/packs.d.ts +0 -71
  460. package/dist/packs.js +0 -180
  461. package/dist/sealed-settings.d.ts +0 -60
  462. package/dist/sealed-settings.js +0 -171
  463. package/dist/sessions.d.ts +0 -6
  464. package/dist/sessions.js +0 -109
  465. package/dist/workspace/computer-serves.d.ts +0 -12
  466. package/dist/workspace/computer-serves.js +0 -15
@@ -3,7 +3,7 @@
3
3
  // stored commit (live/translate.ts), in commit order, each batch naming its commit's seq so a reader that comes back
4
4
  // resumes from it; and beside them, never inside a commit's batch, what the runner holds before pi stores it (the run's
5
5
  // run_live row: a running tool, a partial answer), in the same vocabulary.
6
- import { RUN_RESUMED } from "@parcha/pi-durable-agent/timeline";
6
+ import { RUN_RESUMED } from "../timeline/index.js";
7
7
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
8
8
  import { FINAL_STATES } from "../store/store.js";
9
9
  import { emptyState, snapshotOf, translate } from "./translate.js";
@@ -1,5 +1,5 @@
1
1
  import { AgentDoc, UsageDoc } from "@earendil-works/pi-durable";
2
- import { HOST_PHASE, RUN_RESUMED } from "@parcha/pi-durable-agent/timeline";
2
+ import { HOST_PHASE, RUN_RESUMED } from "../timeline/index.js";
3
3
  import { REFLECT_LABEL, reflectFrom } from "../runner/end-of-run.js";
4
4
  import { KINDS } from "../runner/journal-kinds.js";
5
5
  import { PI_STOP } from "../runner/pi-stop.js";
@@ -107,7 +107,7 @@ export function translate(state, commit) {
107
107
  const tasks = commit.tasks.filter(mine);
108
108
  const submissions = commit.submissions.filter(mine);
109
109
  // The end-of-run turn's input placed in this commit: its messages from there on are the turn's.
110
- state.reflectFrom ??= reflectFrom(submissions);
110
+ state.reflectFrom ??= reflectFrom(submissions, entries);
111
111
  const tag = (entry) => (state.reflectFrom !== undefined && Number(entry.id) >= state.reflectFrom ? { agent_label: REFLECT_LABEL } : {});
112
112
  for (const entry of entries) {
113
113
  const message = modelOf(entry);
@@ -177,6 +177,16 @@ export function translate(state, commit) {
177
177
  events.push({ type: "message_start", message, ...tag(entry) }, { type: "message_end", entry: synthetic, ...tag(entry) });
178
178
  continue;
179
179
  }
180
+ if (entry.kind === KINDS.endOfRunTurn && dataOf(entry).role === "person") {
181
+ // A CLI run's end-of-run turn asked (adapter-loop.ts answering): its prompt, in a commit of its own, is the turn's
182
+ // message, as a pi run's placed input is, so a stream already open shows the turn at once.
183
+ const text = dataOf(entry).text;
184
+ const message = { role: "user", content: typeof text === "string" ? text : "" };
185
+ const synthetic = { ...entry, model: [message] };
186
+ state.entries.push(synthetic);
187
+ events.push({ type: "message_start", message, ...tag(entry) }, { type: "message_end", entry: synthetic, ...tag(entry) });
188
+ continue;
189
+ }
180
190
  if (entry.kind === KINDS.end) {
181
191
  // A person's stop (the only stop a loop ends a run on: a lost claim or a shutdown writes no end): one phase row,
182
192
  // worded the same on every harness, from the loop's own end entry.
package/dist/llm.d.ts CHANGED
@@ -32,9 +32,12 @@ type Models = {
32
32
  errorMessage?: string;
33
33
  }>;
34
34
  };
35
- /** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. */
35
+ /** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. An answer names the model as `named`
36
+ * (the run's own name for it) when the pick reaches it through another provider (a runner's session proxy), else as
37
+ * `<provider>/<model id>`. */
36
38
  export declare function completer(models: Models, pick: (tier: string | undefined) => {
37
39
  provider: string;
38
40
  modelId: string;
41
+ named?: string;
39
42
  } | undefined, thinking: ModelThinkingLevel): Complete;
40
43
  export {};
package/dist/llm.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import { sideRequests } from "./cap.js";
2
2
  export const LLM_TOOL = "llm";
3
3
  const MAX_PROMPT = 400_000;
4
- /** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. */
4
+ /** The completer over `models`, each call on `pick(tier)`'s model at `thinking`. An answer names the model as `named`
5
+ * (the run's own name for it) when the pick reaches it through another provider (a runner's session proxy), else as
6
+ * `<provider>/<model id>`. */
5
7
  export function completer(models, pick, thinking) {
6
8
  return async (args, signal) => {
7
9
  const { prompt, system, maxTokens, tier } = args;
@@ -35,6 +37,6 @@ export function completer(models, pick, thinking) {
35
37
  const cached = (message.usage?.cacheRead ?? 0) + (message.usage?.cacheWrite ?? 0);
36
38
  const usage = message.usage ? { input_tokens: message.usage.input + cached, output_tokens: message.usage.output, cached_input_tokens: cached } : null;
37
39
  const cost = priced && typeof message.usage?.cost?.total === "number" ? message.usage.cost.total : null;
38
- return { text, model: `${ref.provider}/${ref.modelId}`, usage, cost_usd: cost };
40
+ return { text, model: ref.named ?? `${ref.provider}/${ref.modelId}`, usage, cost_usd: cost };
39
41
  };
40
42
  }
@@ -7,17 +7,23 @@ export declare const PARTICLE_1_PRICE: {
7
7
  readonly cacheRead: 0.03;
8
8
  readonly cacheWrite: 0;
9
9
  };
10
- /** Prices serve sets over pi-ai's own catalog entries, by provider and id. pi-ai 1.5.0 lists particle-ai/particle-1 at
10
+ /** How a model takes its tools: "native", the request's own tools parameter (every model pi-ai lists), or "text", the
11
+ * tools described in its system prompt and its calls read back from its reply (runner/text-tools.ts, on the runner's
12
+ * translated route, runner/model-route.ts). A wire format of the model's provider, not a choice of a task's. */
13
+ export type ToolsAs = "native" | "text";
14
+ /** What serve sets over pi-ai's own catalog entries, by provider and id: a price (`cost`), and how the model takes its
15
+ * tools (`toolsAs`, absent: native). pi-ai 1.5.0 lists particle-ai/particle-1 at
11
16
  * OpenRouter's current promotional price ($0.05 input, $0.003 cache read, $0.50 output). A run's cap holds each request
12
17
  * at its worst case, priced from the catalog, before it is sent, and a hold must never price below what can be billed:
13
- * the promotion can end before the catalog follows. So the hold takes Particle's list price. What a request is booked
14
- * at once it answers stays pi-ai's: OpenRouter's billed total (Usage.cost.totalFromProvider), and this price only
15
- * where OpenRouter reports none. */
18
+ * the promotion can end before the catalog follows. So the hold takes Particle's list price, and so does the booking:
19
+ * a request that answers is booked at pi-ai's calculateCost on this same catalog entry, its list price, not at what
20
+ * OpenRouter bills during the promotion. */
16
21
  export declare const PRICE_OVERRIDES: readonly {
17
22
  readonly provider: string;
18
23
  readonly id: string;
19
24
  readonly cost: Model<Api>["cost"];
25
+ readonly toolsAs?: ToolsAs;
20
26
  }[];
21
27
  /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
22
- * place: a request, a price and a capability read find the catalog's entry at the overridden price. */
28
+ * place: a request, a price and a capability read find the catalog's entry at the overridden price, with its toolsAs. */
23
29
  export declare function withLocalModels<M extends MutableModels>(models: M): M;
@@ -1,24 +1,29 @@
1
1
  /** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
2
2
  * 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
3
3
  export const PARTICLE_1_PRICE = { input: 0.25, output: 1, cacheRead: 0.03, cacheWrite: 0 };
4
- /** Prices serve sets over pi-ai's own catalog entries, by provider and id. pi-ai 1.5.0 lists particle-ai/particle-1 at
4
+ /** What serve sets over pi-ai's own catalog entries, by provider and id: a price (`cost`), and how the model takes its
5
+ * tools (`toolsAs`, absent: native). pi-ai 1.5.0 lists particle-ai/particle-1 at
5
6
  * OpenRouter's current promotional price ($0.05 input, $0.003 cache read, $0.50 output). A run's cap holds each request
6
7
  * at its worst case, priced from the catalog, before it is sent, and a hold must never price below what can be billed:
7
- * the promotion can end before the catalog follows. So the hold takes Particle's list price. What a request is booked
8
- * at once it answers stays pi-ai's: OpenRouter's billed total (Usage.cost.totalFromProvider), and this price only
9
- * where OpenRouter reports none. */
8
+ * the promotion can end before the catalog follows. So the hold takes Particle's list price, and so does the booking:
9
+ * a request that answers is booked at pi-ai's calculateCost on this same catalog entry, its list price, not at what
10
+ * OpenRouter bills during the promotion. */
10
11
  export const PRICE_OVERRIDES = [
11
- { provider: "openrouter", id: "particle-ai/particle-1", cost: { ...PARTICLE_1_PRICE } },
12
+ // Particle-1 takes its tools as text: Particle AI, its one provider on OpenRouter, caches no prefix of a request that
13
+ // carries a tools parameter (measured 2026-11-11: such a request renders to a prompt whose token count varies by send,
14
+ // and 0-30% of it is cached); with its tools as text, 76-92% of a review's input is read from the cache.
15
+ { provider: "openrouter", id: "particle-ai/particle-1", cost: { ...PARTICLE_1_PRICE }, toolsAs: "text" },
12
16
  ];
13
17
  /** `list` with each overridden model's price in place of the catalog's, whole: a field of the catalog's cost the override
14
18
  * does not name (its price `tiers`, which pi-ai's calculateCost prices a request at once its input passes one) never
15
- * survives, so a later catalog's promotional tier cannot price a hold below the list price. */
19
+ * survives, so a later catalog's promotional tier cannot price a hold below the list price. An override's `toolsAs`
20
+ * rides on the entry beside it. */
16
21
  const priced = (list, overrides) => list.map((model) => {
17
22
  const override = overrides.find((entry) => entry.id === model.id);
18
- return override ? { ...model, cost: { ...override.cost } } : model;
23
+ return override ? { ...model, cost: { ...override.cost }, ...(override.toolsAs ? { toolsAs: override.toolsAs } : {}) } : model;
19
24
  });
20
25
  /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
21
- * place: a request, a price and a capability read find the catalog's entry at the overridden price. */
26
+ * place: a request, a price and a capability read find the catalog's entry at the overridden price, with its toolsAs. */
22
27
  export function withLocalModels(models) {
23
28
  for (const providerId of new Set(PRICE_OVERRIDES.map((entry) => entry.provider))) {
24
29
  const own = models.getProvider(providerId);
@@ -1,12 +1,9 @@
1
- import { type ToolRegistration } from "@earendil-works/pi-durable";
2
1
  import type { McpCallResult, McpTool, SessionMcp } from "@parcha/agentrun-kernel";
3
- import { type Gate, type Park } from "./tool-gate.js";
4
2
  import { type Workspace } from "./workspace/index.js";
5
- /** The run's pinned MCP tools, in its directory: written once, at its first launch. */
6
- export declare const MCP_PIN = "mcp-tools.json";
7
3
  /** A catalog name of an MCP tool: `mcp:<server>/<tool>`. A server name has no `_`, so `mcp__<server>__<tool>` splits one way. */
8
4
  export declare const MCP_NAME: RegExp;
9
- /** The longest answer the model reads whole; the rest is filed in the run's work/ (monid's rule). */
5
+ /** The longest answer the model reads whole; past it, the rest is filed in the run's work/ as lines read pages through
6
+ * (filed-answer.ts). Within the host's result bound (HOST_RESULT_MAX_CHARS), so every harness passes it whole. */
10
7
  export declare const MCP_CLIP = 60000;
11
8
  /** The most of one upstream answer read. */
12
9
  export declare const MAX_RESPONSE: number;
@@ -19,35 +16,20 @@ export type McpPin = Record<string, {
19
16
  tools: McpTool[];
20
17
  prices?: Record<string, number>;
21
18
  }>;
22
- /** The pipe's entry: each granted server's URL now, and its credential's headers when that URL is the pinned one. */
19
+ /** Each granted server's URL now, and its credential's headers when that URL is the pinned one (the claim step's). */
23
20
  export type McpCredentials = Record<string, {
24
21
  url: string;
25
22
  headers?: Record<string, string>; /** Why its saved credential did not open: its calls are refused unsent. */
26
23
  unopened?: string; /** When its credential ends (ms): a token minted for the run's launch (a github_app server's), whose calls past it are refused unsent, in words. */
27
24
  expires_at?: number;
28
25
  }>;
29
- /** The servers saved on this server (mcp-servers.ts), as a launch reads them. */
26
+ /** The servers saved on this server, as a claim's pin reads them. */
30
27
  export interface McpServerSource {
31
28
  server(name: string): {
32
29
  url: string;
33
30
  tools: readonly McpTool[];
34
31
  prices?: Readonly<Record<string, number>>;
35
32
  } | undefined;
36
- /** The server's credential, opened now: its headers, or why it does not open, each under its own tag; undefined when
37
- * it has none. With `runId`, for that run's launch: a github_app server's static headers with the token minted for
38
- * the run (mint), or why it has none. */
39
- headers(name: string, runId?: string): {
40
- headers: Record<string, string>;
41
- expires_at?: number;
42
- } | {
43
- unopened: string;
44
- } | undefined;
45
- /** Before a launch: an OAuth access token near its expiry refreshed (mcp-servers.ts headersForRun). Never throws. */
46
- refresh?(name: string): Promise<void>;
47
- /** Before a launch: a github_app server's installation token minted for run `runId`, narrowed to the one repository
48
- * its first message (`input`) is about (github-connection.ts githubTargetOf); kept in memory for headers. Never
49
- * throws: a token there is none of is a credential that does not open, said in words to the run's calls. */
50
- mint?(name: string, runId: string, input: unknown): Promise<void>;
51
33
  }
52
34
  /** `mcp:<server>/<tool>` read, or undefined for a name that is not one. */
53
35
  export declare const mcpNameOf: (name: string) => {
@@ -85,42 +67,28 @@ export interface McpGatewayOptions {
85
67
  callMs?: number;
86
68
  connectMs?: number;
87
69
  };
88
- /** The run's tool gate, which a run that is its own process passes (app.ts): each call enters it here, the only place
89
- * an MCP call is gated there (pi's wrapper and the harnesses' hooks leave MCP calls to it). The runner passes none: its
90
- * adapter loop's gate asks before each call's intent, and the call reaches here allowed. A test may omit it too, and
91
- * then every call is let go. Its `executor` and `spill`, where it has them, run an approved call and pass a result
92
- * through. */
93
- gate?: Pick<Gate, "enter"> & Partial<Pick<Gate, "executor" | "spill">>;
94
- /** The run's commit to its store, once it is open: a parked call's request, a priced call's mark and charge, and an
95
- * unpriced call's "not metered" are written on its root. None: a priced call is refused unsent, as a paid call with
96
- * nowhere to book it is (paid-calls.ts). */
97
- commit?: () => Park["commit"] | undefined;
98
- /** Read `credentials` at every call and every request rather than copy it when the gateway is built: a change made
99
- * after (a token refreshed behind the claim, a server removed) reaches it, even through a client already connected.
100
- * Only the runner's MCP claim step (runner/mcp-claim.ts), which keeps that object current, passes it. Without it, the
101
- * credentials are copied at construction and a client sends the headers it connected with. */
102
- liveCredentials?: true;
70
+ /** The run's commit to its store: an unpriced call's "not metered" is written on its root. */
71
+ commit?: () => McpCommit | undefined;
72
+ /** The claim's per-call check of a server's credential (its custody stamp): awaited before each call is checked for
73
+ * sending, it may drop the credential (`credentials[server].unopened`), which the call then refuses unsent; one that
74
+ * throws (a store read failed, the call was stopped) refuses the call unsent too, in words, and the run goes on. Only
75
+ * the runner's MCP claim step passes it: a github_app token whose App was disconnected or replaced. A CLI harness's
76
+ * session proxy ends in the same call. */
77
+ beforeCall?: (server: string, signal: AbortSignal) => Promise<void>;
103
78
  }
79
+ /** A run's journal commit. */
80
+ export type McpCommit = <T>(change: (tx: unknown) => Promise<T>) => Promise<T>;
104
81
  /** What a call with no call id answers where a gate must know it by one: nothing was sent. */
105
82
  export declare const noCallId: (name: string) => string;
106
- /** What a call that needs a person's approval answers from a harness that cannot wait for one: nothing was sent. */
107
- export declare const cannotWait: (name: string) => string;
108
- /** The gateway: a session's servers, and a call that takes the gate's `park` of the harness it came from (its journal's
109
- * commit, and how it ends a parked call's turn); none, the run's root commit. */
83
+ /** The gateway: a session's servers, and their calls. `credentials` is read at every call and every request, never
84
+ * copied: a change the claim step makes after (a token refreshed behind the claim, a server removed) reaches it, even
85
+ * through a client already connected. */
110
86
  export type McpGateway = Omit<SessionMcp, "call"> & {
111
87
  call(server: string, tool: string, args: Record<string, unknown>, context: {
112
88
  signal: AbortSignal;
113
89
  callId?: string;
114
- park?: Park;
115
90
  }): Promise<McpCallResult>;
116
91
  /** The credential values the calls in flight hold for their scrub, every call's together (none when idle). */
117
92
  heldValues(): string[];
118
93
  };
119
94
  export declare function mcpGateway(options: McpGatewayOptions): McpGateway;
120
- /** Whether the gateway's answer is a call the gate parked for a person's approval: the harness ends the turn on it, and
121
- * a harness's session records the call as one that did not run (McpCallResult's `parked`). The door that serves a
122
- * harness's own MCP client sends the answer's content and error only. */
123
- export declare const isParked: (result: McpCallResult) => boolean;
124
- /** pi's tools for the gateway's servers: each granted tool under its wire name (`mcp__<server>__<tool>`), with the pinned
125
- * description and schema, never run again after a crash. */
126
- export declare function mcpRegistrations(gateway: McpGateway): ToolRegistration[];
@@ -1,42 +1,33 @@
1
- // A run's remote MCP servers, in the run's process: the one place every harness's MCP call goes through. pi calls it
2
- // in-process, as the tools it binds for each granted `mcp:<server>/<tool>` (mcpRegistrations); a harness with its own
3
- // MCP client calls it through the session proxy's /mcp/<server> (@parcha/agentrun-kernel/host mcpRoute). On the runner a
4
- // claimed run's spec builds one per claim from its MCP claim step (runner/mcp-run.ts mcpForClaim).
5
- // - What a run may call is pinned at its first launch (runs.ts writes MCP_PIN in the run's directory): each granted
6
- // tool as the server listed it when its owner saved it, and the server's URL then. A later refresh of the server
7
- // never changes a running agent's tools.
8
- // - Its credentials come over the run's secrets pipe (secrets.ts mcpCredentials), only for the servers it grants, with
9
- // each server's URL now: one whose URL is not the pinned one is never sent anything, and the credential the pipe
10
- // holds for a moved server is none.
1
+ // A run's remote MCP servers: the one place every harness's MCP call goes through. A claimed run's spec builds one per
2
+ // claim from its MCP claim step (runner/mcp-run.ts mcpForClaim); pi calls it through the runner's host tools, and a
3
+ // harness with its own MCP client through the session proxy's /mcp/<server> (@parcha/agentrun-kernel/host mcpRoute).
4
+ // - What a run may call is pinned (mcpPinOf): each granted tool as the server listed it when its owner saved it, and
5
+ // the server's URL then. A later refresh of the server never changes a running agent's tools.
6
+ // - Its credentials come from the claim step, only for the servers it grants, with each server's URL now, read at every
7
+ // call and every request: one whose URL is not the pinned one is never sent anything.
11
8
  // - One upstream client per server (the official SDK), connected at its first call; no redirect is followed, so a
12
9
  // credential goes nowhere but the pinned URL, and an answer past MAX_RESPONSE is cut off.
13
10
  // - A call is never sent twice: each harness records its intent before it reaches here (pi-durable's tool intent,
14
11
  // Claude's PreToolUse), and one a crash cut off is answered interrupted there. An aborted call aborts upstream.
15
12
  // - Every failure is a result the model reads, naming the server and never a header.
16
- // - Every call passes the run's tool gate first (tool-gate.ts), as `mcp:<server>/<tool>`: a denied one is refused, and
17
- // one set to ask is parked: its answer is the gate's waiting text, marked parked (isParked), and the harness ends the
18
- // turn, as for any tool. Nothing is sent. Once a person allows it, the gate runs it through the executor this gateway
19
- // registers (`mcp:`), once, and resumes the session with its result. A pinned tool's call whose arguments are not as
20
- // its settings pin them is refused there too, unsent and unasked.
21
- // - A tool its owner priced (the server's `prices`) is held at that price under the run's cap and booked as the run's
22
- // tool cost, as any paid call (cap.ts paidCall): refused unsent when the cap cannot take it. A tool with no price runs,
23
- // marked "not metered" on the run's root (TOOL_UNMETERED), outside the run's cost.
13
+ // - The runner's adapter loop gates every call before its intent (tool-gate.ts RunGate.decide), as
14
+ // `mcp:<server>/<tool>`: a call that reaches here was allowed.
15
+ // - A tool its owner priced (the server's `prices`) is held at that price on the run's one ledger and booked as the
16
+ // run's tool cost (paid-calls.ts paidStep): refused unsent when the cap cannot take it, or when no ledger books it. A
17
+ // tool with no price runs, marked "not metered" on the run's root (TOOL_UNMETERED), outside the run's cost.
24
18
  import { randomUUID } from "node:crypto";
25
- import { defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
26
- import { TOOL_COST, TOOL_UNMETERED } from "@parcha/pi-durable-agent/timeline";
27
- import { holdRefusal, paidLedger, paidStep, writeHold } from "./paid-calls.js";
28
- import { paidCall } from "./cap.js";
29
- import { wireName } from "./catalog.js";
19
+ import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
20
+ import { TOOL_UNMETERED } from "./timeline/index.js";
21
+ import { filedAnswer } from "./filed-answer.js";
22
+ import { paidLedger, paidStep } from "./paid-calls.js";
30
23
  import { metaToolOf } from "./mcp-meta.js";
31
24
  import { SIGN_IN_AGAIN } from "./mcp-oauth.js";
32
- import { GATED_BY_GATEWAY, mcpToolName } from "./tool-gate.js";
33
- import { forModel } from "./result.js";
25
+ import { mcpToolName } from "./tool-gate.js";
34
26
  import { workspaceAt, workspaceErrorWords } from "./workspace/index.js";
35
- /** The run's pinned MCP tools, in its directory: written once, at its first launch. */
36
- export const MCP_PIN = "mcp-tools.json";
37
27
  /** A catalog name of an MCP tool: `mcp:<server>/<tool>`. A server name has no `_`, so `mcp__<server>__<tool>` splits one way. */
38
28
  export const MCP_NAME = /^mcp:([a-z][a-z0-9-]{0,31})\/([A-Za-z0-9_-]{1,64})$/;
39
- /** The longest answer the model reads whole; the rest is filed in the run's work/ (monid's rule). */
29
+ /** The longest answer the model reads whole; past it, the rest is filed in the run's work/ as lines read pages through
30
+ * (filed-answer.ts). Within the host's result bound (HOST_RESULT_MAX_CHARS), so every harness passes it whole. */
40
31
  export const MCP_CLIP = 60_000;
41
32
  /** The most of one upstream answer read. */
42
33
  export const MAX_RESPONSE = 4 * 1024 * 1024;
@@ -186,22 +177,15 @@ const until = (work, signal) => new Promise((resolve, reject) => {
186
177
  });
187
178
  /** What a call with no call id answers where a gate must know it by one: nothing was sent. */
188
179
  export const noCallId = (name) => `The ${name} call was not sent: it came with no call id, so it cannot wait for a person's approval.`;
189
- /** What a call that needs a person's approval answers from a harness that cannot wait for one: nothing was sent. */
190
- export const cannotWait = (name) => `The ${name} call needs a person's approval, which this harness can't wait for yet; nothing was sent.`;
191
- /** The gateways that hold their run's gate: each of their calls enters it, in `call`. */
192
- const gating = new WeakSet();
193
180
  export function mcpGateway(options) {
194
181
  const clients = new Map();
195
182
  const pins = new Map(Object.entries(options.pin));
196
- const live = options.liveCredentials === true;
197
- const credentials = live
198
- ? { get: (server) => (Object.hasOwn(options.credentials, server) ? options.credentials[server] : undefined) }
199
- : new Map(Object.entries(options.credentials));
183
+ const credentials = { get: (server) => (Object.hasOwn(options.credentials, server) ? options.credentials[server] : undefined) };
200
184
  /** Each server's last HTTP status, which tells a refused credential from another failure. */
201
185
  const statuses = new Map();
202
186
  const send = options.fetch ?? fetch;
203
187
  /** The credential values each call in flight took or its server's requests sent while it was out, one set per call, by
204
- * server: with liveCredentials a refresh can swap a token between a call taking its headers and a request leaving, so
188
+ * server: a refresh can swap a token between a call taking its headers and a request leaving, so
205
189
  * what its answer or error is scrubbed of is every one of them, never only the headers it took. A call's set goes when
206
190
  * the call ends, so nothing held outlives the calls that sent it. */
207
191
  const inFlight = new Map();
@@ -263,7 +247,7 @@ export function mcpGateway(options) {
263
247
  const { Client, StreamableHTTPClientTransport } = await import("@modelcontextprotocol/client");
264
248
  // The 2026-07-28 revision first, a 2025-era server through its initialize, as a preview connects.
265
249
  const client = new Client({ name: "agentrun", version: "1.0.0" }, { capabilities: {}, versionNegotiation: { mode: "auto" } });
266
- await client.connect(new StreamableHTTPClientTransport(new URL(url), { fetch: guarded(server, live ? () => credentials.get(server)?.headers ?? {} : headers, status) }), { timeout: options.bounds?.connectMs ?? CONNECT_MS });
250
+ await client.connect(new StreamableHTTPClientTransport(new URL(url), { fetch: guarded(server, () => credentials.get(server)?.headers ?? {}, status) }), { timeout: options.bounds?.connectMs ?? CONNECT_MS });
267
251
  return client;
268
252
  })();
269
253
  clients.set(server, upstream);
@@ -272,28 +256,41 @@ export function mcpGateway(options) {
272
256
  }
273
257
  return upstream;
274
258
  };
275
- /** The model's text of `result`: its text blocks joined, its structured content when it has no text; past MCP_CLIP, or
276
- * with blocks that are not text, the whole result is filed in the run's evidence/mcp/<server>/, through its Workspace
277
- * (never through a link), and the text says where. `clean` scrubs every credential the call's server took or sent. */
259
+ /** The model's text of `result`: its text blocks and its embedded text resources (GitHub's get_file_contents answers a
260
+ * file as one) joined, its structured content when it has neither. Past MCP_CLIP, its start and the rest filed in the
261
+ * run's evidence/mcp/<server>/ as readable lines, through its Workspace (never through a link), the text saying where
262
+ * and the read offset that goes on (filed-answer.ts), so read pages through it with no shell. With blocks that are
263
+ * neither (an image, a blob), the whole result is filed there as JSON, and the text says where. `clean` scrubs every
264
+ * credential the call's server took or sent. */
278
265
  const textOf = async (server, tool, result, clean) => {
279
266
  const blocks = Array.isArray(result.content) ? result.content : [];
280
- const texts = blocks.filter((block) => block?.type === "text" && typeof block.text === "string").map((block) => block.text);
267
+ const texts = blocks.flatMap((block) => {
268
+ if (block?.type === "text" && typeof block.text === "string")
269
+ return [block.text];
270
+ const resource = block?.type === "resource" ? block.resource : undefined;
271
+ if (typeof resource?.text !== "string")
272
+ return [];
273
+ const about = [typeof resource.uri === "string" ? resource.uri : "", typeof resource.mimeType === "string" ? `(${resource.mimeType})` : ""].filter(Boolean).join(" ");
274
+ return [`[resource${about ? ` ${about}` : ""}]\n${resource.text}`];
275
+ });
281
276
  let text = clean(texts.join("\n\n"));
282
277
  if (!text && result.structuredContent !== undefined)
283
278
  text = clean(JSON.stringify(result.structuredContent));
284
279
  const other = blocks.length - texts.length;
285
280
  if (text.length <= MCP_CLIP && other === 0)
286
281
  return text;
287
- const name = `${tool}-${new Date().toISOString().replace(/[:.]/g, "-")}-${randomUUID().slice(0, 8)}.json`;
282
+ const name = `${tool}-${new Date().toISOString().replace(/[:.]/g, "-")}-${randomUUID().slice(0, 8)}`;
283
+ if (other === 0)
284
+ return filedAnswer(() => workspaceAt(options.work()), `evidence/mcp/${server}`, name, text, MCP_CLIP);
288
285
  const head = text.length > MCP_CLIP ? `${text.slice(0, MCP_CLIP)}\n[cut at ${MCP_CLIP} of ${text.length} characters; ` : `${text}\n[${other} block${other > 1 ? "s" : ""} that ${other > 1 ? "are" : "is"} not text; `;
289
286
  try {
290
- await workspaceAt(options.work()).write(`evidence/mcp/${server}/${name}`, clean(JSON.stringify(result)));
287
+ await workspaceAt(options.work()).write(`evidence/mcp/${server}/${name}.json`, clean(JSON.stringify(result)));
291
288
  }
292
289
  catch (error) {
293
290
  // The Workspace's code and the port's line for it, never the error's message, which names paths.
294
291
  return `${head}the whole answer could not be saved (${workspaceErrorWords(error) ?? error?.code ?? "write failed"})]`;
295
292
  }
296
- return `${head}the whole answer is in the run's files at evidence/mcp/${server}/${name}]`;
293
+ return `${head}the whole answer is in the run's files at evidence/mcp/${server}/${name}.json]`;
297
294
  };
298
295
  /** The call itself, to a server whose address is the pinned one. A gate's decision or a paid call's hold goes around
299
296
  * it, in `call` below: the one place every harness's call passes before anything is sent. */
@@ -362,6 +359,16 @@ export function mcpGateway(options) {
362
359
  };
363
360
  /** A call the gate let go: a priced one under the run's cap and booked, an unpriced one marked not metered. */
364
361
  const sent = async (server, tool, args, callId, signal) => {
362
+ // The credential's custody checked first: one the claim drops now is refused below, unsent. A check that could not
363
+ // be made (a store read failed, the call was stopped) refuses this call unsent too, in words: never sent unchecked.
364
+ if (options.beforeCall) {
365
+ try {
366
+ await options.beforeCall(server, signal);
367
+ }
368
+ catch {
369
+ return said(`The MCP server ${server}'s credential can't be used right now: it could not be checked just now. Nothing was sent.`, true);
370
+ }
371
+ }
365
372
  const why = unsendable(server, tool);
366
373
  if (why)
367
374
  return said(why, true);
@@ -391,105 +398,17 @@ export function mcpGateway(options) {
391
398
  const stepped = await paidStep(onLedger, callId ?? name, { name, holdUsd: price, basis: `the price its owner set for ${name}`, by: label.charged_by }, () => call(), () => (went ? price : 0));
392
399
  return "refused" in stepped ? said(stepped.refused, true) : stepped.result;
393
400
  }
394
- if (!commit)
395
- return said(`${name} was not sent: this call has no run to book its price under.`, true);
396
- const paid = await paidCall(name, async () => {
397
- // Held at its price meanwhile; marked right before it leaves, and settled at its price once it left, whatever it
398
- // answers: its owner says each call costs that. One that never left (a failed connect, a stop) books nothing.
399
- const result = await call(async () => {
400
- try {
401
- await writeHold((kind, data) => record(commit, kind, data), { ...label, heldUsd: price });
402
- return undefined;
403
- }
404
- catch (error) {
405
- return holdRefusal(name, error);
406
- }
407
- });
408
- if (went)
409
- await record(commit, TOOL_COST, { ...label, usd: price }).catch(() => undefined);
410
- return result;
411
- }, () => (went ? price : 0), { usd: price, basis: `the price its owner set for ${name}` });
412
- return "refused" in paid ? said(paid.refused, true) : paid.result;
401
+ return said(`${name} was not sent: this call has no run to book its price under.`, true);
413
402
  };
414
- // An approved call, run by the gate once a person allows it: through the same path, once. It has the same deadline as
415
- // any call: forward() gives callTool CALL_MS and a server's first connection CONNECT_MS, so a server that never answers
416
- // ends the call as an error the model reads, the upstream request aborted, and the run goes on; the gate's own stop or
417
- // cancel reaches it through `signal`.
418
- options.gate?.executor?.("mcp:", async (name, args, callId, signal) => {
419
- const parsed = /^mcp:([^/]+)\/(.+)$/.exec(name);
420
- const result = parsed ? await sent(parsed[1], parsed[2], (args ?? {}), callId, signal) : said(`${name} is not an MCP tool.`, true);
421
- return { text: result.content.map((block) => block.text).join("\n\n"), isError: result.isError === true };
422
- });
423
403
  const gateway = {
424
404
  servers: [...pins].map(([name, pinned]) => ({ name, tools: pinned.tools })),
425
405
  heldValues: () => [...new Set([...inFlight.values()].flatMap((calls) => [...calls].flatMap((values) => [...values])))],
426
- async call(server, tool, args, { signal, callId, park: given }) {
406
+ async call(server, tool, args, { signal, callId }) {
427
407
  const why = unsendable(server, tool);
428
408
  if (why)
429
409
  return said(why, true);
430
- const gate = options.gate;
431
- // A parked call is answered and resumed by its id, the harness's own: a call with none is never parked.
432
- if (gate && !callId)
433
- return said(noCallId(mcpToolName(server, tool)), true);
434
- const id = callId ?? `mcp_${randomUUID()}`;
435
- if (gate) {
436
- const name = mcpToolName(server, tool);
437
- // A call parks only where its harness can end the turn on it (a park with `parked`). Anywhere else the gate's
438
- // commit of the request is refused, so an ask leaves no approval waiting, and the call is answered so.
439
- const park = given?.parked ? given : { commit: () => Promise.reject(new CannotPark()) };
440
- const cannot = said(cannotWait(name), true);
441
- let entered;
442
- try {
443
- // The approval card shows the call's declared price, or that it is not metered.
444
- const price = pins.get(server).prices;
445
- entered = await gate.enter(name, args, id, park, { price: price && Object.hasOwn(price, tool) ? price[tool] : "not metered" });
446
- }
447
- catch (error) {
448
- if (error instanceof CannotPark)
449
- return cannot;
450
- return said(`The ${name} call was not sent: the tool gate failed (${String(error?.message ?? error).slice(0, 200)}).`, true);
451
- }
452
- if (entered?.parked)
453
- return park === given ? { ...said(entered.text), parked: true } : cannot;
454
- if (entered)
455
- return said(entered.text, entered.isError);
456
- const result = await sent(server, tool, args, id, signal);
457
- const text = result.content.map((block) => block.text).join("\n\n");
458
- return said(gate.spill ? gate.spill(id, text) : text, result.isError === true);
459
- }
460
- return sent(server, tool, args, id, signal);
410
+ return sent(server, tool, args, callId ?? `mcp_${randomUUID()}`, signal);
461
411
  },
462
412
  };
463
- if (options.gate)
464
- gating.add(gateway);
465
413
  return gateway;
466
414
  }
467
- /** A park refused: the call came from a harness that cannot end its turn on a parked call. */
468
- class CannotPark extends Error {
469
- }
470
- /** Whether the gateway's answer is a call the gate parked for a person's approval: the harness ends the turn on it, and
471
- * a harness's session records the call as one that did not run (McpCallResult's `parked`). The door that serves a
472
- * harness's own MCP client sends the answer's content and error only. */
473
- export const isParked = (result) => result.parked === true;
474
- /** pi's tools for the gateway's servers: each granted tool under its wire name (`mcp__<server>__<tool>`), with the pinned
475
- * description and schema, never run again after a crash. */
476
- export function mcpRegistrations(gateway) {
477
- // Marked when the gateway holds the run's gate: its calls enter the gate in the gateway, so the gate's own wrapper
478
- // (tool-gate.ts extension) leaves them be. Unmarked, the wrapper gates them as any tool.
479
- const marked = gating.has(gateway) ? { [GATED_BY_GATEWAY]: true } : {};
480
- return gateway.servers.flatMap((server) => server.tools.map((tool) => Object.assign(defineTool({
481
- name: wireName(`mcp:${server.name}/${tool.name}`),
482
- description: tool.description || tool.title || `${tool.name}, a tool of the MCP server ${server.name}.`,
483
- replay: "unsafe",
484
- parameters: tool.inputSchema,
485
- execute: async (args, api, context) => {
486
- // The gate's park is this call's own journal commit, as for every pi tool.
487
- // pi ends the turn on a parked answer itself (below), so its park needs nothing told.
488
- const park = { commit: (change) => api.commit(change, context), parked: () => undefined };
489
- const result = await gateway.call(server.name, tool.name, (args ?? {}), { signal: context?.abortSignal ?? new AbortController().signal, ...(api?.callId ? { callId: api.callId, park } : {}) });
490
- const text = result.content.map((block) => block.text).join("\n\n");
491
- // A parked call ends the turn, as ask_person's does; the gate resumes the session once a person answers.
492
- return isParked(result) ? forModel(text, { control: { terminate: true } }) : forModel(text, { isError: result.isError === true });
493
- },
494
- }), marked)));
495
- }
@@ -9,7 +9,7 @@ export declare const MCP_SETTINGS_PAGE = "/#/settings/mcp";
9
9
  export declare const SIGN_IN_AGAIN = "sign in again in Settings \u2192 MCP servers";
10
10
  /** The most sign-ins that may be in flight at once: the in-memory map evicts to it, and the store-backed one refuses past it. */
11
11
  export declare const MAX_PENDING = 64;
12
- /** How long a token refresh's request may take: a run's start waits for it, two tries at most (mcp-servers.ts), so an
12
+ /** How long a token refresh's request may take: a run's start waits for it, two tries at most (runner/mcp-claim.ts), so an
13
13
  * authorization server that never answers holds a start's answer no more than about eight seconds, well under a
14
14
  * client's timeout, and its call is then refused unsent, saying to try again. */
15
15
  export declare const REFRESH_REQUEST_MS = 4000;
@@ -98,18 +98,16 @@ export declare const signInCookie: (port: number | undefined, state: string, htt
98
98
  export declare const startedHere: (cookies: string | undefined, port: number | undefined, state: string | null) => boolean;
99
99
  export declare class McpSignIns {
100
100
  private readonly network;
101
- private readonly pendingStore?;
101
+ private readonly pendingStore;
102
102
  private readonly allowed;
103
- /** `pendingStore`: where sign-ins in flight are kept. Omitted, an in-memory map (the file server); the store server
104
- * passes one over store.mcpOauth. `allowed`: the private-network hosts the owner allows (privateOAuthHosts), read
105
- * at a sign-in's start and again at its callback; omitted, none. */
106
- constructor(network?: OAuthNetwork, pendingStore?: PendingStore | undefined, allowed?: () => Promise<readonly string[]>);
107
- private readonly pending;
103
+ /** `pendingStore`: where sign-ins in flight are kept (over store.mcpOauth). `allowed`: the private-network hosts the
104
+ * owner allows (privateOAuthHosts), read at a sign-in's start and again at its callback. */
105
+ constructor(network: OAuthNetwork, pendingStore: PendingStore, allowed: () => Promise<readonly string[]>);
108
106
  /** This server's address as a browser reaches it (AGENTRUN_PUBLIC_URL, else where it listens), no trailing slash:
109
- * set by McpServers.attach as the server starts listening. */
107
+ * set by McpServersOverStore.attach as the server starts listening. */
110
108
  base: string;
111
109
  /** Where this server listens (`http://<host>:<port>`), whatever `base` is: its port is never an endpoint a loopback
112
- * authorization server may name. Set by McpServers.attach. */
110
+ * authorization server may name. Set by McpServersOverStore.attach. */
113
111
  listening: string;
114
112
  /** This server's own local addresses, whose ports a loopback authorization server may never name: where it listens,
115
113
  * and its public address too when that is on loopback (a local https proxy on another port, in front of the
@@ -147,11 +145,9 @@ export declare class McpSignIns {
147
145
  kind?: ClientKind;
148
146
  keptFor?: string;
149
147
  }): Promise<string>;
150
- /** The callback's sign-in, by its state: once, and only within ten minutes of its start. `was` is the server's save
151
- * when it started (null for none), so a sign-in the owner since replaced or forgot is not written back. */
152
- take(state: string | null): Pending;
153
- /** take() over the pending store (the store server), async: the callback's sign-in, by its state, once and only within
154
- * ten minutes of its start. The same refusal as take() when it is used, expired or unknown. */
148
+ /** The callback's sign-in, by its state, from the pending store: once, and only within ten minutes of its start. `was`
149
+ * is the server's save when it started (null for none), so a sign-in the owner since replaced or forgot is not
150
+ * written back. */
155
151
  takePending(state: string | null): Promise<Pending>;
156
152
  /** The code exchanged (with the verifier and the client the start kept) for the token set to seal. */
157
153
  finish(entry: Pending, code: string, iss: string | undefined, stop?: AbortSignal): Promise<TokenSet>;