@nodetool-ai/kernel 0.8.8 → 0.8.9-bootstrap.0
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/.nodetool-build-stamp +1 -1
- package/dist/actor.d.ts +1 -479
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +1 -1911
- package/dist/actor.js.map +1 -1
- package/dist/correlation-analysis.d.ts +1 -103
- package/dist/correlation-analysis.d.ts.map +1 -1
- package/dist/correlation-analysis.js +1 -845
- package/dist/correlation-analysis.js.map +1 -1
- package/dist/durable-inbox.d.ts +1 -90
- package/dist/durable-inbox.d.ts.map +1 -1
- package/dist/durable-inbox.js +1 -210
- package/dist/durable-inbox.js.map +1 -1
- package/dist/dynamic-slots.d.ts +1 -72
- package/dist/dynamic-slots.d.ts.map +1 -1
- package/dist/dynamic-slots.js +1 -191
- package/dist/dynamic-slots.js.map +1 -1
- package/dist/edge-ids.d.ts +1 -10
- package/dist/edge-ids.d.ts.map +1 -1
- package/dist/edge-ids.js +1 -14
- package/dist/edge-ids.js.map +1 -1
- package/dist/graph-utils.d.ts +1 -71
- package/dist/graph-utils.d.ts.map +1 -1
- package/dist/graph-utils.js +1 -283
- package/dist/graph-utils.js.map +1 -1
- package/dist/graph.d.ts +1 -203
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +1 -867
- package/dist/graph.js.map +1 -1
- package/dist/inbox.d.ts +1 -264
- package/dist/inbox.d.ts.map +1 -1
- package/dist/inbox.js +1 -551
- package/dist/inbox.js.map +1 -1
- package/dist/index.d.ts +1 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -19
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +1 -188
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +1 -238
- package/dist/io.js.map +1 -1
- package/dist/loop.d.ts +1 -35
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +1 -165
- package/dist/loop.js.map +1 -1
- package/dist/message-stream.d.ts +1 -31
- package/dist/message-stream.d.ts.map +1 -1
- package/dist/message-stream.js +1 -63
- package/dist/message-stream.js.map +1 -1
- package/dist/predicates.d.ts +1 -7
- package/dist/predicates.d.ts.map +1 -1
- package/dist/predicates.js +1 -7
- package/dist/predicates.js.map +1 -1
- package/dist/run-state.d.ts +1 -64
- package/dist/run-state.d.ts.map +1 -1
- package/dist/run-state.js +1 -41
- package/dist/run-state.js.map +1 -1
- package/dist/runner.d.ts +1 -523
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -2126
- package/dist/runner.js.map +1 -1
- package/dist/substitute-validator.d.ts +1 -43
- package/dist/substitute-validator.d.ts.map +1 -1
- package/dist/substitute-validator.js +1 -168
- package/dist/substitute-validator.js.map +1 -1
- package/dist/supervisor.d.ts +1 -147
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +1 -286
- package/dist/supervisor.js.map +1 -1
- package/dist/trigger-wakeup.d.ts +1 -122
- package/dist/trigger-wakeup.d.ts.map +1 -1
- package/dist/trigger-wakeup.js +1 -220
- package/dist/trigger-wakeup.js.map +1 -1
- package/package.json +4 -4
package/dist/runner.d.ts
CHANGED
|
@@ -1,524 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* WorkflowRunner – DAG orchestration.
|
|
3
|
-
*
|
|
4
|
-
* Port of src/nodetool/workflows/workflow_runner.py.
|
|
5
|
-
*
|
|
6
|
-
* Responsibilities:
|
|
7
|
-
* - Graph validation and initialization.
|
|
8
|
-
* - Inbox creation with upstream counts.
|
|
9
|
-
* - Input value dispatch to input nodes.
|
|
10
|
-
* - Actor spawning with concurrent execution.
|
|
11
|
-
* - Output routing via send_messages.
|
|
12
|
-
* - Edge counter tracking for EOS propagation.
|
|
13
|
-
* - Control event dispatch.
|
|
14
|
-
* - Completion detection.
|
|
15
|
-
*/
|
|
16
|
-
import type { NodeDescriptor, HydratedGraphData, ProcessingMessage, ControlEvent, CorrelationLineage, Intervention, MissingRuntimeDetails, MissingPackDetails } from "@nodetool-ai/protocol";
|
|
17
|
-
import type { SupervisorHandle } from "./supervisor.js";
|
|
18
|
-
import type { ProcessingContext } from "@nodetool-ai/runtime";
|
|
19
|
-
import { type NodeExecutor } from "./actor.js";
|
|
20
|
-
/**
|
|
21
|
-
* Hints from the actor about how to route an invocation's outputs.
|
|
22
|
-
*
|
|
23
|
-
* `invocationLineage` is applied to outputs that inherit the invocation scope.
|
|
24
|
-
* `perSlotLineage` overrides it per slot (e.g. minted iteration lineage or
|
|
25
|
-
* `outputs.forward()` calls). `lineageDoneSlots` marks slots the node dropped,
|
|
26
|
-
* for which the runner sends `signalLineageDone` instead of a value.
|
|
27
|
-
*/
|
|
28
|
-
export interface OutputRoutingHints {
|
|
29
|
-
/** A recoverable pack refusal for one pending controlled invocation. */
|
|
30
|
-
controlError?: MissingPackDetails;
|
|
31
|
-
/** Lineage carried by the consumed envelope when the node had exactly one. */
|
|
32
|
-
invocationLineage?: CorrelationLineage;
|
|
33
|
-
/** Explicit per-slot lineage overrides (e.g. from outputs.forward). */
|
|
34
|
-
perSlotLineage?: Record<string, CorrelationLineage>;
|
|
35
|
-
/**
|
|
36
|
-
* Slots being dropped for the given lineage. The runner sends
|
|
37
|
-
* `signalLineageDone` to downstream inboxes for these slots instead of
|
|
38
|
-
* delivering a value. §5.
|
|
39
|
-
*/
|
|
40
|
-
lineageDoneSlots?: Set<string>;
|
|
41
|
-
/**
|
|
42
|
-
* A supervisor `skip` verdict: this invocation produced nothing. The runner
|
|
43
|
-
* sends `lineage_done` on every outgoing data edge at `invocationLineage`,
|
|
44
|
-
* *and* `lineage_scope_closed` for every child root the invocation would have
|
|
45
|
-
* opened. Design §5.2.
|
|
46
|
-
*/
|
|
47
|
-
skipInvocation?: boolean;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Issue reported by a node validator. Mirrors the shape of
|
|
51
|
-
* `@nodetool-ai/node-sdk`'s `NodePropertyValidationIssue`, redeclared here to
|
|
52
|
-
* avoid a circular dependency (node-sdk depends on kernel).
|
|
53
|
-
*/
|
|
54
|
-
export interface NodeValidationIssue {
|
|
55
|
-
nodeId?: string;
|
|
56
|
-
nodeType?: string;
|
|
57
|
-
property: string;
|
|
58
|
-
message: string;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Function used by WorkflowRunner to validate each node before execution.
|
|
62
|
-
* `connectedHandles` lists the targetHandles on the node that have an
|
|
63
|
-
* incoming data edge — those properties are produced at runtime and the
|
|
64
|
-
* validator must not flag them as missing.
|
|
65
|
-
*/
|
|
66
|
-
export type NodeValidator = (node: NodeDescriptor, connectedHandles: ReadonlySet<string>) => NodeValidationIssue[] | undefined | null;
|
|
67
|
-
export interface RunJobRequest {
|
|
68
|
-
/** Unique job identifier. */
|
|
69
|
-
job_id: string;
|
|
70
|
-
/** Workflow / graph identifier. */
|
|
71
|
-
workflow_id?: string;
|
|
72
|
-
/** Input parameters keyed by input-node name. */
|
|
73
|
-
params?: Record<string, unknown>;
|
|
74
|
-
/** Optional parent workflow ID for sub-graph execution. */
|
|
75
|
-
parent_id?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Wake-up payload for a trigger-driven run. Mirrors
|
|
78
|
-
* `@nodetool-ai/protocol`'s `RunJobRequest.trigger_event`, redeclared here
|
|
79
|
-
* (like {@link NodeValidationIssue}) to avoid a circular dependency. When
|
|
80
|
-
* present, propagated onto `WorkflowRunnerOptions.executionContext` as
|
|
81
|
-
* `triggerEvent` at the start of the run so actors can read it via
|
|
82
|
-
* `ProcessingContext`.
|
|
83
|
-
*/
|
|
84
|
-
trigger_event?: {
|
|
85
|
-
node_id: string;
|
|
86
|
-
payload: unknown;
|
|
87
|
-
input_id: string;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export interface WorkflowRunnerOptions {
|
|
91
|
-
/**
|
|
92
|
-
* Factory that resolves a NodeDescriptor to a NodeExecutor.
|
|
93
|
-
* This is the integration point for actual node implementations.
|
|
94
|
-
*/
|
|
95
|
-
resolveExecutor: (node: NodeDescriptor) => NodeExecutor;
|
|
96
|
-
/** Optional per-inbox buffer limit. */
|
|
97
|
-
bufferLimit?: number | null;
|
|
98
|
-
/** Optional execution context passed to each node executor call. */
|
|
99
|
-
executionContext?: ProcessingContext;
|
|
100
|
-
/**
|
|
101
|
-
* Optional pre-flight validator invoked once per node after structural
|
|
102
|
-
* graph validation succeeds. Returning a non-empty list of issues aborts
|
|
103
|
-
* the run with a `GraphValidationError` before any actor is spawned.
|
|
104
|
-
*
|
|
105
|
-
* `NodeRegistry.createNodeValidator()` from `@nodetool-ai/node-sdk` produces
|
|
106
|
-
* a callback compatible with this signature.
|
|
107
|
-
*/
|
|
108
|
-
validateNode?: NodeValidator;
|
|
109
|
-
/**
|
|
110
|
-
* Strict mode (docs/RELIABILITY_ARCHITECTURE.md §12: "strict mode is a
|
|
111
|
-
* kernel flag, not a fork"). Default `false` (advisory-only, current
|
|
112
|
-
* behavior).
|
|
113
|
-
*
|
|
114
|
-
* When `true`, the checks that are otherwise logged as advisory warnings —
|
|
115
|
-
* `_checkPendingInboxWork` finding undelivered messages, a controlled node
|
|
116
|
-
* completing with pending `sendControlEvent` responses still unresolved,
|
|
117
|
-
* and `_drainActiveEdges` finding an edge still buffered/open after the
|
|
118
|
-
* graph settled — throw an `Error` instead. The error is caught by the
|
|
119
|
-
* same top-level handler that reports node/graph failures, so a strict
|
|
120
|
-
* violation surfaces as `RunResult.status === "failed"` with a message
|
|
121
|
-
* naming every offending node/edge, exactly like any other run failure.
|
|
122
|
-
*/
|
|
123
|
-
strict?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Turns a failing node invocation into a decision instead of a dead run.
|
|
126
|
-
* Absent — the default — means no escalation is ever constructed and the run
|
|
127
|
-
* behaves exactly as it does today. See docs/workflow-supervisor-design.md.
|
|
128
|
-
*/
|
|
129
|
-
supervisor?: SupervisorHandle;
|
|
130
|
-
}
|
|
131
|
-
export interface RunResult {
|
|
132
|
-
/** Outputs collected from output nodes, keyed by node name/id. */
|
|
133
|
-
outputs: Record<string, unknown[]>;
|
|
134
|
-
/** All processing messages emitted during the run. */
|
|
135
|
-
messages: ProcessingMessage[];
|
|
136
|
-
/** Final job status. */
|
|
137
|
-
status: "completed" | "failed" | "cancelled";
|
|
138
|
-
/** Error message if status is 'failed'. */
|
|
139
|
-
error?: string;
|
|
140
|
-
missingRuntime?: MissingRuntimeDetails;
|
|
141
|
-
missingPack?: MissingPackDetails;
|
|
142
|
-
/**
|
|
143
|
-
* Every supervisor escalation and the verdict it received, in order. A
|
|
144
|
-
* completed run with a non-empty list is "Completed — supervised": a derived
|
|
145
|
-
* display state, not a fifth status, so existing `status` consumers keep
|
|
146
|
-
* working.
|
|
147
|
-
*/
|
|
148
|
-
interventions?: Intervention[];
|
|
149
|
-
}
|
|
150
|
-
export declare class WorkflowRunner {
|
|
151
|
-
readonly jobId: string;
|
|
152
|
-
private _graph;
|
|
153
|
-
private _options;
|
|
154
|
-
/** Per-node inboxes. */
|
|
155
|
-
private _inboxes;
|
|
156
|
-
/** Per-edge message counters (for EdgeUpdate tracking). */
|
|
157
|
-
private _edgeCounters;
|
|
158
|
-
/** Per-edge timestamp of the last emitted edge_update (throttling). */
|
|
159
|
-
private _edgeCounterLastEmitMs;
|
|
160
|
-
/** Edges whose counter advanced since their last emitted edge_update. */
|
|
161
|
-
private _edgeCounterDirty;
|
|
162
|
-
/**
|
|
163
|
-
* Static correlation analysis result. Always populated before actors run.
|
|
164
|
-
*/
|
|
165
|
-
private _correlation;
|
|
166
|
-
/**
|
|
167
|
-
* Multi-edge list inputs: nodeId → set of handles that aggregate
|
|
168
|
-
* multiple edges into a list.
|
|
169
|
-
*/
|
|
170
|
-
private _multiEdgeListInputs;
|
|
171
|
-
/** Collected outputs from output nodes. */
|
|
172
|
-
private _outputs;
|
|
173
|
-
/** All emitted messages. */
|
|
174
|
-
private _messages;
|
|
175
|
-
private _missingRuntime;
|
|
176
|
-
private _missingPack;
|
|
177
|
-
/** Cancellation flag. */
|
|
178
|
-
private _cancelled;
|
|
179
|
-
/**
|
|
180
|
-
* Actors spawned and not yet finished (including their completion
|
|
181
|
-
* handling). Exposed via {@link liveActorCount} for leak accounting — after
|
|
182
|
-
* a run this must be back to zero, and a harness that can't measure it
|
|
183
|
-
* can't assert it.
|
|
184
|
-
*/
|
|
185
|
-
private _liveActors;
|
|
186
|
-
/** Node ids of actors still running; read by quiescence detection. */
|
|
187
|
-
private _liveActorIds;
|
|
188
|
-
/**
|
|
189
|
-
* Outgoing data edges of streaming input nodes that `finishInputStream`
|
|
190
|
-
* has not closed yet. While any is open, values can still arrive from
|
|
191
|
-
* outside the graph, so the graph is never quiescent.
|
|
192
|
-
*/
|
|
193
|
-
private _openExternalStreamEdges;
|
|
194
|
-
/** Schedules a quiescence check; set only for graphs with a Loop node. */
|
|
195
|
-
private _scheduleQuiescenceCheck;
|
|
196
|
-
/**
|
|
197
|
-
* Latch set by `cancel()` and never cleared by `_resetRunState`. A cancel
|
|
198
|
-
* that lands between construction and `run()` would otherwise be dropped —
|
|
199
|
-
* the reset clears `_cancelled` and swaps the AbortController. `_runImpl`
|
|
200
|
-
* re-applies this latch after the reset so such a run terminates as
|
|
201
|
-
* "cancelled". §17.
|
|
202
|
-
*/
|
|
203
|
-
private _cancelRequested;
|
|
204
|
-
/**
|
|
205
|
-
* True while a run is in flight. A second concurrent `run()` on the same
|
|
206
|
-
* instance would clobber all shared run state, so `_runImpl` rejects it. §17.
|
|
207
|
-
*/
|
|
208
|
-
private _running;
|
|
209
|
-
/**
|
|
210
|
-
* Job id used for `edge_update` emissions during a run. Captured from
|
|
211
|
-
* `request.job_id` at the start of `_runImpl` so edge updates and
|
|
212
|
-
* `job_update` messages carry the same id; before a run starts it defaults
|
|
213
|
-
* to the constructor id. §16.
|
|
214
|
-
*/
|
|
215
|
-
private _effectiveJobId;
|
|
216
|
-
/** Run-level cancellation signal source; aborted by `cancel()`. */
|
|
217
|
-
private _abortController;
|
|
218
|
-
/**
|
|
219
|
-
* Pending response resolvers for sendControlEvent, FIFO per node. The
|
|
220
|
-
* controlled actor processes control events in order and emits outputs in
|
|
221
|
-
* order, so the oldest waiter matches the next output. A single slot per
|
|
222
|
-
* node would let a burst of concurrent control events (e.g. parallel agent
|
|
223
|
-
* tool calls) overwrite an earlier resolver, leaving its promise unsettled
|
|
224
|
-
* forever.
|
|
225
|
-
*/
|
|
226
|
-
private _pendingControlResponses;
|
|
227
|
-
/**
|
|
228
|
-
* Executor instance per node. Resolved once and reused so that the
|
|
229
|
-
* instance initialized in _initializeGraph is the same one that executes
|
|
230
|
-
* (NodeRegistry.resolve constructs a fresh instance per call).
|
|
231
|
-
*/
|
|
232
|
-
private _executors;
|
|
233
|
-
/**
|
|
234
|
-
* Nodes whose actor has finished running. A control event sent to such a
|
|
235
|
-
* node can never be answered (the actor's run loop is gone), so
|
|
236
|
-
* sendControlEvent rejects instead of registering a promise that hangs
|
|
237
|
-
* forever. This guards against an agent dispatching a burst of control
|
|
238
|
-
* tool calls where the controlled node errors (and terminates) partway
|
|
239
|
-
* through.
|
|
240
|
-
*/
|
|
241
|
-
private _completedNodes;
|
|
242
|
-
/** Errors reported by node actors, keyed by node id. */
|
|
243
|
-
private _nodeErrors;
|
|
244
|
-
/**
|
|
245
|
-
* Edge ids whose source has already been marked done on the target inbox.
|
|
246
|
-
* `markSourceDone` decrements an upstream counter, so marking the same edge
|
|
247
|
-
* twice would over-decrement and could prematurely close a handle that still
|
|
248
|
-
* has other open upstreams. Early per-slot EOS (`outputs.complete`) and the
|
|
249
|
-
* final `_sendEOS` both guard against double-marking via this set.
|
|
250
|
-
*/
|
|
251
|
-
private _eosSentEdges;
|
|
252
|
-
/** Supervisor escalations and their verdicts, in decision order. */
|
|
253
|
-
private _interventions;
|
|
254
|
-
/**
|
|
255
|
-
* Last output of each node per invocation lineage, for `read_node_output`.
|
|
256
|
-
* Only populated on a supervised run — an unsupervised one keeps nothing.
|
|
257
|
-
* Bounded per node: a 10k-item fan-out must not become a 10k-entry cache.
|
|
258
|
-
*/
|
|
259
|
-
private _recordedOutputs;
|
|
260
|
-
/** Undefined on an unsupervised run, so its `RunResult` is unchanged. */
|
|
261
|
-
private _recordedInterventions;
|
|
262
|
-
/**
|
|
263
|
-
* The handle every escalation actually goes through: whatever the caller
|
|
264
|
-
* configured, under the kernel's bounds. Nothing else in the runner reads
|
|
265
|
-
* `_options.supervisor`.
|
|
266
|
-
*/
|
|
267
|
-
private readonly _supervisor;
|
|
268
|
-
constructor(jobId: string, options: WorkflowRunnerOptions);
|
|
269
|
-
/**
|
|
270
|
-
* Push a streaming input value into the graph while it is running.
|
|
271
|
-
* The input name matches an input-node's `name` (or `id` fallback).
|
|
272
|
-
*/
|
|
273
|
-
pushInputValue(inputName: string, value: unknown, sourceHandle?: string): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
* Signal end-of-stream for an input node so downstream handles can complete.
|
|
276
|
-
*/
|
|
277
|
-
finishInputStream(inputName: string, sourceHandle?: string): void;
|
|
278
|
-
/**
|
|
279
|
-
* Execute a workflow graph.
|
|
280
|
-
*
|
|
281
|
-
* Requires hydrated descriptors: the actor trusts the behavior flags
|
|
282
|
-
* (`is_streaming_input` & co.) to pick the execution mode, so accepting a
|
|
283
|
-
* raw wire graph here would silently run streaming nodes as one-shot
|
|
284
|
-
* process() calls. Hydrate via `Graph.loadFromDict`, node-sdk's
|
|
285
|
-
* `hydrateGraphNodeFlags(graph, registry)`, or — for graphs constructed in
|
|
286
|
-
* code where the author sets the flags — `withExplicitNodeFlags`.
|
|
287
|
-
*/
|
|
288
|
-
run(request: RunJobRequest, graphData: HydratedGraphData): Promise<RunResult>;
|
|
289
|
-
private _runImpl;
|
|
290
|
-
private _resetRunState;
|
|
291
|
-
/**
|
|
292
|
-
* The read-only view a supervisor gets of the run in flight. Built from
|
|
293
|
-
* state the runner already holds, so a run without a supervisor pays for
|
|
294
|
-
* none of it. See docs/workflow-supervisor-design.md §6.
|
|
295
|
-
*/
|
|
296
|
-
private _runStateReader;
|
|
297
|
-
private _runStateDigest;
|
|
298
|
-
private _readRecordedOutput;
|
|
299
|
-
/**
|
|
300
|
-
* Remember what a node emitted, keyed by the invocation's lineage, so a
|
|
301
|
-
* supervisor can read a producer's output while deciding a consumer's
|
|
302
|
-
* failure. Off unless the run is supervised.
|
|
303
|
-
*/
|
|
304
|
-
private _recordNodeOutput;
|
|
305
|
-
/** Actors spawned and not yet finished. Zero before and after a run. */
|
|
306
|
-
get liveActorCount(): number;
|
|
307
|
-
/** Control-event responses still waiting on an actor, summed over nodes. */
|
|
308
|
-
get pendingControlResponseCount(): number;
|
|
309
|
-
/**
|
|
310
|
-
* Push property updates into a running node's executor instance (live
|
|
311
|
-
* parameter changes — e.g. turning a synth knob while the patch plays).
|
|
312
|
-
* Returns true when the node's executor exists and supports live updates;
|
|
313
|
-
* false is not an error — the caller's canvas state already holds the new
|
|
314
|
-
* value for the next run.
|
|
315
|
-
*/
|
|
316
|
-
updateNodeProperties(nodeId: string, properties: Record<string, unknown>): boolean;
|
|
317
|
-
cancel(): void;
|
|
318
|
-
/**
|
|
319
|
-
* Remove edges whose source or target node doesn't exist in the graph.
|
|
320
|
-
* Reconstructs the graph without dangling edges.
|
|
321
|
-
*/
|
|
322
|
-
private _filterInvalidEdges;
|
|
323
|
-
/**
|
|
324
|
-
* Run the optional `validateNode` callback for every node in the graph,
|
|
325
|
-
* passing the set of property handles that have an incoming data edge.
|
|
326
|
-
* Aggregates issues across nodes and throws a single GraphValidationError.
|
|
327
|
-
*/
|
|
328
|
-
private _validateNodes;
|
|
329
|
-
/** Refuse to start when a required workflow input has no supplied value. */
|
|
330
|
-
private _validateRequiredInputs;
|
|
331
|
-
/**
|
|
332
|
-
* Initialize every node's executor before any actor runs.
|
|
333
|
-
*
|
|
334
|
-
* A failure here aborts the run before `_processGraph`, so the actors that
|
|
335
|
-
* would normally call `finalize()` never start. Finalize the executors that
|
|
336
|
-
* did initialize, otherwise whatever they opened (python bridge handles,
|
|
337
|
-
* provider clients, file descriptors) leaks for the lifetime of the process.
|
|
338
|
-
* The failure is also re-thrown with the offending node's identity attached —
|
|
339
|
-
* a bare "connect ECONNREFUSED" gives no clue which node to fix.
|
|
340
|
-
*/
|
|
341
|
-
private _initializeGraph;
|
|
342
|
-
/** Finalize executors, never letting one failure hide another. */
|
|
343
|
-
private _finalizeExecutors;
|
|
344
|
-
/** Resolve (and cache) the executor instance for a node. */
|
|
345
|
-
private _resolveExecutor;
|
|
346
|
-
private _initializeInboxes;
|
|
347
|
-
private _detectMultiEdgeListInputs;
|
|
348
|
-
/**
|
|
349
|
-
* Deliver input parameters to input nodes (nodes with no incoming data edges).
|
|
350
|
-
* After delivery, mark them as done (EOS) since input nodes produce exactly
|
|
351
|
-
* one value.
|
|
352
|
-
*/
|
|
353
|
-
/** Variable-channel name a Set Variable node publishes to (its `name` prop). */
|
|
354
|
-
private _variableChannelName;
|
|
355
|
-
/**
|
|
356
|
-
* Tell the context how many Set Variable writers each channel has, before any
|
|
357
|
-
* actor runs. A channel with no writers then closes on first read so readers
|
|
358
|
-
* (Get Variable streams, Prompt awaits) end cleanly instead of hanging.
|
|
359
|
-
*/
|
|
360
|
-
private _registerVariableChannels;
|
|
361
|
-
private _dispatchInputs;
|
|
362
|
-
/**
|
|
363
|
-
* Spawn one NodeActor per node and run them concurrently.
|
|
364
|
-
* Actors that depend on inputs will block on their inboxes until
|
|
365
|
-
* upstream actors produce data.
|
|
366
|
-
*/
|
|
367
|
-
private _processGraph;
|
|
368
|
-
/**
|
|
369
|
-
* Detect a quiescent graph for Loop nodes (docs/workflow-loops.md).
|
|
370
|
-
*
|
|
371
|
-
* A loop body can finish an iteration without feeding anything back (an
|
|
372
|
-
* `If` routes the value elsewhere, a filter drops it). EOS cannot announce
|
|
373
|
-
* that, because the body's EOS waits for the loop to close. So when every
|
|
374
|
-
* live actor is parked on its inbox, no external stream is open, and some
|
|
375
|
-
* inbox activity happened since the last notice, each Loop is told the
|
|
376
|
-
* graph is quiescent and ends the runs still waiting for feedback. A parked
|
|
377
|
-
* actor is not inside a provider call, a timer, or a write, so nothing can
|
|
378
|
-
* still produce the value those runs wait for.
|
|
379
|
-
*
|
|
380
|
-
* Installed only for graphs that contain a Loop node.
|
|
381
|
-
*/
|
|
382
|
-
private _installQuiescenceDetection;
|
|
383
|
-
/**
|
|
384
|
-
* Route output values from a node to downstream inboxes.
|
|
385
|
-
* For control edges: route control events to the __control__ handle.
|
|
386
|
-
* For data edges: route to the named target handle.
|
|
387
|
-
*/
|
|
388
|
-
private _sendMessages;
|
|
389
|
-
/**
|
|
390
|
-
* A supervisor `skip`: retire one invocation's outputs without emitting.
|
|
391
|
-
*
|
|
392
|
-
* Plain non-emission is not enough. Siblings already buffered against the
|
|
393
|
-
* skipped key would sit at a downstream join forever, and an invocation of an
|
|
394
|
-
* iteration node would have opened child scopes an aggregate is waiting to
|
|
395
|
-
* see closed. So both signals go out on every outgoing data edge: the
|
|
396
|
-
* per-lineage `lineage_done` that unblocks joins, and a `lineage_scope_closed`
|
|
397
|
-
* per child root the invocation could have minted. Design §5.2.
|
|
398
|
-
*/
|
|
399
|
-
private _skipInvocationOutputs;
|
|
400
|
-
/**
|
|
401
|
-
* Mark the source of one data edge done on its target inbox at most once.
|
|
402
|
-
* `markSourceDone` decrements an upstream counter, so calling it twice for
|
|
403
|
-
* the same edge would over-decrement and could prematurely close a handle
|
|
404
|
-
* that still has other open upstreams. Both early per-slot EOS
|
|
405
|
-
* (`_signalSlotEos`) and the final `_sendEOS` route through this guard.
|
|
406
|
-
* Returns true if the mark was applied (first time), false if skipped.
|
|
407
|
-
*/
|
|
408
|
-
private _markEdgeSourceDoneOnce;
|
|
409
|
-
/**
|
|
410
|
-
* Signal early end-of-stream for a single output slot of a node, in
|
|
411
|
-
* response to `outputs.complete(slot)`. Marks every outgoing edge of
|
|
412
|
-
* `(nodeId, slot)` done on its target inbox immediately, rather than
|
|
413
|
-
* waiting for the actor to finish. Idempotent with `_sendEOS` via the
|
|
414
|
-
* `_eosSentEdges` guard so a handle's upstream count is never
|
|
415
|
-
* double-decremented.
|
|
416
|
-
*/
|
|
417
|
-
private _signalSlotEos;
|
|
418
|
-
/**
|
|
419
|
-
* Signal EOS on all outgoing edges of a completed node.
|
|
420
|
-
* For control edges: close the __control__ handle of the target.
|
|
421
|
-
* For data edges: close the named target handle.
|
|
422
|
-
*/
|
|
423
|
-
private _sendEOS;
|
|
424
|
-
/**
|
|
425
|
-
* Route __control_output__ from controller nodes to all controlled
|
|
426
|
-
* nodes via control edges. Wraps raw property dicts in a RunEvent.
|
|
427
|
-
* (Python parity: send_messages special handling of __control_output__.)
|
|
428
|
-
*/
|
|
429
|
-
private _routeControlOutput;
|
|
430
|
-
/**
|
|
431
|
-
* Broadcast a control event to all controlled nodes.
|
|
432
|
-
*/
|
|
433
|
-
dispatchControlEvent(event: ControlEvent): Promise<void>;
|
|
434
|
-
/**
|
|
435
|
-
* Send a control event to a specific target node.
|
|
436
|
-
*/
|
|
437
|
-
dispatchControlEventToTarget(event: ControlEvent, targetNodeId: string): Promise<void>;
|
|
438
|
-
/**
|
|
439
|
-
* Send a run control event to a specific node and await its output.
|
|
440
|
-
* Returns a promise that resolves with the node's output from the next
|
|
441
|
-
* output_update message emitted for that node.
|
|
442
|
-
*/
|
|
443
|
-
sendControlEvent(targetNodeId: string, properties: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
444
|
-
private _incrementEdgeCounter;
|
|
445
|
-
/**
|
|
446
|
-
* Emit the final counter for every edge whose count advanced past its last
|
|
447
|
-
* throttled edge_update, so the badge ends on the exact total. Called from
|
|
448
|
-
* _drainActiveEdges (which runs on completion, cancellation and error).
|
|
449
|
-
*/
|
|
450
|
-
private _flushEdgeCounters;
|
|
451
|
-
/**
|
|
452
|
-
* Post a "drained" EdgeUpdate for any edge whose target handle still has
|
|
453
|
-
* buffered items or open upstream sources. Called during post-completion
|
|
454
|
-
* cleanup to ensure front-end consumers stop listening to streams and
|
|
455
|
-
* clear any spinners.
|
|
456
|
-
*
|
|
457
|
-
* Returns the ids of edges found in that leftover state — §6's "zero
|
|
458
|
-
* pending work" is violated whenever this is non-empty after a normal
|
|
459
|
-
* (non-error) completion. The caller decides what strict mode does with
|
|
460
|
-
* that list; this method's own emit-and-continue behavior never changes,
|
|
461
|
-
* since it also runs on the error/cancellation cleanup path where a
|
|
462
|
-
* partial graph is expected to have open edges.
|
|
463
|
-
*/
|
|
464
|
-
private _drainActiveEdges;
|
|
465
|
-
/**
|
|
466
|
-
* Strict-mode gate for `_drainActiveEdges`'s findings (§12). Split out from
|
|
467
|
-
* its one call site (the success path in `_runImpl`, right after
|
|
468
|
-
* `_processGraph`) so it is unit-testable without a full graph run: in
|
|
469
|
-
* practice any leftover edge state this reports was already caught by the
|
|
470
|
-
* node-level `_checkPendingInboxWork` gate inside `_processGraph` (an
|
|
471
|
-
* inbox's `hasPendingWork()` covers every handle, edge-targeted ones
|
|
472
|
-
* included) and would have thrown before this method is ever reached —
|
|
473
|
-
* this gate exists for the state `_checkPendingInboxWork` cannot see (e.g.
|
|
474
|
-
* a driver that calls `_drainActiveEdges` directly after bypassing
|
|
475
|
-
* `_processGraph`) and as a second line of defense should that ordering
|
|
476
|
-
* ever change.
|
|
477
|
-
*
|
|
478
|
-
* A cancelled run, or one with node errors, legitimately
|
|
479
|
-
* leaves edges mid-flight — that is what the drain reports to the
|
|
480
|
-
* frontend in every mode. Only a run that is otherwise clean but still has
|
|
481
|
-
* leftover edge state is a §6 violation ("zero pending work" after a
|
|
482
|
-
* normal completion).
|
|
483
|
-
*/
|
|
484
|
-
private _enforceCleanEdgeDrain;
|
|
485
|
-
private _checkPendingInboxWork;
|
|
486
|
-
private _isOutputNode;
|
|
487
|
-
/**
|
|
488
|
-
* External input nodes are placeholders that receive runtime params/streamed values.
|
|
489
|
-
* They should not execute as normal source actors.
|
|
490
|
-
*/
|
|
491
|
-
private _isExternalInputNode;
|
|
492
|
-
private _getExternalInputName;
|
|
493
|
-
/**
|
|
494
|
-
* Key a terminal node's outputs are collected under.
|
|
495
|
-
*
|
|
496
|
-
* DSL-authored graphs carry the public name in the Output node's `name`
|
|
497
|
-
* *property* (`output({ name: "hook", value })`) — the descriptor's
|
|
498
|
-
* top-level `name` is absent, and the auto-generated node id (`output`,
|
|
499
|
-
* `output_2`, …) is all that would remain. Promote the property for
|
|
500
|
-
* output-typed nodes so a run's outputs are keyed by the name the author
|
|
501
|
-
* asked for. Mirrors `_getExternalInputName` on the input side and the
|
|
502
|
-
* websocket runner's `require_terminal_result` rewrite; gating on
|
|
503
|
-
* `nodetool.output.` keeps other terminal sinks keyed by id.
|
|
504
|
-
*/
|
|
505
|
-
private _outputCollectionKey;
|
|
506
|
-
private _emit;
|
|
507
|
-
private _resolveInputNodes;
|
|
508
|
-
/**
|
|
509
|
-
* Build control context for a controller node.
|
|
510
|
-
* Returns null if the node has no outgoing control edges.
|
|
511
|
-
*
|
|
512
|
-
* The control context maps controlled node IDs to their metadata
|
|
513
|
-
* (node_type, properties with current values, types, descriptions).
|
|
514
|
-
* This is injected as `_control_context` input so agent nodes can
|
|
515
|
-
* build ControlNodeTool instances for LLM tool-calling.
|
|
516
|
-
*/
|
|
517
|
-
private _buildControlContext;
|
|
518
|
-
/**
|
|
519
|
-
* Build the property schema for a controlled node's "run" action.
|
|
520
|
-
* Maps property names to JSON-schema-like descriptors for ControlNodeTool.
|
|
521
|
-
*/
|
|
522
|
-
private _buildControlActionProperties;
|
|
523
|
-
}
|
|
1
|
+
export * from "@nodetool-ai/execution-core/runner";
|
|
524
2
|
//# sourceMappingURL=runner.d.ts.map
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC"}
|