@parcha/agentrun-dsl 0.1.0-beta.42 → 0.1.0-beta.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/author-references.d.ts +1 -1
- package/dist/author-references.js +1 -1
- package/dist/author.js +1 -11
- package/dist/dry-run.js +0 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/recovery/driver.d.ts +1 -1
- package/dist/vocabulary.d.ts +0 -12
- package/dist/vocabulary.js +7 -18
- package/dist/workflow.d.ts +1 -104
- package/dist/workflow.js +6 -424
- package/package.json +1 -1
- package/schema/workflow.schema.json +0 -54
- package/skills/author/references/language.md +9 -18
package/dist/workflow.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AcceptPredicate } from "./predicates.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EFFECT_FAILURE_CODES } from "./vocabulary.js";
|
|
3
3
|
import { type ConfidenceSource, type SystemOneAnswer, type SystemOneQuestion } from "./system-one.js";
|
|
4
4
|
import { type CostBasis, type DecisionEvidence, type DecisionProvider } from "./decision-provider.js";
|
|
5
5
|
import { type DecisionImageDigest, type DecisionReceipt, type DecisionStateSent } from "./decision-receipts.js";
|
|
@@ -49,32 +49,6 @@ export type WorkflowThinking = "low" | "medium" | "high";
|
|
|
49
49
|
export type NodeMetadata = {
|
|
50
50
|
[key: string]: unknown;
|
|
51
51
|
};
|
|
52
|
-
/** A step guard as a document holds it (StepGuard once validateWorkflow accepted it): an object the validator reads field
|
|
53
|
-
* by field, so a wrong signal or threshold is refused in words an author can act on, never a schema union's. */
|
|
54
|
-
export type NodeGuard = {
|
|
55
|
-
[key: string]: unknown;
|
|
56
|
-
};
|
|
57
|
-
/** A logistic fitted on the job's graded runs: p = 1 / (1 + e^-(b + w·x)), x the guard's signals in order ([self], [jev] or
|
|
58
|
-
* [self, jev]); `n` the graded runs it was fitted on, `fitted_at` when (ISO 8601). */
|
|
59
|
-
export type GuardFit = {
|
|
60
|
-
w: number[];
|
|
61
|
-
b: number;
|
|
62
|
-
n: number;
|
|
63
|
-
fitted_at: string;
|
|
64
|
-
};
|
|
65
|
-
/** The longest question a guard asks Jev, in characters. */
|
|
66
|
-
export declare const GUARD_QUESTION_MAX = 2000;
|
|
67
|
-
/** A step guard: after the step ran, the probability it is right (`p`, from its signal, through `fit` when one is stored);
|
|
68
|
-
* below `threshold` the run hands the job back (escalates, kind `guard`). `self` reads the step's own confidence (agent,
|
|
69
|
-
* decide, judge, pick, sift); `jev` one Jev question over the step's input and output (`question`, or the host's default);
|
|
70
|
-
* `both` a fitted logistic over [self, jev], or with no fit the lower of the two. The engine reads its shape and the
|
|
71
|
-
* step's own confidence; the host's `guardStep` computes p (it asks Jev). */
|
|
72
|
-
export type StepGuard = {
|
|
73
|
-
signal: GuardSignal;
|
|
74
|
-
threshold: number;
|
|
75
|
-
question?: string;
|
|
76
|
-
fit?: GuardFit;
|
|
77
|
-
};
|
|
78
52
|
export type WorkflowNode = {
|
|
79
53
|
node: "chain";
|
|
80
54
|
steps: WorkflowNode[];
|
|
@@ -84,7 +58,6 @@ export type WorkflowNode = {
|
|
|
84
58
|
label: string;
|
|
85
59
|
code: string;
|
|
86
60
|
as?: string;
|
|
87
|
-
guard?: NodeGuard;
|
|
88
61
|
metadata?: NodeMetadata;
|
|
89
62
|
} | {
|
|
90
63
|
node: "agent";
|
|
@@ -106,7 +79,6 @@ export type WorkflowNode = {
|
|
|
106
79
|
* enforces nothing. @minimum 1 @TJS-type integer */
|
|
107
80
|
max_turns?: number;
|
|
108
81
|
context?: AgentContext;
|
|
109
|
-
guard?: NodeGuard;
|
|
110
82
|
metadata?: NodeMetadata;
|
|
111
83
|
} | {
|
|
112
84
|
node: "decide";
|
|
@@ -122,7 +94,6 @@ export type WorkflowNode = {
|
|
|
122
94
|
thinking?: WorkflowThinking;
|
|
123
95
|
verify?: VerifyClause;
|
|
124
96
|
tier?: ModelTier;
|
|
125
|
-
guard?: NodeGuard;
|
|
126
97
|
metadata?: NodeMetadata;
|
|
127
98
|
} | {
|
|
128
99
|
node: "extract";
|
|
@@ -138,7 +109,6 @@ export type WorkflowNode = {
|
|
|
138
109
|
thinking?: WorkflowThinking;
|
|
139
110
|
verify?: VerifyClause;
|
|
140
111
|
tier?: ModelTier;
|
|
141
|
-
guard?: NodeGuard;
|
|
142
112
|
metadata?: NodeMetadata;
|
|
143
113
|
} | {
|
|
144
114
|
node: "report";
|
|
@@ -204,7 +174,6 @@ export type JudgeNode = {
|
|
|
204
174
|
evidence?: DecisionEvidenceMode;
|
|
205
175
|
timeoutMs?: number;
|
|
206
176
|
images?: DecisionImages;
|
|
207
|
-
guard?: NodeGuard;
|
|
208
177
|
metadata?: NodeMetadata;
|
|
209
178
|
};
|
|
210
179
|
/** One choice whose options are the items of a list. `describe` renders each item as its option
|
|
@@ -226,7 +195,6 @@ export type PickNode = {
|
|
|
226
195
|
evidence?: DecisionEvidenceMode;
|
|
227
196
|
timeoutMs?: number;
|
|
228
197
|
images?: DecisionImages;
|
|
229
|
-
guard?: NodeGuard;
|
|
230
198
|
metadata?: NodeMetadata;
|
|
231
199
|
};
|
|
232
200
|
/** The same question set (`out`, a judge schema) asked of every item of a list in ONE request: item i's
|
|
@@ -251,7 +219,6 @@ export type SiftNode = {
|
|
|
251
219
|
evidence?: DecisionEvidenceMode;
|
|
252
220
|
timeoutMs?: number;
|
|
253
221
|
images?: DecisionImages;
|
|
254
|
-
guard?: NodeGuard;
|
|
255
222
|
metadata?: NodeMetadata;
|
|
256
223
|
};
|
|
257
224
|
/** Run one of several named branches. Jev chooses it from `instructions` and `state`, or the workflow
|
|
@@ -319,7 +286,6 @@ export type WorkflowInvocation = {
|
|
|
319
286
|
input: Record<string, unknown>;
|
|
320
287
|
out: string;
|
|
321
288
|
as: string;
|
|
322
|
-
guard?: NodeGuard;
|
|
323
289
|
metadata?: NodeMetadata;
|
|
324
290
|
};
|
|
325
291
|
/** `exit` is a shell command that ended with a non-zero status: retried only when the author
|
|
@@ -403,8 +369,6 @@ export type CallNode = {
|
|
|
403
369
|
/** Repeat the call until its result settles (a queued job, an eventually consistent read). */
|
|
404
370
|
poll?: PollClause;
|
|
405
371
|
requires?: string[];
|
|
406
|
-
/** A step guard (StepGuard): its signal can only be `jev`, a call reports no confidence. */
|
|
407
|
-
guard?: NodeGuard;
|
|
408
372
|
metadata?: NodeMetadata;
|
|
409
373
|
};
|
|
410
374
|
export declare const SHELL_RESULT_SCHEMA: Record<string, unknown>;
|
|
@@ -627,18 +591,6 @@ export type WorkflowDeps = {
|
|
|
627
591
|
* records it, not the state asked. A failed request's DecisionProviderError carries it as `stateSent`. */
|
|
628
592
|
state_sent?: DecisionStateSent;
|
|
629
593
|
}>;
|
|
630
|
-
/** The host's step guards (StepGuard), asked after each guarded step ran and before its state is committed: what the
|
|
631
|
-
* step saw (`input`), what it wrote (`output`), and its own confidence (`self`: an agent or decide node's submitted
|
|
632
|
-
* one, a judge, pick or sift node's weakest answer's; null when the guard reads none or the step reported none). It
|
|
633
|
-
* answers the probability the step is right (`p`); below the guard's threshold, or with no p, the run hands the job
|
|
634
|
-
* back: it escalates (kind `guard`, stage the step's label) with the step's state. A workflow that holds a guard is
|
|
635
|
-
* refused before any node runs on a host without it. */
|
|
636
|
-
guardStep?: (params: GuardStepParams) => Promise<GuardVerdict>;
|
|
637
|
-
/** Escalate nodes the host records instead of obeying, by label (a child workflow's as its events name it,
|
|
638
|
-
* `parent/child`): one it says true of evaluates its `when` as any does and says so in its `escalate.evaluated` event
|
|
639
|
-
* (`soft: true`), and the run goes on past it whether it fired or not. A replay reads what the workflow would have
|
|
640
|
-
* answered past a check it is measuring. Absent: every escalate that fires hands the job back. */
|
|
641
|
-
softEscalate?: (label: string) => boolean;
|
|
642
594
|
/** Records one typed-question request and what its answers decide. It is awaited before the answers
|
|
643
595
|
* reach state, an event or a branch, so a durable recorder holds every decision the run acted on; a
|
|
644
596
|
* rejection fails the node. A request the judge could not answer, or one cancelled in flight, is
|
|
@@ -695,46 +647,6 @@ export type WorkflowEvent = {
|
|
|
695
647
|
detail?: unknown;
|
|
696
648
|
executionPath?: string;
|
|
697
649
|
};
|
|
698
|
-
/** What a host's `guardStep` is asked with (WorkflowDeps.guardStep). */
|
|
699
|
-
export type GuardStepParams = {
|
|
700
|
-
label: string;
|
|
701
|
-
kind: WorkflowNode["node"];
|
|
702
|
-
guard: StepGuard;
|
|
703
|
-
/** What the step was asked to do (guardAskOf): without it two steps over the same input that ask for different things
|
|
704
|
-
* read the same to Jev. */
|
|
705
|
-
task: GuardTask;
|
|
706
|
-
/** What the step saw: its interpolated `state` (or a call's `args`, an executor's `input`, a child's `input`), else the
|
|
707
|
-
* workflow's state before it. */
|
|
708
|
-
input: unknown;
|
|
709
|
-
/** What the step wrote: the value under its `as` (or its label), or the keys it changed. */
|
|
710
|
-
output: unknown;
|
|
711
|
-
/** The step's own confidence in [0, 1], for a guard that reads it; null otherwise or when it reported none. */
|
|
712
|
-
self: number | null;
|
|
713
|
-
executionPath: string;
|
|
714
|
-
item?: MapItem;
|
|
715
|
-
signal?: AbortSignal;
|
|
716
|
-
};
|
|
717
|
-
/** What a guarded step was asked to do, as its guard is asked about it, its instructions first: an agent, decide, extract
|
|
718
|
-
* or pick node's `instructions` (a pick's with whether none may fit); a judge or sift's questions (its `out` compiled,
|
|
719
|
-
* each question's type and words, as its judge was asked them); the schema its value meets (an agent, decide or extract
|
|
720
|
-
* node's `out`, a call's or a child workflow's); a code node's or an executor's code, a tool call's tool, a shell's
|
|
721
|
-
* command, a child's workflow name. */
|
|
722
|
-
export type GuardTask = {
|
|
723
|
-
instructions?: string;
|
|
724
|
-
allow_none?: boolean;
|
|
725
|
-
questions?: Record<string, unknown>;
|
|
726
|
-
schema?: unknown;
|
|
727
|
-
code?: string;
|
|
728
|
-
tool?: string;
|
|
729
|
-
command?: string;
|
|
730
|
-
workflow?: string;
|
|
731
|
-
};
|
|
732
|
-
/** A host's guard verdict: `p`, the probability the step is right. */
|
|
733
|
-
export type GuardVerdict = {
|
|
734
|
-
p: number;
|
|
735
|
-
/** Jev's answer, for a guard that asked it: what the run record keeps beside p. */
|
|
736
|
-
jev?: number | null;
|
|
737
|
-
};
|
|
738
650
|
type JudgeRequest = Parameters<NonNullable<WorkflowDeps["runJudge"]>>[0];
|
|
739
651
|
type JudgeResult = Awaited<ReturnType<NonNullable<WorkflowDeps["runJudge"]>>>;
|
|
740
652
|
/** What a decision recorder gets beside the receipt: the request as the host's `runJudge` received it,
|
|
@@ -916,21 +828,6 @@ export declare class WorkflowDecisionRecordError extends Error {
|
|
|
916
828
|
}
|
|
917
829
|
/** The reserved state key host policy writes under. Engine-owned like every `$`-prefixed key: no node may name it. */
|
|
918
830
|
export declare const HOST_STATE_KEY = "$host";
|
|
919
|
-
/** A node's step guard, as the document holds it (validateWorkflow refused any other shape). */
|
|
920
|
-
export declare function stepGuardOf(node: WorkflowNode): StepGuard | undefined;
|
|
921
|
-
/** The field an agent or decide node whose guard reads `self` submits its confidence in, beside its record. */
|
|
922
|
-
export declare const SELF_CONFIDENCE_FIELD = "confidence";
|
|
923
|
-
/** The engine-owned state key an agent or decide node's own confidence lands under, beside its value: `<key>$confidence`. */
|
|
924
|
-
export declare const confidenceKey: (key: string) => string;
|
|
925
|
-
/** The escalate nodes of a workflow document that read a judge's output, by label as a run names its step (a child's
|
|
926
|
-
* `parent/child`, as WorkflowDeps.softEscalate is asked): each whose `when` (under any number of `not`s) reads a field a
|
|
927
|
-
* judge node wrote (an `ask` predicate: every key its `state` reads, and it reads at least one), the judge being the step that last wrote that path's head on every path a run can take to the
|
|
928
|
-
* escalate (a judge an extract overwrites, one in only some of a route's branches, one a code node with no `as` may have
|
|
929
|
-
* overwritten, are not). A judge's field is one model's opinion of a draft the workflow already wrote, so a host that
|
|
930
|
-
* measures the check may record it instead of obeying it (WorkflowDeps.softEscalate) and read the draft past it. A
|
|
931
|
-
* document too deep to walk, or whose loop's writes do not settle, has none. The document is read as it is: no
|
|
932
|
-
* validation, and a malformed node writes nothing it cannot name. */
|
|
933
|
-
export declare function softEscalates(doc: unknown): Set<string>;
|
|
934
831
|
export declare class WorkflowVerificationError extends Error {
|
|
935
832
|
readonly stage: string;
|
|
936
833
|
readonly candidate: unknown;
|