@relayflows/sdk 2.0.10 → 2.0.12
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/dist/adapters/base.d.ts +6 -0
- package/dist/adapters/base.d.ts.map +1 -1
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +1 -0
- package/dist/adapters/claude.js.map +1 -1
- package/dist/agent-relay-receipt.d.ts +24 -0
- package/dist/agent-relay-receipt.d.ts.map +1 -0
- package/dist/agent-relay-receipt.js +66 -0
- package/dist/agent-relay-receipt.js.map +1 -0
- package/dist/agent-relay-state.d.ts +18 -0
- package/dist/agent-relay-state.d.ts.map +1 -0
- package/dist/agent-relay-state.js +58 -0
- package/dist/agent-relay-state.js.map +1 -0
- package/dist/agent-relay-transport.d.ts +17 -70
- package/dist/agent-relay-transport.d.ts.map +1 -1
- package/dist/agent-relay-transport.js +177 -112
- package/dist/agent-relay-transport.js.map +1 -1
- package/dist/authored-admission.d.ts +5 -0
- package/dist/authored-admission.d.ts.map +1 -0
- package/dist/authored-admission.js +14 -0
- package/dist/authored-admission.js.map +1 -0
- package/dist/authored-budget.d.ts +1 -1
- package/dist/authored-budget.d.ts.map +1 -1
- package/dist/authored-budget.js +3 -3
- package/dist/authored-budget.js.map +1 -1
- package/dist/authored-flow-error.d.ts +1 -1
- package/dist/authored-flow-error.d.ts.map +1 -1
- package/dist/authored-flow-error.js.map +1 -1
- package/dist/authored-flow-executor.d.ts +10 -0
- package/dist/authored-flow-executor.d.ts.map +1 -1
- package/dist/authored-flow-executor.js +10 -7
- package/dist/authored-flow-executor.js.map +1 -1
- package/dist/authored-flow-loader.d.ts +20 -0
- package/dist/authored-flow-loader.d.ts.map +1 -1
- package/dist/authored-flow-loader.js +86 -11
- package/dist/authored-flow-loader.js.map +1 -1
- package/dist/authored-helper-effect.d.ts +1 -1
- package/dist/authored-helper-effect.d.ts.map +1 -1
- package/dist/authored-helper-effect.js +5 -3
- package/dist/authored-helper-effect.js.map +1 -1
- package/dist/authored-mcp.d.ts +1 -1
- package/dist/authored-mcp.d.ts.map +1 -1
- package/dist/authored-mcp.js +7 -4
- package/dist/authored-mcp.js.map +1 -1
- package/dist/authored-node-entry.d.ts +2 -0
- package/dist/authored-node-entry.d.ts.map +1 -0
- package/dist/authored-node-entry.js +111 -0
- package/dist/authored-node-entry.js.map +1 -0
- package/dist/authored-node-runner.d.ts +11 -0
- package/dist/authored-node-runner.d.ts.map +1 -0
- package/dist/authored-node-runner.js +246 -0
- package/dist/authored-node-runner.js.map +1 -0
- package/dist/authored-plugin-effect.d.ts +1 -1
- package/dist/authored-plugin-effect.d.ts.map +1 -1
- package/dist/authored-plugin-effect.js +7 -4
- package/dist/authored-plugin-effect.js.map +1 -1
- package/dist/authored-root.d.ts +38 -0
- package/dist/authored-root.d.ts.map +1 -0
- package/dist/authored-root.js +329 -0
- package/dist/authored-root.js.map +1 -0
- package/dist/authored-runtime-capability.d.ts +6 -0
- package/dist/authored-runtime-capability.d.ts.map +1 -0
- package/dist/authored-runtime-capability.js +40 -0
- package/dist/authored-runtime-capability.js.map +1 -0
- package/dist/authored-source-authority.d.ts +4 -0
- package/dist/authored-source-authority.d.ts.map +1 -0
- package/dist/authored-source-authority.js +61 -0
- package/dist/authored-source-authority.js.map +1 -0
- package/dist/authored-worker-step.d.ts +2 -2
- package/dist/authored-worker-step.d.ts.map +1 -1
- package/dist/authored-worker-step.js +11 -6
- package/dist/authored-worker-step.js.map +1 -1
- package/dist/budget-preflight.d.ts +17 -3
- package/dist/budget-preflight.d.ts.map +1 -1
- package/dist/budget-preflight.js +31 -24
- package/dist/budget-preflight.js.map +1 -1
- package/dist/cli/check.js +3 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/direct-run.d.ts.map +1 -1
- package/dist/cli/direct-run.js +18 -14
- package/dist/cli/direct-run.js.map +1 -1
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +56 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/cli-adapter.d.ts +16 -0
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +17 -0
- package/dist/cli-adapter.js.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/cloud-run.d.ts +11 -1
- package/dist/cloud-run.d.ts.map +1 -1
- package/dist/cloud-run.js +65 -19
- package/dist/cloud-run.js.map +1 -1
- package/dist/failure-kinds.d.ts +7 -3
- package/dist/failure-kinds.d.ts.map +1 -1
- package/dist/failure-kinds.js +5 -1
- package/dist/failure-kinds.js.map +1 -1
- package/dist/journal-client.d.ts +1 -1
- package/dist/journal-client.d.ts.map +1 -1
- package/dist/journal-client.js +6 -2
- package/dist/journal-client.js.map +1 -1
- package/dist/llm-worker.d.ts.map +1 -1
- package/dist/llm-worker.js +4 -2
- package/dist/llm-worker.js.map +1 -1
- package/dist/local-agent.d.ts +1 -1
- package/dist/local-agent.d.ts.map +1 -1
- package/dist/local-agent.js +2 -2
- package/dist/local-agent.js.map +1 -1
- package/dist/model-pricing.d.ts +3 -4
- package/dist/model-pricing.d.ts.map +1 -1
- package/dist/model-pricing.js +4 -4
- package/dist/model-pricing.js.map +1 -1
- package/dist/preflight.d.ts +4 -1
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +36 -18
- package/dist/preflight.js.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/spec.d.ts +5 -4
- package/dist/spec.d.ts.map +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/worker-cli.d.ts +5 -2
- package/dist/worker-cli.d.ts.map +1 -1
- package/dist/worker-cli.js +43 -46
- package/dist/worker-cli.js.map +1 -1
- package/dist/worker-spend.d.ts +4 -3
- package/dist/worker-spend.d.ts.map +1 -1
- package/dist/worker-spend.js +13 -4
- package/dist/worker-spend.js.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +12 -4
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/base.ts +7 -0
- package/src/adapters/claude.ts +1 -0
- package/src/agent-relay-receipt.ts +120 -0
- package/src/agent-relay-state.ts +73 -0
- package/src/agent-relay-transport.ts +242 -156
- package/src/authored-admission.ts +17 -0
- package/src/authored-budget.ts +4 -3
- package/src/authored-flow-error.ts +0 -1
- package/src/authored-flow-executor.ts +27 -7
- package/src/authored-flow-loader.ts +96 -13
- package/src/authored-helper-effect.ts +5 -3
- package/src/authored-mcp.ts +6 -4
- package/src/authored-node-entry.ts +90 -0
- package/src/authored-node-runner.ts +219 -0
- package/src/authored-plugin-effect.ts +6 -3
- package/src/authored-root.ts +396 -0
- package/src/authored-runtime-capability.ts +40 -0
- package/src/authored-source-authority.ts +62 -0
- package/src/authored-worker-step.ts +15 -4
- package/src/budget-preflight.ts +41 -25
- package/src/cli/check.ts +3 -1
- package/src/cli/direct-run.ts +24 -16
- package/src/cli/run.ts +58 -1
- package/src/cli-adapter.ts +27 -0
- package/src/cli.ts +5 -5
- package/src/cloud-run.ts +74 -21
- package/src/failure-kinds.ts +5 -1
- package/src/journal-client.ts +6 -2
- package/src/llm-worker.ts +4 -2
- package/src/local-agent.ts +7 -2
- package/src/model-pricing.ts +4 -4
- package/src/preflight.ts +40 -18
- package/src/protocol.ts +2 -0
- package/src/spec.ts +5 -4
- package/src/worker-cli.ts +50 -54
- package/src/worker-spend.ts +15 -4
- package/src/worker.ts +12 -4
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { loadPinnedAuthoredSource } from './authored-source-authority.js';
|
|
2
|
+
import { assertAuthoredRuntimeAvailable, runAuthoredInNode } from './authored-node-runner.js';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { canonicalize } from './canonical.js';
|
|
6
|
+
import { compileSpec, toKernelSpec } from './compile.js';
|
|
7
|
+
import { executeAuthoredFlow } from './authored-flow-executor.js';
|
|
8
|
+
import { SPEC_SCHEMA_VERSION } from './spec.js';
|
|
9
|
+
import { withWorkerLease } from './worker-lease.js';
|
|
10
|
+
import { isSurfaceCompletionReason } from './authored-step-output.js';
|
|
11
|
+
const ROOT_KIND = 'relayflows.authored-root.v1';
|
|
12
|
+
/** Admit and execute one authored body under a durable kernel root. */
|
|
13
|
+
export async function executeDurableAuthoredFlow(loaded, journal, input, options) {
|
|
14
|
+
assertAuthoredRuntimeAvailable();
|
|
15
|
+
const source = await readFile(loaded.sourcePath);
|
|
16
|
+
const sources = await Promise.all(loaded.graph.map(async (node) => Object.freeze({
|
|
17
|
+
path: node.path,
|
|
18
|
+
sourceSha256: sha256(await readFile(node.path)),
|
|
19
|
+
surface: node.surfaceAuthority,
|
|
20
|
+
})));
|
|
21
|
+
const definition = loaded.getDefinition(loaded.handle);
|
|
22
|
+
const metadata = Object.freeze({
|
|
23
|
+
kind: ROOT_KIND,
|
|
24
|
+
flowName: definition.name,
|
|
25
|
+
flowPath: loaded.sourcePath,
|
|
26
|
+
sourceSha256: sha256(source),
|
|
27
|
+
surface: loaded.surfaceAuthority,
|
|
28
|
+
sources: Object.freeze(sources),
|
|
29
|
+
...(options.localAgentStream === undefined ? {} : { localAgentStream: options.localAgentStream }),
|
|
30
|
+
inputPresent: input !== undefined,
|
|
31
|
+
...(input === undefined ? {} : { input: jsonSnapshot(input, 'authored root input') }),
|
|
32
|
+
});
|
|
33
|
+
const admissionKey = rootAdmissionKey(options.admissionKey ?? randomUUID());
|
|
34
|
+
const stream = `authored-root-${admissionKey.slice(-40)}`;
|
|
35
|
+
const spec = rootSpec(metadata, stream);
|
|
36
|
+
const peer = journal.createPeer();
|
|
37
|
+
await peer.connect();
|
|
38
|
+
await peer.hello('flows-authored-root');
|
|
39
|
+
let cancelDispatch = () => { };
|
|
40
|
+
try {
|
|
41
|
+
const dispatchWait = nextRootDispatch(peer);
|
|
42
|
+
cancelDispatch = dispatchWait.cancel;
|
|
43
|
+
await peer.workerAttach(`worker-${stream}`, ['agent'], {
|
|
44
|
+
workspace: [], streams: [{ stream, read_offset: 0 }],
|
|
45
|
+
});
|
|
46
|
+
const outcome = await journal.runStart(spec, undefined, admissionKey);
|
|
47
|
+
if (outcome.status === 'completed') {
|
|
48
|
+
dispatchWait.cancel();
|
|
49
|
+
return await completedRootResult(journal, outcome.run_id);
|
|
50
|
+
}
|
|
51
|
+
assertRootCanDispatch(outcome);
|
|
52
|
+
// `run.start` is an idempotent receipt. If the first caller died after
|
|
53
|
+
// the daemon dispatched this root, a same-daemon retry sees the existing
|
|
54
|
+
// active run but receives no second dispatch from start itself. Resume is
|
|
55
|
+
// safe for the first caller too: the daemon preserves a live lease and
|
|
56
|
+
// redelivers only when the former worker connection is gone.
|
|
57
|
+
await journal.runResume(outcome.run_id);
|
|
58
|
+
const dispatch = await dispatchWait.promise;
|
|
59
|
+
return await driveRoot(loaded, metadata, journal, peer, dispatch, options);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
cancelDispatch();
|
|
63
|
+
peer.close();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Resume the exact source and Surface instance recorded by an authored root. */
|
|
67
|
+
export async function resumeDurableAuthoredFlow(rootRunId, journal, options) {
|
|
68
|
+
const metadata = await readAuthoredRootMetadata(journal, rootRunId);
|
|
69
|
+
if (metadata === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
assertAuthoredRuntimeAvailable();
|
|
72
|
+
const loaded = await loadPinnedAuthoredSource(metadata);
|
|
73
|
+
if (metadata.localAgentStream !== options.localAgentStream) {
|
|
74
|
+
throw new Error('authored root local agent surface mismatch');
|
|
75
|
+
}
|
|
76
|
+
const stream = rootStreamFromMetadata(await rootKernelStep(journal, rootRunId));
|
|
77
|
+
const peer = journal.createPeer();
|
|
78
|
+
await peer.connect();
|
|
79
|
+
await peer.hello('flows-authored-root-resume');
|
|
80
|
+
let cancelDispatch = () => { };
|
|
81
|
+
try {
|
|
82
|
+
const dispatchWait = nextRootDispatch(peer);
|
|
83
|
+
cancelDispatch = dispatchWait.cancel;
|
|
84
|
+
await peer.workerAttach(`worker-${stream}-${randomUUID()}`, ['agent'], {
|
|
85
|
+
workspace: [], streams: [{ stream, read_offset: 0 }],
|
|
86
|
+
});
|
|
87
|
+
const outcome = await journal.runResume(rootRunId);
|
|
88
|
+
if (outcome.status === 'completed') {
|
|
89
|
+
dispatchWait.cancel();
|
|
90
|
+
return await completedRootResult(journal, rootRunId);
|
|
91
|
+
}
|
|
92
|
+
assertRootCanDispatch(outcome);
|
|
93
|
+
const dispatch = await dispatchWait.promise;
|
|
94
|
+
return await driveRoot(loaded, metadata, journal, peer, dispatch, options);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
cancelDispatch();
|
|
98
|
+
peer.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export async function readAuthoredRootMetadata(journal, runId) {
|
|
102
|
+
const step = await rootKernelStep(journal, runId).catch(() => undefined);
|
|
103
|
+
if (step === undefined || step.id !== 'authored-root' || !hasRootStream(step))
|
|
104
|
+
return undefined;
|
|
105
|
+
if (typeof step.instruction !== 'string') {
|
|
106
|
+
throw new Error('authored root journal has malformed authority metadata');
|
|
107
|
+
}
|
|
108
|
+
let value;
|
|
109
|
+
try {
|
|
110
|
+
value = JSON.parse(step.instruction);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new Error('authored root journal has malformed authority metadata');
|
|
114
|
+
}
|
|
115
|
+
if (!isRootMetadata(value)) {
|
|
116
|
+
throw new Error('authored root journal has malformed authority metadata');
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
async function driveRoot(loaded, metadata, journal, peer, dispatch, options) {
|
|
121
|
+
try {
|
|
122
|
+
const result = await withWorkerLease(peer, dispatch, async (rootSignal) => {
|
|
123
|
+
const callerSignal = options.lifecycle?.signal;
|
|
124
|
+
const signal = callerSignal === undefined ? rootSignal : AbortSignal.any([callerSignal, rootSignal]);
|
|
125
|
+
if (process.versions['bun'] !== undefined) {
|
|
126
|
+
return runAuthoredInNode(metadata, journal.socketPath, dispatch.run_id, {
|
|
127
|
+
dataDir: options.dataDir, localAgentStream: options.localAgentStream,
|
|
128
|
+
...options.lifecycle, signal,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return await executeAuthoredFlow(loaded.handle, journal, metadata.inputPresent ? metadata.input : undefined, {
|
|
132
|
+
getDefinition: loaded.getDefinition,
|
|
133
|
+
dataDir: options.dataDir,
|
|
134
|
+
flowPath: metadata.flowPath,
|
|
135
|
+
localAgentStream: options.localAgentStream,
|
|
136
|
+
rootRunId: dispatch.run_id,
|
|
137
|
+
...options.lifecycle,
|
|
138
|
+
signal: callerSignal === undefined
|
|
139
|
+
? rootSignal
|
|
140
|
+
: AbortSignal.any([callerSignal, rootSignal]),
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
await peer.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt, dispatch.idempotency_key, 'success', {
|
|
144
|
+
output: { name: result.name, completionReason: result.completionReason,
|
|
145
|
+
journalSteps: result.journalSteps,
|
|
146
|
+
...(result.executionRuntime === undefined ? {} : { executionRuntime: result.executionRuntime }) },
|
|
147
|
+
started_pins: dispatch.pins, end_pins: dispatch.pins,
|
|
148
|
+
});
|
|
149
|
+
return Object.freeze({ ...result, rootRunId: dispatch.run_id });
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
await terminalizeRootFailure(peer, dispatch, error);
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A returned body failure is deterministic for this root attempt. Complete
|
|
158
|
+
* every kernel retry with the same declared failure so the run reaches its
|
|
159
|
+
* durable `step_failed` terminal instead of being stranded waiting for a
|
|
160
|
+
* worker after the CLI has already returned. A process crash never enters
|
|
161
|
+
* this path: the running attempt remains recoverable by `run.resume`.
|
|
162
|
+
*/
|
|
163
|
+
async function terminalizeRootFailure(peer, firstDispatch, error) {
|
|
164
|
+
let dispatch = firstDispatch;
|
|
165
|
+
const output = { error: error instanceof Error ? error.message : 'authored root failed' };
|
|
166
|
+
for (;;) {
|
|
167
|
+
const next = nextRootDispatch(peer);
|
|
168
|
+
let outcome;
|
|
169
|
+
try {
|
|
170
|
+
outcome = await peer.stepComplete(dispatch.run_id, dispatch.step_id, dispatch.attempt, dispatch.idempotency_key, 'worker_error', {
|
|
171
|
+
output, started_pins: dispatch.pins, end_pins: dispatch.pins,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
catch (completionError) {
|
|
175
|
+
next.cancel();
|
|
176
|
+
throw completionError;
|
|
177
|
+
}
|
|
178
|
+
if (outcome.status === 'failed') {
|
|
179
|
+
next.cancel();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
assertRootCanDispatch(outcome);
|
|
184
|
+
}
|
|
185
|
+
catch (outcomeError) {
|
|
186
|
+
next.cancel();
|
|
187
|
+
throw outcomeError;
|
|
188
|
+
}
|
|
189
|
+
dispatch = await next.promise;
|
|
190
|
+
if (dispatch.run_id !== firstDispatch.run_id) {
|
|
191
|
+
throw new Error('authored root retry was dispatched for a different run');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function rootSpec(metadata, stream) {
|
|
196
|
+
return toKernelSpec(compileSpec({
|
|
197
|
+
version: SPEC_SCHEMA_VERSION,
|
|
198
|
+
name: `authored-root/${metadata.flowName}`,
|
|
199
|
+
steps: [{
|
|
200
|
+
id: 'authored-root', type: 'agent',
|
|
201
|
+
instruction: canonicalize(metadata),
|
|
202
|
+
surfaces: { streams: [{ stream }] },
|
|
203
|
+
recoveryMode: 'reset', maxIterations: 8,
|
|
204
|
+
}],
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
async function rootKernelStep(journal, runId) {
|
|
208
|
+
const entries = (await journal.journalRead(runId, 1)).entries;
|
|
209
|
+
const spawned = entries.find(entry => entry.entry_type === 'run.spawned');
|
|
210
|
+
const payload = spawned?.payload;
|
|
211
|
+
const step = payload?.spec?.steps?.[0];
|
|
212
|
+
if (typeof step !== 'object' || step === null || Array.isArray(step)) {
|
|
213
|
+
throw new Error('authored root journal has no root step');
|
|
214
|
+
}
|
|
215
|
+
return step;
|
|
216
|
+
}
|
|
217
|
+
function rootStreamFromMetadata(step) {
|
|
218
|
+
const surfaces = step.surfaces;
|
|
219
|
+
const stream = surfaces?.streams?.[0]?.stream;
|
|
220
|
+
if (typeof stream !== 'string' || !stream.startsWith('authored-root-')) {
|
|
221
|
+
throw new Error('authored root journal has no pinned stream');
|
|
222
|
+
}
|
|
223
|
+
return stream;
|
|
224
|
+
}
|
|
225
|
+
function hasRootStream(step) {
|
|
226
|
+
try {
|
|
227
|
+
rootStreamFromMetadata(step);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function nextRootDispatch(peer) {
|
|
235
|
+
let cancel = () => { };
|
|
236
|
+
const promise = new Promise((resolve, reject) => {
|
|
237
|
+
const timer = setTimeout(() => {
|
|
238
|
+
peer.off('step.dispatch', onDispatch);
|
|
239
|
+
reject(new Error('authored root was not dispatched'));
|
|
240
|
+
}, 30_000);
|
|
241
|
+
const onDispatch = (dispatch) => {
|
|
242
|
+
if (dispatch.step_id !== 'authored-root')
|
|
243
|
+
return;
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
peer.off('step.dispatch', onDispatch);
|
|
246
|
+
resolve(dispatch);
|
|
247
|
+
};
|
|
248
|
+
peer.on('step.dispatch', onDispatch);
|
|
249
|
+
cancel = () => {
|
|
250
|
+
clearTimeout(timer);
|
|
251
|
+
peer.off('step.dispatch', onDispatch);
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
return { promise, cancel };
|
|
255
|
+
}
|
|
256
|
+
async function completedRootResult(journal, rootRunId) {
|
|
257
|
+
const entries = (await journal.journalRead(rootRunId, 1)).entries;
|
|
258
|
+
const completed = entries.slice().reverse().find(entry => entry.entry_type === 'step.completed'
|
|
259
|
+
&& entry.step_id === 'authored-root'
|
|
260
|
+
&& entry.payload?.completionReason === 'success');
|
|
261
|
+
const output = completed?.payload?.output;
|
|
262
|
+
if (!isCompletedRootOutput(output)) {
|
|
263
|
+
throw new Error('completed authored root has no durable result');
|
|
264
|
+
}
|
|
265
|
+
return Object.freeze({
|
|
266
|
+
name: output.name,
|
|
267
|
+
completionReason: output.completionReason,
|
|
268
|
+
journalSteps: Object.freeze(output.journalSteps.map(step => Object.freeze({ ...step }))),
|
|
269
|
+
rootRunId,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function isCompletedRootOutput(value) {
|
|
273
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
274
|
+
return false;
|
|
275
|
+
const output = value;
|
|
276
|
+
return typeof output.name === 'string'
|
|
277
|
+
&& (output.completionReason === 'success' || output.completionReason === 'needs_human')
|
|
278
|
+
&& Array.isArray(output.journalSteps)
|
|
279
|
+
&& output.journalSteps.every(step => typeof step === 'object' && step !== null
|
|
280
|
+
&& typeof step.id === 'string' && typeof step.runId === 'string'
|
|
281
|
+
&& isSurfaceCompletionReason(step.completionReason));
|
|
282
|
+
}
|
|
283
|
+
function assertRootCanDispatch(outcome) {
|
|
284
|
+
// The kernel reports `parked` after handing an agent lease to its worker;
|
|
285
|
+
// the pushed dispatch is the authority that work is live. An idempotent
|
|
286
|
+
// start retry may instead observe the same active state as `running`.
|
|
287
|
+
if (outcome.status === 'running' || outcome.status === 'parked')
|
|
288
|
+
return;
|
|
289
|
+
throw new Error(`authored root "${outcome.run_id}" is ${outcome.status}`
|
|
290
|
+
+ (outcome.completion_reason === null ? '' : ` (${outcome.completion_reason})`));
|
|
291
|
+
}
|
|
292
|
+
function rootAdmissionKey(value) {
|
|
293
|
+
return `authored-root:${createHash('sha256').update(value).digest('hex')}`;
|
|
294
|
+
}
|
|
295
|
+
function sha256(bytes) {
|
|
296
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
297
|
+
}
|
|
298
|
+
function jsonSnapshot(value, label) {
|
|
299
|
+
const encoded = JSON.stringify(value);
|
|
300
|
+
if (encoded === undefined)
|
|
301
|
+
throw new Error(`${label} is not JSON serializable`);
|
|
302
|
+
return JSON.parse(encoded);
|
|
303
|
+
}
|
|
304
|
+
function isRootMetadata(value) {
|
|
305
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
306
|
+
return false;
|
|
307
|
+
const root = value;
|
|
308
|
+
const surface = root.surface;
|
|
309
|
+
const sources = root.sources;
|
|
310
|
+
return root.kind === ROOT_KIND && typeof root.flowName === 'string'
|
|
311
|
+
&& typeof root.flowPath === 'string' && /^[a-f0-9]{64}$/.test(root.sourceSha256 ?? '')
|
|
312
|
+
&& typeof root.inputPresent === 'boolean' && surface?.packageName === '@relayflows/surface'
|
|
313
|
+
&& typeof surface.version === 'string' && /^[a-f0-9]{64}$/.test(surface.packageSha256 ?? '')
|
|
314
|
+
&& /^[a-f0-9]{64}$/.test(surface.runtimeSha256 ?? '')
|
|
315
|
+
&& Array.isArray(sources) && sources.length > 0 && sources.every(isRootSourceAuthority)
|
|
316
|
+
&& (root.localAgentStream === undefined
|
|
317
|
+
|| /^local-agent-[a-f0-9-]+$/.test(root.localAgentStream));
|
|
318
|
+
}
|
|
319
|
+
function isRootSourceAuthority(value) {
|
|
320
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
321
|
+
return false;
|
|
322
|
+
const source = value;
|
|
323
|
+
const surface = source.surface;
|
|
324
|
+
return typeof source.path === 'string' && /^[a-f0-9]{64}$/.test(source.sourceSha256 ?? '')
|
|
325
|
+
&& surface?.packageName === '@relayflows/surface' && typeof surface.version === 'string'
|
|
326
|
+
&& /^[a-f0-9]{64}$/.test(surface.packageSha256 ?? '')
|
|
327
|
+
&& /^[a-f0-9]{64}$/.test(surface.runtimeSha256 ?? '');
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=authored-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-root.js","sourceRoot":"","sources":["../src/authored-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAoC,MAAM,6BAA6B,CAAC;AAQpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,MAAM,SAAS,GAAG,6BAA6B,CAAC;AA2BhD,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAA0B,EAC1B,OAAsB,EACtB,KAAc,EACd,OAA+B;IAE/B,8BAA8B,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAC7E,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,YAAY,EAAE,MAAM,CAAC,MAAM,QAAQ,CAAC,IA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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A runtime with no-op promise hooks cannot distinguish await from ignored then. */
|
|
2
|
+
export declare function assertAuthoredPromiseHooks(): void;
|
|
3
|
+
export declare function assertAuthoredNodeVersion(version?: string): void;
|
|
4
|
+
/** PID 1 is valid when the standalone CLI is a container's init process. */
|
|
5
|
+
export declare function parseAuthoredParentPid(value: string | undefined): number;
|
|
6
|
+
//# sourceMappingURL=authored-runtime-capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-runtime-capability.d.ts","sourceRoot":"","sources":["../src/authored-runtime-capability.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,wBAAgB,0BAA0B,IAAI,IAAI,CAejD;AAED,wBAAgB,yBAAyB,CAAC,OAAO,SAAwB,GAAG,IAAI,CAU/E;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIxE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { stripTypeScriptTypes, register } from 'node:module';
|
|
2
|
+
import { createHook } from 'node:async_hooks';
|
|
3
|
+
import { AuthoredFlowExecutionError } from './authored-flow-error.js';
|
|
4
|
+
/** A runtime with no-op promise hooks cannot distinguish await from ignored then. */
|
|
5
|
+
export function assertAuthoredPromiseHooks() {
|
|
6
|
+
let initialized = false;
|
|
7
|
+
let resolved = false;
|
|
8
|
+
const hook = createHook({
|
|
9
|
+
init(_id, type) { if (type === 'PROMISE')
|
|
10
|
+
initialized = true; },
|
|
11
|
+
promiseResolve() { resolved = true; },
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
hook.enable();
|
|
15
|
+
void new Promise((resolve) => resolve());
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
hook.disable();
|
|
19
|
+
}
|
|
20
|
+
if (!initialized || !resolved)
|
|
21
|
+
throw new AuthoredFlowExecutionError('unsupported_promise_lifecycle', 'authored execution requires working Node promise hooks; use the standalone Node-authored runner with Node >=22.14');
|
|
22
|
+
}
|
|
23
|
+
export function assertAuthoredNodeVersion(version = process.versions.node) {
|
|
24
|
+
const [major, minor] = version.split('.').map(Number);
|
|
25
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor)
|
|
26
|
+
|| major < 22 || (major === 22 && minor < 14)
|
|
27
|
+
|| process.versions['bun'] !== undefined
|
|
28
|
+
|| typeof stripTypeScriptTypes !== 'function' || typeof register !== 'function') {
|
|
29
|
+
throw new AuthoredFlowExecutionError('unsupported_promise_lifecycle', 'the authored runner requires Node >=22.14; no workflow body was executed');
|
|
30
|
+
}
|
|
31
|
+
assertAuthoredPromiseHooks();
|
|
32
|
+
}
|
|
33
|
+
/** PID 1 is valid when the standalone CLI is a container's init process. */
|
|
34
|
+
export function parseAuthoredParentPid(value) {
|
|
35
|
+
const pid = Number(value);
|
|
36
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
37
|
+
throw new Error('invalid authored parent identity');
|
|
38
|
+
return pid;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=authored-runtime-capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-runtime-capability.js","sourceRoot":"","sources":["../src/authored-runtime-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,qFAAqF;AACrF,MAAM,UAAU,0BAA0B;IACxC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,IAAI,IAAI,KAAK,SAAS;YAAE,WAAW,GAAG,IAA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AG,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAChG,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuthoredRootMetadata } from './authored-root.js';
|
|
2
|
+
/** Re-open the exact source graph and Surface instance pinned by the durable root. */
|
|
3
|
+
export declare function loadPinnedAuthoredSource(metadata: AuthoredRootMetadata, immutableNodeImport?: boolean): Promise<import("./authored-flow-loader.js").LoadedAuthoredFlow>;
|
|
4
|
+
//# sourceMappingURL=authored-source-authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-source-authority.d.ts","sourceRoot":"","sources":["../src/authored-source-authority.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,sFAAsF;AACtF,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,mBAAmB,UAAQ,mEA4BzG"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { register } from 'node:module';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { canonicalize } from './canonical.js';
|
|
6
|
+
import { loadAuthoredFlow } from './authored-flow-loader.js';
|
|
7
|
+
const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
8
|
+
/** Re-open the exact source graph and Surface instance pinned by the durable root. */
|
|
9
|
+
export async function loadPinnedAuthoredSource(metadata, immutableNodeImport = false) {
|
|
10
|
+
const source = await readFile(metadata.flowPath);
|
|
11
|
+
if (sha256(source) !== metadata.sourceSha256) {
|
|
12
|
+
throw new Error('authored root source authority mismatch');
|
|
13
|
+
}
|
|
14
|
+
const sources = new Map([[pathToFileURL(metadata.flowPath).href, source.toString('utf8')]]);
|
|
15
|
+
for (const pinned of metadata.sources) {
|
|
16
|
+
const bytes = await readFile(pinned.path);
|
|
17
|
+
if (sha256(bytes) !== pinned.sourceSha256) {
|
|
18
|
+
throw new Error(`authored root source authority mismatch for "${pinned.path}"`);
|
|
19
|
+
}
|
|
20
|
+
sources.set(pathToFileURL(pinned.path).href, bytes.toString('utf8'));
|
|
21
|
+
}
|
|
22
|
+
if (immutableNodeImport)
|
|
23
|
+
installPinnedSourceLoader(sources);
|
|
24
|
+
const loaded = await loadAuthoredFlow(metadata.flowPath);
|
|
25
|
+
if (canonicalize(loaded.surfaceAuthority) !== canonicalize(metadata.surface)
|
|
26
|
+
|| loaded.getDefinition(loaded.handle).name !== metadata.flowName) {
|
|
27
|
+
throw new Error('authored root Surface module authority mismatch');
|
|
28
|
+
}
|
|
29
|
+
const loadedSources = loaded.graph.map(node => ({
|
|
30
|
+
path: node.path,
|
|
31
|
+
sourceSha256: metadata.sources.find(source => source.path === node.path)?.sourceSha256 ?? '',
|
|
32
|
+
surface: node.surfaceAuthority,
|
|
33
|
+
}));
|
|
34
|
+
if (canonicalize(loadedSources) !== canonicalize(metadata.sources)) {
|
|
35
|
+
throw new Error('authored root declared source graph authority mismatch');
|
|
36
|
+
}
|
|
37
|
+
return loaded;
|
|
38
|
+
}
|
|
39
|
+
let pinnedSourceLoaderInstalled = false;
|
|
40
|
+
/** Isolated Node child only: preserve original URLs/resolution, load verified bytes. */
|
|
41
|
+
function installPinnedSourceLoader(sources) {
|
|
42
|
+
if (pinnedSourceLoaderInstalled)
|
|
43
|
+
throw new Error('authored Node process already owns a source graph');
|
|
44
|
+
pinnedSourceLoaderInstalled = true;
|
|
45
|
+
// Node >=22.14 supports register and stripTypeScriptTypes. A loader thread
|
|
46
|
+
// receives the captured bytes, never reopening mutable authored paths.
|
|
47
|
+
const loader = `
|
|
48
|
+
import {stripTypeScriptTypes} from 'node:module';
|
|
49
|
+
let sources;
|
|
50
|
+
export function initialize(data){sources=new Map(data);}
|
|
51
|
+
export async function load(url,context,next){
|
|
52
|
+
if(sources.has(url))return {format:'module',shortCircuit:true,
|
|
53
|
+
source:stripTypeScriptTypes(sources.get(url),{mode:'transform',sourceUrl:url})};
|
|
54
|
+
if(url.startsWith('file:') && new URL(url).pathname.endsWith('.flow.ts'))
|
|
55
|
+
throw new Error('authored root declared source graph authority mismatch');
|
|
56
|
+
return next(url,context);
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
register('data:text/javascript,' + encodeURIComponent(loader), { data: [...sources] });
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=authored-source-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored-source-authority.js","sourceRoot":"","sources":["../src/authored-source-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,GAAG,CAAC,KAAiB,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE/F,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,QAA8B,EAAE,mBAAmB,GAAG,KAAK;IACxG,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,OAAO,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,IAAI,CAAC,EAAE,YAAY,IAAI,EAAE;QAC5F,OAAO,EAAE,IAAI,CAAC,gBAAgB;KAC/B,CAAC,CAAC,CAAC;IACJ,IAAI,YAAY,CAAC,aAAa,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,2BAA2B,GAAG,KAAK,CAAC;AAExC,wFAAwF;AACxF,SAAS,yBAAyB,CAAC,OAA4B;IAC7D,IAAI,2BAA2B;QAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACtG,2BAA2B,GAAG,IAAI,CAAC;IACnC,2EAA2E;IAC3E,uEAAuE;IACvE,MAAM,MAAM,GAAG;;;;;;;;;;;GAWd,CAAC;IACF,QAAQ,CAAC,uBAAuB,GAAG,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -6,10 +6,10 @@ import type { AuthoredFlowJournalStep } from './authored-flow-executor.js';
|
|
|
6
6
|
/** Agent and LLM calls share the exact declarative preflight and lease wait. */
|
|
7
7
|
export declare function authoredWorkerRunner(definition: {
|
|
8
8
|
name: string;
|
|
9
|
-
}, journal: JournalClient, flowPath: string, journalSteps: AuthoredFlowJournalStep[], waitOptions: RunLifecycleOptions, localAgentStream?: string, budget?: AuthoredBudget, headerBudget?: unknown): {
|
|
9
|
+
}, journal: JournalClient, flowPath: string, journalSteps: AuthoredFlowJournalStep[], waitOptions: RunLifecycleOptions, localAgentStream?: string, budget?: AuthoredBudget, headerBudget?: unknown, rootRunId?: string): {
|
|
10
10
|
agent(id: string, options: AgentOptions, verification?: NamedGate): Promise<AgentResult>;
|
|
11
11
|
llm(id: string, prompt: string, options?: LlmOptions, verification?: NamedGate): Promise<unknown>;
|
|
12
12
|
};
|
|
13
13
|
/** Deterministic commands execute inline under their per-invocation lease. */
|
|
14
|
-
export declare function authoredDeterministicRunner(name: string, journal: JournalClient, journalSteps: AuthoredFlowJournalStep[], budget: AuthoredBudget): (id: string, command: string, terminal?: boolean, leaseMs?: number, verification?: NamedGate) => Promise<string>;
|
|
14
|
+
export declare function authoredDeterministicRunner(name: string, journal: JournalClient, journalSteps: AuthoredFlowJournalStep[], budget: AuthoredBudget, rootRunId?: string): (id: string, command: string, terminal?: boolean, leaseMs?: number, verification?: NamedGate) => Promise<string>;
|
|
15
15
|
//# sourceMappingURL=authored-worker-step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-worker-step.d.ts","sourceRoot":"","sources":["../src/authored-worker-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG5F,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"authored-worker-step.d.ts","sourceRoot":"","sources":["../src/authored-worker-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG5F,OAAO,EAAmB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,gFAAgF;AAChF,wBAAgB,oBAAoB,CAClC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EACtE,YAAY,EAAE,uBAAuB,EAAE,EAAE,WAAW,EAAE,mBAAmB,EACzE,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,OAAO,EAC1E,SAAS,CAAC,EAAE,MAAM;cAoEA,MAAM,WAAW,YAAY,iBAAiB,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;YAyDhF,MAAM,UAAU,MAAM,YAAY,UAAU,iBAAiB,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;EAmB1G;AAED,8EAA8E;AAC9E,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,cAAc,EACrG,SAAS,CAAC,EAAE,MAAM,IAEJ,IAAI,MAAM,EAAE,SAAS,MAAM,EAAE,kBAAgB,EAAE,UAAU,MAAM,EAAE,eAAe,SAAS,KAAG,OAAO,CAAC,MAAM,CAAC,CAkB1H"}
|
|
@@ -6,9 +6,10 @@ import { AuthoredFlowExecutionError } from './authored-flow-error.js';
|
|
|
6
6
|
import { SPEC_SCHEMA_VERSION } from './spec.js';
|
|
7
7
|
import { isSurfaceCompletionReason, readCompletedStepOutput, readSuccessfulOutput } from './authored-step-output.js';
|
|
8
8
|
import { snapshotJsonValue } from './json-value.js';
|
|
9
|
+
import { authoredChildAdmissionKey } from './authored-admission.js';
|
|
9
10
|
const WORKSPACE_PERMISSION_ANNOTATION = /:\s*(readonly|readwrite)\s*$/i;
|
|
10
11
|
/** Agent and LLM calls share the exact declarative preflight and lease wait. */
|
|
11
|
-
export function authoredWorkerRunner(definition, journal, flowPath, journalSteps, waitOptions, localAgentStream, budget, headerBudget) {
|
|
12
|
+
export function authoredWorkerRunner(definition, journal, flowPath, journalSteps, waitOptions, localAgentStream, budget, headerBudget, rootRunId) {
|
|
12
13
|
async function run(step) {
|
|
13
14
|
const id = step.id;
|
|
14
15
|
const authoring = { version: SPEC_SCHEMA_VERSION, name: `${definition.name}/${id}`, steps: [step], ...(headerBudget === undefined ? {} : { budget: parseBudget(headerBudget) }) };
|
|
@@ -20,7 +21,7 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
|
|
|
20
21
|
const { report, flow: resolved } = checkAuthoredFlow(authoring, flowPath);
|
|
21
22
|
if (!report.ok || resolved === undefined) {
|
|
22
23
|
const refusal = report.diagnostics.find((diagnostic) => diagnostic.severity === 'refusal');
|
|
23
|
-
throw new AuthoredFlowExecutionError(refusal?.kind === '
|
|
24
|
+
throw new AuthoredFlowExecutionError(refusal?.kind === 'budget_syntax_invalid' ? refusal.kind
|
|
24
25
|
: step.type === 'llm' ? 'llm_cli_unresolved' : 'agent_cli_unresolved', refusal?.message
|
|
25
26
|
?? `flow "${definition.name}" step "${id}": no CLI could be resolved for f.${step.type} `
|
|
26
27
|
+ `(searched for flows.json from "${flowPath}")`);
|
|
@@ -52,7 +53,10 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
|
|
|
52
53
|
}
|
|
53
54
|
return readCompletedStepOutput(journal, outcome.run_id, id, journalSteps);
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
const admissionKey = authoredChildAdmissionKey(rootRunId, id);
|
|
57
|
+
return budget === undefined
|
|
58
|
+
? consume(await journal.runStart(spec, undefined, admissionKey))
|
|
59
|
+
: budget.execute(journal, spec, consume, admissionKey);
|
|
56
60
|
}
|
|
57
61
|
return {
|
|
58
62
|
async agent(id, options, verification) {
|
|
@@ -117,7 +121,7 @@ export function authoredWorkerRunner(definition, journal, flowPath, journalSteps
|
|
|
117
121
|
};
|
|
118
122
|
}
|
|
119
123
|
/** Deterministic commands execute inline under their per-invocation lease. */
|
|
120
|
-
export function authoredDeterministicRunner(name, journal, journalSteps, budget) {
|
|
124
|
+
export function authoredDeterministicRunner(name, journal, journalSteps, budget, rootRunId) {
|
|
121
125
|
return async (id, command, terminal = false, leaseMs, verification) => {
|
|
122
126
|
const spec = toKernelSpec(compileSpec({
|
|
123
127
|
version: SPEC_SCHEMA_VERSION,
|
|
@@ -128,9 +132,10 @@ export function authoredDeterministicRunner(name, journal, journalSteps, budget)
|
|
|
128
132
|
...(verification === undefined ? {} : { verification }),
|
|
129
133
|
}],
|
|
130
134
|
}));
|
|
135
|
+
const admissionKey = authoredChildAdmissionKey(rootRunId, id);
|
|
131
136
|
if (terminal)
|
|
132
|
-
return readSuccessfulOutput(journal, await journal.runStart(spec), id, journalSteps);
|
|
133
|
-
return budget.execute(journal, spec, outcome => readSuccessfulOutput(journal, outcome, id, journalSteps));
|
|
137
|
+
return readSuccessfulOutput(journal, await journal.runStart(spec, undefined, admissionKey), id, journalSteps);
|
|
138
|
+
return budget.execute(journal, spec, outcome => readSuccessfulOutput(journal, outcome, id, journalSteps), admissionKey);
|
|
134
139
|
};
|
|
135
140
|
}
|
|
136
141
|
//# sourceMappingURL=authored-worker-step.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-worker-step.js","sourceRoot":"","sources":["../src/authored-worker-step.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAA4B,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAgC,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,oBAAoB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AAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO;oBAClC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;oBACvD,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;iBACxD,CAAC;SACH,CAAC,CAAC,CAAC;QACJ,MAAM,YAAY,GAAG,yBAAyB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC9D,IAAI,QAAQ;YAAE,OAAO,oBAAoB,CACvC,OAAO,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,YAAY,CACjF,CAAC;QACF,OAAO,MAAM,CAAC,OAAO,CACnB,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,CAAC,EAAE,YAAY,CACjG,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { CompiledFlowSpec } from './compile.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { PreflightWarning } from './preflight.js';
|
|
3
|
+
export interface BudgetStepResolution {
|
|
4
|
+
readonly cli?: string;
|
|
5
|
+
readonly model?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Dollar budgets are light enforcement: pricing never refuses a run. A step
|
|
9
|
+
* whose model has no frozen price journals zero dollars (see `workerSpend`),
|
|
10
|
+
* so it cannot trip `maxDollars`, while its reported tokens still count toward
|
|
11
|
+
* any token budget; priced steps still accrue and a crossed limit still stops
|
|
12
|
+
* the run in the kernel. This warning names each dollar-unmetered step so the
|
|
13
|
+
* gap is reported, not silent.
|
|
14
|
+
*
|
|
15
|
+
* Codex selects its own model when none is declared, so a Codex step is
|
|
16
|
+
* expected to be unmetered and says so rather than asking for a fake price.
|
|
17
|
+
*/
|
|
18
|
+
export declare function budgetDiagnostics(flow: CompiledFlowSpec, resolved?: ReadonlyMap<string, BudgetStepResolution>): PreflightWarning[];
|
|
5
19
|
//# sourceMappingURL=budget-preflight.d.ts.map
|