@parcha/agentrun-dsl 0.1.0-beta.16 → 0.1.0-beta.161
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 +153 -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 +35 -1
- package/dist/dry-run.js +131 -25
- package/dist/evidence.d.ts +19 -0
- package/dist/evidence.js +63 -0
- package/dist/graph.d.ts +107 -5
- package/dist/graph.js +284 -9
- 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 +59 -24
- package/dist/recovery/driver.js +251 -73
- package/dist/recovery/frozen-snapshot.d.ts +54 -4
- package/dist/recovery/frozen-snapshot.js +44 -14
- 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 +78 -18
- 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 +19 -9
- package/dist/workflow-shape.d.ts +7 -0
- package/dist/workflow-shape.js +116 -70
- package/dist/workflow.d.ts +171 -19
- package/dist/workflow.js +1063 -399
- package/dist/zod-json-contract.js +6 -8
- package/package.json +12 -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/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 { FROZEN_SNAPSHOT_SCHEMA, FROZEN_SNAPSHOT_SCHEMA_V4, 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)`
|
|
@@ -84,7 +92,12 @@ export type RecoveryOptions = {
|
|
|
84
92
|
/** What a host's effect adapter receives under the driver: the interpreter's parameters, `call`, which keeps each
|
|
85
93
|
* outside call the effect makes on its record as the call ends, and `effect`, the admitted effect: its journal id and
|
|
86
94
|
* the hash of its arguments, as the journal stores them and the same in every process of the run. A host that keeps
|
|
87
|
-
* 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. */
|
|
88
101
|
export type RecoveryEffectParams = Parameters<NonNullable<WorkflowDeps["runEffect"]>>[0] & {
|
|
89
102
|
call?: (record: unknown) => void;
|
|
90
103
|
effect?: {
|
|
@@ -102,6 +115,14 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
102
115
|
pollStartedAt: (node: import("../workflow.js").CallNode, item?: import("../workflow.js").MapItem, executionPath?: string) => number;
|
|
103
116
|
wait: (node: import("../workflow.js").CallNode, ms: number, item?: import("../workflow.js").MapItem, executionPath?: string) => Promise<void>;
|
|
104
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>;
|
|
105
126
|
decision?: (id: string) => Promise<import("../decision-receipts.js").DecisionReceipt | undefined>;
|
|
106
127
|
};
|
|
107
128
|
signal: AbortSignal;
|
|
@@ -149,7 +170,7 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
149
170
|
stepAdmitted(executionPath: unknown): boolean;
|
|
150
171
|
/** The current attempt did not submit: its session closes with its spend kept.
|
|
151
172
|
* The step is `closed` until a retry is admitted, or `failed` when no attempt remains. */
|
|
152
|
-
stepAttemptFailed(executionPath: unknown, final?: boolean): void;
|
|
173
|
+
stepAttemptFailed(executionPath: unknown, final?: boolean, error?: unknown): void;
|
|
153
174
|
/** The step delivered its record; the row and the step record agree before the step commit. */
|
|
154
175
|
stepSubmitted(executionPath: unknown): void;
|
|
155
176
|
/** The short identity of an admitted LLM step (a digest of its frame and path), for the escalation
|
|
@@ -160,8 +181,12 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
160
181
|
* persistence failure. */
|
|
161
182
|
charge(usd: number): Promise<void>;
|
|
162
183
|
/** A question's metered spend, committed with the driver's state so a resume that skips the
|
|
163
|
-
* finished question still reports it
|
|
164
|
-
*
|
|
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. */
|
|
165
190
|
recordQuestionSpend(usd: number | null, route?: {
|
|
166
191
|
executionPath: unknown;
|
|
167
192
|
label: string;
|
|
@@ -172,35 +197,45 @@ export declare function openRecovery(store: RecoveryStore, workflow: Workflow, o
|
|
|
172
197
|
* receipts a resume would write. */
|
|
173
198
|
routeReceipted(executionPath: unknown): void;
|
|
174
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;
|
|
175
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;
|
|
176
220
|
/** The escalation that ended this run (a gate that fired, or an LLM step that failed), written once
|
|
177
221
|
* as an escalation commit before anything acts on it. A later open gets the same row and the same
|
|
178
222
|
* continuation identity, whatever fires again. */
|
|
179
223
|
escalate(row: Omit<EscalationRow, "tail" | "revision">): Promise<EscalationRow>;
|
|
180
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;
|
|
181
227
|
/** How many effects the driver admitted. */
|
|
182
228
|
effectCalls(): number;
|
|
183
|
-
/** What the continuation inherited, against the escalation that admitted it: the level, the sizes of what it
|
|
184
|
-
* read and its identity. */
|
|
185
|
-
annotateHandoff(detail: {
|
|
186
|
-
escalation_revision: number;
|
|
187
|
-
tail: string;
|
|
188
|
-
inherit: string;
|
|
189
|
-
block_chars: number;
|
|
190
|
-
digest_chars: number;
|
|
191
|
-
}): Promise<void>;
|
|
192
|
-
/** The run's spend at the moment its continuation is admitted. Spend may land under this run after
|
|
193
|
-
* the escalation commit, so the row the continuation reads the spend from is brought current here,
|
|
194
|
-
* by one `handoff` commit that names the escalation. The escalation's revision, what the
|
|
195
|
-
* continuation binds on, does not change. */
|
|
196
|
-
handoff(spend: Pick<EscalationRow, "cost_usd" | "turns" | "effect_calls">): Promise<EscalationRow>;
|
|
197
229
|
/** The state the document's committed top-level prefix left behind, plus what a failed map's finished
|
|
198
230
|
* items produced under the map's key: what an escalation on a failure carries. */
|
|
199
231
|
lastState(): Record<string, unknown>;
|
|
200
232
|
readonly started: boolean;
|
|
201
233
|
wrapEffect(run: (params: RecoveryEffectParams) => Promise<unknown>): NonNullable<WorkflowDeps["runEffect"]>;
|
|
202
|
-
/** 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. */
|
|
203
235
|
flush: () => Promise<void>;
|
|
204
|
-
/** 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. */
|
|
205
240
|
close(): Promise<void>;
|
|
206
241
|
}>;
|