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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/CHANGELOG.md +455 -0
  2. package/README.md +376 -125
  3. package/dist/adapters.d.ts +4 -1
  4. package/dist/adapters.js +4 -2
  5. package/dist/agent-rows.d.ts +0 -2
  6. package/dist/agents-store.d.ts +5 -5
  7. package/dist/agents-store.js +14 -14
  8. package/dist/bash-read-only.js +2 -1
  9. package/dist/cap-short.d.ts +12 -0
  10. package/dist/cap-short.js +60 -0
  11. package/dist/cap.d.ts +3 -10
  12. package/dist/cap.js +2 -5
  13. package/dist/catalog.d.ts +0 -5
  14. package/dist/catalog.js +1 -5
  15. package/dist/chatgpt-plan.d.ts +163 -0
  16. package/dist/chatgpt-plan.js +549 -0
  17. package/dist/cli.js +26 -6
  18. package/dist/composio-preset.d.ts +8 -0
  19. package/dist/composio-preset.js +8 -7
  20. package/dist/composio-triggers.d.ts +113 -0
  21. package/dist/composio-triggers.js +411 -0
  22. package/dist/computer-calls.js +2 -2
  23. package/dist/computer-commands.d.ts +2 -0
  24. package/dist/computer-commands.js +7 -3
  25. package/dist/computer-live.d.ts +7 -2
  26. package/dist/computer-live.js +9 -5
  27. package/dist/computer-routes.d.ts +2 -2
  28. package/dist/computer-routes.js +2 -2
  29. package/dist/computer-setting.d.ts +3 -3
  30. package/dist/computer-setting.js +5 -5
  31. package/dist/computer-view.d.ts +15 -0
  32. package/dist/computer-view.js +16 -2
  33. package/dist/computer-viewer.js +14 -1
  34. package/dist/computers.d.ts +5 -2
  35. package/dist/computers.js +9 -5
  36. package/dist/console/assets/index-B8Zn1Iqn.css +1 -0
  37. package/dist/console/assets/index-Jbxjcmdp.js +705 -0
  38. package/dist/console/index.html +2 -2
  39. package/dist/console-links.js +3 -3
  40. package/dist/decision-cap.d.ts +2 -5
  41. package/dist/decision-cap.js +3 -6
  42. package/dist/decision-rows.js +11 -11
  43. package/dist/email/account.d.ts +83 -0
  44. package/dist/email/account.js +159 -0
  45. package/dist/email/answer.d.ts +15 -0
  46. package/dist/email/answer.js +217 -0
  47. package/dist/email/email-faux.d.ts +95 -0
  48. package/dist/email/email-faux.js +849 -0
  49. package/dist/email/labels.d.ts +1 -0
  50. package/dist/email/labels.js +84 -0
  51. package/dist/email/mail.d.ts +186 -0
  52. package/dist/email/mail.js +373 -0
  53. package/dist/email/names.d.ts +50 -0
  54. package/dist/email/names.js +74 -0
  55. package/dist/email/routes.d.ts +10 -0
  56. package/dist/email/routes.js +50 -0
  57. package/dist/email/tools.d.ts +27 -0
  58. package/dist/email/tools.js +562 -0
  59. package/dist/environment.d.ts +17 -2
  60. package/dist/environment.js +36 -8
  61. package/dist/errors.d.ts +6 -0
  62. package/dist/errors.js +12 -0
  63. package/dist/eval-mailbox.d.ts +103 -0
  64. package/dist/eval-mailbox.js +236 -0
  65. package/dist/graph-view.d.ts +9 -2
  66. package/dist/graph-view.js +6 -2
  67. package/dist/harness-install.d.ts +28 -2
  68. package/dist/harness-install.js +147 -59
  69. package/dist/harness-opencode/adapter.js +2 -26
  70. package/dist/harness-opencode/facts.js +5 -2
  71. package/dist/harness-opencode/host/policy.d.ts +2 -0
  72. package/dist/harness-opencode/host/policy.js +10 -5
  73. package/dist/harness-opencode/index.d.ts +1 -1
  74. package/dist/harness-opencode/index.js +1 -1
  75. package/dist/harness-opencode/versions.d.ts +6 -0
  76. package/dist/harness-opencode/versions.js +6 -0
  77. package/dist/harness-table.js +8 -5
  78. package/dist/harness.d.ts +12 -0
  79. package/dist/harness.js +15 -3
  80. package/dist/hosted-search.d.ts +3 -1
  81. package/dist/hosted-search.js +51 -11
  82. package/dist/import-sources.d.ts +1 -1
  83. package/dist/import-sources.js +3 -3
  84. package/dist/import.d.ts +21 -0
  85. package/dist/import.js +186 -1
  86. package/dist/key-check.d.ts +0 -2
  87. package/dist/key-check.js +3 -4
  88. package/dist/key-refusal.d.ts +8 -2
  89. package/dist/key-refusal.js +16 -13
  90. package/dist/learn/check.d.ts +18 -3
  91. package/dist/learn/check.js +328 -3
  92. package/dist/learn/compile.d.ts +12 -4
  93. package/dist/learn/compile.js +57 -20
  94. package/dist/learn/grade.d.ts +4 -0
  95. package/dist/learn/grade.js +4 -1
  96. package/dist/learn/promote.d.ts +130 -64
  97. package/dist/learn/promote.js +113 -202
  98. package/dist/learn/refit.d.ts +21 -12
  99. package/dist/learn/refit.js +51 -23
  100. package/dist/learn/replay-calls.js +1 -1
  101. package/dist/learn/skills.d.ts +2 -7
  102. package/dist/learn/skills.js +28 -14
  103. package/dist/learned-nodes.d.ts +15 -7
  104. package/dist/learned-nodes.js +29 -5
  105. package/dist/learned-workflow.d.ts +41 -31
  106. package/dist/learned-workflow.js +122 -63
  107. package/dist/learning-batch.js +3 -3
  108. package/dist/learning-cost.d.ts +35 -8
  109. package/dist/learning-cost.js +27 -9
  110. package/dist/learning-routes.d.ts +2 -4
  111. package/dist/learning-routes.js +20 -3
  112. package/dist/learning-words.d.ts +1 -1
  113. package/dist/learning-words.js +4 -1
  114. package/dist/learning.d.ts +5 -5
  115. package/dist/link-check.d.ts +27 -0
  116. package/dist/link-check.js +164 -0
  117. package/dist/local-models.d.ts +39 -2
  118. package/dist/local-models.js +49 -5
  119. package/dist/mcp-pin-first.js +6 -0
  120. package/dist/mcp-secret-writes.js +3 -0
  121. package/dist/mcp-servers-store.d.ts +25 -16
  122. package/dist/mcp-servers-store.js +23 -3
  123. package/dist/model-form.d.ts +11 -0
  124. package/dist/model-form.js +17 -1
  125. package/dist/model.d.ts +26 -6
  126. package/dist/model.js +126 -18
  127. package/dist/monid.d.ts +26 -31
  128. package/dist/monid.js +84 -79
  129. package/dist/native/binding.d.ts +13 -0
  130. package/dist/native/binding.js +57 -0
  131. package/dist/native/cli.d.ts +2 -0
  132. package/dist/native/cli.js +48 -0
  133. package/dist/native/connection.d.ts +8 -0
  134. package/dist/native/connection.js +94 -0
  135. package/dist/native/context.d.ts +6 -0
  136. package/dist/native/context.js +22 -0
  137. package/dist/native/discovery.d.ts +27 -0
  138. package/dist/native/discovery.js +404 -0
  139. package/dist/native/environment.d.ts +4 -0
  140. package/dist/native/environment.js +18 -0
  141. package/dist/native/history.d.ts +20 -0
  142. package/dist/native/history.js +147 -0
  143. package/dist/native/instructions.d.ts +21 -0
  144. package/dist/native/instructions.js +173 -0
  145. package/dist/native/remote-worker-bridge.d.ts +3 -0
  146. package/dist/native/remote-worker-bridge.js +278 -0
  147. package/dist/native/remote.d.ts +187 -0
  148. package/dist/native/remote.js +492 -0
  149. package/dist/native/runtime.d.ts +17 -0
  150. package/dist/native/runtime.js +316 -0
  151. package/dist/native/runtimes.d.ts +66 -0
  152. package/dist/native/runtimes.js +41 -0
  153. package/dist/native/schema.d.ts +46 -0
  154. package/dist/native/schema.js +41 -0
  155. package/dist/native/types.d.ts +87 -0
  156. package/dist/native/types.js +1 -0
  157. package/dist/observation/http.d.ts +4 -0
  158. package/dist/observation/http.js +140 -0
  159. package/dist/observation/observer.d.ts +301 -0
  160. package/dist/observation/observer.js +919 -0
  161. package/dist/observation/schema.d.ts +52 -0
  162. package/dist/observation/schema.js +154 -0
  163. package/dist/openapi.d.ts +2 -1
  164. package/dist/openapi.js +404 -93
  165. package/dist/paid-calls.d.ts +8 -3
  166. package/dist/paid-calls.js +6 -2
  167. package/dist/place-offers.d.ts +4 -8
  168. package/dist/place-offers.js +4 -9
  169. package/dist/port-models.d.ts +10 -2
  170. package/dist/port-models.js +6 -2
  171. package/dist/print.d.ts +4 -2
  172. package/dist/print.js +4 -3
  173. package/dist/propose.d.ts +1 -2
  174. package/dist/propose.js +10 -1
  175. package/dist/provider.d.ts +5 -1
  176. package/dist/provider.js +8 -0
  177. package/dist/push-handler.d.ts +3 -2
  178. package/dist/push-handler.js +20 -6
  179. package/dist/refusal-words.d.ts +14 -0
  180. package/dist/refusal-words.js +16 -2
  181. package/dist/run-launch.d.ts +12 -1
  182. package/dist/run-launch.js +13 -4
  183. package/dist/run-learning-served.d.ts +75 -2
  184. package/dist/run-manifest.d.ts +3 -0
  185. package/dist/run-manifest.js +13 -1
  186. package/dist/run-reads-over-store.d.ts +3 -3
  187. package/dist/run-reads-over-store.js +13 -10
  188. package/dist/run-timeline-served.d.ts +3 -2
  189. package/dist/run-timeline-served.js +8 -9
  190. package/dist/run-view.d.ts +44 -38
  191. package/dist/run-view.js +93 -56
  192. package/dist/runnable.d.ts +13 -5
  193. package/dist/runnable.js +69 -60
  194. package/dist/runner/adapter-loop.d.ts +48 -13
  195. package/dist/runner/adapter-loop.js +691 -254
  196. package/dist/runner/adapter-run-spec.d.ts +38 -12
  197. package/dist/runner/adapter-run-spec.js +175 -106
  198. package/dist/runner/adapters/pi.d.ts +24 -0
  199. package/dist/runner/adapters/pi.js +59 -9
  200. package/dist/runner/beside.d.ts +3 -1
  201. package/dist/runner/beside.js +24 -8
  202. package/dist/runner/claim-secrets.d.ts +3 -1
  203. package/dist/runner/claim-secrets.js +28 -4
  204. package/dist/runner/cli-run-spec.d.ts +30 -0
  205. package/dist/runner/cli-run-spec.js +95 -50
  206. package/dist/runner/computer-channel.d.ts +5 -2
  207. package/dist/runner/computer-channel.js +3 -2
  208. package/dist/runner/computer-journal.d.ts +6 -0
  209. package/dist/runner/computer-journal.js +8 -10
  210. package/dist/runner/conformance/harness.js +6 -3
  211. package/dist/runner/end-of-run.d.ts +2 -0
  212. package/dist/runner/end-of-run.js +3 -1
  213. package/dist/runner/feedback-round.d.ts +40 -13
  214. package/dist/runner/feedback-round.js +64 -16
  215. package/dist/runner/harness-loops.js +17 -0
  216. package/dist/runner/journal-kinds.d.ts +59 -13
  217. package/dist/runner/journal-kinds.js +48 -5
  218. package/dist/runner/learning-dispatch.d.ts +3 -2
  219. package/dist/runner/learning-dispatch.js +6 -6
  220. package/dist/runner/learning-end.d.ts +4 -0
  221. package/dist/runner/learning-end.js +64 -36
  222. package/dist/runner/learning-factory.d.ts +3 -0
  223. package/dist/runner/learning-factory.js +8 -2
  224. package/dist/runner/learning-loop.d.ts +2 -0
  225. package/dist/runner/learning-loop.js +19 -4
  226. package/dist/runner/loop.d.ts +18 -0
  227. package/dist/runner/loop.js +34 -0
  228. package/dist/runner/main.d.ts +6 -1
  229. package/dist/runner/main.js +26 -4
  230. package/dist/runner/mcp-run.d.ts +4 -1
  231. package/dist/runner/mcp-run.js +11 -5
  232. package/dist/runner/meta-tools.d.ts +10 -3
  233. package/dist/runner/meta-tools.js +112 -36
  234. package/dist/runner/metrics.d.ts +80 -21
  235. package/dist/runner/metrics.js +114 -39
  236. package/dist/runner/model-route.d.ts +14 -3
  237. package/dist/runner/model-route.js +155 -19
  238. package/dist/runner/monid-run.d.ts +8 -6
  239. package/dist/runner/monid-run.js +117 -43
  240. package/dist/runner/native-loop.d.ts +11 -0
  241. package/dist/runner/native-loop.js +438 -0
  242. package/dist/runner/promotion.d.ts +76 -10
  243. package/dist/runner/promotion.js +476 -154
  244. package/dist/runner/redact.js +3 -0
  245. package/dist/runner/reflect-hook.js +9 -0
  246. package/dist/runner/runner.d.ts +7 -1
  247. package/dist/runner/runner.js +8 -4
  248. package/dist/runner/sdk-loop.d.ts +7 -0
  249. package/dist/runner/sdk-loop.js +470 -0
  250. package/dist/runner/spec-holds.d.ts +16 -2
  251. package/dist/runner/spec-holds.js +42 -14
  252. package/dist/runner/store-secrets.js +17 -2
  253. package/dist/runner/workflow-first.d.ts +30 -20
  254. package/dist/runner/workflow-first.js +22 -32
  255. package/dist/runner/workflow-loop.d.ts +1 -1
  256. package/dist/runner/workflow-loop.js +18 -12
  257. package/dist/runner/workflow-spec.d.ts +4 -1
  258. package/dist/runner/workflow-spec.js +56 -45
  259. package/dist/runs-over-store.d.ts +30 -2
  260. package/dist/runs-over-store.js +46 -14
  261. package/dist/sdk/runs.d.ts +115 -0
  262. package/dist/sdk/runs.js +422 -0
  263. package/dist/sdk/schema.d.ts +175 -0
  264. package/dist/sdk/schema.js +138 -0
  265. package/dist/sdk/workflows.d.ts +22 -0
  266. package/dist/sdk/workflows.js +39 -0
  267. package/dist/secrets.d.ts +2 -0
  268. package/dist/secrets.js +19 -1
  269. package/dist/server.d.ts +48 -32
  270. package/dist/server.js +568 -137
  271. package/dist/skill-route.d.ts +3 -0
  272. package/dist/skill-route.js +16 -0
  273. package/dist/skills/agentrun-serve/SKILL.md +368 -0
  274. package/dist/stats.d.ts +10 -10
  275. package/dist/store/agent-body.d.ts +12 -8
  276. package/dist/store/agent-body.js +9 -4
  277. package/dist/store/dialect.d.ts +3 -0
  278. package/dist/store/dialect.js +1 -0
  279. package/dist/store/index.d.ts +1 -1
  280. package/dist/store/native-command-owner.d.ts +10 -0
  281. package/dist/store/native-command-owner.js +47 -0
  282. package/dist/store/postgres/connection.d.ts +11 -5
  283. package/dist/store/postgres/connection.js +44 -17
  284. package/dist/store/postgres/dialect.js +5 -0
  285. package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
  286. package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
  287. package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
  288. package/dist/store/postgres/store.d.ts +7 -3
  289. package/dist/store/postgres/store.js +4 -0
  290. package/dist/store/schema.d.ts +7 -0
  291. package/dist/store/schema.js +20 -1
  292. package/dist/store/sqlite/connection.js +72 -8
  293. package/dist/store/sqlite/run-launch.d.ts +11 -0
  294. package/dist/store/sqlite/run-launch.js +8 -0
  295. package/dist/store/sqlite/run-patch.d.ts +8 -1
  296. package/dist/store/sqlite/run-patch.js +14 -3
  297. package/dist/store/sqlite/store.js +170 -34
  298. package/dist/store/sqlite/worker.d.ts +2 -0
  299. package/dist/store/sqlite/worker.js +13 -10
  300. package/dist/store/store.d.ts +67 -7
  301. package/dist/store-reads/analytics.d.ts +7 -7
  302. package/dist/store-reads/analytics.js +23 -5
  303. package/dist/store-reads/cap.js +8 -6
  304. package/dist/store-reads/journal.d.ts +5 -0
  305. package/dist/store-reads/journal.js +85 -41
  306. package/dist/store-reads/learning.d.ts +115 -18
  307. package/dist/store-reads/learning.js +170 -68
  308. package/dist/store-reads/runs.d.ts +5 -0
  309. package/dist/store-reads/runs.js +3 -2
  310. package/dist/store-view.js +75 -21
  311. package/dist/template-eval.d.ts +73 -11
  312. package/dist/template-eval.js +535 -75
  313. package/dist/templates.d.ts +84 -21
  314. package/dist/templates.js +254 -47
  315. package/dist/text-urls.d.ts +38 -0
  316. package/dist/text-urls.js +170 -0
  317. package/dist/timeline/index.d.ts +3 -2
  318. package/dist/timeline/index.js +3 -2
  319. package/dist/timeline/labels.d.ts +5 -2
  320. package/dist/timeline/labels.js +29 -6
  321. package/dist/timeline/origin.d.ts +1 -1
  322. package/dist/timeline/origin.js +2 -2
  323. package/dist/timeline/render-text.js +1 -1
  324. package/dist/timeline/timeline.d.ts +66 -4
  325. package/dist/timeline/timeline.js +160 -30
  326. package/dist/timeline/util.d.ts +5 -0
  327. package/dist/timeline/util.js +44 -8
  328. package/dist/timeline/web-calls.d.ts +17 -0
  329. package/dist/timeline/web-calls.js +106 -0
  330. package/dist/tool-gate.d.ts +46 -44
  331. package/dist/tool-gate.js +101 -92
  332. package/dist/tool-list.d.ts +4 -1
  333. package/dist/tool-list.js +8 -1
  334. package/dist/tool-names.d.ts +18 -13
  335. package/dist/tool-names.js +19 -17
  336. package/dist/tool-plane.d.ts +17 -13
  337. package/dist/tool-plane.js +12 -5
  338. package/dist/tools.d.ts +57 -16
  339. package/dist/tools.js +33 -28
  340. package/dist/trigger-adapter.d.ts +56 -5
  341. package/dist/trigger-adapter.js +6 -0
  342. package/dist/trigger-adapters.js +3 -1
  343. package/dist/trigger-composio.d.ts +10 -0
  344. package/dist/trigger-composio.js +122 -0
  345. package/dist/trigger-email.d.ts +4 -0
  346. package/dist/trigger-email.js +181 -0
  347. package/dist/trigger-signatures.d.ts +6 -10
  348. package/dist/trigger-signatures.js +16 -16
  349. package/dist/trigger-targets.d.ts +1 -1
  350. package/dist/trigger-targets.js +4 -3
  351. package/dist/trigger-webhook.js +6 -4
  352. package/dist/triggers.d.ts +105 -8
  353. package/dist/triggers.js +286 -62
  354. package/dist/uploads.d.ts +9 -0
  355. package/dist/uploads.js +27 -0
  356. package/dist/validate.js +1 -7
  357. package/dist/web-fake.d.ts +56 -0
  358. package/dist/web-fake.js +102 -0
  359. package/dist/web-fetch-direct.d.ts +3 -0
  360. package/dist/web-fetch-direct.js +4 -1
  361. package/dist/web-fetch.d.ts +5 -1
  362. package/dist/web-fetch.js +8 -31
  363. package/dist/web-search.d.ts +51 -2
  364. package/dist/web-search.js +116 -18
  365. package/dist/webhooks.d.ts +2 -1
  366. package/dist/webhooks.js +5 -1
  367. package/dist/workflow/decision-recovery.js +5 -2
  368. package/dist/workflow/decisions.d.ts +7 -0
  369. package/dist/workflow/node-runner.js +10 -2
  370. package/dist/workspace/archil-claim.d.ts +3 -0
  371. package/dist/workspace/archil-claim.js +9 -2
  372. package/dist/workspace/computer-deps.d.ts +22 -9
  373. package/dist/workspace/computer-deps.js +78 -37
  374. package/dist/workspace/computer-for-claim.d.ts +54 -4
  375. package/dist/workspace/computer-for-claim.js +179 -39
  376. package/dist/workspace/computer-janitor.d.ts +10 -3
  377. package/dist/workspace/computer-janitor.js +96 -29
  378. package/dist/workspace/computer-kept.d.ts +82 -0
  379. package/dist/workspace/computer-kept.js +147 -0
  380. package/dist/workspace/computer-mcp.js +4 -3
  381. package/dist/workspace/computer-ports.d.ts +23 -3
  382. package/dist/workspace/computer-ports.js +115 -5
  383. package/dist/workspace/index.d.ts +1 -2
  384. package/dist/workspace/index.js +1 -2
  385. package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
  386. package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
  387. package/dist/workspace/resolve-computer.d.ts +15 -3
  388. package/dist/workspace/resolve-computer.js +10 -7
  389. package/dist/workspace/revision-skills.d.ts +6 -2
  390. package/dist/workspace/revision-skills.js +12 -5
  391. package/dist/workspace/run-end-computers.d.ts +30 -0
  392. package/dist/workspace/run-end-computers.js +137 -0
  393. package/dist/workspace/run-tools.d.ts +28 -29
  394. package/dist/workspace/run-tools.js +29 -30
  395. package/dist/wrap-up.d.ts +19 -5
  396. package/dist/wrap-up.js +31 -4
  397. package/package.json +13 -9
  398. package/skills/agentrun-serve/SKILL.md +248 -10
  399. package/templates/README.md +117 -23
  400. package/templates/TOOLS.md +168 -0
  401. package/templates/code-review/agent.md +18 -4
  402. package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
  403. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
  404. package/templates/code-review/evals/other-repo/case.yaml +1 -1
  405. package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
  406. package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
  407. package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
  408. package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
  409. package/templates/code-review/skills/review/DEEP.md +2 -2
  410. package/templates/code-review/skills/review/REVIEWER.md +2 -2
  411. package/templates/code-review/skills/review/SKILL.md +7 -3
  412. package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
  413. package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
  414. package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
  415. package/templates/release-notes/evals/other-repo/case.yaml +1 -1
  416. package/dist/console/assets/index-CjqQirbo.css +0 -1
  417. package/dist/console/assets/index-b6-XY5A9.js +0 -576
  418. package/dist/host-calls.d.ts +0 -20
  419. package/dist/host-calls.js +0 -12
  420. package/dist/runner/adapters/pi-computer.d.ts +0 -9
  421. package/dist/runner/adapters/pi-computer.js +0 -51
  422. package/dist/workspace/computer-script.d.ts +0 -53
  423. package/dist/workspace/computer-script.js +0 -172
@@ -0,0 +1,164 @@
1
+ // A template eval's link check (template-eval.ts graderInput): each http(s) link a run's answer cites, matched in code
2
+ // against every url its calls answered (its web calls', and the URLs any other call's result holds whole), so "every link
3
+ // the answer cites appears in the run's calls" is read from one block, never judged as URL equality from a rubric's prose. A link matches a url when their canonical forms do
4
+ // (canonicalUrl): no fragment, no trailing slash on the path, scheme and host lower-cased, no leading "www." on the host,
5
+ // query keys sorted; the two key
6
+ // sets equal, and each value equal, except that a call's value read as "…" (a timeline read elides query values,
7
+ // scrubUrls) matches any value for its key. Structural only: whether a cited item is in scope stays the rubric's call.
8
+ import { lastJsonBlock } from "./answer-json.js";
9
+ import { linksOf, linksWritten, TRAILING, trimmed, wholeUrl } from "./text-urls.js";
10
+ import { scrubUrl } from "./timeline/index.js";
11
+ import { WEB_FETCH_TOOL } from "./web-fetch.js";
12
+ import { WEB_SEARCH_TOOL } from "./web-search.js";
13
+ const ELIDED = "…";
14
+ const isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15
+ const strings = (value) => (Array.isArray(value) ? value.filter((item) => typeof item === "string") : []);
16
+ /** `url` canonical (see the head of this file), or undefined for one that is not an http(s) URL. */
17
+ export function canonicalUrl(url) {
18
+ let parsed;
19
+ try {
20
+ parsed = new URL(url.trim());
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
26
+ return undefined;
27
+ const query = new Map();
28
+ for (const [key, value] of parsed.searchParams)
29
+ query.set(key, [...(query.get(key) ?? []), value]);
30
+ for (const values of query.values())
31
+ values.sort();
32
+ // A host and the same host with "www." in front are one site (cpsc.gov, www.cpsc.gov); "www." is dropped only where a
33
+ // domain is left after it (never www.com's), and no other subdomain is (m., amp.).
34
+ const host = parsed.host.replace(/^www\.(?=[^.]+\.)/, "");
35
+ return { base: `${parsed.protocol}//${host}${parsed.pathname.replace(/\/+$/, "")}`, query };
36
+ }
37
+ /** Whether a cited link matches a url a call answered: the same base and key set, each value equal unless the call's
38
+ * values are all "…". */
39
+ export function urlMatches(cited, called) {
40
+ if (cited.base !== called.base || cited.query.size !== called.query.size)
41
+ return false;
42
+ for (const [key, values] of called.query) {
43
+ const mine = cited.query.get(key);
44
+ if (!mine)
45
+ return false;
46
+ if (values.every((value) => value === ELIDED))
47
+ continue;
48
+ if (mine.length !== values.length || mine.some((value, i) => value !== values[i]))
49
+ return false;
50
+ }
51
+ return true;
52
+ }
53
+ /** The forms a URL found in plain text may end at, longest first: as found, then less one trailing punctuation mark at a
54
+ * time. A URL can end in one (`/wiki/Yahoo!`), so which is the link is read from what matches, never guessed. */
55
+ function formsOf(raw) {
56
+ const forms = [raw];
57
+ for (let url = raw; url && TRAILING.includes(url.at(-1));)
58
+ forms.push((url = url.slice(0, -1)));
59
+ return forms;
60
+ }
61
+ /** Every http(s) URL in `text`, in order, read as a page's links are (linksWritten, text-urls.ts), each as the forms it may
62
+ * end at: a markdown link's target that its ")" closed as that one form; any other as formsOf gives it. A link's text
63
+ * and target read as two. */
64
+ function linksIn(text) {
65
+ return [...linksWritten(text)].flatMap(({ raw, exact }) => (/^https?:\/\//i.test(raw) ? [exact ? [raw] : formsOf(raw)] : []));
66
+ }
67
+ /** A JSON string's links: the string itself when it is one URL whole (wholeUrl: a field holding a link means all of it),
68
+ * else those in its text. */
69
+ const jsonLinks = (text) => {
70
+ const whole = wholeUrl(text);
71
+ return whole === undefined ? linksIn(text) : [[whole]];
72
+ };
73
+ /** Every string in `value`, property names aside. */
74
+ function stringsIn(value) {
75
+ if (typeof value === "string")
76
+ return [value];
77
+ if (Array.isArray(value))
78
+ return value.flatMap(stringsIn);
79
+ return isObj(value) ? Object.values(value).flatMap(stringsIn) : [];
80
+ }
81
+ /** Every http(s) URL an answer cites, in order, each once, as the forms it may end at (linksIn, jsonLinks): in its text,
82
+ * and in any string of its JSON (the whole answer, else its last json block), read from the parsed JSON so an escape in
83
+ * it never cuts a URL short. */
84
+ export function citedLinks(answer) {
85
+ let found;
86
+ try {
87
+ found = stringsIn(JSON.parse(answer)).flatMap(jsonLinks);
88
+ }
89
+ catch {
90
+ const block = lastJsonBlock(answer);
91
+ let parsed;
92
+ try {
93
+ parsed = block === undefined ? undefined : JSON.parse(block);
94
+ }
95
+ catch {
96
+ parsed = undefined;
97
+ }
98
+ found = parsed === undefined ? linksIn(answer) : [...linksIn(answer.replace(block, "")), ...stringsIn(parsed).flatMap(jsonLinks)];
99
+ }
100
+ return [...new Map(found.map((forms) => [forms.join("\n"), forms])).values()];
101
+ }
102
+ /** A call's urls for the check, and whether it is a web call: a web_search's results', a web_fetch's asked url, final url
103
+ * and page links, with how many of that page's links its output lost to a cut (`links_cut`). Any other call's are the
104
+ * URLs its result holds as it returned them (linksOf: a JSON string that is a URL whole counts whole). A grader reads
105
+ * only such a result's head (CALL_RESULT_CHARS, cut with "..." as timeline/util.ts cut ends it), so one ending in "..."
106
+ * may have held more past it: a cut of unknown count (1), named on a link that matches nothing, never a verdict. */
107
+ function sourceOf(call) {
108
+ const tool = call.name ?? call.tool;
109
+ const text = call.result ?? "";
110
+ if (tool !== WEB_SEARCH_TOOL && tool !== WEB_FETCH_TOOL)
111
+ return { urls: [...linksOf(text)], cut: text.endsWith("...") ? 1 : 0, web: false };
112
+ const end = text.indexOf("\n");
113
+ let read;
114
+ try {
115
+ read = JSON.parse(end < 0 ? text : text.slice(0, end));
116
+ }
117
+ catch {
118
+ read = undefined;
119
+ }
120
+ const out = isObj(read) ? read : {};
121
+ if (tool === WEB_SEARCH_TOOL)
122
+ return { urls: Array.isArray(out.results) ? out.results.flatMap((hit) => (isObj(hit) && typeof hit.url === "string" ? [hit.url] : [])) : [], cut: 0, web: true };
123
+ const asked = isObj(call.arguments) && typeof call.arguments.url === "string" ? [call.arguments.url] : [];
124
+ return { urls: [...asked, ...(typeof out.url === "string" ? [out.url] : []), ...strings(out.links)], cut: typeof out.links_cut === "number" ? out.links_cut : 0, web: true };
125
+ }
126
+ const callsWord = (calls) => (calls.length === 1 ? `call ${calls[0]}` : `calls ${calls.slice(0, -1).join(", ")} and ${calls.at(-1)}`);
127
+ /** The link check's lines for a grader, or undefined when there is nothing to check: the run made no web_search or
128
+ * web_fetch call, and either the answer cites no link or no call returned a URL. One line per distinct link the answer
129
+ * cites, shown as a call's url is (scrubUrl: no query values, fragment or userinfo), saying the first call (numbered as
130
+ * the grader's list numbers them) one of whose urls it matches, or that none does, naming any fetched page whose links
131
+ * were cut, as that page could have held it. */
132
+ export function linkCheck(answer, calls) {
133
+ const sources = calls.map(sourceOf);
134
+ const citations = citedLinks(answer);
135
+ if (!sources.some((source) => source.web) && !(citations.length && sources.some((source) => source.urls.length)))
136
+ return undefined;
137
+ const called = sources.map((source) => source.urls.flatMap((url) => canonicalUrl(url) ?? []));
138
+ const cut = sources.flatMap((source, i) => (source.cut ? [i + 1] : []));
139
+ const seen = new Set();
140
+ const lines = [];
141
+ const matchOf = (cited) => called.findIndex((urls) => urls.some((url) => urlMatches(cited, url)));
142
+ for (const forms of citations) {
143
+ // The longest form that matches a call is the link; with none, a plain-text one less the punctuation around it.
144
+ let [link, at] = [forms.length > 1 ? trimmed(forms[0]) : forms[0], -1];
145
+ for (const form of forms) {
146
+ const canonical = canonicalUrl(form);
147
+ const i = canonical ? matchOf(canonical) : -1;
148
+ if (i < 0)
149
+ continue;
150
+ [link, at] = [form, i];
151
+ break;
152
+ }
153
+ const cited = canonicalUrl(link);
154
+ if (!cited)
155
+ continue;
156
+ const key = JSON.stringify([cited.base, [...cited.query].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))]);
157
+ if (seen.has(key))
158
+ continue;
159
+ seen.add(key);
160
+ lines.push(`${scrubUrl(link)} — ${at >= 0 ? `matches call ${at + 1}` : `no matching call${cut.length ? ` (${callsWord(cut)}'s links were cut)` : ""}`}`);
161
+ }
162
+ const intro = "Each distinct http(s) link the answer cites, checked in code against every url its calls answered (a web_search's results; a web_fetch's url, its final url and its page's links; any other call's URLs as its result holds them): a fragment, a trailing slash, a leading www. on the host and the order of the query are ignored, the query's keys must be the same, and a query value shown as … matches any value for its key. Links are shown with their query values elided.";
163
+ return [intro, ...(lines.length ? lines : ["(the answer cites no http(s) link)"])].join("\n");
164
+ }
@@ -1,4 +1,5 @@
1
1
  import type { Api, Model, MutableModels } from "@earendil-works/pi-ai";
2
+ import { type ModelPrice } from "@parcha/agentrun-kernel/kernel/cap";
2
3
  /** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
3
4
  * 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
4
5
  export declare const PARTICLE_1_PRICE: {
@@ -24,6 +25,42 @@ export declare const PRICE_OVERRIDES: readonly {
24
25
  readonly cost: Model<Api>["cost"];
25
26
  readonly toolsAs?: ToolsAs;
26
27
  }[];
27
- /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
28
- * place: a request, a price and a capability read find the catalog's entry at the overridden price, with its toolsAs. */
28
+ /** Models serve lists that pi-ai's catalog does not: OpenRouter's free variants of models that take tools, each a copy of
29
+ * `like` (a catalog entry on the same provider and wire: its api, base URL, compat and reasoning settings) under its own
30
+ * id, name, input, context window and output ceiling, at $0, taking its tools natively (the `like` entry's `toolsAs` is
31
+ * not copied). Context and output ceiling are OpenRouter's (GET https://openrouter.ai/api/v1/models, read 2026-11-15:
32
+ * context_length and top_provider.max_completion_tokens; pricing "0" prompt and completion). Each one answered a request
33
+ * that defined a tool with a call to that tool, through OpenRouter, on 2026-11-15, billed $0. `mustReason` is that list's
34
+ * `reasoning.mandatory` (read 2026-11-16): a model that must reason has thinking off mapped to no effort (thinkingLevelMap
35
+ * `off: null`, as pi-ai's catalog maps Claude Sonnet 5.5's), so pi-ai never sends it `reasoning: {effort: "none"}`, which
36
+ * OpenRouter refuses with "Reasoning is mandatory for this endpoint and cannot be disabled", and the model reasons at
37
+ * its default. A model that lists `reasoning` among its supported parameters need not reason (Ling 3.2 Flash): only
38
+ * `mandatory` says so. */
39
+ export declare const ADDED_MODELS: readonly {
40
+ readonly provider: string;
41
+ readonly id: string;
42
+ readonly like: string;
43
+ readonly name: string;
44
+ readonly input: readonly ("text" | "image")[];
45
+ readonly contextWindow: number;
46
+ readonly maxTokens: number;
47
+ readonly mustReason: boolean;
48
+ }[];
49
+ /** Whether `provider`/`id` is one of OpenRouter's routers, each of which picks a model per request (the kernel cap's
50
+ * ROUTERS, the one list). OpenRouter lists the price of `auto`, `openrouter/auto*`, `openrouter/fusion`,
51
+ * `openrouter/pareto-code` and `typesafe/jev-router` as -1, the routed model's (read 2026-11-15), which pi-ai's catalog
52
+ * writes as 0; `openrouter/free` routes to a different free model per request. Their zeros say no model's price, so
53
+ * none of them is free: a model serve has no price for, which a cap cannot be kept on and which is never booked at its
54
+ * catalog's $0 (model.ts runModels' `unpriced`). */
55
+ export declare const isRouter: (provider: string, id: string) => boolean;
56
+ /** Whether a catalog entry runs at $0: the kernel's freeModel (kernel/cap/free.ts, the one rule, what a run on it books
57
+ * at $0) on the entry's price, its tiers included. An entry with no cost has no price, so is not free. */
58
+ export declare function isFree(model: {
59
+ id: string;
60
+ api?: string;
61
+ cost?: ModelPrice | null;
62
+ }): boolean;
63
+ /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries and
64
+ * ADDED_MODELS listed beside them, in place: a request, a price and a capability read find the catalog's entry at the
65
+ * overridden price, with its toolsAs, and an added model as if the catalog listed it. */
29
66
  export declare function withLocalModels<M extends MutableModels>(models: M): M;
@@ -1,3 +1,4 @@
1
+ import { freeModel, ROUTERS } from "@parcha/agentrun-kernel/kernel/cap";
1
2
  /** Particle-1's price, USD per million tokens: Particle's own list price, from https://docs.particle.ai/models (read
2
3
  * 2026-11-07: $0.25 input, $0.03 cached input, $1.00 output; no cache-write price, so $0). */
3
4
  export const PARTICLE_1_PRICE = { input: 0.25, output: 1, cacheRead: 0.03, cacheWrite: 0 };
@@ -22,17 +23,60 @@ const priced = (list, overrides) => list.map((model) => {
22
23
  const override = overrides.find((entry) => entry.id === model.id);
23
24
  return override ? { ...model, cost: { ...override.cost }, ...(override.toolsAs ? { toolsAs: override.toolsAs } : {}) } : model;
24
25
  });
25
- /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries, in
26
- * place: a request, a price and a capability read find the catalog's entry at the overridden price, with its toolsAs. */
26
+ const ZERO = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
27
+ /** Models serve lists that pi-ai's catalog does not: OpenRouter's free variants of models that take tools, each a copy of
28
+ * `like` (a catalog entry on the same provider and wire: its api, base URL, compat and reasoning settings) under its own
29
+ * id, name, input, context window and output ceiling, at $0, taking its tools natively (the `like` entry's `toolsAs` is
30
+ * not copied). Context and output ceiling are OpenRouter's (GET https://openrouter.ai/api/v1/models, read 2026-11-15:
31
+ * context_length and top_provider.max_completion_tokens; pricing "0" prompt and completion). Each one answered a request
32
+ * that defined a tool with a call to that tool, through OpenRouter, on 2026-11-15, billed $0. `mustReason` is that list's
33
+ * `reasoning.mandatory` (read 2026-11-16): a model that must reason has thinking off mapped to no effort (thinkingLevelMap
34
+ * `off: null`, as pi-ai's catalog maps Claude Sonnet 5.5's), so pi-ai never sends it `reasoning: {effort: "none"}`, which
35
+ * OpenRouter refuses with "Reasoning is mandatory for this endpoint and cannot be disabled", and the model reasons at
36
+ * its default. A model that lists `reasoning` among its supported parameters need not reason (Ling 3.2 Flash): only
37
+ * `mandatory` says so. */
38
+ export const ADDED_MODELS = [
39
+ { provider: "openrouter", id: "baidu/ernie-5.5-flash-preview:free", like: "inclusionai/ling-3.1-flash", name: "Baidu: ERNIE 5.5 Flash Preview (free)", input: ["text"], contextWindow: 1_024_000, maxTokens: 921_600, mustReason: true },
40
+ { provider: "openrouter", id: "inclusionai/ling-3.2-flash:free", like: "inclusionai/ling-3.1-flash", name: "inclusionAI: Ling 3.2 Flash (free)", input: ["text"], contextWindow: 1_048_576, maxTokens: 262_144, mustReason: false },
41
+ ];
42
+ /** `list` with ADDED_MODELS appended, each built on its `like` entry in `list` (one whose `like` the list lacks is left
43
+ * out) and never twice: once pi-ai lists an id itself, its own entry stands. */
44
+ const added = (list, adds) => [
45
+ ...list,
46
+ ...adds.flatMap(({ id, like, name, input, contextWindow, maxTokens, mustReason }) => {
47
+ const base = list.find((model) => model.id === like);
48
+ if (!base || list.some((model) => model.id === id))
49
+ return [];
50
+ const { toolsAs: _base, ...rest } = base;
51
+ const levels = rest.thinkingLevelMap;
52
+ return [{ ...rest, id, name, input: [...input], contextWindow, maxTokens, cost: { ...ZERO }, ...(mustReason ? { reasoning: true, thinkingLevelMap: { ...levels, off: null } } : {}) }];
53
+ }),
54
+ ];
55
+ /** Whether `provider`/`id` is one of OpenRouter's routers, each of which picks a model per request (the kernel cap's
56
+ * ROUTERS, the one list). OpenRouter lists the price of `auto`, `openrouter/auto*`, `openrouter/fusion`,
57
+ * `openrouter/pareto-code` and `typesafe/jev-router` as -1, the routed model's (read 2026-11-15), which pi-ai's catalog
58
+ * writes as 0; `openrouter/free` routes to a different free model per request. Their zeros say no model's price, so
59
+ * none of them is free: a model serve has no price for, which a cap cannot be kept on and which is never booked at its
60
+ * catalog's $0 (model.ts runModels' `unpriced`). */
61
+ export const isRouter = (provider, id) => provider === "openrouter" && ROUTERS.has(id);
62
+ /** Whether a catalog entry runs at $0: the kernel's freeModel (kernel/cap/free.ts, the one rule, what a run on it books
63
+ * at $0) on the entry's price, its tiers included. An entry with no cost has no price, so is not free. */
64
+ export function isFree(model) {
65
+ return freeModel({ id: model.id, api: model.api ?? "", price: model.cost ?? null, outputCeiling: null });
66
+ }
67
+ /** `models` (pi-ai's built-in catalog, or one built on it) with PRICE_OVERRIDES set on their providers' own entries and
68
+ * ADDED_MODELS listed beside them, in place: a request, a price and a capability read find the catalog's entry at the
69
+ * overridden price, with its toolsAs, and an added model as if the catalog listed it. */
27
70
  export function withLocalModels(models) {
28
- for (const providerId of new Set(PRICE_OVERRIDES.map((entry) => entry.provider))) {
71
+ for (const providerId of new Set([...PRICE_OVERRIDES, ...ADDED_MODELS].map((entry) => entry.provider))) {
29
72
  const own = models.getProvider(providerId);
30
73
  if (!own)
31
74
  continue;
32
75
  const overrides = PRICE_OVERRIDES.filter((entry) => entry.provider === providerId);
76
+ const adds = ADDED_MODELS.filter((entry) => entry.provider === providerId);
33
77
  const listed = Object.assign(Object.create(own), {
34
- getModels: () => priced(own.getModels(), overrides),
35
- ...(own.getAllModels ? { getAllModels: () => priced(own.getAllModels(), overrides) } : {}),
78
+ getModels: () => added(priced(own.getModels(), overrides), adds),
79
+ ...(own.getAllModels ? { getAllModels: () => added(priced(own.getAllModels(), overrides), adds) } : {}),
36
80
  });
37
81
  models.setProvider(listed);
38
82
  }
@@ -6,6 +6,8 @@
6
6
  // store was upgraded): two first runs, or a start and a claim, at once agree on one pin. Nothing moves from a run's old
7
7
  // per-run pin (mcp_pins, dropped at the upgrade): the revision's pin is the one every run of it reads.
8
8
  import { readFile } from "node:fs/promises";
9
+ import { nativeOf } from "./native/binding.js";
10
+ import { sdkOf } from "./sdk/runs.js";
9
11
  import { mcpPinOf } from "./mcp-gateway.js";
10
12
  import { boundTool } from "./mcp-probe.js";
11
13
  import { mcpServersOverStore } from "./mcp-servers-store.js";
@@ -18,6 +20,10 @@ import { GITHUB_UNUSABLE } from "./runner/mcp-github.js";
18
20
  * pin of the other servers alone would stand for good, its missing tool never pinned), and the run is refused in the
19
21
  * words it was (server.ts runnable at a start, the claim's own at a claim). */
20
22
  export async function pinFirst(revision, deps) {
23
+ // Native source MCP names and SDK callback tools belong to their source, never this server's managed registry.
24
+ // Their runnable guards must refuse managed execution without listing or pinning those names first.
25
+ if (nativeOf(revision.body) || sdkOf(revision.body))
26
+ return undefined;
21
27
  if (revision.mcpPin !== undefined && revision.mcpPin !== null)
22
28
  return revision.mcpPin;
23
29
  if (revision.kind !== "agentic")
@@ -65,4 +65,7 @@ registerSecretWrite("previewMcpServer", () => false);
65
65
  // whatever the body (the listing sends the key too, and only the session may type one).
66
66
  registerSecretWrite("listComposioTools", () => true);
67
67
  registerSecretWrite("saveComposioServer", () => true);
68
+ // A Composio server's webhook subscription (composio-triggers.ts): a rotate seals its new secret, a delete drops it.
69
+ registerSecretWrite("rotateComposioSecret", () => true);
70
+ registerSecretWrite("deleteComposioSubscription", () => true);
68
71
  registerNotSecretWrite("refreshMcpServer", "A refresh lists the saved server's tools again with its sealed credential, and writes no credential.");
@@ -106,15 +106,15 @@ export declare class McpServersOverStore {
106
106
  headers?: string[] | undefined;
107
107
  type: string;
108
108
  };
109
- credential: "unreadable" | "sealed" | "expired" | null;
109
+ credential: "sealed" | "expired" | "unreadable" | null;
110
110
  not_metered?: string[] | undefined;
111
111
  tools: {
112
112
  grant_problems?: Record<string, string>;
113
- default_permission: "ask" | "deny" | "allow";
114
- permissions: ("ask" | "deny" | "allow")[];
113
+ default_permission: "allow" | "ask" | "deny";
114
+ permissions: ("allow" | "ask" | "deny")[];
115
115
  fallback_allow_reads?: true | undefined;
116
116
  allow_reads?: true | undefined;
117
- permission: "ask" | "deny" | "allow";
117
+ permission: "allow" | "ask" | "deny";
118
118
  effect: import("./tool-gate.js").ToolEffect;
119
119
  name: string;
120
120
  title?: string;
@@ -147,15 +147,15 @@ export declare class McpServersOverStore {
147
147
  headers?: string[] | undefined;
148
148
  type: string;
149
149
  };
150
- credential: "unreadable" | "sealed" | "expired" | null;
150
+ credential: "sealed" | "expired" | "unreadable" | null;
151
151
  not_metered?: string[] | undefined;
152
152
  tools: {
153
153
  grant_problems?: Record<string, string>;
154
- default_permission: "ask" | "deny" | "allow";
155
- permissions: ("ask" | "deny" | "allow")[];
154
+ default_permission: "allow" | "ask" | "deny";
155
+ permissions: ("allow" | "ask" | "deny")[];
156
156
  fallback_allow_reads?: true | undefined;
157
157
  allow_reads?: true | undefined;
158
- permission: "ask" | "deny" | "allow";
158
+ permission: "allow" | "ask" | "deny";
159
159
  effect: import("./tool-gate.js").ToolEffect;
160
160
  name: string;
161
161
  title?: string;
@@ -210,15 +210,15 @@ export declare class McpServersOverStore {
210
210
  headers?: string[] | undefined;
211
211
  type: string;
212
212
  };
213
- credential: "unreadable" | "sealed" | "expired" | null;
213
+ credential: "sealed" | "expired" | "unreadable" | null;
214
214
  not_metered?: string[] | undefined;
215
215
  tools: {
216
216
  grant_problems?: Record<string, string>;
217
- default_permission: "ask" | "deny" | "allow";
218
- permissions: ("ask" | "deny" | "allow")[];
217
+ default_permission: "allow" | "ask" | "deny";
218
+ permissions: ("allow" | "ask" | "deny")[];
219
219
  fallback_allow_reads?: true | undefined;
220
220
  allow_reads?: true | undefined;
221
- permission: "ask" | "deny" | "allow";
221
+ permission: "allow" | "ask" | "deny";
222
222
  effect: import("./tool-gate.js").ToolEffect;
223
223
  name: string;
224
224
  title?: string;
@@ -255,15 +255,15 @@ export declare class McpServersOverStore {
255
255
  headers?: string[] | undefined;
256
256
  type: string;
257
257
  };
258
- credential: "unreadable" | "sealed" | "expired" | null;
258
+ credential: "sealed" | "expired" | "unreadable" | null;
259
259
  not_metered?: string[] | undefined;
260
260
  tools: {
261
261
  grant_problems?: Record<string, string>;
262
- default_permission: "ask" | "deny" | "allow";
263
- permissions: ("ask" | "deny" | "allow")[];
262
+ default_permission: "allow" | "ask" | "deny";
263
+ permissions: ("allow" | "ask" | "deny")[];
264
264
  fallback_allow_reads?: true | undefined;
265
265
  allow_reads?: true | undefined;
266
- permission: "ask" | "deny" | "allow";
266
+ permission: "allow" | "ask" | "deny";
267
267
  effect: import("./tool-gate.js").ToolEffect;
268
268
  name: string;
269
269
  title?: string;
@@ -319,6 +319,15 @@ export declare class McpServersOverStore {
319
319
  /** The saved OAuth token set of `row` (the row read and checked, as opened), for a sign-in again that reuses the kept
320
320
  * client. */
321
321
  private openedSet;
322
+ /** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
323
+ * preset's default when none) and its toolkit: what its Composio triggers are made with (composio-triggers.ts). Refused
324
+ * when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
325
+ * routes (`route`). The key goes only to Composio. */
326
+ composioOf(name: string, refusal: "field" | "route"): Promise<{
327
+ key: string;
328
+ user: string;
329
+ toolkit: string;
330
+ }>;
322
331
  /** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
323
332
  * tokens, else its record, else url with none. */
324
333
  sourceOf(row: RecordedRow & {
@@ -15,7 +15,7 @@ import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./m
15
15
  import { credentialMark } from "./mcp-secret-writes.js";
16
16
  import { secretMeta, secretName } from "./secret-writes.js";
17
17
  import { dialAt, issuerOf, LOOPBACK, MAX_PENDING, MCP_SETTINGS_PAGE, mcpServerAt, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
18
- import { composioServerId } from "./composio-preset.js";
18
+ import { COMPOSIO_USER, composioServerId } from "./composio-preset.js";
19
19
  import { mcpSourceKey, recordedForAnother, sourceOf, sourceToWrite, standInGiven, storedSource, toolkitGiven } from "./mcp-sources.js";
20
20
  import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
21
21
  import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
@@ -23,7 +23,7 @@ import { serverGate } from "./tool-plane.js";
23
23
  import { toolEffect } from "./tool-gate.js";
24
24
  import { HARNESSES } from "./harness.js";
25
25
  import { harnessOf } from "./harness-table.js";
26
- import { mcpDroppedWords, mcpGrantNameProblem, mcpToolName } from "./tool-names.js";
26
+ import { droppedWords, mcpGrantNameProblem, mcpToolName } from "./tool-names.js";
27
27
  import { isObject, unknownFields } from "./validate.js";
28
28
  /** How many writes an owner's save or tools refresh makes over a row whose credential a run's refresh keeps changing,
29
29
  * each re-applied onto the row read again, before it is refused in words. */
@@ -533,6 +533,26 @@ export class McpServersOverStore {
533
533
  const open = openMcpRow(this.sealKey, row);
534
534
  return "credential" in open && open.credential.type === "oauth" ? open.credential.set : undefined;
535
535
  }
536
+ /** A saved Composio preset server's key (its sealed x-api-key), the Composio user its address names (`user_id`, the
537
+ * preset's default when none) and its toolkit: what its Composio triggers are made with (composio-triggers.ts). Refused
538
+ * when `name` is no such server: on the trigger's `source.server` at its create (`field`), as a 404 on the server's own
539
+ * routes (`route`). The key goes only to Composio. */
540
+ async composioOf(name, refusal) {
541
+ const refuse = (message) => (refusal === "route" ? new ApiError("not_found", message) : invalid([{ field: "source.server", reason: "not_an_option", message }]));
542
+ const row = await this.store.mcp.server(name);
543
+ if (!row)
544
+ throw refusal === "route" ? notFound(name) : refuse(`No MCP server ${name}: save a Composio server in Settings → MCP servers first.`);
545
+ const { source, toolkit } = await this.sourceOf(row);
546
+ if (source !== "composio" || row.auth !== "headers")
547
+ throw refuse(`${name} is not a Composio server: only one saved with Settings → MCP servers → Composio makes Composio triggers.`);
548
+ if (!toolkit)
549
+ throw refuse(`${name} is a Composio server of no toolkit this server can name: save it again with its toolkit's slug.`);
550
+ const { headers } = await this.opened(name, row, refusal === "field" ? "source.server" : "api_key");
551
+ const key = Object.entries(headers).find(([header]) => header.toLowerCase() === "x-api-key")?.[1];
552
+ if (!key)
553
+ throw refuse(`${name}'s saved credential holds no Composio key: save it again with its key.`);
554
+ return { key, user: new URL(row.url).searchParams.get("user_id") || COMPOSIO_USER, toolkit };
555
+ }
536
556
  /** What the saved server `row` is, for a template's apply to match (mcp-sources.ts sourceOf): github on the GitHub App's
537
557
  * tokens, else its record, else url with none. */
538
558
  async sourceOf(row) {
@@ -622,7 +642,7 @@ function grantProblemsOf(env, server, tool) {
622
642
  for (const harness of HARNESSES) {
623
643
  const dropped = harnessOf(env, harness)?.facts?.schemaProblems?.(`mcp__${server}__${tool.name}`, schema)[0];
624
644
  if (dropped)
625
- problems[harness] = mcpDroppedWords(server, tool.name, harness, dropped);
645
+ problems[harness] = droppedWords(mcpToolName(server, tool.name), harness, dropped);
626
646
  }
627
647
  }
628
648
  return Object.keys(problems).length ? { grant_problems: problems } : {};
@@ -13,6 +13,17 @@ export declare function formOf(env: NodeJS.ProcessEnv, vendor: string, id: strin
13
13
  * (harness.ts harnessOffers drops those it does not run). Behind serve's gateway every id is the gateway's own string, so
14
14
  * the host's tier models stand for what it runs; with the faux model none is offered. */
15
15
  export declare function pickerCandidates(env: NodeJS.ProcessEnv, harness: string): string[];
16
+ /** A model a person may pick that runs at $0 (local-models.ts isFree, the kernel's freeModel on its catalog price: all
17
+ * zeros, every tier's too), in the form it takes, with its context window in tokens. */
18
+ export type FreeModel = {
19
+ id: string;
20
+ context_window: number;
21
+ };
22
+ /** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
23
+ * it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
24
+ * pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
25
+ * ids are its own) or with the faux model. */
26
+ export declare function freeCandidates(env: NodeJS.ProcessEnv, harness: string): Promise<FreeModel[]>;
16
27
  /** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
17
28
  * with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
18
29
  export declare function likelyModel(env: NodeJS.ProcessEnv, harness: string, given: string): string | undefined;
@@ -6,6 +6,8 @@ import { ADAPTER_FACTS } from "./adapter-facts.js";
6
6
  import { FAUX_ENV, MODEL_KEYS } from "./model.js";
7
7
  import { openRouterName } from "./provider.js";
8
8
  import { WIRES } from "./wires.js";
9
+ import { PLAN_PROVIDER, planOf, signedIn } from "./chatgpt-plan.js";
10
+ import { PLAN_HARNESSES } from "./harness.js";
9
11
  /** The current models a person may pick, by vendor, in the vendor's own ids (Anthropic's dashes; OpenRouter's dotted name
10
12
  * for the same model is derived, provider.ts openRouterName). The everyday model first: it is the example a refusal gives.
11
13
  * A candidate a harness cannot run on this server (one pi-ai's catalog does not list) is dropped before it is served
@@ -39,7 +41,21 @@ export function pickerCandidates(env, harness) {
39
41
  if (env.AGENT_MODEL_BASE_URL && facts?.wire !== "anthropic-messages")
40
42
  return [...new Set([env.AGENT_MODEL, env.AGENT_MODEL_FAST, env.AGENT_MODEL_STRONG].filter((id) => Boolean(id)))];
41
43
  const vendors = vendorsOf(harness);
42
- return PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)));
44
+ // Signed in to a ChatGPT plan, its models first for a harness that runs on it (`chatgpt/<model-id>`).
45
+ const plan = PLAN_HARNESSES.includes(harness) && signedIn(env) ? (planOf(env)?.models ?? []).map((id) => `${PLAN_PROVIDER}/${id}`) : [];
46
+ return [...plan, ...PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)))];
47
+ }
48
+ /** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
49
+ * it does not run): OpenRouter's chat models whose catalog price is all zeros (pi-ai's own and serve's ADDED_MODELS), on
50
+ * pi with OpenRouter's key, by id. None for an adapter harness (each runs its own wire's vendor), behind a gateway (its
51
+ * ids are its own) or with the faux model. */
52
+ export async function freeCandidates(env, harness) {
53
+ if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL || !env.OPENROUTER_API_KEY || ADAPTER_FACTS.some((f) => f.id === harness))
54
+ return [];
55
+ const [{ builtinModels }, { withLocalModels, isFree }] = await Promise.all([import("@earendil-works/pi-ai/providers/all"), import("./local-models.js")]);
56
+ return withLocalModels(builtinModels()).getModels("openrouter").filter(isFree)
57
+ .map((model) => ({ id: `openrouter/${model.id}`, context_window: model.contextWindow }))
58
+ .sort((a, b) => a.id.localeCompare(b.id));
43
59
  }
44
60
  /** A model id with its spelling taken out (case, spaces, dots, dashes), and the provider's segments off. */
45
61
  const spelled = (given) => (given.split("/").pop() ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
package/dist/model.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ModelCost } from "@earendil-works/pi-ai";
2
2
  import type { Wire } from "@parcha/agentrun-kernel";
3
+ import type { ThinkingLevelMap } from "./port-models.js";
3
4
  import { type HarnessEntry } from "./harness-table.js";
4
5
  import type { Revision } from "./agent-rows.js";
5
6
  /** The child's environment names the faux module by absolute path. */
@@ -54,6 +55,14 @@ export declare const MODEL_KEYS: readonly {
54
55
  * starts (MODEL_KEYS' fields), OpenRouter's named first, as its one key runs every harness. The order a default is
55
56
  * taken in is MODEL_KEYS' own. */
56
57
  export declare const ADD_A_KEY: string;
58
+ /** Whether a ChatGPT sign-in here would give `harness` its model, where it wants a key now: `signed_out` (none yet) or
59
+ * `expired` (sign in again). None where it would not: a harness that needs a key whatever the plan (PLAN_HARNESSES), a
60
+ * server that cannot sign in (a runner, a faux model), one behind serve's gateway (its model is the gateway's), one
61
+ * signed in, or one whose AGENT_MODEL names a key's model the harness runs (hostModel keeps it signed in or not). */
62
+ export declare function planWouldRun(env: NodeJS.ProcessEnv, harness: string): "signed_out" | "expired" | undefined;
63
+ /** `reason`, `harness`'s want of a key for its default model, with what a ChatGPT sign-in here would do about it
64
+ * (planWouldRun), in words; as it was where the sign-in would not. */
65
+ export declare function withPlanWords(env: NodeJS.ProcessEnv, harness: string, reason: string): string;
57
66
  /** Whether `harness` runs the model `id` (its entry in the harness table: harness-table.ts): pi any; one on an adapter, its
58
67
  * wire's vendor's model (or that vendor's on OpenRouter), or behind serve's gateway, on the wire it serves, any id. */
59
68
  export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness: string) => boolean;
@@ -65,8 +74,9 @@ export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness:
65
74
  export declare function hostModel(env: NodeJS.ProcessEnv, tier?: Tier, harness?: string): string | undefined;
66
75
  /** `route_prefix`: the routing prefix this server puts before a gateway's model ids (MODEL_PROVIDER), which a reader takes off
67
76
  * to show the gateway's own id; null with any other source. */
68
- /** The values `models.source` takes here: a faux module, a gateway, or each provider with its own key. */
69
- export declare const MODEL_SOURCES: readonly ["faux", "gateway", "providers"];
77
+ /** The values `models.source` takes here: a faux module, a gateway, each provider with its own key, or, with no key, a
78
+ * person's ChatGPT plan signed in here (chatgpt-plan.ts). */
79
+ export declare const MODEL_SOURCES: readonly ["faux", "gateway", "providers", "chatgpt"];
70
80
  export type ModelSource = {
71
81
  source: (typeof MODEL_SOURCES)[number];
72
82
  route_prefix: string | null;
@@ -150,7 +160,8 @@ export type FauxHelpers = {
150
160
  /** The models for a run, and its model of each tier it uses and of no other: an agentic revision's `ref` (or the
151
161
  * default) is its `default` (a claimed run's: its pin, chooseModel), and a workflow's tiers are the ones its nodes name.
152
162
  * The faux module's replies, the gateway in the environment, or pi-ai's providers. `unpriced`: the ids of its models
153
- * serve has no price for (a gateway model the catalog does not list, with no price set), which a cap cannot be kept on.
163
+ * serve has no price for (a gateway model the catalog does not list, with no price set; an OpenRouter router), which a
164
+ * cap cannot be kept on.
154
165
  * `tierRefs`: a model named for another tier (a subagent's model_tiers), chosen for it in place of the host's. */
155
166
  export declare function runModels(env: NodeJS.ProcessEnv, ref: string | PinnedModel | undefined, tiers?: readonly Tier[], harness?: string, tierRefs?: Readonly<Partial<Record<Tier, string>>>): Promise<{
156
167
  models: import("@earendil-works/pi-ai").MutableModels;
@@ -187,9 +198,10 @@ export declare function wireModels(entry: HarnessEntry, env: NodeJS.ProcessEnv,
187
198
  export declare function runModelRef(env: NodeJS.ProcessEnv, revision: Revision): Promise<ModelRef | undefined>;
188
199
  /** The models a run of `ref` (an agentic revision's own, else the host's) on `harness` would take, of `tiers`, that serve
189
200
  * has no price for here: a gateway's (AGENT_MODEL_BASE_URL) id with no price set and none in the catalog in any form
190
- * (gatewayPrices). None elsewhere: pi-ai's providers price their own models, a $0 entry included, and a harness on a wire the gateway does not serve
201
+ * (gatewayPrices), and OpenRouter's routers anywhere (their $0 is no price: routersOf). None else: pi-ai's providers
202
+ * price their own models, a $0 entry included, and a harness on a wire the gateway does not serve
191
203
  * (Anthropic's Messages: provider.ts WIRES) prices
192
- * by its catalog entry. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
204
+ * by its catalog entry, and a ChatGPT plan's model costs no dollars. One a cap cannot be kept on: capabilities' `models.priced`, and blockersOf's refusal of a capped
193
205
  * run. A model chooseModel cannot give is not this one's to say (its own blocker says why). */
194
206
  export declare function unpricedModels(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[], harness?: string): Promise<string[]>;
195
207
  /** Why `models` (providerModels') send no request on Anthropic's route: ANTHROPIC_BASE_URL is a base a key may not go to,
@@ -208,9 +220,17 @@ export declare function providerModels(env: NodeJS.ProcessEnv): Promise<import("
208
220
  export type Listed = {
209
221
  provider: string;
210
222
  cost: ModelCost;
223
+ thinkingLevelMap?: ThinkingLevelMap;
211
224
  };
212
- /** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order. */
225
+ /** pi-ai's catalog list prices by model id: every provider's entry for it, in the catalog's order, with the effort each
226
+ * thinking level asks for where the entry says. */
213
227
  export declare function catalogPrices(): Promise<Map<string, Listed[]>>;
228
+ /** A gateway model's thinking levels in `catalog` (catalogPrices'), by its own id (the last segment of `id`) in either
229
+ * version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
230
+ * agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
231
+ * pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
232
+ * effort, as its catalog entries say (off: null), not the "none" it refuses. */
233
+ export declare function catalogThinking(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): ThinkingLevelMap | undefined;
214
234
  /** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
215
235
  * its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
216
236
  * (`vendor/model`) the catalog does not list as it is, priced as its model, the vendor named; else the id as it is. Each