yaml-flow 5.4.0 → 6.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.
Files changed (200) hide show
  1. package/board-live-cards-cli.js +2 -2
  2. package/board-livecards-server-runtime.js +488 -551
  3. package/browser/asset-integrity.json +10 -0
  4. package/browser/board-livecards-runtime-client.js +0 -6
  5. package/browser/board-livegraph-engine.js +2 -1676
  6. package/browser/board-livegraph-engine.js.map +1 -1
  7. package/browser/live-cards.js +347 -26
  8. package/browser/live-cards.schema.json +418 -132
  9. package/card-store.js +37 -0
  10. package/dist/batch/index.cjs +1 -108
  11. package/dist/batch/index.cjs.map +1 -1
  12. package/dist/batch/index.js +1 -106
  13. package/dist/batch/index.js.map +1 -1
  14. package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
  15. package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
  16. package/dist/board-live-cards-public-CltXYgaY.d.cts +314 -0
  17. package/dist/board-live-cards-public-f-E-FAyp.d.ts +314 -0
  18. package/dist/board-livegraph-runtime/index.cjs +2 -1671
  19. package/dist/board-livegraph-runtime/index.cjs.map +1 -1
  20. package/dist/board-livegraph-runtime/index.d.cts +1 -2
  21. package/dist/board-livegraph-runtime/index.d.ts +1 -2
  22. package/dist/board-livegraph-runtime/index.js +2 -1662
  23. package/dist/board-livegraph-runtime/index.js.map +1 -1
  24. package/dist/board-livegraph-runtime/jsonata-sync.cjs +7587 -0
  25. package/dist/card-compute/index.cjs +9 -7159
  26. package/dist/card-compute/index.cjs.map +1 -1
  27. package/dist/card-compute/index.d.cts +22 -0
  28. package/dist/card-compute/index.d.ts +22 -0
  29. package/dist/card-compute/index.js +9 -7145
  30. package/dist/card-compute/index.js.map +1 -1
  31. package/dist/card-compute/jsonata-sync.cjs +7587 -0
  32. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +2 -0
  33. package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
  34. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +24 -0
  35. package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +24 -0
  36. package/dist/cli/browser-api/board-live-cards-browser-adapter.js +2 -0
  37. package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
  38. package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
  39. package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
  40. package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
  41. package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
  42. package/dist/cli/browser-api/card-store-browser-api.js +2 -0
  43. package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
  44. package/dist/cli/browser-api/jsonata-sync.cjs +7587 -0
  45. package/dist/cli/node/artifacts-store-cli.cjs +11 -0
  46. package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
  47. package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
  48. package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
  49. package/dist/cli/node/artifacts-store-cli.js +11 -0
  50. package/dist/cli/node/artifacts-store-cli.js.map +1 -0
  51. package/dist/cli/node/board-live-cards-cli.cjs +15 -0
  52. package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
  53. package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
  54. package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
  55. package/dist/cli/node/board-live-cards-cli.js +15 -0
  56. package/dist/cli/node/board-live-cards-cli.js.map +1 -0
  57. package/dist/cli/node/card-store-cli.cjs +8 -0
  58. package/dist/cli/node/card-store-cli.cjs.map +1 -0
  59. package/dist/cli/node/card-store-cli.d.cts +15 -0
  60. package/dist/cli/node/card-store-cli.d.ts +15 -0
  61. package/dist/cli/node/card-store-cli.js +8 -0
  62. package/dist/cli/node/card-store-cli.js.map +1 -0
  63. package/dist/cli/node/fs-board-adapter.cjs +14 -0
  64. package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
  65. package/dist/cli/node/fs-board-adapter.d.cts +204 -0
  66. package/dist/cli/node/fs-board-adapter.d.ts +204 -0
  67. package/dist/cli/node/fs-board-adapter.js +14 -0
  68. package/dist/cli/node/fs-board-adapter.js.map +1 -0
  69. package/dist/cli/node/jsonata-sync.cjs +7587 -0
  70. package/dist/cli/node/source-cli-task-executor.cjs +11 -0
  71. package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
  72. package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
  73. package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
  74. package/dist/cli/node/source-cli-task-executor.js +11 -0
  75. package/dist/cli/node/source-cli-task-executor.js.map +1 -0
  76. package/dist/config/index.cjs +1 -79
  77. package/dist/config/index.cjs.map +1 -1
  78. package/dist/config/index.js +1 -76
  79. package/dist/config/index.js.map +1 -1
  80. package/dist/continuous-event-graph/index.cjs +2 -2129
  81. package/dist/continuous-event-graph/index.cjs.map +1 -1
  82. package/dist/continuous-event-graph/index.d.cts +81 -5
  83. package/dist/continuous-event-graph/index.d.ts +81 -5
  84. package/dist/continuous-event-graph/index.js +2 -2088
  85. package/dist/continuous-event-graph/index.js.map +1 -1
  86. package/dist/continuous-event-graph/jsonata-sync.cjs +7587 -0
  87. package/dist/event-graph/index.cjs +22 -8292
  88. package/dist/event-graph/index.cjs.map +1 -1
  89. package/dist/event-graph/index.js +22 -8237
  90. package/dist/event-graph/index.js.map +1 -1
  91. package/dist/execution-refs.cjs +2 -0
  92. package/dist/execution-refs.cjs.map +1 -0
  93. package/dist/execution-refs.d.cts +222 -0
  94. package/dist/execution-refs.d.ts +222 -0
  95. package/dist/execution-refs.js +2 -0
  96. package/dist/execution-refs.js.map +1 -0
  97. package/dist/index.cjs +29 -13221
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +2 -4
  100. package/dist/index.d.ts +2 -4
  101. package/dist/index.js +29 -13112
  102. package/dist/index.js.map +1 -1
  103. package/dist/inference/index.cjs +5 -617
  104. package/dist/inference/index.cjs.map +1 -1
  105. package/dist/inference/index.js +5 -610
  106. package/dist/inference/index.js.map +1 -1
  107. package/dist/jsonata-sync.cjs +7587 -0
  108. package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
  109. package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
  110. package/dist/pycli/quickjs-board-runtime.global.js +9 -0
  111. package/dist/pycli/quickjs-board-runtime.global.js.map +1 -0
  112. package/dist/pycli/quickjs-step-machine-runtime.global.js +5 -0
  113. package/dist/pycli/quickjs-step-machine-runtime.global.js.map +1 -0
  114. package/dist/step-machine/index.cjs +11 -7129
  115. package/dist/step-machine/index.cjs.map +1 -1
  116. package/dist/step-machine/index.js +11 -7113
  117. package/dist/step-machine/index.js.map +1 -1
  118. package/dist/storage-refs.cjs +10 -0
  119. package/dist/storage-refs.cjs.map +1 -0
  120. package/dist/storage-refs.d.cts +92 -0
  121. package/dist/storage-refs.d.ts +92 -0
  122. package/dist/storage-refs.js +10 -0
  123. package/dist/storage-refs.js.map +1 -0
  124. package/dist/stores/file.cjs +1 -114
  125. package/dist/stores/file.cjs.map +1 -1
  126. package/dist/stores/file.js +1 -112
  127. package/dist/stores/file.js.map +1 -1
  128. package/dist/stores/index.cjs +1 -231
  129. package/dist/stores/index.cjs.map +1 -1
  130. package/dist/stores/index.js +1 -227
  131. package/dist/stores/index.js.map +1 -1
  132. package/dist/stores/localStorage.cjs +1 -76
  133. package/dist/stores/localStorage.cjs.map +1 -1
  134. package/dist/stores/localStorage.js +1 -74
  135. package/dist/stores/localStorage.js.map +1 -1
  136. package/dist/stores/memory.cjs +1 -47
  137. package/dist/stores/memory.cjs.map +1 -1
  138. package/dist/stores/memory.js +1 -45
  139. package/dist/stores/memory.js.map +1 -1
  140. package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +292 -0
  141. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
  142. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
  143. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
  144. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +553 -0
  145. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +365 -0
  146. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
  147. package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
  148. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +53 -1
  149. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +15 -6
  150. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +6 -1
  151. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +57 -0
  152. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +1 -1
  153. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +1 -1
  154. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +7 -2
  155. package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +6 -2
  156. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +97 -0
  157. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +50 -0
  158. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +44 -0
  159. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +70 -0
  160. package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
  161. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
  162. package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
  163. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
  164. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +25 -172
  165. package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
  166. package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +46 -0
  167. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
  168. package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  169. package/examples/example-board/agent-instructions.md +11 -5
  170. package/examples/example-board/demo-chat-handler.js +14 -4
  171. package/examples/example-board/demo-server-config.json +1 -0
  172. package/examples/example-board/demo-server.js +19 -34
  173. package/examples/example-board/demo-shell-browser.html +5 -4
  174. package/examples/example-board/demo-shell-with-server.html +10 -6
  175. package/examples/example-board/demo-task-executor.js +81 -35
  176. package/examples/index.html +0 -14
  177. package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
  178. package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
  179. package/package.json +39 -3
  180. package/schema/live-cards.schema.json +418 -132
  181. package/dist/cli/board-live-cards-cli.cjs +0 -10644
  182. package/dist/cli/board-live-cards-cli.cjs.map +0 -1
  183. package/dist/cli/board-live-cards-cli.d.cts +0 -179
  184. package/dist/cli/board-live-cards-cli.d.ts +0 -179
  185. package/dist/cli/board-live-cards-cli.js +0 -10592
  186. package/dist/cli/board-live-cards-cli.js.map +0 -1
  187. package/dist/journal-9HEgs7dU.d.ts +0 -28
  188. package/dist/journal-B-JCfQnh.d.cts +0 -28
  189. package/dist/schedule-Cszq9LYY.d.ts +0 -21
  190. package/dist/schedule-qWNL0RQh.d.cts +0 -21
  191. package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
  192. package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
  193. package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
  194. package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
  195. package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
  196. package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
  197. package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
  198. package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
  199. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
  200. package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
@@ -1,179 +0,0 @@
1
- import { b as LiveGraphSnapshot, L as LiveGraph } from '../types-CHSdoAAA.cjs';
2
- import { a as LiveCard, R as ReactiveGraph } from '../live-cards-bridge-x5XREkXm.cjs';
3
- import { f as GraphEvent, T as TaskConfig } from '../types-BBhqYGhE.cjs';
4
- import { J as Journal } from '../journal-B-JCfQnh.cjs';
5
-
6
- /**
7
- * board-live-cards-lib — Adapter interfaces and shared domain types.
8
- *
9
- * This file contains only pure TypeScript — no Node built-ins.
10
- * It is safe to include in a neutral/browser/V8 (PyMiniRacer) bundle.
11
- *
12
- * Invariants enforced here:
13
- * - RuntimeInternalStore is never returned raw from public APIs.
14
- * - OutputStore writes are idempotent and schema-versioned.
15
- * - InputStore mutations are explicit operations, never side effects.
16
- * - Locking is acquired at the lib service boundary, not inside adapters.
17
- * - ControlStore writes only during init/administrative flows.
18
- * - InvocationAdapter results are structured, not raw shell-centric.
19
- */
20
-
21
- interface SourceRuntimeEntry {
22
- lastRequestedAt?: string;
23
- lastFetchedAt?: string;
24
- lastError?: string;
25
- /** Timestamp of the most recent card-handler dispatch for this execution run. */
26
- queueRequestedAt?: string;
27
- }
28
- interface InferenceRuntimeEntry {
29
- lastRequestedAt?: string;
30
- lastFetchedAt?: string;
31
- lastError?: string;
32
- /** Same semantics as SourceRuntimeEntry.queueRequestedAt. */
33
- queueRequestedAt?: string;
34
- }
35
- type FetchRuntimeEntry = SourceRuntimeEntry | InferenceRuntimeEntry;
36
- interface SourceTokenPayload {
37
- /** Original callback token from the reactive graph (encodes taskName) */
38
- cbk: string;
39
- /** Board directory (absolute path) */
40
- rg: string;
41
- /** Card id */
42
- cid: string;
43
- /** source_defs[].bindTo */
44
- b: string;
45
- /** source_defs[].outputFile (relative to boardDir) */
46
- d: string;
47
- /** Per-source invocation checksum */
48
- cs?: string;
49
- }
50
- declare function isSourceInFlight(entry: FetchRuntimeEntry | undefined): boolean;
51
- /**
52
- * Decide what to do with a source/inference fetch given the current runtime entry
53
- * and the timestamp of the latest card-handler dispatch (queueRequestedAt).
54
- *
55
- * - 'dispatch' : fetch not yet started for this run, or previous fetch predates the request
56
- * - 'in-flight' : fetch is already running for this run — update queueRequestedAt and wait
57
- * - 'idle' : fetch already completed for this run — nothing to do
58
- */
59
- declare function decideSourceAction(entry: FetchRuntimeEntry | undefined, queueRequestedAt: string): 'dispatch' | 'in-flight' | 'idle';
60
- declare function nextEntryAfterFetchDelivery<T extends FetchRuntimeEntry>(entry: T, fetchedAt: string): T;
61
- declare function nextEntryAfterFetchFailure<T extends FetchRuntimeEntry>(entry: T, reason: string): T;
62
-
63
- /**
64
- * Board Live Cards — Disk persistence + CLI for ReactiveGraph.
65
- */
66
-
67
- /** Envelope stored in board-graph.json — wraps the LiveGraph snapshot with journal pointer. */
68
- interface BoardEnvelope {
69
- lastDrainedJournalId: string;
70
- graph: LiveGraphSnapshot;
71
- }
72
- interface JournalEntry {
73
- id: string;
74
- event: GraphEvent;
75
- }
76
- declare class BoardJournal implements Journal {
77
- private readonly journalPath;
78
- private lastDrainedId;
79
- constructor(journalPath: string, lastDrainedJournalId: string);
80
- append(event: GraphEvent): void;
81
- drain(): GraphEvent[];
82
- get size(): number;
83
- get lastDrainedJournalId(): string;
84
- }
85
- interface CardInventoryEntry {
86
- cardId: string;
87
- cardFilePath: string;
88
- addedAt: string;
89
- }
90
- interface CardInventoryIndex {
91
- byCardId: Map<string, CardInventoryEntry>;
92
- byCardPath: Map<string, CardInventoryEntry>;
93
- }
94
- declare function readCardInventory(boardDir: string): CardInventoryEntry[];
95
- declare function lookupCardPath(boardDir: string, cardId: string): string | null;
96
- declare function appendCardInventory(boardDir: string, entry: CardInventoryEntry): void;
97
- declare function buildCardInventoryIndex(boardDir: string): CardInventoryIndex;
98
- /**
99
- * Initialize a board directory.
100
- * - Dir doesn't exist → create it, write empty board-graph.json
101
- * - Dir exists + valid board-graph.json → no-op, return 'exists'
102
- * - Dir exists + non-empty (no valid board-graph.json) → throw
103
- */
104
- declare function initBoard(dir: string): 'created' | 'exists';
105
- declare function loadBoardEnvelope(dir: string): BoardEnvelope;
106
- declare function loadBoard(dir: string): LiveGraph;
107
- declare function saveBoard(dir: string, rg: ReactiveGraph, journal: BoardJournal): void;
108
- /**
109
- * Acquire an exclusive lock on the board, run `fn`, then release.
110
- * Uses proper-lockfile on board-graph.json.
111
- */
112
- declare function withBoardLock<T>(boardDir: string, fn: () => T): T;
113
-
114
- declare function encodeSourceToken(payload: SourceTokenPayload): string;
115
- declare function decodeSourceToken(token: string): SourceTokenPayload | null;
116
- /**
117
- * Append a raw event to the journal file. No lock, no file read.
118
- * Safe for hundreds of concurrent callers (appendFileSync is atomic for small writes).
119
- */
120
- declare function appendEventToJournal(boardDir: string, event: GraphEvent): void;
121
- /**
122
- * Read journal entries after the given ID. Pure file read, no mutation.
123
- */
124
- declare function getUndrainedEntries(boardDir: string, lastDrainedId: string): JournalEntry[];
125
- /**
126
- * Run one lock-guarded processing pass for this board.
127
- *
128
- * GUARANTEE (single-pass only):
129
- * - At most one process performs this pass at a time (board lock).
130
- * - If lock is acquired, exactly one drain/apply/save cycle is executed.
131
- * - If lock is busy, returns false immediately (no waiting).
132
- *
133
- * This function does NOT guarantee full settlement; it only advances the baton
134
- * by one cycle in the relay model.
135
- */
136
- declare function processAccumulatedEvents(boardDir: string): Promise<boolean>;
137
- /**
138
- * Schedule continued draining until the board eventually settles.
139
- *
140
- * GUARANTEE (system-level eventual progress):
141
- * - Default behavior launches a detached background worker process that runs
142
- * `process-accumulated-events --inline-loop`.
143
- * - Returns quickly to caller; does not synchronously wait for settlement.
144
- * - Under relay assumptions, pending entries eventually drain to zero:
145
- * 1) at least one runner continues, 2) no crash/forced exit in relay window,
146
- * 3) lock remains healthy, 4) new events do not arrive forever.
147
- *
148
- * INTERNAL MODE:
149
- * - `inlineLoop: true` executes the while(pending) loop in the current process.
150
- * - Used by the worker command to avoid recursive worker spawning.
151
- */
152
- declare function processAccumulatedEventsInfinitePass(boardDir: string, settleDelayMs?: number, options?: {
153
- inlineLoop?: boolean;
154
- }): Promise<boolean>;
155
- /**
156
- * Forced drain entrypoint: first run one immediate pass, then delegate to
157
- * infinite-pass continuation.
158
- *
159
- * GUARANTEE:
160
- * - In default mode, this guarantees immediate forward progress (single pass)
161
- * and guaranteed scheduling of eventual continuation (background worker).
162
- * - In `inlineLoop` mode, this runs full in-process settle loop and returns
163
- * only after pending reaches zero (or lock contention aborts loop).
164
- */
165
- declare function processAccumulatedEventsForced(boardDir: string, options?: {
166
- inlineLoop?: boolean;
167
- }): Promise<void>;
168
- type BoardLiveCard = LiveCard;
169
- /**
170
- * Transform a LiveCard into a TaskConfig for the reactive graph.
171
- *
172
- * Every card gets handler: 'card-handler'.
173
- * The handler inspects the card and decides what to do:
174
- * run compute, invoke source_defs.
175
- */
176
- declare function liveCardToTaskConfig(card: BoardLiveCard): TaskConfig;
177
- declare function cli(argv: string[]): Promise<void>;
178
-
179
- export { type BoardEnvelope, BoardJournal, type BoardLiveCard, type CardInventoryEntry, type CardInventoryIndex, type FetchRuntimeEntry, type InferenceRuntimeEntry, type JournalEntry, type SourceRuntimeEntry, type SourceTokenPayload, appendCardInventory, appendEventToJournal, buildCardInventoryIndex, cli, decideSourceAction, decodeSourceToken, encodeSourceToken, getUndrainedEntries, initBoard, isSourceInFlight, liveCardToTaskConfig, loadBoard, loadBoardEnvelope, lookupCardPath, nextEntryAfterFetchDelivery, nextEntryAfterFetchFailure, processAccumulatedEvents, processAccumulatedEventsForced, processAccumulatedEventsInfinitePass, readCardInventory, saveBoard, withBoardLock };
@@ -1,179 +0,0 @@
1
- import { b as LiveGraphSnapshot, L as LiveGraph } from '../types-CoW0gQl3.js';
2
- import { a as LiveCard, R as ReactiveGraph } from '../live-cards-bridge-EQjytzI_.js';
3
- import { f as GraphEvent, T as TaskConfig } from '../types-BBhqYGhE.js';
4
- import { J as Journal } from '../journal-9HEgs7dU.js';
5
-
6
- /**
7
- * board-live-cards-lib — Adapter interfaces and shared domain types.
8
- *
9
- * This file contains only pure TypeScript — no Node built-ins.
10
- * It is safe to include in a neutral/browser/V8 (PyMiniRacer) bundle.
11
- *
12
- * Invariants enforced here:
13
- * - RuntimeInternalStore is never returned raw from public APIs.
14
- * - OutputStore writes are idempotent and schema-versioned.
15
- * - InputStore mutations are explicit operations, never side effects.
16
- * - Locking is acquired at the lib service boundary, not inside adapters.
17
- * - ControlStore writes only during init/administrative flows.
18
- * - InvocationAdapter results are structured, not raw shell-centric.
19
- */
20
-
21
- interface SourceRuntimeEntry {
22
- lastRequestedAt?: string;
23
- lastFetchedAt?: string;
24
- lastError?: string;
25
- /** Timestamp of the most recent card-handler dispatch for this execution run. */
26
- queueRequestedAt?: string;
27
- }
28
- interface InferenceRuntimeEntry {
29
- lastRequestedAt?: string;
30
- lastFetchedAt?: string;
31
- lastError?: string;
32
- /** Same semantics as SourceRuntimeEntry.queueRequestedAt. */
33
- queueRequestedAt?: string;
34
- }
35
- type FetchRuntimeEntry = SourceRuntimeEntry | InferenceRuntimeEntry;
36
- interface SourceTokenPayload {
37
- /** Original callback token from the reactive graph (encodes taskName) */
38
- cbk: string;
39
- /** Board directory (absolute path) */
40
- rg: string;
41
- /** Card id */
42
- cid: string;
43
- /** source_defs[].bindTo */
44
- b: string;
45
- /** source_defs[].outputFile (relative to boardDir) */
46
- d: string;
47
- /** Per-source invocation checksum */
48
- cs?: string;
49
- }
50
- declare function isSourceInFlight(entry: FetchRuntimeEntry | undefined): boolean;
51
- /**
52
- * Decide what to do with a source/inference fetch given the current runtime entry
53
- * and the timestamp of the latest card-handler dispatch (queueRequestedAt).
54
- *
55
- * - 'dispatch' : fetch not yet started for this run, or previous fetch predates the request
56
- * - 'in-flight' : fetch is already running for this run — update queueRequestedAt and wait
57
- * - 'idle' : fetch already completed for this run — nothing to do
58
- */
59
- declare function decideSourceAction(entry: FetchRuntimeEntry | undefined, queueRequestedAt: string): 'dispatch' | 'in-flight' | 'idle';
60
- declare function nextEntryAfterFetchDelivery<T extends FetchRuntimeEntry>(entry: T, fetchedAt: string): T;
61
- declare function nextEntryAfterFetchFailure<T extends FetchRuntimeEntry>(entry: T, reason: string): T;
62
-
63
- /**
64
- * Board Live Cards — Disk persistence + CLI for ReactiveGraph.
65
- */
66
-
67
- /** Envelope stored in board-graph.json — wraps the LiveGraph snapshot with journal pointer. */
68
- interface BoardEnvelope {
69
- lastDrainedJournalId: string;
70
- graph: LiveGraphSnapshot;
71
- }
72
- interface JournalEntry {
73
- id: string;
74
- event: GraphEvent;
75
- }
76
- declare class BoardJournal implements Journal {
77
- private readonly journalPath;
78
- private lastDrainedId;
79
- constructor(journalPath: string, lastDrainedJournalId: string);
80
- append(event: GraphEvent): void;
81
- drain(): GraphEvent[];
82
- get size(): number;
83
- get lastDrainedJournalId(): string;
84
- }
85
- interface CardInventoryEntry {
86
- cardId: string;
87
- cardFilePath: string;
88
- addedAt: string;
89
- }
90
- interface CardInventoryIndex {
91
- byCardId: Map<string, CardInventoryEntry>;
92
- byCardPath: Map<string, CardInventoryEntry>;
93
- }
94
- declare function readCardInventory(boardDir: string): CardInventoryEntry[];
95
- declare function lookupCardPath(boardDir: string, cardId: string): string | null;
96
- declare function appendCardInventory(boardDir: string, entry: CardInventoryEntry): void;
97
- declare function buildCardInventoryIndex(boardDir: string): CardInventoryIndex;
98
- /**
99
- * Initialize a board directory.
100
- * - Dir doesn't exist → create it, write empty board-graph.json
101
- * - Dir exists + valid board-graph.json → no-op, return 'exists'
102
- * - Dir exists + non-empty (no valid board-graph.json) → throw
103
- */
104
- declare function initBoard(dir: string): 'created' | 'exists';
105
- declare function loadBoardEnvelope(dir: string): BoardEnvelope;
106
- declare function loadBoard(dir: string): LiveGraph;
107
- declare function saveBoard(dir: string, rg: ReactiveGraph, journal: BoardJournal): void;
108
- /**
109
- * Acquire an exclusive lock on the board, run `fn`, then release.
110
- * Uses proper-lockfile on board-graph.json.
111
- */
112
- declare function withBoardLock<T>(boardDir: string, fn: () => T): T;
113
-
114
- declare function encodeSourceToken(payload: SourceTokenPayload): string;
115
- declare function decodeSourceToken(token: string): SourceTokenPayload | null;
116
- /**
117
- * Append a raw event to the journal file. No lock, no file read.
118
- * Safe for hundreds of concurrent callers (appendFileSync is atomic for small writes).
119
- */
120
- declare function appendEventToJournal(boardDir: string, event: GraphEvent): void;
121
- /**
122
- * Read journal entries after the given ID. Pure file read, no mutation.
123
- */
124
- declare function getUndrainedEntries(boardDir: string, lastDrainedId: string): JournalEntry[];
125
- /**
126
- * Run one lock-guarded processing pass for this board.
127
- *
128
- * GUARANTEE (single-pass only):
129
- * - At most one process performs this pass at a time (board lock).
130
- * - If lock is acquired, exactly one drain/apply/save cycle is executed.
131
- * - If lock is busy, returns false immediately (no waiting).
132
- *
133
- * This function does NOT guarantee full settlement; it only advances the baton
134
- * by one cycle in the relay model.
135
- */
136
- declare function processAccumulatedEvents(boardDir: string): Promise<boolean>;
137
- /**
138
- * Schedule continued draining until the board eventually settles.
139
- *
140
- * GUARANTEE (system-level eventual progress):
141
- * - Default behavior launches a detached background worker process that runs
142
- * `process-accumulated-events --inline-loop`.
143
- * - Returns quickly to caller; does not synchronously wait for settlement.
144
- * - Under relay assumptions, pending entries eventually drain to zero:
145
- * 1) at least one runner continues, 2) no crash/forced exit in relay window,
146
- * 3) lock remains healthy, 4) new events do not arrive forever.
147
- *
148
- * INTERNAL MODE:
149
- * - `inlineLoop: true` executes the while(pending) loop in the current process.
150
- * - Used by the worker command to avoid recursive worker spawning.
151
- */
152
- declare function processAccumulatedEventsInfinitePass(boardDir: string, settleDelayMs?: number, options?: {
153
- inlineLoop?: boolean;
154
- }): Promise<boolean>;
155
- /**
156
- * Forced drain entrypoint: first run one immediate pass, then delegate to
157
- * infinite-pass continuation.
158
- *
159
- * GUARANTEE:
160
- * - In default mode, this guarantees immediate forward progress (single pass)
161
- * and guaranteed scheduling of eventual continuation (background worker).
162
- * - In `inlineLoop` mode, this runs full in-process settle loop and returns
163
- * only after pending reaches zero (or lock contention aborts loop).
164
- */
165
- declare function processAccumulatedEventsForced(boardDir: string, options?: {
166
- inlineLoop?: boolean;
167
- }): Promise<void>;
168
- type BoardLiveCard = LiveCard;
169
- /**
170
- * Transform a LiveCard into a TaskConfig for the reactive graph.
171
- *
172
- * Every card gets handler: 'card-handler'.
173
- * The handler inspects the card and decides what to do:
174
- * run compute, invoke source_defs.
175
- */
176
- declare function liveCardToTaskConfig(card: BoardLiveCard): TaskConfig;
177
- declare function cli(argv: string[]): Promise<void>;
178
-
179
- export { type BoardEnvelope, BoardJournal, type BoardLiveCard, type CardInventoryEntry, type CardInventoryIndex, type FetchRuntimeEntry, type InferenceRuntimeEntry, type JournalEntry, type SourceRuntimeEntry, type SourceTokenPayload, appendCardInventory, appendEventToJournal, buildCardInventoryIndex, cli, decideSourceAction, decodeSourceToken, encodeSourceToken, getUndrainedEntries, initBoard, isSourceInFlight, liveCardToTaskConfig, loadBoard, loadBoardEnvelope, lookupCardPath, nextEntryAfterFetchDelivery, nextEntryAfterFetchFailure, processAccumulatedEvents, processAccumulatedEventsForced, processAccumulatedEventsInfinitePass, readCardInventory, saveBoard, withBoardLock };