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

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 (444) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/README.md +343 -246
  3. package/dist/adapters.d.ts +0 -7
  4. package/dist/adapters.js +11 -22
  5. package/dist/agent-rows.d.ts +98 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +60 -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 +14 -0
  14. package/dist/api-only.js +33 -0
  15. package/dist/archil-routes.d.ts +1 -1
  16. package/dist/bash-read-only.d.ts +22 -0
  17. package/dist/bash-read-only.js +701 -0
  18. package/dist/box-egress-vm.d.ts +0 -8
  19. package/dist/box-egress-vm.js +0 -10
  20. package/dist/box-egress.d.ts +0 -4
  21. package/dist/box-egress.js +1 -16
  22. package/dist/box-paths.d.ts +25 -2
  23. package/dist/box-paths.js +79 -11
  24. package/dist/box-relay.d.ts +0 -11
  25. package/dist/box-relay.js +0 -20
  26. package/dist/box-settings.d.ts +26 -0
  27. package/dist/box-settings.js +63 -0
  28. package/dist/boxes.d.ts +21 -1
  29. package/dist/boxes.js +27 -20
  30. package/dist/browser-commands.d.ts +5 -2
  31. package/dist/browser-commands.js +4 -4
  32. package/dist/browser-computer.d.ts +5 -0
  33. package/dist/browser-computer.js +21 -0
  34. package/dist/browser-cost.d.ts +9 -6
  35. package/dist/browser-cost.js +94 -51
  36. package/dist/browser-live.d.ts +7 -20
  37. package/dist/browser-live.js +15 -93
  38. package/dist/browser-person.d.ts +18 -53
  39. package/dist/browser-person.js +94 -279
  40. package/dist/budget.d.ts +0 -4
  41. package/dist/budget.js +0 -7
  42. package/dist/cap.d.ts +8 -12
  43. package/dist/cap.js +12 -27
  44. package/dist/cli.js +61 -20
  45. package/dist/closed-pipes.d.ts +2 -0
  46. package/dist/closed-pipes.js +13 -0
  47. package/dist/computer-commands.d.ts +2 -0
  48. package/dist/computer-commands.js +2 -0
  49. package/dist/computer-keys.js +5 -2
  50. package/dist/computer-setting.d.ts +20 -4
  51. package/dist/computer-setting.js +25 -5
  52. package/dist/computers.d.ts +31 -3
  53. package/dist/computers.js +70 -11
  54. package/dist/confine.d.ts +120 -0
  55. package/dist/confine.js +436 -0
  56. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  57. package/dist/console/assets/index-opTN5Naq.css +1 -0
  58. package/dist/console/index.html +2 -2
  59. package/dist/daytona-api.d.ts +0 -11
  60. package/dist/daytona-api.js +1 -82
  61. package/dist/decision-rows.d.ts +1 -1
  62. package/dist/decision-rows.js +1 -1
  63. package/dist/docker-daemon.d.ts +31 -0
  64. package/dist/docker-daemon.js +56 -0
  65. package/dist/docker-host-addresses.d.ts +37 -0
  66. package/dist/docker-host-addresses.js +110 -0
  67. package/dist/effort-guidance.js +4 -3
  68. package/dist/environment.d.ts +0 -3
  69. package/dist/environment.js +3 -5
  70. package/dist/errors.d.ts +0 -2
  71. package/dist/errors.js +6 -9
  72. package/dist/filed-answer.d.ts +32 -0
  73. package/dist/filed-answer.js +160 -0
  74. package/dist/files.d.ts +1 -11
  75. package/dist/files.js +2 -21
  76. package/dist/github-connection.d.ts +2 -2
  77. package/dist/github-connection.js +1 -1
  78. package/dist/graph-view.d.ts +3 -5
  79. package/dist/graph-view.js +4 -14
  80. package/dist/handed-values.d.ts +9 -0
  81. package/dist/handed-values.js +26 -0
  82. package/dist/harness-install.d.ts +22 -5
  83. package/dist/harness-install.js +98 -20
  84. package/dist/harness-opencode/adapter.d.ts +7 -0
  85. package/dist/harness-opencode/adapter.js +23 -6
  86. package/dist/harness-opencode/index.d.ts +1 -1
  87. package/dist/harness-opencode/index.js +1 -1
  88. package/dist/harness-opencode/verify.d.ts +17 -0
  89. package/dist/harness-opencode/verify.js +30 -10
  90. package/dist/harness-table.js +6 -1
  91. package/dist/harness.d.ts +4 -3
  92. package/dist/harness.js +16 -1
  93. package/dist/heard.js +1 -1
  94. package/dist/held-fd.d.ts +5 -0
  95. package/dist/held-fd.js +14 -0
  96. package/dist/host-calls.d.ts +20 -0
  97. package/dist/host-calls.js +12 -0
  98. package/dist/host-tools.d.ts +4 -21
  99. package/dist/host-tools.js +4 -61
  100. package/dist/host.d.ts +2 -4
  101. package/dist/host.js +2 -7
  102. package/dist/import-summary.d.ts +1 -5
  103. package/dist/import-summary.js +0 -21
  104. package/dist/import.d.ts +6 -6
  105. package/dist/import.js +62 -24
  106. package/dist/key-refusal.d.ts +5 -1
  107. package/dist/key-refusal.js +19 -4
  108. package/dist/learn/check.d.ts +6 -2
  109. package/dist/learn/check.js +83 -29
  110. package/dist/learn/folder.d.ts +5 -1
  111. package/dist/learn/folder.js +10 -3
  112. package/dist/learn/grade.d.ts +14 -0
  113. package/dist/learn/grade.js +68 -12
  114. package/dist/learn/index.d.ts +4 -4
  115. package/dist/learn/index.js +4 -4
  116. package/dist/learn/reflect.d.ts +31 -2
  117. package/dist/learn/reflect.js +79 -4
  118. package/dist/learn/relevance.d.ts +24 -0
  119. package/dist/learn/relevance.js +91 -0
  120. package/dist/learn/secrets.d.ts +8 -1
  121. package/dist/learn/secrets.js +95 -15
  122. package/dist/learn/skills.d.ts +112 -14
  123. package/dist/learn/skills.js +556 -52
  124. package/dist/learned-workflow.d.ts +37 -5
  125. package/dist/learned-workflow.js +106 -12
  126. package/dist/learning-routes.d.ts +16 -49
  127. package/dist/learning-routes.js +46 -36
  128. package/dist/learning-run.d.ts +6 -250
  129. package/dist/learning-run.js +11 -665
  130. package/dist/learning-words.d.ts +12 -5
  131. package/dist/learning-words.js +18 -9
  132. package/dist/learning.d.ts +93 -77
  133. package/dist/learning.js +176 -304
  134. package/dist/live/stream.js +1 -1
  135. package/dist/live/translate.js +13 -3
  136. package/dist/local-models.d.ts +11 -5
  137. package/dist/local-models.js +13 -8
  138. package/dist/mcp-gateway.d.ts +11 -52
  139. package/dist/mcp-gateway.js +44 -148
  140. package/dist/mcp-oauth.d.ts +10 -14
  141. package/dist/mcp-oauth.js +14 -32
  142. package/dist/mcp-probe.d.ts +0 -7
  143. package/dist/mcp-probe.js +4 -10
  144. package/dist/mcp-servers-store.d.ts +6 -6
  145. package/dist/mcp-servers-store.js +13 -15
  146. package/dist/mcp-store.js +3 -4
  147. package/dist/mcp.js +4 -3
  148. package/dist/model.d.ts +6 -7
  149. package/dist/model.js +43 -27
  150. package/dist/monid.d.ts +0 -2
  151. package/dist/monid.js +3 -6
  152. package/dist/openapi.d.ts +8 -1
  153. package/dist/openapi.js +124 -50
  154. package/dist/page.d.ts +1 -3
  155. package/dist/page.js +9 -19
  156. package/dist/paid-calls.d.ts +21 -27
  157. package/dist/paid-calls.js +28 -62
  158. package/dist/pause.d.ts +0 -2
  159. package/dist/pause.js +1 -8
  160. package/dist/place.d.ts +0 -5
  161. package/dist/place.js +0 -10
  162. package/dist/print.d.ts +2 -1
  163. package/dist/print.js +4 -2
  164. package/dist/propose.js +83 -39
  165. package/dist/push-handler.d.ts +1 -1
  166. package/dist/reflect-range.d.ts +25 -0
  167. package/dist/reflect-range.js +30 -0
  168. package/dist/refusal-words.d.ts +5 -1
  169. package/dist/refusal-words.js +5 -1
  170. package/dist/rows.d.ts +1 -1
  171. package/dist/run-cut.d.ts +0 -6
  172. package/dist/run-cut.js +0 -6
  173. package/dist/run-db.d.ts +2 -13
  174. package/dist/run-db.js +2 -41
  175. package/dist/run-launch.d.ts +19 -2
  176. package/dist/run-launch.js +13 -5
  177. package/dist/run-learning-served.d.ts +46 -2
  178. package/dist/run-learning-served.js +26 -7
  179. package/dist/run-reads-over-store.d.ts +1 -1
  180. package/dist/run-reads-over-store.js +15 -6
  181. package/dist/run-secrets.d.ts +33 -0
  182. package/dist/run-secrets.js +53 -0
  183. package/dist/run-timeline-served.d.ts +5 -1
  184. package/dist/run-timeline-served.js +19 -5
  185. package/dist/run-view.d.ts +12 -17
  186. package/dist/run-view.js +29 -28
  187. package/dist/runnable.d.ts +18 -10
  188. package/dist/runnable.js +21 -10
  189. package/dist/runner/adapter-loop.d.ts +14 -3
  190. package/dist/runner/adapter-loop.js +464 -62
  191. package/dist/runner/adapter-run-spec.d.ts +29 -8
  192. package/dist/runner/adapter-run-spec.js +96 -37
  193. package/dist/runner/adapters/index.js +11 -1
  194. package/dist/runner/adapters/pi.d.ts +15 -1
  195. package/dist/runner/adapters/pi.js +19 -5
  196. package/dist/runner/beside.d.ts +30 -3
  197. package/dist/runner/beside.js +54 -12
  198. package/dist/runner/claim-secrets.d.ts +10 -1
  199. package/dist/runner/claim-secrets.js +49 -15
  200. package/dist/runner/cli-run-spec.d.ts +2 -0
  201. package/dist/runner/cli-run-spec.js +60 -17
  202. package/dist/runner/commands.js +1 -1
  203. package/dist/runner/computer-journal.d.ts +15 -2
  204. package/dist/runner/computer-journal.js +41 -5
  205. package/dist/runner/conformance/harness.js +118 -8
  206. package/dist/runner/conformance/subject.d.ts +4 -1
  207. package/dist/runner/dispatch.d.ts +8 -1
  208. package/dist/runner/dispatch.js +81 -7
  209. package/dist/runner/end-of-run.d.ts +8 -2
  210. package/dist/runner/end-of-run.js +10 -4
  211. package/dist/runner/github-app.js +1 -1
  212. package/dist/runner/harness-loops.d.ts +9 -1
  213. package/dist/runner/harness-loops.js +15 -2
  214. package/dist/runner/journal-kinds.d.ts +30 -6
  215. package/dist/runner/journal-kinds.js +20 -5
  216. package/dist/runner/journal-reader.d.ts +1 -1
  217. package/dist/runner/journal-reader.js +2 -2
  218. package/dist/runner/learning-ask.d.ts +4 -0
  219. package/dist/runner/learning-ask.js +15 -1
  220. package/dist/runner/learning-end.d.ts +18 -3
  221. package/dist/runner/learning-end.js +113 -11
  222. package/dist/runner/learning-loop.d.ts +5 -0
  223. package/dist/runner/learning-loop.js +26 -6
  224. package/dist/runner/live-ticker.d.ts +1 -1
  225. package/dist/runner/live-ticker.js +28 -4
  226. package/dist/runner/loop-contract.d.ts +3 -2
  227. package/dist/runner/main.d.ts +64 -10
  228. package/dist/runner/main.js +165 -27
  229. package/dist/runner/mcp-claim.d.ts +1 -1
  230. package/dist/runner/mcp-claim.js +2 -3
  231. package/dist/runner/mcp-run.d.ts +2 -0
  232. package/dist/runner/mcp-run.js +15 -5
  233. package/dist/runner/memory-claim.d.ts +9 -0
  234. package/dist/runner/memory-claim.js +25 -0
  235. package/dist/runner/metrics.d.ts +33 -1
  236. package/dist/runner/metrics.js +85 -1
  237. package/dist/runner/model-route.d.ts +13 -0
  238. package/dist/runner/model-route.js +154 -11
  239. package/dist/runner/redact.d.ts +8 -2
  240. package/dist/runner/redact.js +11 -2
  241. package/dist/runner/reflect-hook.d.ts +12 -1
  242. package/dist/runner/reflect-hook.js +33 -3
  243. package/dist/runner/runner.d.ts +20 -0
  244. package/dist/runner/runner.js +56 -10
  245. package/dist/runner/store-port.d.ts +1 -1
  246. package/dist/runner/store-secrets.d.ts +3 -3
  247. package/dist/runner/store-secrets.js +8 -12
  248. package/dist/runner/text-tools.d.ts +44 -0
  249. package/dist/runner/text-tools.js +237 -0
  250. package/dist/runner/workflow-loop.d.ts +6 -0
  251. package/dist/runner/workflow-loop.js +6 -4
  252. package/dist/runner/workflow-spec.d.ts +18 -0
  253. package/dist/runner/workflow-spec.js +68 -26
  254. package/dist/runs-over-store.d.ts +8 -3
  255. package/dist/runs-over-store.js +76 -19
  256. package/dist/seal-key.d.ts +54 -15
  257. package/dist/seal-key.js +232 -82
  258. package/dist/sealed-settings-store.d.ts +19 -4
  259. package/dist/sealed-settings-store.js +9 -9
  260. package/dist/sealing.d.ts +4 -0
  261. package/dist/sealing.js +20 -0
  262. package/dist/secret-cut.d.ts +1 -1
  263. package/dist/secret-cut.js +1 -1
  264. package/dist/secret-name.d.ts +9 -0
  265. package/dist/secret-name.js +15 -0
  266. package/dist/secret-writes.d.ts +0 -1
  267. package/dist/secret-writes.js +0 -1
  268. package/dist/secrets.d.ts +2 -10
  269. package/dist/secrets.js +21 -17
  270. package/dist/server-fs.d.ts +4 -0
  271. package/dist/server-fs.js +8 -2
  272. package/dist/server-lock.d.ts +0 -24
  273. package/dist/server-lock.js +1 -80
  274. package/dist/server-secrets-store.d.ts +4 -4
  275. package/dist/server-secrets-store.js +10 -32
  276. package/dist/server-secrets.d.ts +4 -9
  277. package/dist/server-secrets.js +12 -33
  278. package/dist/server.d.ts +26 -44
  279. package/dist/server.js +229 -142
  280. package/dist/sign-ins-store.d.ts +34 -36
  281. package/dist/sign-ins-store.js +27 -38
  282. package/dist/sign-ins.d.ts +2 -119
  283. package/dist/sign-ins.js +5 -311
  284. package/dist/standard-webhooks.d.ts +1 -1
  285. package/dist/standard-webhooks.js +1 -1
  286. package/dist/stats.d.ts +3 -2
  287. package/dist/stats.js +1 -1
  288. package/dist/store/agent-body.d.ts +8 -2
  289. package/dist/store/agent-body.js +16 -4
  290. package/dist/store/index.d.ts +3 -3
  291. package/dist/store/index.js +3 -3
  292. package/dist/store/open.d.ts +18 -5
  293. package/dist/store/open.js +23 -3
  294. package/dist/store/postgres/connection.d.ts +18 -2
  295. package/dist/store/postgres/connection.js +156 -32
  296. package/dist/store/postgres/migrate.d.ts +4 -0
  297. package/dist/store/postgres/migrate.js +27 -3
  298. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  299. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  300. package/dist/store/postgres/store.d.ts +9 -2
  301. package/dist/store/postgres/store.js +9 -0
  302. package/dist/store/schema.js +1 -1
  303. package/dist/store/seal.js +2 -2
  304. package/dist/store/sqlite/connection.js +49 -5
  305. package/dist/store/sqlite/run-patch.d.ts +3 -0
  306. package/dist/store/sqlite/run-patch.js +3 -0
  307. package/dist/store/sqlite/store.js +64 -20
  308. package/dist/store/store.d.ts +38 -6
  309. package/dist/store/store.js +12 -2
  310. package/dist/store-reads/cap.d.ts +1 -1
  311. package/dist/store-reads/cap.js +22 -4
  312. package/dist/store-reads/journal.d.ts +25 -6
  313. package/dist/store-reads/journal.js +173 -21
  314. package/dist/store-reads/learning.d.ts +26 -8
  315. package/dist/store-reads/learning.js +12 -4
  316. package/dist/store-reads/workflow.d.ts +1 -1
  317. package/dist/store-reads/workflow.js +1 -1
  318. package/dist/store-view.d.ts +5 -1
  319. package/dist/store-view.js +91 -23
  320. package/dist/template-eval.d.ts +60 -4
  321. package/dist/template-eval.js +120 -54
  322. package/dist/templates.d.ts +24 -10
  323. package/dist/templates.js +69 -38
  324. package/dist/timeline/group.d.ts +33 -0
  325. package/dist/timeline/group.js +77 -0
  326. package/dist/timeline/index.d.ts +7 -0
  327. package/dist/timeline/index.js +7 -0
  328. package/dist/timeline/labels.d.ts +79 -0
  329. package/dist/timeline/labels.js +150 -0
  330. package/dist/timeline/origin.d.ts +56 -0
  331. package/dist/timeline/origin.js +92 -0
  332. package/dist/timeline/render-text.d.ts +11 -0
  333. package/dist/timeline/render-text.js +62 -0
  334. package/dist/timeline/timeline.d.ts +274 -0
  335. package/dist/timeline/timeline.js +1308 -0
  336. package/dist/timeline/util.d.ts +17 -0
  337. package/dist/timeline/util.js +49 -0
  338. package/dist/tool-gate.d.ts +41 -216
  339. package/dist/tool-gate.js +79 -540
  340. package/dist/tool-keys-store.d.ts +11 -12
  341. package/dist/tool-keys-store.js +24 -31
  342. package/dist/tool-keys.d.ts +9 -104
  343. package/dist/tool-keys.js +15 -271
  344. package/dist/tool-plane.d.ts +14 -42
  345. package/dist/tool-plane.js +23 -81
  346. package/dist/tool-settings-store.d.ts +1 -2
  347. package/dist/tool-settings-store.js +5 -8
  348. package/dist/tools.d.ts +31 -19
  349. package/dist/tools.js +101 -108
  350. package/dist/trigger-adapter.d.ts +2 -2
  351. package/dist/trigger-schedule.js +2 -1
  352. package/dist/trigger-secrets-shown.js +5 -1
  353. package/dist/trigger-targets.d.ts +13 -1
  354. package/dist/trigger-targets.js +31 -1
  355. package/dist/triggers.d.ts +2 -2
  356. package/dist/triggers.js +3 -3
  357. package/dist/turn-end.d.ts +1 -1
  358. package/dist/turn-end.js +1 -1
  359. package/dist/turns.d.ts +0 -6
  360. package/dist/turns.js +0 -19
  361. package/dist/uploads.js +1 -1
  362. package/dist/usage.d.ts +0 -2
  363. package/dist/usage.js +0 -2
  364. package/dist/validate.d.ts +2 -0
  365. package/dist/validate.js +23 -14
  366. package/dist/webhooks.d.ts +102 -76
  367. package/dist/webhooks.js +266 -233
  368. package/dist/workflow-run.d.ts +114 -0
  369. package/dist/workflow-run.js +144 -0
  370. package/dist/workspace/beneath.d.ts +19 -0
  371. package/dist/workspace/beneath.js +106 -0
  372. package/dist/workspace/computer-deps.d.ts +52 -5
  373. package/dist/workspace/computer-deps.js +154 -19
  374. package/dist/workspace/computer-for-claim.d.ts +19 -14
  375. package/dist/workspace/computer-for-claim.js +77 -16
  376. package/dist/workspace/computer-hold.d.ts +6 -1
  377. package/dist/workspace/computer-hold.js +6 -1
  378. package/dist/workspace/computer-janitor.d.ts +47 -0
  379. package/dist/workspace/computer-janitor.js +182 -0
  380. package/dist/workspace/computer-providers.d.ts +6 -2
  381. package/dist/workspace/computer-providers.js +1 -1
  382. package/dist/workspace/grep-worker.d.ts +5 -0
  383. package/dist/workspace/grep-worker.js +9 -6
  384. package/dist/workspace/index.d.ts +4 -3
  385. package/dist/workspace/index.js +4 -4
  386. package/dist/workspace/local.d.ts +11 -2
  387. package/dist/workspace/local.js +161 -43
  388. package/dist/workspace/resolve-computer.d.ts +50 -10
  389. package/dist/workspace/resolve-computer.js +46 -11
  390. package/dist/workspace/run-tools.d.ts +13 -31
  391. package/dist/workspace/run-tools.js +10 -27
  392. package/dist/workspace-paths.d.ts +0 -17
  393. package/dist/workspace-paths.js +1 -41
  394. package/dist/workspace.d.ts +0 -17
  395. package/dist/workspace.js +3 -99
  396. package/launcher/agentrun-serve +6 -33
  397. package/package.json +14 -14
  398. package/templates/README.md +9 -3
  399. package/templates/inbound-lead/agent.md +1 -1
  400. package/templates/kyb/agent.md +1 -1
  401. package/templates/market-monitor/agent.md +2 -2
  402. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  403. package/dist/app.d.ts +0 -5
  404. package/dist/app.js +0 -514
  405. package/dist/bound-files.d.ts +0 -4
  406. package/dist/bound-files.js +0 -164
  407. package/dist/bounds.d.ts +0 -26
  408. package/dist/bounds.js +0 -137
  409. package/dist/coding-tools.d.ts +0 -47
  410. package/dist/coding-tools.js +0 -189
  411. package/dist/computer-adb.d.ts +0 -12
  412. package/dist/computer-adb.js +0 -14
  413. package/dist/console/assets/index-35-7aeIZ.js +0 -519
  414. package/dist/console/assets/index-Cejbov-Y.css +0 -1
  415. package/dist/content-filter.d.ts +0 -7
  416. package/dist/content-filter.js +0 -23
  417. package/dist/disk.d.ts +0 -33
  418. package/dist/disk.js +0 -85
  419. package/dist/door-line.d.ts +0 -23
  420. package/dist/door-line.js +0 -83
  421. package/dist/grade.d.ts +0 -63
  422. package/dist/grade.js +0 -150
  423. package/dist/harness-app.d.ts +0 -69
  424. package/dist/harness-app.js +0 -1162
  425. package/dist/mcp-servers.d.ts +0 -269
  426. package/dist/mcp-servers.js +0 -456
  427. package/dist/packs.d.ts +0 -71
  428. package/dist/packs.js +0 -180
  429. package/dist/request-start.d.ts +0 -27
  430. package/dist/request-start.js +0 -381
  431. package/dist/run-box.d.ts +0 -205
  432. package/dist/run-box.js +0 -661
  433. package/dist/run-holder.d.ts +0 -52
  434. package/dist/run-holder.js +0 -139
  435. package/dist/runs.d.ts +0 -1200
  436. package/dist/runs.js +0 -4103
  437. package/dist/sealed-settings.d.ts +0 -60
  438. package/dist/sealed-settings.js +0 -178
  439. package/dist/served-only.d.ts +0 -5
  440. package/dist/served-only.js +0 -12
  441. package/dist/sessions.d.ts +0 -6
  442. package/dist/sessions.js +0 -109
  443. package/dist/workspace/computer-serves.d.ts +0 -12
  444. package/dist/workspace/computer-serves.js +0 -15
package/dist/mcp-oauth.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // OAuth sign-in to a remote MCP server, run by this server with the official SDK's `auth` (@modelcontextprotocol/client):
2
2
  // RFC 9728 then RFC 8414 discovery, the client (the owner's pre-registered one; else this server's client metadata
3
3
  // document, only when its address is public https; else dynamic registration), PKCE S256, the RFC 8707 resource, the
4
- // code exchange and the refresh. What is here is only what the SDK's provider keeps: a sign-in in progress, in memory by
5
- // its state (random, used once, ten minutes), and the token set the callback hands mcp-servers.ts to seal. No token is
6
- // ever answered, logged or handed to the browser.
4
+ // code exchange and the refresh. What is here is only what the SDK's provider keeps: a sign-in in progress, kept in the
5
+ // store by its state (random, used once, ten minutes; mcp-servers-store.ts pendingOverStore), and the token set the
6
+ // callback hands mcp-servers-store.ts to seal. No token is ever answered, logged or handed to the browser.
7
7
  import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
8
8
  import dns from "node:dns/promises";
9
9
  import net from "node:net";
@@ -22,7 +22,7 @@ const STATE_MS = 10 * 60_000;
22
22
  /** 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. */
23
23
  export const MAX_PENDING = 64;
24
24
  const REQUEST_MS = 15_000;
25
- /** 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
25
+ /** 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
26
26
  * authorization server that never answers holds a start's answer no more than about eight seconds, well under a
27
27
  * client's timeout, and its call is then refused unsent, saying to try again. */
28
28
  export const REFRESH_REQUEST_MS = 4_000;
@@ -238,20 +238,18 @@ export class McpSignIns {
238
238
  network;
239
239
  pendingStore;
240
240
  allowed;
241
- /** `pendingStore`: where sign-ins in flight are kept. Omitted, an in-memory map (the file server); the store server
242
- * passes one over store.mcpOauth. `allowed`: the private-network hosts the owner allows (privateOAuthHosts), read
243
- * at a sign-in's start and again at its callback; omitted, none. */
244
- constructor(network = systemNetwork, pendingStore, allowed = async () => []) {
241
+ /** `pendingStore`: where sign-ins in flight are kept (over store.mcpOauth). `allowed`: the private-network hosts the
242
+ * owner allows (privateOAuthHosts), read at a sign-in's start and again at its callback. */
243
+ constructor(network, pendingStore, allowed) {
245
244
  this.network = network;
246
245
  this.pendingStore = pendingStore;
247
246
  this.allowed = allowed;
248
247
  }
249
- pending = new Map();
250
248
  /** This server's address as a browser reaches it (AGENTRUN_PUBLIC_URL, else where it listens), no trailing slash:
251
- * set by McpServers.attach as the server starts listening. */
249
+ * set by McpServersOverStore.attach as the server starts listening. */
252
250
  base = "";
253
251
  /** Where this server listens (`http://<host>:<port>`), whatever `base` is: its port is never an endpoint a loopback
254
- * authorization server may name. Set by McpServers.attach. */
252
+ * authorization server may name. Set by McpServersOverStore.attach. */
255
253
  listening = "";
256
254
  /** This server's own local addresses, whose ports a loopback authorization server may never name: where it listens,
257
255
  * and its public address too when that is on loopback (a local https proxy on another port, in front of the
@@ -276,10 +274,6 @@ export class McpSignIns {
276
274
  /** Discovery, the client, PKCE and the state: the URL the owner opens to say yes. */
277
275
  async start(name, url, options) {
278
276
  const now = Date.now();
279
- if (!this.pendingStore)
280
- for (const [state, entry] of this.pending)
281
- if (entry.expires <= now || this.pending.size >= MAX_PENDING)
282
- this.pending.delete(state);
283
277
  const state = randomBytes(32).toString("base64url");
284
278
  const entry = { name, url: url.href, was: options.was, ...(options.scope ? { scope: options.scope } : {}), kind: options.kind ?? "dynamic", ...(options.client ? { client: options.client } : {}), ...(options.keptFor ? { keptFor: options.keptFor } : {}), expires: now + STATE_MS };
285
279
  let opened;
@@ -299,26 +293,14 @@ export class McpSignIns {
299
293
  throw new ApiError("upstream_failed", `The sign-in to ${url.origin} did not start: its authorization server gave no page to open.`);
300
294
  if (entry.client?.client_id === provider.clientMetadataUrl)
301
295
  entry.kind = "metadata-document";
302
- if (this.pendingStore)
303
- await this.pendingStore.set(state, entry);
304
- else
305
- this.pending.set(state, entry);
296
+ await this.pendingStore.set(state, entry);
306
297
  return opened.href;
307
298
  }
308
- /** The callback's sign-in, by its state: once, and only within ten minutes of its start. `was` is the server's save
309
- * when it started (null for none), so a sign-in the owner since replaced or forgot is not written back. */
310
- take(state) {
311
- const entry = state ? this.pending.get(state) : undefined;
312
- if (state)
313
- this.pending.delete(state);
314
- if (!entry || entry.expires <= Date.now())
315
- throw new ApiError("bad_request", `This sign-in link was used already, is older than ${STATE_MS / 60_000} minutes, or is not this server's: start the sign-in again in Settings → MCP servers.`);
316
- return entry;
317
- }
318
- /** take() over the pending store (the store server), async: the callback's sign-in, by its state, once and only within
319
- * ten minutes of its start. The same refusal as take() when it is used, expired or unknown. */
299
+ /** The callback's sign-in, by its state, from the pending store: once, and only within ten minutes of its start. `was`
300
+ * is the server's save when it started (null for none), so a sign-in the owner since replaced or forgot is not
301
+ * written back. */
320
302
  async takePending(state) {
321
- const entry = state && this.pendingStore ? await this.pendingStore.take(state) : undefined;
303
+ const entry = state ? await this.pendingStore.take(state) : undefined;
322
304
  if (!entry || entry.expires <= Date.now())
323
305
  throw new ApiError("bad_request", `This sign-in link was used already, is older than ${STATE_MS / 60_000} minutes, or is not this server's: start the sign-in again in Settings → MCP servers.`);
324
306
  return entry;
@@ -1,14 +1,9 @@
1
1
  import { ApiError, type InputIssue } from "./errors.js";
2
2
  export declare const MCP_SERVER_NAME: RegExp;
3
- /** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
4
- * as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
5
- export declare const RESERVED_MCP_NAMES: readonly string[];
6
3
  export declare const MCP_AUTH_TYPES: readonly ["none", "bearer", "headers", "oauth", "github_app"];
7
4
  /** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
8
5
  * after "The MCP server <name>'s credential can't be used right now: " (mcp-gateway.ts). The one place they are said. */
9
6
  export declare const UNUSABLE: {
10
- /** This server was started without its seal key. */
11
- readonly noSealKey: "this server was started without its seal key (AGENTRUN_SEAL_KEY); start it with the key the credential was saved under, or update the credential in Settings → MCP servers";
12
7
  /** Sealed under another seal key, or damaged. */
13
8
  readonly damaged: "it was sealed under another seal key, or damaged; update it in Settings → MCP servers";
14
9
  /** An OAuth sign-in its authorization server refused to refresh, or with no refresh token left. */
@@ -60,8 +55,6 @@ export type Auth = {
60
55
  type: AuthType;
61
56
  headers?: HeaderMap;
62
57
  };
63
- /** How a server gets a seal key: what its launcher does (launcher/agentrun-serve). */
64
- export declare const SEAL_KEY_HOW = "Start it with its launcher, agentrun-serve, which keeps one in agentrun/seal.key under $XDG_CONFIG_HOME (~/.config by default), made at the first start, 0600 in a 0700 directory; or hand it AGENTRUN_SEAL_KEY (32 random bytes in base64).";
65
58
  export declare const notFound: (name: string) => ApiError;
66
59
  export declare const credentialMissing: (type: AuthType, message: string) => InputIssue;
67
60
  export declare const nameOf: (name: string) => void;
package/dist/mcp-probe.js CHANGED
@@ -1,7 +1,6 @@
1
- // The MCP server probe and request validation, shared between the file McpServers (mcp-servers.ts) and the store-backed one
2
- // (mcp-servers-store.ts). Moved here verbatim so both answer and refuse byte-identically; the storage, sealing and sign-in
3
- // state differ between the two, nothing here does. Until the cutover deletes mcp-servers.ts, the file class still carries
4
- // its own copies; from the cutover on this is the one home (the switch repoints mcp-gateway.ts's UNUSABLE import here).
1
+ // The MCP server probe and request validation of the owner's registry (mcp-servers-store.ts), and the words a run's calls
2
+ // read when a saved credential can't be used (UNUSABLE, which the runner's claim step
3
+ // runner/mcp-claim.ts hands the gateway).
5
4
  //
6
5
  // Nothing here opens a credential or touches a store: listServer connects to a URL with the official SDK client, agrees a
7
6
  // protocol revision and lists every tool (all pages, under caps); the validation turns a request body into a URL, auth and
@@ -9,20 +8,17 @@
9
8
  import { ApiError, invalid } from "./errors.js";
10
9
  import { metaToolOf } from "./mcp-meta.js";
11
10
  import { SIGN_IN_AGAIN } from "./mcp-oauth.js";
12
- import { SEAL_KEY_ENV } from "./tool-keys.js";
13
11
  import { isObject, unknownFields } from "./validate.js";
14
12
  export const MCP_SERVER_NAME = /^[a-z][a-z0-9-]{0,31}$/;
15
13
  /** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
16
14
  * as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
17
- export const RESERVED_MCP_NAMES = ["hands", "monid"];
15
+ const RESERVED_MCP_NAMES = ["hands", "monid"];
18
16
  export const MCP_AUTH_TYPES = ["none", "bearer", "headers", "oauth", "github_app"];
19
17
  /** Where an owner updates a saved MCP server, as people read it. */
20
18
  const MCP_SETTINGS = "Settings → MCP servers";
21
19
  /** Why a saved credential can't be used for a run's calls, each with its own remedy and no other, as the model reads it
22
20
  * after "The MCP server <name>'s credential can't be used right now: " (mcp-gateway.ts). The one place they are said. */
23
21
  export const UNUSABLE = {
24
- /** This server was started without its seal key. */
25
- noSealKey: `this server was started without its seal key (${SEAL_KEY_ENV}); start it with the key the credential was saved under, or update the credential in ${MCP_SETTINGS}`,
26
22
  /** Sealed under another seal key, or damaged. */
27
23
  damaged: `it was sealed under another seal key, or damaged; update it in ${MCP_SETTINGS}`,
28
24
  /** An OAuth sign-in its authorization server refused to refresh, or with no refresh token left. */
@@ -69,8 +65,6 @@ const LOOPBACK = (host) => LOOPBACK_NAMES.includes(host) || LOOPBACK_V4.test(hos
69
65
  export function boundTool(tool) {
70
66
  return { name: tool.name, ...(tool.title ? { title: tool.title } : {}), ...(tool.description ? { description: tool.description } : {}), inputSchema: (tool.input_schema ?? {}), ...(tool.annotations ? { annotations: tool.annotations } : {}) };
71
67
  }
72
- /** How a server gets a seal key: what its launcher does (launcher/agentrun-serve). */
73
- export const SEAL_KEY_HOW = `Start it with its launcher, agentrun-serve, which keeps one in agentrun/seal.key under $XDG_CONFIG_HOME (~/.config by default), made at the first start, 0600 in a 0700 directory; or hand it ${SEAL_KEY_ENV} (32 random bytes in base64).`;
74
68
  export const notFound = (name) => new ApiError("not_found", `No MCP server ${name}: GET /v2/settings/mcp-servers lists them.`);
75
69
  export const credentialMissing = (type, message) => ({ field: type === "bearer" ? "auth.token" : type === "oauth" ? "auth.type" : "auth.headers", reason: "missing", message: type === "oauth" ? `${message} An OAuth server is signed in to first: POST /v2/settings/mcp-servers/{name}/oauth/start.` : message });
76
70
  export const nameOf = (name) => {
@@ -32,7 +32,7 @@ export declare class McpServersOverStore {
32
32
  private readonly inflight;
33
33
  private readonly stopped;
34
34
  constructor(store: McpServersStore, env: NodeJS.ProcessEnv, version: string, network?: OAuthNetwork);
35
- /** This server's address as a browser reaches it and where it listens (McpServers.attach). */
35
+ /** This server's address as a browser reaches it and where it listens. */
36
36
  attach(base: string, listening: string): void;
37
37
  clientDocument(): {
38
38
  redirect_uris: string[];
@@ -56,7 +56,7 @@ export declare class McpServersOverStore {
56
56
  };
57
57
  /** The origin the authorization server sends the browser back to. */
58
58
  get callbackOrigin(): string;
59
- /** The server's own tool settings, set as the server starts (McpServers.toolSettings). */
59
+ /** The server's own tool settings, set as the server starts. */
60
60
  toolSettings: () => ToolSettingsMap;
61
61
  close(boundMs?: number): Promise<void>;
62
62
  private track;
@@ -234,18 +234,18 @@ export declare class McpServersOverStore {
234
234
  private callback;
235
235
  private listServer;
236
236
  private need;
237
- /** The saved credential opened, or the refusal that asks for it again (McpServers.opened). */
237
+ /** The saved credential opened, or the refusal that asks for it again. */
238
238
  private opened;
239
239
  /** The saved OAuth token set, for a sign-in again that reuses the kept client. */
240
240
  private openedSet;
241
241
  private view;
242
- /** A body's URL, auth and prices, or 422 (McpServers.admit). */
242
+ /** A body's URL, auth and prices, or 422. */
243
243
  private admit;
244
244
  /** `headers` and, for a github_app server, an installation token of the connected App to list its tools with. Its URL
245
245
  * is checked first (githubMcpUrl), so a row saved at another address never gets a token minted or sent. */
246
246
  private withAppToken;
247
247
  }
248
- /** The McpServers surface over the one store: the switch swaps `new McpServers(data, env, version)` for this. No load() is
249
- * needed — every read goes to the store (the runner also writes the OAuth state), so a read is always current. */
248
+ /** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
249
+ * the OAuth state), so a read is always current. */
250
250
  export declare function mcpServersOverStore(store: McpServersStore, env: NodeJS.ProcessEnv, version: string, network?: OAuthNetwork): McpServersOverStore;
251
251
  export {};
@@ -1,14 +1,12 @@
1
- // The owner's remote MCP servers over the one store (store.mcp, store.mcpOauth), the store-backed replacement for the
2
- // McpServers file class (mcp-servers.ts). The probe and request validation are shared verbatim (mcp-probe.ts), so every
3
- // answer and refusal reads the same; what differs is only where the registry and the sign-ins in flight live and how the
4
- // credential is sealed. The credential is one sealed blob per row (store/seal.ts §7, the url's origin bound inside), so a
5
- // read opens it to show the auth's header names, the OAuth note and whether the sign-in expired; with no seal key a read
6
- // shows less than the file did (a degenerate misconfiguration — no credential can be saved without the key anyway).
1
+ // The owner's remote MCP servers over the one store (store.mcp, store.mcpOauth): the registry and the sign-ins in flight.
2
+ // The probe and request validation are mcp-probe.ts'. The credential is one sealed blob per row (store/seal.ts §7, the
3
+ // url's origin bound inside), so a read opens it to show the auth's header names, the OAuth note and whether the sign-in
4
+ // expired. The server never starts without its seal key, so every credential is kept sealed under it.
7
5
  //
8
6
  // Per the run-time ruling, the runner reads MCP servers, pins and credentials from the store at a run's claim
9
7
  // (runner/mcp-claim.ts), including the OAuth token refresh. So this server-side registry has NO headers()/headersForRun()
10
8
  // and does NO token refresh: it is the owner's create/preview/save/refresh(tools)/remove and the OAuth sign-in, and nothing
11
- // a run's launch calls. The switch wires it where `new McpServers(...)` was; mcpSource is dropped.
9
+ // a run's launch calls.
12
10
  import { ApiError, invalid } from "./errors.js";
13
11
  import { authOf, canonical, credentialMissing, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
14
12
  import { listMcpServers, openServerCredential, putPendingSignIn, removeMcpServer, removeMcpServerIfCredential, rewriteMcpServer, saveMcpServerIfCredential, takePendingSignIn } from "./mcp-store.js";
@@ -88,7 +86,7 @@ export class McpServersOverStore {
88
86
  constructor(store, env, version, network = systemNetwork) {
89
87
  this.store = store;
90
88
  this.version = version;
91
- // The server never starts without a seal key (seal-key.ts ensureSealKey), so there is no keyless registry: every
89
+ // The server never starts without a seal key (seal-key.ts bootSealKey), so there is no keyless registry: every
92
90
  // credential is kept sealed under it.
93
91
  const sealKey = sealKeyOf(env[SEAL_KEY_ENV]);
94
92
  if (!sealKey)
@@ -96,7 +94,7 @@ export class McpServersOverStore {
96
94
  this.sealKey = sealKey;
97
95
  this.signIns = new McpSignIns(network, pendingOverStore(store, sealKey), () => privateOAuthHosts(store));
98
96
  }
99
- /** This server's address as a browser reaches it and where it listens (McpServers.attach). */
97
+ /** This server's address as a browser reaches it and where it listens. */
100
98
  attach(base, listening) {
101
99
  this.signIns.base = base.replace(/\/+$/, "");
102
100
  this.signIns.listening = listening.replace(/\/+$/, "");
@@ -108,7 +106,7 @@ export class McpServersOverStore {
108
106
  get callbackOrigin() {
109
107
  return new URL(this.signIns.base).origin;
110
108
  }
111
- /** The server's own tool settings, set as the server starts (McpServers.toolSettings). */
109
+ /** The server's own tool settings, set as the server starts. */
112
110
  toolSettings = () => ({});
113
111
  async close(boundMs = 2_000) {
114
112
  this.stopped.abort();
@@ -346,7 +344,7 @@ export class McpServersOverStore {
346
344
  throw notFound(name);
347
345
  return row;
348
346
  }
349
- /** The saved credential opened, or the refusal that asks for it again (McpServers.opened). */
347
+ /** The saved credential opened, or the refusal that asks for it again. */
350
348
  async opened(name, row, field) {
351
349
  // No credential kept: none for a server that takes none, nor for a github_app server with no static headers.
352
350
  if (row.auth === "none" || row.sealed === null)
@@ -389,7 +387,7 @@ export class McpServersOverStore {
389
387
  url: row.url,
390
388
  ...(prices && Object.keys(prices).length ? { prices } : {}),
391
389
  ...listed,
392
- // Each priced tool's price in USD a call, as the owner saved them (main's file registry served them on every read).
390
+ // Each priced tool's price in USD a call, as the owner saved them, on every read.
393
391
  ...(prices && Object.keys(prices).length ? { prices } : {}),
394
392
  tools: listed.tools.map((tool) => ({ ...tool, ...serverGate(`mcp:${name}/${tool.name}`, settings) })),
395
393
  ...(unmetered.length ? { not_metered: unmetered } : {}),
@@ -401,7 +399,7 @@ export class McpServersOverStore {
401
399
  secret: secretOf(row),
402
400
  };
403
401
  }
404
- /** A body's URL, auth and prices, or 422 (McpServers.admit). */
402
+ /** A body's URL, auth and prices, or 422. */
405
403
  admit(body, priced = false) {
406
404
  const issues = unknownFields(body, priced ? ["url", "auth", "prices"] : ["url", "auth"]);
407
405
  const url = urlOf(body.url, issues);
@@ -433,8 +431,8 @@ export class McpServersOverStore {
433
431
  /** Which save of a server this is: a PUT or a sign-in makes a new one (its updated time moves), a refresh of its tools or
434
432
  * token does not change the url. The staleness key an OAuth sign-in carries from start to callback. */
435
433
  const saving = (row) => `${row.url} ${row.updatedAt}`;
436
- /** The McpServers surface over the one store: the switch swaps `new McpServers(data, env, version)` for this. No load() is
437
- * needed — every read goes to the store (the runner also writes the OAuth state), so a read is always current. */
434
+ /** The owner's MCP registry over the one store. No load() is needed: every read goes to the store (the runner also writes
435
+ * the OAuth state), so a read is always current. */
438
436
  export function mcpServersOverStore(store, env, version, network) {
439
437
  return new McpServersOverStore(store, env, version, network);
440
438
  }
package/dist/mcp-store.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // The MCP registry and OAuth sign-ins in flight, in the one store (store.mcp, store.mcpOauth), sealed with the store's one
2
2
  // rule (store/seal.ts): the registry row's credential under AAD mcp_servers|<name>|sealed with the url
3
3
  // origin inside the plaintext, and a pending sign-in's secret parts (the PKCE verifier and the OAuth client, with its
4
- // secret) under AAD mcp_oauth_pending|<state>|sealed. The
5
- // store-backed replacement for mcp-servers.ts's file store and mcp-oauth.ts's in-memory pending map; the cut wires these
6
- // into McpServers / McpSignIns, which keep their SDK tool-probe, validation and sign-in flow. The store never opens a
7
- // credential; only this process (and a runner) does, with the seal key.
4
+ // secret) under AAD mcp_oauth_pending|<state>|sealed. McpServersOverStore (mcp-servers-store.ts) and McpSignIns
5
+ // (mcp-oauth.ts) keep the SDK tool-probe, validation and sign-in flow over these. The store never opens a credential;
6
+ // only this process (and a runner) does, with the seal key.
8
7
  import { openMcpCredential, sealColumn, sealedAt, sealMcpCredential, unsealColumn, } from "./store/index.js";
9
8
  import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
10
9
  import { tokenLeftOf } from "./mcp-probe.js";
package/dist/mcp.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // server's own (the transport's rule against DNS rebinding; on loopback the Host check comes first, in server.ts).
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { Readable, Writable } from "node:stream";
9
- import { homeBusy, storeBusy } from "./agents.js";
9
+ import { answerOf, logged } from "./agents.js";
10
10
  import { ApiError, invalid } from "./errors.js";
11
11
  import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
12
12
  import { isJson, ownOrigin } from "./page.js";
@@ -289,8 +289,9 @@ export function mcpEndpoint({ route, authorized, authFailed, version }) {
289
289
  await res.settled;
290
290
  }
291
291
  catch (error) {
292
- const known = error instanceof ApiError ? error : storeBusy(error) ? homeBusy() : new ApiError("internal", error?.message ?? String(error));
293
- if (!(error instanceof ApiError) && !storeBusy(error))
292
+ // The same answer the HTTP route gives (answerOf): a store busy or past a write's deadline is home_busy, never 500.
293
+ const known = answerOf(error);
294
+ if (logged(error))
294
295
  process.stderr.write(`agentrun-serve: mcp: ${error?.stack ?? String(error)}\n`);
295
296
  return { status: known.status, headers: { "content-type": "application/json" }, bytes: Buffer.from(JSON.stringify(known.body(requestId))), tooBig: false };
296
297
  }
package/dist/model.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { ModelCost, ModelThinkingLevel } from "@earendil-works/pi-ai";
1
+ import type { ModelCost } from "@earendil-works/pi-ai";
2
2
  import { type HarnessEntry } from "./harness-table.js";
3
- import type { Revision } from "@parcha/pi-durable-agent";
3
+ import type { Revision } from "./agent-rows.js";
4
4
  /** The child's environment names the faux module by absolute path. */
5
5
  export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
6
6
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
@@ -13,8 +13,6 @@ export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
13
13
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
14
14
  * request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
15
15
  export declare const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
16
- /** A run's `effort`, passed to its child. */
17
- export declare const EFFORT_ENV = "AGENTRUN_SERVE_EFFORT";
18
16
  /** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
19
17
  * holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
20
18
  * that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment (pi-durable-disk's
@@ -25,6 +23,7 @@ export declare const EFFORTS: readonly ["low", "medium", "high"];
25
23
  export type Effort = (typeof EFFORTS)[number];
26
24
  /** The thinking levels a revision or the host may name. Never off. */
27
25
  export declare const THINKING_LEVELS: readonly ["low", "medium", "high", "xhigh", "max"];
26
+ export type ThinkingLevel = (typeof THINKING_LEVELS)[number];
28
27
  export declare const TIERS: readonly ["fast", "default", "strong"];
29
28
  export type Tier = (typeof TIERS)[number];
30
29
  /** The workflow node kinds that run on a model. */
@@ -131,9 +130,9 @@ export declare const GATEWAY_KEY_ENV = "AGENT_MODEL_API_KEY";
131
130
  * of that tier; through a gateway (`AGENT_MODEL_BASE_URL`), where every model is the gateway's, its key alone. Asked as
132
131
  * chooseModel is, faux or not, so a run on the faux model is handed what a run on its model would be. */
133
132
  export declare function modelKeys(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[]): string[];
134
- /** A run's thinking level: its `effort`, else its revision's `thinking`, else the host's `AGENT_THINKING`, else medium.
135
- * Never off. */
136
- export declare function thinkingOf(env: NodeJS.ProcessEnv, revision?: string): ModelThinkingLevel;
133
+ /** `value` as a thinking level (THINKING_LEVELS, exactly), else undefined: a revision's `thinking` or the host's
134
+ * `AGENT_THINKING` that names none is no level. A run's effort is its own, else these (runs-over-store.ts prepareLaunch). */
135
+ export declare function thinkingLevel(value: unknown): ThinkingLevel | undefined;
137
136
  /** The helpers a faux module's reply gets, so it needs no import of its own. */
138
137
  export type FauxHelpers = {
139
138
  /** Aborted when the turn is stopped: a slow reply resolves with `message("", { stopReason: "aborted" })`. */
package/dist/model.js CHANGED
@@ -25,8 +25,6 @@ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filte
25
25
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
26
26
  * request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
27
27
  export const FAUX_UPSTREAM_ENV = "AGENTRUN_SERVE_FAUX_UPSTREAM";
28
- /** A run's `effort`, passed to its child. */
29
- export const EFFORT_ENV = "AGENTRUN_SERVE_EFFORT";
30
28
  /** The model the server's keys give a run that names none (hostModel at the run's launch, from every key the server
31
29
  * holds), passed to its child as its effort is: behind a gateway the run holds the gateway's key alone, never the key
32
30
  * that names its default (runs.ts). A model id, never a secret, so its name has no secret's segment (pi-durable-disk's
@@ -277,11 +275,10 @@ export function modelKeys(env, ref, tiers = ["default"]) {
277
275
  const providers = named.flatMap((name) => (name && name.indexOf("/") > 0 ? [name.slice(0, name.indexOf("/"))] : []));
278
276
  return [...new Set(providers.flatMap((provider) => PROVIDER_KEYS[provider] ?? []))];
279
277
  }
280
- /** A run's thinking level: its `effort`, else its revision's `thinking`, else the host's `AGENT_THINKING`, else medium.
281
- * Never off. */
282
- export function thinkingOf(env, revision) {
283
- const level = [env[EFFORT_ENV], revision, env.AGENT_THINKING].find((name) => THINKING_LEVELS.includes(name));
284
- return (level ?? "medium");
278
+ /** `value` as a thinking level (THINKING_LEVELS, exactly), else undefined: a revision's `thinking` or the host's
279
+ * `AGENT_THINKING` that names none is no level. A run's effort is its own, else these (runs-over-store.ts prepareLaunch). */
280
+ export function thinkingLevel(value) {
281
+ return THINKING_LEVELS.includes(value) ? value : undefined;
285
282
  }
286
283
  /** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
287
284
  * default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
@@ -400,7 +397,8 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
400
397
  /** The price of each gateway model of `byTier` (its tiers' models, `namedBy` the provider a ref named), in USD per million
401
398
  * input, output, cache-read and cache-write tokens: a tier's own price (`AGENT_MODEL_FAST_PRICE`,
402
399
  * `AGENT_MODEL_STRONG_PRICE`) goes with its model, else the default's (`AGENT_MODEL_PRICE`); a model two tiers share
403
- * takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), a $0 entry included. An id with no price
400
+ * takes the default's. With none set, pi-ai's catalog prices it (catalogPrice), from a metered entry alone: a $0 one (a
401
+ * plan's, a free tier's) never prices it (#2339). An id with no price
404
402
  * is absent: its answers carry no total (unpricedApi) and a harness books it unknown (adapters.ts priceOf), so the run's
405
403
  * cost reads unknown, never $0, and a cap refuses it (blockersOf refuses a capped run on it before it starts). */
406
404
  async function gatewayPrices(env, byTier, namedBy) {
@@ -596,29 +594,47 @@ export function catalogPrice(catalog, id, named) {
596
594
  * gpt-5.4-mini; pair by pair, so llama-3-1-8b is llama-3.1-8b), and each digit-dot-digit as a dash (claude-haiku-4.5,
597
595
  * claude-haiku-4-5). Not `id` itself. */
598
596
  const flippedForms = (id) => [...new Set([id.replace(/(\d)-(\d)/g, "$1.$2"), id.replace(/(\d)\.(\d)/g, "$1-$2")])].filter((form) => form !== id);
599
- /** `id`'s price in `catalog` (listedPrice): its own entries when the catalog lists it; else those of its flipped forms
600
- * (flippedForms), only when every entry they hold has one price. A flip that finds different prices, across providers
601
- * or across the two flips, leaves the model unpriced: the cap refuses it rather than keep a price picked by luck. */
597
+ /** `id`'s price in `catalog` (listedPrice): its own entries' metered price when the catalog lists one; else its flipped
598
+ * forms' (flippedForms), only when every metered entry they hold has one price; else the metered price a gateway lists
599
+ * under a vendor's id for it (`<vendor>/<id>`, the named vendor's first: pi-ai lists the bare id of some models only
600
+ * under subscription plans, at $0, and the gateways that meter them under the vendor's). A flip that finds different
601
+ * prices leaves the model unpriced, and so does an id with no metered entry anywhere (#2339: a plan's $0 never prices a
602
+ * metered model): the cap refuses it rather than keep a price picked by luck or a $0 nobody bills. */
602
603
  function catalogEntries(catalog, id, named) {
603
604
  const own = catalog.get(id);
604
- if (own)
605
- return listedPrice(own, named);
606
- const flipped = flippedForms(id).flatMap((form) => catalog.get(form) ?? []);
607
- if (!flipped.length)
608
- return undefined;
609
- const one = JSON.stringify(flipped[0].cost);
610
- return flipped.every((entry) => JSON.stringify(entry.cost) === one) ? flipped[0].cost : undefined;
605
+ const listed = own ? listedPrice(own, named) : undefined;
606
+ if (listed)
607
+ return listed;
608
+ const flipped = flippedForms(id).flatMap((form) => (catalog.get(form) ?? []).filter(({ cost }) => cost.input + cost.output > 0));
609
+ if (flipped.length) {
610
+ const one = JSON.stringify(flipped[0].cost);
611
+ return flipped.every((entry) => JSON.stringify(entry.cost) === one) ? flipped[0].cost : undefined;
612
+ }
613
+ return vendorPrice(catalog, id, named);
611
614
  }
612
- /** A gateway model's catalog price: the paid entry of the provider its ref names, when the catalog lists one. Else, as
613
- * the gateway does not say whose model answers (a named provider is a hint), the highest any provider lists, so the
614
- * estimate and a cap on it err high: one entry's whole price, the one with the most input plus output (the first of
615
- * equals), so a $0 entry never wins over a paid one, a named provider's included. An id the catalog lists at $0 is a
616
- * known $0; one it does not list has no price (undefined). */
615
+ /** The metered price gateways list for `id` under a vendor's id (`<vendor>/<id>`, or a flipped form of it): the named
616
+ * vendor's id when the catalog has one, else every vendor's; the highest paid entry, so an estimate errs high. */
617
+ function vendorPrice(catalog, id, named) {
618
+ const forms = new Set([id, ...flippedForms(id)]);
619
+ const keyed = (key) => {
620
+ const slash = key.indexOf("/");
621
+ return slash > 0 && forms.has(key.slice(slash + 1)) ? key.slice(0, slash) : undefined;
622
+ };
623
+ const vendors = [...catalog.keys()].filter((key) => keyed(key) !== undefined);
624
+ const chosen = named !== undefined && vendors.some((key) => keyed(key) === named) ? vendors.filter((key) => keyed(key) === named) : vendors;
625
+ return listedPrice(chosen.flatMap((key) => catalog.get(key) ?? []), undefined);
626
+ }
627
+ /** A gateway model's catalog price from `entries`: the metered (paid) entry of the provider its ref names, when the
628
+ * catalog lists one. Else, as the gateway does not say whose model answers (a named provider is a hint), the highest
629
+ * paid entry any provider lists, so the estimate and a cap on it err high: one entry's whole price, the one with the
630
+ * most input plus output (the first of equals). A $0 entry (a plan's, a free tier's) never prices it: with no paid
631
+ * entry the price is unknown (undefined), never $0. */
617
632
  function listedPrice(entries, named) {
618
- if (!entries.length)
633
+ const paid = entries.filter(({ cost }) => cost.input + cost.output > 0);
634
+ if (!paid.length)
619
635
  return undefined;
620
- const own = named === undefined ? undefined : entries.find((entry) => entry.provider === named);
621
- if (own && own.cost.input + own.cost.output > 0)
636
+ const own = named === undefined ? undefined : paid.find((entry) => entry.provider === named);
637
+ if (own)
622
638
  return own.cost;
623
- return entries.reduce((top, { cost }) => (cost.input + cost.output > top.input + top.output ? cost : top), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
639
+ return paid.reduce((top, entry) => (entry.cost.input + entry.cost.output > top.cost.input + top.cost.output ? entry : top)).cost;
624
640
  }
package/dist/monid.d.ts CHANGED
@@ -69,8 +69,6 @@ export declare const MONID_RUN_ALLOWANCE_USD = 1;
69
69
  * and the run's cost unknown, never $0. pi binds it (monidTool); another harness runs it as a host tool
70
70
  * (host-tools.ts), whose `api` commits to the run's store as pi's does. */
71
71
  export declare function monidRegistration(kind: Kind, env: NodeJS.ProcessEnv, work: () => Workspace): ToolRegistration;
72
- /** The three, as another harness's host tools. */
73
- export declare const monidTools: (env: NodeJS.ProcessEnv, work: () => Workspace) => ToolRegistration[];
74
72
  /** The table's entry for `monid.<kind>`: it needs MONID_API_KEY, and no workflow node names it yet. */
75
73
  export declare const monidTool: (kind: Kind) => ToolEntry;
76
74
  export {};
package/dist/monid.js CHANGED
@@ -17,11 +17,11 @@
17
17
  import { randomUUID } from "node:crypto";
18
18
  import { localWorkspace, workspaceErrorWords } from "./workspace/index.js";
19
19
  import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
20
- import { registerLabel, TOOL_COST } from "@parcha/pi-durable-agent/timeline";
20
+ import { registerLabel, TOOL_COST } from "./timeline/index.js";
21
21
  import { paidCall } from "./cap.js";
22
22
  import { wireName } from "./catalog.js";
23
23
  import { fauxFetch } from "./decisions.js";
24
- import { holdRefusal, paidLedger, paidStep, settleOnRoot, writeHold } from "./paid-calls.js";
24
+ import { holdRefusal, paidLedger, paidStep, writeHold } from "./paid-calls.js";
25
25
  import { forModel } from "./result.js";
26
26
  import { isObject } from "./validate.js";
27
27
  export const MONID_KEY_ENV = "MONID_API_KEY";
@@ -246,9 +246,8 @@ export function monidRegistration(kind, env, work) {
246
246
  // Settled at what it charged: $0 only when monid charged nothing, null (unknown) when it may have and did not say.
247
247
  // Paid for, it answers even when this cannot be written, never a failure the model would retry.
248
248
  const usd = chargeOf(answer);
249
- // Written to the run's root when it is set (paid-calls.ts settleIn): a stopped turn's call can no longer commit.
250
249
  const settle = { ...label, usd: usd === undefined ? 0 : usd };
251
- await (settleOnRoot(TOOL_COST, settle) ?? record(api, TOOL_COST, settle, context)).catch(() => undefined);
250
+ await record(api, TOOL_COST, settle, context).catch(() => undefined);
252
251
  return answer;
253
252
  };
254
253
  // On the runner's one ledger (paid-calls.ts Ledger.paid): held there at the same figure and settled at the same charge
@@ -273,8 +272,6 @@ export function monidRegistration(kind, env, work) {
273
272
  },
274
273
  });
275
274
  }
276
- /** The three, as another harness's host tools. */
277
- export const monidTools = (env, work) => KINDS.map((kind) => monidRegistration(kind, env, work));
278
275
  /** The table's entry for `monid.<kind>`: it needs MONID_API_KEY, and no workflow node names it yet. */
279
276
  export const monidTool = (kind) => ({
280
277
  summary: SPECS[kind].summary,
package/dist/openapi.d.ts CHANGED
@@ -4,8 +4,15 @@ import "./computers.js";
4
4
  type Json = Record<string, unknown>;
5
5
  /** Why each capability this server turns off answers 501, by the route's capability. */
6
6
  export declare const UNSUPPORTED: Readonly<Record<string, string>>;
7
+ /** The contract's operations this server does not serve, and never will as they are: a home's packed export and import
8
+ * (its files are read and written one by one, under /agents/{id}/home/files) and a run's kill (stop and cancel end a
9
+ * run). They are left out of the served document, so no client is generated for them, and their paths answer 404.
10
+ * Capabilities say each is off (home.export, home.import, runs.kill). */
11
+ export declare const NOT_SERVED: readonly string[];
7
12
  /** The RUN_FIELDS every run's view and summary hold (runs.ts): required, beside the contract's. */
8
13
  export declare const RUN_FIELDS_SENT: string[];
14
+ /** The capabilities every answer carries beside the contract's required ones (server.ts capabilitiesWith). */
15
+ export declare const CAPABILITIES_SENT: string[];
9
16
  /** The field every saved sign-in is sent with beside the contract's, required: `secret`, its one secret's metadata
10
17
  * (secrets/1, sign-ins-secrets.ts). */
11
18
  export declare const SIGN_IN_FIELDS_SENT: string[];
@@ -13,7 +20,7 @@ export declare const SIGN_IN_FIELDS_SENT: string[];
13
20
  * instructions, and the server mints or keeps version, skills and tools when a write leaves them out. */
14
21
  export declare const DEFINITION_INPUT_OPTIONAL: string[];
15
22
  /** Definition's own: only instructions ever misses from an answer (a workflow revision keeps none); version, skills
16
- * and tools are always sent (agents.ts definitionOf), so they stay required there. */
23
+ * and tools are always sent (agents-store.ts definitionOf), so they stay required there. */
17
24
  export declare const DEFINITION_OPTIONAL: string[];
18
25
  /** The document: the contract, its operations this server turns off marked with why (`capabilityOf` gives an
19
26
  * operation's capability here, by its operationId), and this server's own routes added and marked. */