yaml-flow 8.5.0 → 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.
Files changed (44) hide show
  1. package/browser/asset-integrity.json +3 -3
  2. package/browser/board-livecards-client.js +1 -1
  3. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
  4. package/cli/bundled/board-live-cards-cli.mjs +13 -13
  5. package/cli/bundled/chat-store-cli.mjs +13 -13
  6. package/cli/{types-D2s3VzyY.d.ts → types-H3EMBPY2.d.ts} +7 -2
  7. package/examples/board/demo-shell-with-server.html +2 -2
  8. package/examples/board/doc.html +2 -2
  9. package/examples/board/server/README-mcp-api.md +680 -0
  10. package/examples/board/test/server-http-mcp-test.js +391 -34
  11. package/examples/board-local/demo-shell-localstorage.html +3 -3
  12. package/lib/artifacts-store-public.d.cts +1 -1
  13. package/lib/artifacts-store-public.d.ts +1 -1
  14. package/lib/board-live-cards-mcp.cjs +1 -1
  15. package/lib/board-live-cards-mcp.d.cts +42 -5
  16. package/lib/board-live-cards-mcp.d.ts +42 -5
  17. package/lib/board-live-cards-mcp.js +1 -1
  18. package/lib/board-live-cards-node.cjs +14 -14
  19. package/lib/board-live-cards-node.d.cts +4 -4
  20. package/lib/board-live-cards-node.d.ts +4 -4
  21. package/lib/board-live-cards-node.js +14 -14
  22. package/lib/{board-live-cards-public-CvkDfZQ7.d.cts → board-live-cards-public-B13InXhC.d.cts} +7 -2
  23. package/lib/{board-live-cards-public-DdVhH4M-.d.ts → board-live-cards-public-BGS22cMb.d.ts} +7 -2
  24. package/lib/board-live-cards-public.cjs +1 -1
  25. package/lib/board-live-cards-public.d.cts +1 -1
  26. package/lib/board-live-cards-public.d.ts +1 -1
  27. package/lib/board-live-cards-public.js +1 -1
  28. package/lib/board-live-cards-server-runtime.cjs +4 -4
  29. package/lib/board-live-cards-server-runtime.d.cts +2 -2
  30. package/lib/board-live-cards-server-runtime.d.ts +2 -2
  31. package/lib/board-live-cards-server-runtime.js +4 -4
  32. package/lib/card-store-public.d.cts +1 -1
  33. package/lib/card-store-public.d.ts +1 -1
  34. package/lib/chat-store-public.cjs +1 -1
  35. package/lib/chat-store-public.d.cts +6 -1
  36. package/lib/chat-store-public.d.ts +6 -1
  37. package/lib/chat-store-public.js +1 -1
  38. package/lib/server-runtime/index.cjs +4 -4
  39. package/lib/server-runtime/index.d.cts +3 -3
  40. package/lib/server-runtime/index.d.ts +3 -3
  41. package/lib/server-runtime/index.js +4 -4
  42. package/lib/{types-QNI__eAf.d.ts → types-30R357js.d.ts} +1 -1
  43. package/lib/{types-NM_d_1oZ.d.cts → types-CIgsh56O.d.cts} +1 -1
  44. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- 'use strict';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}}exports.createBoardLiveCardsMcp=Z;//# sourceMappingURL=board-live-cards-mcp.cjs.map
1
+ 'use strict';var module$1=require('module');require('ajv-formats');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var ae=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-mcp.cjs', document.baseURI).href)));ae("./jsonata-sync.cjs");var de=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('board-live-cards-mcp.cjs', document.baseURI).href))),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}}exports.createBoardLiveCardsMcp=$e;//# sourceMappingURL=board-live-cards-mcp.cjs.map
2
2
  //# sourceMappingURL=board-live-cards-mcp.cjs.map
@@ -1,4 +1,4 @@
1
- import { L as LiveCard, C as CommandResult } from './board-live-cards-public-CvkDfZQ7.cjs';
1
+ import { C as CommandResult, L as LiveCard } from './board-live-cards-public-B13InXhC.cjs';
2
2
  import { CardStorePublic } from './card-store-public.cjs';
3
3
  import { ChatStorePublic } from './chat-store-public.cjs';
4
4
  import { C as ChatRecord } from './chat-storage-lib-0imhRX3l.cjs';
@@ -114,6 +114,30 @@ interface BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult {
114
114
  files: Array<Record<string, unknown>>;
115
115
  };
116
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
+ }
117
141
  interface BoardLiveCardsMcpBoardDeps {
118
142
  status(input: {}): CommandResult;
119
143
  getOutputsDataObject(input: {
@@ -155,7 +179,15 @@ interface BoardLiveCardsMcpNonCoreDeps {
155
179
  }): CommandResult;
156
180
  evalCardCompute(input: {
157
181
  body: unknown;
158
- }): CommandResult;
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
+ }>;
159
191
  probeSourcePreflight(input: {
160
192
  params: {
161
193
  sourceIdx: number;
@@ -221,7 +253,7 @@ interface BoardLiveCardsMcp {
221
253
  candidateCardContent: UnknownRecord;
222
254
  mockRequires: UnknownRecord;
223
255
  mockFetchedSources: UnknownRecord;
224
- }): unknown;
256
+ }): BoardLiveCardsMcpPreflightMaterializeResult | CommandResult;
225
257
  preflightProbeSingleSourceInCandidateCard(args: {
226
258
  candidateCardContent: UnknownRecord;
227
259
  mockProjections: UnknownRecord;
@@ -232,10 +264,15 @@ interface BoardLiveCardsMcp {
232
264
  mockProjections: UnknownRecord;
233
265
  sourceIdx: number;
234
266
  }): unknown;
267
+ preflightRunSingleSourceInLiveCard(args: {
268
+ cardId: string;
269
+ sourceIdx: number;
270
+ mockRequires: UnknownRecord;
271
+ }): unknown;
235
272
  preflightRunOneCycleWithCandidateCard(args: {
236
273
  candidateCardContent: UnknownRecord;
237
274
  mockRequires: UnknownRecord;
238
- }): unknown;
275
+ }): BoardLiveCardsMcpPreflightRunOneCycleResult;
239
276
  manageReadCard(args: {
240
277
  cardId: string;
241
278
  }): LiveCard[];
@@ -256,4 +293,4 @@ interface BoardLiveCardsMcp {
256
293
  }
257
294
  declare function createBoardLiveCardsMcp(deps: BoardLiveCardsMcpDeps): BoardLiveCardsMcp;
258
295
 
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 };
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 };
@@ -1,4 +1,4 @@
1
- import { L as LiveCard, C as CommandResult } from './board-live-cards-public-DdVhH4M-.js';
1
+ import { C as CommandResult, L as LiveCard } from './board-live-cards-public-BGS22cMb.js';
2
2
  import { CardStorePublic } from './card-store-public.js';
3
3
  import { ChatStorePublic } from './chat-store-public.js';
4
4
  import { C as ChatRecord } from './chat-storage-lib-CJn7a6OH.js';
@@ -114,6 +114,30 @@ interface BoardLiveCardsMcpManageAddChatEntryAndAnyAttachmentsResult {
114
114
  files: Array<Record<string, unknown>>;
115
115
  };
116
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
+ }
117
141
  interface BoardLiveCardsMcpBoardDeps {
118
142
  status(input: {}): CommandResult;
119
143
  getOutputsDataObject(input: {
@@ -155,7 +179,15 @@ interface BoardLiveCardsMcpNonCoreDeps {
155
179
  }): CommandResult;
156
180
  evalCardCompute(input: {
157
181
  body: unknown;
158
- }): CommandResult;
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
+ }>;
159
191
  probeSourcePreflight(input: {
160
192
  params: {
161
193
  sourceIdx: number;
@@ -221,7 +253,7 @@ interface BoardLiveCardsMcp {
221
253
  candidateCardContent: UnknownRecord;
222
254
  mockRequires: UnknownRecord;
223
255
  mockFetchedSources: UnknownRecord;
224
- }): unknown;
256
+ }): BoardLiveCardsMcpPreflightMaterializeResult | CommandResult;
225
257
  preflightProbeSingleSourceInCandidateCard(args: {
226
258
  candidateCardContent: UnknownRecord;
227
259
  mockProjections: UnknownRecord;
@@ -232,10 +264,15 @@ interface BoardLiveCardsMcp {
232
264
  mockProjections: UnknownRecord;
233
265
  sourceIdx: number;
234
266
  }): unknown;
267
+ preflightRunSingleSourceInLiveCard(args: {
268
+ cardId: string;
269
+ sourceIdx: number;
270
+ mockRequires: UnknownRecord;
271
+ }): unknown;
235
272
  preflightRunOneCycleWithCandidateCard(args: {
236
273
  candidateCardContent: UnknownRecord;
237
274
  mockRequires: UnknownRecord;
238
- }): unknown;
275
+ }): BoardLiveCardsMcpPreflightRunOneCycleResult;
239
276
  manageReadCard(args: {
240
277
  cardId: string;
241
278
  }): LiveCard[];
@@ -256,4 +293,4 @@ interface BoardLiveCardsMcp {
256
293
  }
257
294
  declare function createBoardLiveCardsMcp(deps: BoardLiveCardsMcpDeps): BoardLiveCardsMcp;
258
295
 
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 };
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 };
@@ -1,2 +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
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
2
  //# sourceMappingURL=board-live-cards-mcp.js.map