yaml-flow 8.1.1 → 8.2.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/asset-integrity.json +3 -3
- package/browser/board-livecards-localstorage.js +5 -5
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
- package/cli/node/board-live-cards-cli.js +6 -6
- package/cli/node/card-store-cli.js +4 -4
- package/cli/node/fs-board-adapter.d.ts +2 -2
- package/cli/node/fs-board-adapter.js +7 -7
- package/cli/node/step-machine-cli.js +3 -3
- package/cli/{types-D2XnLbBj.d.ts → types-CSiGbY__.d.ts} +1 -1
- package/examples/board/demo-chat-copilot.flow.json +38 -0
- package/examples/board/{demo-chat-handler.js → demo-chat-copilot.js} +55 -39
- package/examples/board/demo-chat-echo.flow.json +38 -0
- package/examples/board/demo-chat-echo.js +92 -0
- package/examples/board/demo-server-config.copilot-chat.json +10 -0
- package/examples/board/demo-server-config.json +2 -2
- package/examples/board/demo-server.js +57 -8
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/test/demo-http-test.js +45 -0
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/{artifacts-store-lib-public-BWC3YuLa.d.ts → artifacts-store-lib-public-BPW_C15z.d.ts} +1 -1
- package/lib/{artifacts-store-lib-public-DBICnGL6.d.cts → artifacts-store-lib-public-DfU9t5-S.d.cts} +1 -1
- package/lib/artifacts-store-public.d.cts +2 -2
- package/lib/artifacts-store-public.d.ts +2 -2
- package/lib/board-live-cards-node.cjs +7 -7
- package/lib/board-live-cards-node.d.cts +5 -5
- package/lib/board-live-cards-node.d.ts +5 -5
- package/lib/board-live-cards-node.js +7 -7
- package/lib/{board-live-cards-public-dJAl5IL-.d.ts → board-live-cards-public-B8b_0k_j.d.ts} +1 -1
- package/lib/{board-live-cards-public-BF9FP0mL.d.cts → board-live-cards-public-W2zK59m0.d.cts} +1 -1
- package/lib/board-live-cards-public.cjs +2 -2
- package/lib/board-live-cards-public.d.cts +1 -1
- package/lib/board-live-cards-public.d.ts +1 -1
- package/lib/board-live-cards-public.js +2 -2
- package/lib/board-live-cards-server-runtime.cjs +5 -5
- package/lib/board-live-cards-server-runtime.d.cts +2 -2
- package/lib/board-live-cards-server-runtime.d.ts +2 -2
- package/lib/board-live-cards-server-runtime.js +5 -5
- package/lib/card-store-public.d.cts +1 -1
- package/lib/card-store-public.d.ts +1 -1
- package/lib/server-runtime/index.cjs +5 -5
- package/lib/server-runtime/index.d.cts +3 -3
- package/lib/server-runtime/index.d.ts +3 -3
- package/lib/server-runtime/index.js +5 -5
- package/lib/step-machine-public/index.cjs +3 -3
- package/lib/step-machine-public/index.d.cts +26 -9
- package/lib/step-machine-public/index.d.ts +26 -9
- package/lib/step-machine-public/index.js +3 -3
- package/lib/{types-D48hpnTR.d.ts → types-Bm7IFD7r.d.ts} +22 -2
- package/lib/{types-CXBzvC0s.d.cts → types-seTI8zta.d.cts} +22 -2
- package/package.json +1 -1
|
@@ -16,9 +16,13 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
createFsBoardPlatformAdapter,
|
|
18
18
|
createArtifactsStore,
|
|
19
|
+
invokeRefSync,
|
|
19
20
|
parseRef,
|
|
20
21
|
serializeRef,
|
|
21
22
|
} from 'yaml-flow/board-live-cards-node';
|
|
23
|
+
import {
|
|
24
|
+
createStepMachineChatFlowRunner,
|
|
25
|
+
} from 'yaml-flow/step-machine-public';
|
|
22
26
|
|
|
23
27
|
const __filename = fileURLToPath(import.meta.url);
|
|
24
28
|
const __dirname = path.dirname(__filename);
|
|
@@ -41,6 +45,40 @@ function resolveFromConfig(configValue) {
|
|
|
41
45
|
return path.resolve(__dirname, configValue);
|
|
42
46
|
}
|
|
43
47
|
|
|
48
|
+
function loadJsonFromConfig(configValue) {
|
|
49
|
+
const resolved = resolveFromConfig(configValue);
|
|
50
|
+
if (!resolved || !fs.existsSync(resolved)) return null;
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(fs.readFileSync(resolved, 'utf-8'));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function buildChatHandlerFlowFromScript(scriptPath) {
|
|
59
|
+
if (!scriptPath) return null;
|
|
60
|
+
const resolved = path.isAbsolute(scriptPath) ? scriptPath : path.resolve(__dirname, scriptPath);
|
|
61
|
+
return {
|
|
62
|
+
id: 'demo-chat-script-handler',
|
|
63
|
+
settings: { start_step: 'respond', max_total_steps: 5, timeout_ms: 120000 },
|
|
64
|
+
steps: {
|
|
65
|
+
respond: {
|
|
66
|
+
description: 'Run the example board chat responder from a script path',
|
|
67
|
+
handler: {
|
|
68
|
+
type: 'ref',
|
|
69
|
+
howToRun: 'local-node',
|
|
70
|
+
whatToRun: { kind: 'fs-path', value: resolved },
|
|
71
|
+
},
|
|
72
|
+
transitions: { success: 'completed', failure: 'failed' },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
terminal_states: {
|
|
76
|
+
completed: { description: 'Chat response completed', return_intent: 'success', return_artifacts: false },
|
|
77
|
+
failed: { description: 'Chat response failed', return_intent: 'failure', return_artifacts: false },
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
44
82
|
function resolveKindRefFromConfig(configValue) {
|
|
45
83
|
if (typeof configValue !== 'string' || !configValue.trim()) return null;
|
|
46
84
|
const trimmed = configValue.trim();
|
|
@@ -62,10 +100,12 @@ const configuredCardsDir = resolveFromConfig(serverConfig.cardsDir);
|
|
|
62
100
|
const configuredTaskExecutorPath = resolveFromConfig(serverConfig.taskExecutorPath || serverConfig.demoTaskExecutorPath);
|
|
63
101
|
const configuredStepMachineCliPath = resolveFromConfig(serverConfig.stepMachineCliPath);
|
|
64
102
|
const configuredChatHandlerPath = resolveFromConfig(serverConfig.chatHandlerPath);
|
|
103
|
+
const configuredChatHandlerFlow = loadJsonFromConfig(serverConfig.chatHandlerFlowPath) || buildChatHandlerFlowFromScript(configuredChatHandlerPath);
|
|
65
104
|
const configuredInferenceAdapterPath = resolveFromConfig(serverConfig.inferenceAdapterPath);
|
|
66
105
|
const configuredGandalfCardsDir = resolveFromConfig(serverConfig.gandalfCardsDir);
|
|
67
106
|
const configuredGandalfTaskExecutorPath = resolveFromConfig(serverConfig.gandalfTaskExecutorPath);
|
|
68
107
|
const configuredGandalfChatHandlerPath = resolveFromConfig(serverConfig.gandalfChatHandlerPath);
|
|
108
|
+
const configuredGandalfChatHandlerFlow = loadJsonFromConfig(serverConfig.gandalfChatHandlerFlowPath) || buildChatHandlerFlowFromScript(configuredGandalfChatHandlerPath);
|
|
69
109
|
const configuredGandalfInferenceAdapterPath = resolveFromConfig(serverConfig.gandalfInferenceAdapterPath);
|
|
70
110
|
const configuredServerMetaStoreRef = resolveKindRefFromConfig(serverConfig.serverMetaStoreRef);
|
|
71
111
|
|
|
@@ -104,12 +144,12 @@ const defaultCardsDir = path.resolve(
|
|
|
104
144
|
);
|
|
105
145
|
|
|
106
146
|
const defaultTaskExecutorPath = process.env.DEMO_TASK_EXECUTOR_PATH || configuredTaskExecutorPath || null;
|
|
107
|
-
const
|
|
147
|
+
const defaultChatHandlerFlow = configuredChatHandlerFlow || buildChatHandlerFlowFromScript(process.env.DEMO_CHAT_HANDLER_PATH || configuredChatHandlerPath || null);
|
|
108
148
|
const defaultInferenceAdapterPath = process.env.DEMO_INFERENCE_ADAPTER_PATH || configuredInferenceAdapterPath || null;
|
|
109
149
|
const defaultStepMachineCliPath = process.env.DEMO_STEP_MACHINE_CLI_PATH || configuredStepMachineCliPath || null;
|
|
110
150
|
const defaultGandalfCardsDir = process.env.DEMO_GANDALF_CARDS_DIR || configuredGandalfCardsDir || null;
|
|
111
151
|
const defaultGandalfTaskExecutorPath = process.env.DEMO_GANDALF_TASK_EXECUTOR_PATH || configuredGandalfTaskExecutorPath || null;
|
|
112
|
-
const
|
|
152
|
+
const defaultGandalfChatHandlerFlow = configuredGandalfChatHandlerFlow || buildChatHandlerFlowFromScript(process.env.DEMO_GANDALF_CHAT_HANDLER_PATH || configuredGandalfChatHandlerPath || null);
|
|
113
153
|
const defaultGandalfInferenceAdapterPath = process.env.DEMO_GANDALF_INFERENCE_ADAPTER_PATH || configuredGandalfInferenceAdapterPath || null;
|
|
114
154
|
|
|
115
155
|
// ---------------------------------------------------------------------------
|
|
@@ -287,7 +327,7 @@ const logger = { info: console.log, warn: console.warn, error: console.error };
|
|
|
287
327
|
// Track per-board host config for demo-setup (FS paths are host concerns, not runtime concerns)
|
|
288
328
|
const boardHostConfig = new Map();
|
|
289
329
|
|
|
290
|
-
function buildBoardContextConfig(label, boardDir, taskExecPath,
|
|
330
|
+
function buildBoardContextConfig(label, boardDir, taskExecPath, chatHandlerFlow, infAdapterPath, boardId) {
|
|
291
331
|
fs.mkdirSync(boardDir, { recursive: true });
|
|
292
332
|
|
|
293
333
|
// Runtime card store lives inside the board's setup dir, isolated from the source cards dir.
|
|
@@ -321,7 +361,7 @@ function buildBoardContextConfig(label, boardDir, taskExecPath, chatHandlerPath,
|
|
|
321
361
|
outputsStoreRef: serializeRef({ kind: 'fs-path', value: path.join(path.dirname(boardDir), 'runtime-out', '.outputs') }),
|
|
322
362
|
notifyRef: { kind: 'named-pipe', value: namedPipePath(notifyChannel) },
|
|
323
363
|
taskExecutorRef: makeExecutionRef(taskExecPath, 'task-executor'),
|
|
324
|
-
|
|
364
|
+
chatHandlerFlow,
|
|
325
365
|
inferenceAdapterRef: makeExecutionRef(infAdapterPath, 'inference-adapter'),
|
|
326
366
|
};
|
|
327
367
|
}
|
|
@@ -335,24 +375,32 @@ const runtime = createMultiBoardServerRuntime({
|
|
|
335
375
|
const sourceCardsDir = typeof entry.cardsDir === 'string' ? path.resolve(entry.cardsDir) : defaultCardsDir;
|
|
336
376
|
const boardRoot = path.join(setupDir, `board-${boardId}`);
|
|
337
377
|
const boardDir = path.join(boardRoot, 'runtime');
|
|
378
|
+
const flowRunner = createStepMachineChatFlowRunner({
|
|
379
|
+
invokeRef: (ref, stepArgs) => invokeRefSync(ref, stepArgs, {
|
|
380
|
+
cliDir: __dirname,
|
|
381
|
+
cwd: __dirname,
|
|
382
|
+
label: 'demo-chat-flow',
|
|
383
|
+
timeoutMs: 120000,
|
|
384
|
+
}),
|
|
385
|
+
});
|
|
338
386
|
|
|
339
387
|
const taskExecPath = typeof entry.taskExecutorPath === 'string' ? entry.taskExecutorPath : defaultTaskExecutorPath;
|
|
340
|
-
const
|
|
388
|
+
const chatHandlerFlow = entry.chatHandlerFlow || loadJsonFromConfig(entry.chatHandlerFlowPath) || buildChatHandlerFlowFromScript(typeof entry.chatHandlerPath === 'string' ? entry.chatHandlerPath : null) || defaultChatHandlerFlow;
|
|
341
389
|
const infAdapterPath = typeof entry.inferenceAdapterPath === 'string' ? entry.inferenceAdapterPath : defaultInferenceAdapterPath;
|
|
342
390
|
const stepMachinePath = typeof entry.stepMachineCliPath === 'string' ? entry.stepMachineCliPath : defaultStepMachineCliPath;
|
|
343
391
|
|
|
344
392
|
const sourceGandalfCardsDir = typeof entry.gandalfCardsDir === 'string' ? path.resolve(entry.gandalfCardsDir) : defaultGandalfCardsDir;
|
|
345
393
|
const gandalfTaskExecPath = typeof entry.gandalfTaskExecutorPath === 'string' ? entry.gandalfTaskExecutorPath : defaultGandalfTaskExecutorPath;
|
|
346
|
-
const
|
|
394
|
+
const gandalfChatFlow = entry.gandalfChatHandlerFlow || loadJsonFromConfig(entry.gandalfChatHandlerFlowPath) || buildChatHandlerFlowFromScript(typeof entry.gandalfChatHandlerPath === 'string' ? entry.gandalfChatHandlerPath : null) || defaultGandalfChatHandlerFlow;
|
|
347
395
|
const gandalfInfPath = typeof entry.gandalfInferenceAdapterPath === 'string' ? entry.gandalfInferenceAdapterPath : defaultGandalfInferenceAdapterPath;
|
|
348
396
|
|
|
349
|
-
const baseCfg = buildBoardContextConfig('base', boardDir, taskExecPath,
|
|
397
|
+
const baseCfg = buildBoardContextConfig('base', boardDir, taskExecPath, chatHandlerFlow, infAdapterPath, boardId);
|
|
350
398
|
|
|
351
399
|
const boards = [baseCfg];
|
|
352
400
|
let gandalfBoardDir = null;
|
|
353
401
|
if (sourceGandalfCardsDir && gandalfTaskExecPath) {
|
|
354
402
|
gandalfBoardDir = path.join(boardRoot, 'gandalf-runtime');
|
|
355
|
-
const gandalfCfg = buildBoardContextConfig('gandalf', gandalfBoardDir, gandalfTaskExecPath,
|
|
403
|
+
const gandalfCfg = buildBoardContextConfig('gandalf', gandalfBoardDir, gandalfTaskExecPath, gandalfChatFlow, gandalfInfPath, boardId);
|
|
356
404
|
gandalfCfg.outputsStoreRef = serializeRef({ kind: 'fs-path', value: path.join(boardRoot, 'gandalf-runtime-out', '.outputs') });
|
|
357
405
|
boards.push(gandalfCfg);
|
|
358
406
|
}
|
|
@@ -372,6 +420,7 @@ const runtime = createMultiBoardServerRuntime({
|
|
|
372
420
|
boardId,
|
|
373
421
|
boards,
|
|
374
422
|
invocationAdapter,
|
|
423
|
+
chatFlowRunner: flowRunner,
|
|
375
424
|
notificationTransport,
|
|
376
425
|
logger,
|
|
377
426
|
serverUrl: `http://127.0.0.1:${PORT}`,
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
20
20
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
21
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.
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
22
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.2.0/browser/live-cards.js"></script>
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.2.0/browser/board-livecards-client.js"></script>
|
|
24
24
|
</head>
|
|
25
25
|
<body class="bg-light">
|
|
26
26
|
<div class="container-fluid py-3">
|
|
@@ -139,6 +139,36 @@ function waitUntil(predicate, timeoutMs, label) {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
function waitUntilAsync(predicate, timeoutMs, label) {
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
const deadline = Date.now() + timeoutMs;
|
|
145
|
+
let inFlight = false;
|
|
146
|
+
const interval = setInterval(async () => {
|
|
147
|
+
if (inFlight) return;
|
|
148
|
+
inFlight = true;
|
|
149
|
+
try {
|
|
150
|
+
const result = await predicate();
|
|
151
|
+
if (result !== undefined && result !== null && result !== false) {
|
|
152
|
+
clearInterval(interval);
|
|
153
|
+
resolve(result);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (Date.now() > deadline) {
|
|
157
|
+
clearInterval(interval);
|
|
158
|
+
reject(new Error(`Timeout (${timeoutMs}ms) waiting for: ${label}`));
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
if (Date.now() > deadline) {
|
|
162
|
+
clearInterval(interval);
|
|
163
|
+
reject(new Error(`Timeout (${timeoutMs}ms) waiting for: ${label}`));
|
|
164
|
+
}
|
|
165
|
+
} finally {
|
|
166
|
+
inFlight = false;
|
|
167
|
+
}
|
|
168
|
+
}, 150);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
142
172
|
const waitForInitialPayload = (ms = 15_000) =>
|
|
143
173
|
waitUntil(() => NS.initialPayload || false, ms, 'initial SSE payload');
|
|
144
174
|
|
|
@@ -256,6 +286,21 @@ try {
|
|
|
256
286
|
assert(httpSummary, 'statusSnapshot.summary missing from board-status');
|
|
257
287
|
console.log(`[step4] board-status summary: ${JSON.stringify(httpSummary)}`);
|
|
258
288
|
|
|
289
|
+
console.log('\n=== Step 5: echo chat flow ===');
|
|
290
|
+
const chatCardId = initialPayload.cardDefinitions[0].id;
|
|
291
|
+
const sendChatRes = await httpJson('POST', `${BASE}/cards/${encodeURIComponent(chatCardId)}/actions`, {
|
|
292
|
+
actionType: 'chat-send',
|
|
293
|
+
payload: { text: 'hello echo test' },
|
|
294
|
+
});
|
|
295
|
+
assert(sendChatRes.status === 200, `chat-send returned ${sendChatRes.status}`);
|
|
296
|
+
const chats = await waitUntilAsync(async () => {
|
|
297
|
+
const chatsRes = await httpGet(`${BASE}/cards/${encodeURIComponent(chatCardId)}/chats`);
|
|
298
|
+
const messages = chatsRes.data && Array.isArray(chatsRes.data.messages) ? chatsRes.data.messages : [];
|
|
299
|
+
return messages.some((m) => typeof m.text === 'string' && m.text.includes('Echo: hello echo test')) ? messages : false;
|
|
300
|
+
}, 10_000, 'echo chat response');
|
|
301
|
+
assert(chats.some((m) => typeof m.text === 'string' && m.text.includes('Echo: hello echo test')), 'echo chat response missing');
|
|
302
|
+
console.log('[step5] echo chat response received');
|
|
303
|
+
|
|
259
304
|
// ── T1: PATCH holdings (+1 row) and verify recomputation ──
|
|
260
305
|
console.log('\n=== T1: patch holdings (+1 row) ===');
|
|
261
306
|
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>Example Board Demo (LocalStorage Runtime)</title>
|
|
7
7
|
<link rel="icon" type="image/svg+xml" href="../../browser/favicon.svg" />
|
|
8
8
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
9
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
9
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.2.0/browser/compute-jsonata.js"></script>
|
|
10
10
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
12
12
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
13
13
|
<script src="https://cdn.jsdelivr.net/npm/leader-line/leader-line.min.js"></script>
|
|
14
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.2.0/browser/live-cards.js"></script>
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.2.0/browser/board-livecards-localstorage.js"></script>
|
|
16
16
|
</head>
|
|
17
17
|
<body class="bg-light">
|
|
18
18
|
<div class="container-fluid py-3">
|
package/lib/{artifacts-store-lib-public-DBICnGL6.d.cts → artifacts-store-lib-public-DfU9t5-S.d.cts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommandInput, a as CommandResult } from './board-live-cards-public-
|
|
1
|
+
import { C as CommandInput, a as CommandResult } from './board-live-cards-public-W2zK59m0.cjs';
|
|
2
2
|
import { B as BlobStorage } from './storage-interface-BhAON-gW.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './board-live-cards-public-
|
|
2
|
-
export { A as ArtifactsStorePublic, a as createArtifactsStorePublic } from './artifacts-store-lib-public-
|
|
1
|
+
import './board-live-cards-public-W2zK59m0.cjs';
|
|
2
|
+
export { A as ArtifactsStorePublic, a as createArtifactsStorePublic } from './artifacts-store-lib-public-DfU9t5-S.cjs';
|
|
3
3
|
import './storage-interface-BhAON-gW.cjs';
|
|
4
4
|
import './execution-refs.cjs';
|
|
5
5
|
import './types-BBhqYGhE.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './board-live-cards-public-
|
|
2
|
-
export { A as ArtifactsStorePublic, a as createArtifactsStorePublic } from './artifacts-store-lib-public-
|
|
1
|
+
import './board-live-cards-public-B8b_0k_j.js';
|
|
2
|
+
export { A as ArtifactsStorePublic, a as createArtifactsStorePublic } from './artifacts-store-lib-public-BPW_C15z.js';
|
|
3
3
|
import './storage-interface-BhAON-gW.js';
|
|
4
4
|
import './execution-refs.js';
|
|
5
5
|
import './types-BBhqYGhE.js';
|