bareloop 0.54.1 → 0.56.0

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 (149) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/bareloop.context.md +67 -6
  3. package/package.json +3 -3
  4. package/src/authorflow.js +217 -238
  5. package/src/authoring.js +22 -6
  6. package/src/authorjob.js +138 -30
  7. package/src/authorreadout.js +15 -4
  8. package/src/authorrun.js +13 -4
  9. package/src/authorscout.js +9 -6
  10. package/src/behaviour.js +14 -0
  11. package/src/blockasks.js +43 -0
  12. package/src/cardschedule.js +42 -0
  13. package/src/checkblock.js +772 -0
  14. package/src/checklist.js +128 -0
  15. package/src/checkpick.js +294 -0
  16. package/src/checksuggest.js +28 -0
  17. package/src/checkwords.js +27 -0
  18. package/src/cli.js +1 -1
  19. package/src/config.js +24 -1
  20. package/src/declaredclose.js +30 -1
  21. package/src/destpoint.js +151 -0
  22. package/src/draftspend.js +85 -0
  23. package/src/facts.js +8 -1
  24. package/src/factwords.js +14 -1
  25. package/src/fitcheck.js +5 -3
  26. package/src/job.js +81 -1
  27. package/src/jobblock.js +9 -0
  28. package/src/labelscan.js +11 -0
  29. package/src/launcher.js +3 -2
  30. package/src/mcpchecks.js +52 -0
  31. package/src/mcppick.js +36 -0
  32. package/src/mcpsources.js +77 -0
  33. package/src/mcpuse.js +97 -0
  34. package/src/natural.js +23 -0
  35. package/src/pagemap.js +20 -5
  36. package/src/panel/authorroutes.js +105 -18
  37. package/src/panel/authorsession.js +293 -44
  38. package/src/panel/index.html +873 -41
  39. package/src/panel/jobgrid.js +117 -0
  40. package/src/panel/jobplan.js +103 -35
  41. package/src/panel/scheduler.js +80 -13
  42. package/src/panel/schedules.js +189 -28
  43. package/src/panel/schedulestart.js +44 -13
  44. package/src/panel/server.js +471 -39
  45. package/src/panel/settingsroutes.js +133 -3
  46. package/src/panel/status.js +19 -1
  47. package/src/panel/tickets.js +44 -0
  48. package/src/pickrecord.js +163 -0
  49. package/src/placerule.js +355 -0
  50. package/src/plan.js +31 -2
  51. package/src/planrun.js +71 -15
  52. package/src/prcheckout.js +259 -0
  53. package/src/promptregisters.js +11 -0
  54. package/src/questionbox.js +112 -0
  55. package/src/readshim.js +3 -2
  56. package/src/revises.js +56 -0
  57. package/src/rowedit.js +115 -0
  58. package/src/rubricstep.js +265 -132
  59. package/src/run.js +19 -2
  60. package/src/runexport.js +2 -0
  61. package/src/runlist.js +3 -2
  62. package/src/schedulewords.js +46 -4
  63. package/src/source.js +81 -7
  64. package/src/stepmcp.js +86 -0
  65. package/src/ticket.js +113 -0
  66. package/src/ticketfilter.js +76 -0
  67. package/src/ticketlabels.js +79 -0
  68. package/src/ticketmcp.js +111 -0
  69. package/src/ticketnext.js +35 -0
  70. package/src/ticketrepo.js +98 -0
  71. package/src/ticketschedule.js +32 -0
  72. package/src/ticketshape.js +45 -0
  73. package/src/tools.js +9 -0
  74. package/src/trigger.js +14 -2
  75. package/src/triggerclock.js +7 -3
  76. package/src/triggerfiles.js +19 -11
  77. package/src/triggertickets.js +244 -0
  78. package/src/userrun.js +191 -10
  79. package/src/validate.js +3 -1
  80. package/src/worktree.js +43 -1
  81. package/types/authorflow.d.ts +86 -93
  82. package/types/authorjob.d.ts +35 -4
  83. package/types/authorreadout.d.ts +4 -3
  84. package/types/authorscout.d.ts +4 -2
  85. package/types/behaviour.d.ts +12 -0
  86. package/types/blockasks.d.ts +37 -0
  87. package/types/cardschedule.d.ts +24 -0
  88. package/types/checkblock.d.ts +361 -0
  89. package/types/checklist.d.ts +134 -0
  90. package/types/checkpick.d.ts +160 -0
  91. package/types/checksuggest.d.ts +30 -0
  92. package/types/checkwords.d.ts +14 -0
  93. package/types/config.d.ts +7 -0
  94. package/types/declaredclose.d.ts +4 -0
  95. package/types/destpoint.d.ts +89 -0
  96. package/types/draftspend.d.ts +37 -0
  97. package/types/factwords.d.ts +7 -0
  98. package/types/fitcheck.d.ts +7 -1
  99. package/types/job.d.ts +13 -0
  100. package/types/jobblock.d.ts +9 -0
  101. package/types/labelscan.d.ts +7 -0
  102. package/types/launcher.d.ts +2 -2
  103. package/types/mcpchecks.d.ts +8 -0
  104. package/types/mcppick.d.ts +33 -0
  105. package/types/mcpsources.d.ts +51 -0
  106. package/types/mcpuse.d.ts +15 -0
  107. package/types/natural.d.ts +2 -0
  108. package/types/pagemap.d.ts +6 -1
  109. package/types/panel/authorroutes.d.ts +11 -2
  110. package/types/panel/authorsession.d.ts +69 -3
  111. package/types/panel/jobgrid.d.ts +405 -0
  112. package/types/panel/jobplan.d.ts +55 -11
  113. package/types/panel/scheduler.d.ts +7 -2
  114. package/types/panel/schedules.d.ts +124 -4
  115. package/types/panel/schedulestart.d.ts +21 -3
  116. package/types/panel/server.d.ts +432 -10
  117. package/types/panel/settingsroutes.d.ts +4 -2
  118. package/types/panel/status.d.ts +16 -2
  119. package/types/panel/tickets.d.ts +61 -0
  120. package/types/pickrecord.d.ts +100 -0
  121. package/types/placerule.d.ts +194 -0
  122. package/types/plan.d.ts +1 -0
  123. package/types/prcheckout.d.ts +151 -0
  124. package/types/questionbox.d.ts +87 -0
  125. package/types/readshim.d.ts +4 -3
  126. package/types/revises.d.ts +23 -0
  127. package/types/rowedit.d.ts +32 -0
  128. package/types/rubricstep.d.ts +100 -48
  129. package/types/run.d.ts +27 -1
  130. package/types/runlist.d.ts +6 -3
  131. package/types/schedulewords.d.ts +29 -2
  132. package/types/source.d.ts +40 -4
  133. package/types/stepmcp.d.ts +40 -0
  134. package/types/ticket.d.ts +114 -0
  135. package/types/ticketfilter.d.ts +34 -0
  136. package/types/ticketlabels.d.ts +44 -0
  137. package/types/ticketmcp.d.ts +84 -0
  138. package/types/ticketnext.d.ts +33 -0
  139. package/types/ticketrepo.d.ts +118 -0
  140. package/types/ticketschedule.d.ts +21 -0
  141. package/types/ticketshape.d.ts +37 -0
  142. package/types/tools.d.ts +1 -0
  143. package/types/trigger.d.ts +9 -1
  144. package/types/triggerclock.d.ts +6 -2
  145. package/types/triggerfiles.d.ts +13 -5
  146. package/types/triggertickets.d.ts +110 -0
  147. package/types/userrun.d.ts +50 -0
  148. package/types/validate.d.ts +1 -0
  149. package/types/worktree.d.ts +19 -0
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The check in plain words, one fixed phrase per rule: the ask, the `~` line an agree writes, the plan card and the Audit all read this one function.
3
+ * @param {{rule: string, value?: number, size?: number, wordsPerSection?: number, names?: string[], phrases?: string[]}} c @returns {string}
4
+ */
5
+ export function plainWords(c: {
6
+ rule: string;
7
+ value?: number;
8
+ size?: number;
9
+ wordsPerSection?: number;
10
+ names?: string[];
11
+ phrases?: string[];
12
+ }): string;
13
+ /** the rules of bareguard's list a person may pick here (text rules only: the ones a plain answer can be judged by) */
14
+ export const OFFERED: readonly string[];
package/types/config.d.ts CHANGED
@@ -31,6 +31,13 @@ export function providerFieldProblem(field: string, v: unknown): string | null;
31
31
  * @returns {string|null}
32
32
  */
33
33
  export function modelsProblem(list: unknown): string | null;
34
+ /**
35
+ * The rule for `mcpPaths` (extra MCP config files the person added): a list of absolute, NUL-free paths, no duplicates. Plain words, or null.
36
+ * (The Settings > MCP tab, R3, is the writer; `~` is expanded there, so what is stored is always absolute. One line, at most 500 characters: fwd's rule.)
37
+ * @param {unknown} list
38
+ * @returns {string|null}
39
+ */
40
+ export function mcpPathProblem(list: unknown): string | null;
34
41
  /**
35
42
  * Apply a patch and write. `null` deletes a field. Top-level fields shallow-merge;
36
43
  * `keys` merges per key variable name, then per field; `models.<ENV>` is REPLACED WHOLE (`null`
@@ -186,6 +186,10 @@ export const DECLARED_GENRES: readonly string[];
186
186
  * channel of its own.
187
187
  */
188
188
  export const CLOSE_DECL_FIELDS: readonly string[];
189
+ /** the fields of a row of the one check list that the signed close carries (`closeDecl.list`); the row's own words are never signed */
190
+ export const SIGNED_ROW_FIELDS: readonly string[];
191
+ /** the states a signed row may end in */
192
+ export const SIGNED_STATES: readonly string[];
189
193
  /** what a stored calibration set carries, ENUMERATED: the frozen cases and the judge
190
194
  * tier that graded them. Both are inside the spec, so `jobSpecHash` covers both — which
191
195
  * is the whole mechanism behind "a judge-model bump forces a full recalibration"
@@ -0,0 +1,89 @@
1
+ /**
2
+ * What the AI is told (the numbered job text only, no `~` rules) and the one rule, with a legal example.
3
+ * @param {{jobLines: {n: number, text: string}[], destination: string}} o @returns {string}
4
+ */
5
+ export function destPrompt({ jobLines, destination }: {
6
+ jobLines: {
7
+ n: number;
8
+ text: string;
9
+ }[];
10
+ destination: string;
11
+ }): string;
12
+ /** @typedef {{line: number, file: string, folder: string}} DestPoint */
13
+ /** does `file` lie under the Destination (a folder, a file, a glob, or `.`)? @param {string} file @param {string} destination @returns {boolean} */
14
+ export function destinationCovers(file: string, destination: string): boolean;
15
+ /**
16
+ * Read the AI's reply and decide, all in code. Malformed (no repair): not JSON, not `{points:[...]}`, a point that is not an object with a whole line, a string file and a string folder.
17
+ * A point survives only when its line is a job line, the file path is written in that line's own text, the file is in the repo's committed tree, the folder is a real parent folder
18
+ * of that file, and the file is NOT under the Destination. The survivors are ordered by line.
19
+ * @param {unknown} text @param {{jobLines: {n: number, text: string}[], files: readonly string[], destination: string}} o
20
+ * @returns {{status: 'malformed'}|{status: 'ok', points: DestPoint[], dropped: number}}
21
+ */
22
+ export function decideDestPoint(text: unknown, { jobLines, files, destination }: {
23
+ jobLines: {
24
+ n: number;
25
+ text: string;
26
+ }[];
27
+ files: readonly string[];
28
+ destination: string;
29
+ }): {
30
+ status: "malformed";
31
+ } | {
32
+ status: "ok";
33
+ points: DestPoint[];
34
+ dropped: number;
35
+ };
36
+ /**
37
+ * Run the pointing call: one call (one retry on a malformed reply, a transport failure or a 429). Never throws on a call casualty; every failure is `absent` (no question).
38
+ * @param {{jobLines: {n: number, text: string}[], files: readonly string[], destination: string, provider?: any, maxTokens?: number, ceilingUsd?: number|null,
39
+ * callTimeoutMs?: number, onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void,
40
+ * createLoop?: Function, rates?: {in: number, out: number}|null, callOptions?: Record<string, any>, sleep?: (ms: number) => Promise<void>}} o
41
+ * @returns {Promise<{state: 'point'|'none'|'absent', point: DestPoint|null, reason: string|null, calls: {label: string, costUsd: number|null, unpricedRounds: number}[]}>}
42
+ */
43
+ export function runDestPoint({ jobLines, files, destination, provider, maxTokens, ceilingUsd, callTimeoutMs, onCall, createLoop, rates, callOptions, sleep, }: {
44
+ jobLines: {
45
+ n: number;
46
+ text: string;
47
+ }[];
48
+ files: readonly string[];
49
+ destination: string;
50
+ provider?: any;
51
+ maxTokens?: number;
52
+ ceilingUsd?: number | null;
53
+ callTimeoutMs?: number;
54
+ onCall?: (call: {
55
+ label: string;
56
+ costUsd: number | null;
57
+ unpricedRounds: number;
58
+ thinkingStatus?: string;
59
+ raw?: string;
60
+ }) => void;
61
+ createLoop?: Function;
62
+ rates?: {
63
+ in: number;
64
+ out: number;
65
+ } | null;
66
+ callOptions?: Record<string, any>;
67
+ sleep?: (ms: number) => Promise<void>;
68
+ }): Promise<{
69
+ state: "point" | "none" | "absent";
70
+ point: DestPoint | null;
71
+ reason: string | null;
72
+ calls: {
73
+ label: string;
74
+ costUsd: number | null;
75
+ unpricedRounds: number;
76
+ }[];
77
+ }>;
78
+ /** the label of the one paid call, as the drafting book sees it */
79
+ export const DEST_CALL_LABEL: "dest-point";
80
+ export const DEST_SYSTEM: "You read the numbered lines of a code job. You never invent words: every file path you name must be copied, character for character, from the job line that holds it.";
81
+ export function destQuestionText(p: DestPoint, destination: string): string;
82
+ /** the answer words the question ends with (said once, here; the panel's question box shows the question without them and has the buttons instead) */
83
+ export const DEST_ANSWER: " Type yes to set it, or no to keep it as it is.";
84
+ export function yesNoOf(text: unknown): "yes" | "no" | null;
85
+ export type DestPoint = {
86
+ line: number;
87
+ file: string;
88
+ folder: string;
89
+ };
@@ -88,6 +88,43 @@ export function readDraftSteps(dir: string): {
88
88
  }[];
89
89
  humans: ReturnType<typeof humanRowWords>[];
90
90
  }[];
91
+ /**
92
+ * fwd am14 item 6: the label this draft's record carries (`revise 1`, `revise 2`, `start over`; src/revises.js `draftLabelOf` owns the words), or null for a first draft.
93
+ * @param {string} dir
94
+ * @returns {string|null}
95
+ */
96
+ export function readDraftLabel(dir: string): string | null;
97
+ /**
98
+ * The checks the draft ended with, each marked who added it (`agent` = the drafter, `you` = the person's own pick): the last `draft-checks` line of the log, or `[]` (a draft from before it, or a job that has none).
99
+ * @param {string} dir
100
+ * @returns {{line: number, text: string, by: 'agent'|'you'}[]}
101
+ */
102
+ export function readDraftChecks(dir: string): {
103
+ line: number;
104
+ text: string;
105
+ by: "agent" | "you";
106
+ }[];
107
+ /**
108
+ * The suggested checks code could not build, one plain sentence each (the last `draft-notbuilt` line of the log): the Audit's draft lines. `[]` when there are none.
109
+ * @param {string} dir
110
+ * @returns {{line: number, text: string}[]}
111
+ */
112
+ export function readDraftNotBuilt(dir: string): {
113
+ line: number;
114
+ text: string;
115
+ }[];
116
+ /**
117
+ * The check list's rows as the drafting ended (draft log `ledger` rows of phase `final`, the last one per key): each row's own words, so the Job tab can name a
118
+ * Not checked row in the person's words. `null` when the session has no readable log or no final row (a CLI run, an imported run, a deleted session). Never throws.
119
+ * @param {string} dir
120
+ * @returns {{key: string, rowKind: string, words: string[], state: string}[]|null}
121
+ */
122
+ export function readDraftLedger(dir: string): {
123
+ key: string;
124
+ rowKind: string;
125
+ words: string[];
126
+ state: string;
127
+ }[] | null;
91
128
  /**
92
129
  * The DRAFTING PART of a run (hamr 2026-10-06, option A): the first part of the run's views, built from the session's
93
130
  * drafting log. `null` when the run did not come out of a panel session, or the log carries no metered call (a Reuse
@@ -32,6 +32,13 @@ export function keptSetOf(look: {
32
32
  decimal?: string;
33
33
  }[];
34
34
  } | null;
35
+ /**
36
+ * The label lists the drafter is told, one per input: ONE owner with the proof above. An input the page-word map read (a look with a
37
+ * `dropped` list) is offered the labels `keptSetOf` accepts, nothing else; any other input keeps the code-made list the proof reads.
38
+ * @param {Record<string, string>} texts @param {Parameters<typeof keptSetOf>[0]} look
39
+ * @returns {string[]}
40
+ */
41
+ export function labelListsFor(texts: Record<string, string>, look: Parameters<typeof keptSetOf>[0]): string[];
35
42
  /**
36
43
  * The reds for ONE fact part against its frozen source text.
37
44
  * @param {{part: any, text: string, line: number|string, scan?: import('./labelscan.js').LabelScan, kept?: ReturnType<typeof keptSetOf>}} o
@@ -95,14 +95,20 @@ export function notFoundList(notFound: {
95
95
  line: number;
96
96
  ask: string;
97
97
  }[]): string;
98
- export function fitQuestionText({ found, total, notFound }: {
98
+ export function fitQuestionText({ found, total, notFound, foundAsks }: {
99
99
  found: number;
100
100
  total: number;
101
101
  notFound: {
102
102
  line: number;
103
103
  ask: string;
104
104
  }[];
105
+ foundAsks?: {
106
+ line: number;
107
+ ask: string;
108
+ }[];
105
109
  }): string;
110
+ /** the answer words the question ends with (said once, here; the panel's question box shows the question without them and has the buttons instead) */
111
+ export const FIT_ANSWER: " Type go on to keep drafting, or anything else to stop and change the job or the page.";
106
112
  export type FitAsk = {
107
113
  line: number;
108
114
  ask: string;
package/types/job.d.ts CHANGED
@@ -25,6 +25,11 @@
25
25
  * @returns {string|null} a red `detail`, or `null` when the value is admitted
26
26
  */
27
27
  export function validateBaseUrl(value: unknown): string | null;
28
+ /**
29
+ * The ONE reader of a job's flow type: the field when present; an `mcp` block with no `flowType` is a Tickets job; no `mcp` block is plain.
30
+ * @param {Record<string, any>} spec @returns {'plain'|'mcp'|'tickets'}
31
+ */
32
+ export function flowTypeOf(spec: Record<string, any>): "plain" | "mcp" | "tickets";
28
33
  /**
29
34
  * Validate an operator-owned job spec (`schema: "job-v1"`). Never throws on
30
35
  * JSON text or plain parsed data — the ingest contract; a live object with a
@@ -271,6 +276,14 @@ export const PROVIDERS: readonly string[];
271
276
  * candidate at N3. `provider` is part of the key by definition (top-level,
272
277
  * not duplicated here). */
273
278
  export const CONDITION_KEYS: readonly string[];
279
+ /** the job's flow types; `flowType` is set by code from the job card and signed with the job (fwdloop M13 piece 4) */
280
+ export const FLOW_TYPES: readonly string[];
281
+ /** the words the card's Flow type menu and the Job tab use for each flow type (fwd's am2 names) */
282
+ export const FLOW_TYPE_LABELS: Readonly<{
283
+ plain: "plain";
284
+ mcp: "MCP";
285
+ tickets: "Tickets MCP";
286
+ }>;
274
287
  /**
275
288
  * The fields a "Reuse workflow" run may change: where the work lands (the write fence, `writeScope`, and a
276
289
  * `destination`/`source` where a spec ever carries them), the `inputs` the person pointed at (P7: Inputs is open on a reuse) and the two ceilings. Everything else in a signed spec is
@@ -35,6 +35,15 @@ export function parseInputs(text: unknown): {
35
35
  * @returns {string}
36
36
  */
37
37
  export function renderJobLines(lines: JobLine[]): string;
38
+ /**
39
+ * The job lines as the job BOX reads them (R10): each line's text, then one `~` line per rule. The inverse of {@link parseJobBlock}, so a card reopened by a Revise holds
40
+ * the `~` lines the person's answers added.
41
+ * @param {{text: string, rules: string[]}[]} lines @returns {string}
42
+ */
43
+ export function jobBoxText(lines: {
44
+ text: string;
45
+ rules: string[];
46
+ }[]): string;
38
47
  /**
39
48
  * The PASS:/FAIL: examples the person wrote, each kept with its line number (answer 2 of a rubric interview — what the
40
49
  * calibration compile reads). Empty string when there are none.
@@ -21,6 +21,13 @@ export function labelOnList(scan: LabelScan, shape: string, idOrText: unknown):
21
21
  * @returns {string}
22
22
  */
23
23
  export function renderLabelList(inputLabel: string, scan: LabelScan): string;
24
+ /**
25
+ * The list a page-word map input is shown: ONLY the labels the map kept (what the draft gate's `keptSetOf` accepts), so the prompt and the
26
+ * proof read the same words. Empty = no label was kept, so the drafter leaves the label out.
27
+ * @param {string} inputLabel @param {string[]} labels
28
+ * @returns {string}
29
+ */
30
+ export function renderKeptLabelList(inputLabel: string, labels: string[]): string;
24
31
  /** the shapes a list is made for */
25
32
  export const LABEL_SHAPES: readonly string[];
26
33
  /** a label must occur at least this often to be listed (1: a one-page document with one total still has its label; the list is cut to the highest counts) */
@@ -30,7 +30,7 @@
30
30
  * @property {import('./tty-colour.js').Paint} [paintErr] colour for stderr lines (default: `paint`)
31
31
  * @property {number} [now] ms clock for the run list's age rules (default: real time); tests pass their own
32
32
  * @property {string} [platform]
33
- * @property {Record<string, string|undefined>} [env] raw env handed to the panel child (default process.env)
33
+ * @property {Record<string, string|undefined>} [env] raw env: handed whole to the panel child, stripped by npmEnv for the update npm child (default process.env)
34
34
  */
35
35
  /**
36
36
  * The run counts, from the panel's own `listRuns` rows. `status.key === 'running'` is the panel's word; `needs` is the one tag
@@ -321,7 +321,7 @@ export type LauncherDeps = {
321
321
  now?: number | undefined;
322
322
  platform?: string | undefined;
323
323
  /**
324
- * raw env handed to the panel child (default process.env)
324
+ * raw env: handed whole to the panel child, stripped by npmEnv for the update npm child (default process.env)
325
325
  */
326
326
  env?: Record<string, string | undefined> | undefined;
327
327
  };
@@ -0,0 +1,8 @@
1
+ /** append ONE line; throws when it cannot be written @param {string|undefined} home @param {Record<string, any>} entry */
2
+ export function appendMcpCheck(home: string | undefined, entry: Record<string, any>): void;
3
+ /** the newest line per `path\tserver` @param {string|undefined} home @returns {Map<string, any>} */
4
+ export function newestMcpChecks(home: string | undefined): Map<string, any>;
5
+ /** the tool names of the newest OK line (with at least one tool) for this server at this path, or null @param {string|undefined} home @param {string} server @param {string} path @returns {string[]|null} */
6
+ export function newestOkMcpTools(home: string | undefined, server: string, path: string): string[] | null;
7
+ export const MCP_CHECKS_FILE: "mcp-checks.jsonl";
8
+ export function mcpChecksFile(home: string | undefined): string;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @param {string} server
3
+ * @param {{ home?: string, mcpHome?: string }} [o] `home` the config home (undefined = `~/.config/bareloop`); `mcpHome` the person's home folder the MCP config places live under (tests inject one)
4
+ * @returns {{ ok: true, server: string, tools: string[] } | { ok: false, say: string }}
5
+ */
6
+ export function mcpPickFor(server: string, o?: {
7
+ home?: string;
8
+ mcpHome?: string;
9
+ }): {
10
+ ok: true;
11
+ server: string;
12
+ tools: string[];
13
+ } | {
14
+ ok: false;
15
+ say: string;
16
+ };
17
+ /**
18
+ * The spec with the card's flow type and MCP pick signed into it. A `plain` pick writes NOTHING (no `flowType` key, no `mcp`), so every plain job keeps the hash it had before
19
+ * the card had these controls. The `mcp` block is the pick's server and EVERY tool of its newest check; the agent never sets it (`assembleSpec` refuses a draft that carries it).
20
+ * @template {Record<string, any>} T
21
+ * R5: a Tickets job also signs the drafter's PROPOSED `ticketFilter` (already read by `ticketFilterReds`), if it made one: the person signs the whole hash. Never on an `mcp` job.
22
+ * @param {T} spec @param {'plain'|'mcp'|'tickets'} flowType @param {{ server: string, tools: string[] }|null} pick @param {{priority?: string[], labels?: string[]}|undefined} [ticketFilter]
23
+ * @returns {T}
24
+ */
25
+ export function signFlow<T extends Record<string, any>>(spec: T, flowType: "plain" | "mcp" | "tickets", pick: {
26
+ server: string;
27
+ tools: string[];
28
+ } | null, ticketFilter?: {
29
+ priority?: string[];
30
+ labels?: string[];
31
+ } | undefined): T;
32
+ /** the one refusal for an MCP nobody has checked (or whose check never succeeded) */
33
+ export const NEVER_CHECKED_SAY: "press check tools in Settings > MCP first";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The added paths in config.json; none when the file is missing, and a plain-words `problem` when it cannot be read (never papered over).
3
+ * @param {string} [home] the config home (tests); undefined = `~/.config/bareloop`
4
+ * @returns {{ paths: string[], problem: string|null }}
5
+ */
6
+ export function addedMcpPaths(home?: string): {
7
+ paths: string[];
8
+ problem: string | null;
9
+ };
10
+ /**
11
+ * Every place, in order, with the servers found in it.
12
+ * `status`: 'found' (a readable file), 'missing' (no file) or 'not-json' (a file that is not JSON; bare-agent skips it silently).
13
+ * A server: `{name, remote, shadowedBy}`; `shadowedBy` is the shown path of the earlier place that has the same name (the earlier one wins), or null.
14
+ * @param {{ home?: string, mcpHome?: string }} [o] `home` the config home (tests); `mcpHome` the person's home folder the four places live under
15
+ * (tests inject a fixture one so discovery never reads the real `~`; undefined = `os.homedir()`)
16
+ * @returns {{ places: Array<{ path: string, file: string, added: boolean, status: 'found'|'missing'|'not-json', servers: Array<{name: string, remote: boolean, shadowedBy: string|null}> }>, problem: string|null }}
17
+ */
18
+ export function mcpSources(o?: {
19
+ home?: string;
20
+ mcpHome?: string;
21
+ }): {
22
+ places: Array<{
23
+ path: string;
24
+ file: string;
25
+ added: boolean;
26
+ status: "found" | "missing" | "not-json";
27
+ servers: Array<{
28
+ name: string;
29
+ remote: boolean;
30
+ shadowedBy: string | null;
31
+ }>;
32
+ }>;
33
+ problem: string | null;
34
+ };
35
+ /**
36
+ * The file that holds the WINNING `server` (the first place in the list that has the name), whether it is remote, or null when no place has it.
37
+ * Every place bareloop starts an MCP from takes its config file from here.
38
+ * @param {string} server @param {{ home?: string, mcpHome?: string }} [o]
39
+ * @returns {{ file: string, remote: boolean } | null}
40
+ */
41
+ export function mcpConfigFor(server: string, o?: {
42
+ home?: string;
43
+ mcpHome?: string;
44
+ }): {
45
+ file: string;
46
+ remote: boolean;
47
+ } | null;
48
+ export { mcpPathProblem } from "./config.js";
49
+ export function DEFAULT_MCP_PLACES(home?: string): string[];
50
+ export function showMcpPath(p: string, home?: string): string;
51
+ export function expandMcpPath(p: string, home?: string): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param {Array<{ spine?: string, runid?: string }>} rows the run list's rows (`readRunList().rows`)
3
+ * @param {string[]} servers the server names to count for; a step tool row belongs to the LONGEST name that prefixes it with `_`
4
+ * @returns {Map<string, { calls: number, runs: number, last: string|null, denied: number, tools: Map<string, number> }>}
5
+ */
6
+ export function countMcpUse(rows: Array<{
7
+ spine?: string;
8
+ runid?: string;
9
+ }>, servers: string[]): Map<string, {
10
+ calls: number;
11
+ runs: number;
12
+ last: string | null;
13
+ denied: number;
14
+ tools: Map<string, number>;
15
+ }>;
@@ -0,0 +1,2 @@
1
+ /** @param {unknown} x @param {unknown} y @returns {number} negative, 0 or positive, like a sort callback */
2
+ export function compareNatural(x: unknown, y: unknown): number;
@@ -101,6 +101,7 @@ export function readingOfQuestion(q: unknown): string | null;
101
101
  * bound they wrote themselves is theirs and nothing is asked. `agree` writes the reading as a `~` rule in plain words (the answer text is
102
102
  * `reading`), so the drafter is told it and the fact signs plain.
103
103
  * - CAN'T CHECK: no kept fact carries it (PRD v1.106 Part 5 Q3 T2). `drop it` leaves it Not checked.
104
+ * A COUNT rule (`isCountable`: words, list items or lines, sections) is none of these: it is asked once, as a pick (R10, fwd am24); the look's facts about it stay.
104
105
  * One ask per rule text on a line; readings first, then can't-check asks, each in line order. The caller applies the machine's cap and the answer gate.
105
106
  * @param {{facts?: {line: number, forRule?: number, name?: string, shape?: string, unit?: string[], currency?: string[], reading?: import('./pagerules.js').Reading}[]}|null|undefined} look
106
107
  * @param {{n: number, text?: string, rule?: string, rules?: string[]}[]|null|undefined} jobLines
@@ -140,6 +141,10 @@ export const DROP_IT: "drop it";
140
141
  export function isDropIt(text: unknown): boolean;
141
142
  export function isAgree(text: unknown): boolean;
142
143
  export function stripAgreeLead(text: string): string;
144
+ export function readingTail(n: number): string;
145
+ export function cantCheckTail(n: number): string;
146
+ export function readingQuestion(n: number, rule: string, reading: string): string;
147
+ export function cantCheckQuestion(n: number, rule: string): string;
143
148
  /**
144
149
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only)
145
150
  */
@@ -148,7 +153,7 @@ export type LookAsk = {
148
153
  rule: number;
149
154
  source: "look";
150
155
  question: string;
151
- ask: "reading" | "cant-check";
156
+ ask: "reading" | "cant-check" | "check" | "no-check";
152
157
  ruleText: string;
153
158
  reading?: string;
154
159
  };
@@ -53,8 +53,9 @@ export function settleFetchingStep(state: any): void;
53
53
  * deliberately has none of).
54
54
  * @param {{ port: number, token: string, env?: Record<string,string|undefined>,
55
55
  * sessionsRoot?: string, spawnFn?: typeof realSpawn, bareloopBin?: string,
56
- * jobsDir?: string, fetchImpl?: typeof fetch, home?: string,
56
+ * jobsDir?: string, fetchImpl?: typeof fetch, home?: string, mcpHome?: string, newestUnrunTicket?: typeof newestUnrunTicket,
57
57
  * schedules?: ReturnType<typeof import('./schedules.js').createScheduleDoor>,
58
+ * isSkippedTicket?: (job: string, number: number) => boolean, skippedRunOf?: (job: string, number: number) => string|null,
58
59
  * sessionDeps?: Record<string, any>,
59
60
  * runJobNames?: () => string[],
60
61
  * startFrom?: {get: (runid: string, o?: {model?: string}) => any, getImport: (id: string, o?: {model?: string}) => any, listJobs?: (o?: {model?: string}) => any[]} }} opts
@@ -69,7 +70,11 @@ export function createAuthorRoutes(opts: {
69
70
  jobsDir?: string;
70
71
  fetchImpl?: typeof fetch;
71
72
  home?: string;
73
+ mcpHome?: string;
74
+ newestUnrunTicket?: typeof newestUnrunTicket;
72
75
  schedules?: ReturnType<typeof import("./schedules.js").createScheduleDoor>;
76
+ isSkippedTicket?: (job: string, number: number) => boolean;
77
+ skippedRunOf?: (job: string, number: number) => string | null;
73
78
  sessionDeps?: Record<string, any>;
74
79
  runJobNames?: () => string[];
75
80
  startFrom?: {
@@ -115,7 +120,8 @@ export function createAuthorRoutes(opts: {
115
120
  * it to sign"), and this is where it is checked, not trusted.
116
121
  * @param {ReturnType<typeof createSession>} session
117
122
  * @param {string} claimedHash
118
- * @param {{env: any, spawnFn: typeof realSpawn, bareloopBin: string, sessionsRoot?: string, home?: string, reviewDoor?: boolean, onSpawnError?: (e: Error) => void, onExit?: (code: number|null) => void}} o
123
+ * @param {{env: any, spawnFn: typeof realSpawn, bareloopBin: string, sessionsRoot?: string, home?: string, reviewDoor?: boolean, onSpawnError?: (e: Error) => void, onExit?: (code: number|null) => void, anyway?: boolean, schedules?: ReturnType<typeof import('./schedules.js').createScheduleDoor>}} o
124
+ * `schedules` (R7, piece 9): the schedule door. A session whose card picked a Schedule has it signed WITH the job here, written OFF, before the run is spawned; a refusal spawns nothing.
119
125
  * @returns {{ok: boolean, error?: string, job?: string}}
120
126
  */
121
127
  export function signRun(session: ReturnType<typeof createSession>, claimedHash: string, o: {
@@ -127,6 +133,8 @@ export function signRun(session: ReturnType<typeof createSession>, claimedHash:
127
133
  reviewDoor?: boolean;
128
134
  onSpawnError?: (e: Error) => void;
129
135
  onExit?: (code: number | null) => void;
136
+ anyway?: boolean;
137
+ schedules?: ReturnType<typeof import("./schedules.js").createScheduleDoor>;
130
138
  }): {
131
139
  ok: boolean;
132
140
  error?: string;
@@ -140,5 +148,6 @@ export const OLD_JOB_RERUN_WORDS: "This run was made by an older bareloop. Its s
140
148
  export const OLD_JOB_PAUSE_WORDS: "This run was made by an older bareloop. Its saved job doesn't pass today's checks, so it can't be paused from here. Use Reuse workflow on a newer run, or start a new job.";
141
149
  export { panelMoney2 };
142
150
  import { spawn as realSpawn } from 'node:child_process';
151
+ import { newestUnrunTicket } from '../ticketnext.js';
143
152
  import { createSession } from './authorsession.js';
144
153
  import { panelMoney2 } from '../panelmoney.js';
@@ -14,7 +14,7 @@ export function advanceSteps(steps: StepLine[], id: string, detail?: string, lab
14
14
  * The confirm turn's plan as a chat message (P7): a STRUCTURED `{role:'bot', kind:'plan', plan}` the page draws with the
15
15
  * same renderer the Job tab uses — each numbered job line, its `~` rule, its drafted checks folded; the AI's own "not
16
16
  * checked"; the always-on guards. `questions` (what the plan still asks) ride inside the plan. One owner of the shape.
17
- * @param {{goal?: string, checks?: string[], checkItems?: {text: string, fromLine: number[]|null}[], notChecked?: string[], questions?: string[], protections?: string[], signedFacts?: string[]}} p the confirm turn's plan
17
+ * @param {{goal?: string, checks?: string[], checkItems?: {text: string, fromLine: number[]|null, by?: 'agent'|'you'|'default'|null, key?: string}[], notChecked?: string[], notCheckedBy?: Record<string, 'you'|'agent'|'default'>, suggested?: {key: string, line: number, text: string}[], editable?: boolean, questions?: string[], protections?: string[], signedFacts?: string[], ticketFilter?: any, picked?: {line: number, text: string}[]}} p the confirm turn's plan
18
18
  * @param {{n: number, text: string, rule: string}[]|null} jobLines
19
19
  * @returns {{role: 'bot', kind: 'plan', text: string, plan: ReturnType<typeof planFromConfirm> & {goal: string, questions: string[]}}}
20
20
  */
@@ -24,11 +24,25 @@ export function planMessage(p: {
24
24
  checkItems?: {
25
25
  text: string;
26
26
  fromLine: number[] | null;
27
+ by?: "agent" | "you" | "default" | null;
28
+ key?: string;
27
29
  }[];
28
30
  notChecked?: string[];
31
+ notCheckedBy?: Record<string, "you" | "agent" | "default">;
32
+ suggested?: {
33
+ key: string;
34
+ line: number;
35
+ text: string;
36
+ }[];
37
+ editable?: boolean;
29
38
  questions?: string[];
30
39
  protections?: string[];
31
40
  signedFacts?: string[];
41
+ ticketFilter?: any;
42
+ picked?: {
43
+ line: number;
44
+ text: string;
45
+ }[];
32
46
  }, jobLines: {
33
47
  n: number;
34
48
  text: string;
@@ -80,6 +94,42 @@ export function cardSource(card: any): string;
80
94
  * @returns {Record<string, any>}
81
95
  */
82
96
  export function cardFields(card: any): Record<string, any>;
97
+ /**
98
+ * The card's flow type and MCP, normalised: a card with no `flowType` (or `plain`) is plain with no MCP; any other pick keeps its server name.
99
+ * @param {any} card @returns {{flowType: 'plain'|'mcp'|'tickets', mcp: string}}
100
+ */
101
+ export function flowOfCard(card: any): {
102
+ flowType: "plain" | "mcp" | "tickets";
103
+ mcp: string;
104
+ };
105
+ /**
106
+ * ITEM33-BUILD piece 8: what the card's Flow type and MCP become, decided at $0 before any session (nothing is started, no server runs). A plain card is `{flowType:'plain', pick:null}`.
107
+ * An MCP or Tickets card needs a server named in Settings > MCP and that server's newest successful `check tools` (`mcpPickFor`: ALL its tools, set by code); an unknown flow type, no pick, a
108
+ * never-checked MCP and a Tickets card with no ticket-list Inputs line are refused in plain words.
109
+ * @param {any} card @param {{ home?: string, mcpHome?: string }} [o]
110
+ * @returns {{ok: true, flowType: 'plain'|'mcp'|'tickets', pick: {server: string, tools: string[]}|null} | {ok: false, error: string}}
111
+ */
112
+ export function resolveFlowCard(card: any, o?: {
113
+ home?: string;
114
+ mcpHome?: string;
115
+ }): {
116
+ ok: true;
117
+ flowType: "plain" | "mcp" | "tickets";
118
+ pick: {
119
+ server: string;
120
+ tools: string[];
121
+ } | null;
122
+ } | {
123
+ ok: false;
124
+ error: string;
125
+ };
126
+ /**
127
+ * The by-hand ticket of a Tickets MCP run (ITEM33-BUILD piece 8): the number typed on the card, the same number `--ticket` takes, or BLANK = the newest ticket this job has not run
128
+ * (R6: `run-u` finds it with the schedule's own look, src/ticketnext.js, and a list that cannot be looked at says so and asks for a number). Any other job takes none.
129
+ * @param {any} card @param {'plain'|'mcp'|'tickets'} flowType the FINAL flow type of the job (the card's, or the reused spec's)
130
+ * @returns {string|null} the refusal in plain words, or null when the card is fine
131
+ */
132
+ export function ticketBoxProblem(card: any, flowType: "plain" | "mcp" | "tickets"): string | null;
83
133
  /**
84
134
  * Did any JOB box on `card` change from what the origin run prefilled (`origin`)? Whitespace is not compared (a one-line input drops
85
135
  * a text's newlines); an absent thinking tick reads as off.
@@ -165,8 +215,8 @@ export function validateJobCard(card: any, opts?: {
165
215
  * `signPrepare()` are the only ways in.
166
216
  * @param {any} card the validated job card (see {@link validateJobCard})
167
217
  * @param {{env?: Record<string,string|undefined>, sessionsRoot?: string, home?: string, timeoutMs?: number,
168
- * scout?: any, generate?: Function, confirmGenerate?: Function, authorFn?: Function,
169
- * prepareSigningFn?: Function, npmCiFn?: Function, lookFn?: Function|null, fitFn?: Function|null, fetchUrl?: (url: string) => Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>, draftThinking?: "on"|"off", reuse?: {spec: any, workflowKey: string}}} [deps] `scout`..`prepareSigningFn` are
218
+ * scout?: any, generate?: Function, pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carryFrom?: string, carryKind?: string, confirmGenerate?: Function, authorFn?: Function,
219
+ * prepareSigningFn?: Function, npmCiFn?: Function, lookFn?: Function|null, fitFn?: Function|null, destFn?: Function|null, fetchUrl?: (url: string) => Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>, draftThinking?: "on"|"off", reuse?: {spec: any, workflowKey: string}, schedule?: import('../trigger.js').Trigger|null, flow?: {flowType: 'plain'|'mcp'|'tickets', pick: {server: string, tools: string[]}|null}}} [deps] `scout`..`prepareSigningFn` are
170
220
  * TEST SEAMS ONLY — see the note just above where each is read, below. `reuse` (Reuse workflow) is NOT a seam: the
171
221
  * caller (`/api/author/start`) sets it only when the server's own same-job rule held.
172
222
  * @returns {any} the session object
@@ -178,12 +228,18 @@ export function createSession(card: any, deps?: {
178
228
  timeoutMs?: number;
179
229
  scout?: any;
180
230
  generate?: Function;
231
+ pickGenerate?: Function | null;
232
+ ledgerGenerate?: Function | null;
233
+ editGenerate?: Function | null;
234
+ carryFrom?: string;
235
+ carryKind?: string;
181
236
  confirmGenerate?: Function;
182
237
  authorFn?: Function;
183
238
  prepareSigningFn?: Function;
184
239
  npmCiFn?: Function;
185
240
  lookFn?: Function | null;
186
241
  fitFn?: Function | null;
242
+ destFn?: Function | null;
187
243
  fetchUrl?: (url: string) => Promise<{
188
244
  ok: true;
189
245
  text: string;
@@ -197,6 +253,14 @@ export function createSession(card: any, deps?: {
197
253
  spec: any;
198
254
  workflowKey: string;
199
255
  };
256
+ schedule?: import("../trigger.js").Trigger | null;
257
+ flow?: {
258
+ flowType: "plain" | "mcp" | "tickets";
259
+ pick: {
260
+ server: string;
261
+ tools: string[];
262
+ } | null;
263
+ };
200
264
  }): any;
201
265
  /**
202
266
  * THE PROGRESS LIST's one table (hamr 2026-10-04, "one place showing all"): every pipeline step the left Chat panel
@@ -230,6 +294,8 @@ export const CARD_FIELDS: readonly string[];
230
294
  export const JOB_BOXES: readonly string[];
231
295
  /** the refusal for a plain-files rubric job whose Destination is not an absolute folder (ends with the words the session start shows) */
232
296
  export const FILES_DESTINATION_WORDS: "Destination must be the full path of a folder, like /home/me/out \u2014 the finished files are delivered there. Nothing spent.";
297
+ /** the fixed example of a Destination refusal (code-owned; it never guesses a folder from the job's words) */
298
+ export const DESTINATION_HINT: "Type the folder that holds the files the job should change, like src/.";
233
299
  export type StepLine = {
234
300
  id: string;
235
301
  label: string;