@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,418 @@
1
+ import { type LearnedNote, type Problem, type Verdict } from "./learn/index.js";
2
+ /** The server's learning switch (`--learning`, AGENTRUN_SERVE_LEARNING; capabilities.features.learning). `on`, the
3
+ * default: a run learns when its agent's definition says `learning: true`. `off`: no run this server starts does. */
4
+ export declare const LEARNING_MODES: readonly ["on", "off"];
5
+ export type LearningMode = (typeof LEARNING_MODES)[number];
6
+ export declare const LEARNING_ENV = "AGENTRUN_SERVE_LEARNING";
7
+ /** The switch: `given`, else AGENTRUN_SERVE_LEARNING, else on. Any other value is an error, and the server does not start. */
8
+ export declare function learningOf(env: NodeJS.ProcessEnv, given?: string): LearningMode;
9
+ /** How much of what a run learned its instructions hold under `# Learned` by default, in UTF-8 bytes (learnedOf): its
10
+ * notes whole while they fit, else the index and the notes changed last, whole, while they fit. */
11
+ export declare const LEARNING_BUDGET = 8000;
12
+ export declare const LEARNING_BUDGET_ENV = "AGENTRUN_SERVE_LEARNING_BUDGET";
13
+ /** The learning budget: `given` (`--learning-budget`), else AGENTRUN_SERVE_LEARNING_BUDGET, else LEARNING_BUDGET. Any
14
+ * value that is not a whole number of bytes, 0 or more, is an error, and the server does not start. */
15
+ export declare function learningBudgetOf(env: NodeJS.ProcessEnv, given?: number): number;
16
+ /** Where a run's learning stands (its `learning`, runs.ts): `seeded` once it starts from what its agent learned,
17
+ * `reflecting` while its end-of-run turn runs and until what it answered is checked, `proposed` once that passed the
18
+ * checks and is kept in the run's directory (propose.ts), `merged` once it is on main (grade.ts), or `dropped` with a
19
+ * reason from the closed list. A learning fault never refuses a run: it starts with nothing learned, `seed_failed`. */
20
+ export declare const LEARNING_STATES: readonly ["seeded", "reflecting", "proposed", "merged", "dropped"];
21
+ export declare const LEARNING_REASONS: readonly ["seed_failed", "no_budget", "unknown_cost", "no_write_tool", "tool_denied", "cancelled", "crashed", "reflect_timeout", "reflect_failed", "empty", "unparsed", "propose_failed", "checker", "screen", "screen_down", "grader", "grade_failed"];
22
+ /** The reasons only an older server gave (an agent with no write tool, or a tool gate denying it, from before the
23
+ * end-of-run turn answered with its notes): still read, from a run's serve.json and the ledger, and counted; never
24
+ * given now. */
25
+ export declare const LEGACY_LEARNING_REASONS: readonly LearningReason[];
26
+ export type LearningState = (typeof LEARNING_STATES)[number];
27
+ export type LearningReason = (typeof LEARNING_REASONS)[number];
28
+ /** Tokens by the platform's names, as a run's metrics and /v2/stats count them: `input` is the input neither read from
29
+ * nor written to the cache. */
30
+ export type Tokens = {
31
+ input: number;
32
+ cache_read: number;
33
+ cache_write: number;
34
+ output: number;
35
+ };
36
+ export declare const NO_TOKENS: Tokens;
37
+ /** The variable that names the grader's model, as `--grade-model` does. */
38
+ export declare const GRADE_MODEL_ENV = "AGENTRUN_SERVE_GRADE_MODEL";
39
+ /** The model this server grades on, by name: `given` (`--grade-model`), else GRADE_MODEL_ENV, else its strong tier
40
+ * (AGENT_MODEL_STRONG); undefined when it names none, and each run is graded on its agent's own model (grade.ts). A
41
+ * name is a model as the strong tier takes one: sent as it is to a gateway, a provider/model-id otherwise. */
42
+ export declare const gradeModelOf: (env: NodeJS.ProcessEnv, given?: string) => string | undefined;
43
+ /** A note a run read from its copy of the folder (`used`), by its file and its front matter's name. */
44
+ export type NoteUsed = {
45
+ file: string;
46
+ name: string;
47
+ };
48
+ /** A note a run's learning added to the folder (`learned`): its file, its name, and the notes it superseded. */
49
+ export type NoteLearned = NoteUsed & {
50
+ supersedes: string[];
51
+ };
52
+ /** A run's learning as serve.json keeps it. Past the view's four fields: the checker's `problems` (printable), the
53
+ * grader's `verdict` and the blob of each note it read superseded (`graded`, by file), both kept before the merge, the
54
+ * merge commit, and what the grade cost (null when unknown, never 0), which is in no run's totals; the notes the run
55
+ * read from `.learning/` (`used`, found in its rows as it settles), and once merged the notes it added (`learned`);
56
+ * and how many notes it started from (`seed_notes`). Names are kept as written, and cut of the host's secrets as they
57
+ * leave. */
58
+ export type Learning = {
59
+ state: LearningState;
60
+ reason: LearningReason | null;
61
+ detail: string | null;
62
+ at: string;
63
+ problems?: Problem[];
64
+ verdict?: Verdict;
65
+ graded?: Record<string, string>;
66
+ merged?: string;
67
+ cost_usd?: {
68
+ grade: number | null;
69
+ };
70
+ tokens?: {
71
+ grade: Tokens | null;
72
+ };
73
+ used?: NoteUsed[];
74
+ learned?: NoteLearned[];
75
+ /** How many active notes the run started from: its seed's, set as it is seeded (none for a seed that failed). */
76
+ seed_notes?: number;
77
+ /** Once it asked its end-of-run turn: when its job's answer was final (before it looked back), and what the run had
78
+ * cost by then (null when unknown); once that turn ended, what the turn itself cost (null when unknown). */
79
+ answered_at?: string;
80
+ job_cost_usd?: number | null;
81
+ look_back_usd?: number | null;
82
+ /** A merge's notes that wait for a person's OK (`status: pending` on main): in no index, and no run reads them until
83
+ * approved. */
84
+ pending?: {
85
+ file: string;
86
+ name: string;
87
+ }[];
88
+ /** A merge's skill and workflow draft, by name and the path of its SKILL.md or workflow.json; `pending` when it waits
89
+ * for a person's OK (`status: pending` in its SKILL.md or README.md), and no run is given it until approved. */
90
+ skills?: LearnedFile[];
91
+ workflows?: LearnedFile[];
92
+ };
93
+ /** A skill or a workflow draft a merge added or changed. */
94
+ export type LearnedFile = {
95
+ file: string;
96
+ name: string;
97
+ pending?: true;
98
+ };
99
+ /** What a run's learning keeps whatever its learning does after: what it read, how many notes it started from, and its
100
+ * answer's time and its costs (learning-run.ts setLearning). */
101
+ export declare const KEPT_LEARNING: readonly ["used", "seed_notes", "answered_at", "job_cost_usd", "look_back_usd"];
102
+ /** What a text or a name that leaves shows of the host's secrets now: none (secretsShown). */
103
+ export type Shown = {
104
+ text: (text: string) => string;
105
+ name: (name: string) => string;
106
+ holds: (text: string) => boolean;
107
+ };
108
+ /** The host's secrets as a reader cuts them: a text holding a value or a shape is cut of it (whole when long:
109
+ * learn/secrets.ts redactSecrets), and a file's name holding one reads REDACTED whole, not a name of the folder's (its
110
+ * route still answers the real name, to a caller who knows it); any other text or name is shown as it is. */
111
+ export declare function secretsShown(values: readonly string[]): Shown;
112
+ /** The notes a run read and learned, as a view or a list shows them, each name cut of the host's secrets (`shown`):
113
+ * `used` once the run settled, `learned` and `pending` (what waits for the owner's OK) once it merged, and the skill
114
+ * and the workflow draft it merged (`skills`, `workflows`, each `pending` while it waits), each only when it holds one.
115
+ * serve.json's are read as untrusted: an entry out of shape is left out. */
116
+ export declare function notesView({ state, used, learned, pending, skills, workflows }: Learning, shown: Shown, settled: boolean): {
117
+ used?: NoteUsed[];
118
+ learned?: NoteLearned[];
119
+ pending?: NoteUsed[];
120
+ skills?: LearnedFile[];
121
+ workflows?: LearnedFile[];
122
+ };
123
+ /** A run's learning in a person's words as a read shows them (learning-words.ts wordsOf): each part cut of the host's
124
+ * secrets as they are now (`shown`) first, then the words cut short to `max`, so a secret is never shown in part. */
125
+ export declare const detailShown: (learning: Learning, shown: Shown, max?: number) => string | null;
126
+ /** A run's learning as its view shows it: the state, why in a person's words (detailShown), and when, and the notes it
127
+ * read, learned and holds for the owner's OK (notesView). */
128
+ export declare const learningView: (learning: Learning, shown: Shown, settled: boolean) => {
129
+ used?: NoteUsed[];
130
+ learned?: NoteLearned[];
131
+ pending?: NoteUsed[];
132
+ skills?: LearnedFile[];
133
+ workflows?: LearnedFile[];
134
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
135
+ 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;
136
+ detail: string | null;
137
+ at: string;
138
+ };
139
+ /** A run's learning as a list shows it: its state and reason, its detail cut of the host's secrets and then short (at
140
+ * most LIST_DETAIL characters, so a secret is never cut in half and shown), and the notes it read and learned
141
+ * (notesView); never its time. */
142
+ export declare const shortLearning: (learning: Learning | null, shown: Shown, settled: boolean) => ({
143
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
144
+ 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;
145
+ detail: string | null;
146
+ } & Omit<{
147
+ used?: NoteUsed[];
148
+ learned?: NoteLearned[];
149
+ pending?: NoteUsed[];
150
+ skills?: LearnedFile[];
151
+ workflows?: LearnedFile[];
152
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
153
+ 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;
154
+ detail: string | null;
155
+ at: string;
156
+ }, "at" | "state" | "reason" | "detail">) | null;
157
+ /** A run's learning as its view shows it, in short for a list: all of it but its time, its detail cut short. */
158
+ export declare function shortOf<T extends {
159
+ state: LearningState;
160
+ reason: LearningReason | null;
161
+ detail: string | null;
162
+ at: string;
163
+ }>({ state, reason, detail, at: _, ...notes }: T): {
164
+ state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
165
+ 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;
166
+ detail: string | null;
167
+ } & Omit<T, "at" | "state" | "reason" | "detail">;
168
+ /** The label of the end-of-run turn's timeline rows, and the kind and label of a run's learning row. */
169
+ export declare const LEARNING_LABEL = "learning";
170
+ /** A run's proposal, in its directory (propose.ts): the seed it was checked against, each new note's file and text, its
171
+ * skill's and workflow draft's files by path and text (`files`: a SKILL.md, a workflow.json and its README.md; absent
172
+ * when it gives none), and what the user said in the run as the grader reads it (each message cut of the host's
173
+ * secrets, then shortened to GRADE_CAPS.askedMessage; absent in a proposal kept before the grader read them). */
174
+ export declare const PROPOSAL = "learning-proposal.json";
175
+ export type Proposal = {
176
+ seed: string;
177
+ notes: {
178
+ file: string;
179
+ text: string;
180
+ }[];
181
+ files?: {
182
+ file: string;
183
+ text: string;
184
+ }[];
185
+ asked?: string[];
186
+ };
187
+ /** A run's pin, in its directory: written once, when the run is made, and never changed by a resume. */
188
+ export declare const LEARNING_PIN = "learning.json";
189
+ /** Where a run finds its agent's notes: in its work, a copy the run may read and nothing reads back. */
190
+ export declare const LEARNED_DIR = ".learning";
191
+ /** What the run's end-of-run turn answered, and what the user said in the run, kept in the run's directory as the run
192
+ * settles (learning-run.ts beforeSettle), where the host alone reads it: what propose.ts checks. */
193
+ export declare const LEARNING_TURN = "learning-turn.json";
194
+ export type Turn = {
195
+ answer: string;
196
+ asked: string[];
197
+ };
198
+ /** What a run's pin holds: the commit of main it was seeded from, and what it reads under `# Learned` (learnedOf), when
199
+ * it learned anything. `learned`, the index alone, is a pin an earlier server wrote, read as that server gave it.
200
+ * `skills`: the files of the learned skills laid in its work, by their paths under `.agents/skills/`, as a revision
201
+ * names its own; `skills_left_out`: the learned skills it does not get, over their budget or holding a secret.
202
+ * `workflows`: the names of the learned workflows the run may run (its `learned_workflow` tool), each written whole in
203
+ * LEARNED_WORKFLOWS_FILE in the run's directory, outside its work; `workflows_left_out`: the learned workflows it does
204
+ * not get, their lines over what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET), or holding a
205
+ * secret, or every one when `workflows_off` says why the run is offered none (its harness's requests go where a learned
206
+ * workflow's could not follow: learnedWorkflowsOff). */
207
+ export type Pin = {
208
+ seed: string;
209
+ section?: string;
210
+ learned?: string;
211
+ skills?: string[];
212
+ skills_left_out?: string[];
213
+ workflows?: string[];
214
+ workflows_left_out?: string[];
215
+ workflows_off?: string;
216
+ };
217
+ /** What a run is seeded from: main's commit, its index and its active notes by file, and the name of every entry at its
218
+ * top. `skipped` names what was there and not read. `recent`, when seedOf read it: the active notes' files, the one
219
+ * changed last on main first. `skills`, when seedOf read them: the skills the agent wrote, the one changed last on main
220
+ * first. */
221
+ export type Seed = {
222
+ sha: string;
223
+ index?: string;
224
+ notes: Record<string, string>;
225
+ files: string[];
226
+ skipped: string[];
227
+ recent?: string[];
228
+ skills?: LearnedSkill[];
229
+ workflows?: LearnedWorkflow[];
230
+ };
231
+ /** A workflow the agent learned, as a run may run it: its name, the line its README says what it does with, and its
232
+ * workflow.json whole. */
233
+ export type LearnedWorkflow = {
234
+ name: string;
235
+ description: string;
236
+ workflow: string;
237
+ };
238
+ /** Where a run keeps the learned workflows its pin names, whole: in the run's directory, beside its pin, never in its
239
+ * work, so nothing the run does changes what its `learned_workflow` tool runs. */
240
+ export declare const LEARNED_WORKFLOWS_FILE = "learned-workflows.json";
241
+ /** The most bytes the `learned_workflow` tool's description gives its workflows, each one's line (workflowLine)
242
+ * together: every harness sends the description with each request, so it never grows with what an agent learned. */
243
+ export declare const LEARNED_WORKFLOWS_BUDGET: number;
244
+ /** A learned workflow's line in the `learned_workflow` tool's description: its name, and what its README says it does. */
245
+ export declare const workflowLine: ({ name, description }: Pick<LearnedWorkflow, "name" | "description">) => string;
246
+ /** The most bytes of learned skills one run gets, every file of each together. They get no more than what the
247
+ * revision's own skills leave of the adapters' cap on a run's skills in all (SKILL_BYTES): over that cap an adapter
248
+ * refuses the whole set, and every skill, the revision's too, would be inlined in the prompt (skills.ts splitSkills). */
249
+ export declare const LEARNED_SKILLS_BUDGET: number;
250
+ /** A skill the agent wrote, as a seed holds it: its name, its files' bytes together, and each file's text by its path
251
+ * inside the skill, read only when the skill could fit a run's budget at all. */
252
+ export type LearnedSkill = {
253
+ name: string;
254
+ bytes: number;
255
+ files?: Record<string, string>;
256
+ };
257
+ /** The agent's learning folder: its home's `learning/` entry, which only the host writes. The home is files.ts homeOf,
258
+ * the one definition the home's routes use too, so two ids that differ only in case never share a folder. */
259
+ export declare const learningRepo: (data: string, agentId: string) => string;
260
+ /** The agent's learning folder, its home and the folder made where absent (checkedFolder). A link swapped in for a part
261
+ * just made is caught by the check after. `<data>/homes` is the operator's, as the data directory is. Every write into
262
+ * the folder goes through it, in the agent's queue: before anything reads or makes the repository, and again once
263
+ * `git init` has made `.git`; before a run's end-of-run turn reads its seed again (seedAt), before its proposal is
264
+ * checked against it (propose.ts), before its grade reads main and its merge writes it (grade.ts), and before a
265
+ * person's edit, create or retire (learning-routes.ts). A refusal throws: a run about to start starts with nothing
266
+ * learned (seed_failed), a run that ended drops what it learned (reflect_failed, propose_failed or grade_failed), and
267
+ * a person's write is an error. */
268
+ export declare const agentFolder: (data: string, agentId: string) => Promise<string>;
269
+ /** The agent's learning folder for a person's read, outside the queue: the same check as agentFolder's, and nothing
270
+ * made. A link or a non-directory throws as it does there; a missing level passes, so a folder never made reads as
271
+ * empty (mainOf finds no main). */
272
+ export declare const readFolder: (data: string, agentId: string) => Promise<string>;
273
+ /** One git call on `repo` (none for `init`), from `cwd`: its stdout, or a rejection naming the command and its stderr.
274
+ * `env` adds to the call's environment (a temporary index, a work tree named outright). */
275
+ export declare function git(cwd: string, repo: string | undefined, args: readonly string[], input?: string | Uint8Array, env?: NodeJS.ProcessEnv): Promise<Buffer>;
276
+ export declare const line: (out: Buffer) => string;
277
+ /** Why this host keeps no learning folder, or undefined when it can: git MIN_GIT or later on `env`'s PATH. */
278
+ export declare function learningBlocker(env?: NodeJS.ProcessEnv): Promise<string | undefined>;
279
+ /** Runs `work` once every call queued before it on the agent's folder has finished: one at a time per agent, in this
280
+ * process. Everything that touches an agent's folder goes through it, so two runs made at once never both make it. */
281
+ export declare const withAgentRepo: <T>(data: string, agentId: string, work: () => Promise<T>) => Promise<T>;
282
+ /** Runs `work` after every grade of the agent's runs queued before it (grade.ts): one grade at a time per agent, each
283
+ * against main as the one before left it. Its own queue, so a grade's model call never holds a run's seed. */
284
+ export declare const withAgentGrade: <T>(data: string, agentId: string, work: () => Promise<T>) => Promise<T>;
285
+ /** Main's commit, or undefined when there is no main yet: no repository, one whose `init` never finished, or one whose
286
+ * making stopped before main. A main that is there, by its ref, and names no commit git can read is an error: the
287
+ * repository is never made again over it. */
288
+ export declare function mainOf(cwd: string, repo: string): Promise<string | undefined>;
289
+ /** Makes the agent's folder, or finishes one whose making stopped before main: `init` with no template, then the host's
290
+ * one commit on main, holding an empty `MEMORY.md` alone, made with plumbing. The working tree and the index show that
291
+ * commit's tree first (written here, never checked out; a `MEMORY.md` that is a link is refused, never written
292
+ * through), and main is created last, only where it is not there yet: a making that stops anywhere before leaves no
293
+ * main, and the next one does it all again. Called in the queue, on the folder agentFolder made and checked; `check`
294
+ * checks it again once `.git` is made. */
295
+ export declare function openAgentRepo(cwd: string, repo: string, check: () => Promise<unknown>): Promise<string>;
296
+ /** Brings the folder's checked-out files in line with commit `sha` of main: host-only files, so no hook or filter runs,
297
+ * with the work tree named outright, the folder itself. Why it could not, when it could not. In the queue, on the
298
+ * folder agentFolder checked. */
299
+ export declare const checkOut: (repo: string, sha: string) => Promise<Error | undefined>;
300
+ /** The blobs `oids` hold, in order, read in one `cat-file --batch`. One git cannot read throws. */
301
+ export declare function readBlobs(cwd: string, repo: string, oids: readonly string[]): Promise<Buffer[]>;
302
+ /** What commit `sha` holds for a run, read with plumbing: its index and its active notes, the `.md` files at its top.
303
+ * Only a regular file (mode 100644) under FILE_CAP, in UTF-8, is read, and only a note in shape (learn/notes.ts
304
+ * parseNoteFile); anything else is named in `skipped`. Only an active note is a run's: a pending, superseded or retired
305
+ * one is not, and nothing serves it (learnedOf, layLearned). A read git fails (an
306
+ * object missing, a timeout) throws. */
307
+ export declare function readSeed(cwd: string, repo: string, sha: string): Promise<Seed>;
308
+ /** The skills commit `sha` holds under SKILLS_DIR, read with plumbing, by name. A skill is read when its folder's
309
+ * name and each of its files' paths are in shape, it holds a SKILL.md, and each file is a regular one (mode 100644) in
310
+ * UTF-8; else it is named in `skipped`. Only an active skill is a run's, one whose SKILL.md sets no status (or
311
+ * `active`): one held for its owner's OK (`status: pending`), or with any other status, is left out as a note that is
312
+ * not active is (readSeed). One over LEARNED_SKILLS_BUDGET, which no run could get, is held with its bytes and none of
313
+ * its files. A symbolic link or a submodule at SKILLS_DIR or anywhere under it throws, as a read
314
+ * git fails does: the run starts with nothing learned, and no link is ever laid in its work or followed. */
315
+ export declare function readSkills(cwd: string, repo: string, sha: string): Promise<{
316
+ skills: LearnedSkill[];
317
+ skipped: string[];
318
+ }>;
319
+ /** The workflows commit `sha` holds under WORKFLOWS_DIR, read with plumbing, by name: each a folder with a workflow.json
320
+ * and a README.md, each a regular file (mode 100644) of at most FILE_CAP bytes in UTF-8; else named in `skipped`. Only an
321
+ * active one is a run's, by the rule a skill is (readSkills): its README.md sets no status, or `active`; one held for
322
+ * its owner's OK, or retired, is left out. A symbolic link or a submodule under WORKFLOWS_DIR throws. */
323
+ export declare function readWorkflows(cwd: string, repo: string, sha: string): Promise<{
324
+ workflows: LearnedWorkflow[];
325
+ skipped: string[];
326
+ }>;
327
+ /** A learned workflow README's front matter, each key to its value (quotes dropped; a `>` or `|` value's indented lines
328
+ * joined by spaces), or undefined when it does not read one way: no front matter, none closed (`---` on a line of its
329
+ * own, the last line or not), a line that is neither a key at its left edge, a comment, blank, nor a line of a `>` or
330
+ * `|` value, or a key set twice. */
331
+ export declare function readmeFront(text: string): Map<string, string> | undefined;
332
+ /** Each file's place in main's first-parent log from `sha`, by the newest commit that changed it: 0 for those the newest
333
+ * commit changed, and so on, so two changes in one second keep their order. A run's notes (seedOf) and a person's view
334
+ * of them (learning-routes.ts) are in this order, the one changed last first. */
335
+ export declare function changedOrder(cwd: string, repo: string, sha: string): Promise<Map<string, number>>;
336
+ /** The seed of a run of agent `agentId` about to be made: main's commit, the folder made first when it is absent, and
337
+ * what that commit holds, its active notes in the order they changed on main, the one changed last first (then by
338
+ * name). In the agent's queue. */
339
+ export declare function seedOf(data: string, agentId: string): Promise<Seed>;
340
+ /** The skills the agent wrote at commit `sha` (readSkills): what a run's pin names, laid again. In the agent's queue,
341
+ * through agentFolder. */
342
+ export declare const skillsAt: (data: string, agentId: string, sha: string) => Promise<LearnedSkill[]>;
343
+ /** What commit `sha` of the agent's folder holds for a run, as seedOf reads main: a run's seed, read again. In the
344
+ * agent's queue, through agentFolder. */
345
+ export declare const seedAt: (data: string, agentId: string, sha: string) => Promise<Seed>;
346
+ /** The active notes of a seed, parsed. */
347
+ export declare const activeOf: (seed: Pick<Seed, "notes">) => LearnedNote[];
348
+ /** Test seams, tests only: once a part of an agent's learning folder is made (before its check), before a run's
349
+ * learned files are written, once its pin is in place, before what its end-of-run turn wrote is checked, as a run that
350
+ * learns opens again for a follow-up, and as each git call starts (its arguments). */
351
+ export declare const learningTestHooks: {
352
+ git?: (args: readonly string[]) => void;
353
+ afterMkdir?: (dir: string) => Promise<void> | void;
354
+ beforePin?: (runDir: string) => Promise<void> | void;
355
+ afterPin?: (runDir: string) => Promise<void> | void;
356
+ beforePropose?: (runDir: string) => Promise<void> | void;
357
+ beforeReopen?: (runDir: string) => Promise<void> | void;
358
+ };
359
+ /** As the run in `runDir` settles after its end-of-run turn ended, before it reads ended and before a follow-up can
360
+ * open it again: what the turn answered and what the user said, kept whole in `<run dir>/learning-turn.json`, so
361
+ * nothing the run does after its end reaches what is checked. One already there stays (a server that went after it
362
+ * was written). Throws when the write fails. */
363
+ export declare function keepTurn(runDir: string, turn: Turn): Promise<void>;
364
+ /** The turn a run's directory keeps (keepTurn). One that is not there, or out of shape, throws. */
365
+ export declare function readTurn(runDir: string): Promise<Turn>;
366
+ /** Lays `seed`'s index and active notes in `dir`, made fresh: whatever was there goes. The index names the active notes
367
+ * alone (servedIndex), and each file is cut of the host's secrets (`shown`), the index a line at a time. */
368
+ export declare function layLearned(dir: string, seed: Seed, shown: Shown): Promise<void>;
369
+ /** How a run reads what it learned (learnedOf): the server's learning budget, in bytes; whether its agent has the read
370
+ * tool; the host's secrets, which every text is cut of. */
371
+ export type LearnedOptions = {
372
+ budget: number;
373
+ read: boolean;
374
+ shown: Shown;
375
+ workflowsOff?: string;
376
+ };
377
+ /** What a run of `seed` reads under `# Learned`, the same for every harness, or undefined when it learned nothing. Only
378
+ * active notes are served: a pending, superseded or retired one is never there, whole or in the index, nor counted
379
+ * toward the budget (readSeed reads active notes alone, and servedIndex drops their lines). Its active notes, newest
380
+ * first (`seed.recent`, else by name): each whole while all fit `budget`, the UTF-8 bytes of
381
+ * what follows the first paragraph. Past it, or when the index names a note main does not hold whole: the index as a
382
+ * run loads it (learn/notes.ts loadedIndex, the first 200 lines and no more than 25 KB, past the budget when it is
383
+ * larger), then the newest notes that fit what is left, each whole, and the rest named only in the index; an agent
384
+ * with the read tool is told they are in `.learning/`, one without is not. Every text is cut of the host's secrets. */
385
+ export declare function learnedOf(seed: Seed, options: LearnedOptions): string | undefined;
386
+ /** Writes `seed` into the run just made in `runDir`: the index and each active note into `work/.learning/`, made fresh
387
+ * (whatever was there goes), then the pin, with what the run reads under `# Learned` (learnedOf) and the learned
388
+ * skills it gets beside the revision's `own` skill files (chooseSkills), then those skills, last, into
389
+ * `work/.agents/skills/`. A write that fails leaves no `.learning/`, no learned skill and no pin, and throws. */
390
+ export declare function pinSeed(runDir: string, work: string, seed: Seed, options: LearnedOptions & {
391
+ own?: readonly string[];
392
+ }): Promise<Pin>;
393
+ /** Lays the learned skills a reopened run's pin names (`pin.skills`) again, fresh, from `read` (the skills of its seed's
394
+ * commit: skillsAt): what the run wrote over them, or took away, is not what it learned. Each only with the files the
395
+ * pin names. Throws when it cannot, a link on the way among the reasons. */
396
+ export declare function layPinnedSkills(work: string, pin: Pin, read: () => Promise<LearnedSkill[]>): Promise<void>;
397
+ /** Takes back a seed whose copy a server went down during (runs.ts load): the learned skills its pin names, the pin,
398
+ * then its `work/.learning/`. True when the pin or the copy was there. */
399
+ export declare function dropSeed(runDir: string, work: string): Promise<boolean>;
400
+ /** The run's pin, as its process reads it: undefined when the run has none (its agent does not learn, its seed failed, a
401
+ * workflow's run). A pin out of shape is an error, never read as none. */
402
+ export declare function readPin(runDir: string): Promise<Pin | undefined>;
403
+ /** The heading of what a run learned, in its instructions. */
404
+ export declare const LEARNED_HEADING = "# Learned";
405
+ /** A run's instructions, with `# Learned` after them when its pin in `runDir` says it learns: that it learns, then what
406
+ * the pin says it learned, or that it has learned nothing yet. A run with no pin (its agent does not learn, its seed
407
+ * failed, a workflow's run) is never asked what to keep, so it is told nothing. And its skill files: the revision's
408
+ * `own`, then the learned ones its pin names, by their paths under `.agents/skills/` in `work`, but for a skill named
409
+ * like one of the revision's, which is the revision's. A learned skill the work no longer holds whole, as a harness reads
410
+ * it (no link on the way: workspace.ts), is left out: a learning fault never fails a run. The one path for every harness
411
+ * (app.ts): pi's system prompt, claude-agent's and codex's instructions, and the skills each gets. */
412
+ export declare function withLearned(runDir: string, work: string, instructions: string, own?: readonly string[]): Promise<{
413
+ instructions: string;
414
+ skills: string[];
415
+ }>;
416
+ /** The learned workflows a run's pin names, as its directory keeps them (LEARNED_WORKFLOWS_FILE): none when the pin
417
+ * names none. A file that is not the list the pin names throws. */
418
+ export declare function pinnedWorkflows(runDir: string, pin: Pin | undefined): Promise<LearnedWorkflow[]>;