@parcha/agentrun-serve 0.1.0-beta.37 → 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 (620) hide show
  1. package/CHANGELOG.md +700 -0
  2. package/README.md +441 -177
  3. package/dist/adapters.d.ts +4 -1
  4. package/dist/adapters.js +4 -2
  5. package/dist/agent-rows.d.ts +1 -3
  6. package/dist/agents-store.d.ts +35 -3
  7. package/dist/agents-store.js +48 -23
  8. package/dist/answer-json.d.ts +34 -1
  9. package/dist/answer-json.js +91 -9
  10. package/dist/api-only.d.ts +1 -1
  11. package/dist/api-only.js +2 -2
  12. package/dist/bash-read-only.js +2 -1
  13. package/dist/browser-cost.js +52 -93
  14. package/dist/cap-short.d.ts +12 -0
  15. package/dist/cap-short.js +60 -0
  16. package/dist/cap.d.ts +3 -400
  17. package/dist/cap.js +6 -942
  18. package/dist/catalog.d.ts +0 -5
  19. package/dist/catalog.js +2 -6
  20. package/dist/chatgpt-plan.d.ts +163 -0
  21. package/dist/chatgpt-plan.js +549 -0
  22. package/dist/cli.js +26 -6
  23. package/dist/composio-preset.d.ts +25 -0
  24. package/dist/composio-preset.js +51 -8
  25. package/dist/composio-triggers.d.ts +113 -0
  26. package/dist/composio-triggers.js +411 -0
  27. package/dist/computer-calls.d.ts +36 -24
  28. package/dist/computer-calls.js +110 -27
  29. package/dist/computer-commands.d.ts +2 -0
  30. package/dist/computer-commands.js +7 -3
  31. package/dist/computer-live.d.ts +12 -2
  32. package/dist/computer-live.js +21 -5
  33. package/dist/computer-routes.d.ts +2 -2
  34. package/dist/computer-routes.js +2 -2
  35. package/dist/computer-setting.d.ts +15 -2
  36. package/dist/computer-setting.js +20 -4
  37. package/dist/computer-view.d.ts +18 -2
  38. package/dist/computer-view.js +21 -6
  39. package/dist/computer-viewer.js +40 -13
  40. package/dist/computers.d.ts +8 -2
  41. package/dist/computers.js +18 -8
  42. package/dist/console/assets/index-BNhZs-jp.css +1 -0
  43. package/dist/console/assets/index-BQv5aOGB.js +700 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/console-links.d.ts +2 -0
  46. package/dist/console-links.js +6 -3
  47. package/dist/decision-cap.d.ts +2 -5
  48. package/dist/decision-cap.js +3 -6
  49. package/dist/decision-rows.js +11 -11
  50. package/dist/decisions.js +4 -0
  51. package/dist/email/account.d.ts +84 -0
  52. package/dist/email/account.js +159 -0
  53. package/dist/email/answer.d.ts +10 -0
  54. package/dist/email/answer.js +182 -0
  55. package/dist/email/email-faux.d.ts +95 -0
  56. package/dist/email/email-faux.js +849 -0
  57. package/dist/email/labels.d.ts +1 -0
  58. package/dist/email/labels.js +84 -0
  59. package/dist/email/mail.d.ts +186 -0
  60. package/dist/email/mail.js +380 -0
  61. package/dist/email/names.d.ts +20 -0
  62. package/dist/email/names.js +40 -0
  63. package/dist/email/routes.d.ts +9 -0
  64. package/dist/email/routes.js +50 -0
  65. package/dist/email/tools.d.ts +20 -0
  66. package/dist/email/tools.js +517 -0
  67. package/dist/environment.d.ts +17 -2
  68. package/dist/environment.js +36 -8
  69. package/dist/errors.d.ts +6 -0
  70. package/dist/errors.js +12 -0
  71. package/dist/eval-mailbox.d.ts +103 -0
  72. package/dist/eval-mailbox.js +236 -0
  73. package/dist/faux-computers.js +4 -2
  74. package/dist/graph-view.d.ts +9 -2
  75. package/dist/graph-view.js +6 -2
  76. package/dist/harness-install.d.ts +28 -2
  77. package/dist/harness-install.js +147 -59
  78. package/dist/harness-opencode/adapter.js +2 -22
  79. package/dist/harness-opencode/facts.js +5 -4
  80. package/dist/harness-opencode/host/policy.d.ts +4 -5
  81. package/dist/harness-opencode/host/policy.js +14 -33
  82. package/dist/harness-opencode/index.d.ts +1 -1
  83. package/dist/harness-opencode/index.js +1 -1
  84. package/dist/harness-opencode/versions.d.ts +6 -0
  85. package/dist/harness-opencode/versions.js +6 -0
  86. package/dist/harness-table.d.ts +0 -2
  87. package/dist/harness-table.js +8 -7
  88. package/dist/harness.d.ts +12 -0
  89. package/dist/harness.js +15 -3
  90. package/dist/host-tools.d.ts +1 -5
  91. package/dist/host-tools.js +7 -10
  92. package/dist/hosted-search.d.ts +3 -3
  93. package/dist/hosted-search.js +51 -32
  94. package/dist/import-sources.d.ts +1 -1
  95. package/dist/import-sources.js +3 -3
  96. package/dist/import.d.ts +21 -0
  97. package/dist/import.js +186 -1
  98. package/dist/key-check.d.ts +0 -2
  99. package/dist/key-check.js +3 -4
  100. package/dist/key-refusal.d.ts +8 -2
  101. package/dist/key-refusal.js +16 -13
  102. package/dist/key-words.d.ts +3 -2
  103. package/dist/key-words.js +4 -2
  104. package/dist/learn/check.d.ts +24 -4
  105. package/dist/learn/check.js +340 -7
  106. package/dist/learn/commit.d.ts +10 -0
  107. package/dist/learn/commit.js +18 -4
  108. package/dist/learn/compile.d.ts +250 -0
  109. package/dist/learn/compile.js +507 -0
  110. package/dist/learn/general.d.ts +3 -0
  111. package/dist/learn/general.js +4 -2
  112. package/dist/learn/grade.d.ts +5 -1
  113. package/dist/learn/grade.js +11 -7
  114. package/dist/learn/notes.d.ts +8 -0
  115. package/dist/learn/notes.js +18 -0
  116. package/dist/learn/promote.d.ts +308 -0
  117. package/dist/learn/promote.js +321 -0
  118. package/dist/learn/refit.d.ts +48 -0
  119. package/dist/learn/refit.js +264 -0
  120. package/dist/learn/reflect.d.ts +5 -25
  121. package/dist/learn/reflect.js +14 -131
  122. package/dist/learn/replay-calls.d.ts +63 -0
  123. package/dist/learn/replay-calls.js +158 -0
  124. package/dist/learn/skills.d.ts +19 -16
  125. package/dist/learn/skills.js +157 -53
  126. package/dist/learn/workflow-nodes.d.ts +15 -0
  127. package/dist/learn/workflow-nodes.js +44 -0
  128. package/dist/learned-nodes.d.ts +58 -2
  129. package/dist/learned-nodes.js +68 -5
  130. package/dist/learned-workflow.d.ts +58 -32
  131. package/dist/learned-workflow.js +215 -77
  132. package/dist/learning-batch.d.ts +2 -2
  133. package/dist/learning-batch.js +4 -4
  134. package/dist/learning-cost.d.ts +41 -11
  135. package/dist/learning-cost.js +31 -13
  136. package/dist/learning-routes.d.ts +12 -2
  137. package/dist/learning-routes.js +34 -6
  138. package/dist/learning-words.d.ts +8 -1
  139. package/dist/learning-words.js +11 -1
  140. package/dist/learning.d.ts +26 -1
  141. package/dist/learning.js +7 -4
  142. package/dist/link-check.d.ts +27 -0
  143. package/dist/link-check.js +164 -0
  144. package/dist/llm.js +0 -3
  145. package/dist/local-models.d.ts +33 -2
  146. package/dist/local-models.js +43 -5
  147. package/dist/mcp-gateway.d.ts +12 -20
  148. package/dist/mcp-gateway.js +16 -44
  149. package/dist/mcp-oauth.d.ts +5 -0
  150. package/dist/mcp-oauth.js +1 -1
  151. package/dist/mcp-pin-first.d.ts +37 -0
  152. package/dist/mcp-pin-first.js +113 -0
  153. package/dist/mcp-probe.d.ts +8 -9
  154. package/dist/mcp-probe.js +16 -33
  155. package/dist/mcp-secret-writes.js +3 -0
  156. package/dist/mcp-servers-store.d.ts +102 -26
  157. package/dist/mcp-servers-store.js +151 -25
  158. package/dist/mcp-sources.d.ts +39 -0
  159. package/dist/mcp-sources.js +74 -0
  160. package/dist/mcp-store.d.ts +11 -0
  161. package/dist/mcp-store.js +16 -2
  162. package/dist/mcp-wire.d.ts +22 -0
  163. package/dist/mcp-wire.js +36 -0
  164. package/dist/mcp.js +3 -3
  165. package/dist/meta-tool-names.d.ts +1 -0
  166. package/dist/meta-tool-names.js +3 -0
  167. package/dist/model-form.d.ts +11 -0
  168. package/dist/model-form.js +17 -1
  169. package/dist/model.d.ts +39 -6
  170. package/dist/model.js +171 -32
  171. package/dist/monid.d.ts +50 -29
  172. package/dist/monid.js +234 -143
  173. package/dist/native/binding.d.ts +13 -0
  174. package/dist/native/binding.js +57 -0
  175. package/dist/native/cli.d.ts +2 -0
  176. package/dist/native/cli.js +48 -0
  177. package/dist/native/connection.d.ts +8 -0
  178. package/dist/native/connection.js +94 -0
  179. package/dist/native/context.d.ts +6 -0
  180. package/dist/native/context.js +22 -0
  181. package/dist/native/discovery.d.ts +27 -0
  182. package/dist/native/discovery.js +404 -0
  183. package/dist/native/environment.d.ts +4 -0
  184. package/dist/native/environment.js +18 -0
  185. package/dist/native/history.d.ts +20 -0
  186. package/dist/native/history.js +147 -0
  187. package/dist/native/instructions.d.ts +21 -0
  188. package/dist/native/instructions.js +173 -0
  189. package/dist/native/remote-worker-bridge.d.ts +3 -0
  190. package/dist/native/remote-worker-bridge.js +278 -0
  191. package/dist/native/remote.d.ts +187 -0
  192. package/dist/native/remote.js +492 -0
  193. package/dist/native/runtime.d.ts +17 -0
  194. package/dist/native/runtime.js +316 -0
  195. package/dist/native/runtimes.d.ts +66 -0
  196. package/dist/native/runtimes.js +41 -0
  197. package/dist/native/schema.d.ts +46 -0
  198. package/dist/native/schema.js +41 -0
  199. package/dist/native/types.d.ts +87 -0
  200. package/dist/native/types.js +1 -0
  201. package/dist/observation/http.d.ts +4 -0
  202. package/dist/observation/http.js +140 -0
  203. package/dist/observation/observer.d.ts +301 -0
  204. package/dist/observation/observer.js +919 -0
  205. package/dist/observation/schema.d.ts +52 -0
  206. package/dist/observation/schema.js +154 -0
  207. package/dist/openapi.d.ts +1 -0
  208. package/dist/openapi.js +705 -126
  209. package/dist/paid-calls.d.ts +34 -32
  210. package/dist/paid-calls.js +52 -104
  211. package/dist/place-offers.d.ts +4 -8
  212. package/dist/place-offers.js +4 -9
  213. package/dist/port-models.d.ts +7 -2
  214. package/dist/port-models.js +5 -2
  215. package/dist/print.d.ts +4 -2
  216. package/dist/print.js +4 -3
  217. package/dist/propose.d.ts +8 -3
  218. package/dist/propose.js +28 -7
  219. package/dist/provider.d.ts +5 -1
  220. package/dist/provider.js +17 -2
  221. package/dist/push-handler.d.ts +3 -2
  222. package/dist/push-handler.js +20 -6
  223. package/dist/reflect-range.js +2 -1
  224. package/dist/refusal-words.d.ts +11 -0
  225. package/dist/refusal-words.js +13 -2
  226. package/dist/rows.d.ts +5 -3
  227. package/dist/rows.js +15 -4
  228. package/dist/run-launch.d.ts +23 -1
  229. package/dist/run-launch.js +17 -4
  230. package/dist/run-learning-served.d.ts +84 -0
  231. package/dist/run-manifest.d.ts +8 -0
  232. package/dist/run-manifest.js +33 -1
  233. package/dist/run-reads-over-store.d.ts +3 -3
  234. package/dist/run-reads-over-store.js +13 -10
  235. package/dist/run-secrets.js +2 -3
  236. package/dist/run-timeline-served.d.ts +3 -2
  237. package/dist/run-timeline-served.js +12 -10
  238. package/dist/run-view.d.ts +59 -41
  239. package/dist/run-view.js +128 -64
  240. package/dist/runnable.d.ts +13 -8
  241. package/dist/runnable.js +77 -60
  242. package/dist/runner/adapter-loop.d.ts +60 -15
  243. package/dist/runner/adapter-loop.js +1406 -464
  244. package/dist/runner/adapter-run-spec.d.ts +45 -14
  245. package/dist/runner/adapter-run-spec.js +200 -116
  246. package/dist/runner/adapters/pi.d.ts +40 -7
  247. package/dist/runner/adapters/pi.js +149 -38
  248. package/dist/runner/beside.d.ts +3 -1
  249. package/dist/runner/beside.js +24 -8
  250. package/dist/runner/claim-secrets.d.ts +3 -1
  251. package/dist/runner/claim-secrets.js +28 -4
  252. package/dist/runner/cli-run-spec.d.ts +30 -0
  253. package/dist/runner/cli-run-spec.js +150 -66
  254. package/dist/runner/computer-channel.d.ts +5 -2
  255. package/dist/runner/computer-channel.js +5 -3
  256. package/dist/runner/computer-journal.d.ts +6 -0
  257. package/dist/runner/computer-journal.js +8 -10
  258. package/dist/runner/conformance/harness.d.ts +3 -0
  259. package/dist/runner/conformance/harness.js +149 -5
  260. package/dist/runner/conformance/subject.d.ts +11 -4
  261. package/dist/runner/end-of-run.d.ts +8 -5
  262. package/dist/runner/end-of-run.js +11 -6
  263. package/dist/runner/feedback-round.d.ts +79 -0
  264. package/dist/runner/feedback-round.js +127 -0
  265. package/dist/runner/harness-loops.js +17 -0
  266. package/dist/runner/journal-kinds.d.ts +55 -13
  267. package/dist/runner/journal-kinds.js +19 -0
  268. package/dist/runner/learning-dispatch.d.ts +3 -2
  269. package/dist/runner/learning-dispatch.js +6 -6
  270. package/dist/runner/learning-end.d.ts +58 -19
  271. package/dist/runner/learning-end.js +316 -115
  272. package/dist/runner/learning-factory.d.ts +3 -0
  273. package/dist/runner/learning-factory.js +8 -2
  274. package/dist/runner/learning-loop.d.ts +21 -1
  275. package/dist/runner/learning-loop.js +24 -6
  276. package/dist/runner/learning-seed.d.ts +4 -0
  277. package/dist/runner/learning-seed.js +14 -0
  278. package/dist/runner/loop-contract.d.ts +19 -3
  279. package/dist/runner/loop.d.ts +34 -1
  280. package/dist/runner/loop.js +55 -1
  281. package/dist/runner/main.d.ts +6 -1
  282. package/dist/runner/main.js +26 -4
  283. package/dist/runner/mcp-claim.d.ts +5 -1
  284. package/dist/runner/mcp-claim.js +66 -50
  285. package/dist/runner/mcp-run.d.ts +20 -53
  286. package/dist/runner/mcp-run.js +22 -88
  287. package/dist/runner/meta-tools.d.ts +44 -0
  288. package/dist/runner/meta-tools.js +344 -0
  289. package/dist/runner/metrics.d.ts +80 -21
  290. package/dist/runner/metrics.js +128 -42
  291. package/dist/runner/model-route.d.ts +12 -3
  292. package/dist/runner/model-route.js +149 -19
  293. package/dist/runner/monid-run.d.ts +18 -0
  294. package/dist/runner/monid-run.js +170 -0
  295. package/dist/runner/native-loop.d.ts +11 -0
  296. package/dist/runner/native-loop.js +438 -0
  297. package/dist/runner/promotion.d.ts +146 -0
  298. package/dist/runner/promotion.js +803 -0
  299. package/dist/runner/redact.js +3 -0
  300. package/dist/runner/reflect-hook.d.ts +36 -21
  301. package/dist/runner/reflect-hook.js +147 -49
  302. package/dist/runner/runner.d.ts +7 -1
  303. package/dist/runner/runner.js +34 -8
  304. package/dist/runner/sdk-loop.d.ts +7 -0
  305. package/dist/runner/sdk-loop.js +470 -0
  306. package/dist/runner/sessions.d.ts +8 -3
  307. package/dist/runner/sessions.js +5 -1
  308. package/dist/runner/spec-holds.d.ts +16 -2
  309. package/dist/runner/spec-holds.js +42 -14
  310. package/dist/runner/step-guard.d.ts +62 -0
  311. package/dist/runner/step-guard.js +93 -0
  312. package/dist/runner/store-secrets.js +17 -2
  313. package/dist/runner/subagent.d.ts +0 -3
  314. package/dist/runner/subagent.js +7 -12
  315. package/dist/runner/workflow-first.d.ts +226 -0
  316. package/dist/runner/workflow-first.js +293 -0
  317. package/dist/runner/workflow-loop.d.ts +1 -1
  318. package/dist/runner/workflow-loop.js +32 -19
  319. package/dist/runner/workflow-spec.d.ts +5 -1
  320. package/dist/runner/workflow-spec.js +63 -48
  321. package/dist/runs-over-store.d.ts +41 -4
  322. package/dist/runs-over-store.js +64 -22
  323. package/dist/sdk/runs.d.ts +115 -0
  324. package/dist/sdk/runs.js +422 -0
  325. package/dist/sdk/schema.d.ts +175 -0
  326. package/dist/sdk/schema.js +138 -0
  327. package/dist/sdk/workflows.d.ts +22 -0
  328. package/dist/sdk/workflows.js +39 -0
  329. package/dist/secrets.d.ts +2 -0
  330. package/dist/secrets.js +19 -1
  331. package/dist/server.d.ts +108 -20
  332. package/dist/server.js +874 -157
  333. package/dist/settings-wake.d.ts +8 -6
  334. package/dist/settings-wake.js +13 -7
  335. package/dist/skill-route.d.ts +3 -0
  336. package/dist/skill-route.js +16 -0
  337. package/dist/skills/agentrun-serve/SKILL.md +368 -0
  338. package/dist/stats.d.ts +10 -10
  339. package/dist/store/agent-body.d.ts +22 -7
  340. package/dist/store/agent-body.js +23 -14
  341. package/dist/store/command-wake.d.ts +3 -2
  342. package/dist/store/command-wake.js +4 -4
  343. package/dist/store/index.d.ts +1 -1
  344. package/dist/store/native-command-owner.d.ts +10 -0
  345. package/dist/store/native-command-owner.js +47 -0
  346. package/dist/store/postgres/connection.js +3 -1
  347. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  348. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  349. package/dist/store/postgres/migrations/0012_revision_monid_pin.sql +4 -0
  350. package/dist/store/postgres/migrations/0013_native_command_owner.sql +6 -0
  351. package/dist/store/postgres/migrations/0014_run_cost_upper_bound.sql +6 -0
  352. package/dist/store/postgres/store.js +3 -0
  353. package/dist/store/schema.d.ts +16 -0
  354. package/dist/store/schema.js +47 -8
  355. package/dist/store/sqlite/connection.d.ts +2 -2
  356. package/dist/store/sqlite/connection.js +2 -2
  357. package/dist/store/sqlite/run-patch.d.ts +8 -1
  358. package/dist/store/sqlite/run-patch.js +33 -10
  359. package/dist/store/sqlite/store.js +184 -28
  360. package/dist/store/store.d.ts +98 -21
  361. package/dist/store-reads/analytics.d.ts +7 -7
  362. package/dist/store-reads/analytics.js +23 -5
  363. package/dist/store-reads/cap.js +8 -6
  364. package/dist/store-reads/journal.d.ts +30 -1
  365. package/dist/store-reads/journal.js +141 -83
  366. package/dist/store-reads/learning.d.ts +179 -13
  367. package/dist/store-reads/learning.js +230 -68
  368. package/dist/store-reads/loop.d.ts +61 -0
  369. package/dist/store-reads/loop.js +111 -0
  370. package/dist/store-reads/runs.d.ts +5 -0
  371. package/dist/store-reads/runs.js +3 -2
  372. package/dist/store-view.d.ts +3 -2
  373. package/dist/store-view.js +109 -37
  374. package/dist/template-eval.d.ts +87 -16
  375. package/dist/template-eval.js +605 -120
  376. package/dist/template-github-permissions.d.ts +2 -2
  377. package/dist/template-github-permissions.js +2 -1
  378. package/dist/template-import.d.ts +31 -0
  379. package/dist/template-import.js +121 -0
  380. package/dist/template-source.d.ts +51 -0
  381. package/dist/template-source.js +371 -0
  382. package/dist/templates.d.ts +274 -52
  383. package/dist/templates.js +670 -201
  384. package/dist/text-urls.d.ts +38 -0
  385. package/dist/text-urls.js +170 -0
  386. package/dist/timeline/computer.d.ts +48 -0
  387. package/dist/timeline/computer.js +169 -0
  388. package/dist/timeline/index.d.ts +7 -5
  389. package/dist/timeline/index.js +7 -5
  390. package/dist/timeline/labels.d.ts +11 -4
  391. package/dist/timeline/labels.js +122 -8
  392. package/dist/timeline/origin.d.ts +20 -6
  393. package/dist/timeline/origin.js +13 -6
  394. package/dist/timeline/render-text.js +1 -1
  395. package/dist/timeline/timeline.d.ts +76 -20
  396. package/dist/timeline/timeline.js +184 -39
  397. package/dist/timeline/util.d.ts +5 -0
  398. package/dist/timeline/util.js +44 -8
  399. package/dist/timeline/web-calls.d.ts +17 -0
  400. package/dist/timeline/web-calls.js +106 -0
  401. package/dist/tool-gate.d.ts +103 -76
  402. package/dist/tool-gate.js +200 -127
  403. package/dist/tool-keys.d.ts +4 -1
  404. package/dist/tool-keys.js +8 -3
  405. package/dist/tool-list.d.ts +29 -0
  406. package/dist/tool-list.js +50 -0
  407. package/dist/tool-names.d.ts +76 -0
  408. package/dist/tool-names.js +101 -0
  409. package/dist/tool-plane.d.ts +34 -28
  410. package/dist/tool-plane.js +72 -37
  411. package/dist/tools.d.ts +59 -15
  412. package/dist/tools.js +46 -42
  413. package/dist/trigger-adapter.d.ts +85 -5
  414. package/dist/trigger-adapter.js +6 -0
  415. package/dist/trigger-adapters.js +3 -1
  416. package/dist/trigger-composio.d.ts +10 -0
  417. package/dist/trigger-composio.js +122 -0
  418. package/dist/trigger-email.d.ts +4 -0
  419. package/dist/trigger-email.js +228 -0
  420. package/dist/trigger-signatures.d.ts +6 -10
  421. package/dist/trigger-signatures.js +16 -16
  422. package/dist/trigger-targets.d.ts +1 -1
  423. package/dist/trigger-targets.js +4 -3
  424. package/dist/trigger-webhook.js +6 -4
  425. package/dist/triggers.d.ts +94 -9
  426. package/dist/triggers.js +263 -62
  427. package/dist/uploads.d.ts +9 -0
  428. package/dist/uploads.js +27 -0
  429. package/dist/validate.d.ts +15 -7
  430. package/dist/validate.js +91 -50
  431. package/dist/web-fake.d.ts +56 -0
  432. package/dist/web-fake.js +102 -0
  433. package/dist/web-fetch-direct.d.ts +3 -0
  434. package/dist/web-fetch-direct.js +4 -1
  435. package/dist/web-fetch.d.ts +6 -8
  436. package/dist/web-fetch.js +10 -53
  437. package/dist/web-search.d.ts +51 -2
  438. package/dist/web-search.js +116 -18
  439. package/dist/webhooks.d.ts +2 -1
  440. package/dist/webhooks.js +5 -1
  441. package/dist/workflow/node-runner.js +10 -2
  442. package/dist/workspace/archil-claim.d.ts +3 -0
  443. package/dist/workspace/archil-claim.js +9 -2
  444. package/dist/workspace/computer-deps.d.ts +25 -9
  445. package/dist/workspace/computer-deps.js +82 -38
  446. package/dist/workspace/computer-for-claim.d.ts +60 -4
  447. package/dist/workspace/computer-for-claim.js +203 -45
  448. package/dist/workspace/computer-hold.js +7 -1
  449. package/dist/workspace/computer-janitor.d.ts +10 -3
  450. package/dist/workspace/computer-janitor.js +96 -29
  451. package/dist/workspace/computer-kept.d.ts +82 -0
  452. package/dist/workspace/computer-kept.js +147 -0
  453. package/dist/workspace/computer-mcp.js +4 -3
  454. package/dist/workspace/computer-ports.d.ts +23 -3
  455. package/dist/workspace/computer-ports.js +115 -5
  456. package/dist/workspace/index.d.ts +2 -3
  457. package/dist/workspace/index.js +1 -2
  458. package/dist/workspace/kind-skills/desktop/SKILL.md +31 -11
  459. package/dist/workspace/kind-skills/phone/SKILL.md +29 -14
  460. package/dist/workspace/local.js +2 -2
  461. package/dist/workspace/resolve-computer.d.ts +33 -1
  462. package/dist/workspace/resolve-computer.js +37 -16
  463. package/dist/workspace/revision-skills.d.ts +6 -2
  464. package/dist/workspace/revision-skills.js +12 -5
  465. package/dist/workspace/run-end-computers.d.ts +30 -0
  466. package/dist/workspace/run-end-computers.js +137 -0
  467. package/dist/workspace/run-tools.d.ts +40 -23
  468. package/dist/workspace/run-tools.js +46 -19
  469. package/dist/wrap-up.d.ts +35 -0
  470. package/dist/wrap-up.js +48 -0
  471. package/launcher/agentrun-serve +4 -2
  472. package/package.json +13 -9
  473. package/skills/agentrun-serve/SKILL.md +248 -10
  474. package/templates/README.md +220 -60
  475. package/templates/TOOLS.md +168 -0
  476. package/templates/code-review/agent.md +46 -16
  477. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  478. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  479. package/templates/code-review/evals/injection/case.yaml +2 -1
  480. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  481. package/templates/code-review/evals/mentions-defused/case.yaml +3 -3
  482. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  483. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  484. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  485. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  486. package/templates/code-review/evals/null-name/case.yaml +2 -1
  487. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  488. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  489. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  490. package/templates/code-review/evals/off-by-one/graders/no-repo-reads.md +2 -1
  491. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  492. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  493. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  494. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  495. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  496. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  497. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  498. package/templates/code-review/evals/pasted-by-reference/case.yaml +5 -0
  499. package/templates/code-review/evals/pasted-by-reference/graders/by-reference.md +15 -0
  500. package/templates/code-review/evals/pasted-by-reference/graders/head-sha.md +6 -0
  501. package/templates/code-review/evals/pasted-by-reference/prompt.md +31 -0
  502. package/templates/code-review/evals/re-review/case.yaml +2 -1
  503. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  504. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  505. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  506. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  507. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  508. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  509. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  510. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  511. package/templates/code-review/skills/review/DEEP.md +5 -4
  512. package/templates/code-review/skills/review/REVIEWER.md +5 -4
  513. package/templates/code-review/skills/review/SKILL.md +11 -6
  514. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  515. package/templates/inbound-lead/agent.md +26 -16
  516. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  517. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  518. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  519. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  520. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  521. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  522. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  523. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  524. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  525. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  526. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  527. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  528. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  529. package/templates/kyb/agent.md +15 -5
  530. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  531. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  532. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  533. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  534. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  535. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  536. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  537. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  538. package/templates/kyb/kyb.schema.json +8 -7
  539. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  540. package/templates/market-monitor/agent.md +19 -12
  541. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  542. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  543. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  544. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  545. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  546. package/templates/release-notes/agent.md +32 -10
  547. package/templates/release-notes/evals/draft-not-publish/case.yaml +5 -4
  548. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  549. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  550. package/templates/release-notes/evals/issue-write-refused/case.yaml +5 -4
  551. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  552. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  553. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  554. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  555. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  556. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  557. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  558. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  559. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  560. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  561. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  562. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  563. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  564. package/templates/release-notes/notes.schema.json +1 -1
  565. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  566. package/dist/console/assets/index-Cn6JX1uH.js +0 -563
  567. package/dist/console/assets/index-DRN62V5v.css +0 -1
  568. package/dist/host-calls.d.ts +0 -20
  569. package/dist/host-calls.js +0 -12
  570. package/dist/runner/adapters/pi-computer.d.ts +0 -7
  571. package/dist/runner/adapters/pi-computer.js +0 -43
  572. package/dist/tool-blurbs.d.ts +0 -4
  573. package/dist/tool-blurbs.js +0 -28
  574. package/dist/tool-budget.d.ts +0 -38
  575. package/dist/tool-budget.js +0 -62
  576. package/dist/workspace/computer-script.d.ts +0 -37
  577. package/dist/workspace/computer-script.js +0 -138
  578. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  579. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  580. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  581. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  582. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  583. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  584. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  585. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  586. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  587. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  588. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  589. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  590. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  591. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  592. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  593. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  594. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  595. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  596. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  597. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  598. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  599. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  600. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  601. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  602. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  603. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  604. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  605. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  606. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  607. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  608. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  609. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  610. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  611. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  612. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  613. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  614. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  615. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  616. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  617. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  618. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  619. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  620. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -1,6 +1,5 @@
1
- import type { Context } from "@earendil-works/chord/context";
2
1
  import type { Refusal } from "@parcha/agentrun-kernel";
3
- import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
2
+ import type { ToolRegistration } from "@earendil-works/pi-durable";
4
3
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
5
4
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
6
5
  export declare const PARALLEL_SEARCH_USD = 0.001;
@@ -10,7 +9,6 @@ export declare const PARALLEL_EXTRACT_USD = 0.001;
10
9
  /** One paid request: `name` in the cap's refusal, `tool` and `by` on its records, `usd` its price, `basis` why. */
11
10
  export type Fee = {
12
11
  name: string;
13
- tool: string;
14
12
  by: string;
15
13
  usd: number;
16
14
  basis: string;
@@ -22,23 +20,21 @@ export declare const parallelExtractFee: (urls?: number) => Fee;
22
20
  /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
23
21
  * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
24
22
  export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
25
- /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
26
- * refusal, in the cap's words. */
23
+ /** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
24
+ * nothing was sent. Its message is the refusal, in the cap's words. */
27
25
  export declare class PaidRefused extends Error {
28
26
  readonly name = "PaidRefused";
29
27
  }
30
- /** Where a paid request is booked: the call it is booked under, and one record written to the run's root, where its
31
- * spend is read on every harness (cap.ts, harness-app.ts). */
28
+ /** Where a paid request is booked: the call it is booked under, and the run's one ledger. */
32
29
  export type Ledger = {
33
30
  call: string;
34
- record(kind: string, data: Record<string, string | number | null>): Promise<void>;
35
- /** The run's one ledger on the runner (the kernel cap's paidCalls, the adapter loop's): a paid request is admitted and
36
- * settled there, in the run's runner records, in place of this process's run spend (cap.ts paidCall) and the root's
37
- * TOOL_STARTED/TOOL_COST marks. */
31
+ /** The run's one ledger (the kernel cap's paid tool calls, the adapter loop's): a paid request is admitted and settled
32
+ * there, in the run's runner records. With none, a paid request is refused unsent. */
38
33
  paid?: PaidBooking;
39
34
  /** The run's pause on the runner (the adapter loop's RunLedger.pause): a paid step of the agent's own that `paid`
40
35
  * refused for room is handed to it, so the run pauses at its next request in the cap's words, as main's paidCall
41
- * pauses by default. A person's take-over books through no paid step (browser-cost.ts personTime) and never pauses. */
36
+ * pauses by default. A person's take-over books through no paid step (browser-cost.ts personTime) and never pauses.
37
+ * A refusal for good (stopRun) ends the run there instead. */
42
38
  pause?: (refusal: LedgerRefusal) => Promise<void>;
43
39
  };
44
40
  /** A cap refusal as the run's pause reads it: its words, and for room its figures. */
@@ -46,7 +42,8 @@ export type LedgerRefusal = Refusal;
46
42
  /** The kernel cap's booking of a run's paid calls (RunTools), as a paid request uses it. */
47
43
  export type PaidBooking = {
48
44
  /** `chargedBy`: who charges for it (the charge's `charged_by` on main's records: parallel, monid, an MCP server, a
49
- * 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. */
50
47
  admit(request: {
51
48
  id: string;
52
49
  name: string;
@@ -59,37 +56,42 @@ export type PaidBooking = {
59
56
  owed?: true;
60
57
  hold?: true;
61
58
  ref?: string;
59
+ under?: string;
62
60
  }): Promise<unknown>;
63
61
  /** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
64
62
  settle(id: string, usd: number | null, options?: {
65
63
  readonly givenBack?: true;
66
64
  }): Promise<unknown>;
67
65
  };
68
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
- * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
- * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
71
- export declare function writeHold(write: (kind: string, data: Record<string, string | number | null>) => Promise<void>, data: Record<string, string | number | null>): Promise<void>;
72
- /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
73
- export declare const holdRefusal: (name: string, error: unknown) => string;
74
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
75
- * call's own commits, so a stopped turn sends nothing new. On the
76
- * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
77
- * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
78
- * settled there, never booked beside it where the cap does not judge it. */
79
- export declare const ledgerOf: (api: ToolExecutionApi, context: Context) => Ledger;
66
+ /** What a paid call with no run's ledger to book it on tells the model: `name` was not sent (as mcp-gateway.ts says it). */
67
+ export declare const unbookedRefusal: (name: string) => string;
68
+ /** The ledger of tool call `call`: the run's one ledger it runs in (the adapter loop's bookedIn, which carries the run's
69
+ * paid tool calls and its pause), under the call's own id, so a paid request is admitted on the run's cap before it is
70
+ * sent and settled there; none outside one. */
71
+ export declare const ledgerOf: (call: string) => Ledger;
80
72
  /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
81
73
  export declare function booking<T extends ToolRegistration>(tool: T): T;
82
- /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
74
+ /** `work` with its paid requests booked in `ledger` (a host tool call's, a workflow call node's); with none, outside any
75
+ * call's ledger, where a paid request is refused. */
83
76
  export declare const bookedIn: <T>(ledger: Ledger | undefined, work: () => Promise<T>) => Promise<T>;
84
- /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
85
- * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
86
- * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
87
- * price. */
77
+ /** `send`, one request to a paid provider at `fee`, on the run's one ledger under the call it runs in (Ledger.paid):
78
+ * admitted at the fee's price, then sent, then settled at what it may have charged (its price on a 2xx, a 408 or a 5xx
79
+ * or when it threw after it was sent; $0 on another 4xx); a settle that cannot be written leaves it at its hold, never
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,
81
+ * or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
88
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";
89
85
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
90
86
  export declare const paidLedger: () => PaidBooking | undefined;
87
+ /** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
88
+ * could fix, so the run's next request and every tool call after this one (a script's too) are refused in them, and the
89
+ * run ends failed in them, past its cap too, as a cap refusal for good ends it. Its code is the cap's, so the refused
90
+ * request reads as the cap's refusal (no model error row of its own). */
91
+ export declare const stopRun: (words: string) => Promise<void>;
91
92
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
92
- * 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
93
95
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
94
96
  * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
95
97
  export declare function paidStep<T>(paid: PaidBooking, call: string | undefined, fee: {
@@ -106,7 +108,7 @@ export declare function paidStep<T>(paid: PaidBooking, call: string | undefined,
106
108
  result: T;
107
109
  } | {
108
110
  thrown: unknown;
109
- }) => number | null, pause?: Ledger["pause"]): Promise<{
111
+ }) => number | null | typeof GIVEN_BACK, pause?: Ledger["pause"]): Promise<{
110
112
  refused: string;
111
113
  } | {
112
114
  result: T;
@@ -1,22 +1,20 @@
1
- // A web tool's request to Parallel (its search, web-search.ts; its extract, web-fetch.ts), booked as monid.run's call
2
- // is (monid.ts): under the run's cap by cap.ts' rule for a paid call (what the run has spent and holds, plus the
3
- // request's price, within the cap; never on an unknown spend), else refused unsent in the cap's words; marked in the
4
- // run's store before it is sent (TOOL_STARTED, held at its price) and settled after (TOOL_COST, what it charged). A
5
- // charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes through
6
- // the run's one Parallel client's `post` (web-fetch.ts), which books it here by the endpoint it asks.
1
+ // A web tool's request to Parallel (its search, web-search.ts; its extract, web-fetch.ts), booked as a monid endpoint's
2
+ // call is (monid.ts): on the run's one ledger (the kernel cap's paid tool calls, RunTools), admitted at the request's price
3
+ // before it is sent (refused unsent in the cap's words when the cap does not hold it) and settled after at what it
4
+ // charged. A charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes
5
+ // through the run's one Parallel client's `post` (web-fetch.ts), which books it here by the endpoint it asks.
7
6
  // Parallel's answers report what they used as SKU counts, never an amount, so each request is booked at Parallel's
8
7
  // published price, an estimate: its price on a 2xx; nothing on a 4xx other than a 408 (Parallel refused it before any
9
8
  // work); and its price on a 408, a 5xx or a request that failed or was stopped after it was sent, which Parallel may
10
9
  // have billed, as the decision provider books Parallel's (@parcha/agentrun-decisions).
11
- // A request with no call to book it under, or to an endpoint with no price here, is never sent: it fails closed.
12
- // The call a request is booked under (its id, and how a record is written to the run's store) is set around the call:
13
- // around a tool's execute by `booking`, where the web tools are bound (tools.ts, host-tools.ts), and around a workflow
14
- // call node's effect by `bookedIn`, with the ledger the workflow's runner gives it (app.ts). The client deep inside a
15
- // tool books without the call passed down to it.
10
+ // A request with no run's ledger to book it on, or to an endpoint with no price here, is never sent: it fails closed,
11
+ // as a priced MCP call does (mcp-gateway.ts).
12
+ // The ledger a request is booked on (the run's RunTools, its pause, the call it runs under) is set around the call: around
13
+ // each host tool call by the adapter loop's `bookedIn`, around a workflow call node's tool by its own (workflow-spec.ts),
14
+ // and narrowed to the tool's own call by `booking`, where the web tools are bound (tools.ts). The client deep inside a
15
+ // tool books without the ledger passed down to it.
16
16
  import { AsyncLocalStorage } from "node:async_hooks";
17
- import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
18
- import { TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
19
- import { paidCall, SPEND_CAP_REACHED } from "./cap.js";
17
+ import { SPEND_CAP_REACHED } from "./cap.js";
20
18
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
21
19
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
22
20
  export const PARALLEL_SEARCH_USD = 0.001;
@@ -28,10 +26,10 @@ const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
28
26
  /** A fast search for `n` results: $0.001, and $0.001 for each past the 10 it includes. */
29
27
  export const parallelSearchFee = (n) => {
30
28
  const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
31
- return { name: "Parallel's search", tool: "web_search", by: "parallel", usd: usd(PARALLEL_SEARCH_USD + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a fast search of ${n} results` : "Parallel's list price for a fast search" };
29
+ return { name: "Parallel's search", by: "parallel", usd: usd(PARALLEL_SEARCH_USD + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a fast search of ${n} results` : "Parallel's list price for a fast search" };
32
30
  };
33
31
  /** An extract of `urls` URLs (the web tools ask one at a time). */
34
- export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", tool: "web_fetch", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
32
+ export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
35
33
  /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
36
34
  * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
37
35
  export function parallelFeeOf(url, body) {
@@ -43,8 +41,8 @@ export function parallelFeeOf(url, body) {
43
41
  return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
44
42
  return undefined;
45
43
  }
46
- /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
47
- * refusal, in the cap's words. */
44
+ /** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
45
+ * nothing was sent. Its message is the refusal, in the cap's words. */
48
46
  export class PaidRefused extends Error {
49
47
  name = "PaidRefused";
50
48
  }
@@ -65,82 +63,56 @@ const pauseOn = async (error, pause = ledgers.getStore()?.pause) => {
65
63
  await pause(room);
66
64
  };
67
65
  const ledgers = new AsyncLocalStorage();
68
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
- * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
- * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
71
- export async function writeHold(write, data) {
72
- await write(TOOL_STARTED, data);
73
- }
74
- /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
75
- export const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
76
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
77
- * call's own commits, so a stopped turn sends nothing new. On the
78
- * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
79
- * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
80
- * settled there, never booked beside it where the cap does not judge it. */
81
- export const ledgerOf = (api, context) => {
66
+ /** What a paid call whose hold the run's ledger could not keep tells the model: `name` was not sent, and why. */
67
+ const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
68
+ /** What a paid call with no run's ledger to book it on tells the model: `name` was not sent (as mcp-gateway.ts says it). */
69
+ export const unbookedRefusal = (name) => `${name} was not sent: this call has no run to book its price under.`;
70
+ /** The ledger of tool call `call`: the run's one ledger it runs in (the adapter loop's bookedIn, which carries the run's
71
+ * paid tool calls and its pause), under the call's own id, so a paid request is admitted on the run's cap before it is
72
+ * sent and settled there; none outside one. */
73
+ export const ledgerOf = (call) => {
82
74
  const outer = ledgers.getStore();
83
- return {
84
- call: api.callId,
85
- record: (kind, data) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context),
86
- ...(outer?.paid ? { paid: outer.paid } : {}),
87
- ...(outer?.pause ? { pause: outer.pause } : {}),
88
- };
75
+ return { call, ...(outer?.paid ? { paid: outer.paid } : {}), ...(outer?.pause ? { pause: outer.pause } : {}) };
89
76
  };
90
77
  /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
91
78
  export function booking(tool) {
92
- return { ...tool, execute: (args, api, context) => ledgers.run(ledgerOf(api, context), () => tool.execute(args, api, context)) };
79
+ return { ...tool, execute: (args, api, context) => ledgers.run(ledgerOf(api.callId), () => tool.execute(args, api, context)) };
93
80
  }
94
- /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
81
+ /** `work` with its paid requests booked in `ledger` (a host tool call's, a workflow call node's); with none, outside any
82
+ * call's ledger, where a paid request is refused. */
95
83
  export const bookedIn = (ledger, work) => (ledger ? ledgers.run(ledger, work) : work());
96
84
  /** Whether Parallel may have billed a request it answered `status`: a 2xx, a 408 or a 5xx; never another 4xx. */
97
85
  const billed = (status) => (status >= 200 && status < 300) || status === 408 || status >= 500;
98
- /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
99
- * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
100
- * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
101
- * price. */
86
+ /** `send`, one request to a paid provider at `fee`, on the run's one ledger under the call it runs in (Ledger.paid):
87
+ * admitted at the fee's price, then sent, then settled at what it may have charged (its price on a 2xx, a 408 or a 5xx
88
+ * or when it threw after it was sent; $0 on another 4xx); a settle that cannot be written leaves it at its hold, never
89
+ * less. It throws PaidRefused, in the cap's words, when the cap does not hold its price, when its hold could not be kept,
90
+ * or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
102
91
  export async function paidRequest(fee, send) {
103
92
  const ledger = ledgers.getStore();
104
- if (!ledger)
105
- throw new PaidRefused(`${fee.name} was not sent: this request has no call to book it under`);
106
- const label = { tool: fee.tool, charged_by: fee.by, call: ledger.call };
107
- const chargeOf = (sent) => ("unmarked" in sent ? undefined : "thrown" in sent || billed(sent.response.status) ? fee.usd : 0);
108
- if (ledger.paid)
109
- return paidOn(ledger.paid, ledger.call, fee, send, chargeOf);
110
- const sent = async () => {
111
- try {
112
- await writeHold(ledger.record, { ...label, heldUsd: fee.usd });
113
- }
114
- catch (error) {
115
- return { unmarked: holdRefusal(fee.name, error) };
116
- }
117
- let outcome;
118
- try {
119
- outcome = { response: await send() };
120
- }
121
- catch (thrown) {
122
- outcome = { thrown };
123
- }
124
- // Settled at what it may have charged, even when this cannot be written: the request was sent.
125
- await ledger.record(TOOL_COST, { ...label, usd: chargeOf(outcome) ?? null }).catch(() => undefined);
126
- return outcome;
127
- };
128
- const paid = await paidCall(fee.name, sent, chargeOf, { usd: fee.usd, basis: fee.basis });
129
- if ("refused" in paid)
130
- throw new PaidRefused(paid.refused);
131
- const outcome = paid.result;
132
- if ("unmarked" in outcome)
133
- throw new PaidRefused(outcome.unmarked);
134
- if ("thrown" in outcome)
135
- throw outcome.thrown;
136
- return outcome.response;
93
+ if (!ledger?.paid)
94
+ throw new PaidRefused(unbookedRefusal(fee.name));
95
+ const stepped = await paidStep(ledger.paid, ledger.call, { name: fee.name, holdUsd: fee.usd, basis: fee.basis, by: fee.by }, send, (outcome) => ("thrown" in outcome || billed(outcome.result.status) ? fee.usd : 0));
96
+ if ("refused" in stepped)
97
+ throw new PaidRefused(stepped.refused);
98
+ return stepped.result;
137
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";
138
102
  /** Each paid request of this process on the run's one ledger, numbered within its call (one call may make several). */
139
103
  let paidSeq = 0;
140
104
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
141
105
  export const paidLedger = () => ledgers.getStore()?.paid;
106
+ /** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
107
+ * could fix, so the run's next request and every tool call after this one (a script's too) are refused in them, and the
108
+ * run ends failed in them, past its cap too, as a cap refusal for good ends it. Its code is the cap's, so the refused
109
+ * request reads as the cap's refusal (no model error row of its own). */
110
+ export const stopRun = async (words) => {
111
+ await ledgers.getStore()?.pause?.({ refuse: words, code: SPEND_CAP_REACHED, forGood: true });
112
+ };
142
113
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
143
- * 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
144
116
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
145
117
  * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
146
118
  export async function paidStep(paid, call, fee, run, chargeOf, pause) {
@@ -164,33 +136,9 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
164
136
  outcome = { thrown };
165
137
  }
166
138
  // A hold-only step (`hold`) is given back, never a charge: its money is booked by its own charges' steps.
167
- 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);
168
141
  if ("thrown" in outcome)
169
142
  throw outcome.thrown;
170
143
  return outcome;
171
144
  }
172
- /** `send` on the run's one ledger (Ledger.paid): admitted at the fee's price (refused unsent in the cap's words), then
173
- * sent, then settled at what it may have charged (chargeOf: its price on a 2xx, a 408 or a 5xx or when it threw after
174
- * it was sent; $0 on another 4xx). A settle that cannot be written leaves the request at its hold, never less. */
175
- async function paidOn(paid, call, fee, send, chargeOf) {
176
- const id = `${call}#${(paidSeq += 1)}`;
177
- try {
178
- await paid.admit({ id, name: fee.name, holdUsd: fee.usd, basis: fee.basis, call, chargedBy: fee.by });
179
- }
180
- catch (error) {
181
- await pauseOn(error);
182
- const said = String(error?.message ?? error);
183
- throw new PaidRefused(error?.code === "spend_cap_reached" ? said : holdRefusal(fee.name, error));
184
- }
185
- let outcome;
186
- try {
187
- outcome = { response: await send() };
188
- }
189
- catch (thrown) {
190
- outcome = { thrown };
191
- }
192
- await paid.settle(id, chargeOf(outcome) ?? null).catch(() => undefined);
193
- if ("thrown" in outcome)
194
- throw outcome.thrown;
195
- return outcome.response;
196
- }
@@ -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,16 @@ 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). */
19
+ export type SessionLike = Partial<Pick<Model<Api>, "reasoning" | "cost" | "contextWindow" | "maxTokens" | "thinkingLevelMap">> & {
16
20
  readonly input?: readonly string[];
17
21
  readonly inputLimits?: unknown;
22
+ readonly developerRole?: boolean;
18
23
  };
19
24
  /** 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
25
  * `model` in `api` at the proxy `url` (sessionBaseUrl), under `provider`, with `headers` (the session key as the proxy
@@ -24,11 +24,14 @@ 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 } } : {}),
32
35
  };
33
36
  }
34
37
  /** 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";
@@ -29,19 +28,25 @@ export type Proposed = {
29
28
  * seed holds is no change, and `MEMORY.md` is the host's (the checker ignores it). A skill is laid at
30
29
  * `skills/<name>/SKILL.md`; a draft at `workflows/<name>/workflow.json`, with the README.md the host writes from the
31
30
  * description its block gives. `outcome`, how the run's job ended (only a completed run adds or changes a skill);
32
- * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets. */
31
+ * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets; `outputSchema`: the
32
+ * agent's, which a draft's dry run holds its answer to (learn/skills.ts draftDryRun). */
33
33
  export declare const proposeRun: (input: {
34
34
  folder: Workspace;
35
35
  runDir: string;
36
36
  seed: string;
37
37
  notesSeed?: string;
38
+ revised?: {
39
+ workflow: string;
40
+ base: string;
41
+ };
38
42
  turn: Turn;
39
43
  refuse: readonly string[];
40
44
  outcome?: string;
41
45
  tools?: readonly string[];
42
46
  gated?: Readonly<Record<string, string>>;
43
47
  deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
44
- ask?: DraftAsk;
45
48
  decisions?: DraftDecisions;
49
+ workflowAdapters?: readonly ("runNode" | "runJudge")[];
46
50
  workflows?: false;
51
+ outputSchema?: unknown;
47
52
  }) => Promise<Proposed>;