yaml-flow 8.2.5 → 8.4.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-client.js +1 -1
- package/browser/board-livecards-localstorage.js +6 -4
- package/browser/live-cards.js +19 -25
- package/cli/{board-live-cards-lib-Iq_XAC09.d.ts → board-live-cards-lib-tjYsPt5U.d.ts} +1 -1
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +3 -3
- package/cli/browser-api/board-live-cards-browser-adapter.js +3 -2
- package/cli/browser-api/card-store-browser-api.d.ts +1 -1
- package/cli/browser-api/card-store-browser-api.js +1 -1
- package/cli/{execution-interface-ftO1W7Po.d.ts → execution-interface-DCFBy4L8.d.ts} +151 -2
- package/cli/node/artifacts-store-cli.js +5 -5
- package/cli/node/batch-runner-cli.d.ts +3 -0
- package/cli/node/batch-runner-cli.js +2 -1
- package/cli/node/board-live-cards-cli.js +14 -8
- package/cli/node/card-store-cli.js +6 -6
- package/cli/node/chat-store-cli.d.ts +23 -0
- package/cli/node/chat-store-cli.js +8 -0
- package/cli/node/execution-adapter.d.ts +4 -2
- package/cli/node/execution-adapter.js +2 -2
- package/cli/node/fs-board-adapter.d.ts +75 -75
- package/cli/node/fs-board-adapter.js +14 -10
- package/cli/node/source-cli-task-executor.js +4 -4
- package/cli/node/step-machine-cli.js +3 -3
- package/cli/{types--rXGWbSR.d.ts → types-Dc2VRMUw.d.ts} +27 -124
- package/examples/board/demo-shell-with-server.html +3 -196
- package/examples/board/doc.html +465 -0
- package/examples/board/server/board-server.js +30 -82
- package/examples/board/server/board-worker/source_def_flows.json +2 -2
- package/examples/board/server/chat-flow/copilot-chat/assistant.js +44 -185
- package/examples/board/server/chat-flow/copilot-chat/copilot_wrapper.bat +157 -0
- package/examples/board/server/chat-flow/copilot-chat/copilot_wrapper_helper.ps1 +190 -0
- package/examples/board/server/chat-flow/flow-steps.json +122 -56
- package/examples/board/test/server-http-test.js +252 -220
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/{artifacts-store-lib-public-GD4H-fFp.d.ts → artifacts-store-lib-454TAuov.d.ts} +2 -32
- package/lib/{artifacts-store-lib-public-C5UL5tyG.d.cts → artifacts-store-lib-zsGFbBV8.d.cts} +2 -32
- package/lib/artifacts-store-public.d.cts +34 -3
- package/lib/artifacts-store-public.d.ts +34 -3
- package/lib/board-live-cards-node.cjs +14 -10
- package/lib/board-live-cards-node.d.cts +42 -21
- package/lib/board-live-cards-node.d.ts +42 -21
- package/lib/board-live-cards-node.js +14 -10
- package/lib/{board-live-cards-public-BLXbcBNk.d.cts → board-live-cards-public-BM6jCEIa.d.cts} +25 -5
- package/lib/{board-live-cards-public-BZaNb2mi.d.ts → board-live-cards-public-Bz07XKRK.d.ts} +25 -5
- package/lib/board-live-cards-public.cjs +2 -2
- 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 +2 -2
- package/lib/board-live-cards-server-runtime.cjs +4 -4
- package/lib/board-live-cards-server-runtime.d.cts +5 -3
- package/lib/board-live-cards-server-runtime.d.ts +5 -3
- package/lib/board-live-cards-server-runtime.js +4 -4
- package/lib/board-worker-adapter.cjs +2 -2
- package/lib/board-worker-adapter.js +2 -2
- package/lib/card-store-public.d.cts +2 -2
- package/lib/card-store-public.d.ts +2 -2
- package/lib/chat-storage-lib-DGaKrjVe.d.ts +53 -0
- package/lib/chat-storage-lib-OX0Q_Ttf.d.cts +53 -0
- package/lib/chat-store-public.cjs +2 -0
- package/lib/chat-store-public.d.cts +128 -0
- package/lib/chat-store-public.d.ts +128 -0
- package/lib/chat-store-public.js +2 -0
- package/lib/execution-refs.cjs +1 -1
- package/lib/execution-refs.d.cts +10 -1
- package/lib/execution-refs.d.ts +10 -1
- package/lib/execution-refs.js +1 -1
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/server-runtime/index.cjs +4 -4
- package/lib/server-runtime/index.d.cts +6 -4
- package/lib/server-runtime/index.d.ts +6 -4
- package/lib/server-runtime/index.js +4 -4
- package/lib/step-machine-public/index.cjs +3 -3
- 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 +3 -3
- package/lib/{storage-interface-B6ecOulj.d.ts → storage-interface-B-7pDHwD.d.cts} +36 -1
- package/lib/{storage-interface-B6ecOulj.d.cts → storage-interface-B-7pDHwD.d.ts} +36 -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-D-xVWPdY.d.ts → types-Cn0b8G-i.d.ts} +16 -65
- package/lib/{types-Bztd1KoK.d.cts → types-Dszjwfud.d.cts} +16 -65
- package/package.json +8 -2
- package/examples/board/.board-ws/cards/store/_index.json +0 -17
- package/examples/board/.board-ws/cards/store/card-market-prices.json +0 -80
- package/examples/board/.board-ws/cards/store/card-portfolio-value.json +0 -90
- package/examples/board/.board-ws/cards/store/card-portfolio.json +0 -78
- package/examples/board/server/chat-flow/chat-clear-processing.js +0 -41
- package/examples/board/server/chat-flow/chat-open-turn.js +0 -144
- package/examples/board/server/chat-flow/chat-write-assistant.js +0 -44
- package/examples/board/server/chat-flow/echo-probe/assistant.js +0 -28
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "card-portfolio-value",
|
|
3
|
-
"meta": {
|
|
4
|
-
"title": "Portfolio Value",
|
|
5
|
-
"tags": [
|
|
6
|
-
"portfolio",
|
|
7
|
-
"value"
|
|
8
|
-
],
|
|
9
|
-
"desc": "Computes total portfolio value, gainers/losers summary, and per-position P&L from holdings and live market quotes."
|
|
10
|
-
},
|
|
11
|
-
"requires": [
|
|
12
|
-
"holdings",
|
|
13
|
-
"quotes"
|
|
14
|
-
],
|
|
15
|
-
"provides": [
|
|
16
|
-
{
|
|
17
|
-
"bindTo": "positions",
|
|
18
|
-
"ref": "computed_values.positions"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"compute": [
|
|
22
|
-
{
|
|
23
|
-
"bindTo": "positions",
|
|
24
|
-
"expr": "($hMap := $merge(requires.holdings.{ticker: $}); $map(requires.quotes.quoteResponse.result, function($q) { ($h := $lookup($hMap, $q.symbol); $qty := $h.quantity; $cb := $h.cost_basis; $val := $round($q.regularMarketPrice * $qty, 2); $cost := $round($cb * $qty, 2); $chg := $round($q.regularMarketChange * $qty, 2); {\"ticker\": $q.symbol, \"quantity\": $qty, \"cost_basis\": $cb, \"price\": $round($q.regularMarketPrice, 2), \"value\": $val, \"gain_$\": $round($val - $cost, 2), \"gain_%\": $round(($val - $cost) / $cost * 100, 2), \"chg_$\": $chg, \"chg_pct\": $round($q.regularMarketChangePercent, 2)}) }))"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"bindTo": "totalValue",
|
|
28
|
-
"expr": "$round($sum(computed_values.positions.value), 2)"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"bindTo": "gainers",
|
|
32
|
-
"expr": "$count($filter(computed_values.positions, function($p){ $p.chg_pct > 0 }))"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"bindTo": "losers",
|
|
36
|
-
"expr": "$count($filter(computed_values.positions, function($p){ $p.chg_pct < 0 }))"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"bindTo": "gainersLosers",
|
|
40
|
-
"expr": "computed_values.gainers & ' up · ' & computed_values.losers & ' down'"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"view": {
|
|
44
|
-
"elements": [
|
|
45
|
-
{
|
|
46
|
-
"kind": "metric",
|
|
47
|
-
"label": "Portfolio Value ($)",
|
|
48
|
-
"data": {
|
|
49
|
-
"bind": "computed_values.totalValue"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"kind": "text",
|
|
54
|
-
"data": {
|
|
55
|
-
"bind": "computed_values.gainersLosers"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"kind": "table",
|
|
60
|
-
"label": "Positions",
|
|
61
|
-
"data": {
|
|
62
|
-
"bind": "computed_values.positions",
|
|
63
|
-
"columns": [
|
|
64
|
-
"ticker",
|
|
65
|
-
"value",
|
|
66
|
-
"gain_$",
|
|
67
|
-
"gain_%"
|
|
68
|
-
],
|
|
69
|
-
"sortable": true
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"layout": {
|
|
74
|
-
"board": {
|
|
75
|
-
"col": 4,
|
|
76
|
-
"order": 3
|
|
77
|
-
},
|
|
78
|
-
"canvas": {
|
|
79
|
-
"x": 840,
|
|
80
|
-
"y": 50,
|
|
81
|
-
"w": 420,
|
|
82
|
-
"h": 380
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"features": {
|
|
86
|
-
"chat": true
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
"card_data": {}
|
|
90
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "card-portfolio",
|
|
3
|
-
"meta": {
|
|
4
|
-
"title": "My Portfolio",
|
|
5
|
-
"tags": [
|
|
6
|
-
"portfolio"
|
|
7
|
-
],
|
|
8
|
-
"desc": "Manage your stock holdings — edit tickers and quantities inline, add or delete rows. Changes propagate downstream immediately."
|
|
9
|
-
},
|
|
10
|
-
"provides": [
|
|
11
|
-
{
|
|
12
|
-
"bindTo": "holdings",
|
|
13
|
-
"ref": "card_data.holdings"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"compute": [],
|
|
17
|
-
"view": {
|
|
18
|
-
"elements": [
|
|
19
|
-
{
|
|
20
|
-
"kind": "editable-table",
|
|
21
|
-
"label": "Holdings",
|
|
22
|
-
"data": {
|
|
23
|
-
"bind": "card_data.holdings",
|
|
24
|
-
"writeTo": "card_data.holdings",
|
|
25
|
-
"columns": [
|
|
26
|
-
"ticker",
|
|
27
|
-
"quantity",
|
|
28
|
-
"cost_basis"
|
|
29
|
-
],
|
|
30
|
-
"schema": {
|
|
31
|
-
"properties": {
|
|
32
|
-
"quantity": {
|
|
33
|
-
"type": "number"
|
|
34
|
-
},
|
|
35
|
-
"cost_basis": {
|
|
36
|
-
"type": "number"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"layout": {
|
|
44
|
-
"board": {
|
|
45
|
-
"col": 4,
|
|
46
|
-
"order": 1
|
|
47
|
-
},
|
|
48
|
-
"canvas": {
|
|
49
|
-
"x": 50,
|
|
50
|
-
"y": 50,
|
|
51
|
-
"w": 320,
|
|
52
|
-
"h": 340
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"features": {
|
|
56
|
-
"chat": true
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"card_data": {
|
|
60
|
-
"holdings": [
|
|
61
|
-
{
|
|
62
|
-
"ticker": "AAPL",
|
|
63
|
-
"quantity": 10,
|
|
64
|
-
"cost_basis": 150
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"ticker": "NVDA",
|
|
68
|
-
"quantity": 5,
|
|
69
|
-
"cost_basis": 310
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"ticker": "GOOG",
|
|
73
|
-
"quantity": 3,
|
|
74
|
-
"cost_basis": 33
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import { createFsBoardChatStorage } from 'yaml-flow/board-live-cards-node';
|
|
6
|
-
|
|
7
|
-
function readJsonStdin() {
|
|
8
|
-
try {
|
|
9
|
-
const raw = fs.readFileSync(0, 'utf-8').trim();
|
|
10
|
-
if (!raw) return {};
|
|
11
|
-
const parsed = JSON.parse(raw);
|
|
12
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
13
|
-
} catch {
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const input = readJsonStdin();
|
|
19
|
-
const boardSetupRoot = typeof input.boardSetupRoot === 'string' ? input.boardSetupRoot : '';
|
|
20
|
-
const boardRuntimeDir = typeof input.boardRuntimeDir === 'string' ? input.boardRuntimeDir : 'runtime';
|
|
21
|
-
const cardId = typeof input.cardId === 'string' ? input.cardId : '';
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
if (!boardSetupRoot || !cardId) {
|
|
25
|
-
process.stderr.write('chat-clear-processing requires boardSetupRoot and cardId\n');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const boardDir = path.join(boardSetupRoot, boardRuntimeDir || 'runtime');
|
|
30
|
-
if (!fs.existsSync(boardDir)) {
|
|
31
|
-
process.stdout.write(JSON.stringify({ cleared: true, skipped: true }));
|
|
32
|
-
process.exit(0);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const chatStorage = createFsBoardChatStorage(boardDir);
|
|
36
|
-
chatStorage.setProcessing(cardId, false);
|
|
37
|
-
process.stdout.write(JSON.stringify({ cleared: true }));
|
|
38
|
-
} catch (err) {
|
|
39
|
-
process.stderr.write((err instanceof Error ? err.message : String(err)) + '\n');
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
|
|
5
|
-
function readJsonStdin() {
|
|
6
|
-
try {
|
|
7
|
-
const raw = fs.readFileSync(0, 'utf-8').trim();
|
|
8
|
-
if (!raw) return {};
|
|
9
|
-
const parsed = JSON.parse(raw);
|
|
10
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
11
|
-
} catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function parseBoolean(value, fallback = false) {
|
|
17
|
-
if (value === true || value === 1) return true;
|
|
18
|
-
if (value === false || value === 0) return false;
|
|
19
|
-
if (typeof value === 'string') {
|
|
20
|
-
const normalized = value.trim().toLowerCase();
|
|
21
|
-
if (['1', 'true', 'yes', 'on'].includes(normalized)) return true;
|
|
22
|
-
if (['0', 'false', 'no', 'off'].includes(normalized)) return false;
|
|
23
|
-
}
|
|
24
|
-
return fallback;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function parsePositiveInt(value, fallback = null) {
|
|
28
|
-
const n = Number(value);
|
|
29
|
-
if (!Number.isFinite(n) || n <= 0) return fallback;
|
|
30
|
-
return Math.floor(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function parseChatEnvelope(raw) {
|
|
34
|
-
// Chat payload supports either plain text or a JSON envelope.
|
|
35
|
-
// JSON fields: prompt|text|userText|query, probe, chatTimeoutMs|chatCopilotTimeoutMs, chatTimeMs.
|
|
36
|
-
if (!raw) {
|
|
37
|
-
return {
|
|
38
|
-
userText: '',
|
|
39
|
-
probe: false,
|
|
40
|
-
chatHandlerMode: 'copilot',
|
|
41
|
-
chatCopilotTimeoutMs: null,
|
|
42
|
-
chatTimeMs: null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
const parsed = JSON.parse(raw);
|
|
48
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
49
|
-
throw new Error('not-an-object');
|
|
50
|
-
}
|
|
51
|
-
const prompt = [parsed.prompt, parsed.text, parsed.userText, parsed.query]
|
|
52
|
-
.find((value) => typeof value === 'string' && value.trim().length > 0);
|
|
53
|
-
const probe = parseBoolean(parsed.probe, false);
|
|
54
|
-
const modeFromInput = typeof parsed.chatHandlerMode === 'string' ? parsed.chatHandlerMode.trim().toLowerCase() : '';
|
|
55
|
-
return {
|
|
56
|
-
userText: (typeof prompt === 'string' ? prompt : raw).trim(),
|
|
57
|
-
probe,
|
|
58
|
-
chatHandlerMode: modeFromInput || (probe ? 'probe' : 'copilot'),
|
|
59
|
-
chatCopilotTimeoutMs: parsePositiveInt(parsed.chatTimeoutMs ?? parsed.chatCopilotTimeoutMs, null),
|
|
60
|
-
chatTimeMs: parsePositiveInt(parsed.chatTimeMs, null),
|
|
61
|
-
};
|
|
62
|
-
} catch {
|
|
63
|
-
return {
|
|
64
|
-
userText: raw.trim(),
|
|
65
|
-
probe: false,
|
|
66
|
-
chatHandlerMode: 'copilot',
|
|
67
|
-
chatCopilotTimeoutMs: null,
|
|
68
|
-
chatTimeMs: null,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const extra = readJsonStdin();
|
|
74
|
-
const boardId = typeof extra.boardId === 'string' ? extra.boardId : '';
|
|
75
|
-
const cardId = typeof extra.cardId === 'string' ? extra.cardId : '';
|
|
76
|
-
const boardSetupRoot = typeof extra.boardSetupRoot === 'string' ? extra.boardSetupRoot : '';
|
|
77
|
-
const boardRuntimeDir = typeof extra.boardRuntimeDir === 'string' ? extra.boardRuntimeDir : 'runtime';
|
|
78
|
-
const runtimeStatusDir = typeof extra.runtimeStatusDir === 'string' ? extra.runtimeStatusDir : 'runtime-out';
|
|
79
|
-
const cardsDir = typeof extra.cardsDir === 'string' ? extra.cardsDir : 'cards';
|
|
80
|
-
const projectRoot = typeof extra.projectRoot === 'string' ? extra.projectRoot : '';
|
|
81
|
-
const chatFlowRoot = typeof extra.chatFlowRoot === 'string' ? extra.chatFlowRoot : '';
|
|
82
|
-
const serverUrl = typeof extra.serverUrl === 'string' ? extra.serverUrl.replace(/\/$/, '') : '';
|
|
83
|
-
const apiBasePath = typeof extra.apiBasePath === 'string' ? extra.apiBasePath : '/api/board';
|
|
84
|
-
const lastChatEntryId = typeof extra.lastChatEntryId === 'string' ? extra.lastChatEntryId : '';
|
|
85
|
-
|
|
86
|
-
if (!cardId || !serverUrl || !apiBasePath || !lastChatEntryId) {
|
|
87
|
-
process.stderr.write('chat-open-turn requires cardId, serverUrl, apiBasePath, and lastChatEntryId\n');
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let messageText = '';
|
|
92
|
-
try {
|
|
93
|
-
const chatsUrl = `${serverUrl}${apiBasePath}/cards/${encodeURIComponent(cardId)}/chats`;
|
|
94
|
-
const res = await fetch(chatsUrl);
|
|
95
|
-
if (!res.ok) {
|
|
96
|
-
process.stderr.write(`chat-open-turn could not fetch chat history: HTTP ${res.status}\n`);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
const data = await res.json();
|
|
100
|
-
const messages = Array.isArray(data?.messages) ? data.messages : [];
|
|
101
|
-
const currentUser = messages.find((message) =>
|
|
102
|
-
typeof message?.id === 'string'
|
|
103
|
-
&& message.id === lastChatEntryId
|
|
104
|
-
&& message.role === 'user'
|
|
105
|
-
);
|
|
106
|
-
messageText = typeof currentUser?.text === 'string' ? currentUser.text : '';
|
|
107
|
-
} catch (err) {
|
|
108
|
-
process.stderr.write(`chat-open-turn could not fetch current user turn: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!messageText) {
|
|
113
|
-
process.stderr.write('chat-open-turn could not resolve user text for lastChatEntryId\n');
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const envelope = parseChatEnvelope(messageText);
|
|
118
|
-
const userText = envelope.userText;
|
|
119
|
-
const probe = envelope.probe;
|
|
120
|
-
const chatHandlerMode = envelope.chatHandlerMode;
|
|
121
|
-
const chatCopilotTimeoutMs = envelope.chatCopilotTimeoutMs
|
|
122
|
-
?? (Number.isFinite(Number(extra.chatCopilotTimeoutMs)) && Number(extra.chatCopilotTimeoutMs) > 0
|
|
123
|
-
? Math.floor(Number(extra.chatCopilotTimeoutMs))
|
|
124
|
-
: 300000);
|
|
125
|
-
const chatTimeMs = envelope.chatTimeMs;
|
|
126
|
-
|
|
127
|
-
process.stdout.write(JSON.stringify({
|
|
128
|
-
boardId,
|
|
129
|
-
cardId,
|
|
130
|
-
boardSetupRoot,
|
|
131
|
-
boardRuntimeDir,
|
|
132
|
-
runtimeStatusDir,
|
|
133
|
-
cardsDir,
|
|
134
|
-
projectRoot,
|
|
135
|
-
chatFlowRoot,
|
|
136
|
-
userText,
|
|
137
|
-
serverUrl,
|
|
138
|
-
apiBasePath,
|
|
139
|
-
lastChatEntryId,
|
|
140
|
-
probe,
|
|
141
|
-
chatHandlerMode,
|
|
142
|
-
chatCopilotTimeoutMs,
|
|
143
|
-
chatTimeMs,
|
|
144
|
-
}));
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
|
|
5
|
-
function readJsonStdin() {
|
|
6
|
-
try {
|
|
7
|
-
const raw = fs.readFileSync(0, 'utf-8').trim();
|
|
8
|
-
if (!raw) return {};
|
|
9
|
-
const parsed = JSON.parse(raw);
|
|
10
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
11
|
-
} catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const input = readJsonStdin();
|
|
17
|
-
const cardId = typeof input.cardId === 'string' ? input.cardId : '';
|
|
18
|
-
const serverUrl = typeof input.serverUrl === 'string' ? input.serverUrl.replace(/\/$/, '') : '';
|
|
19
|
-
const apiBasePath = typeof input.apiBasePath === 'string' ? input.apiBasePath : '/api/board';
|
|
20
|
-
const replyText = typeof input.replyText === 'string' ? input.replyText : '';
|
|
21
|
-
|
|
22
|
-
if (!cardId || !serverUrl) {
|
|
23
|
-
process.stderr.write('chat-write-assistant requires cardId and serverUrl\n');
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const postUrl = `${serverUrl}${apiBasePath}/cards/${encodeURIComponent(cardId)}/chats`;
|
|
29
|
-
const postRes = await fetch(postUrl, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: { 'Content-Type': 'application/json' },
|
|
32
|
-
body: JSON.stringify({ role: 'assistant', text: replyText, files: [], done: true }),
|
|
33
|
-
});
|
|
34
|
-
if (!postRes.ok) {
|
|
35
|
-
const err = await postRes.text();
|
|
36
|
-
process.stderr.write(`chat-write-assistant POST failed: ${err}\n`);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
const postData = await postRes.json();
|
|
40
|
-
process.stdout.write(JSON.stringify({ replyId: postData?.id, replyText }));
|
|
41
|
-
} catch (err) {
|
|
42
|
-
process.stderr.write((err instanceof Error ? err.message : String(err)) + '\n');
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
|
|
5
|
-
function readJsonStdin() {
|
|
6
|
-
try {
|
|
7
|
-
const raw = fs.readFileSync(0, 'utf-8').trim();
|
|
8
|
-
if (!raw) return {};
|
|
9
|
-
const parsed = JSON.parse(raw);
|
|
10
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
11
|
-
} catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const input = readJsonStdin();
|
|
17
|
-
const userText = typeof input.userText === 'string' ? input.userText : '';
|
|
18
|
-
const chatTimeMs = Number.isFinite(Number(input.chatTimeMs)) && Number(input.chatTimeMs) > 0
|
|
19
|
-
? Math.min(120000, Math.floor(Number(input.chatTimeMs)))
|
|
20
|
-
: 0;
|
|
21
|
-
|
|
22
|
-
if (chatTimeMs > 0) {
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, chatTimeMs));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
process.stdout.write(JSON.stringify({
|
|
27
|
-
replyText: `Echo: ${userText}`,
|
|
28
|
-
}));
|