yaml-flow 8.7.0 → 8.8.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/browser/adapters/firebase-storage.js +2 -2
- package/browser/adapters/firestore-storage.js +2 -2
- package/browser/adapters/localstorage-storage.js +3 -3
- package/browser/asset-integrity.json +11 -15
- package/browser/live-cards.schema.json +10 -1
- package/browser/server-runtime-controlface.js +5 -5
- package/examples/ARCHITECTURE.md +0 -27
- package/examples/board/server/board-server.js +151 -101
- package/examples/board/server/board-worker/source_def_flows.json +0 -8
- package/examples/board/server/board-worker/task-executor.js +1 -3
- package/examples/board/test/server-http-test.js +181 -152
- package/examples/board-firestore/server/worker.js +9 -1
- package/examples/portfolio-tracker/portfolio-tracker.js +11 -1
- package/examples/portfolio-tracker/test/portfolio-t4.js +12 -2
- package/lib/{artifacts-store-lib-D9nMkVcE.d.cts → artifacts-store-lib-C6qBpMfU.d.cts} +1 -1
- package/lib/{artifacts-store-lib-DSSMqVL2.d.ts → artifacts-store-lib-D4qf7Q-7.d.ts} +1 -1
- package/lib/artifacts-store-public.d.cts +3 -3
- package/lib/artifacts-store-public.d.ts +3 -3
- package/lib/board-live-cards-mcp.cjs +1 -1
- package/lib/board-live-cards-mcp.d.cts +7 -7
- package/lib/board-live-cards-mcp.d.ts +7 -7
- package/lib/board-live-cards-mcp.js +1 -1
- package/lib/board-live-cards-node.cjs +8 -8
- package/lib/board-live-cards-node.d.cts +16 -14
- package/lib/board-live-cards-node.d.ts +16 -14
- package/lib/board-live-cards-node.js +8 -8
- package/lib/{board-live-cards-public-DQzPe7A9.d.cts → board-live-cards-public-BT5HrgqZ.d.cts} +82 -59
- package/lib/{board-live-cards-public-D-DJek3X.d.ts → board-live-cards-public-DSRamFm8.d.ts} +82 -59
- package/lib/{board-live-cards-public-async-CgMCYYft.d.cts → board-live-cards-public-async-CYjr4mgX.d.cts} +18 -8
- package/lib/{board-live-cards-public-async-3hUuHxDx.d.ts → board-live-cards-public-async-DlyC3PgC.d.ts} +18 -8
- package/lib/board-live-cards-public.cjs +1 -1
- package/lib/board-live-cards-public.d.cts +2 -2
- package/lib/board-live-cards-public.d.ts +2 -2
- package/lib/board-live-cards-public.js +1 -1
- package/lib/board-live-cards-server-runtime.cjs +1 -1
- package/lib/board-live-cards-server-runtime.d.cts +6 -8
- package/lib/board-live-cards-server-runtime.d.ts +6 -8
- package/lib/board-live-cards-server-runtime.js +1 -1
- package/lib/board-livegraph-runtime/index.cjs +1 -1
- package/lib/board-livegraph-runtime/index.js +1 -1
- package/lib/{board-platform-adapter-async-DOfEq_HC.d.cts → board-platform-adapter-async-BZIftm36.d.cts} +18 -14
- package/lib/{board-platform-adapter-async-JZPCzZnH.d.ts → board-platform-adapter-async-JP9V-U5E.d.ts} +18 -14
- package/lib/board-worker-adapter.cjs +1 -24
- package/lib/board-worker-adapter.d.cts +68 -3
- package/lib/board-worker-adapter.d.ts +68 -3
- package/lib/board-worker-adapter.js +1 -24
- package/lib/card-compute/index.cjs +1 -1
- package/lib/card-compute/index.js +1 -1
- package/lib/card-store-public.d.cts +2 -2
- package/lib/card-store-public.d.ts +2 -2
- package/lib/card-validation.cjs +1 -1
- package/lib/card-validation.js +1 -1
- package/lib/chat-store-public.cjs +1 -1
- package/lib/chat-store-public.d.cts +20 -20
- package/lib/chat-store-public.d.ts +20 -20
- package/lib/chat-store-public.js +1 -1
- package/lib/chunk-2GSI6C45.js +7 -0
- package/lib/chunk-35N7ONTH.js +2 -0
- package/lib/chunk-37HDEW26.cjs +2 -0
- package/lib/{chunk-PMUSJQSR.cjs → chunk-3CZCGNY4.cjs} +2 -2
- package/lib/chunk-3KC6LBOG.js +3 -0
- package/lib/{chunk-BQS3EIEK.js → chunk-44L64VQ2.js} +3 -3
- package/lib/chunk-6OPXQPSC.js +2 -0
- package/lib/chunk-7BTZCOT5.js +2 -0
- package/lib/{chunk-U2N6MCD5.cjs → chunk-7JVHYHT2.cjs} +2 -2
- package/lib/chunk-7QZ267XP.cjs +2 -0
- package/lib/{chunk-XQRNDX4Q.js → chunk-ANKA7HEJ.js} +2 -2
- package/lib/{chunk-KAWQPLIE.cjs → chunk-BQUQTOPB.cjs} +2 -2
- package/lib/chunk-CMFD27ZC.cjs +3 -0
- package/lib/chunk-DOFNXJ4C.js +3 -0
- package/lib/chunk-ETW3BXHD.cjs +2 -0
- package/lib/chunk-FO4KNVU7.cjs +2 -0
- package/lib/{chunk-SGV7PU4H.js → chunk-FOFGEABN.js} +2 -2
- package/lib/chunk-GPCMBPLK.cjs +2 -0
- package/lib/chunk-GU3T75C4.js +3 -0
- package/lib/chunk-H3EHFCDZ.js +3 -0
- package/lib/chunk-H4TYOSMD.cjs +45 -0
- package/lib/chunk-HFW7E2Z7.cjs +4 -0
- package/lib/chunk-HWYMZK3N.cjs +3 -0
- package/lib/chunk-IQIZA7TN.cjs +7 -0
- package/lib/chunk-J4MHQ7JF.js +45 -0
- package/lib/chunk-MCPADH33.cjs +2 -0
- package/lib/chunk-NBJTYAYN.cjs +2 -0
- package/lib/chunk-NDAKMJQK.cjs +3 -0
- package/lib/chunk-NNSBBO5R.js +2 -0
- package/lib/chunk-NU5NO5NM.js +2 -0
- package/lib/chunk-O4RKTQBP.cjs +3 -0
- package/lib/chunk-O5UYCGIN.js +2 -0
- package/lib/chunk-Q3OTUDIE.js +2 -0
- package/lib/chunk-R44X3RQB.cjs +2 -0
- package/lib/chunk-RKKSVOP2.js +2 -0
- package/lib/chunk-UB54HZA4.cjs +2 -0
- package/lib/{chunk-CIAJNUR4.js → chunk-VGDLSS2H.js} +2 -2
- package/lib/{chunk-SFVO2LB2.cjs → chunk-VQCIOKJV.cjs} +3 -3
- package/lib/chunk-VS3BXEYK.js +4 -0
- package/lib/chunk-Y4WK7HE4.js +2 -0
- package/lib/chunk-YBYXCFAI.js +2 -0
- package/lib/chunk-ZK3E7L4Y.cjs +2 -0
- package/lib/cloud-storage.cjs +1 -1
- package/lib/cloud-storage.d.cts +6 -6
- package/lib/cloud-storage.d.ts +6 -6
- package/lib/cloud-storage.js +1 -1
- package/lib/continuous-event-graph/index.cjs +1 -1
- package/lib/continuous-event-graph/index.js +1 -1
- package/lib/execution-refs.cjs +1 -1
- package/lib/execution-refs.js +1 -1
- package/lib/firebase-storage/index.cjs +2 -2
- package/lib/firebase-storage/index.d.cts +2 -2
- package/lib/firebase-storage/index.d.ts +2 -2
- package/lib/firebase-storage/index.js +2 -2
- package/lib/firestore-storage/index.cjs +2 -2
- package/lib/firestore-storage/index.d.cts +23 -8
- package/lib/firestore-storage/index.d.ts +23 -8
- package/lib/firestore-storage/index.js +2 -2
- package/lib/index.cjs +2 -2
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/localstorage-storage/index.cjs +1 -1
- package/lib/localstorage-storage/index.d.cts +10 -6
- package/lib/localstorage-storage/index.d.ts +10 -6
- package/lib/localstorage-storage/index.js +1 -1
- package/lib/{mcp-tool-registries-W3TRj6O5.d.cts → mcp-tool-registries-CRtea2x4.d.cts} +3 -0
- package/lib/{mcp-tool-registries-BBObLYga.d.ts → mcp-tool-registries-D3rWSppt.d.ts} +3 -0
- package/lib/server-jobs-queue-runner/index.cjs +1 -1
- package/lib/server-jobs-queue-runner/index.d.cts +12 -9
- package/lib/server-jobs-queue-runner/index.d.ts +12 -9
- package/lib/server-jobs-queue-runner/index.js +1 -1
- package/lib/server-runtime/index.cjs +1 -1
- package/lib/server-runtime/index.d.cts +7 -9
- package/lib/server-runtime/index.d.ts +7 -9
- package/lib/server-runtime/index.js +1 -1
- package/lib/server-runtime-agentface/index.d.cts +7 -9
- package/lib/server-runtime-agentface/index.d.ts +7 -9
- package/lib/server-runtime-controlface/index.cjs +1 -1
- package/lib/server-runtime-controlface/index.d.cts +19 -71
- package/lib/server-runtime-controlface/index.d.ts +19 -71
- package/lib/server-runtime-controlface/index.js +1 -1
- package/lib/server-runtime-core/index.cjs +1 -1
- package/lib/server-runtime-core/index.d.cts +61 -21
- package/lib/server-runtime-core/index.d.ts +61 -21
- package/lib/server-runtime-core/index.js +1 -1
- package/lib/server-runtime-watchers/index.cjs +1 -1
- package/lib/server-runtime-watchers/index.d.cts +9 -65
- package/lib/server-runtime-watchers/index.d.ts +9 -65
- package/lib/server-runtime-watchers/index.js +1 -1
- package/lib/server-runtime-webhooks/index.d.cts +7 -9
- package/lib/server-runtime-webhooks/index.d.ts +7 -9
- package/lib/sse-hub-CYXisfXJ.d.cts +63 -0
- package/lib/sse-hub-Dodwtc3_.d.ts +63 -0
- package/lib/step-machine-public/index.cjs +1 -1
- package/lib/step-machine-public/index.d.cts +1 -1
- package/lib/step-machine-public/index.d.ts +1 -1
- package/lib/step-machine-public/index.js +1 -1
- package/lib/{storage-async-interface-BRR4eBjx.d.cts → storage-async-interface-CG0bMqvE.d.ts} +20 -1
- package/lib/{storage-async-interface-DhlOVPSp.d.ts → storage-async-interface-CyO-zwVQ.d.cts} +20 -1
- package/lib/{storage-interface-BFiD3kyB.d.ts → storage-interface-D-iEiTJA.d.cts} +45 -1
- package/lib/{storage-interface-BFiD3kyB.d.cts → storage-interface-D-iEiTJA.d.ts} +45 -1
- package/lib/stores/index.d.cts +1 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/kv.d.cts +1 -1
- package/lib/stores/kv.d.ts +1 -1
- package/lib/{types-CF2xUcZW.d.ts → types-BtH3scgE.d.ts} +66 -29
- package/lib/{types-BzQY45dH.d.cts → types-Ch0u3FKP.d.cts} +66 -29
- package/package.json +4 -5
- package/schema/live-cards.schema.json +10 -1
- package/browser/board-livecards-client.js +0 -2
- package/examples/board/demo-shell-with-server.html +0 -272
- package/examples/board/doc.html +0 -465
- package/examples/board/server-config.json +0 -24
- package/lib/chat-storage-lib-B9Q34Dyv.d.cts +0 -54
- package/lib/chat-storage-lib-DB9iSai2.d.ts +0 -54
- package/lib/chunk-5XHOHTLZ.cjs +0 -2
- package/lib/chunk-6APH25VI.js +0 -2
- package/lib/chunk-76ON3V7R.js +0 -2
- package/lib/chunk-7ICPAABP.cjs +0 -7
- package/lib/chunk-CPAXTVBQ.cjs +0 -2
- package/lib/chunk-DDYSXP2A.cjs +0 -3
- package/lib/chunk-EGRHWZRV.js +0 -2
- package/lib/chunk-GL2OHR2E.cjs +0 -2
- package/lib/chunk-GYQXDNNI.cjs +0 -2
- package/lib/chunk-H5HBXPOI.cjs +0 -3
- package/lib/chunk-IPLSRN6P.cjs +0 -4
- package/lib/chunk-J5J6BG7B.js +0 -2
- package/lib/chunk-M3OU6IS5.cjs +0 -2
- package/lib/chunk-M6STQR5F.cjs +0 -2
- package/lib/chunk-N6P2JW4W.js +0 -3
- package/lib/chunk-NJJ7WEDT.cjs +0 -2
- package/lib/chunk-NKIQRCOM.cjs +0 -2
- package/lib/chunk-NMZ6XNLB.cjs +0 -3
- package/lib/chunk-OEFTOO47.cjs +0 -3
- package/lib/chunk-PRHQBGPT.js +0 -2
- package/lib/chunk-S44QZUDX.js +0 -2
- package/lib/chunk-TSN3RTXT.js +0 -4
- package/lib/chunk-VLBB3D6B.js +0 -3
- package/lib/chunk-VMW4Z6EF.js +0 -3
- package/lib/chunk-VXJHBWK3.js +0 -2
- package/lib/chunk-WHDEBJLT.js +0 -7
- package/lib/chunk-YGALANRO.js +0 -2
- package/lib/chunk-ZXQR7GHT.js +0 -3
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { e as BoardPlatformAdapter, d as BoardNonCorePlatformAdapter, c as BoardLiveCardsPublic, a as CommandResult, f as BoardWorkerRequest } from './board-live-cards-public-D-DJek3X.js';
|
|
3
|
-
import { A as AsyncBoardPlatformAdapter } from './board-platform-adapter-async-JZPCzZnH.js';
|
|
4
|
-
import { A as AsyncBoardLiveCardsPublic } from './board-live-cards-public-async-3hUuHxDx.js';
|
|
1
|
+
import { e as BoardPlatformAdapter, l as BoardLiveCardsNonCorePublic, d as BoardNonCorePlatformAdapter, c as BoardLiveCardsPublic, a as CommandResult } from './board-live-cards-public-DSRamFm8.js';
|
|
5
2
|
import { ExecutionRef } from './execution-refs.js';
|
|
6
|
-
import { a as KindValueRef } from './storage-interface-
|
|
7
|
-
import {
|
|
3
|
+
import { f as QueueStorage, a as KindValueRef } from './storage-interface-D-iEiTJA.js';
|
|
4
|
+
import { A as AsyncBoardPlatformAdapter } from './board-platform-adapter-async-JP9V-U5E.js';
|
|
5
|
+
import { A as AsyncBoardLiveCardsPublic } from './board-live-cards-public-async-DlyC3PgC.js';
|
|
8
6
|
|
|
7
|
+
interface BoardWorkerRequest {
|
|
8
|
+
boardId?: string;
|
|
9
|
+
ref: ExecutionRef;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface BoardWorkerQueuedRequest {
|
|
13
|
+
messageId: string;
|
|
14
|
+
enqueuedAt: string;
|
|
15
|
+
attempt: number;
|
|
16
|
+
request: BoardWorkerRequest;
|
|
17
|
+
}
|
|
18
|
+
interface BoardWorkerLeasedRequest extends BoardWorkerQueuedRequest {
|
|
19
|
+
leaseToken: string;
|
|
20
|
+
leaseExpiresAt: string;
|
|
21
|
+
}
|
|
22
|
+
interface BoardWorkerDeadLetterRequest extends BoardWorkerQueuedRequest {
|
|
23
|
+
reason?: string;
|
|
24
|
+
}
|
|
25
|
+
interface BoardWorkerStore {
|
|
26
|
+
enqueueRequest(request: BoardWorkerRequest): string;
|
|
27
|
+
enqueueRequestIfAbsent?(request: BoardWorkerRequest, dedupKey: string): string | null;
|
|
28
|
+
leaseRequests(opts?: {
|
|
29
|
+
max?: number;
|
|
30
|
+
visibilityMs?: number;
|
|
31
|
+
}): BoardWorkerLeasedRequest[];
|
|
32
|
+
ackRequest(messageId: string, leaseToken: string): boolean;
|
|
33
|
+
nackRequest(messageId: string, leaseToken: string, opts?: {
|
|
34
|
+
dead?: boolean;
|
|
35
|
+
reason?: string;
|
|
36
|
+
}): boolean;
|
|
37
|
+
peekActive(): BoardWorkerQueuedRequest[];
|
|
38
|
+
peekDeadLetter(): BoardWorkerDeadLetterRequest[];
|
|
39
|
+
}
|
|
40
|
+
declare function createBoardWorkerStore(queue: QueueStorage): BoardWorkerStore;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* server-runtime/types.ts
|
|
44
|
+
*
|
|
45
|
+
* Platform-free adapter interfaces for the board server runtime.
|
|
46
|
+
*
|
|
47
|
+
* The runtime (index.ts) imports ONLY this file and board-live-cards-public
|
|
48
|
+
* for its dependencies — no node:fs, node:net, node:child_process, etc.
|
|
49
|
+
*
|
|
50
|
+
* Hosts (demo-server, Azure Function, Firebase Function) provide implementations
|
|
51
|
+
* of these interfaces when constructing the runtime.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
type BoardRuntimeNonCorePublic = Pick<BoardLiveCardsNonCorePublic, 'describeTaskExecutorCapabilities' | 'validateCardPreflight' | 'evalCardCompute' | 'probeSourcePreflight' | 'runSourcePreflight' | 'simulateCardCycle'>;
|
|
9
55
|
type Awaitable<T> = T | Promise<T>;
|
|
10
56
|
type BoardRuntimePlatformAdapter = BoardPlatformAdapter | AsyncBoardPlatformAdapter;
|
|
11
57
|
type BoardRuntimePublic = BoardLiveCardsPublic | AsyncBoardLiveCardsPublic;
|
|
@@ -80,27 +126,22 @@ interface HostedBoardQueueLaneTuning {
|
|
|
80
126
|
interface BoardContextConfig {
|
|
81
127
|
label: string;
|
|
82
128
|
boardAdapter: BoardRuntimePlatformAdapter;
|
|
129
|
+
nonCore?: BoardRuntimeNonCorePublic;
|
|
83
130
|
nonCoreAdapter?: BoardNonCorePlatformAdapter;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* Use this to give the embedder full control over the on-disk layout (e.g.
|
|
92
|
-
* via createFsBoardFileArtifactsStore(baseDir, { filesSubdir: '' })).
|
|
93
|
-
*/
|
|
94
|
-
filesArtifactsStore?: ArtifactsStore;
|
|
131
|
+
boardRuntimeStoreRef: string;
|
|
132
|
+
/** Explicit ref for externally backed runtime storage (journal + internal queue lanes). */
|
|
133
|
+
queueStoreRef: string;
|
|
134
|
+
/** Explicit blob root ref for persisted card/file attachments. */
|
|
135
|
+
artifactsStoreRef: string;
|
|
136
|
+
/** Explicit ref for fetched source payloads. */
|
|
137
|
+
fetchedSourcesStoreRef: string;
|
|
95
138
|
baseRef: KindValueRef;
|
|
96
139
|
cardStoreRef: string;
|
|
97
140
|
outputsStoreRef: string;
|
|
98
|
-
/**
|
|
99
|
-
chatStoreRef
|
|
100
|
-
/**
|
|
101
|
-
scratchStoreRef
|
|
102
|
-
/** Optional ref pointing archive storage at a different backend than the board runtime. */
|
|
103
|
-
archiveStoreRef?: string;
|
|
141
|
+
/** Explicit ref pointing persisted card chat storage at a different backend. */
|
|
142
|
+
chatStoreRef: string;
|
|
143
|
+
/** Explicit ref pointing scratch storage at a different backend than the board runtime. */
|
|
144
|
+
scratchStoreRef: string;
|
|
104
145
|
/** Notification endpoint ref — e.g. ::named-pipe::<path> or ::firestore-watch::<path> */
|
|
105
146
|
notifyRef?: KindValueRef;
|
|
106
147
|
taskExecutorRef?: ExecutionRef;
|
|
@@ -117,8 +158,6 @@ interface SingleBoardRuntimeOptions {
|
|
|
117
158
|
boards: BoardContextConfig[];
|
|
118
159
|
invocationAdapter: InvocationAdapter;
|
|
119
160
|
chatFlowRunner?: ChatHandlerFlowRunner;
|
|
120
|
-
/** Chat storage backend. Defaults to an in-memory store when omitted. */
|
|
121
|
-
chatStorage?: ChatStorage;
|
|
122
161
|
notificationTransport?: NotificationTransport;
|
|
123
162
|
logger?: RuntimeLogger;
|
|
124
163
|
serverUrl?: string;
|
|
@@ -156,10 +195,8 @@ interface SingleBoardRuntime {
|
|
|
156
195
|
readonly queueLaneTuning: HostedBoardQueueLaneTuning;
|
|
157
196
|
handleRuntimeApi(req: RuntimeRequest, res: RuntimeResponse, parsedUrl: URL): Promise<boolean>;
|
|
158
197
|
buildPublishedRuntimePayload(): Awaitable<unknown>;
|
|
159
|
-
processAccumulatedEvents(): Awaitable<CommandResult>;
|
|
160
|
-
processAccumulatedLane(): Awaitable<CommandResult>;
|
|
161
198
|
handleChatAgentRequest(request: BoardWorkerRequest): Awaitable<void>;
|
|
162
|
-
clearChatRecords(cardId: string): void
|
|
199
|
+
clearChatRecords(cardId: string): Awaitable<void>;
|
|
163
200
|
/** Report that a source fetch completed. Token is the source callback token; ref is the blob ref (b64:<base64url(json)>). */
|
|
164
201
|
reportSourceFetched(token: string, ref: string): Awaitable<CommandResult>;
|
|
165
202
|
/** Report that a source fetch failed. Token is the source callback token. */
|
|
@@ -209,4 +246,4 @@ interface RuntimeResponse {
|
|
|
209
246
|
end(data?: string | Buffer): void;
|
|
210
247
|
}
|
|
211
248
|
|
|
212
|
-
export type
|
|
249
|
+
export { type Awaitable as A, type BoardContextConfig as B, type ChatHandlerFlowRunner as C, type DescribeEnvelope as D, type HostedBoardQueueLaneTuning as H, type InvocationAdapter as I, type MultiBoardRuntimeOptions as M, type NotificationTransport as N, type QueueLaneRuntimeTuning as Q, type RuntimeLogger as R, type SingleBoardRuntimeOptions as S, type MultiBoardRuntime as a, type SingleBoardRuntime as b, type BoardRuntimeNonCorePublic as c, type BoardRuntimePlatformAdapter as d, type BoardRuntimePublic as e, type BoardWorkerRequest as f, type RuntimeRequest as g, type RuntimeResponse as h, type BoardWorkerStore as i, type BoardWorkerDeadLetterRequest as j, type BoardWorkerLeasedRequest as k, type BoardWorkerQueuedRequest as l, createBoardWorkerStore as m };
|
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { e as BoardPlatformAdapter, d as BoardNonCorePlatformAdapter, c as BoardLiveCardsPublic, a as CommandResult, f as BoardWorkerRequest } from './board-live-cards-public-DQzPe7A9.cjs';
|
|
3
|
-
import { A as AsyncBoardPlatformAdapter } from './board-platform-adapter-async-DOfEq_HC.cjs';
|
|
4
|
-
import { A as AsyncBoardLiveCardsPublic } from './board-live-cards-public-async-CgMCYYft.cjs';
|
|
1
|
+
import { e as BoardPlatformAdapter, l as BoardLiveCardsNonCorePublic, d as BoardNonCorePlatformAdapter, c as BoardLiveCardsPublic, a as CommandResult } from './board-live-cards-public-BT5HrgqZ.cjs';
|
|
5
2
|
import { ExecutionRef } from './execution-refs.cjs';
|
|
6
|
-
import { a as KindValueRef } from './storage-interface-
|
|
7
|
-
import {
|
|
3
|
+
import { f as QueueStorage, a as KindValueRef } from './storage-interface-D-iEiTJA.cjs';
|
|
4
|
+
import { A as AsyncBoardPlatformAdapter } from './board-platform-adapter-async-BZIftm36.cjs';
|
|
5
|
+
import { A as AsyncBoardLiveCardsPublic } from './board-live-cards-public-async-CYjr4mgX.cjs';
|
|
8
6
|
|
|
7
|
+
interface BoardWorkerRequest {
|
|
8
|
+
boardId?: string;
|
|
9
|
+
ref: ExecutionRef;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface BoardWorkerQueuedRequest {
|
|
13
|
+
messageId: string;
|
|
14
|
+
enqueuedAt: string;
|
|
15
|
+
attempt: number;
|
|
16
|
+
request: BoardWorkerRequest;
|
|
17
|
+
}
|
|
18
|
+
interface BoardWorkerLeasedRequest extends BoardWorkerQueuedRequest {
|
|
19
|
+
leaseToken: string;
|
|
20
|
+
leaseExpiresAt: string;
|
|
21
|
+
}
|
|
22
|
+
interface BoardWorkerDeadLetterRequest extends BoardWorkerQueuedRequest {
|
|
23
|
+
reason?: string;
|
|
24
|
+
}
|
|
25
|
+
interface BoardWorkerStore {
|
|
26
|
+
enqueueRequest(request: BoardWorkerRequest): string;
|
|
27
|
+
enqueueRequestIfAbsent?(request: BoardWorkerRequest, dedupKey: string): string | null;
|
|
28
|
+
leaseRequests(opts?: {
|
|
29
|
+
max?: number;
|
|
30
|
+
visibilityMs?: number;
|
|
31
|
+
}): BoardWorkerLeasedRequest[];
|
|
32
|
+
ackRequest(messageId: string, leaseToken: string): boolean;
|
|
33
|
+
nackRequest(messageId: string, leaseToken: string, opts?: {
|
|
34
|
+
dead?: boolean;
|
|
35
|
+
reason?: string;
|
|
36
|
+
}): boolean;
|
|
37
|
+
peekActive(): BoardWorkerQueuedRequest[];
|
|
38
|
+
peekDeadLetter(): BoardWorkerDeadLetterRequest[];
|
|
39
|
+
}
|
|
40
|
+
declare function createBoardWorkerStore(queue: QueueStorage): BoardWorkerStore;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* server-runtime/types.ts
|
|
44
|
+
*
|
|
45
|
+
* Platform-free adapter interfaces for the board server runtime.
|
|
46
|
+
*
|
|
47
|
+
* The runtime (index.ts) imports ONLY this file and board-live-cards-public
|
|
48
|
+
* for its dependencies — no node:fs, node:net, node:child_process, etc.
|
|
49
|
+
*
|
|
50
|
+
* Hosts (demo-server, Azure Function, Firebase Function) provide implementations
|
|
51
|
+
* of these interfaces when constructing the runtime.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
type BoardRuntimeNonCorePublic = Pick<BoardLiveCardsNonCorePublic, 'describeTaskExecutorCapabilities' | 'validateCardPreflight' | 'evalCardCompute' | 'probeSourcePreflight' | 'runSourcePreflight' | 'simulateCardCycle'>;
|
|
9
55
|
type Awaitable<T> = T | Promise<T>;
|
|
10
56
|
type BoardRuntimePlatformAdapter = BoardPlatformAdapter | AsyncBoardPlatformAdapter;
|
|
11
57
|
type BoardRuntimePublic = BoardLiveCardsPublic | AsyncBoardLiveCardsPublic;
|
|
@@ -80,27 +126,22 @@ interface HostedBoardQueueLaneTuning {
|
|
|
80
126
|
interface BoardContextConfig {
|
|
81
127
|
label: string;
|
|
82
128
|
boardAdapter: BoardRuntimePlatformAdapter;
|
|
129
|
+
nonCore?: BoardRuntimeNonCorePublic;
|
|
83
130
|
nonCoreAdapter?: BoardNonCorePlatformAdapter;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* Use this to give the embedder full control over the on-disk layout (e.g.
|
|
92
|
-
* via createFsBoardFileArtifactsStore(baseDir, { filesSubdir: '' })).
|
|
93
|
-
*/
|
|
94
|
-
filesArtifactsStore?: ArtifactsStore;
|
|
131
|
+
boardRuntimeStoreRef: string;
|
|
132
|
+
/** Explicit ref for externally backed runtime storage (journal + internal queue lanes). */
|
|
133
|
+
queueStoreRef: string;
|
|
134
|
+
/** Explicit blob root ref for persisted card/file attachments. */
|
|
135
|
+
artifactsStoreRef: string;
|
|
136
|
+
/** Explicit ref for fetched source payloads. */
|
|
137
|
+
fetchedSourcesStoreRef: string;
|
|
95
138
|
baseRef: KindValueRef;
|
|
96
139
|
cardStoreRef: string;
|
|
97
140
|
outputsStoreRef: string;
|
|
98
|
-
/**
|
|
99
|
-
chatStoreRef
|
|
100
|
-
/**
|
|
101
|
-
scratchStoreRef
|
|
102
|
-
/** Optional ref pointing archive storage at a different backend than the board runtime. */
|
|
103
|
-
archiveStoreRef?: string;
|
|
141
|
+
/** Explicit ref pointing persisted card chat storage at a different backend. */
|
|
142
|
+
chatStoreRef: string;
|
|
143
|
+
/** Explicit ref pointing scratch storage at a different backend than the board runtime. */
|
|
144
|
+
scratchStoreRef: string;
|
|
104
145
|
/** Notification endpoint ref — e.g. ::named-pipe::<path> or ::firestore-watch::<path> */
|
|
105
146
|
notifyRef?: KindValueRef;
|
|
106
147
|
taskExecutorRef?: ExecutionRef;
|
|
@@ -117,8 +158,6 @@ interface SingleBoardRuntimeOptions {
|
|
|
117
158
|
boards: BoardContextConfig[];
|
|
118
159
|
invocationAdapter: InvocationAdapter;
|
|
119
160
|
chatFlowRunner?: ChatHandlerFlowRunner;
|
|
120
|
-
/** Chat storage backend. Defaults to an in-memory store when omitted. */
|
|
121
|
-
chatStorage?: ChatStorage;
|
|
122
161
|
notificationTransport?: NotificationTransport;
|
|
123
162
|
logger?: RuntimeLogger;
|
|
124
163
|
serverUrl?: string;
|
|
@@ -156,10 +195,8 @@ interface SingleBoardRuntime {
|
|
|
156
195
|
readonly queueLaneTuning: HostedBoardQueueLaneTuning;
|
|
157
196
|
handleRuntimeApi(req: RuntimeRequest, res: RuntimeResponse, parsedUrl: URL): Promise<boolean>;
|
|
158
197
|
buildPublishedRuntimePayload(): Awaitable<unknown>;
|
|
159
|
-
processAccumulatedEvents(): Awaitable<CommandResult>;
|
|
160
|
-
processAccumulatedLane(): Awaitable<CommandResult>;
|
|
161
198
|
handleChatAgentRequest(request: BoardWorkerRequest): Awaitable<void>;
|
|
162
|
-
clearChatRecords(cardId: string): void
|
|
199
|
+
clearChatRecords(cardId: string): Awaitable<void>;
|
|
163
200
|
/** Report that a source fetch completed. Token is the source callback token; ref is the blob ref (b64:<base64url(json)>). */
|
|
164
201
|
reportSourceFetched(token: string, ref: string): Awaitable<CommandResult>;
|
|
165
202
|
/** Report that a source fetch failed. Token is the source callback token. */
|
|
@@ -209,4 +246,4 @@ interface RuntimeResponse {
|
|
|
209
246
|
end(data?: string | Buffer): void;
|
|
210
247
|
}
|
|
211
248
|
|
|
212
|
-
export type
|
|
249
|
+
export { type Awaitable as A, type BoardContextConfig as B, type ChatHandlerFlowRunner as C, type DescribeEnvelope as D, type HostedBoardQueueLaneTuning as H, type InvocationAdapter as I, type MultiBoardRuntimeOptions as M, type NotificationTransport as N, type QueueLaneRuntimeTuning as Q, type RuntimeLogger as R, type SingleBoardRuntimeOptions as S, type MultiBoardRuntime as a, type SingleBoardRuntime as b, type BoardRuntimeNonCorePublic as c, type BoardRuntimePlatformAdapter as d, type BoardRuntimePublic as e, type BoardWorkerRequest as f, type RuntimeRequest as g, type RuntimeResponse as h, type BoardWorkerStore as i, type BoardWorkerDeadLetterRequest as j, type BoardWorkerLeasedRequest as k, type BoardWorkerQueuedRequest as l, createBoardWorkerStore as m };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml-flow",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.8.0",
|
|
4
4
|
"description": "Unified workflow engine: step-machine (sequential) + event-graph (stateless DAG) with pluggable storage",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -136,16 +136,15 @@
|
|
|
136
136
|
"!examples/**/cards/**/files/**"
|
|
137
137
|
],
|
|
138
138
|
"scripts": {
|
|
139
|
-
"build": "npm run -s build:lib
|
|
139
|
+
"build": "npm run -s build:lib",
|
|
140
140
|
"build:lib": "tsup --config tsup.config.ts",
|
|
141
141
|
"build:cli": "tsup --config tsup.cli.config.ts",
|
|
142
142
|
"build:cli-bundled": "node scripts/build-cli-bundled.mjs",
|
|
143
|
-
"build:public-examples": "node scripts/generate-public-examples.mjs",
|
|
144
143
|
"build:browser": "tsup --config tsup.browser.config.ts && node scripts/generate-browser-integrity.mjs",
|
|
145
144
|
"check:bundle-budget": "node scripts/check-bundle-budgets.mjs",
|
|
146
145
|
"check:browser-bundle": "node scripts/check-browser-bundle-safety.mjs",
|
|
147
146
|
"check:minified": "node scripts/check-minified.mjs",
|
|
148
|
-
"release:gate": "npm run -s build && npm run -s build:browser && npm run -s test:run && npm run -s test:e2e && npm run -s check:bundle-budget && npm run -s check:browser-bundle && npm run -s check:minified",
|
|
147
|
+
"release:gate": "npm run -s build && npm run -s build:cli && npm run -s build:browser && npm run -s test:run && npm run -s test:e2e && npm run -s check:bundle-budget && npm run -s check:browser-bundle && npm run -s check:minified",
|
|
149
148
|
"standalone": "echo standalone is canonical; no assembly step required",
|
|
150
149
|
"pycli:install": "python -m pip install -r py-standalone/requirements.txt",
|
|
151
150
|
"pycli:install:venv": "c:/Users/sreenaga/ADO/ai-tool-evolver/.venv/Scripts/python.exe -m pip install -r py-standalone/requirements.txt",
|
|
@@ -161,7 +160,7 @@
|
|
|
161
160
|
"validate:cards": "tsx scripts/validate-live-cards.ts",
|
|
162
161
|
"lint": "eslint src/",
|
|
163
162
|
"typecheck": "tsc --noEmit",
|
|
164
|
-
"prepublishOnly": "npm run build && npm run build:
|
|
163
|
+
"prepublishOnly": "npm run build && npm run build:cli && npm run build:browser && npm run check:bundle-budget && npm run check:browser-bundle && npm run check:minified"
|
|
165
164
|
},
|
|
166
165
|
"devDependencies": {
|
|
167
166
|
"@types/node": "^20.10.0",
|
|
@@ -145,7 +145,13 @@
|
|
|
145
145
|
"type": "string"
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
}
|
|
148
|
+
},
|
|
149
|
+
"additionalProperties": true
|
|
150
|
+
},
|
|
151
|
+
"__private": {
|
|
152
|
+
"description": "Control-plane-owned private state. Stripped entirely from all regular /mcp read responses. Writable only via 'setstate.card-private' and 'manage.admin-upsert-card'. Agents must never author this field. Keys inside use plain names (no leading underscores).",
|
|
153
|
+
"type": "object",
|
|
154
|
+
"additionalProperties": true
|
|
149
155
|
},
|
|
150
156
|
"requires": {
|
|
151
157
|
"type": "array",
|
|
@@ -506,6 +512,9 @@
|
|
|
506
512
|
"meta": {
|
|
507
513
|
"$ref": "#/definitions/meta"
|
|
508
514
|
},
|
|
515
|
+
"__private": {
|
|
516
|
+
"$ref": "#/definitions/__private"
|
|
517
|
+
},
|
|
509
518
|
"view": {
|
|
510
519
|
"$ref": "#/definitions/view"
|
|
511
520
|
},
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var BoardLiveCardsClient=(function(exports){'use strict';function W(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function pt(t,e){let r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return {schema_version:r.schema_version||"v1",card_id:typeof r.card_id=="string"?r.card_id:t,card_data:r.card_data&&typeof r.card_data=="object"&&!Array.isArray(r.card_data)?structuredClone(r.card_data):{},computed_values:r.computed_values&&typeof r.computed_values=="object"&&!Array.isArray(r.computed_values)?structuredClone(r.computed_values):{}}}function E(t,e){if(!t||typeof t!="object")throw new Error("payload must be an object");if(!e)throw new Error("cardId is required");let m=(Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).find(C=>C.id===e);if(!m)throw new Error(`cardDefinitions has no entry with id ${e}`);let n=t.statusSnapshot&&typeof t.statusSnapshot=="object"?t.statusSnapshot:{},o=t.cardRuntimeById&&typeof t.cardRuntimeById=="object"?t.cardRuntimeById:{},y=t.dataObjectsByToken&&typeof t.dataObjectsByToken=="object"?t.dataObjectsByToken:{},u=(Array.isArray(n.cards)?n.cards:[]).find(C=>C.name===e),l=structuredClone(m),i=pt(e,o[e]),s={...l.card_data&&typeof l.card_data=="object"&&!Array.isArray(l.card_data)?l.card_data:{},...i.card_data||{},status:W(u?.status),lastRun:u?.runtime?.last_transition_at??null};u?.error?.message&&(s.error=u.error.message);let g=u?{task_status:u.status??null,card_status:W(u.status),runtime:structuredClone(u.runtime??{}),error:u.error?structuredClone(u.error):null,blocked_by:Array.isArray(u.blocked_by)?structuredClone(u.blocked_by):[],requires_missing:Array.isArray(u.requires_missing)?structuredClone(u.requires_missing):[]}:{task_status:null,card_status:s.status??"fresh",runtime:{last_transition_at:s.lastRun??null},error:s.error?{message:s.error}:null,blocked_by:[],requires_missing:[]},k=Array.isArray(l.requires)?l.requires:[],c={};for(let[C,x]of Object.entries(y))c[C]=structuredClone(x);for(let C of k)Object.prototype.hasOwnProperty.call(c,C)||(c[C]=null);let d=(t.cardChatsByCardId&&typeof t.cardChatsByCardId=="object"?t.cardChatsByCardId:{})[e],S=d?{messages:Array.isArray(d.messages)?d.messages:[],receiving:!!d.receiving,processing:!!d.processing}:null;return {id:e,card:l,card_data:s,requires:c,computed_values:i.computed_values,runtime_state:g,card_chats:S}}function U(t){if(!t||typeof t!="object")throw new Error("payload must be an object");return (Array.isArray(t.cardDefinitions)?t.cardDefinitions:[]).map(r=>E(t,r.id))}function G(t){return JSON.parse(JSON.stringify(t))}function B(t,e){if(t===e)return t;try{if(JSON.stringify(t)===JSON.stringify(e))return t}catch{}return e}function _(t,e){if(t===e)return true;try{return JSON.stringify(t)===JSON.stringify(e)}catch{return false}}function gt(t){return t==="running"||t==="in-progress"?"loading":t==="failed"?"error":"fresh"}function q(t,e,r){let m=t,o=(m&&Array.isArray(m.cardDefinitions)?m.cardDefinitions:[]).map(u=>u.id),y=e&&e.modelsById||{},h={};for(let u of o){let l=r(t,u),i=y[u];if(!i){h[u]=l;continue}let p=l.card_chats!=null?B(i.card_chats,l.card_chats??null):i.card_chats??null,s={id:l.id,card:B(i.card,l.card),card_data:B(i.card_data,l.card_data),requires:B(i.requires,l.requires),computed_values:B(i.computed_values,l.computed_values),runtime_state:B(i.runtime_state,l.runtime_state),card_chats:p};h[u]=s.card===i.card&&s.card_data===i.card_data&&s.requires===i.requires&&s.computed_values===i.computed_values&&s.runtime_state===i.runtime_state&&s.card_chats===i.card_chats?i:s;}return {payload:t,cardIds:o,modelsById:h}}function H(t,e={}){if(!t)return t;let r=typeof e.includeCard=="function"?e.includeCard:(()=>true),m=typeof e.mapCard=="function"?e.mapCard:(u=>u),n=false,o=[],y={};for(let u of t.cardIds){let l=t.modelsById[u];if(!l){n=true;continue}if(!r(l,t)){n=true;continue}let i=m(l,t);if(!i||i.id!==u)throw new Error(`deriveBoardState: mapped card must preserve id "${u}"`);i!==l&&(n=true),o.push(u),y[u]=i;}let h=typeof e.mapPayload=="function"?e.mapPayload(t.payload,{sourceState:t,cardIds:o,modelsById:y}):t.payload;return h!==t.payload&&(n=true),!n&&o.length===t.cardIds.length?t:{payload:h,cardIds:o,modelsById:y}}function J(t,e,r,m){if(!t||!Array.isArray(e)||e.length===0)return t;let n=t.modelsById,o=t.cardIds,y=false,h=false,u={};for(let i of o){let p=n[i],s=p&&p.requires;if(s&&typeof s=="object")for(let g of Object.keys(s))(u[g]=u[g]||[]).push(i);}function l(){y||(n={...n},y=true);}for(let i of e)if(!(!i||!i.kind)){if(i.kind==="computed_values"){let p=i.cardId,s=n[p];if(!s)continue;let g=i.values||{};if(_(s.computed_values,g))continue;l(),n[p]={...s,computed_values:g},h=true;}else if(i.kind==="data_object"){let p=i.key,s=i.payload,g=u[p]||[];for(let k of g){let c=n[k];if(!c)continue;let w=c.requires||{};_(w[p],s)||(l(),n[k]={...c,requires:{...w,[p]:s}},h=true);}}else if(i.kind==="card_refreshed"){let p=i.cardId,s=null,g=n[p],k=i.card;if(g&&k&&typeof k=="object"&&!Array.isArray(k)){let c=k,w=c.card_data&&typeof c.card_data=="object"&&!Array.isArray(c.card_data)?c.card_data:g.card_data,d=c.requires&&typeof c.requires=="object"&&!Array.isArray(c.requires)?c.requires:g.requires,S=c.computed_values&&typeof c.computed_values=="object"&&!Array.isArray(c.computed_values)?c.computed_values:g.computed_values,C=c.runtime_state&&typeof c.runtime_state=="object"&&!Array.isArray(c.runtime_state)?c.runtime_state:g.runtime_state;s={...g,card:k,card_data:w,requires:d,computed_values:S,runtime_state:C};}if(!s)try{let c=m();c&&(s=r(c,p));}catch{}if(!s||g&&_(g.card,s.card)&&_(g.card_data,s.card_data)&&_(g.requires,s.requires)&&_(g.computed_values,s.computed_values)&&_(g.runtime_state,s.runtime_state))continue;l(),n[p]=s,o.includes(p)||(o=[...o,p]),h=true;}else if(i.kind==="card_removed"){let p=i.cardId;if(!n[p])continue;l(),delete n[p],o=o.filter(s=>s!==p),h=true;}else if(i.kind==="card_chats"){let p=i.cardId,s=n[p];if(!s)continue;let g=Array.isArray(i.messages)?i.messages:s.card_chats?.messages??[],k=typeof i.receiving=="boolean"?i.receiving:s.card_chats?.receiving??false,c=typeof i.processing=="boolean"?i.processing:s.card_chats?.processing??false,w={messages:g,receiving:k,processing:c};if(_(s.card_chats,w))continue;l(),n[p]={...s,card_chats:w},h=true;}else if(i.kind==="chat_messages"){let p=i.cardId,s=n[p];if(!s)continue;let g=Array.isArray(i.messages)?i.messages:[],k=s.card_chats||{receiving:false,processing:false},c={messages:g,receiving:k.receiving,processing:!!k.processing};if(_(s.card_chats,c))continue;l(),n[p]={...s,card_chats:c},h=true;}else if(i.kind==="status"){let p=i.status?.cards??[];for(let s of p){let g=s?.name;if(!g||!n[g])continue;let k=n[g],c=gt(s.status),w={...k.card_data||{},status:c,lastRun:s.runtime?.last_transition_at??null,...s.error?.message?{error:s.error.message}:{}};s.error?.message||delete w.error;let d={task_status:s.status??null,card_status:c,runtime:s.runtime?G(s.runtime):{},error:s.error?G(s.error):null,blocked_by:Array.isArray(s.blocked_by)?G(s.blocked_by):[],requires_missing:Array.isArray(s.requires_missing)?G(s.requires_missing):[]};_(k.card_data,w)&&_(k.runtime_state,d)||(l(),n[g]={...k,card_data:w,runtime_state:d},h=true);}}}return h?{payload:t.payload,cardIds:o,modelsById:n}:t}function Ie(t,e="/api/boards"){let r=e.replace(/\/$/,""),m=encodeURIComponent(t||"default"),n=`${r}/${m}`;return {initBoard:`${n}/init-board`,stream:`${n}/sse`,patchCard:o=>`${n}/cards/${encodeURIComponent(o)}`,retriggerCard:o=>`${n}/cards/${encodeURIComponent(o)}/retrigger`,cardAction:o=>`${n}/cards/${encodeURIComponent(o)}/actions`,cardFile:o=>`${n}/cards/${encodeURIComponent(o)}/files`,cardChats:o=>`${n}/cards/${encodeURIComponent(o)}/chats`,chatSubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/subscribe-sse`,chatUnsubscribeSse:o=>`${n}/cards/${encodeURIComponent(o)}/chats/unsubscribe-sse`}}function Be(t="/api/board"){let e=t.replace(/\/$/,"");return {initBoard:`${e}/init-board`,stream:`${e}/sse`,patchCard:r=>`${e}/cards/${encodeURIComponent(r)}`,retriggerCard:r=>`${e}/cards/${encodeURIComponent(r)}/retrigger`,cardAction:r=>`${e}/cards/${encodeURIComponent(r)}/actions`,cardFile:r=>`${e}/cards/${encodeURIComponent(r)}/files`,cardChats:r=>`${e}/cards/${encodeURIComponent(r)}/chats`,chatSubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/subscribe-sse`,chatUnsubscribeSse:r=>`${e}/cards/${encodeURIComponent(r)}/chats/unsubscribe-sse`}}function ht(t){let e=t.getServerOrigin();if(!e||!t.boardId)return null;let r=t.boardPaths(t.boardId);return `${e}${r.initBoard.replace(/\/init-board$/,"")}`}async function Z(t){if(!t.file)return null;let e=t.boardPaths(t.boardId),r=typeof t.turnId=="string"&&t.turnId!=="",m=t.inChat?`${e.cardFile(t.cardId)}?inChat=true${r?`&turn-id=${encodeURIComponent(t.turnId)}`:""}`:e.cardFile(t.cardId),n=typeof t.file.name=="string"?t.file.name:"upload.bin",o=t.file.type||"application/octet-stream",y=await t.fetchServer(m,{method:"POST",headers:{"content-type":o,"x-file-name":encodeURIComponent(n)},body:t.file});if(!y.ok){let u=await y.text();throw new Error(`Upload failed for ${t.cardId} (${y.status})${u?": "+u:""}`)}return (await y.json())?.file??null}async function mt(t){let{actionType:e}=t;if(e!=="chat-send"&&e!=="file-upload")return t.payload||{};let r={...t.payload||{}},m=typeof r["turn-id"]=="string"?String(r["turn-id"]):typeof r.turnId=="string"?String(r.turnId):typeof r.turn=="string"?String(r.turn):"",n=Array.isArray(r.files)?r.files:[];if(!n.length)return r.files=[],r;let o=[];for(let y of n){let h=await Z({...t,file:y,inChat:e==="chat-send",turnId:e==="chat-send"?m:void 0});h&&o.push(h);}return r.files=e==="chat-send"?[]:o,r}async function yt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.patchCard(t.cardId),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(t.patch||{})});if(!r.ok)throw new Error(`PATCH failed for ${t.cardId} (${r.status})`)}async function kt(t){let e=t.boardPaths(t.boardId),r=await t.fetchServer(e.retriggerCard(t.cardId),{method:"POST"});if(!r.ok)throw new Error(`retrigger failed for ${t.cardId} (${r.status})`)}async function St(t){let e=t.boardPaths(t.boardId),r=await mt(t),m=await t.fetchServer(e.cardAction(t.cardId),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({actionType:t.actionType,payload:r})});if(!m.ok)throw new Error(`${t.actionType==="refresh"?"Refresh":"Action"} failed for ${t.cardId} (${m.status})`);return {payload:r}}function Oe(t,e=null){return q(t,e,E)}function Pe(t,e,r){return J(t,e,E,r)}function De(t,e){let r=new Set(e.map(String)),m=t.cardIds.filter(o=>r.has(o)),n={};for(let o of m)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:m,modelsById:n}}function je(t,e){let r=e instanceof Set?e:new Set(e.map(String)),m=t.cardIds.filter(o=>!r.has(o)),n={};for(let o of m)n[o]=t.modelsById[o];return {payload:t.payload,cardIds:m,modelsById:n}}function vt(t){let e=t?.core,r=t?.engine??e?.engine;r&&typeof r.onServerSseEvent=="function"?r.onServerSseEvent():r&&typeof r.refreshOpenChatModal=="function"&&r.refreshOpenChatModal();}function bt(){let t=globalThis.LiveCard;if(!t)throw new Error("LiveCard global not loaded \u2014 include live-cards.js before this script");return t}function Ct(t){if(!t||typeof t!="object")throw new Error("options are required");let{fetchServer:e,boardPaths:r,getServerOrigin:m}=t;if(typeof e!="function")throw new Error("options.fetchServer is required");if(typeof r!="function")throw new Error("options.boardPaths is required");if(typeof m!="function")throw new Error("options.getServerOrigin is required");let n={current:null},o=new Set,y=null,h=null,u=null,l={},i={},p=globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():`lc-${Date.now()}-${Math.random().toString(36).slice(2)}`;function s(){for(let a of o)a(n.current);}function g(){return n.current?n.current.payload:null}function k(a){return n.current=a,s(),n.current}function c(){let a=h;if(!a)throw new Error("Board runtime session is not bound to a board yet");let f=u??r(a);return u=f,{boardId:a,paths:f}}function w(a){let f=q(a,n.current,E);return k(f),f}function d(a,f){let v=q(a,f??n.current,E);return k(v),v}function S(a){return k(a)}function C(a){if(!n.current)return n.current;let f=J(n.current,a,E,g);return k(f),f}async function x(a,f,v){let{boardId:R}=c();return Z({fetchServer:e,boardPaths:r,boardId:R,cardId:a,file:f,inChat:v?.inChat,turnId:v?.turnId})}async function M(a,f,v){let{boardId:R}=c();return f==="chat-send"&&await A(a),St({fetchServer:e,boardPaths:r,boardId:R,cardId:a,actionType:f,payload:v})}function b(a,f){return i[a]=f,f.finally(()=>{i[a]===f&&delete i[a];})}async function A(a){let f=i[a];if(f){await f;return}l[a]||await K(a);}async function $(a,f){let{boardId:v}=c();await yt({fetchServer:e,boardPaths:r,boardId:v,cardId:a,patch:f});}async function tt(a){let{boardId:f}=c();await kt({fetchServer:e,boardPaths:r,boardId:f,cardId:a});}async function K(a){let{paths:f}=c(),v=i[a];if(v){await v;return}if(l[a])return;l[a]=true;let R=(async()=>{await e(f.chatSubscribeSse(a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})});})().catch(()=>{delete l[a];});await b(a,R);}async function et(a){let{paths:f}=c(),v=i[a];if(v)try{await v;}catch{}delete l[a];try{await e(f.chatUnsubscribeSse(a),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})});}catch{}}function rt(a){Object.keys(l).forEach(f=>{e(a.chatSubscribeSse(f),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({clientId:p})}).catch(()=>{});});}function V(a){let f=a;f?.kind==="notification-batch"&&Array.isArray(f.notifications)?C(f.notifications):f?.cardDefinitions&&w(f);}function nt(a){return h=String(a.boardId||"default"),u=r(h),a.state!==void 0?S(a.state??null):a.payload?d(a.payload,n.current):n.current}function st(a){return V(a),n.current}function F(){y&&(y.close(),y=null);}async function at(a={}){let f=String(a.boardId||h||"default");h=f;let v=r(f);if(u=v,a.initialState!==void 0?S(a.initialState??null):a.initialPayload!==void 0&&d(a.initialPayload,n.current),a.skipInitBoard!==true){let O=typeof a.taskExecutorPath=="string"?a.taskExecutorPath.trim():"",P=O?`${v.initBoard}?taskExecutorPath=${encodeURIComponent(O)}`:v.initBoard,T=await e(P);if(!T.ok)throw new Error(`Server init-board failed (${T.status}).`)}let R=m();if(!R)throw new Error("Server origin not resolved before SSE start");F();let I=!n.current,dt=`${R}${v.stream}${v.stream.includes("?")?"&":"?"}clientId=${encodeURIComponent(p)}`,X=await new Promise((O,P)=>{let T=new EventSource(dt);y=T;let D=false,j=I?setTimeout(()=>{D||P(new Error("SSE initial payload timeout (15s)"));},15e3):null;T.onopen=()=>{rt(v),I||O(n.current?.payload??null);},T.onmessage=ct=>{try{let N=JSON.parse(ct.data||"{}");V(N),!D&&I&&(N?.cardDefinitions||U(N))&&(D=!0,j&&clearTimeout(j),O(N));}catch{if(!I)return}},T.onerror=()=>{I&&!D&&(j&&clearTimeout(j),P(new Error("SSE connection failed during bootstrap")));};});if(I){if(!U(X))throw new Error("SSE payload missing published runtime artifacts");w(X);}return n.current}function ot(a){return o.add(a),a(n.current),()=>{o.delete(a);}}function it(){F(),Object.keys(l).forEach(a=>delete l[a]),u=null,h=null,o.clear(),n.current=null;}return {bootstrap:at,attachProvidedState:nt,applyServerUpdate:st,seedStateFromPayload:d,seedState:S,applyNotificationBatch:C,replacePayload:w,subscribe:ot,closeSse:F,isConnected:()=>y!=null,getState:()=>n.current,getPayload:g,getBoardId:()=>h,getClientId:()=>p,getSseClientId:()=>p,patchCardState:$,retriggerCard:tt,dispatchCardAction:M,uploadCardFile:x,subscribeCardChats:K,unsubscribeCardChats:et,dispose:it}}function Q(t){if(!t||typeof t!="object")throw new Error("options are required");if(!t.session)throw new Error("options.session is required");let{session:e,...r}=t,m=t.session&&"canvas"in t&&typeof t.canvas=="object"?t.canvas:{height:"72vh",overflow:"auto"},n=e.getState()?H(e.getState(),r):null,o=null,y=String(t.initialMode||"board"),h=new Set;function u(){for(let d of h)d(n);}function l(d){n=d?H(d,r):null,u(),o&&n&&(o.setState(()=>n),vt(o));}let i=e.subscribe(d=>{l(d);});function p(d){if(!n)throw new Error("Derived board runtime has no state to mount");let S=d?.rootElement;if(!S)throw new Error("mountBoard requires params.rootElement");y=String(d?.mode||y||"board");let C=r.boardPaths&&r.getServerOrigin&&e.getBoardId()?ht({boardPaths:r.boardPaths,getServerOrigin:r.getServerOrigin,boardId:e.getBoardId()}):null,x=bt(),M=x.init({resolve:b=>n?.modelsById[b],chartLib:globalThis.Chart??null,markdown:globalThis.marked?b=>globalThis.marked.parse(b):null,sanitize:globalThis.DOMPurify?b=>globalThis.DOMPurify.sanitize(b):null,onPatchState:(b,A)=>e.patchCardState(b,A),onRefresh:b=>e.retriggerCard(b),onAction:(b,A,$)=>e.dispatchCardAction(b,A,$).then(()=>{}),startReceivingChats:b=>{e.subscribeCardChats(b);},stopReceivingChats:b=>{e.unsubscribeCardChats(b);},fileUrlBase:C||void 0});return S.innerHTML="",o=x.Board(M,S,{initialState:n,getNodeIds:b=>b.cardIds,selectNode:(b,A)=>b.modelsById[A],mode:y,canvas:m}),o}function s(d){return h.add(d),d(n),()=>{h.delete(d);}}function g(d){y=String(d||"board");let S=o&&o.core;S&&typeof S.setMode=="function"&&S.setMode(y);}function k(){if(!o)return;y="canvas";let d=o.core;d&&typeof d.setMode=="function"&&d.setMode("canvas"),d&&typeof d.autoLayout=="function"&&d.autoLayout();}function c(d){let S=o&&o.core;S&&typeof S.setDevMode=="function"&&S.setDevMode(!!d);}function w(){i(),h.clear(),o=null;}return {mountBoard:p,subscribe:s,getState:()=>n,getFullState:()=>e.getState(),getBoardId:()=>e.getBoardId(),getClientId:()=>e.getClientId(),getSseClientId:()=>e.getSseClientId(),patchCardState:(d,S)=>e.patchCardState(d,S),retriggerCard:d=>e.retriggerCard(d),dispatchCardAction:(d,S,C)=>e.dispatchCardAction(d,S,C),uploadCardFile:(d,S,C)=>e.uploadCardFile(d,S,C),subscribeCardChats:d=>e.subscribeCardChats(d),unsubscribeCardChats:d=>e.unsubscribeCardChats(d),setMode:g,autoLayout:k,setDevMode:c,getCurrentMode:()=>y,dispose:w}}function Ne(t){let e=Ct(t),r=Q({session:e,boardPaths:t.boardPaths,getServerOrigin:t.getServerOrigin});async function m(n){let o=String(n?.boardId||"default");return await e.bootstrap({boardId:o,taskExecutorPath:n?.taskExecutorPath}),r.mountBoard({rootElement:n.rootElement,mode:n.mode})}return {bootstrapBoard:m,dispose:()=>{r.dispose(),e.dispose();},setMode:n=>r.setMode(n),autoLayout:()=>r.autoLayout(),setDevMode:n=>r.setDevMode(n),getCurrentMode:()=>r.getCurrentMode(),getState:()=>e.getState(),getRuntimeSession:()=>e,createDerivedRuntime:(n={})=>Q({session:e,...n})}}exports.applyBoardNotifications=Pe;exports.applyNotification=J;exports.buildBoardState=q;exports.buildFileUrlBase=ht;exports.createBoardRuntimeClient=Ne;exports.createBoardRuntimeSession=Ct;exports.createDerivedBoardRuntime=Q;exports.defaultBoardPaths=Ie;exports.deriveBoardState=H;exports.dispatchCardAction=St;exports.patchCardState=yt;exports.pickBoardState=De;exports.prepareActionPayload=mt;exports.retriggerCard=kt;exports.selectAllLiveCardModels=U;exports.selectLiveCardModel=E;exports.serverPayloadToBoardState=Oe;exports.singleBoardPaths=Be;exports.subtractBoardState=je;exports.uploadCardFile=Z;return exports;})({});//# sourceMappingURL=board-livecards-client.js.map
|
|
2
|
-
//# sourceMappingURL=board-livecards-client.js.map
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>Example Board Demo (Server Runtime)</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="../../browser/favicon.svg" />
|
|
8
|
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
9
|
-
<style>
|
|
10
|
-
/* Scale down markdown headings inside cards to stay in proportion with card body text */
|
|
11
|
-
.lc-result h1 { font-size: 1rem; font-weight: 700; margin: 0.5rem 0 0.25rem; }
|
|
12
|
-
.lc-result h2 { font-size: 0.9rem; font-weight: 700; margin: 0.5rem 0 0.25rem; border-bottom: 1px solid #dee2e6; padding-bottom: 0.1rem; }
|
|
13
|
-
.lc-result h3 { font-size: 0.85rem; font-weight: 600; margin: 0.4rem 0 0.2rem; }
|
|
14
|
-
.lc-result p { font-size: 0.8rem; margin: 0 0 0.25rem; }
|
|
15
|
-
.lc-result ul, .lc-result ol { font-size: 0.8rem; margin: 0 0 0.25rem; padding-left: 1.2rem; }
|
|
16
|
-
.lc-result li { margin-bottom: 0.15rem; }
|
|
17
|
-
</style>
|
|
18
|
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
19
|
-
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
20
|
-
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
21
|
-
<script src="https://cdn.jsdelivr.net/npm/leader-line/leader-line.min.js"></script>
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.7.0/browser/live-cards.js"></script>
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.7.0/browser/board-livecards-client.js"></script>
|
|
24
|
-
</head>
|
|
25
|
-
<body class="bg-light">
|
|
26
|
-
<div class="container-fluid py-3">
|
|
27
|
-
<div class="d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3">
|
|
28
|
-
<div>
|
|
29
|
-
<h1 class="h4 mb-0" id="boardTitle">Example Board (Server Runtime)</h1>
|
|
30
|
-
<div class="small text-muted" id="boardDesc"></div>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="d-flex align-items-center gap-2">
|
|
33
|
-
<select class="form-select form-select-sm" id="boardSelector" style="max-width:180px" title="Active board"></select>
|
|
34
|
-
<button class="btn btn-sm btn-outline-success" id="addBoardBtn">+ Board</button>
|
|
35
|
-
<div id="addBoardForm" class="d-flex align-items-center gap-1" style="display:none!important">
|
|
36
|
-
<input class="form-control form-control-sm" id="newBoardId" placeholder="board-id" style="max-width:110px" />
|
|
37
|
-
<input class="form-control form-control-sm" id="newBoardLabel" placeholder="Label (optional)" style="max-width:150px" />
|
|
38
|
-
<button class="btn btn-sm btn-success" id="addBoardSubmit">Add</button>
|
|
39
|
-
<button class="btn btn-sm btn-secondary" id="addBoardCancel">Cancel</button>
|
|
40
|
-
</div>
|
|
41
|
-
<button class="btn btn-sm btn-outline-primary" id="modeBoard">Board</button>
|
|
42
|
-
<button class="btn btn-sm btn-outline-primary" id="modeCanvas">Canvas</button>
|
|
43
|
-
<button class="btn btn-sm btn-outline-secondary" id="autoLayout">Auto Layout</button>
|
|
44
|
-
<button class="btn btn-sm btn-outline-dark" id="refreshAll" style="display:none">Refresh All</button>
|
|
45
|
-
<div class="form-check ms-2">
|
|
46
|
-
<input class="form-check-input" type="checkbox" id="devModeToggle" />
|
|
47
|
-
<label class="form-check-label" for="devModeToggle">Dev Mode</label>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<div class="alert alert-info small py-2 mb-3">
|
|
53
|
-
Server runtime mode: board initializes on first connect and streams updates via SSE.
|
|
54
|
-
Source execution and event processing happen on the server side.
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<div id="boardRoot">
|
|
58
|
-
<div class="d-flex align-items-center justify-content-center" style="height: 72vh;">
|
|
59
|
-
<div class="text-center">
|
|
60
|
-
<div class="spinner-border mb-3" role="status">
|
|
61
|
-
<span class="visually-hidden">Loading...</span>
|
|
62
|
-
</div>
|
|
63
|
-
<p class="text-muted">Initializing board...</p>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
|
|
69
|
-
<script>
|
|
70
|
-
(function () {
|
|
71
|
-
const createBoardRuntimeClient = window.BoardLiveCardsClient && window.BoardLiveCardsClient.createBoardRuntimeClient;
|
|
72
|
-
const defaultBoardPaths = window.BoardLiveCardsClient && window.BoardLiveCardsClient.defaultBoardPaths;
|
|
73
|
-
if (!createBoardRuntimeClient || !defaultBoardPaths) {
|
|
74
|
-
document.getElementById('boardRoot').innerHTML =
|
|
75
|
-
'<div class="alert alert-danger">board-livecards-client.js not loaded. Run <code>npm run build:browser</code> first.</div>';
|
|
76
|
-
throw new Error('BoardLiveCardsClient not loaded');
|
|
77
|
-
}
|
|
78
|
-
let currentMode = 'canvas';
|
|
79
|
-
let bootstrapCompleted = false;
|
|
80
|
-
let activeBoardId = 'live';
|
|
81
|
-
let runtimeClient = null;
|
|
82
|
-
|
|
83
|
-
function boardPaths(boardId) {
|
|
84
|
-
return defaultBoardPaths(boardId || activeBoardId || 'default');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function localServerOrigins() {
|
|
88
|
-
const params = new URLSearchParams(window.location.search || '');
|
|
89
|
-
const fromQuery = params.get('demoServerOrigin');
|
|
90
|
-
const fromWindow = window.DEMO_SERVER_ORIGIN;
|
|
91
|
-
const hostPref = window.location.hostname === 'localhost' ? 'localhost' : '127.0.0.1';
|
|
92
|
-
const hostAlt = hostPref === 'localhost' ? '127.0.0.1' : 'localhost';
|
|
93
|
-
const defaults = [
|
|
94
|
-
`http://${hostPref}:7799`,
|
|
95
|
-
`http://${hostAlt}:7799`,
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
const unique = [];
|
|
99
|
-
const push = (v) => {
|
|
100
|
-
if (!v || typeof v !== 'string') return;
|
|
101
|
-
if (unique.includes(v)) return;
|
|
102
|
-
unique.push(v);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
push(fromWindow);
|
|
106
|
-
push(fromQuery);
|
|
107
|
-
defaults.forEach(push);
|
|
108
|
-
return unique;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
let activeServerOrigin = null;
|
|
112
|
-
|
|
113
|
-
async function fetchServer(path, init) {
|
|
114
|
-
const origins = activeServerOrigin ? [activeServerOrigin] : localServerOrigins();
|
|
115
|
-
const failures = [];
|
|
116
|
-
|
|
117
|
-
for (const origin of origins) {
|
|
118
|
-
const url = `${origin}${path}`;
|
|
119
|
-
try {
|
|
120
|
-
const res = await fetch(url, init);
|
|
121
|
-
activeServerOrigin = origin;
|
|
122
|
-
return res;
|
|
123
|
-
} catch (err) {
|
|
124
|
-
failures.push(`${url} -> ${String(err && err.message || err)}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const tip = 'Start the server from the yaml-flow folder: node public-examples/board/server/board-server.js';
|
|
129
|
-
throw new Error(`Unable to reach example-board demo server. Tried: ${failures.join(' | ')}. ${tip}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
runtimeClient = createBoardRuntimeClient({
|
|
133
|
-
fetchServer,
|
|
134
|
-
boardPaths,
|
|
135
|
-
getServerOrigin: function () { return activeServerOrigin; },
|
|
136
|
-
initialMode: currentMode,
|
|
137
|
-
canvas: { height: '72vh', overflow: 'auto' },
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
async function loadBoardList() {
|
|
141
|
-
try {
|
|
142
|
-
const res = await fetchServer('/api/boards');
|
|
143
|
-
if (!res.ok) return;
|
|
144
|
-
const data = await res.json();
|
|
145
|
-
const boards = Array.isArray(data && data.boards) ? data.boards : [];
|
|
146
|
-
const sel = document.getElementById('boardSelector');
|
|
147
|
-
const prev = sel.value;
|
|
148
|
-
sel.innerHTML = boards.map((b) =>
|
|
149
|
-
`<option value="${b.id}"${b.id === (prev || activeBoardId) ? ' selected' : ''}>${b.label || b.id}</option>`
|
|
150
|
-
).join('');
|
|
151
|
-
if (boards.length && !boards.some((b) => b.id === activeBoardId)) {
|
|
152
|
-
activeBoardId = boards[0].id;
|
|
153
|
-
sel.value = activeBoardId;
|
|
154
|
-
}
|
|
155
|
-
} catch (err) {
|
|
156
|
-
console.warn('Could not load board list', err);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async function switchBoard(boardId) {
|
|
161
|
-
if (boardId === activeBoardId && bootstrapCompleted) return;
|
|
162
|
-
runtimeClient.dispose();
|
|
163
|
-
bootstrapCompleted = false;
|
|
164
|
-
activeBoardId = boardId;
|
|
165
|
-
document.getElementById('boardRoot').innerHTML =
|
|
166
|
-
'<div class="d-flex align-items-center justify-content-center" style="height:72vh">'
|
|
167
|
-
+ '<div class="text-center"><div class="spinner-border mb-3" role="status">'
|
|
168
|
-
+ '<span class="visually-hidden">Loading...</span></div>'
|
|
169
|
-
+ '<p class="text-muted">Loading board...</p></div></div>';
|
|
170
|
-
await bootstrap(boardId);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async function bootstrap(boardId) {
|
|
174
|
-
const bid = boardId || activeBoardId || 'default';
|
|
175
|
-
|
|
176
|
-
// Board title from registry label or fallback
|
|
177
|
-
document.getElementById('boardTitle').textContent = bid + ' (Server Runtime)';
|
|
178
|
-
document.getElementById('boardDesc').textContent = '';
|
|
179
|
-
|
|
180
|
-
// SSE-first bootstrap: init-board initializes the board server-side,
|
|
181
|
-
// then /sse sends the full payload as the first frame. No separate
|
|
182
|
-
// demo-setup step needed — the server runs it automatically at init time.
|
|
183
|
-
await runtimeClient.bootstrapBoard({
|
|
184
|
-
boardId: bid,
|
|
185
|
-
rootElement: document.getElementById('boardRoot'),
|
|
186
|
-
mode: currentMode,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
bootstrapCompleted = true;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
document.getElementById('modeBoard').addEventListener('click', function () {
|
|
193
|
-
currentMode = 'board';
|
|
194
|
-
runtimeClient.setMode('board');
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
document.getElementById('modeCanvas').addEventListener('click', function () {
|
|
198
|
-
currentMode = 'canvas';
|
|
199
|
-
runtimeClient.setMode('canvas');
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
document.getElementById('autoLayout').addEventListener('click', function () {
|
|
203
|
-
currentMode = 'canvas';
|
|
204
|
-
runtimeClient.autoLayout();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
document.getElementById('devModeToggle').addEventListener('change', function () {
|
|
208
|
-
runtimeClient.setDevMode(this.checked);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
document.getElementById('boardSelector').addEventListener('change', function () {
|
|
212
|
-
switchBoard(this.value).catch(function (err) {
|
|
213
|
-
console.error(err);
|
|
214
|
-
document.getElementById('boardRoot').innerHTML =
|
|
215
|
-
`<div class="alert alert-danger">Failed to switch board: ${String(err && err.message || err)}</div>`;
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
document.getElementById('addBoardBtn').addEventListener('click', function () {
|
|
220
|
-
document.getElementById('addBoardForm').style.removeProperty('display');
|
|
221
|
-
document.getElementById('newBoardId').focus();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
document.getElementById('addBoardCancel').addEventListener('click', function () {
|
|
225
|
-
document.getElementById('addBoardForm').style.display = 'none';
|
|
226
|
-
document.getElementById('newBoardId').value = '';
|
|
227
|
-
document.getElementById('newBoardLabel').value = '';
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
document.getElementById('addBoardSubmit').addEventListener('click', async function () {
|
|
231
|
-
const id = document.getElementById('newBoardId').value.trim();
|
|
232
|
-
const label = document.getElementById('newBoardLabel').value.trim();
|
|
233
|
-
if (!id) {
|
|
234
|
-
alert('Board id is required');
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
try {
|
|
238
|
-
const res = await fetchServer('/api/boards', {
|
|
239
|
-
method: 'POST',
|
|
240
|
-
headers: { 'content-type': 'application/json' },
|
|
241
|
-
body: JSON.stringify({ id, label: label || id }),
|
|
242
|
-
});
|
|
243
|
-
const data = await res.json();
|
|
244
|
-
if (!res.ok) {
|
|
245
|
-
alert(data.error || 'Failed to add board');
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
document.getElementById('addBoardForm').style.display = 'none';
|
|
249
|
-
document.getElementById('newBoardId').value = '';
|
|
250
|
-
document.getElementById('newBoardLabel').value = '';
|
|
251
|
-
await loadBoardList();
|
|
252
|
-
await switchBoard(id);
|
|
253
|
-
} catch (err) {
|
|
254
|
-
alert('Error adding board: ' + String((err && err.message) || err));
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
loadBoardList().then(function () {
|
|
259
|
-
return bootstrap(activeBoardId);
|
|
260
|
-
}).catch(function (err) {
|
|
261
|
-
console.error(err);
|
|
262
|
-
document.getElementById('boardRoot').innerHTML =
|
|
263
|
-
`<div class="alert alert-danger">Failed to start server runtime demo: ${String(err && err.message || err)}</div>`;
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
window.addEventListener('beforeunload', function () {
|
|
267
|
-
runtimeClient.dispose();
|
|
268
|
-
});
|
|
269
|
-
})();
|
|
270
|
-
</script>
|
|
271
|
-
</body>
|
|
272
|
-
</html>
|