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

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 (410) hide show
  1. package/CHANGELOG.md +418 -0
  2. package/README.md +325 -124
  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-BNhZs-jp.css +1 -0
  37. package/dist/console/assets/index-BQv5aOGB.js +700 -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 +84 -0
  44. package/dist/email/account.js +159 -0
  45. package/dist/email/answer.d.ts +10 -0
  46. package/dist/email/answer.js +182 -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 +380 -0
  53. package/dist/email/names.d.ts +20 -0
  54. package/dist/email/names.js +40 -0
  55. package/dist/email/routes.d.ts +9 -0
  56. package/dist/email/routes.js +50 -0
  57. package/dist/email/tools.d.ts +20 -0
  58. package/dist/email/tools.js +517 -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 +9 -2
  93. package/dist/learn/compile.js +52 -16
  94. package/dist/learn/grade.d.ts +4 -0
  95. package/dist/learn/grade.js +4 -1
  96. package/dist/learn/promote.d.ts +106 -51
  97. package/dist/learn/promote.js +82 -189
  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 +26 -8
  109. package/dist/learning-cost.js +17 -7
  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 +33 -2
  118. package/dist/local-models.js +43 -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 +1 -0
  164. package/dist/openapi.js +394 -85
  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 +7 -2
  170. package/dist/port-models.js +5 -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 +11 -0
  180. package/dist/refusal-words.js +13 -2
  181. package/dist/run-launch.d.ts +10 -1
  182. package/dist/run-launch.js +11 -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 +42 -35
  191. package/dist/run-view.js +79 -44
  192. package/dist/runnable.d.ts +13 -5
  193. package/dist/runnable.js +69 -60
  194. package/dist/runner/adapter-loop.d.ts +42 -11
  195. package/dist/runner/adapter-loop.js +651 -247
  196. package/dist/runner/adapter-run-spec.d.ts +37 -12
  197. package/dist/runner/adapter-run-spec.js +139 -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 +94 -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 +37 -13
  217. package/dist/runner/journal-kinds.js +9 -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 +12 -3
  237. package/dist/runner/model-route.js +139 -18
  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 +74 -8
  243. package/dist/runner/promotion.js +365 -124
  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 +554 -130
  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/index.d.ts +1 -1
  278. package/dist/store/native-command-owner.d.ts +10 -0
  279. package/dist/store/native-command-owner.js +47 -0
  280. package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
  281. package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
  282. package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
  283. package/dist/store/postgres/store.js +3 -0
  284. package/dist/store/schema.d.ts +7 -0
  285. package/dist/store/schema.js +20 -1
  286. package/dist/store/sqlite/run-patch.d.ts +8 -1
  287. package/dist/store/sqlite/run-patch.js +14 -3
  288. package/dist/store/sqlite/store.js +133 -18
  289. package/dist/store/store.d.ts +52 -7
  290. package/dist/store-reads/analytics.d.ts +7 -7
  291. package/dist/store-reads/analytics.js +23 -5
  292. package/dist/store-reads/cap.js +8 -6
  293. package/dist/store-reads/journal.d.ts +5 -0
  294. package/dist/store-reads/journal.js +85 -41
  295. package/dist/store-reads/learning.d.ts +85 -5
  296. package/dist/store-reads/learning.js +45 -17
  297. package/dist/store-reads/runs.d.ts +5 -0
  298. package/dist/store-reads/runs.js +3 -2
  299. package/dist/store-view.js +75 -21
  300. package/dist/template-eval.d.ts +73 -11
  301. package/dist/template-eval.js +535 -75
  302. package/dist/templates.d.ts +70 -20
  303. package/dist/templates.js +191 -34
  304. package/dist/text-urls.d.ts +38 -0
  305. package/dist/text-urls.js +170 -0
  306. package/dist/timeline/index.d.ts +3 -2
  307. package/dist/timeline/index.js +3 -2
  308. package/dist/timeline/labels.d.ts +5 -2
  309. package/dist/timeline/labels.js +29 -6
  310. package/dist/timeline/origin.d.ts +1 -1
  311. package/dist/timeline/origin.js +2 -2
  312. package/dist/timeline/render-text.js +1 -1
  313. package/dist/timeline/timeline.d.ts +66 -4
  314. package/dist/timeline/timeline.js +160 -30
  315. package/dist/timeline/util.d.ts +5 -0
  316. package/dist/timeline/util.js +44 -8
  317. package/dist/timeline/web-calls.d.ts +17 -0
  318. package/dist/timeline/web-calls.js +106 -0
  319. package/dist/tool-gate.d.ts +42 -42
  320. package/dist/tool-gate.js +97 -91
  321. package/dist/tool-list.d.ts +4 -1
  322. package/dist/tool-list.js +8 -1
  323. package/dist/tool-names.d.ts +18 -13
  324. package/dist/tool-names.js +19 -17
  325. package/dist/tool-plane.d.ts +17 -13
  326. package/dist/tool-plane.js +12 -5
  327. package/dist/tools.d.ts +44 -16
  328. package/dist/tools.js +28 -28
  329. package/dist/trigger-adapter.d.ts +85 -5
  330. package/dist/trigger-adapter.js +6 -0
  331. package/dist/trigger-adapters.js +3 -1
  332. package/dist/trigger-composio.d.ts +10 -0
  333. package/dist/trigger-composio.js +122 -0
  334. package/dist/trigger-email.d.ts +4 -0
  335. package/dist/trigger-email.js +228 -0
  336. package/dist/trigger-signatures.d.ts +6 -10
  337. package/dist/trigger-signatures.js +16 -16
  338. package/dist/trigger-targets.d.ts +1 -1
  339. package/dist/trigger-targets.js +4 -3
  340. package/dist/trigger-webhook.js +6 -4
  341. package/dist/triggers.d.ts +94 -9
  342. package/dist/triggers.js +263 -62
  343. package/dist/uploads.d.ts +9 -0
  344. package/dist/uploads.js +27 -0
  345. package/dist/validate.js +1 -7
  346. package/dist/web-fake.d.ts +56 -0
  347. package/dist/web-fake.js +102 -0
  348. package/dist/web-fetch-direct.d.ts +3 -0
  349. package/dist/web-fetch-direct.js +4 -1
  350. package/dist/web-fetch.d.ts +5 -1
  351. package/dist/web-fetch.js +8 -31
  352. package/dist/web-search.d.ts +51 -2
  353. package/dist/web-search.js +116 -18
  354. package/dist/webhooks.d.ts +2 -1
  355. package/dist/webhooks.js +5 -1
  356. package/dist/workflow/node-runner.js +10 -2
  357. package/dist/workspace/archil-claim.d.ts +3 -0
  358. package/dist/workspace/archil-claim.js +9 -2
  359. package/dist/workspace/computer-deps.d.ts +22 -9
  360. package/dist/workspace/computer-deps.js +78 -37
  361. package/dist/workspace/computer-for-claim.d.ts +54 -4
  362. package/dist/workspace/computer-for-claim.js +179 -39
  363. package/dist/workspace/computer-janitor.d.ts +10 -3
  364. package/dist/workspace/computer-janitor.js +96 -29
  365. package/dist/workspace/computer-kept.d.ts +82 -0
  366. package/dist/workspace/computer-kept.js +147 -0
  367. package/dist/workspace/computer-mcp.js +4 -3
  368. package/dist/workspace/computer-ports.d.ts +23 -3
  369. package/dist/workspace/computer-ports.js +115 -5
  370. package/dist/workspace/index.d.ts +1 -2
  371. package/dist/workspace/index.js +1 -2
  372. package/dist/workspace/kind-skills/desktop/SKILL.md +25 -18
  373. package/dist/workspace/kind-skills/phone/SKILL.md +28 -17
  374. package/dist/workspace/resolve-computer.d.ts +15 -3
  375. package/dist/workspace/resolve-computer.js +10 -7
  376. package/dist/workspace/revision-skills.d.ts +6 -2
  377. package/dist/workspace/revision-skills.js +12 -5
  378. package/dist/workspace/run-end-computers.d.ts +30 -0
  379. package/dist/workspace/run-end-computers.js +137 -0
  380. package/dist/workspace/run-tools.d.ts +28 -29
  381. package/dist/workspace/run-tools.js +29 -30
  382. package/dist/wrap-up.d.ts +19 -5
  383. package/dist/wrap-up.js +31 -4
  384. package/package.json +13 -9
  385. package/skills/agentrun-serve/SKILL.md +248 -10
  386. package/templates/README.md +117 -23
  387. package/templates/TOOLS.md +168 -0
  388. package/templates/code-review/agent.md +18 -4
  389. package/templates/code-review/evals/mentions-defused/case.yaml +1 -1
  390. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
  391. package/templates/code-review/evals/other-repo/case.yaml +1 -1
  392. package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
  393. package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
  394. package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
  395. package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
  396. package/templates/code-review/skills/review/DEEP.md +2 -2
  397. package/templates/code-review/skills/review/REVIEWER.md +2 -2
  398. package/templates/code-review/skills/review/SKILL.md +7 -3
  399. package/templates/release-notes/evals/draft-not-publish/case.yaml +1 -1
  400. package/templates/release-notes/evals/issue-write-refused/case.yaml +1 -1
  401. package/templates/release-notes/evals/late-arrival/case.yaml +1 -1
  402. package/templates/release-notes/evals/other-repo/case.yaml +1 -1
  403. package/dist/console/assets/index-CjqQirbo.css +0 -1
  404. package/dist/console/assets/index-b6-XY5A9.js +0 -576
  405. package/dist/host-calls.d.ts +0 -20
  406. package/dist/host-calls.js +0 -12
  407. package/dist/runner/adapters/pi-computer.d.ts +0 -9
  408. package/dist/runner/adapters/pi-computer.js +0 -51
  409. package/dist/workspace/computer-script.d.ts +0 -53
  410. package/dist/workspace/computer-script.js +0 -172
@@ -1,65 +1,67 @@
1
1
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
2
2
  import { defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
3
- import { checkRaise, followUpOf, parkOf } from "@parcha/agentrun-kernel/kernel/cap";
3
+ import { checkRaise, followUpOf, freeModelRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
4
4
  import { inspectWorkflow } from "@parcha/agentrun-dsl";
5
5
  import { decisionProvidersIn } from "../decisions.js";
6
6
  import { dropLiveViewer, putLiveViewer } from "../browser-live.js";
7
7
  import { runnerLiveOf } from "../live-reach.js";
8
8
  import { llmTiers, nodeTiers, thinkingLevel, TIERS, tierModelOf, workflowNodes } from "../model.js";
9
- import { firstMessage, inputMessage } from "../run-manifest.js";
9
+ import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
10
10
  import { learningStartOf, seedFailed } from "../run-launch.js";
11
11
  import { isWebHostTool } from "../tool-list.js";
12
- import { deniedText, mcpServersOf, noApproverText, runGate } from "../tool-gate.js";
12
+ import { deniedText, noApproverText, runGate } from "../tool-gate.js";
13
13
  import { DECISION_PROVIDER_KEYS, loadToolSettings, recheckPlane, TOOL_PLANE_ENV } from "../tool-plane.js";
14
14
  import { readApprovers } from "../server-approvers.js";
15
15
  import { ASK_TOOL, askPerson, toolOf } from "../tools.js";
16
16
  import { hostToolOf } from "../host-tools.js";
17
17
  import { WEB_SEARCH_TOOL } from "../web-search.js";
18
- import { environmentLine } from "../environment.js";
18
+ import { webCut } from "../timeline/web-calls.js";
19
+ import { environmentLine, runZone } from "../environment.js";
19
20
  import { effortGuidance } from "../effort-guidance.js";
20
21
  import { outputContract } from "../answer-json.js";
21
22
  import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
22
23
  import { laidOf, layLearningSeed } from "./learning-seed.js";
23
24
  import { learningWorkspace } from "../learn/folder.js";
24
25
  import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
25
- import { learnedAskFits, learnedAskShown, LEARNED_WORKFLOW_TOOL, learnedMcpTools, learnedWorkflowTool } from "../learned-workflow.js";
26
+ import { learnedAskShown, LEARNED_WORKFLOW_TOOL, learnedMcpCalls, learnedWorkflowTool } from "../learned-workflow.js";
26
27
  import { PORT_PROVIDER, tieredModels, tierProvider } from "../port-models.js";
27
28
  import { promptOf, readsFiles } from "../skills.js";
28
29
  import { openRunWorkspace } from "../workspace/run-workspace.js";
29
30
  import { layOwnSkills } from "../workspace/revision-skills.js";
30
31
  import { COMPUTER_ROOT, runFolder } from "../workspace/paths.js";
31
32
  import { runTools, withKindTools } from "../workspace/run-tools.js";
32
- import { copyRunFiles } from "../uploads.js";
33
+ import { placeRunInputs } from "../uploads.js";
33
34
  import { handedSignInReadsBack, signInReads } from "../sign-ins-store.js";
34
35
  import { UNREADABLE_SIGN_IN } from "../run-view.js";
35
36
  import { durableWait } from "../workflow/pi-versions.js";
36
37
  import { claimSecrets, hostDecisionKeys, learnedDecisionKeys, savedModelKeys, tierModelKeys, withModelKeys } from "./claim-secrets.js";
37
- import { mcpForClaim } from "./mcp-run.js";
38
+ import { catalogSessionNames, mcpForClaim } from "./mcp-run.js";
38
39
  import { hostLifecycle } from "./adapter-loop.js";
39
40
  import { piAdapter } from "./adapters/pi.js";
40
- import { computerCodemode } from "./adapters/pi-computer.js";
41
41
  import { agentEntriesOf } from "./loop.js";
42
42
  import { SUBAGENT_TIERS, SUBAGENT_TOOL, subagentTool } from "./subagent.js";
43
- import { wireName } from "../catalog.js";
44
43
  import { ClaimRefused } from "./loop-contract.js";
45
- import { bookedSpend, cliRunMetrics, runEndCost, runMetrics } from "./metrics.js";
44
+ import { bookedSpend, cliRunMetrics, endCostOf, runCostOf, runMetrics } from "./metrics.js";
46
45
  import { journalEntries } from "./journal-reader.js";
47
- import { piShaped } from "../store-reads/journal.js";
46
+ import { hashedMcpOf, piShaped } from "../store-reads/journal.js";
48
47
  import { claimPromotion, promotionGate, replayCallsFor, replayClaimed, replayLaid } from "./promotion.js";
49
48
  import { laidFor, pathMetrics, servedOf, workflowFirstOf } from "./workflow-first.js";
50
49
  import { pastRunsOverStore, runPathOverStore } from "../store-reads/learning.js";
51
50
  import { specBuilt } from "./spec-holds.js";
52
51
  import { archilClaim, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
53
52
  import { loadArchilSettings } from "../archil-settings.js";
54
- import { computerReadyWords, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
53
+ import { settingOfDefinition } from "../computer-setting.js";
54
+ import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
55
+ import { hadComputer } from "./computer-journal.js";
55
56
  import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
57
+ import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
56
58
  import { heldSpecOf } from "./held-run.js";
57
59
  import { loopComputerOf } from "./computer-channel.js";
58
60
  import { githubAppAccess } from "./github-app.js";
59
61
  import { prCheckoutForClaim } from "./pr-checkout.js";
60
62
  import { holdStored, storeSecrets } from "./store-secrets.js";
61
63
  import { bashPolicyOf } from "../bash-read-only.js";
62
- import { monidForClaim, monidSessionNames, withMonid } from "./monid-run.js";
64
+ import { monidForClaim, withMonid } from "./monid-run.js";
63
65
  /** The wires pi speaks on the runner: main's pi's (provider.ts), Anthropic's Messages and OpenAI's Responses. */
64
66
  export const PI_WIRES = Object.freeze(["anthropic-messages", "openai-responses"]);
65
67
  /** The browser's catalog name (tools.ts TOOLS.browser). */
@@ -75,6 +77,9 @@ export const browserListed = (host, granted) => BROWSER_ON_RUNNER && host.ledger
75
77
  * model's tier is held and booked at the tier, as main's calculateCost does). `api` is the proxy's shape, for the
76
78
  * overhead its provider adds; the output ceiling is the route's when it carries one, else none. */
77
79
  export function capModelOf(route) {
80
+ // A ChatGPT plan's route is billed to the plan: the one plan rule (planCapModel), a CLI's plan model's too.
81
+ if (route.provider.plan)
82
+ return planCapModel(route.model, route.provider.api, route.outputCeiling ?? null);
78
83
  // A model serve has no price for carries placeholder zeros: the cap reads it as unknown (null), never as $0.
79
84
  const cost = route.unpriced ? undefined : route.cost;
80
85
  const price = cost
@@ -101,67 +106,48 @@ const isSubagentRoute = (key) => key.startsWith(SUBAGENT_ROUTE);
101
106
  export function modelAskOf(pinned, ref) {
102
107
  return pinned ? { pinned, ...(ref ? { ref } : {}) } : ref;
103
108
  }
104
- export async function adapterRunGate(store, claim, revision, root, shell, mcpServers = [], options = {}) {
109
+ export async function adapterRunGate(store, claim, revision, root, shell, options = {}) {
105
110
  let current = await storeSettings(store);
106
111
  const approvers = await readApprovers(store.settings);
107
112
  // A Workspace's paths are in the run's folder: its folder named as a computer names it, for the gate's path checks.
108
113
  const folder = typeof root === "string" ? root : COMPUTER_ROOT;
109
114
  // Where the run's shell is (run-tools.ts shell): with no computer, a tool no setting names takes the kernel's ruled
110
- // default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused. The run's MCP servers
111
- // (mcpServersOf its grants), so a harness naming an MCP tool its own way (OpenCode's `<server>_<tool>`) is held to that
112
- // tool's settings, never to a table tool's of the same shape.
115
+ // default (tool-gate.ts defaultPermission): bash asks first, the background tools are refused.
113
116
  // An MCP tool's effect as the run's pin marks it (ClaimMcp.effectOf): what "allow reads" lifts an ask by.
114
- // pi's code mode on a desktop or a phone (pi-computer.ts) owns the name `codemode` there: held to the kind's setting.
115
- const where = { root: folder, work: folder, mcpServers, ...(options.computerCodemode ? { computerCodemode: true } : {}), ...(options.effectOf ? { effectOf: options.effectOf } : {}), ...(options.argumentsOf ? { argumentsOf: options.argumentsOf } : {}) };
117
+ const where = { root: folder, work: folder, ...(options.effectOf ? { effectOf: options.effectOf } : {}), ...(options.argumentsOf ? { argumentsOf: options.argumentsOf } : {}) };
116
118
  const gate = runGate({ ...where, ...(shell === undefined ? {} : { computer: shell === "computer" }) }, claim.runId, revision, () => current, approvers);
117
- // A script's computer calls (computer_script, pi's code mode) run on the run's computer, a desktop that mounts no folder
118
- // too: decided as on a computer, so its shell.run and processes.start follow bash's one setting alike. The run's own
119
- // host tools keep `gate`, where its bash is (Archil's exec, or none).
120
- const onComputer = runGate({ ...where, computer: true }, claim.runId, revision, () => current, approvers);
121
119
  // The run's learned workflows, once its spec has read them (learn): a learned_workflow call is asked about its MCP nodes.
122
120
  let learned = [];
123
121
  const decide = async (call, options = {}) => {
124
122
  current = await storeSettings(store);
125
123
  const decision = await gate.decide(call.tool, call.args, options);
126
- // A learned workflow's MCP nodes are the run's own MCP calls, held to the same settings, decided for the whole call
127
- // before any node runs, never mid-run: one set to deny refuses the call in the gate's words, nothing sent; one set to
128
- // ask asks for the call, up front, on the run's one card (a running workflow can't park mid-call: it is never run
129
- // again after a crash), and the person's allow lets that call's MCP nodes run, and only that call's.
130
- // Checked whether the learned_workflow call is itself allowed or asked: a workflow that can't run is never put to a
131
- // person.
124
+ // A learned workflow's MCP nodes are the run's own MCP calls, held to the same settings: one set to deny refuses the
125
+ // whole call in the gate's words before any node runs, nothing sent; the actions set to ask are put to a person on the
126
+ // call's one card, up front, each with its arguments' shape (learnedAskShown), and the person's allow passes the
127
+ // calls nested in this one of the tools that card named (adapter-loop.ts preIntentGate), and no other. Each MCP call
128
+ // is still asked at the gate as itself as it runs (its pins, a deny set since). Checked whether the learned_workflow
129
+ // call is itself allowed or asked: a workflow that can't run is never put to a person.
132
130
  if (call.tool !== LEARNED_WORKFLOW_TOOL || typeof decision === "object")
133
131
  return decision;
134
- const tools = await mcpOf(call.args);
132
+ const actions = await mcpOf(call.args);
135
133
  const refused = (why) => ({ deny: `The learned workflow ${String(call.args.name)} was not run: ${why}` });
136
- const denied = tools.find((tool) => gate.policy(tool) === "deny");
134
+ const denied = actions.find(({ tool }) => gate.policy(tool) === "deny");
137
135
  if (denied)
138
- return refused(deniedText(denied, undefined, gate.denyFrom(denied)));
139
- const asks = tools.filter((tool) => gate.policy(tool) === "ask");
136
+ return refused(deniedText(denied.tool, undefined, gate.denyFrom(denied.tool)));
137
+ const asks = actions.filter(({ tool }) => gate.policy(tool) === "ask");
140
138
  // An ask no one can answer (the server's accounts off) is refused at once in the gate's words, never parked.
141
139
  if (asks.length && !approvers)
142
- return refused(noApproverText(asks[0], "no"));
143
- // A card that could not name every MCP tool the person would approve (past its preview's bound) is never shown: the
144
- // call is refused, so no allow covers a tool its approver did not see.
145
- if (asks.length && !learnedAskFits(asks))
146
- return refused(`its approval card can't name all ${asks.length} MCP tools it would call that are set to ask: set some of them to allow or deny for this agent.`);
147
- return asks.length ? "ask" : decision;
140
+ return refused(noApproverText(asks[0].tool, "no"));
141
+ return asks.length ? { ask: learnedAskShown(asks) } : decision;
148
142
  };
149
- /** The MCP tools the learned workflow a learned_workflow call names can call; none for another call or workflow. */
143
+ /** The MCP actions the learned workflow a learned_workflow call names can call; none for another call or workflow. */
150
144
  const mcpOf = async (args) => {
151
145
  const flow = learned.find((one) => one.name === args?.name);
152
- return flow ? learnedMcpTools(flow.workflow) : [];
146
+ return flow ? learnedMcpCalls(flow.workflow) : [];
153
147
  };
154
148
  // An ask is named as main's pending approval is (RunGate.askedAs: its settings key), beside the decision, which is
155
149
  // unchanged. The permissions are the learned workflow's (main's toolGate.policy and denyFrom), over the same settings.
156
- const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); }, decide: (tool, args) => gate.decide(tool, args) };
157
- // What a learned_workflow call's card shows beside its own input: every MCP tool set to ask that the workflow can call,
158
- // and that their arguments are decided while it runs, so the person sees what they approve.
159
- const askedFor = async (tool, args) => {
160
- if (tool !== LEARNED_WORKFLOW_TOOL)
161
- return undefined;
162
- const asks = (await mcpOf(args)).filter((one) => gate.policy(one) === "ask");
163
- return asks.length ? learnedAskShown(asks) : undefined;
164
- };
150
+ const permissions = { policy: (tool) => gate.policy(tool), denyFrom: (tool) => gate.denyFrom(tool), refresh: async () => { current = await storeSettings(store); } };
165
151
  // A tool's setting now, read from the store as each call's is (SessionIO.permission: Codex's live search, which runs
166
152
  // inside a model request, is offered only while it says allow). A read that fails is a deny, never the last good read's
167
153
  // allow: a deny saved since may be in what did not read, and no call reaches the gate to say otherwise.
@@ -169,12 +155,7 @@ export async function adapterRunGate(store, claim, revision, root, shell, mcpSer
169
155
  current = await storeSettings(store);
170
156
  return current.unreadable ? "deny" : gate.policy(tool);
171
157
  };
172
- // A script's computer call, held as the tool it is (computer-script.ts HELD_AS), with the settings read from the store now.
173
- const script = async (tool, args) => {
174
- current = await storeSettings(store);
175
- return onComputer.decide(tool, args);
176
- };
177
- return Object.assign(decide, { askedAs: (tool) => gate.askedAs(tool), askedFor, permissions, permission, script, learn: (flows) => void (learned = flows) });
158
+ return Object.assign(decide, { askedAs: (tool, args) => gate.askedAs(tool, args), permissions, permission, learn: (flows) => void (learned = flows) });
178
159
  }
179
160
  /** The server's tool settings from the store now; a read that throws is unread (no value of it said). A workflow's call
180
161
  * and model nodes read theirs through it too (workflow-spec.ts callPolicyOf), so both gates fail closed alike. */
@@ -237,9 +218,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
237
218
  : await openRunWorkspace({ mode: 2, agentId: runRow.agentId, runId: claim.runId, archil, log });
238
219
  holds.hold({ ws });
239
220
  // The run's uploaded files, copied into its work/inputs/ before the first turn, from what its start held for it, once
240
- // per run (uploads.ts copyRunFiles); a copy that fails ends the run failed, saying why.
241
- if (launch.files?.length)
242
- await copyRunFiles(deps.data, claim.runId, ws.workspace, launch.files);
221
+ // per run (uploads.ts copyRunFiles), and its opening message saved beside them as inputs/message.md (placeRunInputs);
222
+ // a copy that fails ends the run failed, saying why.
223
+ await placeRunInputs(deps.data, claim.runId, ws.workspace, launch.files ?? [], messageText(launch.input));
243
224
  // The pull request's checkout, when the revision asks for one (pr-checkout.ts): the server's own fetch before the first
244
225
  // turn, with the GitHub App's read-only token for that one repository (or none); the run is told what it holds, or why
245
226
  // there is none. Held from the fetch's start, so the release (after the tools' end) removes it however the claim ends; a
@@ -258,23 +239,29 @@ async function adapterSpec(launch, run, deps, claim, holds) {
258
239
  // The run's computer, from the one shared claim-time function (the CLI spec takes the same): none for a runner place, a
259
240
  // Docker container for a sandbox, under the claim's epoch (the one fence). It throws computer_unavailable (nothing made)
260
241
  // when the computer cannot be had: the run fails in its words.
261
- const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(launch.computer !== undefined ? { computer: launch.computer } : {}) }, deps.store,
242
+ const claimSignal = run.stopped ?? run.signal;
243
+ const computer = await deps.computerForClaim({ runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place }, deps.store,
262
244
  // revokeMount removes the run's Archil mount credential when the computer is released (and if a start fails after a mint);
263
245
  // the run's end revokes it too (below), so it goes on every outcome even when no computer is made. Idempotent. What
264
246
  // became of the agent's own computer (a persistent setting) is said on the run's timeline.
265
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, ...(archil ? { revokeMount: () => archil.revoke() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
247
+ // A person's stop ends the claim's waits at once: a first image pull or registration (Agent37's runs minutes) among them.
248
+ // Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer): a later
249
+ // claim's is a new one whatever ended the earlier claim (a lost runner, a server's stop, a park past its keep). The
250
+ // computer a park kept, attached again, brings its mount credential with it (inheritMount): none is minted.
251
+ { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, hadComputer: () => hadComputer(deps.journal(claim), context), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
266
252
  // The run's shell is its computer's (600 s) where one mounts its folder; with none, Archil's serverless exec in Mode 2
267
253
  // (295 s), and in Mode 1 none at all: no bash family, its folder being one of this server's own (run-tools.ts).
268
254
  // A desktop's or a phone's hold (the person's take-over) wraps its ports: a call made while the person holds it waits,
269
255
  // and the agent's hand-over (computer_request_handoff) asks the person through it.
270
256
  holds.hold({ computer });
271
- const loopComputer = loopComputerOf(computer.computer, computer.held);
257
+ const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
272
258
  const heldComputer = heldSpecOf(launch, loopComputer);
273
259
  // Under the agent's bash policy, its shell's environment is the policy's too (bash-read-only.ts policyEnv).
274
260
  const bashPolicy = bashPolicyOf(body.toolSettings);
275
- // pi's codemode is its script tool (codeMode): a code-only computer lists no computer_script beside it, and a
276
- // tools-only one gets no codemode (tools.computer is absent then).
277
- const tools = await runTools(ws.workspace, computer.computer, { mode, context, codeMode: true, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }) });
261
+ // The computer's tools are the run's own host tools, as on every harness: the host's codemode (meta-tools.ts) calls them
262
+ // as `tools.<name>`, each a nested call, gated and recorded as the model's own call is. A computer that replaced an
263
+ // earlier claim's holds its acts to what it showed.
264
+ const tools = await runTools(ws.workspace, computer.computer, { mode, context, ...(computer.hold ? { hold: computer.hold } : {}), ...(bashPolicy === undefined ? {} : { bashPolicy }), ...(computer.replaced ? { replaced: true } : {}) });
278
265
  holds.hold({ tools });
279
266
  // The run's model route: its model through routeOf (NEVER re-resolved — the launch's model, pinned at start), the catalog
280
267
  // price with tiers for the cap, and the proxy's price (pi-ai calculateCost, tiered).
@@ -291,6 +278,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
291
278
  // saved in Settings → Model keys runs the next run with no restart (withModelKeys).
292
279
  const modelEnv = withModelKeys(deps.env, toolEnv);
293
280
  const route = await deps.routeOf(modelAskOf(launch.model, body.model), modelEnv, "default", PI_WIRES, undefined, cut);
281
+ await planBeforeRun(modelEnv, route.provider.plan ? { provider: PLAN_PROVIDER } : undefined);
294
282
  // The run's models of other tiers, for its learned workflows' nodes of a tier (learnedTierRoutes, filled once the seed's
295
283
  // lay chose the workflows, below): read when the session opens (pi.ts options.tiers), each on a proxy of its own.
296
284
  const tierRoutes = new Map();
@@ -302,9 +290,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
302
290
  // (adapter-loop waitInClaim, the browser's personWait below). It stays out of this session's host tools: a CLI
303
291
  // harness gets the same tool as a host tool (cli-run-spec.ts), whose turn the loop cuts at the question.
304
292
  // - the browser's durable extension, when the run gets one (bindNonHandTools, below, before the session opens).
305
- // - pi's code mode, with a desktop or a phone (pi-computer.ts): the `codemode` tool beside the run's own, its scripts
306
- // with `computer` bound on the run's held port.
307
- const native = [...(granted.includes(ASK_TOOL) ? [defineExtension({ name: "ask_person", tools: [askPerson] })] : []), ...(tools.computer ? [computerCodemode(tools.computer)] : [])];
293
+ const native = granted.includes(ASK_TOOL) ? [defineExtension({ name: "ask_person", tools: [askPerson] })] : [];
308
294
  // pi-native tools in the session's own extension (PiAdapterOptions.tools): the subagent tool, pushed below.
309
295
  const piTools = [];
310
296
  // A run granted subagent (runner/subagent.ts): the model of each of its tiers, the revision's own (modelTiers) else the
@@ -357,10 +343,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
357
343
  // The gate names the run's folder by its Workspace (Mode 2: its folder on the run's disk, never this machine's folder at
358
344
  // the same path), for its path checks; it reads nothing in it.
359
345
  // A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf).
360
- const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcpServersOf(granted), { computerCodemode: Boolean(tools.computer), ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}) });
361
- // What a script's shell and files are held to: this gate's settings, decided as on the run's computer (gate.script), so a
362
- // denied bash or write holds inside computer_script and codemode.
363
- tools.computer?.guard.install(gate.script);
346
+ const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {});
364
347
  // The run's one cap, as the loop's runCap reads it (adapter-loop.ts RunCapConfig): the launch's cap figure (undefined
365
348
  // uncapped — every paid request still books through the one cap), the run's model priced WITH tiers, strict where the
366
349
  // launch says. The loop builds the kernel runCap from these over the run's own sessions (its model requests, its paid
@@ -378,9 +361,10 @@ async function adapterSpec(launch, run, deps, claim, holds) {
378
361
  const tierRoute = tierRoutes.get(by);
379
362
  return tierRoute && tierRoute.model === id ? capModelOf(tierRoute) : undefined;
380
363
  },
381
- ...(launch.capMode === "strict" ? { mode: "strict" } : {}),
382
364
  // What its learning runs' grades took beside it, read by every gate with its own sessions (none: it queues none).
383
365
  ...(besideOf ? { beside: besideOf } : {}),
366
+ // The most requests on free models it makes, capped or not (AGENTRUN_FREE_MODEL_REQUESTS).
367
+ freeRequests: freeModelRequestsOf(deps.env),
384
368
  };
385
369
  // The run's cap figure and what a refusal does to it (parkOf, with the kernel's raise rule): present only when the run
386
370
  // has a cap. A park names the cap the loop holds the run to then (a raise's, else this one).
@@ -405,8 +389,9 @@ async function adapterSpec(launch, run, deps, claim, holds) {
405
389
  const start = learningStartOf(launch);
406
390
  // The revision's own skills are laid in the run's .agents/skills/ before they are read (main's server start laid them;
407
391
  // on the one store the claim does), from the revision row's texts (the body keeps only each file's SHA-256): each
408
- // folder not there yet, never over a learned skill or an earlier claim's.
409
- await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: launch.computer?.kind });
392
+ // folder not there yet, never over a learned skill or an earlier claim's. A desktop or a phone (the revision's computer
393
+ // setting, the one computerForClaim starts) brings its kind's skill, named in the prompt beside the revision's own.
394
+ const kindSkills = await layOwnSkills(ws.workspace, (revisionRow.skills ?? {}), { computer: settingOfDefinition(body)?.computer.kind });
410
395
  // A learning run's seed, read once from its learning folder where the run's place keeps it: its notes in .learning/
411
396
  // and its learned skills beside the revision's own (runner/learning-seed.ts), cut of the server's secrets, the learned
412
397
  // skills then in the skill list the prompt names, its learned workflows the ones its learned_workflow tool runs. Laid
@@ -440,7 +425,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
440
425
  store: deps.store, agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, launch, context, log, folder: learningFolder, shown, sealKey: deps.sealKey,
441
426
  })), revision.body.outputSchema) : {};
442
427
  // A replay run runs only its revision, while it still replays: else its claim is refused (the run ends failed, no agent).
443
- await replayClaimed(deps.store, runRow.agentId, launch, firstChoice);
428
+ await replayClaimed(deps.store, runRow.agentId, claim.runId, launch, firstChoice);
444
429
  // A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
445
430
  // answered from that recording (runner/promotion.ts replayCallsFor, learn/replay-calls.ts).
446
431
  const replay = await replayCallsFor(deps.store, claim.runId, launch, context);
@@ -474,7 +459,8 @@ async function adapterSpec(launch, run, deps, claim, holds) {
474
459
  // spec builds too), on the claim's keys and the run's one ledger and redactor.
475
460
  // An agent whose computer is a browser the claim started gets the browser tool on that one session (tools.ts).
476
461
  const claimBrowser = computer.computer?.kind === "browser" ? computer.computer.browser : undefined;
477
- const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
462
+ const fakes = deps.evalFakes?.(runRow.agentId);
463
+ const host = { ...buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: cut, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}) }), ...(claimBrowser ? { browserComputer: claimBrowser } : {}) };
478
464
  // The run's tools. The hands (read/write/edit/bash and the background tools) are the kernel registry's over the run's
479
465
  // Workspace and computer (runTools.hostTools); the gate is the adapter loop's own (spec.gate), so they run as asked.
480
466
  const results = new Map();
@@ -486,7 +472,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
486
472
  gate.learn(workflows);
487
473
  // The run's monid endpoints (monid-run.ts), one host tool each from its revision's pin, on the claim's keys and beside
488
474
  // its MCP tools in the loop's one catalog seam; their answers pass the run's one redactor as the other non-hand tools'.
489
- const monid = monidForClaim(body.monidPin, toolEnv, () => ws.workspace, claim.runId);
475
+ const monid = monidForClaim(revisionRow.monidPin ?? undefined, toolEnv, () => ws.workspace, claim.runId, () => launch.maxCostUsd !== undefined, fakes?.monid);
490
476
  const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, cut)) });
491
477
  const nonHandTools = (await bindNonHandTools(host, revision.kind, granted, run, context, results, root, launch.plane, workflows, native, gate.permissions, tiers, catalog, () => route.model, replay)).map((tool) => answersCut(tool, cut));
492
478
  const sessionTools = [...handTools, ...nonHandTools];
@@ -498,9 +484,12 @@ async function adapterSpec(launch, run, deps, claim, holds) {
498
484
  // The one path for every harness.
499
485
  // A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
500
486
  const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section, start.use === true) : (body.instructions ?? "");
501
- const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
487
+ const instructions = await promptOf(laid, [...Object.keys(body.skills ?? {}), ...kindSkills, ...(seedLaid?.skills ?? [])], ws.workspace, { onDemand: readsFiles(granted) });
502
488
  const guidance = effortGuidance(launch.effort);
503
- const system = [environmentLine(), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line));
489
+ // The run's clock: a template eval case's (EvalFakes.now), else the real one.
490
+ const now = fakes?.now;
491
+ const zone = await runZone(deps.store, launch.inputOrigin);
492
+ const system = [environmentLine(now, zone), checkout?.note, instructions, outputContract(body.outputSchema), guidance].filter((line) => Boolean(line));
504
493
  // The subagent tool, one of the session's own tools (no extension of its own): a child's tools are a subset of the
505
494
  // revision's grants (each by its session name: an MCP tool's wire name, the browser's registrations), its model the
506
495
  // agent's own or one of the tiers resolved above.
@@ -508,7 +497,7 @@ async function adapterSpec(launch, run, deps, claim, holds) {
508
497
  const browserNames = native.filter((extension) => extension.name !== "ask_person").flatMap((extension) => (extension.tools ?? []).map((tool) => tool.name));
509
498
  piTools.push(subagentTool({
510
499
  granted,
511
- sessionNames: (catalog) => (catalog === BROWSER_TOOL ? browserNames : monidSessionNames(catalog, body.monidPin) ?? [wireName(catalog)]),
500
+ sessionNames: (grant) => (grant === BROWSER_TOOL ? browserNames : catalogSessionNames(catalog, grant)),
512
501
  tier: (tier) => {
513
502
  const why = tierWhy.get(tier);
514
503
  if (why !== undefined)
@@ -517,12 +506,13 @@ async function adapterSpec(launch, run, deps, claim, holds) {
517
506
  const at = tierRoutes.get(subagentRoute(tier));
518
507
  if (!at)
519
508
  return { ref: { provider: PORT_PROVIDER, modelId: route.model } };
520
- // A capped run never sends a request it cannot price: an unpriced tier refuses the call, and the run goes on.
521
- if (at.unpriced && launch.maxCostUsd !== undefined)
509
+ // A capped run never sends a request it cannot price: an unpriced tier refuses the call, and the run goes on. A
510
+ // ChatGPT plan's tier is not unpriced: it costs the run no dollars (capModelOf).
511
+ if (at.unpriced && !at.provider.plan && launch.maxCostUsd !== undefined)
522
512
  return { why: `${at.model} has no known price here, so this run's cost cap cannot hold its requests.` };
523
513
  return { ref: { provider: tierProvider(subagentRoute(tier)), modelId: at.model } };
524
514
  },
525
- preamble: environmentLine(),
515
+ preamble: environmentLine(now, zone),
526
516
  }));
527
517
  }
528
518
  // The level pi thinks at: the launch's effort (the run's own, else its revision's, else the host's), every level pi's
@@ -590,32 +580,37 @@ async function adapterSpec(launch, run, deps, claim, holds) {
590
580
  // The run's computer as the claim made it, with the person's hold on a desktop or phone: the loop shows the hold up,
591
581
  // applies a take-over and a hand-back to it, and answers the computer call channel's rows on it.
592
582
  ...(loopComputer ? { computer: loopComputer } : {}),
583
+ // A desktop or a phone as a codemode script gets it: the script's `computer`, over the run's computer tools.
584
+ ...(tools.computer ? { scriptComputer: tools.computer } : {}),
585
+ // A computer that replaced an earlier claim's: the model is told once, on its next request (the loop's computer note).
586
+ ...(computer.replaced ? { computerNote: computerReplacedNote(computer.replaced) } : {}),
593
587
  workRoot: root,
594
- // The end's metrics and cost, from the run's journal, as the old per-run end path read them (metrics.ts runMetrics =
595
- // runs.ts storedMetrics/costOf). A pi run adds its effort, no model (metrics.ts).
588
+ // The end's cost: its booking's, by the one rule every reader of an ended run's cost takes (metrics.ts runCostOf):
589
+ // every model request its session's proxy booked (pi's own answers and its side calls: a learned workflow's nodes,
590
+ // web_search's hosted search with its fee), its paid tool calls (a Parallel search's, a monid call's, a person's
591
+ // browser time, each booked in its own session) and its decisions (a learned workflow's decision nodes, LS-07; one
592
+ // that reported none is unknown, never the cap's hold for it). A request a cancel or a stop cut while it streamed is
593
+ // booked at no known cost (the provider may bill what it streamed), so the run's cost is unknown, never the $0 its cut
594
+ // answer carries. One cheap read, apart from the metrics below, so metrics that run late never take the cost with them.
595
+ endCost: async () => endCostOf(runCostOf((await journalEntries(deps.journal(claim), context)))),
596
+ // The end's metrics, from the run's journal, as the old per-run end path read them (metrics.ts runMetrics =
597
+ // runs.ts storedMetrics). A pi run adds its effort, no model (metrics.ts).
596
598
  endPatch: async () => {
597
599
  // The root's entries and every conversation a task of the run owns (a subagent's): a child's requests are the run's.
598
600
  const entries = await agentEntriesOf(deps.journal(claim), context);
599
601
  // The path it took and the learned revision it ran on, for a run that learns (workflow-first.ts pathMetrics), by the
600
602
  // one classifier the cost per run reads back (runPathOverStore).
601
603
  const path = pathMetrics(launch, launch.learning ? await runPathOverStore(deps.store, claim.runId, launch.learning, run.redact) : undefined, entries);
602
- // Its cost is its booking's, as a CLI run's is (metrics.ts bookedSpend, the one reader): every model request its
603
- // session's proxy booked, pi's own answers and its side calls (a learned workflow's nodes, web_search's hosted search
604
- // with its fee) alike, and its decisions (a learned workflow's decision nodes, LS-07; one that reported none is
605
- // unknown, never the cap's hold for it). A request a cancel or a stop cut while it streamed is booked at no known cost
606
- // (the provider may bill what it streamed), so the run's cost is unknown, never the $0 its cut answer carries.
607
- const all = (await journalEntries(deps.journal(claim), context));
608
- const booked = bookedSpend(all, "model");
609
- // Its paid tool calls (a Parallel search's, a monid call's, a person's browser time), booked on the run's one ledger
610
- // (each on its cap, in its own session, not on the root), are the run's cost too; any part unknown leaves the run's unknown.
611
- const total = runEndCost({ model: booked.usd, paid: run.ledger?.paid ? run.ledger.paid.spentUsd() : 0, decisions: bookedSpend(all, "decisions").usd });
612
604
  // A run its learned workflow served first: that call is on the loop's record (no pi answer carries its tokens), so its
613
605
  // metrics are its booking's, as a CLI harness's run reads them: the workflow's nodes and the agent's own after a handback.
606
+ // An MCP tool called by a hashed wire name is counted under its catalog name, as its timeline names it.
607
+ const catalog = await hashedMcpOf(deps.store, claim.runId);
614
608
  const { metrics } = servedOf(entries)
615
- ? { metrics: cliRunMetrics(piShaped(entries), booked, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), model: launch.model ? `${launch.model.provider}/${launch.model.modelId}` : route.model }) }
616
- : runMetrics(entries, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}) });
617
- // An unknown cost is written as null, never left out: a follow-up's end clears the cost an earlier end stored.
618
- return { costUsd: total, metrics: { ...metrics, ...path } };
609
+ ? { metrics: cliRunMetrics(piShaped(entries), bookedSpend((await journalEntries(deps.journal(claim), context)), "model"), { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), model: launch.model ? `${launch.model.provider}/${launch.model.modelId}` : route.model, catalog }) }
610
+ : runMetrics(entries, { ...(launch.effort !== undefined ? { effort: launch.effort } : {}), catalog });
611
+ // Its cost is endCost's, read apart (an unknown one written as null, never left out: a follow-up's end clears the
612
+ // cost an earlier end stored).
613
+ return { metrics: { ...metrics, ...path } };
619
614
  },
620
615
  // A run started with hold: true holds its computer for its owner (computer-held.ts): the loop waits for their start
621
616
  // and release, and runs their calls on it.
@@ -624,7 +619,11 @@ async function adapterSpec(launch, run, deps, claim, holds) {
624
619
  // scratch swept), its computer let go, then its Workspace's end (Mode 2 sweeps the exec spill).
625
620
  // The run's Archil mount credential is revoked at its end on every outcome, even with no computer (the computer's
626
621
  // release revokes it too; revoke is idempotent, so a second call is a no-op). A run that minted none revokes nothing.
627
- release: () => holds.release(),
622
+ // At a park, a desktop or a phone is kept for the resume instead (spec-holds.ts SpecHolds.release `parked`), its mount
623
+ // credential with it, and the run's timeline is told so.
624
+ ...(computer.keeps ? { keptWords: computerKeptWords(computer.keeps) } : {}),
625
+ release: (how) => holds.release(how),
626
+ endCheckout: () => holds.endCheckout(),
628
627
  };
629
628
  }
630
629
  /** The host-tool ctx a non-hand tool is wrapped with (host-tools.ts hostToolOf): the run's own Harness (its commit,
@@ -699,7 +698,12 @@ export async function learnedWorkflowHostTool(opts) {
699
698
  return undefined;
700
699
  const flows = opts.workflows;
701
700
  const tiers = opts.tiers ?? new Map();
702
- const mcpTools = (opts.mcp?.tools ?? []).map((one) => opts.mcp.catalogOf(one.name)).filter((name) => typeof name === "string");
701
+ // Each MCP tool of the run by its catalog name, to the name the session's tools hold it by: what an MCP node calls,
702
+ // nested in the workflow's call.
703
+ const mcpTools = new Map((opts.mcp?.tools ?? []).flatMap((one) => {
704
+ const catalog = opts.mcp.catalogOf(one.name);
705
+ return typeof catalog === "string" ? [[catalog, one.name]] : [];
706
+ }));
703
707
  const byProvider = new Map([[PORT_PROVIDER, await opts.run.ledger.models(LEARNED_WORKFLOW_TOOL)]]);
704
708
  for (const [tier, model] of tiers)
705
709
  if ("model" in model)
@@ -718,8 +722,28 @@ export async function learnedWorkflowHostTool(opts) {
718
722
  const providers = await decisionProvidersIn(opts.env);
719
723
  const decisions = providers ? { decisions: { providers, book: opts.run.ledger.decisions, pause: (refusal) => opts.run.ledger.pause(refusal) } } : {};
720
724
  // A call node's native web_search goes through the session's port too, labelled web_search, as the run's own does.
721
- const tool = learnedWorkflowTool({ workflows: flows, granted: opts.granted, ...(opts.plane ? { plane: opts.plane } : {}), env: opts.env, work: opts.work, models: tieredModels(byProvider), modelOf, search: () => opts.run.ledger.models(WEB_SEARCH_TOOL), policy: opts.permissions.policy, denyFrom: opts.permissions.denyFrom, refresh: opts.permissions.refresh, decide: opts.permissions.decide, mcpTools, ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}), ...(opts.replay ? { replay: opts.replay } : {}) });
722
- return hostToolOf(LEARNED_WORKFLOW_TOOL, tool, opts.ctx) ?? undefined;
725
+ const tool = learnedWorkflowTool({ workflows: flows, granted: opts.granted, ...(opts.plane ? { plane: opts.plane } : {}), env: opts.env, work: opts.work, models: tieredModels(byProvider), modelOf, search: () => opts.run.ledger.models(WEB_SEARCH_TOOL), policy: opts.permissions.policy, denyFrom: opts.permissions.denyFrom, refresh: opts.permissions.refresh, mcpTools, nestedOf: (callId) => nestedBy.get(callId), ...decisions, ...(opts.workspace ? { workspace: opts.workspace } : {}), ...(opts.modelName ? { modelName: opts.modelName } : {}), ...(opts.replay ? { replay: opts.replay } : {}) });
726
+ const host = hostToolOf(LEARNED_WORKFLOW_TOOL, tool, opts.ctx);
727
+ if (!host)
728
+ return undefined;
729
+ // The tool nests calls (HostTool.nests): its MCP nodes are the session's tools called nested in it, which the harness
730
+ // hands each call (`nested`), each asked at the gate and recorded as its own; it runs again whole after a park or a
731
+ // crash, each node answered as it was the first time.
732
+ const nestedBy = new Map();
733
+ return {
734
+ ...host,
735
+ nests: true,
736
+ async call(args, context) {
737
+ if (context.nested)
738
+ nestedBy.set(context.callId, context.nested);
739
+ try {
740
+ return await host.call(args, context);
741
+ }
742
+ finally {
743
+ nestedBy.delete(context.callId);
744
+ }
745
+ },
746
+ };
723
747
  }
724
748
  /** The run's non-hand tools as HostTool[], bound through the ToolHost seam and wrapped as the hands are (host-tools.ts
725
749
  * hostToolOf): web_fetch, web_search and monid, each by its catalog name under the adapter loop's one gate (`spec.gate`;
@@ -738,14 +762,16 @@ export function liveViewersOf(store, sealKey, claim, cut) {
738
762
  drop: (tag) => dropLiveViewer(store, claim, tag),
739
763
  };
740
764
  }
741
- /** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). */
765
+ /** `tool` with its answer's text, and a throw's message, cut by `cut` (the run's one redactor). A web call's answer is cut
766
+ * string by string inside its JSON (timeline/web-calls.ts webCut), so what the harness stores still parses and keeps
767
+ * its links whole for a grader's link check. */
742
768
  export function answersCut(tool, cut) {
743
769
  return {
744
770
  ...tool,
745
771
  call: async (args, context) => {
746
772
  try {
747
773
  const answer = await tool.call(args, context);
748
- return { ...answer, text: cut(answer.text) };
774
+ return { ...answer, text: webCut(tool.name, answer.text, cut) ?? cut(answer.text) };
749
775
  }
750
776
  catch (error) {
751
777
  if (error instanceof Error) {
@@ -768,7 +794,11 @@ export function answersCut(tool, cut) {
768
794
  export function buildToolHost(opts) {
769
795
  const liveAt = runnerLiveOf(opts.env, opts.sealKey);
770
796
  const { root, claim, run, life } = opts;
797
+ const { web, now, email } = opts.fakes ?? {};
771
798
  return {
799
+ ...(web ? { web } : {}),
800
+ ...(now ? { now } : {}),
801
+ ...(email ? { emailFake: email } : {}),
772
802
  // The run's directory and its per-claim environment: the hands come from runTools, so the non-hand tools get the run's
773
803
  // environment only.
774
804
  where: { root, work: root, ref: { id: claim.runId } },
@@ -798,6 +828,9 @@ export function buildToolHost(opts) {
798
828
  // What a tool files for the run's read (monid's whole answer past the model's cut) goes in the run's own Workspace, the
799
829
  // one its hands read: in Mode 2 its folder on the run's disk, never the local folder at `root`.
800
830
  workspace: opts.workspace,
831
+ // The trigger that started the run, and the agent's own settings: an email's run reads its thread alone (email/tools.ts).
832
+ ...(opts.launch?.trigger && opts.launch.inputOrigin?.kind === "trigger" ? { startedBy: { trigger: opts.launch.trigger, source: opts.launch.inputOrigin.source } } : {}),
833
+ ...(opts.toolSettings !== undefined ? { toolSettings: opts.toolSettings } : {}),
801
834
  };
802
835
  }
803
836
  /** The run's web host tools (tool-list.ts `host` rows: web_fetch, web_search, monid) as HostTool[], each bound through `host` by its
@@ -3,6 +3,7 @@ import type { Models } from "@earendil-works/pi-ai";
3
3
  import { type Extension, type Harness, type Registry, type ToolRegistration } from "@earendil-works/pi-durable";
4
4
  import { type AgentAdapter, type SessionIO, type SessionPort, type Wire } from "@parcha/agentrun-kernel";
5
5
  import { type ModelProxy, type ProviderPolicy } from "@parcha/agentrun-kernel/host";
6
+ import { type ThinkingLevelMap } from "../../port-models.js";
6
7
  import { type CallStatus } from "../journal-kinds.js";
7
8
  import { CALL_REFUSED } from "../../timeline/index.js";
8
9
  import { type ComputerCallRecord } from "../../computer-calls.js";
@@ -57,6 +58,8 @@ export interface PiAdapterOptions {
57
58
  readonly credential: () => string | Promise<string>;
58
59
  readonly headers?: Readonly<Record<string, string>>;
59
60
  readonly auth?: "bearer" | "x-api-key";
61
+ readonly plan?: boolean;
62
+ readonly refused?: (credential: string) => Promise<void>;
60
63
  };
61
64
  /** The model pi asks for. */
62
65
  readonly model: string;
@@ -67,6 +70,8 @@ export interface PiAdapterOptions {
67
70
  readonly maxTokens?: number;
68
71
  readonly input?: readonly string[];
69
72
  readonly inputLimits?: unknown;
73
+ readonly developerRole?: boolean;
74
+ readonly thinkingLevelMap?: ThinkingLevelMap;
70
75
  };
71
76
  /** The price of a request's usage, for the proxy's booking. */
72
77
  readonly price?: (model: string, usage: never) => number | null;
@@ -95,6 +100,13 @@ export interface PiAdapterOptions {
95
100
  * requests are the run's, under its one cap, each priced at its own model. Reached through `port(label, tier)`. */
96
101
  readonly tiers?: ReadonlyMap<string, TierModel>;
97
102
  }
103
+ /** The input tokens pi (the @earendil-works/pi-* 1.5.2 packages serve pins) sends in a run's first model request before
104
+ * the agent's own prompt: pi writes no system prompt of its own, so it is serve's (the environment line and the wrapper
105
+ * around the agent's instructions) and the host's code mode tool, which every run is offered, with no tool granted.
106
+ * Counted with o200k_base on the first request a run sent through its spec to a scripted provider on gpt-6.1-sol, 286
107
+ * tokens, stated at 280 so its date line never puts it over (test/cap-save-warning.test.mjs keeps it at or under that
108
+ * count). A save under a cap prices a least step on it (cap-short.ts). */
109
+ export declare const PI_BASE_INPUT_TOKENS = 280;
98
110
  /** pi as an AgentAdapter for one claim's run. */
99
111
  export declare function piAdapter(options: PiAdapterOptions): AgentAdapter;
100
112
  /** A tier's model as its proxy takes it: its route's provider, model, catalog entry, price and fetch (model-route.ts). */
@@ -125,6 +137,18 @@ export declare function piPolicy(model: string, tools: readonly string[], auth?:
125
137
  * request. `webSearch`: the run's web_search is the provider's hosted search, whose one tool each wire's policy admits
126
138
  * as its CLI's own search (claude-agent's on Messages, codex's live search on Responses). */
127
139
  export declare function policyFor(provider: PiAdapterOptions["provider"], model: string, tools: readonly string[], webSearch?: boolean): Promise<ProviderPolicy>;
140
+ /** The reasoning settings of the first request a pi session on `route` sends at thinking `level` (the run's effort; none,
141
+ * pi's default): on Messages its `thinking` block (budgeted where the session's model reasons, which puts Claude's
142
+ * thinking minimum in its least output) and any `output_config`, on Responses its `reasoning`. Read from the body pi-ai
143
+ * builds for the session's own model (sessionOn's, at the same level), which is never sent: its payload hook stops it
144
+ * before any request. A save under a cap prices its least output on these (cap-short.ts). */
145
+ export declare function piReasoningOf(route: {
146
+ readonly provider: {
147
+ readonly api: Wire;
148
+ };
149
+ readonly model: string;
150
+ readonly like?: PiAdapterOptions["like"];
151
+ }, level: string | undefined): Promise<Record<string, unknown>>;
128
152
  /** A refused call's words by call (the gate's deny, main's words), held from the refusal (beforeTool's block) to the
129
153
  * call's result (afterTool): a blocked result becomes those words alone, an error, as main gives a refused call's
130
154
  * result, never pi's framing of a blocked call. Every other result is pi's own. `held`: the words still held. */