@parcha/agentrun-dsl 0.1.0-beta.13 → 0.1.0-beta.131
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 +155 -16
- 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 +20 -11
- package/dist/authoring.js +5 -4
- package/dist/cli.js +19 -13
- 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 +41 -1
- package/dist/dry-run.js +158 -27
- package/dist/evidence.d.ts +19 -0
- package/dist/evidence.js +63 -0
- package/dist/graph.d.ts +169 -0
- package/dist/graph.js +433 -0
- package/dist/index.d.ts +19 -12
- package/dist/index.js +17 -10
- package/dist/inspection.d.ts +5 -0
- package/dist/inspection.js +14 -1
- package/dist/job.d.ts +14 -0
- package/dist/job.js +5 -0
- 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/canonical-hash.d.ts +1 -1
- package/dist/recovery/canonical-hash.js +3 -3
- package/dist/recovery/driver.d.ts +79 -24
- package/dist/recovery/driver.js +634 -78
- package/dist/recovery/execution-path.d.ts +8 -0
- package/dist/recovery/execution-path.js +14 -0
- package/dist/recovery/frozen-snapshot.d.ts +128 -3
- package/dist/recovery/frozen-snapshot.js +63 -12
- package/dist/recovery/handoff-receipts.d.ts +0 -35
- package/dist/recovery/handoff-receipts.js +2 -44
- package/dist/recovery/index.d.ts +6 -10
- package/dist/recovery/index.js +5 -8
- package/dist/recovery/item-state.d.ts +48 -0
- package/dist/recovery/item-state.js +89 -0
- package/dist/recovery/journal.d.ts +6 -3
- package/dist/recovery/journal.js +20 -8
- package/dist/recovery/store.d.ts +33 -9
- package/dist/recovery/testing/conformance.js +55 -0
- package/dist/recovery/with-recovery.d.ts +9 -3
- package/dist/recovery/with-recovery.js +78 -18
- package/dist/submit-envelope.d.ts +9 -0
- package/dist/submit-envelope.js +44 -0
- package/dist/system-one.d.ts +37 -2
- package/dist/system-one.js +112 -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 +19 -9
- package/dist/workflow-shape.d.ts +7 -0
- package/dist/workflow-shape.js +116 -70
- package/dist/workflow.d.ts +173 -18
- package/dist/workflow.js +1103 -398
- package/dist/zod-json-contract.js +6 -8
- package/package.json +19 -4
- package/schema/workflow.schema.json +366 -1
- package/skills/author/SKILL.md +6 -1
- package/skills/author/references/jev-decisions.md +50 -5
- package/skills/author/references/language.md +19 -14
- package/skills/author/references/sdk-authoring.md +2 -0
- 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
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { RouteNode, Workflow, WorkflowDeps, WorkflowNode } from "../workflow.js";
|
|
2
|
-
import { type RouteDecision, type QuestionReceipts, type StepRecord, type EscalationRow } from "./frozen-snapshot.js";
|
|
2
|
+
import { FROZEN_SNAPSHOT_SCHEMA, FROZEN_SNAPSHOT_SCHEMA_V4, type RouteDecision, type QuestionReceipts, type StepRecord, type EscalationRow, type DecisionRequest } from "./frozen-snapshot.js";
|
|
3
3
|
import type { RecoveryBinding, RecoveryEffect, RecoveryStore } from "./store.js";
|
|
4
4
|
/** The branch a route runs for its answer, as the interpreter takes it: the node's `unsure` branch when
|
|
5
|
-
* the answer's confidence is below `unsure.gte`, else the choice the answer names.
|
|
5
|
+
* the answer's confidence is below `unsure.gte`, else the choice the answer names. A refused answer chose no branch:
|
|
6
|
+
* with an `unsure` branch the route took it (choice null, refused); without one the run escalated, and there is no
|
|
7
|
+
* decision (null). */
|
|
6
8
|
export declare function routeTaken(node: RouteNode, answers: unknown): {
|
|
7
9
|
branch: string;
|
|
8
|
-
choice: string;
|
|
10
|
+
choice: string | null;
|
|
9
11
|
unsure: boolean;
|
|
10
|
-
|
|
12
|
+
refused?: true;
|
|
13
|
+
} | null;
|
|
11
14
|
/** The binding of a run of `workflow` under what the host binds beside it. */
|
|
12
15
|
export declare function recoveryBinding(workflow: Workflow, bind?: Record<string, unknown>): string;
|
|
13
16
|
/** What a store is opened under for a run of `workflow`: its binding, and the digest of each input the binding
|
|
@@ -45,6 +48,11 @@ export type RecoveryOptions = {
|
|
|
45
48
|
/** Closes the session of an LLM step's attempt that ended without a submission. It runs on the driver's commit
|
|
46
49
|
* chain, before the commit that records the attempt as closed; its failure is the run's. */
|
|
47
50
|
closeStepSession?: (sessionId: string) => Promise<unknown>;
|
|
51
|
+
/** The host's barrier for an effect's admission: called on the driver's commit chain right after the admission's commit
|
|
52
|
+
* and before the effect is dispatched, so a host whose store syncs between commits (a run store at synchronous NORMAL)
|
|
53
|
+
* makes the admission durable first. Its failure is the run's, and the effect, admitted, is never dispatched: it stays
|
|
54
|
+
* unknown, for a reconcile. Absent, nothing runs between the admission and the dispatch. */
|
|
55
|
+
afterAdmit?: () => Promise<void>;
|
|
48
56
|
/** Settles effects a killed process left unknown, through the driver's own open of the run (one generation per process).
|
|
49
57
|
* `openRecovery` calls it once, after the open and before anything resumes, when the journal holds an effect that was
|
|
50
58
|
* admitted and never completed; `unknown` is those effects, with their `intent` and the `args` the call was admitted with (what the host's door is sent; absent on a record written before args were kept). `complete(id, value, receipt)`
|
|
@@ -65,11 +73,31 @@ export type RecoveryOptions = {
|
|
|
65
73
|
};
|
|
66
74
|
calls?: unknown[];
|
|
67
75
|
}) => Promise<void>) => Promise<void>;
|
|
76
|
+
/** How a new run, or one stored whole, is kept. `"v3"` (the default in this release) keeps the driver's whole state in
|
|
77
|
+
* one record, rewritten at every commit, so a map's commits grow with the square of its items. `"v4"`, the keyed
|
|
78
|
+
* layout, keeps what lies in each map item in that item's record and each state the driver references once by its
|
|
79
|
+
* digest (a failed map's finished results too), so a commit writes what it changed: a run stored whole moves to it at
|
|
80
|
+
* its first commit. After that move, the checkpoint bases of the driver's record keep the ids of the effects admitted
|
|
81
|
+
* before it: a cost bounded by the work done before the move, which later commits do not grow; each commit after the
|
|
82
|
+
* move costs the same however many items the map has. Only a store that
|
|
83
|
+
* keeps parts (its opened journal has `items` and `stateOf`) can hold it; on any other the driver keeps `"v3"` and says
|
|
84
|
+
* why once per open, in a `layout` note. A run stored in the keyed layout stays in it whatever this says, and a driver
|
|
85
|
+
* that knows only `"v3"` refuses to open it (`FROZEN_CHECKPOINT_INVALID`). Release 0.1.0-beta.13 and earlier fail their
|
|
86
|
+
* own task on a run in the keyed layout and report it refused; that ends the run's agent nodes in flight, and the run
|
|
87
|
+
* then fails on this release too, with no call repeated and nothing corrupted. So opt in only when no process on an
|
|
88
|
+
* earlier release can open the run. A build from this release on leaves a run stored in a schema newer than it knows
|
|
89
|
+
* pending (`RECOVERY_SCHEMA_NEWER`), for a build that knows it. */
|
|
90
|
+
layout?: "v3" | "v4";
|
|
68
91
|
};
|
|
69
92
|
/** What a host's effect adapter receives under the driver: the interpreter's parameters, `call`, which keeps each
|
|
70
93
|
* outside call the effect makes on its record as the call ends, and `effect`, the admitted effect: its journal id and
|
|
71
94
|
* the hash of its arguments, as the journal stores them and the same in every process of the run. A host that keeps
|
|
72
|
-
* what an outside call answered under them can settle an effect whose call was cut with `journal.complete`.
|
|
95
|
+
* what an outside call answered under them can settle an effect whose call was cut with `journal.complete`.
|
|
96
|
+
*
|
|
97
|
+
* What the adapter returns is the effect's result, whatever its fields. An adapter that cannot know whether the outside
|
|
98
|
+
* call happened throws: a `RecoveryError` with code `FROZEN_EFFECT_UNKNOWN`, its `cause` what it observed (kept for the
|
|
99
|
+
* operator in the checkpoint's `unknownResponses`), or an `EffectOutcomeUnknownError`. The effect then stays unknown,
|
|
100
|
+
* is never dispatched again, and the run resumes only once the host reconciles it, as after any call that throws. */
|
|
73
101
|
export type RecoveryEffectParams = Parameters<NonNullable<WorkflowDeps["runEffect"]>>[0] & {
|
|
74
102
|
call?: (record: unknown) => void;
|
|
75
103
|
effect?: {
|
|
@@ -87,6 +115,14 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
87
115
|
pollStartedAt: (node: import("../workflow.js").CallNode, item?: import("../workflow.js").MapItem, executionPath?: string) => number;
|
|
88
116
|
wait: (node: import("../workflow.js").CallNode, ms: number, item?: import("../workflow.js").MapItem, executionPath?: string) => Promise<void>;
|
|
89
117
|
fail?: (node: WorkflowNode, results: unknown[], error: unknown, executionPath?: string) => Promise<void>;
|
|
118
|
+
failItem?: (node: WorkflowNode, failure: import("../workflow.js").MapItemFailure, executionPath?: string) => Promise<void>;
|
|
119
|
+
itemFailure?: (node: WorkflowNode, executionPath
|
|
120
|
+
/** One write in the keyed layout: the driver's record without what lies in map items, the records of the items that
|
|
121
|
+
* changed, and the states first referenced now. `admitting` is an effect admitted in this write; `owner` the item that
|
|
122
|
+
* lists it. */
|
|
123
|
+
? /** One write in the keyed layout: the driver's record without what lies in map items, the records of the items that
|
|
124
|
+
* changed, and the states first referenced now. `admitting` is an effect admitted in this write; `owner` the item that
|
|
125
|
+
* lists it. */: string) => Promise<import("../workflow.js").MapItemFailure | undefined>;
|
|
90
126
|
decision?: (id: string) => Promise<import("../decision-receipts.js").DecisionReceipt | undefined>;
|
|
91
127
|
};
|
|
92
128
|
signal: AbortSignal;
|
|
@@ -101,6 +137,11 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
101
137
|
message: string;
|
|
102
138
|
label: string;
|
|
103
139
|
} | null;
|
|
140
|
+
/** How this open keeps the run: the layout's schema, and why it is not the keyed one the host asked for. */
|
|
141
|
+
readonly layout: {
|
|
142
|
+
schema: typeof FROZEN_SNAPSHOT_SCHEMA | typeof FROZEN_SNAPSHOT_SCHEMA_V4;
|
|
143
|
+
reason?: string;
|
|
144
|
+
};
|
|
104
145
|
binding: string;
|
|
105
146
|
/** The run's key: what its step sessions and effects are named under. */
|
|
106
147
|
driverId: string;
|
|
@@ -129,7 +170,7 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
129
170
|
stepAdmitted(executionPath: unknown): boolean;
|
|
130
171
|
/** The current attempt did not submit: its session closes with its spend kept.
|
|
131
172
|
* The step is `closed` until a retry is admitted, or `failed` when no attempt remains. */
|
|
132
|
-
stepAttemptFailed(executionPath: unknown, final?: boolean): void;
|
|
173
|
+
stepAttemptFailed(executionPath: unknown, final?: boolean, error?: unknown): void;
|
|
133
174
|
/** The step delivered its record; the row and the step record agree before the step commit. */
|
|
134
175
|
stepSubmitted(executionPath: unknown): void;
|
|
135
176
|
/** The short identity of an admitted LLM step (a digest of its frame and path), for the escalation
|
|
@@ -140,8 +181,12 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
140
181
|
* persistence failure. */
|
|
141
182
|
charge(usd: number): Promise<void>;
|
|
142
183
|
/** A question's metered spend, committed with the driver's state so a resume that skips the
|
|
143
|
-
* finished question still reports it
|
|
144
|
-
*
|
|
184
|
+
* finished question still reports it. A priced answer adds to `questionSpendUsd`; an answer with no
|
|
185
|
+
* price (`null`, or a cost that is not a non-negative finite number) is counted in
|
|
186
|
+
* `unpricedQuestionCount` instead, so the run's spend is read as incomplete and never as a bare total
|
|
187
|
+
* that silently omits it: an unknown cost is never zero. A route's answer is its decision: it commits
|
|
188
|
+
* in the same save, once per route path, and a resume inside the branch follows it instead of asking
|
|
189
|
+
* again; its price, priced or not, is recorded the same way. */
|
|
145
190
|
recordQuestionSpend(usd: number | null, route?: {
|
|
146
191
|
executionPath: unknown;
|
|
147
192
|
label: string;
|
|
@@ -152,35 +197,45 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
152
197
|
* receipts a resume would write. */
|
|
153
198
|
routeReceipted(executionPath: unknown): void;
|
|
154
199
|
/** The committed decision of the route at `executionPath`, if it was answered in an earlier process. */
|
|
200
|
+
/** Moves the poll window of the call node at `executionPath` back by `ms`, the time its host held the call (a pause
|
|
201
|
+
* for a raise of the run's spend cap, which no deadline is for), durably: a later open reads the moved window, and
|
|
202
|
+
* the next effect's check (wrapEffect) and the interpreter's poll start (pollStartedAt) take it. A node with no poll
|
|
203
|
+
* window started, or no time held, moves nothing. `hold` names the hold (the host's id for it): one hold moves the
|
|
204
|
+
* window once, however often a resume reports it again. */
|
|
205
|
+
holdPoll(executionPath: unknown, ms: number, hold: string): void;
|
|
155
206
|
routeDecision(executionPath: unknown): RouteDecision | undefined;
|
|
207
|
+
/** Every decision request this run committed, by decision id. */
|
|
208
|
+
decisionRequests(): Record<string, DecisionRequest>;
|
|
209
|
+
/** Admits a decision's request before the host's judge is asked, in the driver's next commit, which the caller
|
|
210
|
+
* awaits: a new request, or the next attempt of one that failed in its own process (undefined). A request found
|
|
211
|
+
* in any other status was asked by an earlier process and is returned as it stands; the caller does not ask again.
|
|
212
|
+
* An admitted request is in flight until `decisionSettled`: a pause waits for it, as for an effect. */
|
|
213
|
+
admitDecision(executionPath: unknown, request: Pick<DecisionRequest, "decision_id" | "kind" | "label" | "model" | "request_sha256">): DecisionRequest | undefined;
|
|
214
|
+
/** A request `admitDecision` admitted is no longer in flight. */
|
|
215
|
+
decisionSettled(): void;
|
|
216
|
+
/** A decision request's one outcome, with its spend (null when unknown), in the driver's next commit, together with
|
|
217
|
+
* whatever `alongside` records (the answer's spend, a route's decision): no commit holds the one without the other.
|
|
218
|
+
* It never applies a stop: a request the run asked ends whatever stops the run. */
|
|
219
|
+
decisionEnded(executionPath: unknown, decisionId: string, status: "answered" | "failed" | "interrupted", cost_usd: number | null, alongside?: () => void): void;
|
|
156
220
|
/** The escalation that ended this run (a gate that fired, or an LLM step that failed), written once
|
|
157
221
|
* as an escalation commit before anything acts on it. A later open gets the same row and the same
|
|
158
222
|
* continuation identity, whatever fires again. */
|
|
159
223
|
escalate(row: Omit<EscalationRow, "tail" | "revision">): Promise<EscalationRow>;
|
|
160
224
|
escalation(): EscalationRow | undefined;
|
|
225
|
+
/** The driver's frame as it stands, serialized: what a host shows of a live run while its store is held. */
|
|
226
|
+
pinJson(): string;
|
|
161
227
|
/** How many effects the driver admitted. */
|
|
162
228
|
effectCalls(): number;
|
|
163
|
-
/** What the continuation inherited, against the escalation that admitted it: the level, the sizes of what it
|
|
164
|
-
* read and its identity. */
|
|
165
|
-
annotateHandoff(detail: {
|
|
166
|
-
escalation_revision: number;
|
|
167
|
-
tail: string;
|
|
168
|
-
inherit: string;
|
|
169
|
-
block_chars: number;
|
|
170
|
-
digest_chars: number;
|
|
171
|
-
}): Promise<void>;
|
|
172
|
-
/** The run's spend at the moment its continuation is admitted. Spend may land under this run after
|
|
173
|
-
* the escalation commit, so the row the continuation reads the spend from is brought current here,
|
|
174
|
-
* by one `handoff` commit that names the escalation. The escalation's revision, what the
|
|
175
|
-
* continuation binds on, does not change. */
|
|
176
|
-
handoff(spend: Pick<EscalationRow, "cost_usd" | "turns" | "effect_calls">): Promise<EscalationRow>;
|
|
177
229
|
/** The state the document's committed top-level prefix left behind, plus what a failed map's finished
|
|
178
230
|
* items produced under the map's key: what an escalation on a failure carries. */
|
|
179
231
|
lastState(): Record<string, unknown>;
|
|
180
232
|
readonly started: boolean;
|
|
181
233
|
wrapEffect(run: (params: RecoveryEffectParams) => Promise<unknown>): NonNullable<WorkflowDeps["runEffect"]>;
|
|
182
|
-
/** Every commit the driver started has landed; a failed one is thrown. */
|
|
234
|
+
/** Every commit the driver started has landed; a failed one is thrown, a pause's or a cancel's own commit included. */
|
|
183
235
|
flush: () => Promise<void>;
|
|
184
|
-
/** Let go of the run once every commit the driver started has landed.
|
|
236
|
+
/** Let go of the run once every commit the driver started has landed. A commit the store refused after a pause or
|
|
237
|
+
* cancel is thrown once the journal is released: the stop is not durable, and the host must not take the run as
|
|
238
|
+
* stopped. It is thrown even when a later stop's commit lands, since a later commit does not carry every record the
|
|
239
|
+
* refused one held. A run's own failed commit is the run's failure and is not thrown again here. */
|
|
185
240
|
close(): Promise<void>;
|
|
186
241
|
}>;
|