@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.35

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 (227) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +84 -16
  3. package/dist/adapters.d.ts +3 -0
  4. package/dist/adapters.js +7 -0
  5. package/dist/agent-rows.d.ts +1 -0
  6. package/dist/agents-store.js +17 -2
  7. package/dist/archil-settings.d.ts +11 -1
  8. package/dist/archil-settings.js +10 -0
  9. package/dist/bash-read-only.d.ts +13 -0
  10. package/dist/bash-read-only.js +77 -0
  11. package/dist/browser-cost.d.ts +2 -2
  12. package/dist/browser-cost.js +6 -4
  13. package/dist/budget.d.ts +0 -5
  14. package/dist/budget.js +0 -5
  15. package/dist/cap.d.ts +6 -3
  16. package/dist/cap.js +7 -4
  17. package/dist/cli.js +32 -5
  18. package/dist/computer-keys.d.ts +20 -10
  19. package/dist/computer-keys.js +36 -57
  20. package/dist/computer-setting.d.ts +6 -5
  21. package/dist/computer-setting.js +54 -26
  22. package/dist/computers.d.ts +9 -4
  23. package/dist/computers.js +4 -2
  24. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  25. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  26. package/dist/console/index.html +2 -2
  27. package/dist/content-filter.d.ts +7 -0
  28. package/dist/content-filter.js +23 -0
  29. package/dist/decision-cap.d.ts +7 -29
  30. package/dist/decision-cap.js +3 -94
  31. package/dist/errors.d.ts +1 -0
  32. package/dist/errors.js +3 -0
  33. package/dist/explain.js +3 -1
  34. package/dist/github-connection.js +25 -7
  35. package/dist/github-faux.d.ts +26 -0
  36. package/dist/github-faux.js +76 -0
  37. package/dist/github.d.ts +6 -2
  38. package/dist/github.js +5 -3
  39. package/dist/graph-served.d.ts +5 -3
  40. package/dist/graph-served.js +14 -6
  41. package/dist/graph-view.js +5 -2
  42. package/dist/harness-opencode/harness.js +0 -1
  43. package/dist/harness-opencode/host/policy.js +2 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/learn/check.d.ts +3 -1
  47. package/dist/learn/check.js +3 -3
  48. package/dist/learn/folder.d.ts +6 -3
  49. package/dist/learn/folder.js +7 -16
  50. package/dist/learn/grade.d.ts +4 -1
  51. package/dist/learn/grade.js +43 -5
  52. package/dist/learn/index.d.ts +2 -2
  53. package/dist/learn/index.js +2 -2
  54. package/dist/learn/learning.sh +1 -14
  55. package/dist/learn/notes.d.ts +14 -3
  56. package/dist/learn/notes.js +16 -6
  57. package/dist/learn/reflect.js +5 -3
  58. package/dist/learn/skills.d.ts +48 -5
  59. package/dist/learn/skills.js +97 -21
  60. package/dist/learned-nodes.d.ts +14 -0
  61. package/dist/learned-nodes.js +8 -0
  62. package/dist/learned-workflow.d.ts +9 -5
  63. package/dist/learned-workflow.js +53 -9
  64. package/dist/learning-routes.d.ts +41 -0
  65. package/dist/learning-routes.js +94 -26
  66. package/dist/learning-run.d.ts +7 -5
  67. package/dist/learning-run.js +9 -6
  68. package/dist/learning.d.ts +0 -22
  69. package/dist/learning.js +0 -16
  70. package/dist/llm.d.ts +4 -1
  71. package/dist/llm.js +4 -2
  72. package/dist/mcp-gateway.d.ts +6 -0
  73. package/dist/mcp-gateway.js +11 -1
  74. package/dist/mcp-servers-store.d.ts +12 -12
  75. package/dist/model.d.ts +3 -0
  76. package/dist/model.js +8 -0
  77. package/dist/openapi.js +37 -13
  78. package/dist/paid-calls.js +1 -1
  79. package/dist/pause.d.ts +2 -19
  80. package/dist/pause.js +5 -74
  81. package/dist/port-models.d.ts +10 -3
  82. package/dist/port-models.js +26 -6
  83. package/dist/propose.d.ts +2 -0
  84. package/dist/propose.js +1 -10
  85. package/dist/run-launch.d.ts +5 -3
  86. package/dist/run-launch.js +6 -5
  87. package/dist/run-learning-served.d.ts +11 -0
  88. package/dist/run-reads-over-store.d.ts +4 -2
  89. package/dist/run-reads-over-store.js +10 -8
  90. package/dist/run-timeline-served.js +12 -2
  91. package/dist/run-view.d.ts +30 -14
  92. package/dist/run-view.js +60 -32
  93. package/dist/runnable.d.ts +4 -1
  94. package/dist/runnable.js +14 -2
  95. package/dist/runner/adapter-loop.d.ts +30 -4
  96. package/dist/runner/adapter-loop.js +253 -29
  97. package/dist/runner/adapter-run-spec.d.ts +21 -0
  98. package/dist/runner/adapter-run-spec.js +104 -28
  99. package/dist/runner/adapters/pi.d.ts +29 -1
  100. package/dist/runner/adapters/pi.js +95 -23
  101. package/dist/runner/beside.d.ts +8 -0
  102. package/dist/runner/beside.js +18 -0
  103. package/dist/runner/claim-secrets.d.ts +6 -0
  104. package/dist/runner/claim-secrets.js +15 -1
  105. package/dist/runner/cli-run-spec.d.ts +3 -0
  106. package/dist/runner/cli-run-spec.js +123 -34
  107. package/dist/runner/conformance/harness.d.ts +1 -0
  108. package/dist/runner/conformance/harness.js +5 -5
  109. package/dist/runner/github-app.d.ts +7 -2
  110. package/dist/runner/github-app.js +46 -15
  111. package/dist/runner/harness-loops.d.ts +6 -1
  112. package/dist/runner/harness-loops.js +23 -0
  113. package/dist/runner/journal-kinds.d.ts +38 -2
  114. package/dist/runner/journal-kinds.js +23 -0
  115. package/dist/runner/learning-end.js +88 -16
  116. package/dist/runner/learning-loop.d.ts +2 -0
  117. package/dist/runner/learning-loop.js +13 -5
  118. package/dist/runner/learning-seed.d.ts +6 -0
  119. package/dist/runner/learning-seed.js +6 -0
  120. package/dist/runner/loop-contract.d.ts +4 -0
  121. package/dist/runner/main.d.ts +9 -4
  122. package/dist/runner/main.js +26 -11
  123. package/dist/runner/mcp-claim.d.ts +3 -0
  124. package/dist/runner/mcp-claim.js +6 -1
  125. package/dist/runner/mcp-github.d.ts +11 -2
  126. package/dist/runner/mcp-github.js +55 -4
  127. package/dist/runner/mcp-run.js +1 -0
  128. package/dist/runner/metrics.d.ts +14 -1
  129. package/dist/runner/metrics.js +72 -1
  130. package/dist/runner/model-route.d.ts +3 -0
  131. package/dist/runner/model-route.js +1 -1
  132. package/dist/runner/runner.js +90 -8
  133. package/dist/runner/spec-holds.d.ts +7 -2
  134. package/dist/runner/spec-holds.js +4 -3
  135. package/dist/runner/workflow-host.d.ts +7 -2
  136. package/dist/runner/workflow-host.js +3 -1
  137. package/dist/runner/workflow-loop.d.ts +4 -1
  138. package/dist/runner/workflow-loop.js +8 -2
  139. package/dist/runner/workflow-spec.d.ts +3 -0
  140. package/dist/runner/workflow-spec.js +156 -78
  141. package/dist/runs-over-store.d.ts +7 -1
  142. package/dist/runs-over-store.js +42 -11
  143. package/dist/seal-key.d.ts +0 -2
  144. package/dist/seal-key.js +0 -2
  145. package/dist/server-lock.js +4 -5
  146. package/dist/server.d.ts +21 -18
  147. package/dist/server.js +183 -34
  148. package/dist/stop-signals.d.ts +4 -2
  149. package/dist/stop-signals.js +5 -3
  150. package/dist/store/agent-body.d.ts +5 -1
  151. package/dist/store/agent-body.js +11 -5
  152. package/dist/store/deadline.d.ts +18 -0
  153. package/dist/store/deadline.js +45 -0
  154. package/dist/store/postgres/connection.d.ts +4 -0
  155. package/dist/store/postgres/connection.js +55 -9
  156. package/dist/store/sqlite/connection.js +3 -38
  157. package/dist/store-reads/journal.js +39 -4
  158. package/dist/store-reads/learning.d.ts +58 -2
  159. package/dist/store-reads/learning.js +172 -7
  160. package/dist/store-view.d.ts +15 -1
  161. package/dist/store-view.js +45 -12
  162. package/dist/templates.d.ts +9 -4
  163. package/dist/templates.js +14 -9
  164. package/dist/timeline/timeline.d.ts +8 -0
  165. package/dist/tool-budget.d.ts +18 -0
  166. package/dist/tool-budget.js +50 -0
  167. package/dist/tool-gate.d.ts +6 -2
  168. package/dist/tool-gate.js +8 -5
  169. package/dist/tool-plane.d.ts +9 -10
  170. package/dist/tools.d.ts +37 -7
  171. package/dist/tools.js +73 -12
  172. package/dist/uploads.d.ts +28 -5
  173. package/dist/uploads.js +82 -9
  174. package/dist/usage.d.ts +1 -47
  175. package/dist/usage.js +3 -82
  176. package/dist/validate.d.ts +2 -0
  177. package/dist/validate.js +11 -1
  178. package/dist/workspace/archil-claim.d.ts +2 -2
  179. package/dist/workspace/archil-claim.js +4 -3
  180. package/dist/workspace/archil-disk.d.ts +10 -1
  181. package/dist/workspace/archil-disk.js +4 -0
  182. package/dist/workspace/archil-exec.d.ts +12 -2
  183. package/dist/workspace/archil-exec.js +16 -0
  184. package/dist/workspace/archil.d.ts +2 -2
  185. package/dist/workspace/archil.js +25 -5
  186. package/dist/workspace/attach.js +2 -0
  187. package/dist/workspace/computer-deps.d.ts +9 -10
  188. package/dist/workspace/computer-deps.js +53 -40
  189. package/dist/workspace/computer-for-claim.d.ts +5 -3
  190. package/dist/workspace/computer-for-claim.js +28 -16
  191. package/dist/workspace/computer-ledger.d.ts +1 -8
  192. package/dist/workspace/computer-ledger.js +0 -3
  193. package/dist/workspace/computer-providers.d.ts +5 -3
  194. package/dist/workspace/computer-providers.js +11 -9
  195. package/dist/workspace/hands.d.ts +5 -2
  196. package/dist/workspace/hands.js +4 -3
  197. package/dist/workspace/index.d.ts +3 -3
  198. package/dist/workspace/index.js +1 -1
  199. package/dist/workspace/local.d.ts +3 -0
  200. package/dist/workspace/local.js +9 -0
  201. package/dist/workspace/paths.js +3 -2
  202. package/dist/workspace/pi-env.d.ts +4 -0
  203. package/dist/workspace/pi-env.js +3 -2
  204. package/dist/workspace/resolve-computer.d.ts +8 -3
  205. package/dist/workspace/resolve-computer.js +28 -11
  206. package/dist/workspace/run-tools.d.ts +2 -0
  207. package/dist/workspace/run-tools.js +9 -3
  208. package/dist/workspace/workspace.d.ts +5 -0
  209. package/dist/workspace.d.ts +0 -3
  210. package/dist/workspace.js +1 -14
  211. package/package.json +14 -14
  212. package/skills/agentrun-serve/SKILL.md +1 -1
  213. package/templates/README.md +2 -2
  214. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  215. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  216. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  217. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  218. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  219. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  220. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  221. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  222. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  223. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  224. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  225. package/templates/release-notes/agent.md +11 -0
  226. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  227. package/dist/console/assets/index-opTN5Naq.css +0 -1
@@ -34,6 +34,9 @@ export type SnapNote = {
34
34
  origin: "you" | "run";
35
35
  supersedes: string[];
36
36
  superseded_by: string | null;
37
+ /** Past SNAPSHOT.md v1, additive, on a retired note alone: the status its restore gives back (notes.ts LearnedNote
38
+ * retired_from). */
39
+ retired_from?: "active" | "pending";
37
40
  order: number;
38
41
  history: SnapHistory;
39
42
  };
@@ -47,6 +50,9 @@ export type SnapLearned = {
47
50
  file: string;
48
51
  description: string;
49
52
  status: "active" | "pending" | "retired";
53
+ /** Past SNAPSHOT.md v1, additive, on a retired skill or draft alone: the status its restore gives back (skills.ts
54
+ * retiredFrom). */
55
+ retired_from?: "active" | "pending";
50
56
  run: string | null;
51
57
  files: SnapFile[];
52
58
  oid: string;
@@ -263,9 +269,6 @@ export declare function folderAt(ws: Workspace, commit: string): Promise<{
263
269
  blobs: ReadonlyMap<string, Buffer>;
264
270
  } | undefined>;
265
271
  export declare function learningRepair(ws: Workspace): Promise<Snapshot | undefined>;
266
- /** Main's text of `path` just before the newest person's retire of it on `main`'s line, or undefined (never retired by
267
- * a person). A read through the script: git's history is not in the snapshot. */
268
- export declare function beforeRetire(ws: Workspace, main: string, path: string): Promise<string | undefined>;
269
272
  /** Whether `main` holds anything at `path`, as git stores it (any mode, any type): what the snapshot leaves out (a file
270
273
  * that is no note) included. A read through the script. */
271
274
  export declare function heldOnMain(ws: Workspace, main: string, path: string): Promise<boolean>;
@@ -21,7 +21,7 @@ import { createHash, randomBytes } from "node:crypto";
21
21
  import { readFileSync } from "node:fs";
22
22
  import { isWorkspaceError, learningWorkspace as oneLearningWorkspace, } from "../workspace/index.js";
23
23
  import { INDEX_FILE, NOTE_FILE, parseNoteFile } from "./notes.js";
24
- import { learnedFront, learnedName, learnedStatus, SKILLS_DIR, WORKFLOWS_DIR } from "./skills.js";
24
+ import { learnedFront, learnedName, learnedStatus, retiredFrom, SKILLS_DIR, WORKFLOWS_DIR } from "./skills.js";
25
25
  /** The host's folder inside the learning folder: the snapshot, the diffs and the script. Never a note's, never seeded. */
26
26
  export const HOST_DIR = ".agentrun";
27
27
  export const SNAPSHOT_FILE = `${HOST_DIR}/snapshot.json`;
@@ -117,7 +117,7 @@ function noteEntry(file, text, oid, bytes, order, history) {
117
117
  const note = parseNoteFile(file, text);
118
118
  if (Array.isArray(note))
119
119
  return undefined;
120
- return { file, oid, bytes, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, supersedes: [...note.supersedes], superseded_by: note.superseded_by, order, history };
120
+ return { file, oid, bytes, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, supersedes: [...note.supersedes], superseded_by: note.superseded_by, ...(note.retired_from ? { retired_from: note.retired_from } : {}), order, history };
121
121
  }
122
122
  // ---------------------------------------------------------------------------------------------------------------------
123
123
  // A snapshot from main whole (the script's `read`): a folder whose snapshot is not main's.
@@ -276,9 +276,10 @@ function learnedItem(kind, name, files, links, text, at, said) {
276
276
  const body = text(key.path);
277
277
  if (body === undefined)
278
278
  return undefined;
279
- fields = { description: learnedFront(body)?.description ?? "", status: learnedStatus(body) };
279
+ const status = learnedStatus(body);
280
+ fields = { description: learnedFront(body)?.description ?? "", status, ...(status === "retired" ? { retired_from: retiredFrom(body) } : {}) };
280
281
  }
281
- return { name, file: key.path, description: fields.description, status: fields.status, run: at.run, files: [...files].sort((a, b) => byBytes(a.path, b.path)), oid: key.oid, bytes: key.bytes, order: at.order, history: at.history, ...(links.length ? { links: [...links].sort(byBytes) } : {}) };
282
+ return { name, file: key.path, description: fields.description, status: fields.status, ...(fields.retired_from ? { retired_from: fields.retired_from } : {}), run: at.run, files: [...files].sort((a, b) => byBytes(a.path, b.path)), oid: key.oid, bytes: key.bytes, order: at.order, history: at.history, ...(links.length ? { links: [...links].sort(byBytes) } : {}) };
282
283
  }
283
284
  /** A commit's message and trailers, as git keeps them: a person's names their action and the file, with Changed-By (and
284
285
  * Approved-Via on an approval); a run's merge names the run, then the grader's reason, then its Run-Id. */
@@ -357,7 +358,7 @@ export function nextSnapshot(before, change, seconds) {
357
358
  order: 0,
358
359
  history: touched.has(key) ? foldNewer(old?.history, commit, key) : (old?.history ?? { at: commit.at }),
359
360
  run: runId && touched.has(viewFile(kind, name)) ? runId : (old?.run ?? null),
360
- }, keyText === undefined && old ? { description: old.description, status: old.status } : undefined);
361
+ }, keyText === undefined && old ? { description: old.description, status: old.status, ...(old.retired_from ? { retired_from: old.retired_from } : {}) } : undefined);
361
362
  if (item)
362
363
  out.push(item);
363
364
  }
@@ -517,7 +518,7 @@ export async function readRunDiff(ws, run) {
517
518
  return diff;
518
519
  }
519
520
  /** The notes of a snapshot as the learning modules take them (buildIndex, mergeProblems): their front matter, no body. */
520
- export const snapshotNotes = (snapshot) => (snapshot?.notes ?? []).map((note) => ({ file: note.file, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, superseded_by: note.superseded_by, supersedes: [...note.supersedes], keys: [], body: "" }));
521
+ export const snapshotNotes = (snapshot) => (snapshot?.notes ?? []).map((note) => ({ file: note.file, name: note.name, description: note.description, type: note.type, status: note.status, origin: note.origin, superseded_by: note.superseded_by, supersedes: [...note.supersedes], retired_from: note.status === "retired" ? (note.retired_from ?? "pending") : null, keys: [], body: "" }));
521
522
  /** Every name at main's top a snapshot knows: the index, the notes, and the learned folders' tops. */
522
523
  export const topOf = (snapshot) => (snapshot ? [INDEX_FILE, ...snapshot.notes.map((note) => note.file), ...(snapshot.skills.length ? [SKILLS_DIR] : []), ...(snapshot.workflows.length ? [WORKFLOWS_DIR] : [])] : []);
523
524
  // ---------------------------------------------------------------------------------------------------------------------
@@ -704,16 +705,6 @@ export async function learningRepair(ws) {
704
705
  }
705
706
  throw new Error("the learning folder's main kept moving while its snapshot was rebuilt");
706
707
  }
707
- /** Main's text of `path` just before the newest person's retire of it on `main`'s line, or undefined (never retired by
708
- * a person). A read through the script: git's history is not in the snapshot. */
709
- export async function beforeRetire(ws, main, path) {
710
- const result = await runScript(ws, ["before-retire", main, checkPath(path)]);
711
- if (result.code === 1)
712
- return undefined;
713
- if (result.code !== 0)
714
- throw failed("before-retire", result);
715
- return textOf(result.stdout);
716
- }
717
708
  /** Whether `main` holds anything at `path`, as git stores it (any mode, any type): what the snapshot leaves out (a file
718
709
  * that is no note) included. A read through the script. */
719
710
  export async function heldOnMain(ws, main, path) {
@@ -41,6 +41,9 @@ export type GradeInput = {
41
41
  readonly source: string;
42
42
  readonly text: string;
43
43
  }[];
44
+ /** Why each draft (by its workflow.json's path) waits for its owner's OK whatever the grade (skills.ts unpricedLine:
45
+ * a step calling an MCP tool with no declared price). Said under the draft; parseVerdict holds it. */
46
+ readonly held?: Readonly<Record<string, readonly string[]>>;
44
47
  };
45
48
  /** What bounds the grader's prompt, in UTF-16 units, as a completion counts them. `prompt` is the most it ever is:
46
49
  * the fixed text, the instructions cut to `instructions`, INDEX_LINES + CAPS.supersedes index lines cut to
@@ -107,4 +110,4 @@ export declare function gradePrompt(input: GradeInput): string;
107
110
  * file it was not asked to judge, or a merge with an item not kept, is no merge. `proposed` are the new notes the
108
111
  * prompt was built from, or the files it asked an item for (gradedFiles: a note's file, a skill's SKILL.md, a draft's
109
112
  * workflow.json). Throws only when `proposed` is not a list a checked proposal could hold, never on the answer. */
110
- export declare function parseVerdict(text: unknown, proposed: readonly NoteText[] | readonly string[]): Verdict;
113
+ export declare function parseVerdict(text: unknown, proposed: readonly NoteText[] | readonly string[], held?: Readonly<Record<string, readonly string[]>>): Verdict;
@@ -13,7 +13,7 @@ import { createHash } from "node:crypto";
13
13
  import { CAPS } from "./check.js";
14
14
  import { hiddenCharacter } from "./invisible.js";
15
15
  import { INDEX_FILE, INDEX_LINES, indexLine, NOTE_FILE, parseNoteFile, runMarkedRisky, withoutRiskyMark } from "./notes.js";
16
- import { learnedName, learnedPlace } from "./skills.js";
16
+ import { draftMcpTools, learnedName, learnedPlace } from "./skills.js";
17
17
  /** What the grader asks of each new note, and when it keeps one. The one statement of it. */
18
18
  export const GRADE_RUBRIC = [
19
19
  "Ask each question of each new note, skill and workflow draft:",
@@ -51,7 +51,7 @@ export const GRADE_RUBRIC = [
51
51
  " report-format note\") is no repeat.",
52
52
  "- Contradicts: does it go against an active note that it does not supersede?",
53
53
  // LS-09 risky-rule block: begin. One reading on every grade model (luna held the refund limit, Sonnet kept it active as
54
- // the user's own policy): four tests on the rule's words, and who asked never changes the answer. Shared with LS-05's
54
+ // the user's own policy): five tests on the rule's words, and who asked never changes the answer. Shared with LS-05's
55
55
  // rubric work (learn-e6): change it here only, and together.
56
56
  "- Risky: would its rule widen trust in a site, a source or a seller, skip or loosen an approval or a check, or name",
57
57
  " an account or a destination for money or data (described in words: a number for it is a secret)? Answer from the",
@@ -62,7 +62,11 @@ export const GRADE_RUBRIC = [
62
62
  " 2. it exempts a case, a person, a site or a source from a check or an approval;",
63
63
  " 3. it tells the agent to trust a site, a source or a seller it names over what it would otherwise check, or to buy",
64
64
  " from or pay one;",
65
- " 4. it names where money or data goes.",
65
+ " 4. it names where money or data goes;",
66
+ // LS-07: a learned workflow's MCP call node runs its tool on an outside server with no person in the loop, at every call.
67
+ " 5. it is a workflow draft with a call node whose tool is an MCP tool (named mcp:<server>/<tool>, a side effect on an",
68
+ " outside server) that writes, sends, posts, pays or deletes anything there: the learned workflow runs that tool",
69
+ " unattended at every call. A draft whose MCP tools only read is not risky for them.",
66
70
  " Who asked never changes the answer: a rule the user stated as their own policy, asked to remember, or that only",
67
71
  " writes down how they already work is risky all the same when a test holds. Risky drops nothing: it holds the item",
68
72
  " for the user's OK. An item that holds an account number is a Secret drop, not Risky.",
@@ -274,6 +278,33 @@ function dryRunLines(file, dryRuns, fence) {
274
278
  const detail = dryRunDetail(dry);
275
279
  return detail ? [`${said} What the check said is below, as data: it is made from the draft's own text.`, fence(`${file}, its dry run`, detail), ""] : [said, ""];
276
280
  }
281
+ /** What the grader is told of draft `file`'s MCP call nodes (LS-07), below its fence: each MCP tool they run, once, by its
282
+ * server and tool. The host's own words: each name is one skills.ts LEARNED_MCP_TOOL takes, so it holds nothing else.
283
+ * Nothing for a skill, or a draft with none, or one that does not parse. */
284
+ function mcpLines(file, text) {
285
+ if (learnedPlace(file)?.kind !== "workflow")
286
+ return [];
287
+ let doc;
288
+ try {
289
+ doc = JSON.parse(text);
290
+ }
291
+ catch {
292
+ return [];
293
+ }
294
+ const named = draftMcpTools(doc).map((name) => {
295
+ const [server, tool] = name.slice("mcp:".length).split("/");
296
+ return `\`${name}\` (server ${server}, tool ${tool})`;
297
+ });
298
+ return named.length ? [`Its call nodes run MCP tools, each a side effect on an outside server, unattended at every call: ${named.join(", ")}.`, ""] : [];
299
+ }
300
+ /** What the grader is told of draft `file`'s hold (GradeInput.held): that it waits for its owner's OK whatever the
301
+ * grade, in the host's words, and why, fenced as data (each line names one of the draft's own steps, its text). */
302
+ function heldLines(file, held, fence) {
303
+ const lines = held?.[file] ?? [];
304
+ if (!lines.length)
305
+ return [];
306
+ return ["It waits for its owner's OK whatever you decide, for the reason below, as data: it names the draft's own steps.", fence(`${file}, why it waits`, lines.map((line) => line.replace(/[\p{Cc}\p{Cf}]/gu, " ")).join("\n")), ""];
307
+ }
277
308
  /** gradePrompt with the user's messages given `budget` characters. Every other part is capped; the messages take the
278
309
  * room the rest leaves: over the cap, it is built again with fewer (the first and the newest that fit, the rest named),
279
310
  * so a proposal the checker passed never makes it throw. */
@@ -390,7 +421,7 @@ function promptWithin(input, budget) {
390
421
  // Each new note as the grader judges it: without its run's risky mark, which the verdict's hold reads after.
391
422
  ...(proposed.length ? proposed.map(({ file, text }) => fence(`${file}, new`, withoutRiskyMark(text))) : ["There are none."]),
392
423
  ...(learned.length
393
- ? ["", "## The new skill and workflow draft", "", "A workflow draft's README.md is judged with its workflow.json, as one item.", "", ...learned.flatMap(({ file, text }) => [fence(`${file}, new`, text), ...dryRunLines(file, input.dryRuns, fence)])]
424
+ ? ["", "## The new skill and workflow draft", "", "A workflow draft's README.md is judged with its workflow.json, as one item.", "", ...learned.flatMap(({ file, text }) => [fence(`${file}, new`, text), ...mcpLines(file, text), ...heldLines(file, input.held, fence), ...dryRunLines(file, input.dryRuns, fence)])]
394
425
  : []),
395
426
  "",
396
427
  "## Your verdict",
@@ -487,7 +518,7 @@ const PLANTED = /\bplanted\b/i;
487
518
  * file it was not asked to judge, or a merge with an item not kept, is no merge. `proposed` are the new notes the
488
519
  * prompt was built from, or the files it asked an item for (gradedFiles: a note's file, a skill's SKILL.md, a draft's
489
520
  * workflow.json). Throws only when `proposed` is not a list a checked proposal could hold, never on the answer. */
490
- export function parseVerdict(text, proposed) {
521
+ export function parseVerdict(text, proposed, held = {}) {
491
522
  const names = Array.isArray(proposed) ? proposed.map((item) => (typeof item === "string" ? item : item?.file)) : [];
492
523
  if (!Array.isArray(proposed) || names.length === 0 || !names.every(isGraded) || new Set(names).size < names.length)
493
524
  throw new Error("the proposal must hold one new item or more, each a note's file, a skill's SKILL.md or a draft's workflow.json, each once");
@@ -517,6 +548,13 @@ export function parseVerdict(text, proposed) {
517
548
  // So does one the run's own turn marked `risky: true` (reflectPrompt): the hold is the run's or the grader's,
518
549
  // whichever says so, and never rests on one grading model's reading of Risky.
519
550
  const marked = decided === "keep" && runMarkedRisky(texts.get(item.file));
551
+ // A draft held in code (an MCP tool with no declared price, LS-07) waits whatever the grade: its why is the hold's.
552
+ // Never over a Planted one: that drops the whole proposal (PLANTED below), whatever else holds it.
553
+ const holds = decided !== "drop" && !PLANTED.test(asked) ? (held[item.file] ?? []) : [];
554
+ if (holds.length) {
555
+ items.push({ file: item.file, keep: true, pending: true, origin: origin, question: "Unpriced", why: oneLine(holds.join("; "), REASON_MAX) });
556
+ continue;
557
+ }
520
558
  const decision = decided === "keep" && (marked || asked.trim().toLowerCase() === "risky") ? "pending" : decided;
521
559
  const askedAs = asked || (marked ? "Risky" : "");
522
560
  items.push({ file: item.file, keep: decision !== "drop", ...(decision === "pending" ? { pending: true } : {}), ...(decision === "drop" ? {} : { origin }), ...(askedAs ? { question: askedAs } : {}), why: oneLine(item.why, REASON_MAX) });
@@ -2,6 +2,6 @@ export { CAPS, checkNote, checkProposal, mergeProblems, printable, supersededBy,
2
2
  export { GRADE_CAPS, GRADE_RUBRIC, gradedFiles, gradedItems, gradePrompt, parseVerdict, shortMessage, UNREADABLE_REASON, CONTRADICTED_REASON, CONTRADICTED_TWICE_REASON, CONTRADICTION_ASK, type GradeInput, type IndexEntry, type NoteText, type Verdict, type VerdictItem } from "./grade.js";
3
3
  export { hiddenCharacter } from "./invisible.js";
4
4
  export { ANSWER_MAX, NOTE_BLOCK, parseReflection, reflectAgain, reflectDryRun, reflectPrompt, SKILL_BLOCK, WORKFLOW_BLOCK, type LearnedBlock, type Reflection } from "./reflect.js";
5
- export { activeNotes, approve, buildIndex, INDEX_BYTES, INDEX_FILE, INDEX_LINES, indexLine, loadedIndex, mergedNote, NOTE_FILE, NOTE_ORIGINS, NOTE_STATUSES, NOTE_TYPES, parseNoteFile, retire, supersede, type LearnedNote, type NoteOrigin, type NoteStatus, type NoteType } from "./notes.js";
5
+ export { activeNotes, approve, buildIndex, INDEX_BYTES, INDEX_FILE, INDEX_LINES, indexLine, loadedIndex, mergedNote, NOTE_FILE, NOTE_ORIGINS, NOTE_STATUSES, NOTE_TYPES, parseNoteFile, restore, retire, supersede, type LearnedNote, type NoteOrigin, type NoteStatus, type NoteType } from "./notes.js";
6
6
  export { learnedSecretShapes, MIN_SECRET, PRINT_MAX, redactLearned, redactSecrets, secretShapes, valueMatcher } from "./secrets.js";
7
- export { decodedStrings, draftDryRun, draftFiles, draftProblems, DRY_RUN_FAILED, frontKeys, frontMatter, held, isHeld, LEARNED_KEYS, LEARNED_MAX_TURNS, learnedFront, learnedName, learnedPlace, learnedStatus, NO_TOOL_LIST, readmeOf, released, retiredLearned, servedSkill, servedSkills, setsStatus, SKILL_NAME, SKILLS_DIR, skillProblems, statusOnOneLine, UNCLEAR_FRONT, WORKFLOW_NAME, WORKFLOWS_DIR, type DraftDryRun, type DraftProblem, type DraftReader, type LearnedPlace } from "./skills.js";
7
+ export { decodedStrings, draftDryRun, draftFiles, draftProblems, DRY_RUN_FAILED, frontKeys, frontMatter, held, isHeld, LEARNED_KEYS, LEARNED_MAX_TURNS, learnedFront, learnedName, learnedPlace, learnedStatus, NO_TOOL_LIST, readmeOf, released, restorable, restoredLearned, retiredFrom, retiredLearned, servedSkill, servedSkills, setsStatus, SKILL_NAME, SKILLS_DIR, skillProblems, statusOnOneLine, UNCLEAR_FRONT, WORKFLOW_NAME, WORKFLOWS_DIR, type DraftDryRun, type DraftProblem, type DraftReader, type LearnedPlace } from "./skills.js";
@@ -6,6 +6,6 @@ export { CAPS, checkNote, checkProposal, mergeProblems, printable, supersededBy,
6
6
  export { GRADE_CAPS, GRADE_RUBRIC, gradedFiles, gradedItems, gradePrompt, parseVerdict, shortMessage, UNREADABLE_REASON, CONTRADICTED_REASON, CONTRADICTED_TWICE_REASON, CONTRADICTION_ASK } from "./grade.js";
7
7
  export { hiddenCharacter } from "./invisible.js";
8
8
  export { ANSWER_MAX, NOTE_BLOCK, parseReflection, reflectAgain, reflectDryRun, reflectPrompt, SKILL_BLOCK, WORKFLOW_BLOCK } from "./reflect.js";
9
- export { activeNotes, approve, buildIndex, INDEX_BYTES, INDEX_FILE, INDEX_LINES, indexLine, loadedIndex, mergedNote, NOTE_FILE, NOTE_ORIGINS, NOTE_STATUSES, NOTE_TYPES, parseNoteFile, retire, supersede } from "./notes.js";
9
+ export { activeNotes, approve, buildIndex, INDEX_BYTES, INDEX_FILE, INDEX_LINES, indexLine, loadedIndex, mergedNote, NOTE_FILE, NOTE_ORIGINS, NOTE_STATUSES, NOTE_TYPES, parseNoteFile, restore, retire, supersede } from "./notes.js";
10
10
  export { learnedSecretShapes, MIN_SECRET, PRINT_MAX, redactLearned, redactSecrets, secretShapes, valueMatcher } from "./secrets.js";
11
- export { decodedStrings, draftDryRun, draftFiles, draftProblems, DRY_RUN_FAILED, frontKeys, frontMatter, held, isHeld, LEARNED_KEYS, LEARNED_MAX_TURNS, learnedFront, learnedName, learnedPlace, learnedStatus, NO_TOOL_LIST, readmeOf, released, retiredLearned, servedSkill, servedSkills, setsStatus, SKILL_NAME, SKILLS_DIR, skillProblems, statusOnOneLine, UNCLEAR_FRONT, WORKFLOW_NAME, WORKFLOWS_DIR } from "./skills.js";
11
+ export { decodedStrings, draftDryRun, draftFiles, draftProblems, DRY_RUN_FAILED, frontKeys, frontMatter, held, isHeld, LEARNED_KEYS, LEARNED_MAX_TURNS, learnedFront, learnedName, learnedPlace, learnedStatus, NO_TOOL_LIST, readmeOf, released, restorable, restoredLearned, retiredFrom, retiredLearned, servedSkill, servedSkills, setsStatus, SKILL_NAME, SKILLS_DIR, skillProblems, statusOnOneLine, UNCLEAR_FRONT, WORKFLOW_NAME, WORKFLOWS_DIR } from "./skills.js";
@@ -21,8 +21,6 @@
21
21
  # snapshot <main> the working tree and snapshot.json written again at <main>, which must be main (else 3)
22
22
  # read [commit] main's (or <commit>'s) tree, its first-parent log and its blobs, for the host to build a
23
23
  # snapshot from; 1 when <commit> is not in the repository
24
- # before-retire <main> <path>
25
- # the text <path> had just before the newest person's retire of it on <main>'s line (else 1)
26
24
  # has <main> <path> whether <main> holds anything at <path>, any mode, any type (0 yes, 1 no)
27
25
  # stdin, for init, commit and snapshot: header lines, a blank line, then (init and commit) a fast-import stream:
28
26
  # ref <name> the temporary ref the stream commits on (refs/agentrun/import-<hex>)
@@ -342,17 +340,6 @@ case $op in
342
340
  printf 'agentrun-read 1 %s %s %s %s\n' "${main:-none}" "$(($(wc -c < "$tmp/tree")))" "$(($(wc -c < "$tmp/log")))" "$(($(wc -c < "$tmp/blobs")))"
343
341
  cat "$tmp/tree" "$tmp/log" "$tmp/blobs"
344
342
  ;;
345
- before-retire)
346
- main=${2:-}
347
- path=${3:-}
348
- hex40 "$main" || die "before-retire takes a main"
349
- [ -n "$path" ] || die "before-retire takes a path"
350
- g log --first-parent '--format=%H%x1f%s' "$main" -- "$path" > "$tmp/walk" || die "log failed"
351
- wanted="learning: retired by a person: $path"
352
- commit=$(awk -F "$(printf '\037')" -v wanted="$wanted" '$2 == wanted { print $1; exit }' "$tmp/walk")
353
- [ -n "$commit" ] || exit 1
354
- g cat-file blob "$commit^:$path" 2> /dev/null || exit 1
355
- ;;
356
343
  has)
357
344
  main=${2:-}
358
345
  path=${3:-}
@@ -361,6 +348,6 @@ case $op in
361
348
  g cat-file -e "$main:$path" 2> /dev/null || exit 1
362
349
  ;;
363
350
  *)
364
- die "no op $op: init, commit, snapshot, read, before-retire or has"
351
+ die "no op $op: init, commit, snapshot, read or has"
365
352
  ;;
366
353
  esac
@@ -12,7 +12,12 @@ export type NoteStatus = (typeof NOTE_STATUSES)[number];
12
12
  export type NoteOrigin = (typeof NOTE_ORIGINS)[number];
13
13
  /** A note's file name: in the folder itself, never under a directory or hidden, and never the index. */
14
14
  export declare const NOTE_FILE: RegExp;
15
- /** `supersedes`: the notes it replaces, by file name; `keys`: every key its front matter sets. */
15
+ /** The statuses a retire records it was retired from (`retired_from`), the one a restore gives back. */
16
+ export declare const RETIRED_FROM: readonly ["active", "pending"];
17
+ export type RetiredFrom = (typeof RETIRED_FROM)[number];
18
+ /** `supersedes`: the notes it replaces, by file name; `retired_from`: on a retired note, the status a restore gives back:
19
+ * `pending` when its retire recorded none (fail closed: only an approval makes a note active); null on any other note.
20
+ * `keys`: every key its front matter sets. */
16
21
  export type LearnedNote = {
17
22
  file: string;
18
23
  name: string;
@@ -22,6 +27,7 @@ export type LearnedNote = {
22
27
  origin: NoteOrigin;
23
28
  superseded_by: string | null;
24
29
  supersedes: string[];
30
+ retired_from: RetiredFrom | null;
25
31
  keys: string[];
26
32
  body: string;
27
33
  };
@@ -46,8 +52,13 @@ export declare function runMarkedRisky(text: string | undefined): boolean;
46
52
  export declare const approve: (text: string) => string;
47
53
  /** `text`, a note's file, as the host leaves it when note `by` supersedes it: `status: superseded` and `superseded_by`. */
48
54
  export declare function supersede(text: string, by: string): string;
49
- /** `text`, a note's file, as the host leaves it when a person retires it: `status: retired`, and no `superseded_by`. */
50
- export declare const retire: (text: string) => string;
55
+ /** `text`, a note's file, as the host leaves it when a person retires it: `status: retired` and `retired_from`, the status
56
+ * it had (`from`: active or pending), which its restore gives back; no `superseded_by`. */
57
+ export declare const retire: (text: string, from: RetiredFrom) => string;
58
+ /** `text`, a retired note's file (`note`, as parsed), as the host leaves it when a person restores it: back in the status
59
+ * its retire recorded (`retired_from`), active or pending. A note retired while it waited for its owner's OK waits again:
60
+ * only an approval makes it active. */
61
+ export declare const restore: (text: string, note: Pick<LearnedNote, "retired_from">) => string;
51
62
  /** The active ones of `notes`, by file name. */
52
63
  export declare function activeNotes(notes: Iterable<LearnedNote>): LearnedNote[];
53
64
  /** A note's line in the index, `- [name](file.md) — description`, each run of whitespace one space. */
@@ -2,7 +2,7 @@
2
2
  // index a run reads, one line per active note. A note is `<slug>.md`: front matter with `name`, `description` and `type`
3
3
  // (Claude Code's four), optionally `supersedes: [old.md]` (the notes it replaces), and what only the host sets:
4
4
  // `status: superseded | retired | pending` with `superseded_by` (absent, it is active; pending, it waits for its owner's
5
- // OK) and `origin: you | run` (a note kept from what the user asked, or one the run worked out; absent, the run's). Then
5
+ // OK), `retired_from: active | pending` on a retired note (the status a restore gives it back), and `origin: you | run` (a note kept from what the user asked, or one the run worked out; absent, the run's). Then
6
6
  // its body. The host builds the index from the active notes' front matter; nothing else writes it.
7
7
  /** The index: what a run reads. */
8
8
  export const INDEX_FILE = "MEMORY.md";
@@ -15,6 +15,8 @@ export const NOTE_STATUSES = Object.freeze(["active", "superseded", "retired", "
15
15
  export const NOTE_ORIGINS = Object.freeze(["you", "run"]);
16
16
  /** A note's file name: in the folder itself, never under a directory or hidden, and never the index. */
17
17
  export const NOTE_FILE = /^(?!MEMORY\.md$)[A-Za-z0-9][A-Za-z0-9._-]{0,95}\.md$/;
18
+ /** The statuses a retire records it was retired from (`retired_from`), the one a restore gives back. */
19
+ export const RETIRED_FROM = Object.freeze(["active", "pending"]);
18
20
  /** A value as front matter writes it: bare, or in one pair of quotes. */
19
21
  const unquoted = (value) => (/^"[^"]*"$|^'[^']*'$/.test(value) ? value.slice(1, -1) : value);
20
22
  /** The front matter, between its two `---` lines, and what follows it. */
@@ -61,6 +63,9 @@ export function parseNoteFile(file, text) {
61
63
  const by = fields.get("superseded_by") || null;
62
64
  if (by !== null && !NOTE_FILE.test(by))
63
65
  out.push("superseded_by is not a note's file name");
66
+ const from = fields.get("retired_from") || null;
67
+ if (from !== null && !RETIRED_FROM.includes(from))
68
+ out.push(`retired_from is not ${RETIRED_FROM.join(" or ")}`);
64
69
  const supersedes = listOf(fields.get("supersedes") ?? "");
65
70
  if (supersedes.some((old) => !NOTE_FILE.test(old)))
66
71
  out.push("supersedes is not a list of notes' file names");
@@ -68,11 +73,11 @@ export function parseNoteFile(file, text) {
68
73
  out.push("supersedes names a note twice");
69
74
  if (out.length)
70
75
  return out;
71
- return { file, name: fields.get("name"), description: fields.get("description"), type: type, status: status, origin: origin, superseded_by: by, supersedes, keys: [...fields.keys()], body: lf.slice(head[0].length) };
76
+ return { file, name: fields.get("name"), description: fields.get("description"), type: type, status: status, origin: origin, superseded_by: by, supersedes, retired_from: status === "retired" ? (from ?? "pending") : null, keys: [...fields.keys()], body: lf.slice(head[0].length) };
72
77
  }
73
78
  /** `text`, a note's file, with `lines` in its front matter in place of any it had of the keys `replaced` (`status` and
74
79
  * `superseded_by` unless named); the rest as it was, with LF line ends. */
75
- function marked(text, lines, replaced = ["status", "superseded_by"]) {
80
+ function marked(text, lines, replaced = ["status", "superseded_by", "retired_from"]) {
76
81
  const lf = text.replace(/\r\n/g, "\n");
77
82
  const head = FRONT.exec(lf);
78
83
  if (!head || head.index !== 0)
@@ -87,7 +92,7 @@ export function mergedNote(text, as) {
87
92
  if (!NOTE_ORIGINS.includes(as.origin))
88
93
  throw new Error(`origin is ${NOTE_ORIGINS.join(" or ")}`);
89
94
  // The run's own `risky` mark is read by the grade (runMarkedRisky) and never kept: a held note says so by its status.
90
- return marked(text, [...(as.origin === "you" ? ["origin: you"] : []), ...(as.pending ? ["status: pending"] : [])], ["status", "superseded_by", "origin", "risky"]);
95
+ return marked(text, [...(as.origin === "you" ? ["origin: you"] : []), ...(as.pending ? ["status: pending"] : [])], ["status", "superseded_by", "retired_from", "origin", "risky"]);
91
96
  }
92
97
  /** `text`, a run's new note, without the mark its end-of-run turn may set (`risky:`), as the grader reads it: the grader
93
98
  * judges each note on its own, and the mark holds only what it keeps (parseVerdict). A text with no front matter is
@@ -122,8 +127,13 @@ export function supersede(text, by) {
122
127
  throw new Error("superseded_by must be a note's file name");
123
128
  return marked(text, ["status: superseded", `superseded_by: ${by}`]);
124
129
  }
125
- /** `text`, a note's file, as the host leaves it when a person retires it: `status: retired`, and no `superseded_by`. */
126
- export const retire = (text) => marked(text, ["status: retired"]);
130
+ /** `text`, a note's file, as the host leaves it when a person retires it: `status: retired` and `retired_from`, the status
131
+ * it had (`from`: active or pending), which its restore gives back; no `superseded_by`. */
132
+ export const retire = (text, from) => marked(text, ["status: retired", `retired_from: ${from}`]);
133
+ /** `text`, a retired note's file (`note`, as parsed), as the host leaves it when a person restores it: back in the status
134
+ * its retire recorded (`retired_from`), active or pending. A note retired while it waited for its owner's OK waits again:
135
+ * only an approval makes it active. */
136
+ export const restore = (text, note) => marked(text, note.retired_from === "active" ? [] : ["status: pending"]);
127
137
  /** The active ones of `notes`, by file name. */
128
138
  export function activeNotes(notes) {
129
139
  return [...notes].filter((note) => note.status === "active").sort((a, b) => (a.file < b.file ? -1 : a.file > b.file ? 1 : 0));
@@ -6,7 +6,7 @@
6
6
  import { createHash } from "node:crypto";
7
7
  import { CAPS } from "./check.js";
8
8
  import { INDEX_FILE, INDEX_LINES } from "./notes.js";
9
- import { SKILL_NAME } from "./skills.js";
9
+ import { LEARNED_MCP_TOOL, SKILL_NAME } from "./skills.js";
10
10
  /** Control and invisible characters: none may reach the prompt through a value the host puts in it. */
11
11
  const UNSEEN = /[\p{Cc}\p{Cf}]/u;
12
12
  /** The info word that opens a note's block in the answer: ```note <file>. */
@@ -18,8 +18,10 @@ export const WORKFLOW_BLOCK = "workflow";
18
18
  /** How many earlier runs of an agent a learned skill has been given to before the host asks for its job as a workflow
19
19
  * draft (`draftFor`): a run proposes one only when it thinks to, and few do. */
20
20
  export const DRAFT_AFTER_RUNS = 3;
21
- /** A tool's name as the prompt may print it. */
21
+ /** A tool's name as the prompt may print it: a table tool's, or an MCP tool's a learned workflow may run (skills.ts
22
+ * LEARNED_MCP_TOOL). */
22
23
  const TOOL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
24
+ const printable = (tool) => TOOL_NAME.test(tool) || LEARNED_MCP_TOOL.test(tool);
23
25
  /** The end-of-run turn's message. `dir` is the run's copy of the folder relative to the run's workspace (`.learning`),
24
26
  * where the agent can read its notes: the prompt never names a path of the host's, which a box would not see. `active`
25
27
  * is how many notes are active in it, so how many lines the index has left. `tools`, the tools a workflow draft's
@@ -35,7 +37,7 @@ export function reflectPrompt(options) {
35
37
  throw new Error("the directory must be a path relative to the run's workspace, with no control or unseen characters");
36
38
  if (!Number.isSafeInteger(active) || active < 0)
37
39
  throw new Error("the count of active notes must be a whole number, 0 or more");
38
- if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !TOOL_NAME.test(tool)))
40
+ if (!Array.isArray(tools) || tools.some((tool) => typeof tool !== "string" || !printable(tool)))
39
41
  throw new Error("each tool must be a tool's name");
40
42
  if (!Array.isArray(draftFor) || draftFor.some((name) => typeof name !== "string" || !SKILL_NAME.test(name)))
41
43
  throw new Error("each skill a draft is asked for must be a skill's name");
@@ -74,22 +74,37 @@ export declare const isHeld: (text: string) => boolean;
74
74
  * retiredLearned), which take the `status:` line out whole, can edit. One set any other way reads unclear (learnedStatus:
75
75
  * retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
76
76
  * only one-line statuses (held, retiredLearned). */
77
- export declare function statusOnOneLine(text: string): boolean;
77
+ export declare const statusOnOneLine: (text: string) => boolean;
78
78
  /** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
79
79
  * pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
80
80
  * passes. */
81
81
  export declare function held(text: string): string;
82
82
  /** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
83
- * no `status` line, so it is given to every later run. Throws on a text with no front matter. */
83
+ * no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
84
84
  export declare function released(text: string): string;
85
+ /** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
86
+ * retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
87
+ * `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
88
+ * them (fail closed: only an approval makes a skill or a draft active). */
89
+ export declare function retiredFrom(text: string): "active" | "pending";
90
+ /** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
91
+ * (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
92
+ * One that is not is refused until it is written so (a restore never edits half a value). */
93
+ export declare const restorable: (text: string) => boolean;
94
+ /** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
95
+ * retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
96
+ * one way, or whose status is not one plain line (released). */
97
+ export declare const restoredLearned: (text: string) => string;
85
98
  /** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
86
99
  * the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
87
100
  * it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
88
101
  * of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
89
102
  * a restore refuses it until it reads one way. A run is given only an active one. */
90
103
  export declare function learnedStatus(text: string): "active" | "pending" | "retired";
91
- /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` last in its front matter
92
- * (any status line before it dropped), so no later run is given it. Throws on a text with no front matter. */
104
+ /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
105
+ * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
106
+ * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
107
+ * matter. */
93
108
  export declare function retiredLearned(text: string): string;
94
109
  /** A draft's `README.md` as the host writes it, from the workflow's name and the one-line description its block gives. */
95
110
  export declare const readmeOf: (name: string, description: string) => string;
@@ -180,6 +195,28 @@ export declare const LEARNED_NODES = "a learned workflow runs model and tool-cal
180
195
  /** Where a deny was set (tool-gate.ts SettingFrom), and its words (tool-gate.ts denyPlace), kept here so the learn
181
196
  * module needs no import of the gate. */
182
197
  type SettingFrom = "agent" | "server" | "default";
198
+ /** An MCP tool a learned workflow's call node may run, by its address (`via: "tool"`, `tool: "mcp:<server>/<tool>"`,
199
+ * LS-07): its server's name as a server is named (mcp-probe.ts MCP_SERVER_NAME) and one tool's name in MCP's own
200
+ * charset, never a wildcard. The one rule for it: the tools a draft may name (tools.ts learnedWorkflowTools), the
201
+ * end-of-run prompt that prints them (reflect.ts), and what the grader is told of a draft (grade.ts). */
202
+ export declare const LEARNED_MCP_TOOL: RegExp;
203
+ /** The MCP tools a draft's call nodes run, each once, in the order they come (LS-07): every call node in `doc`, nested
204
+ * ones too, whose tool is an MCP tool's address. Read from the JSON as it is, for the grader's words; never a check. */
205
+ export declare function draftMcpTools(doc: unknown): string[];
206
+ /** One step of a learned workflow that runs an MCP tool with no declared per-call price: its label, the tool and its
207
+ * server. */
208
+ export type UnpricedCall = {
209
+ readonly label: string;
210
+ readonly tool: string;
211
+ readonly server: string;
212
+ };
213
+ /** The call nodes of a learned workflow (`doc`, its parsed workflow.json, nested ones too) whose tool is an MCP tool
214
+ * (LEARNED_MCP_TOOL) that `priceOf` gives no price for (mcp-probe.ts McpPrices: none declared). Such a tool runs "not
215
+ * metered", outside the run's cost and cap (mcp-gateway.ts), so a learned workflow that calls one unattended waits for
216
+ * its owner's OK whatever the grade (LS-07): a structural fact, held in code. Each step once, in order. */
217
+ export declare function unpricedCalls(doc: unknown, priceOf: (tool: string) => number | undefined): UnpricedCall[];
218
+ /** Why a learned workflow that calls `call` waits for its owner's OK, in a person's words. */
219
+ export declare const unpricedLine: (call: UnpricedCall) => string;
183
220
  /** Every string a learned workflow's workflow.json decodes to, each object's keys too, as JSON.parse reads them (its
184
221
  * escapes decoded: what draftProblems and a learned call's run read, and a model node is given). Text a scan of the
185
222
  * stored JSON misses, spelled in \u escapes, is there as it will be read. None for a text that does not parse (the
@@ -197,5 +234,11 @@ export declare const LEARNED_MAX_TURNS = 8;
197
234
  * apply_patch) is never on the list. A model node that names any tool is refused (MODEL_NODE_TOOLS), and a node the
198
235
  * learned runner cannot run (LEARNED_NODES: a judge's). With no list it
199
236
  * fails closed: a draft the DSL refuses only once given an empty list names a tool. */
200
- export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>): DraftProblem[];
237
+ /** The MCP tools set to ask a learned call would ask its approver about (`asked`, learnedDraftTools), and whether a card
238
+ * names them all (`fits`: learned-workflow.ts learnedAskFits, the gate's own rule, handed in so it is never copied). */
239
+ export type DraftAsk = {
240
+ readonly asked: readonly string[];
241
+ readonly fits: (asks: readonly string[]) => boolean;
242
+ };
243
+ export declare function draftProblems(dsl: DraftReader, text: string, tools?: readonly string[], gated?: Readonly<Record<string, string>>, deniedBy?: Readonly<Record<string, SettingFrom>>, ask?: DraftAsk): DraftProblem[];
201
244
  export {};