@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
@@ -42,7 +42,8 @@ export type LedgerRefusal = Refusal;
42
42
  /** The kernel cap's booking of a run's paid calls (RunTools), as a paid request uses it. */
43
43
  export type PaidBooking = {
44
44
  /** `chargedBy`: who charges for it (the charge's `charged_by` on main's records: parallel, monid, an MCP server, a
45
- * browser vendor), named on its runner.request. */
45
+ * browser vendor), named on its runner.request. `under`: the model session whose tool call it runs in (RunTools.admit),
46
+ * whose requests in flight it is judged beside and never waits on. */
46
47
  admit(request: {
47
48
  id: string;
48
49
  name: string;
@@ -55,6 +56,7 @@ export type PaidBooking = {
55
56
  owed?: true;
56
57
  hold?: true;
57
58
  ref?: string;
59
+ under?: string;
58
60
  }): Promise<unknown>;
59
61
  /** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
60
62
  settle(id: string, usd: number | null, options?: {
@@ -78,6 +80,8 @@ export declare const bookedIn: <T>(ledger: Ledger | undefined, work: () => Promi
78
80
  * less. It throws PaidRefused, in the cap's words, when the cap does not hold its price, when its hold could not be kept,
79
81
  * or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
80
82
  export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Promise<Response>;
83
+ /** paidStep's chargeOf for a step that charged nothing and is given back: its mark settled with no charge row. */
84
+ export declare const GIVEN_BACK = "given back";
81
85
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
82
86
  export declare const paidLedger: () => PaidBooking | undefined;
83
87
  /** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
@@ -86,7 +90,8 @@ export declare const paidLedger: () => PaidBooking | undefined;
86
90
  * request reads as the cap's refusal (no model error row of its own). */
87
91
  export declare const stopRun: (words: string) => Promise<void>;
88
92
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
89
- * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
93
+ * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold; GIVEN_BACK:
94
+ * given back, nothing charged, as a hold-only step's: a request its provider refused unrun leaves no charge row). One refused
90
95
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
91
96
  * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
92
97
  export declare function paidStep<T>(paid: PaidBooking, call: string | undefined, fee: {
@@ -103,7 +108,7 @@ export declare function paidStep<T>(paid: PaidBooking, call: string | undefined,
103
108
  result: T;
104
109
  } | {
105
110
  thrown: unknown;
106
- }) => number | null, pause?: Ledger["pause"]): Promise<{
111
+ }) => number | null | typeof GIVEN_BACK, pause?: Ledger["pause"]): Promise<{
107
112
  refused: string;
108
113
  } | {
109
114
  result: T;
@@ -97,6 +97,8 @@ export async function paidRequest(fee, send) {
97
97
  throw new PaidRefused(stepped.refused);
98
98
  return stepped.result;
99
99
  }
100
+ /** paidStep's chargeOf for a step that charged nothing and is given back: its mark settled with no charge row. */
101
+ export const GIVEN_BACK = "given back";
100
102
  /** Each paid request of this process on the run's one ledger, numbered within its call (one call may make several). */
101
103
  let paidSeq = 0;
102
104
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
@@ -109,7 +111,8 @@ export const stopRun = async (words) => {
109
111
  await ledgers.getStore()?.pause?.({ refuse: words, code: SPEND_CAP_REACHED, forGood: true });
110
112
  };
111
113
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
112
- * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
114
+ * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold; GIVEN_BACK:
115
+ * given back, nothing charged, as a hold-only step's: a request its provider refused unrun leaves no charge row). One refused
113
116
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
114
117
  * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
115
118
  export async function paidStep(paid, call, fee, run, chargeOf, pause) {
@@ -133,7 +136,8 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
133
136
  outcome = { thrown };
134
137
  }
135
138
  // A hold-only step (`hold`) is given back, never a charge: its money is booked by its own charges' steps.
136
- await (fee.hold ? paid.settle(id, 0, { givenBack: true }) : paid.settle(id, chargeOf(outcome))).catch(() => undefined);
139
+ const charge = fee.hold ? GIVEN_BACK : chargeOf(outcome);
140
+ await (charge === GIVEN_BACK ? paid.settle(id, 0, { givenBack: true }) : paid.settle(id, charge)).catch(() => undefined);
137
141
  if ("thrown" in outcome)
138
142
  throw outcome.thrown;
139
143
  return outcome;
@@ -1,14 +1,9 @@
1
- /** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
2
- * its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
3
- * list is narrowed to none (workspace/computer-deps.ts networkOf). */
4
- export declare const remoteNoList: (id: "daytona" | "modal") => string;
5
1
  /** Every box a place may name, in the order capabilities lists them. */
6
2
  export declare const BOX_IDS: readonly ["docker", "modal", "daytona"];
7
3
  export type BoxId = (typeof BOX_IDS)[number];
8
4
  /** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
9
5
  * capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
10
- * `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere; a remote box, whose
11
- * computer is never made with a host list). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
6
+ * `network_reason` when it is available and has none for a cause of its own (a daemon elsewhere). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
12
7
  * its computers' egress proxy refuses as the host's (docker-host-addresses.ts: the read through the socket and
13
8
  * AGENTRUN_DOCKER_HOST_ADDRESSES). */
14
9
  export type BoxOffer = {
@@ -87,8 +82,9 @@ export declare function placeOffers(env: NodeJS.ProcessEnv, options?: PlaceOffer
87
82
  /** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
88
83
  * computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
89
84
  * runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
90
- * (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
91
- * (remoteNoList). With `allow` none, none has a network. */
85
+ * (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's through the
86
+ * egress proxy their computer's init starts (an allowlist too: @parcha/agentrun-computer's hosted/network.ts). With
87
+ * `allow` none, none has a network. */
92
88
  export declare function withNetworks(offers: readonly BoxOffer[], allow: readonly string[] | "none", docker?: {
93
89
  refused?: string;
94
90
  hostAddresses?: readonly string[];
@@ -14,10 +14,6 @@ import { readFile } from "node:fs/promises";
14
14
  import { userInfo } from "node:os";
15
15
  import { PROVIDERS } from "@parcha/agentrun-computer";
16
16
  import { withoutSecrets } from "./secrets.js";
17
- /** Why a remote box (Daytona's, Modal's) has no network, said in capabilities whenever the server's host list is set:
18
- * its computer is made with no network (Daytona) or no network or an open one (Modal), never with a host list, so a
19
- * list is narrowed to none (workspace/computer-deps.ts networkOf). */
20
- export const remoteNoList = (id) => `a ${id === "daytona" ? "Daytona" : "Modal"} computer is never made with a host list, so a ${id} box has no network`;
21
17
  /** Every box a place may name, in the order capabilities lists them. */
22
18
  export const BOX_IDS = ["docker", "modal", "daytona"];
23
19
  /** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
@@ -180,8 +176,9 @@ export async function placeOffers(env, options = {}) {
180
176
  /** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
181
177
  * computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
182
178
  * runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
183
- * (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's none
184
- * (remoteNoList). With `allow` none, none has a network. */
179
+ * (box-paths.ts dockerComputerRefusal, docker-host-addresses.ts noHostAddresses); Daytona's and Modal's through the
180
+ * egress proxy their computer's init starts (an allowlist too: @parcha/agentrun-computer's hosted/network.ts). With
181
+ * `allow` none, none has a network. */
185
182
  export function withNetworks(offers, allow, docker = {}) {
186
183
  return offers.map((offer) => {
187
184
  if (!offer.available)
@@ -195,8 +192,6 @@ export function withNetworks(offers, allow, docker = {}) {
195
192
  return { ...offer, network: "none", network_reason: "AGENTRUN_BOX_ALLOW is none" };
196
193
  return { ...offer, network: "allowlist", ...(docker.hostAddresses?.length ? { host_addresses: [...docker.hostAddresses] } : {}) };
197
194
  }
198
- if (allow === "none" || (offer.id !== "daytona" && offer.id !== "modal"))
199
- return { ...offer, network: "none" };
200
- return { ...offer, network: "none", network_reason: remoteNoList(offer.id) };
195
+ return { ...offer, network: allow === "none" ? "none" : "allowlist" };
201
196
  });
202
197
  }
@@ -10,11 +10,19 @@ export declare const tierProvider: (tier: string) => string;
10
10
  * base; OpenAI's adds /responses to a base that holds /v1. The one rule for the port's models and pi's own (runner
11
11
  * adapters/pi.ts). */
12
12
  export declare const sessionBaseUrl: (api: SessionPort["api"], url: string) => string;
13
+ /** The effort a model asks for at each thinking level, as pi-ai's catalog says (null: no effort sent). */
14
+ export type ThinkingLevelMap = NonNullable<Model<Api>["thinkingLevelMap"]>;
13
15
  /** The catalog's entry for a session's model, as its route carries it (model-route.ts `like`): its reasoning, price,
14
- * window and ceiling, and what it takes as input with its input limits. */
15
- export type SessionLike = Partial<Pick<Model<Api>, "reasoning" | "cost" | "contextWindow" | "maxTokens">> & {
16
+ * window and ceiling, the effort each thinking level asks for, and what it takes as input with its input limits. */
17
+ /** `developerRole`: on Responses, the instructions go as a developer message, not a system one (a ChatGPT plan's route,
18
+ * which takes no system message). `adaptiveThinking`: on Messages, the session asks its thinking level as an adaptive
19
+ * effort (pi-ai's `forceAdaptiveThinking`), never a token budget: the route's own translation reads that level back
20
+ * (model-route.ts LEVELS_BY_NAME). */
21
+ export type SessionLike = Partial<Pick<Model<Api>, "reasoning" | "cost" | "contextWindow" | "maxTokens" | "thinkingLevelMap">> & {
16
22
  readonly input?: readonly string[];
17
23
  readonly inputLimits?: unknown;
24
+ readonly developerRole?: boolean;
25
+ readonly adaptiveThinking?: boolean;
18
26
  };
19
27
  /** The one model of a session's route as pi-ai lists it, for the port's requests and for pi's own (runner adapters/pi.ts):
20
28
  * `model` in `api` at the proxy `url` (sessionBaseUrl), under `provider`, with `headers` (the session key as the proxy
@@ -24,11 +24,15 @@ export function sessionModel(api, url, model, options) {
24
24
  // What the model takes as input and its input limits, as the catalog says (the route's `like`): a model that takes no
25
25
  // images is sent pi-ai's placeholder in place of one, and pi's read holds an image to its limits. Unsaid, text and
26
26
  // images within pi's defaults.
27
- reasoning: like?.reasoning ?? options.reasoning, input: like?.input ? [...like.input] : ["text", "image"],
27
+ // The effort each thinking level asks for, as the catalog says: a level it maps to null sends none, so pi's thinking
28
+ // off sends no "none" to a model that refuses it (gpt-6.1-sol). Unsaid, pi-ai's defaults.
29
+ reasoning: like?.reasoning ?? options.reasoning, ...(like?.thinkingLevelMap ? { thinkingLevelMap: like.thinkingLevelMap } : {}),
30
+ input: like?.input ? [...like.input] : ["text", "image"],
28
31
  ...(like?.inputLimits ? { inputLimits: like.inputLimits } : {}),
29
32
  cost: like?.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
30
33
  contextWindow: like?.contextWindow ?? 200_000, maxTokens: like?.maxTokens ?? 32_000,
31
- ...(api === "openai-responses" ? { compat: { supportsDeveloperRole: false } } : {}),
34
+ ...(api === "openai-responses" ? { compat: { supportsDeveloperRole: like?.developerRole === true } } : {}),
35
+ ...(api === "anthropic-messages" && like?.adaptiveThinking ? { compat: { forceAdaptiveThinking: true } } : {}),
32
36
  };
33
37
  }
34
38
  /** pi-ai's provider for the one model of a session's proxy on its wire: pi-ai's client of `api` (Anthropic's Messages or
package/dist/print.d.ts CHANGED
@@ -21,8 +21,9 @@ export declare function banner(o: {
21
21
  /** One log line. */
22
22
  export declare const logLine: (event: string, fields?: Record<string, string | number>) => string;
23
23
  /** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
24
- * first claim, `run_ended` (run, agent, status, cost_usd) once it is final. Any other event has none. Ids and numbers
25
- * only: no token or secret reaches a line. */
24
+ * first claim, `run_ended` (run, agent, status, cost_usd) once it is final: `cost_usd` the exact cost or "unknown", and
25
+ * beside an unknown one `cost_usd_at_most` when the run's stored cost is the most it can have cost. Any other event has
26
+ * none. Ids and numbers only: no token or secret reaches a line. */
26
27
  export declare function runLine(event: {
27
28
  type: string;
28
29
  runId?: string;
@@ -30,6 +31,7 @@ export declare function runLine(event: {
30
31
  kind?: string;
31
32
  status?: string;
32
33
  costUsd?: number | null;
34
+ costAtMostUsd?: number;
33
35
  }): string | undefined;
34
36
  /** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
35
37
  export declare function durationMs(text: string): number | undefined;
package/dist/print.js CHANGED
@@ -26,13 +26,14 @@ const value = (v) => {
26
26
  /** One log line. */
27
27
  export const logLine = (event, fields = {}) => [`at=${new Date().toISOString()}`, `event=${event}`, ...Object.entries(fields).map(([k, v]) => `${k}=${value(v)}`)].join(" ");
28
28
  /** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
29
- * first claim, `run_ended` (run, agent, status, cost_usd) once it is final. Any other event has none. Ids and numbers
30
- * only: no token or secret reaches a line. */
29
+ * first claim, `run_ended` (run, agent, status, cost_usd) once it is final: `cost_usd` the exact cost or "unknown", and
30
+ * beside an unknown one `cost_usd_at_most` when the run's stored cost is the most it can have cost. Any other event has
31
+ * none. Ids and numbers only: no token or secret reaches a line. */
31
32
  export function runLine(event) {
32
33
  if (event.type === "started")
33
34
  return logLine("run_started", { run: event.runId, agent: event.agent, kind: event.kind });
34
35
  if (event.type === "ended")
35
- return logLine("run_ended", { run: event.runId, agent: event.agent, status: event.status === "ended" ? "completed" : event.status, cost_usd: event.costUsd ?? "unknown" });
36
+ return logLine("run_ended", { run: event.runId, agent: event.agent, status: event.status === "ended" ? "completed" : event.status, cost_usd: event.costUsd ?? "unknown", ...(event.costAtMostUsd !== undefined ? { cost_usd_at_most: event.costAtMostUsd } : {}) });
36
37
  return undefined;
37
38
  }
38
39
  /** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
package/dist/propose.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { DraftAsk } from "./learn/skills.js";
2
1
  import { type Problem } from "./learn/index.js";
3
2
  import type { DraftDecisions } from "./learn/skills.js";
4
3
  import { type Turn } from "./learning.js";
@@ -46,8 +45,8 @@ export declare const proposeRun: (input: {
46
45
  tools?: readonly string[];
47
46
  gated?: Readonly<Record<string, string>>;
48
47
  deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
49
- ask?: DraftAsk;
50
48
  decisions?: DraftDecisions;
49
+ workflowAdapters?: readonly ("runNode" | "runJudge")[];
51
50
  workflows?: false;
52
51
  outputSchema?: unknown;
53
52
  }) => Promise<Proposed>;
package/dist/propose.js CHANGED
@@ -1,3 +1,12 @@
1
+ // Learning, after a run: the notes its end-of-run turn answered with, and a skill or a workflow draft beside them, are read
2
+ // by the host (learn/reflect.ts parseReflection), checked against the commit the run started from (learn/check.ts
3
+ // checkProposal), and kept as its proposal (`learning-proposal.json`, in the directory the caller gives), or dropped. The
4
+ // answer is what the runner's end-of-run turn read from the run's store (runner/learning-end.ts), never the run's work;
5
+ // and no file the run wrote is read at all, in `.learning/` or anywhere. The seed is
6
+ // read from the agent's learning folder through its Workspace, as the reflect hook's check reads it (learn/seed-check.ts):
7
+ // the snapshot and its bodies when main is the seed (no exec), else one read-only exec of the learning script at that
8
+ // commit. Nothing is written to git here, and nothing is written at all before the checks pass: what they refuse (a
9
+ // note holding a secret among them) is never kept anywhere.
1
10
  import { join } from "node:path";
2
11
  import { checkProposal, draftDryRun, draftFiles, NOTE_BLOCK, unstorable, parseReflection, redactSecrets, shortMessage, SKILL_BLOCK, SKILLS_DIR, WORKFLOW_BLOCK, WORKFLOWS_DIR } from "./learn/index.js";
3
12
  import { folderAt, readLearning, readSnapshot } from "./learn/folder.js";
@@ -150,7 +159,7 @@ export const proposeRun = async (input) => {
150
159
  return { state: "dropped", reason: "checker", problems: leaky };
151
160
  // A skill or a draft whose seed text has a status is a person's call (retired, or waiting for their OK): never changed.
152
161
  const dryRuns = {};
153
- const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(input.decisions ? { decisions: input.decisions } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
162
+ const check = (some) => checkProposal({ workflowAdapters: input.workflowAdapters, base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.decisions ? { decisions: input.decisions } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
154
163
  // The static checks first, every one (validateWorkflow with executeCode: false, draftProblems' refusal of code nodes,
155
164
  // caps, secrets): a draft they refuse is never dry-run, nor is any when they refuse the answer whole. Then each draft
156
165
  // left is dry-run on its example, else on a synthesized input (learn/skills.ts draftDryRun): every model and tool
@@ -51,12 +51,16 @@ export declare function anthropicModelId(model: ModelRef): string;
51
51
  * path), its key, read per request, how the endpoint takes it, the model id sent, and the catalog entry that prices it.
52
52
  * `who`: the harness, for a refusal's words. Throws a HarnessUnavailable where the run cannot go: a model of another
53
53
  * vendor, a key that is not set (its `keys` name the ones that would fix it), or an endpoint a key may not go to. */
54
+ /** `billing: "plan"`: a ChatGPT plan's route (chatgpt-plan.ts), billed to the plan, never priced here; its credential is
55
+ * the plan's token, asked at each request, and `refused` tells the plan OpenAI answered 401 to one it sent. */
54
56
  export type Provider = {
55
57
  origin: string;
56
- credential: () => string;
58
+ credential: () => string | Promise<string>;
57
59
  auth: "bearer" | "x-api-key";
58
60
  modelId: string;
59
61
  priceModel: ModelRef;
62
+ billing?: "plan";
63
+ refused?: (credential: string) => Promise<void>;
60
64
  };
61
65
  export declare function providerFor(wire: Wire, env: NodeJS.ProcessEnv, model: ModelRef, who: string): Provider;
62
66
  /** The catalog entry a run on `wire` of `model` is capped and priced by: providerFor's, or the model's own (normalized)
package/dist/provider.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { chooseModel, FAUX_ENV, hostModel, MODEL_PROVIDER } from "./model.js";
2
2
  import { WIRES } from "./wires.js";
3
3
  import { modelFormWhy } from "./model-form.js";
4
+ import { EXPIRED, PLAN_ORIGIN, PLAN_PROVIDER, planOf, SIGNED_OUT } from "./chatgpt-plan.js";
4
5
  // Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
5
6
  export { WIRES };
6
7
  /** Why this server cannot run a harness here, in words a person can act on; `fix`, when installing is the fix; `keys`,
@@ -117,6 +118,13 @@ export function providerFor(wire, env, model, who) {
117
118
  throw env.ANTHROPIC_BASE_URL ? new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY.`, undefined, ["ANTHROPIC_API_KEY"]) : new HarnessUnavailable(`${who} needs ANTHROPIC_API_KEY or OPENROUTER_API_KEY.`, undefined, ["ANTHROPIC_API_KEY", "OPENROUTER_API_KEY"]);
118
119
  return { origin, credential: () => env.ANTHROPIC_API_KEY ?? "", auth: "x-api-key", modelId: own, priceModel: { provider: "anthropic", modelId: own } };
119
120
  }
121
+ // A ChatGPT plan's model: OpenAI's Responses API on the plan's token, whatever else is set.
122
+ if (model.provider === PLAN_PROVIDER) {
123
+ const plan = planOf(env);
124
+ if (plan?.state !== "signed_in")
125
+ throw new HarnessUnavailable(plan?.state === "expired" ? EXPIRED : SIGNED_OUT);
126
+ return { origin: PLAN_ORIGIN, credential: () => plan.token(), auth: "bearer", modelId: model.modelId, priceModel: model, billing: "plan", refused: (sent) => plan.refused(sent) };
127
+ }
120
128
  if (env.AGENT_MODEL_BASE_URL)
121
129
  return gatewayProvider(env, model);
122
130
  if (model.provider === "openrouter" && model.modelId.startsWith("openai/"))
@@ -48,5 +48,6 @@ export type PushAnswer = {
48
48
  body: unknown;
49
49
  headers?: Record<string, string>;
50
50
  };
51
- /** The request to /v2/hooks/{segment}: its answer, or the one 401 (thrown). */
52
- export declare function receivePush(deps: PushDeps, req: IncomingMessage, segment: string): Promise<PushAnswer>;
51
+ /** The request to /v2/hooks/{segment}, or /v2/hooks/{segment}/{sub} for a source that keeps its key per scope
52
+ * (Push.scoped): its answer, or the one 401 (thrown). */
53
+ export declare function receivePush(deps: PushDeps, req: IncomingMessage, segment: string, sub?: string): Promise<PushAnswer>;
@@ -49,21 +49,31 @@ export function readCapped(req, max, ms = HOOK_BODY_MS) {
49
49
  }
50
50
  /** The one answer to every refused request. */
51
51
  const REFUSED = "this route needs a request signed by the webhook trigger's secret";
52
- /** The request to /v2/hooks/{segment}: its answer, or the one 401 (thrown). */
53
- export async function receivePush(deps, req, segment) {
54
- const route = `/v2/hooks/${segment}`;
52
+ /** A scope a source's own path names (/v2/hooks/{source}/{scope}): an id this server made. */
53
+ const SCOPE = /^[A-Za-z0-9_-]{1,64}$/;
54
+ /** The request to /v2/hooks/{segment}, or /v2/hooks/{segment}/{sub} for a source that keeps its key per scope
55
+ * (Push.scoped): its answer, or the one 401 (thrown). */
56
+ export async function receivePush(deps, req, segment, sub) {
57
+ const route = `/v2/hooks/${segment}${sub === undefined ? "" : `/${sub}`}`;
55
58
  const refuse = (reason) => (deps.refused(route, reason), new ApiError("unauthenticated", REFUSED));
56
59
  let name;
60
+ let scoped;
57
61
  try {
58
62
  name = decodeURIComponent(segment);
63
+ scoped = sub === undefined ? undefined : decodeURIComponent(sub);
59
64
  }
60
65
  catch {
61
66
  throw refuse("malformed_path");
62
67
  }
68
+ if (scoped !== undefined && !SCOPE.test(scoped))
69
+ throw refuse("malformed_path");
63
70
  // A source's own path (its settings are the server's), else a trigger's, checked by that trigger's own source (its
64
71
  // settings are a trigger's). A path that names no such trigger is checked as the first such source's, against the
65
72
  // decoy: the same work and the same 401, so no id is learned by asking.
66
73
  const own = deps.adapters.find((a) => a.id === name && a.push && a.settings?.scope === "server");
74
+ // Only a source that keeps its key per scope has paths under its own: any other path with a second segment names no hook.
75
+ if (scoped !== undefined && !own?.push?.scoped)
76
+ throw refuse("no_hook");
67
77
  const named = own || !ID.test(name) ? undefined : await deps.hooked(name);
68
78
  const trigger = named && deps.adapters.find((a) => a.id === named.kind && a.push && a.settings?.scope === "trigger");
69
79
  const adapter = own ?? trigger ?? deps.adapters.find((a) => a.push && a.settings?.scope === "trigger");
@@ -77,12 +87,14 @@ export async function receivePush(deps, req, segment) {
77
87
  const body = await readCapped(req, push.maxBodyBytes, deps.bodyMs);
78
88
  const source = trigger ? named : undefined;
79
89
  const pathTrigger = source ? name : undefined;
80
- const key = own ? deps.setting(adapter.id, "server", push.key) : pathTrigger && deps.setting(adapter.id, pathTrigger, push.key);
90
+ // A source that keeps its key per scope is checked with its path's scope's (none on its bare path: the decoy's 401).
91
+ const ownScope = own ? (push.scoped ? scoped : "server") : undefined;
92
+ const key = own ? ownScope && deps.setting(adapter.id, ownScope, push.key) : pathTrigger && deps.setting(adapter.id, pathTrigger, push.key);
81
93
  // Checked against the clock now the body has arrived: a timestamp at the tolerance's edge never passes by a slow body.
82
94
  const refusal = push.verify(key ?? DECOY, req.headers, body, Date.now(), key ? source : undefined);
83
95
  if (!key || refusal)
84
96
  throw refuse(key ? refusal : own ? "no_key" : "no_webhook_trigger");
85
- const scope = own ? "server" : pathTrigger;
97
+ const scope = own ? ownScope : pathTrigger;
86
98
  const ctx = {
87
99
  setting: (field) => deps.setting(adapter.id, scope, field),
88
100
  notice: async (event, doc) => deps.notice?.(adapter.id, event, doc),
@@ -91,7 +103,9 @@ export async function receivePush(deps, req, segment) {
91
103
  const handshake = await push.handshake?.(req.headers, body, ctx);
92
104
  if (handshake)
93
105
  return handshake;
94
- const events = push.parse(req.headers, body, source);
106
+ const parsed = push.parse(req.headers, body, source);
107
+ // A scoped source's events happened in its path's scope: its takes matches each trigger's to it.
108
+ const events = Array.isArray(parsed) && own && push.scoped ? parsed.map((event) => ({ ...event, scope })) : parsed;
95
109
  // Verified, and not an event its trigger takes: answered, so the sender does not send it again, and said once.
96
110
  if (!Array.isArray(events)) {
97
111
  deps.say({ condition: "hook_ignored", source: adapter.id, route, ...(pathTrigger ? { trigger: pathTrigger } : {}), reason: events.ignored, ...(events.event ? { event: events.event } : {}) });
@@ -7,6 +7,20 @@ export declare const RAN_UNKNOWN = "It had started before the deny, and whether
7
7
  export declare const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
8
8
  /** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
9
9
  export declare const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
10
+ /** How a refusal of a setting's deny, or of an ask no one can approve, opens (deniedText, noApproverText). */
11
+ export declare const DENIED_OPENING = "Permission denied: ";
12
+ /** The field of an asked call's card that says why a call its setting allows asks a person anyway (a tool's own ask,
13
+ * tools.ts ToolEntry.asks): written by the gate alone, so the model's own arguments never carry it onto the card. */
14
+ export declare const ASKED_BECAUSE = "asked_because";
15
+ /** How a person's deny opens (refusedText). */
16
+ export declare const USER_DENIED_OPENING = "The user denied this ";
17
+ /** What a read-only bash policy's refusal says after the tool's name (bash-read-only.ts readOnlyText). */
18
+ export declare const READ_ONLY_REFUSED = " is read-only for this agent, so this call was refused: ";
19
+ /** What a refusal of a tool no call of which can pass says after its name (a bash policy or a pin that does not read). */
20
+ export declare const CANT_BE_CALLED = " can't be called: ";
21
+ /** The words a refused call's answer opens with (or, past the tool's name, says first): what a script that reads its
22
+ * calls' answers as text (Codex's code mode) checks for, as the desktop and phone kind skills name them. */
23
+ export declare const REFUSAL_OPENINGS: readonly string[];
10
24
  /** Where a permission was set (permissionFrom's `from`): the agent's own tool settings, the server's, or the default; or
11
25
  * "unattended": an ask the agent's approvals "never" allowed. */
12
26
  export type SettingFrom = "agent" | "server" | "default" | "unattended";
@@ -9,6 +9,20 @@ export const RAN_UNKNOWN = "It had started before the deny, and whether it took
9
9
  export const STOPPED_WHILE_WAITING = "Not run: the run was stopped while it waited";
10
10
  /** A call that waited when its run ended (completed or failed) without anyone stopping it: never sent. */
11
11
  export const ENDED_WHILE_WAITING = "Not run: the run ended while it waited";
12
+ /** How a refusal of a setting's deny, or of an ask no one can approve, opens (deniedText, noApproverText). */
13
+ export const DENIED_OPENING = "Permission denied: ";
14
+ /** The field of an asked call's card that says why a call its setting allows asks a person anyway (a tool's own ask,
15
+ * tools.ts ToolEntry.asks): written by the gate alone, so the model's own arguments never carry it onto the card. */
16
+ export const ASKED_BECAUSE = "asked_because";
17
+ /** How a person's deny opens (refusedText). */
18
+ export const USER_DENIED_OPENING = "The user denied this ";
19
+ /** What a read-only bash policy's refusal says after the tool's name (bash-read-only.ts readOnlyText). */
20
+ export const READ_ONLY_REFUSED = " is read-only for this agent, so this call was refused: ";
21
+ /** What a refusal of a tool no call of which can pass says after its name (a bash policy or a pin that does not read). */
22
+ export const CANT_BE_CALLED = " can't be called: ";
23
+ /** The words a refused call's answer opens with (or, past the tool's name, says first): what a script that reads its
24
+ * calls' answers as text (Codex's code mode) checks for, as the desktop and phone kind skills name them. */
25
+ export const REFUSAL_OPENINGS = [DENIED_OPENING, USER_DENIED_OPENING, READ_ONLY_REFUSED, CANT_BE_CALLED];
12
26
  /** Where a deny was set, in words: the place a person changes it. */
13
27
  export const denyPlace = (from = "server") => (from === "agent" ? "for this agent" : from === "default" ? "by default" : "on this server");
14
28
  /** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
@@ -17,7 +31,7 @@ export const deniedText = (tool, heldTo, from = "server", ran = "no") => {
17
31
  // `ran`: "unknown" for a call an earlier attempt of which may have been sent (an approved call cut mid-flight, or a
18
32
  // replay-safe call run again after a crash): the words never claim it wasn't.
19
33
  const what = ran === "no" ? NOT_RUN : RAN_UNKNOWN;
20
- return heldTo && heldTo !== tool ? `Permission denied: ${tool} follows ${heldTo}'s setting, which is deny ${denyPlace(from)}. ${what} Don't retry it.` : `Permission denied: ${tool} is set to deny ${denyPlace(from)}. ${what} Don't retry it.`;
34
+ return heldTo && heldTo !== tool ? `${DENIED_OPENING}${tool} follows ${heldTo}'s setting, which is deny ${denyPlace(from)}. ${what} Don't retry it.` : `${DENIED_OPENING}${tool} is set to deny ${denyPlace(from)}. ${what} Don't retry it.`;
21
35
  };
22
36
  /** A workflow model node's tool set to ask: a model node cannot wait for a person's approval (the gate parks no workflow
23
37
  * call), so the call is refused unrun and the model reads why (tool-gate.ts RunGate, on main and on the runner). */
@@ -26,4 +40,4 @@ export const modelNodeAskText = (tool, ran = "no") => `This ${tool} call needs a
26
40
  * (main's per-run process and the runner's workflow spec, the same words). */
27
41
  export const callNodeAskText = (tool) => `This ${tool} call needs a person's approval, which a workflow's call node cannot wait for; it was not run.`;
28
42
  /** A call a person denied, with their reason when they gave one. */
29
- export const refusedText = (tool, note, ran = "no") => `The user denied this ${tool} call. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}${note ? ` Reason: ${note}` : ""}`;
43
+ export const refusedText = (tool, note, ran = "no") => `${USER_DENIED_OPENING}${tool} call. ${ran === "no" ? NOT_RUN : RAN_UNKNOWN}${note ? ` Reason: ${note}` : ""}`;
@@ -1,3 +1,5 @@
1
+ import type { SdkWorkflowTool, SdkWorkflowAdapter } from "./sdk/workflows.js";
2
+ import type { NativeBinding } from "./native/types.js";
1
3
  import { type MessageOrigin } from "./timeline/index.js";
2
4
  import type { Plane } from "./tool-plane.js";
3
5
  import type { RunTrigger } from "./triggers.js";
@@ -10,6 +12,14 @@ import type { Place } from "./workspace/place.js";
10
12
  * names (a learning run's `{ runId }`). `model`, `plane`, `approvers`, `documents` and `boxAllow` are the per-run choices
11
13
  * the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
12
14
  export interface RunLaunch {
15
+ readonly sdk?: {
16
+ runtime: "claude-agent-sdk" | "codex-sdk";
17
+ instructions: string;
18
+ model?: string;
19
+ workflow_tools?: SdkWorkflowTool[];
20
+ workflow_adapters?: SdkWorkflowAdapter[];
21
+ };
22
+ readonly native?: NativeBinding;
13
23
  /** The start request's body, as the person or trigger gave it, or an object a built-in run names. */
14
24
  readonly input: unknown;
15
25
  readonly title: string;
@@ -26,7 +36,6 @@ export interface RunLaunch {
26
36
  };
27
37
  readonly effort?: string;
28
38
  readonly maxCostUsd?: number;
29
- readonly capMode?: string;
30
39
  /** The tool plane as the server resolved it at start (tool-plane.ts). */
31
40
  readonly plane?: Plane;
32
41
  /** Whether a person can answer a tool call's approval for this run. */
@@ -120,6 +129,8 @@ export declare function readLaunchBody(stored: unknown): RunLaunch | undefined;
120
129
  /** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
121
130
  * routes and the runner; undefined when the run does not learn. */
122
131
  export declare const learningStartOf: (launch: RunLaunch) => RunLaunch["learning"];
132
+ /** The same start read from a launch body's `learning` member alone (Store.runs.learningStarts), as readLaunchBody reads it. */
133
+ export declare const learningStartOfStored: (stored: unknown) => RunLaunch["learning"];
123
134
  /** Why a learning run starts with nothing learned, as main says it: its agent's learning folder could not be read
124
135
  * (`unreadable`, STOPPED.unreadable), or what was read could not be made into its start (`not_copied`,
125
136
  * STOPPED.notCopied). */
@@ -1,3 +1,4 @@
1
+ import { nativeOf } from "./native/binding.js";
1
2
  // A run's launch record: the one JSON body the server writes when it starts a run (start = INSERT run, design 2.1), and
2
3
  // the runner reads at its claim to build the run's spec. It replaces the per-run `serve.json` the old per-run process read
3
4
  // (app.ts meta.input, place, effort, cap): no process, no door, no marker file, one body written once. What a person sees
@@ -12,9 +13,13 @@ import { isObject } from "./validate.js";
12
13
  const readDisk = (value) => isObject(value) && typeof value.disk_id === "string" && (value.kind === "launch" || value.kind === "agent") ? { diskId: value.disk_id, kind: value.kind } : undefined;
13
14
  /** The replay a launch body names, as read back, or undefined. */
14
15
  const readReplay = (value) => isObject(value) && typeof value.of === "string" && typeof value.workflow === "string" && typeof value.digest === "string" ? { of: value.of, workflow: value.workflow, digest: value.digest } : undefined;
15
- /** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
16
+ /** The trigger a launch body names, as read back: `{ id, firing_key }` and its firing's `attrs` (each a string) when it
17
+ * kept them, or null (triggerOf of the old serve.json). */
16
18
  function readTrigger(value) {
17
- return isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string" ? { id: value.id, firing_key: value.firing_key } : null;
19
+ if (!(isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string"))
20
+ return null;
21
+ const attrs = isObject(value.attrs) ? Object.fromEntries(Object.entries(value.attrs).filter((entry) => typeof entry[1] === "string")) : {};
22
+ return { id: value.id, firing_key: value.firing_key, ...(Object.keys(attrs).length ? { attrs } : {}) };
18
23
  }
19
24
  /** Where a run runs, as read back from a launch body, or undefined when it names none. */
20
25
  function readPlace(value) {
@@ -47,6 +52,8 @@ export function keepInputOrigin(stored, trigger) {
47
52
  export function launchBody(launch) {
48
53
  return {
49
54
  input: launch.input,
55
+ ...(launch.sdk ? { sdk: launch.sdk } : {}),
56
+ ...(launch.native ? { native: launch.native } : {}),
50
57
  title: launch.title,
51
58
  ...(launch.repo !== undefined ? { repo: launch.repo } : {}),
52
59
  place: launch.place,
@@ -54,7 +61,6 @@ export function launchBody(launch) {
54
61
  ...(launch.model ? { model: launch.model } : {}),
55
62
  ...(launch.effort !== undefined ? { effort: launch.effort } : {}),
56
63
  ...(launch.maxCostUsd !== undefined ? { max_cost_usd: launch.maxCostUsd } : {}),
57
- ...(launch.capMode !== undefined ? { cap_mode: launch.capMode } : {}),
58
64
  ...(launch.plane ? { plane: launch.plane } : {}),
59
65
  ...(launch.approvers !== undefined ? { approvers: launch.approvers } : {}),
60
66
  ...(launch.documents !== undefined ? { documents: launch.documents } : {}),
@@ -100,6 +106,8 @@ export function readLaunchBody(stored) {
100
106
  const archilDisk = readDisk(stored.archil_disk);
101
107
  return {
102
108
  input: stored.input,
109
+ ...(isObject(stored.sdk) && (stored.sdk.runtime === "claude-agent-sdk" || stored.sdk.runtime === "codex-sdk") && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
110
+ ...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
103
111
  title: typeof stored.title === "string" ? stored.title : "",
104
112
  ...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
105
113
  place,
@@ -107,7 +115,6 @@ export function readLaunchBody(stored) {
107
115
  ...(model ? { model } : {}),
108
116
  ...(typeof stored.effort === "string" ? { effort: stored.effort } : {}),
109
117
  ...(typeof stored.max_cost_usd === "number" ? { maxCostUsd: stored.max_cost_usd } : {}),
110
- ...(typeof stored.cap_mode === "string" ? { capMode: stored.cap_mode } : {}),
111
118
  ...(isObject(stored.plane) ? { plane: stored.plane } : {}),
112
119
  ...(typeof stored.approvers === "boolean" ? { approvers: stored.approvers } : {}),
113
120
  ...(typeof stored.documents === "string" ? { documents: stored.documents } : {}),
@@ -127,6 +134,8 @@ export function readLaunchBody(stored) {
127
134
  /** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
128
135
  * routes and the runner; undefined when the run does not learn. */
129
136
  export const learningStartOf = (launch) => launch.learning;
137
+ /** The same start read from a launch body's `learning` member alone (Store.runs.learningStarts), as readLaunchBody reads it. */
138
+ export const learningStartOfStored = (stored) => (stored === undefined ? undefined : readLearning(stored) ?? { given: [], seed: null, section: "" });
130
139
  const SEED_FAILURES = ["unreadable", "not_copied"];
131
140
  /** A learning start with no seed (no commit of main, runs-over-store.ts learningStartFor): the run learns nothing, is
132
141
  * never asked what to keep, and so is never told it learns. Why is its `seedFailed`, when its start records one. */