fwdloop 0.34.0 → 0.35.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.
- package/README.md +14 -0
- package/bin/fwdloop +4 -0
- package/package.json +1 -1
- package/src/action-line.js +100 -0
- package/src/action-stop.js +44 -0
- package/src/ask.js +9 -2
- package/src/authoring.js +24 -11
- package/src/checkblock.js +7 -2
- package/src/checked.js +7 -2
- package/src/checklist.js +0 -2
- package/src/declaration.js +11 -28
- package/src/drafter.js +132 -81
- package/src/jobkey.js +2 -3
- package/src/pageask.js +19 -1
- package/src/pagemap.js +8 -2
- package/src/panel/author.js +62 -35
- package/src/panel/authorcard.js +2 -9
- package/src/panel/data.js +5 -1
- package/src/panel/index.html +59 -36
- package/src/runner.js +87 -41
- package/src/runvalues.js +9 -1
- package/src/setup.js +2 -0
- package/src/sheetbuild.js +4 -7
- package/src/sheetlook.js +1 -1
- package/src/signed-text.js +1 -5
- package/src/whole-job.js +27 -11
- package/types/action-line.d.ts +71 -0
- package/types/action-stop.d.ts +36 -0
- package/types/ask.d.ts +3 -2
- package/types/authoring.d.ts +5 -2
- package/types/checkblock.d.ts +1 -0
- package/types/checked.d.ts +2 -0
- package/types/checklist.d.ts +0 -2
- package/types/drafter.d.ts +9 -2
- package/types/pageask.d.ts +12 -1
- package/types/panel/author.d.ts +1 -1
- package/types/panel/data.d.ts +1 -1
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/sheetbuild.d.ts +1 -3
- package/types/whole-job.d.ts +3 -3
- package/src/added-end.js +0 -60
- package/types/added-end.d.ts +0 -62
package/src/whole-job.js
CHANGED
|
@@ -4,23 +4,39 @@
|
|
|
4
4
|
// `Line <n>: you accepted this at the Ask.`; the last Ask itself and the send line are not sections. The accepted artifact is `{text}`, so the send ships it unchanged.
|
|
5
5
|
// Throws away: nothing of a step's saved output beyond what `renderSentMd` already drops. Third outcomes: a work step with no readable saved output refuses, naming the step.
|
|
6
6
|
import { renderSentMd } from './send.js';
|
|
7
|
-
import { addedLinesOf } from './added-end.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
* The
|
|
11
|
-
* (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
|
|
9
|
+
* The Ask the action reads: the Ask right before the one signed send (M13 am11: the action ships the step before it). -1 = none.
|
|
12
10
|
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
13
|
-
* @returns {number}
|
|
11
|
+
* @returns {number}
|
|
14
12
|
*/
|
|
15
|
-
|
|
13
|
+
function askBeforeSend({ steps, askLines, sendLines }) {
|
|
16
14
|
if (sendLines.size !== 1) return -1;
|
|
17
15
|
const send = [...sendLines.values()][0];
|
|
18
|
-
const lines = steps.map((s) => ({ n: s.fromLine, text: s.goal }));
|
|
19
|
-
if (!addedLinesOf(lines, { sends: [...sendLines.values()], asks: [...askLines.values()] }).has(send.line)) return -1;
|
|
20
16
|
const sendStep = steps.find((s) => s.fromLine === send.line);
|
|
21
17
|
const askIds = (sendStep?.reads ?? []).filter((id) => steps.some((s) => s.emits === id && askLines.has(s.fromLine)));
|
|
22
18
|
if (askIds.length !== 1) return -1;
|
|
23
|
-
|
|
19
|
+
const idx = steps.findIndex((s) => s.emits === askIds[0]);
|
|
20
|
+
return steps[idx + 1] === sendStep ? idx : -1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The emits of every work step (not an Ask) before step `idx`, in job order. */
|
|
24
|
+
function workBefore(steps, idx, askLines) {
|
|
25
|
+
return steps.slice(0, idx).filter((s) => !askLines.has(s.fromLine) && typeof s.emits === 'string').map((s) => /** @type {string} */ (s.emits));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The index of the Ask that shows the whole job: the Ask right before the action, when the plan has it read EVERY work step before it (what `readEveryStep` writes into a plan
|
|
30
|
+
* drafted from M13 am9 on). A plan signed with that Ask reading one step (a job signed before am9) finds -1 and keeps today's behaviour exactly: a stored plan is never reinterpreted.
|
|
31
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
32
|
+
* @returns {number} -1 = none
|
|
33
|
+
*/
|
|
34
|
+
export function wholeJobAskIndex({ steps, askLines, sendLines }) {
|
|
35
|
+
const idx = askBeforeSend({ steps, askLines, sendLines });
|
|
36
|
+
if (idx < 1) return idx === 0 ? -1 : idx;
|
|
37
|
+
const work = workBefore(steps, idx, askLines);
|
|
38
|
+
const reads = steps[idx].reads ?? [];
|
|
39
|
+
return work.length > 0 && reads.length === work.length && work.every((e) => reads.includes(e)) ? idx : -1;
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
/**
|
|
@@ -53,7 +69,7 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
|
|
|
53
69
|
|
|
54
70
|
/**
|
|
55
71
|
* M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
|
|
56
|
-
* redo still re-runs the step just before the Ask; the rest in job order). Only
|
|
72
|
+
* redo still re-runs the step just before the Ask; the rest in job order). Only for the Ask right before the action; any other plan comes back as it was.
|
|
57
73
|
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
58
74
|
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
59
75
|
* @returns {S[]}
|
|
@@ -62,9 +78,9 @@ export function readEveryStep(steps, arbiter) {
|
|
|
62
78
|
if (!Array.isArray(steps) || !steps.every((s) => s && typeof s === 'object')) return steps;
|
|
63
79
|
const askLines = new Map((arbiter?.asks ?? []).map((a) => [a.line, a]));
|
|
64
80
|
const sendLines = new Map((arbiter?.sends ?? []).map((x) => [x.line, x]));
|
|
65
|
-
const idx =
|
|
81
|
+
const idx = askBeforeSend({ steps, askLines, sendLines });
|
|
66
82
|
if (idx < 1) return steps;
|
|
67
|
-
const work = steps
|
|
83
|
+
const work = workBefore(steps, idx, askLines);
|
|
68
84
|
if (work.length === 0) return steps;
|
|
69
85
|
const reads = [work[work.length - 1], ...work.slice(0, -1)];
|
|
70
86
|
return steps.map((s, i) => (i === idx ? { ...s, reads } : s));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The job as the model sees it (F204's listing): `n. text`, ` gN: rule` per `; ` part, then the Destination.
|
|
3
|
+
* @param {{n: number, text: string, guardrail?: string}[]} lines `parseSignedText`'s lines @param {Set<number>} askLines @param {string} destination
|
|
4
|
+
*/
|
|
5
|
+
export function jobListing(lines: {
|
|
6
|
+
n: number;
|
|
7
|
+
text: string;
|
|
8
|
+
guardrail?: string;
|
|
9
|
+
}[], askLines: Set<number>, destination: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Code's check of the recognise answer: the action is the LAST line (and not an Ask) or there is none.
|
|
12
|
+
* @param {any} args the tool call's arguments @param {number} lastLine @param {boolean} lastIsAsk
|
|
13
|
+
* @returns {boolean} true = the last line is the action
|
|
14
|
+
*/
|
|
15
|
+
export function recognisedIsLast(args: any, lastLine: number, lastIsAsk: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Code's check of the suggestion: one plain line, not empty, not long, no control characters. Anything else is no suggestion.
|
|
18
|
+
* @param {any} args @returns {string|null}
|
|
19
|
+
*/
|
|
20
|
+
export function cleanSuggestion(args: any): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The prose file without its (tentative) send line: the one writer of "this job has no write". Only the arbiter's `send at line <n> to ...` line is removed.
|
|
23
|
+
* @param {string} proseText
|
|
24
|
+
*/
|
|
25
|
+
export function withoutSend(proseText: string): string;
|
|
26
|
+
export const RECOGNISE_TOOL: "record_action";
|
|
27
|
+
export const SUGGEST_TOOL: "suggest_action";
|
|
28
|
+
export const MAX_SUGGESTION_CHARS: 300;
|
|
29
|
+
export const RECOGNISE_SYSTEM: "A person wrote a numbered list of steps for a job. The finished result goes to the Destination named below the list.\n\nIs there a last step that writes or sends everything that came before it? Answer with that step's number, or null if there is none.\n\nA step that only reads, makes, lists, checks or asks something is not one. The step does not have to name the Destination: the Destination is only where the result goes.\n\nAnswer by calling the tool record_action exactly once, with the field \"action\" holding one required field: line (the step's number, or null).";
|
|
30
|
+
export const SUGGEST_SYSTEM: "A person wrote a numbered list of steps for a job. The finished result goes to the Destination named below the list. The list has no last step that writes or sends everything that came before it.\n\nYour one task: suggest ONE last step that writes or sends everything that came before it to the Destination.\n\nRules:\n- Write the step as one short plain sentence, in the person's voice, like their other steps. It must say that the result is written or sent to the Destination.\n- Do not repeat or change any existing step. Do not write a step that asks the person a question.\n\nAnswer by calling the tool suggest_action exactly once. The one required field is text (the new step).";
|
|
31
|
+
export namespace RECOGNISE_SCHEMA {
|
|
32
|
+
export let type: string;
|
|
33
|
+
export namespace properties {
|
|
34
|
+
namespace action {
|
|
35
|
+
let type_1: string;
|
|
36
|
+
export { type_1 as type };
|
|
37
|
+
export namespace properties_1 {
|
|
38
|
+
namespace line {
|
|
39
|
+
let type_2: string[];
|
|
40
|
+
export { type_2 as type };
|
|
41
|
+
export let description: string;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export { properties_1 as properties };
|
|
45
|
+
export let required: string[];
|
|
46
|
+
export let additionalProperties: boolean;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
let required_1: string[];
|
|
50
|
+
export { required_1 as required };
|
|
51
|
+
let additionalProperties_1: boolean;
|
|
52
|
+
export { additionalProperties_1 as additionalProperties };
|
|
53
|
+
}
|
|
54
|
+
export namespace SUGGEST_SCHEMA {
|
|
55
|
+
let type_3: string;
|
|
56
|
+
export { type_3 as type };
|
|
57
|
+
export namespace properties_2 {
|
|
58
|
+
namespace text {
|
|
59
|
+
let type_4: string;
|
|
60
|
+
export { type_4 as type };
|
|
61
|
+
let description_1: string;
|
|
62
|
+
export { description_1 as description };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export { properties_2 as properties };
|
|
66
|
+
let required_2: string[];
|
|
67
|
+
export { required_2 as required };
|
|
68
|
+
let additionalProperties_2: boolean;
|
|
69
|
+
export { additionalProperties_2 as additionalProperties };
|
|
70
|
+
}
|
|
71
|
+
export function suggestionQuestion(line: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ acceptedSha: string|null|undefined, outgoing: Record<string, any> }} a `acceptedSha` = the sha256 recorded at the last Ask accepted this run; `outgoing` = the artifact about to go out
|
|
3
|
+
* @returns {{ go: true, outgoingSha: string } | { go: false, question: string, outgoingSha: string }}
|
|
4
|
+
*/
|
|
5
|
+
export function decideAction({ acceptedSha, outgoing }: {
|
|
6
|
+
acceptedSha: string | null | undefined;
|
|
7
|
+
outgoing: Record<string, any>;
|
|
8
|
+
}): {
|
|
9
|
+
go: true;
|
|
10
|
+
outgoingSha: string;
|
|
11
|
+
} | {
|
|
12
|
+
go: false;
|
|
13
|
+
question: string;
|
|
14
|
+
outgoingSha: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The accept to compare against: the sha of the LAST Ask (by step order) before step `i` that was accepted in this run, or null when there is none.
|
|
18
|
+
* @param {{ emits?: string }[]} steps @param {number} i @param {Map<string, string|null>} acceptedAskEmitsThisRun
|
|
19
|
+
*/
|
|
20
|
+
export function lastAcceptedSha(steps: {
|
|
21
|
+
emits?: string;
|
|
22
|
+
}[], i: number, acceptedAskEmitsThisRun: Map<string, string | null>): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* am11a 1/2: the wait of the stop. The LAST Ask's own wait when the job has an Ask before the action; else the card's Ask wait kept in the run's signed values (`arbiter.actionWaitMs`), else 1h.
|
|
25
|
+
* @param {{ fromLine: number }[]} steps @param {number} i @param {Map<number, {ttlMs: number}>} askLines @param {number|undefined} actionWaitMs
|
|
26
|
+
*/
|
|
27
|
+
export function stopWaitMs(steps: {
|
|
28
|
+
fromLine: number;
|
|
29
|
+
}[], i: number, askLines: Map<number, {
|
|
30
|
+
ttlMs: number;
|
|
31
|
+
}>, actionWaitMs: number | undefined): number;
|
|
32
|
+
export const ACTION_STOP_KIND: "action-stop";
|
|
33
|
+
export const STOP_CHANGED: "This changed since you accepted it.";
|
|
34
|
+
export const STOP_UNSEEN: "You have not seen this yet.";
|
|
35
|
+
/** am11a 1: the card's Ask wait is 1h unless the person changes it; this is the default when nothing else is signed. */
|
|
36
|
+
export const DEFAULT_ACTION_WAIT_MS: 3600000;
|
package/types/ask.d.ts
CHANGED
|
@@ -188,10 +188,10 @@ export function answerAsk({ runDir, askId, decision: givenDecision, reason, cloc
|
|
|
188
188
|
* Written once with the rest of the record; an existing archive is never
|
|
189
189
|
* rewritten to add it (the `wx` create refuses).
|
|
190
190
|
*
|
|
191
|
-
* @param {{ runDir: string, askId: string, question: string, askedAt: string, expiresAt: string, evidence: unknown, emits?: string }} opts
|
|
191
|
+
* @param {{ runDir: string, askId: string, question: string, askedAt: string, expiresAt: string, evidence: unknown, emits?: string, kind?: string }} opts
|
|
192
192
|
* @returns {{ ok: true } | { ok: false, red: string }}
|
|
193
193
|
*/
|
|
194
|
-
export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, evidence, emits, }: {
|
|
194
|
+
export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, evidence, emits, kind, }: {
|
|
195
195
|
runDir: string;
|
|
196
196
|
askId: string;
|
|
197
197
|
question: string;
|
|
@@ -199,6 +199,7 @@ export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, e
|
|
|
199
199
|
expiresAt: string;
|
|
200
200
|
evidence: unknown;
|
|
201
201
|
emits?: string;
|
|
202
|
+
kind?: string;
|
|
202
203
|
}): {
|
|
203
204
|
ok: true;
|
|
204
205
|
} | {
|
package/types/authoring.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function scrub(text: any, secrets: any): any;
|
|
|
57
57
|
export function sweepForSecrets(dir: any, secrets: any): number;
|
|
58
58
|
/** Exact signed TTL with its unit, never rounded: 2h / 30m / 20s / 1500ms (the largest unit that divides it exactly). */
|
|
59
59
|
export function fmtTtl(ms: any): string;
|
|
60
|
-
/** Zero-based indexes of the heading lines in a readout's text (split on "\n"): the panel renders those bold. */
|
|
60
|
+
/** Zero-based indexes of the header and heading lines in a readout's text (split on "\n"): the panel renders those bold. */
|
|
61
61
|
export function readoutHeadIndexes(text: any): any[];
|
|
62
62
|
/** Plain-text readout of what the human is about to sign. Pure. */
|
|
63
63
|
export function buildReadout({ declaration, arbiter, lines, name, modelId, costUsd, rounds, spendComplete, root, }: {
|
|
@@ -113,7 +113,7 @@ export function writePlanFiles(dir: string, files: Record<string, string>, opts?
|
|
|
113
113
|
* Test seam: `provider`/`rates`/`modelId` are injected; without them a live provider is built.
|
|
114
114
|
* `onResult({ ok })` (M4d am32): called once, after the spend is booked and just before the result files are written (the CLI gives its monthly hold back there).
|
|
115
115
|
*/
|
|
116
|
-
export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, }: {
|
|
116
|
+
export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, actionMode, }: {
|
|
117
117
|
proseFile: any;
|
|
118
118
|
dir: any;
|
|
119
119
|
root: any;
|
|
@@ -141,6 +141,7 @@ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThink
|
|
|
141
141
|
mcpServer?: string | undefined;
|
|
142
142
|
mcpPick?: any;
|
|
143
143
|
mcpServers?: string[] | undefined;
|
|
144
|
+
actionMode?: "check" | "known" | null | undefined;
|
|
144
145
|
}): Promise<{
|
|
145
146
|
ok: boolean;
|
|
146
147
|
wrote: boolean;
|
|
@@ -272,3 +273,5 @@ export function SIGN_LINE(dir: any, hash: any): string;
|
|
|
272
273
|
export const OPEN_QUESTION_SAY: "A question the plan raised is still open. Answer it in the panel (fwdloop panel), then sign the plan it drafts after your answers. Nothing was signed.";
|
|
273
274
|
export const ANSWERED_QUESTION_SAY: "This plan raised questions, and your answers went into a newer plan. Sign the newest plan, not this one. Nothing was signed.";
|
|
274
275
|
export function costText(n: any, spendComplete?: boolean): string;
|
|
276
|
+
/** The readout's top line prefix: ONE owner for the text `buildReadout` writes and the bold `readoutHeadIndexes` finds. */
|
|
277
|
+
export const READOUT_HEADER_PREFIX: "DRAFT READOUT \u2014 NOT SIGNED \u2014 flow ";
|
package/types/checkblock.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export const REASON: Readonly<{
|
|
|
34
34
|
manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
|
|
35
35
|
oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
|
|
36
36
|
countNeedsFact: "a result count needs a fact to count; this line has none";
|
|
37
|
+
countNeedsSuggested: "a result count needs a fact to count; add the suggested fact on this line to count its results";
|
|
37
38
|
lookNoWords: "the page does not hold the words of the look's fact for this rule";
|
|
38
39
|
afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
|
|
39
40
|
noPick: "No check was picked for it, so you judge it at Accept.";
|
package/types/checked.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The words for a step with no machine check of its content: the ONE owner (the card and the draft readout both call it). @param {boolean} hasAsk the job has a signed ask @param {boolean} afterLastAsk the step comes after the last ask */
|
|
2
|
+
export function hitlWords(hasAsk: boolean, afterLastAsk: boolean): "No machine check of the content; you check it after you accept." | "No machine check of the content: you check it at the ask." | "No machine check of the content; the machine checks only that the step happened.";
|
|
1
3
|
/**
|
|
2
4
|
* One entry per step, in plan order: the plain sentences for what its typed close checks.
|
|
3
5
|
* M10b piece 4: with `lines` (the signed job lines) a step that reads a sheet also carries `sheet`, its line's block (src/sheetblock.js `sheetLineBlocks`: guardrails,
|
package/types/checklist.d.ts
CHANGED
|
@@ -20,8 +20,6 @@ export function ledgerUserText(jobLines: {
|
|
|
20
20
|
export const MAX_BANG: 3;
|
|
21
21
|
/** the reason a check on a version or a date goes under Not checked: it is true only for the input as it is today */
|
|
22
22
|
export const WEEK_ONLY_WORDS: "It names a version or a date from the input, true only for the input as it is today, so you judge it at Accept.";
|
|
23
|
-
/** the label of the list call, as the drafting book and the draft log see it */
|
|
24
|
-
export const LEDGER_LABEL: "ledger-suggest";
|
|
25
23
|
export const LEDGER_TOOL: "suggest_extra_checks";
|
|
26
24
|
/** the reason the empty list is logged with */
|
|
27
25
|
export const EMPTY_LIST_WORDS: "empty list: nothing to check";
|
package/types/drafter.d.ts
CHANGED
|
@@ -310,12 +310,12 @@ export function goalForLine(fromLine: any, lines: any): any;
|
|
|
310
310
|
*
|
|
311
311
|
* @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
|
|
312
312
|
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
|
|
313
|
-
* questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
|
|
313
|
+
* questions?:{line:number, question:string}[], proseText?:string, action?:{line:number, by?:'agent'|'you', dropped?:true}|null, droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
|
|
314
314
|
* checkCard?:ReturnType<typeof cardOfBlock>, notCheckedBy?:Record<string,'you'|'agent'|'default'>, look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
|
|
315
315
|
* `learnHints` (M8 item 5a): the earlier runs' notes block (src/learnstore.js hintsForRun), appended to the drafter's system prompt; null = nothing.
|
|
316
316
|
* `look` / `pageLooks` (M10 item 3) are there when the job signs a web page: the kept facts (with their `reading`, the input a later ask reads), every drop, and per page its address, sha256 and the AI's map. Each drop is also a line in `notChecked`.
|
|
317
317
|
*/
|
|
318
|
-
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, columnAnswers, carriedColumns, onColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, onSheetDropped, onChoices, onPickRecord, learnHints, mcpServers, flowType, mcp, }: {
|
|
318
|
+
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, columnAnswers, carriedColumns, onColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, onSheetDropped, onChoices, onPickRecord, learnHints, mcpServers, flowType, mcp, actionMode, }: {
|
|
319
319
|
proseText: any;
|
|
320
320
|
slot: any;
|
|
321
321
|
model: any;
|
|
@@ -364,6 +364,7 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
364
364
|
mcpServers?: string[] | undefined;
|
|
365
365
|
flowType?: "tickets" | "mcp" | "plain" | undefined;
|
|
366
366
|
mcp?: any;
|
|
367
|
+
actionMode?: "check" | "known" | null | undefined;
|
|
367
368
|
}): Promise<{
|
|
368
369
|
ok: boolean;
|
|
369
370
|
declaration: object | null;
|
|
@@ -384,6 +385,12 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
384
385
|
line: number;
|
|
385
386
|
question: string;
|
|
386
387
|
}[];
|
|
388
|
+
proseText?: string;
|
|
389
|
+
action?: {
|
|
390
|
+
line: number;
|
|
391
|
+
by?: "agent" | "you";
|
|
392
|
+
dropped?: true;
|
|
393
|
+
} | null;
|
|
387
394
|
droppedQuestions?: object[];
|
|
388
395
|
notChecked?: string[];
|
|
389
396
|
thinking?: {
|
package/types/pageask.d.ts
CHANGED
|
@@ -27,6 +27,15 @@ export function tooManyAsksText(asks: {
|
|
|
27
27
|
ruleText: string;
|
|
28
28
|
reading?: string;
|
|
29
29
|
}[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* M17 am8: what a button-picked answer decided, as the one Audit line; null when the row has no pick (a box-answered drafter question, an older record).
|
|
32
|
+
* @param {{choice?: string, words?: string}} h
|
|
33
|
+
* @returns {string|null}
|
|
34
|
+
*/
|
|
35
|
+
export function decidedWords(h: {
|
|
36
|
+
choice?: string;
|
|
37
|
+
words?: string;
|
|
38
|
+
}): string | null;
|
|
30
39
|
/**
|
|
31
40
|
* What a typed answer to a look ask does, the ONE place that decides (the panel's answer route, the setup record and the Result tab all read it).
|
|
32
41
|
* `agree` / `yes` to a reading ask takes the code's reading; `drop it` to a can't-check ask leaves the rule Not checked (no `~` line); anything else is the
|
|
@@ -34,7 +43,7 @@ export function tooManyAsksText(asks: {
|
|
|
34
43
|
* M10 am16: a shape guardrail's ask (`ask: 'check'` proposes a check, `'no-check'` found none) takes the same words: `agree` takes the proposal (and the check it
|
|
35
44
|
* carries, `check`), `drop it` leaves the rule Not checked (either kind), anything else is the person's own words (`own`: a `~` rule on the line, no check).
|
|
36
45
|
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed @param {'agree'|'drop'|'rule'} [choice] M10 am29: the button used; absent = today's words reading (CLI, old files)
|
|
37
|
-
* @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
46
|
+
* @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean, action?: 'known', actionLine?: string}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
38
47
|
*/
|
|
39
48
|
export function ruleOfAnswer(q: {
|
|
40
49
|
source?: string;
|
|
@@ -46,6 +55,8 @@ export function ruleOfAnswer(q: {
|
|
|
46
55
|
left: boolean;
|
|
47
56
|
check?: Record<string, any>;
|
|
48
57
|
own?: boolean;
|
|
58
|
+
action?: "known";
|
|
59
|
+
actionLine?: string;
|
|
49
60
|
};
|
|
50
61
|
/** the most asks before drafting; more than this is a job to rewrite, not a questionnaire (am1) */
|
|
51
62
|
export const MAX_LOOK_ASKS: 3;
|
package/types/panel/author.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export function createAuthor(opts: {
|
|
|
44
44
|
/** `GET /api/author/run-again`, its flow entry carrying the trigger card like the list's entries do. @param {string|null} flow @param {string|null} runId */
|
|
45
45
|
runAgain(flow: string | null, runId: string | null): any;
|
|
46
46
|
/** M4b am4 item 7: how many drafts are open for `whoami` and the launcher's stop warning: the card `live()` returns (the newest draft not abandoned or signed), 0 or 1. */
|
|
47
|
-
openDrafts():
|
|
47
|
+
openDrafts(): 1 | 0;
|
|
48
48
|
run: (body: any) => {
|
|
49
49
|
status: any;
|
|
50
50
|
body: any;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -757,7 +757,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
|
|
|
757
757
|
name: string;
|
|
758
758
|
title: string | null;
|
|
759
759
|
number: number | null;
|
|
760
|
-
bucket: "
|
|
760
|
+
bucket: "skip" | "done" | "stop" | "wait";
|
|
761
761
|
glyph: string;
|
|
762
762
|
at: number;
|
|
763
763
|
ex: "r" | "n" | "g" | "q";
|
package/types/panel/jobgrid.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export function buildJobGrid({ runs, anyway, now }: {
|
|
|
69
69
|
name: string;
|
|
70
70
|
title: string | null;
|
|
71
71
|
number: number | null;
|
|
72
|
-
bucket: "
|
|
72
|
+
bucket: "skip" | "done" | "stop" | "wait";
|
|
73
73
|
glyph: string;
|
|
74
74
|
at: number;
|
|
75
75
|
ex: "r" | "n" | "g" | "q";
|
package/types/sheetbuild.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export function buildSheetLine({ line, tables, suggestions }: {
|
|
|
38
38
|
* The declaration with every green sheet step's `close.sheet` REWRITTEN by code from what the AI suggested there (`buildSheetLine`). A step with no suggestion is left alone; a step none of whose
|
|
39
39
|
* suggestions can be built loses `close.sheet` (its rules are Not checked with their reasons). Pure over the declaration it is given (a copy is returned).
|
|
40
40
|
* @param {{declaration: any, lines: {n: number, text?: string, rules?: string[], guardrail?: string, rule?: string}[], tables: Record<string, {header: string[], rows: any[]}>}} o
|
|
41
|
-
* @returns {Promise<{declaration: any, notChecked: Record<string, string>, refused: {line: number, helper: string, why: string}[], unbuilt: {line: number, lost: string[]}[]}>} `unbuilt`: the green sheet steps left with no check, each with its rules as Not-checked lines. `notChecked`: `line N: "rule"` -> the refusal that named it (or `
|
|
41
|
+
* @returns {Promise<{declaration: any, notChecked: Record<string, string>, refused: {line: number, helper: string, why: string}[], unbuilt: {line: number, lost: string[]}[]}>} `unbuilt`: the green sheet steps left with no check, each with its rules as Not-checked lines. `notChecked`: `line N: "rule"` -> the refusal that named it (or `NO_VALUE_WHY`), for each rule of a
|
|
42
42
|
* rewritten line that no check holds
|
|
43
43
|
*/
|
|
44
44
|
export function buildSheetChecks({ declaration, lines, tables }: {
|
|
@@ -69,8 +69,6 @@ export function buildSheetChecks({ declaration, lines, tables }: {
|
|
|
69
69
|
}>;
|
|
70
70
|
/** the fields of a suggestion code does not read: it names every check itself */
|
|
71
71
|
export const SUGGESTION_DROPPED: readonly string[];
|
|
72
|
-
/** M17 am7 item 2: the words of a rule no check holds and nothing refused: the one no-pick sentence (src/ticketrows.js), not a third copy */
|
|
73
|
-
export const NO_SUGGESTION: "No check was picked for it, so you judge it at the Ask.";
|
|
74
72
|
export type Placed = {
|
|
75
73
|
check: any;
|
|
76
74
|
covers: number[];
|
package/types/whole-job.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The index of the Ask that shows the whole job: the Ask
|
|
3
|
-
*
|
|
2
|
+
* The index of the Ask that shows the whole job: the Ask right before the action, when the plan has it read EVERY work step before it (what `readEveryStep` writes into a plan
|
|
3
|
+
* drafted from M13 am9 on). A plan signed with that Ask reading one step (a job signed before am9) finds -1 and keeps today's behaviour exactly: a stored plan is never reinterpreted.
|
|
4
4
|
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
5
5
|
* @returns {number} -1 = none
|
|
6
6
|
*/
|
|
@@ -49,7 +49,7 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
|
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
51
|
* M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
|
|
52
|
-
* redo still re-runs the step just before the Ask; the rest in job order). Only
|
|
52
|
+
* redo still re-runs the step just before the Ask; the rest in job order). Only for the Ask right before the action; any other plan comes back as it was.
|
|
53
53
|
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
54
54
|
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
55
55
|
* @returns {S[]}
|
package/src/added-end.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// M13 am8: the end of a job is added by code, never typed. ONE writer of the added lines (`addEnd`), ONE reader that finds them again in a plan (`addedLinesOf`).
|
|
2
|
-
// Given the card's parsed job steps and its Destination: no Destination -> nothing added; the last line not an Ask -> `ask <wait>: check the result with me`
|
|
3
|
-
// then `write it out`; the last line an Ask -> only `write it out`. The send is always the added `write it out`. The wait is the card's Ask wait (the
|
|
4
|
-
// caller's `jobFileLines` writes it out, as it does for any ask line with no wait of its own).
|
|
5
|
-
// Throws away: nothing. Third outcomes: an empty job adds nothing (the card refuses an empty job before this runs).
|
|
6
|
-
|
|
7
|
-
export const ADDED_ASK_QUESTION = 'check the result with me';
|
|
8
|
-
export const ADDED_WRITE = 'write it out';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
|
|
12
|
-
* @param {string} destination the card's Destination ('' = none)
|
|
13
|
-
* @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
|
|
14
|
-
*/
|
|
15
|
-
export function addEnd(steps, destination) {
|
|
16
|
-
if (destination === '' || steps.length === 0) return { steps, added: [] };
|
|
17
|
-
const out = [...steps];
|
|
18
|
-
/** @type {number[]} */
|
|
19
|
-
const added = [];
|
|
20
|
-
if (out[out.length - 1].ask === null) {
|
|
21
|
-
const n = out.length + 1;
|
|
22
|
-
out.push({ n, text: `ask: ${ADDED_ASK_QUESTION}`, ask: { wait: null, question: ADDED_ASK_QUESTION }, guardrails: [] });
|
|
23
|
-
added.push(n);
|
|
24
|
-
}
|
|
25
|
-
const n = out.length + 1;
|
|
26
|
-
out.push({ n, text: ADDED_WRITE, ask: null, guardrails: [] });
|
|
27
|
-
added.push(n);
|
|
28
|
-
return { steps: out, added };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
|
|
33
|
-
* when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
|
|
34
|
-
* @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
35
|
-
* @returns {Set<number>}
|
|
36
|
-
*/
|
|
37
|
-
export function addedLinesOf(lines, arbiter) {
|
|
38
|
-
const found = new Set();
|
|
39
|
-
const send = (arbiter?.sends ?? [])[0];
|
|
40
|
-
if (!send) return found;
|
|
41
|
-
const textOf = (/** @type {number} */ n) => lines.find((l) => l.n === n)?.text;
|
|
42
|
-
if (textOf(send.line) !== ADDED_WRITE) return found;
|
|
43
|
-
found.add(send.line);
|
|
44
|
-
if (textOf(send.line - 1) === ADDED_ASK_QUESTION && (arbiter.asks ?? []).some((a) => a.line === send.line - 1)) found.add(send.line - 1);
|
|
45
|
-
return found;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
|
|
50
|
-
* the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
|
|
51
|
-
* @template {{ n: number, text: string }} L
|
|
52
|
-
* @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
53
|
-
* @returns {L[]}
|
|
54
|
-
*/
|
|
55
|
-
export function typedLinesOf(lines, arbiter) {
|
|
56
|
-
const sends = arbiter?.sends ?? [];
|
|
57
|
-
const lastSend = sends.length === 1 && sends[0].line === lines.length ? sends[0].line : null;
|
|
58
|
-
const added = addedLinesOf(lines, arbiter);
|
|
59
|
-
return lines.filter((l) => l.n !== lastSend && !added.has(l.n));
|
|
60
|
-
}
|
package/types/added-end.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
|
|
3
|
-
* @param {string} destination the card's Destination ('' = none)
|
|
4
|
-
* @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
|
|
5
|
-
*/
|
|
6
|
-
export function addEnd(steps: {
|
|
7
|
-
n: number;
|
|
8
|
-
text: string;
|
|
9
|
-
ask: null | {
|
|
10
|
-
wait: string | null;
|
|
11
|
-
question: string;
|
|
12
|
-
};
|
|
13
|
-
guardrails: string[];
|
|
14
|
-
}[], destination: string): {
|
|
15
|
-
steps: {
|
|
16
|
-
n: number;
|
|
17
|
-
text: string;
|
|
18
|
-
ask: null | {
|
|
19
|
-
wait: string | null;
|
|
20
|
-
question: string;
|
|
21
|
-
};
|
|
22
|
-
guardrails: string[];
|
|
23
|
-
}[];
|
|
24
|
-
added: number[];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
|
|
28
|
-
* when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
|
|
29
|
-
* @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
30
|
-
* @returns {Set<number>}
|
|
31
|
-
*/
|
|
32
|
-
export function addedLinesOf(lines: {
|
|
33
|
-
n: number;
|
|
34
|
-
text: string;
|
|
35
|
-
}[], arbiter: {
|
|
36
|
-
sends?: {
|
|
37
|
-
line: number;
|
|
38
|
-
}[];
|
|
39
|
-
asks?: {
|
|
40
|
-
line: number;
|
|
41
|
-
}[];
|
|
42
|
-
}): Set<number>;
|
|
43
|
-
/**
|
|
44
|
-
* The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
|
|
45
|
-
* the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
|
|
46
|
-
* @template {{ n: number, text: string }} L
|
|
47
|
-
* @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
48
|
-
* @returns {L[]}
|
|
49
|
-
*/
|
|
50
|
-
export function typedLinesOf<L extends {
|
|
51
|
-
n: number;
|
|
52
|
-
text: string;
|
|
53
|
-
}>(lines: L[], arbiter: {
|
|
54
|
-
sends?: {
|
|
55
|
-
line: number;
|
|
56
|
-
}[];
|
|
57
|
-
asks?: {
|
|
58
|
-
line: number;
|
|
59
|
-
}[];
|
|
60
|
-
}): L[];
|
|
61
|
-
export const ADDED_ASK_QUESTION: "check the result with me";
|
|
62
|
-
export const ADDED_WRITE: "write it out";
|