@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45

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 (346) hide show
  1. package/CHANGELOG.md +131 -5
  2. package/README.md +371 -300
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +52 -16
  28. package/dist/composio-preset.js +69 -7
  29. package/dist/composio-triggers.d.ts +14 -0
  30. package/dist/composio-triggers.js +79 -15
  31. package/dist/computer-attach.d.ts +40 -5
  32. package/dist/computer-attach.js +130 -15
  33. package/dist/computer-keys.d.ts +3 -0
  34. package/dist/computer-keys.js +7 -1
  35. package/dist/computer-live.js +3 -2
  36. package/dist/computers.d.ts +21 -10
  37. package/dist/computers.js +39 -28
  38. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  39. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/decisions.d.ts +1 -1
  42. package/dist/dial-relay.d.ts +29 -0
  43. package/dist/dial-relay.js +94 -0
  44. package/dist/email/tools.js +10 -5
  45. package/dist/env-proxy.d.ts +2 -0
  46. package/dist/env-proxy.js +35 -0
  47. package/dist/errors.d.ts +3 -1
  48. package/dist/errors.js +7 -4
  49. package/dist/faux-computers.d.ts +8 -2
  50. package/dist/faux-computers.js +83 -6
  51. package/dist/harness-archive.d.ts +67 -0
  52. package/dist/harness-archive.js +177 -0
  53. package/dist/harness-goose.d.ts +34 -0
  54. package/dist/harness-goose.js +87 -0
  55. package/dist/harness-install.d.ts +21 -0
  56. package/dist/harness-install.js +24 -11
  57. package/dist/harness-opencode/adapter.js +1 -1
  58. package/dist/harness-table.d.ts +9 -1
  59. package/dist/harness-table.js +20 -3
  60. package/dist/harness.d.ts +1 -2
  61. package/dist/harness.js +3 -4
  62. package/dist/host.js +2 -1
  63. package/dist/key-check.js +3 -0
  64. package/dist/learn/audit.d.ts +6 -6
  65. package/dist/learn/audit.js +3 -7
  66. package/dist/learn/check.d.ts +23 -89
  67. package/dist/learn/check.js +57 -335
  68. package/dist/learn/commit.d.ts +63 -90
  69. package/dist/learn/commit.js +124 -316
  70. package/dist/learn/compile.d.ts +53 -50
  71. package/dist/learn/compile.js +87 -102
  72. package/dist/learn/corrections.d.ts +13 -0
  73. package/dist/learn/corrections.js +23 -0
  74. package/dist/learn/delete.d.ts +5 -5
  75. package/dist/learn/delete.js +8 -10
  76. package/dist/learn/folder.d.ts +35 -47
  77. package/dist/learn/folder.js +118 -134
  78. package/dist/learn/index.d.ts +3 -5
  79. package/dist/learn/index.js +6 -9
  80. package/dist/learn/learning.sh +45 -15
  81. package/dist/learn/promote.d.ts +13 -1
  82. package/dist/learn/promote.js +9 -0
  83. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
  84. package/dist/learn/{skills.js → workflow-draft.js} +48 -58
  85. package/dist/learn/workflow-nodes.js +1 -1
  86. package/dist/learned-workflow.js +2 -2
  87. package/dist/learning-cost.d.ts +38 -24
  88. package/dist/learning-cost.js +41 -24
  89. package/dist/learning-routes.d.ts +91 -170
  90. package/dist/learning-routes.js +183 -421
  91. package/dist/learning-run.d.ts +19 -40
  92. package/dist/learning-run.js +23 -93
  93. package/dist/learning-setting.d.ts +4 -4
  94. package/dist/learning-setting.js +6 -6
  95. package/dist/learning-words.d.ts +28 -74
  96. package/dist/learning-words.js +64 -162
  97. package/dist/learning.d.ts +61 -392
  98. package/dist/learning.js +101 -651
  99. package/dist/live-reach.d.ts +25 -2
  100. package/dist/live-reach.js +46 -4
  101. package/dist/llms.txt +1 -1
  102. package/dist/local-models.d.ts +3 -11
  103. package/dist/local-models.js +5 -6
  104. package/dist/mcp-servers-store.d.ts +4 -4
  105. package/dist/model-form.js +6 -5
  106. package/dist/model.d.ts +4 -0
  107. package/dist/model.js +26 -9
  108. package/dist/native/binding.js +1 -1
  109. package/dist/native/connection.js +1 -1
  110. package/dist/native/discovery.js +1 -1
  111. package/dist/native/instructions.d.ts +3 -0
  112. package/dist/native/instructions.js +5 -3
  113. package/dist/native/remote-worker-bridge.js +9 -43
  114. package/dist/native/remote.d.ts +8 -15
  115. package/dist/native/remote.js +3 -3
  116. package/dist/native/schema.js +1 -1
  117. package/dist/native/types.d.ts +2 -2
  118. package/dist/openapi.js +268 -316
  119. package/dist/paid-calls.d.ts +8 -0
  120. package/dist/paid-calls.js +20 -0
  121. package/dist/particle-provider.d.ts +11 -0
  122. package/dist/particle-provider.js +135 -0
  123. package/dist/port-models.d.ts +12 -4
  124. package/dist/port-models.js +28 -11
  125. package/dist/print.d.ts +27 -0
  126. package/dist/print.js +21 -0
  127. package/dist/provider.d.ts +7 -0
  128. package/dist/provider.js +15 -1
  129. package/dist/reflect-range.js +2 -3
  130. package/dist/run-launch.d.ts +14 -28
  131. package/dist/run-launch.js +9 -12
  132. package/dist/run-learning-served.d.ts +15 -89
  133. package/dist/run-listing.d.ts +34 -0
  134. package/dist/run-listing.js +128 -0
  135. package/dist/run-model-key.js +1 -1
  136. package/dist/run-timeline-served.js +5 -3
  137. package/dist/run-trace.d.ts +97 -0
  138. package/dist/run-trace.js +253 -0
  139. package/dist/run-view.d.ts +15 -0
  140. package/dist/run-view.js +9 -0
  141. package/dist/runnable.js +2 -1
  142. package/dist/runner/adapter-loop.d.ts +8 -6
  143. package/dist/runner/adapter-loop.js +16 -12
  144. package/dist/runner/adapter-run-spec.d.ts +16 -4
  145. package/dist/runner/adapter-run-spec.js +64 -58
  146. package/dist/runner/adapters/index.js +22 -0
  147. package/dist/runner/adapters/pi.d.ts +4 -12
  148. package/dist/runner/adapters/pi.js +2 -2
  149. package/dist/runner/audit.d.ts +1 -1
  150. package/dist/runner/audit.js +16 -8
  151. package/dist/runner/beside.d.ts +6 -2
  152. package/dist/runner/beside.js +38 -9
  153. package/dist/runner/claim-secrets.d.ts +18 -2
  154. package/dist/runner/claim-secrets.js +42 -18
  155. package/dist/runner/cli-run-spec.js +55 -51
  156. package/dist/runner/conformance/harness.d.ts +6 -0
  157. package/dist/runner/conformance/harness.js +16 -5
  158. package/dist/runner/dispatch.d.ts +2 -2
  159. package/dist/runner/end-of-run.d.ts +6 -14
  160. package/dist/runner/end-of-run.js +8 -33
  161. package/dist/runner/feedback-round.d.ts +2 -2
  162. package/dist/runner/feedback-round.js +7 -7
  163. package/dist/runner/github-app.js +3 -1
  164. package/dist/runner/harness-loops.d.ts +0 -8
  165. package/dist/runner/harness-loops.js +11 -59
  166. package/dist/runner/held.d.ts +170 -0
  167. package/dist/runner/held.js +57 -0
  168. package/dist/runner/journal-kinds.d.ts +2 -3
  169. package/dist/runner/journal-kinds.js +2 -3
  170. package/dist/runner/learned-first.d.ts +40 -0
  171. package/dist/runner/learned-first.js +32 -0
  172. package/dist/runner/learning-end.d.ts +77 -69
  173. package/dist/runner/learning-end.js +250 -303
  174. package/dist/runner/learning-seed.d.ts +15 -33
  175. package/dist/runner/learning-seed.js +24 -45
  176. package/dist/runner/loop-contract.d.ts +2 -3
  177. package/dist/runner/main.d.ts +17 -9
  178. package/dist/runner/main.js +63 -20
  179. package/dist/runner/mcp-run.d.ts +11 -0
  180. package/dist/runner/mcp-run.js +67 -0
  181. package/dist/runner/memory-claim.d.ts +10 -5
  182. package/dist/runner/memory-claim.js +12 -6
  183. package/dist/runner/model-route.d.ts +7 -4
  184. package/dist/runner/model-route.js +22 -10
  185. package/dist/runner/native-loop.d.ts +0 -7
  186. package/dist/runner/native-loop.js +9 -101
  187. package/dist/runner/promotion.d.ts +8 -6
  188. package/dist/runner/promotion.js +19 -12
  189. package/dist/runner/reflect-hook.d.ts +64 -95
  190. package/dist/runner/reflect-hook.js +112 -225
  191. package/dist/runner/run-channel.d.ts +43 -0
  192. package/dist/runner/run-channel.js +467 -0
  193. package/dist/runner/run-child-host.d.ts +169 -0
  194. package/dist/runner/run-child-host.js +1222 -0
  195. package/dist/runner/run-child.d.ts +1 -0
  196. package/dist/runner/run-child.js +254 -0
  197. package/dist/runner/run-errors.d.ts +2 -0
  198. package/dist/runner/run-errors.js +20 -0
  199. package/dist/runner/runner.js +1 -5
  200. package/dist/runner/sdk-ask.d.ts +78 -0
  201. package/dist/runner/sdk-ask.js +158 -0
  202. package/dist/runner/sdk-loop.d.ts +2 -4
  203. package/dist/runner/sdk-loop.js +29 -49
  204. package/dist/runner/store-secrets.d.ts +5 -3
  205. package/dist/runner/store-secrets.js +5 -1
  206. package/dist/runner/workflow-first.d.ts +5 -0
  207. package/dist/runner/workflow-first.js +4 -0
  208. package/dist/runner/workflow-spec.js +7 -2
  209. package/dist/runs-over-store.d.ts +16 -28
  210. package/dist/runs-over-store.js +31 -38
  211. package/dist/sdk/runs.d.ts +6 -11
  212. package/dist/sdk/runs.js +20 -41
  213. package/dist/sdk/schema.js +3 -4
  214. package/dist/seal-key.d.ts +5 -0
  215. package/dist/seal-key.js +7 -0
  216. package/dist/secrets.d.ts +3 -0
  217. package/dist/secrets.js +16 -3
  218. package/dist/server.d.ts +55 -33
  219. package/dist/server.js +685 -320
  220. package/dist/sign-ins-store.d.ts +8 -0
  221. package/dist/sign-ins-store.js +36 -1
  222. package/dist/skills.js +1 -1
  223. package/dist/store/index.d.ts +2 -2
  224. package/dist/store/index.js +1 -1
  225. package/dist/store/journal/storage.js +3 -0
  226. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  227. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  228. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  229. package/dist/store/schema.d.ts +53 -4
  230. package/dist/store/schema.js +137 -6
  231. package/dist/store/sqlite/connection.d.ts +2 -0
  232. package/dist/store/sqlite/connection.js +3 -1
  233. package/dist/store/sqlite/run-patch.d.ts +0 -17
  234. package/dist/store/sqlite/run-patch.js +4 -33
  235. package/dist/store/sqlite/store.js +246 -63
  236. package/dist/store/sqlite/worker.js +25 -0
  237. package/dist/store/store.d.ts +193 -36
  238. package/dist/store/store.js +25 -3
  239. package/dist/store-reads/learning.d.ts +102 -204
  240. package/dist/store-reads/learning.js +159 -321
  241. package/dist/store-reads/loop.d.ts +0 -1
  242. package/dist/store-reads/loop.js +1 -1
  243. package/dist/store-view.d.ts +29 -1
  244. package/dist/store-view.js +97 -31
  245. package/dist/template-eval.d.ts +3 -6
  246. package/dist/template-eval.js +22 -36
  247. package/dist/templates.d.ts +2 -1
  248. package/dist/templates.js +6 -3
  249. package/dist/timeline/index.d.ts +1 -1
  250. package/dist/timeline/index.js +1 -1
  251. package/dist/timeline/timeline.d.ts +5 -1
  252. package/dist/timeline/timeline.js +16 -0
  253. package/dist/tool-gate.d.ts +0 -7
  254. package/dist/tool-gate.js +1 -15
  255. package/dist/tool-keys-store.d.ts +1 -1
  256. package/dist/tool-keys.d.ts +6 -4
  257. package/dist/tool-keys.js +12 -6
  258. package/dist/tools.d.ts +2 -2
  259. package/dist/tools.js +11 -4
  260. package/dist/triggers.d.ts +60 -5
  261. package/dist/triggers.js +123 -18
  262. package/dist/validate.js +1 -1
  263. package/dist/webhooks.d.ts +4 -1
  264. package/dist/webhooks.js +11 -4
  265. package/dist/workspace/agent-computer.d.ts +2 -0
  266. package/dist/workspace/agent-computer.js +2 -0
  267. package/dist/workspace/archil-claim.d.ts +7 -0
  268. package/dist/workspace/archil-claim.js +29 -0
  269. package/dist/workspace/archil.d.ts +9 -1
  270. package/dist/workspace/archil.js +165 -3
  271. package/dist/workspace/attach.d.ts +3 -1
  272. package/dist/workspace/attach.js +2 -0
  273. package/dist/workspace/attached-computers.d.ts +16 -5
  274. package/dist/workspace/attached-computers.js +25 -9
  275. package/dist/workspace/computer-deps.js +1 -1
  276. package/dist/workspace/computer-for-claim.d.ts +7 -3
  277. package/dist/workspace/computer-for-claim.js +119 -22
  278. package/dist/workspace/computer-hold.js +2 -1
  279. package/dist/workspace/computer-kept.d.ts +11 -1
  280. package/dist/workspace/computer-kept.js +24 -3
  281. package/dist/workspace/resolve-computer.d.ts +33 -19
  282. package/dist/workspace/resolve-computer.js +172 -64
  283. package/dist/workspace/revision-skills.d.ts +1 -2
  284. package/dist/workspace/revision-skills.js +3 -4
  285. package/dist/workspace/run-workspace.d.ts +1 -1
  286. package/dist/workspace/run-workspace.js +5 -0
  287. package/dist/workspace/synced-folder.d.ts +85 -0
  288. package/dist/workspace/synced-folder.js +230 -0
  289. package/dist/workspace/workspace.d.ts +4 -0
  290. package/launcher/agentrun-serve +1 -1
  291. package/package.json +10 -10
  292. package/templates/README.md +7 -7
  293. package/templates/inbound-lead/agent.md +3 -3
  294. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  295. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  296. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  297. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  298. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  299. package/templates/inbound-lead/lead.schema.json +6 -5
  300. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  301. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  302. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  303. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  304. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  305. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  306. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  307. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  308. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  309. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  310. package/dist/console/assets/index-BUktRvS-.css +0 -1
  311. package/dist/console/assets/index-nB9kTfIN.js +0 -711
  312. package/dist/learn/grade.d.ts +0 -138
  313. package/dist/learn/grade.js +0 -682
  314. package/dist/learn/notes.d.ts +0 -81
  315. package/dist/learn/notes.js +0 -178
  316. package/dist/learn/reflect.d.ts +0 -77
  317. package/dist/learn/reflect.js +0 -228
  318. package/dist/learn/relevance.d.ts +0 -24
  319. package/dist/learn/relevance.js +0 -91
  320. package/dist/learn/seed-check.d.ts +0 -74
  321. package/dist/learn/seed-check.js +0 -103
  322. package/dist/learning-batch.d.ts +0 -291
  323. package/dist/learning-batch.js +0 -600
  324. package/dist/learning-evals.d.ts +0 -35
  325. package/dist/learning-evals.js +0 -99
  326. package/dist/native/context.d.ts +0 -6
  327. package/dist/native/context.js +0 -22
  328. package/dist/propose.d.ts +0 -52
  329. package/dist/propose.js +0 -224
  330. package/dist/runner/learning-ask.d.ts +0 -47
  331. package/dist/runner/learning-ask.js +0 -128
  332. package/dist/runner/learning-dispatch.d.ts +0 -45
  333. package/dist/runner/learning-dispatch.js +0 -99
  334. package/dist/runner/learning-factory.d.ts +0 -16
  335. package/dist/runner/learning-factory.js +0 -50
  336. package/dist/runner/learning-loop.d.ts +0 -273
  337. package/dist/runner/learning-loop.js +0 -521
  338. package/dist/usage.d.ts +0 -11
  339. package/dist/usage.js +0 -11
  340. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  341. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  342. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  343. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  344. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  345. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  346. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -22,22 +22,21 @@ const usd = (value) => Math.round(value * 1e6) / 1e6;
22
22
  * the run's cost here would read other than its usage row (A8). `+ 0` makes a noise-sized negative a plain 0, never -0. */
23
23
  export const noiseOff = (value) => Math.round(value * 1e12) / 1e12 + 0;
24
24
  /** A run's own cost and what learning added for it, from its row's cost (`rowUsd`: the job, its look-back and any turn a
25
- * person asked of it after), what it kept as it answered (`looked`, none for a run that did not look back) and what its
26
- * grade spent (`gradeUsd`: its learning run's cost once that run ended, stopped or failed, 0 while it runs or when there
27
- * is none, null when unknown):
25
+ * person asked of it after) and what it kept as it answered (`looked`, none for a run that did not look back):
28
26
  * - `cost_usd`: the job's own $: its row's cost less its look-back, never under what it had cost when it answered (a
29
27
  * later turn's spend is the job's too); its row's cost for a run that did not look back;
30
- * - `learning_usd`: what learning cost for it: its look-back and its grade, 0 for a run that does not learn; null when
31
- * either is unknown (a grade that failed or was stopped mid-ask spent what no one knows);
28
+ * - `learning_usd`: what learning cost for it: its look-back (its compile turn) and what was spent beside it
29
+ * (`besideUsd`: its audit's shadow run), 0 for a run that does not learn; null when unknown (a turn stopped mid-ask
30
+ * spent what no one knows, or a shadow still running);
32
31
  * - `total_usd`: their sum, the run's all-in $; null when either is. */
33
- export function runCostOf(rowUsd, looked, gradeUsd = 0) {
32
+ export function runCostOf(rowUsd, looked, besideUsd = 0) {
34
33
  const answered = looked?.answered_at !== undefined;
35
34
  const asAnswered = answered ? (looked.job_cost_usd ?? null) : rowUsd;
36
35
  const back = answered ? (looked.look_back_usd ?? null) : 0;
37
36
  // What the row holds past the answer and its look-back is a later turn's spend, unknown once the row's cost is; with the
38
37
  // look-back's cost unknown the two can't be told apart, and the job is what it had cost when it answered.
39
38
  const job = !answered || asAnswered === null || back === null ? asAnswered : rowUsd === null ? null : Math.max(asAnswered, rowUsd - back);
40
- const spent = back === null || gradeUsd === null ? null : back + gradeUsd;
39
+ const spent = back === null || besideUsd === null ? null : back + besideUsd;
41
40
  return { cost_usd: job === null ? null : noiseOff(job), learning_usd: spent === null ? null : noiseOff(spent), total_usd: job === null || spent === null ? null : noiseOff(job + spent) };
42
41
  }
43
42
  /** The fewest runs after the takeover a "times cheaper" figure needs: fewer say too little. */
@@ -51,11 +50,25 @@ export const COST_RUNS_MAX = 10_000;
51
50
  /** The paths a learned workflow served a run on: it ran first and answered alone (`workflow`) or handed back
52
51
  * (`handed_back`). A `replay` checks a new revision on a graded input and serves no one; an `agent` run is by hand. */
53
52
  export const SERVED_PATHS = ["workflow", "handed_back"];
53
+ /** Each run of the series (every run, oldest first, before a read's limit) with `took_over`: true on the first run a
54
+ * revision (`workflow` at `digest`) served (SERVED_PATHS), never on a replay or a run no revision ran. A promotion is
55
+ * written as a run is claimed, after the runs queued before it started, so where a revision took over is read from the
56
+ * runs it served, never from start times. */
57
+ export function tookOverOf(runs) {
58
+ const seen = new Set();
59
+ return runs.map((run) => {
60
+ const revision = run.digest !== null && SERVED_PATHS.includes(run.path) ? JSON.stringify([run.workflow, run.digest]) : null;
61
+ const first = revision !== null && !seen.has(revision);
62
+ if (revision !== null)
63
+ seen.add(revision);
64
+ return { ...run, took_over: first };
65
+ });
66
+ }
54
67
  /** Why the after side has a figure or not: `priced`, it has; `no_served_runs`, no learned workflow has taken over (a
55
68
  * replay is no served run); `cost_unknown`, runs were served but none's all-in cost is known exactly. */
56
69
  export const AFTER_STATES = ["priced", "no_served_runs", "cost_unknown"];
57
70
  export function costSummary(runs, replay = null) {
58
- const first = runs.findIndex((run) => run.path === "workflow");
71
+ const first = runs.findIndex((run) => SERVED_PATHS.includes(run.path));
59
72
  const beforeSide = (first < 0 ? runs : runs.slice(0, first)).filter((run) => run.path === "agent").map((run) => ({ value: run.cost_usd, bound: run.cost_upper_bound }));
60
73
  // Served runs alone: a replay (a check of a new revision, at workflow cost) and a run by hand are never the after side.
61
74
  const served = first < 0 ? [] : runs.slice(first).filter((run) => SERVED_PATHS.includes(run.path));
@@ -79,17 +92,19 @@ export function costSummary(runs, replay = null) {
79
92
  /** The paths of the runs that do a job: the bill's run index counts these. A replay checks a revision and an audit's
80
93
  * shadow audits a run: their spend is learning, booked where it falls (billOf) and carried by the runs they serve. */
81
94
  export const JOB_PATHS = ["agent", "workflow", "handed_back"];
82
- /** The bill over `runs` (the cost series, oldest first, replays among them) and `promotedAt` (when the agent's first
83
- * run on a served path started, null for none): each run that does a job, all in (its own $, its look-back, grade and
84
- * audit shadow), with each replay's $ joining the run that does a job it followed (the first one when none did),
85
- * cumulative; against the baseline times the runs shown so far. Spend booked with no point to join (a replay after a
86
- * job of unknown cost) is carried to the next point, and with none after it is still booked: in the gap, and no
87
- * break-even while it puts the bill over the line. Every sum and difference has its float noise rounded off (noiseOff),
88
- * so a tie reads as a tie and a decision's sub-micro-dollar cost is booked as the usage row books it. */
89
- export function billOf(runs, promotedAt) {
95
+ /** The bill over `runs` (the cost series, oldest first, replays among them): each run that does a job, all in (its own
96
+ * $, its compile turn and its audit shadow), with each replay's $ joining the run that does a job it followed (the first
97
+ * one when none did), cumulative; against the baseline times the runs shown so far. Spend booked with no point to join
98
+ * (a replay after a job of unknown cost) is carried to the next point, and with none after it is still booked: in the
99
+ * gap, and no break-even while it puts the bill over the line. Every sum and difference has its float noise rounded off
100
+ * (noiseOff), so a tie reads as a tie and a decision's sub-micro-dollar cost is booked as the usage row books it. */
101
+ export function billOf(runs) {
90
102
  const jobs = runs.filter((run) => JOB_PATHS.includes(run.path));
91
103
  const priced = (run) => run.total_usd !== null && !run.cost_upper_bound;
92
- const before = jobs.filter((run) => run.path === "agent" && (promotedAt === null || run.started_at < promotedAt) && run.cost_usd !== null && !run.cost_upper_bound);
104
+ // The first run a learned workflow served (the summary's takeover): by its place in the series, never by a start time,
105
+ // which two runs queued together can share.
106
+ const first = jobs.findIndex((run) => SERVED_PATHS.includes(run.path));
107
+ const before = (first < 0 ? jobs : jobs.slice(0, first)).filter((run) => run.path === "agent" && run.cost_usd !== null && !run.cost_upper_bound);
93
108
  const baseline = before.length ? { runs: before.length, mean_usd: usd(before.reduce((sum, run) => sum + run.cost_usd, 0) / before.length) } : null;
94
109
  // Each replay's $ joins the job it followed; one before every job joins the first.
95
110
  const extra = new Map();
@@ -133,8 +148,9 @@ export function billOf(runs, promotedAt) {
133
148
  });
134
149
  // Replays with no job at all to join (every job run archived, say) are booked all the same.
135
150
  actual = noiseOff(early.reduce((sum, one) => sum + one, actual));
136
- const first = promotedAt === null ? -1 : jobs.findIndex((run) => run.started_at >= promotedAt);
137
- const promoted = first < 0 ? null : { n: first + 1, run_id: jobs[first].run_id, at: promotedAt };
151
+ // Of it, learning's: the booked total less the priced jobs' own $ (each priced job's total is its own $ and its learning).
152
+ const learning = noiseOff(jobs.reduce((rest, run) => (priced(run) ? noiseOff(rest - run.cost_usd) : rest), actual));
153
+ const promoted = first < 0 ? null : { n: first + 1, run_id: jobs[first].run_id, at: jobs[first].started_at };
138
154
  // The booked total against the line at the last point: spend after it (carried to no point) is in.
139
155
  const tail = line === null ? Number.NaN : noiseOff(actual - noiseOff(line * shown));
140
156
  let breakEven = null;
@@ -148,7 +164,7 @@ export function billOf(runs, promotedAt) {
148
164
  }
149
165
  }
150
166
  const gap = !breakEven && line !== null && points.length ? tail : null;
151
- return { baseline, promoted, points, break_even: breakEven, gap_usd: gap, withheld, booked_usd: actual };
167
+ return { baseline, promoted, points, break_even: breakEven, gap_usd: gap, withheld, booked_usd: actual, learning_usd: learning };
152
168
  }
153
169
  /** Each revision's spend split over its first `k` served runs (`served`: the runs a learned workflow served, oldest
154
170
  * first, with the workflow and digest that served each: a revision is both, as two workflows of the same text share a
@@ -160,12 +176,13 @@ export function amortize(revisions, served) {
160
176
  const shares = new Map();
161
177
  let rest = 0;
162
178
  const out = revisions.map((revision) => {
163
- const runs = served.filter((one) => one.workflow === revision.workflow && one.digest === revision.digest).slice(0, revision.k);
179
+ const all = served.filter((one) => one.workflow === revision.workflow && one.digest === revision.digest);
180
+ const runs = all.slice(0, revision.k);
164
181
  if (revision.spend_usd === null) {
165
182
  for (const run of runs)
166
183
  shares.set(run.run_id, null);
167
184
  rest = null;
168
- return { ...revision, served: runs.length, attributed_usd: null, unattributed_usd: null };
185
+ return { ...revision, served: all.length, attributed_usd: null, unattributed_usd: null };
169
186
  }
170
187
  // Its whole micro-dollars (read off its pico-dollars, so float noise never drops one), split in integers; the rest
171
188
  // under a micro-dollar is the k-th run's.
@@ -182,14 +199,14 @@ export function amortize(revisions, served) {
182
199
  const left = noiseOff(revision.spend_usd - carried);
183
200
  if (rest !== null)
184
201
  rest = noiseOff(rest + left);
185
- return { ...revision, served: runs.length, attributed_usd: carried, unattributed_usd: left };
202
+ return { ...revision, served: all.length, attributed_usd: carried, unattributed_usd: left };
186
203
  });
187
204
  return { shares, revisions: out, unattributed_usd: rest };
188
205
  }
189
206
  /** The series as CSV (RFC 4180, a header line, `\r\n` line ends): one row a run, an unknown figure empty. A text cell that
190
207
  * a spreadsheet would read as a formula (one starting with =, +, -, @, a tab or a carriage return) starts with a `'`, so
191
208
  * it opens as the text it is. */
192
- export const COST_CSV_COLUMNS = ["n", "run_id", "started_at", "path", "workflow", "learned_revision", "cost_usd", "cost_upper_bound", "learning_usd", "total_usd"];
209
+ export const COST_CSV_COLUMNS = ["n", "run_id", "started_at", "path", "workflow", "digest", "audited", "cost_usd", "cost_upper_bound", "learning_usd", "total_usd"];
193
210
  export function costCsv(runs) {
194
211
  const cell = (value) => {
195
212
  const raw = value === null || value === undefined ? "" : String(value);
@@ -1,6 +1,8 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
- import type { DraftDecisions } from "./learn/skills.js";
3
- import { type ItemStatus, type Learning, type NoteRuns, type Shown } from "./learning.js";
2
+ import { type DraftDecisions } from "./learn/workflow-draft.js";
3
+ import { type SnapHistory } from "./learn/folder.js";
4
+ import type { ServingState } from "./learn/promote.js";
5
+ import { type ItemStatus, type Learning, type Shown } from "./learning.js";
4
6
  import type { Impact } from "./learning-run.js";
5
7
  import { type LearnedUse } from "./store-reads/learning.js";
6
8
  import type { Store } from "./store/store.js";
@@ -9,41 +11,16 @@ type Page<T> = {
9
11
  total: number;
10
12
  next_cursor: string | null;
11
13
  };
12
- type NoteView = {
13
- file: string;
14
- name: string;
15
- description: string;
16
- type: string;
17
- status: string;
18
- origin: string;
19
- superseded_by: string | null;
20
- text: string;
21
- etag: string;
22
- retired?: Retired;
23
- last_change?: LastChange;
24
- runs: {
25
- given: number;
26
- read: number;
27
- };
28
- };
29
- /** When a retired note, skill or draft was retired, and by whom: a person (its retire's commit), else a run. */
30
- /** Who retired a retired item, and when, and `from`, the status its restore gives back; or, for a skill or draft that
31
- * reads retired only because its file can't be read (its front matter reads no way: unclearFront, read from its file as
32
- * the view is made), that no one did: the host could not read it (`why`), with no `from`, since its restore waits for
33
- * the file to be fixed. One closed shape. */
14
+ /** Who retired a retired draft, and when, and `from`, the status its restore gives back; or, for one that reads retired
15
+ * only because its README.md can't be read (its front matter reads no way: unclearFront, read from its file as the view
16
+ * is made), that no one did: the host could not read it (`why`), with no `from`, since its restore waits for the file to
17
+ * be fixed. One closed shape. */
34
18
  type Retired = {
35
19
  at: string;
36
20
  by: "person" | "run" | "host";
37
21
  from?: "active" | "pending";
38
22
  why?: "unreadable";
39
23
  };
40
- /** The newest change to a note, skill or draft (its file: the note, a SKILL.md, a draft's README.md): what it was, by
41
- * whom and when. A person's is named by its commit (`learning: <kind> by a person: <file>`); a run's merge is `learned`. */
42
- type LastChange = {
43
- kind: "approved" | "edited" | "created" | "retired" | "restored" | "learned" | "superseded";
44
- by: "person" | "run";
45
- at: string;
46
- };
47
24
  type Change = {
48
25
  by: {
49
26
  run: string;
@@ -63,55 +40,71 @@ export type Counts = {
63
40
  };
64
41
  export { secretsShown, type Shown } from "./learning.js";
65
42
  export declare const etagOf: (oid: string) => string;
66
- /** A skill or a workflow draft as the view lists it: its folder's name, its file (a skill's SKILL.md, a draft's
67
- * workflow.json, with its `readme`), its description, `pending` while it waits for its owner's OK, the run whose merge
68
- * last changed it, its size in bytes, and the ETag of the file that says whether it waits (a SKILL.md, a README.md),
69
- * which an approval names; cut of the host's secrets (a name or a file holding one reads [redacted]). */
70
- type LearnedView = {
43
+ /** A workflow draft as the view lists it: its folder's name, its workflow.json with its `readme`, its description, its
44
+ * status, the run whose merge last changed it, its size in bytes, and the ETag of its README.md (the file that says
45
+ * whether it waits, which an approval names); cut of the host's secrets (a name or a file holding one reads [redacted]).
46
+ * `status` is one word: its README.md's `pending` or `retired`, else where it stands as the promotions read says it
47
+ * (`stateOf`, learn/promote.ts servingStateOf): `serving`, `checking`, `held` or `stopped`. */
48
+ type WorkflowView = {
71
49
  name: string;
72
50
  file: string;
73
- readme?: string;
51
+ readme: string;
74
52
  description: string;
75
- status: "active" | "pending" | "retired";
53
+ status: "pending" | "retired" | ServingState;
76
54
  run: string | null;
77
55
  bytes: number;
78
56
  etag: string;
79
57
  retired?: Retired;
80
- last_change?: LastChange;
58
+ last_change?: SnapHistory["last"];
81
59
  };
82
60
  /** For tests: how many times a folder's statuses were read (once per commit of its main). */
83
61
  export declare const pendingTestHooks: {
84
62
  reads: number;
85
63
  };
86
- /** Each learned item's status on agent `agentId`'s folder's main, by file (a note's; a skill's SKILL.md; a workflow
87
- * draft's workflow.json, as its README.md says it), from its snapshot: `active`, `pending`, `superseded` or `retired`,
88
- * with what a note supersedes. Built once per main (a list asks for many runs). A folder never made, or with no main,
89
- * holds none; one whose snapshot cannot be read is undefined. */
64
+ /** Each workflow draft's status on agent `agentId`'s folder's main, by its workflow.json (as its README.md says it):
65
+ * `active`, `pending` or `retired`. Built once per main (a list asks for many runs). A folder never made, or with no
66
+ * main, holds none; one whose snapshot cannot be read is undefined. */
90
67
  export declare function statusesOf(data: string, agentId: string): Promise<ReadonlyMap<string, ItemStatus> | undefined>;
91
- /** How many of agent `agentId`'s learned items wait for its owner's OK on its folder's main (statusesOf): notes, skills
92
- * and workflow drafts held with `status: pending`. A folder never made has none waiting; one that cannot be read is
93
- * undefined (the caller shows no count). */
68
+ /** How many of agent `agentId`'s workflow drafts wait for its owner's OK on its folder's main (statusesOf). A folder
69
+ * never made has none waiting; one that cannot be read is undefined (the caller shows no count). */
94
70
  export declare function pendingCount(data: string, agentId: string): Promise<number | undefined>;
95
- /** GET /agents/{id}/learning: main, its index, the first page of its notes and of its log, and how the agent's runs
96
- * fared and what learning changed for them (`counts`, `impact`: learning-run.ts, from the runs' rows and the learning
97
- * ledger); an agent with no folder (its learning never on) has an empty one. */
71
+ /** GET /agents/{id}/learning: main, its corrections.md, its workflow drafts and the first page of its log, and how the
72
+ * agent's runs fared and what learning changed for them (`counts`, `impact`); an agent with no folder (its learning
73
+ * never on) has an empty one. `stateOf`: where each workflow neither pending nor retired stands, by its folder name (the
74
+ * promotions read's own word: learn/promote.ts servingStateOf over the agent's records). */
98
75
  type AgentView = {
99
76
  agent: string;
100
77
  main: string | null;
101
- index: string;
102
- notes: Page<NoteView>;
103
- skills: LearnedView[];
104
- workflows: LearnedView[];
78
+ corrections: string;
79
+ workflows: WorkflowView[];
105
80
  log: Page<Change>;
106
81
  counts: Counts;
107
82
  impact: Impact;
108
83
  };
109
- export declare function agentLearning(data: string, agentId: string, shown: Shown, counts: Counts, impact: Impact, runs?: NoteRuns): Promise<AgentView>;
110
- /** GET /agents/{id}/learning/notes?cursor=&limit=&status=: a page of the notes, ordered as the view's. A page at an
111
- * older main whose notes this server cannot read as they were any more is the first page of main now. */
112
- export declare function learningNotes(data: string, agentId: string, query: URLSearchParams, shown: Shown, runs?: NoteRuns): Promise<Page<NoteView>>;
84
+ export declare function agentLearning(data: string, agentId: string, shown: Shown, counts: Counts, impact: Impact, stateOf: (workflow: string) => ServingState): Promise<AgentView>;
113
85
  /** GET /agents/{id}/learning/log?cursor=&limit=: a page of the changes on main, newest first. */
114
86
  export declare function learningLog(data: string, agentId: string, query: URLSearchParams, shown: Shown): Promise<Page<Change>>;
87
+ /** GET /agents/{id}/learning/corrections: corrections.md on main as text (empty when main holds none), its ETag (its blob
88
+ * id; an empty file's when there is none) and the cap a PUT keeps to, cut of the host's secrets as every read is. */
89
+ export declare function correctionsView(data: string, agentId: string, shown: Shown): Promise<{
90
+ text: string;
91
+ etag: string;
92
+ cap_bytes: number;
93
+ }>;
94
+ /** PUT /agents/{id}/learning/corrections: corrections.md replaced whole by a person (`text`), only over the version they
95
+ * read (`ifMatch`: its ETag; none, or `*`, is 428; another version is 412). Refused whole, nothing written, when it holds
96
+ * what must never be stored (a host secret, text shaped like one, a hidden character) or passes the cap (422 with the
97
+ * problems, printable). A text read cut of a secret and sent back replaces the secret with the cut: a person's write never
98
+ * puts a secret back. In the agent's queue, one commit on main. */
99
+ export declare function correctionsWrite(data: string, agentId: string, input: {
100
+ text: string;
101
+ ifMatch?: string;
102
+ refuse: readonly string[];
103
+ }): Promise<{
104
+ text: string;
105
+ etag: string;
106
+ cap_bytes: number;
107
+ }>;
115
108
  /** One revision of a learned workflow: a commit on main that changed its workflow.json, with that commit's text (null
116
109
  * when the commit holds no such file: it was deleted there), cut of the host's secrets. */
117
110
  type WorkflowRevision = {
@@ -141,80 +134,53 @@ export declare function workflowAtDigest(data: string, agentId: string, name: st
141
134
  text: string;
142
135
  commit: string;
143
136
  } | undefined>;
144
- /** GET /agents/{id}/learning/files/{file}: the file on main as text, its ETag, and its type (a draft's workflow.json is
137
+ /** GET /agents/{id}/learning/files/{file}: a draft's file on main as text, its ETag, and its type (workflow.json is
145
138
  * JSON). */
146
- export declare function readNote(data: string, agentId: string, raw: string, shown: Shown): Promise<{
139
+ export declare function readLearnedFile(data: string, agentId: string, raw: string, shown: Shown): Promise<{
147
140
  text: string;
148
141
  etag: string;
149
142
  type?: string;
150
143
  }>;
151
- /** A note (or a skill's or draft's file) as a text answer: its ETag, an explicit type (markdown unless it names one),
152
- * nosniff, and a sandbox on whatever opens it. */
153
- export declare function sendNote(res: ServerResponse, status: number, note: {
144
+ /** A learning file as a text answer: its ETag, an explicit type (markdown unless it names one), nosniff, and a sandbox on
145
+ * whatever opens it. */
146
+ export declare function sendText(res: ServerResponse, status: number, file: {
154
147
  text: string;
155
148
  etag: string;
156
149
  type?: string;
157
150
  }, headers?: Record<string, string>): void;
158
- /** A PUT's body, read to its end (over `max` bytes is 413): the note's whole text, as `text/markdown` or `text/plain`, or
159
- * as `application/json` `{text}`, the one form the console's page may send under its session (page.ts: a write from
160
- * the page is JSON from its own origin). A JSON body that is not an object is 400; one whose `text` is missing or not
161
- * text, or with another field, is 422 by field, as every JSON body here. */
162
- export declare function noteBody(req: IncomingMessage, max: number): Promise<Buffer>;
163
- /** PUT /agents/{id}/learning/files/{file} (`body`, the note's whole text), or POST .../retire or .../approve (`approve`;
164
- * no body), as a person: the precondition, then the checks (a retire's and an approve's, the note's format alone: never
165
- * its secrets), then one commit on main by the learning script (learn/folder.ts writeLearning), in the agent's queue,
166
- * on the agent's learning folder: the note, and MEMORY.md rebuilt from main's notes with it, its message
167
- * `learning: <edited|created|retired|approved> by a person: <file>` and a `Changed-By: user` trailer (and
168
- * `Approved-Via: console` on an approval), main moved only from the main it read (computed again on a main that moved
169
- * meanwhile), then the checked-out files and the snapshot. A note the checks refuse is never written to git. A retire
170
- * of a note that is not active, and an edit that changes nothing, commit nothing. `refuse`: the host's secrets. */
171
- export declare function writeNote(data: string, agentId: string, raw: string, input: {
151
+ /** A PUT's body, read to its end (over `max` bytes is 413): the file's whole text, as `text/markdown` or `text/plain`, or
152
+ * as `application/json` `{text}`, the one form the console's page may send under its session (page.ts: a write from the
153
+ * page is JSON from its own origin). A JSON body that is not an object is 400; one whose `text` is missing or not text,
154
+ * or with another field, is 422 by field, as every JSON body here. A body that is not UTF-8 is 422. */
155
+ export declare function textBody(req: IncomingMessage, max: number): Promise<string>;
156
+ /** The tools and gate a draft's workflow.json is checked against (learning-end.ts checkDraftOf's own). */
157
+ type DraftTools = () => Promise<{
158
+ tools: string[];
159
+ gated: Record<string, string>;
160
+ deniedBy?: Record<string, "agent" | "server" | "default">;
161
+ decisions?: DraftDecisions;
162
+ }>;
163
+ /** POST /agents/{id}/learning/files/{file}/approve, .../retire or .../restore, as a person, on a draft's README.md
164
+ * (`file`): If-Match on the version read (none, or `*`, is 428; another is 412), then one commit on main by the learning
165
+ * script (learn/folder.ts writeLearning), in the agent's queue, its message `learning: <approved|retired|restored> by a
166
+ * person: <file>` with a `Changed-By: user` trailer (and `Approved-Via: console` on an approval). An approval releases a
167
+ * held draft (status: pending) to every later run; a retire takes it out of every later run unchecked, so a leaking one
168
+ * can always be revoked; a restore brings it back to the status its retire recorded, checked again as a new draft is
169
+ * (secrets' shapes, the host's values, hidden characters, its README's format, its workflow.json against the agent's
170
+ * tools and gate). A retire of a retired draft commits nothing. `refuse`: the host's secrets. */
171
+ export declare function changeWorkflow(data: string, agentId: string, raw: string, input: {
172
+ action: "approve" | "retire" | "restore";
172
173
  ifMatch?: string;
173
- ifNoneMatch?: string;
174
- body?: Buffer;
175
174
  refuse: readonly string[];
176
- approve?: boolean;
177
- restore?: boolean;
178
- draftTools?: () => Promise<{
179
- tools: string[];
180
- gated: Record<string, string>;
181
- deniedBy?: Record<string, "agent" | "server" | "default">;
182
- decisions?: DraftDecisions;
183
- }>;
175
+ draftTools?: DraftTools;
184
176
  }): Promise<{
185
- status: 200 | 201;
177
+ status: 200;
186
178
  file: string;
187
179
  text: string;
188
180
  etag: string;
189
181
  }>;
190
- /** A learned workflow as a promotion makes it into an agent of its own: its folder's name, its README's description,
191
- * its workflow.json parsed, and the tools its call nodes call. */
192
- export type Promotable = {
193
- name: string;
194
- description: string;
195
- workflow: Record<string, unknown>;
196
- calls: string[];
197
- };
198
- /** POST /agents/{id}/learning/workflows/{name}/promote's read of the learned workflow `raw` (percent-encoded) on agent
199
- * `agentId`'s main: an active one alone, as every later run is given it. One that waits for its owner's OK, or that a
200
- * person retired, is 409 learned_not_active: a promotion never runs what the owner has not let every run use. Each of
201
- * its files is checked again as a restore checks it (unstorable: a secret's shape, the host's values as they are now,
202
- * a hidden character), and its workflow.json as the learning checker checks a run's draft against the agent's tools and
203
- * its gate (draftProblems: the DSL's validation with no code run, no code node, no shell or executor call, no call node
204
- * on a tool the agent does not have or the gate holds to ask or deny). Any of those is 400 with `problems`, printable.
205
- * Reads only: the folder is never written. */
206
- export declare function promotable(data: string, agentId: string, raw: string, input: {
207
- refuse: readonly string[];
208
- draftTools: () => Promise<{
209
- tools: string[];
210
- gated: Record<string, string>;
211
- deniedBy?: Record<string, "agent" | "server" | "default">;
212
- decisions?: DraftDecisions;
213
- }>;
214
- }): Promise<Promotable>;
215
182
  /** GET /runs/{id}/learning's body, from the run's learning as it reads now, the seed it started from and whether it
216
- * settled: the one shape, read from the one store (store-reads/learning.ts
217
- * runLearningOverStore). */
183
+ * settled: the one shape, read from the one store (store-reads/learning.ts runLearningOverStore). */
218
184
  export declare function runLearningBody(input: {
219
185
  readonly id: string;
220
186
  readonly learning: Learning;
@@ -222,24 +188,15 @@ export declare function runLearningBody(input: {
222
188
  readonly settled: boolean;
223
189
  readonly used?: LearnedUse;
224
190
  }, shown: Shown, secrets: readonly string[]): {
191
+ run: string;
192
+ state: "dropped" | "merged" | "seeded" | "reflecting";
193
+ reason: "cancelled" | "use" | "empty" | "crashed" | "reflect_failed" | "no_budget" | "checker" | "unknown_cost" | "seed_failed" | null;
194
+ detail: string | null;
195
+ at: string;
196
+ workflows: import("./learning.js").LearnedFile[];
197
+ corrections: number;
225
198
  seed: string | null;
226
199
  merged: string | null;
227
- pending: {
228
- file: string;
229
- name: string;
230
- }[];
231
- verdict: {
232
- merge: boolean;
233
- reason: string;
234
- items: {
235
- why: string;
236
- question?: string | undefined;
237
- origin?: "run" | "you" | undefined;
238
- pending?: boolean | undefined;
239
- file: string;
240
- keep: boolean;
241
- }[];
242
- } | null;
243
200
  problems: {
244
201
  detail: string;
245
202
  path?: string | undefined;
@@ -247,7 +204,6 @@ export declare function runLearningBody(input: {
247
204
  }[];
248
205
  compiled: {
249
206
  workflow: string;
250
- from_notes: string[];
251
207
  attempts: {
252
208
  ok: boolean;
253
209
  errors: string[];
@@ -256,41 +212,20 @@ export declare function runLearningBody(input: {
256
212
  promoted: boolean | null;
257
213
  } | null;
258
214
  draft_errors: string[];
259
- cost_usd: {
260
- grade: number | null;
261
- };
262
- tokens: {
263
- grade: import("./learning.js").Tokens | null;
264
- };
265
215
  used: {
266
- skills: {
267
- name: string;
268
- read: boolean;
269
- }[];
270
216
  workflows: {
271
217
  name: string;
272
218
  calls: number;
273
219
  failed: number;
274
220
  }[];
275
221
  };
276
- given?: import("./learning.js").NoteUsed[];
277
- read?: import("./learning.js").NoteUsed[];
278
- learned?: import("./learning.js").NoteLearned[];
279
- skills?: import("./learning.js").LearnedFile[];
280
- workflows?: import("./learning.js").LearnedFile[];
281
- run: string;
282
- state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
283
- reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
284
- detail: string | null;
285
- at: string;
286
222
  };
287
223
  /** GET /runs/{id}/learning/diff over the one store: once merged (its learning end, store-reads/learning.ts
288
224
  * runLearningEnd), its merge commit against its parent, as its merge's script wrote it (`.agentrun/diffs/<run>.json` in
289
- * its agent's learning folder); before, its kept proposal (new notes only, from its learning_proposals row) against its
290
- * seed; a run that proposed nothing, no file, against the seed its launch's learning start names. A run that does not
291
- * learn (no learning start and no learning end) is not_found. A file's patch is withheld when too large (as the script
292
- * wrote it), or when it holds one of the host's secrets now (`shown`); any other is served as every learning text is
293
- * (`shown.text`: a loopback address reads "a local address"). */
225
+ * its agent's learning folder); a run that merged nothing, no file, against the seed its launch's learning start names. A
226
+ * run that does not learn (no learning start and no learning end) is not_found. A file's patch is withheld when too large
227
+ * (as the script wrote it), or when it holds one of the host's secrets now (`shown`); any other is served as every
228
+ * learning text is (`shown.text`: a loopback address reads "a local address"). */
294
229
  export declare function runDiffOverStore(data: string, store: Store, runId: string, shown: Shown): Promise<{
295
230
  base: string;
296
231
  head: string;
@@ -305,20 +240,6 @@ export declare function runDiffOverStore(data: string, store: Store, runId: stri
305
240
  patch: string;
306
241
  withheld?: undefined;
307
242
  })[];
308
- } | {
309
- base: string;
310
- head: null;
311
- files: ({
312
- path: string;
313
- status: string;
314
- withheld: string;
315
- patch?: undefined;
316
- } | {
317
- path: string;
318
- status: string;
319
- patch: string;
320
- withheld?: undefined;
321
- })[];
322
243
  } | {
323
244
  base: string | null;
324
245
  head: null;