@parcha/agentrun-dsl 0.1.0-beta.28 → 0.1.0-beta.280
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 +22 -17
- package/dist/author-references.d.ts +2 -2
- package/dist/author-references.js +2 -2
- package/dist/author.d.ts +0 -2
- package/dist/author.js +12 -7
- package/dist/authoring.js +3 -2
- 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 +60 -2
- package/dist/decision-receipts.js +13 -3
- package/dist/dry-run.d.ts +31 -1
- package/dist/dry-run.js +120 -14
- package/dist/edit.d.ts +158 -0
- package/dist/edit.js +1486 -0
- package/dist/evidence.d.ts +19 -0
- package/dist/evidence.js +63 -0
- package/dist/graph.d.ts +17 -0
- package/dist/graph.js +71 -6
- 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/pointer-warning.d.ts +14 -0
- package/dist/pointer-warning.js +22 -0
- package/dist/predicates.d.ts +32 -2
- package/dist/predicates.js +66 -6
- 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 +48 -20
- package/dist/recovery/driver.js +150 -41
- package/dist/recovery/frozen-snapshot.d.ts +30 -1
- package/dist/recovery/frozen-snapshot.js +26 -8
- 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/item-state.d.ts +2 -1
- package/dist/recovery/item-state.js +7 -13
- package/dist/recovery/with-recovery.d.ts +9 -3
- package/dist/recovery/with-recovery.js +72 -15
- package/dist/submit-envelope.d.ts +2 -1
- package/dist/submit-envelope.js +12 -5
- 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 +16 -3
- package/dist/vocabulary.js +22 -7
- package/dist/workflow-shape.js +4 -2
- package/dist/workflow.d.ts +131 -15
- package/dist/workflow.js +807 -233
- package/dist/zod-json-contract.js +6 -8
- package/package.json +12 -4
- package/schema/workflow.schema.json +346 -1
- package/skills/author/references/jev-decisions.md +50 -5
- package/skills/author/references/language.md +14 -9
- 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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DecisionEvidence } from "./decision-provider.js";
|
|
2
|
+
/** The longest title an item keeps, in code points. */
|
|
3
|
+
export declare const EVIDENCE_TITLE_MAX = 300;
|
|
4
|
+
/** The longest passage an item keeps, in code points. */
|
|
5
|
+
export declare const EVIDENCE_EXCERPT_MAX = 4096;
|
|
6
|
+
/** The most passages one item keeps. */
|
|
7
|
+
export declare const EVIDENCE_EXCERPTS_PER_ITEM = 5;
|
|
8
|
+
/** The most items a decision's evidence keeps. */
|
|
9
|
+
export declare const EVIDENCE_ITEMS_MAX = 20;
|
|
10
|
+
/** The most code points of titles and passages a decision's evidence keeps, all items together. */
|
|
11
|
+
export declare const EVIDENCE_TEXT_MAX: number;
|
|
12
|
+
/** What a caller keeps of each citation: `excerpts: false` keeps none of its passages. */
|
|
13
|
+
export type EvidenceOptions = {
|
|
14
|
+
excerpts?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Raw citations as a decision's evidence. Items in order, each kept or dropped by its URL, its text plain and cut, until
|
|
17
|
+
* the item count or the code-point budget is reached. With `excerpts: false` no item keeps a passage. Idempotent: clean
|
|
18
|
+
* evidence comes back as it went in. */
|
|
19
|
+
export declare function evidenceOf(raw: unknown, { excerpts: withExcerpts }?: EvidenceOptions): DecisionEvidence[];
|
package/dist/evidence.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isRecord } from "./record.js";
|
|
2
|
+
/** The longest title an item keeps, in code points. */
|
|
3
|
+
export const EVIDENCE_TITLE_MAX = 300;
|
|
4
|
+
/** The longest passage an item keeps, in code points. */
|
|
5
|
+
export const EVIDENCE_EXCERPT_MAX = 4096;
|
|
6
|
+
/** The most passages one item keeps. */
|
|
7
|
+
export const EVIDENCE_EXCERPTS_PER_ITEM = 5;
|
|
8
|
+
/** The most items a decision's evidence keeps. */
|
|
9
|
+
export const EVIDENCE_ITEMS_MAX = 20;
|
|
10
|
+
/** The most code points of titles and passages a decision's evidence keeps, all items together. */
|
|
11
|
+
export const EVIDENCE_TEXT_MAX = 32 * 1024;
|
|
12
|
+
/** The longest `scope` an item keeps, in code points. */
|
|
13
|
+
const SCOPE_MAX = 64;
|
|
14
|
+
// C0 controls but tab, newline and return; DEL and the C1 controls; the Unicode direction marks, overrides and isolates.
|
|
15
|
+
const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f--]/g;
|
|
16
|
+
const codePoints = (text) => Array.from(text).length;
|
|
17
|
+
/** `text` with its control characters gone, cut to `max` code points (an ellipsis marking a cut). */
|
|
18
|
+
function plain(text, max) {
|
|
19
|
+
const clean = text.replace(CONTROL, "");
|
|
20
|
+
const chars = Array.from(clean);
|
|
21
|
+
return chars.length <= max ? clean : `${chars.slice(0, Math.max(0, max - 1)).join("")}…`;
|
|
22
|
+
}
|
|
23
|
+
/** The URL as the parser normalizes it, if it is http(s) with no user or password; else undefined, and its item is dropped. */
|
|
24
|
+
function webUrl(url) {
|
|
25
|
+
if (typeof url !== "string")
|
|
26
|
+
return undefined;
|
|
27
|
+
const parsed = URL.parse(url);
|
|
28
|
+
if (!parsed || (parsed.protocol !== "http:" && parsed.protocol !== "https:") || parsed.username || parsed.password)
|
|
29
|
+
return undefined;
|
|
30
|
+
return parsed.href;
|
|
31
|
+
}
|
|
32
|
+
/** Raw citations as a decision's evidence. Items in order, each kept or dropped by its URL, its text plain and cut, until
|
|
33
|
+
* the item count or the code-point budget is reached. With `excerpts: false` no item keeps a passage. Idempotent: clean
|
|
34
|
+
* evidence comes back as it went in. */
|
|
35
|
+
export function evidenceOf(raw, { excerpts: withExcerpts = true } = {}) {
|
|
36
|
+
const kept = [];
|
|
37
|
+
let left = EVIDENCE_TEXT_MAX;
|
|
38
|
+
for (const item of Array.isArray(raw) ? raw : []) {
|
|
39
|
+
if (kept.length >= EVIDENCE_ITEMS_MAX || left <= 0)
|
|
40
|
+
break;
|
|
41
|
+
if (!isRecord(item))
|
|
42
|
+
continue;
|
|
43
|
+
const { url: rawUrl, title: rawTitle, excerpts: rawExcerpts, scope: rawScope } = item;
|
|
44
|
+
const url = webUrl(rawUrl);
|
|
45
|
+
if (!url)
|
|
46
|
+
continue;
|
|
47
|
+
const title = typeof rawTitle === "string" ? plain(rawTitle, Math.min(EVIDENCE_TITLE_MAX, left)) : null;
|
|
48
|
+
left -= title === null ? 0 : codePoints(title);
|
|
49
|
+
const excerpts = [];
|
|
50
|
+
for (const excerpt of withExcerpts && Array.isArray(rawExcerpts) ? rawExcerpts : []) {
|
|
51
|
+
if (excerpts.length >= EVIDENCE_EXCERPTS_PER_ITEM || left <= 0)
|
|
52
|
+
break;
|
|
53
|
+
if (typeof excerpt !== "string")
|
|
54
|
+
continue;
|
|
55
|
+
const text = plain(excerpt, Math.min(EVIDENCE_EXCERPT_MAX, left));
|
|
56
|
+
excerpts.push(text);
|
|
57
|
+
left -= codePoints(text);
|
|
58
|
+
}
|
|
59
|
+
const scope = typeof rawScope === "string" && rawScope ? plain(rawScope, SCOPE_MAX) : "call";
|
|
60
|
+
kept.push({ url, title, excerpts, scope });
|
|
61
|
+
}
|
|
62
|
+
return kept;
|
|
63
|
+
}
|
package/dist/graph.d.ts
CHANGED
|
@@ -14,6 +14,23 @@ export type GraphNode = {
|
|
|
14
14
|
label: string;
|
|
15
15
|
via?: string;
|
|
16
16
|
changeCheck?: string;
|
|
17
|
+
} & GraphDecision;
|
|
18
|
+
/** One typed question a decision node asks, as a viewer shows it: its id, its type (`unknown` when its schema is not a
|
|
19
|
+
* question the reader recognizes), its instructions, and a choice's options. */
|
|
20
|
+
export type GraphQuestion = {
|
|
21
|
+
id: string;
|
|
22
|
+
type: "noul" | "choice" | "score" | "unknown";
|
|
23
|
+
instructions: string;
|
|
24
|
+
options?: string[];
|
|
25
|
+
};
|
|
26
|
+
/** What a decision node (judge, pick, sift, a judged route, or a loop or escalate whose predicate is `ask`) says about
|
|
27
|
+
* its decision, read from the document: the provider and model it names (absent when it names none), its questions, and
|
|
28
|
+
* the tokens of the images it sends. A graph of another node carries none of these. */
|
|
29
|
+
export type GraphDecision = {
|
|
30
|
+
provider?: string;
|
|
31
|
+
model?: string;
|
|
32
|
+
questions?: GraphQuestion[];
|
|
33
|
+
images?: string[];
|
|
17
34
|
};
|
|
18
35
|
/** How control reaches `to` from `from`.
|
|
19
36
|
* - `next`: a chain enters its first step and each step is followed by the next; a loop enters its body, which runs again
|
package/dist/graph.js
CHANGED
|
@@ -58,16 +58,17 @@ const ownFields = (node) => {
|
|
|
58
58
|
export function workflowGraph(workflow) {
|
|
59
59
|
const nodes = [];
|
|
60
60
|
const edges = [];
|
|
61
|
-
const visit = (node, path, depth) => {
|
|
61
|
+
const visit = (node, path, depth, schemas) => {
|
|
62
62
|
if (!isObject(node) || typeof node.node !== "string" || depth > MAX_DEPTH)
|
|
63
63
|
return;
|
|
64
64
|
nodes.push({ path, kind: node.node, label: typeof node.label === "string" ? node.label : node.node,
|
|
65
|
-
...(node.node === "call" && typeof node.via === "string" ? { via: node.via } : {}), changeCheck: fnv1a(canonicalJson(ownFields(node)))
|
|
66
|
-
|
|
65
|
+
...(node.node === "call" && typeof node.via === "string" ? { via: node.via } : {}), changeCheck: fnv1a(canonicalJson(ownFields(node))),
|
|
66
|
+
...decisionOf(node, schemas) });
|
|
67
|
+
const child = (target, at, kind, from = path, inner = schemas) => {
|
|
67
68
|
if (!isObject(target) || typeof target.node !== "string" || depth + 1 > MAX_DEPTH)
|
|
68
69
|
return;
|
|
69
70
|
edges.push({ from, to: at, kind });
|
|
70
|
-
visit(target, at, depth + 1);
|
|
71
|
+
visit(target, at, depth + 1, inner);
|
|
71
72
|
};
|
|
72
73
|
switch (node.node) {
|
|
73
74
|
case "chain":
|
|
@@ -92,13 +93,77 @@ export function workflowGraph(workflow) {
|
|
|
92
93
|
break;
|
|
93
94
|
case "workflow":
|
|
94
95
|
if (isObject(node.workflow))
|
|
95
|
-
child(node.workflow.root, `${path}/workflow/root`, "child");
|
|
96
|
+
child(node.workflow.root, `${path}/workflow/root`, "child", path, isObject(node.workflow.schemas) ? node.workflow.schemas : {});
|
|
96
97
|
break;
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
|
-
visit(isObject(workflow) ? workflow.root : undefined, "/root", 0);
|
|
100
|
+
visit(isObject(workflow) ? workflow.root : undefined, "/root", 0, isObject(workflow) && isObject(workflow.schemas) ? workflow.schemas : {});
|
|
100
101
|
return { nodes, edges };
|
|
101
102
|
}
|
|
103
|
+
/** The questions of a question schema (`out` of a judge or sift): a flat object whose properties are the questions, a
|
|
104
|
+
* string enum a choice, a boolean a noul, an integer a score; a local `#/definitions/<id>` reference is followed. */
|
|
105
|
+
const schemaQuestions = (schemaId, schemas) => {
|
|
106
|
+
const root = typeof schemaId === "string" && Object.hasOwn(schemas, schemaId) ? schemas[schemaId] : undefined;
|
|
107
|
+
const resolve = (spec) => {
|
|
108
|
+
for (let hops = 0; isObject(spec) && typeof spec.$ref === "string" && hops < 8; hops += 1) {
|
|
109
|
+
const id = /^#\/definitions\/(.+)$/.exec(spec.$ref)?.[1];
|
|
110
|
+
const inline = isObject(root) && isObject(root.definitions) ? root.definitions : {};
|
|
111
|
+
spec = id === undefined ? undefined : Object.hasOwn(inline, id) ? inline[id] : Object.hasOwn(schemas, id) ? schemas[id] : undefined;
|
|
112
|
+
}
|
|
113
|
+
return spec;
|
|
114
|
+
};
|
|
115
|
+
const object = resolve(root);
|
|
116
|
+
if (!isObject(object) || !isObject(object.properties))
|
|
117
|
+
return [];
|
|
118
|
+
return Object.entries(object.properties).map(([id, raw]) => {
|
|
119
|
+
const spec = resolve(raw);
|
|
120
|
+
const instructions = isObject(spec) && typeof spec.description === "string" ? spec.description : "";
|
|
121
|
+
const types = isObject(spec) ? (Array.isArray(spec.type) ? spec.type : [spec.type]).filter((type) => type !== "null") : [];
|
|
122
|
+
if (isObject(spec) && Array.isArray(spec.enum))
|
|
123
|
+
return { id, type: "choice", instructions, options: spec.enum.map(String) };
|
|
124
|
+
if (types.length === 1 && types[0] === "boolean")
|
|
125
|
+
return { id, type: "noul", instructions };
|
|
126
|
+
if (types.length === 1 && types[0] === "integer")
|
|
127
|
+
return { id, type: "score", instructions };
|
|
128
|
+
return { id, type: "unknown", instructions };
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
/** A decision node's provider, model, questions and image tokens, as written. */
|
|
132
|
+
const decisionOf = (node, schemas) => {
|
|
133
|
+
let source = node;
|
|
134
|
+
let questions;
|
|
135
|
+
const text = (value) => typeof value === "string" ? value : "";
|
|
136
|
+
switch (node.node) {
|
|
137
|
+
case "judge":
|
|
138
|
+
case "sift":
|
|
139
|
+
questions = schemaQuestions(node.out, schemas);
|
|
140
|
+
break;
|
|
141
|
+
case "pick":
|
|
142
|
+
questions = [{ id: "pick", type: "choice", instructions: text(node.instructions) }];
|
|
143
|
+
break;
|
|
144
|
+
case "route":
|
|
145
|
+
if (node.valuePath !== undefined)
|
|
146
|
+
return {};
|
|
147
|
+
questions = [{ id: "branch", type: "choice", instructions: text(node.instructions), options: isObject(node.branches) ? Object.keys(node.branches) : [] }];
|
|
148
|
+
break;
|
|
149
|
+
case "loop":
|
|
150
|
+
case "escalate": {
|
|
151
|
+
const predicate = node.node === "loop" ? node.until : node.when;
|
|
152
|
+
if (!isObject(predicate) || predicate.predicate !== "ask")
|
|
153
|
+
return {};
|
|
154
|
+
source = predicate;
|
|
155
|
+
questions = [{ id: "holds", type: "noul", instructions: text(predicate.instructions) }];
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default: return {};
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
...(typeof source.provider === "string" ? { provider: source.provider } : {}),
|
|
162
|
+
...(typeof source.model === "string" ? { model: source.model } : {}),
|
|
163
|
+
questions,
|
|
164
|
+
...(isObject(source.images) && Object.keys(source.images).length ? { images: Object.keys(source.images) } : {}),
|
|
165
|
+
};
|
|
166
|
+
};
|
|
102
167
|
/** The execution path an instance of a node ran at, as the node's path in the document: a map's item and a loop's
|
|
103
168
|
* iteration have no node of their own. */
|
|
104
169
|
const definitionPath = (path) => path.replace(/\/items\/\d+\/body/g, "/body").replace(/\/iterations\/\d+(?=\/|$)/g, "");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
export { defineWorkflow, runTypedWorkflow, WorkflowSchemaConversionError } from "./authoring.js";
|
|
2
2
|
export type { StandardJSONSchema, AuthoringSchema, TypedWorkflow, TypedWorkflowRunResult, WorkflowInput, WorkflowOutput, } from "./authoring.js";
|
|
3
|
-
export { runWorkflow, validateWorkflow, workflowSha256, WorkflowInvalidError, WorkflowInputInvalidError, WorkflowOutputInvalidError, WorkflowCodeError, WorkflowStateError, WorkflowVerificationError, WorkflowDecisionRecordError, EffectFailure, EffectDeadlineExceededError, EffectOutcomeUnknownError, EscalationSignal, routesByValue, isItemFailure, } from "./workflow.js";
|
|
3
|
+
export { runWorkflow, validateWorkflow, workflowSha256, WorkflowInvalidError, WorkflowInputInvalidError, WorkflowOutputInvalidError, WorkflowCodeError, WorkflowStateError, WorkflowVerificationError, WorkflowDecisionRecordError, EffectFailure, EffectDeadlineExceededError, EffectOutcomeUnknownError, EscalationSignal, routesByValue, isItemFailure, MAP_LIMITS, } from "./workflow.js";
|
|
4
4
|
export { defineJob } from "./job.js";
|
|
5
5
|
export type { Job } from "./job.js";
|
|
6
|
-
export { DECISION_RECEIPT_VERSION, rederiveDecision } from "./decision-receipts.js";
|
|
7
|
-
export type { DecisionKind, DecisionReceipt, DecisionRule } from "./decision-receipts.js";
|
|
8
|
-
export type { Workflow, WorkflowNode, NodeMetadata, WorkflowDeps, WorkflowEvent, WorkflowRunResult, HostPolicy, HostPolicyContext, Escalation, EffectSettlement, MapItem, MapItemFailure, DecisionExchange, LlmNode, JudgeNode, PickNode, SiftNode, RouteNode, RouteByJudgmentNode, RouteByValueNode, WorkflowInvocation, ArtifactNode, ArtifactState, CallNode, CodeNode, CallRetryClass, EffectFailureCode, CallPredicate, PollClause, ModelTier, AgentContext, WorkflowEffort, WorkflowThinking, VerifyClause, AskPredicate, MechanicalPredicate, Predicate, ValidationCode, ValidationIssue, ValidateWorkflowOptions, } from "./workflow.js";
|
|
9
|
-
export { dryRunWorkflow, synthesizeInstance } from "./dry-run.js";
|
|
6
|
+
export { DECISION_RECEIPT_VERSION, DECISION_INTERRUPTED, DECISION_REFUSED, DECISION_STATE_MAX_BYTES, rederiveDecision } from "./decision-receipts.js";
|
|
7
|
+
export type { DecisionImageDigest, DecisionKind, DecisionReceipt, DecisionRule, DecisionStateCut, DecisionStateSent } from "./decision-receipts.js";
|
|
8
|
+
export type { Workflow, WorkflowNode, NodeMetadata, WorkflowDeps, MapLimits, WorkflowEvent, WorkflowRunResult, HostPolicy, HostPolicyContext, Escalation, EffectSettlement, MapItem, MapItemFailure, DecisionExchange, LlmNode, JudgeNode, PickNode, SiftNode, RouteNode, RouteByJudgmentNode, RouteByValueNode, WorkflowInvocation, ArtifactNode, ArtifactState, CallNode, CodeNode, CallRetryClass, EffectFailureCode, CallPredicate, PollClause, ModelTier, AgentContext, WorkflowEffort, WorkflowThinking, VerifyClause, AskPredicate, DecisionEvidenceMode, DecisionImages, MechanicalPredicate, Predicate, ReservedName, ValidationCode, ValidationIssue, ValidateWorkflowOptions, } from "./workflow.js";
|
|
9
|
+
export { dryRunWorkflow, SYNTHESIS_BUDGET, SynthesisTooLarge, synthesizeInstance, type SynthesisBudget } from "./dry-run.js";
|
|
10
10
|
export type { DryRunOptions, DryRunResult } from "./dry-run.js";
|
|
11
|
-
export { compileQuestions, validateAnswers, answersToValue, answersSidecar, answerConfidence, synthesizeAnswers, SYSTEM_ONE_LIMITS, SystemOneError, isSystemOneResponseReason, } from "./system-one.js";
|
|
12
|
-
export type { SystemOneQuestion, SystemOneAnswer, SystemOneBox, SystemOneResult, SystemOneRetryClass, SystemOneResponseReason, CompiledQuestions, AnswersSidecar, } from "./system-one.js";
|
|
11
|
+
export { compileQuestions, validateAnswers, answersToValue, answersSidecar, answerConfidence, synthesizeAnswers, SYSTEM_ONE_LIMITS, SystemOneError, isSystemOneResponseReason, deriveConfidence, completeConfidence, refusedQuestions, } from "./system-one.js";
|
|
12
|
+
export type { SystemOneQuestion, SystemOneAnswer, SystemOneBox, SystemOneResult, SystemOneRetryClass, SystemOneResponseReason, CompiledQuestions, AnswersSidecar, ConfidenceSource, } from "./system-one.js";
|
|
13
|
+
export { judgeFromProvider, judgeFromProviders, checkCapabilities, chargedCost, DecisionProviderError, imageDimensions } from "./decision-provider.js";
|
|
14
|
+
export { evidenceOf, EVIDENCE_EXCERPT_MAX, EVIDENCE_EXCERPTS_PER_ITEM, EVIDENCE_ITEMS_MAX, EVIDENCE_TEXT_MAX, EVIDENCE_TITLE_MAX, type EvidenceOptions } from "./evidence.js";
|
|
15
|
+
export type { DecisionProvider, DecisionCapabilities, DecisionInput, DecisionRequest, DecisionContext, DecisionEvidence, DecisionOutcome, ProviderAnswer, CostBasis, DecisionProviderErrorCode, DecisionImage, LoadImage, JudgeFromProviderOptions, } from "./decision-provider.js";
|
|
13
16
|
export { inspectWorkflow, formatWorkflowTree } from "./inspection.js";
|
|
14
17
|
export type { WorkflowInspection, WorkflowInspectionNode } from "./inspection.js";
|
|
15
|
-
export { runWorkflowSlice, assertWorkflowCapabilities, desugarWorkflow, stageSchemaForNode, submissionSchemaForNode, mergeStageDelta, REPORT_SCHEMA, SHELL_RESULT_SCHEMA, childSteps, declaredWrites,
|
|
16
|
-
export { compileTransform, compileTransformSyntax, deniedGlobalReferences } from "./code-exec.js";
|
|
18
|
+
export { runWorkflowSlice, assertWorkflowCapabilities, desugarWorkflow, stageSchemaForNode, submissionSchemaForNode, mergeStageDelta, REPORT_SCHEMA, SHELL_RESULT_SCHEMA, childSteps, declaredWrites, artifactNodeIsProse, schemaProblems, HOST_STATE_KEY, normalizeStringNullsForSchema, placeholderValue, placeholdersOf, } from "./workflow.js";
|
|
19
|
+
export { compileTransform, compileTransformSyntax, deniedGlobalReferences, type TransformOutcome, transformScript } from "./code-exec.js";
|
|
17
20
|
export { resolveSchemaForWorkflow } from "./schema-references.js";
|
|
21
|
+
export { formatPointerWarning, parsePointerWarning, type PointerWarning } from "./pointer-warning.js";
|
|
22
|
+
export { patternRisk, PATTERN_SCREEN_LIMITS } from "./pattern-screen.js";
|
|
18
23
|
export { submitParameters } from "./submit-envelope.js";
|
|
19
24
|
export { getPath, predicateMatches } from "./predicates.js";
|
|
20
25
|
export type { StopPredicate, AcceptPredicate } from "./predicates.js";
|
|
21
|
-
export { authorContract, renderAuthorContract, renderAuthorHostAddendum,
|
|
26
|
+
export { authorContract, renderAuthorContract, renderAuthorHostAddendum, applyHostOutputTypes, authorWorkflow, authorSkillDirectory, loadAuthorReference, loadAuthorSkillBundle, } from "./author.js";
|
|
22
27
|
export type { AuthorHostAddendum, CandidatePolicyOptions, AuthorWorkflowOptions, AuthoredWorkflow, HostOutputTypeOptions } from "./author.js";
|
|
23
|
-
export {
|
|
24
|
-
export type { WorkflowNodeKind, WorkflowPredicateName } from "./vocabulary.js";
|
|
28
|
+
export { GENERATIVE_NODE_KINDS, JUDGMENT_NODE_KINDS, NODE_FIELDS, HOST_NODE_FIELDS, IGNORED_NODE_FIELDS, MECHANICAL_PREDICATES, WORKFLOW_PREDICATES, PREDICATE_FIELDS, FIELD_TYPES, EFFORT_LEVELS, THINKING_LEVELS, MODEL_TIERS, AGENT_CONTEXTS, CALL_TRANSPORTS, CALL_RETRY_CLASSES, EFFECT_FAILURE_CODES, PROSE_ARTIFACT_TYPES, } from "./vocabulary.js";
|
|
29
|
+
export type { WorkflowNodeKind, WorkflowPredicateName, FieldType } from "./vocabulary.js";
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
export { defineWorkflow, runTypedWorkflow, WorkflowSchemaConversionError } from "./authoring.js";
|
|
2
|
-
export { runWorkflow, validateWorkflow, workflowSha256, WorkflowInvalidError, WorkflowInputInvalidError, WorkflowOutputInvalidError, WorkflowCodeError, WorkflowStateError, WorkflowVerificationError, WorkflowDecisionRecordError, EffectFailure, EffectDeadlineExceededError, EffectOutcomeUnknownError, EscalationSignal, routesByValue, isItemFailure, } from "./workflow.js";
|
|
2
|
+
export { runWorkflow, validateWorkflow, workflowSha256, WorkflowInvalidError, WorkflowInputInvalidError, WorkflowOutputInvalidError, WorkflowCodeError, WorkflowStateError, WorkflowVerificationError, WorkflowDecisionRecordError, EffectFailure, EffectDeadlineExceededError, EffectOutcomeUnknownError, EscalationSignal, routesByValue, isItemFailure, MAP_LIMITS, } from "./workflow.js";
|
|
3
3
|
export { defineJob } from "./job.js";
|
|
4
|
-
export { DECISION_RECEIPT_VERSION, rederiveDecision } from "./decision-receipts.js";
|
|
5
|
-
export { dryRunWorkflow, synthesizeInstance } from "./dry-run.js";
|
|
6
|
-
export { compileQuestions, validateAnswers, answersToValue, answersSidecar, answerConfidence, synthesizeAnswers, SYSTEM_ONE_LIMITS, SystemOneError, isSystemOneResponseReason, } from "./system-one.js";
|
|
4
|
+
export { DECISION_RECEIPT_VERSION, DECISION_INTERRUPTED, DECISION_REFUSED, DECISION_STATE_MAX_BYTES, rederiveDecision } from "./decision-receipts.js";
|
|
5
|
+
export { dryRunWorkflow, SYNTHESIS_BUDGET, SynthesisTooLarge, synthesizeInstance } from "./dry-run.js";
|
|
6
|
+
export { compileQuestions, validateAnswers, answersToValue, answersSidecar, answerConfidence, synthesizeAnswers, SYSTEM_ONE_LIMITS, SystemOneError, isSystemOneResponseReason, deriveConfidence, completeConfidence, refusedQuestions, } from "./system-one.js";
|
|
7
|
+
export { judgeFromProvider, judgeFromProviders, checkCapabilities, chargedCost, DecisionProviderError, imageDimensions } from "./decision-provider.js";
|
|
8
|
+
export { evidenceOf, EVIDENCE_EXCERPT_MAX, EVIDENCE_EXCERPTS_PER_ITEM, EVIDENCE_ITEMS_MAX, EVIDENCE_TEXT_MAX, EVIDENCE_TITLE_MAX } from "./evidence.js";
|
|
7
9
|
export { inspectWorkflow, formatWorkflowTree } from "./inspection.js";
|
|
8
10
|
export { runWorkflowSlice, assertWorkflowCapabilities, desugarWorkflow, stageSchemaForNode, submissionSchemaForNode, mergeStageDelta, REPORT_SCHEMA, SHELL_RESULT_SCHEMA,
|
|
9
11
|
// Document helpers a host facade needs to speak about a workflow without re-implementing the walk.
|
|
10
|
-
childSteps, declaredWrites,
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
childSteps, declaredWrites, artifactNodeIsProse, schemaProblems, HOST_STATE_KEY,
|
|
13
|
+
// The host-side normalization the interpreter itself uses.
|
|
14
|
+
normalizeStringNullsForSchema,
|
|
15
|
+
// Interpolation's placeholders in a string and its lookup order for one, for a host check of what a step reads.
|
|
16
|
+
placeholderValue, placeholdersOf, } from "./workflow.js";
|
|
17
|
+
export { compileTransform, compileTransformSyntax, deniedGlobalReferences, transformScript } from "./code-exec.js";
|
|
14
18
|
export { resolveSchemaForWorkflow } from "./schema-references.js";
|
|
19
|
+
export { formatPointerWarning, parsePointerWarning } from "./pointer-warning.js";
|
|
20
|
+
export { patternRisk, PATTERN_SCREEN_LIMITS } from "./pattern-screen.js";
|
|
15
21
|
export { submitParameters } from "./submit-envelope.js";
|
|
16
22
|
export { getPath, predicateMatches } from "./predicates.js";
|
|
17
|
-
export { authorContract, renderAuthorContract, renderAuthorHostAddendum,
|
|
18
|
-
export {
|
|
23
|
+
export { authorContract, renderAuthorContract, renderAuthorHostAddendum, applyHostOutputTypes, authorWorkflow, authorSkillDirectory, loadAuthorReference, loadAuthorSkillBundle, } from "./author.js";
|
|
24
|
+
export { GENERATIVE_NODE_KINDS, JUDGMENT_NODE_KINDS, NODE_FIELDS, HOST_NODE_FIELDS, IGNORED_NODE_FIELDS, MECHANICAL_PREDICATES, WORKFLOW_PREDICATES, PREDICATE_FIELDS, FIELD_TYPES, EFFORT_LEVELS, THINKING_LEVELS, MODEL_TIERS, AGENT_CONTEXTS, CALL_TRANSPORTS, CALL_RETRY_CLASSES, EFFECT_FAILURE_CODES, PROSE_ARTIFACT_TYPES, } from "./vocabulary.js";
|
package/dist/inspection.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export type WorkflowInspectionNode = {
|
|
|
11
11
|
/** Effective selection from completed map-item state; absent means whole item state. */
|
|
12
12
|
resultPath?: string;
|
|
13
13
|
childWorkflow?: string;
|
|
14
|
+
/** A decision node's (or an `ask` predicate's) provider and pinned model, when it names them, and the tokens of the
|
|
15
|
+
* images it sends. */
|
|
16
|
+
provider?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
images?: string[];
|
|
14
19
|
};
|
|
15
20
|
export type WorkflowInspection = {
|
|
16
21
|
name: string;
|
package/dist/inspection.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { routesByValue, workflowDocumentError, workflowSha256 } from "./workflow.js";
|
|
2
2
|
import { workflowShapeErrors } from "./workflow-shape.js";
|
|
3
|
+
/** What a decision node, or a loop's or escalate's `ask` predicate, names of its provider, model and images. */
|
|
4
|
+
function decisionFields(node) {
|
|
5
|
+
const source = node.node === "loop" ? node.until : node.node === "escalate" ? node.when
|
|
6
|
+
: ["judge", "pick", "sift"].includes(node.node) || node.node === "route" && !routesByValue(node) ? node : undefined;
|
|
7
|
+
if (!source || ((node.node === "loop" || node.node === "escalate") && source.predicate !== "ask"))
|
|
8
|
+
return {};
|
|
9
|
+
const { provider, model, images } = source;
|
|
10
|
+
return {
|
|
11
|
+
...(typeof provider === "string" ? { provider } : {}), ...(typeof model === "string" ? { model } : {}),
|
|
12
|
+
...(images && typeof images === "object" && Object.keys(images).length ? { images: Object.keys(images) } : {}),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
3
15
|
const pointer = (part) => part.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
4
16
|
/** Inspect a workflow's structure without running authored code, adapters, or schema probes.
|
|
5
17
|
* The input must be plain JSON data. This is a review aid, not execution admission: use
|
|
@@ -26,7 +38,8 @@ export function inspectWorkflow(value) {
|
|
|
26
38
|
...("out" in node && node.out && node.node !== "sift" ? { outputSchema: node.out } : {}),
|
|
27
39
|
...(node.node === "map" && (node.resultPath || "as" in node.body && node.body.as)
|
|
28
40
|
? { resultPath: node.resultPath || node.body.as } : {}),
|
|
29
|
-
...(node.node === "workflow" ? { childWorkflow: node.workflow.name } : {}),
|
|
41
|
+
...(node.node === "workflow" ? { childWorkflow: node.workflow.name } : {}),
|
|
42
|
+
...decisionFields(node), });
|
|
30
43
|
if (["agent", "decide", "extract", "report"].includes(node.node) ||
|
|
31
44
|
node.node === "artifact" && ["markdown", "report"].includes(node.type))
|
|
32
45
|
adapters.add("runNode");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The longest pattern read (characters), and the most quantifiers in one: a schema pattern is a few dozen of each. */
|
|
2
|
+
export declare const PATTERN_SCREEN_LIMITS: {
|
|
3
|
+
readonly chars: 4096;
|
|
4
|
+
readonly quantifiers: 128;
|
|
5
|
+
};
|
|
6
|
+
/** Why `pattern` may backtrack exponentially (or could not be read), or undefined when it is safe to test strings
|
|
7
|
+
* against. */
|
|
8
|
+
export declare function patternRisk(pattern: string): string | undefined;
|
|
9
|
+
/** Each pattern `schema` would test strings with (a `pattern`, a `patternProperties` key) that may backtrack
|
|
10
|
+
* exponentially, with why. */
|
|
11
|
+
export declare function riskyPatterns(schema: unknown): {
|
|
12
|
+
pattern: string;
|
|
13
|
+
why: string;
|
|
14
|
+
}[];
|