@parcha/agentrun-dsl 0.1.0-beta.19 → 0.1.0-beta.191
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/NOTICE +2 -0
- package/README.md +139 -21
- package/dist/author-references.d.ts +8 -0
- package/dist/author-references.js +8 -0
- package/dist/author.d.ts +4 -3
- package/dist/author.js +19 -10
- package/dist/authoring.js +4 -3
- package/dist/cli.js +13 -12
- package/dist/code-exec.d.ts +19 -0
- package/dist/code-exec.js +54 -5
- package/dist/decision-provider.d.ts +166 -0
- package/dist/decision-provider.js +238 -0
- package/dist/decision-receipts.d.ts +64 -3
- package/dist/decision-receipts.js +50 -8
- package/dist/dry-run.d.ts +31 -1
- package/dist/dry-run.js +122 -16
- package/dist/edit.d.ts +98 -0
- package/dist/edit.js +1144 -0
- package/dist/evidence.d.ts +19 -0
- package/dist/evidence.js +63 -0
- package/dist/graph.d.ts +91 -5
- package/dist/graph.js +212 -10
- package/dist/index.d.ts +17 -12
- package/dist/index.js +16 -10
- package/dist/inspection.d.ts +5 -0
- package/dist/inspection.js +14 -1
- package/dist/pattern-screen.d.ts +14 -0
- package/dist/pattern-screen.js +451 -0
- package/dist/predicates.d.ts +29 -0
- package/dist/predicates.js +62 -3
- package/dist/record.d.ts +4 -0
- package/dist/record.js +6 -0
- package/dist/recovery/binding.js +2 -1
- package/dist/recovery/call-key.d.ts +0 -4
- package/dist/recovery/call-key.js +0 -7
- package/dist/recovery/driver.d.ts +61 -24
- package/dist/recovery/driver.js +193 -68
- package/dist/recovery/frozen-snapshot.d.ts +33 -3
- package/dist/recovery/frozen-snapshot.js +28 -12
- package/dist/recovery/handoff-receipts.d.ts +0 -35
- package/dist/recovery/handoff-receipts.js +2 -44
- package/dist/recovery/index.d.ts +4 -8
- package/dist/recovery/index.js +4 -7
- package/dist/recovery/with-recovery.d.ts +9 -3
- package/dist/recovery/with-recovery.js +72 -15
- package/dist/submit-envelope.d.ts +9 -0
- package/dist/submit-envelope.js +44 -0
- package/dist/system-one.d.ts +21 -2
- package/dist/system-one.js +96 -18
- package/dist/testing/decision-provider.d.ts +32 -0
- package/dist/testing/decision-provider.js +183 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +2 -0
- package/dist/vocabulary.d.ts +11 -3
- package/dist/vocabulary.js +18 -8
- package/dist/workflow-shape.js +34 -7
- package/dist/workflow.d.ts +128 -19
- package/dist/workflow.js +772 -238
- package/dist/zod-json-contract.js +6 -8
- package/package.json +16 -4
- package/schema/workflow.schema.json +352 -1
- package/skills/author/SKILL.md +4 -1
- package/skills/author/references/jev-decisions.md +50 -5
- package/skills/author/references/language.md +17 -12
- package/dist/recovery/effect-failure.d.ts +0 -34
- package/dist/recovery/effect-failure.js +0 -62
- package/dist/recovery/handoff-block.d.ts +0 -36
- package/dist/recovery/handoff-block.js +0 -148
- package/dist/recovery/handoff-digest.d.ts +0 -58
- package/dist/recovery/handoff-digest.js +0 -195
- package/dist/recovery/handoff-files.d.ts +0 -54
- package/dist/recovery/handoff-files.js +0 -162
- package/dist/recovery/handoff-redact.d.ts +0 -12
- package/dist/recovery/handoff-redact.js +0 -44
- package/dist/recovery/handoff.d.ts +0 -44
- package/dist/recovery/handoff.js +0 -46
package/dist/dry-run.js
CHANGED
|
@@ -2,29 +2,75 @@ import { Compile } from "typebox/compile";
|
|
|
2
2
|
import { runWorkflow, validateWorkflow, WorkflowInvalidError, WorkflowInputInvalidError, WorkflowOutputInvalidError } from "./workflow.js";
|
|
3
3
|
import { resolveSchemaForWorkflow } from "./schema-references.js";
|
|
4
4
|
import { synthesizeAnswers } from "./system-one.js";
|
|
5
|
-
|
|
5
|
+
import { isRecord } from "./record.js";
|
|
6
|
+
/** A provider for every id the workflow names, and a default: the dry run answers each decision itself, so a node's
|
|
7
|
+
* provider and timeoutMs hold it to no host's providers. */
|
|
8
|
+
function syntheticProviders(workflow) {
|
|
9
|
+
const ids = new Set(["dry-run"]);
|
|
10
|
+
JSON.stringify(workflow, (key, value) => { if (key === "provider" && typeof value === "string")
|
|
11
|
+
ids.add(value); return value; });
|
|
12
|
+
const capabilities = { types: ["noul", "choice", "score", "box"], inputs: ["text", "json", "image", "pdf", "url"], evidence: "citations",
|
|
13
|
+
probability: "none", grounding: false, replay: "deduped", maxQuestions: null, maxStateBytes: null };
|
|
14
|
+
const provider = (id) => ({ id, needs: [], capabilities, decide: async () => { throw new Error("A dry run answers its decisions itself."); } });
|
|
15
|
+
return { providers: Object.fromEntries([...ids].map((id) => [id, provider(id)])), default: "dry-run" };
|
|
16
|
+
}
|
|
17
|
+
/** The default: a million values and 16 million characters, far past what a real workflow's dry run builds (a few
|
|
18
|
+
* thousand values at most), and well within a host's memory (a few hundred MB at worst). */
|
|
19
|
+
export const SYNTHESIS_BUDGET = { values: 1_000_000, chars: 16_000_000 };
|
|
20
|
+
/** The schema asked synthesis for more than its budget: the dry run ends not run, saying so. */
|
|
21
|
+
export class SynthesisTooLarge extends Error {
|
|
22
|
+
name = "SynthesisTooLarge";
|
|
23
|
+
}
|
|
24
|
+
/** A budget's limits, each field the default unless given as a number (a field given as undefined keeps the default). */
|
|
25
|
+
const spendOf = (limit = {}) => ({
|
|
26
|
+
values: 0,
|
|
27
|
+
chars: 0,
|
|
28
|
+
limit: { values: typeof limit.values === "number" ? limit.values : SYNTHESIS_BUDGET.values, chars: typeof limit.chars === "number" ? limit.chars : SYNTHESIS_BUDGET.chars },
|
|
29
|
+
});
|
|
30
|
+
/** A literal's characters as the value it is (a const, an enum's first): its serialized size. */
|
|
31
|
+
const literalChars = (value) => JSON.stringify(value)?.length ?? 0;
|
|
32
|
+
function charge(spend, values, chars) {
|
|
33
|
+
spend.values += values;
|
|
34
|
+
spend.chars += chars;
|
|
35
|
+
if (spend.values > spend.limit.values || spend.chars > spend.limit.chars) {
|
|
36
|
+
throw new SynthesisTooLarge(`the schema is too large to synthesize: past ${spend.limit.values} values or ${spend.limit.chars} characters`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** A value of `schema` (its `$ref`s read from `definitions`), synthesized within `budget` (SYNTHESIS_BUDGET when none):
|
|
40
|
+
* past it, SynthesisTooLarge. */
|
|
41
|
+
export function synthesizeInstance(schema, definitions = {}, depth = 0, budget = SYNTHESIS_BUDGET) {
|
|
42
|
+
return synthesize(schema, definitions, depth, spendOf(budget));
|
|
43
|
+
}
|
|
44
|
+
function synthesize(schema, definitions, depth, spend) {
|
|
45
|
+
// Every value it makes is counted before it is made, once (a $ref, an anyOf or a oneOf is the value it leads to, not one
|
|
46
|
+
// of its own): past the budget it throws, having built no more than the budget.
|
|
6
47
|
if (depth > 12 || !schema || typeof schema !== "object")
|
|
7
|
-
return null;
|
|
48
|
+
return (charge(spend, 1, 0), null);
|
|
8
49
|
const spec = schema;
|
|
9
50
|
if (typeof spec.$ref === "string") {
|
|
10
51
|
const match = /^#\/definitions\/(.+)$/.exec(spec.$ref);
|
|
11
|
-
return match && definitions[match[1]] ?
|
|
52
|
+
return match && definitions[match[1]] ? synthesize(definitions[match[1]], definitions, depth + 1, spend) : (charge(spend, 1, 0), null);
|
|
12
53
|
}
|
|
54
|
+
// A literal is charged its serialized size: one written long in the schema does not escape the character budget.
|
|
13
55
|
if (spec.const !== undefined)
|
|
14
|
-
return spec.const;
|
|
56
|
+
return (charge(spend, 1, literalChars(spec.const)), spec.const);
|
|
15
57
|
if (Array.isArray(spec.enum) && spec.enum.length)
|
|
16
|
-
return spec.enum[0];
|
|
58
|
+
return (charge(spend, 1, literalChars(spec.enum[0])), spec.enum[0]);
|
|
17
59
|
if (Array.isArray(spec.anyOf) && spec.anyOf.length) {
|
|
18
60
|
const branch = spec.anyOf.find((candidate) => candidate?.type !== "null") ?? spec.anyOf[0];
|
|
19
|
-
return
|
|
61
|
+
return synthesize(branch, definitions, depth + 1, spend);
|
|
20
62
|
}
|
|
21
63
|
if (Array.isArray(spec.oneOf) && spec.oneOf.length)
|
|
22
|
-
return
|
|
64
|
+
return synthesize(spec.oneOf[0], definitions, depth + 1, spend);
|
|
65
|
+
// The one value made below.
|
|
66
|
+
charge(spend, 1, 0);
|
|
23
67
|
const type = Array.isArray(spec.type) ? spec.type[0] : spec.type;
|
|
24
68
|
if (type === "object" || (!type && spec.properties)) {
|
|
25
69
|
const out = Object.create(null);
|
|
26
70
|
for (const [key, property] of Object.entries(spec.properties || {})) {
|
|
27
|
-
|
|
71
|
+
// Its name is built into every value made under it, and serialized with it: charged before it is added.
|
|
72
|
+
charge(spend, 0, key.length);
|
|
73
|
+
out[key] = synthesize(property, definitions, depth + 1, spend);
|
|
28
74
|
}
|
|
29
75
|
return { ...out };
|
|
30
76
|
}
|
|
@@ -34,12 +80,17 @@ export function synthesizeInstance(schema, definitions = {}, depth = 0) {
|
|
|
34
80
|
const min = Number.isInteger(spec.minItems) ? spec.minItems : 1;
|
|
35
81
|
if (!spec.items)
|
|
36
82
|
return [];
|
|
37
|
-
|
|
83
|
+
// Each item is at least one value: a length past what the budget has left is refused before the array is made.
|
|
84
|
+
const length = Math.max(1, min);
|
|
85
|
+
if (length > spend.limit.values - spend.values)
|
|
86
|
+
charge(spend, length, 0);
|
|
87
|
+
return Array.from({ length }, () => synthesize(spec.items, definitions, depth + 1, spend));
|
|
38
88
|
}
|
|
39
89
|
if (type === "string") {
|
|
40
90
|
if (spec.maxLength === 0)
|
|
41
91
|
return "";
|
|
42
92
|
const min = Number.isInteger(spec.minLength) ? spec.minLength : 1;
|
|
93
|
+
charge(spend, 0, Math.max(1, min));
|
|
43
94
|
return "x".repeat(Math.max(1, min));
|
|
44
95
|
}
|
|
45
96
|
if (type === "integer") {
|
|
@@ -79,6 +130,8 @@ export function synthesizeInstance(schema, definitions = {}, depth = 0) {
|
|
|
79
130
|
return false;
|
|
80
131
|
if (type === "null")
|
|
81
132
|
return null;
|
|
133
|
+
// A schema synthesis cannot read: one character.
|
|
134
|
+
charge(spend, 0, 1);
|
|
82
135
|
return "x";
|
|
83
136
|
}
|
|
84
137
|
function unsupportedConstructs(schema, path, found, depth = 0) {
|
|
@@ -140,19 +193,29 @@ export async function dryRunWorkflow(workflow, opts = {}) {
|
|
|
140
193
|
scanSchemas(workflow);
|
|
141
194
|
if (skipped.length)
|
|
142
195
|
return { ok: true, status: "not_run", skipped };
|
|
196
|
+
// One budget for everything this dry run synthesizes.
|
|
197
|
+
const spend = spendOf(opts.budget);
|
|
143
198
|
let input = opts.input ?? {};
|
|
144
199
|
if (opts.input === undefined && workflow.input) {
|
|
145
200
|
const schema = resolveSchemaForWorkflow(workflow, workflow.schemas[workflow.input.schemaId]);
|
|
146
|
-
|
|
147
|
-
|
|
201
|
+
let generated;
|
|
202
|
+
try {
|
|
203
|
+
generated = synthesize(schema, schema.definitions ?? workflow.schemas, 0, spend);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if (error instanceof SynthesisTooLarge)
|
|
207
|
+
return { ok: true, status: "not_run", skipped: [error.message] };
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
if (!isRecord(generated) || !Compile(schema).Check(generated)) {
|
|
148
211
|
return { ok: true, status: "not_run", skipped: ["Could not synthesize a valid input object. Supply input explicitly to dryRunWorkflow or the dry-run CLI."] };
|
|
149
212
|
}
|
|
150
213
|
input = generated;
|
|
151
214
|
}
|
|
152
215
|
if (opts.probeContext && !Object.prototype.hasOwnProperty.call(input, "context")) {
|
|
153
216
|
input = { ...input, context: {
|
|
154
|
-
references: opts.probeContext
|
|
155
|
-
references_parsed: opts.probeContext
|
|
217
|
+
references: opts.probeContext.references ?? {},
|
|
218
|
+
references_parsed: opts.probeContext.references_parsed ?? {},
|
|
156
219
|
} };
|
|
157
220
|
}
|
|
158
221
|
let currentLabel = "";
|
|
@@ -162,12 +225,43 @@ export async function dryRunWorkflow(workflow, opts = {}) {
|
|
|
162
225
|
// Why the dry run stopped early, kept here: the interpreter may wrap what an adapter throws.
|
|
163
226
|
let stopped;
|
|
164
227
|
const stop = (reason) => { stopped ??= reason; throw new Error(stopped); };
|
|
228
|
+
/** A step's synthetic answer within the run's budget: past it, the dry run stops (the interpreter may wrap the throw). */
|
|
229
|
+
const synthesized = (make) => {
|
|
230
|
+
try {
|
|
231
|
+
return make();
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (error instanceof SynthesisTooLarge)
|
|
235
|
+
stop(error.message);
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const deadlineMs = opts.deadlineMs ?? 60_000;
|
|
240
|
+
const deadline = Date.now() + deadlineMs;
|
|
241
|
+
const maxVisits = opts.maxVisits ?? maxSteps * 10;
|
|
242
|
+
let visits = 0;
|
|
243
|
+
const pastDeadline = () => {
|
|
244
|
+
if (Date.now() > deadline)
|
|
245
|
+
stop(`The dry run stopped past its ${deadlineMs} ms deadline.`);
|
|
246
|
+
};
|
|
247
|
+
/** A node's visit (a loop's body each iteration, a map's body for each item), counted against maxVisits and the
|
|
248
|
+
* deadline, so a loop whose body asks nothing (no step) still ends. Synchronous: it reads the clock, never a timer, so
|
|
249
|
+
* a run that never yields still stops. */
|
|
250
|
+
const visit = () => {
|
|
251
|
+
if (opts.signal?.aborted)
|
|
252
|
+
stop("The dry run was stopped before it finished.");
|
|
253
|
+
visits += 1;
|
|
254
|
+
if (visits > maxVisits)
|
|
255
|
+
stop(`The dry run stopped after ${maxVisits} node visits: on synthetic values the workflow's loops or maps go on further, asking nothing. Supply input, or lower a loop's maxIters.`);
|
|
256
|
+
pastDeadline();
|
|
257
|
+
};
|
|
165
258
|
const step = async () => {
|
|
166
259
|
if (opts.signal?.aborted)
|
|
167
260
|
stop("The dry run was stopped before it finished.");
|
|
168
261
|
steps += 1;
|
|
169
262
|
if (steps > maxSteps)
|
|
170
263
|
stop(`The dry run stopped after ${maxSteps} synthetic steps: on synthetic values the workflow's loops or maps go on further. Supply input, or lower a loop's maxIters.`);
|
|
264
|
+
pastDeadline();
|
|
171
265
|
if (steps % 64 === 0) {
|
|
172
266
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
173
267
|
if (opts.signal?.aborted)
|
|
@@ -177,30 +271,42 @@ export async function dryRunWorkflow(workflow, opts = {}) {
|
|
|
177
271
|
const runCode = opts.runCode;
|
|
178
272
|
try {
|
|
179
273
|
const result = await runWorkflow(workflow, input, {
|
|
274
|
+
onVisit: () => visit(),
|
|
180
275
|
sop: opts.sop,
|
|
181
276
|
...(runCode ? { runCode: async (...args) => { await step(); return runCode(...args); } } : {}),
|
|
182
277
|
onEvent: (event) => { if (typeof event.label === "string")
|
|
183
278
|
currentLabel = event.label; },
|
|
184
279
|
runNode: async ({ schema, review }) => {
|
|
185
280
|
await step();
|
|
186
|
-
const candidate =
|
|
281
|
+
const candidate = synthesized(() => synthesize(schema, schema.definitions ?? workflow.schemas, 0, spend));
|
|
187
282
|
if (review)
|
|
188
283
|
await review(candidate);
|
|
189
284
|
return candidate;
|
|
190
285
|
},
|
|
191
|
-
|
|
286
|
+
// A node that requires evidence gets a placeholder, as a provider that gives evidence would answer it.
|
|
287
|
+
runJudge: async ({ questions, evidence }) => {
|
|
288
|
+
await step();
|
|
289
|
+
// Its answers are synthetic values like any step's: each charged its serialized size against the run's budget (a
|
|
290
|
+
// choice's first option may be a long string, and a map collects one per item).
|
|
291
|
+
const answers = synthesizeAnswers(questions);
|
|
292
|
+
synthesized(() => charge(spend, Object.keys(answers).length, literalChars(answers)));
|
|
293
|
+
return { answers, model: "synthetic", usage: null, cost_usd: null, request_sha256: "",
|
|
294
|
+
...(evidence === "required" ? { evidence: [{ url: "https://example.invalid/dry-run", title: null, excerpts: [], scope: "dry_run" }] } : {}) };
|
|
295
|
+
},
|
|
192
296
|
syntheticEffects: true,
|
|
297
|
+
decisionProviders: syntheticProviders(workflow),
|
|
193
298
|
runEffect: async ({ node, schema }) => {
|
|
194
299
|
await step();
|
|
195
300
|
return node.via === "shell"
|
|
196
301
|
? { code: 0, stdout: "{}", stderr: "", truncated: false }
|
|
197
|
-
:
|
|
302
|
+
: synthesized(() => synthesize(schema ?? (workflow.schemas || {})[node.out], schema?.definitions ?? workflow.schemas ?? {}, 0, spend));
|
|
198
303
|
},
|
|
199
304
|
});
|
|
200
305
|
if (result.status === "escalated") {
|
|
201
306
|
// Synthetic values tripping an escalate predicate proves nothing about real cases.
|
|
202
307
|
return { ok: true, status: "not_run", skipped: [`escalated:${result.escalation.kind}@${result.escalation.stage} on synthetic values`] };
|
|
203
308
|
}
|
|
309
|
+
opts.onOutput?.(result.output);
|
|
204
310
|
return { ok: true, status: "passed" };
|
|
205
311
|
}
|
|
206
312
|
catch (error) {
|
package/dist/edit.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** A workflow document as JSON: an object whose `root` is a node. */
|
|
2
|
+
export type WorkflowDocument = Record<string, unknown>;
|
|
3
|
+
/** A node as JSON: an object whose `node` is its kind. */
|
|
4
|
+
export type WorkflowNodeJson = Record<string, unknown>;
|
|
5
|
+
/** Where a child sits under its parent node: the pointer segments from the parent to it. A chain's `steps` and a
|
|
6
|
+
* parallel's `branches` hold many, by index; a map's or a loop's `body`, a route branch's `branches/<name>/body` (the
|
|
7
|
+
* name pointer-escaped, as in a graph path) and a child workflow's `workflow/root` hold one. The document holds its
|
|
8
|
+
* root at `root`, under the parent path `""`. */
|
|
9
|
+
export type Slot = "root" | "steps" | "branches" | "body" | "workflow/root" | `branches/${string}/body`;
|
|
10
|
+
/** What an operation returns: the next document and what happened to the nodes of the one it was given. */
|
|
11
|
+
export type EditResult = {
|
|
12
|
+
doc: WorkflowDocument;
|
|
13
|
+
/** Each node whose path changed, from its path before to its path after, in the input's document order. */
|
|
14
|
+
moved: Map<string, string>;
|
|
15
|
+
/** The paths, in the result, of the nodes the input did not have. */
|
|
16
|
+
added: string[];
|
|
17
|
+
/** The paths, in the input, of the nodes the result does not have. */
|
|
18
|
+
removed: string[];
|
|
19
|
+
/** The paths, in the result, of the nodes that were kept with their own fields changed. */
|
|
20
|
+
changed: string[];
|
|
21
|
+
};
|
|
22
|
+
/** What rename returns: an EditResult, and the code and shell sources in scope that mention the old key. */
|
|
23
|
+
export type RenameResult = EditResult & {
|
|
24
|
+
mentions: string[];
|
|
25
|
+
};
|
|
26
|
+
/** What duplicate returns: an EditResult, and the paths, in the result, of the copy's code and shell sources that
|
|
27
|
+
* mention a key the copy writes under a fresh name, by its old name. */
|
|
28
|
+
export type DuplicateResult = EditResult & {
|
|
29
|
+
mentions: string[];
|
|
30
|
+
};
|
|
31
|
+
/** Every code an EditError carries. */
|
|
32
|
+
export declare const EDIT_ERROR_CODES: readonly ["DOCUMENT_INVALID", "PATH_NOT_FOUND", "SLOT_INVALID", "INDEX_OUT_OF_RANGE", "NODE_INVALID", "FIELD_INVALID", "NAME_INVALID", "NAME_TAKEN", "NAME_SHARED", "BRANCH_NOT_FOUND", "BRANCH_TAKEN", "BRANCH_IN_USE", "MOVE_INTO_SELF", "WRAP_INVALID", "UNWRAP_INVALID", "STRUCTURE_INVALID"];
|
|
33
|
+
export type EditErrorCode = typeof EDIT_ERROR_CODES[number];
|
|
34
|
+
/** The one error the operations throw. `path` is the node it is about, in the input document where that node existed
|
|
35
|
+
* there; `related` names other nodes the error is about: the one holding a taken name, the other writers of a key. */
|
|
36
|
+
export declare class EditError extends Error {
|
|
37
|
+
readonly code: EditErrorCode;
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly related: readonly string[];
|
|
40
|
+
constructor(code: EditErrorCode, path: string, message: string, related?: readonly string[]);
|
|
41
|
+
}
|
|
42
|
+
/** The fields setField writes on this node: its kind's (and its route form's) own fields, without `node` and the child
|
|
43
|
+
* slots. A property panel lists these. */
|
|
44
|
+
export declare function editableFields(node: WorkflowNodeJson): string[];
|
|
45
|
+
/** The fields the schema requires of this node's kind (and its route form), `node` included. */
|
|
46
|
+
export declare function requiredFields(node: WorkflowNodeJson): string[];
|
|
47
|
+
/** Where the node at `path` sits: its parent's path, the slot it is in, and its index there (0 in a slot that holds one
|
|
48
|
+
* node). Undefined when no node sits there. */
|
|
49
|
+
export declare function locate(doc: WorkflowDocument, path: string): {
|
|
50
|
+
parentPath: string;
|
|
51
|
+
slot: Slot;
|
|
52
|
+
index: number;
|
|
53
|
+
} | undefined;
|
|
54
|
+
/** Put `node` (copied) into `slot` of the node at `parentPath`, at `index`. In a chain's steps or a parallel's branches
|
|
55
|
+
* the index is a position, 0 to the count. A slot that holds one node takes index 0 when empty; when it holds a node,
|
|
56
|
+
* 0 puts the new one first and 1 puts it last, in a new chain of the two. */
|
|
57
|
+
export declare function insert(doc: WorkflowDocument, parentPath: string, slot: Slot, index: number, node: WorkflowNodeJson): EditResult;
|
|
58
|
+
/** Take out the node at `path`, and everything inside it. */
|
|
59
|
+
export declare function remove(doc: WorkflowDocument, path: string): EditResult;
|
|
60
|
+
/** Move the node at `fromPath` into `slot` of the node at `toParentPath`, at `index`, counted in the document as given:
|
|
61
|
+
* the drop point a canvas shows. A node never moves inside itself. */
|
|
62
|
+
export declare function move(doc: WorkflowDocument, fromPath: string, toParentPath: string, slot: Slot, index: number): EditResult;
|
|
63
|
+
/** Put a copy of the node at `path` right after it: the next step or branch, or, in a slot that holds one node, the
|
|
64
|
+
* second step of a new chain. Every node of the copy gets a fresh label, every key it writes a fresh name, and its own
|
|
65
|
+
* references follow its keys; the copy's code and shell sources that mention an old key are listed in `mentions`. */
|
|
66
|
+
export declare function duplicate(doc: WorkflowDocument, path: string): DuplicateResult;
|
|
67
|
+
/** The containers wrap makes. */
|
|
68
|
+
export type WrapKind = "map" | "loop" | "route" | "parallel" | "chain";
|
|
69
|
+
/** Put the nodes at `paths` (one node, or consecutive steps or branches of one container, in any order) into a new
|
|
70
|
+
* container of `kind`, where the first of them was. A map's, loop's or route's body is the one node or a chain of
|
|
71
|
+
* them; a parallel takes each as a branch. The new container's fields are placeholders the validator flags. */
|
|
72
|
+
export declare function wrap(doc: WorkflowDocument, paths: readonly string[], kind: WrapKind): EditResult;
|
|
73
|
+
/** Put the children of the container at `path` where it was: a chain's steps or a parallel's branches, the body of a
|
|
74
|
+
* map or a loop, or the body of the route branch `branch` names. Into a chain they are spliced; a parallel's branches
|
|
75
|
+
* join an enclosing parallel; a slot that holds one node takes one child, or a chain of a parallel's branches. */
|
|
76
|
+
export declare function unwrap(doc: WorkflowDocument, path: string, branch?: string): EditResult;
|
|
77
|
+
/** Add a branch to the parallel or route at `path`: `node` (copied) last among a parallel's branches, or as the body of
|
|
78
|
+
* a new route branch `name`, after the others. */
|
|
79
|
+
export declare function addBranch(doc: WorkflowDocument, path: string, node: WorkflowNodeJson, name?: string): EditResult;
|
|
80
|
+
/** Take out a branch of the parallel or route at `path`: a parallel's by its index, a route's by its name. */
|
|
81
|
+
export declare function removeBranch(doc: WorkflowDocument, path: string, branch: string | number): EditResult;
|
|
82
|
+
/** Rename branch `from` of the route at `path` to `to`, in its place among the others; `otherwise` and `unsure` follow. */
|
|
83
|
+
export declare function renameBranch(doc: WorkflowDocument, path: string, from: string, to: string): EditResult;
|
|
84
|
+
/** Write `value` (copied) at the field of the node at `path`, in its place; `undefined` removes an optional field. */
|
|
85
|
+
export declare function setField(doc: WorkflowDocument, path: string, field: string, value: unknown): EditResult;
|
|
86
|
+
/** Rename the label of the node at `path`. When the label is the key the node writes (an agent, decide, extract or code
|
|
87
|
+
* node with no `as`), every reference in scope follows it, and the code and shell sources in scope that mention the old
|
|
88
|
+
* key are listed in `mentions`, unchanged: a code node's own code included, when it names the key. */
|
|
89
|
+
export declare function rename(doc: WorkflowDocument, path: string, name: string): RenameResult;
|
|
90
|
+
/** Which key renameKey renames: the node's `as` (the default), or a map's `failedAs`. */
|
|
91
|
+
export type RenameKeyOptions = {
|
|
92
|
+
field?: "as" | "failedAs";
|
|
93
|
+
};
|
|
94
|
+
/** Rename the state key the node at `path` writes: its `as` when it has one, else its label when the label is the key
|
|
95
|
+
* (an agent, decide, extract or code node with no `as`, where this is `rename`); or, with `field: "failedAs"`, the key a
|
|
96
|
+
* map writes its failed items under. Every reference in scope follows it, `<key>$answers` and `<key>$verify` included,
|
|
97
|
+
* and the code and shell sources in scope that mention the old key are listed in `mentions`, unchanged. */
|
|
98
|
+
export declare function renameKey(doc: WorkflowDocument, path: string, name: string, options?: RenameKeyOptions): RenameResult;
|