@parcha/agentrun-dsl 0.1.0-beta.10 → 0.1.0-beta.101
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 +154 -15
- package/dist/author-references.d.ts +8 -0
- package/dist/author-references.js +8 -0
- package/dist/author.d.ts +13 -5
- package/dist/author.js +26 -14
- package/dist/authoring.js +5 -4
- package/dist/cli.js +19 -13
- package/dist/decision-provider.d.ts +166 -0
- package/dist/decision-provider.js +238 -0
- package/dist/decision-receipts.d.ts +159 -0
- package/dist/decision-receipts.js +93 -0
- 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 -10
- package/dist/index.js +16 -8
- 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.d.ts +10 -0
- package/dist/recovery/binding.js +44 -0
- package/dist/recovery/call-key.d.ts +9 -0
- package/dist/recovery/call-key.js +17 -0
- package/dist/recovery/canonical-hash.d.ts +7 -0
- package/dist/recovery/canonical-hash.js +22 -0
- package/dist/recovery/driver.d.ts +241 -0
- package/dist/recovery/driver.js +1333 -0
- package/dist/recovery/errors.d.ts +31 -0
- package/dist/recovery/errors.js +51 -0
- package/dist/recovery/execution-path.d.ts +53 -0
- package/dist/recovery/execution-path.js +167 -0
- package/dist/recovery/file-store.d.ts +7 -0
- package/dist/recovery/file-store.js +131 -0
- package/dist/recovery/frozen-snapshot.d.ts +274 -0
- package/dist/recovery/frozen-snapshot.js +187 -0
- package/dist/recovery/handoff-receipts.d.ts +7 -0
- package/dist/recovery/handoff-receipts.js +11 -0
- package/dist/recovery/index.d.ts +14 -0
- package/dist/recovery/index.js +13 -0
- package/dist/recovery/item-state.d.ts +48 -0
- package/dist/recovery/item-state.js +89 -0
- package/dist/recovery/journal.d.ts +28 -0
- package/dist/recovery/journal.js +139 -0
- package/dist/recovery/memory-store.d.ts +4 -0
- package/dist/recovery/memory-store.js +20 -0
- package/dist/recovery/store.d.ts +105 -0
- package/dist/recovery/store.js +6 -0
- package/dist/recovery/testing/conformance.d.ts +4 -0
- package/dist/recovery/testing/conformance.js +268 -0
- package/dist/recovery/testing/crash-points.d.ts +18 -0
- package/dist/recovery/testing/crash-points.js +43 -0
- package/dist/recovery/testing/crash-sweep.d.ts +65 -0
- package/dist/recovery/testing/crash-sweep.js +146 -0
- package/dist/recovery/testing/index.d.ts +3 -0
- package/dist/recovery/testing/index.js +4 -0
- package/dist/recovery/testing/preload.d.ts +1 -0
- package/dist/recovery/testing/preload.js +3 -0
- package/dist/recovery/transport-facts.d.ts +23 -0
- package/dist/recovery/transport-facts.js +46 -0
- package/dist/recovery/with-recovery.d.ts +50 -0
- package/dist/recovery/with-recovery.js +144 -0
- 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 +194 -16
- package/dist/workflow.js +1309 -452
- package/dist/zod-json-contract.js +6 -8
- package/package.json +27 -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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** The widest provider tool-call id that is keyed as it is. */
|
|
3
|
+
export const CALL_KEY_BYTES = 256;
|
|
4
|
+
const PREFIX_CHARS = 64;
|
|
5
|
+
const DIGEST_HEX = 32;
|
|
6
|
+
/** A host's own key for a provider-minted tool-call id. A provider may fold arbitrary data into
|
|
7
|
+
* its call ids (a reasoning signature, for one), so an id's length is the provider's, not ours: an id
|
|
8
|
+
* within `CALL_KEY_BYTES` is its own key, and a wider one is keyed by its leading characters (made
|
|
9
|
+
* identifier-safe) and a SHA-256 prefix of the whole id. The mapping is deterministic, so the same
|
|
10
|
+
* call always has the same key, and two different wide ids share a key only on a digest collision.
|
|
11
|
+
* Only keys use it: what goes back to the provider is always the id it minted. */
|
|
12
|
+
export function callKey(callId) {
|
|
13
|
+
if (Buffer.byteLength(callId) <= CALL_KEY_BYTES)
|
|
14
|
+
return callId;
|
|
15
|
+
const prefix = callId.slice(0, PREFIX_CHARS).replace(/[^A-Za-z0-9_.-]/g, "_");
|
|
16
|
+
return `${prefix}~${createHash("sha256").update(callId).digest("hex").slice(0, DIGEST_HEX)}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** SHA-256 of a value's JSON with every object's keys sorted (`canonicalJson`): the identity of a binding, an input,
|
|
2
|
+
* an intent's arguments or a set of file hashes, independent of key order. */
|
|
3
|
+
export declare const canonicalHash: (value: unknown) => string;
|
|
4
|
+
/** SHA-256 of a value serialized with sorted keys: an identity for a contract a host persists. Not interchangeable
|
|
5
|
+
* with canonicalHash: it writes an undefined member as `undefined` and never calls toJSON, and both identities are
|
|
6
|
+
* persisted. */
|
|
7
|
+
export declare function canonicalSha256(value: unknown): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalJson } from "./item-state.js";
|
|
3
|
+
/** SHA-256 of a value's JSON with every object's keys sorted (`canonicalJson`): the identity of a binding, an input,
|
|
4
|
+
* an intent's arguments or a set of file hashes, independent of key order. */
|
|
5
|
+
export const canonicalHash = (value) => createHash("sha256").update(canonicalJson(value)).digest("hex");
|
|
6
|
+
function canonical(value) {
|
|
7
|
+
if (value === null || typeof value !== "object")
|
|
8
|
+
return JSON.stringify(value);
|
|
9
|
+
if (Array.isArray(value))
|
|
10
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
11
|
+
const object = value;
|
|
12
|
+
return `{${Object.keys(object)
|
|
13
|
+
.sort()
|
|
14
|
+
.map((key) => `${JSON.stringify(key)}:${canonical(object[key])}`)
|
|
15
|
+
.join(",")}}`;
|
|
16
|
+
}
|
|
17
|
+
/** SHA-256 of a value serialized with sorted keys: an identity for a contract a host persists. Not interchangeable
|
|
18
|
+
* with canonicalHash: it writes an undefined member as `undefined` and never calls toJSON, and both identities are
|
|
19
|
+
* persisted. */
|
|
20
|
+
export function canonicalSha256(value) {
|
|
21
|
+
return createHash("sha256").update(canonical(value)).digest("hex");
|
|
22
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
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, type DecisionRequest } from "./frozen-snapshot.js";
|
|
3
|
+
import type { RecoveryBinding, RecoveryEffect, RecoveryStore } from "./store.js";
|
|
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. 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). */
|
|
8
|
+
export declare function routeTaken(node: RouteNode, answers: unknown): {
|
|
9
|
+
branch: string;
|
|
10
|
+
choice: string | null;
|
|
11
|
+
unsure: boolean;
|
|
12
|
+
refused?: true;
|
|
13
|
+
} | null;
|
|
14
|
+
/** The binding of a run of `workflow` under what the host binds beside it. */
|
|
15
|
+
export declare function recoveryBinding(workflow: Workflow, bind?: Record<string, unknown>): string;
|
|
16
|
+
/** What a store is opened under for a run of `workflow`: its binding, and the digest of each input the binding
|
|
17
|
+
* covers. The driver opens its store under it, and so does an operator who reconciles an effect by hand. */
|
|
18
|
+
export declare function recoveryBound(workflow: Workflow, bind?: Record<string, unknown>): RecoveryBinding;
|
|
19
|
+
/** A host's pause or cancel, and who issued it. */
|
|
20
|
+
export type RecoveryStop = {
|
|
21
|
+
action: "pause" | "cancel";
|
|
22
|
+
source?: string;
|
|
23
|
+
};
|
|
24
|
+
/** How the driver reads the files a workflow declares it writes. */
|
|
25
|
+
export type RecoveryFiles = {
|
|
26
|
+
/** Whether two names are one file. */
|
|
27
|
+
same(a: string, b: string): boolean;
|
|
28
|
+
/** The SHA-256 of each named file, by name. A missing file, or one outside the place files live, is refused
|
|
29
|
+
* with FROZEN_ARTIFACT_INVALID. */
|
|
30
|
+
hashes(names: string[]): Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
/** The files of a workspace directory: a name is relative to it, and a file that resolves outside it is refused. */
|
|
33
|
+
export declare function workspaceFiles(cwd: string): RecoveryFiles;
|
|
34
|
+
export type RecoveryOptions = {
|
|
35
|
+
/** The run's identity. Its step sessions, its effects' receipts and the continuation of its escalation are named
|
|
36
|
+
* under it, so the same run is opened with the same key in every process. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** What else must not change between two opens of the run, beside the workflow: the host's own inputs. */
|
|
39
|
+
bind?: Record<string, unknown>;
|
|
40
|
+
/** The document the interpreter runs, when the host rewrites the authored one before running it. Execution paths
|
|
41
|
+
* resolve in it; the binding, the labels and the declared files are the authored document's. Absent, the
|
|
42
|
+
* desugared workflow. */
|
|
43
|
+
view?: Workflow;
|
|
44
|
+
/** Files only the host writes. A workflow that declares one of them is refused before any step runs. */
|
|
45
|
+
reservedOutputs?: readonly string[];
|
|
46
|
+
/** The files a workflow declares it writes. Absent, the files of the process's working directory. */
|
|
47
|
+
files?: RecoveryFiles;
|
|
48
|
+
/** Closes the session of an LLM step's attempt that ended without a submission. It runs on the driver's commit
|
|
49
|
+
* chain, before the commit that records the attempt as closed; its failure is the run's. */
|
|
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>;
|
|
56
|
+
/** Settles effects a killed process left unknown, through the driver's own open of the run (one generation per process).
|
|
57
|
+
* `openRecovery` calls it once, after the open and before anything resumes, when the journal holds an effect that was
|
|
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)`
|
|
59
|
+
* records `value` as the effect's result, as `journal.complete` does with `{ value, files }`, hashing the files the effect declares (a missing one refuses the settlement); `receipt.intent` names
|
|
60
|
+
* the call the host's door answered, as a handoff reads it. `receipt.calls` are the outside calls the host MADE or FOUND APPLIED
|
|
61
|
+
* while settling it, records of the shape `{ outcome: "applied" | "failed" | "unknown", ... }`, so that the effect's `calls` lists
|
|
62
|
+
* every applied call exactly once. They are kept on the effect before it completes, after the calls an earlier process kept, as a
|
|
63
|
+
* dispatch keeps its own. A re-send is a call of this process. A settle from evidence that the call applied (a provider's own
|
|
64
|
+
* lookup, an answer the host kept) reports `{ outcome: "applied" }` when the calls the effect holds include no applied entry,
|
|
65
|
+
* and adds none when its applied call is already there. A settle that made no call and found none applied reports none. The
|
|
66
|
+
* effect is then answered from that result and not
|
|
67
|
+
* dispatched again. One it leaves unknown is refused at resume (`FROZEN_EFFECT_UNKNOWN`). A throw fails the open with
|
|
68
|
+
* `RECOVERY_RECONCILE_FAILED`, keeping the cause, before any effect is dispatched. */
|
|
69
|
+
reconcile?: (unknown: RecoveryEffect[], complete: (id: string, value: unknown, receipt?: {
|
|
70
|
+
intent?: {
|
|
71
|
+
tool: string;
|
|
72
|
+
args?: unknown;
|
|
73
|
+
};
|
|
74
|
+
calls?: unknown[];
|
|
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";
|
|
91
|
+
};
|
|
92
|
+
/** What a host's effect adapter receives under the driver: the interpreter's parameters, `call`, which keeps each
|
|
93
|
+
* outside call the effect makes on its record as the call ends, and `effect`, the admitted effect: its journal id and
|
|
94
|
+
* the hash of its arguments, as the journal stores them and the same in every process of the run. A host that keeps
|
|
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. */
|
|
101
|
+
export type RecoveryEffectParams = Parameters<NonNullable<WorkflowDeps["runEffect"]>>[0] & {
|
|
102
|
+
call?: (record: unknown) => void;
|
|
103
|
+
effect?: {
|
|
104
|
+
id: string;
|
|
105
|
+
argsHash: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/** Opens the durable state of one run of `workflow` in `store` and takes ownership of it. Execution remains in the
|
|
109
|
+
* interpreter: the workflow runs with the returned driver's hooks, and `close` lets go of the run. */
|
|
110
|
+
export declare function openRecovery(store: RecoveryStore, workflow: Workflow, options: RecoveryOptions): Promise<{
|
|
111
|
+
recovery: {
|
|
112
|
+
supportsExecutionPaths?: boolean;
|
|
113
|
+
resume: (node: WorkflowNode, state: Record<string, unknown>, item?: import("../workflow.js").MapItem, executionPath?: string) => Promise<Record<string, unknown> | undefined>;
|
|
114
|
+
commit: (node: WorkflowNode, state: Record<string, unknown>, item?: import("../workflow.js").MapItem, executionPath?: string) => Promise<void>;
|
|
115
|
+
pollStartedAt: (node: import("../workflow.js").CallNode, item?: import("../workflow.js").MapItem, executionPath?: string) => number;
|
|
116
|
+
wait: (node: import("../workflow.js").CallNode, ms: number, item?: import("../workflow.js").MapItem, executionPath?: string) => Promise<void>;
|
|
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>;
|
|
126
|
+
decision?: (id: string) => Promise<import("../decision-receipts.js").DecisionReceipt | undefined>;
|
|
127
|
+
};
|
|
128
|
+
signal: AbortSignal;
|
|
129
|
+
resumed: boolean;
|
|
130
|
+
/** This process's generation of the run: a request this process makes is named with it, so a
|
|
131
|
+
* process that asks again never reuses an earlier process's invocation. */
|
|
132
|
+
readonly generation: number;
|
|
133
|
+
/** A refusal found before any step, or null: the host escalates it before any step runs. */
|
|
134
|
+
preStepRefusal: {
|
|
135
|
+
code: string;
|
|
136
|
+
kind: string;
|
|
137
|
+
message: string;
|
|
138
|
+
label: string;
|
|
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
|
+
};
|
|
145
|
+
binding: string;
|
|
146
|
+
/** The run's key: what its step sessions and effects are named under. */
|
|
147
|
+
driverId: string;
|
|
148
|
+
/** The host hands the driver its stop here. A cancel stops the driver at once, and its steps and effects through
|
|
149
|
+
* its signal. A pause refuses new work at once and is taken when no effect is in flight: an effect already
|
|
150
|
+
* dispatched completes and commits its receipt first, so a paused run resumes without a reconciliation. */
|
|
151
|
+
stop: (stop: RecoveryStop) => void;
|
|
152
|
+
/** The driver's stop check, for a branch that hands off without entering the interpreter: a pause or cancel the
|
|
153
|
+
* driver took stops the run here, before anything resumes. */
|
|
154
|
+
checkStop(): void;
|
|
155
|
+
/** A seam for new work: it waits while a pause waits for an effect in flight, then applies any stop taken. */
|
|
156
|
+
seam: () => Promise<void>;
|
|
157
|
+
/** An LLM step's execution record, admitted before it dispatches. The first call fixes the label
|
|
158
|
+
* the interpreter names it by (a child's step under its invocation) and the retry limit; a resume
|
|
159
|
+
* at this path gets the same record, so its session is found again. A closed attempt advances to a new
|
|
160
|
+
* session identity here, and only here; a failed step never gets another. */
|
|
161
|
+
stepSession(executionPath: unknown, label: string, admission?: {
|
|
162
|
+
attemptsAllowed: number;
|
|
163
|
+
}): StepRecord & {
|
|
164
|
+
stepId: string;
|
|
165
|
+
sessionId: string;
|
|
166
|
+
earlierSessionIds: string[];
|
|
167
|
+
};
|
|
168
|
+
/** Whether the step already has an execution record: a resumed step was admitted in an earlier
|
|
169
|
+
* process and is continued, never refused again. */
|
|
170
|
+
stepAdmitted(executionPath: unknown): boolean;
|
|
171
|
+
/** The current attempt did not submit: its session closes with its spend kept.
|
|
172
|
+
* The step is `closed` until a retry is admitted, or `failed` when no attempt remains. */
|
|
173
|
+
stepAttemptFailed(executionPath: unknown, final?: boolean, error?: unknown): void;
|
|
174
|
+
/** The step delivered its record; the row and the step record agree before the step commit. */
|
|
175
|
+
stepSubmitted(executionPath: unknown): void;
|
|
176
|
+
/** The short identity of an admitted LLM step (a digest of its frame and path), for the escalation
|
|
177
|
+
* row when it fails; null for a path that ran no LLM step. */
|
|
178
|
+
stepId(executionPath: unknown): string | null;
|
|
179
|
+
/** Spend outside any question or session, committed with the driver's state the moment it is priced, so the run's
|
|
180
|
+
* recorded spend holds it. It may be called inside a tool, so it never applies a stop; a failed commit is the run's
|
|
181
|
+
* persistence failure. */
|
|
182
|
+
charge(usd: number): Promise<void>;
|
|
183
|
+
/** A question's metered spend, committed with the driver's state so a resume that skips the
|
|
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. */
|
|
190
|
+
recordQuestionSpend(usd: number | null, route?: {
|
|
191
|
+
executionPath: unknown;
|
|
192
|
+
label: string;
|
|
193
|
+
result: Record<string, unknown>;
|
|
194
|
+
receipts: QuestionReceipts | null;
|
|
195
|
+
}): void;
|
|
196
|
+
/** The host has written what it keeps of the route at `executionPath`: its decision no longer carries the
|
|
197
|
+
* receipts a resume would write. */
|
|
198
|
+
routeReceipted(executionPath: unknown): void;
|
|
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;
|
|
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;
|
|
220
|
+
/** The escalation that ended this run (a gate that fired, or an LLM step that failed), written once
|
|
221
|
+
* as an escalation commit before anything acts on it. A later open gets the same row and the same
|
|
222
|
+
* continuation identity, whatever fires again. */
|
|
223
|
+
escalate(row: Omit<EscalationRow, "tail" | "revision">): Promise<EscalationRow>;
|
|
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;
|
|
227
|
+
/** How many effects the driver admitted. */
|
|
228
|
+
effectCalls(): number;
|
|
229
|
+
/** The state the document's committed top-level prefix left behind, plus what a failed map's finished
|
|
230
|
+
* items produced under the map's key: what an escalation on a failure carries. */
|
|
231
|
+
lastState(): Record<string, unknown>;
|
|
232
|
+
readonly started: boolean;
|
|
233
|
+
wrapEffect(run: (params: RecoveryEffectParams) => Promise<unknown>): NonNullable<WorkflowDeps["runEffect"]>;
|
|
234
|
+
/** Every commit the driver started has landed; a failed one is thrown, a pause's or a cancel's own commit included. */
|
|
235
|
+
flush: () => Promise<void>;
|
|
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. */
|
|
240
|
+
close(): Promise<void>;
|
|
241
|
+
}>;
|