@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
@@ -0,0 +1,306 @@
1
+ import type { AnalyticsFilter, Revision, RunRow, StartedRun } from "@parcha/pi-durable-agent";
2
+ import type { TimelineEvent } from "@parcha/pi-durable-agent/timeline";
3
+ import { type LearnedFile, type Learning, type LearningReason, type LearningState, type NoteLearned, type Shown } from "./learning.js";
4
+ import type { Run, RunsOptions, Status } from "./runs.js";
5
+ import { type Json } from "./validate.js";
6
+ /** A run's end-of-run turn: the job's outcome, the newest store entry before the turn and, once the run ended, the newest
7
+ * after it (its rows are those between), its deadline, and how it ended. */
8
+ export type Reflect = {
9
+ outcome: Status;
10
+ after: number;
11
+ until?: number;
12
+ deadline: string;
13
+ ended?: true;
14
+ timedOut?: true;
15
+ };
16
+ /** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
17
+ * with, at its one call (reflectTurn); the tool gate reads it there and refuses that turn's writes under work/.learning/ (tool-gate.ts NOTE_ONLY_TEXT). */
18
+ declare const REFLECT_ORIGIN = "reflect";
19
+ export type TurnOrigin = typeof REFLECT_ORIGIN;
20
+ /** The run asked its end-of-run turn and has not ended since. */
21
+ export declare const reflecting: (run: {
22
+ meta: {
23
+ reflect?: Reflect;
24
+ };
25
+ }) => boolean;
26
+ /** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
27
+ * is, and so is a live row. */
28
+ export declare function reflects(reflect: Reflect | undefined, id: string | number): boolean;
29
+ /** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
30
+ * a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
31
+ * the run's store, and no row shows it. */
32
+ export declare function labelled(reflect: Reflect | undefined, rows: TimelineEvent[]): TimelineEvent[];
33
+ /** The files of the run's copy of the folder its job read, in the order it first read them, each once: every `read`
34
+ * call whose result came back a success, matched to its call by id (claude-agent's rows can hold the result above the
35
+ * call), on any harness: pi's, claude-agent's (the host's `read`, served to its CLI as `mcp__hands__read`) and codex's
36
+ * (the same tool, as an app-server dynamic tool) rows all name it `read`, with the path as the model gave it. The
37
+ * end-of-run turn's reads are its own, not the job's, and are left out; so is a read that failed or never ended, and
38
+ * MEMORY.md, which is no note. Which of these files are notes the run started from is for its seed to say (noteUsed). */
39
+ export declare function notesRead(reflect: Reflect | undefined, rows: readonly TimelineEvent[]): string[];
40
+ /** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
41
+ * and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
42
+ * secrets now, `shown`, then cut short). One row, which says where the learning ended. */
43
+ export declare function withLearning(rows: readonly TimelineEvent[], learning: Learning | undefined, shown: Shown): TimelineEvent[];
44
+ /** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
45
+ * started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded,
46
+ * reflecting or proposed: a run this server holds). A run with learning off, a workflow's or an imported one, has
47
+ * none, and is not counted. */
48
+ export declare function learningStats(rows: readonly RunRow[], filter: AnalyticsFilter, learningOf: (row: RunRow) => {
49
+ state: string;
50
+ reason: string | null;
51
+ } | null): {
52
+ runs: number;
53
+ merged: number;
54
+ dropped: Record<string, number>;
55
+ in_progress: number;
56
+ };
57
+ /** One side of an agent's impact: how many runs, their median time to the answer, the median of their job's own cost
58
+ * over the `cost_runs` whose cost is known, and the median of what learning itself cost a run (its look-back and its
59
+ * grade), over the runs that learn whose learning cost is known. */
60
+ export type ImpactSide = {
61
+ runs: number;
62
+ median_duration_s: number;
63
+ median_cost_usd: number | null;
64
+ cost_runs: number;
65
+ median_learning_usd: number | null;
66
+ };
67
+ export type Impact = {
68
+ before: ImpactSide;
69
+ after: ImpactSide;
70
+ } | null;
71
+ /** What a run's learning tells its impact (learning-run.ts ofAgent), from memory or from its ledger line: how it
72
+ * ended and when, how many notes it started from, when its answer was final and its costs; `grade_usd` once it ended
73
+ * (0 when nothing was graded), and `look_back_usd` 0 for a run that never looked back. */
74
+ export type ImpactLearning = {
75
+ state: string;
76
+ reason: string | null;
77
+ at: string;
78
+ seed_notes?: number;
79
+ answered_at?: string;
80
+ job_cost_usd?: number | null;
81
+ look_back_usd?: number | null;
82
+ grade_usd?: number | null;
83
+ };
84
+ /** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
85
+ * never a run's files. `after`: its completed agentic runs that started from at least one active note. `before`: its
86
+ * completed agentic runs that started before its first note, the earlier of its first merge's end and the start of its
87
+ * first run that started from a note (a person's note comes first that way); none of them could have. Each side's
88
+ * figures (sideOf, figuresOf): its time to the answer in seconds to a tenth, its job's own cost, what learning cost.
89
+ * An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
90
+ * note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
91
+ export declare function learningImpact(rows: readonly RunRow[], learningOf: (row: RunRow) => ImpactLearning | null | undefined): Impact;
92
+ /** What learning needs of the server's options: the data directory and the agents, its tokens, the switch, and its bounds. */
93
+ export type LearningOptions = Pick<RunsOptions, "agents" | "token" | "doorToken" | "storedKeys" | "ownSecrets" | "learning" | "learningBudget" | "reflectTimeoutMs" | "gradeTimeoutMs" | "gradeModel">;
94
+ /** What the kernel (runs.ts) hands learning: its runs, and the parts of a run's life learning moves. */
95
+ export type LearningKernel = {
96
+ /** Run `id` when the kernel holds it; read from the agent store the first time (`get`). */
97
+ held(id: string): Run | undefined;
98
+ get(id: string): Promise<Run | null>;
99
+ /** Whether the run's process lives. */
100
+ live(run: Run): boolean;
101
+ /** One request to a live run's door, never waking it, with who sent a turn it sends; one to its door, waking it. */
102
+ toLiveDoor(run: Run, path: string, body?: Json, turnOrigin?: TurnOrigin): Promise<Json | null>;
103
+ toDoor(run: Run, path: string, body: Json): Promise<unknown>;
104
+ /** The run's turn aborted; its process let go (SIGTERM). */
105
+ abortTurn(run: Run): Promise<void>;
106
+ terminate(run: Run): void;
107
+ /** Its status as one more change; its rows, as served, again. */
108
+ mark(run: Run): void;
109
+ show(run: Run): void;
110
+ /** Its serve.json written, in turn (onSaved follows). */
111
+ save(run: Run): Promise<void>;
112
+ /** A run's cost from its rows: null when unknown. */
113
+ costOf(rows: readonly TimelineEvent[]): number | null;
114
+ /** The test hooks startServe's options name, as a run's process gets them. */
115
+ fauxEnv(): NodeJS.ProcessEnv;
116
+ };
117
+ /** The learning of every run the kernel holds, from the end-of-run turn to the merge. */
118
+ export declare class LearningRuns {
119
+ private readonly options;
120
+ private readonly kernel;
121
+ /** Why this host keeps no learning folder, said once. */
122
+ private learningOff?;
123
+ /** The secrets each launch of a run that learns handed its process (runs.ts launch()), by run id, so a key a person
124
+ * replaced or deleted while the run lived is still refused in what its end-of-run turn wrote. In memory only, never on
125
+ * disk: a server that restarts loses them, and the run's next launch hands it the keys as they are then, which the
126
+ * check reads too. Dropped once the run's learning ends, and when the server closes. */
127
+ private readonly handed;
128
+ /** Aborted as the server closes: a grade's screen and grader stop, and leave the run's learning `proposed`. */
129
+ private readonly stopping;
130
+ /** The runs whose learning's end is in the learning ledger (usage.ts): read at the start, and each one written since. */
131
+ private readonly recorded;
132
+ /** By run: what its end-of-run turn wrote, being checked (proposeOnce), and its proposal, being graded (gradeOnce). */
133
+ private readonly proposing;
134
+ private readonly grading;
135
+ /** The host's secrets as shown() last cut them, by their values, and the saved keys it read. */
136
+ private cut?;
137
+ private saved?;
138
+ constructor(options: LearningOptions, kernel: LearningKernel);
139
+ private get closing();
140
+ /** A run of `revision` about to be made for agent `agentId`. It learns when the server's switch (`--learning`) is on and
141
+ * its agent's definition says `learning: true`; then its seed is read now, before the run is made, so the folder is
142
+ * read once whatever the run's setup does, and what comes back pins it in the run once it is made and its input
143
+ * saved (a server that goes down during the copy leaves no learning saved: onLoad), at `at`: its
144
+ * learning, `seeded`, or `dropped` as `seed_failed` (a learning fault never refuses a run). Undefined when it does
145
+ * not learn. What the run reads under `# Learned` is its notes within the server's learning budget, told of
146
+ * `.learning/` only when its agent has the read tool, and cut of the host's secrets as they are then. */
147
+ onStart(agentId: string, revision: Revision): Promise<((started: Pick<StartedRun, "runId" | "dir" | "workspace">, at: string) => Promise<Learning>) | undefined>;
148
+ /** The run's serve.json holds `learning` now: the learning ledger's line for the run (usage.ts), once, when that
149
+ * learning has ended. Never rejects: a line not written is written by the next save, or by the next start's pass. */
150
+ onSaved(run: Pick<Run, "id" | "agentId">, learning: Learning | null | undefined): Promise<void>;
151
+ /** The run's job ended with `end`. True when its end-of-run turn is asked first: the run is finishing with that
152
+ * outcome, and is let go once the turn ends. False when it is let go now, its learning dropped when it skips the turn. */
153
+ beforeFinish(run: Run, end: {
154
+ outcome: Status;
155
+ error?: Run["error"];
156
+ abort?: boolean;
157
+ }): boolean;
158
+ /** A run read at a start, before the kernel holds it, `save` writing its serve.json: one a server went down while it
159
+ * copied the run's seed (running, its input saved and no learning, and a pin or a `work/.learning/` there) has both
160
+ * taken back, so it starts again with nothing learned, and its learning dropped as `seed_failed`, saved before the
161
+ * ledger's line (onSaved). Called before anything reads the run: its relaunch, a settle, a follow-up. A seed_failed
162
+ * run asks no end-of-run turn (reflectSkip). A copy that never began leaves nothing, and the learning stays null. */
163
+ onLoad(row: Pick<RunRow, "id" | "agent" | "state">, dir: string, meta: Run["meta"], save: () => Promise<void>): Promise<void>;
164
+ /** A run's process launched, handed the secrets named `names`: what each held then, as handover read it, kept beside
165
+ * the run while its learning is under way (a key replaced since stays refused in its notes). */
166
+ onLaunch(run: Run, names: readonly string[]): void;
167
+ /** A running run read at a start, `live` when its process serves it still. One a server left while its end-of-run turn
168
+ * ran is finishing with its job's outcome, and nothing opens it again; when its process lives, the turn is asked again
169
+ * under the same request id, which it takes once, and waited for. */
170
+ onAdopt(run: Run, live: boolean): void;
171
+ /** The run's end being written: its end-of-run turn's rows closed, and its learning settled from how the turn went;
172
+ * then what the turn answered, and what the user said in the run, kept in its directory before the run reads ended,
173
+ * so a follow-up that opens it again never changes what is checked. */
174
+ beforeSettle(run: Run, outcome: Status): Promise<void>;
175
+ /** The run's end written, as it would be without learning: what its end-of-run turn wrote checked, then graded and
176
+ * merged. Called only then, so a slow or failing check never holds the job. A run already `proposed` is graded: one
177
+ * a follow-up opened again mid-grade, whose server went while it ran, which the next start passed over as running.
178
+ * gradeOnce does nothing for any other state, nor while a grade of the run is in flight here. */
179
+ afterSettle(run: Run): Promise<void>;
180
+ /** A run that learns, opened again for a follow-up, before its process starts: `work/.learning/` laid again from its
181
+ * seed where the run took it away, so the follow-up finds the notes its instructions name where they say, and the
182
+ * learned skills its pin names laid again, fresh, so its process reads each where it was. A fault leaves it without. */
183
+ onReopen(run: Run): Promise<void>;
184
+ /** Its process launched again for the follow-up: an end-of-run turn its process went in would resume with the run, so
185
+ * it is aborted before the follow-up is sent. One that cannot be aborted runs out ahead of it, and its rows are never
186
+ * the follow-up's answer, which comes after them. */
187
+ afterReopen(run: Run): Promise<void>;
188
+ /** The server's start: the learning ledger read from now, beside the running runs' pass, never before it (a line
189
+ * written twice meanwhile is read once). What comes back takes every run once that pass is done: each ended run whose
190
+ * learning a server left between steps, what its end-of-run turn wrote not checked yet, or its proposal not graded or
191
+ * merged, is checked or graded now, once; a learning end saved and not in the ledger (a server that went between the
192
+ * two) is written there. */
193
+ recover(): (rows: readonly RunRow[]) => Promise<void>;
194
+ /** The server closing: a grade's screen and grader stop, and leave the run's learning `proposed`; nothing new starts. */
195
+ close(): void;
196
+ /** Once every run has settled: each check in flight, then each grade, ended. */
197
+ idle(): Promise<void>;
198
+ /** A held run's learning, in short, from memory (null when it does not learn); undefined for a run the kernel does not
199
+ * hold. For a count, which reads the rest from the learning ledger and never a run's files. */
200
+ heldLearning(runId: string): {
201
+ state: LearningState;
202
+ reason: LearningReason | null;
203
+ } | null | undefined;
204
+ /** The host's secrets as they are now, as a reader cuts them (secretsShown): the ones this server holds, the keys
205
+ * saved on it, and its tokens, as the learning routes cut them. Built again only once they change. Every run's view
206
+ * and every row of a list asks it, so the saved keys, which are read from their file and opened one by one, are read
207
+ * once and kept until a person saves or deletes one (keysChanged). */
208
+ shown(): Shown;
209
+ /** A key was saved on this server or deleted from it: the next view reads them again. */
210
+ keysChanged(): void;
211
+ /** A run's learning as its view shows it (learning.ts learningView), cut of the host's secrets now; `settled`, once
212
+ * the run has ended and settled, shows the notes it read. */
213
+ view(learning: Learning | undefined, settled: boolean): {
214
+ used?: import("./learning.js").NoteUsed[];
215
+ learned?: NoteLearned[];
216
+ pending?: import("./learning.js").NoteUsed[];
217
+ skills?: LearnedFile[];
218
+ workflows?: LearnedFile[];
219
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
220
+ 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;
221
+ detail: string | null;
222
+ at: string;
223
+ } | null;
224
+ /** A run's learning as a list shows it (learning.ts shortLearning): from serve.json for a run the kernel does not hold. */
225
+ short(learning: Learning | null, settled: boolean): ({
226
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
227
+ 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;
228
+ detail: string | null;
229
+ } & Omit<{
230
+ used?: import("./learning.js").NoteUsed[];
231
+ learned?: NoteLearned[];
232
+ pending?: import("./learning.js").NoteUsed[];
233
+ skills?: LearnedFile[];
234
+ workflows?: LearnedFile[];
235
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
236
+ 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;
237
+ detail: string | null;
238
+ at: string;
239
+ }, "at" | "state" | "reason" | "detail">) | null;
240
+ /** How the runs `rows` holds that tried to learn fared, over `filter` (learningStats): a held run's learning from
241
+ * memory, any other's end from the learning ledger, never a run's files. */
242
+ counts(rows: readonly RunRow[], filter: AnalyticsFilter): Promise<ReturnType<typeof learningStats>>;
243
+ /** Agent `agentId`'s runs (`rows`, its own) as its learning view counts them, the ledger read once: how they fared
244
+ * (counts, less `runs`), and what learning changed (learningImpact), each run's learning from memory when the kernel
245
+ * holds it, else its end from its ledger line; never a run's files. */
246
+ ofAgent(rows: readonly RunRow[], agentId: string): Promise<{
247
+ counts: Omit<ReturnType<typeof learningStats>, "runs">;
248
+ impact: Impact;
249
+ }>;
250
+ /** What a run of `agentId` starts from: its learning folder's main (learning.ts), the folder made first when it is
251
+ * absent; else why it starts with nothing learned. A learning fault never refuses a run: a host without the git
252
+ * learning needs is said once, and a folder that cannot be made or read once per run. */
253
+ private seedFor;
254
+ /** Moves the run's learning on, and shows its row. What it keeps whatever it does after (learning.ts KEPT_LEARNING:
255
+ * the notes the run read, how many it started from, its answer's time and costs) stays with it. Saved by the caller,
256
+ * or with the run's end. */
257
+ private setLearning;
258
+ /** As the run settles, before its end is written: the notes its job read from its copy of the folder (notesRead), by
259
+ * their names in its seed, kept with its learning (`used`), so a view or a list reads them from serve.json and never
260
+ * from its rows again. Only a note the run started from counts: MEMORY.md, a file the run wrote there, and a note
261
+ * not in its seed are not notes it used. Read again at each settle, a follow-up's reads with the rest. A seed that
262
+ * cannot be read leaves what was there, and says why. */
263
+ private noteUsed;
264
+ private dropLearning;
265
+ /** Why a run that just ended asks no end-of-run turn: a drop's reason and detail; null when it does not learn, or asked
266
+ * one already (one per run, ever); undefined when it asks one. The cap keeps no reserve: a run its cap stopped has no
267
+ * room left, and one whose spend is unknown cannot be kept within its cap. */
268
+ private reflectSkip;
269
+ /** The run answered or failed: it is finishing with that outcome, and its harness is asked one end-of-run turn first.
270
+ * The turn is saved before it is asked, so a restart asks it again under the same id, never twice. */
271
+ private reflect;
272
+ /** Asks the end-of-run turn through the run's door and waits for its end, its deadline (the turn is aborted) or the
273
+ * process to go; then lets the run go. The turn answers with its notes: it writes nothing, so nothing the run left in
274
+ * its copy of the folder counts. */
275
+ private reflectTurn;
276
+ /** How the end-of-run turn ends: `ended` once the run's door says it is idle (the turn was taken before the submit was
277
+ * answered, so idle is after it), `timeout` at `deadline`, `gone` when the process went or the run was cancelled. */
278
+ private reflectEnd;
279
+ /** At the run's end: the end-of-run turn's rows closed, and its learning settled from how the turn went. A run that
280
+ * never left `seeded` went before it could reflect. */
281
+ private closeLearning;
282
+ /** What the run's end-of-run turn wrote, checked and kept as its proposal or dropped (propose.ts), once at a time, after
283
+ * the run has ended. Never rejects: `proposed` or `dropped`, `propose_failed` for a fault. A server that goes
284
+ * meanwhile leaves it `reflecting` in serve.json, and the next start checks it again. */
285
+ private proposeOnce;
286
+ /** The tools a run's workflow draft may name: its revision's granted tools a workflow's call node runs here that the
287
+ * gate allows, under the server's tool settings and the agent's own (tools.ts learnedDraftTools); `gated`, those set to
288
+ * ask or deny, which a draft that calls one is refused for. None for a revision not found, so a draft that names one is
289
+ * refused. */
290
+ private draftTools;
291
+ private propose;
292
+ /** The run's proposal merged into main or dropped (grade.ts), one grade at a time per agent, after the checks and
293
+ * never in a run's way. The verdict and what the grade spent are kept in serve.json before the merge, so a restart
294
+ * never asks the grader again; what it spent is in the ledger with the run's end. A server that closes mid-grade leaves the
295
+ * learning `proposed`, and its next start grades it. */
296
+ private gradeOnce;
297
+ private grade;
298
+ /** What a run's learning refuses, and cuts from what it says: the secrets this server holds, wherever its launcher put
299
+ * them, the keys saved on it, what each launch handed the run, and its own tokens. */
300
+ private refused;
301
+ /** This server's environment for a call of its own (a grade's screen and grader): its secrets readable, never a
302
+ * child's, the keys saved on it with them (a Jev key saved through the settings API screens as one in the environment
303
+ * does), and the test hooks a run's process gets. */
304
+ private hostEnv;
305
+ }
306
+ export {};