yaml-flow 8.4.23 → 8.5.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/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 +6 -6
- package/cli/{types-juH2nFpz.d.ts → types-D2s3VzyY.d.ts} +3 -2
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board/server/board-server.js +8 -0
- package/examples/board/server/chat-flow/copilot-chat/assistant.js +4 -2
- package/examples/board/server/chat-flow/flow-steps.json +70 -10
- package/examples/board/test/server-http-mcp-test.js +791 -0
- package/examples/board/test/server-http-test.js +32 -15
- 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 +259 -0
- package/lib/board-live-cards-mcp.d.ts +259 -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-CvkDfZQ7.d.cts} +1 -1
- package/lib/{board-live-cards-public-ydXuA4zh.d.ts → board-live-cards-public-DdVhH4M-.d.ts} +1 -1
- 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 +2 -2
- package/lib/chat-store-public.d.ts +2 -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-D501gMQt.d.cts → types-NM_d_1oZ.d.cts} +5 -2
- package/lib/{types-1L1D33mr.d.ts → types-QNI__eAf.d.ts} +5 -2
- package/package.json +10 -2
- package/browser/board-livecards-localstorage.js +0 -10
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { L as LiveCard, C as CommandResult } from './board-live-cards-public-DdVhH4M-.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 BoardLiveCardsMcpBoardDeps {
|
|
118
|
+
status(input: {}): CommandResult;
|
|
119
|
+
getOutputsDataObject(input: {
|
|
120
|
+
params: {
|
|
121
|
+
key: string;
|
|
122
|
+
};
|
|
123
|
+
}): CommandResult;
|
|
124
|
+
getOutputsComputedValues(input: {
|
|
125
|
+
params: {
|
|
126
|
+
key: string;
|
|
127
|
+
};
|
|
128
|
+
}): CommandResult;
|
|
129
|
+
getOutputsFetchedSources(input: {
|
|
130
|
+
params: {
|
|
131
|
+
key: string;
|
|
132
|
+
};
|
|
133
|
+
}): CommandResult<Record<string, string>>;
|
|
134
|
+
removeCard(input: {
|
|
135
|
+
params: {
|
|
136
|
+
id: string;
|
|
137
|
+
};
|
|
138
|
+
}): CommandResult;
|
|
139
|
+
cardRefreshedNotify(input: {
|
|
140
|
+
params: {
|
|
141
|
+
cardId: string;
|
|
142
|
+
};
|
|
143
|
+
}): CommandResult;
|
|
144
|
+
upsertCard(input: {
|
|
145
|
+
params: {
|
|
146
|
+
cardId: string;
|
|
147
|
+
restart?: boolean;
|
|
148
|
+
};
|
|
149
|
+
}): CommandResult;
|
|
150
|
+
}
|
|
151
|
+
interface BoardLiveCardsMcpNonCoreDeps {
|
|
152
|
+
describeTaskExecutorCapabilities(input: {}): CommandResult;
|
|
153
|
+
validateCardPreflight(input: {
|
|
154
|
+
body: unknown;
|
|
155
|
+
}): CommandResult;
|
|
156
|
+
evalCardCompute(input: {
|
|
157
|
+
body: unknown;
|
|
158
|
+
}): CommandResult;
|
|
159
|
+
probeSourcePreflight(input: {
|
|
160
|
+
params: {
|
|
161
|
+
sourceIdx: number;
|
|
162
|
+
};
|
|
163
|
+
body: unknown;
|
|
164
|
+
}): CommandResult;
|
|
165
|
+
runSourcePreflight(input: {
|
|
166
|
+
params: {
|
|
167
|
+
sourceIdx: number;
|
|
168
|
+
};
|
|
169
|
+
body: unknown;
|
|
170
|
+
}): CommandResult;
|
|
171
|
+
simulateCardCycle(input: {
|
|
172
|
+
body: unknown;
|
|
173
|
+
}): CommandResult;
|
|
174
|
+
}
|
|
175
|
+
interface BoardLiveCardsMcpDeps {
|
|
176
|
+
board: BoardLiveCardsMcpBoardDeps;
|
|
177
|
+
nonCore: BoardLiveCardsMcpNonCoreDeps;
|
|
178
|
+
cardStore: CardStorePublic;
|
|
179
|
+
chatStore: ChatStorePublic;
|
|
180
|
+
uploadCardFile(args: {
|
|
181
|
+
cardId: string;
|
|
182
|
+
fileName: string;
|
|
183
|
+
contentType: string;
|
|
184
|
+
bytes: Uint8Array;
|
|
185
|
+
}): {
|
|
186
|
+
ok: true;
|
|
187
|
+
file: Record<string, unknown>;
|
|
188
|
+
};
|
|
189
|
+
buildFileDownloadUrl(args: {
|
|
190
|
+
cardId: string;
|
|
191
|
+
fileIdx: number;
|
|
192
|
+
storedName?: string | null;
|
|
193
|
+
}): string;
|
|
194
|
+
readFetchedSourceJsonByRef?(args: {
|
|
195
|
+
cardId: string;
|
|
196
|
+
ref: string;
|
|
197
|
+
}): unknown | null;
|
|
198
|
+
}
|
|
199
|
+
interface BoardLiveCardsMcp {
|
|
200
|
+
discoverSourceKinds(): BoardLiveCardsMcpDiscoverSourceKindsResult;
|
|
201
|
+
inspectBoardRuntimeStatus(): BoardLiveCardsMcpBoardStatusResult;
|
|
202
|
+
inspectCardDefinitionAndRuntime(args: {
|
|
203
|
+
cardId: string;
|
|
204
|
+
}): BoardLiveCardsMcpInspectCardDefinitionAndRuntimeResult;
|
|
205
|
+
inspectChatMessagesOnCards(args: {
|
|
206
|
+
cardId: string;
|
|
207
|
+
lastUserTurns?: number;
|
|
208
|
+
tail?: number;
|
|
209
|
+
turnId?: string;
|
|
210
|
+
allTurns?: boolean;
|
|
211
|
+
tailTurnsBeforeId?: string;
|
|
212
|
+
}): BoardLiveCardsMcpInspectChatMessagesResult;
|
|
213
|
+
inspectFileContents(args: {
|
|
214
|
+
cardId: string;
|
|
215
|
+
fileIdx: number;
|
|
216
|
+
}): BoardLiveCardsMcpFileDownloadDescriptor;
|
|
217
|
+
preflightValidateCandidateCardDefinition(args: {
|
|
218
|
+
candidateCardContent: UnknownRecord;
|
|
219
|
+
}): unknown;
|
|
220
|
+
preflightMaterializeCandidateCard(args: {
|
|
221
|
+
candidateCardContent: UnknownRecord;
|
|
222
|
+
mockRequires: UnknownRecord;
|
|
223
|
+
mockFetchedSources: UnknownRecord;
|
|
224
|
+
}): unknown;
|
|
225
|
+
preflightProbeSingleSourceInCandidateCard(args: {
|
|
226
|
+
candidateCardContent: UnknownRecord;
|
|
227
|
+
mockProjections: UnknownRecord;
|
|
228
|
+
sourceIdx: number;
|
|
229
|
+
}): unknown;
|
|
230
|
+
preflightRunSingleSourceInCandidateCard(args: {
|
|
231
|
+
candidateCardContent: UnknownRecord;
|
|
232
|
+
mockProjections: UnknownRecord;
|
|
233
|
+
sourceIdx: number;
|
|
234
|
+
}): unknown;
|
|
235
|
+
preflightRunOneCycleWithCandidateCard(args: {
|
|
236
|
+
candidateCardContent: UnknownRecord;
|
|
237
|
+
mockRequires: UnknownRecord;
|
|
238
|
+
}): unknown;
|
|
239
|
+
manageReadCard(args: {
|
|
240
|
+
cardId: string;
|
|
241
|
+
}): LiveCard[];
|
|
242
|
+
manageAddChatEntryAndAnyAttachments(args: {
|
|
243
|
+
cardId: string;
|
|
244
|
+
role: string;
|
|
245
|
+
text?: string;
|
|
246
|
+
turn?: string;
|
|
247
|
+
files?: unknown[];
|
|
248
|
+
}): BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult;
|
|
249
|
+
manageUpsertCard(args: {
|
|
250
|
+
cardId: string;
|
|
251
|
+
candidateCardContent: UnknownRecord;
|
|
252
|
+
}): BoardLiveCardsMcpManageUpsertCardResult;
|
|
253
|
+
manageDeprecate(args: {
|
|
254
|
+
cardId: string;
|
|
255
|
+
}): unknown;
|
|
256
|
+
}
|
|
257
|
+
declare function createBoardLiveCardsMcp(deps: BoardLiveCardsMcpDeps): BoardLiveCardsMcp;
|
|
258
|
+
|
|
259
|
+
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 BoardLiveCardsMcpRenderedView, type BoardLiveCardsMcpRenderedViewElement, createBoardLiveCardsMcp };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function m(a,i){if(a?.status==="success")return Object.prototype.hasOwnProperty.call(a,"data")?a.data:void 0;throw a?.status==="fail"||a?.status==="error"?new Error(a.error||`${i} failed`):new Error(`${i} returned an unexpected response`)}function d(a){return a&&typeof a=="object"&&!Array.isArray(a)?a:{}}function C(a){return Array.isArray(a)?a:[]}function F(a,i){if(typeof i!="string"||i.length===0)return;let c=a,p=i;p.startsWith("fetched_sources.")&&(c=d(a).fetched_sources,p=p.slice(16));for(let x of p.split(".")){if(c==null||typeof c!="object")return;c=c[x];}return c}function G(a,i){let c=d(a.view),p=C(c.elements);return {layout:c.layout,features:c.features,elements:p.map((x,T)=>{let k=d(x),v=d(k.data),q=typeof k.visible=="string"?!!F(i,k.visible):true,A=typeof v.bind=="string"?v.bind:void 0,M=A?F(i,A):void 0,I={id:typeof k.id=="string"&&k.id?k.id:`element-${T}`,kind:k.kind,label:k.label,visible:q};return A&&(I.bind=A),Array.isArray(v.columns)&&(I.columns=v.columns),typeof v.maxRows=="number"&&(I.maxRows=v.maxRows),M!==void 0&&(I.resolved=Array.isArray(M)&&typeof I.maxRows=="number"?M.slice(0,I.maxRows):M),I})}}function Q(a){if(typeof a!="string"||!a.trim())return null;let i=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(a.trim());if(!i)return null;let c=Number.parseInt(i[2],10);return !Number.isInteger(c)||c<0?null:c}function X(a){return {"card-content":a}}function O(a,i){let c=m(a.get({params:{id:i}}),"cardStore.get"),p=Array.isArray(c?.cards)?c.cards:[];if(p.length===0)throw new Error(`Card "${i}" not found`);return p[0]}function Z(a){let{board:i,nonCore:c,cardStore:p,chatStore:x,uploadCardFile:T,buildFileDownloadUrl:k,readFetchedSourceJsonByRef:v}=a;function q(r){if(Array.isArray(r.bytes))return new Uint8Array(r.bytes.map(e=>Math.max(0,Math.min(255,Number(e)||0))));if(typeof r.text=="string")return new TextEncoder().encode(r.text);if(typeof r.base64=="string"){let e=String(r.base64).replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),f=atob(n);return Uint8Array.from(f,o=>o.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function A(){let r=d(m(c.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:r.version,commonSourceFields:d(r.commonSourceDefFields),sourceKinds:d(r.sourceKinds)}}function M(){let r=d(m(i.status({}),"status")),e=d(r.summary),n=C(r.cards);return {meta:d(r.meta),summary:{card_count:typeof e.card_count=="number"?e.card_count:0,completed:typeof e.completed=="number"?e.completed:0,eligible:typeof e.eligible=="number"?e.eligible:0,pending:typeof e.pending=="number"?e.pending:0,blocked:typeof e.blocked=="number"?e.blocked:0,in_progress:typeof e.in_progress=="number"?e.in_progress:0,failed:typeof e.failed=="number"?e.failed:0,unresolved:typeof e.unresolved=="number"?e.unresolved:0},cards:n.map(f=>{let o=d(f);return {"card-id":typeof o.name=="string"?o.name:null,status:o.status??null,error:o.error??null,requires:C(o.requires),requires_satisfied:C(o.requires_satisfied),requires_missing:C(o.requires_missing),provides_declared:C(o.provides_declared),provides_runtime:C(o.provides_runtime)}})}}function I(r){let e=String(r.cardId||"").trim();if(!e)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let n=d(m(i.status({}),"status")),o=C(n.cards).map(d).find(s=>s.name===e);if(!o)throw new Error(`card "${e}" not found in board status`);let t=d(O(p,e)),g=C(o.requires_satisfied).filter(s=>typeof s=="string"&&!!s),b=C(o.provides_runtime).filter(s=>typeof s=="string"&&!!s),l=Object.fromEntries(g.map(s=>[s,m(i.getOutputsDataObject({params:{key:s}}),`getOutputsDataObject(${s})`)])),w=Object.fromEntries(b.map(s=>[s,m(i.getOutputsDataObject({params:{key:s}}),`getOutputsDataObject(${s})`)])),_=d(m(i.getOutputsComputedValues({params:{key:e}}),"getOutputsComputedValues")),U=m(i.getOutputsFetchedSources({params:{key:e}}),"getOutputsFetchedSources"),L=C(t.source_defs).map(d),u={};for(let s of L)typeof s.bindTo=="string"&&typeof s.outputFile=="string"&&(u[s.outputFile]=s.bindTo);let h={};for(let[s,B]of Object.entries(U)){let y=u[s]??s;if(!v||typeof B!="string"){h[y]=null;continue}try{h[y]=v({cardId:e,ref:B});}catch{h[y]=null;}}let R={card_data:d(t.card_data),requires:l,fetched_sources:h,computed_values:_};return {cardId:e,card_status_in_board:o,card_definition_and_static_data:t,refs_for_fetched_source_files:U,runtime_data:{requires:l,provides:w,computed_values:_,rendered_view:G(t,R)}}}function j(r){let e=String(r.cardId||"").trim();if(!e)throw new Error("inspectChatMessagesOnCards requires cardId");let n=typeof r.turnId=="string"?r.turnId:"",f=r.allTurns===true,o=typeof r.tailTurnsBeforeId=="string"?r.tailTurnsBeforeId:"",t=f?void 0:r.lastUserTurns??(n?void 0:1),g=r.tail,b=t===void 0?{params:{cardId:e}}:{params:{cardId:e},body:{lastUserTurns:t}},l=m(x.readAll(b),"chatStore.readAll"),w=d(O(p,e)),_=C(d(w.card_data).files).map((u,h)=>({idx:h,stored_name:d(u).stored_name})).filter(u=>typeof u.stored_name=="string"&&u.stored_name.length>0),U=(Array.isArray(l.records)?l.records:[]).filter(u=>n?typeof u?.turn=="string"?u.turn===n:n==="":true);if(o){if(t===void 0||!Number.isInteger(t)||t<=0)throw new Error("inspectChatMessagesOnCards requires tail-turns when tail-turns-before-id is provided");let u=new Map,h=[];for(let y of Array.isArray(l.records)?l.records:[]){let S=typeof y?.turn=="string"?y.turn:"";u.has(S)||(u.set(S,[]),h.push(S)),u.get(S).push(y);}let R=h.findIndex(y=>y===o),s=Math.max(0,R-t);U=(R===-1?[]:h.slice(s,R)).flatMap(y=>u.get(y)??[]);}let L=U.map(u=>{let R=d(u.payload),s={...u},B=typeof u?.role=="string"?u.role:typeof R.role=="string"?String(R.role):"",y=typeof u?.text=="string"?u.text:typeof R.text=="string"?String(R.text):"";if(B==="system"){let S=Q(y);if(S!==null&&_.some(D=>D.idx===S)){let D=`Retrieve using inspect-file-contents --card-id ${e} --file-idx ${S}`;s.retrieval_hint=D,Object.keys(R).length>0&&typeof u.role!="string"&&(s.payload={...R,retrieval_hint:D});}}return s});return {cardId:e,messages:typeof g=="number"&&g>=0?L.slice(-g):L}}function P(r){let e=String(r.cardId||"").trim(),n=Number(r.fileIdx);if(!e)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(n)||n<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let f=d(O(p,e)),o=C(d(f.card_data).files).map(d);if(n>=o.length)throw new Error(`attachment index ${n} is out of range for card "${e}"`);let t=o[n],g=typeof t.stored_name=="string"?t.stored_name:null;return {cardId:e,fileIdx:n,downloadUrl:k({cardId:e,fileIdx:n,storedName:g}),...typeof t.name=="string"?{name:t.name}:{},...typeof t.stored_name=="string"?{stored_name:t.stored_name}:{},...typeof t.mime_type=="string"?{mime_type:t.mime_type}:{},...typeof t.size=="number"?{size:t.size}:{},...typeof t.uploaded_at=="string"?{uploaded_at:t.uploaded_at}:{}}}function E(r){return c.validateCardPreflight({body:X(r.candidateCardContent)})}function $(r){return c.evalCardCompute({body:{"card-content":r.candidateCardContent,"mock-requires":r.mockRequires,"mock-fetched-sources":r.mockFetchedSources}})}function N(r){return c.probeSourcePreflight({params:{sourceIdx:r.sourceIdx},body:{"card-content":r.candidateCardContent,"mock-projections":r.mockProjections}})}function V(r){return c.runSourcePreflight({params:{sourceIdx:r.sourceIdx},body:{"card-content":r.candidateCardContent,"mock-projections":r.mockProjections}})}function K(r){return c.simulateCardCycle({body:{"card-content":r.candidateCardContent,"mock-requires":r.mockRequires}})}function z(r){let e=String(r.cardId||"").trim();if(!e)throw new Error("manageReadCard requires cardId");let n=m(p.get({params:{id:e}}),"cardStore.get");return Array.isArray(n.cards)?n.cards:[]}function W(r){let e=String(r.cardId||"").trim(),n=String(r.role||"").trim(),f=typeof r.text=="string"?r.text:"",o=typeof r.turn=="string"?r.turn:"";if(!e)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!n)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let t=C(r.files).map(b=>{let l=d(b),w=String(l.file_name??l.fileName??l.name??"").trim(),_=String(l.content_type??l.contentType??"application/octet-stream");if(!w)throw new Error("file entry requires file_name");return T({cardId:e,fileName:w,contentType:_,bytes:q(l)}).file});t.forEach((b,l)=>{let w=n==="assistant"?`AI generated: ${String(b.name||"")} as ${String(b.stored_name||"")} #${l}`:`file uploaded: ${String(b.name||"")} as ${String(b.stored_name||"")} #${l}`;m(x.append({params:{cardId:e},body:{role:"system",text:w,files:[],turn:o}}),"chatStore.append(system attachment message)");});let g=m(x.append({params:{cardId:e},body:{role:n,text:f,files:t,turn:o}}),"chatStore.append");return {status:"success",data:{cardId:e,id:String(g.id),role:n,turn:o,files:t}}}function J(r){let e=String(r.cardId||"").trim(),n=d(r.candidateCardContent);if(!e)throw new Error("manageUpsertCard requires cardId");if(typeof n.id!="string"||!n.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(n.id!==e)throw new Error(`candidateCardContent.id must match cardId (${e})`);let f=E({candidateCardContent:n}),o=d(f),t=d(o.data);if(o.status!=="success"||t.isValid!==true)return {status:"fail",step:"validate",validation:f};let g=null;try{g=O(p,e);}catch{g=null;}let b=p.set({body:n});m(b,"cardStore.set");let l;try{l=i.upsertCard({params:{cardId:e,restart:!0}}),m(l,"upsertCard");}catch(_){try{g&&p.set({body:g});}catch{}throw _}let w=null;try{w=i.cardRefreshedNotify({params:{cardId:e}}),m(w,"cardRefreshedNotify");}catch{w=null;}return {status:"success",data:{validation:f,card_saved:null,board_result:l,refresh_notify:w}}}function H(r){let e=String(r.cardId||"").trim();if(!e)throw new Error("manageDeprecate requires cardId");let n=i.removeCard({params:{id:e}});return m(n,"removeCard"),n}return {discoverSourceKinds:A,inspectBoardRuntimeStatus:M,inspectCardDefinitionAndRuntime:I,inspectChatMessagesOnCards:j,inspectFileContents:P,preflightValidateCandidateCardDefinition:E,preflightMaterializeCandidateCard:$,preflightProbeSingleSourceInCandidateCard:N,preflightRunSingleSourceInCandidateCard:V,preflightRunOneCycleWithCandidateCard:K,manageReadCard:z,manageAddChatEntryAndAnyAttachments:W,manageUpsertCard:J,manageDeprecate:H}}export{Z as createBoardLiveCardsMcp};//# sourceMappingURL=board-live-cards-mcp.js.map
|
|
2
|
+
//# sourceMappingURL=board-live-cards-mcp.js.map
|