@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31

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 (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -14,7 +14,7 @@ export type Reflect = {
14
14
  timedOut?: true;
15
15
  };
16
16
  /** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
17
- * with, at its one call (reflectTurn); the per-tool gate, once this server has one, takes it there. */
17
+ * with, at its one call (reflectTurn); the tool gate reads it there and refuses that turn's writes under work/.learning/ (tool-gate.ts NOTE_ONLY_TEXT). */
18
18
  declare const REFLECT_ORIGIN = "reflect";
19
19
  export type TurnOrigin = typeof REFLECT_ORIGIN;
20
20
  /** The run asked its end-of-run turn and has not ended since. */
@@ -90,7 +90,7 @@ export type ImpactLearning = {
90
90
  * note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
91
91
  export declare function learningImpact(rows: readonly RunRow[], learningOf: (row: RunRow) => ImpactLearning | null | undefined): Impact;
92
92
  /** What learning needs of the server's options: the data directory and the agents, its tokens, the switch, and its bounds. */
93
- export type LearningOptions = Pick<RunsOptions, "agents" | "token" | "doorToken" | "storedKeys" | "learning" | "learningBudget" | "reflectTimeoutMs" | "gradeTimeoutMs" | "gradeModel">;
93
+ export type LearningOptions = Pick<RunsOptions, "agents" | "token" | "doorToken" | "storedKeys" | "ownSecrets" | "learning" | "learningBudget" | "reflectTimeoutMs" | "gradeTimeoutMs" | "gradeModel">;
94
94
  /** What the kernel (runs.ts) hands learning: its runs, and the parts of a run's life learning moves. */
95
95
  export type LearningKernel = {
96
96
  /** Run `id` when the kernel holds it; read from the agent store the first time (`get`). */
@@ -163,7 +163,7 @@ export declare class LearningRuns {
163
163
  onLoad(row: Pick<RunRow, "id" | "agent" | "state">, dir: string, meta: Run["meta"], save: () => Promise<void>): Promise<void>;
164
164
  /** A run's process launched, handed the secrets named `names`: what each held then, as handover read it, kept beside
165
165
  * the run while its learning is under way (a key replaced since stays refused in its notes). */
166
- onLaunch(run: Run, names: readonly string[]): void;
166
+ onLaunch(run: Run, names: readonly string[], also?: readonly string[]): void;
167
167
  /** A running run read at a start, `live` when its process serves it still. One a server left while its end-of-run turn
168
168
  * ran is finishing with its job's outcome, and nothing opens it again; when its process lives, the turn is asked again
169
169
  * under the same request id, which it takes once, and waited for. */
@@ -236,7 +236,7 @@ export declare class LearningRuns {
236
236
  reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
237
237
  detail: string | null;
238
238
  at: string;
239
- }, "at" | "reason" | "state" | "detail">) | null;
239
+ }, "at" | "state" | "reason" | "detail">) | null;
240
240
  /** How the runs `rows` holds that tried to learn fared, over `filter` (learningStats): a held run's learning from
241
241
  * memory, any other's end from the learning ledger, never a run's files. */
242
242
  counts(rows: readonly RunRow[], filter: AnalyticsFilter): Promise<ReturnType<typeof learningStats>>;
@@ -283,8 +283,10 @@ export declare class LearningRuns {
283
283
  * the run has ended. Never rejects: `proposed` or `dropped`, `propose_failed` for a fault. A server that goes
284
284
  * meanwhile leaves it `reflecting` in serve.json, and the next start checks it again. */
285
285
  private proposeOnce;
286
- /** The tools a run's workflow draft may name: its revision's granted tools a workflow node runs here (tools.ts
287
- * learnedWorkflowTools); none for a revision not found, so a draft that names one is refused. */
286
+ /** The tools a run's workflow draft may name: its revision's granted tools a workflow's call node runs here that the
287
+ * gate allows, under the server's tool settings and the agent's own (tools.ts learnedDraftTools); `gated`, those set to
288
+ * ask or deny, which a draft that calls one is refused for. None for a revision not found, so a draft that names one is
289
+ * refused. */
288
290
  private draftTools;
289
291
  private propose;
290
292
  /** The run's proposal merged into main or dropped (grade.ts), one grade at a time per agent, after the checks and
@@ -16,6 +16,7 @@
16
16
  import { lstat, readFile } from "node:fs/promises";
17
17
  import { join, posix } from "node:path";
18
18
  import { ANSWER_MAX, INDEX_FILE, parseNoteFile, redactSecrets } from "./learn/index.js";
19
+ import { learnedWorkflowsOff } from "./adapters.js";
19
20
  import { CAP_REFUSAL_PREFIX, SPEND_CAP_REACHED } from "./cap.js";
20
21
  import { readJson, RUN_META, runDoorToken } from "./files.js";
21
22
  import { activeOf, detailShown, dropSeed, gradeModelOf, keepTurn, KEPT_LEARNING, layLearned, layPinnedSkills, LEARNED_DIR, LEARNING_BUDGET, LEARNING_LABEL, learningBlocker, learningTestHooks, learningView, pinSeed, PROPOSAL, readPin, readTurn, secretsShown, seedAt, seedOf, shortLearning, skillsAt, withAgentGrade } from "./learning.js";
@@ -26,7 +27,7 @@ import { ended, outcomeOf, outcomes, record } from "./usage.js";
26
27
  import { isObject } from "./validate.js";
27
28
  import { REFLECT_REQUEST } from "./turns.js";
28
29
  /** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
29
- * with, at its one call (reflectTurn); the per-tool gate, once this server has one, takes it there. */
30
+ * with, at its one call (reflectTurn); the tool gate reads it there and refuses that turn's writes under work/.learning/ (tool-gate.ts NOTE_ONLY_TEXT). */
30
31
  const REFLECT_ORIGIN = "reflect";
31
32
  /** The run asked its end-of-run turn and has not ended since. */
32
33
  export const reflecting = (run) => run.meta.reflect !== undefined && run.meta.reflect.until === undefined;
@@ -85,6 +86,18 @@ export function notesRead(reflect, rows) {
85
86
  }
86
87
  return [...read];
87
88
  }
89
+ /** How much of a grader's answer the host could not read a run keeps: its start and its end, where such an answer goes
90
+ * wrong (words before its JSON, or JSON cut off). */
91
+ const UNREAD_MAX = 2_000;
92
+ /** How much of an answer redactSecrets reads before it gives up on it whole: more than the grader's answer can hold
93
+ * (GRADE_MAX_TOKENS). */
94
+ const UNREAD_SCAN = 256 * 1024;
95
+ /** `text` cut of `values` (redactSecrets), whole, and then in size at whitespace. Cut of secrets first: a key may hold a
96
+ * space, or be written in spaced parts, and a cut before could leave a part of it. */
97
+ const unreadShown = (text, values) => {
98
+ const cut = redactSecrets(text, values, UNREAD_SCAN);
99
+ return cut.length <= UNREAD_MAX ? cut : `${cut.slice(0, 1_500).replace(/\S*$/, "")}\n…\n${cut.slice(-(UNREAD_MAX - 1_503)).replace(/^\S*/, "")}`;
100
+ };
88
101
  /** `verdict` with its reason, and each item's question and why, cut of `values` (learn/secrets.ts redactSecrets). */
89
102
  const cutVerdict = (verdict, values) => ({
90
103
  ...verdict,
@@ -259,11 +272,18 @@ export class LearningRuns {
259
272
  if ("seed" in seeded) {
260
273
  try {
261
274
  const own = revision.kind === "agentic" ? Object.keys(revision.body.skills) : [];
262
- const pin = await pinSeed(started.dir, started.workspace, seeded.seed, { budget: this.options.learningBudget ?? LEARNING_BUDGET, read, shown: this.shown(), own });
275
+ // Its harness's requests going where a learned workflow's could not follow: it is offered none (fail closed).
276
+ const workflowsOff = revision.kind === "agentic" ? await learnedWorkflowsOff(revision.body.harness, this.hostEnv(), revision.body.model) : undefined;
277
+ const pin = await pinSeed(started.dir, started.workspace, seeded.seed, { budget: this.options.learningBudget ?? LEARNING_BUDGET, read, shown: this.shown(), own, ...(workflowsOff ? { workflowsOff } : {}) });
263
278
  for (const path of seeded.seed.skipped)
264
279
  warn(started.runId, `its learning folder's ${path} was not read`);
265
280
  for (const name of pin.skills_left_out ?? [])
266
281
  warn(started.runId, `starts without the skill ${name} its agent learned: it is over what is left of the learned skills' budget, or holds a secret`);
282
+ if (pin.workflows_off)
283
+ warn(started.runId, `starts without the workflows its agent learned (${(pin.workflows_left_out ?? []).join(", ")}): ${pin.workflows_off}`);
284
+ else
285
+ for (const name of pin.workflows_left_out ?? [])
286
+ warn(started.runId, `starts without the workflow ${name} its agent learned: its line is over what is left of the learned_workflow tool's description budget, or it holds a secret`);
267
287
  }
268
288
  catch (error) {
269
289
  warn(started.runId, `starts with nothing learned: ${error.message}`);
@@ -314,10 +334,10 @@ export class LearningRuns {
314
334
  }
315
335
  /** A run's process launched, handed the secrets named `names`: what each held then, as handover read it, kept beside
316
336
  * the run while its learning is under way (a key replaced since stays refused in its notes). */
317
- onLaunch(run, names) {
337
+ onLaunch(run, names, also = []) {
318
338
  if (!run.meta.learning || ended(run.meta.learning))
319
339
  return;
320
- const values = names.flatMap((name) => secret(name, this.options.storedKeys) ?? []);
340
+ const values = [...names.flatMap((name) => secret(name, this.options.storedKeys) ?? []), ...also];
321
341
  if (!values.length)
322
342
  return;
323
343
  const kept = this.handed.get(run.id) ?? new Set();
@@ -438,7 +458,7 @@ export class LearningRuns {
438
458
  * once and kept until a person saves or deletes one (keysChanged). */
439
459
  shown() {
440
460
  const saved = (this.saved ??= new Map(SECRET_NAMES.map((name) => [name, this.options.storedKeys?.(name)])));
441
- const values = [...hostSecrets(process.env, (name) => saved.get(name)), this.options.token, this.options.doorToken];
461
+ const values = [...hostSecrets(process.env, (name) => saved.get(name)), this.options.token, this.options.doorToken, ...(this.options.ownSecrets?.() ?? [])];
442
462
  const key = values.join("\0");
443
463
  if (this.cut?.key !== key)
444
464
  this.cut = { key, shown: secretsShown(values) };
@@ -585,8 +605,13 @@ export class LearningRuns {
585
605
  const seed = await seedAt(this.options.agents.dir, run.agentId, pin.seed);
586
606
  await this.kernel.save(run);
587
607
  const { reflectPrompt } = await import("./learn/index.js");
588
- const tools = await this.draftTools(run);
589
- // The one call that sends the end-of-run turn, with its origin.
608
+ const { tools } = await this.draftTools(run);
609
+ // The one call that sends the end-of-run turn, with its origin. Only while the run is finishing with no outcome yet,
610
+ // read in the same tick the origin's write starts in (toLiveDoor writes it before its first await): a message
611
+ // waits while the run is finishing (runs.ts message), so a write starts only before that wait ends. One whose
612
+ // process went while this turn was made ready has its outcome already: it is asked nothing.
613
+ if (!run.finishing || run.outcome)
614
+ return;
590
615
  await this.kernel.toLiveDoor(run, "/submit", { requestId: reflectId(run.id), content: reflectPrompt({ dir: LEARNED_DIR, active: Object.keys(seed.notes).length, tools }), whenBusy: "followUp" }, REFLECT_ORIGIN);
591
616
  end = await this.reflectEnd(run, Date.parse(reflect.deadline));
592
617
  }
@@ -664,14 +689,19 @@ export class LearningRuns {
664
689
  return Promise.resolve();
665
690
  return once(this.proposing, run.id, () => this.propose(run));
666
691
  }
667
- /** The tools a run's workflow draft may name: its revision's granted tools a workflow node runs here (tools.ts
668
- * learnedWorkflowTools); none for a revision not found, so a draft that names one is refused. */
692
+ /** The tools a run's workflow draft may name: its revision's granted tools a workflow's call node runs here that the
693
+ * gate allows, under the server's tool settings and the agent's own (tools.ts learnedDraftTools); `gated`, those set to
694
+ * ask or deny, which a draft that calls one is refused for. None for a revision not found, so a draft that names one is
695
+ * refused. */
669
696
  async draftTools(run) {
670
697
  const known = await this.options.agents.revision(run.agentId, run.revision);
671
698
  if (known?.revision.kind !== "agentic")
672
- return [];
673
- const { learnedWorkflowTools } = await import("./tools.js");
674
- return learnedWorkflowTools(known.revision.body.tools);
699
+ return { tools: [], gated: {} };
700
+ const [{ learnedDraftTools }, { permissionOf }, { readToolSettings }] = await Promise.all([import("./tools.js"), import("./tool-gate.js"), import("./tool-plane.js")]);
701
+ // The server's settings, beside the agent store, as the run's gate reads them, and the agent's own.
702
+ const server = readToolSettings(this.options.agents.dir).settings;
703
+ const agent = (known.revision.body.toolSettings ?? {});
704
+ return learnedDraftTools(known.revision.body.tools, (name) => permissionOf(name, server, agent));
675
705
  }
676
706
  async propose(run) {
677
707
  try {
@@ -682,9 +712,10 @@ export class LearningRuns {
682
712
  const { proposeRun } = await import("./propose.js");
683
713
  // The secrets this server holds, wherever its launcher put them, the keys saved on it, what each launch handed the
684
714
  // run, and its own tokens. How the job ended, before its end-of-run turn: only a completed run keeps a skill.
685
- const proposed = await proposeRun({ data: this.options.agents.dir, agentId: run.agentId, runDir: run.dir, seed: pin.seed, turn: await readTurn(run.dir), refuse: this.refused(run), ...(run.meta.reflect ? { outcome: run.meta.reflect.outcome } : {}), tools: await this.draftTools(run) });
715
+ const proposed = await proposeRun({ data: this.options.agents.dir, agentId: run.agentId, runDir: run.dir, seed: pin.seed, turn: await readTurn(run.dir), refuse: this.refused(run), ...(run.meta.reflect ? { outcome: run.meta.reflect.outcome } : {}), ...(await this.draftTools(run)) });
716
+ // What the checks left out goes on with it (`problems`), to be said with what it learned.
686
717
  if (proposed.state === "proposed")
687
- this.setLearning(run, "proposed", null, said.proposed(proposed.notes, proposed.skills, proposed.workflows));
718
+ this.setLearning(run, "proposed", null, said.proposed(proposed.notes, proposed.skills, proposed.workflows), proposed.left ? { problems: proposed.left } : {});
688
719
  else if (proposed.reason === "empty")
689
720
  this.setLearning(run, "dropped", "empty", said.empty);
690
721
  else if (proposed.reason === "unparsed") {
@@ -715,7 +746,9 @@ export class LearningRuns {
715
746
  if (before?.state !== "proposed" || this.closing)
716
747
  return;
717
748
  const data = this.options.agents.dir;
718
- let kept = before.verdict ? { verdict: before.verdict, graded: before.graded, cost_usd: before.cost_usd, tokens: before.tokens } : {};
749
+ // What the checks left out of the proposal (a verdict per item) stays with it to its end.
750
+ const checkedOut = before.problems?.length ? { problems: before.problems } : {};
751
+ let kept = before.verdict ? { ...checkedOut, verdict: before.verdict, graded: before.graded, cost_usd: before.cost_usd, tokens: before.tokens } : { ...checkedOut };
719
752
  // Its end saved, and with it its line in the ledger, which carries what the grade spent (onSaved).
720
753
  const end = (state, reason, detail, more = {}) => {
721
754
  this.setLearning(run, state, reason, detail, { ...kept, ...more });
@@ -726,7 +759,7 @@ export class LearningRuns {
726
759
  const known = await this.options.agents.revision(run.agentId, run.revision);
727
760
  if (known?.revision.kind !== "agentic")
728
761
  throw new Error("the run's revision is not agentic");
729
- const { judgeProposal, mergeProposal, readForGrade } = await import("./grade.js");
762
+ const { judgeProposal, keptProposal, mergeProposal, readForGrade } = await import("./grade.js");
730
763
  const main = kept.verdict ? undefined : await readForGrade(data, run.agentId, run.id, proposal);
731
764
  // Main took a note of the same name, or superseded one it supersedes, since the run started: refused before the
732
765
  // grader is asked.
@@ -737,9 +770,7 @@ export class LearningRuns {
737
770
  const env = this.hostEnv();
738
771
  const gradeModel = gradeModelOf(env, this.options.gradeModel);
739
772
  const judged = await judgeProposal({ runId: run.id, agent: { instructions, harness, model, thinking }, main, proposed: proposal.notes, ...(proposal.files ? { files: proposal.files } : {}), ...(proposal.asked ? { asked: proposal.asked } : {}), ...(gradeModel ? { gradeModel } : {}), env, signal: this.stopping.signal, ...(this.options.gradeTimeoutMs ? { gradeTimeoutMs: this.options.gradeTimeoutMs } : {}) });
740
- kept = { cost_usd: { grade: judged.cost.usd }, tokens: { grade: judged.cost.tokens } };
741
- if ("file" in judged)
742
- return await end("dropped", judged.reason, judged.reason === "screen" ? said.screen : said.stopped(STOPPED.screenDown));
773
+ kept = { ...checkedOut, cost_usd: { grade: judged.cost.usd }, tokens: { grade: judged.cost.tokens } };
743
774
  if ("error" in judged) {
744
775
  warn(run.id, `its grader gave no verdict: ${judged.error.message}`);
745
776
  return await end("dropped", "grade_failed", said.stopped(STOPPED.noReview));
@@ -747,8 +778,17 @@ export class LearningRuns {
747
778
  // Kept cut of every secret the run's notes were checked against, the keys its launches handed it included, which a
748
779
  // read no longer knows: its reason and its items' words are what the run's words are said from again (wordsOf).
749
780
  kept.verdict = cutVerdict(judged.verdict, this.refused(run));
750
- if (!kept.verdict.merge)
751
- return await end("dropped", "grader", notKept(kept.verdict));
781
+ if (!kept.verdict.merge) {
782
+ // What it proposed is lost whole: its skill and its draft are named, from the proposal (a verdict the host
783
+ // refused has no items), and the line cut of every secret the verdict was.
784
+ const lost = (proposal.files ?? []).flatMap(({ file }) => {
785
+ const place = /^(?:skills\/([^/]+)\/SKILL\.md|workflows\/([^/]+)\/workflow\.json)$/.exec(file);
786
+ return place ? [{ file, name: (place[1] ?? place[2]) }] : [];
787
+ });
788
+ // Two answers it could not read: the last kept, in size and cut of every secret, to diagnose it by.
789
+ const unread = "unread" in judged && judged.unread !== undefined ? { unread: unreadShown(judged.unread, this.refused(run)) } : {};
790
+ return await end("dropped", "grader", redactSecrets(notKept(kept.verdict, lost), this.refused(run)), { ...(lost.length ? { lost } : {}), ...unread });
791
+ }
752
792
  // Kept before the merge, with the blobs it judged superseded: a restart merges on this verdict, never asks the
753
793
  // grader again, and checks the same blobs.
754
794
  kept.graded = main.graded;
@@ -757,21 +797,24 @@ export class LearningRuns {
757
797
  }
758
798
  // A verdict kept with no `graded`: a note the proposal supersedes is refused, never marked on a text nobody knows
759
799
  // was read.
760
- const merge = await mergeProposal(data, run.agentId, run.id, proposal, kept.verdict?.reason || "The grader kept every new note.", kept.graded ?? {}, kept.verdict);
800
+ // A verdict per item: what it keeps merges, what it drops is left out (keptProposal), and said.
801
+ const merging = keptProposal(proposal, kept.verdict);
802
+ const left = (kept.verdict?.items ?? []).filter((item) => !item.keep);
803
+ const merge = await mergeProposal(data, run.agentId, run.id, merging, kept.verdict?.reason || "The grader kept every new note.", kept.graded ?? {}, kept.verdict);
761
804
  if ("problems" in merge)
762
805
  return await end("dropped", "checker", said.stale(merge.problems), { problems: merge.problems });
763
806
  if (merge.checkout)
764
807
  warn(run.id, `its merge is on main, but the folder's files were not brought in line: ${merge.checkout.message}`);
765
808
  // A note the user asked for whose rule is risky waits on main for their OK: named here, and no run reads it yet.
766
809
  const waiting = new Set((kept.verdict?.items ?? []).filter((item) => item.pending).map((item) => item.file));
767
- const pending = proposal.notes.filter(({ file }) => waiting.has(file)).map(({ file, text }) => ({ file, name: nameOf(file, text) }));
810
+ const pending = merging.notes.filter(({ file }) => waiting.has(file)).map(({ file, text }) => ({ file, name: nameOf(file, text) }));
768
811
  // What it learned: the notes it added that runs read, a note that waits for its OK not among them; and its skill
769
812
  // and workflow draft, each pending when it waits.
770
- const learned = learnedOf(proposal).filter(({ file }) => !waiting.has(file));
771
- const made = (suffix) => (proposal.files ?? []).filter(({ file }) => file.endsWith(suffix)).map(({ file }) => ({ file, name: file.split("/")[1], ...(waiting.has(file) ? { pending: true } : {}) }));
813
+ const learned = learnedOf(merging).filter(({ file }) => !waiting.has(file));
814
+ const made = (suffix) => (merging.files ?? []).filter(({ file }) => file.endsWith(suffix)).map(({ file }) => ({ file, name: file.split("/")[1], ...(waiting.has(file) ? { pending: true } : {}) }));
772
815
  const skills = made("/SKILL.md");
773
816
  const workflows = made("/workflow.json");
774
- await end("merged", null, redactSecrets(said.merged(learned, pending, [...skills, ...workflows]), this.refused(run)), { merged: merge.merged, learned, ...(pending.length ? { pending } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}) });
817
+ await end("merged", null, redactSecrets(said.merged(learned, pending, [...skills, ...workflows], left, before.problems ?? []), this.refused(run)), { merged: merge.merged, learned, ...(pending.length ? { pending } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}) });
775
818
  }
776
819
  catch (error) {
777
820
  // A server closing: nothing was decided, and the next start grades the run.
@@ -786,7 +829,7 @@ export class LearningRuns {
786
829
  refused(run) {
787
830
  // The run's own door token too: its process holds it, so its notes may.
788
831
  const own = run.doorToken ?? runDoorToken(run.dir);
789
- return [...hostSecrets(process.env, this.options.storedKeys), ...(this.handed.get(run.id) ?? []), this.options.token, this.options.doorToken, ...(own ? [own] : [])];
832
+ return [...hostSecrets(process.env, this.options.storedKeys), ...(this.handed.get(run.id) ?? []), this.options.token, this.options.doorToken, ...(this.options.ownSecrets?.() ?? []), ...(own ? [own] : [])];
790
833
  }
791
834
  /** This server's environment for a call of its own (a grade's screen and grader): its secrets readable, never a
792
835
  * child's, the keys saved on it with them (a Jev key saved through the settings API screens as one in the environment
@@ -37,13 +37,16 @@ export declare const said: {
37
37
  asked: string;
38
38
  proposed: (notes: number, skills?: number, workflows?: number) => string;
39
39
  /** What it learned, by name, and how many older notes they replace, and its skill and workflow by name; then what
40
- * waits for the owner's OK, by name. A merge that only holds things for the OK says that alone. */
40
+ * waits for the owner's OK, by name; then, when the grader dropped an item and kept others (a verdict per item), its
41
+ * word on the first it dropped. A merge that only holds things for the OK says that alone. */
41
42
  merged: (learned: readonly {
42
43
  name: string;
43
44
  supersedes: readonly string[];
44
45
  }[], pending?: readonly {
45
46
  name: string;
46
- }[], files?: readonly Pick<LearnedFile, "file" | "name" | "pending">[]) => string;
47
+ }[], files?: readonly Pick<LearnedFile, "file" | "name" | "pending">[], left?: readonly {
48
+ why: string;
49
+ }[], checked?: readonly Pick<Problem, "rule" | "path">[]) => string;
47
50
  empty: string;
48
51
  /** The run's answer gave its notes, but not in the format asked for, so none was read. */
49
52
  unparsed: string;
@@ -64,10 +67,14 @@ export declare const said: {
64
67
  };
65
68
  /** Why a verdict kept nothing, in a person's words: the grader's word on the first note it did not keep, since its
66
69
  * reason may open on a note it kept; when it dropped none, or gave one no word, its own reason, unless that is
67
- * parseVerdict's own; an answer that held neither is said as such. */
68
- export declare function notKept(verdict: Pick<Verdict, "reason" | "items">): string;
70
+ * parseVerdict's own; an answer that held neither is said as such. Nothing merged, so the skill and the workflow draft
71
+ * the run proposed (`lost`, from its proposal: a verdict the host refused has no items) are lost with it: named before
72
+ * the why, so a long why cut short never cuts them off; the one the why speaks of as its subject ("Not kept, the
73
+ * skill X: …"), any other as lost with it ("Not kept, with the skill X: …"). The caller cuts the line of the host's
74
+ * secrets: a name is the run's to choose. */
75
+ export declare function notKept(verdict: Pick<Verdict, "reason" | "items">, lost?: readonly Pick<LearnedFile, "file">[]): string;
69
76
  /** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
70
77
  * grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
71
78
  * secrets as they are now); any other detail, the server's own sentence, cut as well. The caller cuts the words short
72
79
  * after. */
73
- export declare function wordsOf(learning: Pick<Learning, "state" | "reason" | "detail" | "learned" | "pending" | "verdict" | "skills" | "workflows">, cut: (text: string) => string): string | null;
80
+ export declare function wordsOf(learning: Pick<Learning, "state" | "reason" | "detail" | "learned" | "pending" | "verdict" | "skills" | "workflows" | "problems" | "lost">, cut: (text: string) => string): string | null;
@@ -102,20 +102,23 @@ export const said = {
102
102
  asked: "Looking back on this run.",
103
103
  proposed: (notes, skills = 0, workflows = 0) => `Checking ${listed([...(notes || !(skills || workflows) ? [count(notes, "new note")] : []), ...(skills ? [count(skills, "skill")] : []), ...(workflows ? [count(workflows, "workflow")] : [])])}…`,
104
104
  /** What it learned, by name, and how many older notes they replace, and its skill and workflow by name; then what
105
- * waits for the owner's OK, by name. A merge that only holds things for the OK says that alone. */
106
- merged: (learned, pending = [], files = []) => {
105
+ * waits for the owner's OK, by name; then, when the grader dropped an item and kept others (a verdict per item), its
106
+ * word on the first it dropped. A merge that only holds things for the OK says that alone. */
107
+ merged: (learned, pending = [], files = [], left = [], checked = []) => {
107
108
  const flat = (name) => name.replace(/\s+/g, " ").trim();
108
109
  const kind = (file) => `${file.file.startsWith("skills/") ? "skill" : "workflow"} ${flat(file.name)}`;
109
110
  const held = [...pending.map((note) => flat(note.name)), ...files.filter((file) => file.pending).map(kind)];
110
111
  const waiting = held.length ? `Waiting for your OK: ${held.join("; ")}.` : "";
111
112
  const made = files.filter((file) => !file.pending).map(kind);
113
+ const dropped = [left.length ? said.grader(left[0].why) : "", checked.length ? said.checker(checked) : ""].filter(Boolean).join(" ");
112
114
  if (!learned.length && !made.length)
113
- return waiting;
115
+ return [waiting, dropped].filter(Boolean).join(" ");
114
116
  const names = learned.map((note) => flat(note.name));
115
117
  const replaced = learned.reduce((n, note) => n + note.supersedes.length, 0);
116
118
  const notes = names.length ? `${names.length === 1 ? `Learned: ${names[0]}` : `Learned ${names.length} notes: ${names.join("; ")}`}${replaced ? ` (replaces ${count(replaced, "older note")})` : ""}` : "";
117
119
  const kept = [notes, made.length ? `${notes ? "Also learned" : "Learned"} ${listed(made.map((made) => `the ${made}`))}` : ""].filter(Boolean).join(". ");
118
- return waiting ? `${kept}. ${waiting}` : kept;
120
+ const base = waiting ? `${kept}. ${waiting}` : kept;
121
+ return dropped ? `${base}${base.endsWith(".") ? "" : "."} ${dropped}` : base;
119
122
  },
120
123
  empty: "Nothing new to remember from this run.",
121
124
  /** The run's answer gave its notes, but not in the format asked for, so none was read. */
@@ -143,14 +146,28 @@ export const said = {
143
146
  * it refused (an item for a file it was not asked about, a file judged twice, a new note with no item, a merge that
144
147
  * did not keep every note). Found by asking it, so they follow it. */
145
148
  const OWN_REASONS = new Set(["", "[]", '{"merge":true,"reason":"r","items":[{"file":"a.md","keep":false,"why":"w"}]}', '{"merge":false,"reason":"r","items":[]}', '{"merge":false,"reason":"r","items":[{"file":"b.md","keep":false,"why":"w"}]}', '{"merge":false,"reason":"r","items":[{"file":"a.md","keep":false,"why":"w"},{"file":"a.md","keep":false,"why":"w"}]}'].map((answer) => parseVerdict(answer, ["a.md"]).reason));
149
+ /** The skill or the workflow draft at `file` as a person names it ("the skill X", "the workflow Y"), or undefined for a
150
+ * note's file or a draft's README.md. */
151
+ const learnedWords = (file) => {
152
+ const place = /^(skills)\/([^/]+)\/SKILL\.md$|^(workflows)\/([^/]+)\/workflow\.json$/.exec(file);
153
+ return place ? (place[1] ? `the skill ${place[2]}` : `the workflow ${place[4]}`) : undefined;
154
+ };
146
155
  /** Why a verdict kept nothing, in a person's words: the grader's word on the first note it did not keep, since its
147
156
  * reason may open on a note it kept; when it dropped none, or gave one no word, its own reason, unless that is
148
- * parseVerdict's own; an answer that held neither is said as such. */
149
- export function notKept(verdict) {
150
- const why = verdict.items.find((item) => !item.keep)?.why;
151
- if (why)
152
- return said.grader(why);
153
- return OWN_REASONS.has(verdict.reason) ? said.stopped(STOPPED.unread) : said.grader(verdict.reason);
157
+ * parseVerdict's own; an answer that held neither is said as such. Nothing merged, so the skill and the workflow draft
158
+ * the run proposed (`lost`, from its proposal: a verdict the host refused has no items) are lost with it: named before
159
+ * the why, so a long why cut short never cuts them off; the one the why speaks of as its subject ("Not kept, the
160
+ * skill X: …"), any other as lost with it ("Not kept, with the skill X: …"). The caller cuts the line of the host's
161
+ * secrets: a name is the run's to choose. */
162
+ export function notKept(verdict, lost = []) {
163
+ const dropped = verdict.items.find((item) => !item.keep);
164
+ const said_ = dropped?.why ? said.grader(dropped.why) : OWN_REASONS.has(verdict.reason) ? said.stopped(STOPPED.unread) : said.grader(verdict.reason);
165
+ const subject = dropped?.why ? learnedWords(dropped.file) : undefined;
166
+ const others = [...new Set(lost.flatMap(({ file }) => learnedWords(file) ?? []))].filter((words) => words !== subject);
167
+ if (!subject && !others.length)
168
+ return said_;
169
+ const named = [subject, others.length ? `with ${listed(others)}` : ""].filter(Boolean).join(" ");
170
+ return said_.replace(/^Not kept: /, `Not kept, ${named}: `);
154
171
  }
155
172
  /** A run's learning in words as a read says them, whole: what it learned and what waits for the owner's OK, or why the
156
173
  * grader kept nothing, said again from its parts (`learned`, `pending`, `verdict`) each cut by `cut` first (the host's
@@ -163,9 +180,13 @@ export function wordsOf(learning, cut) {
163
180
  const waiting = Array.isArray(pending) ? pending.filter((note) => typeof note?.name === "string") : [];
164
181
  const files = [...(Array.isArray(learning.skills) ? learning.skills : []), ...(Array.isArray(learning.workflows) ? learning.workflows : [])].filter((file) => typeof file?.file === "string" && typeof file.name === "string");
165
182
  if (kept.length || waiting.length || files.length)
166
- return said.merged(kept.map((note) => ({ name: cut(note.name), supersedes: note.supersedes })), waiting.map((note) => ({ name: cut(note.name) })), files.map((file) => ({ file: file.file, name: cut(file.name), ...(file.pending ? { pending: true } : {}) })));
183
+ return said.merged(kept.map((note) => ({ name: cut(note.name), supersedes: note.supersedes })), waiting.map((note) => ({ name: cut(note.name) })), files.map((file) => ({ file: file.file, name: cut(file.name), ...(file.pending ? { pending: true } : {}) })), (verdict?.items ?? []).filter((item) => !item.keep && typeof item.why === "string").map((item) => ({ why: cut(item.why) })), Array.isArray(learning.problems) ? learning.problems : []);
184
+ }
185
+ if (learning.state === "dropped" && learning.reason === "grader" && verdict) {
186
+ // serve.json's `lost` is read as untrusted: an entry out of shape is left out. The whole line is cut again, the names
187
+ // in it included.
188
+ const lost = Array.isArray(learning.lost) ? learning.lost.filter((file) => typeof file?.file === "string") : [];
189
+ return cut(notKept({ reason: cut(verdict.reason), items: (verdict.items ?? []).map((item) => ({ ...item, why: cut(item.why) })) }, lost));
167
190
  }
168
- if (learning.state === "dropped" && learning.reason === "grader" && verdict)
169
- return notKept({ reason: cut(verdict.reason), items: (verdict.items ?? []).map((item) => ({ ...item, why: cut(item.why) })) });
170
191
  return learning.detail === null ? null : cut(learning.detail);
171
192
  }
@@ -89,6 +89,12 @@ export type Learning = {
89
89
  * for a person's OK (`status: pending` in its SKILL.md or README.md), and no run is given it until approved. */
90
90
  skills?: LearnedFile[];
91
91
  workflows?: LearnedFile[];
92
+ /** A grader's drop's skill and workflow draft, from what the run proposed: lost with the rest, and named when its
93
+ * learning is said (learning-words.ts notKept). */
94
+ lost?: LearnedFile[];
95
+ /** 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
96
+ * run's file to diagnose it by, and served by no read. */
97
+ unread?: string;
92
98
  };
93
99
  /** A skill or a workflow draft a merge added or changed. */
94
100
  export type LearnedFile = {
@@ -153,7 +159,7 @@ export declare const shortLearning: (learning: Learning | null, shown: Shown, se
153
159
  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
160
  detail: string | null;
155
161
  at: string;
156
- }, "at" | "reason" | "state" | "detail">) | null;
162
+ }, "at" | "state" | "reason" | "detail">) | null;
157
163
  /** 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
164
  export declare function shortOf<T extends {
159
165
  state: LearningState;
@@ -164,7 +170,7 @@ export declare function shortOf<T extends {
164
170
  state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
165
171
  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
172
  detail: string | null;
167
- } & Omit<T, "at" | "reason" | "state" | "detail">;
173
+ } & Omit<T, "at" | "state" | "reason" | "detail">;
168
174
  /** The label of the end-of-run turn's timeline rows, and the kind and label of a run's learning row. */
169
175
  export declare const LEARNING_LABEL = "learning";
170
176
  /** A run's proposal, in its directory (propose.ts): the seed it was checked against, each new note's file and text, its
@@ -198,13 +204,21 @@ export type Turn = {
198
204
  /** What a run's pin holds: the commit of main it was seeded from, and what it reads under `# Learned` (learnedOf), when
199
205
  * it learned anything. `learned`, the index alone, is a pin an earlier server wrote, read as that server gave it.
200
206
  * `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. */
207
+ * names its own; `skills_left_out`: the learned skills it does not get, over their budget or holding a secret.
208
+ * `workflows`: the names of the learned workflows the run may run (its `learned_workflow` tool), each written whole in
209
+ * LEARNED_WORKFLOWS_FILE in the run's directory, outside its work; `workflows_left_out`: the learned workflows it does
210
+ * not get, their lines over what is left of the tool's description budget (LEARNED_WORKFLOWS_BUDGET), or holding a
211
+ * secret, or every one when `workflows_off` says why the run is offered none (its harness's requests go where a learned
212
+ * workflow's could not follow: learnedWorkflowsOff). */
202
213
  export type Pin = {
203
214
  seed: string;
204
215
  section?: string;
205
216
  learned?: string;
206
217
  skills?: string[];
207
218
  skills_left_out?: string[];
219
+ workflows?: string[];
220
+ workflows_left_out?: string[];
221
+ workflows_off?: string;
208
222
  };
209
223
  /** 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
210
224
  * top. `skipped` names what was there and not read. `recent`, when seedOf read it: the active notes' files, the one
@@ -218,7 +232,25 @@ export type Seed = {
218
232
  skipped: string[];
219
233
  recent?: string[];
220
234
  skills?: LearnedSkill[];
235
+ workflows?: LearnedWorkflow[];
221
236
  };
237
+ /** A workflow the agent learned, as a run may run it: its name, the line its README says what it does with, and its
238
+ * workflow.json whole. */
239
+ export type LearnedWorkflow = {
240
+ name: string;
241
+ description: string;
242
+ workflow: string;
243
+ };
244
+ /** Where a run keeps the learned workflows its pin names, whole: in the run's directory, beside its pin, never in its
245
+ * work, so nothing the run does changes what its `learned_workflow` tool runs. */
246
+ export declare const LEARNED_WORKFLOWS_FILE = "learned-workflows.json";
247
+ /** The most bytes the `learned_workflow` tool's description gives its workflows, each one's line (workflowLine)
248
+ * together: every harness sends the description with each request, so it never grows with what an agent learned. */
249
+ export declare const LEARNED_WORKFLOWS_BUDGET: number;
250
+ /** A learned workflow's line in the `learned_workflow` tool's description: its name, and what its README says it does. */
251
+ export declare const workflowLine: ({ name, description, workflow }: Pick<LearnedWorkflow, "name" | "description"> & {
252
+ workflow?: string;
253
+ }) => string;
222
254
  /** The most bytes of learned skills one run gets, every file of each together. They get no more than what the
223
255
  * revision's own skills leave of the adapters' cap on a run's skills in all (SKILL_BYTES): over that cap an adapter
224
256
  * refuses the whole set, and every skill, the revision's too, would be inlined in the prompt (skills.ts splitSkills). */
@@ -292,6 +324,19 @@ export declare function readSkills(cwd: string, repo: string, sha: string): Prom
292
324
  skills: LearnedSkill[];
293
325
  skipped: string[];
294
326
  }>;
327
+ /** The workflows commit `sha` holds under WORKFLOWS_DIR, read with plumbing, by name: each a folder with a workflow.json
328
+ * 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
329
+ * active one is a run's, by the rule a skill is (readSkills): its README.md sets no status, or `active`; one held for
330
+ * its owner's OK, or retired, is left out. A symbolic link or a submodule under WORKFLOWS_DIR throws. */
331
+ export declare function readWorkflows(cwd: string, repo: string, sha: string): Promise<{
332
+ workflows: LearnedWorkflow[];
333
+ skipped: string[];
334
+ }>;
335
+ /** A learned workflow README's front matter, each key to its value (quotes dropped; a `>` or `|` value's indented lines
336
+ * joined by spaces), or undefined when it does not read one way: no front matter, none closed (`---` on a line of its
337
+ * 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
338
+ * `|` value, or a key set twice. */
339
+ export declare function readmeFront(text: string): Map<string, string> | undefined;
295
340
  /** Each file's place in main's first-parent log from `sha`, by the newest commit that changed it: 0 for those the newest
296
341
  * commit changed, and so on, so two changes in one second keep their order. A run's notes (seedOf) and a person's view
297
342
  * of them (learning-routes.ts) are in this order, the one changed last first. */
@@ -335,6 +380,7 @@ export type LearnedOptions = {
335
380
  budget: number;
336
381
  read: boolean;
337
382
  shown: Shown;
383
+ workflowsOff?: string;
338
384
  };
339
385
  /** What a run of `seed` reads under `# Learned`, the same for every harness, or undefined when it learned nothing. Only
340
386
  * active notes are served: a pending, superseded or retired one is never there, whole or in the index, nor counted
@@ -375,3 +421,6 @@ export declare function withLearned(runDir: string, work: string, instructions:
375
421
  instructions: string;
376
422
  skills: string[];
377
423
  }>;
424
+ /** The learned workflows a run's pin names, as its directory keeps them (LEARNED_WORKFLOWS_FILE): none when the pin
425
+ * names none. A file that is not the list the pin names throws. */
426
+ export declare function pinnedWorkflows(runDir: string, pin: Pin | undefined): Promise<LearnedWorkflow[]>;