fwdloop 0.7.0 → 0.8.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/bin/fwdloop +80 -2
- package/package.json +4 -4
- package/src/authoring.js +313 -0
- package/src/catalogue.json +1 -1
- package/src/declaration.js +16 -2
- package/src/docx.js +33 -4
- package/src/drafter.js +324 -0
- package/src/input-facts.js +45 -0
- package/src/primitives.js +10 -1
- package/src/provider.js +4 -2
- package/src/sign-confirm.js +27 -0
- package/src/signed-text.js +19 -5
- package/src/types.js +1 -0
- package/types/authoring.d.ts +132 -0
- package/types/declaration.d.ts +7 -1
- package/types/docx.d.ts +8 -0
- package/types/drafter.d.ts +164 -0
- package/types/input-facts.d.ts +14 -0
- package/types/primitives.d.ts +4 -0
- package/types/provider.d.ts +3 -1
- package/types/sign-confirm.d.ts +18 -0
- package/types/signed-text.d.ts +14 -0
- package/types/types.d.ts +4 -0
package/types/declaration.d.ts
CHANGED
|
@@ -27,13 +27,19 @@ export function checkShapes(declaration: any): {
|
|
|
27
27
|
* exception.
|
|
28
28
|
*
|
|
29
29
|
* @param {unknown} declaration
|
|
30
|
-
*
|
|
30
|
+
* `wired` (optional Set of verbs): when given, a granted verb outside it is a red
|
|
31
|
+
* by name, even if the catalogue lists it. Omitted = no wired check (existing callers).
|
|
32
|
+
* `verbatimGoals` (optional boolean; M6a amendment 1): when true, a step naming a signed line must carry that line's
|
|
33
|
+
* text as its goal, exactly. Off by default so already-signed flows keep running; draft and sign turn it on.
|
|
34
|
+
* @param {{ arbiter?: unknown, lines?: unknown, catalogue?: unknown, wired?: Set<string>, verbatimGoals?: boolean }} [context]
|
|
31
35
|
* @returns {ValidateDeclarationResult}
|
|
32
36
|
*/
|
|
33
37
|
export function validateDeclaration(declaration: unknown, context?: {
|
|
34
38
|
arbiter?: unknown;
|
|
35
39
|
lines?: unknown;
|
|
36
40
|
catalogue?: unknown;
|
|
41
|
+
wired?: Set<string>;
|
|
42
|
+
verbatimGoals?: boolean;
|
|
37
43
|
}): ValidateDeclarationResult;
|
|
38
44
|
/** @typedef {import('./types.js').Arbiter} Arbiter */
|
|
39
45
|
/** @typedef {import('./types.js').SignedLine} SignedLine */
|
package/types/docx.d.ts
CHANGED
|
@@ -7,4 +7,12 @@ export function readDocxText(path: string): {
|
|
|
7
7
|
ok: false;
|
|
8
8
|
red: string;
|
|
9
9
|
};
|
|
10
|
+
/** @param {string} path @returns {{ok:true,headings:string[]}|{ok:false,red:string}} */
|
|
11
|
+
export function readDocxHeadings(path: string): {
|
|
12
|
+
ok: true;
|
|
13
|
+
headings: string[];
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
red: string;
|
|
17
|
+
};
|
|
10
18
|
export const DOCX_MAX_UNCOMPRESSED_BYTES: number;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/** The forced tool's parameter schema. `menu` = wiredMenu(). */
|
|
2
|
+
export function buildDeclarationSchema(menu: any): {
|
|
3
|
+
type: string;
|
|
4
|
+
properties: {
|
|
5
|
+
steps: {
|
|
6
|
+
type: string;
|
|
7
|
+
minItems: number;
|
|
8
|
+
items: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
primitives: {
|
|
12
|
+
type: string;
|
|
13
|
+
items: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: any;
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
reads: {
|
|
20
|
+
type: string;
|
|
21
|
+
items: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
emits: {
|
|
27
|
+
type: string;
|
|
28
|
+
minLength: number;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
fromLine: {
|
|
32
|
+
type: string[];
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
picks: {
|
|
36
|
+
type: string;
|
|
37
|
+
additionalProperties: {
|
|
38
|
+
type: string;
|
|
39
|
+
items: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
close: {
|
|
46
|
+
type: string;
|
|
47
|
+
properties: {
|
|
48
|
+
class: {
|
|
49
|
+
type: string;
|
|
50
|
+
enum: string[];
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
shape: {
|
|
54
|
+
type: string;
|
|
55
|
+
properties: {};
|
|
56
|
+
additionalProperties: boolean;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
required: string[];
|
|
61
|
+
additionalProperties: boolean;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
required: string[];
|
|
65
|
+
additionalProperties: boolean;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
guardrailClasses: {
|
|
69
|
+
type: string;
|
|
70
|
+
additionalProperties: {
|
|
71
|
+
type: string;
|
|
72
|
+
enum: string[];
|
|
73
|
+
};
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
unjudgeable: {
|
|
77
|
+
type: string;
|
|
78
|
+
additionalProperties: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
refused: {
|
|
84
|
+
type: string;
|
|
85
|
+
items: {
|
|
86
|
+
type: string;
|
|
87
|
+
properties: {
|
|
88
|
+
line: {
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
91
|
+
reason: {
|
|
92
|
+
type: string;
|
|
93
|
+
minLength: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
required: string[];
|
|
97
|
+
additionalProperties: boolean;
|
|
98
|
+
};
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
required: string[];
|
|
103
|
+
additionalProperties: boolean;
|
|
104
|
+
};
|
|
105
|
+
export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
106
|
+
menu: any;
|
|
107
|
+
lines: any;
|
|
108
|
+
arbiter: any;
|
|
109
|
+
factsInfo: any;
|
|
110
|
+
}): string;
|
|
111
|
+
/**
|
|
112
|
+
* A step's goal = its signed line's text, exactly as parseSignedText's `lines` gives it: the words after
|
|
113
|
+
* "N. " (trailing comma kept; on an ask line the mark is stripped, leaving the question). Continuation
|
|
114
|
+
* lines do not exist in the grammar. A step naming no signed line gets a fixed placeholder, never model prose.
|
|
115
|
+
*/
|
|
116
|
+
export function goalForLine(fromLine: any, lines: any): any;
|
|
117
|
+
/**
|
|
118
|
+
* Draft one declaration. `provider`/`rates`/`modelId` may be injected (tests,
|
|
119
|
+
* the batch); otherwise a live provider is built from `slot` (throws on a bad
|
|
120
|
+
* key — the batch preflights first). `budgetUsd` is this draft's hard cap.
|
|
121
|
+
* `makeProviderFn` is a test seam: the live-provider factory (default `makeProvider`).
|
|
122
|
+
*
|
|
123
|
+
* @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
|
|
124
|
+
* costUsd:number|null, modelReturned:string|null, modelId?:string, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[]}>}
|
|
125
|
+
*/
|
|
126
|
+
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, budgetUsd, skills, makeProviderFn, }: {
|
|
127
|
+
proseText: any;
|
|
128
|
+
slot?: string | undefined;
|
|
129
|
+
model: any;
|
|
130
|
+
provider: any;
|
|
131
|
+
rates: any;
|
|
132
|
+
modelId: any;
|
|
133
|
+
budgetUsd?: number | undefined;
|
|
134
|
+
skills?: readonly string[] | undefined;
|
|
135
|
+
makeProviderFn?: typeof makeProvider | undefined;
|
|
136
|
+
}): Promise<{
|
|
137
|
+
ok: boolean;
|
|
138
|
+
declaration: object | null;
|
|
139
|
+
reds: string[];
|
|
140
|
+
rounds: number;
|
|
141
|
+
calls: number;
|
|
142
|
+
spendComplete: boolean;
|
|
143
|
+
costUsd: number | null;
|
|
144
|
+
modelReturned: string | null;
|
|
145
|
+
modelId?: string;
|
|
146
|
+
tokens?: object | null;
|
|
147
|
+
structureRetries: number;
|
|
148
|
+
revisions: number;
|
|
149
|
+
stop: string | null;
|
|
150
|
+
log: object[];
|
|
151
|
+
}>;
|
|
152
|
+
export const MAX_STRUCTURE_RETRIES: 2;
|
|
153
|
+
export const MAX_REVISIONS: 2;
|
|
154
|
+
export const DRAFT_MAX_TOKENS: 16000;
|
|
155
|
+
export const DRAFT_SKILLS: readonly string[];
|
|
156
|
+
export const CLASSES: readonly string[];
|
|
157
|
+
export const DRAFT_PROVIDER_OPTIONS: Readonly<{
|
|
158
|
+
thinking: Readonly<{
|
|
159
|
+
type: "disabled";
|
|
160
|
+
}>;
|
|
161
|
+
timeoutMs: 300000;
|
|
162
|
+
deadlineMs: 240000;
|
|
163
|
+
}>;
|
|
164
|
+
import { makeProvider } from './provider.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Array<{kind?:string, role:string, path:string}>} sources arbiter.sources
|
|
3
|
+
* @returns {{ok:boolean, inputFacts:Record<string,string[]>, info:string[], reds:string[]}}
|
|
4
|
+
*/
|
|
5
|
+
export function readInputFacts(sources: Array<{
|
|
6
|
+
kind?: string;
|
|
7
|
+
role: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}>): {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
inputFacts: Record<string, string[]>;
|
|
12
|
+
info: string[];
|
|
13
|
+
reds: string[];
|
|
14
|
+
};
|
package/types/primitives.d.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* `.csv` belongs to `addressCells`, anything else has no text primitive.
|
|
4
4
|
* Pure and exported so tests can hit the four cases directly (F41 item 3). */
|
|
5
5
|
export function rolePrimitiveFor(frozenPath: any): "read" | "readDocx" | "addressCells" | null;
|
|
6
|
+
/** The wired menu, one place: the catalogue entries whose verb is in
|
|
7
|
+
* WIRED_VERBS (and, when `skills` is given, in a signed skill). Absence,
|
|
8
|
+
* not refusal. Throws only if catalogue.json itself is unreadable. */
|
|
9
|
+
export function wiredMenu(skills: any): import("./types.js").CatalogueEntry[];
|
|
6
10
|
/**
|
|
7
11
|
* Resolve the granted tools for one step's model call. Never throws —
|
|
8
12
|
* a verb absent from the catalogue, or present but unimplemented here, is
|
package/types/provider.d.ts
CHANGED
|
@@ -281,13 +281,15 @@ export function checkKeyPreflight(slotName: string, env?: Record<string, string
|
|
|
281
281
|
* values this project uses.
|
|
282
282
|
*
|
|
283
283
|
* @param {string} slotName
|
|
284
|
-
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number }} [options]
|
|
284
|
+
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number, thinking?: object|null }} [options]
|
|
285
|
+
* `thinking` (bare-agent >=0.49) is sent verbatim as body.thinking; unset/null leaves the body unchanged.
|
|
285
286
|
* @returns {{ provider: any, rates: {in:number, out:number}, modelId: string, suffix: string, slot: string }}
|
|
286
287
|
*/
|
|
287
288
|
export function makeProvider(slotName: string, options?: {
|
|
288
289
|
model?: string;
|
|
289
290
|
timeoutMs?: number;
|
|
290
291
|
deadlineMs?: number;
|
|
292
|
+
thinking?: object | null;
|
|
291
293
|
}): {
|
|
292
294
|
provider: any;
|
|
293
295
|
rates: {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** stdin AND stdout must both be TTYs. */
|
|
2
|
+
export function isInteractive(stdin?: NodeJS.ReadStream & {
|
|
3
|
+
fd: 0;
|
|
4
|
+
}, stdout?: NodeJS.WriteStream & {
|
|
5
|
+
fd: 1;
|
|
6
|
+
}): boolean;
|
|
7
|
+
/** Show the flow name, read one line, compare exactly (trimmed). Empty answer / EOF / mismatch refuse by name. */
|
|
8
|
+
export function confirmTypedName({ name, input, output }: {
|
|
9
|
+
name: any;
|
|
10
|
+
input?: (NodeJS.ReadStream & {
|
|
11
|
+
fd: 0;
|
|
12
|
+
}) | undefined;
|
|
13
|
+
output?: (NodeJS.WriteStream & {
|
|
14
|
+
fd: 1;
|
|
15
|
+
}) | undefined;
|
|
16
|
+
}): Promise<any>;
|
|
17
|
+
export const NEEDS_TTY: "sign needs an interactive terminal \u2014 run it yourself";
|
|
18
|
+
export const NAME_MISMATCH: "typed name does not match";
|
package/types/signed-text.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M6a amendment 1: a NEW flow (draft, sign) may not carry an ask whose wait the human never typed. The
|
|
3
|
+
* parser still fills the legacy 30m default for `ask:` so flows signed before the amendment keep running;
|
|
4
|
+
* this names each ask that relies on it. Returns [] when every ask carries `ask <int><s|m|h>:`.
|
|
5
|
+
*
|
|
6
|
+
* @param {{ asks?: Array<{ line: number, ttlSigned?: boolean }> }} arbiter
|
|
7
|
+
* @returns {string[]}
|
|
8
|
+
*/
|
|
9
|
+
export function unsignedAskTtls(arbiter: {
|
|
10
|
+
asks?: Array<{
|
|
11
|
+
line: number;
|
|
12
|
+
ttlSigned?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
}): string[];
|
|
1
15
|
/**
|
|
2
16
|
* Parse the human's signed text. Never throws — any input that isn't a
|
|
3
17
|
* usable signed text comes back as `{ ok: false, reds }`, never an
|
package/types/types.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export type AskSlot = {
|
|
|
23
23
|
* - the ask's time-to-live in milliseconds.
|
|
24
24
|
*/
|
|
25
25
|
ttlMs: number;
|
|
26
|
+
/**
|
|
27
|
+
* - true when the human typed the wait (`ask <int><s|m|h>:`); false on the legacy `ask:` 30m default, which draft and sign refuse (M6a amendment 1).
|
|
28
|
+
*/
|
|
29
|
+
ttlSigned?: boolean | undefined;
|
|
26
30
|
/**
|
|
27
31
|
* - the words after the mark, trimmed — the
|
|
28
32
|
* human's own question. Nothing reads this yet outside signed-text.js.
|