yaml-flow 8.4.25 → 8.5.1
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/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
- package/cli/browser-api/board-live-cards-browser-adapter.js +1 -1
- package/cli/bundled/board-live-cards-cli.mjs +14 -14
- package/cli/bundled/chat-store-cli.mjs +13 -13
- package/cli/{types-juH2nFpz.d.ts → types-H3EMBPY2.d.ts} +10 -4
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board/server/README-mcp-api.md +680 -0
- package/examples/board/server/board-server.js +4 -0
- package/examples/board/server/chat-flow/copilot-chat/assistant.js +4 -2
- package/examples/board/server/chat-flow/flow-steps.json +9 -8
- package/examples/board/test/server-http-mcp-test.js +1148 -0
- package/examples/board/test/server-http-test.js +7 -7
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/artifacts-store-public.d.cts +1 -1
- package/lib/artifacts-store-public.d.ts +1 -1
- package/lib/board-live-cards-mcp.cjs +2 -0
- package/lib/board-live-cards-mcp.d.cts +296 -0
- package/lib/board-live-cards-mcp.d.ts +296 -0
- package/lib/board-live-cards-mcp.js +2 -0
- package/lib/board-live-cards-node.cjs +14 -14
- package/lib/board-live-cards-node.d.cts +8 -6
- package/lib/board-live-cards-node.d.ts +8 -6
- package/lib/board-live-cards-node.js +14 -14
- package/lib/{board-live-cards-public-B4RcYPC_.d.cts → board-live-cards-public-B13InXhC.d.cts} +8 -3
- package/lib/{board-live-cards-public-ydXuA4zh.d.ts → board-live-cards-public-BGS22cMb.d.ts} +8 -3
- package/lib/board-live-cards-public.cjs +1 -1
- 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 +1 -1
- package/lib/board-live-cards-server-runtime.cjs +5 -4
- package/lib/board-live-cards-server-runtime.d.cts +3 -3
- package/lib/board-live-cards-server-runtime.d.ts +3 -3
- package/lib/board-live-cards-server-runtime.js +5 -4
- package/lib/card-store-public.d.cts +1 -1
- package/lib/card-store-public.d.ts +1 -1
- package/lib/{chat-storage-lib-B1wU27y3.d.cts → chat-storage-lib-0imhRX3l.d.cts} +2 -1
- package/lib/{chat-storage-lib-DsF4kPon.d.ts → chat-storage-lib-CJn7a6OH.d.ts} +2 -1
- package/lib/chat-store-public.cjs +1 -1
- package/lib/chat-store-public.d.cts +7 -2
- package/lib/chat-store-public.d.ts +7 -2
- package/lib/chat-store-public.js +1 -1
- package/lib/server-runtime/index.cjs +5 -4
- package/lib/server-runtime/index.d.cts +4 -4
- package/lib/server-runtime/index.d.ts +4 -4
- package/lib/server-runtime/index.js +5 -4
- package/lib/{types-DwPRb-PY.d.ts → types-30R357js.d.ts} +3 -2
- package/lib/{types-BpfMamGs.d.cts → types-CIgsh56O.d.cts} +3 -2
- package/package.json +10 -2
- package/browser/board-livecards-localstorage.js +0 -10
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { C as CommandResult, L as LiveCard } from './board-live-cards-public-BGS22cMb.js';
|
|
2
|
+
import { CardStorePublic } from './card-store-public.js';
|
|
3
|
+
import { ChatStorePublic } from './chat-store-public.js';
|
|
4
|
+
import { C as ChatRecord } from './chat-storage-lib-CJn7a6OH.js';
|
|
5
|
+
import './storage-interface-B2WD9D5n.js';
|
|
6
|
+
import './execution-refs.js';
|
|
7
|
+
import './types-BBhqYGhE.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* board-live-cards-mcp.ts
|
|
11
|
+
*
|
|
12
|
+
* Platform-free MCP-oriented facade for board-live-cards.
|
|
13
|
+
*
|
|
14
|
+
* This layer preserves the wrapper-script-visible tool semantics while using
|
|
15
|
+
* the existing public library surfaces instead of shelling out to CLIs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
type UnknownRecord = Record<string, unknown>;
|
|
19
|
+
interface BoardLiveCardsMcpFileDownloadDescriptor {
|
|
20
|
+
cardId: string;
|
|
21
|
+
fileIdx: number;
|
|
22
|
+
downloadUrl: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
stored_name?: string;
|
|
25
|
+
mime_type?: string;
|
|
26
|
+
size?: number;
|
|
27
|
+
uploaded_at?: string;
|
|
28
|
+
}
|
|
29
|
+
interface BoardLiveCardsMcpDiscoverSourceKindsResult {
|
|
30
|
+
version?: unknown;
|
|
31
|
+
commonSourceFields: UnknownRecord;
|
|
32
|
+
sourceKinds: UnknownRecord;
|
|
33
|
+
}
|
|
34
|
+
interface BoardLiveCardsMcpBoardStatusCard {
|
|
35
|
+
'card-id': string | null;
|
|
36
|
+
status: unknown;
|
|
37
|
+
error: unknown;
|
|
38
|
+
requires: unknown[];
|
|
39
|
+
requires_satisfied: unknown[];
|
|
40
|
+
requires_missing: unknown[];
|
|
41
|
+
provides_declared: unknown[];
|
|
42
|
+
provides_runtime: unknown[];
|
|
43
|
+
}
|
|
44
|
+
interface BoardLiveCardsMcpBoardStatusResult {
|
|
45
|
+
meta: UnknownRecord;
|
|
46
|
+
summary: {
|
|
47
|
+
card_count: number;
|
|
48
|
+
completed: number;
|
|
49
|
+
eligible: number;
|
|
50
|
+
pending: number;
|
|
51
|
+
blocked: number;
|
|
52
|
+
in_progress: number;
|
|
53
|
+
failed: number;
|
|
54
|
+
unresolved: number;
|
|
55
|
+
};
|
|
56
|
+
cards: BoardLiveCardsMcpBoardStatusCard[];
|
|
57
|
+
}
|
|
58
|
+
interface BoardLiveCardsMcpRenderedViewElement {
|
|
59
|
+
id: string;
|
|
60
|
+
kind: unknown;
|
|
61
|
+
label: unknown;
|
|
62
|
+
visible: boolean;
|
|
63
|
+
bind?: string;
|
|
64
|
+
columns?: unknown[];
|
|
65
|
+
maxRows?: number;
|
|
66
|
+
resolved?: unknown;
|
|
67
|
+
}
|
|
68
|
+
interface BoardLiveCardsMcpRenderedView {
|
|
69
|
+
layout: unknown;
|
|
70
|
+
features: unknown;
|
|
71
|
+
elements: BoardLiveCardsMcpRenderedViewElement[];
|
|
72
|
+
}
|
|
73
|
+
interface BoardLiveCardsMcpInspectCardDefinitionAndRuntimeResult {
|
|
74
|
+
cardId: string;
|
|
75
|
+
card_status_in_board: UnknownRecord;
|
|
76
|
+
card_definition_and_static_data: UnknownRecord;
|
|
77
|
+
refs_for_fetched_source_files: Record<string, string>;
|
|
78
|
+
runtime_data: {
|
|
79
|
+
requires: Record<string, unknown>;
|
|
80
|
+
provides: Record<string, unknown>;
|
|
81
|
+
computed_values: UnknownRecord;
|
|
82
|
+
rendered_view: BoardLiveCardsMcpRenderedView;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
interface BoardLiveCardsMcpInspectChatMessagesResult {
|
|
86
|
+
cardId: string;
|
|
87
|
+
messages: Array<ChatRecord & {
|
|
88
|
+
retrieval_hint?: string;
|
|
89
|
+
payload?: UnknownRecord;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
interface BoardLiveCardsMcpManageUpsertCardFailureResult {
|
|
93
|
+
status: 'fail';
|
|
94
|
+
step: 'validate';
|
|
95
|
+
validation: unknown;
|
|
96
|
+
}
|
|
97
|
+
interface BoardLiveCardsMcpManageUpsertCardSuccessResult {
|
|
98
|
+
status: 'success';
|
|
99
|
+
data: {
|
|
100
|
+
validation: unknown;
|
|
101
|
+
card_saved: unknown;
|
|
102
|
+
board_result: unknown;
|
|
103
|
+
refresh_notify: unknown;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
type BoardLiveCardsMcpManageUpsertCardResult = BoardLiveCardsMcpManageUpsertCardFailureResult | BoardLiveCardsMcpManageUpsertCardSuccessResult;
|
|
107
|
+
interface BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult {
|
|
108
|
+
status: 'success';
|
|
109
|
+
data: {
|
|
110
|
+
cardId: string;
|
|
111
|
+
id: string;
|
|
112
|
+
role: string;
|
|
113
|
+
turn: string;
|
|
114
|
+
files: Array<Record<string, unknown>>;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
interface BoardLiveCardsMcpPreflightRunOneCycleResult {
|
|
118
|
+
status: 'success';
|
|
119
|
+
data: {
|
|
120
|
+
cardId: string;
|
|
121
|
+
ok: boolean;
|
|
122
|
+
issues: string[];
|
|
123
|
+
provides_outputs: Record<string, unknown>;
|
|
124
|
+
rendered_view: BoardLiveCardsMcpRenderedView;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface BoardLiveCardsMcpPreflightMaterializeResult {
|
|
128
|
+
status: 'success';
|
|
129
|
+
data: {
|
|
130
|
+
cardId: string;
|
|
131
|
+
ok: boolean;
|
|
132
|
+
computed_values: UnknownRecord;
|
|
133
|
+
errors: Array<{
|
|
134
|
+
bindTo: string;
|
|
135
|
+
error: string;
|
|
136
|
+
}>;
|
|
137
|
+
provides_outputs: Record<string, unknown>;
|
|
138
|
+
rendered_view: BoardLiveCardsMcpRenderedView;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
interface BoardLiveCardsMcpBoardDeps {
|
|
142
|
+
status(input: {}): CommandResult;
|
|
143
|
+
getOutputsDataObject(input: {
|
|
144
|
+
params: {
|
|
145
|
+
key: string;
|
|
146
|
+
};
|
|
147
|
+
}): CommandResult;
|
|
148
|
+
getOutputsComputedValues(input: {
|
|
149
|
+
params: {
|
|
150
|
+
key: string;
|
|
151
|
+
};
|
|
152
|
+
}): CommandResult;
|
|
153
|
+
getOutputsFetchedSources(input: {
|
|
154
|
+
params: {
|
|
155
|
+
key: string;
|
|
156
|
+
};
|
|
157
|
+
}): CommandResult<Record<string, string>>;
|
|
158
|
+
removeCard(input: {
|
|
159
|
+
params: {
|
|
160
|
+
id: string;
|
|
161
|
+
};
|
|
162
|
+
}): CommandResult;
|
|
163
|
+
cardRefreshedNotify(input: {
|
|
164
|
+
params: {
|
|
165
|
+
cardId: string;
|
|
166
|
+
};
|
|
167
|
+
}): CommandResult;
|
|
168
|
+
upsertCard(input: {
|
|
169
|
+
params: {
|
|
170
|
+
cardId: string;
|
|
171
|
+
restart?: boolean;
|
|
172
|
+
};
|
|
173
|
+
}): CommandResult;
|
|
174
|
+
}
|
|
175
|
+
interface BoardLiveCardsMcpNonCoreDeps {
|
|
176
|
+
describeTaskExecutorCapabilities(input: {}): CommandResult;
|
|
177
|
+
validateCardPreflight(input: {
|
|
178
|
+
body: unknown;
|
|
179
|
+
}): CommandResult;
|
|
180
|
+
evalCardCompute(input: {
|
|
181
|
+
body: unknown;
|
|
182
|
+
}): CommandResult<{
|
|
183
|
+
cardId: string;
|
|
184
|
+
ok: boolean;
|
|
185
|
+
computed_values: Record<string, unknown>;
|
|
186
|
+
errors: Array<{
|
|
187
|
+
bindTo: string;
|
|
188
|
+
error: string;
|
|
189
|
+
}>;
|
|
190
|
+
}>;
|
|
191
|
+
probeSourcePreflight(input: {
|
|
192
|
+
params: {
|
|
193
|
+
sourceIdx: number;
|
|
194
|
+
};
|
|
195
|
+
body: unknown;
|
|
196
|
+
}): CommandResult;
|
|
197
|
+
runSourcePreflight(input: {
|
|
198
|
+
params: {
|
|
199
|
+
sourceIdx: number;
|
|
200
|
+
};
|
|
201
|
+
body: unknown;
|
|
202
|
+
}): CommandResult;
|
|
203
|
+
simulateCardCycle(input: {
|
|
204
|
+
body: unknown;
|
|
205
|
+
}): CommandResult;
|
|
206
|
+
}
|
|
207
|
+
interface BoardLiveCardsMcpDeps {
|
|
208
|
+
board: BoardLiveCardsMcpBoardDeps;
|
|
209
|
+
nonCore: BoardLiveCardsMcpNonCoreDeps;
|
|
210
|
+
cardStore: CardStorePublic;
|
|
211
|
+
chatStore: ChatStorePublic;
|
|
212
|
+
uploadCardFile(args: {
|
|
213
|
+
cardId: string;
|
|
214
|
+
fileName: string;
|
|
215
|
+
contentType: string;
|
|
216
|
+
bytes: Uint8Array;
|
|
217
|
+
}): {
|
|
218
|
+
ok: true;
|
|
219
|
+
file: Record<string, unknown>;
|
|
220
|
+
};
|
|
221
|
+
buildFileDownloadUrl(args: {
|
|
222
|
+
cardId: string;
|
|
223
|
+
fileIdx: number;
|
|
224
|
+
storedName?: string | null;
|
|
225
|
+
}): string;
|
|
226
|
+
readFetchedSourceJsonByRef?(args: {
|
|
227
|
+
cardId: string;
|
|
228
|
+
ref: string;
|
|
229
|
+
}): unknown | null;
|
|
230
|
+
}
|
|
231
|
+
interface BoardLiveCardsMcp {
|
|
232
|
+
discoverSourceKinds(): BoardLiveCardsMcpDiscoverSourceKindsResult;
|
|
233
|
+
inspectBoardRuntimeStatus(): BoardLiveCardsMcpBoardStatusResult;
|
|
234
|
+
inspectCardDefinitionAndRuntime(args: {
|
|
235
|
+
cardId: string;
|
|
236
|
+
}): BoardLiveCardsMcpInspectCardDefinitionAndRuntimeResult;
|
|
237
|
+
inspectChatMessagesOnCards(args: {
|
|
238
|
+
cardId: string;
|
|
239
|
+
lastUserTurns?: number;
|
|
240
|
+
tail?: number;
|
|
241
|
+
turnId?: string;
|
|
242
|
+
allTurns?: boolean;
|
|
243
|
+
tailTurnsBeforeId?: string;
|
|
244
|
+
}): BoardLiveCardsMcpInspectChatMessagesResult;
|
|
245
|
+
inspectFileContents(args: {
|
|
246
|
+
cardId: string;
|
|
247
|
+
fileIdx: number;
|
|
248
|
+
}): BoardLiveCardsMcpFileDownloadDescriptor;
|
|
249
|
+
preflightValidateCandidateCardDefinition(args: {
|
|
250
|
+
candidateCardContent: UnknownRecord;
|
|
251
|
+
}): unknown;
|
|
252
|
+
preflightMaterializeCandidateCard(args: {
|
|
253
|
+
candidateCardContent: UnknownRecord;
|
|
254
|
+
mockRequires: UnknownRecord;
|
|
255
|
+
mockFetchedSources: UnknownRecord;
|
|
256
|
+
}): BoardLiveCardsMcpPreflightMaterializeResult | CommandResult;
|
|
257
|
+
preflightProbeSingleSourceInCandidateCard(args: {
|
|
258
|
+
candidateCardContent: UnknownRecord;
|
|
259
|
+
mockProjections: UnknownRecord;
|
|
260
|
+
sourceIdx: number;
|
|
261
|
+
}): unknown;
|
|
262
|
+
preflightRunSingleSourceInCandidateCard(args: {
|
|
263
|
+
candidateCardContent: UnknownRecord;
|
|
264
|
+
mockProjections: UnknownRecord;
|
|
265
|
+
sourceIdx: number;
|
|
266
|
+
}): unknown;
|
|
267
|
+
preflightRunSingleSourceInLiveCard(args: {
|
|
268
|
+
cardId: string;
|
|
269
|
+
sourceIdx: number;
|
|
270
|
+
mockRequires: UnknownRecord;
|
|
271
|
+
}): unknown;
|
|
272
|
+
preflightRunOneCycleWithCandidateCard(args: {
|
|
273
|
+
candidateCardContent: UnknownRecord;
|
|
274
|
+
mockRequires: UnknownRecord;
|
|
275
|
+
}): BoardLiveCardsMcpPreflightRunOneCycleResult;
|
|
276
|
+
manageReadCard(args: {
|
|
277
|
+
cardId: string;
|
|
278
|
+
}): LiveCard[];
|
|
279
|
+
manageAddChatEntryAndAnyAttachments(args: {
|
|
280
|
+
cardId: string;
|
|
281
|
+
role: string;
|
|
282
|
+
text?: string;
|
|
283
|
+
turn?: string;
|
|
284
|
+
files?: unknown[];
|
|
285
|
+
}): BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult;
|
|
286
|
+
manageUpsertCard(args: {
|
|
287
|
+
cardId: string;
|
|
288
|
+
candidateCardContent: UnknownRecord;
|
|
289
|
+
}): BoardLiveCardsMcpManageUpsertCardResult;
|
|
290
|
+
manageDeprecate(args: {
|
|
291
|
+
cardId: string;
|
|
292
|
+
}): unknown;
|
|
293
|
+
}
|
|
294
|
+
declare function createBoardLiveCardsMcp(deps: BoardLiveCardsMcpDeps): BoardLiveCardsMcp;
|
|
295
|
+
|
|
296
|
+
export { type BoardLiveCardsMcp, type BoardLiveCardsMcpBoardDeps, type BoardLiveCardsMcpBoardStatusCard, type BoardLiveCardsMcpBoardStatusResult, type BoardLiveCardsMcpDeps, type BoardLiveCardsMcpDiscoverSourceKindsResult, type BoardLiveCardsMcpFileDownloadDescriptor, type BoardLiveCardsMcpInspectCardDefinitionAndRuntimeResult, type BoardLiveCardsMcpInspectChatMessagesResult, type BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult, type BoardLiveCardsMcpManageUpsertCardFailureResult, type BoardLiveCardsMcpManageUpsertCardResult, type BoardLiveCardsMcpManageUpsertCardSuccessResult, type BoardLiveCardsMcpNonCoreDeps, type BoardLiveCardsMcpPreflightMaterializeResult, type BoardLiveCardsMcpPreflightRunOneCycleResult, type BoardLiveCardsMcpRenderedView, type BoardLiveCardsMcpRenderedViewElement, createBoardLiveCardsMcp };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {createRequire}from'module';import'ajv-formats';var ae=createRequire(import.meta.url);ae("./jsonata-sync.cjs");var de=createRequire(import.meta.url),L=de("./jsonata-sync.cjs"),V=L;function D(e,r){if(!r||!e)return;let s=r.split("."),t=e;for(let a=0;a<s.length;a++){if(t==null)return;t=t[s[a]];}return t}function K(e,r,s){let t=r.split("."),a=e;for(let c=0;c<t.length-1;c++)(a[t[c]]==null||typeof a[t[c]]!="object")&&(a[t[c]]={}),a=a[t[c]];a[t[t.length-1]]=s;}async function ce(e,r){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=r?.sourcesData??{};let s=e.requires??{},t={card_data:e.card_data,requires:s,expects_data:s,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let a of e.compute)try{let c=await L(a.expr).evaluate(t);K(e.computed_values,a.bindTo,c),t.computed_values=e.computed_values;}catch{}return e}function ue(e,r){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=r?.sourcesData??{};let s=e.requires??{},t={card_data:e.card_data,requires:s,expects_data:s,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},a=[];for(let c of e.compute)try{let l=V(c.expr).evaluate(t);K(e.computed_values,c.bindTo,l),t.computed_values=e.computed_values;}catch(l){let m=l instanceof Error?l.message:String(l);a.push({bindTo:c.bindTo,error:m});}return a.length>0?{ok:true,node:e,errors:a}:{ok:true,node:e}}async function pe(e,r,s){let t={...s??{},card_data:r.card_data??{},requires:r.requires??{},fetched_sources:r._sourcesData??{},computed_values:r.computed_values??{}};return L(e).evaluate(t)}function le(e,r){return r.startsWith("fetched_sources.")?D(e._sourcesData??{},r.slice(16)):D(e,r)}var P=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),fe=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function me(e){let r=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let s=e;(typeof s.id!="string"||!s.id)&&r.push("id: required, must be a non-empty string");for(let t of Object.keys(s))fe.has(t)||r.push(`Unknown top-level key: "${t}"`);if((s.card_data==null||typeof s.card_data!="object"||Array.isArray(s.card_data))&&r.push("card_data: required, must be an object"),s.meta!=null)if(typeof s.meta!="object"||Array.isArray(s.meta))r.push("meta: must be an object");else {let t=s.meta;t.title!=null&&typeof t.title!="string"&&r.push("meta.title: must be a string"),t.tags!=null&&!Array.isArray(t.tags)&&r.push("meta.tags: must be an array");}if(s.requires!=null&&!Array.isArray(s.requires)&&r.push("requires: must be an array of strings"),s.provides!=null&&(Array.isArray(s.provides)?s.provides.forEach((t,a)=>{if(!t||typeof t!="object"||Array.isArray(t))r.push(`provides[${a}]: must be an object with bindTo and ref`);else {let c=t;(typeof c.bindTo!="string"||!c.bindTo)&&r.push(`provides[${a}]: missing required "bindTo" string`),(typeof c.ref!="string"||!c.ref)&&r.push(`provides[${a}]: missing required "ref" string`);}}):r.push("provides: must be an array of { bindTo, ref } bindings")),s.compute!=null&&(Array.isArray(s.compute)?s.compute.forEach((t,a)=>{if(!t||typeof t!="object"||Array.isArray(t))r.push(`compute[${a}]: must be a compute step object`);else {let c=t;(typeof c.bindTo!="string"||!c.bindTo)&&r.push(`compute[${a}]: missing required "bindTo" property`),(typeof c.expr!="string"||!c.expr)&&r.push(`compute[${a}]: missing required "expr" string (JSONata expression)`);}}):r.push("compute: must be an array of compute steps")),s.source_defs!=null)if(!Array.isArray(s.source_defs))r.push("source_defs: must be an array");else {let t=new Set,a=new Set;s.source_defs.forEach((c,l)=>{if(!c||typeof c!="object"||Array.isArray(c))r.push(`source_defs[${l}]: must be an object`);else {let m=c;typeof m.bindTo!="string"||!m.bindTo?r.push(`source_defs[${l}]: missing required "bindTo" property`):(t.has(m.bindTo)&&r.push(`source_defs[${l}]: bindTo "${m.bindTo}" is not unique across source_defs`),t.add(m.bindTo)),typeof m.outputFile!="string"||!m.outputFile?r.push(`source_defs[${l}]: missing required "outputFile" property`):(a.has(m.outputFile)&&r.push(`source_defs[${l}]: outputFile "${m.outputFile}" is not unique across source_defs`),a.add(m.outputFile)),m.optionalForCompletionGating!=null&&typeof m.optionalForCompletionGating!="boolean"&&r.push(`source_defs[${l}]: optionalForCompletionGating must be a boolean`);}});}if(s.view!=null)if(typeof s.view!="object"||Array.isArray(s.view))r.push("view: must be an object");else {let t=s.view;!Array.isArray(t.elements)||t.elements.length===0?r.push("view.elements: required, must be a non-empty array"):t.elements.forEach((a,c)=>{if(!a||typeof a!="object"){r.push(`view.elements[${c}]: must be an object`);return}!a.kind||typeof a.kind!="string"?r.push(`view.elements[${c}].kind: required, must be a string`):P.has(a.kind)||r.push(`view.elements[${c}].kind: unknown kind "${a.kind}". Valid: ${[...P].join(", ")}`),a.data!=null&&(typeof a.data!="object"||Array.isArray(a.data))&&r.push(`view.elements[${c}].data: must be an object`);}),t.layout!=null&&(typeof t.layout!="object"||Array.isArray(t.layout))&&r.push("view.layout: must be an object"),t.features!=null&&(typeof t.features!="object"||Array.isArray(t.features))&&r.push("view.features: must be an object");}return {ok:r.length===0,errors:r}}async function ge(e,r){if(!e||e.length===0)return [];let s={card_data:r.card_data??{},requires:r.requires??{}};return Promise.all(e.map(async t=>{let a={};if(t.projections&&typeof t.projections=="object"&&!Array.isArray(t.projections)){for(let[c,l]of Object.entries(t.projections))if(typeof l=="string"&&l.trim().length>0)try{a[c]=await L(l).evaluate(s);}catch{a[c]=void 0;}}return {...t,_projections:a}}))}function ye(e,r){if(!e||e.length===0)return [];let s={card_data:r.card_data??{},requires:r.requires??{}};return e.map(t=>{let a={};if(t.projections&&typeof t.projections=="object"&&!Array.isArray(t.projections)){for(let[c,l]of Object.entries(t.projections))if(typeof l=="string"&&l.trim().length>0)try{a[c]=V(l).evaluate(s);}catch{a[c]=void 0;}}return {...t,_projections:a}})}var z={run:ce,runSync:ue,eval:pe,resolve:le,validate:me,enrichSources:ge,enrichSourcesSync:ye};function _(e,r){if(e?.status==="success")return Object.prototype.hasOwnProperty.call(e,"data")?e.data:void 0;throw e?.status==="fail"||e?.status==="error"?new Error(e.error||`${r} failed`):new Error(`${r} returned an unexpected response`)}function we(e,r){if(e?.status==="success"&&Object.prototype.hasOwnProperty.call(e,"data"))return e.data;throw e?.status==="success"?new Error(`${r} returned success without data`):e?.status==="fail"||e?.status==="error"?new Error(e.error||`${r} failed`):new Error(`${r} returned an unexpected response`)}function d(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function C(e){return Array.isArray(e)?e:[]}function O(e,r){if(typeof r!="string"||r.length===0)return;let s=e,t=r;t.startsWith("fetched_sources.")&&(s=d(e).fetched_sources,t=t.slice(16));for(let a of t.split(".")){if(s==null||typeof s!="object")return;s=s[a];}return s}function F(e,r){let s=d(e.view),t=C(s.elements);return {layout:s.layout,features:s.features,elements:t.map((a,c)=>{let l=d(a),m=d(l.data),q=typeof l.visible=="string"?!!O(r,l.visible):true,S=typeof m.bind=="string"?m.bind:void 0,I=S?O(r,S):void 0,x={id:typeof l.id=="string"&&l.id?l.id:`element-${c}`,kind:l.kind,label:l.label,visible:q};return S&&(x.bind=S),Array.isArray(m.columns)&&(x.columns=m.columns),typeof m.maxRows=="number"&&(x.maxRows=m.maxRows),I!==void 0&&(x.resolved=Array.isArray(I)&&typeof x.maxRows=="number"?I.slice(0,x.maxRows):I),x})}}function W(e,r){let s=typeof e.id=="string"&&e.id?e.id:"card",t=C(e.provides),a=t.length>0?t:[{bindTo:s,ref:"card_data"}],c={};for(let l of a){let m=d(l),q=typeof m.bindTo=="string"?m.bindTo:"",S=typeof m.ref=="string"?m.ref:"";if(!q||!S)continue;let I=O(r,S);I!==void 0&&(c[q]=I);}return c}function be(e){if(typeof e!="string"||!e.trim())return null;let r=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(e.trim());if(!r)return null;let s=Number.parseInt(r[2],10);return !Number.isInteger(s)||s<0?null:s}function Ce(e){return {"card-content":e}}function M(e,r){let s=_(e.get({params:{id:r}}),"cardStore.get"),t=Array.isArray(s?.cards)?s.cards:[];if(t.length===0)throw new Error(`Card "${r}" not found`);return t[0]}function $e(e){let{board:r,nonCore:s,cardStore:t,chatStore:a,uploadCardFile:c,buildFileDownloadUrl:l,readFetchedSourceJsonByRef:m}=e;function q(n){if(Array.isArray(n.bytes))return new Uint8Array(n.bytes.map(o=>Math.max(0,Math.min(255,Number(o)||0))));if(typeof n.text=="string")return new TextEncoder().encode(n.text);if(typeof n.base64=="string"){let o=String(n.base64).replace(/-/g,"+").replace(/_/g,"/"),i=o+"=".repeat((4-o.length%4)%4),g=atob(i);return Uint8Array.from(g,u=>u.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function S(){let n=d(_(s.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:n.version,commonSourceFields:d(n.commonSourceDefFields),sourceKinds:d(n.sourceKinds)}}function I(){let n=d(_(r.status({}),"status")),o=d(n.summary),i=C(n.cards);return {meta:d(n.meta),summary:{card_count:typeof o.card_count=="number"?o.card_count:0,completed:typeof o.completed=="number"?o.completed:0,eligible:typeof o.eligible=="number"?o.eligible:0,pending:typeof o.pending=="number"?o.pending:0,blocked:typeof o.blocked=="number"?o.blocked:0,in_progress:typeof o.in_progress=="number"?o.in_progress:0,failed:typeof o.failed=="number"?o.failed:0,unresolved:typeof o.unresolved=="number"?o.unresolved:0},cards:i.map(g=>{let u=d(g);return {"card-id":typeof u.name=="string"?u.name:null,status:u.status??null,error:u.error??null,requires:C(u.requires),requires_satisfied:C(u.requires_satisfied),requires_missing:C(u.requires_missing),provides_declared:C(u.provides_declared),provides_runtime:C(u.provides_runtime)}})}}function x(n){let o=String(n.cardId||"").trim();if(!o)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let i=d(_(r.status({}),"status")),u=C(i.cards).map(d).find(f=>f.name===o);if(!u)throw new Error(`card "${o}" not found in board status`);let p=d(M(t,o)),y=C(u.requires_satisfied).filter(f=>typeof f=="string"&&!!f),v=C(u.provides_runtime).filter(f=>typeof f=="string"&&!!f),w=Object.fromEntries(y.map(f=>[f,_(r.getOutputsDataObject({params:{key:f}}),`getOutputsDataObject(${f})`)])),h=Object.fromEntries(v.map(f=>[f,_(r.getOutputsDataObject({params:{key:f}}),`getOutputsDataObject(${f})`)])),R=d(_(r.getOutputsComputedValues({params:{key:o}}),"getOutputsComputedValues")),b=_(r.getOutputsFetchedSources({params:{key:o}}),"getOutputsFetchedSources"),j=C(p.source_defs).map(d),A={};for(let f of j)typeof f.bindTo=="string"&&typeof f.outputFile=="string"&&(A[f.outputFile]=f.bindTo);let k={};for(let[f,T]of Object.entries(b)){let E=A[f]??f;if(!m||typeof T!="string"){k[E]=null;continue}try{k[E]=m({cardId:o,ref:T});}catch{k[E]=null;}}let $={card_data:d(p.card_data),requires:w,fetched_sources:k,computed_values:R};return {cardId:o,card_status_in_board:u,card_definition_and_static_data:p,refs_for_fetched_source_files:b,runtime_data:{requires:w,provides:h,computed_values:R,rendered_view:F(p,$)}}}function J(n){let o=String(n.cardId||"").trim();if(!o)throw new Error("inspectChatMessagesOnCards requires cardId");let i=typeof n.turnId=="string"?n.turnId:"",g=n.allTurns===true,u=typeof n.tailTurnsBeforeId=="string"?n.tailTurnsBeforeId:"",p=g?void 0:n.lastUserTurns??(i?void 0:1),y=n.tail,v={...p===void 0?{}:{tailTurns:p},...i?{turnId:i}:{},...g?{allTurns:true}:{},...u?{tailTurnsBeforeId:u}:{}},w=Object.keys(v).length>0?{params:{cardId:o},body:v}:{params:{cardId:o}},h=_(a.readAll(w),"chatStore.readAll"),R=d(M(t,o)),b=C(d(R.card_data).files).map((k,$)=>({idx:$,stored_name:d(k).stored_name})).filter(k=>typeof k.stored_name=="string"&&k.stored_name.length>0),A=(Array.isArray(h.records)?h.records:[]).map(k=>{let f=d(k.payload),T={...k},E=typeof k?.role=="string"?k.role:typeof f.role=="string"?String(f.role):"",oe=typeof k?.text=="string"?k.text:typeof f.text=="string"?String(f.text):"";if(E==="system"){let B=be(oe);if(B!==null&&b.some(U=>U.idx===B)){let U=`Retrieve using inspect-file-contents --card-id ${o} --file-idx ${B}`;T.retrieval_hint=U,Object.keys(f).length>0&&typeof k.role!="string"&&(T.payload={...f,retrieval_hint:U});}}return T});return {cardId:o,messages:typeof y=="number"&&y>=0?A.slice(-y):A}}function G(n){let o=String(n.cardId||"").trim(),i=Number(n.fileIdx);if(!o)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(i)||i<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let g=d(M(t,o)),u=C(d(g.card_data).files).map(d);if(i>=u.length)throw new Error(`attachment index ${i} is out of range for card "${o}"`);let p=u[i],y=typeof p.stored_name=="string"?p.stored_name:null;return {cardId:o,fileIdx:i,downloadUrl:l({cardId:o,fileIdx:i,storedName:y}),...typeof p.name=="string"?{name:p.name}:{},...typeof p.stored_name=="string"?{stored_name:p.stored_name}:{},...typeof p.mime_type=="string"?{mime_type:p.mime_type}:{},...typeof p.size=="number"?{size:p.size}:{},...typeof p.uploaded_at=="string"?{uploaded_at:p.uploaded_at}:{}}}function N(n){return s.validateCardPreflight({body:Ce(n.candidateCardContent)})}function H(n){if(!n.mockRequires||typeof n.mockRequires!="object"||Array.isArray(n.mockRequires))throw new Error("preflightMaterializeCandidateCard requires mockRequires");if(!n.mockFetchedSources||typeof n.mockFetchedSources!="object"||Array.isArray(n.mockFetchedSources))throw new Error("preflightMaterializeCandidateCard requires mockFetchedSources");let o=s.evalCardCompute({body:{"card-content":n.candidateCardContent,"mock-requires":n.mockRequires,"mock-fetched-sources":n.mockFetchedSources}});if(o.status!=="success")return o;let i=d(we(o,"evalCardCompute")),g=d(n.candidateCardContent),u={card_data:d(g.card_data),requires:d(n.mockRequires),fetched_sources:d(n.mockFetchedSources),computed_values:d(i.computed_values)};return {status:"success",data:{cardId:typeof i.cardId=="string"?i.cardId:typeof g.id=="string"?g.id:"(unknown)",ok:i.ok===true,computed_values:d(i.computed_values),errors:C(i.errors).map(p=>{let y=d(p);return {bindTo:typeof y.bindTo=="string"?y.bindTo:"",error:typeof y.error=="string"?y.error:""}}),provides_outputs:W(g,u),rendered_view:F(g,u)}}}function Y(n){return s.probeSourcePreflight({params:{sourceIdx:n.sourceIdx},body:{"card-content":n.candidateCardContent,"mock-projections":n.mockProjections}})}function Q(n){return s.runSourcePreflight({params:{sourceIdx:n.sourceIdx},body:{"card-content":n.candidateCardContent,"mock-projections":n.mockProjections}})}function X(n){let o=String(n.cardId||"").trim();if(!o)throw new Error("preflightRunSingleSourceInLiveCard requires cardId");if(!n.mockRequires||typeof n.mockRequires!="object"||Array.isArray(n.mockRequires))throw new Error("preflightRunSingleSourceInLiveCard requires mockRequires");let i=d(M(t,o)),g=C(i.source_defs).filter(p=>!!p&&typeof p=="object"&&!Array.isArray(p)),u={};if(n.sourceIdx>=0&&n.sourceIdx<g.length){let p=g[n.sourceIdx],y=z.enrichSourcesSync([p],{card_data:d(i.card_data),requires:n.mockRequires});Array.isArray(y)&&y.length>0&&(u=d(y[0]._projections));}return s.runSourcePreflight({params:{sourceIdx:n.sourceIdx},body:{"card-content":i,"mock-requires":n.mockRequires,"mock-projections":u}})}function Z(n){let o=d(_(s.simulateCardCycle({body:{"card-content":n.candidateCardContent,"mock-requires":n.mockRequires}}),"simulateCardCycle")),i=d(n.candidateCardContent),g=d(o.validation),u=C(o.source_probes),p=C(o.projection_errors),y=C(o.compute_errors),v=d(o.computed_values),w={card_data:d(i.card_data),requires:n.mockRequires,fetched_sources:{},computed_values:v},h=[];for(let R of C(g.issues))typeof R=="string"&&R&&h.push(R);for(let R of u){let b=d(R),j=typeof b.bindTo=="string"?b.bindTo:"source",A=typeof b.error=="string"?b.error:"";A&&h.push(`${j}: ${A}`);}for(let R of p){let b=d(R),j=typeof b.bindTo=="string"?b.bindTo:"source",A=typeof b.key=="string"?b.key:"projection",k=typeof b.error=="string"?b.error:"projection failed";h.push(`${j}.${A}: ${k}`);}for(let R of y){let b=d(R),j=typeof b.bindTo=="string"?b.bindTo:"compute",A=typeof b.error=="string"?b.error:"compute failed";h.push(`${j}: ${A}`);}return {status:"success",data:{cardId:typeof o.cardId=="string"?o.cardId:"(unknown)",ok:o.ok===true,issues:h,provides_outputs:W(i,w),rendered_view:F(i,w)}}}function ee(n){let o=String(n.cardId||"").trim();if(!o)throw new Error("manageReadCard requires cardId");let i=_(t.get({params:{id:o}}),"cardStore.get");return Array.isArray(i.cards)?i.cards:[]}function re(n){let o=String(n.cardId||"").trim(),i=String(n.role||"").trim(),g=typeof n.text=="string"?n.text:"",u=typeof n.turn=="string"?n.turn:"";if(!o)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!i)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let p=C(n.files).map(v=>{let w=d(v),h=String(w.file_name??w.fileName??w.name??"").trim(),R=String(w.content_type??w.contentType??"application/octet-stream");if(!h)throw new Error("file entry requires file_name");return c({cardId:o,fileName:h,contentType:R,bytes:q(w)}).file});p.forEach((v,w)=>{let h=i==="assistant"?`AI generated: ${String(v.name||"")} as ${String(v.stored_name||"")} #${w}`:`file uploaded: ${String(v.name||"")} as ${String(v.stored_name||"")} #${w}`;_(a.append({params:{cardId:o},body:{role:"system",text:h,files:[],turn:u}}),"chatStore.append(system attachment message)");});let y=_(a.append({params:{cardId:o},body:{role:i,text:g,files:p,turn:u}}),"chatStore.append");return {status:"success",data:{cardId:o,id:String(y.id),role:i,turn:u,files:p}}}function te(n){let o=String(n.cardId||"").trim(),i=d(n.candidateCardContent);if(!o)throw new Error("manageUpsertCard requires cardId");if(typeof i.id!="string"||!i.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(i.id!==o)throw new Error(`candidateCardContent.id must match cardId (${o})`);let g=N({candidateCardContent:i}),u=d(g),p=d(u.data);if(u.status!=="success"||p.isValid!==true)return {status:"fail",step:"validate",validation:g};let y=null;try{y=M(t,o);}catch{y=null;}let v=t.set({body:i});_(v,"cardStore.set");let w;try{w=r.upsertCard({params:{cardId:o,restart:!0}}),_(w,"upsertCard");}catch(R){try{y&&t.set({body:y});}catch{}throw R}let h=null;try{h=r.cardRefreshedNotify({params:{cardId:o}}),_(h,"cardRefreshedNotify");}catch{h=null;}return {status:"success",data:{validation:g,card_saved:null,board_result:w,refresh_notify:h}}}function ne(n){let o=String(n.cardId||"").trim();if(!o)throw new Error("manageDeprecate requires cardId");let i=r.removeCard({params:{id:o}});return _(i,"removeCard"),i}return {discoverSourceKinds:S,inspectBoardRuntimeStatus:I,inspectCardDefinitionAndRuntime:x,inspectChatMessagesOnCards:J,inspectFileContents:G,preflightValidateCandidateCardDefinition:N,preflightMaterializeCandidateCard:H,preflightProbeSingleSourceInCandidateCard:Y,preflightRunSingleSourceInCandidateCard:Q,preflightRunSingleSourceInLiveCard:X,preflightRunOneCycleWithCandidateCard:Z,manageReadCard:ee,manageAddChatEntryAndAnyAttachments:re,manageUpsertCard:te,manageDeprecate:ne}}export{$e as createBoardLiveCardsMcp};//# sourceMappingURL=board-live-cards-mcp.js.map
|
|
2
|
+
//# sourceMappingURL=board-live-cards-mcp.js.map
|