yaml-flow 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -20
- package/board-live-cards-cli.js +37 -0
- package/browser/card-compute.js +132 -431
- package/browser/live-cards.js +41 -27
- package/browser/live-cards.schema.json +59 -77
- package/dist/card-compute/index.cjs +135 -415
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +52 -49
- package/dist/card-compute/index.d.ts +52 -49
- package/dist/card-compute/index.js +134 -415
- package/dist/card-compute/index.js.map +1 -1
- package/dist/cli/board-live-cards-cli.cjs +2379 -0
- package/dist/cli/board-live-cards-cli.cjs.map +1 -0
- package/dist/cli/board-live-cards-cli.d.cts +213 -0
- package/dist/cli/board-live-cards-cli.d.ts +213 -0
- package/dist/cli/board-live-cards-cli.js +2332 -0
- package/dist/cli/board-live-cards-cli.js.map +1 -0
- package/dist/{constants-B2zqu10b.d.ts → constants-DuzE5n03.d.ts} +2 -2
- package/dist/{constants-DJZU1pwJ.d.cts → constants-ozjf1Ejw.d.cts} +2 -2
- package/dist/continuous-event-graph/index.cjs +201 -448
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +16 -340
- package/dist/continuous-event-graph/index.d.ts +16 -340
- package/dist/continuous-event-graph/index.js +198 -448
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/event-graph/index.cjs +4 -4
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.d.cts +5 -5
- package/dist/event-graph/index.d.ts +5 -5
- package/dist/event-graph/index.js +4 -4
- package/dist/event-graph/index.js.map +1 -1
- package/dist/index.cjs +278 -533
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +278 -533
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +138 -19
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.d.cts +2 -2
- package/dist/inference/index.d.ts +2 -2
- package/dist/inference/index.js +138 -19
- package/dist/inference/index.js.map +1 -1
- package/dist/journal-BJDjWb5Q.d.cts +343 -0
- package/dist/journal-B_2JnBMF.d.ts +343 -0
- package/dist/step-machine/index.cjs +18 -1
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.d.cts +2 -2
- package/dist/step-machine/index.d.ts +2 -2
- package/dist/step-machine/index.js +18 -1
- package/dist/step-machine/index.js.map +1 -1
- package/dist/stores/file.d.cts +1 -1
- package/dist/stores/file.d.ts +1 -1
- package/dist/stores/index.d.cts +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/localStorage.d.cts +1 -1
- package/dist/stores/localStorage.d.ts +1 -1
- package/dist/stores/memory.d.cts +1 -1
- package/dist/stores/memory.d.ts +1 -1
- package/dist/{types-BwvgvlOO.d.cts → types-BzLD8bjb.d.cts} +1 -1
- package/dist/{types-ClRA8hzC.d.ts → types-C2eJ7DAV.d.ts} +1 -1
- package/dist/{types-DEj7OakX.d.cts → types-CMFSIjpc.d.cts} +39 -4
- package/dist/{types-DEj7OakX.d.ts → types-CMFSIjpc.d.ts} +39 -4
- package/dist/{types-FZ_eyErS.d.cts → types-ycun84cq.d.cts} +1 -0
- package/dist/{types-FZ_eyErS.d.ts → types-ycun84cq.d.ts} +1 -0
- package/dist/{validate-DEZ2Ymdb.d.ts → validate-DJQTQ6bP.d.ts} +1 -1
- package/dist/{validate-DqKTZg_o.d.cts → validate-ke92Cleg.d.cts} +1 -1
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +16 -0
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/browser/boards/portfolio-tracker/fetch-prices.js +43 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +7 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +189 -0
- package/examples/browser/livecards-browser/index.html +688 -0
- package/examples/browser/step-machine-browser/index.html +367 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
- package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +36 -0
- package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +30 -0
- package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +19 -0
- package/examples/cli/step-machine-demo/step-cli-echo-y.js +15 -0
- package/examples/cli/step-machine-demo/step2-double-cli.js +39 -0
- package/examples/cli/step-machine-demo/two-step-math-handlers.js +32 -0
- package/examples/cli/step-machine-demo/two-step-math.flow.yaml +31 -0
- package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +24 -0
- package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +35 -0
- package/examples/index.html +792 -0
- package/examples/ingest.js +733 -0
- package/examples/npm-libs/batch/batch-step-machine.ts +121 -0
- package/examples/npm-libs/continuous-event-graph/live-cards-board.ts +215 -0
- package/examples/npm-libs/continuous-event-graph/live-portfolio-dashboard.ts +555 -0
- package/examples/npm-libs/continuous-event-graph/portfolio-tracker.ts +287 -0
- package/examples/npm-libs/continuous-event-graph/reactive-monitoring.ts +265 -0
- package/examples/npm-libs/continuous-event-graph/reactive-pipeline.ts +168 -0
- package/examples/npm-libs/continuous-event-graph/soc-incident-board.ts +287 -0
- package/examples/npm-libs/continuous-event-graph/stock-dashboard.ts +229 -0
- package/examples/npm-libs/event-graph/ci-cd-pipeline.ts +243 -0
- package/examples/npm-libs/event-graph/executor-diamond.ts +165 -0
- package/examples/npm-libs/event-graph/executor-pipeline.ts +161 -0
- package/examples/npm-libs/event-graph/research-pipeline.ts +137 -0
- package/examples/npm-libs/flows/ai-conversation.yaml +116 -0
- package/examples/npm-libs/flows/order-processing.yaml +143 -0
- package/examples/npm-libs/flows/simple-greeting.yaml +54 -0
- package/examples/npm-libs/graph-of-graphs/multi-stage-etl.ts +307 -0
- package/examples/npm-libs/graph-of-graphs/url-processing-pipeline.ts +254 -0
- package/examples/npm-libs/inference/azure-deployment.ts +149 -0
- package/examples/npm-libs/inference/copilot-cli.ts +138 -0
- package/examples/npm-libs/inference/data-pipeline.ts +145 -0
- package/examples/npm-libs/inference/pluggable-adapters.ts +254 -0
- package/examples/npm-libs/node/ai-conversation.ts +195 -0
- package/examples/npm-libs/node/simple-greeting.ts +101 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/holdings-table.json +22 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-form.json +43 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/portfolio-value.json +15 -0
- package/examples/step-machine-cli/portfolio-tracker/cards/price-fetch.json +15 -0
- package/examples/step-machine-cli/portfolio-tracker/fetch-prices.js +48 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +58 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +27 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +25 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +29 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +27 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/status-cli.js +25 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +37 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +53 -0
- package/examples/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +35 -0
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +227 -0
- package/examples/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +38 -0
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +29 -0
- package/package.json +14 -2
- package/schema/board-status.schema.json +118 -0
- package/schema/flow.schema.json +5 -0
- package/schema/live-cards.schema.json +59 -77
- package/step-machine-cli.js +674 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
const repoRoot = path.resolve(__dirname, '..', '..', '..', '..');
|
|
8
|
+
const boardCliPath = path.join(repoRoot, 'board-live-cards-cli.js');
|
|
9
|
+
|
|
10
|
+
export function runBoardCli(args, options = {}) {
|
|
11
|
+
const { capture = false, cwd = process.cwd() } = options;
|
|
12
|
+
const result = spawnSync(process.execPath, [boardCliPath, ...args], {
|
|
13
|
+
cwd,
|
|
14
|
+
encoding: 'utf-8',
|
|
15
|
+
windowsHide: true,
|
|
16
|
+
stdio: capture ? 'pipe' : 'pipe',
|
|
17
|
+
env: {
|
|
18
|
+
...process.env,
|
|
19
|
+
BOARD_LIVE_CARDS_NO_SPAWN: process.env.BOARD_LIVE_CARDS_NO_SPAWN ?? '1',
|
|
20
|
+
BOARD_DIR: process.env.BOARD_DIR ?? '',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (result.error) {
|
|
25
|
+
throw new Error(`Failed to launch board-live-cards-cli: ${result.error.message}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ((result.status ?? 1) !== 0) {
|
|
29
|
+
const stderr = (result.stderr ?? '').trim();
|
|
30
|
+
const stdout = (result.stdout ?? '').trim();
|
|
31
|
+
throw new Error(`board-live-cards-cli failed (${result.status}): ${stderr || stdout || 'no output'}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return capture ? (result.stdout ?? '') : '';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function readStdinJson() {
|
|
38
|
+
let raw = '';
|
|
39
|
+
process.stdin.setEncoding('utf-8');
|
|
40
|
+
|
|
41
|
+
for await (const chunk of process.stdin) {
|
|
42
|
+
raw += chunk;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!raw.trim()) {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return JSON.parse(raw);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function writeResult(payload) {
|
|
53
|
+
process.stdout.write(JSON.stringify(payload));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function writeFailure(message) {
|
|
57
|
+
writeResult({ result: 'failure', error: message });
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const input = await readStdinJson();
|
|
7
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
8
|
+
const cardsGlob = String(input.CARDS_GLOB ?? '').trim();
|
|
9
|
+
|
|
10
|
+
if (!boardDir || !cardsGlob) {
|
|
11
|
+
writeFailure('BOARD_DIR and CARDS_GLOB are required');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
runBoardCli(['add-cards', '--rg', boardDir, '--card-glob', cardsGlob]);
|
|
16
|
+
|
|
17
|
+
writeResult({
|
|
18
|
+
result: 'success',
|
|
19
|
+
data: {
|
|
20
|
+
board_dir: boardDir,
|
|
21
|
+
cards_glob: cardsGlob,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26
|
+
writeFailure(message);
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const input = await readStdinJson();
|
|
7
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
8
|
+
|
|
9
|
+
if (!boardDir) {
|
|
10
|
+
writeFailure('BOARD_DIR is required');
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
runBoardCli(['init', boardDir]);
|
|
15
|
+
writeResult({
|
|
16
|
+
result: 'success',
|
|
17
|
+
data: {
|
|
18
|
+
board_dir: boardDir,
|
|
19
|
+
message: `initialized ${boardDir}`,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
+
writeFailure(message);
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { readStdinJson, writeFailure, writeResult } from './_board-cli.js';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const input = await readStdinJson();
|
|
9
|
+
const boardDirInput = String(input.BOARD_DIR ?? '').trim();
|
|
10
|
+
|
|
11
|
+
if (!boardDirInput) {
|
|
12
|
+
writeFailure('BOARD_DIR is required');
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const boardDir = path.resolve(boardDirInput);
|
|
17
|
+
fs.rmSync(boardDir, { recursive: true, force: true });
|
|
18
|
+
|
|
19
|
+
writeResult({
|
|
20
|
+
result: 'success',
|
|
21
|
+
data: {
|
|
22
|
+
board_dir: boardDir,
|
|
23
|
+
reset: true,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
+
writeFailure(message);
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const input = await readStdinJson();
|
|
7
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
8
|
+
const task = String(input.TASK ?? '').trim();
|
|
9
|
+
|
|
10
|
+
if (!boardDir || !task) {
|
|
11
|
+
writeFailure('BOARD_DIR and TASK are required');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
runBoardCli(['retrigger', '--rg', boardDir, '--task', task]);
|
|
16
|
+
|
|
17
|
+
writeResult({
|
|
18
|
+
result: 'success',
|
|
19
|
+
data: {
|
|
20
|
+
task,
|
|
21
|
+
retriggered: true,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26
|
+
writeFailure(message);
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const input = await readStdinJson();
|
|
7
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
8
|
+
|
|
9
|
+
if (!boardDir) {
|
|
10
|
+
writeFailure('BOARD_DIR is required');
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const status = runBoardCli(['status', '--rg', boardDir], { capture: true });
|
|
15
|
+
|
|
16
|
+
writeResult({
|
|
17
|
+
result: 'success',
|
|
18
|
+
data: {
|
|
19
|
+
status,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
+
writeFailure(message);
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const input = await readStdinJson();
|
|
9
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
10
|
+
const cardsDir = String(input.CARDS_DIR ?? '').trim();
|
|
11
|
+
const holdings = input.HOLDINGS;
|
|
12
|
+
|
|
13
|
+
if (!boardDir || !cardsDir || !Array.isArray(holdings)) {
|
|
14
|
+
writeFailure('BOARD_DIR, CARDS_DIR and HOLDINGS array are required');
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cardPath = path.join(cardsDir, 'portfolio-form.json');
|
|
19
|
+
const raw = fs.readFileSync(cardPath, 'utf-8');
|
|
20
|
+
const card = JSON.parse(raw);
|
|
21
|
+
card.state = card.state ?? {};
|
|
22
|
+
card.state.holdings = holdings;
|
|
23
|
+
fs.writeFileSync(cardPath, `${JSON.stringify(card, null, 2)}\n`, 'utf-8');
|
|
24
|
+
|
|
25
|
+
runBoardCli(['update-card', '--rg', boardDir, '--card-id', 'portfolio-form', '--restart']);
|
|
26
|
+
|
|
27
|
+
writeResult({
|
|
28
|
+
result: 'success',
|
|
29
|
+
data: {
|
|
30
|
+
saved: true,
|
|
31
|
+
holdings_count: holdings.length,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
writeFailure(message);
|
|
37
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readStdinJson, runBoardCli, writeFailure, writeResult } from './_board-cli.js';
|
|
4
|
+
|
|
5
|
+
function sleep(ms) {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const input = await readStdinJson();
|
|
11
|
+
const boardDir = String(input.BOARD_DIR ?? '').trim();
|
|
12
|
+
const tasks = Array.isArray(input.COMPLETION_TASKS) ? input.COMPLETION_TASKS : [];
|
|
13
|
+
const label = String(input.LABEL ?? 'WAIT');
|
|
14
|
+
const timeoutMs = Number(input.TIMEOUT_MS ?? 30000);
|
|
15
|
+
const pollMs = Number(input.POLL_MS ?? 500);
|
|
16
|
+
|
|
17
|
+
if (!boardDir || tasks.length === 0) {
|
|
18
|
+
writeFailure('BOARD_DIR and COMPLETION_TASKS are required');
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const started = Date.now();
|
|
23
|
+
|
|
24
|
+
while (Date.now() - started < timeoutMs) {
|
|
25
|
+
const status = runBoardCli(['status', '--rg', boardDir], { capture: true });
|
|
26
|
+
const complete = tasks.every((task) => new RegExp(`\\bcompleted\\s+${task}\\b`).test(status));
|
|
27
|
+
|
|
28
|
+
if (complete) {
|
|
29
|
+
writeResult({
|
|
30
|
+
result: 'success',
|
|
31
|
+
data: {
|
|
32
|
+
label,
|
|
33
|
+
completed: true,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await sleep(pollMs);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
writeResult({
|
|
43
|
+
result: 'timeout',
|
|
44
|
+
data: {
|
|
45
|
+
label,
|
|
46
|
+
completed: false,
|
|
47
|
+
error: `${label}: timed out waiting for completion`,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
writeFailure(message);
|
|
53
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { readStdinJson, writeFailure, writeResult } from './_board-cli.js';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const input = await readStdinJson();
|
|
9
|
+
const boardDirInput = String(input.BOARD_DIR ?? '').trim();
|
|
10
|
+
const tmpFileName = String(input.TMP_FILE_NAME ?? '').trim() || 'tmp_file1';
|
|
11
|
+
const prices = input.PRICES;
|
|
12
|
+
|
|
13
|
+
if (!boardDirInput || !prices || typeof prices !== 'object' || Array.isArray(prices)) {
|
|
14
|
+
writeFailure('BOARD_DIR and PRICES object are required');
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const boardDir = path.resolve(boardDirInput);
|
|
19
|
+
const payload = JSON.stringify(prices);
|
|
20
|
+
const tmpFile = path.join(boardDir, tmpFileName);
|
|
21
|
+
|
|
22
|
+
fs.mkdirSync(path.dirname(tmpFile), { recursive: true });
|
|
23
|
+
fs.writeFileSync(tmpFile, payload, 'utf-8');
|
|
24
|
+
|
|
25
|
+
writeResult({
|
|
26
|
+
result: 'success',
|
|
27
|
+
data: {
|
|
28
|
+
wrote: true,
|
|
29
|
+
tmp_file: tmpFile,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
writeFailure(message);
|
|
35
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
id: portfolio-tracker-step-machine
|
|
2
|
+
handler_vars:
|
|
3
|
+
BOARDCLI_CMD: ../../../board-live-cards-cli.js
|
|
4
|
+
TMP_FILE_NAME: tmp_file1
|
|
5
|
+
settings:
|
|
6
|
+
start_step: t0_reset_board
|
|
7
|
+
max_total_steps: 150
|
|
8
|
+
timeout_ms: 300000
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
t0_reset_board:
|
|
12
|
+
description: Reset board runtime directory for idempotent reruns
|
|
13
|
+
expects_data: [runtime_root, board_name]
|
|
14
|
+
produces_data: [board_dir]
|
|
15
|
+
handler:
|
|
16
|
+
cli: node ./handlers/reset-board-dir-cli.js
|
|
17
|
+
input-transforms:
|
|
18
|
+
BOARD_DIR: runtime_root & "/" & board_name
|
|
19
|
+
output-transforms:
|
|
20
|
+
board_dir: data.board_dir
|
|
21
|
+
transitions:
|
|
22
|
+
success: t0_init_board
|
|
23
|
+
failure_transitions:
|
|
24
|
+
failure: failed_state
|
|
25
|
+
|
|
26
|
+
t0_init_board:
|
|
27
|
+
description: Initialize board runtime directory
|
|
28
|
+
expects_data: [board_dir]
|
|
29
|
+
produces_data: [board_dir]
|
|
30
|
+
handler:
|
|
31
|
+
cli: node %%BOARDCLI_CMD%% init "%%BOARD_DIR%%"
|
|
32
|
+
result-mode: exit-code
|
|
33
|
+
input-transforms:
|
|
34
|
+
BOARD_DIR: board_dir
|
|
35
|
+
output-transforms:
|
|
36
|
+
board_dir: BOARD_DIR
|
|
37
|
+
transitions:
|
|
38
|
+
success: t0_add_cards
|
|
39
|
+
failure_transitions:
|
|
40
|
+
failure: failed_state
|
|
41
|
+
|
|
42
|
+
t0_add_cards:
|
|
43
|
+
description: Add local portfolio cards
|
|
44
|
+
expects_data: [board_dir, cards_template_dir]
|
|
45
|
+
produces_data: [cards_dir]
|
|
46
|
+
handler:
|
|
47
|
+
cli: node %%BOARDCLI_CMD%% add-cards --rg "%%BOARD_DIR%%" --card-glob "%%CARDS_GLOB%%"
|
|
48
|
+
result-mode: exit-code
|
|
49
|
+
input-transforms:
|
|
50
|
+
BOARD_DIR: board_dir
|
|
51
|
+
CARDS_GLOB: cards_template_dir & "/*.json"
|
|
52
|
+
output-transforms:
|
|
53
|
+
cards_dir: cards_template_dir
|
|
54
|
+
transitions:
|
|
55
|
+
success: t1_write_prices
|
|
56
|
+
failure_transitions:
|
|
57
|
+
failure: failed_state
|
|
58
|
+
|
|
59
|
+
t1_write_prices:
|
|
60
|
+
description: Write baseline prices
|
|
61
|
+
expects_data: [board_dir, prices_t1]
|
|
62
|
+
produces_data: [prices_written_t1]
|
|
63
|
+
handler:
|
|
64
|
+
cli: node ./handlers/write-prices-cli.js
|
|
65
|
+
input-transforms:
|
|
66
|
+
BOARD_DIR: board_dir
|
|
67
|
+
TMP_FILE_NAME: TMP_FILE_NAME
|
|
68
|
+
PRICES: prices_t1
|
|
69
|
+
output-transforms:
|
|
70
|
+
prices_written_t1: data.wrote
|
|
71
|
+
transitions:
|
|
72
|
+
success: t1_wait
|
|
73
|
+
failure_transitions:
|
|
74
|
+
failure: failed_state
|
|
75
|
+
|
|
76
|
+
t1_wait:
|
|
77
|
+
description: Wait for cards to complete after T1
|
|
78
|
+
expects_data: [board_dir, completion_tasks]
|
|
79
|
+
produces_data: [t1_done]
|
|
80
|
+
handler:
|
|
81
|
+
cli: node ./handlers/wait-completed-cli.js
|
|
82
|
+
input-transforms:
|
|
83
|
+
BOARD_DIR: board_dir
|
|
84
|
+
COMPLETION_TASKS: completion_tasks
|
|
85
|
+
LABEL: "'T1'"
|
|
86
|
+
TIMEOUT_MS: "60000"
|
|
87
|
+
POLL_MS: "500"
|
|
88
|
+
output-transforms:
|
|
89
|
+
t1_done: data.completed
|
|
90
|
+
transitions:
|
|
91
|
+
success: t2_update_holdings
|
|
92
|
+
failure_transitions:
|
|
93
|
+
timeout: failed_state
|
|
94
|
+
failure: failed_state
|
|
95
|
+
|
|
96
|
+
t2_update_holdings:
|
|
97
|
+
description: Add GOOG position to holdings
|
|
98
|
+
expects_data: [board_dir, cards_dir, holdings_t2]
|
|
99
|
+
produces_data: [t2_holdings_saved]
|
|
100
|
+
handler:
|
|
101
|
+
cli: node ./handlers/update-holdings-cli.js
|
|
102
|
+
input-transforms:
|
|
103
|
+
BOARD_DIR: board_dir
|
|
104
|
+
CARDS_DIR: cards_dir
|
|
105
|
+
HOLDINGS: holdings_t2
|
|
106
|
+
output-transforms:
|
|
107
|
+
t2_holdings_saved: data.saved
|
|
108
|
+
transitions:
|
|
109
|
+
success: t2_write_prices
|
|
110
|
+
failure_transitions:
|
|
111
|
+
failure: failed_state
|
|
112
|
+
|
|
113
|
+
t2_write_prices:
|
|
114
|
+
description: Write prices after T2 holdings update
|
|
115
|
+
expects_data: [board_dir, prices_t2]
|
|
116
|
+
produces_data: [prices_written_t2]
|
|
117
|
+
handler:
|
|
118
|
+
cli: node ./handlers/write-prices-cli.js
|
|
119
|
+
input-transforms:
|
|
120
|
+
BOARD_DIR: board_dir
|
|
121
|
+
TMP_FILE_NAME: TMP_FILE_NAME
|
|
122
|
+
PRICES: prices_t2
|
|
123
|
+
output-transforms:
|
|
124
|
+
prices_written_t2: data.wrote
|
|
125
|
+
transitions:
|
|
126
|
+
success: t2_wait
|
|
127
|
+
failure_transitions:
|
|
128
|
+
failure: failed_state
|
|
129
|
+
|
|
130
|
+
t2_wait:
|
|
131
|
+
description: Wait for cards to complete after T2
|
|
132
|
+
expects_data: [board_dir, completion_tasks]
|
|
133
|
+
produces_data: [t2_done]
|
|
134
|
+
handler:
|
|
135
|
+
cli: node ./handlers/wait-completed-cli.js
|
|
136
|
+
input-transforms:
|
|
137
|
+
BOARD_DIR: board_dir
|
|
138
|
+
COMPLETION_TASKS: completion_tasks
|
|
139
|
+
LABEL: "'T2'"
|
|
140
|
+
TIMEOUT_MS: "60000"
|
|
141
|
+
POLL_MS: "500"
|
|
142
|
+
output-transforms:
|
|
143
|
+
t2_done: data.completed
|
|
144
|
+
transitions:
|
|
145
|
+
success: t3_retrigger
|
|
146
|
+
failure_transitions:
|
|
147
|
+
timeout: failed_state
|
|
148
|
+
failure: failed_state
|
|
149
|
+
|
|
150
|
+
t3_retrigger:
|
|
151
|
+
description: Retrigger price-fetch task
|
|
152
|
+
expects_data: [board_dir, price_fetch_task]
|
|
153
|
+
produces_data: [t3_retriggered]
|
|
154
|
+
handler:
|
|
155
|
+
cli: node %%BOARDCLI_CMD%% retrigger --rg "%%BOARD_DIR%%" --task "%%TASK%%"
|
|
156
|
+
result-mode: exit-code
|
|
157
|
+
input-transforms:
|
|
158
|
+
BOARD_DIR: board_dir
|
|
159
|
+
TASK: price_fetch_task
|
|
160
|
+
output-transforms:
|
|
161
|
+
t3_retriggered: true
|
|
162
|
+
transitions:
|
|
163
|
+
success: t3_write_prices
|
|
164
|
+
failure_transitions:
|
|
165
|
+
failure: failed_state
|
|
166
|
+
|
|
167
|
+
t3_write_prices:
|
|
168
|
+
description: Write final refreshed prices
|
|
169
|
+
expects_data: [board_dir, prices_t3]
|
|
170
|
+
produces_data: [prices_written_t3]
|
|
171
|
+
handler:
|
|
172
|
+
cli: node ./handlers/write-prices-cli.js
|
|
173
|
+
input-transforms:
|
|
174
|
+
BOARD_DIR: board_dir
|
|
175
|
+
TMP_FILE_NAME: TMP_FILE_NAME
|
|
176
|
+
PRICES: prices_t3
|
|
177
|
+
output-transforms:
|
|
178
|
+
prices_written_t3: data.wrote
|
|
179
|
+
transitions:
|
|
180
|
+
success: t3_wait
|
|
181
|
+
failure_transitions:
|
|
182
|
+
failure: failed_state
|
|
183
|
+
|
|
184
|
+
t3_wait:
|
|
185
|
+
description: Wait for cards to complete after T3
|
|
186
|
+
expects_data: [board_dir, completion_tasks]
|
|
187
|
+
produces_data: [t3_done]
|
|
188
|
+
handler:
|
|
189
|
+
cli: node ./handlers/wait-completed-cli.js
|
|
190
|
+
input-transforms:
|
|
191
|
+
BOARD_DIR: board_dir
|
|
192
|
+
COMPLETION_TASKS: completion_tasks
|
|
193
|
+
LABEL: "'T3'"
|
|
194
|
+
TIMEOUT_MS: "60000"
|
|
195
|
+
POLL_MS: "500"
|
|
196
|
+
output-transforms:
|
|
197
|
+
t3_done: data.completed
|
|
198
|
+
transitions:
|
|
199
|
+
success: t4_status
|
|
200
|
+
failure_transitions:
|
|
201
|
+
timeout: failed_state
|
|
202
|
+
failure: failed_state
|
|
203
|
+
|
|
204
|
+
t4_status:
|
|
205
|
+
description: Capture final board status
|
|
206
|
+
expects_data: [board_dir]
|
|
207
|
+
produces_data: [final_status]
|
|
208
|
+
handler:
|
|
209
|
+
cli: node %%BOARDCLI_CMD%% status --rg "%%BOARD_DIR%%"
|
|
210
|
+
result-mode: exit-code
|
|
211
|
+
input-transforms:
|
|
212
|
+
BOARD_DIR: board_dir
|
|
213
|
+
output-transforms:
|
|
214
|
+
final_status: stdout
|
|
215
|
+
transitions:
|
|
216
|
+
success: success_state
|
|
217
|
+
failure_transitions:
|
|
218
|
+
failure: failed_state
|
|
219
|
+
|
|
220
|
+
terminal_states:
|
|
221
|
+
success_state:
|
|
222
|
+
return_intent: success
|
|
223
|
+
return_artifacts: [board_dir, t1_done, t2_done, t3_done, final_status]
|
|
224
|
+
|
|
225
|
+
failed_state:
|
|
226
|
+
return_intent: failure
|
|
227
|
+
return_artifacts: [error, board_dir, final_status]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtime_root": "./runtime",
|
|
3
|
+
"board_name": "portfolio-tracker-board",
|
|
4
|
+
"cards_template_dir": "./cards",
|
|
5
|
+
"completion_tasks": [
|
|
6
|
+
"portfolio-form",
|
|
7
|
+
"price-fetch",
|
|
8
|
+
"holdings-table",
|
|
9
|
+
"portfolio-value"
|
|
10
|
+
],
|
|
11
|
+
"price_fetch_task": "price-fetch",
|
|
12
|
+
"prices_t1": {
|
|
13
|
+
"AAPL": 198.5,
|
|
14
|
+
"MSFT": 425.3,
|
|
15
|
+
"GOOG": 178.9,
|
|
16
|
+
"AMZN": 192.4,
|
|
17
|
+
"TSLA": 168.75
|
|
18
|
+
},
|
|
19
|
+
"holdings_t2": [
|
|
20
|
+
{ "symbol": "AAPL", "qty": 50 },
|
|
21
|
+
{ "symbol": "MSFT", "qty": 30 },
|
|
22
|
+
{ "symbol": "GOOG", "qty": 100 }
|
|
23
|
+
],
|
|
24
|
+
"prices_t2": {
|
|
25
|
+
"AAPL": 198.5,
|
|
26
|
+
"MSFT": 425.3,
|
|
27
|
+
"GOOG": 178.9,
|
|
28
|
+
"AMZN": 192.4,
|
|
29
|
+
"TSLA": 168.75
|
|
30
|
+
},
|
|
31
|
+
"prices_t3": {
|
|
32
|
+
"AAPL": 205,
|
|
33
|
+
"MSFT": 425.3,
|
|
34
|
+
"GOOG": 178.9,
|
|
35
|
+
"AMZN": 192.4,
|
|
36
|
+
"TSLA": 168.75
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
cd /d "%~dp0"
|
|
4
|
+
|
|
5
|
+
set "BOARD_LIVE_CARDS_NO_SPAWN=1"
|
|
6
|
+
set "EXAMPLE_TEMP_ROOT=%TEMP%\yaml-flow-step-machine-portfolio-tracker"
|
|
7
|
+
set "STORE_DIR=%EXAMPLE_TEMP_ROOT%\store"
|
|
8
|
+
set "RUNTIME_ROOT=%EXAMPLE_TEMP_ROOT%\runtime"
|
|
9
|
+
|
|
10
|
+
if /I "%~1"=="pause" goto :pause
|
|
11
|
+
if /I "%~1"=="resume" goto :resume
|
|
12
|
+
if /I "%~1"=="status" goto :status
|
|
13
|
+
goto :run
|
|
14
|
+
|
|
15
|
+
:pause
|
|
16
|
+
node ..\..\..\step-machine-cli.js --store file --store-dir "%STORE_DIR%" --pause
|
|
17
|
+
exit /b %ERRORLEVEL%
|
|
18
|
+
|
|
19
|
+
:resume
|
|
20
|
+
node ..\..\..\step-machine-cli.js portfolio-tracker.flow.yaml --store file --store-dir "%STORE_DIR%" --resume
|
|
21
|
+
exit /b %ERRORLEVEL%
|
|
22
|
+
|
|
23
|
+
:status
|
|
24
|
+
node ..\..\..\step-machine-cli.js --store file --store-dir "%STORE_DIR%" --status
|
|
25
|
+
exit /b %ERRORLEVEL%
|
|
26
|
+
|
|
27
|
+
:run
|
|
28
|
+
node -e "const fs=require('fs');const cp=require('child_process');const raw=JSON.parse(fs.readFileSync('portfolio-tracker.input.json','utf8'));raw.runtime_root=(process.env.RUNTIME_ROOT||'').replace(/\\\\/g,'/');const input=JSON.stringify(raw);const r=cp.spawnSync(process.execPath,['..\\..\\..\\step-machine-cli.js','portfolio-tracker.flow.yaml','--store','file','--store-dir',process.env.STORE_DIR,'--initial-data',input],{stdio:'inherit',windowsHide:true,env:{...process.env,BOARD_LIVE_CARDS_NO_SPAWN:'1'}});process.exit(r.status??1);"
|
|
29
|
+
exit /b %ERRORLEVEL%
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml-flow",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Unified workflow engine: step-machine (sequential) + event-graph (stateless DAG) with pluggable storage",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"main": "./dist/index.cjs",
|
|
9
9
|
"module": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
+
"bin": {
|
|
12
|
+
"board-live-cards-cli": "./board-live-cards-cli.js",
|
|
13
|
+
"step-machine-cli": "./step-machine-cli.js"
|
|
14
|
+
},
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
@@ -74,9 +78,12 @@
|
|
|
74
78
|
"./stores/file": false
|
|
75
79
|
},
|
|
76
80
|
"files": [
|
|
81
|
+
"board-live-cards-cli.js",
|
|
82
|
+
"step-machine-cli.js",
|
|
77
83
|
"dist",
|
|
78
84
|
"schema",
|
|
79
|
-
"browser"
|
|
85
|
+
"browser",
|
|
86
|
+
"examples"
|
|
80
87
|
],
|
|
81
88
|
"scripts": {
|
|
82
89
|
"build": "tsup",
|
|
@@ -89,12 +96,17 @@
|
|
|
89
96
|
},
|
|
90
97
|
"devDependencies": {
|
|
91
98
|
"@types/node": "^20.10.0",
|
|
99
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
92
100
|
"tsup": "^8.0.0",
|
|
101
|
+
"tsx": "^4.21.0",
|
|
93
102
|
"typescript": "^5.3.0",
|
|
94
103
|
"vitest": "^1.0.0"
|
|
95
104
|
},
|
|
96
105
|
"dependencies": {
|
|
97
106
|
"ajv-formats": "^3.0.1",
|
|
107
|
+
"fast-glob": "^3.3.3",
|
|
108
|
+
"jsonata": "^2.1.0",
|
|
109
|
+
"proper-lockfile": "^4.1.2",
|
|
98
110
|
"yaml": "^2.3.4"
|
|
99
111
|
},
|
|
100
112
|
"optionalDependencies": {
|