@parcha/agentrun-dsl 0.1.0-beta.1
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +67 -0
- package/dist/authoring.d.ts +72 -0
- package/dist/authoring.js +138 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +135 -0
- package/dist/code-exec.d.ts +4 -0
- package/dist/code-exec.js +45 -0
- package/dist/demo.d.ts +54 -0
- package/dist/demo.js +80 -0
- package/dist/dry-run.d.ts +19 -0
- package/dist/dry-run.js +191 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +8 -0
- package/dist/inspection.d.ts +35 -0
- package/dist/inspection.js +107 -0
- package/dist/predicates.d.ts +34 -0
- package/dist/predicates.js +43 -0
- package/dist/schema-references.d.ts +3 -0
- package/dist/schema-references.js +66 -0
- package/dist/system-one.d.ts +78 -0
- package/dist/system-one.js +193 -0
- package/dist/workflow-shape.d.ts +1 -0
- package/dist/workflow-shape.js +181 -0
- package/dist/workflow.d.ts +541 -0
- package/dist/workflow.js +2294 -0
- package/dist/zod-json-contract.d.ts +1 -0
- package/dist/zod-json-contract.js +106 -0
- package/package.json +52 -0
- package/schema/workflow.schema.json +1850 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { type AcceptPredicate } from "./predicates.js";
|
|
2
|
+
import { type SystemOneAnswer, type SystemOneQuestion } from "./system-one.js";
|
|
3
|
+
export { resolveSchemaForWorkflow } from "./schema-references.js";
|
|
4
|
+
/** The model tier a node asks for: `fast` (the cheap tier), `strong` (the host's stronger model),
|
|
5
|
+
* or the kind's default. A router that sends the few thin cases to `strong` buys depth only where the
|
|
6
|
+
* decision is on the edge. */
|
|
7
|
+
export type ModelTier = "fast" | "default" | "strong";
|
|
8
|
+
export type VerifyClause = {
|
|
9
|
+
out: string;
|
|
10
|
+
state?: Record<string, unknown>;
|
|
11
|
+
maxDrives?: number;
|
|
12
|
+
override?: {
|
|
13
|
+
below: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type AskPredicate = {
|
|
17
|
+
predicate: "ask";
|
|
18
|
+
instructions: string;
|
|
19
|
+
state?: Record<string, unknown>;
|
|
20
|
+
criteria?: {
|
|
21
|
+
true?: string;
|
|
22
|
+
false?: string;
|
|
23
|
+
};
|
|
24
|
+
gte?: number;
|
|
25
|
+
};
|
|
26
|
+
export type MechanicalPredicate = AcceptPredicate;
|
|
27
|
+
export type Predicate = MechanicalPredicate | AskPredicate;
|
|
28
|
+
export type WorkflowEffort = "minimal" | "low" | "medium" | "high";
|
|
29
|
+
/** The author's thinking dial. There is deliberately no "off": thinking is never off. */
|
|
30
|
+
export type WorkflowThinking = "low" | "medium" | "high";
|
|
31
|
+
export type WorkflowNode = {
|
|
32
|
+
node: "chain";
|
|
33
|
+
steps: WorkflowNode[];
|
|
34
|
+
} | {
|
|
35
|
+
node: "code";
|
|
36
|
+
label: string;
|
|
37
|
+
code: string;
|
|
38
|
+
as?: string;
|
|
39
|
+
} | {
|
|
40
|
+
node: "agent";
|
|
41
|
+
label: string;
|
|
42
|
+
instructions: string;
|
|
43
|
+
state?: Record<string, unknown>;
|
|
44
|
+
sopSection?: string | string[];
|
|
45
|
+
out: string;
|
|
46
|
+
as?: string;
|
|
47
|
+
requires?: string[];
|
|
48
|
+
tools?: string[];
|
|
49
|
+
effort?: WorkflowEffort;
|
|
50
|
+
thinking?: WorkflowThinking;
|
|
51
|
+
verify?: VerifyClause;
|
|
52
|
+
tier?: ModelTier;
|
|
53
|
+
} | {
|
|
54
|
+
node: "decide";
|
|
55
|
+
label: string;
|
|
56
|
+
instructions: string;
|
|
57
|
+
state?: Record<string, unknown>;
|
|
58
|
+
sopSection?: string | string[];
|
|
59
|
+
out: string;
|
|
60
|
+
as?: string;
|
|
61
|
+
requires?: string[];
|
|
62
|
+
tools?: string[];
|
|
63
|
+
effort?: WorkflowEffort;
|
|
64
|
+
thinking?: WorkflowThinking;
|
|
65
|
+
verify?: VerifyClause;
|
|
66
|
+
tier?: ModelTier;
|
|
67
|
+
} | {
|
|
68
|
+
node: "extract";
|
|
69
|
+
label: string;
|
|
70
|
+
instructions: string;
|
|
71
|
+
state?: Record<string, unknown>;
|
|
72
|
+
sopSection?: string | string[];
|
|
73
|
+
out: string;
|
|
74
|
+
as?: string;
|
|
75
|
+
requires?: string[];
|
|
76
|
+
tools?: string[];
|
|
77
|
+
effort?: WorkflowEffort;
|
|
78
|
+
thinking?: WorkflowThinking;
|
|
79
|
+
verify?: VerifyClause;
|
|
80
|
+
tier?: ModelTier;
|
|
81
|
+
} | {
|
|
82
|
+
node: "report";
|
|
83
|
+
label: string;
|
|
84
|
+
instructions: string;
|
|
85
|
+
state?: Record<string, unknown>;
|
|
86
|
+
sopSection?: string | string[];
|
|
87
|
+
requires?: string[];
|
|
88
|
+
tools?: string[];
|
|
89
|
+
effort?: WorkflowEffort;
|
|
90
|
+
thinking?: WorkflowThinking;
|
|
91
|
+
} | ArtifactNode | {
|
|
92
|
+
node: "map";
|
|
93
|
+
label: string;
|
|
94
|
+
itemsPath: string;
|
|
95
|
+
body: WorkflowNode;
|
|
96
|
+
as: string;
|
|
97
|
+
resultPath?: string;
|
|
98
|
+
maxConcurrency?: number;
|
|
99
|
+
} | {
|
|
100
|
+
node: "parallel";
|
|
101
|
+
label: string;
|
|
102
|
+
branches: WorkflowNode[];
|
|
103
|
+
} | {
|
|
104
|
+
node: "loop";
|
|
105
|
+
label: string;
|
|
106
|
+
body: WorkflowNode;
|
|
107
|
+
until: Predicate;
|
|
108
|
+
maxIters: number;
|
|
109
|
+
} | {
|
|
110
|
+
node: "escalate";
|
|
111
|
+
label: string;
|
|
112
|
+
when: Predicate;
|
|
113
|
+
kind: string;
|
|
114
|
+
stage: string;
|
|
115
|
+
summary: string;
|
|
116
|
+
} | JudgeNode | PickNode | SiftNode | RouteNode | CallNode | WorkflowInvocation;
|
|
117
|
+
/** A judgment as typed questions. `state` is what the questions see, interpolated by value from the
|
|
118
|
+
* workflow state (a whole-string placeholder keeps its type); `out` is a flat schema of enums,
|
|
119
|
+
* booleans and level-integers — the question set. The schema-valid value lands at `as`, the raw
|
|
120
|
+
* answers with their confidences at `<as>$answers`. No tools, no turns, one request. */
|
|
121
|
+
export type JudgeNode = {
|
|
122
|
+
node: "judge";
|
|
123
|
+
label: string;
|
|
124
|
+
state: Record<string, unknown>;
|
|
125
|
+
out: string;
|
|
126
|
+
as: string;
|
|
127
|
+
requires?: string[];
|
|
128
|
+
};
|
|
129
|
+
/** One choice whose options are the items of a list. `describe` renders each item as its option
|
|
130
|
+
* text (`{item.field}`); `allowNone` adds a none-of-these option. The result at `as` is
|
|
131
|
+
* {index, item, none, option}; confidence is `<as>$answers.confidence.pick` and the
|
|
132
|
+
* distribution is `<as>$answers.answers.pick.probabilities`. */
|
|
133
|
+
export type PickNode = {
|
|
134
|
+
node: "pick";
|
|
135
|
+
label: string;
|
|
136
|
+
itemsPath: string;
|
|
137
|
+
describe: string;
|
|
138
|
+
instructions: string;
|
|
139
|
+
state?: Record<string, unknown>;
|
|
140
|
+
allowNone?: boolean;
|
|
141
|
+
as: string;
|
|
142
|
+
requires?: string[];
|
|
143
|
+
};
|
|
144
|
+
/** The same question set (`out`, a judge schema) asked of every item of a list in ONE request: item i's
|
|
145
|
+
* questions are prefixed `i.`; every answer lands in `as.answers[i]` and `as.values[i]`. `keep`
|
|
146
|
+
* filters: items whose answer at `keep.path` (a question id, or `<id>.confidence`) is at least
|
|
147
|
+
* `keep.gte` (a boolean question keeps on yes) land in `as.items`, in the original order. */
|
|
148
|
+
export type SiftNode = {
|
|
149
|
+
node: "sift";
|
|
150
|
+
label: string;
|
|
151
|
+
itemsPath: string;
|
|
152
|
+
describe?: string;
|
|
153
|
+
state?: Record<string, unknown>;
|
|
154
|
+
out: string;
|
|
155
|
+
as: string;
|
|
156
|
+
keep?: {
|
|
157
|
+
path: string;
|
|
158
|
+
gte?: number;
|
|
159
|
+
};
|
|
160
|
+
requires?: string[];
|
|
161
|
+
};
|
|
162
|
+
/** A choice among subgraphs. The options are the branch names, their criteria the branch
|
|
163
|
+
* descriptions; the chosen branch runs on the state. `as` (optional) records the choice and its
|
|
164
|
+
* distribution; `unsure` names the branch taken when confidence is below `gte`. */
|
|
165
|
+
export type RouteNode = {
|
|
166
|
+
node: "route";
|
|
167
|
+
label: string;
|
|
168
|
+
state: Record<string, unknown>;
|
|
169
|
+
instructions: string;
|
|
170
|
+
branches: {
|
|
171
|
+
[branch: string]: {
|
|
172
|
+
criteria?: string;
|
|
173
|
+
body: WorkflowNode;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
unsure?: {
|
|
177
|
+
branch: string;
|
|
178
|
+
gte: number;
|
|
179
|
+
};
|
|
180
|
+
as?: string;
|
|
181
|
+
requires?: string[];
|
|
182
|
+
};
|
|
183
|
+
/** A child workflow invoked as one step of its parent. The child is embedded whole, so the parent
|
|
184
|
+
* digest covers every child byte; `input` is interpolated by value and is the child's ENTIRE initial
|
|
185
|
+
* state (no parent state leaks in); the child's validated output is checked against the parent's
|
|
186
|
+
* `out` schema and lands at `as`. The parent owns the terminal: a child never renders a report or
|
|
187
|
+
* delivers an artifact. Children may otherwise compose all workflow primitives. */
|
|
188
|
+
export type WorkflowInvocation = {
|
|
189
|
+
node: "workflow";
|
|
190
|
+
label: string;
|
|
191
|
+
workflow: Workflow;
|
|
192
|
+
input: Record<string, unknown>;
|
|
193
|
+
out: string;
|
|
194
|
+
as: string;
|
|
195
|
+
};
|
|
196
|
+
/** `exit` is a shell command that ended with a non-zero status: retried only when the author
|
|
197
|
+
* declared retry, since re-running a command is the author's call. */
|
|
198
|
+
export type CallRetryClass = "timeout" | "http_5xx" | "http_429" | "connection" | "exit";
|
|
199
|
+
/** The workflow's terminal deliverable. Types "markdown" and "report" use the report
|
|
200
|
+
* writer; other non-empty types name a workspace file produced by an earlier call.
|
|
201
|
+
* File existence and delivery are the host's responsibility. */
|
|
202
|
+
export type ArtifactNode = {
|
|
203
|
+
node: "artifact";
|
|
204
|
+
label: string;
|
|
205
|
+
/** Host-defined file type, or "markdown"/"report" for prose. */
|
|
206
|
+
type: string;
|
|
207
|
+
/** File types: the workspace-relative primary file, produced by an earlier call. */
|
|
208
|
+
path?: string;
|
|
209
|
+
/** Prose types: the report writer's fields. */
|
|
210
|
+
instructions?: string;
|
|
211
|
+
state?: Record<string, unknown>;
|
|
212
|
+
sopSection?: string | string[];
|
|
213
|
+
tools?: string[];
|
|
214
|
+
effort?: WorkflowEffort;
|
|
215
|
+
thinking?: WorkflowThinking;
|
|
216
|
+
requires?: string[];
|
|
217
|
+
};
|
|
218
|
+
export type ArtifactState = {
|
|
219
|
+
path: string;
|
|
220
|
+
filename: string;
|
|
221
|
+
type: string;
|
|
222
|
+
};
|
|
223
|
+
export declare function artifactNodeIsProse(node: ArtifactNode): boolean;
|
|
224
|
+
export declare function desugarWorkflow(workflow: Workflow): Workflow;
|
|
225
|
+
export declare function terminalArtifactType(workflow: Workflow): string | null;
|
|
226
|
+
/** A predicate a `call` evaluates against ITS OWN RESULT: paths are result-relative. */
|
|
227
|
+
export type CallPredicate = MechanicalPredicate;
|
|
228
|
+
export type PollClause = {
|
|
229
|
+
until: CallPredicate;
|
|
230
|
+
fail_when?: CallPredicate;
|
|
231
|
+
interval_s: number;
|
|
232
|
+
deadline_s: number;
|
|
233
|
+
};
|
|
234
|
+
export type CallNode = {
|
|
235
|
+
node: "call";
|
|
236
|
+
label: string;
|
|
237
|
+
via: "tool" | "executor" | "shell";
|
|
238
|
+
/** `via: tool` — the host tool address. */
|
|
239
|
+
tool?: string;
|
|
240
|
+
/** `via: tool` — typed args; `{dot.path}` interpolation by value. */
|
|
241
|
+
args?: Record<string, unknown>;
|
|
242
|
+
/** `via: executor` — the body run on the executor; must `return` JSON. */
|
|
243
|
+
code?: string;
|
|
244
|
+
/** `via: executor` — the JSON value bound to `input` inside the body; interpolated. */
|
|
245
|
+
input?: Record<string, unknown>;
|
|
246
|
+
/** `via: shell` — the command, taken LITERALLY (it is code; `{…}` in it is the script's own
|
|
247
|
+
* syntax). Values reach it through `env`. */
|
|
248
|
+
command?: string;
|
|
249
|
+
/** `via: shell` — environment variables for the command, interpolated by value and passed to
|
|
250
|
+
* the process directly (never through shell quoting): the way a long prompt or a JSON record
|
|
251
|
+
* reaches a script. */
|
|
252
|
+
env?: {
|
|
253
|
+
[name: string]: string;
|
|
254
|
+
};
|
|
255
|
+
/** Reserved. Only `sandbox` is accepted today. */
|
|
256
|
+
where?: "sandbox";
|
|
257
|
+
/** Schema id of the JSON result (`tool` and `executor`); `shell` results are the fixed ShellResult shape. */
|
|
258
|
+
out?: string;
|
|
259
|
+
/** State key the result lands under. */
|
|
260
|
+
as: string;
|
|
261
|
+
/** Workspace-relative files the node promises to create; verified after the effect. Each entry
|
|
262
|
+
* interpolates `{dot.path}` by value, so a call inside a map can name its item's file. */
|
|
263
|
+
produces?: string[];
|
|
264
|
+
/** Wall bound in seconds for one execution. Required: an unbounded effect is how a stalled provider becomes a stalled job. */
|
|
265
|
+
deadline_s: number;
|
|
266
|
+
retry?: {
|
|
267
|
+
attempts: number;
|
|
268
|
+
backoff_s?: number;
|
|
269
|
+
on?: CallRetryClass[];
|
|
270
|
+
};
|
|
271
|
+
/** Repeat the call until its result settles (a queued job, an eventually consistent read). */
|
|
272
|
+
poll?: PollClause;
|
|
273
|
+
requires?: string[];
|
|
274
|
+
};
|
|
275
|
+
export declare const SHELL_RESULT_SCHEMA: Record<string, unknown>;
|
|
276
|
+
export type LlmNode = Extract<WorkflowNode, {
|
|
277
|
+
node: "agent" | "decide" | "extract" | "report";
|
|
278
|
+
}>;
|
|
279
|
+
export declare const REPORT_SCHEMA: Record<string, unknown>;
|
|
280
|
+
export type Workflow = {
|
|
281
|
+
v: 2;
|
|
282
|
+
name: string;
|
|
283
|
+
schemas: {
|
|
284
|
+
[id: string]: {
|
|
285
|
+
[keyword: string]: unknown;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/** Initial state schema, enforced when present. Required for child workflows. */
|
|
289
|
+
input?: {
|
|
290
|
+
schemaId: string;
|
|
291
|
+
};
|
|
292
|
+
output: {
|
|
293
|
+
schemaId: string;
|
|
294
|
+
path?: string;
|
|
295
|
+
};
|
|
296
|
+
root: WorkflowNode;
|
|
297
|
+
};
|
|
298
|
+
export type Escalation = {
|
|
299
|
+
kind: string;
|
|
300
|
+
stage: string;
|
|
301
|
+
summary: string;
|
|
302
|
+
state: Record<string, unknown>;
|
|
303
|
+
label?: string;
|
|
304
|
+
executionPath?: string;
|
|
305
|
+
};
|
|
306
|
+
export type WorkflowRunResult = {
|
|
307
|
+
status: "complete";
|
|
308
|
+
state: Record<string, unknown>;
|
|
309
|
+
output: unknown;
|
|
310
|
+
} | {
|
|
311
|
+
status: "escalated";
|
|
312
|
+
state: Record<string, unknown>;
|
|
313
|
+
escalation: Escalation;
|
|
314
|
+
};
|
|
315
|
+
export type MapItem = {
|
|
316
|
+
label: string;
|
|
317
|
+
index: number;
|
|
318
|
+
};
|
|
319
|
+
export type WorkflowDeps = {
|
|
320
|
+
maxQuestionsPerRequest?: number;
|
|
321
|
+
runNode?: (params: {
|
|
322
|
+
kind: "agent" | "decide" | "extract" | "report";
|
|
323
|
+
label: string;
|
|
324
|
+
item?: MapItem;
|
|
325
|
+
executionPath?: string;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
system: string[];
|
|
328
|
+
user: string;
|
|
329
|
+
schema: Record<string, unknown>;
|
|
330
|
+
effort?: WorkflowEffort;
|
|
331
|
+
thinking?: WorkflowThinking;
|
|
332
|
+
tools?: string[];
|
|
333
|
+
/** The node's verify clause compiled to a submit-time reviewer: the runner hands it to the
|
|
334
|
+
* session's submit tool (`submit.review`); a verdict that does not accept continues the SAME
|
|
335
|
+
* session with the message as the next tool result. The engine verifies returned submissions even if the runner ignores this hook. */
|
|
336
|
+
review?: (candidate: unknown) => Promise<{
|
|
337
|
+
accepted: true;
|
|
338
|
+
} | {
|
|
339
|
+
accepted: false;
|
|
340
|
+
message: string;
|
|
341
|
+
}>;
|
|
342
|
+
tier?: ModelTier;
|
|
343
|
+
}) => Promise<unknown>;
|
|
344
|
+
runEffect?: (params: {
|
|
345
|
+
node: CallNode;
|
|
346
|
+
schema?: Record<string, unknown>;
|
|
347
|
+
input: Record<string, unknown>;
|
|
348
|
+
produces: string[];
|
|
349
|
+
attempt: number;
|
|
350
|
+
idempotencyKey: string;
|
|
351
|
+
signal: AbortSignal;
|
|
352
|
+
item?: MapItem;
|
|
353
|
+
executionPath?: string;
|
|
354
|
+
}) => Promise<unknown>;
|
|
355
|
+
runJudge?: (params: {
|
|
356
|
+
label: string;
|
|
357
|
+
kind: "judge" | "pick" | "sift" | "route" | "ask";
|
|
358
|
+
item?: MapItem;
|
|
359
|
+
executionPath?: string;
|
|
360
|
+
signal?: AbortSignal;
|
|
361
|
+
state: unknown;
|
|
362
|
+
questions: Record<string, SystemOneQuestion>;
|
|
363
|
+
}) => Promise<{
|
|
364
|
+
answers: Record<string, SystemOneAnswer>;
|
|
365
|
+
model?: string | null;
|
|
366
|
+
usage?: {
|
|
367
|
+
input_tokens: number;
|
|
368
|
+
output_tokens: number;
|
|
369
|
+
} | null;
|
|
370
|
+
cost_usd?: number | null;
|
|
371
|
+
request_sha256?: string;
|
|
372
|
+
}>;
|
|
373
|
+
syntheticEffects?: boolean;
|
|
374
|
+
checkpoint?: (state: Record<string, unknown>, label: string, executionPath?: string) => Promise<void>;
|
|
375
|
+
/** Critical recovery stores stop execution on write failure; omitted retains legacy best effort. */
|
|
376
|
+
checkpointFailureMode?: "required" | "best_effort";
|
|
377
|
+
recovery?: {
|
|
378
|
+
/** Required for composed child graphs: every store key must include executionPath. */
|
|
379
|
+
supportsExecutionPaths?: boolean;
|
|
380
|
+
resume: (node: WorkflowNode, state: Record<string, unknown>, item?: MapItem, executionPath?: string) => Promise<Record<string, unknown> | undefined>;
|
|
381
|
+
commit: (node: WorkflowNode, state: Record<string, unknown>, item?: MapItem, executionPath?: string) => Promise<void>;
|
|
382
|
+
pollStartedAt: (node: CallNode, item?: MapItem, executionPath?: string) => number;
|
|
383
|
+
wait: (node: CallNode, ms: number, item?: MapItem, executionPath?: string) => Promise<void>;
|
|
384
|
+
fail?: (node: WorkflowNode, results: unknown[], error: unknown, executionPath?: string) => Promise<void>;
|
|
385
|
+
};
|
|
386
|
+
/** A completed-effect memo keyed by the call's idempotency key. A hit skips the effect and
|
|
387
|
+
* reuses its result; polled calls are never memoized (their result is a moment in time). */
|
|
388
|
+
memo?: {
|
|
389
|
+
get: (key: string, node: CallNode) => Promise<unknown>;
|
|
390
|
+
put: (key: string, node: CallNode, result: unknown) => Promise<void>;
|
|
391
|
+
};
|
|
392
|
+
sop?: string;
|
|
393
|
+
skill?: string;
|
|
394
|
+
signal?: AbortSignal;
|
|
395
|
+
/** Best-effort observation only: thrown errors and rejected promises are ignored.
|
|
396
|
+
* Observers are never awaited. Use required checkpoints for durable lifecycle gates. */
|
|
397
|
+
onEvent?: (event: {
|
|
398
|
+
type: string;
|
|
399
|
+
label: string;
|
|
400
|
+
detail?: unknown;
|
|
401
|
+
executionPath?: string;
|
|
402
|
+
}) => void;
|
|
403
|
+
};
|
|
404
|
+
export declare const declaredWrites: (node: WorkflowNode | undefined) => Set<string>;
|
|
405
|
+
export declare const childSteps: (child: Workflow | undefined) => WorkflowNode[] | null;
|
|
406
|
+
export declare class EffectFailure extends Error {
|
|
407
|
+
readonly retryClass: CallRetryClass | null;
|
|
408
|
+
constructor(message: string, retryClass?: CallRetryClass | null);
|
|
409
|
+
}
|
|
410
|
+
export declare function parseCsvRows(text: string): string[][];
|
|
411
|
+
export declare function buildReferenceContext(files: Record<string, string>): {
|
|
412
|
+
references: Record<string, string>;
|
|
413
|
+
references_parsed: Record<string, {
|
|
414
|
+
header: string[];
|
|
415
|
+
rows: string[][];
|
|
416
|
+
}>;
|
|
417
|
+
};
|
|
418
|
+
export declare function normalizeStringNullsForSchema(value: unknown, schema: Record<string, unknown> | undefined, depth?: number): unknown;
|
|
419
|
+
export declare function workflowSha256(workflow: Workflow): string;
|
|
420
|
+
/** Bound the complete document before any recursive schema or semantic traversal. Shared
|
|
421
|
+
* objects are valid, but each occurrence consumes the budget; cycles are never JSON. */
|
|
422
|
+
export declare function workflowDocumentError(value: unknown): string | undefined;
|
|
423
|
+
/** Set executeCode:false for untrusted author feedback: check syntax and mechanical contracts
|
|
424
|
+
* without evaluating authored expressions or probing transforms. This is not execution admission;
|
|
425
|
+
* trusted/default validation and runtime output checks remain authoritative. */
|
|
426
|
+
export declare function validateWorkflow(workflow: Workflow, opts?: {
|
|
427
|
+
executeCode?: boolean;
|
|
428
|
+
input?: Record<string, unknown>;
|
|
429
|
+
inputKeys?: string[];
|
|
430
|
+
probeContext?: {
|
|
431
|
+
references?: Record<string, string>;
|
|
432
|
+
references_parsed?: Record<string, {
|
|
433
|
+
header: string[];
|
|
434
|
+
rows: string[][];
|
|
435
|
+
}>;
|
|
436
|
+
};
|
|
437
|
+
}): {
|
|
438
|
+
ok: true;
|
|
439
|
+
} | {
|
|
440
|
+
ok: false;
|
|
441
|
+
errors: string[];
|
|
442
|
+
};
|
|
443
|
+
export declare class EscalationSignal extends Error {
|
|
444
|
+
readonly escalation: Escalation;
|
|
445
|
+
constructor(escalation: Escalation);
|
|
446
|
+
}
|
|
447
|
+
export declare function schemaProblems(validator: {
|
|
448
|
+
Errors: (candidate: unknown) => Iterable<any>;
|
|
449
|
+
}, candidate: unknown): string[];
|
|
450
|
+
export declare class WorkflowInvalidError extends Error {
|
|
451
|
+
readonly workflowName: string;
|
|
452
|
+
readonly problems: string[];
|
|
453
|
+
readonly code = "workflow_invalid";
|
|
454
|
+
readonly stage = "validate";
|
|
455
|
+
constructor(workflowName: string, problems: string[]);
|
|
456
|
+
}
|
|
457
|
+
export declare class WorkflowInputInvalidError extends Error {
|
|
458
|
+
readonly workflowName: string;
|
|
459
|
+
readonly problems: string[];
|
|
460
|
+
readonly code = "input_invalid";
|
|
461
|
+
readonly stage = "input";
|
|
462
|
+
constructor(workflowName: string, problems: string[]);
|
|
463
|
+
}
|
|
464
|
+
/** The adapter returned after its deadline. Its effect must be reconciled by the host;
|
|
465
|
+
* the engine refuses the late result and never retries it automatically. */
|
|
466
|
+
export declare class EffectDeadlineExceededError extends Error {
|
|
467
|
+
readonly stage: string;
|
|
468
|
+
readonly lateResult: unknown;
|
|
469
|
+
readonly code = "effect_deadline_exceeded";
|
|
470
|
+
constructor(stage: string, lateResult: unknown);
|
|
471
|
+
}
|
|
472
|
+
export type EffectSettlement = {
|
|
473
|
+
status: "fulfilled";
|
|
474
|
+
value: unknown;
|
|
475
|
+
} | {
|
|
476
|
+
status: "rejected";
|
|
477
|
+
reason: unknown;
|
|
478
|
+
};
|
|
479
|
+
/** An admitted effect did not settle before cancellation or its deadline. An abort signal
|
|
480
|
+
* cannot prove whether the external effect occurred. Reconcile before any new admission. */
|
|
481
|
+
export declare class EffectOutcomeUnknownError extends Error {
|
|
482
|
+
readonly stage: string;
|
|
483
|
+
readonly interruption: "deadline" | "cancelled";
|
|
484
|
+
readonly attempt: number;
|
|
485
|
+
readonly idempotencyKey: string;
|
|
486
|
+
readonly settlement: Promise<EffectSettlement>;
|
|
487
|
+
readonly executionPath?: string | undefined;
|
|
488
|
+
readonly code = "effect_outcome_unknown";
|
|
489
|
+
readonly outcome = "unknown";
|
|
490
|
+
constructor(stage: string, interruption: "deadline" | "cancelled", attempt: number, idempotencyKey: string, settlement: Promise<EffectSettlement>, cause?: unknown, executionPath?: string | undefined);
|
|
491
|
+
}
|
|
492
|
+
export declare class WorkflowOutputInvalidError extends Error {
|
|
493
|
+
readonly problems: string[];
|
|
494
|
+
readonly stage: string;
|
|
495
|
+
readonly code = "output_invalid";
|
|
496
|
+
constructor(summary: string, problems: string[], stage?: string);
|
|
497
|
+
}
|
|
498
|
+
/** Local transform failure. The cause is retained for trusted hosts, not author-facing diagnostics. */
|
|
499
|
+
export declare class WorkflowCodeError extends Error {
|
|
500
|
+
readonly stage: string;
|
|
501
|
+
readonly code = "code_transform_failed";
|
|
502
|
+
constructor(stage: string, cause: unknown);
|
|
503
|
+
}
|
|
504
|
+
/** A mechanical state-contract failure, distinct from provider or authored-code errors.
|
|
505
|
+
* Trusted hosts retain the location; a parallel collision key can be runtime-derived
|
|
506
|
+
* and must be omitted by public diagnostics. No full state object is retained. */
|
|
507
|
+
export declare class WorkflowStateError extends Error {
|
|
508
|
+
readonly stage: string;
|
|
509
|
+
readonly path: string;
|
|
510
|
+
readonly reason: "required_nonempty" | "missing_interpolation" | "expected_list" | "empty_selection" | "missing_map_result" | "parallel_write_conflict";
|
|
511
|
+
readonly code = "state_invalid";
|
|
512
|
+
constructor(summary: string, stage: string, path: string, reason: "required_nonempty" | "missing_interpolation" | "expected_list" | "empty_selection" | "missing_map_result" | "parallel_write_conflict");
|
|
513
|
+
}
|
|
514
|
+
export declare function stageSchemaForNode(workflow: Workflow, node: LlmNode): Record<string, unknown>;
|
|
515
|
+
export declare const submissionSchemaForNode: typeof stageSchemaForNode;
|
|
516
|
+
export declare function mergeStageDelta(state: Record<string, unknown>, node: LlmNode, result: Record<string, unknown>, schema: Record<string, unknown>): Record<string, unknown>;
|
|
517
|
+
export declare class WorkflowVerificationError extends Error {
|
|
518
|
+
readonly stage: string;
|
|
519
|
+
readonly candidate: unknown;
|
|
520
|
+
readonly drives: unknown[];
|
|
521
|
+
readonly code = "WORKFLOW_VERIFICATION_FAILED";
|
|
522
|
+
constructor(stage: string, candidate: unknown, drives: unknown[], message: string);
|
|
523
|
+
}
|
|
524
|
+
export declare function assertWorkflowCapabilities(node: WorkflowNode, deps: WorkflowDeps, workflow?: Workflow): void;
|
|
525
|
+
export declare function runWorkflow(workflow: Workflow, input: Record<string, unknown>, deps: WorkflowDeps): Promise<WorkflowRunResult>;
|
|
526
|
+
export declare function runWorkflowSlice(workflow: Workflow, input: Record<string, unknown>, focus: {
|
|
527
|
+
from: string;
|
|
528
|
+
to?: string;
|
|
529
|
+
seed?: Record<string, unknown>;
|
|
530
|
+
}, deps: WorkflowDeps): Promise<{
|
|
531
|
+
status: "complete";
|
|
532
|
+
state: Record<string, unknown>;
|
|
533
|
+
focus: {
|
|
534
|
+
from: string;
|
|
535
|
+
to: string;
|
|
536
|
+
};
|
|
537
|
+
} | {
|
|
538
|
+
status: "escalated";
|
|
539
|
+
state: Record<string, unknown>;
|
|
540
|
+
escalation: Escalation;
|
|
541
|
+
}>;
|