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

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 (350) hide show
  1. package/CHANGELOG.md +148 -5
  2. package/README.md +385 -305
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +62 -19
  28. package/dist/composio-preset.js +69 -7
  29. package/dist/composio-triggers.d.ts +14 -0
  30. package/dist/composio-triggers.js +79 -15
  31. package/dist/computer-attach.d.ts +40 -5
  32. package/dist/computer-attach.js +130 -15
  33. package/dist/computer-keys.d.ts +3 -0
  34. package/dist/computer-keys.js +7 -1
  35. package/dist/computer-live.js +3 -2
  36. package/dist/computers.d.ts +21 -10
  37. package/dist/computers.js +39 -28
  38. package/dist/console/assets/index-C2MYaUBa.css +1 -0
  39. package/dist/console/assets/index-CZZeCReB.js +701 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/decisions.d.ts +1 -1
  42. package/dist/dial-relay.d.ts +29 -0
  43. package/dist/dial-relay.js +94 -0
  44. package/dist/email/tools.js +10 -5
  45. package/dist/env-proxy.d.ts +2 -0
  46. package/dist/env-proxy.js +35 -0
  47. package/dist/errors.d.ts +3 -1
  48. package/dist/errors.js +7 -4
  49. package/dist/faux-computers.d.ts +8 -2
  50. package/dist/faux-computers.js +83 -6
  51. package/dist/harness-archive.d.ts +67 -0
  52. package/dist/harness-archive.js +177 -0
  53. package/dist/harness-goose.d.ts +34 -0
  54. package/dist/harness-goose.js +87 -0
  55. package/dist/harness-install.d.ts +21 -0
  56. package/dist/harness-install.js +24 -11
  57. package/dist/harness-opencode/adapter.js +1 -1
  58. package/dist/harness-table.d.ts +9 -1
  59. package/dist/harness-table.js +20 -3
  60. package/dist/harness.d.ts +1 -2
  61. package/dist/harness.js +3 -4
  62. package/dist/host.js +2 -1
  63. package/dist/import.d.ts +10 -0
  64. package/dist/import.js +28 -8
  65. package/dist/key-check.js +3 -0
  66. package/dist/learn/audit.d.ts +6 -6
  67. package/dist/learn/audit.js +3 -7
  68. package/dist/learn/check.d.ts +23 -89
  69. package/dist/learn/check.js +57 -335
  70. package/dist/learn/commit.d.ts +63 -90
  71. package/dist/learn/commit.js +124 -316
  72. package/dist/learn/compile.d.ts +53 -50
  73. package/dist/learn/compile.js +89 -104
  74. package/dist/learn/corrections.d.ts +13 -0
  75. package/dist/learn/corrections.js +23 -0
  76. package/dist/learn/delete.d.ts +5 -5
  77. package/dist/learn/delete.js +8 -10
  78. package/dist/learn/folder.d.ts +35 -47
  79. package/dist/learn/folder.js +118 -134
  80. package/dist/learn/index.d.ts +3 -5
  81. package/dist/learn/index.js +6 -9
  82. package/dist/learn/learning.sh +45 -15
  83. package/dist/learn/promote.d.ts +23 -5
  84. package/dist/learn/promote.js +40 -2
  85. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
  86. package/dist/learn/{skills.js → workflow-draft.js} +48 -58
  87. package/dist/learn/workflow-nodes.js +1 -1
  88. package/dist/learned-workflow.js +2 -2
  89. package/dist/learning-cost.d.ts +38 -24
  90. package/dist/learning-cost.js +41 -24
  91. package/dist/learning-routes.d.ts +91 -170
  92. package/dist/learning-routes.js +183 -421
  93. package/dist/learning-run.d.ts +19 -40
  94. package/dist/learning-run.js +23 -93
  95. package/dist/learning-setting.d.ts +21 -10
  96. package/dist/learning-setting.js +47 -11
  97. package/dist/learning-words.d.ts +28 -74
  98. package/dist/learning-words.js +64 -162
  99. package/dist/learning.d.ts +61 -392
  100. package/dist/learning.js +101 -651
  101. package/dist/live-reach.d.ts +25 -2
  102. package/dist/live-reach.js +46 -4
  103. package/dist/llms.txt +1 -1
  104. package/dist/local-models.d.ts +3 -11
  105. package/dist/local-models.js +5 -6
  106. package/dist/mcp-servers-store.d.ts +4 -4
  107. package/dist/model-form.js +6 -5
  108. package/dist/model.d.ts +4 -0
  109. package/dist/model.js +26 -9
  110. package/dist/native/binding.js +1 -1
  111. package/dist/native/connection.js +1 -1
  112. package/dist/native/discovery.js +1 -1
  113. package/dist/native/instructions.d.ts +3 -0
  114. package/dist/native/instructions.js +5 -3
  115. package/dist/native/remote-worker-bridge.js +9 -43
  116. package/dist/native/remote.d.ts +8 -15
  117. package/dist/native/remote.js +3 -3
  118. package/dist/native/schema.js +1 -1
  119. package/dist/native/types.d.ts +2 -2
  120. package/dist/openapi.js +273 -319
  121. package/dist/paid-calls.d.ts +8 -0
  122. package/dist/paid-calls.js +20 -0
  123. package/dist/particle-provider.d.ts +11 -0
  124. package/dist/particle-provider.js +135 -0
  125. package/dist/port-models.d.ts +12 -4
  126. package/dist/port-models.js +28 -11
  127. package/dist/print.d.ts +27 -0
  128. package/dist/print.js +21 -0
  129. package/dist/provider.d.ts +7 -0
  130. package/dist/provider.js +15 -1
  131. package/dist/reflect-range.js +2 -3
  132. package/dist/run-launch.d.ts +14 -28
  133. package/dist/run-launch.js +9 -12
  134. package/dist/run-learning-served.d.ts +15 -89
  135. package/dist/run-listing.d.ts +34 -0
  136. package/dist/run-listing.js +128 -0
  137. package/dist/run-model-key.js +1 -1
  138. package/dist/run-timeline-served.js +5 -3
  139. package/dist/run-trace.d.ts +97 -0
  140. package/dist/run-trace.js +253 -0
  141. package/dist/run-view.d.ts +15 -0
  142. package/dist/run-view.js +9 -0
  143. package/dist/runnable.js +2 -1
  144. package/dist/runner/adapter-loop.d.ts +8 -6
  145. package/dist/runner/adapter-loop.js +16 -12
  146. package/dist/runner/adapter-run-spec.d.ts +16 -4
  147. package/dist/runner/adapter-run-spec.js +64 -58
  148. package/dist/runner/adapters/index.js +22 -0
  149. package/dist/runner/adapters/pi.d.ts +4 -12
  150. package/dist/runner/adapters/pi.js +2 -2
  151. package/dist/runner/audit.d.ts +1 -1
  152. package/dist/runner/audit.js +30 -13
  153. package/dist/runner/beside.d.ts +6 -2
  154. package/dist/runner/beside.js +38 -9
  155. package/dist/runner/claim-secrets.d.ts +18 -2
  156. package/dist/runner/claim-secrets.js +42 -18
  157. package/dist/runner/cli-run-spec.js +55 -51
  158. package/dist/runner/conformance/harness.d.ts +6 -0
  159. package/dist/runner/conformance/harness.js +35 -13
  160. package/dist/runner/conformance/subject.d.ts +6 -0
  161. package/dist/runner/dispatch.d.ts +2 -2
  162. package/dist/runner/end-of-run.d.ts +6 -14
  163. package/dist/runner/end-of-run.js +8 -33
  164. package/dist/runner/feedback-round.d.ts +2 -2
  165. package/dist/runner/feedback-round.js +7 -7
  166. package/dist/runner/github-app.js +3 -1
  167. package/dist/runner/harness-loops.d.ts +0 -8
  168. package/dist/runner/harness-loops.js +11 -59
  169. package/dist/runner/held.d.ts +170 -0
  170. package/dist/runner/held.js +57 -0
  171. package/dist/runner/journal-kinds.d.ts +2 -3
  172. package/dist/runner/journal-kinds.js +2 -3
  173. package/dist/runner/learned-first.d.ts +40 -0
  174. package/dist/runner/learned-first.js +32 -0
  175. package/dist/runner/learning-end.d.ts +77 -69
  176. package/dist/runner/learning-end.js +250 -303
  177. package/dist/runner/learning-seed.d.ts +15 -33
  178. package/dist/runner/learning-seed.js +24 -45
  179. package/dist/runner/loop-contract.d.ts +2 -3
  180. package/dist/runner/main.d.ts +17 -9
  181. package/dist/runner/main.js +82 -20
  182. package/dist/runner/mcp-run.d.ts +11 -0
  183. package/dist/runner/mcp-run.js +67 -0
  184. package/dist/runner/memory-claim.d.ts +10 -5
  185. package/dist/runner/memory-claim.js +12 -6
  186. package/dist/runner/model-route.d.ts +7 -4
  187. package/dist/runner/model-route.js +22 -10
  188. package/dist/runner/native-loop.d.ts +0 -7
  189. package/dist/runner/native-loop.js +9 -101
  190. package/dist/runner/promotion.d.ts +12 -8
  191. package/dist/runner/promotion.js +37 -28
  192. package/dist/runner/reflect-hook.d.ts +64 -95
  193. package/dist/runner/reflect-hook.js +112 -225
  194. package/dist/runner/run-channel.d.ts +43 -0
  195. package/dist/runner/run-channel.js +467 -0
  196. package/dist/runner/run-child-host.d.ts +169 -0
  197. package/dist/runner/run-child-host.js +1230 -0
  198. package/dist/runner/run-child.d.ts +1 -0
  199. package/dist/runner/run-child.js +254 -0
  200. package/dist/runner/run-errors.d.ts +2 -0
  201. package/dist/runner/run-errors.js +20 -0
  202. package/dist/runner/runner.js +1 -5
  203. package/dist/runner/sdk-ask.d.ts +78 -0
  204. package/dist/runner/sdk-ask.js +158 -0
  205. package/dist/runner/sdk-loop.d.ts +2 -4
  206. package/dist/runner/sdk-loop.js +29 -49
  207. package/dist/runner/store-secrets.d.ts +5 -3
  208. package/dist/runner/store-secrets.js +5 -1
  209. package/dist/runner/workflow-first.d.ts +5 -0
  210. package/dist/runner/workflow-first.js +4 -0
  211. package/dist/runner/workflow-spec.js +7 -2
  212. package/dist/runs-over-store.d.ts +16 -28
  213. package/dist/runs-over-store.js +31 -38
  214. package/dist/sdk/runs.d.ts +6 -11
  215. package/dist/sdk/runs.js +20 -41
  216. package/dist/sdk/schema.js +3 -4
  217. package/dist/seal-key.d.ts +5 -0
  218. package/dist/seal-key.js +7 -0
  219. package/dist/secrets.d.ts +3 -0
  220. package/dist/secrets.js +16 -3
  221. package/dist/server.d.ts +55 -33
  222. package/dist/server.js +689 -322
  223. package/dist/sign-ins-store.d.ts +8 -0
  224. package/dist/sign-ins-store.js +36 -1
  225. package/dist/skills.js +1 -1
  226. package/dist/store/index.d.ts +2 -2
  227. package/dist/store/index.js +1 -1
  228. package/dist/store/journal/storage.js +3 -0
  229. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  230. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  231. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  232. package/dist/store/schema.d.ts +53 -4
  233. package/dist/store/schema.js +137 -6
  234. package/dist/store/sqlite/connection.d.ts +2 -0
  235. package/dist/store/sqlite/connection.js +3 -1
  236. package/dist/store/sqlite/run-patch.d.ts +0 -17
  237. package/dist/store/sqlite/run-patch.js +4 -33
  238. package/dist/store/sqlite/store.js +246 -63
  239. package/dist/store/sqlite/worker.js +25 -0
  240. package/dist/store/store.d.ts +193 -36
  241. package/dist/store/store.js +25 -3
  242. package/dist/store-reads/learning.d.ts +102 -204
  243. package/dist/store-reads/learning.js +159 -321
  244. package/dist/store-reads/loop.d.ts +0 -1
  245. package/dist/store-reads/loop.js +1 -1
  246. package/dist/store-view.d.ts +29 -1
  247. package/dist/store-view.js +97 -31
  248. package/dist/template-eval.d.ts +3 -6
  249. package/dist/template-eval.js +22 -36
  250. package/dist/templates.d.ts +8 -4
  251. package/dist/templates.js +44 -6
  252. package/dist/timeline/index.d.ts +1 -1
  253. package/dist/timeline/index.js +1 -1
  254. package/dist/timeline/timeline.d.ts +5 -1
  255. package/dist/timeline/timeline.js +16 -0
  256. package/dist/tool-gate.d.ts +0 -7
  257. package/dist/tool-gate.js +1 -15
  258. package/dist/tool-keys-store.d.ts +1 -1
  259. package/dist/tool-keys.d.ts +6 -4
  260. package/dist/tool-keys.js +12 -6
  261. package/dist/tools.d.ts +2 -2
  262. package/dist/tools.js +11 -4
  263. package/dist/triggers.d.ts +65 -6
  264. package/dist/triggers.js +125 -19
  265. package/dist/validate.js +1 -1
  266. package/dist/webhooks.d.ts +7 -2
  267. package/dist/webhooks.js +12 -5
  268. package/dist/workspace/agent-computer.d.ts +2 -0
  269. package/dist/workspace/agent-computer.js +2 -0
  270. package/dist/workspace/archil-claim.d.ts +7 -0
  271. package/dist/workspace/archil-claim.js +29 -0
  272. package/dist/workspace/archil.d.ts +9 -1
  273. package/dist/workspace/archil.js +165 -3
  274. package/dist/workspace/attach.d.ts +3 -1
  275. package/dist/workspace/attach.js +2 -0
  276. package/dist/workspace/attached-computers.d.ts +16 -5
  277. package/dist/workspace/attached-computers.js +25 -9
  278. package/dist/workspace/computer-deps.js +1 -1
  279. package/dist/workspace/computer-for-claim.d.ts +7 -3
  280. package/dist/workspace/computer-for-claim.js +119 -22
  281. package/dist/workspace/computer-hold.js +2 -1
  282. package/dist/workspace/computer-kept.d.ts +11 -1
  283. package/dist/workspace/computer-kept.js +24 -3
  284. package/dist/workspace/resolve-computer.d.ts +33 -19
  285. package/dist/workspace/resolve-computer.js +172 -64
  286. package/dist/workspace/revision-skills.d.ts +1 -2
  287. package/dist/workspace/revision-skills.js +3 -4
  288. package/dist/workspace/run-workspace.d.ts +1 -1
  289. package/dist/workspace/run-workspace.js +5 -0
  290. package/dist/workspace/synced-folder.d.ts +85 -0
  291. package/dist/workspace/synced-folder.js +230 -0
  292. package/dist/workspace/workspace.d.ts +4 -0
  293. package/launcher/agentrun-serve +1 -1
  294. package/package.json +10 -10
  295. package/templates/README.md +8 -8
  296. package/templates/inbound-lead/agent.md +5 -4
  297. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  298. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  299. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  300. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  301. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  302. package/templates/inbound-lead/lead.schema.json +6 -5
  303. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  304. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  305. package/templates/kyb/agent.md +2 -1
  306. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  307. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  308. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  309. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  310. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  311. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  312. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  313. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  314. package/dist/console/assets/index-BUktRvS-.css +0 -1
  315. package/dist/console/assets/index-nB9kTfIN.js +0 -711
  316. package/dist/learn/grade.d.ts +0 -138
  317. package/dist/learn/grade.js +0 -682
  318. package/dist/learn/notes.d.ts +0 -81
  319. package/dist/learn/notes.js +0 -178
  320. package/dist/learn/reflect.d.ts +0 -77
  321. package/dist/learn/reflect.js +0 -228
  322. package/dist/learn/relevance.d.ts +0 -24
  323. package/dist/learn/relevance.js +0 -91
  324. package/dist/learn/seed-check.d.ts +0 -74
  325. package/dist/learn/seed-check.js +0 -103
  326. package/dist/learning-batch.d.ts +0 -291
  327. package/dist/learning-batch.js +0 -600
  328. package/dist/learning-evals.d.ts +0 -35
  329. package/dist/learning-evals.js +0 -99
  330. package/dist/native/context.d.ts +0 -6
  331. package/dist/native/context.js +0 -22
  332. package/dist/propose.d.ts +0 -52
  333. package/dist/propose.js +0 -224
  334. package/dist/runner/learning-ask.d.ts +0 -47
  335. package/dist/runner/learning-ask.js +0 -128
  336. package/dist/runner/learning-dispatch.d.ts +0 -45
  337. package/dist/runner/learning-dispatch.js +0 -99
  338. package/dist/runner/learning-factory.d.ts +0 -16
  339. package/dist/runner/learning-factory.js +0 -50
  340. package/dist/runner/learning-loop.d.ts +0 -273
  341. package/dist/runner/learning-loop.js +0 -521
  342. package/dist/usage.d.ts +0 -11
  343. package/dist/usage.js +0 -11
  344. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  345. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  346. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  347. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  348. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  349. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  350. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -1,34 +1,23 @@
1
- import { type DraftDryRun, type LearnedNote, type Problem, type Verdict } from "./learn/index.js";
1
+ import { type Problem } from "./learn/index.js";
2
2
  import { type LearningFolder } from "./learn/folder.js";
3
- import { type Workspace } from "./workspace/index.js";
3
+ import type { Workspace } from "./workspace/index.js";
4
+ export { learnsOf } from "./learning-setting.js";
4
5
  /** The server's learning switch (`--learning`, AGENTRUN_SERVE_LEARNING; capabilities.features.learning). `on`, the
5
6
  * default: a run learns when its agent's definition says `learning: true`. `off`: no run this server starts does. */
6
7
  export declare const LEARNING_MODES: readonly ["on", "off"];
7
8
  export type LearningMode = (typeof LEARNING_MODES)[number];
8
- /** Whether a revision's `learning` (its definition's: true, false, "notes" or the loop's numbers, learning-setting.ts) has
9
- * its runs learn: true (or an object) learns notes, skills and workflows; "notes" learns notes and skills alone, never
10
- * given a learned workflow nor asked to draft one. */
11
- export declare const learnsOf: (learning: unknown) => boolean;
12
9
  export declare const LEARNING_ENV = "AGENTRUN_SERVE_LEARNING";
13
10
  /** The switch: `given`, else AGENTRUN_SERVE_LEARNING, else on. Any other value is an error, and the server does not start. */
14
11
  export declare function learningOf(env: NodeJS.ProcessEnv, given?: string): LearningMode;
15
- /** How much of what a run learned its instructions hold under `# Learned` by default, in UTF-8 bytes (learnedParts): its
16
- * notes whole while they fit, else the notes that bear most on the run whole while they fit, then a line for each of
17
- * the next while they fit; the rest are left out, and the run's log names them. */
18
- export declare const LEARNING_BUDGET = 8000;
19
- export declare const LEARNING_BUDGET_ENV = "AGENTRUN_SERVE_LEARNING_BUDGET";
20
- /** The learning budget: `given` (`--learning-budget`), else AGENTRUN_SERVE_LEARNING_BUDGET, else LEARNING_BUDGET. Any
21
- * value that is not a whole number of bytes, 0 or more, is an error, and the server does not start. */
22
- export declare function learningBudgetOf(env: NodeJS.ProcessEnv, given?: number): number;
23
12
  /** Where a run's learning stands (its `learning`, runs.ts): `seeded` once it starts from what its agent learned,
24
- * `reflecting` while its end-of-run turn runs and until what it answered is checked, `proposed` once that passed the
25
- * checks and is kept (propose.ts), `merged` once it is on main (runner/learning-loop.ts), or `dropped` with a
26
- * reason from the closed list. A learning fault never refuses a run: it starts with nothing learned, `seed_failed`. */
27
- export declare const LEARNING_STATES: readonly ["seeded", "reflecting", "proposed", "merged", "dropped"];
28
- export declare const LEARNING_REASONS: readonly ["seed_failed", "no_budget", "unknown_cost", "cancelled", "crashed", "reflect_timeout", "reflect_failed", "empty", "unparsed", "propose_failed", "checker", "grader", "grade_failed", "use"];
13
+ * `reflecting` while its end-of-run step runs (its compile turn, its owner's correction), `merged` once what it learned
14
+ * is on main, or `dropped` with a reason from the closed list. A learning fault never refuses a run: it starts with
15
+ * nothing learned, `seed_failed`. */
16
+ export declare const LEARNING_STATES: readonly ["seeded", "reflecting", "merged", "dropped"];
17
+ export declare const LEARNING_REASONS: readonly ["seed_failed", "no_budget", "unknown_cost", "cancelled", "crashed", "reflect_failed", "empty", "checker", "use"];
29
18
  /** A run's own `learning` on its start (POST /agents/{agent_id}/runs): it starts from what its agent learned, as a run that
30
- * learns does, and keeps nothing (no end-of-run turn, no proposal, no grade, no merge, at any end), so runs of one agent
31
- * read one learned state however many run at once. Its learning ends `dropped`, reason `use`. */
19
+ * learns does, and keeps nothing (no compile, no correction, at any end), so runs of one agent read one learned state
20
+ * however many run at once. Its learning ends `dropped`, reason `use`. */
32
21
  export declare const RUN_LEARNING_USE = "use";
33
22
  export type LearningState = (typeof LEARNING_STATES)[number];
34
23
  export type LearningReason = (typeof LEARNING_REASONS)[number];
@@ -40,76 +29,28 @@ export type Tokens = {
40
29
  cache_write: number;
41
30
  output: number;
42
31
  };
43
- /** The variable that names the grader's model, as `--grade-model` does. */
44
- export declare const GRADE_MODEL_ENV = "AGENTRUN_SERVE_GRADE_MODEL";
45
- /** The model this server grades on, by name: `given` (`--grade-model`), else GRADE_MODEL_ENV, else its strong tier
46
- * (AGENT_MODEL_STRONG); undefined when it names none, and each run is graded on its agent's own model (runner/learning-loop.ts). A
47
- * name is a model as the strong tier takes one: sent as it is to a gateway, a provider/model-id otherwise. */
48
- export declare const gradeModelOf: (env: NodeJS.ProcessEnv, given?: string) => string | undefined;
49
- /** How many of an agent's runs were given a note, and read it, by the note's file (learning-run.ts noteRuns). */
50
- export type NoteRuns = Map<string, {
51
- given: number;
52
- read: number;
53
- }>;
54
- /** A note by its file and its front matter's name: one a run was given (`given`) or read (`read`). */
55
- export type NoteUsed = {
56
- file: string;
57
- name: string;
58
- };
59
- /** A note a run's learning added to the folder (`learned`): its file, its name, and the notes it superseded. */
60
- export type NoteLearned = NoteUsed & {
61
- supersedes: string[];
62
- };
63
- /** A run's learning as the store keeps it. Past the view's four fields: the checker's `problems` (printable), the
64
- * grader's `verdict` and the blob of each note it read superseded (`graded`, by file), both kept before the merge, the
65
- * merge commit, and what the grade cost (null when unknown, never 0), which is in no run's totals; the notes the run
66
- * started with (`given`: each note its # Learned section names, whole or as an index line, set as it is seeded) and read
67
- * from `.learning/` (`read`, found in its rows as it settles), and once merged the notes it added (`learned`);
68
- * and how many notes it started from (`seed_notes`). Names are kept as written, and cut of the host's secrets as they
69
- * leave. */
32
+ /** A run's learning as the store keeps it. Past the view's four fields: the checks' `problems` (printable), the merge
33
+ * commit, and once it merged the workflow draft it wrote (`workflows`) or the corrections it added (`corrections`, the
34
+ * lines). */
70
35
  export type Learning = {
71
36
  state: LearningState;
72
37
  reason: LearningReason | null;
73
38
  detail: string | null;
74
39
  at: string;
75
40
  problems?: Problem[];
76
- verdict?: Verdict;
77
- graded?: Record<string, string>;
78
41
  merged?: string;
79
- cost_usd?: {
80
- grade: number | null;
81
- };
82
- tokens?: {
83
- grade: Tokens | null;
84
- };
85
- given?: NoteUsed[];
86
- read?: NoteUsed[];
87
- learned?: NoteLearned[];
88
- /** How many active notes the run started from: its seed's, set as it is seeded (none for a seed that failed). */
89
- seed_notes?: number;
90
- /** Once it asked its end-of-run turn: when its job's answer was final (before it looked back), and what the run had
91
- * cost by then (null when unknown); once that turn ended, what the turn itself cost (null when unknown). */
42
+ /** Once its end-of-run step asked its compile turn: when its job's answer was final, and what the run had cost by then
43
+ * (null when unknown); once that turn ended, what the turn itself cost (null when unknown). */
92
44
  answered_at?: string;
93
45
  job_cost_usd?: number | null;
94
46
  look_back_usd?: number | null;
95
- /** A merge's notes that wait for a person's OK (`status: pending` on main): in no index, and no run reads them until
96
- * approved. */
97
- pending?: {
98
- file: string;
99
- name: string;
100
- }[];
101
- /** A merge's skill and workflow draft, by name and the path of its SKILL.md or workflow.json; `pending` when it waits
102
- * for a person's OK (`status: pending` in its SKILL.md or README.md), and no run is given it until approved. */
103
- skills?: LearnedFile[];
47
+ /** A merge's workflow draft, by name and the path of its workflow.json; `pending` when it waits for a person's OK
48
+ * (`status: pending` in its README.md), and no run is given it until approved. */
104
49
  workflows?: LearnedFile[];
105
- /** A grader's drop's skill and workflow draft, from what the run proposed: lost with the rest, and named when its
106
- * learning is said (learning-words.ts notKept). */
107
- lost?: LearnedFile[];
108
- /** A grader's drop on two answers the host could not read: the last, cut of secrets and in size (UNREAD_MAX), kept on the
109
- * run's file to diagnose it by, and served by no read. */
110
- unread?: string;
50
+ /** How many lines of its owner's words a merge added to corrections.md. */
51
+ corrections?: number;
111
52
  /** The compile turn's record, when the run's end-of-run turn wrote the agent's job as a learned workflow
112
- * (learn/compile.ts): the workflow, the notes it absorbed, and each attempt with what the checks refused. */
53
+ * (learn/compile.ts): the workflow, and each attempt with what the checks refused. */
113
54
  compiled?: LearningCompiled;
114
55
  /** What the checks refused of a compiled draft that never passed: never silent, on the run's learning and its API. */
115
56
  draft_errors?: string[];
@@ -118,7 +59,6 @@ export type Learning = {
118
59
  * promotion records when the run's learning is read, absent while undecided. */
119
60
  export type LearningCompiled = {
120
61
  workflow: string;
121
- from_notes: string[];
122
62
  attempts: {
123
63
  ok: boolean;
124
64
  errors: string[];
@@ -126,7 +66,7 @@ export type LearningCompiled = {
126
66
  digest?: string;
127
67
  promoted?: boolean;
128
68
  };
129
- /** A skill or a workflow draft a merge added or changed. */
69
+ /** A workflow draft a merge added or changed. */
130
70
  export type LearnedFile = {
131
71
  file: string;
132
72
  name: string;
@@ -139,55 +79,39 @@ export type Shown = {
139
79
  holds: (text: string) => boolean;
140
80
  };
141
81
  /** The host's secrets as a reader cuts them: a text holding a value or a shape is cut of it (whole when long:
142
- * learn/secrets.ts redactLearned, a bank's numbers too), and a file's name holding one reads REDACTED whole, not a name of the folder's (its
143
- * route still answers the real name, to a caller who knows it); any other text or name is shown as it is. A text served
144
- * has no loopback address, the address alone (key-refusal.ts withoutLoopbackAddresses, the pattern a run's words share,
145
- * run-view.ts shownOf): the host's own, never a person's; a run error's `url:` tail is no rule of a note's, a patch's or a
146
- * workflow.json's, so their label, line ends and JSON stay. `local`: kept, for what a run itself is given (its .learning/ notes, runner/learning-seed.ts, and its
147
- * # Learned section, server.ts's learning start), where an address on the run's own machine is the note's to give. */
82
+ * learn/secrets.ts redactLearned, a bank's numbers too), and a file's name holding one reads REDACTED whole; any other
83
+ * text or name is shown as it is. A text served has no loopback address (key-refusal.ts withoutLoopbackAddresses): the
84
+ * host's own, never a person's. `local`: kept, for what a run itself is given (its # Learned section), where an address
85
+ * on the run's own machine is the owner's to give. */
148
86
  export declare function secretsShown(values: readonly string[], { local }?: {
149
87
  local?: boolean;
150
88
  }): Shown;
151
- /** The notes a run read and learned, as a view or a list shows them, each name cut of the host's secrets (`shown`):
152
- * `given` from its start, `read` once the run settled, `learned` and `pending` (what waits for the owner's OK) once it merged, and the skill
153
- * and the workflow draft it merged (`skills`, `workflows`, each `pending` while it waits), each only when it holds one.
154
- * the stored ones are read as untrusted: an entry out of shape is left out. */
155
- export declare function notesView({ state, given, read: opened, learned, pending, skills, workflows }: Learning, shown: Shown, settled: boolean): {
156
- given?: NoteUsed[];
157
- read?: NoteUsed[];
158
- learned?: NoteLearned[];
159
- pending?: NoteUsed[];
160
- skills?: LearnedFile[];
89
+ /** The workflow draft a run merged, as a view or a list shows it (each `pending` while it waits), each name cut of the
90
+ * host's secrets (`shown`), only when it holds one. The stored ones are read as untrusted: an entry out of shape is
91
+ * left out. */
92
+ export declare function filesView({ state, workflows }: Learning, shown: Shown): {
161
93
  workflows?: LearnedFile[];
162
94
  };
163
- /** A learned item's status on main (a note's front matter, a skill's SKILL.md, a draft's README.md), with what a note
164
- * supersedes. */
95
+ /** A draft's status on main (its README.md's). */
165
96
  export type ItemStatus = {
166
97
  status: string;
167
- supersedes?: readonly string[];
168
98
  };
169
- /** Whether a run's learning held anything for its owner's OK: a merge with a held note, skill or draft. Only such a
170
- * run's reads check main (currentLearning). */
99
+ /** Whether a run's learning held anything for its owner's OK: a merge with a held draft. Only such a run's reads check
100
+ * main (currentLearning). */
171
101
  export declare const holdsForOk: (learning: Learning | undefined) => learning is Learning;
172
- /** A merged run's learning as it reads now: what it held for the owner's OK checked against each item's status on
173
- * main now (`status`, by file: a note's, a skill's SKILL.md, a draft's workflow.json). Still pending, it waits; approved
174
- * (active), it is learned, as a merge that held nothing says it; retired or gone, it is no longer said. The record keeps
175
- * what the merge wrote; only its reads change. No status (the folder unread): as written. */
102
+ /** A merged run's learning as it reads now: what it held for the owner's OK checked against each draft's status on main
103
+ * now (`status`, by its workflow.json). Still pending, it waits; approved (active), it is learned, as a merge that held
104
+ * nothing says it; retired or gone, it is no longer said. No status (the folder unread): as written. */
176
105
  export declare function currentLearning(learning: Learning, status: ReadonlyMap<string, ItemStatus> | undefined): Learning;
177
106
  /** 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
178
107
  * secrets as they are now (`shown`) first, then the words cut short to `max`, so a secret is never shown in part. */
179
108
  export declare const detailShown: (learning: Learning, shown: Shown, max?: number) => string | null;
180
- /** A run's learning as its view shows it: the state, why in a person's words (detailShown), and when, and the notes it
181
- * read, learned and holds for the owner's OK (notesView). */
182
- export declare const learningView: (learning: Learning, shown: Shown, settled: boolean) => {
183
- given?: NoteUsed[];
184
- read?: NoteUsed[];
185
- learned?: NoteLearned[];
186
- pending?: NoteUsed[];
187
- skills?: LearnedFile[];
109
+ /** A run's learning as its view shows it: the state, why in a person's words (detailShown), when, and the draft it
110
+ * merged (filesView). */
111
+ export declare const learningView: (learning: Learning, shown: Shown) => {
188
112
  workflows?: LearnedFile[];
189
- state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
190
- reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
113
+ state: "dropped" | "merged" | "seeded" | "reflecting";
114
+ reason: "cancelled" | "use" | "empty" | "crashed" | "reflect_failed" | "no_budget" | "checker" | "unknown_cost" | "seed_failed" | null;
191
115
  detail: string | null;
192
116
  at: string;
193
117
  };
@@ -200,88 +124,25 @@ export declare function shortOf<T extends {
200
124
  reason: LearningReason | null;
201
125
  detail: string | null;
202
126
  at: string;
203
- }>({ state, reason, detail, at: _, ...notes }: T): {
204
- state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
205
- reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
127
+ }>({ state, reason, detail, at: _, ...rest }: T): {
128
+ state: "dropped" | "merged" | "seeded" | "reflecting";
129
+ reason: "cancelled" | "use" | "empty" | "crashed" | "reflect_failed" | "no_budget" | "checker" | "unknown_cost" | "seed_failed" | null;
206
130
  detail: string | null;
207
131
  } & Omit<T, "at" | "reason" | "state" | "detail">;
208
132
  /** The label of the end-of-run turn's timeline rows, and the kind and label of a run's learning row. */
209
133
  export declare const LEARNING_LABEL = "learning";
210
- /** A run's proposal, in its directory (propose.ts): the seed it was checked against, each new note's file and text, its
211
- * skill's and workflow draft's files by path and text (`files`: a SKILL.md, a workflow.json and its README.md; absent
212
- * when it gives none), and what the user said in the run as the grader reads it (each message cut of the host's
213
- * secrets, then shortened to its head and tail, shortMessage; absent in a proposal kept before the grader read them). */
214
- export declare const PROPOSAL = "learning-proposal.json";
215
- /** A run's proposal: its notes, skill and drafts, each draft's dry run by its workflow.json's path (learn/skills.ts
216
- * draftDryRun: passed, or not run and why), the skill of each draft's name as the folder holds it at the seed
217
- * (`drafted`, its SKILL.md: shown to the grader beside the draft, never graded or merged), and what was said in the run.
218
- * `bases`: a file whose conflict base is not the seed, by its path: a revised workflow's, the commit of main its compile
219
- * ask read it at. */
220
- export type Proposal = {
221
- seed: string;
222
- bases?: Record<string, string>;
223
- notes: {
224
- file: string;
225
- text: string;
226
- }[];
227
- files?: {
228
- file: string;
229
- text: string;
230
- }[];
231
- dryRuns?: Record<string, DraftDryRun>;
232
- drafted?: {
233
- file: string;
234
- text: string;
235
- }[];
236
- asked?: string[];
237
- triggered?: Triggered[];
238
- };
239
134
  /** A message a trigger sent the run that its owner did not write (a webhook body, a Slack or GitHub event), by its
240
135
  * source: never what the user said. */
241
136
  export type Triggered = {
242
137
  source: string;
243
138
  text: string;
244
139
  };
245
- /** A run's pin, in its directory: written once, when the run is made, and never changed by a resume. */
246
- export declare const LEARNING_PIN = "learning.json";
247
- /** Where a run finds its agent's notes: in its work, a copy the run may read and nothing reads back. */
248
- export declare const LEARNED_DIR = ".learning";
249
- /** What the run's end-of-run turn answered, and what the user said in the run: what propose.ts checks. */
250
- export type Turn = {
251
- answer: string;
252
- asked: string[];
253
- triggered?: Triggered[];
254
- };
255
- /** What a run's pin holds: the commit of main it was seeded from (null: the folder had no main yet, so the run learns
256
- * from an empty seed), and what it reads under `# Learned` (learnedParts), when it learned anything.
257
- * `skills`: the files of the learned skills laid in its work, by their paths under `.agents/skills/`, as a revision
258
- * names its own; `skills_left_out`: the learned skills it does not get, over their budget or holding a secret.
259
- * `workflows`: the names of the learned workflows the run may run (its `learned_workflow` tool), each written whole in
260
- * LEARNED_WORKFLOWS_FILE in the run's directory, outside its work; `workflows_left_out`: the learned workflows it does
261
- * not get, their lines over what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET), or holding a
262
- * secret. Every harness runs them, on the run's one model route. */
263
- export type Pin = {
264
- seed: string | null;
265
- section?: string;
266
- given?: NoteUsed[];
267
- skills?: string[];
268
- skills_left_out?: string[];
269
- workflows?: string[];
270
- workflows_left_out?: string[];
271
- };
272
- /** What a run is seeded from: main's commit (null when the folder has none yet), its index and its active notes by
273
- * file, and the name of every entry at its top. `skipped` names what was there and not read. `recent`, when seedOf read it: the active notes' files, the one
274
- * changed last on main first. `skills`, when seedOf read them: the skills the agent wrote, the one changed last on main
275
- * first. `workflows`: its active learned workflows, by name. */
140
+ /** What a run is seeded from: main's commit (null when the folder has none yet), corrections.md's text ("" when none),
141
+ * and its active learned workflows, by name. */
276
142
  export type Seed = {
277
143
  sha: string | null;
278
- index?: string;
279
- notes: Record<string, string>;
280
- files: string[];
281
- skipped: string[];
282
- recent?: string[];
283
- skills?: LearnedSkill[];
284
- workflows?: LearnedWorkflow[];
144
+ corrections: string;
145
+ workflows: LearnedWorkflow[];
285
146
  };
286
147
  /** A workflow the agent learned, as a run may run it: its name, the line its README says what it does with, and its
287
148
  * workflow.json whole. */
@@ -290,9 +151,6 @@ export type LearnedWorkflow = {
290
151
  description: string;
291
152
  workflow: string;
292
153
  };
293
- /** Where a run keeps the learned workflows its pin names, whole: in the run's directory, beside its pin, never in its
294
- * work, so nothing the run does changes what its `learned_workflow` tool runs. */
295
- export declare const LEARNED_WORKFLOWS_FILE = "learned-workflows.json";
296
154
  /** The most bytes the `learned_workflow` tool's description gives its workflows, each one's line (workflowLine)
297
155
  * together: every harness sends the description with each request, so it never grows with what an agent learned. */
298
156
  export declare const LEARNED_WORKFLOWS_BUDGET: number;
@@ -302,17 +160,6 @@ export declare const LEARNED_WORKFLOWS_BUDGET: number;
302
160
  export declare const workflowLine: ({ name, description, workflow }: Pick<LearnedWorkflow, "name" | "description"> & {
303
161
  workflow?: string;
304
162
  }) => string;
305
- /** The most bytes of learned skills one run gets, every file of each together. They get no more than what the
306
- * revision's own skills leave of the adapters' cap on a run's skills in all (SKILL_BYTES): over that cap an adapter
307
- * refuses the whole set, and every skill, the revision's too, would be inlined in the prompt (skills.ts splitSkills). */
308
- export declare const LEARNED_SKILLS_BUDGET: number;
309
- /** A skill the agent wrote, as a seed holds it: its name, its files' bytes together, and each file's text by its path
310
- * inside the skill, read only when the skill could fit a run's budget at all. */
311
- export type LearnedSkill = {
312
- name: string;
313
- bytes: number;
314
- files?: Record<string, string>;
315
- };
316
163
  /** The agent's learning folder: `learning/` in its folder on the disk, which only the host writes. The folder is files.ts
317
164
  * agentFolderOf (server-fs.ts agentDiskDir), so two ids that differ only in case never share one. */
318
165
  export declare const learningRepo: (data: string, agentId: string) => string;
@@ -322,164 +169,13 @@ export declare const withAgentRepo: <T>(data: string, agentId: string, work: ()
322
169
  /** Agent `agentId`'s learning folder (learn/folder.ts learningWorkspace), in this server's place: Mode 1's local folder
323
170
  * under `data`. The one point that names the place; its `end()` is called in a finally after every use. */
324
171
  export declare const learningFolderOf: (data: string, agentId: string) => LearningFolder;
325
- /** What the learning folder's read at a commit gives a run's seed (the folder's script's read op, through the agent's
326
- * learning Workspace): each file of its index, its active notes and its active skills, by its path from the folder's
327
- * root, each skill it left out whole and why (`refused`, always there: a skill holding a tracked link), and every entry
328
- * at the commit's top whatever its status (`held`: the index, every note, the skills' and workflows' folders); or why
329
- * it has none: the folder cannot answer now (`unavailable`), or the commit is no longer there (`gone`). */
330
- export type SeedRead = {
331
- ok: true;
332
- files: readonly {
333
- path: string;
334
- text: string;
335
- }[];
336
- refused: readonly {
337
- skill: string;
338
- why: string;
339
- }[];
340
- held: readonly string[];
341
- } | {
342
- ok: false;
343
- why: "unavailable" | "gone";
344
- };
345
- /** The read at `commit` (null: the folder has no main yet, an empty read). */
346
- export type SeedReader = (commit: string | null) => Promise<SeedRead>;
347
- /** What a seed can't tell from its read alone, as the folder's snapshot keeps it: each note file's place in main's log
348
- * (0 the newest) and each skill's by its name. Order alone: what main holds is the read's (`held`). */
349
- export type SeedOrder = {
350
- readonly notes: readonly {
351
- file: string;
352
- order: number;
353
- }[];
354
- readonly skills?: readonly {
355
- name: string;
356
- order: number;
357
- }[];
358
- };
359
- /** A run's seed from the folder's read at `commit` (`read`): its index, its notes the one changed last first, its
360
- * skills grouped by folder, the one changed last first, each with its files while it could fit a run's budget at all
361
- * (LEARNED_SKILLS_BUDGET), else held by its size alone, and its active learned workflows by name. A path that is none (a file deeper than the folder's top, a
362
- * skill folder named out of shape) is named in `skipped`. A skill the read refused is not in it, and is said in one
363
- * `warn` line of the run. No commit yet (null, read as null) is an empty seed whose commit stays null; a read that fails
364
- * throws, saying why, and the run starts with nothing learned (or, opened again, keeps what it has). No git here: the
365
- * read is the folder's. */
366
- export declare function seedFrom(commit: string | null, read: SeedReader, { order, warn }?: {
367
- order?: SeedOrder;
368
- warn?: (line: string) => void;
369
- }): Promise<Seed>;
370
- /** What seedFrom reads through the agent's learning folder: the script's read at a commit, or the snapshot and its
371
- * bodies when the commit is main's (learn/seed-check.ts readSeed). No git in this process. */
372
- export declare const readerOf: (ws: Workspace) => SeedReader;
373
172
  /** The seed of a run of agent `agentId` about to be made: main's commit, the folder made first when it is absent (the
374
- * learning script's init), and what main holds for a run (seedFrom over the folder's read): its index, its active
375
- * notes the one changed last first, its active skills, and its active learned workflows. A skill the read refused is
376
- * said through `warn`. In the agent's queue. No git in this process: the folder's own script and file API. */
377
- export declare function seedOf(data: string, agentId: string, warn?: (line: string) => void): Promise<Seed>;
378
- /** What commit `sha` of the agent's folder holds for a run, as seedOf reads main: a run's seed, read again (a follow-up's
379
- * copy, the names of the notes it read). No commit (a pin of an empty seed) is the empty seed. */
380
- export declare const seedAt: (data: string, agentId: string, sha: string | null) => Promise<Seed>;
381
- /** The skills the agent wrote at commit `sha` (seedAt's): what a run's pin names, laid again. */
382
- export declare const skillsAt: (data: string, agentId: string, sha: string | null) => Promise<LearnedSkill[]>;
383
- /** The active notes of a seed, parsed. */
384
- export declare const activeOf: (seed: Pick<Seed, "notes">) => LearnedNote[];
385
- /** Test seams, tests only: once a part of an agent's learning folder is made (before its check), before a run's
386
- * learned files are written, once its pin is in place, before what its end-of-run turn wrote is checked, as a run that
387
- * learns opens again for a follow-up, and as each git call starts (its arguments). */
388
- export declare const learningTestHooks: {
389
- afterPin?: (runDir: string) => Promise<void> | void;
390
- };
391
- /** Lays `seed`'s index and active notes in the run's `.learning/`, through its Workspace, made fresh: whatever was there
392
- * goes. The index names the active notes alone (servedIndex), and each file is cut of the host's secrets (`shown`), the
393
- * index a line at a time. */
394
- export declare function layLearned(work: Workspace, seed: Seed, shown: Shown): Promise<void>;
395
- /** How a run reads what it learned (learnedParts): the server's learning budget, in bytes; whether its agent has the read
396
- * tool; the host's secrets, which every text is cut of; and which of its notes it is given (`select`, byRelevance when
397
- * none) for the run it starts (`run`: what the selector may read of it, its input). */
398
- export type LearnedOptions = {
399
- budget: number;
400
- read: boolean;
401
- shown: Shown;
402
- select?: NoteSelector;
403
- run?: RunInput;
404
- };
405
- /** What a note selector may read of the run it chooses for: the input it was started with. */
406
- export type RunInput = {
407
- readonly input?: unknown;
408
- };
409
- /** What a note selector chooses from: the agent's active notes, newest first, each with the UTF-8 bytes it takes whole
410
- * (its block and the blank line before it); the bytes the served index takes (0 when there is none); whether every index
411
- * line names an active note (none names one main does not hold whole); and the learning budget. */
412
- export type NoteCandidates = {
413
- /** Each note, with the bytes it takes whole and the bytes it takes as one rule line (`lineBytes`: its name, file and
414
- * description on one line). */
415
- readonly notes: readonly {
416
- readonly note: LearnedNote;
417
- readonly bytes: number;
418
- readonly lineBytes: number;
419
- }[];
420
- readonly indexBytes: number;
421
- readonly indexComplete: boolean;
422
- readonly budget: number;
423
- /** Whether the run has the read tool, so the section past the budget names `.learning/` (READ_LINE) and its room is kept
424
- * for that line. Absent: kept, as for a run that has it. */
425
- readonly read?: boolean;
426
- };
427
- /** A selector's choice: the notes the run reads whole, in the order it reads them (a subset of the candidates), and
428
- * whether it reads the index first. Without the index, the notes are all it is given; or, with `lines`, the notes it
429
- * reads as one rule line each after them, in their place (`index` is then false). */
430
- export type NoteSelection = {
431
- readonly whole: readonly LearnedNote[];
432
- readonly index: boolean;
433
- readonly lines?: readonly LearnedNote[];
434
- };
435
- /** The port that chooses which of an agent's notes a run gets (learnedParts; byRelevance when none is named). It chooses only: the seed, the pin, the cut of
436
- * the host's secrets and the section's words stay learnedParts'. A selector keeps the budget: its whole notes, and the
437
- * index when it serves it, fit `budget`, past which only the index may go (as loadedIndex bounds it). */
438
- export type NoteSelector = (candidates: NoteCandidates, run: RunInput) => NoteSelection;
439
- /** The selector by recency: every note whole while all fit the budget and the index names no note main does not hold
440
- * whole; notes that fit with an index that names one it lacks, the index, then the newest notes that fit what it
441
- * leaves, each whole; past the budget, the newest notes whole while they fit, then a line for each of the next while
442
- * they fit (withinBudget). */
443
- export declare const byRecency: NoteSelector;
444
- /** The default selector, by relevance, past the budget: while the notes fit it, recency's choice (byRecency). Else each
445
- * note is scored against the run's input (learn/relevance.ts: BM25 over its name, description and body, a code
446
- * review's changed paths' words weighed PATH_WEIGHT; no model call), and the run reads the notes that bear on it most
447
- * whole, best first, while they fit the budget, then one rule line for each of the next while they fit what is left
448
- * (withinBudget), a note that bears on it in no word a line at most; the rest are left out. An input with no word any
449
- * note holds reads by recency. */
450
- export declare const byRelevance: NoteSelector;
451
- /** What a run of `seed` reads under `# Learned` (`section`, the same for every harness, undefined when it learned
452
- * nothing) and the notes that names (`given`), from one choice of the selector, so the section and the given notes never
453
- * come from two choices. Only active notes are served: a pending, superseded or retired one is never there, whole or in
454
- * the index, nor counted toward the budget (readSeed reads active notes alone, and servedIndex drops their lines). Its
455
- * active notes, newest first (`seed.recent`, else by name), each whole while all fit `budget`; past it, the selector's
456
- * choice (byRelevance by default). An agent with the read tool is told the rest are in `.learning/`, one without is not.
457
- * Notes past a budget that holds none of them (0 among them) are said to be there (NONE_FIT), never "Nothing learned yet.".
458
- * Every text is cut of the host's secrets. A run "was given" `given`; of them, it "read" those whose file it opened
459
- * (store-reads/learning.ts notesReadOf). Whether it applied one given whole is not measured. `left`: the active notes
460
- * the section names in no way, over the budget, which the run's log names (runner/learning-seed.ts). */
461
- export declare function learnedParts(seed: Seed, options: LearnedOptions): {
462
- section: string | undefined;
463
- given: LearnedNote[];
464
- left: LearnedNote[];
465
- };
466
- /** Lays each of `skills` in the run's `.agents/skills/<name>/` through its Workspace, a folder made new for it (one
467
- * already there throws EXISTS); a link on the way is ESCAPE, and nothing is written through it. Each name goes in
468
- * `made` once its folder is, so a caller that fails takes back what was laid. */
469
- export declare function laySkills(work: Workspace, skills: readonly LearnedSkill[], made: string[]): Promise<void>;
470
- /** Takes the learned skills `names` back out of the run's work: each `.agents/skills/<name>/`, unless a folder on the
471
- * way is a link (or no folder), when nothing is touched. */
472
- export declare function takeSkills(work: Workspace, names: Iterable<string>): Promise<void>;
473
- /** Which of `seed`'s learned skills a run gets, in `work`, in the seed's order: each whole while they fit their budget,
474
- * LEARNED_SKILLS_BUDGET and never more than the revision's `own` skill files leave of SKILL_BYTES, sized in each form a
475
- * harness is handed them, the larger: as they are in `work` (claude-agent, codex) and as servedSkills writes them
476
- * (OpenCode, whose check reads that form). One named like a folder of the revision's skills, or like anything already in `work/.agents/skills/`, is
477
- * the revision's, and not the run's; one that does not fit, or holds a host secret (`shown`) as stored or as laid, is
478
- * left out. */
479
- export declare function chooseSkills(work: Workspace, seed: Seed, own: readonly string[], shown: Shown): Promise<{
480
- taken: LearnedSkill[];
481
- left: string[];
482
- }>;
173
+ * learning script's init), and what main holds for a run (seedIn). In the agent's queue. No git in this process: the
174
+ * folder's own script and file API. */
175
+ export declare function seedOf(data: string, agentId: string): Promise<Seed>;
176
+ /** What commit `commit` of the folder holds for a run, as seedOf reads main (one read-only exec of the script). No commit
177
+ * (null) is the empty seed; a commit the folder no longer holds throws. */
178
+ export declare function seedAt(ws: Workspace, commit: string | null): Promise<Seed>;
483
179
  /** Whether `text` holds a host secret (`shown`): as written, or, read as JSON, in any string it decodes to (its escapes
484
180
  * decoded), or nested past the bound. The one check a learned workflow's text passes at a run's start (chooseWorkflows)
485
181
  * and every text its compile turn is told (runner/learning-end.ts compileAskOf); a text that is not JSON is read as
@@ -488,44 +184,17 @@ export declare const holdsSecret: (text: string, shown: Shown) => boolean;
488
184
  /** Which of `seed`'s learned workflows a run may run (its `learned_workflow` tool), in the seed's order: each while its
489
185
  * line (workflowLine) fits what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET). One that does not,
490
186
  * or holds a host secret (`shown`), is left out and named in `left`, but for one whose name is itself a secret, never
491
- * named. Main's start (pinSeed) and a runner's claim (runner/learning-seed.ts) choose them the one way. */
187
+ * named. */
492
188
  export declare function chooseWorkflows(seed: Seed, shown: Shown): {
493
189
  flows: LearnedWorkflow[];
494
190
  left: string[];
495
191
  };
496
- /** Writes `seed` into the run just made in `runDir`, its files through the run's Workspace (`work`): the index and each
497
- * active note into `.learning/`, made fresh (whatever was there goes), then the pin, with what the run reads under
498
- * `# Learned` (learnedParts) and the learned skills it gets beside the revision's `own` skill files (chooseSkills), then
499
- * those skills, last, into `.agents/skills/`. A write that fails leaves no `.learning/`, no learned skill and no pin,
500
- * and throws. */
501
- export declare function pinSeed(runDir: string, work: Workspace, seed: Seed, options: LearnedOptions & {
502
- own?: readonly string[];
503
- }): Promise<Pin>;
504
- /** Lays the learned skills a reopened run's pin names (`pin.skills`) again, fresh, from `read` (the skills of its seed's
505
- * commit: skillsAt): what the run wrote over them, or took away, is not what it learned. Each only with the files the
506
- * pin names. Throws when it cannot, a link on the way among the reasons. */
507
- export declare function layPinnedSkills(work: Workspace, pin: Pin, read: () => Promise<LearnedSkill[]>): Promise<void>;
508
- /** Takes back a seed whose copy a server went down during (runs.ts load): the learned skills its pin names, the pin,
509
- * then the run's `.learning/`, through its Workspace. True when the pin or the copy was there. */
510
- export declare function dropSeed(runDir: string, work: Workspace): Promise<boolean>;
511
- /** The run's pin, as its process reads it: undefined when the run has none (its agent does not learn, its seed failed, a
512
- * workflow's run). A pin out of shape is an error, never read as none. */
513
- export declare function readPin(runDir: string): Promise<Pin | undefined>;
192
+ /** A run's # Learned text from its seed: corrections.md whole, each line cut of the host's secrets (`shown`). Empty when
193
+ * the owner corrected nothing yet. */
194
+ export declare const learnedSection: (seed: Pick<Seed, "corrections">, shown: Shown) => string;
514
195
  /** The heading of what a run learned, in its instructions. */
515
196
  export declare const LEARNED_HEADING = "# Learned";
516
- /** A run's instructions with its # Learned section laid in main's position: the revision's instructions, then the heading,
517
- * LEARNS (USES for a run that only `use`s what its agent learned), and the section text — "Nothing learned yet." when the
518
- * run learns but its section is empty (no notes yet, or a seed that could not be read). Shared so the runner (laying
519
- * launch.learning.section, read with no folder) and app.ts (withLearned) lay the same bytes. */
520
- export declare const laidLearned: (instructions: string, section: string | undefined, use?: boolean) => string;
521
- /** A run's instructions, with `# Learned` after them when its pin in `runDir` says it learns: that it learns, then what
522
- * the pin says it learned, or that it has learned nothing yet. A run with no pin (its agent does not learn, its seed
523
- * failed, a workflow's run) is never asked what to keep, so it is told nothing. And its skill files: the revision's
524
- * `own`, then the learned ones its pin names, by their paths under `.agents/skills/` in `work`, but for a skill named
525
- * like one of the revision's, which is the revision's. A learned skill the work no longer holds whole, as a harness reads
526
- * it through the run's Workspace (no link on the way), is left out: a learning fault never fails a run. The one path for
527
- * every harness (app.ts): pi's system prompt, claude-agent's and codex's instructions, and the skills each gets. */
528
- export declare function withLearned(runDir: string, given: Workspace | string, instructions: string, own?: readonly string[]): Promise<{
529
- instructions: string;
530
- skills: string[];
531
- }>;
197
+ /** A run's instructions with its # Learned section laid in: the revision's instructions, then the heading, and its owner's
198
+ * corrections (CORRECTIONS_INTRO, then the section), or "Nothing learned yet." when there are none (or a seed that could
199
+ * not be read). Shared so every harness lays the same bytes. */
200
+ export declare const laidLearned: (instructions: string, section: string | undefined) => string;