@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.30

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 (273) hide show
  1. package/CHANGELOG.md +748 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +2190 -2
  5. package/dist/adapters.d.ts +234 -0
  6. package/dist/adapters.js +585 -0
  7. package/dist/agents.d.ts +130 -0
  8. package/dist/agents.js +308 -0
  9. package/dist/app.d.ts +7 -0
  10. package/dist/app.js +384 -0
  11. package/dist/background.d.ts +28 -0
  12. package/dist/background.js +376 -0
  13. package/dist/bound-files.d.ts +4 -0
  14. package/dist/bound-files.js +164 -0
  15. package/dist/box/record.d.ts +6 -0
  16. package/dist/box/record.js +41 -0
  17. package/dist/box/sweep.d.ts +53 -0
  18. package/dist/box/sweep.js +193 -0
  19. package/dist/box-egress.d.ts +98 -0
  20. package/dist/box-egress.js +259 -0
  21. package/dist/box-image.d.ts +98 -0
  22. package/dist/box-image.js +285 -0
  23. package/dist/box-relay-vm.d.ts +80 -0
  24. package/dist/box-relay-vm.js +389 -0
  25. package/dist/box-relay.d.ts +45 -0
  26. package/dist/box-relay.js +227 -0
  27. package/dist/boxes.d.ts +72 -0
  28. package/dist/boxes.js +189 -0
  29. package/dist/browser-cost.d.ts +41 -0
  30. package/dist/browser-cost.js +158 -0
  31. package/dist/cap.d.ts +332 -0
  32. package/dist/cap.js +992 -0
  33. package/dist/catalog.d.ts +20 -0
  34. package/dist/catalog.js +53 -0
  35. package/dist/cli.d.ts +2 -0
  36. package/dist/cli.js +167 -0
  37. package/dist/coding-tools.d.ts +35 -0
  38. package/dist/coding-tools.js +87 -0
  39. package/dist/console/THIRD-PARTY-NOTICES.txt +1721 -0
  40. package/dist/console/assets/index-34jfpIbQ.js +481 -0
  41. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  42. package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  43. package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
  44. package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
  45. package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
  46. package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
  47. package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
  48. package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
  49. package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
  50. package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  51. package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
  52. package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
  53. package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
  54. package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
  55. package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  56. package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  57. package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
  58. package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  59. package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
  60. package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
  61. package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
  62. package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
  63. package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
  64. package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
  65. package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
  66. package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
  67. package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
  68. package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
  69. package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
  70. package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
  71. package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
  72. package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
  73. package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
  74. package/dist/console/index.html +15 -0
  75. package/dist/content-filter.d.ts +7 -0
  76. package/dist/content-filter.js +23 -0
  77. package/dist/daytona-api.d.ts +21 -0
  78. package/dist/daytona-api.js +101 -0
  79. package/dist/decision-rows.d.ts +19 -0
  80. package/dist/decision-rows.js +123 -0
  81. package/dist/decisions.d.ts +94 -0
  82. package/dist/decisions.js +184 -0
  83. package/dist/effort-guidance.d.ts +5 -0
  84. package/dist/effort-guidance.js +14 -0
  85. package/dist/environment.d.ts +5 -0
  86. package/dist/environment.js +11 -0
  87. package/dist/errors.d.ts +74 -0
  88. package/dist/errors.js +69 -0
  89. package/dist/exa-keyless.d.ts +35 -0
  90. package/dist/exa-keyless.js +202 -0
  91. package/dist/fetch-page.d.ts +114 -0
  92. package/dist/fetch-page.js +182 -0
  93. package/dist/files.d.ts +65 -0
  94. package/dist/files.js +158 -0
  95. package/dist/grade.d.ts +93 -0
  96. package/dist/grade.js +328 -0
  97. package/dist/graph-served.d.ts +23 -0
  98. package/dist/graph-served.js +75 -0
  99. package/dist/graph-view.d.ts +102 -0
  100. package/dist/graph-view.js +219 -0
  101. package/dist/harness-app.d.ts +40 -0
  102. package/dist/harness-app.js +708 -0
  103. package/dist/harness-opencode/adapter.d.ts +45 -0
  104. package/dist/harness-opencode/adapter.js +272 -0
  105. package/dist/harness-opencode/binary.d.ts +18 -0
  106. package/dist/harness-opencode/binary.js +87 -0
  107. package/dist/harness-opencode/config.d.ts +24 -0
  108. package/dist/harness-opencode/config.js +61 -0
  109. package/dist/harness-opencode/harness.d.ts +77 -0
  110. package/dist/harness-opencode/harness.js +620 -0
  111. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  112. package/dist/harness-opencode/host/mcp.js +208 -0
  113. package/dist/harness-opencode/host/policy.d.ts +71 -0
  114. package/dist/harness-opencode/host/policy.js +419 -0
  115. package/dist/harness-opencode/host/server.d.ts +55 -0
  116. package/dist/harness-opencode/host/server.js +165 -0
  117. package/dist/harness-opencode/index.d.ts +9 -0
  118. package/dist/harness-opencode/index.js +6 -0
  119. package/dist/harness-opencode/verify.d.ts +32 -0
  120. package/dist/harness-opencode/verify.js +75 -0
  121. package/dist/harness-opencode/versions.d.ts +33 -0
  122. package/dist/harness-opencode/versions.js +64 -0
  123. package/dist/harness.d.ts +56 -0
  124. package/dist/harness.js +77 -0
  125. package/dist/home-path.d.ts +27 -0
  126. package/dist/home-path.js +78 -0
  127. package/dist/host-tools.d.ts +30 -0
  128. package/dist/host-tools.js +154 -0
  129. package/dist/host.d.ts +39 -0
  130. package/dist/host.js +85 -0
  131. package/dist/hosted-search.d.ts +27 -0
  132. package/dist/hosted-search.js +133 -0
  133. package/dist/import-sources.d.ts +104 -0
  134. package/dist/import-sources.js +629 -0
  135. package/dist/import-summary.d.ts +25 -0
  136. package/dist/import-summary.js +75 -0
  137. package/dist/import-worker.d.ts +26 -0
  138. package/dist/import-worker.js +41 -0
  139. package/dist/import.d.ts +145 -0
  140. package/dist/import.js +1222 -0
  141. package/dist/index.d.ts +7 -0
  142. package/dist/index.js +6 -0
  143. package/dist/key-check.d.ts +37 -0
  144. package/dist/key-check.js +112 -0
  145. package/dist/key-refusal.d.ts +51 -0
  146. package/dist/key-refusal.js +191 -0
  147. package/dist/learn/check.d.ts +108 -0
  148. package/dist/learn/check.js +277 -0
  149. package/dist/learn/grade.d.ts +80 -0
  150. package/dist/learn/grade.js +445 -0
  151. package/dist/learn/index.d.ts +7 -0
  152. package/dist/learn/index.js +11 -0
  153. package/dist/learn/invisible.d.ts +5 -0
  154. package/dist/learn/invisible.js +42 -0
  155. package/dist/learn/notes.d.ts +59 -0
  156. package/dist/learn/notes.js +147 -0
  157. package/dist/learn/reflect.d.ts +49 -0
  158. package/dist/learn/reflect.js +213 -0
  159. package/dist/learn/secrets.d.ts +18 -0
  160. package/dist/learn/secrets.js +131 -0
  161. package/dist/learn/skills.d.ts +97 -0
  162. package/dist/learn/skills.js +271 -0
  163. package/dist/learned-workflow.d.ts +59 -0
  164. package/dist/learned-workflow.js +191 -0
  165. package/dist/learning-routes.d.ts +196 -0
  166. package/dist/learning-routes.js +609 -0
  167. package/dist/learning-run.d.ts +306 -0
  168. package/dist/learning-run.js +819 -0
  169. package/dist/learning-words.d.ts +76 -0
  170. package/dist/learning-words.js +174 -0
  171. package/dist/learning.d.ts +418 -0
  172. package/dist/learning.js +946 -0
  173. package/dist/llm.d.ts +40 -0
  174. package/dist/llm.js +37 -0
  175. package/dist/llms.txt +37 -0
  176. package/dist/mcp-servers.d.ts +118 -0
  177. package/dist/mcp-servers.js +450 -0
  178. package/dist/mcp.d.ts +51 -0
  179. package/dist/mcp.js +392 -0
  180. package/dist/model.d.ts +186 -0
  181. package/dist/model.js +485 -0
  182. package/dist/monid.d.ts +74 -0
  183. package/dist/monid.js +277 -0
  184. package/dist/openapi/agentrun-v2.openapi.json +4806 -0
  185. package/dist/openapi.d.ts +10 -0
  186. package/dist/openapi.js +1727 -0
  187. package/dist/owner.d.ts +55 -0
  188. package/dist/owner.js +222 -0
  189. package/dist/packs.d.ts +71 -0
  190. package/dist/packs.js +180 -0
  191. package/dist/page.d.ts +32 -0
  192. package/dist/page.js +133 -0
  193. package/dist/paid-calls.d.ts +50 -0
  194. package/dist/paid-calls.js +110 -0
  195. package/dist/pause.d.ts +70 -0
  196. package/dist/pause.js +97 -0
  197. package/dist/pdf-pages.d.ts +44 -0
  198. package/dist/pdf-pages.js +147 -0
  199. package/dist/place.d.ts +69 -0
  200. package/dist/place.js +137 -0
  201. package/dist/print.d.ts +20 -0
  202. package/dist/print.js +29 -0
  203. package/dist/propose.d.ts +40 -0
  204. package/dist/propose.js +112 -0
  205. package/dist/quiet-sqlite-warning.d.ts +1 -0
  206. package/dist/quiet-sqlite-warning.js +14 -0
  207. package/dist/request-start.d.ts +22 -0
  208. package/dist/request-start.js +350 -0
  209. package/dist/result.d.ts +3 -0
  210. package/dist/result.js +5 -0
  211. package/dist/rows.d.ts +46 -0
  212. package/dist/rows.js +121 -0
  213. package/dist/run-box.d.ts +186 -0
  214. package/dist/run-box.js +590 -0
  215. package/dist/run-manifest.d.ts +27 -0
  216. package/dist/run-manifest.js +60 -0
  217. package/dist/runnable.d.ts +83 -0
  218. package/dist/runnable.js +170 -0
  219. package/dist/runs.d.ts +1062 -0
  220. package/dist/runs.js +3020 -0
  221. package/dist/secret-cut.d.ts +27 -0
  222. package/dist/secret-cut.js +109 -0
  223. package/dist/secrets.d.ts +62 -0
  224. package/dist/secrets.js +158 -0
  225. package/dist/server-lock.d.ts +44 -0
  226. package/dist/server-lock.js +140 -0
  227. package/dist/server.d.ts +722 -0
  228. package/dist/server.js +2118 -0
  229. package/dist/sessions.d.ts +4 -0
  230. package/dist/sessions.js +105 -0
  231. package/dist/sign-ins.d.ts +99 -0
  232. package/dist/sign-ins.js +288 -0
  233. package/dist/skills.d.ts +43 -0
  234. package/dist/skills.js +96 -0
  235. package/dist/stats.d.ts +106 -0
  236. package/dist/stats.js +103 -0
  237. package/dist/tool-gate.d.ts +266 -0
  238. package/dist/tool-gate.js +554 -0
  239. package/dist/tool-keys.d.ts +187 -0
  240. package/dist/tool-keys.js +315 -0
  241. package/dist/tool-plane.d.ts +228 -0
  242. package/dist/tool-plane.js +400 -0
  243. package/dist/tools.d.ts +202 -0
  244. package/dist/tools.js +372 -0
  245. package/dist/trigger-secrets.d.ts +32 -0
  246. package/dist/trigger-secrets.js +143 -0
  247. package/dist/triggers.d.ts +439 -0
  248. package/dist/triggers.js +863 -0
  249. package/dist/turn-end.d.ts +24 -0
  250. package/dist/turn-end.js +15 -0
  251. package/dist/turns.d.ts +34 -0
  252. package/dist/turns.js +202 -0
  253. package/dist/uploads.d.ts +104 -0
  254. package/dist/uploads.js +474 -0
  255. package/dist/usage-lines.d.ts +26 -0
  256. package/dist/usage-lines.js +28 -0
  257. package/dist/usage.d.ts +29 -0
  258. package/dist/usage.js +58 -0
  259. package/dist/validate.d.ts +57 -0
  260. package/dist/validate.js +184 -0
  261. package/dist/web-fetch.d.ts +64 -0
  262. package/dist/web-fetch.js +262 -0
  263. package/dist/web-search.d.ts +54 -0
  264. package/dist/web-search.js +136 -0
  265. package/dist/webhooks.d.ts +189 -0
  266. package/dist/webhooks.js +503 -0
  267. package/dist/workspace-paths.d.ts +33 -0
  268. package/dist/workspace-paths.js +104 -0
  269. package/dist/workspace.d.ts +88 -0
  270. package/dist/workspace.js +369 -0
  271. package/launcher/agentrun-serve +109 -0
  272. package/package.json +100 -4
  273. package/skills/agentrun-serve/SKILL.md +128 -0
package/dist/runs.d.ts ADDED
@@ -0,0 +1,1062 @@
1
+ import { type ChildProcess } from "node:child_process";
2
+ import { type Revision, type RevisionKind, type RunOrigin, type RunRow } from "@parcha/pi-durable-agent";
3
+ import { type MessageOrigin, type RunMetrics, type TimelineEvent } from "@parcha/pi-durable-agent/timeline";
4
+ import type { RUN_EVENTS, RunNotice } from "./webhooks.js";
5
+ import type { RunTrigger } from "./triggers.js";
6
+ import { type AgentEntry, type Agents } from "./agents.js";
7
+ import { type DaytonaApi } from "./daytona-api.js";
8
+ import { type Learning, type LearningMode, type LearningReason, type LearningState } from "./learning.js";
9
+ import { LearningRuns, type Reflect } from "./learning-run.js";
10
+ import { type BoxHost, type Quarantine } from "./box/sweep.js";
11
+ import { type RefusalFigures } from "./cap.js";
12
+ import { type Tier } from "./model.js";
13
+ import { type Plane, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
14
+ import { type PendingApproval } from "./tool-gate.js";
15
+ import { type Page, RowLog } from "./rows.js";
16
+ import { type Json } from "./validate.js";
17
+ import { Turns } from "./turns.js";
18
+ import { type StoredKeys } from "./secrets.js";
19
+ import type { HandedSignIn, SignIns } from "./sign-ins.js";
20
+ import { type Place } from "./place.js";
21
+ import type { BoxProvider } from "@parcha/pi-transport";
22
+ import type { RemoteLimits } from "./run-box.js";
23
+ import type { Emitted } from "./webhooks.js";
24
+ export type Status = "queued" | "working" | "paused" | "input_required" | "completed" | "failed" | "cancelled";
25
+ export type State = "working" | "waiting" | "idle";
26
+ export declare const STATUSES: readonly Status[];
27
+ type RunMeta = {
28
+ title: string;
29
+ created_at: string;
30
+ /** The run's input: an agentic run's first message is its `content`, a workflow run's input is the whole of it. */
31
+ input?: Json;
32
+ effort?: string;
33
+ max_cost_usd?: number;
34
+ /** Each raise of its cap (PATCH /runs/{id}): from what, to what, when, and the pause it answers (pauseOf), if any. */
35
+ cap_raised?: {
36
+ from: number;
37
+ to: number;
38
+ at: string;
39
+ pause?: string;
40
+ }[];
41
+ /** The one follow-up that sends a run paused at its cap on once its cap is raised (resumeRaised): for which pause, by
42
+ * what id, whether it went, how many tries failed and why, and which process was being let go when it was asked for
43
+ * (its pid and start ticks): it goes once that process is gone, here or after a restart. */
44
+ cap_continue?: {
45
+ pause: string;
46
+ message_id: string;
47
+ sent: boolean;
48
+ tries: number;
49
+ error?: string;
50
+ paused?: string;
51
+ };
52
+ error?: {
53
+ code: string;
54
+ message: string;
55
+ details?: {
56
+ reason: string;
57
+ };
58
+ };
59
+ /** A workflow run's output, once it completed. */
60
+ output?: unknown;
61
+ /** A workflow run that escalated: what a person is to look at. Its time is the run's saved end, read with it. */
62
+ review?: SavedReview;
63
+ /** Where the run stood when its turn was stopped: the person's last message, by its timeline row's id (its store
64
+ * entry's), or the root conversation's place 0 before any. It stays stopped until a message newer than that is shown. */
65
+ stopped_at?: string;
66
+ /** A run stopped by an older server: how many messages the person had sent then. Read only when `stopped_at` is not. */
67
+ stopped_after?: number;
68
+ /** What its newest process took its thinking level from (app.ts's thinkingOf), as its environment had them: `effort`,
69
+ * the run's effort, and `host`, the host's AGENT_THINKING. Absent for a process an older server started. */
70
+ launch_thinking?: {
71
+ effort?: string;
72
+ host?: string;
73
+ };
74
+ /** Its tools' providers, resolved at its first launch and kept for its life (tool-plane.ts). */
75
+ tool_plane?: Plane;
76
+ /** Where it runs, as its start resolved it (place.ts): its process reads it. Absent for a run an older server started,
77
+ * which ran on the runner. */
78
+ place?: Place;
79
+ /** Where the run's learning stands (learning.ts); absent for a run that does not learn. */
80
+ learning?: Learning;
81
+ /** The run's end-of-run turn, saved before it is asked. */
82
+ reflect?: Reflect;
83
+ /** A run whose cost was unknown when it ended: the sum of its charges whose cost is known, and how many have none
84
+ * (costsofar/1), as its view said then, so a list row read from the store says it too. */
85
+ cost_so_far?: SoFar;
86
+ /** A person's answer to each tool call that waited for approval (tool-gate.ts), by its id: the first one wins, and
87
+ * the run's process reads it here. A cancel marks one still waiting canceled. */
88
+ approvals?: Record<string, ApprovalAnswer>;
89
+ /** A cancel that waits for the run's gate to cut the approved calls it overrode (Runs.cancel): their ids, kept so an
90
+ * operator (and a test) reads that it did, never how long it took. Absent on a cancel that waits on nothing. */
91
+ cancel_waits_for?: string[];
92
+ /** The trigger that started it, and its firing's key (triggers.ts); absent for a run a caller started. */
93
+ trigger?: RunTrigger;
94
+ };
95
+ /** A tool call that waited for a person's approval, as the run's store has it (tool-gate.ts): `resolved` once the run's
96
+ * process acted on the answer. */
97
+ type Approval = {
98
+ id: string;
99
+ tool: string;
100
+ call_id: string;
101
+ args_json: string;
102
+ requested_at: string;
103
+ price?: number | "not metered";
104
+ resolved?: true;
105
+ };
106
+ /** `args_shown`: the call's arguments as the server shows them (shownArgs), which the gate's resume message names. */
107
+ /** `by`: "message", a deny a person's message gave while the call waited (Runs.message). */
108
+ /** `superseded`: the answer a stop or a cancel overrode before the run's process acted on it, kept as it was given. */
109
+ type ApprovalAnswer = {
110
+ decision: "allow" | "deny" | "canceled" | "withdrawn";
111
+ note?: string;
112
+ answered_at: string;
113
+ args_shown?: string;
114
+ by?: "message";
115
+ superseded?: {
116
+ decision: string;
117
+ answered_at: string;
118
+ note?: string;
119
+ by?: "message";
120
+ };
121
+ };
122
+ type RunError = {
123
+ code: string;
124
+ message: string;
125
+ retryable: boolean;
126
+ details?: {
127
+ reason: string;
128
+ };
129
+ };
130
+ /** Why an escalated workflow run waits for a person: the escalation's kind, the escalate node's label, its summary,
131
+ * and when the run ended (`at`, the run's `ended_at`). */
132
+ export type RunReview = {
133
+ kind: string | null;
134
+ node: string | null;
135
+ reason: string;
136
+ at: string;
137
+ };
138
+ /** A review as serve.json keeps it: `at` is not kept, as it is the run's saved end, which the store stamps. */
139
+ type SavedReview = Omit<RunReview, "at">;
140
+ /** One run as this server holds it. */
141
+ /** A run's answer or output as a view served it: `out`, redacted from `input` over the held values whose digest is `keys`. */
142
+ type Served = {
143
+ keys: string;
144
+ input: unknown;
145
+ out: unknown;
146
+ };
147
+ export type Run = {
148
+ id: string;
149
+ /** The values of the secrets each launch handed its process: what its errors never show, a key rotated since included. */
150
+ handed?: Set<string>;
151
+ /** What a view last served of its answer and its workflow output (runs.ts servedOnce), with what it was made from. */
152
+ served?: {
153
+ answer?: Served;
154
+ output?: Served;
155
+ };
156
+ agentId: string;
157
+ kind: RevisionKind;
158
+ revision: string;
159
+ /** The harness its revision names (pi when it names none, or its revision is gone). */
160
+ harness: string;
161
+ /** The newest store entry the run has shown. */
162
+ lastEntry?: number;
163
+ /** What the live path's rows keep served (keepCommitted), for a learning row shown between its snapshots. */
164
+ keep?: (id: string) => boolean;
165
+ /** What its pinned revision's tools resolve from (tool-plane.ts), resolved again at each launch. */
166
+ tooling?: Tooling;
167
+ /** Imported history (`agentrun-serve import`): the source it was run in, and its id there. It takes no message, and a
168
+ * stop or a cancel moves nothing. */
169
+ imported?: {
170
+ source: string;
171
+ session: string;
172
+ };
173
+ /** The revision's number among its agent's. */
174
+ version: number;
175
+ dir: string;
176
+ meta: RunMeta;
177
+ log: RowLog;
178
+ /** The run's rows as they come in (before the log names them), with each `ask_person` answer's waiting row. */
179
+ rows: TimelineEvent[];
180
+ /** The person's messages the run took, and how each one's turn ended (turns.ts): its end is read from them. */
181
+ turns: Turns;
182
+ /** Its tool calls that waited for a person's approval, read from its store's entries, by id. */
183
+ approvals?: Map<string, Approval>;
184
+ /** The whole text of each assistant message of its end-of-run turn, by store entry: what the turn answered, whose
185
+ * notes learning reads (learning-run.ts). */
186
+ turnText?: Map<number, string>;
187
+ child?: ChildProcess;
188
+ /** The pid of a run process an earlier server started that still serves the run: supervised by its run.json. */
189
+ orphan?: number;
190
+ /** Adopted with a saved stop: its first snapshot is checked once, and a turn still working is aborted. */
191
+ finishStop?: boolean;
192
+ /** A completed run opening again for a follow-up: every follow-up meanwhile waits for this one, never a second. */
193
+ reopening?: Promise<void>;
194
+ /** A follow-up to a run whose turn had ended is on its way: a launch it makes opens the run for it (FOLLOW_UP_OPEN_ENV). */
195
+ followUpOpen?: true;
196
+ feed?: AbortController;
197
+ /** An agentic run's turn is running; a workflow run's process serves. */
198
+ working: boolean;
199
+ /** Messages this server sent the run that its rows do not show yet. */
200
+ submitted: number;
201
+ /** The write of its end-of-run turn's origin (toLiveDoor), which a person's turn waits for before it removes it. */
202
+ originWrite?: Promise<unknown>;
203
+ /** The user_message rows the run has shown, by id: one shown for the first time is a submitted message arriving. */
204
+ users: Set<string>;
205
+ /** The rows the live path has shown as live, by id, over every connection to the run's door. */
206
+ live: Set<string>;
207
+ cancel: boolean;
208
+ /** Set when the run has answered or failed and is being let go; the outcome it gets. */
209
+ finishing?: Status;
210
+ /** A stop on its way: from its mark to its abort's answer, or a server's abort of a saved stop's turn that outlived the
211
+ * server before it (finishStop). The abort withdraws every input queued behind that turn, so a message meanwhile waits
212
+ * for it (message). */
213
+ stopping?: true;
214
+ endedAt?: string;
215
+ outcome?: Status;
216
+ error?: RunError;
217
+ /** The cost the store recorded when it carried the run back; null when it recorded none (unknown). */
218
+ costUsd?: number | null;
219
+ /** A workflow run's decisions' cost, from its receipts once its end is read: null when one is unknown. */
220
+ decisionCost?: number | null;
221
+ /** The same decisions, apart: the sum of the costs that are known, and how many are not. */
222
+ decisionsPriced?: {
223
+ known: number;
224
+ unpriced: number;
225
+ };
226
+ /** The saved sign-in its next launch hands its browser (pinSignIn), never kept on disk by the run. */
227
+ signIn?: HandedSignIn;
228
+ /** Whether its process, as last settled, let the run go (and its browser's sessions with it), or went without. */
229
+ letGo?: boolean;
230
+ /** A workflow run's decision rows, from its released store: its timeline shows one row each (decision-rows.ts). Null
231
+ * when they cannot be read: its timeline's usage row then reads unknown. */
232
+ decisions?: Record<string, unknown>[] | null;
233
+ /** How many of a workflow run's llm calls' answers its node log held when its rows were last read: their cost is in its
234
+ * rows (each a REQUEST_COST entry, committed before its answer is logged), so its graph counts only the later ones. */
235
+ llmRead?: number;
236
+ /** What every conversation of its store says it used, as the settle that ends it read them. */
237
+ metrics?: RunMetrics;
238
+ relaunches: number;
239
+ /** Its start's launch is next: the one a deny is told as under ask (relaunchPlane's `first`). */
240
+ firstLaunch?: true;
241
+ /** Its newest launch has not reported back: its mark (RUN_LAUNCHING) is on disk. */
242
+ launching?: boolean;
243
+ /** The store has it running and its serve.json holds no input: its server went down before it set the run up (whose
244
+ * first write is the input), so it never launched. A serve.json written since (its failure, a stop) never adds one. */
245
+ notSetUp?: boolean;
246
+ /** Its files being copied into its work/ before its first launch, until they are: nothing launches it meanwhile (a
247
+ * request that would waits for it), and nothing but a cancel settles it. */
248
+ preparing?: Promise<void>;
249
+ settled: boolean;
250
+ settling?: Promise<void>;
251
+ /** The newest write of its serve.json: one at a time, in order. */
252
+ saving?: Promise<void>;
253
+ /** Settles of this run not yet done: while any is, nothing starts its process again. */
254
+ settles: number;
255
+ updatedAt: string;
256
+ /** Its own door token (RUN_DOOR_TOKEN), once read or made; absent for a run an older server started, whose door takes
257
+ * the server-wide one. */
258
+ doorToken?: string;
259
+ /** A remote box's making and seed, asked by the run's process through the relay: one at a time. */
260
+ boxing?: Promise<{
261
+ id: string;
262
+ made: boolean;
263
+ }>;
264
+ /** Its remote box's newest pull: a read of its files waits for it. */
265
+ pulling?: Promise<void>;
266
+ /** It stood waiting for the person when last marked: a turn's end is the change into that. */
267
+ waited?: boolean;
268
+ /** The pause at its cap (its mark) whose process was let go: once per pause. */
269
+ parked?: string;
270
+ /** A raise of its cap being taken (raiseCap): the next one waits for it, so two at once resume it once. */
271
+ raising?: Promise<unknown>;
272
+ /** Its raise's follow-up is being sent (resumeRaised), or waits to be tried again (its time): never two at once. */
273
+ resuming?: "sending" | number;
274
+ /** Its newest refusal for room's figures, from that refusal's own start mark (cap.ts RefusalFigures). */
275
+ capRefusal?: RefusalFigures;
276
+ /** That refusal's own start mark (its entry): the pause a raise answers is keyed to it (pauseOf). */
277
+ capMark?: number;
278
+ /** What it has spent paused at that refusal (its row), its process gone: the store's spend (spentNow), read once. */
279
+ capSpent?: {
280
+ mark: string;
281
+ usd: number | null;
282
+ at?: number;
283
+ };
284
+ };
285
+ /** The waiting row after each answered `ask_person` call, which the timeline module does not know. The question comes
286
+ * from the call's row, whose label this module registers. */
287
+ export declare function withAsks(rows: readonly TimelineEvent[]): TimelineEvent[];
288
+ /** The row that says a run's booked spend passed its cap, and by how much, after its usage row: a request's cost is
289
+ * booked once it answers, and one carrying a native web search is held at an allowance, not a bound (cap.ts), so a run
290
+ * can pass its cap by its last request. The next request is then refused, and the run ends spend_cap_reached. */
291
+ export declare function withOverCap(rows: TimelineEvent[], cap: number | undefined): TimelineEvent[];
292
+ /** What a run waits on, as `pending` says it (one field for every kind; a tool call waiting on approval is another):
293
+ * the question a waiting run asked, read from its last meaningful row (withAsks' waiting row), the same row its
294
+ * status reads, never from a scan of its timeline. */
295
+ type Pending = {
296
+ kind: "question";
297
+ question: string;
298
+ asked_at: string;
299
+ } | PendingApproval | {
300
+ kind: "budget";
301
+ cap_usd: number;
302
+ spent_usd?: number;
303
+ needs_usd?: number;
304
+ suggested_cap_usd?: number;
305
+ said: string;
306
+ at: string;
307
+ } | null;
308
+ /** How many of the refused request's least a run paused at its cap is offered on top of what was taken (suggestedCap). */
309
+ export declare const SUGGESTED_RAISE_FACTOR = 10;
310
+ /** The raise a run paused at its cap is offered: what the cap counted as taken plus SUGGESTED_RAISE_FACTOR times the
311
+ * refused request's least, rounded up to a whole dollar, and always above the cap (the next dollar above it, if not),
312
+ * so a PATCH with it is a raise. */
313
+ export declare const suggestedCap: (cap: number, spentUsd: number, needsUsd: number) => number;
314
+ /** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
315
+ export declare const costOf: (rows: readonly TimelineEvent[]) => number | null;
316
+ /** What a run's paid tools charged (`tool`'s alone, when given), from the same rows its cost is read from: each charge's
317
+ * line carries it (`usage` on a `phase` row); null when one is unknown. A call still marked, in flight or cut, is no
318
+ * charge here. */
319
+ export declare const toolCostOf: (rows: readonly TimelineEvent[], tool?: string) => number | null;
320
+ /** What a run's paid tools are known to have charged (`tool`'s alone, when given; every other tool's with `others`): each
321
+ * charge's line that names its cost, a charge of unknown cost adding nothing. */
322
+ export declare const knownToolCostOf: (rows: readonly TimelineEvent[], tool?: string, others?: boolean) => number;
323
+ /** A run's cost for its views: its usage row's, else what the store kept when it carried the run back (0 before any
324
+ * request). A usage row that says unknown, or says nothing, stays unknown: what the store kept dates from before a
325
+ * follow-up. */
326
+ export declare function costView(rows: readonly TimelineEvent[], stored: number | null | undefined, decisions?: number | null): number | null;
327
+ /** What a run whose cost is unknown has cost so far (costsofar/1): the sum of its charges whose cost is known, and how many
328
+ * have none, from its usage row, plus a workflow's decisions (`decisions`: their known sum and how many are not known;
329
+ * null when they could not be read, which says nothing). Undefined while the cost is known, when the row says neither
330
+ * (an older run's), or when a workflow's decisions are unreadable. No ceiling is claimed. */
331
+ export type SoFar = {
332
+ so_far_usd: number;
333
+ unpriced: number;
334
+ };
335
+ export declare function soFarOf(rows: readonly TimelineEvent[], decisions?: {
336
+ known: number;
337
+ unpriced: number;
338
+ } | null): SoFar | undefined;
339
+ /** Whether the turn a stop ended is still where the run stands: no message shown is newer than the stop's. By order,
340
+ * never by a count or by the stopped message itself, which a compaction can take off the rows. */
341
+ export declare const stoppedAt: (meta: {
342
+ stopped_at?: string;
343
+ stopped_after?: number;
344
+ }, rows: readonly TimelineEvent[]) => boolean;
345
+ /** What a stop keeps of where the run stands: the person's last message, by its id, or the place before any. */
346
+ export declare const stopMark: (rows: readonly TimelineEvent[]) => {
347
+ stopped_at: string;
348
+ };
349
+ /** The rows a snapshot that no longer holds them leaves served: those committed entries made. A row any connection
350
+ * showed live is not one (`live` holds them for the run), so a live row that ended while the door was away goes. */
351
+ export declare function keepCommitted(live: Set<string>, rows: readonly TimelineEvent[], isLive: (id: string) => boolean): (id: string) => boolean;
352
+ /** A run's status and state, by the contract's table. */
353
+ export declare function statusOf(run: Run): {
354
+ status: Status;
355
+ state: State;
356
+ };
357
+ /** The waits between carry backs that found the store busy, and a hook called at each such refusal. */
358
+ export type CarryBackRetry = {
359
+ delaysMs?: readonly number[];
360
+ onBusy?: (runId: string, attempt: number) => void;
361
+ };
362
+ /** How a run is asked to start: its input and title, its effort and cap, and what puts its files in its work/. `origin`:
363
+ * the store's key for what asked (an Idempotency-Key's, a trigger's firing): a key that already started a run gets that
364
+ * run. `trigger`: the trigger and firing that started it. */
365
+ export type StartOptions = {
366
+ input: Json;
367
+ title: string;
368
+ place: Place;
369
+ effort?: string;
370
+ maxCostUsd?: number;
371
+ trigger?: RunTrigger;
372
+ inputs?: (work: string) => Promise<unknown>;
373
+ origin?: RunOrigin;
374
+ };
375
+ /** `token` is the server's own: no run's process sees it. */
376
+ /** `maxRuns`: the most runs with a live process at once; `settleRetryMs`: how often a carry back the store refused is
377
+ * tried again; `readyTimeoutMs`: how long a request to a run waits for its door (a run's first message, sent by its
378
+ * start, always waits READY_TIMEOUT_MS); `log` takes a run's start and end (print.ts). */
379
+ export type RunsOptions = {
380
+ dockerAllow?: readonly string[] | "none";
381
+ agents: Agents;
382
+ token: string; /** The server's saved tool keys, read by name for its runs alone (secrets.ts). */
383
+ storedKeys?: StoredKeys;
384
+ documents?: string;
385
+ doorTokenFile: string;
386
+ doorToken: string; /** The test switches a run's process gets (server.ts fauxEnvOf): empty outside tests. */
387
+ fauxEnv?: NodeJS.ProcessEnv;
388
+ runBoxes?: BoxProvider; /** The server's Daytona provider, with its key: remote boxes are made, seeded, pulled and destroyed with it, here alone (box-relay.ts). */
389
+ remoteBoxes?: BoxProvider; /** Daytona's API and the same key, for what the provider does not do: a kept box's idle stop, and its wake at a start (daytona-api.ts). */
390
+ remoteApi?: DaytonaApi; /** The server's VM box provider, with its client: a VM run's box is made, seeded, pulled and ended with it, here alone, as a Daytona one is (box-relay-vm.ts); it has no network. */
391
+ vmBoxes?: BoxProvider; /** A VM box's limits (run-box.ts RemoteLimits), from the box settings. */
392
+ vmLimits?: RemoteLimits; /** The relay's VM half, which lets go of a run's programs at its end. */
393
+ vmRelay?: {
394
+ drop(runId: string): void;
395
+ }; /** The hosts a remote box may reach (run-box.ts boxAllowOf); `none`, or absent, for none. */
396
+ boxAllow?: readonly string[] | "none"; /** Called once, with the provider's refusal's code and words, when it cannot keep that list here: from then on each remote box is made with no network. */
397
+ onNoBoxList?: (code: string, message: string) => void;
398
+ toolSettings?: () => ToolSettingsMap; /** Whether anyone can answer a tool call's approval here (accounts on); false, the run's gate refuses each ask (tool-gate.ts). */
399
+ approvers?: boolean;
400
+ drainTimeout?: string;
401
+ carryBackRetry?: CarryBackRetry;
402
+ maxRuns?: number;
403
+ box?: {
404
+ host: BoxHost;
405
+ quarantine: Quarantine;
406
+ };
407
+ settleRetryMs?: number;
408
+ readyTimeoutMs?: number;
409
+ reflectTimeoutMs?: number;
410
+ gradeTimeoutMs?: number; /** The grader's model (`--grade-model`), before AGENTRUN_SERVE_GRADE_MODEL and the strong tier (grade.ts gradeModelOf). */
411
+ gradeModel?: string; /** How much of what a run learned its instructions hold, in bytes (`--learning-budget`, learning.ts learnedOf). */
412
+ learningBudget?: number;
413
+ log?: (event: string, fields: Record<string, string | number>) => void;
414
+ notify?: RunNotify;
415
+ learning?: LearningMode; /** Each agent's saved sign-ins (sign-ins.ts): absent, no run gets one. */
416
+ signIns?: SignIns; /** The secrets this server makes and keeps sealed while it runs (each webhook trigger's), read at each check, so a rotation is seen at once: what a run's learning refuses and cuts, as it does the saved keys. */
417
+ ownSecrets?: () => readonly string[];
418
+ };
419
+ /** Told of a run's moment each time it is seen (webhooks.ts' emit, which queues each one once): a wait it reached, and an
420
+ * end once the agent store has it. `marker` names the moment (the person's turn it waits at, the end's time), the same
421
+ * when another server sees it again. It says what came of it: `unsaved`, not in the outbox on disk yet. */
422
+ export type RunNotify = (event: (typeof RUN_EVENTS)[number], run: RunNotice & {
423
+ status: Status;
424
+ }, marker: string) => Emitted;
425
+ /** Why a message that may not answer a person's question is not sent. */
426
+ export declare const WAITS_ON_A_PERSON = "The run is waiting on a person.";
427
+ /** The secrets a run's process is handed over its pipe (secrets.ts): every one but the server's own and the decision
428
+ * keys, which go on their own descriptor. */
429
+ export declare const RUN_SECRETS: string[];
430
+ type KeyRow = {
431
+ kind: string;
432
+ fields: readonly string[];
433
+ unlocks: readonly string[];
434
+ };
435
+ /** What of a revision decides the secrets its runs are handed, none of it a key, read once per revision (a revision
436
+ * never changes): its harness, the model it names, the tools it binds (named as its process binds them, app.ts: an
437
+ * agentic revision's `tools`, a workflow's on its model nodes and its `call` nodes), a workflow's tiers (those its model
438
+ * nodes and `llm` calls run on), and its decision providers (decisions.ts' decisionKeysFor: a workflow's decision
439
+ * nodes', providersNamed, Jev for a node that names none; an agentic revision's, none). Names only: no instruction and
440
+ * no skill. */
441
+ export type RunNeeds = {
442
+ harness: string;
443
+ model?: string;
444
+ tools: readonly string[];
445
+ tiers?: readonly Tier[];
446
+ decisionProviders: readonly string[];
447
+ };
448
+ /** `revision`'s RunNeeds. */
449
+ export declare function needsOf(revision: Revision): Promise<RunNeeds>;
450
+ /** The secrets a run of `needs` is handed over its pipe, by the keys `env` holds now: RUN_SECRETS but each field of a
451
+ * `tool` row of `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does
452
+ * not need, from the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the
453
+ * gateway's (model.ts' modelKeys: its own model, or the host's of each tier it runs); codex's and claude-agent's, the
454
+ * one key their route sends for the revision's model (adapters.ts' harnessModelKeys). Read at each launch, so a key
455
+ * saved with no restart counts at the next. */
456
+ export declare function keysFor(needs: RunNeeds, env: NodeJS.ProcessEnv, rows?: readonly KeyRow[]): string[];
457
+ /** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
458
+ export declare function secretsFor(revision: Revision, rows?: readonly KeyRow[], env?: NodeJS.ProcessEnv): Promise<string[]>;
459
+ /** The decision providers a run of `revision` needs keys for (needsOf). Its web tools' need, Parallel's where one
460
+ * resolves to Parallel, is its tool plane's (tool-plane.ts' handsParallel), read at each launch. */
461
+ export declare function decisionProvidersFor(revision: Revision): Promise<readonly string[]>;
462
+ /** A run's process's environment: no secret in it (they go over its pipe), nor the token by value; the AGENT_MODEL
463
+ * variables and the rest pass, and the door token goes by file. A test hook's name passes never (withoutFaux): the run
464
+ * gets one only from startServe's options. */
465
+ export declare const childEnv: (env: NodeJS.ProcessEnv, token: string) => NodeJS.ProcessEnv;
466
+ /** The line of the run process's log a failure's message is made of: its last, past any harness's own lines (a proxy's
467
+ * refusal just before a crash says nothing of why the process went). */
468
+ export declare function failureLine(log: string): string;
469
+ /** The last line of the run process's log, in words, for a failure's message. */
470
+ export declare function lastLogLine(run: Pick<Run, "dir">): Promise<string>;
471
+ /** Seams for tests, each unset in a server: `personsTurn` holds a person's turn just after its origin went. */
472
+ export declare const runsTestHooks: {
473
+ personsTurn?: (runDir: string) => Promise<void> | void;
474
+ };
475
+ export declare class Runs {
476
+ private readonly options;
477
+ private readonly runs;
478
+ /** Each workflow revision's workflow, by revision id, as a graph read it: a revision never changes. */
479
+ private readonly workflows;
480
+ /** What decides the secrets each revision's runs are handed (needsOf), by revision id: read once, from the revision the
481
+ * run is pinned to, never from a request. The keys themselves are read at each launch (keysFor). */
482
+ private readonly needs;
483
+ /** Every run's graph as served, part by part (servedGraph), and each workflow run's last graph read whole, which a
484
+ * poll that met a busy store answers, marked stale: one LRU by bytes across runs (graph-served.ts PartCache). */
485
+ private readonly graphCache;
486
+ private readonly adopting;
487
+ /** The hosts this server's next remote box asks for: the setting's, until the provider cannot keep a list here, then none. */
488
+ private remoteAllow;
489
+ private readonly clock;
490
+ private readonly cli;
491
+ private readonly app;
492
+ private closing;
493
+ /** Set once `close` is done: the store is closed, so nothing settles after it. */
494
+ private closed;
495
+ /** Runs past the cap's check whose process is not started yet. */
496
+ private starting;
497
+ /** The memory the starts counted in `starting` reserve, in MiB. */
498
+ private startingMib;
499
+ /** This host's memory, out of which each live run reserves what its harness takes (host.ts), beside `maxRuns`. */
500
+ private readonly memory;
501
+ /** The start sweep of the boxes runs left: once, before any run opens a box (sweepOnce). */
502
+ private swept?;
503
+ /** The runs' learning (learning-run.ts): a step this file calls as a run starts, ends, settles, opens again and is
504
+ * recovered, handed what it moves of a run. */
505
+ readonly learning: LearningRuns;
506
+ /** When this server took the data root (one server a root): a run started since is its own, never one to recover. */
507
+ private readonly bootedAt;
508
+ constructor(options: RunsOptions);
509
+ /** A test's seam (startServe's `beforeAbort`): awaited by a stop between its mark and its abort, so a test can hold a
510
+ * stop in flight there. */
511
+ beforeAbort?: (runId: string) => Promise<void> | void;
512
+ /** A test's seam (startServe's `beforeReopenLaunch`): awaited by a reopen after the run reads open again and before its
513
+ * launch, so a test can hold a reopen there. */
514
+ beforeReopenLaunch?: (runId: string) => Promise<void> | void;
515
+ /** A test's seam (startServe's `onRunLoad`): told each run read in from its store, its timeline with it. */
516
+ onRunLoad?: (runId: string) => void;
517
+ /** A test's seam (startServe's `beforeSubmit`): awaited by a message before it goes to the run's door. */
518
+ beforeSubmit?: (runId: string, content: string) => Promise<void> | void;
519
+ /** A test's seam (startServe's `beforeMetaSave`): awaited before a run's serve.json is written; one that throws fails
520
+ * the write, as a full disk would. */
521
+ beforeMetaSave?: (runId: string, meta: Readonly<RunMeta>) => Promise<void> | void;
522
+ /** A test's seam (startServe's `messageOrigin`): the origin a message sent through the messages route carries. */
523
+ messageOrigin?: (runId: string, content: string) => MessageOrigin | undefined;
524
+ private get store();
525
+ /** Run `id` when this process holds it, never read from disk. */
526
+ held(id: string): Run | undefined;
527
+ /** Run `id`, read from the agent store the first time this process sees it. */
528
+ get(id: string): Promise<Run | null>;
529
+ /** One Run per run id, however many requests ask for it at once. */
530
+ private adopt;
531
+ private load;
532
+ private blank;
533
+ /** Writes the run's serve.json as it is when its turn comes; then tells learning what it now holds (the ledger's line
534
+ * once the run's learning ended). */
535
+ /** Writes the run's serve.json, after any write already under way: `meta`, a copy its caller publishes to run.meta
536
+ * only once this resolves (a raise, takeRaise), else run.meta, each as it stands when the write starts. */
537
+ private saveMeta;
538
+ private record;
539
+ /** The door a live run serves, from its run.json: running, a fresh heartbeat, and a loopback address. */
540
+ private doorOf;
541
+ private storeFile;
542
+ /** The run's rows from its store, opened read-only; only once its claim is released. An agentic run's rows are its
543
+ * root conversation's; a workflow run's are its model nodes'. `atEnd`: a settle's read, which reads every
544
+ * conversation (a workflow's nodes, a harness's session) once and counts the run's metrics from all of them. */
545
+ private readStore;
546
+ /** New rows in: into the log, then the run's status, then whatever the status asks for. */
547
+ /** `keep`: rows that stay served though `rows` no longer holds them (the live path's committed rows). */
548
+ private take;
549
+ /** The approval rows as the run's answers say them now (a stop or a cancel withdraws a call, an answer settles one),
550
+ * shown at once: an answer takes no new rows. */
551
+ private restate;
552
+ /** The run's rows into its log, as served: a workflow run's decisions and the run's learning row are the served view's
553
+ * only, never the run's own rows, which its cost and its answer are read from. */
554
+ private show;
555
+ /** A live process: the child this server started, or one an earlier server started that still serves the run. */
556
+ private live;
557
+ /** How an agentic run ends: over its cap, or as the turn of the person's newest message ended (turns.ts), once every
558
+ * message the run took has had its turn. Undefined while one is open, or when the run stopped, waits, or its turn
559
+ * ended interrupted (the run then waits for the person), or while its records name no message (a live process of an
560
+ * older server: the run's next process writes its turn's end as it opens). Never from the order of its rows, or from
561
+ * when its door said idle. A workflow run ends when its workflow does. */
562
+ private decide;
563
+ /** A run's error as a person reads it, in its error box and on its Timeline row alike: a refused key in plain words
564
+ * (plainKey), else the harness's text with no loopback address (withoutLoopback: Codex names serve's own proxy). */
565
+ private errorWords;
566
+ /** An error row as served: its summary and text in errorWords' terms. The run's own rows, which its status reads, keep
567
+ * what the harness said. */
568
+ private servedError;
569
+ /** What serve shows of a run's error text, for every run kind: no held secret (redacted, key-refusal.ts' one rule) and
570
+ * no loopback address. */
571
+ private shown;
572
+ /** A run's answer as serve serves it: no held secret, never cut (redactedAnswer). Loopback addresses stay: an answer is
573
+ * the model's own words, and a local address there can be what the person asked about. */
574
+ private servedAnswer;
575
+ /** A workflow run's output as serve serves it: each string in it as servedAnswer, its shape kept. */
576
+ private servedOutput;
577
+ /** `redact(values)` over the values `run` holds, read once per input and held value set: a console polls a run's
578
+ * view, and an answer a run was made to write can be large. The run keeps the one it served last, of each slot; a key
579
+ * saved or deleted changes the values' digest, and the next view redacts again. */
580
+ private servedOnce;
581
+ /** A workflow run's graph as serve serves it: its nodes, each decision and each call (its input, output and error) with
582
+ * no held secret, by its answer's rule (redactedOutput), and only then cut: a map item's label at 200 characters, a
583
+ * call's error at 2000, and a text stored cut (a decision's state past 64 KB, an error logged cut) less its last 6
584
+ * times the longest held value plus 16 characters, where a value the stored cut split would sit. The view a busy
585
+ * store's read keeps is the one graph-view.ts made, whole, so a key saved after it is still found. Each part is
586
+ * served once per content and held value set: a console polls the graph while the run goes. */
587
+ private servedGraph;
588
+ /** The timeline's redaction of `run`'s error rows and of what a tool's result shows (its summary and preview), applied
589
+ * before a row is cut (timelineOf's `redact`), so a cut never leaves the head of a key. Every such cut is within
590
+ * redacted()'s SHOWN, so its window holds. */
591
+ /** How a run's decision rows show a text (decision-rows.ts Shown): the run's redactor, and as many characters held back
592
+ * from a text stored cut as a held value takes in its widest form. */
593
+ private decisionShown;
594
+ private redactor;
595
+ /** The last line of the run process's log (lastLogLine) for a failure's message, with every value its errors never
596
+ * show cut out: its process may have written a secret or its sign-in's pointer there. */
597
+ private lastLine;
598
+ /** Every secret value `run`'s errors never show, as learning's checker holds them (learning-run.ts refused): this
599
+ * server's secrets wherever its launcher put them and the keys saved on it, what each launch handed the run, and the
600
+ * server's own tokens. */
601
+ private refusedValues;
602
+ /** A run's model error in a person's words when its provider refused the run's key (key-refusal.ts): the key its
603
+ * harness's route sends, by this server's settings and keys, and no secret's value. */
604
+ private plainKey;
605
+ /** Records the run's status as a change when it moves, and lets go of a live run that answered, failed or is over its cap. */
606
+ /** What a run paused at its cap has spent once its process is gone: its store's spend as the cap reads it (spentIn),
607
+ * read once per pause (its refusal's row). None while its process lives, nor when the store says unknown or cannot
608
+ * be read: the refusal's own figure stands then. */
609
+ private spentNow;
610
+ /** The run's live process, by its pid and start ticks (processIdentity). */
611
+ private liveIdentity;
612
+ private refresh;
613
+ /** The test hooks startServe's options name, as a run's process and this server's own calls get them. */
614
+ private fauxEnv;
615
+ /** Let go of a live run with `outcome`: SIGTERM, after aborting its turn when it is still working. */
616
+ private finish;
617
+ /** SIGTERM to the run's process: it drains, releases the run and exits. */
618
+ private terminate;
619
+ /** Supervise a run process an earlier server started: follow its door, and settle the run once its run.json says it
620
+ * let go (released, or its lease lapsed) or the process is gone. */
621
+ private adoptProcess;
622
+ /** At start: every run the store says is running is read, supervised when its process lives, carried back when it
623
+ * already ended, and opened again when its process went before it ended. */
624
+ /** Every run's box let go that nothing owns, and every run cgroup no record names: once, before any run of this server
625
+ * starts, opens again or relaunches, so a box or cgroup being made is never swept away. */
626
+ private sweepOnce;
627
+ /** A sandbox run's box (run-box.ts), destroyed by its label: at every settle, a cancel included, and at archive. A
628
+ * remote box's work/ is pulled first, and its box goes only once that pull brought it back whole (or there is no box).
629
+ * A copy that stopped for good (an archive the extractor cannot read, a limit it cannot pass) keeps the box, said in
630
+ * the log, its lifetime bounding it, and the run ends. Any other failure at a run's end (`ending`) throws
631
+ * PullPending, and the end is tried again; at an archive it only warns, the box kept for the run's end or the next
632
+ * start's sweep. A destroy that fails only warns: the next start's sweep tries again, and the box's lifetime bounds it. */
633
+ private dropBox;
634
+ /** A remote box kept because its copy back is not whole: said in the log, and set to stop once idle, so it costs its
635
+ * disk alone until the next start's pull (which wakes it) or its lifetime. */
636
+ private keepBox;
637
+ /** What wakes run `runId`'s remote box when Daytona stopped or paused it (a class that pauses when idle, while the run
638
+ * waited for a person): how many it woke. */
639
+ private wakeOf;
640
+ /** Pulls run `run`'s remote box into its work/, after any pull already running: at a turn's end in the background (a
641
+ * failure warns, and the next pull brings it), or awaited (`strict`: a failure throws). */
642
+ private pullBox;
643
+ /** Waits for the pull run `id`'s turn's end began, if any, up to PULL_WAIT_MS: its files then show what its box wrote. */
644
+ pulled(id: string): Promise<void>;
645
+ /** Whether run `id` is one this server holds in a remote box and has not ended: the relay serves no other. */
646
+ servesBox(id: string): boolean;
647
+ /** The server's provider of a remote place's boxes: the VM box's, or Daytona's. */
648
+ private remoteOf;
649
+ /** Run `id`'s remote box, found or made and seeded: what its process asks the relay for at its first tool call. */
650
+ ensureBox(id: string): Promise<{
651
+ id: string;
652
+ made: boolean;
653
+ }>;
654
+ /** The run's box let go (archive, or its process gone after an archive): reaped by the box's own count. */
655
+ private teardown;
656
+ /** After an archive (a run's, or an agent's, which archives its runs): the box of every run now archived is let go,
657
+ * now when its process is gone, else when it exits. */
658
+ archived(): Promise<void>;
659
+ recover(): Promise<void>;
660
+ /** The run's status, state and whether its rows are all in, as one more change of its log when any of them moves. A wait
661
+ * is told each time it is seen: webhooks.ts queues each wait once, whichever server sees it first. */
662
+ private mark;
663
+ /** Tells webhooks.ts (`notify`) of a moment of the run under `marker`: a wait it reached (mark), or an end the agent store
664
+ * has (settle, persistLater, reopen). What it already queued it queues no more. */
665
+ private notice;
666
+ /** A call to run `run`'s door: with its own door token, or, for a process an older server started, the server-wide one. */
667
+ private headers;
668
+ /** Run `id`'s own door token, the one its calls to the box relay carry; none for a run it does not hold or that has none. */
669
+ relayToken(id: string): string | undefined;
670
+ /** Follow the door's events into an agentic run's rows, again after each drop while the process lives. A workflow
671
+ * run is only watched: the door's events are a root conversation's, and a workflow run has none. */
672
+ private connect;
673
+ private follow;
674
+ /** The door of a run that is not finished, starting or waking its process when it is not live. */
675
+ private ensureLive;
676
+ /** The refusal of a message to an imported run: it was run elsewhere, and is kept as history. */
677
+ private importedRefusal;
678
+ private finished;
679
+ /** Abort an agentic run's turn running now through the door, when there is one; never wakes the run. A workflow run
680
+ * has no turn: the door's abort would give it a root conversation. */
681
+ private abortTurn;
682
+ /** One request to the door of a run whose process lives, never waking it (toDoor wakes no run that is finishing): again
683
+ * while it opens or parks. `turnOrigin`: who sent a turn this request sends (learning-run.ts's REFLECT_ORIGIN), kept in
684
+ * the run's directory before it goes, where the tool gate reads it (tool-gate.ts NOTE_ONLY_TEXT); a person's message
685
+ * removes it. */
686
+ private toLiveDoor;
687
+ private toDoor;
688
+ /** Reads what decides the secrets runs of `run`'s revision are handed (needsOf), once per revision: from `given` (a
689
+ * start's, read from the store), else from the agent store, waiting out a busy one as a run's end does. */
690
+ private pinNeeds;
691
+ /** The saved sign-in the run's browser starts from (sign-ins.ts), resolved before each launch: made at the vendor when
692
+ * its agent has none, and leased to this run to save unless another run of the agent holds the lease. One that cannot
693
+ * be had (the vendor not answering, a seal key changed) leaves its browser signed out, said in its log. */
694
+ private pinSignIn;
695
+ /** Lets go of the save lease the run holds on its agent's sign-in, if any: at once when its process let its sessions go
696
+ * (`clean`), else by the gone rule (sign-ins.ts). */
697
+ private releaseSignIn;
698
+ private launch;
699
+ /** Writes the run's launch mark before its process is spawned: a spawn that takes the server down leaves it, and the
700
+ * next start fails the run rather than launch it again and go down with it. The file exists once the call returns,
701
+ * which a server's death does not undo; no fsync, which would hold the event loop on the disk at every launch. */
702
+ private markLaunching;
703
+ /** The run's newest launch came through with the server up: its process serves, or exited while it was watched. Its
704
+ * callers are event handlers, so a mark that cannot be removed is logged, never thrown: a throw there stops the
705
+ * server and every run on it. The mark left behind fails the run at the next start, which never launches it again. */
706
+ private reportedBack;
707
+ /** Opens the run again on its directory after its process went before the run ended: it resumes from its store. An
708
+ * agentic run whose first message never landed gets it again, under the same request id. */
709
+ private relaunch;
710
+ /** After the run's process exited, or was found gone: its rows from its released store, then, when it is over, its
711
+ * carry back. One at a time per run, and none once the run has its outcome. */
712
+ private settle;
713
+ /** `exited`: the process this server supervised exited. Exiting on an error before it released fails the run; going
714
+ * any other way before the run ended (killed, or found gone at a start) opens it again. */
715
+ private settleOnce;
716
+ /** A workflow run's carry back, `workflowCarry` of @parcha/pi-durable-agent/workflow on its released store, and its
717
+ * output when it completed; undefined while its workflow has not ended. */
718
+ private workflowEnd;
719
+ /** A workflow run's decisions' cost, from their receipts in its released store: a receipt whose cost is unknown leaves
720
+ * the run's unknown, never $0. Read at its end and again when a restarted server adopts it as ended. */
721
+ private readDecisionCost;
722
+ /** Ends the run in the agent store, once: how it ended, its cost, a line for the list and its metrics. A store held by
723
+ * another writer is tried again with backoff; past the last try the run stays unsettled, and the next start carries it back. */
724
+ private carryBack;
725
+ /** The run's metrics as the store keeps them: what its entries say it used, the effort its newest process ran at (unknown
726
+ * for one an older server started), and on a harness other than pi the model its revision names (its entries name the
727
+ * harness). A busy store throws, for the write's retries; a revision that cannot be read otherwise adds nothing. */
728
+ private storedMetrics;
729
+ /** Tries `persist` again every settleRetryMs while the server lives, until it lands. */
730
+ private persistLater;
731
+ /** How long a run's end waits for a busy store, step by step. */
732
+ private busyDelays;
733
+ /** Hears that `what` was busy for run `runId`, and says so when another try follows. */
734
+ private onBusy;
735
+ /** The run's store, read again while another connection holds it, within the same retries. */
736
+ private storeWhenFree;
737
+ /** Start a run of `revision` (number `version`) of `entry`'s agent: `startRun` in the store, then its process, then an
738
+ * agentic run's first message, `input.content`. */
739
+ /** A place for one more live run of `harness`, taken for this start (counted in `starting` and `startingMib` from
740
+ * here, so two starts at once cannot both take the last place), or 429 rate_limited; the function returned gives it
741
+ * back once the run holds it as a live run, or did not start. A place is one under the cap on the count and the
742
+ * memory a run of its harness reserves (host.ts): both must be free. A run that has ended (failed, completed,
743
+ * cancelled) still holds its place until its process exits; a start that needs that place waits for it, up to that
744
+ * process's drain and kill, never refused for a place already being given back. A harness whose one run is more than
745
+ * the whole memory for runs is refused at once, never a 429 (capabilities say so too). From the read of what is held
746
+ * to the reservation nothing awaits, so two starts at once never both take the last of it. */
747
+ private takePlace;
748
+ /** `inputs` copies the run's files into its work/ (uploads.ts), after the store made it and before its process starts. */
749
+ create(entry: AgentEntry, revision: Revision, version: number, options: StartOptions): Promise<Run>;
750
+ /** Writes the serve.json of a run being set up. When it fails, the store has the run as running and no process will
751
+ * run it: it ends failed here, never left for a later start to open with half its files. */
752
+ private setUp;
753
+ private start;
754
+ /** Copies the run's files into its work/ under the launch mark: a server that goes down while it copies leaves the
755
+ * mark, and the next start fails the run rather than run it on part of its files. Copied whole, the mark goes, and the
756
+ * launch makes its own. False when the copy failed, and the run ended so (or was cancelled meanwhile). */
757
+ private prepare;
758
+ /** One message to the run's door. `origin`: who wrote it when the person did not (a raised cap's follow-up, an
759
+ * approval's resume), carried to its user entry so the Timeline shows it as the server's (pi-durable-agent's
760
+ * MessageOrigin); the model reads the same text either way. `answers: false`: the run's door refuses the message
761
+ * (WAITING) when the run's turn ended on ask_person, and when the run is busy (BUSY), so it is never queued behind a
762
+ * turn that may end so; decided at the door's admission, past every wait here. */
763
+ private submit;
764
+ /** Whether the run's harness takes a message mid-turn. */
765
+ private steers;
766
+ /** Whether the run's store already took a message under `requestId`: a trigger's firing sent it, and the server went
767
+ * down before it wrote so. Read before sending it again, so a completed run is not opened again for a message it
768
+ * already has. Only for a run with no live process: a live one holds its store, and takes the message through its
769
+ * door, which takes one per id anyway. The store keeps the id as JSON text, as pi submits it, or as a harness's door
770
+ * keeps its journal (doorKey), where a busy refusal is not a message taken (doorTook). A store held past the retries
771
+ * throws as busy. */
772
+ tookMessage(run: Run, requestId: string): Promise<boolean>;
773
+ /** Raises the cap of an agentic run that names one, to `cap`: above its own (by more than CAP_TOLERANCE), or the same as
774
+ * its newest raise (a retry, which changes nothing). serve.json keeps it before any answer, and a raise it could not keep
775
+ * is undone, so the run's next process opens under it (CAP_ENV), as does a server started again. A run paused at its
776
+ * cap goes on: the raise names the pause it answers, and the pause gets one follow-up, "The cap was raised to $X;
777
+ * continue the task." under an id fixed now, which refresh sends once the paused process is gone (resumeRaised), here
778
+ * or after a restart; a second raise before it goes raises what it says. A run working keeps the cap its process was
779
+ * opened with until its next process. Raises of one run are taken one at a time. */
780
+ raiseCap(run: Run, cap: number): Promise<{
781
+ resumed: boolean;
782
+ messageId?: string;
783
+ note?: string;
784
+ }>;
785
+ private takeRaise;
786
+ /** Sends a raised run its pause's follow-up, under its id (the door takes one id once), at the run's cap now: as a
787
+ * follow-up to a run whose process has gone (message()), so the process it starts resumes nothing and opens under the
788
+ * new cap, or to the process another launch started. Marked sent in serve.json. One that cannot be sent is tried
789
+ * again (CONTINUE_RETRY_MS), and after CONTINUE_TRIES the run fails, saying why: never a pause stuck in silence. */
790
+ private resumeRaised;
791
+ /** Ends a raised run whose follow-up could not be sent: failed, in words a person can act on. */
792
+ private failRaised;
793
+ /** One message to an agentic run, its mode chosen by the run's state (the contract's table). `requestId`: the message's
794
+ * id in the run's store, which takes one message per id (a trigger's firing key); default a new one. */
795
+ message(run: Run, content: string, requestId?: string, { answers }?: {
796
+ answers?: boolean;
797
+ }): Promise<{
798
+ mode: "steer" | "answer" | "follow_up";
799
+ messageId: string;
800
+ }>;
801
+ /** A person's turn is sent next: no turn from here on is the server's own end-of-run turn (tool-gate.ts NOTE_ONLY_TEXT),
802
+ * so its origin goes, right before the turn is sent. */
803
+ private personsTurn;
804
+ /** Waits, up to a request's deadline, while `holds` (checked every `everyMs`): else 503 `unavailable`, saying `why`. */
805
+ private waitWhile;
806
+ /** A completed agentic run that gets a follow-up opens again: the same run on its own store and session, under its
807
+ * cap, taking a place under the server's. Launched here, with no wait after the place is taken, so no start takes
808
+ * it meanwhile. An archived run, or a run of an archived agent, stays closed. */
809
+ private reopen;
810
+ /** Waits, up to a request's deadline, until a live run's rows show every message sent to it, and any rows at all: its
811
+ * record has caught up with its process. Its end, a cancel or its process going ends the wait. */
812
+ private caughtUp;
813
+ /** Abort the turn that is running; the run stays open, `input_required` and idle. A workflow run has no turn to stop. */
814
+ stop(run: Run): Promise<boolean>;
815
+ /** message()'s decline of the tool call that waits for approval: a deny with the message as its note, which the
816
+ * run's gate acts on as any deny, resuming the session with the refusal and the person's words in one message. */
817
+ private declineBy;
818
+ /** The answers given and not acted on yet (the run's process has not resolved them), overridden by a stop or a cancel:
819
+ * `withdrawn` or `canceled`, each keeping the answer it superseded, so nothing runs and nothing resumes, and the
820
+ * history shows what was given. The run's gate reads the answer again just before it acts (tool-gate.ts). */
821
+ private supersede;
822
+ /** Until every tool call of the run that waited for approval is resolved in its store (its process acted on its answer,
823
+ * or cut it), or `ms` pass. */
824
+ private untilResolved;
825
+ /** stop()'s withdrawal of the tool call that waits for approval: never run, and an answer after is 409. */
826
+ private withdraw;
827
+ /** stop() of a run with no turn to abort (parked on an approval it withdrew): the stop's mark, as a stop saves it. */
828
+ private stopIdle;
829
+ /** stop()'s mark and abort, once it took the stop. */
830
+ private stopTurn;
831
+ /** A person's answer to the tool call `id` that waits for approval (tool-gate.ts): kept in the run's serve.json before
832
+ * it returns, the first answer winning (the same one again changes nothing; another is 409, `already_answered`). The
833
+ * run's process reads it there, runs or refuses the call, and resumes; a run with no process gets one. */
834
+ approve(run: Run, id: string, decision: "allow" | "deny", note?: string): Promise<void>;
835
+ /** Record the cancel and signal the run. An agentic run reads `cancelled` from here on (the first end a run comes to is
836
+ * its last: nothing its turn writes later moves it), and is carried back so once its process has exited; a workflow
837
+ * run reads it once it is carried back, with how its workflow stopped. */
838
+ cancel(run: Run): Promise<boolean>;
839
+ /** Pause a workflow run (`paused` true) or resume it: the mark in its directory, which its process reads before each
840
+ * node starts. A run that has ended is not continuable. */
841
+ pause(run: Run, paused: boolean): Promise<{
842
+ run_id: string;
843
+ paused: boolean;
844
+ status: Status;
845
+ }>;
846
+ /** A workflow run's graph as it stands (graph-view.ts), live while it runs. */
847
+ graph(run: Run): Promise<{
848
+ stale: boolean;
849
+ read_at: string;
850
+ run: {
851
+ id: string;
852
+ agent: string;
853
+ revision: string;
854
+ status: string;
855
+ paused: boolean;
856
+ startedAt: string;
857
+ endedAt: string | null;
858
+ };
859
+ workflow: unknown;
860
+ graph: import("@parcha/agentrun-dsl/graph").WorkflowGraph;
861
+ nodes: Record<string, {
862
+ status: import("./graph-view.js").GraphNodeStatus;
863
+ startedAt?: string;
864
+ endedAt?: string;
865
+ branch?: string;
866
+ items?: {
867
+ index: number;
868
+ status: import("./graph-view.js").GraphNodeStatus;
869
+ executionPath: string;
870
+ label?: string;
871
+ branches?: Record<string, string>;
872
+ }[];
873
+ }>;
874
+ decisions: {
875
+ images: {
876
+ token: {} | null;
877
+ ref: {} | null;
878
+ url: string | null;
879
+ }[];
880
+ error_cut?: boolean | undefined;
881
+ id: {} | null;
882
+ node: string | null;
883
+ executionPath: {} | null;
884
+ item: {} | null;
885
+ kind: {} | null;
886
+ provider: {} | null;
887
+ model: {} | null;
888
+ status: {} | null;
889
+ questions: {} | null;
890
+ answers: {} | null;
891
+ evidence: {};
892
+ rule: {} | null;
893
+ action: {} | null;
894
+ cost_usd: number | null;
895
+ cost_basis: {} | null;
896
+ latency_ms: {} | null;
897
+ state: {} | null;
898
+ state_truncated: boolean;
899
+ error: string | null;
900
+ }[];
901
+ effects: {
902
+ node: string | null;
903
+ executionPath: string | null;
904
+ item: number | null;
905
+ tool: string;
906
+ status: string;
907
+ input: unknown;
908
+ output: unknown;
909
+ error: string | null;
910
+ error_cut?: boolean;
911
+ startedAt: string;
912
+ endedAt: string | null;
913
+ }[];
914
+ totals: {
915
+ cost_usd: number | null;
916
+ decisions: number;
917
+ effects: number;
918
+ elapsed_ms: number | null;
919
+ };
920
+ }>;
921
+ /** How long a run's process gets after SIGTERM before SIGKILL: its drain and a second to exit. */
922
+ private killAfterMs;
923
+ /** What close() will wait on: the runs whose processes are left to finish their turn (those this server started, and
924
+ * those it adopted), and the longest it can wait on them: a kill bound for the started ones, and one more for the
925
+ * adopted ones, which it stops after them. */
926
+ stopping(): {
927
+ runs: number;
928
+ boundMs: number;
929
+ };
930
+ close(): Promise<void>;
931
+ /** A run's cost from its rows, else what the store recorded when it carried the run back. */
932
+ cost(run: Run): {
933
+ so_far_usd?: number | undefined;
934
+ unpriced?: number | undefined;
935
+ usd: number | null;
936
+ basis: string;
937
+ charge_state: null;
938
+ cap_usd: number | null;
939
+ };
940
+ /** `Run`, as the contract shows it. `known`: its stored row as the caller already has it, so nothing is read; a run
941
+ * just written has none worth reading (`{ stored: null }`: it is neither archived nor ended), and its start's answer
942
+ * must not read the store once the run exists, since a busy store would then refuse a run that runs. */
943
+ view(run: Run, known?: {
944
+ stored: RunRow | null;
945
+ }): Promise<{
946
+ created_at: string;
947
+ updated_at: string;
948
+ ended_at: string | null;
949
+ result: {
950
+ output: unknown;
951
+ final_answer: string | null;
952
+ } | null;
953
+ error: RunError | null;
954
+ review: RunReview | null;
955
+ pending: Pending;
956
+ cost: {
957
+ so_far_usd?: number | undefined;
958
+ unpriced?: number | undefined;
959
+ usd: number | null;
960
+ basis: string;
961
+ charge_state: null;
962
+ cap_usd: number | null;
963
+ };
964
+ archived_at: string | null;
965
+ imported_from: {
966
+ source: string;
967
+ session: string;
968
+ } | null;
969
+ trigger: RunTrigger | null;
970
+ learning: {
971
+ used?: import("./learning.js").NoteUsed[];
972
+ learned?: import("./learning.js").NoteLearned[];
973
+ pending?: import("./learning.js").NoteUsed[];
974
+ skills?: import("./learning.js").LearnedFile[];
975
+ workflows?: import("./learning.js").LearnedFile[];
976
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
977
+ reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
978
+ detail: string | null;
979
+ at: string;
980
+ } | null;
981
+ poll_after_ms: number;
982
+ last_progress_at: string | null;
983
+ effort?: string | undefined;
984
+ run_id: string;
985
+ agent_id: string;
986
+ agent_version: number;
987
+ revision: string;
988
+ kind: RevisionKind;
989
+ sha: null;
990
+ status: Status;
991
+ state: State;
992
+ title: string;
993
+ place: Place;
994
+ }>;
995
+ summary(run: Run): Promise<{
996
+ created_at: string;
997
+ ended_at: string | null;
998
+ error: RunError | null;
999
+ review: RunReview | null;
1000
+ pending: Pending;
1001
+ cost: {
1002
+ so_far_usd?: number | undefined;
1003
+ unpriced?: number | undefined;
1004
+ usd: number | null;
1005
+ basis: string;
1006
+ charge_state: null;
1007
+ cap_usd: number | null;
1008
+ };
1009
+ archived_at: string | null;
1010
+ imported_from: {
1011
+ source: string;
1012
+ session: string;
1013
+ } | null;
1014
+ trigger: RunTrigger | null;
1015
+ learning: ({
1016
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
1017
+ reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
1018
+ detail: string | null;
1019
+ } & Omit<{
1020
+ used?: import("./learning.js").NoteUsed[];
1021
+ learned?: import("./learning.js").NoteLearned[];
1022
+ pending?: import("./learning.js").NoteUsed[];
1023
+ skills?: import("./learning.js").LearnedFile[];
1024
+ workflows?: import("./learning.js").LearnedFile[];
1025
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
1026
+ reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
1027
+ detail: string | null;
1028
+ at: string;
1029
+ }, "at" | "state" | "reason" | "detail">) | null;
1030
+ effort?: string | undefined;
1031
+ run_id: string;
1032
+ agent_id: string;
1033
+ agent_version: number;
1034
+ revision: string;
1035
+ kind: RevisionKind;
1036
+ sha: null;
1037
+ status: Status;
1038
+ state: State;
1039
+ title: string;
1040
+ }>;
1041
+ /** A run's status for a list: an ended run's from its row, a running one's from the run itself. */
1042
+ statusOfRow(row: RunRow): Promise<Status>;
1043
+ /** A run's summary for a list. An ended run this server holds no Run for is read from its row and its serve.json alone,
1044
+ * not its store; `versions` numbers its agent's revisions. */
1045
+ summaryOfRow(row: RunRow, versions: Map<string, number>): Promise<Awaited<ReturnType<Runs["summary"]>>>;
1046
+ /** A key was saved on this server or deleted from it: each held run's learning row and decision rows shown again, cut
1047
+ * of the keys as they are now (learning-run.ts shown, decision-rows.ts), as its view and its lists already are from
1048
+ * the next read on. */
1049
+ keysChanged(): void;
1050
+ /** A held run's learning, in short (learning-run.ts heldLearning). */
1051
+ heldLearning(runId: string): {
1052
+ state: LearningState;
1053
+ reason: LearningReason | null;
1054
+ } | null | undefined;
1055
+ /** The timeline from change `after`, held up to `waitMs` for a change when there is none. */
1056
+ page(run: Run, after: number, waitMs: number, limit: number): Promise<Page & {
1057
+ status: Status;
1058
+ state: State;
1059
+ final: boolean;
1060
+ }>;
1061
+ }
1062
+ export {};