yaml-flow 3.1.1 → 5.0.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/README.md +81 -20
- package/board-live-cards-cli.js +37 -0
- package/browser/board-livegraph-runtime.js +1453 -0
- package/browser/board-livegraph-runtime.js.map +1 -0
- package/browser/card-compute.js +153 -433
- package/browser/live-cards.js +868 -115
- package/browser/live-cards.schema.json +90 -83
- package/dist/board-livegraph-runtime/index.cjs +1448 -0
- package/dist/board-livegraph-runtime/index.cjs.map +1 -0
- package/dist/board-livegraph-runtime/index.d.cts +101 -0
- package/dist/board-livegraph-runtime/index.d.ts +101 -0
- package/dist/board-livegraph-runtime/index.js +1441 -0
- package/dist/board-livegraph-runtime/index.js.map +1 -0
- package/dist/card-compute/index.cjs +266 -431
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +77 -49
- package/dist/card-compute/index.d.ts +77 -49
- package/dist/card-compute/index.js +263 -432
- package/dist/card-compute/index.js.map +1 -1
- package/dist/cli/board-live-cards-cli.cjs +2750 -0
- package/dist/cli/board-live-cards-cli.cjs.map +1 -0
- package/dist/cli/board-live-cards-cli.d.cts +205 -0
- package/dist/cli/board-live-cards-cli.d.ts +205 -0
- package/dist/cli/board-live-cards-cli.js +2702 -0
- package/dist/cli/board-live-cards-cli.js.map +1 -0
- package/dist/{constants-B2zqu10b.d.ts → constants-DuzE5n03.d.ts} +2 -2
- package/dist/{constants-DJZU1pwJ.d.cts → constants-ozjf1Ejw.d.cts} +2 -2
- package/dist/continuous-event-graph/index.cjs +258 -464
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +18 -358
- package/dist/continuous-event-graph/index.d.ts +18 -358
- package/dist/continuous-event-graph/index.js +255 -464
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/event-graph/index.cjs +4 -4
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.d.cts +5 -5
- package/dist/event-graph/index.d.ts +5 -5
- package/dist/event-graph/index.js +4 -4
- package/dist/event-graph/index.js.map +1 -1
- package/dist/index.cjs +1684 -555
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.js +1678 -555
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +138 -19
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.d.cts +2 -2
- package/dist/inference/index.d.ts +2 -2
- package/dist/inference/index.js +138 -19
- package/dist/inference/index.js.map +1 -1
- package/dist/journal-DRfJiheM.d.cts +28 -0
- package/dist/journal-NLYuqege.d.ts +28 -0
- package/dist/live-cards-bridge-Or7fdEJV.d.ts +316 -0
- package/dist/live-cards-bridge-vGJ6tMzN.d.cts +316 -0
- package/dist/schedule-CMcZe5Ny.d.ts +21 -0
- package/dist/schedule-CiucyCan.d.cts +21 -0
- package/dist/step-machine/index.cjs +18 -1
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.d.cts +2 -2
- package/dist/step-machine/index.d.ts +2 -2
- package/dist/step-machine/index.js +18 -1
- package/dist/step-machine/index.js.map +1 -1
- package/dist/stores/file.d.cts +1 -1
- package/dist/stores/file.d.ts +1 -1
- package/dist/stores/index.d.cts +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/localStorage.d.cts +1 -1
- package/dist/stores/localStorage.d.ts +1 -1
- package/dist/stores/memory.d.cts +1 -1
- package/dist/stores/memory.d.ts +1 -1
- package/dist/{types-BwvgvlOO.d.cts → types-BzLD8bjb.d.cts} +1 -1
- package/dist/{types-ClRA8hzC.d.ts → types-C2eJ7DAV.d.ts} +1 -1
- package/dist/{types-DEj7OakX.d.cts → types-CMFSIjpc.d.cts} +39 -4
- package/dist/{types-DEj7OakX.d.ts → types-CMFSIjpc.d.ts} +39 -4
- package/dist/{types-FZ_eyErS.d.cts → types-ycun84cq.d.cts} +1 -0
- package/dist/{types-FZ_eyErS.d.ts → types-ycun84cq.d.ts} +1 -0
- package/dist/{validate-DEZ2Ymdb.d.ts → validate-DJQTQ6bP.d.ts} +1 -1
- package/dist/{validate-DqKTZg_o.d.cts → validate-ke92Cleg.d.cts} +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +16 -0
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/browser/boards/portfolio-tracker/fetch-prices.js +43 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +7 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +217 -0
- package/examples/browser/livecards-browser/index.html +41 -0
- package/examples/browser/{index.html → step-machine-browser/index.html} +53 -53
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
- package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +36 -0
- package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +30 -0
- package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +19 -0
- package/examples/cli/step-machine-demo/step-cli-echo-y.js +15 -0
- package/examples/cli/step-machine-demo/step2-double-cli.js +39 -0
- package/examples/cli/step-machine-demo/two-step-math-handlers.js +32 -0
- package/examples/cli/step-machine-demo/two-step-math.flow.yaml +31 -0
- package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +24 -0
- package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +35 -0
- package/examples/example-board/board.yaml +23 -0
- package/examples/example-board/bootstrap_payload.json +1 -0
- package/examples/example-board/cards/card-chain-region-alert.json +39 -0
- package/examples/example-board/cards/card-chain-region-totals.json +26 -0
- package/examples/example-board/cards/card-chain-top-region.json +24 -0
- package/examples/example-board/cards/card-ex-actions.json +32 -0
- package/examples/example-board/cards/card-ex-chart.json +30 -0
- package/examples/example-board/cards/card-ex-filter.json +36 -0
- package/examples/example-board/cards/card-ex-filtered-by-preference.json +59 -0
- package/examples/example-board/cards/card-ex-form.json +91 -0
- package/examples/example-board/cards/card-ex-list.json +22 -0
- package/examples/example-board/cards/card-ex-markdown.json +17 -0
- package/examples/example-board/cards/card-ex-metric.json +19 -0
- package/examples/example-board/cards/card-ex-narrative.json +36 -0
- package/examples/example-board/cards/card-ex-source-http.json +28 -0
- package/examples/example-board/cards/card-ex-source.json +21 -0
- package/examples/example-board/cards/card-ex-status.json +35 -0
- package/examples/example-board/cards/card-ex-table.json +30 -0
- package/examples/example-board/cards/card-ex-todo.json +29 -0
- package/examples/example-board/demo-chat-handler.js +69 -0
- package/examples/example-board/demo-server.js +87 -0
- package/examples/example-board/demo-shell-browser.html +806 -0
- package/examples/example-board/demo-shell-with-server.html +280 -0
- package/examples/example-board/demo-shell.html +62 -0
- package/examples/example-board/demo-task-executor.js +255 -0
- package/examples/example-board/mock.db +15 -0
- package/examples/example-board/reusable-board-runtime-client.js +265 -0
- package/examples/example-board/reusable-runtime-artifacts-adapter.js +233 -0
- package/examples/example-board/reusable-server-runtime.js +1284 -0
- package/examples/index.html +799 -0
- package/examples/{batch → npm-libs/batch}/batch-step-machine.ts +1 -1
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/live-cards-board.ts +18 -18
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/live-portfolio-dashboard.ts +24 -24
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/portfolio-tracker.ts +1 -1
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/reactive-monitoring.ts +1 -1
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/reactive-pipeline.ts +1 -1
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/soc-incident-board.ts +1 -1
- package/examples/{continuous-event-graph → npm-libs/continuous-event-graph}/stock-dashboard.ts +1 -1
- package/examples/{event-graph → npm-libs/event-graph}/ci-cd-pipeline.ts +1 -1
- package/examples/{event-graph → npm-libs/event-graph}/executor-diamond.ts +1 -1
- package/examples/{event-graph → npm-libs/event-graph}/executor-pipeline.ts +1 -1
- package/examples/{event-graph → npm-libs/event-graph}/research-pipeline.ts +1 -1
- package/examples/{graph-of-graphs → npm-libs/graph-of-graphs}/multi-stage-etl.ts +1 -1
- package/examples/{graph-of-graphs → npm-libs/graph-of-graphs}/url-processing-pipeline.ts +1 -1
- package/examples/{inference → npm-libs/inference}/azure-deployment.ts +1 -1
- package/examples/{inference → npm-libs/inference}/copilot-cli.ts +1 -1
- package/examples/{inference → npm-libs/inference}/data-pipeline.ts +1 -1
- package/examples/{inference → npm-libs/inference}/pluggable-adapters.ts +1 -1
- package/examples/{node → npm-libs/node}/ai-conversation.ts +1 -1
- package/examples/{node → npm-libs/node}/simple-greeting.ts +2 -2
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker-task-executor.cjs +96 -0
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
- package/package.json +27 -2
- package/schema/board-status.schema.json +118 -0
- package/schema/card-runtime.schema.json +25 -0
- package/schema/flow.schema.json +5 -0
- package/schema/live-cards.schema.json +90 -83
- package/step-machine-cli.js +674 -0
- package/browser/ingest-board.js +0 -296
- package/examples/ingest.js +0 -733
- /package/examples/{flows → npm-libs/flows}/ai-conversation.yaml +0 -0
- /package/examples/{flows → npm-libs/flows}/order-processing.yaml +0 -0
- /package/examples/{flows → npm-libs/flows}/simple-greeting.yaml +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot,
|
|
2
|
-
export { B as BlockedTask, P as PendingTask, d as UnresolvedDependency } from '../types-
|
|
3
|
-
import { T as TaskConfig, f as GraphEvent, G as GraphConfig
|
|
4
|
-
export { c as ExecutionState, g as GraphSettings } from '../types-
|
|
5
|
-
|
|
1
|
+
import { L as LiveGraph, N as NodeInfo, b as LiveGraphSnapshot, D as DownstreamResult, U as UnreachableNodesResult, c as UnreachableTokensResult, e as UpstreamResult, a as LiveGraphHealth } from '../types-C2eJ7DAV.js';
|
|
2
|
+
export { B as BlockedTask, P as PendingTask, S as ScheduleResult, d as UnresolvedDependency } from '../types-C2eJ7DAV.js';
|
|
3
|
+
import { T as TaskConfig, f as GraphEvent, G as GraphConfig } from '../types-CMFSIjpc.js';
|
|
4
|
+
export { c as ExecutionState, e as GraphEngineStore, g as GraphSettings } from '../types-CMFSIjpc.js';
|
|
5
|
+
export { s as schedule } from '../schedule-CMcZe5Ny.js';
|
|
6
|
+
import { R as ReactiveGraph, e as TaskHandlerInput, T as TaskHandlerFn } from '../live-cards-bridge-Or7fdEJV.js';
|
|
7
|
+
export { L as LiveBoard, a as LiveCard, b as LiveCardsToReactiveOptions, c as LiveCardsToReactiveResult, d as ReactiveGraphOptions, f as TaskHandlerReturn, h as computeDataHash, g as createReactiveGraph, l as liveCardsToReactiveGraph } from '../live-cards-bridge-Or7fdEJV.js';
|
|
8
|
+
import { a as GraphValidationResult } from '../validate-DJQTQ6bP.js';
|
|
9
|
+
export { J as Journal, M as MemoryJournal } from '../journal-NLYuqege.js';
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Continuous Event Graph — Core
|
|
@@ -21,11 +25,12 @@ import { a as GraphValidationResult } from '../validate-DEZ2Ymdb.js';
|
|
|
21
25
|
*/
|
|
22
26
|
declare function createLiveGraph(config: GraphConfig, executionId?: string): LiveGraph;
|
|
23
27
|
/**
|
|
24
|
-
* Apply an
|
|
25
|
-
* Events are the shared vocabulary
|
|
26
|
-
* task-
|
|
28
|
+
* Apply an event to the LiveGraph, producing a new LiveGraph.
|
|
29
|
+
* Events are the shared vocabulary — both execution state transitions
|
|
30
|
+
* (task-started, task-completed, etc.) and structural mutations
|
|
31
|
+
* (task-upsert, task-removal, node-requires-add, etc.).
|
|
27
32
|
*
|
|
28
|
-
*
|
|
33
|
+
* Pure function: f(LiveGraph, GraphEvent) → LiveGraph
|
|
29
34
|
*/
|
|
30
35
|
declare function applyEvent(live: LiveGraph, event: GraphEvent): LiveGraph;
|
|
31
36
|
/**
|
|
@@ -35,8 +40,9 @@ declare function applyEvent(live: LiveGraph, event: GraphEvent): LiveGraph;
|
|
|
35
40
|
*/
|
|
36
41
|
declare function applyEvents(live: LiveGraph, events: GraphEvent[]): LiveGraph;
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
39
|
-
* If the node already exists,
|
|
43
|
+
* Upsert a node (task) in the live graph. Updates both config and state atomically.
|
|
44
|
+
* If the node already exists, replaces its config but preserves its state.
|
|
45
|
+
* If new, creates fresh default state.
|
|
40
46
|
*/
|
|
41
47
|
declare function addNode(live: LiveGraph, name: string, taskConfig: TaskConfig): LiveGraph;
|
|
42
48
|
/**
|
|
@@ -109,24 +115,6 @@ declare function snapshot(live: LiveGraph): LiveGraphSnapshot;
|
|
|
109
115
|
*/
|
|
110
116
|
declare function restore(data: unknown): LiveGraph;
|
|
111
117
|
|
|
112
|
-
/**
|
|
113
|
-
* Continuous Event Graph — Schedule
|
|
114
|
-
*
|
|
115
|
-
* Pure read-only projection: LiveGraph → ScheduleResult
|
|
116
|
-
*
|
|
117
|
-
* Classifies every non-terminal task into one of:
|
|
118
|
-
* - eligible: all requires satisfied, ready to dispatch
|
|
119
|
-
* - pending: requires not yet met, but a viable producer exists (normal waiting)
|
|
120
|
-
* - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
|
|
121
|
-
* - blocked: requires not met because the producing task FAILED (caller's problem)
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Compute the scheduling status of every task in the live graph.
|
|
126
|
-
* Pure function — no side effects.
|
|
127
|
-
*/
|
|
128
|
-
declare function schedule(live: LiveGraph): ScheduleResult;
|
|
129
|
-
|
|
130
118
|
/**
|
|
131
119
|
* Continuous Event Graph — Inspect
|
|
132
120
|
*
|
|
@@ -183,185 +171,6 @@ declare function getUpstream(live: LiveGraph, nodeName: string): UpstreamResult;
|
|
|
183
171
|
*/
|
|
184
172
|
declare function getDownstream(live: LiveGraph, nodeName: string): DownstreamResult;
|
|
185
173
|
|
|
186
|
-
/**
|
|
187
|
-
* Continuous Event Graph — Journal
|
|
188
|
-
*
|
|
189
|
-
* Append-only event log for the reactive layer.
|
|
190
|
-
* Handlers append events here; drain() reads and clears atomically.
|
|
191
|
-
*
|
|
192
|
-
* Two adapters:
|
|
193
|
-
* - MemoryJournal: in-process array (default)
|
|
194
|
-
* - FileJournal: append to a JSONL file, truncate on drain
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
interface Journal {
|
|
198
|
-
/** Append an event to the journal. Safe to call from concurrent callbacks. */
|
|
199
|
-
append(event: GraphEvent): void;
|
|
200
|
-
/** Read all pending events and clear the journal atomically. */
|
|
201
|
-
drain(): GraphEvent[];
|
|
202
|
-
/** Number of pending events (for observability). */
|
|
203
|
-
readonly size: number;
|
|
204
|
-
}
|
|
205
|
-
declare class MemoryJournal implements Journal {
|
|
206
|
-
private buffer;
|
|
207
|
-
append(event: GraphEvent): void;
|
|
208
|
-
drain(): GraphEvent[];
|
|
209
|
-
get size(): number;
|
|
210
|
-
}
|
|
211
|
-
declare class FileJournal implements Journal {
|
|
212
|
-
private readonly path;
|
|
213
|
-
private pending;
|
|
214
|
-
constructor(path: string);
|
|
215
|
-
append(event: GraphEvent): void;
|
|
216
|
-
drain(): GraphEvent[];
|
|
217
|
-
get size(): number;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Continuous Event Graph — Reactive Layer
|
|
222
|
-
*
|
|
223
|
-
* Push-based, self-sustaining execution wrapper.
|
|
224
|
-
*
|
|
225
|
-
* Pattern:
|
|
226
|
-
* 1. Register handlers for tasks
|
|
227
|
-
* 2. Push an event (or inject tokens)
|
|
228
|
-
* 3. The graph drives itself: drain journal → applyEvents → schedule → dispatch → repeat
|
|
229
|
-
*
|
|
230
|
-
* No daemon, no polling. Each handler callback appends to the journal,
|
|
231
|
-
* which triggers a drain cycle that may dispatch the next wave.
|
|
232
|
-
*
|
|
233
|
-
* Dispatch failures, retries, and timeouts are managed internally
|
|
234
|
-
* without touching the core engine types.
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Deterministic hash of a data payload.
|
|
239
|
-
* Recursively-sorted JSON → SHA-256 hex (first 16 chars for compactness).
|
|
240
|
-
* Used to auto-compute dataHash when the handler doesn't provide one.
|
|
241
|
-
* Exported so handler authors can pre-compute or test hashes.
|
|
242
|
-
*/
|
|
243
|
-
declare function computeDataHash(data: Record<string, unknown>): string;
|
|
244
|
-
/**
|
|
245
|
-
* Input passed to a task handler function.
|
|
246
|
-
*
|
|
247
|
-
* The reactive layer resolves upstream data from `requires` into `state`,
|
|
248
|
-
* and provides this task's own engine store as `taskState`.
|
|
249
|
-
* Handlers push output data back via `graph.resolveCallback(callbackToken, data)`.
|
|
250
|
-
*/
|
|
251
|
-
interface TaskHandlerInput {
|
|
252
|
-
/** This task's node ID (task name) */
|
|
253
|
-
nodeId: string;
|
|
254
|
-
/**
|
|
255
|
-
* Upstream dependency data, keyed by require token name.
|
|
256
|
-
* Only tokens from this task's `requires` are present.
|
|
257
|
-
* Value is the producing task's `data` field (or undefined if not yet available).
|
|
258
|
-
*/
|
|
259
|
-
state: Readonly<Record<string, Record<string, unknown> | undefined>>;
|
|
260
|
-
/**
|
|
261
|
-
* This task's own GraphEngineStore — includes status, data, executionCount, etc.
|
|
262
|
-
*/
|
|
263
|
-
taskState: Readonly<GraphEngineStore>;
|
|
264
|
-
/** This task's config */
|
|
265
|
-
config: Readonly<TaskConfig>;
|
|
266
|
-
/**
|
|
267
|
-
* Opaque callback token encoding this task's identity.
|
|
268
|
-
* Pass this to `graph.resolveCallback(callbackToken, data)` to complete the task.
|
|
269
|
-
* Can be serialized and sent to external systems (webhooks, other scripts,
|
|
270
|
-
* message queues) — any process with this token can push data back.
|
|
271
|
-
*/
|
|
272
|
-
callbackToken: string;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Handler return value — initiation status only.
|
|
276
|
-
* - `'task-initiated'` — async work started successfully; data will arrive via resolveCallback
|
|
277
|
-
* - `'task-initiate-failure'` — failed to start (bad config, connection refused, etc.)
|
|
278
|
-
*/
|
|
279
|
-
type TaskHandlerReturn = 'task-initiated' | 'task-initiate-failure';
|
|
280
|
-
/**
|
|
281
|
-
* A named task handler function.
|
|
282
|
-
* Registered in the handler registry, referenced by name in `taskConfig.taskHandlers`.
|
|
283
|
-
*
|
|
284
|
-
* The handler's job is to **initiate** async work, not await it.
|
|
285
|
-
*
|
|
286
|
-
* Flow:
|
|
287
|
-
* 1. Handler receives `callbackToken` + upstream `state`
|
|
288
|
-
* 2. Handler kicks off background work (internal, external script, webhook, etc.)
|
|
289
|
-
* — passes `callbackToken` to the background work
|
|
290
|
-
* 3. Handler returns `'task-initiated'` immediately
|
|
291
|
-
* 4. Background work runs independently — when done, it calls
|
|
292
|
-
* `graph.resolveCallback(callbackToken, data)` for success, or
|
|
293
|
-
* `graph.resolveCallback(callbackToken, {}, ['error msg'])` for failure
|
|
294
|
-
* 5. resolveCallback completes the task → data-changed cascade fires
|
|
295
|
-
*
|
|
296
|
-
* The callbackToken is opaque — pass it to the background work so it can
|
|
297
|
-
* call back. Works across processes, scripts, webhooks, message queues.
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* ```ts
|
|
301
|
-
* const fetchYahoo: TaskHandlerFn = async ({ state, callbackToken }) => {
|
|
302
|
-
* const symbols = state['portfolio-form']?.holdings?.map(h => h.symbol) ?? [];
|
|
303
|
-
* // Kick off background work — do NOT await
|
|
304
|
-
* fetch(`https://api.yahoo.com/prices?s=${symbols.join(',')}`)
|
|
305
|
-
* .then(res => res.json())
|
|
306
|
-
* .then(prices => graph.resolveCallback(callbackToken, { prices }))
|
|
307
|
-
* .catch(err => graph.resolveCallback(callbackToken, {}, [err.message]));
|
|
308
|
-
* // Return immediately — background work will resolveCallback when done
|
|
309
|
-
* return 'task-initiated';
|
|
310
|
-
* };
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
type TaskHandlerFn = (input: TaskHandlerInput) => Promise<TaskHandlerReturn>;
|
|
314
|
-
interface ReactiveGraphOptions {
|
|
315
|
-
/** Named handler registry — handler name → handler function */
|
|
316
|
-
handlers: Record<string, TaskHandlerFn>;
|
|
317
|
-
/** Journal adapter (default: MemoryJournal) */
|
|
318
|
-
journal?: Journal;
|
|
319
|
-
/** Called after each drain cycle — for observability */
|
|
320
|
-
onDrain?: (events: GraphEvent[], live: LiveGraph, scheduleResult: ScheduleResult) => void;
|
|
321
|
-
}
|
|
322
|
-
interface ReactiveGraph {
|
|
323
|
-
/** Push an event into the graph via journal. Triggers drain → schedule → dispatch. */
|
|
324
|
-
push(event: GraphEvent): void;
|
|
325
|
-
/** Push multiple events via journal. Single drain cycle after all are journaled. */
|
|
326
|
-
pushAll(events: GraphEvent[]): void;
|
|
327
|
-
/**
|
|
328
|
-
* Resolve a callback token — complete (or fail) a task after initiation.
|
|
329
|
-
* Journals task-completed or task-failed, then drains.
|
|
330
|
-
* Gracefully ignores invalid tokens or tokens for tasks no longer in the graph.
|
|
331
|
-
*/
|
|
332
|
-
resolveCallback(callbackToken: string, data: Record<string, unknown>, errors?: string[]): void;
|
|
333
|
-
/** Add a node to the graph config. Journals nothing — structural mutation. */
|
|
334
|
-
addNode(name: string, taskConfig: TaskConfig): void;
|
|
335
|
-
/** Remove a node from the graph config. Structural mutation. */
|
|
336
|
-
removeNode(name: string): void;
|
|
337
|
-
/** Add required tokens to an existing node. Structural mutation + drain. */
|
|
338
|
-
addRequires(nodeName: string, tokens: string[]): void;
|
|
339
|
-
/** Remove required tokens from an existing node. Structural mutation + drain. */
|
|
340
|
-
removeRequires(nodeName: string, tokens: string[]): void;
|
|
341
|
-
/** Add provided tokens to an existing node. Structural mutation + drain. */
|
|
342
|
-
addProvides(nodeName: string, tokens: string[]): void;
|
|
343
|
-
/** Remove provided tokens from an existing node. Structural mutation. */
|
|
344
|
-
removeProvides(nodeName: string, tokens: string[]): void;
|
|
345
|
-
/** Register a named handler in the registry. */
|
|
346
|
-
registerHandler(name: string, fn: TaskHandlerFn): void;
|
|
347
|
-
/** Unregister a named handler from the registry. */
|
|
348
|
-
unregisterHandler(name: string): void;
|
|
349
|
-
/**
|
|
350
|
-
* Re-trigger a task: journals a task-restart event, then drains.
|
|
351
|
-
* data-changed cascade handles downstream automatically.
|
|
352
|
-
*/
|
|
353
|
-
retrigger(taskName: string): void;
|
|
354
|
-
/** Re-trigger multiple tasks via journal. */
|
|
355
|
-
retriggerAll(taskNames: string[]): void;
|
|
356
|
-
/** Read-only snapshot of current LiveGraph state. */
|
|
357
|
-
getState(): LiveGraph;
|
|
358
|
-
/** Current schedule projection. */
|
|
359
|
-
getSchedule(): ScheduleResult;
|
|
360
|
-
/** Stop accepting events. */
|
|
361
|
-
dispose(): void;
|
|
362
|
-
}
|
|
363
|
-
declare function createReactiveGraph(config: GraphConfig, options: ReactiveGraphOptions, executionId?: string): ReactiveGraph;
|
|
364
|
-
|
|
365
174
|
/**
|
|
366
175
|
* Continuous Event Graph — Validation Utilities
|
|
367
176
|
*
|
|
@@ -665,153 +474,4 @@ declare function createWebhookHandler(options: WebhookHandlerOptions): TaskHandl
|
|
|
665
474
|
*/
|
|
666
475
|
declare function createNoopHandler(getResolve: () => ResolveCallbackFn, staticData?: Record<string, unknown>): TaskHandlerFn;
|
|
667
476
|
|
|
668
|
-
|
|
669
|
-
* Live Cards → Reactive Graph
|
|
670
|
-
*
|
|
671
|
-
* Takes an array of live card JSONs (card / source nodes) and produces
|
|
672
|
-
* a fully wired ReactiveGraph where:
|
|
673
|
-
*
|
|
674
|
-
* - Each card becomes a task in the graph
|
|
675
|
-
* - card.data.requires → task.requires (upstream card IDs as tokens)
|
|
676
|
-
* - Each card produces a token equal to its own ID
|
|
677
|
-
* - Card-type nodes: handler runs CardCompute.run() on a clone of the card,
|
|
678
|
-
* returns the computed state as data (auto-hashed by the reactive layer)
|
|
679
|
-
* - Source-type nodes: handler uses the source definition to fetch data,
|
|
680
|
-
* or falls back to a user-provided handler / noop
|
|
681
|
-
*
|
|
682
|
-
* The reactive graph auto-computes dataHash on every handler result,
|
|
683
|
-
* so `data-changed` refresh strategy works out of the box.
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```ts
|
|
687
|
-
* import { liveCardsToReactiveGraph } from 'yaml-flow/continuous-event-graph';
|
|
688
|
-
*
|
|
689
|
-
* const cards = [
|
|
690
|
-
* { id: 'prices', type: 'source', source: { kind: 'api', bindTo: 'state.raw', url_template: '...' }, state: {} },
|
|
691
|
-
* { id: 'dashboard', type: 'card', data: { requires: ['prices'] }, state: {}, compute: { total: { fn: 'sum', ... } }, view: { ... } },
|
|
692
|
-
* ];
|
|
693
|
-
*
|
|
694
|
-
* const rg = liveCardsToReactiveGraph(cards, {
|
|
695
|
-
* sourceHandlers: {
|
|
696
|
-
* prices: async () => ({ data: { raw: await fetchPrices() } }),
|
|
697
|
-
* },
|
|
698
|
-
* });
|
|
699
|
-
*
|
|
700
|
-
* // One push → the whole board computes itself
|
|
701
|
-
* rg.push({ type: 'inject-tokens', tokens: [], timestamp: new Date().toISOString() });
|
|
702
|
-
* ```
|
|
703
|
-
*/
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Minimal live card shape accepted by this utility.
|
|
707
|
-
* Matches the live-cards.schema.json structure.
|
|
708
|
-
*/
|
|
709
|
-
interface LiveCard {
|
|
710
|
-
id: string;
|
|
711
|
-
type: 'card' | 'source';
|
|
712
|
-
meta?: {
|
|
713
|
-
title?: string;
|
|
714
|
-
tags?: string[];
|
|
715
|
-
};
|
|
716
|
-
data?: {
|
|
717
|
-
requires?: string[];
|
|
718
|
-
provides?: Record<string, unknown>;
|
|
719
|
-
};
|
|
720
|
-
state?: Record<string, unknown>;
|
|
721
|
-
compute?: Record<string, unknown>;
|
|
722
|
-
source?: {
|
|
723
|
-
kind: 'api' | 'websocket' | 'static' | 'llm';
|
|
724
|
-
bindTo: string;
|
|
725
|
-
url_template?: string;
|
|
726
|
-
method?: string;
|
|
727
|
-
headers?: Record<string, unknown>;
|
|
728
|
-
body_template?: Record<string, unknown>;
|
|
729
|
-
poll_interval?: number;
|
|
730
|
-
transform?: string;
|
|
731
|
-
[key: string]: unknown;
|
|
732
|
-
};
|
|
733
|
-
view?: Record<string, unknown>;
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* A Board is a named container of live card nodes.
|
|
737
|
-
* Matches the shape used by LiveCard.Board() in browser/live-cards.js:
|
|
738
|
-
* LiveCard.Board(engine, el, { nodes, positions?, mode, canvas, ... })
|
|
739
|
-
*
|
|
740
|
-
* The `nodes` array contains the card/source JSON objects.
|
|
741
|
-
* Board-level metadata (id, title, settings) is carried through to the
|
|
742
|
-
* generated GraphConfig.
|
|
743
|
-
*/
|
|
744
|
-
interface LiveBoard {
|
|
745
|
-
/** Board identifier */
|
|
746
|
-
id?: string;
|
|
747
|
-
/** Human-readable title */
|
|
748
|
-
title?: string;
|
|
749
|
-
/** The card/source nodes on this board */
|
|
750
|
-
nodes: LiveCard[];
|
|
751
|
-
/** Board display mode (informational — not used by the reactive graph) */
|
|
752
|
-
mode?: 'board' | 'canvas';
|
|
753
|
-
/** Canvas positions keyed by node ID (informational — not used) */
|
|
754
|
-
positions?: Record<string, {
|
|
755
|
-
x?: number;
|
|
756
|
-
y?: number;
|
|
757
|
-
w?: number;
|
|
758
|
-
h?: number;
|
|
759
|
-
}>;
|
|
760
|
-
/** Board-level settings forwarded to GraphConfig.settings */
|
|
761
|
-
settings?: Partial<GraphConfig['settings']>;
|
|
762
|
-
}
|
|
763
|
-
interface LiveCardsToReactiveOptions {
|
|
764
|
-
/** Custom handlers for source nodes (keyed by card ID). */
|
|
765
|
-
sourceHandlers?: Record<string, TaskHandlerFn>;
|
|
766
|
-
/**
|
|
767
|
-
* Default handler factory for source nodes without an explicit handler.
|
|
768
|
-
* Called once per source card during graph construction.
|
|
769
|
-
* If not provided, source nodes without explicit handlers get a noop handler
|
|
770
|
-
* that returns the card's current state.
|
|
771
|
-
*/
|
|
772
|
-
defaultSourceHandler?: (card: LiveCard) => TaskHandlerFn;
|
|
773
|
-
/**
|
|
774
|
-
* Custom handlers for card nodes (keyed by card ID).
|
|
775
|
-
* Overrides the default CardCompute.run() behavior.
|
|
776
|
-
*/
|
|
777
|
-
cardHandlers?: Record<string, TaskHandlerFn>;
|
|
778
|
-
/**
|
|
779
|
-
* If provided, upstream card state is injected into downstream cards
|
|
780
|
-
* before running compute. The key is the upstream card ID and the value
|
|
781
|
-
* is the upstream card's latest state.
|
|
782
|
-
*/
|
|
783
|
-
sharedState?: Map<string, Record<string, unknown>>;
|
|
784
|
-
/** Override reactive graph options (journal, callbacks, etc.) */
|
|
785
|
-
reactiveOptions?: Partial<Omit<ReactiveGraphOptions, 'handlers'>>;
|
|
786
|
-
/** Graph-level settings overrides */
|
|
787
|
-
graphSettings?: Partial<GraphConfig['settings']>;
|
|
788
|
-
/** Execution ID for the reactive graph */
|
|
789
|
-
executionId?: string;
|
|
790
|
-
}
|
|
791
|
-
interface LiveCardsToReactiveResult {
|
|
792
|
-
/** The fully wired reactive graph — ready to push events into. */
|
|
793
|
-
graph: ReactiveGraph;
|
|
794
|
-
/** The generated GraphConfig (for inspection/serialization). */
|
|
795
|
-
config: GraphConfig;
|
|
796
|
-
/** The handler map (for use with validateReactiveGraph). */
|
|
797
|
-
handlers: Record<string, TaskHandlerFn>;
|
|
798
|
-
/** Card lookup by ID (original references). */
|
|
799
|
-
cards: Map<string, LiveCard>;
|
|
800
|
-
/**
|
|
801
|
-
* Shared state map: cardId → latest computed state.
|
|
802
|
-
* Updated automatically by built-in handlers after each task completes.
|
|
803
|
-
* Custom cardHandlers/sourceHandlers can also read upstream data directly
|
|
804
|
-
* from the engine: graph.getState().state.tasks[cardId].data
|
|
805
|
-
*/
|
|
806
|
-
sharedState: Map<string, Record<string, unknown>>;
|
|
807
|
-
}
|
|
808
|
-
/**
|
|
809
|
-
* Convert live card JSONs or a Board into a fully wired ReactiveGraph.
|
|
810
|
-
*
|
|
811
|
-
* Overloads:
|
|
812
|
-
* liveCardsToReactiveGraph(cards[], options?) — from a flat array of cards
|
|
813
|
-
* liveCardsToReactiveGraph(board, options?) — from a LiveBoard object
|
|
814
|
-
*/
|
|
815
|
-
declare function liveCardsToReactiveGraph(input: LiveCard[] | LiveBoard, options?: LiveCardsToReactiveOptions): LiveCardsToReactiveResult;
|
|
816
|
-
|
|
817
|
-
export { DownstreamResult, FileJournal, GraphConfig, GraphEngineStore, GraphEvent, type GraphMutation, type Journal, type LiveBoard, type LiveCard, type LiveCardsToReactiveOptions, type LiveCardsToReactiveResult, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, MemoryJournal, NodeInfo, type ReactiveGraph, type ReactiveGraphOptions, type ReactiveGraphValidationInput, type ResolveCallbackFn, ScheduleResult, type ScriptHandlerOptions, type ShellHandlerOptions, TaskConfig, type TaskHandlerFn, type TaskHandlerInput, type TaskHandlerReturn, UnreachableNodesResult, UnreachableTokensResult, UpstreamResult, type WebhookHandlerOptions, addNode, addProvides, addRequires, applyEvent, applyEvents, computeDataHash, createCallbackHandler, createFireAndForgetHandler, createLiveGraph, createNoopHandler, createReactiveGraph, createScriptHandler, createShellHandler, createWebhookHandler, disableNode, drainTokens, enableNode, getDownstream, getNode, getUnreachableNodes, getUnreachableTokens, getUpstream, injectTokens, inspect, liveCardsToReactiveGraph, mutateGraph, removeNode, removeProvides, removeRequires, resetNode, restore, schedule, snapshot, validateLiveGraph, validateReactiveGraph };
|
|
477
|
+
export { DownstreamResult, GraphConfig, GraphEvent, type GraphMutation, LiveGraph, LiveGraphHealth, LiveGraphSnapshot, NodeInfo, ReactiveGraph, type ReactiveGraphValidationInput, type ResolveCallbackFn, type ScriptHandlerOptions, type ShellHandlerOptions, TaskConfig, TaskHandlerFn, TaskHandlerInput, UnreachableNodesResult, UnreachableTokensResult, UpstreamResult, type WebhookHandlerOptions, addNode, addProvides, addRequires, applyEvent, applyEvents, createCallbackHandler, createFireAndForgetHandler, createLiveGraph, createNoopHandler, createScriptHandler, createShellHandler, createWebhookHandler, disableNode, drainTokens, enableNode, getDownstream, getNode, getUnreachableNodes, getUnreachableTokens, getUpstream, injectTokens, inspect, mutateGraph, removeNode, removeProvides, removeRequires, resetNode, restore, snapshot, validateLiveGraph, validateReactiveGraph };
|