@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58

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 (312) hide show
  1. package/CHANGELOG.md +281 -0
  2. package/README.md +246 -66
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +15 -5
  11. package/dist/api-only.js +32 -8
  12. package/dist/box-paths.d.ts +4 -3
  13. package/dist/box-paths.js +7 -4
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/chatgpt-plan.d.ts +18 -8
  19. package/dist/chatgpt-plan.js +91 -34
  20. package/dist/claude-login-token.d.ts +117 -0
  21. package/dist/claude-login-token.js +737 -0
  22. package/dist/claude-login.d.ts +120 -22
  23. package/dist/claude-login.js +347 -63
  24. package/dist/claude-sign-in.d.ts +17 -6
  25. package/dist/claude-sign-in.js +42 -39
  26. package/dist/cli.js +33 -10
  27. package/dist/composio-made.d.ts +4 -0
  28. package/dist/composio-made.js +4 -0
  29. package/dist/composio-preset.d.ts +43 -2
  30. package/dist/composio-preset.js +92 -4
  31. package/dist/computer-attach.d.ts +35 -17
  32. package/dist/computer-attach.js +301 -49
  33. package/dist/computer-held-routes.d.ts +5 -4
  34. package/dist/computer-held-routes.js +29 -8
  35. package/dist/computer-held.d.ts +6 -1
  36. package/dist/computer-held.js +14 -0
  37. package/dist/computer-record.js +4 -2
  38. package/dist/computer-viewer.js +4 -1
  39. package/dist/computers.d.ts +10 -10
  40. package/dist/computers.js +5 -5
  41. package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
  42. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  43. package/dist/console/assets/index-DPh29cyz.js +747 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/decisions.d.ts +1 -1
  46. package/dist/decisions.js +1 -1
  47. package/dist/dial-relay.d.ts +25 -4
  48. package/dist/dial-relay.js +129 -1
  49. package/dist/docker-host-addresses.d.ts +22 -11
  50. package/dist/docker-host-addresses.js +38 -26
  51. package/dist/env-switch.d.ts +8 -0
  52. package/dist/env-switch.js +31 -2
  53. package/dist/errors.d.ts +1 -0
  54. package/dist/errors.js +2 -0
  55. package/dist/fal-price.d.ts +56 -20
  56. package/dist/fal-price.js +400 -90
  57. package/dist/handed-values.d.ts +43 -1
  58. package/dist/handed-values.js +119 -2
  59. package/dist/harness-archive.d.ts +13 -10
  60. package/dist/harness-archive.js +60 -34
  61. package/dist/harness-check.d.ts +3 -1
  62. package/dist/harness-check.js +25 -46
  63. package/dist/harness-keys.d.ts +73 -27
  64. package/dist/harness-keys.js +194 -61
  65. package/dist/harness-recipe-entry.d.ts +8 -7
  66. package/dist/harness-recipe-entry.js +21 -32
  67. package/dist/harness-recipe.d.ts +38 -25
  68. package/dist/harness-recipe.js +49 -36
  69. package/dist/harness-sign-in.js +12 -23
  70. package/dist/harness-table.d.ts +10 -3
  71. package/dist/harness-table.js +26 -21
  72. package/dist/harness.d.ts +1 -0
  73. package/dist/harness.js +17 -5
  74. package/dist/hosted-search.d.ts +1 -1
  75. package/dist/hosted-search.js +1 -2
  76. package/dist/import-worker.d.ts +4 -2
  77. package/dist/import-worker.js +9 -2
  78. package/dist/in-flight.d.ts +26 -0
  79. package/dist/in-flight.js +52 -0
  80. package/dist/key-refusal.d.ts +9 -4
  81. package/dist/key-refusal.js +107 -25
  82. package/dist/learn/ledger.d.ts +170 -0
  83. package/dist/learn/ledger.js +218 -0
  84. package/dist/learn/promote.d.ts +3 -3
  85. package/dist/learn/promote.js +1 -1
  86. package/dist/learn/secrets.d.ts +13 -3
  87. package/dist/learn/secrets.js +118 -17
  88. package/dist/learning-cost.d.ts +28 -23
  89. package/dist/learning-cost.js +19 -23
  90. package/dist/link-check.js +1 -1
  91. package/dist/live-reach.d.ts +2 -0
  92. package/dist/live-reach.js +2 -0
  93. package/dist/llms.txt +1 -1
  94. package/dist/marketplace.d.ts +77 -0
  95. package/dist/marketplace.js +224 -0
  96. package/dist/mcp-api-only-origins.d.ts +35 -0
  97. package/dist/mcp-api-only-origins.js +57 -0
  98. package/dist/mcp-gateway.d.ts +7 -5
  99. package/dist/mcp-gateway.js +9 -12
  100. package/dist/mcp-secret-writes.js +5 -3
  101. package/dist/mcp-servers-store.d.ts +28 -6
  102. package/dist/mcp-servers-store.js +53 -4
  103. package/dist/media-duration.d.ts +3 -0
  104. package/dist/media-duration.js +90 -9
  105. package/dist/micro.d.ts +2 -0
  106. package/dist/micro.js +2 -0
  107. package/dist/model-form.d.ts +5 -4
  108. package/dist/model-form.js +11 -7
  109. package/dist/model.d.ts +10 -6
  110. package/dist/model.js +16 -11
  111. package/dist/monid.d.ts +14 -1
  112. package/dist/monid.js +103 -26
  113. package/dist/ollama-provider.d.ts +7 -1
  114. package/dist/ollama-provider.js +14 -2
  115. package/dist/openapi.js +210 -37
  116. package/dist/otel/genai.d.ts +65 -0
  117. package/dist/otel/genai.js +116 -0
  118. package/dist/otel/tracer.d.ts +55 -0
  119. package/dist/otel/tracer.js +308 -0
  120. package/dist/page.d.ts +2 -0
  121. package/dist/page.js +3 -1
  122. package/dist/paid-calls.d.ts +1 -32
  123. package/dist/paid-calls.js +4 -39
  124. package/dist/place-offers.d.ts +4 -0
  125. package/dist/place-offers.js +7 -4
  126. package/dist/provider.d.ts +11 -2
  127. package/dist/provider.js +59 -8
  128. package/dist/redact/match.d.ts +30 -3
  129. package/dist/redact/match.js +422 -41
  130. package/dist/refusal-words.d.ts +11 -0
  131. package/dist/refusal-words.js +11 -0
  132. package/dist/run-census.d.ts +67 -0
  133. package/dist/run-census.js +240 -0
  134. package/dist/run-computer.d.ts +6 -3
  135. package/dist/run-computer.js +4 -1
  136. package/dist/run-cut.d.ts +15 -6
  137. package/dist/run-cut.js +30 -9
  138. package/dist/run-files.d.ts +3 -0
  139. package/dist/run-files.js +3 -0
  140. package/dist/run-launch.d.ts +12 -1
  141. package/dist/run-launch.js +9 -10
  142. package/dist/run-learning-served.d.ts +4 -2
  143. package/dist/run-model-key.d.ts +8 -0
  144. package/dist/run-model-key.js +31 -1
  145. package/dist/run-reads-over-store.d.ts +24 -6
  146. package/dist/run-reads-over-store.js +67 -23
  147. package/dist/run-recordings.d.ts +5 -1
  148. package/dist/run-recordings.js +39 -14
  149. package/dist/run-timeline-served.d.ts +2 -0
  150. package/dist/run-timeline-served.js +2 -2
  151. package/dist/run-usage.d.ts +1 -0
  152. package/dist/run-view.d.ts +1 -2
  153. package/dist/run-view.js +2 -1
  154. package/dist/runnable.d.ts +10 -1
  155. package/dist/runnable.js +20 -8
  156. package/dist/runner/adapter-loop.d.ts +11 -0
  157. package/dist/runner/adapter-loop.js +58 -26
  158. package/dist/runner/adapter-run-spec.d.ts +55 -11
  159. package/dist/runner/adapter-run-spec.js +183 -52
  160. package/dist/runner/adapters/pi.js +25 -3
  161. package/dist/runner/beside.d.ts +9 -2
  162. package/dist/runner/beside.js +27 -9
  163. package/dist/runner/big-writes.js +1 -10
  164. package/dist/runner/claim-secrets.d.ts +27 -10
  165. package/dist/runner/claim-secrets.js +49 -22
  166. package/dist/runner/cli-run-spec.d.ts +6 -0
  167. package/dist/runner/cli-run-spec.js +97 -38
  168. package/dist/runner/computer-journal.d.ts +9 -1
  169. package/dist/runner/computer-journal.js +26 -0
  170. package/dist/runner/conformance/harness.js +1 -1
  171. package/dist/runner/feedback-round.js +3 -0
  172. package/dist/runner/harness-loops.d.ts +6 -5
  173. package/dist/runner/harness-loops.js +7 -7
  174. package/dist/runner/held.d.ts +24 -6
  175. package/dist/runner/journal-kinds.d.ts +5 -0
  176. package/dist/runner/journal-kinds.js +5 -0
  177. package/dist/runner/main.d.ts +11 -6
  178. package/dist/runner/main.js +19 -9
  179. package/dist/runner/mcp-claim.js +31 -3
  180. package/dist/runner/mcp-run.d.ts +9 -0
  181. package/dist/runner/mcp-run.js +11 -5
  182. package/dist/runner/model-route.d.ts +17 -0
  183. package/dist/runner/model-route.js +120 -2
  184. package/dist/runner/presence.d.ts +11 -1
  185. package/dist/runner/presence.js +7 -0
  186. package/dist/runner/reflect-hook.js +1 -1
  187. package/dist/runner/run-child-host.d.ts +22 -8
  188. package/dist/runner/run-child-host.js +128 -41
  189. package/dist/runner/run-child.js +5 -2
  190. package/dist/runner/runner.d.ts +17 -3
  191. package/dist/runner/runner.js +130 -34
  192. package/dist/runner/save-slots.js +2 -1
  193. package/dist/runner/store-port.d.ts +1 -1
  194. package/dist/runner/store-secrets.d.ts +6 -0
  195. package/dist/runner/store-secrets.js +49 -7
  196. package/dist/runner/subagent.d.ts +11 -0
  197. package/dist/runner/subagent.js +16 -38
  198. package/dist/runner/workflow-first.d.ts +35 -15
  199. package/dist/runner/workflow-first.js +38 -25
  200. package/dist/runner/workflow-spec.js +4 -3
  201. package/dist/runs-over-store.d.ts +15 -6
  202. package/dist/runs-over-store.js +33 -21
  203. package/dist/scrub-command.d.ts +73 -0
  204. package/dist/scrub-command.js +307 -0
  205. package/dist/secret-cut.d.ts +73 -0
  206. package/dist/secret-cut.js +291 -4
  207. package/dist/secret-rules.d.ts +143 -0
  208. package/dist/secret-rules.js +2564 -0
  209. package/dist/secrets.d.ts +7 -0
  210. package/dist/secrets.js +20 -0
  211. package/dist/server-keys.d.ts +20 -0
  212. package/dist/server-keys.js +25 -6
  213. package/dist/server.d.ts +65 -13
  214. package/dist/server.js +470 -157
  215. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  216. package/dist/slots.d.ts +9 -0
  217. package/dist/slots.js +45 -0
  218. package/dist/store/index.d.ts +1 -1
  219. package/dist/store/index.js +1 -1
  220. package/dist/store/journal/storage.js +1 -1
  221. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  222. package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
  223. package/dist/store/schema.d.ts +23 -0
  224. package/dist/store/schema.js +58 -2
  225. package/dist/store/seal.d.ts +6 -1
  226. package/dist/store/seal.js +5 -3
  227. package/dist/store/sqlite/run-launch.d.ts +9 -1
  228. package/dist/store/sqlite/run-launch.js +24 -13
  229. package/dist/store/sqlite/run-patch.d.ts +12 -2
  230. package/dist/store/sqlite/run-patch.js +42 -5
  231. package/dist/store/sqlite/store.js +105 -12
  232. package/dist/store/store.d.ts +57 -2
  233. package/dist/store/store.js +20 -0
  234. package/dist/store-reads/learning.d.ts +84 -124
  235. package/dist/store-reads/learning.js +210 -274
  236. package/dist/store-view.d.ts +3 -0
  237. package/dist/store-view.js +3 -3
  238. package/dist/suggestions.js +3 -2
  239. package/dist/template-eval.d.ts +39 -9
  240. package/dist/template-eval.js +191 -60
  241. package/dist/template-import.js +6 -2
  242. package/dist/templates.d.ts +10 -2
  243. package/dist/templates.js +28 -8
  244. package/dist/timeline/labels.d.ts +6 -4
  245. package/dist/timeline/labels.js +18 -6
  246. package/dist/timeline/timeline.d.ts +5 -0
  247. package/dist/timeline/timeline.js +14 -8
  248. package/dist/timeline/util.js +1 -1
  249. package/dist/timeline/web-calls.d.ts +22 -7
  250. package/dist/timeline/web-calls.js +106 -35
  251. package/dist/tool-gate.d.ts +42 -3
  252. package/dist/tool-gate.js +66 -5
  253. package/dist/tool-keys-store.d.ts +2 -4
  254. package/dist/tool-keys-store.js +5 -21
  255. package/dist/tool-keys.d.ts +2 -2
  256. package/dist/tool-keys.js +2 -2
  257. package/dist/tool-list.js +1 -1
  258. package/dist/tool-plane.d.ts +2 -2
  259. package/dist/tool-plane.js +35 -33
  260. package/dist/tools.js +13 -7
  261. package/dist/trigger-targets.d.ts +4 -0
  262. package/dist/trigger-targets.js +9 -2
  263. package/dist/triggers.d.ts +67 -4
  264. package/dist/triggers.js +171 -22
  265. package/dist/until.d.ts +3 -0
  266. package/dist/until.js +11 -0
  267. package/dist/web-fake.d.ts +1 -3
  268. package/dist/web-fake.js +7 -18
  269. package/dist/web-fetch.d.ts +6 -72
  270. package/dist/web-fetch.js +11 -265
  271. package/dist/web-run.d.ts +31 -0
  272. package/dist/web-run.js +90 -0
  273. package/dist/web-save.d.ts +10 -13
  274. package/dist/web-save.js +13 -55
  275. package/dist/web-search.d.ts +9 -127
  276. package/dist/web-search.js +23 -259
  277. package/dist/wires.d.ts +13 -0
  278. package/dist/wires.js +11 -0
  279. package/dist/workflow-run.d.ts +5 -4
  280. package/dist/workflow-run.js +5 -4
  281. package/dist/workspace/attached-computers.d.ts +32 -9
  282. package/dist/workspace/attached-computers.js +77 -13
  283. package/dist/workspace/computer-deps.d.ts +8 -2
  284. package/dist/workspace/computer-deps.js +10 -3
  285. package/dist/workspace/computer-for-claim.d.ts +12 -1
  286. package/dist/workspace/computer-for-claim.js +83 -11
  287. package/dist/workspace/computer-kept.d.ts +3 -0
  288. package/dist/workspace/computer-kept.js +11 -2
  289. package/dist/workspace/index.d.ts +1 -1
  290. package/dist/workspace/index.js +1 -1
  291. package/dist/workspace/kind-skills.d.ts +4 -0
  292. package/dist/workspace/kind-skills.js +9 -0
  293. package/dist/workspace/paired-route.d.ts +91 -0
  294. package/dist/workspace/paired-route.js +153 -0
  295. package/dist/workspace/synced-folder.js +3 -4
  296. package/dist/wrapped.d.ts +20 -6
  297. package/dist/wrapped.js +66 -25
  298. package/package.json +17 -11
  299. package/skills/agentrun-serve/SKILL.md +4 -0
  300. package/templates/README.md +32 -10
  301. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  302. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  303. package/dist/exa-keyless.d.ts +0 -34
  304. package/dist/exa-keyless.js +0 -118
  305. package/dist/firecrawl-keyless.d.ts +0 -41
  306. package/dist/firecrawl-keyless.js +0 -152
  307. package/dist/keyless-mcp.d.ts +0 -36
  308. package/dist/keyless-mcp.js +0 -127
  309. package/dist/text-urls.d.ts +0 -38
  310. package/dist/text-urls.js +0 -170
  311. package/dist/web-fetch-direct.d.ts +0 -119
  312. package/dist/web-fetch-direct.js +0 -190
@@ -1,8 +1,9 @@
1
1
  import { type ItemStatus, type Learning, type Shown } from "../learning.js";
2
2
  import { type RunLaunch } from "../run-launch.js";
3
3
  import { type Impact, type ImpactLearning } from "../learning-run.js";
4
- import { amortize, type Bill, type CostReplay, type CostRun, type CostSummary, type RunPath, runCostOf } from "../learning-cost.js";
5
- import { type PastRun, workflowCostsOf } from "../runner/workflow-first.js";
4
+ import { type Bill, type CostReplay, type CostRun, type CostSummary, type RunPath } from "../learning-cost.js";
5
+ import { type Answered, type LedgerRow, type RevisionAt, type RunFigures, type Summarized } from "../learn/ledger.js";
6
+ import { type PastRuns, workflowCostsOf } from "../runner/workflow-first.js";
6
7
  import { type Reflect } from "../reflect-range.js";
7
8
  import type { EntryLike, TimelineEvent } from "../timeline/index.js";
8
9
  import type { AnalyticsFilter } from "./analytics.js";
@@ -10,23 +11,6 @@ import { type PromotionRecord, type Refused, type ResetRevision } from "../learn
10
11
  import type { LearningProposal, Store } from "../store/store.js";
11
12
  /** A run's learning end: the Learning fields its end sets. */
12
13
  export type RunLearningEnd = Learning;
13
- /** The kept row as the end-of-run hook writes it (runner/reflect-hook.ts), read as untrusted. */
14
- type KeptRow = {
15
- readonly state?: unknown;
16
- readonly reason?: unknown;
17
- readonly detail?: unknown;
18
- readonly problems?: Learning["problems"];
19
- readonly merged?: unknown;
20
- readonly workflows?: Learning["workflows"];
21
- readonly corrections?: unknown;
22
- readonly compiled?: unknown;
23
- readonly draft_errors?: unknown;
24
- readonly answered_at?: unknown;
25
- readonly job_cost_usd?: unknown;
26
- readonly look_back_usd?: unknown;
27
- };
28
- /** What a kept row says of a run that looked back (its compile turn's figures): none for one that did not. */
29
- declare function answeredOf(row: KeptRow): Pick<Learning, "answered_at" | "job_cost_usd" | "look_back_usd">;
30
14
  /** The reads of a run's records a learning read makes: its launch, a round of its kept learning, a run's row. The
31
15
  * store's own reads, one a run, or an agent's read at once (agentRecordsOf). */
32
16
  export type RunRecords = {
@@ -82,17 +66,17 @@ export declare function agentLearningOverStore(store: Store, agentId: string): P
82
66
  counts: Omit<LearningCounts, "runs">;
83
67
  impact: Impact;
84
68
  }>;
85
- /** Agent `agentId`'s cost per run from the one store (GET /agents/{id}/learning/cost, learning-cost.ts): each of its
86
- * agentic runs that ended (ended, stopped or failed), oldest first, each run that does a job numbered from 1 (a replay
87
- * none: the bill's numbering), with its own cost and what learning added for it (runCostOf over its row's cost and its
88
- * learning's spend, learningSpendOf), the path it took and the learned workflow it ran (its run record's, pathOfRow), the
89
- * revision of that workflow (metrics.workflow_digest) and whether an audit's shadow ran for it; and what
90
- * the series shows (costSummary). A run still at work, an imported or archived one and a workflow revision's run are left
91
- * out. A run that learns whose record names no path (its end's patch was late or failed, or no runner wrote its end) is
92
- * left out too and counted (`unknown_path_runs`): its path and cost are not known, never `agent` at $0. `limit`: the
93
- * latest runs shown, each keeping its number; the summary is over every run; `bill` is the owner's bill over all of
94
- * them (billOf, with the revision ledger: agentLedgerOf). Its champion skips what `refused` names of the agent's
95
- * promotion records (purged-workflow.ts refusedOf, the purge gate's), as a run's claim does; absent, none. */
69
+ /** Agent `agentId`'s cost per run from the one store (GET /agents/{id}/learning/cost, learning-cost.ts): what its ledger
70
+ * says (learn/ledger.ts summarize, agentLedgerOverStore): each of its agentic runs that ended (ended, stopped or
71
+ * failed), oldest first, each run that does a job numbered from 1 (a replay none: the bill's numbering), with its own
72
+ * cost and what learning added for it, the path it took and the learned workflow it ran, the revision of that workflow
73
+ * and whether an audit's shadow ran for it; what the series shows (costSummary); and each learned workflow against the
74
+ * money rule (workflowCostsOf over the same figures, pastRunsOf). A run still at work, an imported or archived one and a
75
+ * workflow revision's run are left out. A run that learns whose end named no path is left out too and counted
76
+ * (`unknown_path_runs`): its path and cost are not known, never `agent` at $0. `limit`: the latest runs shown, each
77
+ * keeping its number; the summary is over every run; `bill` is the owner's bill over all of them. Its champion skips
78
+ * what `refused` names of the agent's promotion records (purged-workflow.ts refusedOf, the purge gate's), as a run's
79
+ * claim does; absent, none. */
96
80
  export type RefusedFor = (agentId: string, records: readonly PromotionRecord[]) => Promise<Refused>;
97
81
  export declare function agentCostOverStore(store: Store, agentId: string, limit?: number, refused?: RefusedFor): Promise<{
98
82
  runs: CostRun[];
@@ -103,91 +87,77 @@ export declare function agentCostOverStore(store: Store, agentId: string, limit?
103
87
  workflows: ReturnType<typeof workflowCostsOf>;
104
88
  bill: Bill;
105
89
  }>;
106
- type LedgerRow = Pick<RunRecord, "id" | "metrics" | "startedAt" | "costUsd" | "costAtMostUsd">;
107
- /** A compile turn a run's end-of-run step asked (runner/reflect-hook.ts), as its kept round says it: the revision it
108
- * drafted (`digest`, null when every draft failed its checks, or the turn was stopped or capped before a draft was kept,
109
- * so it drafted none; `workflow` null for the latter, which kept no draft's name) and what its turn spent (`usd`, the
110
- * round's `look_back_usd`: the step's only model turn is its compile turn, so that one figure is the compile's; null when
111
- * unknown). */
112
- export type CompileSpend = {
113
- readonly workflow: string | null;
114
- readonly digest: string | null;
115
- readonly usd: number | null;
116
- };
117
- /** Each revision of the agent's learned workflows (one per workflow and digest its promotion records name, in the order
118
- * they were first recorded) with its learning spend, and what its served runs carry of it (amortize), over `rows`: the
119
- * agent's ended runs that do a job or check one (no shadow, no imported or archived run). A revision is its workflow and
120
- * its digest, never the digest alone: two workflows of the same text share a digest, and each pays its own way. Its
121
- * spend is the compile turns that drafted it (`compiles` of its workflow at its digest: a recompile drafts a revision of
122
- * its own) and its check (the replay runs that ran it: metrics.path `replay` of its workflow at its digest); unknown
123
- * once a part's cost is (null, or only a bound). A compile whose drafts all failed drafted none: no revision carries it
124
- * (the bill's unattributed does). It is spread over its first K served runs (`workflow` or `handed_back` of its workflow
125
- * at its digest), K its check's compile_after; `state` from its newest record. A revision an earlier reset of the agent's
126
- * learning deleted (`reset`, learn/promote.ts keepResetLedger) is one too, first, stopped, at the K it was kept with,
127
- * unless the records name it again. Serving is the champion's (championOf), skipping what `refused` names (the purge
128
- * gate's), so a purged run's revision is never said to serve. */
129
- export declare function revisionLedgerOf(records: readonly PromotionRecord[], rows: readonly LedgerRow[], compiles?: readonly CompileSpend[], reset?: readonly ResetRevision[], refused?: Refused): ReturnType<typeof amortize>;
130
- /** Run `runId`'s path and its costs as GET /runs/{id} shows them (A8): `path` its record's (metrics.path, RUN_PATHS:
131
- * `agent` for a run that does not learn; null while it has not ended, for a workflow revision's run, and for a run that
132
- * learns whose end named none); `usd` its own spend, the job's (runCostOf's `cost_usd`: its row's cost, `rowUsd` when
133
- * given, less its compile turns; null while unknown); `learning_usd` what learning spent for it: its follow-up rounds'
134
- * turns (learningSpendOf less its compile turns, each its revision's), its audit shadow's cost, and its share of its
135
- * revision's compile and check (revisionLedgerOf); `all_in_usd` the two. A replay or a shadow run carries none: its
136
- * spend is on the runs it serves, so its `learning_usd` and `all_in_usd` are 0, and the sum of every run's `all_in_usd`
137
- * and the bill's `unattributed_usd` is the booked total. While the run is at work `usd` is `rowUsd` and the rest null;
138
- * null while unknown (its shadow still at work, a compile's or a check's cost unknown), never $0. Undefined for an
139
- * unknown run. Its revision's champion skips what `refused` names of the agent's promotion records (agentCostOverStore). */
140
- export declare function runAllInOverStore(store: Store, runId: string, rowUsd?: number | null, refused?: RefusedFor): Promise<{
90
+ /** The agent's ledger read over the one store and summed (learn/ledger.ts summarize): its runs (as runs.list reads
91
+ * them), each one's ledger row and spend rows (Learning.ledger), its promotion records (the revisions' K and state,
92
+ * revisionsOf, skipping what `refused` names) and its audits' shadow runs. `records`: where a run's launch and rounds
93
+ * are read (the agent's at once by default, agentRecordsOf). */
94
+ export declare function agentLedgerOverStore(store: Store, agentId: string, refused?: RefusedFor, records?: RunRecords): Promise<{
95
+ out: Summarized;
96
+ promotions: PromotionRecord[];
97
+ skip: Refused | undefined;
98
+ listed: RunRecord[];
99
+ }>;
100
+ /** Whether run `run`'s ledger row stands for it as it is now: written for the end the run has (`epoch`, the run's epoch
101
+ * after the end that wrote it: run-patch.ts recordLedger), with no cost healed since. A runner or server of the build
102
+ * before the ledger writes none: its end of a run again (a follow-up's, or a grade's round that keeps the end it had, at
103
+ * the same ended_at) moves the run's epoch, as every end and every claim does, and its heal of a cost (Runs.healCost:
104
+ * only over an unknown cost, at the same epoch and end) makes the cost known. Either leaves the row for the run as it
105
+ * was, and its reader records it again from the run's row (record), as for a run with no row. A cancel that wins an
106
+ * end moves its ended_at alone (run-patch.ts refuseLeftovers): the row stands. */
107
+ export declare function ledgerRowStands(row: Pick<LedgerRow, "cost"> & {
108
+ readonly epoch: number;
109
+ }, run: Pick<RunRecord, "epoch" | "costUsd" | "costAtMostUsd">): boolean;
110
+ /** Each revision of the agent's learned workflows its promotion records name (one per workflow and digest, in the order
111
+ * they were first recorded), with the served runs its spend is spread over (K, its check's compile_after) and `state`
112
+ * from its newest record: `checking` while its check replays, `serving` for the champion (championOf, skipping what
113
+ * `refused` names: the purge gate's, so a purged run's revision is never said to serve), else `stopped`. A revision an
114
+ * earlier reset of the agent's learning deleted (`reset`, learn/promote.ts keepResetLedger) comes first, stopped, at the
115
+ * K it was kept with, unless the records name it again. What each one spent is the ledger's (learn/ledger.ts summarize),
116
+ * whatever the records say. */
117
+ export declare function revisionsOf(records: readonly PromotionRecord[], reset?: readonly ResetRevision[], refused?: Refused): RevisionAt[];
118
+ /** A run's costs as GET /runs/{id} shows them (RunAllIn, runAllInOverStore). */
119
+ export type RunAllIn = {
141
120
  path: RunPath | null;
142
- usd: number | null;
143
- learning_usd: number | null;
144
- all_in_usd: number | null;
145
- } | undefined>;
121
+ } & Pick<RunFigures, "usd" | "learning_usd" | "all_in_usd" | "compile_usd" | "followup_usd" | "shadow_usd" | "share_usd">;
122
+ /** Run `runId`'s path and its costs as GET /runs/{id} shows them (A8), the figures GET .../learning/cost reads for it
123
+ * (learn/ledger.ts figuresOf over its ledger row: one formula): `path` its record's (metrics.path, RUN_PATHS: `agent`
124
+ * for a run that does not learn; null while it has not ended, for a workflow revision's run, and for a run that learns
125
+ * whose end named none); `usd` its own spend, the job's (its look-back left out); `learning_usd` what learning spent for
126
+ * it: its follow-up rounds' turns, its audit shadow's cost, and its share of its revision's compile and check (its own
127
+ * compile turns are its revision's: `compile_usd`); `all_in_usd` the two; and `learning_usd`'s parts. A replay or a
128
+ * shadow run carries none: its spend is on the runs it serves, so its `learning_usd` and `all_in_usd` are 0, and the sum
129
+ * of every run's `all_in_usd` and the bill's `unattributed_usd` is the booked total. `rowUsd`: the cost its view reads
130
+ * (its row's when absent); one other than its row's (an imported run's estimate, a booking where its end stored none)
131
+ * is its job's, less its look-back. While the run is at work `usd` is `rowUsd` and the rest null; null while unknown (its shadow still at work, a compile's or
132
+ * a check's cost unknown), never $0. Undefined for an unknown run. A served run's share is the agent's ledger's
133
+ * (agentLedgerOverStore), its revision's champion skipping what `refused` names of the agent's promotion records. */
134
+ export declare function runAllInOverStore(store: Store, runId: string, rowUsd?: number | null, refused?: RefusedFor): Promise<RunAllIn | undefined>;
146
135
  /** The check the serving promotion was decided on, as the cost summary says it: the champion (championOf) of the learned
147
136
  * workflow the newest run a learned workflow ran first on ran (`workflow` or `handed_back`), its record's check numbers
148
137
  * (the share of the inputs it ran on that said what the agent said, against the agent's own 100%). `cleared`: it passed
149
138
  * (a champion is promoted), with the agreement check it passed (`agreed` of `alone`, its bar `agree_min`). Null when no run was served, nothing serves now (held, or never promoted), or it was promoted
150
139
  * on no input (a dry run). The champion skips what `refused` names (the purge gate's). */
151
140
  export declare function servingReplayOf(records: readonly PromotionRecord[], runs: readonly CostRun[], refused?: Refused): CostReplay | null;
152
- /** What run `runId`'s learning spent, as its cost per run counts it, over every round a follow-up opened (roundsOf): what
153
- * it kept as it answered (answeredOf). A run a follow-up opened again (roundsSpendOf's figures): its job is what it had
154
- * cost when its first round answered, and everything after (each later round's follow-up turn and every round's
155
- * look-back: feedback the run was given is learning, never the job) is its look-back here, `rowUsd` (the run's row cost)
156
- * less that job (roundsLooked). */
157
- export declare function learningSpendOf(store: RunRecords, runId: string, rowUsd: number | null): Promise<ReturnType<typeof answeredOf> | null>;
158
141
  /** Every round run `runId` kept (one a follow-up opened again is a round past its first), oldest first: none when it kept
159
142
  * no learning. The store's proposal(runId) is the newest round alone; a read of what the run's learning did or spent
160
143
  * reads them all. */
161
144
  export declare function roundsOf(store: Pick<RunRecords, "learning">, runId: string): Promise<LearningProposal[]>;
162
145
  type RunRecord = NonNullable<Awaited<ReturnType<Store["runs"]["get"]>>>;
163
- /** A run's own cost and what learning added for it (runCostOf): its row's cost, every round of its learning
164
- * (learningSpendOf) and its audit's shadow run (shadowSpendOf). `total_usd` is the run's all-in cost, the one the cost page shows and the money rule reads
165
- * (pastRunsOverStore); null when any part is unknown. */
166
- export declare function allInOf(store: RunRecords, run: RunRecord): Promise<ReturnType<typeof runCostOf>>;
167
- /** What run `runId`'s audit shadow run (runner/audit.ts) adds to its all-in cost: `open` while it is queued or running
168
- * (its cost not known yet: `usd` null, never $0), else its cost once it ended, stopped or failed (null: unknown); 0 when
169
- * none was started, and for a shadow itself. */
170
- export declare function shadowSpendOf(store: {
171
- readonly runs: Pick<RunRecords["runs"], "get">;
172
- }, runId: string): Promise<{
173
- open: boolean;
174
- usd: number | null;
175
- }>;
176
- /** One run of the cost series, as number `n` of it (null for a replay), `placed` its path and workflow as pathOfRow reads
177
- * them off its record (agentCostOverStore has them): its figures (allInOf), the workflow
178
- * revision that ran it and whether an audit's shadow ran for it (agentCostOverStore's loop body); `took_over` is the
179
- * series' (tookOverOf). */
180
- export declare function costRunOf(store: RunRecords, run: RunRecord, n: number | null, { path, workflow }: {
181
- path: RunPath;
182
- workflow: string | null;
183
- }): Promise<Omit<CostRun, "took_over">>;
184
- /** The runs the money rule reads for agent `agentId` (runner/workflow-first.ts costLineOf), one set for the run's launch
185
- * and the cost page: of its newest PAST_RUNS runs on no named disk (learn/learning-of.ts: one on a named disk learns
186
- * nothing), each that ended (ended, stopped or failed) since its learning's reset (learn/compile.ts sinceReset: a
187
- * workflow before it is not the one it learned after, whatever its name), is neither imported nor archived nor a
188
- * workflow revision's run, with its all-in cost (allInOf). `known`: all-in costs already read, by run id (the cost
189
- * page's series), read again for no run; `records`, where any other's rows are read (the store's by default). */
190
- export declare function pastRunsOverStore(store: Store, agentId: string, known?: ReadonlyMap<string, number | null>, records?: RunRecords): Promise<PastRun[]>;
146
+ /** What the money rule reads of the agent (runner/workflow-first.ts PastRuns) off its summed ledger (`out`, a
147
+ * summarize over `listed`, its runs as runs.list read them, newest first): of its newest PAST_RUNS runs on no named disk
148
+ * (learn/learning-of.ts: one on a named disk learns nothing), those since its learning's reset (`since`,
149
+ * learn/compile.ts sinceReset: a workflow before it is not the one it learned after, whatever its name), each series
150
+ * run among them with its all-in cost as the series reads it (RunFigures.series_total_usd), and the by-hand side over
151
+ * those same runs: the mean job's own $ (RunFigures.usd: no compile turn, follow-up or shadow) of the ones on the
152
+ * `agent` path, with the ones its mean left out (cost unknown or only a bound). The served side and the by-hand side
153
+ * read one set of runs: the cost page and a run's launch read the same window (pastRunsOverStore). */
154
+ export declare function pastRunsOf(out: Summarized, listed: readonly RunRecord[], since: (row: Pick<RunRecord, "id" | "startedAt">) => boolean): PastRuns;
155
+ /** What the money rule reads for agent `agentId` at a run's launch (pastRunsOf), bounded whatever the agent's history:
156
+ * its newest PAST_RUNS runs on no named disk (one runs.list page), the ledger of those runs alone (Learning.ledger with
157
+ * their ids), and each one's launch or rounds read only where its row needs them (no ledger row, a stale one, or no
158
+ * path). Summed with no revision records: the money rule reads each run's own all-in and job $, never a revision's
159
+ * share. The cost page reads the same window of the same figures (agentCostOverStore). */
160
+ export declare function pastRunsOverStore(store: Store, agentId: string): Promise<PastRuns>;
191
161
  /** The money rule's decision for agent `agentId` (runner/workflow-first.ts costStopOf) over the runs a run's launch reads
192
162
  * (pastRunsOverStore), as the launch reads them: runs that can't be read now stop nothing (workflowFirstOf serves). What
193
163
  * the promotions read and the learning view fold into each workflow's state (learn/promote.ts servingStateOf). */
@@ -199,15 +169,17 @@ export declare const costStopOverStore: (store: Store, agentId: string) => Promi
199
169
  * new answer is the agent's, with its digest. Else, for a run its launch offered a learned workflow, its timeline
200
170
  * (runner/learning-end.ts runPathOf, the agent calling the tool itself): `workflow` when its job did only that,
201
171
  * `handed_back` when the agent went on, with the workflow its job called last. Any other run's path is `agent`. Both
202
- * read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's round never moves the path. */
172
+ * read the run's rows less its feedback rounds' (withoutFeedbackRounds): a grade's round never moves the path. `cut` on a
173
+ * hand-back a restart cut (servedOf: the workflow's call ended `interrupted`), never one the workflow made itself. */
203
174
  export declare function runPathOverStore(store: Store, runId: string, started: RunLaunch["learning"], redact?: (text: string) => string): Promise<{
204
175
  path: RunPath;
205
176
  workflow: string | null;
206
177
  digest?: string;
207
178
  promotion?: number;
179
+ cut?: true;
208
180
  }>;
209
181
  /** The path a run's views say it took (GET /runs/{id} and each runs list row: `path`, and `workflow`), read off its record
210
- * as the cost per run reads it (pathOfRow, revisionOfRow: costRunOf's own read, so the run views and GET
182
+ * as the cost per run reads it (pathOfRow, revisionOfRow: the ledger read's own, so the run views and GET
211
183
  * .../learning/cost never disagree). `path` is null for a run not ended, a workflow revision's run, and a run that learns
212
184
  * whose record names none; `workflow` names the learned workflow and its revision only on a run it served (path
213
185
  * `workflow` or `handed_back`; the name only when its launch offered one, the digest null when its record names none,
@@ -229,25 +201,13 @@ type Laid = {
229
201
  };
230
202
  /** What every claim of a run laid, from its learningLaid entries, each name once. None laid when it has no entry. */
231
203
  export declare function laidOf(entries: readonly Pick<EntryLike, "kind" | "data">[]): Laid;
232
- /** What every round of a run that a follow-up opened again spent (undefined for a run with one round): when its first
233
- * round's job answered and what the job cost to then, and the look-backs of every round added up. A figure that is
234
- * unknown in any round is unknown (null). */
235
- type RoundsSpend = {
236
- answered_at: string;
237
- job_cost_usd: number | null;
238
- look_back_usd: number | null;
239
- };
240
- /** What a run with rounds (`rounds`) kept as it answered, as its cost per run and its impact both read it: its job is
241
- * what it had cost when its first round answered; everything its row (`rowUsd`) spent after that (each later round's
242
- * follow-up turn and every round's look-back: feedback the run was given is learning, never the job) is its look-back;
243
- * unknown when the row's cost is and the job's is known (the request no one priced came after the job answered: a later
244
- * round stopped mid-request keeps no figures, so the rounds' sum would read short as if settled); the rounds'
245
- * look-backs added up when the job's cost is unknown. */
246
- export declare function roundsLooked(rounds: RoundsSpend, rowUsd: number | null): RoundsSpend;
247
- export declare function roundsSpendOf(store: RunRecords, runId: string): Promise<RoundsSpend | undefined>;
204
+ /** What every round of run `runId` spent when a follow-up opened it again (learn/ledger.ts roundsSpentIn): when its first
205
+ * round's job answered and what the job cost to then, and the look-backs of every round added up (null once one is
206
+ * unknown); undefined for a run with one round, or none that answered. */
207
+ export declare function roundsSpendOf(store: Pick<RunRecords, "learning">, runId: string): Promise<Answered | undefined>;
248
208
  /** What a run's learning end tells its impact: how it ended and when, the corrections and workflows it started from, when
249
209
  * its job answered and its costs once it looked back (a look-back of 0 for an ended one that did not). */
250
- export declare function impactLearningOf(end: RunLearningEnd, started: RunLaunch["learning"], laid: Laid | undefined, rounds?: RoundsSpend, rowUsd?: number | null): ImpactLearning;
210
+ export declare function impactLearningOf(end: RunLearningEnd, started: RunLaunch["learning"], laid: Laid | undefined, rounds?: Answered, rowUsd?: number | null): ImpactLearning;
251
211
  /** What a run's job did with the learned workflows its launch offered it (GET /runs/{id}/learning `used`): each learned
252
212
  * workflow the job called, by the call's `name` (callArgsOf), how many calls and how many failed. The end-of-run turn's
253
213
  * rows are left out. */
@@ -312,10 +272,10 @@ export declare function runLearningOverStore(store: Store, runId: string, shown:
312
272
  } | {
313
273
  graded: {
314
274
  workflow: string | null;
315
- feedback_status: "running" | "ended" | "not_run" | null;
275
+ feedback_status: "ended" | "running" | "not_run" | null;
316
276
  source: "feedback" | "eval";
317
277
  graded_at: string;
318
- path: "agent" | "workflow" | "replay" | "audit" | "handed_back";
278
+ path: "agent" | "handed_back" | "workflow" | "replay" | "audit";
319
279
  workflow_digest: string | null;
320
280
  feedback: "correction" | null;
321
281
  run_id: string;