yaml-flow 8.11.9 → 8.11.11
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 +5 -5
- package/browser/live-cards.schema.json +33 -2
- package/browser/server-runtime-controlface.js +5 -5
- package/lib/board-live-cards-mcp.cjs +1 -1
- package/lib/board-live-cards-mcp.js +1 -1
- package/lib/board-live-cards-node.cjs +2 -2
- package/lib/board-live-cards-node.js +1 -1
- package/lib/board-live-cards-public.cjs +1 -1
- package/lib/board-live-cards-public.js +1 -1
- package/lib/board-live-cards-server-runtime.cjs +1 -1
- package/lib/board-live-cards-server-runtime.js +1 -1
- package/lib/board-livegraph-runtime/index.cjs +1 -1
- package/lib/board-livegraph-runtime/index.js +1 -1
- package/lib/card-compute/index.cjs +1 -1
- package/lib/card-compute/index.js +1 -1
- package/lib/card-store-public.cjs +1 -1
- package/lib/card-store-public.js +1 -1
- package/lib/card-validation.cjs +1 -1
- package/lib/card-validation.js +1 -1
- package/lib/chunk-23X3V5FR.cjs +2 -0
- package/lib/{chunk-22S5GCQK.cjs → chunk-2AIIEBBL.cjs} +3 -3
- package/lib/chunk-3EITX4IQ.cjs +3 -0
- package/lib/chunk-4P52IVQN.cjs +2 -0
- package/lib/chunk-JQALMLNI.js +2 -0
- package/lib/chunk-NJCDHKPX.js +3 -0
- package/lib/{chunk-3C52UCJC.js → chunk-QOOIN523.js} +3 -3
- package/lib/chunk-WFMVZ3LO.js +2 -0
- package/lib/cloud-storage.cjs +1 -1
- package/lib/cloud-storage.js +1 -1
- package/lib/continuous-event-graph/index.cjs +1 -1
- package/lib/continuous-event-graph/index.js +1 -1
- package/lib/firestore-storage/index.cjs +1 -1
- package/lib/firestore-storage/index.js +1 -1
- package/lib/index.cjs +2 -2
- package/lib/index.js +1 -1
- package/lib/localstorage-storage/index.cjs +1 -1
- package/lib/localstorage-storage/index.js +1 -1
- package/lib/{mcp-tool-registries-CRtea2x4.d.cts → mcp-tool-registries-B6KrbGuh.d.cts} +9 -0
- package/lib/{mcp-tool-registries-D3rWSppt.d.ts → mcp-tool-registries-BbxbZCbF.d.ts} +9 -0
- package/lib/server-runtime/index.cjs +1 -1
- package/lib/server-runtime/index.js +1 -1
- package/lib/server-runtime-agentface/index.d.cts +1 -1
- package/lib/server-runtime-agentface/index.d.ts +1 -1
- package/lib/server-runtime-controlface/index.cjs +1 -1
- package/lib/server-runtime-controlface/index.js +1 -1
- package/lib/server-runtime-core/index.cjs +1 -1
- package/lib/server-runtime-core/index.d.cts +14 -1
- package/lib/server-runtime-core/index.d.ts +14 -1
- package/lib/server-runtime-core/index.js +1 -1
- package/lib/server-runtime-webhooks/index.d.cts +1 -1
- package/lib/server-runtime-webhooks/index.d.ts +1 -1
- package/package.json +1 -1
- package/schema/live-cards.schema.json +33 -2
- package/lib/chunk-3HCH2ZFB.cjs +0 -2
- package/lib/chunk-AW6XLBHX.cjs +0 -2
- package/lib/chunk-BSZYTSFX.js +0 -2
- package/lib/chunk-CVTL2EFR.js +0 -3
- package/lib/chunk-F6KRSQ7V.js +0 -2
- package/lib/chunk-P7STTKRO.cjs +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var chunkLFVMX23W_cjs=require('./chunk-LFVMX23W.cjs'),chunkNM6O35RY_cjs=require('./chunk-NM6O35RY.cjs'),chunkNBJTYAYN_cjs=require('./chunk-NBJTYAYN.cjs'),chunk3HCH2ZFB_cjs=require('./chunk-3HCH2ZFB.cjs'),chunkBQUQTOPB_cjs=require('./chunk-BQUQTOPB.cjs'),chunkGPCMBPLK_cjs=require('./chunk-GPCMBPLK.cjs'),chunk7FGPOGRV_cjs=require('./chunk-7FGPOGRV.cjs'),chunkLPXVVMQT_cjs=require('./chunk-LPXVVMQT.cjs'),chunk272IYUKT_cjs=require('./chunk-272IYUKT.cjs'),chunkTIQ775WI_cjs=require('./chunk-TIQ775WI.cjs'),chunkCSHNTZW4_cjs=require('./chunk-CSHNTZW4.cjs'),chunkC7RR2JCL_cjs=require('./chunk-C7RR2JCL.cjs'),chunkCAID4CGO_cjs=require('./chunk-CAID4CGO.cjs'),chunkSDJ3747Q_cjs=require('./chunk-SDJ3747Q.cjs'),chunkOF4FPYNI_cjs=require('./chunk-OF4FPYNI.cjs'),chunk2RIHC5TZ_cjs=require('./chunk-2RIHC5TZ.cjs');function ce(g){let{apiBasePath:w,json:b,readJsonBody:I,bootstrapBoard:B,createMcpControlplaneToolRegistry:$,retriggerCard:N,applyCardAction:x,resolveChatHandlerTarget:_,sendCardFileDownloadResponse:H}=g;async function E(T,S,z){let q=T.method||"GET",K=z,l=K.pathname;try{if(q==="POST"&&l===`${w}/mcp-actions`){await B();let f=Date.now(),y=new Date(f).toISOString(),k=await I(T),u=typeof k.tool=="string"?k.tool.trim():"",P=k.args&&typeof k.args=="object"&&!Array.isArray(k.args)?k.args:{};if(!u)return b(S,400,{error:"tool is required"}),!0;let v=chunkLPXVVMQT_cjs.a(P,"card_id");if(!v)return b(S,400,{error:"MCP action requires card_id"}),!0;if(u==="retrigger-card"||u==="retrigger"){await N(v);let O=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:200}}),!0}let A=chunkLPXVVMQT_cjs.c(P,"payload");if(u==="chat-send"&&!await _(v)){let O=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:409}),!0}if(u==="chat-send"){let O=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!O||!String(O).trim()){let U=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(U).toISOString(),responseSentAtMs:U,responseStatus:400}),!0}}await x(v,u,A);let D=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(D).toISOString(),responseSentAtMs:D,responseStatus:200}}),!0}if(q==="POST"&&l===`${w}/mcp-controlplane`){await B();let f=await I(T),y=typeof f.tool=="string"?f.tool.trim():"",k=f.args&&typeof f.args=="object"&&!Array.isArray(f.args)?f.args:{};if(!y)return b(S,400,{error:"tool is required"}),!0;try{let u=await chunk272IYUKT_cjs.a(y,k,$());if(u&&typeof u=="object"&&!Array.isArray(u)){let P=u;if(P.status==="fail")return b(S,400,{error:chunk272IYUKT_cjs.b(u,"Request failed")}),!0;if(P.status==="error")return b(S,500,{error:chunk272IYUKT_cjs.b(u,"Internal error")}),!0}b(S,200,u);}catch(u){let P=typeof u?.statusCode=="number"?Number(u.statusCode):500,v=u instanceof Error?u.message:String(u);b(S,P,{error:v});}return !0}let R=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/retrigger$`));if(q==="POST"&&R){await B();let f=decodeURIComponent(R[1]);return await N(f),b(S,200,{ok:!0}),!0}let F=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/actions$`));if(q==="POST"&&F){await B();let f=decodeURIComponent(F[1]),y=Date.now(),k=new Date(y).toISOString(),u=await I(T),P=u?.actionType;if(P==="chat-send"&&!await _(f)){let A=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(A).toISOString(),responseSentAtMs:A,responseStatus:409}),!0}if(P==="chat-send"){let A=u?.payload??{},D=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!D||!String(D).trim()){let O=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:400}),!0}}await x(f,P,u?.payload);let v=Date.now();return b(S,200,{ok:!0,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(v).toISOString(),responseSentAtMs:v,responseStatus:200}),!0}let p=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/files/(\\d+)$`));if(q==="GET"&&p){let f=decodeURIComponent(p[1]),y=parseInt(p[2],10),k=K.searchParams.get("sn");return await H(S,f,y,k),!0}return !1}catch(R){let F=R?.statusCode||500;return b(S,F,{error:String(R?.message||R)}),true}}return {handleRuntimeApi:E}}var Ke=3e4;function Ve(g){let w=g.socket?.remoteAddress??"";return w==="127.0.0.1"||w==="::1"||w==="::ffff:127.0.0.1"}function ue(g){let{apiBasePath:w,emitNotifications:b,readJsonBody:I,json:B}=g,$=`${w}/notify-q`;async function N(x,_,H){if(H.pathname!==$)return false;if((x.method??"").toUpperCase()!=="POST")return B(_,405,{status:"error",error:"Method not allowed"}),true;if(!Ve(x))return B(_,403,{status:"error",error:"Forbidden"}),true;let E;try{E=await I(x);}catch{return B(_,400,{status:"error",error:"Invalid JSON body"}),true}if(!E||typeof E!="object"||!Array.isArray(E.notifications))return B(_,400,{status:"error",error:"body.notifications must be an array"}),true;let T=E.notifications,{accepted:S,rejected:z}=chunk3HCH2ZFB_cjs.b(T,Date.now(),Ke);return S.length>0&&b(S),B(_,200,{status:"success",data:{accepted:S.length,rejected:z}}),true}return {handleNotifyRoute:N}}var le={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},de="chat-handler-flow-queue",ot="__probe__echo__probe__";function Mr(g){let w=String(g.apiBasePath||"/api/board").replace(/\/$/,""),b={...le,...g.corsHeaders||{}},I=g.queueLaneTuning??{},B=g.boardId||"",$=Number.isInteger(g.chatBootstrapTailTurns)&&g.chatBootstrapTailTurns>0?g.chatBootstrapTailTurns:1,N=g.logger||{info:console.log,warn:console.warn,error:console.error},x=g.invocationAdapter,_=g.chatFlowRunner||null,H=g.notificationTransport||null,E=g.serverUrl||null,T=g.executionExtra||{},S=g.onSseClientConnected,z=g.onSseClientDisconnected,q=g.onChannelSubscribed,K=g.onChannelUnsubscribed,l=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async(t,e)=>await Q.buildSseOneShotBatch({params:{cardId:t},body:{receiving:e}}),onSseClientDisconnected:z}),R=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async()=>({status:"success",data:{kind:"notification-batch",category:"batch",notifications:[]}})});function F(t){function e(a){return {...a,queueStorageForRef(d,C){return chunkSDJ3747Q_cjs.a(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function r(a){return {...a,queueStorageForRef(d,C){return chunkTIQ775WI_cjs.h(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function n(a){return {async get(d){return a.get(d)},async set(d){return a.set(d)},async del(d){return a.del(d)},async patch(d){return a.patch(d)},async appendFiles(d){return a.appendFiles(d)}}}function o(a){return {async get(d){return await a.get(d)},async set(d){return await a.set(d)},async del(d){return await a.del(d)},async patch(d){return await a.patch(d)},async appendFiles(d){return await a.appendFiles(d)}}}let s=null;function i(a){if(a.kind==="notification-batch"){V(a.notifications,s??void 0);return}V([a],s??void 0);}let c=chunkBQUQTOPB_cjs.a(t.boardAdapter)?r(t.boardAdapter):e(t.boardAdapter),j=t.nonCoreAdapter??(!chunkBQUQTOPB_cjs.a(c)&&P(c)?c:null),h=chunkBQUQTOPB_cjs.a(c)?chunkTIQ775WI_cjs.i(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}):chunkC7RR2JCL_cjs.e(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}),M=t.nonCore??(j?chunkC7RR2JCL_cjs.f(t.baseRef,j,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,taskExecutorRef:t.taskExecutorRef}):null),We=c.chatStorageForRef(t.chatStoreRef),lt,Je=chunkBQUQTOPB_cjs.a(c)?(()=>{let a=chunkTIQ775WI_cjs.d(chunkTIQ775WI_cjs.c(chunkTIQ775WI_cjs.b(c.kvStorageForRef(t.cardStoreRef)),c.hashFn),N.warn),d=chunkTIQ775WI_cjs.g(a,{emitNotification:i}),C=o(d);return lt={get(m){return C.get(m)},set(m){return C.set(m)}},C})():(()=>{let a=c.kvStorageForRef(t.cardStoreRef),C=chunkCAID4CGO_cjs.H(chunkCAID4CGO_cjs.m({readIndex:()=>a.read("_index"),writeIndex:m=>a.write("_index",m),readCard:m=>a.read(m),writeCard:(m,pt)=>(a.write(m,pt),m),removeCard:m=>{a.delete(m);},cardExists:m=>a.read(m)!==null,defaultCardKey:m=>m},N.warn),{emitNotification:i});return lt=C,n(C)})(),ft;if(chunkBQUQTOPB_cjs.a(c)){let a=c.blobStorageForRef(t.artifactsStoreRef);ft={async putBytes(d,C){if(a.writeBytes){await a.writeBytes(d,C);return}let m=JSON.stringify({__kind:"bytes-array",data:[...C]});await a.write(d,m);},async getBytes(d){if(a.readBytes){let m=await a.readBytes(d);if(m!==null)return m}let C=await a.read(d);if(C===null)return null;try{let m=JSON.parse(C);if(m&&m.__kind==="bytes-array"&&Array.isArray(m.data))return new Uint8Array(m.data)}catch{}return new TextEncoder().encode(C)},async listKeys(d){return await a.listKeys(d)}};}else {let a=c.blobStorageForRef(t.artifactsStoreRef),d=chunkNBJTYAYN_cjs.a(a);ft={putBytes(C,m,pt){d.putBytes(C,m,pt);},getBytes(C){return d.getBytes(C)},listKeys(C){return d.list(C).map(m=>m.key)}};}let ze={async init(a){return h.init(a)},async status(a){return h.status(a)},async getConfig(a){return h.getConfig(a)},async getAllOutputsDataObjects(a){return h.getAllOutputsDataObjects(a)},async getAllOutputsComputedValues(a){return h.getAllOutputsComputedValues(a)},async getOutputsFetchedSources(a){return h.getOutputsFetchedSources(a)},async buildSseOneShotPayload(a){return h.buildSseOneShotPayload(a)},async upsertCard(a){return h.upsertCard(a)},async removeCard(a){return h.removeCard(a)},async sourceDataFetched(a){return h.sourceDataFetched(a)},async sourceDataFetchFailure(a){return h.sourceDataFetchFailure(a)}};return s={label:t.label,board:h,nonCore:M,publicCardStore:lt,boardOps:ze,cardStoreOps:Je,get filesArtifacts(){return ft},get chatStorage(){return We},boardAdapter:c,boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:chunk3HCH2ZFB_cjs.c(),notificationTeardown:null,initialized:false,cardsBootstrapped:false},s}let p=g.boards.map(F),f=new Map;function y(t){return f.get(t)??0}function k(t){return t.queueStoreRef}function u(t,e){if(chunkBQUQTOPB_cjs.a(t.boardAdapter)){let n=t.boardAdapter.queueStorageForRef(k(t),e);return chunkCSHNTZW4_cjs.a(n)}let r=t.boardAdapter.queueStorageForRef(k(t),e);return chunkGPCMBPLK_cjs.a(r)}function P(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function v(t){let e=p[y(t)];return {files:e?e.filesArtifacts:null}}function A(){return chunkNBJTYAYN_cjs.c()}function D(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}function O(t){return "cardId"in t&&typeof t.cardId=="string"?W(t.cardId)??void 0:p[0]??void 0}function U(t){for(let e of t){let r=O(e);if(r)return r}return p[0]??void 0}function ct(t,e={}){if(!t||t.length===0)return;let r=chunk2RIHC5TZ_cjs.e(t),n={kind:"notification-batch",category:"batch",notifications:r},o=e.ctx??U(r);if(e.appendState!==false&&o&&chunk3HCH2ZFB_cjs.e(o.notification,n),e.broadcastSse!==false){let s=r.filter(c=>c.kind==="message_enqueued"),i=r.filter(c=>c.kind!=="message_enqueued");i.length>0&&l.broadcastNotificationBatch(i),s.length>0&&R.broadcastNotificationBatch(s);}if(!(e.mirrorExternal===false||!o?.boardAdapter.publishBoardChangeNotifications))try{let s=r.filter(i=>i.category==="board-output"||i.category==="card-store"||i.category==="chat-store"||i.category==="hosted-runtime");s.length>0&&o.boardAdapter.publishBoardChangeNotifications(s);}catch{}}function V(t,e){ct(t,{ctx:e,appendState:true,broadcastSse:true,mirrorExternal:true});}async function fe(t){if(!t||t.notificationTeardown||!H||!t.notifyRef)return;let e=await H.subscribe(t.notifyRef,r=>{let n=chunk3HCH2ZFB_cjs.a(r);ct(n,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});});t.notificationTeardown=e;}async function pe(t){if(!t||t.initialized)return;let e={boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,artifactsStoreRef:t.artifactsStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef},r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow);let n=await t.boardOps.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await fe(t),!t.chatHandlerFlow&&t.chatHandlerRef&&x.describe)try{let o=await x.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?N.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&N.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){N.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}async function ut(t){let e=[],r=await t.boardOps.status({});r.status==="success"&&r.data!=null&&chunk3HCH2ZFB_cjs.d(r.data)&&e.push({kind:"status",status:r.data});let n=await t.boardOps.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,i]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:i});let o=await t.boardOps.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,i]of Object.entries(o.data))s&&i&&typeof i=="object"&&!Array.isArray(i)&&e.push({kind:"computed_values",cardId:s,values:i});e.length>0&&ct(e,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});}async function Rt(t,e){if(!t||t.cardsBootstrapped)return;let r=await t.cardStoreOps.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(f.set(o.id,e),await t.boardOps.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function G(){for(let t of p)await pe(t);}async function at(){await G();for(let t=0;t<p.length;t++)await ut(p[t]),await Rt(p[t],t),await ut(p[t]);}async function yt(t=false){t||await G();for(let e of p){let r=await e.board.processAccumulatedEvents({});if(r.status!=="success")return r}return {status:"success"}}function W(t){return p[y(t)]??null}async function Y(t){let e=W(t);if(!e)return null;let r=await e.cardStoreOps.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}async function me(){let t=async r=>{if(!r)return [];let n=await r.cardStoreOps.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of p)e.push(...await t(r));return e}function ht(){return p[0]??null}function ge(t){return W(t)??ht()}function L(t){let e=ge(t);if(!e)throw Object.assign(new Error(`Board context is unavailable for chat operations: ${t}`),{statusCode:404});return e.chatStorage}async function Re(t){return await L(t).isProcessing(t)}async function tt(t,e){let r=await Q.setProcessing({params:{cardId:t},body:{active:e}});if(r.status!=="success")throw Object.assign(new Error(r.error||`Failed to set chat processing for card: ${t}`),{statusCode:500})}let Q=chunkOF4FPYNI_cjs.a({append(t,e,r,n,o){return L(t).append(t,e,r,n,o)},readAll(t){return L(t).readAll(t)},readAfter(t,e){return L(t).readAfter(t,e)},clear(t){return L(t).clear(t)},setProcessing(t,e){return L(t).setProcessing(t,e)},isProcessing(t){return L(t).isProcessing(t)},getConfig(t){return L(t).getConfig(t)},setConfig(t,e){return L(t).setConfig(t,e)}},{emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);}}),wt=chunk3HCH2ZFB_cjs.p({boardContexts:p,cardOwnerIndex:f,cardContextForCard:t=>W(t),readStatusSnapshot:()=>Se(),readDataObjectsByToken:()=>Ae(),readCardRuntimeArtifacts:()=>Ce(),readCardFromStore:t=>Y(t),readCardDefinitions:()=>me(),processAccumulatedLaneInternal:t=>yt(t),reportSourceFetched:(t,e)=>kt(t,{ref:e}),reportSourceFetchFailure:(t,e)=>Pt(t,{reason:e}),uploadCardFile:(t,e,r,n,o)=>Ct(t,e,r,n,o),chatStorePublic:Q,serverUrl:E,apiBasePath:w}),ye=wt.mcpCardStoreFacade,st=wt.createMcpFacade,he=chunk3HCH2ZFB_cjs.j({boardId:B,bootstrapBoard:()=>at(),sseHub:l,onChannelSubscribed:q,onChannelUnsubscribed:K,getMcpFacade:()=>st(),getMcpCardStoreFacade:()=>ye()});function we(t){return chunk3HCH2ZFB_cjs.m(t)}function be(){return chunk3HCH2ZFB_cjs.n(st())}function bt(){return chunk3HCH2ZFB_cjs.o({boardId:B,uploadCardFile:Ct,getMcpFacade:()=>st(),controlplane:he})}let it=chunk3HCH2ZFB_cjs.k({boardId:B,boardContexts:p,readChatRecords:(t,e)=>ve(t,e),getChatProcessing:t=>Re(t),chatBootstrapTailTurns:$}),Se=it.readStatusSnapshot,Ce=it.readCardRuntimeArtifacts,Ae=it.readDataObjectsByToken,dt=it.buildPublishedRuntimePayload;async function St(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=W(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=await Y(t);if(!i)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let c=o?JSON.stringify(i):null,j=e(i)||i;if(o&&JSON.stringify(j)===c)return;let h=await s.cardStoreOps.set({body:j});if(h.status!=="success")throw Object.assign(new Error(h.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let M=await s.boardOps.upsertCard({params:{cardId:t,restart:true}});if(M.status!=="success")throw Object.assign(new Error(M.error||`Failed to upsert card: ${t}`),{statusCode:500})}}async function Be(t,e){await St(t,e,{syncBoard:true});}async function ke(t,e){await St(t,e,{syncBoard:false});}async function Pe(t){let e=W(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!await Y(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=await e.boardOps.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}async function Oe(t){let e=await Q.clear({params:{cardId:t}});if(e.status!=="success")throw Object.assign(new Error(e.error||`Failed to clear chat records for card: ${t}`),{statusCode:500});try{await tt(t,!1);}catch{}}async function Fe(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"",i=await Q.append({params:{cardId:t},body:{role:e||"system",text:s,files:n,turn:o}});if(i.status!=="success")throw Object.assign(new Error(i.error||`Failed to append chat record for card: ${t}`),{statusCode:500});return String(i.data?.id||"")}async function ve(t,e){let r=Number.isInteger(e?.tailTurns)&&e?.tailTurns>0?e?.tailTurns:void 0,n=await Q.readAll({params:{cardId:t},...r===void 0?{}:{body:{tailTurns:r}}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to read chat records for card: ${t}`),{statusCode:500});return Array.isArray(n.data?.records)?n.data.records:[]}let Ct=chunk3HCH2ZFB_cjs.l({safeCardId:t=>D(t),artifactsStores:t=>v(t),cardFileMetadataStore:()=>A(),readCardFromStore:t=>Y(t),updateCardLocalOnly:(t,e)=>ke(t,e),writeChatRecord:(t,e,r,n,o)=>Fe(t,e,r,n,o)}).uploadCardFile;async function At(t){let e=W(t);if(!e)return null;let r=await e.boardOps.getConfig({params:{key:"chat-handler-flow"}}),o=(r.status==="success"?r.data?.value:null)??e.chatHandlerFlow??null,s=e.chatHandlerRef;return o==null&&(!s||typeof s!="object")?null:{ctx:e,handlerFlow:o,handlerRef:s}}function xe(t){let e=typeof t=="string"?t.trim():"";if(e.length<ot.length*2||!e.startsWith(ot)||!e.endsWith(ot))return null;let r=e.slice(ot.length,e.length-ot.length).trim(),n=/^([A-Za-z0-9_-]+)__(.*)$/s.exec(r);return n?{assistant:n[1].trim().toLowerCase(),text:n[2].trim()}:{assistant:"echo",text:r}}async function Te(t,e,r=false,n="",o=""){try{let s=await At(t);if(!s){try{await tt(t,!1);}catch{}return}let{ctx:i,handlerFlow:c,handlerRef:j}=s;if(!r)try{await tt(t,!0);}catch{}let h={boardId:B,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...typeof o=="string"&&o.trim()?{probe:o.trim()}:{},...T,...E?{serverUrl:E}:{}},M=c!=null?{meta:"chat-handler-flow",howToRun:"built-in",whatToRun:{kind:"built-in",value:de}}:j;chunkBQUQTOPB_cjs.a(i.boardAdapter)?await u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}):u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}),await Promise.resolve(i.boardAdapter.requestProcessAccumulated?.());}catch(s){try{await tt(t,!1);}catch{}N.warn(`[chat-handler] queue failed for card "${t}": ${s instanceof Error?s.message:String(s)}`);}}async function Ne(t,e,r){if(e.howToRun==="built-in"&&chunkBQUQTOPB_cjs.b(e)===de){let n=_,o=r.__chatHandlerFlow,s={...r};return delete s.__chatHandlerFlow,n?n.run(o,s,{boardId:B,cardId:String(s.cardId||""),label:t.label,logger:N,serverUrl:E,executionExtra:T}):{dispatched:false,error:"chat-handler-flow configured but no chatFlowRunner was provided"}}return x.invoke(e,r)}async function Ee(t,e=false){e||await G();let r=typeof t.args?.cardId=="string"?t.args.cardId:"",n=r?W(r):ht();if(!n)throw new Error(r?`Board context is unavailable for chat-agent request: ${r}`:"Board context is unavailable for chat-agent request");let o=await Ne(n,t.ref,t.args);if(!o.dispatched){if(r)try{await tt(r,!1);}catch{}throw new Error(o.error||`chat-agent dispatch failed for card "${r||"unknown"}"`)}}async function je(t,e,r){if(e==="chat-send"){let o=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"";if(r&&"files"in r&&r.files!==void 0&&r.files!==null)throw Object.assign(new Error('chat-send does not accept a "files" parameter; upload attachments via manage.add-chat-attachment first'),{statusCode:400});let s=bt(),i=xe(r?.text),c=i?i.text:r?.text,j=await chunk272IYUKT_cjs.a("manage.add-chat-entry-and-any-attachments",{board_id:B,card_id:t,role:"user",text:c,turn_id:o,files:[]},s);if(j?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(j,`chat-send append failed for card ${t}`));let h=j?.data?.id;if(typeof h!="string"||!h)throw new Error(`chat-send did not return an append id for card ${t}`);let M=await chunk272IYUKT_cjs.a("setstate.chat-processing-started",{board_id:B,card_id:t},s);if(M?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(M,`chat-send processing update failed for card ${t}`));Te(t,h,true,o,i?.assistant||"");return}await Be(t,o=>{let s=new Date().toISOString(),i=o.card_data&&typeof o.card_data=="object"?o.card_data:{};if(o.card_data=i,e==="file-upload"){let c=A().normalizeIncoming(r?.files,s);return c.length>0&&A().merge(i,c),o}if(e==="action"){let c=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!c)return o;i.lastAction={buttonId:c,at:s},i.lastActionText=`${c} @ ${s}`;}return o});}function et(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...b,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}async function Bt(t,e,r){let n=await Y(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=A().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,i=D(t),c=v(t),j=String(s.stored_name||""),h=`${i}/${j}`,M=c.files?await c.files.getBytes(h):null;if(!M)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:M}}async function Me(t,e,r,n){let{fileRecord:o,bytes:s}=await Bt(e,r,n),i=String(o.name||o.stored_name||"download.bin"),c=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":c,"Content-Disposition":`attachment; filename="${i}"`,"Content-Length":s.length}),t.end(s);}function _e(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function De(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
|
|
2
|
-
`)}async function rt(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(chunkBQUQTOPB_cjs.d(e)).trim();return r?JSON.parse(r):{}}async function
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunkLFVMX23W_cjs=require('./chunk-LFVMX23W.cjs'),chunkNM6O35RY_cjs=require('./chunk-NM6O35RY.cjs'),chunkNBJTYAYN_cjs=require('./chunk-NBJTYAYN.cjs'),chunk23X3V5FR_cjs=require('./chunk-23X3V5FR.cjs'),chunkBQUQTOPB_cjs=require('./chunk-BQUQTOPB.cjs'),chunkGPCMBPLK_cjs=require('./chunk-GPCMBPLK.cjs'),chunk7FGPOGRV_cjs=require('./chunk-7FGPOGRV.cjs'),chunkLPXVVMQT_cjs=require('./chunk-LPXVVMQT.cjs'),chunk272IYUKT_cjs=require('./chunk-272IYUKT.cjs'),chunkTIQ775WI_cjs=require('./chunk-TIQ775WI.cjs'),chunkCSHNTZW4_cjs=require('./chunk-CSHNTZW4.cjs'),chunkC7RR2JCL_cjs=require('./chunk-C7RR2JCL.cjs'),chunkCAID4CGO_cjs=require('./chunk-CAID4CGO.cjs'),chunkSDJ3747Q_cjs=require('./chunk-SDJ3747Q.cjs'),chunkOF4FPYNI_cjs=require('./chunk-OF4FPYNI.cjs'),chunk2RIHC5TZ_cjs=require('./chunk-2RIHC5TZ.cjs');function ue(g){let{apiBasePath:w,json:b,readJsonBody:I,bootstrapBoard:B,createMcpControlplaneToolRegistry:$,retriggerCard:N,applyCardAction:x,resolveChatHandlerTarget:_,sendCardFileDownloadResponse:H}=g;async function E(T,S,z){let q=T.method||"GET",K=z,l=K.pathname;try{if(q==="POST"&&l===`${w}/mcp-actions`){await B();let f=Date.now(),y=new Date(f).toISOString(),k=await I(T),u=typeof k.tool=="string"?k.tool.trim():"",P=k.args&&typeof k.args=="object"&&!Array.isArray(k.args)?k.args:{};if(!u)return b(S,400,{error:"tool is required"}),!0;let v=chunkLPXVVMQT_cjs.a(P,"card_id");if(!v)return b(S,400,{error:"MCP action requires card_id"}),!0;if(u==="retrigger-card"||u==="retrigger"){await N(v);let O=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:200}}),!0}let A=chunkLPXVVMQT_cjs.c(P,"payload");if(u==="chat-send"&&!await _(v)){let O=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:409}),!0}if(u==="chat-send"){let O=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!O||!String(O).trim()){let U=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(U).toISOString(),responseSentAtMs:U,responseStatus:400}),!0}}await x(v,u,A);let D=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(D).toISOString(),responseSentAtMs:D,responseStatus:200}}),!0}if(q==="POST"&&l===`${w}/mcp-controlplane`){await B();let f=await I(T),y=typeof f.tool=="string"?f.tool.trim():"",k=f.args&&typeof f.args=="object"&&!Array.isArray(f.args)?f.args:{};if(!y)return b(S,400,{error:"tool is required"}),!0;try{let u=await chunk272IYUKT_cjs.a(y,k,$());if(u&&typeof u=="object"&&!Array.isArray(u)){let P=u;if(P.status==="fail")return b(S,400,{error:chunk272IYUKT_cjs.b(u,"Request failed")}),!0;if(P.status==="error")return b(S,500,{error:chunk272IYUKT_cjs.b(u,"Internal error")}),!0}b(S,200,u);}catch(u){let P=typeof u?.statusCode=="number"?Number(u.statusCode):500,v=u instanceof Error?u.message:String(u);b(S,P,{error:v});}return !0}let R=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/retrigger$`));if(q==="POST"&&R){await B();let f=decodeURIComponent(R[1]);return await N(f),b(S,200,{ok:!0}),!0}let F=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/actions$`));if(q==="POST"&&F){await B();let f=decodeURIComponent(F[1]),y=Date.now(),k=new Date(y).toISOString(),u=await I(T),P=u?.actionType;if(P==="chat-send"&&!await _(f)){let A=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(A).toISOString(),responseSentAtMs:A,responseStatus:409}),!0}if(P==="chat-send"){let A=u?.payload??{},D=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!D||!String(D).trim()){let O=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:400}),!0}}await x(f,P,u?.payload);let v=Date.now();return b(S,200,{ok:!0,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(v).toISOString(),responseSentAtMs:v,responseStatus:200}),!0}let p=l.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/cards/([^/]+)/files/(\\d+)$`));if(q==="GET"&&p){let f=decodeURIComponent(p[1]),y=parseInt(p[2],10),k=K.searchParams.get("sn");return await H(S,f,y,k),!0}return !1}catch(R){let F=R?.statusCode||500;return b(S,F,{error:String(R?.message||R)}),true}}return {handleRuntimeApi:E}}var Ge=3e4;function Qe(g){let w=g.socket?.remoteAddress??"";return w==="127.0.0.1"||w==="::1"||w==="::ffff:127.0.0.1"}function de(g){let{apiBasePath:w,emitNotifications:b,readJsonBody:I,json:B}=g,$=`${w}/notify-q`;async function N(x,_,H){if(H.pathname!==$)return false;if((x.method??"").toUpperCase()!=="POST")return B(_,405,{status:"error",error:"Method not allowed"}),true;if(!Qe(x))return B(_,403,{status:"error",error:"Forbidden"}),true;let E;try{E=await I(x);}catch{return B(_,400,{status:"error",error:"Invalid JSON body"}),true}if(!E||typeof E!="object"||!Array.isArray(E.notifications))return B(_,400,{status:"error",error:"body.notifications must be an array"}),true;let T=E.notifications,{accepted:S,rejected:z}=chunk23X3V5FR_cjs.b(T,Date.now(),Ge);return S.length>0&&b(S),B(_,200,{status:"success",data:{accepted:S.length,rejected:z}}),true}return {handleNotifyRoute:N}}var fe={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},le="chat-handler-flow-queue",ot="__probe__echo__probe__";function _r(g){let w=String(g.apiBasePath||"/api/board").replace(/\/$/,""),b={...fe,...g.corsHeaders||{}},I=g.queueLaneTuning??{},B=g.boardId||"",$=Number.isInteger(g.chatBootstrapTailTurns)&&g.chatBootstrapTailTurns>0?g.chatBootstrapTailTurns:1,N=g.logger||{info:console.log,warn:console.warn,error:console.error},x=g.invocationAdapter,_=g.chatFlowRunner||null,H=g.notificationTransport||null,E=g.serverUrl||null,T=g.executionExtra||{},S=g.onSseClientConnected,z=g.onSseClientDisconnected,q=g.onChannelSubscribed,K=g.onChannelUnsubscribed,l=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async(t,e)=>await Q.buildSseOneShotBatch({params:{cardId:t},body:{receiving:e}}),onSseClientDisconnected:z}),R=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async()=>({status:"success",data:{kind:"notification-batch",category:"batch",notifications:[]}})});function F(t){function e(a){return {...a,queueStorageForRef(d,C){return chunkSDJ3747Q_cjs.a(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function r(a){return {...a,queueStorageForRef(d,C){return chunkTIQ775WI_cjs.h(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function n(a){return {async get(d){return a.get(d)},async set(d){return a.set(d)},async del(d){return a.del(d)},async patch(d){return a.patch(d)},async appendFiles(d){return a.appendFiles(d)}}}function o(a){return {async get(d){return await a.get(d)},async set(d){return await a.set(d)},async del(d){return await a.del(d)},async patch(d){return await a.patch(d)},async appendFiles(d){return await a.appendFiles(d)}}}let s=null;function i(a){if(a.kind==="notification-batch"){V(a.notifications,s??void 0);return}V([a],s??void 0);}let c=chunkBQUQTOPB_cjs.a(t.boardAdapter)?r(t.boardAdapter):e(t.boardAdapter),j=t.nonCoreAdapter??(!chunkBQUQTOPB_cjs.a(c)&&P(c)?c:null),h=chunkBQUQTOPB_cjs.a(c)?chunkTIQ775WI_cjs.i(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}):chunkC7RR2JCL_cjs.e(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}),M=t.nonCore??(j?chunkC7RR2JCL_cjs.f(t.baseRef,j,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,taskExecutorRef:t.taskExecutorRef}):null),ze=c.chatStorageForRef(t.chatStoreRef),lt,Ke=chunkBQUQTOPB_cjs.a(c)?(()=>{let a=chunkTIQ775WI_cjs.d(chunkTIQ775WI_cjs.c(chunkTIQ775WI_cjs.b(c.kvStorageForRef(t.cardStoreRef)),c.hashFn),N.warn),d=chunkTIQ775WI_cjs.g(a,{emitNotification:i}),C=o(d);return lt={get(m){return C.get(m)},set(m){return C.set(m)}},C})():(()=>{let a=c.kvStorageForRef(t.cardStoreRef),C=chunkCAID4CGO_cjs.H(chunkCAID4CGO_cjs.m({readIndex:()=>a.read("_index"),writeIndex:m=>a.write("_index",m),readCard:m=>a.read(m),writeCard:(m,pt)=>(a.write(m,pt),m),removeCard:m=>{a.delete(m);},cardExists:m=>a.read(m)!==null,defaultCardKey:m=>m},N.warn),{emitNotification:i});return lt=C,n(C)})(),ft;if(chunkBQUQTOPB_cjs.a(c)){let a=c.blobStorageForRef(t.artifactsStoreRef);ft={async putBytes(d,C){if(a.writeBytes){await a.writeBytes(d,C);return}let m=JSON.stringify({__kind:"bytes-array",data:[...C]});await a.write(d,m);},async getBytes(d){if(a.readBytes){let m=await a.readBytes(d);if(m!==null)return m}let C=await a.read(d);if(C===null)return null;try{let m=JSON.parse(C);if(m&&m.__kind==="bytes-array"&&Array.isArray(m.data))return new Uint8Array(m.data)}catch{}return new TextEncoder().encode(C)},async listKeys(d){return await a.listKeys(d)}};}else {let a=c.blobStorageForRef(t.artifactsStoreRef),d=chunkNBJTYAYN_cjs.a(a);ft={putBytes(C,m,pt){d.putBytes(C,m,pt);},getBytes(C){return d.getBytes(C)},listKeys(C){return d.list(C).map(m=>m.key)}};}let Ve={async init(a){return h.init(a)},async status(a){return h.status(a)},async getConfig(a){return h.getConfig(a)},async getAllOutputsDataObjects(a){return h.getAllOutputsDataObjects(a)},async getAllOutputsComputedValues(a){return h.getAllOutputsComputedValues(a)},async getOutputsFetchedSources(a){return h.getOutputsFetchedSources(a)},async buildSseOneShotPayload(a){return h.buildSseOneShotPayload(a)},async upsertCard(a){return h.upsertCard(a)},async removeCard(a){return h.removeCard(a)},async sourceDataFetched(a){return h.sourceDataFetched(a)},async sourceDataFetchFailure(a){return h.sourceDataFetchFailure(a)}};return s={label:t.label,board:h,nonCore:M,publicCardStore:lt,boardOps:Ve,cardStoreOps:Ke,get filesArtifacts(){return ft},get chatStorage(){return ze},boardAdapter:c,boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:chunk23X3V5FR_cjs.c(),notificationTeardown:null,initialized:false,cardsBootstrapped:false},s}let p=g.boards.map(F),f=new Map;function y(t){return f.get(t)??0}function k(t){return t.queueStoreRef}function u(t,e){if(chunkBQUQTOPB_cjs.a(t.boardAdapter)){let n=t.boardAdapter.queueStorageForRef(k(t),e);return chunkCSHNTZW4_cjs.a(n)}let r=t.boardAdapter.queueStorageForRef(k(t),e);return chunkGPCMBPLK_cjs.a(r)}function P(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function v(t){let e=p[y(t)];return {files:e?e.filesArtifacts:null}}function A(){return chunkNBJTYAYN_cjs.c()}function D(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}function O(t){return "cardId"in t&&typeof t.cardId=="string"?W(t.cardId)??void 0:p[0]??void 0}function U(t){for(let e of t){let r=O(e);if(r)return r}return p[0]??void 0}function ct(t,e={}){if(!t||t.length===0)return;let r=chunk2RIHC5TZ_cjs.e(t),n={kind:"notification-batch",category:"batch",notifications:r},o=e.ctx??U(r);if(e.appendState!==false&&o&&chunk23X3V5FR_cjs.e(o.notification,n),e.broadcastSse!==false){let s=r.filter(c=>c.kind==="message_enqueued"),i=r.filter(c=>c.kind!=="message_enqueued");i.length>0&&l.broadcastNotificationBatch(i),s.length>0&&R.broadcastNotificationBatch(s);}if(!(e.mirrorExternal===false||!o?.boardAdapter.publishBoardChangeNotifications))try{let s=r.filter(i=>i.category==="board-output"||i.category==="card-store"||i.category==="chat-store"||i.category==="hosted-runtime");s.length>0&&o.boardAdapter.publishBoardChangeNotifications(s);}catch{}}function V(t,e){ct(t,{ctx:e,appendState:true,broadcastSse:true,mirrorExternal:true});}async function pe(t){if(!t||t.notificationTeardown||!H||!t.notifyRef)return;let e=await H.subscribe(t.notifyRef,r=>{let n=chunk23X3V5FR_cjs.a(r);ct(n,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});});t.notificationTeardown=e;}async function me(t){if(!t||t.initialized)return;let e={boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,artifactsStoreRef:t.artifactsStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef},r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow);let n=await t.boardOps.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await pe(t),!t.chatHandlerFlow&&t.chatHandlerRef&&x.describe)try{let o=await x.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?N.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&N.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){N.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}async function ut(t){let e=[],r=await t.boardOps.status({});r.status==="success"&&r.data!=null&&chunk23X3V5FR_cjs.d(r.data)&&e.push({kind:"status",status:r.data});let n=await t.boardOps.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,i]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:i});let o=await t.boardOps.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,i]of Object.entries(o.data))s&&i&&typeof i=="object"&&!Array.isArray(i)&&e.push({kind:"computed_values",cardId:s,values:i});e.length>0&&ct(e,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});}async function Rt(t,e){if(!t||t.cardsBootstrapped)return;let r=await t.cardStoreOps.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(f.set(o.id,e),await t.boardOps.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function G(){for(let t of p)await me(t);}async function at(){await G();for(let t=0;t<p.length;t++)await ut(p[t]),await Rt(p[t],t),await ut(p[t]);}async function yt(t=false){t||await G();for(let e of p){let r=await e.board.processAccumulatedEvents({});if(r.status!=="success")return r}return {status:"success"}}function W(t){return p[y(t)]??null}async function Y(t){let e=W(t);if(!e)return null;let r=await e.cardStoreOps.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}async function ge(){let t=async r=>{if(!r)return [];let n=await r.cardStoreOps.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of p)e.push(...await t(r));return e}function ht(){return p[0]??null}function Re(t){return W(t)??ht()}function L(t){let e=Re(t);if(!e)throw Object.assign(new Error(`Board context is unavailable for chat operations: ${t}`),{statusCode:404});return e.chatStorage}async function ye(t){return await L(t).isProcessing(t)}async function tt(t,e){let r=await Q.setProcessing({params:{cardId:t},body:{active:e}});if(r.status!=="success")throw Object.assign(new Error(r.error||`Failed to set chat processing for card: ${t}`),{statusCode:500})}let Q=chunkOF4FPYNI_cjs.a({append(t,e,r,n,o){return L(t).append(t,e,r,n,o)},readAll(t){return L(t).readAll(t)},readAfter(t,e){return L(t).readAfter(t,e)},clear(t){return L(t).clear(t)},setProcessing(t,e){return L(t).setProcessing(t,e)},isProcessing(t){return L(t).isProcessing(t)},getConfig(t){return L(t).getConfig(t)},setConfig(t,e){return L(t).setConfig(t,e)}},{emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);}}),wt=chunk23X3V5FR_cjs.p({boardContexts:p,cardOwnerIndex:f,cardContextForCard:t=>W(t),readStatusSnapshot:()=>Ce(),readDataObjectsByToken:()=>Be(),readCardRuntimeArtifacts:()=>Ae(),readCardFromStore:t=>Y(t),readCardDefinitions:()=>ge(),processAccumulatedLaneInternal:t=>yt(t),reportSourceFetched:(t,e)=>Pt(t,{ref:e}),reportSourceFetchFailure:(t,e)=>Ot(t,{reason:e}),uploadCardFile:(t,e,r,n,o)=>At(t,e,r,n,o),chatStorePublic:Q,serverUrl:E,apiBasePath:w}),he=wt.mcpCardStoreFacade,st=wt.createMcpFacade,we=chunk23X3V5FR_cjs.j({boardId:B,bootstrapBoard:()=>at(),sseHub:l,onChannelSubscribed:q,onChannelUnsubscribed:K,getMcpFacade:()=>st(),getMcpCardStoreFacade:()=>he()});function be(t){return chunk23X3V5FR_cjs.m(t)}function Se(){return chunk23X3V5FR_cjs.n(st())}function bt(){return chunk23X3V5FR_cjs.o({boardId:B,uploadCardFile:At,uploadCardFilesMultiple:Te,getMcpFacade:()=>st(),controlplane:we})}let it=chunk23X3V5FR_cjs.k({boardId:B,boardContexts:p,readChatRecords:(t,e)=>xe(t,e),getChatProcessing:t=>ye(t),chatBootstrapTailTurns:$}),Ce=it.readStatusSnapshot,Ae=it.readCardRuntimeArtifacts,Be=it.readDataObjectsByToken,dt=it.buildPublishedRuntimePayload;async function St(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=W(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=await Y(t);if(!i)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let c=o?JSON.stringify(i):null,j=e(i)||i;if(o&&JSON.stringify(j)===c)return;let h=await s.cardStoreOps.set({body:j});if(h.status!=="success")throw Object.assign(new Error(h.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let M=await s.boardOps.upsertCard({params:{cardId:t,restart:true}});if(M.status!=="success")throw Object.assign(new Error(M.error||`Failed to upsert card: ${t}`),{statusCode:500})}}async function ke(t,e){await St(t,e,{syncBoard:true});}async function Pe(t,e){await St(t,e,{syncBoard:false});}async function Oe(t){let e=W(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!await Y(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=await e.boardOps.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}async function Fe(t){let e=await Q.clear({params:{cardId:t}});if(e.status!=="success")throw Object.assign(new Error(e.error||`Failed to clear chat records for card: ${t}`),{statusCode:500});try{await tt(t,!1);}catch{}}async function ve(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"",i=await Q.append({params:{cardId:t},body:{role:e||"system",text:s,files:n,turn:o}});if(i.status!=="success")throw Object.assign(new Error(i.error||`Failed to append chat record for card: ${t}`),{statusCode:500});return String(i.data?.id||"")}async function xe(t,e){let r=Number.isInteger(e?.tailTurns)&&e?.tailTurns>0?e?.tailTurns:void 0,n=await Q.readAll({params:{cardId:t},...r===void 0?{}:{body:{tailTurns:r}}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to read chat records for card: ${t}`),{statusCode:500});return Array.isArray(n.data?.records)?n.data.records:[]}let Ct=chunk23X3V5FR_cjs.l({safeCardId:t=>D(t),artifactsStores:t=>v(t),cardFileMetadataStore:()=>A(),readCardFromStore:t=>Y(t),updateCardLocalOnly:(t,e)=>Pe(t,e),writeChatRecord:(t,e,r,n,o)=>ve(t,e,r,n,o)}),At=Ct.uploadCardFile,Te=Ct.uploadCardFilesMultiple;async function Bt(t){let e=W(t);if(!e)return null;let r=await e.boardOps.getConfig({params:{key:"chat-handler-flow"}}),o=(r.status==="success"?r.data?.value:null)??e.chatHandlerFlow??null,s=e.chatHandlerRef;return o==null&&(!s||typeof s!="object")?null:{ctx:e,handlerFlow:o,handlerRef:s}}function Ne(t){let e=typeof t=="string"?t.trim():"";if(e.length<ot.length*2||!e.startsWith(ot)||!e.endsWith(ot))return null;let r=e.slice(ot.length,e.length-ot.length).trim(),n=/^([A-Za-z0-9_-]+)__(.*)$/s.exec(r);return n?{assistant:n[1].trim().toLowerCase(),text:n[2].trim()}:{assistant:"echo",text:r}}async function Ee(t,e,r=false,n="",o=""){try{let s=await Bt(t);if(!s){try{await tt(t,!1);}catch{}return}let{ctx:i,handlerFlow:c,handlerRef:j}=s;if(!r)try{await tt(t,!0);}catch{}let h={boardId:B,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...typeof o=="string"&&o.trim()?{probe:o.trim()}:{},...T,...E?{serverUrl:E}:{}},M=c!=null?{meta:"chat-handler-flow",howToRun:"built-in",whatToRun:{kind:"built-in",value:le}}:j;chunkBQUQTOPB_cjs.a(i.boardAdapter)?await u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}):u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}),await Promise.resolve(i.boardAdapter.requestProcessAccumulated?.());}catch(s){try{await tt(t,!1);}catch{}N.warn(`[chat-handler] queue failed for card "${t}": ${s instanceof Error?s.message:String(s)}`);}}async function je(t,e,r){if(e.howToRun==="built-in"&&chunkBQUQTOPB_cjs.b(e)===le){let n=_,o=r.__chatHandlerFlow,s={...r};return delete s.__chatHandlerFlow,n?n.run(o,s,{boardId:B,cardId:String(s.cardId||""),label:t.label,logger:N,serverUrl:E,executionExtra:T}):{dispatched:false,error:"chat-handler-flow configured but no chatFlowRunner was provided"}}return x.invoke(e,r)}async function Me(t,e=false){e||await G();let r=typeof t.args?.cardId=="string"?t.args.cardId:"",n=r?W(r):ht();if(!n)throw new Error(r?`Board context is unavailable for chat-agent request: ${r}`:"Board context is unavailable for chat-agent request");let o=await je(n,t.ref,t.args);if(!o.dispatched){if(r)try{await tt(r,!1);}catch{}throw new Error(o.error||`chat-agent dispatch failed for card "${r||"unknown"}"`)}}async function _e(t,e,r){if(e==="chat-send"){let o=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"";if(r&&"files"in r&&r.files!==void 0&&r.files!==null)throw Object.assign(new Error('chat-send does not accept a "files" parameter; upload attachments via manage.add-chat-attachment first'),{statusCode:400});let s=bt(),i=Ne(r?.text),c=i?i.text:r?.text,j=await chunk272IYUKT_cjs.a("manage.add-chat-entry-and-any-attachments",{board_id:B,card_id:t,role:"user",text:c,turn_id:o,files:[]},s);if(j?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(j,`chat-send append failed for card ${t}`));let h=j?.data?.id;if(typeof h!="string"||!h)throw new Error(`chat-send did not return an append id for card ${t}`);let M=await chunk272IYUKT_cjs.a("setstate.chat-processing-started",{board_id:B,card_id:t},s);if(M?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(M,`chat-send processing update failed for card ${t}`));Ee(t,h,true,o,i?.assistant||"");return}await ke(t,o=>{let s=new Date().toISOString(),i=o.card_data&&typeof o.card_data=="object"?o.card_data:{};if(o.card_data=i,e==="file-upload"){let c=A().normalizeIncoming(r?.files,s);return c.length>0&&A().merge(i,c),o}if(e==="action"){let c=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!c)return o;i.lastAction={buttonId:c,at:s},i.lastActionText=`${c} @ ${s}`;}return o});}function et(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...b,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}async function kt(t,e,r){let n=await Y(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=A().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,i=D(t),c=v(t),j=String(s.stored_name||""),h=`${i}/${j}`,M=c.files?await c.files.getBytes(h):null;if(!M)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:M}}async function De(t,e,r,n){let{fileRecord:o,bytes:s}=await kt(e,r,n),i=String(o.name||o.stored_name||"download.bin"),c=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":c,"Content-Disposition":`attachment; filename="${i}"`,"Content-Length":s.length}),t.end(s);}function Ie(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function qe(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
|
|
2
|
+
`)}async function rt(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(chunkBQUQTOPB_cjs.d(e)).trim();return r?JSON.parse(r):{}}async function Pt(t,e){let r=typeof e.ref=="string"?e.ref.trim():"";if(!r)return {status:"fail",error:"board-worker success callback requires body.ref"};let n=p[0];return n?n.boardOps.sourceDataFetched({params:{token:t,ref:r}}):{status:"fail",error:"no board context"}}async function Ot(t,e){let r=typeof e.reason=="string"&&e.reason.trim()?e.reason:"unknown",n=p[0];return n?n.boardOps.sourceDataFetchFailure({params:{token:t,reason:r}}):{status:"fail",error:"no board context"}}let $e=chunkLFVMX23W_cjs.b({sseHub:l,queueSseHub:R,corsHeaders:b,json:et,buildPublishedRuntimePayload:()=>dt(),onSseClientConnected:S,onChannelSubscribed:q,onChannelUnsubscribed:K,apiBasePath:w,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),bootstrapBoard:()=>at(),boardContexts:p,publishPersistedStateSnapshot:t=>ut(t),upsertCardsFromSource:(t,e)=>Rt(t,e)}).handleWatchersRoutes,He=chunk7FGPOGRV_cjs.a({apiBasePath:w,json:et,readJsonBody:t=>rt(t),bootstrapBoard:()=>at(),createMcpFacade:()=>st(),createMcpToolRegistry:t=>be(t),resolveCardFileDownloadPayload:(t,e,r)=>kt(t,e,r),isLikelyTextMimeType:t=>Ie(t),sliceTextByLines:(t,e,r)=>qe(t,e,r)}).handleAgentfaceApi,Le=chunkNM6O35RY_cjs.a({apiBasePath:w,json:et,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),createMcpWebhookToolRegistry:()=>Se()}).handleWebhooksApi,Ue=ue({apiBasePath:w,json:et,readJsonBody:t=>rt(t),bootstrapBoard:()=>at(),createMcpControlplaneToolRegistry:()=>bt(),retriggerCard:t=>Oe(t),applyCardAction:(t,e,r)=>_e(t,e,r),resolveChatHandlerTarget:t=>Bt(t),sendCardFileDownloadResponse:(t,e,r,n)=>De(t,e,r,n)}).handleRuntimeApi,We=de({apiBasePath:w,emitNotifications:t=>V(t),readJsonBody:t=>rt(t),json:(t,e,r)=>et(t,e,r)}).handleNotifyRoute;async function Je(t,e,r){return !!(await He(t,e,r)||await Le(t,e,r)||await $e(t,e,r)||await We(t,e,r)||await Ue(t,e,r))}return {get apiBasePath(){return w},get corsHeaders(){return b},get queueLaneTuning(){return I},handleRuntimeApi:Je,emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);},buildPublishedRuntimePayload:dt,__drainProcessAccumulatedLane:yt,handleChatAgentRequest:Me,clearChatRecords:Fe,reportSourceFetched(t,e){return Pt(t,{ref:e})},reportSourceFetchFailure(t,e){return Ot(t,{reason:e})},get cardStore(){return p[0]?.publicCardStore??{get(){return Promise.resolve({status:"fail",error:"no board context"})},set(){return Promise.resolve({status:"fail",error:"no board context"})}}}}}function Dr(g){let w=String(g.apiBasePath||"/api/boards").replace(/\/$/,""),b={...fe,...g.corsHeaders||{}},I=g.serverMetaStore,B=g.boardRuntimeFactory,$=new Map,N="boards-config.json";function x(){let l=I.getText(N);if(!l)return {boards:[{id:"default",label:"Default Board"}]};try{return JSON.parse(l)}catch{return {boards:[{id:"default",label:"Default Board"}]}}}function _(l){I.putText(N,JSON.stringify(l,null,2));}function H(l){let R=String(l||"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/^_+|_+$/g,"");return R.length>0&&R.length<=64?R:null}function E(l){if($.has(l))return $.get(l);let F=x().boards.find(f=>f.id===l)||{},p=B(l,F);return $.set(l,p),p}function T(l,R,F){let p=JSON.stringify(F),f=typeof Buffer<"u"?Buffer.byteLength(p):new TextEncoder().encode(p).length;l.writeHead(R,{...b,"Content-Type":"application/json; charset=utf-8","Content-Length":f}),l.end(p);}async function S(l,R,F){let p=l.method||"GET",f=F.pathname;if(p==="GET"&&f===w)return T(R,200,{ok:true,boards:x().boards}),true;if(p==="POST"&&f===w){let y=[];for await(let O of l)y.push(O);let k=typeof Buffer<"u"?Buffer.concat(y).toString("utf-8").trim():new TextDecoder().decode(chunkBQUQTOPB_cjs.d(y)).trim(),u={};try{u=k?JSON.parse(k):{};}catch{u={};}let P=H(u.id);if(!P)return T(R,400,{error:"board id must be 1-64 alphanumeric/dash/underscore characters"}),true;let v=x();if(v.boards.some(O=>O.id===P))return T(R,409,{error:`Board "${P}" is already registered`}),true;let A=typeof u.label=="string"&&u.label.trim()?u.label.trim():P,D={id:P,label:A};for(let[O,U]of Object.entries(u))O==="id"||O==="label"||U!=null&&(D[O]=U);return v.boards.push(D),_(v),T(R,200,{ok:true,board:D}),true}return false}async function z(l,R,F){let f=F.pathname.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(w)}/([^/]+)(/|$)`));if(!f)return false;let y=H(decodeURIComponent(f[1]));return y?x().boards.some(P=>P.id===y)?!!await E(y).handleRuntimeApi(l,R,F):(T(R,404,{error:`Board "${y}" not registered. POST ${w} with {id} to register it first.`}),true):(T(R,400,{error:"Invalid board id"}),true)}async function q(l,R,F){return !!(await S(l,R,F)||await z(l,R,F))}function K(l){if(!x().boards.some(F=>F.id===l))throw Object.assign(new Error(`Board "${l}" not registered`),{statusCode:404});return {service:E(l)}}return {get apiBasePath(){return w},get corsHeaders(){return b},handleApi:q,requireBoardService:K}}exports.a=_r;exports.b=Dr;//# sourceMappingURL=chunk-2AIIEBBL.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-2AIIEBBL.cjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkUJ7ZTV4J_cjs=require('./chunk-UJ7ZTV4J.cjs'),chunkGNFE24S7_cjs=require('./chunk-GNFE24S7.cjs'),$=require('ajv-formats'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var $__default=/*#__PURE__*/_interopDefault($);var g={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},presentation:{type:"object",description:"Semantic presentation hints authored on the card, expressed from the user's perception of the card on the Main Canvas. Content shape is inferred from view.elements[].kind; runtime placement and live drag/resize coordinates are frontend-managed and must not be authored into card JSON.",properties:{prominence:{type:"string",default:"standard",description:"How much the user should care about this card / how much attention it earns. Default: standard; omit unless a non-standard value is needed.",enum:["glance","standard","feature","spotlight"]},footprint:{type:"string",default:"standard",description:"How much room the card wants to render well, independent of attention. Default: standard; omit unless a non-standard value is needed.",enum:["compact","standard","wide","large"]},resizable:{type:"boolean",default:true,description:"Whether the user may resize this card at runtime. Default: true; omit unless it must be false."}},additionalProperties:true},tags:{type:"array",items:{type:"string"}}},additionalProperties:true},__private:{description:"Control-plane-owned private state. Stripped entirely from all regular /mcp read responses. Writable only via 'setstate.card-private' and 'manage.admin-upsert-card'. Agents must never author this field. Keys inside use plain names (no leading underscores).",type:"object",additionalProperties:true},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},skip_when:{type:"string",description:"JSONata over card_data/requires. Truthy skips this source."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],additionalProperties:false,properties:{kind:{enum:["metric","table","editable-table","chart","form","list","notes","todo","alert","narrative","badge","text","markdown","markup","selection","searchbox","query","ref","custom","actions","multi-file-upload"]},id:{type:"string",description:"Optional element ID for targeted updates and action routing"},label:{type:"string",description:"Heading above this element (also the metric/alert title)"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},containerStyle:{type:"object",description:"Inline style applied to the element container"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{allOf:[{$ref:"#/definitions/value_source"}],description:"The element value: { bind } (dynamic) or { value } (static literal)"},writeTo:{$ref:"#/definitions/write_ref"},spec:{type:"object",description:"Per-kind static configuration (constrained per kind below)"}},allOf:[{if:{properties:{kind:{const:"metric"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"table"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_table"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"list"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_table"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"chart"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_chart"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"alert"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_alert"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"badge"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_badge"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"narrative"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"text"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_text"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"markdown"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"markup"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"actions"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_actions"},data:false,writeTo:false}}},{if:{properties:{kind:{const:"selection"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_single_field"}}}},{if:{properties:{kind:{const:"searchbox"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_searchbox"}}}},{if:{properties:{kind:{const:"query"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_searchbox"}}}},{if:{properties:{kind:{const:"form"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_form"}}}},{if:{properties:{kind:{const:"notes"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"}}}},{if:{properties:{kind:{const:"todo"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"}}}},{if:{properties:{kind:{const:"editable-table"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_editable_table"}}}},{if:{properties:{kind:{const:"ref"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_ref"}}}}]},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}}}},value_source:{description:"Element value source. Exactly one of `bind` (dynamic path) or `value` (static inline literal).",type:"object",oneOf:[{required:["bind"],additionalProperties:false,properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read the value from"}}},{required:["value"],additionalProperties:false,properties:{value:{description:"Static inline literal value (no binding)."}}}]},write_ref:{type:"string",pattern:"^card_data(\\.|$)",description:"card_data path the element writes user input to (input kinds only)"},spec_empty:{type:"object",additionalProperties:false,properties:{}},spec_table:{type:"object",additionalProperties:false,properties:{columns:{type:"array",items:{type:"string"},description:"Visible columns, in order"},maxRows:{type:"integer",description:"Max rows to display"},sortable:{type:"boolean",default:true,description:"Enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"}}},spec_chart:{type:"object",additionalProperties:false,properties:{chartType:{enum:["bar","line","area","scatter","pie","doughnut"],description:"Explicit chart type (else auto-detected)"},columns:{type:"array",items:{type:"string"},description:"First column is the label/x axis; rest are series"},labelKey:{type:"string",description:"Row key to use as the category/x label"},xKey:{type:"string",description:"Row key to use as the x axis (line charts)"},series:{type:"array",items:{type:"string"},description:"Row keys to plot as series"},stacked:{type:"boolean",description:"Stack bar/area series"},legend:{type:"boolean",default:true,description:"Show the legend"},grid:{type:"boolean",default:true,description:"Show the cartesian grid"},height:{type:"integer",default:220,description:"Chart height in pixels"}}},spec_alert:{type:"object",additionalProperties:false,properties:{thresholds:{type:"object",additionalProperties:false,properties:{green:{type:"string",description:"Comparison expr, e.g. '>=80'"},amber:{type:"string",description:"Comparison expr, e.g. '>=50'"}}}}},spec_badge:{type:"object",additionalProperties:false,properties:{colorMap:{type:"object",additionalProperties:{type:"string"},description:"value \u2192 tone/Bootstrap color"}}},spec_text:{type:"object",additionalProperties:false,properties:{format:{enum:["default","file-links"],description:"'file-links' renders the bound file array as download links"},style:{enum:["default","muted","muted-italic","heading"],description:"Display style"},hideIfEmpty:{type:"boolean",description:"Render nothing when the value is empty"}}},spec_actions:{type:"object",additionalProperties:false,required:["buttons"],properties:{buttons:{type:"array",description:"Button definitions; clicks emit an action save keyed by element id + button id",items:{type:"object",required:["id","label"],additionalProperties:false,properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}},spec_form:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"JSON-Schema-ish { properties, required } describing the form fields"},discardLabel:{type:"string"},saveLabel:{type:"string"},validators:{type:"array",description:"Cross-field validation rules. Each item is a [jsonataExpr, errorMessage] pair; the expr is evaluated against { data: <current field values> } and must return true to pass. Required-field emptiness is already handled by fields.required, so validators are for format/relationship rules. Runs on blur and submit.",items:{type:"array",minItems:2,maxItems:2,items:{type:"string"}}}}},spec_single_field:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"Single-property JSON-Schema-ish { properties, required } for the control"}}},spec_searchbox:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"Single-property JSON-Schema-ish { properties, required } for the query field"},actionLabel:{type:"string",description:"Submit button label (default 'Search')"}}},spec_editable_table:{type:"object",additionalProperties:false,properties:{schema:{type:"object",description:"JSON-Schema-ish { properties } describing per-column cell types"},columns:{type:"array",items:{type:"string"},description:"Explicit column order"},addRow:{type:"boolean",default:true},deleteRow:{type:"boolean",default:true},placeholder:{type:"string"}}},spec_ref:{type:"object",additionalProperties:true,required:["viewBind"],properties:{viewBind:{$ref:"#/definitions/bind_ref",description:"Path to a computed view descriptor { kind, data?, spec? } selecting the effective kind at runtime"},fallbackKind:{enum:["metric","table","editable-table","chart","form","list","notes","todo","alert","narrative","badge","text","markdown","markup","selection","searchbox","query","ref","custom","actions","multi-file-upload"],description:"Kind to use when viewBind is absent/unresolved"},columns:{type:"array",items:{type:"string"},description:"Columns to forward to the resolved table/list view"}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},__private:{$ref:"#/definitions/__private"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"User editable data on card. Includes uploaded-file metadata maintained by host handlers. Not to be used for card static content.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}},filegroups:{type:"array",description:"Optional grouped multi-file upload submissions maintained by host handlers. Each entry references files in card_data.files by index and carries an optional message. Identified by array position.",items:{type:"object",required:["file_idxs"],properties:{message:{type:"string",description:"Optional message associated with the upload group; empty string when none."},file_idxs:{type:"array",description:"Indexes into card_data.files identifying the files in this group, in upload order.",items:{type:"integer",minimum:0}},created_at:{type:"string",format:"date-time"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var v=chunkGNFE24S7_cjs.b(chunkUJ7ZTV4J_cjs.q(),1);var A=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3EITX4IQ.cjs', document.baseURI).href))),E=A("./jsonata-sync.cjs"),m=null;var _=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,N=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function P(e){let t=new Set,s;for(_.lastIndex=0;(s=_.exec(e))!==null;)t.add(s[1]);return t}function w(e){let t=N.exec(e);return t?t[1]:null}function h(e,t,s,o){try{E(e);}catch(n){let d=n instanceof Error?n.message:String(n);o.push(`${t}: invalid JSONata expression (${d})`);return}let i=P(e);for(let n of i)s.has(n)||o.push(`${t}: disallowed namespace "${n}" in expression`);}function b(e,t,s){if(Array.isArray(e)){e.forEach((i,n)=>{b(i,`${t}/${n}`,s);});return}if(typeof e=="string"){let i=w(e);if(!i)return;new Set(["card_data","requires","computed_values"]).has(i)||s.push(`${t}: disallowed namespace "${i}" in view reference`);return}if(!e||typeof e!="object")return;let o=e;for(let[i,n]of Object.entries(o))b(n,`${t}/${i}`,s);}function T(){if(m)return m;let e=new v.default({allErrors:true});return $__default.default(e),m=e.compile(g),m}function R(e){let t=T(),s=t(e),o=(t.errors??[]).map(i=>`${i.instancePath||"/"}: ${i.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let i=e.source_defs;if(Array.isArray(i)){let n=new Set,d=new Set;i.forEach((p,l)=>{if(!p||typeof p!="object"||Array.isArray(p))return;let r=p;typeof r.bindTo=="string"&&r.bindTo&&(n.has(r.bindTo)&&o.push(`/source_defs/${l}/bindTo: bindTo "${r.bindTo}" must be unique across all source_defs`),n.add(r.bindTo)),typeof r.outputFile=="string"&&r.outputFile&&(d.has(r.outputFile)&&o.push(`/source_defs/${l}/outputFile: outputFile "${r.outputFile}" must be unique across all source_defs`),d.add(r.outputFile));});}}return !s||o.length>0?{ok:false,errors:o}:{ok:true,errors:[]}}function O(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let s=e,o=s.compute;Array.isArray(o)&&o.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r.expr;typeof a!="string"||a.trim().length===0||h(a,`/compute/${c}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let i=new Set(["card_data","requires","fetched_sources","computed_values"]),n=s.provides;Array.isArray(n)&&n.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r.ref;if(typeof a!="string"||a.trim().length===0)return;let u=w(a);u===null?t.push(`/provides/${c}/ref: path "${a}" must start with a valid namespace (${[...i].join(", ")})`):i.has(u)||t.push(`/provides/${c}/ref: disallowed namespace "${u}" in path "${a}" (valid: ${[...i].join(", ")})`);});let d=s.view;d&&typeof d=="object"&&!Array.isArray(d)&&b(d,"/view",t);let p=new Set(["card_data","requires"]),l=s.source_defs;return Array.isArray(l)&&l.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r,u=a.skip_when;typeof u=="string"&&u.trim().length>0&&h(u,`/source_defs/${c}/skip_when`,p,t);let f=a.projections;if(!(!f||typeof f!="object"||Array.isArray(f)))for(let[k,y]of Object.entries(f))typeof y!="string"||y.trim().length===0||h(y,`/source_defs/${c}/projections/${k}`,p,t);}),{ok:t.length===0,errors:t}}function V(e){return F(e)}function F(e){let t=R(e);if(!t.ok)return t;let s=O(e);return s.ok?{ok:true,errors:[]}:{ok:false,errors:s.errors}}
|
|
2
|
+
exports.a=R;exports.b=O;exports.c=V;exports.d=F;//# sourceMappingURL=chunk-3EITX4IQ.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-3EITX4IQ.cjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {q}from'./chunk-MNEOJWPS.js';import {b as b$1}from'./chunk-FW4363Y4.js';import $ from'ajv-formats';import {createRequire}from'module';var g={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},presentation:{type:"object",description:"Semantic presentation hints authored on the card, expressed from the user's perception of the card on the Main Canvas. Content shape is inferred from view.elements[].kind; runtime placement and live drag/resize coordinates are frontend-managed and must not be authored into card JSON.",properties:{prominence:{type:"string",default:"standard",description:"How much the user should care about this card / how much attention it earns. Default: standard; omit unless a non-standard value is needed.",enum:["glance","standard","feature","spotlight"]},footprint:{type:"string",default:"standard",description:"How much room the card wants to render well, independent of attention. Default: standard; omit unless a non-standard value is needed.",enum:["compact","standard","wide","large"]},resizable:{type:"boolean",default:true,description:"Whether the user may resize this card at runtime. Default: true; omit unless it must be false."}},additionalProperties:true},tags:{type:"array",items:{type:"string"}}},additionalProperties:true},__private:{description:"Control-plane-owned private state. Stripped entirely from all regular /mcp read responses. Writable only via 'setstate.card-private' and 'manage.admin-upsert-card'. Agents must never author this field. Keys inside use plain names (no leading underscores).",type:"object",additionalProperties:true},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},skip_when:{type:"string",description:"JSONata over card_data/requires. Truthy skips this source."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],additionalProperties:false,properties:{kind:{enum:["metric","table","editable-table","chart","form","list","notes","todo","alert","narrative","badge","text","markdown","markup","selection","searchbox","query","ref","custom","actions","multi-file-upload"]},id:{type:"string",description:"Optional element ID for targeted updates and action routing"},label:{type:"string",description:"Heading above this element (also the metric/alert title)"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},containerStyle:{type:"object",description:"Inline style applied to the element container"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{allOf:[{$ref:"#/definitions/value_source"}],description:"The element value: { bind } (dynamic) or { value } (static literal)"},writeTo:{$ref:"#/definitions/write_ref"},spec:{type:"object",description:"Per-kind static configuration (constrained per kind below)"}},allOf:[{if:{properties:{kind:{const:"metric"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"table"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_table"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"list"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_table"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"chart"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_chart"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"alert"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_alert"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"badge"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_badge"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"narrative"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"text"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_text"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"markdown"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"markup"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"},writeTo:false},required:["data"]}},{if:{properties:{kind:{const:"actions"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_actions"},data:false,writeTo:false}}},{if:{properties:{kind:{const:"selection"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_single_field"}}}},{if:{properties:{kind:{const:"searchbox"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_searchbox"}}}},{if:{properties:{kind:{const:"query"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_searchbox"}}}},{if:{properties:{kind:{const:"form"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_form"}}}},{if:{properties:{kind:{const:"notes"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"}}}},{if:{properties:{kind:{const:"todo"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_empty"}}}},{if:{properties:{kind:{const:"editable-table"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_editable_table"}}}},{if:{properties:{kind:{const:"ref"}},required:["kind"]},then:{properties:{spec:{$ref:"#/definitions/spec_ref"}}}}]},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}}}},value_source:{description:"Element value source. Exactly one of `bind` (dynamic path) or `value` (static inline literal).",type:"object",oneOf:[{required:["bind"],additionalProperties:false,properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read the value from"}}},{required:["value"],additionalProperties:false,properties:{value:{description:"Static inline literal value (no binding)."}}}]},write_ref:{type:"string",pattern:"^card_data(\\.|$)",description:"card_data path the element writes user input to (input kinds only)"},spec_empty:{type:"object",additionalProperties:false,properties:{}},spec_table:{type:"object",additionalProperties:false,properties:{columns:{type:"array",items:{type:"string"},description:"Visible columns, in order"},maxRows:{type:"integer",description:"Max rows to display"},sortable:{type:"boolean",default:true,description:"Enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"}}},spec_chart:{type:"object",additionalProperties:false,properties:{chartType:{enum:["bar","line","area","scatter","pie","doughnut"],description:"Explicit chart type (else auto-detected)"},columns:{type:"array",items:{type:"string"},description:"First column is the label/x axis; rest are series"},labelKey:{type:"string",description:"Row key to use as the category/x label"},xKey:{type:"string",description:"Row key to use as the x axis (line charts)"},series:{type:"array",items:{type:"string"},description:"Row keys to plot as series"},stacked:{type:"boolean",description:"Stack bar/area series"},legend:{type:"boolean",default:true,description:"Show the legend"},grid:{type:"boolean",default:true,description:"Show the cartesian grid"},height:{type:"integer",default:220,description:"Chart height in pixels"}}},spec_alert:{type:"object",additionalProperties:false,properties:{thresholds:{type:"object",additionalProperties:false,properties:{green:{type:"string",description:"Comparison expr, e.g. '>=80'"},amber:{type:"string",description:"Comparison expr, e.g. '>=50'"}}}}},spec_badge:{type:"object",additionalProperties:false,properties:{colorMap:{type:"object",additionalProperties:{type:"string"},description:"value \u2192 tone/Bootstrap color"}}},spec_text:{type:"object",additionalProperties:false,properties:{format:{enum:["default","file-links"],description:"'file-links' renders the bound file array as download links"},style:{enum:["default","muted","muted-italic","heading"],description:"Display style"},hideIfEmpty:{type:"boolean",description:"Render nothing when the value is empty"}}},spec_actions:{type:"object",additionalProperties:false,required:["buttons"],properties:{buttons:{type:"array",description:"Button definitions; clicks emit an action save keyed by element id + button id",items:{type:"object",required:["id","label"],additionalProperties:false,properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}},spec_form:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"JSON-Schema-ish { properties, required } describing the form fields"},discardLabel:{type:"string"},saveLabel:{type:"string"},validators:{type:"array",description:"Cross-field validation rules. Each item is a [jsonataExpr, errorMessage] pair; the expr is evaluated against { data: <current field values> } and must return true to pass. Required-field emptiness is already handled by fields.required, so validators are for format/relationship rules. Runs on blur and submit.",items:{type:"array",minItems:2,maxItems:2,items:{type:"string"}}}}},spec_single_field:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"Single-property JSON-Schema-ish { properties, required } for the control"}}},spec_searchbox:{type:"object",additionalProperties:false,required:["fields"],properties:{fields:{type:"object",description:"Single-property JSON-Schema-ish { properties, required } for the query field"},actionLabel:{type:"string",description:"Submit button label (default 'Search')"}}},spec_editable_table:{type:"object",additionalProperties:false,properties:{schema:{type:"object",description:"JSON-Schema-ish { properties } describing per-column cell types"},columns:{type:"array",items:{type:"string"},description:"Explicit column order"},addRow:{type:"boolean",default:true},deleteRow:{type:"boolean",default:true},placeholder:{type:"string"}}},spec_ref:{type:"object",additionalProperties:true,required:["viewBind"],properties:{viewBind:{$ref:"#/definitions/bind_ref",description:"Path to a computed view descriptor { kind, data?, spec? } selecting the effective kind at runtime"},fallbackKind:{enum:["metric","table","editable-table","chart","form","list","notes","todo","alert","narrative","badge","text","markdown","markup","selection","searchbox","query","ref","custom","actions","multi-file-upload"],description:"Kind to use when viewBind is absent/unresolved"},columns:{type:"array",items:{type:"string"},description:"Columns to forward to the resolved table/list view"}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},__private:{$ref:"#/definitions/__private"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"User editable data on card. Includes uploaded-file metadata maintained by host handlers. Not to be used for card static content.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}},filegroups:{type:"array",description:"Optional grouped multi-file upload submissions maintained by host handlers. Each entry references files in card_data.files by index and carries an optional message. Identified by array position.",items:{type:"object",required:["file_idxs"],properties:{message:{type:"string",description:"Optional message associated with the upload group; empty string when none."},file_idxs:{type:"array",description:"Indexes into card_data.files identifying the files in this group, in upload order.",items:{type:"integer",minimum:0}},created_at:{type:"string",format:"date-time"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var v=b$1(q(),1);var A=createRequire(import.meta.url),E=A("./jsonata-sync.cjs"),m=null;var _=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,N=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function P(e){let t=new Set,s;for(_.lastIndex=0;(s=_.exec(e))!==null;)t.add(s[1]);return t}function w(e){let t=N.exec(e);return t?t[1]:null}function h(e,t,s,o){try{E(e);}catch(n){let d=n instanceof Error?n.message:String(n);o.push(`${t}: invalid JSONata expression (${d})`);return}let i=P(e);for(let n of i)s.has(n)||o.push(`${t}: disallowed namespace "${n}" in expression`);}function b(e,t,s){if(Array.isArray(e)){e.forEach((i,n)=>{b(i,`${t}/${n}`,s);});return}if(typeof e=="string"){let i=w(e);if(!i)return;new Set(["card_data","requires","computed_values"]).has(i)||s.push(`${t}: disallowed namespace "${i}" in view reference`);return}if(!e||typeof e!="object")return;let o=e;for(let[i,n]of Object.entries(o))b(n,`${t}/${i}`,s);}function T(){if(m)return m;let e=new v.default({allErrors:true});return $(e),m=e.compile(g),m}function R(e){let t=T(),s=t(e),o=(t.errors??[]).map(i=>`${i.instancePath||"/"}: ${i.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let i=e.source_defs;if(Array.isArray(i)){let n=new Set,d=new Set;i.forEach((p,l)=>{if(!p||typeof p!="object"||Array.isArray(p))return;let r=p;typeof r.bindTo=="string"&&r.bindTo&&(n.has(r.bindTo)&&o.push(`/source_defs/${l}/bindTo: bindTo "${r.bindTo}" must be unique across all source_defs`),n.add(r.bindTo)),typeof r.outputFile=="string"&&r.outputFile&&(d.has(r.outputFile)&&o.push(`/source_defs/${l}/outputFile: outputFile "${r.outputFile}" must be unique across all source_defs`),d.add(r.outputFile));});}}return !s||o.length>0?{ok:false,errors:o}:{ok:true,errors:[]}}function O(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let s=e,o=s.compute;Array.isArray(o)&&o.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r.expr;typeof a!="string"||a.trim().length===0||h(a,`/compute/${c}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let i=new Set(["card_data","requires","fetched_sources","computed_values"]),n=s.provides;Array.isArray(n)&&n.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r.ref;if(typeof a!="string"||a.trim().length===0)return;let u=w(a);u===null?t.push(`/provides/${c}/ref: path "${a}" must start with a valid namespace (${[...i].join(", ")})`):i.has(u)||t.push(`/provides/${c}/ref: disallowed namespace "${u}" in path "${a}" (valid: ${[...i].join(", ")})`);});let d=s.view;d&&typeof d=="object"&&!Array.isArray(d)&&b(d,"/view",t);let p=new Set(["card_data","requires"]),l=s.source_defs;return Array.isArray(l)&&l.forEach((r,c)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r,u=a.skip_when;typeof u=="string"&&u.trim().length>0&&h(u,`/source_defs/${c}/skip_when`,p,t);let f=a.projections;if(!(!f||typeof f!="object"||Array.isArray(f)))for(let[k,y]of Object.entries(f))typeof y!="string"||y.trim().length===0||h(y,`/source_defs/${c}/projections/${k}`,p,t);}),{ok:t.length===0,errors:t}}function V(e){return F(e)}function F(e){let t=R(e);if(!t.ok)return t;let s=O(e);return s.ok?{ok:true,errors:[]}:{ok:false,errors:s.errors}}
|
|
2
|
+
export{R as a,O as b,V as c,F as d};//# sourceMappingURL=chunk-NJCDHKPX.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-NJCDHKPX.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a,b}from'./chunk-JB4Q2W7I.js';import {a as a$3}from'./chunk-XYN5D3GL.js';import {a as a$5,c as c$2}from'./chunk-O5UYCGIN.js';import {p,j,k,l,c as c$1,d as d$1,m as m$1,n,e as e$2,a as a$7,b as b$3,o}from'./chunk-F6KRSQ7V.js';import {a as a$4,d as d$2,b as b$2,c as c$3}from'./chunk-FOFGEABN.js';import {a as a$b}from'./chunk-RKKSVOP2.js';import {a as a$2}from'./chunk-NTICU4OK.js';import {a as a$8,c as c$4}from'./chunk-O7NOHKVR.js';import {a as a$9,b as b$4}from'./chunk-ZJ5M5COT.js';import {i,d,c,b as b$1,g,h}from'./chunk-E7SDEZSI.js';import {a as a$a}from'./chunk-PEJRTZU3.js';import {e,f}from'./chunk-C7OY3PYL.js';import {H,m}from'./chunk-QJQ53PLM.js';import {a as a$6}from'./chunk-BJGK5FNL.js';import {a as a$1}from'./chunk-NIBLKYXN.js';import {e as e$1}from'./chunk-UGB7PC4P.js';function ce(g){let{apiBasePath:w,json:b,readJsonBody:I,bootstrapBoard:B,createMcpControlplaneToolRegistry:$,retriggerCard:N,applyCardAction:x,resolveChatHandlerTarget:_,sendCardFileDownloadResponse:H}=g;async function E(T,S,z){let q=T.method||"GET",K=z,l=K.pathname;try{if(q==="POST"&&l===`${w}/mcp-actions`){await B();let f=Date.now(),y=new Date(f).toISOString(),k=await I(T),u=typeof k.tool=="string"?k.tool.trim():"",P=k.args&&typeof k.args=="object"&&!Array.isArray(k.args)?k.args:{};if(!u)return b(S,400,{error:"tool is required"}),!0;let v=a$8(P,"card_id");if(!v)return b(S,400,{error:"MCP action requires card_id"}),!0;if(u==="retrigger-card"||u==="retrigger"){await N(v);let O=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:200}}),!0}let A=c$4(P,"payload");if(u==="chat-send"&&!await _(v)){let O=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:409}),!0}if(u==="chat-send"){let O=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!O||!String(O).trim()){let U=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(U).toISOString(),responseSentAtMs:U,responseStatus:400}),!0}}await x(v,u,A);let D=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(D).toISOString(),responseSentAtMs:D,responseStatus:200}}),!0}if(q==="POST"&&l===`${w}/mcp-controlplane`){await B();let f=await I(T),y=typeof f.tool=="string"?f.tool.trim():"",k=f.args&&typeof f.args=="object"&&!Array.isArray(f.args)?f.args:{};if(!y)return b(S,400,{error:"tool is required"}),!0;try{let u=await a$9(y,k,$());if(u&&typeof u=="object"&&!Array.isArray(u)){let P=u;if(P.status==="fail")return b(S,400,{error:b$4(u,"Request failed")}),!0;if(P.status==="error")return b(S,500,{error:b$4(u,"Internal error")}),!0}b(S,200,u);}catch(u){let P=typeof u?.statusCode=="number"?Number(u.statusCode):500,v=u instanceof Error?u.message:String(u);b(S,P,{error:v});}return !0}let R=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/retrigger$`));if(q==="POST"&&R){await B();let f=decodeURIComponent(R[1]);return await N(f),b(S,200,{ok:!0}),!0}let F=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/actions$`));if(q==="POST"&&F){await B();let f=decodeURIComponent(F[1]),y=Date.now(),k=new Date(y).toISOString(),u=await I(T),P=u?.actionType;if(P==="chat-send"&&!await _(f)){let A=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(A).toISOString(),responseSentAtMs:A,responseStatus:409}),!0}if(P==="chat-send"){let A=u?.payload??{},D=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!D||!String(D).trim()){let O=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:400}),!0}}await x(f,P,u?.payload);let v=Date.now();return b(S,200,{ok:!0,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(v).toISOString(),responseSentAtMs:v,responseStatus:200}),!0}let p=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/files/(\\d+)$`));if(q==="GET"&&p){let f=decodeURIComponent(p[1]),y=parseInt(p[2],10),k=K.searchParams.get("sn");return await H(S,f,y,k),!0}return !1}catch(R){let F=R?.statusCode||500;return b(S,F,{error:String(R?.message||R)}),true}}return {handleRuntimeApi:E}}var Ke=3e4;function Ve(g){let w=g.socket?.remoteAddress??"";return w==="127.0.0.1"||w==="::1"||w==="::ffff:127.0.0.1"}function ue(g){let{apiBasePath:w,emitNotifications:b,readJsonBody:I,json:B}=g,$=`${w}/notify-q`;async function N(x,_,H){if(H.pathname!==$)return false;if((x.method??"").toUpperCase()!=="POST")return B(_,405,{status:"error",error:"Method not allowed"}),true;if(!Ve(x))return B(_,403,{status:"error",error:"Forbidden"}),true;let E;try{E=await I(x);}catch{return B(_,400,{status:"error",error:"Invalid JSON body"}),true}if(!E||typeof E!="object"||!Array.isArray(E.notifications))return B(_,400,{status:"error",error:"body.notifications must be an array"}),true;let T=E.notifications,{accepted:S,rejected:z}=b$3(T,Date.now(),Ke);return S.length>0&&b(S),B(_,200,{status:"success",data:{accepted:S.length,rejected:z}}),true}return {handleNotifyRoute:N}}var le={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},de="chat-handler-flow-queue",ot="__probe__echo__probe__";function Mr(g$1){let w=String(g$1.apiBasePath||"/api/board").replace(/\/$/,""),b$3={...le,...g$1.corsHeaders||{}},I=g$1.queueLaneTuning??{},B=g$1.boardId||"",$=Number.isInteger(g$1.chatBootstrapTailTurns)&&g$1.chatBootstrapTailTurns>0?g$1.chatBootstrapTailTurns:1,N=g$1.logger||{info:console.log,warn:console.warn,error:console.error},x=g$1.invocationAdapter,_=g$1.chatFlowRunner||null,H$1=g$1.notificationTransport||null,E=g$1.serverUrl||null,T=g$1.executionExtra||{},S=g$1.onSseClientConnected,z=g$1.onSseClientDisconnected,q=g$1.onChannelSubscribed,K=g$1.onChannelUnsubscribed,l$1=a({buildChatOneShotBatch:async(t,e)=>await Q.buildSseOneShotBatch({params:{cardId:t},body:{receiving:e}}),onSseClientDisconnected:z}),R=a({buildChatOneShotBatch:async()=>({status:"success",data:{kind:"notification-batch",category:"batch",notifications:[]}})});function F(t){function e$1(a){return {...a,queueStorageForRef(d,C){return a$6(a.queueStorageForRef(d,C),{lane:C,emitNotification:i$1})}}}function r(a){return {...a,queueStorageForRef(d,C){return h(a.queueStorageForRef(d,C),{lane:C,emitNotification:i$1})}}}function n(a){return {async get(d){return a.get(d)},async set(d){return a.set(d)},async del(d){return a.del(d)},async patch(d){return a.patch(d)},async appendFiles(d){return a.appendFiles(d)}}}function o(a){return {async get(d){return await a.get(d)},async set(d){return await a.set(d)},async del(d){return await a.del(d)},async patch(d){return await a.patch(d)},async appendFiles(d){return await a.appendFiles(d)}}}let s=null;function i$1(a){if(a.kind==="notification-batch"){V(a.notifications,s??void 0);return}V([a],s??void 0);}let c$2=a$4(t.boardAdapter)?r(t.boardAdapter):e$1(t.boardAdapter),j=t.nonCoreAdapter??(!a$4(c$2)&&P(c$2)?c$2:null),h$1=a$4(c$2)?i(t.baseRef,c$2,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i$1}):e(t.baseRef,c$2,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i$1}),M=t.nonCore??(j?f(t.baseRef,j,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,taskExecutorRef:t.taskExecutorRef}):null),We=c$2.chatStorageForRef(t.chatStoreRef),lt,Je=a$4(c$2)?(()=>{let a=d(c(b$1(c$2.kvStorageForRef(t.cardStoreRef)),c$2.hashFn),N.warn),d$1=g(a,{emitNotification:i$1}),C=o(d$1);return lt={get(m){return C.get(m)},set(m){return C.set(m)}},C})():(()=>{let a=c$2.kvStorageForRef(t.cardStoreRef),C=H(m({readIndex:()=>a.read("_index"),writeIndex:m=>a.write("_index",m),readCard:m=>a.read(m),writeCard:(m,pt)=>(a.write(m,pt),m),removeCard:m=>{a.delete(m);},cardExists:m=>a.read(m)!==null,defaultCardKey:m=>m},N.warn),{emitNotification:i$1});return lt=C,n(C)})(),ft;if(a$4(c$2)){let a=c$2.blobStorageForRef(t.artifactsStoreRef);ft={async putBytes(d,C){if(a.writeBytes){await a.writeBytes(d,C);return}let m=JSON.stringify({__kind:"bytes-array",data:[...C]});await a.write(d,m);},async getBytes(d){if(a.readBytes){let m=await a.readBytes(d);if(m!==null)return m}let C=await a.read(d);if(C===null)return null;try{let m=JSON.parse(C);if(m&&m.__kind==="bytes-array"&&Array.isArray(m.data))return new Uint8Array(m.data)}catch{}return new TextEncoder().encode(C)},async listKeys(d){return await a.listKeys(d)}};}else {let a=c$2.blobStorageForRef(t.artifactsStoreRef),d=a$5(a);ft={putBytes(C,m,pt){d.putBytes(C,m,pt);},getBytes(C){return d.getBytes(C)},listKeys(C){return d.list(C).map(m=>m.key)}};}let ze={async init(a){return h$1.init(a)},async status(a){return h$1.status(a)},async getConfig(a){return h$1.getConfig(a)},async getAllOutputsDataObjects(a){return h$1.getAllOutputsDataObjects(a)},async getAllOutputsComputedValues(a){return h$1.getAllOutputsComputedValues(a)},async getOutputsFetchedSources(a){return h$1.getOutputsFetchedSources(a)},async buildSseOneShotPayload(a){return h$1.buildSseOneShotPayload(a)},async upsertCard(a){return h$1.upsertCard(a)},async removeCard(a){return h$1.removeCard(a)},async sourceDataFetched(a){return h$1.sourceDataFetched(a)},async sourceDataFetchFailure(a){return h$1.sourceDataFetchFailure(a)}};return s={label:t.label,board:h$1,nonCore:M,publicCardStore:lt,boardOps:ze,cardStoreOps:Je,get filesArtifacts(){return ft},get chatStorage(){return We},boardAdapter:c$2,boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:c$1(),notificationTeardown:null,initialized:false,cardsBootstrapped:false},s}let p$1=g$1.boards.map(F),f$1=new Map;function y(t){return f$1.get(t)??0}function k$1(t){return t.queueStoreRef}function u(t,e){if(a$4(t.boardAdapter)){let n=t.boardAdapter.queueStorageForRef(k$1(t),e);return a$a(n)}let r=t.boardAdapter.queueStorageForRef(k$1(t),e);return a$b(r)}function P(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function v(t){let e=p$1[y(t)];return {files:e?e.filesArtifacts:null}}function A(){return c$2()}function D(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}function O(t){return "cardId"in t&&typeof t.cardId=="string"?W(t.cardId)??void 0:p$1[0]??void 0}function U(t){for(let e of t){let r=O(e);if(r)return r}return p$1[0]??void 0}function ct(t,e={}){if(!t||t.length===0)return;let r=e$1(t),n={kind:"notification-batch",category:"batch",notifications:r},o=e.ctx??U(r);if(e.appendState!==false&&o&&e$2(o.notification,n),e.broadcastSse!==false){let s=r.filter(c=>c.kind==="message_enqueued"),i=r.filter(c=>c.kind!=="message_enqueued");i.length>0&&l$1.broadcastNotificationBatch(i),s.length>0&&R.broadcastNotificationBatch(s);}if(!(e.mirrorExternal===false||!o?.boardAdapter.publishBoardChangeNotifications))try{let s=r.filter(i=>i.category==="board-output"||i.category==="card-store"||i.category==="chat-store"||i.category==="hosted-runtime");s.length>0&&o.boardAdapter.publishBoardChangeNotifications(s);}catch{}}function V(t,e){ct(t,{ctx:e,appendState:true,broadcastSse:true,mirrorExternal:true});}async function fe(t){if(!t||t.notificationTeardown||!H$1||!t.notifyRef)return;let e=await H$1.subscribe(t.notifyRef,r=>{let n=a$7(r);ct(n,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});});t.notificationTeardown=e;}async function pe(t){if(!t||t.initialized)return;let e={boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,artifactsStoreRef:t.artifactsStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef},r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow);let n=await t.boardOps.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await fe(t),!t.chatHandlerFlow&&t.chatHandlerRef&&x.describe)try{let o=await x.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?N.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&N.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){N.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}async function ut(t){let e=[],r=await t.boardOps.status({});r.status==="success"&&r.data!=null&&d$1(r.data)&&e.push({kind:"status",status:r.data});let n=await t.boardOps.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,i]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:i});let o=await t.boardOps.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,i]of Object.entries(o.data))s&&i&&typeof i=="object"&&!Array.isArray(i)&&e.push({kind:"computed_values",cardId:s,values:i});e.length>0&&ct(e,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});}async function Rt(t,e){if(!t||t.cardsBootstrapped)return;let r=await t.cardStoreOps.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(f$1.set(o.id,e),await t.boardOps.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function G(){for(let t of p$1)await pe(t);}async function at(){await G();for(let t=0;t<p$1.length;t++)await ut(p$1[t]),await Rt(p$1[t],t),await ut(p$1[t]);}async function yt(t=false){t||await G();for(let e of p$1){let r=await e.board.processAccumulatedEvents({});if(r.status!=="success")return r}return {status:"success"}}function W(t){return p$1[y(t)]??null}async function Y(t){let e=W(t);if(!e)return null;let r=await e.cardStoreOps.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}async function me(){let t=async r=>{if(!r)return [];let n=await r.cardStoreOps.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of p$1)e.push(...await t(r));return e}function ht(){return p$1[0]??null}function ge(t){return W(t)??ht()}function L(t){let e=ge(t);if(!e)throw Object.assign(new Error(`Board context is unavailable for chat operations: ${t}`),{statusCode:404});return e.chatStorage}async function Re(t){return await L(t).isProcessing(t)}async function tt(t,e){let r=await Q.setProcessing({params:{cardId:t},body:{active:e}});if(r.status!=="success")throw Object.assign(new Error(r.error||`Failed to set chat processing for card: ${t}`),{statusCode:500})}let Q=a$1({append(t,e,r,n,o){return L(t).append(t,e,r,n,o)},readAll(t){return L(t).readAll(t)},readAfter(t,e){return L(t).readAfter(t,e)},clear(t){return L(t).clear(t)},setProcessing(t,e){return L(t).setProcessing(t,e)},isProcessing(t){return L(t).isProcessing(t)},getConfig(t){return L(t).getConfig(t)},setConfig(t,e){return L(t).setConfig(t,e)}},{emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);}}),wt=p({boardContexts:p$1,cardOwnerIndex:f$1,cardContextForCard:t=>W(t),readStatusSnapshot:()=>Se(),readDataObjectsByToken:()=>Ae(),readCardRuntimeArtifacts:()=>Ce(),readCardFromStore:t=>Y(t),readCardDefinitions:()=>me(),processAccumulatedLaneInternal:t=>yt(t),reportSourceFetched:(t,e)=>kt(t,{ref:e}),reportSourceFetchFailure:(t,e)=>Pt(t,{reason:e}),uploadCardFile:(t,e,r,n,o)=>Ct(t,e,r,n,o),chatStorePublic:Q,serverUrl:E,apiBasePath:w}),ye=wt.mcpCardStoreFacade,st=wt.createMcpFacade,he=j({boardId:B,bootstrapBoard:()=>at(),sseHub:l$1,onChannelSubscribed:q,onChannelUnsubscribed:K,getMcpFacade:()=>st(),getMcpCardStoreFacade:()=>ye()});function we(t){return m$1(t)}function be(){return n(st())}function bt(){return o({boardId:B,uploadCardFile:Ct,getMcpFacade:()=>st(),controlplane:he})}let it=k({boardId:B,boardContexts:p$1,readChatRecords:(t,e)=>ve(t,e),getChatProcessing:t=>Re(t),chatBootstrapTailTurns:$}),Se=it.readStatusSnapshot,Ce=it.readCardRuntimeArtifacts,Ae=it.readDataObjectsByToken,dt=it.buildPublishedRuntimePayload;async function St(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=W(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=await Y(t);if(!i)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let c=o?JSON.stringify(i):null,j=e(i)||i;if(o&&JSON.stringify(j)===c)return;let h=await s.cardStoreOps.set({body:j});if(h.status!=="success")throw Object.assign(new Error(h.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let M=await s.boardOps.upsertCard({params:{cardId:t,restart:true}});if(M.status!=="success")throw Object.assign(new Error(M.error||`Failed to upsert card: ${t}`),{statusCode:500})}}async function Be(t,e){await St(t,e,{syncBoard:true});}async function ke(t,e){await St(t,e,{syncBoard:false});}async function Pe(t){let e=W(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!await Y(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=await e.boardOps.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}async function Oe(t){let e=await Q.clear({params:{cardId:t}});if(e.status!=="success")throw Object.assign(new Error(e.error||`Failed to clear chat records for card: ${t}`),{statusCode:500});try{await tt(t,!1);}catch{}}async function Fe(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"",i=await Q.append({params:{cardId:t},body:{role:e||"system",text:s,files:n,turn:o}});if(i.status!=="success")throw Object.assign(new Error(i.error||`Failed to append chat record for card: ${t}`),{statusCode:500});return String(i.data?.id||"")}async function ve(t,e){let r=Number.isInteger(e?.tailTurns)&&e?.tailTurns>0?e?.tailTurns:void 0,n=await Q.readAll({params:{cardId:t},...r===void 0?{}:{body:{tailTurns:r}}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to read chat records for card: ${t}`),{statusCode:500});return Array.isArray(n.data?.records)?n.data.records:[]}let Ct=l({safeCardId:t=>D(t),artifactsStores:t=>v(t),cardFileMetadataStore:()=>A(),readCardFromStore:t=>Y(t),updateCardLocalOnly:(t,e)=>ke(t,e),writeChatRecord:(t,e,r,n,o)=>Fe(t,e,r,n,o)}).uploadCardFile;async function At(t){let e=W(t);if(!e)return null;let r=await e.boardOps.getConfig({params:{key:"chat-handler-flow"}}),o=(r.status==="success"?r.data?.value:null)??e.chatHandlerFlow??null,s=e.chatHandlerRef;return o==null&&(!s||typeof s!="object")?null:{ctx:e,handlerFlow:o,handlerRef:s}}function xe(t){let e=typeof t=="string"?t.trim():"";if(e.length<ot.length*2||!e.startsWith(ot)||!e.endsWith(ot))return null;let r=e.slice(ot.length,e.length-ot.length).trim(),n=/^([A-Za-z0-9_-]+)__(.*)$/s.exec(r);return n?{assistant:n[1].trim().toLowerCase(),text:n[2].trim()}:{assistant:"echo",text:r}}async function Te(t,e,r=false,n="",o=""){try{let s=await At(t);if(!s){try{await tt(t,!1);}catch{}return}let{ctx:i,handlerFlow:c,handlerRef:j}=s;if(!r)try{await tt(t,!0);}catch{}let h={boardId:B,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...typeof o=="string"&&o.trim()?{probe:o.trim()}:{},...T,...E?{serverUrl:E}:{}},M=c!=null?{meta:"chat-handler-flow",howToRun:"built-in",whatToRun:{kind:"built-in",value:de}}:j;a$4(i.boardAdapter)?await u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}):u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}),await Promise.resolve(i.boardAdapter.requestProcessAccumulated?.());}catch(s){try{await tt(t,!1);}catch{}N.warn(`[chat-handler] queue failed for card "${t}": ${s instanceof Error?s.message:String(s)}`);}}async function Ne(t,e,r){if(e.howToRun==="built-in"&&b$2(e)===de){let n=_,o=r.__chatHandlerFlow,s={...r};return delete s.__chatHandlerFlow,n?n.run(o,s,{boardId:B,cardId:String(s.cardId||""),label:t.label,logger:N,serverUrl:E,executionExtra:T}):{dispatched:false,error:"chat-handler-flow configured but no chatFlowRunner was provided"}}return x.invoke(e,r)}async function Ee(t,e=false){e||await G();let r=typeof t.args?.cardId=="string"?t.args.cardId:"",n=r?W(r):ht();if(!n)throw new Error(r?`Board context is unavailable for chat-agent request: ${r}`:"Board context is unavailable for chat-agent request");let o=await Ne(n,t.ref,t.args);if(!o.dispatched){if(r)try{await tt(r,!1);}catch{}throw new Error(o.error||`chat-agent dispatch failed for card "${r||"unknown"}"`)}}async function je(t,e,r){if(e==="chat-send"){let o=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"";if(r&&"files"in r&&r.files!==void 0&&r.files!==null)throw Object.assign(new Error('chat-send does not accept a "files" parameter; upload attachments via manage.add-chat-attachment first'),{statusCode:400});let s=bt(),i=xe(r?.text),c=i?i.text:r?.text,j=await a$9("manage.add-chat-entry-and-any-attachments",{board_id:B,card_id:t,role:"user",text:c,turn_id:o,files:[]},s);if(j?.status!=="success")throw new Error(b$4(j,`chat-send append failed for card ${t}`));let h=j?.data?.id;if(typeof h!="string"||!h)throw new Error(`chat-send did not return an append id for card ${t}`);let M=await a$9("setstate.chat-processing-started",{board_id:B,card_id:t},s);if(M?.status!=="success")throw new Error(b$4(M,`chat-send processing update failed for card ${t}`));Te(t,h,true,o,i?.assistant||"");return}await Be(t,o=>{let s=new Date().toISOString(),i=o.card_data&&typeof o.card_data=="object"?o.card_data:{};if(o.card_data=i,e==="file-upload"){let c=A().normalizeIncoming(r?.files,s);return c.length>0&&A().merge(i,c),o}if(e==="action"){let c=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!c)return o;i.lastAction={buttonId:c,at:s},i.lastActionText=`${c} @ ${s}`;}return o});}function et(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...b$3,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}async function Bt(t,e,r){let n=await Y(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=A().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,i=D(t),c=v(t),j=String(s.stored_name||""),h=`${i}/${j}`,M=c.files?await c.files.getBytes(h):null;if(!M)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:M}}async function Me(t,e,r,n){let{fileRecord:o,bytes:s}=await Bt(e,r,n),i=String(o.name||o.stored_name||"download.bin"),c=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":c,"Content-Disposition":`attachment; filename="${i}"`,"Content-Length":s.length}),t.end(s);}function _e(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function De(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
|
|
2
|
-
`)}async function rt(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(d$2(e)).trim();return r?JSON.parse(r):{}}async function
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,b}from'./chunk-JB4Q2W7I.js';import {a as a$3}from'./chunk-XYN5D3GL.js';import {a as a$5,c as c$2}from'./chunk-O5UYCGIN.js';import {p,j,k,l,c as c$1,d as d$1,m as m$1,n,e as e$2,a as a$7,b as b$3,o}from'./chunk-WFMVZ3LO.js';import {a as a$4,d as d$2,b as b$2,c as c$3}from'./chunk-FOFGEABN.js';import {a as a$b}from'./chunk-RKKSVOP2.js';import {a as a$2}from'./chunk-NTICU4OK.js';import {a as a$8,c as c$4}from'./chunk-O7NOHKVR.js';import {a as a$9,b as b$4}from'./chunk-ZJ5M5COT.js';import {i,d,c,b as b$1,g,h}from'./chunk-E7SDEZSI.js';import {a as a$a}from'./chunk-PEJRTZU3.js';import {e,f}from'./chunk-C7OY3PYL.js';import {H,m}from'./chunk-QJQ53PLM.js';import {a as a$6}from'./chunk-BJGK5FNL.js';import {a as a$1}from'./chunk-NIBLKYXN.js';import {e as e$1}from'./chunk-UGB7PC4P.js';function ue(g){let{apiBasePath:w,json:b,readJsonBody:I,bootstrapBoard:B,createMcpControlplaneToolRegistry:$,retriggerCard:N,applyCardAction:x,resolveChatHandlerTarget:_,sendCardFileDownloadResponse:H}=g;async function E(T,S,z){let q=T.method||"GET",K=z,l=K.pathname;try{if(q==="POST"&&l===`${w}/mcp-actions`){await B();let f=Date.now(),y=new Date(f).toISOString(),k=await I(T),u=typeof k.tool=="string"?k.tool.trim():"",P=k.args&&typeof k.args=="object"&&!Array.isArray(k.args)?k.args:{};if(!u)return b(S,400,{error:"tool is required"}),!0;let v=a$8(P,"card_id");if(!v)return b(S,400,{error:"MCP action requires card_id"}),!0;if(u==="retrigger-card"||u==="retrigger"){await N(v);let O=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:200}}),!0}let A=c$4(P,"payload");if(u==="chat-send"&&!await _(v)){let O=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:409}),!0}if(u==="chat-send"){let O=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!O||!String(O).trim()){let U=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${v}`,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(U).toISOString(),responseSentAtMs:U,responseStatus:400}),!0}}await x(v,u,A);let D=Date.now();return b(S,200,{status:"success",data:{ok:!0,cardId:v,actionType:u,requestReceivedAt:y,requestReceivedAtMs:f,responseSentAt:new Date(D).toISOString(),responseSentAtMs:D,responseStatus:200}}),!0}if(q==="POST"&&l===`${w}/mcp-controlplane`){await B();let f=await I(T),y=typeof f.tool=="string"?f.tool.trim():"",k=f.args&&typeof f.args=="object"&&!Array.isArray(f.args)?f.args:{};if(!y)return b(S,400,{error:"tool is required"}),!0;try{let u=await a$9(y,k,$());if(u&&typeof u=="object"&&!Array.isArray(u)){let P=u;if(P.status==="fail")return b(S,400,{error:b$4(u,"Request failed")}),!0;if(P.status==="error")return b(S,500,{error:b$4(u,"Internal error")}),!0}b(S,200,u);}catch(u){let P=typeof u?.statusCode=="number"?Number(u.statusCode):500,v=u instanceof Error?u.message:String(u);b(S,P,{error:v});}return !0}let R=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/retrigger$`));if(q==="POST"&&R){await B();let f=decodeURIComponent(R[1]);return await N(f),b(S,200,{ok:!0}),!0}let F=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/actions$`));if(q==="POST"&&F){await B();let f=decodeURIComponent(F[1]),y=Date.now(),k=new Date(y).toISOString(),u=await I(T),P=u?.actionType;if(P==="chat-send"&&!await _(f)){let A=Date.now();return b(S,409,{error:`chat handler is not configured for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(A).toISOString(),responseSentAtMs:A,responseStatus:409}),!0}if(P==="chat-send"){let A=u?.payload??{},D=typeof A["turn-id"]=="string"?A["turn-id"]:typeof A.turnId=="string"?A.turnId:typeof A.turn=="string"?A.turn:"";if(!D||!String(D).trim()){let O=Date.now();return b(S,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${f}`,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:400}),!0}}await x(f,P,u?.payload);let v=Date.now();return b(S,200,{ok:!0,requestReceivedAt:k,requestReceivedAtMs:y,responseSentAt:new Date(v).toISOString(),responseSentAtMs:v,responseStatus:200}),!0}let p=l.match(new RegExp(`^${c$3(w)}/cards/([^/]+)/files/(\\d+)$`));if(q==="GET"&&p){let f=decodeURIComponent(p[1]),y=parseInt(p[2],10),k=K.searchParams.get("sn");return await H(S,f,y,k),!0}return !1}catch(R){let F=R?.statusCode||500;return b(S,F,{error:String(R?.message||R)}),true}}return {handleRuntimeApi:E}}var Ge=3e4;function Qe(g){let w=g.socket?.remoteAddress??"";return w==="127.0.0.1"||w==="::1"||w==="::ffff:127.0.0.1"}function de(g){let{apiBasePath:w,emitNotifications:b,readJsonBody:I,json:B}=g,$=`${w}/notify-q`;async function N(x,_,H){if(H.pathname!==$)return false;if((x.method??"").toUpperCase()!=="POST")return B(_,405,{status:"error",error:"Method not allowed"}),true;if(!Qe(x))return B(_,403,{status:"error",error:"Forbidden"}),true;let E;try{E=await I(x);}catch{return B(_,400,{status:"error",error:"Invalid JSON body"}),true}if(!E||typeof E!="object"||!Array.isArray(E.notifications))return B(_,400,{status:"error",error:"body.notifications must be an array"}),true;let T=E.notifications,{accepted:S,rejected:z}=b$3(T,Date.now(),Ge);return S.length>0&&b(S),B(_,200,{status:"success",data:{accepted:S.length,rejected:z}}),true}return {handleNotifyRoute:N}}var fe={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},le="chat-handler-flow-queue",ot="__probe__echo__probe__";function _r(g$1){let w=String(g$1.apiBasePath||"/api/board").replace(/\/$/,""),b$3={...fe,...g$1.corsHeaders||{}},I=g$1.queueLaneTuning??{},B=g$1.boardId||"",$=Number.isInteger(g$1.chatBootstrapTailTurns)&&g$1.chatBootstrapTailTurns>0?g$1.chatBootstrapTailTurns:1,N=g$1.logger||{info:console.log,warn:console.warn,error:console.error},x=g$1.invocationAdapter,_=g$1.chatFlowRunner||null,H$1=g$1.notificationTransport||null,E=g$1.serverUrl||null,T=g$1.executionExtra||{},S=g$1.onSseClientConnected,z=g$1.onSseClientDisconnected,q=g$1.onChannelSubscribed,K=g$1.onChannelUnsubscribed,l$1=a({buildChatOneShotBatch:async(t,e)=>await Q.buildSseOneShotBatch({params:{cardId:t},body:{receiving:e}}),onSseClientDisconnected:z}),R=a({buildChatOneShotBatch:async()=>({status:"success",data:{kind:"notification-batch",category:"batch",notifications:[]}})});function F(t){function e$1(a){return {...a,queueStorageForRef(d,C){return a$6(a.queueStorageForRef(d,C),{lane:C,emitNotification:i$1})}}}function r(a){return {...a,queueStorageForRef(d,C){return h(a.queueStorageForRef(d,C),{lane:C,emitNotification:i$1})}}}function n(a){return {async get(d){return a.get(d)},async set(d){return a.set(d)},async del(d){return a.del(d)},async patch(d){return a.patch(d)},async appendFiles(d){return a.appendFiles(d)}}}function o(a){return {async get(d){return await a.get(d)},async set(d){return await a.set(d)},async del(d){return await a.del(d)},async patch(d){return await a.patch(d)},async appendFiles(d){return await a.appendFiles(d)}}}let s=null;function i$1(a){if(a.kind==="notification-batch"){V(a.notifications,s??void 0);return}V([a],s??void 0);}let c$2=a$4(t.boardAdapter)?r(t.boardAdapter):e$1(t.boardAdapter),j=t.nonCoreAdapter??(!a$4(c$2)&&P(c$2)?c$2:null),h$1=a$4(c$2)?i(t.baseRef,c$2,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i$1}):e(t.baseRef,c$2,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i$1}),M=t.nonCore??(j?f(t.baseRef,j,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,taskExecutorRef:t.taskExecutorRef}):null),ze=c$2.chatStorageForRef(t.chatStoreRef),lt,Ke=a$4(c$2)?(()=>{let a=d(c(b$1(c$2.kvStorageForRef(t.cardStoreRef)),c$2.hashFn),N.warn),d$1=g(a,{emitNotification:i$1}),C=o(d$1);return lt={get(m){return C.get(m)},set(m){return C.set(m)}},C})():(()=>{let a=c$2.kvStorageForRef(t.cardStoreRef),C=H(m({readIndex:()=>a.read("_index"),writeIndex:m=>a.write("_index",m),readCard:m=>a.read(m),writeCard:(m,pt)=>(a.write(m,pt),m),removeCard:m=>{a.delete(m);},cardExists:m=>a.read(m)!==null,defaultCardKey:m=>m},N.warn),{emitNotification:i$1});return lt=C,n(C)})(),ft;if(a$4(c$2)){let a=c$2.blobStorageForRef(t.artifactsStoreRef);ft={async putBytes(d,C){if(a.writeBytes){await a.writeBytes(d,C);return}let m=JSON.stringify({__kind:"bytes-array",data:[...C]});await a.write(d,m);},async getBytes(d){if(a.readBytes){let m=await a.readBytes(d);if(m!==null)return m}let C=await a.read(d);if(C===null)return null;try{let m=JSON.parse(C);if(m&&m.__kind==="bytes-array"&&Array.isArray(m.data))return new Uint8Array(m.data)}catch{}return new TextEncoder().encode(C)},async listKeys(d){return await a.listKeys(d)}};}else {let a=c$2.blobStorageForRef(t.artifactsStoreRef),d=a$5(a);ft={putBytes(C,m,pt){d.putBytes(C,m,pt);},getBytes(C){return d.getBytes(C)},listKeys(C){return d.list(C).map(m=>m.key)}};}let Ve={async init(a){return h$1.init(a)},async status(a){return h$1.status(a)},async getConfig(a){return h$1.getConfig(a)},async getAllOutputsDataObjects(a){return h$1.getAllOutputsDataObjects(a)},async getAllOutputsComputedValues(a){return h$1.getAllOutputsComputedValues(a)},async getOutputsFetchedSources(a){return h$1.getOutputsFetchedSources(a)},async buildSseOneShotPayload(a){return h$1.buildSseOneShotPayload(a)},async upsertCard(a){return h$1.upsertCard(a)},async removeCard(a){return h$1.removeCard(a)},async sourceDataFetched(a){return h$1.sourceDataFetched(a)},async sourceDataFetchFailure(a){return h$1.sourceDataFetchFailure(a)}};return s={label:t.label,board:h$1,nonCore:M,publicCardStore:lt,boardOps:Ve,cardStoreOps:Ke,get filesArtifacts(){return ft},get chatStorage(){return ze},boardAdapter:c$2,boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:c$1(),notificationTeardown:null,initialized:false,cardsBootstrapped:false},s}let p$1=g$1.boards.map(F),f$1=new Map;function y(t){return f$1.get(t)??0}function k$1(t){return t.queueStoreRef}function u(t,e){if(a$4(t.boardAdapter)){let n=t.boardAdapter.queueStorageForRef(k$1(t),e);return a$a(n)}let r=t.boardAdapter.queueStorageForRef(k$1(t),e);return a$b(r)}function P(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function v(t){let e=p$1[y(t)];return {files:e?e.filesArtifacts:null}}function A(){return c$2()}function D(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}function O(t){return "cardId"in t&&typeof t.cardId=="string"?W(t.cardId)??void 0:p$1[0]??void 0}function U(t){for(let e of t){let r=O(e);if(r)return r}return p$1[0]??void 0}function ct(t,e={}){if(!t||t.length===0)return;let r=e$1(t),n={kind:"notification-batch",category:"batch",notifications:r},o=e.ctx??U(r);if(e.appendState!==false&&o&&e$2(o.notification,n),e.broadcastSse!==false){let s=r.filter(c=>c.kind==="message_enqueued"),i=r.filter(c=>c.kind!=="message_enqueued");i.length>0&&l$1.broadcastNotificationBatch(i),s.length>0&&R.broadcastNotificationBatch(s);}if(!(e.mirrorExternal===false||!o?.boardAdapter.publishBoardChangeNotifications))try{let s=r.filter(i=>i.category==="board-output"||i.category==="card-store"||i.category==="chat-store"||i.category==="hosted-runtime");s.length>0&&o.boardAdapter.publishBoardChangeNotifications(s);}catch{}}function V(t,e){ct(t,{ctx:e,appendState:true,broadcastSse:true,mirrorExternal:true});}async function pe(t){if(!t||t.notificationTeardown||!H$1||!t.notifyRef)return;let e=await H$1.subscribe(t.notifyRef,r=>{let n=a$7(r);ct(n,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});});t.notificationTeardown=e;}async function me(t){if(!t||t.initialized)return;let e={boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,artifactsStoreRef:t.artifactsStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef},r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow);let n=await t.boardOps.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await pe(t),!t.chatHandlerFlow&&t.chatHandlerRef&&x.describe)try{let o=await x.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?N.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&N.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){N.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}async function ut(t){let e=[],r=await t.boardOps.status({});r.status==="success"&&r.data!=null&&d$1(r.data)&&e.push({kind:"status",status:r.data});let n=await t.boardOps.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,i]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:i});let o=await t.boardOps.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,i]of Object.entries(o.data))s&&i&&typeof i=="object"&&!Array.isArray(i)&&e.push({kind:"computed_values",cardId:s,values:i});e.length>0&&ct(e,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});}async function Rt(t,e){if(!t||t.cardsBootstrapped)return;let r=await t.cardStoreOps.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(f$1.set(o.id,e),await t.boardOps.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function G(){for(let t of p$1)await me(t);}async function at(){await G();for(let t=0;t<p$1.length;t++)await ut(p$1[t]),await Rt(p$1[t],t),await ut(p$1[t]);}async function yt(t=false){t||await G();for(let e of p$1){let r=await e.board.processAccumulatedEvents({});if(r.status!=="success")return r}return {status:"success"}}function W(t){return p$1[y(t)]??null}async function Y(t){let e=W(t);if(!e)return null;let r=await e.cardStoreOps.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}async function ge(){let t=async r=>{if(!r)return [];let n=await r.cardStoreOps.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of p$1)e.push(...await t(r));return e}function ht(){return p$1[0]??null}function Re(t){return W(t)??ht()}function L(t){let e=Re(t);if(!e)throw Object.assign(new Error(`Board context is unavailable for chat operations: ${t}`),{statusCode:404});return e.chatStorage}async function ye(t){return await L(t).isProcessing(t)}async function tt(t,e){let r=await Q.setProcessing({params:{cardId:t},body:{active:e}});if(r.status!=="success")throw Object.assign(new Error(r.error||`Failed to set chat processing for card: ${t}`),{statusCode:500})}let Q=a$1({append(t,e,r,n,o){return L(t).append(t,e,r,n,o)},readAll(t){return L(t).readAll(t)},readAfter(t,e){return L(t).readAfter(t,e)},clear(t){return L(t).clear(t)},setProcessing(t,e){return L(t).setProcessing(t,e)},isProcessing(t){return L(t).isProcessing(t)},getConfig(t){return L(t).getConfig(t)},setConfig(t,e){return L(t).setConfig(t,e)}},{emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);}}),wt=p({boardContexts:p$1,cardOwnerIndex:f$1,cardContextForCard:t=>W(t),readStatusSnapshot:()=>Ce(),readDataObjectsByToken:()=>Be(),readCardRuntimeArtifacts:()=>Ae(),readCardFromStore:t=>Y(t),readCardDefinitions:()=>ge(),processAccumulatedLaneInternal:t=>yt(t),reportSourceFetched:(t,e)=>Pt(t,{ref:e}),reportSourceFetchFailure:(t,e)=>Ot(t,{reason:e}),uploadCardFile:(t,e,r,n,o)=>At(t,e,r,n,o),chatStorePublic:Q,serverUrl:E,apiBasePath:w}),he=wt.mcpCardStoreFacade,st=wt.createMcpFacade,we=j({boardId:B,bootstrapBoard:()=>at(),sseHub:l$1,onChannelSubscribed:q,onChannelUnsubscribed:K,getMcpFacade:()=>st(),getMcpCardStoreFacade:()=>he()});function be(t){return m$1(t)}function Se(){return n(st())}function bt(){return o({boardId:B,uploadCardFile:At,uploadCardFilesMultiple:Te,getMcpFacade:()=>st(),controlplane:we})}let it=k({boardId:B,boardContexts:p$1,readChatRecords:(t,e)=>xe(t,e),getChatProcessing:t=>ye(t),chatBootstrapTailTurns:$}),Ce=it.readStatusSnapshot,Ae=it.readCardRuntimeArtifacts,Be=it.readDataObjectsByToken,dt=it.buildPublishedRuntimePayload;async function St(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=W(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=await Y(t);if(!i)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let c=o?JSON.stringify(i):null,j=e(i)||i;if(o&&JSON.stringify(j)===c)return;let h=await s.cardStoreOps.set({body:j});if(h.status!=="success")throw Object.assign(new Error(h.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let M=await s.boardOps.upsertCard({params:{cardId:t,restart:true}});if(M.status!=="success")throw Object.assign(new Error(M.error||`Failed to upsert card: ${t}`),{statusCode:500})}}async function ke(t,e){await St(t,e,{syncBoard:true});}async function Pe(t,e){await St(t,e,{syncBoard:false});}async function Oe(t){let e=W(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!await Y(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=await e.boardOps.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}async function Fe(t){let e=await Q.clear({params:{cardId:t}});if(e.status!=="success")throw Object.assign(new Error(e.error||`Failed to clear chat records for card: ${t}`),{statusCode:500});try{await tt(t,!1);}catch{}}async function ve(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"",i=await Q.append({params:{cardId:t},body:{role:e||"system",text:s,files:n,turn:o}});if(i.status!=="success")throw Object.assign(new Error(i.error||`Failed to append chat record for card: ${t}`),{statusCode:500});return String(i.data?.id||"")}async function xe(t,e){let r=Number.isInteger(e?.tailTurns)&&e?.tailTurns>0?e?.tailTurns:void 0,n=await Q.readAll({params:{cardId:t},...r===void 0?{}:{body:{tailTurns:r}}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to read chat records for card: ${t}`),{statusCode:500});return Array.isArray(n.data?.records)?n.data.records:[]}let Ct=l({safeCardId:t=>D(t),artifactsStores:t=>v(t),cardFileMetadataStore:()=>A(),readCardFromStore:t=>Y(t),updateCardLocalOnly:(t,e)=>Pe(t,e),writeChatRecord:(t,e,r,n,o)=>ve(t,e,r,n,o)}),At=Ct.uploadCardFile,Te=Ct.uploadCardFilesMultiple;async function Bt(t){let e=W(t);if(!e)return null;let r=await e.boardOps.getConfig({params:{key:"chat-handler-flow"}}),o=(r.status==="success"?r.data?.value:null)??e.chatHandlerFlow??null,s=e.chatHandlerRef;return o==null&&(!s||typeof s!="object")?null:{ctx:e,handlerFlow:o,handlerRef:s}}function Ne(t){let e=typeof t=="string"?t.trim():"";if(e.length<ot.length*2||!e.startsWith(ot)||!e.endsWith(ot))return null;let r=e.slice(ot.length,e.length-ot.length).trim(),n=/^([A-Za-z0-9_-]+)__(.*)$/s.exec(r);return n?{assistant:n[1].trim().toLowerCase(),text:n[2].trim()}:{assistant:"echo",text:r}}async function Ee(t,e,r=false,n="",o=""){try{let s=await Bt(t);if(!s){try{await tt(t,!1);}catch{}return}let{ctx:i,handlerFlow:c,handlerRef:j}=s;if(!r)try{await tt(t,!0);}catch{}let h={boardId:B,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...typeof o=="string"&&o.trim()?{probe:o.trim()}:{},...T,...E?{serverUrl:E}:{}},M=c!=null?{meta:"chat-handler-flow",howToRun:"built-in",whatToRun:{kind:"built-in",value:le}}:j;a$4(i.boardAdapter)?await u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}):u(i,"chat-agent").enqueueRequest({boardId:B,ref:M,args:c!=null?{...h,__chatHandlerFlow:c}:h}),await Promise.resolve(i.boardAdapter.requestProcessAccumulated?.());}catch(s){try{await tt(t,!1);}catch{}N.warn(`[chat-handler] queue failed for card "${t}": ${s instanceof Error?s.message:String(s)}`);}}async function je(t,e,r){if(e.howToRun==="built-in"&&b$2(e)===le){let n=_,o=r.__chatHandlerFlow,s={...r};return delete s.__chatHandlerFlow,n?n.run(o,s,{boardId:B,cardId:String(s.cardId||""),label:t.label,logger:N,serverUrl:E,executionExtra:T}):{dispatched:false,error:"chat-handler-flow configured but no chatFlowRunner was provided"}}return x.invoke(e,r)}async function Me(t,e=false){e||await G();let r=typeof t.args?.cardId=="string"?t.args.cardId:"",n=r?W(r):ht();if(!n)throw new Error(r?`Board context is unavailable for chat-agent request: ${r}`:"Board context is unavailable for chat-agent request");let o=await je(n,t.ref,t.args);if(!o.dispatched){if(r)try{await tt(r,!1);}catch{}throw new Error(o.error||`chat-agent dispatch failed for card "${r||"unknown"}"`)}}async function _e(t,e,r){if(e==="chat-send"){let o=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"";if(r&&"files"in r&&r.files!==void 0&&r.files!==null)throw Object.assign(new Error('chat-send does not accept a "files" parameter; upload attachments via manage.add-chat-attachment first'),{statusCode:400});let s=bt(),i=Ne(r?.text),c=i?i.text:r?.text,j=await a$9("manage.add-chat-entry-and-any-attachments",{board_id:B,card_id:t,role:"user",text:c,turn_id:o,files:[]},s);if(j?.status!=="success")throw new Error(b$4(j,`chat-send append failed for card ${t}`));let h=j?.data?.id;if(typeof h!="string"||!h)throw new Error(`chat-send did not return an append id for card ${t}`);let M=await a$9("setstate.chat-processing-started",{board_id:B,card_id:t},s);if(M?.status!=="success")throw new Error(b$4(M,`chat-send processing update failed for card ${t}`));Ee(t,h,true,o,i?.assistant||"");return}await ke(t,o=>{let s=new Date().toISOString(),i=o.card_data&&typeof o.card_data=="object"?o.card_data:{};if(o.card_data=i,e==="file-upload"){let c=A().normalizeIncoming(r?.files,s);return c.length>0&&A().merge(i,c),o}if(e==="action"){let c=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!c)return o;i.lastAction={buttonId:c,at:s},i.lastActionText=`${c} @ ${s}`;}return o});}function et(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...b$3,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}async function kt(t,e,r){let n=await Y(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=A().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,i=D(t),c=v(t),j=String(s.stored_name||""),h=`${i}/${j}`,M=c.files?await c.files.getBytes(h):null;if(!M)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:M}}async function De(t,e,r,n){let{fileRecord:o,bytes:s}=await kt(e,r,n),i=String(o.name||o.stored_name||"download.bin"),c=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":c,"Content-Disposition":`attachment; filename="${i}"`,"Content-Length":s.length}),t.end(s);}function Ie(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function qe(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
|
|
2
|
+
`)}async function rt(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(d$2(e)).trim();return r?JSON.parse(r):{}}async function Pt(t,e){let r=typeof e.ref=="string"?e.ref.trim():"";if(!r)return {status:"fail",error:"board-worker success callback requires body.ref"};let n=p$1[0];return n?n.boardOps.sourceDataFetched({params:{token:t,ref:r}}):{status:"fail",error:"no board context"}}async function Ot(t,e){let r=typeof e.reason=="string"&&e.reason.trim()?e.reason:"unknown",n=p$1[0];return n?n.boardOps.sourceDataFetchFailure({params:{token:t,reason:r}}):{status:"fail",error:"no board context"}}let $e=b({sseHub:l$1,queueSseHub:R,corsHeaders:b$3,json:et,buildPublishedRuntimePayload:()=>dt(),onSseClientConnected:S,onChannelSubscribed:q,onChannelUnsubscribed:K,apiBasePath:w,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),bootstrapBoard:()=>at(),boardContexts:p$1,publishPersistedStateSnapshot:t=>ut(t),upsertCardsFromSource:(t,e)=>Rt(t,e)}).handleWatchersRoutes,He=a$2({apiBasePath:w,json:et,readJsonBody:t=>rt(t),bootstrapBoard:()=>at(),createMcpFacade:()=>st(),createMcpToolRegistry:t=>be(t),resolveCardFileDownloadPayload:(t,e,r)=>kt(t,e,r),isLikelyTextMimeType:t=>Ie(t),sliceTextByLines:(t,e,r)=>qe(t,e,r)}).handleAgentfaceApi,Le=a$3({apiBasePath:w,json:et,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),createMcpWebhookToolRegistry:()=>Se()}).handleWebhooksApi,Ue=ue({apiBasePath:w,json:et,readJsonBody:t=>rt(t),bootstrapBoard:()=>at(),createMcpControlplaneToolRegistry:()=>bt(),retriggerCard:t=>Oe(t),applyCardAction:(t,e,r)=>_e(t,e,r),resolveChatHandlerTarget:t=>Bt(t),sendCardFileDownloadResponse:(t,e,r,n)=>De(t,e,r,n)}).handleRuntimeApi,We=de({apiBasePath:w,emitNotifications:t=>V(t),readJsonBody:t=>rt(t),json:(t,e,r)=>et(t,e,r)}).handleNotifyRoute;async function Je(t,e,r){return !!(await He(t,e,r)||await Le(t,e,r)||await $e(t,e,r)||await We(t,e,r)||await Ue(t,e,r))}return {get apiBasePath(){return w},get corsHeaders(){return b$3},get queueLaneTuning(){return I},handleRuntimeApi:Je,emitNotification(t){if(t.kind==="notification-batch"){V(t.notifications);return}V([t]);},buildPublishedRuntimePayload:dt,__drainProcessAccumulatedLane:yt,handleChatAgentRequest:Me,clearChatRecords:Fe,reportSourceFetched(t,e){return Pt(t,{ref:e})},reportSourceFetchFailure(t,e){return Ot(t,{reason:e})},get cardStore(){return p$1[0]?.publicCardStore??{get(){return Promise.resolve({status:"fail",error:"no board context"})},set(){return Promise.resolve({status:"fail",error:"no board context"})}}}}}function Dr(g){let w=String(g.apiBasePath||"/api/boards").replace(/\/$/,""),b={...fe,...g.corsHeaders||{}},I=g.serverMetaStore,B=g.boardRuntimeFactory,$=new Map,N="boards-config.json";function x(){let l=I.getText(N);if(!l)return {boards:[{id:"default",label:"Default Board"}]};try{return JSON.parse(l)}catch{return {boards:[{id:"default",label:"Default Board"}]}}}function _(l){I.putText(N,JSON.stringify(l,null,2));}function H(l){let R=String(l||"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/^_+|_+$/g,"");return R.length>0&&R.length<=64?R:null}function E(l){if($.has(l))return $.get(l);let F=x().boards.find(f=>f.id===l)||{},p=B(l,F);return $.set(l,p),p}function T(l,R,F){let p=JSON.stringify(F),f=typeof Buffer<"u"?Buffer.byteLength(p):new TextEncoder().encode(p).length;l.writeHead(R,{...b,"Content-Type":"application/json; charset=utf-8","Content-Length":f}),l.end(p);}async function S(l,R,F){let p=l.method||"GET",f=F.pathname;if(p==="GET"&&f===w)return T(R,200,{ok:true,boards:x().boards}),true;if(p==="POST"&&f===w){let y=[];for await(let O of l)y.push(O);let k=typeof Buffer<"u"?Buffer.concat(y).toString("utf-8").trim():new TextDecoder().decode(d$2(y)).trim(),u={};try{u=k?JSON.parse(k):{};}catch{u={};}let P=H(u.id);if(!P)return T(R,400,{error:"board id must be 1-64 alphanumeric/dash/underscore characters"}),true;let v=x();if(v.boards.some(O=>O.id===P))return T(R,409,{error:`Board "${P}" is already registered`}),true;let A=typeof u.label=="string"&&u.label.trim()?u.label.trim():P,D={id:P,label:A};for(let[O,U]of Object.entries(u))O==="id"||O==="label"||U!=null&&(D[O]=U);return v.boards.push(D),_(v),T(R,200,{ok:true,board:D}),true}return false}async function z(l,R,F){let f=F.pathname.match(new RegExp(`^${c$3(w)}/([^/]+)(/|$)`));if(!f)return false;let y=H(decodeURIComponent(f[1]));return y?x().boards.some(P=>P.id===y)?!!await E(y).handleRuntimeApi(l,R,F):(T(R,404,{error:`Board "${y}" not registered. POST ${w} with {id} to register it first.`}),true):(T(R,400,{error:"Invalid board id"}),true)}async function q(l,R,F){return !!(await S(l,R,F)||await z(l,R,F))}function K(l){if(!x().boards.some(F=>F.id===l))throw Object.assign(new Error(`Board "${l}" not registered`),{statusCode:404});return {service:E(l)}}return {get apiBasePath(){return w},get corsHeaders(){return b},handleApi:q,requireBoardService:K}}export{_r as a,Dr as b};//# sourceMappingURL=chunk-QOOIN523.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-QOOIN523.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-FOFGEABN.js';import {a,c,d,e,b,f}from'./chunk-O7NOHKVR.js';import {a as a$2}from'./chunk-ONJG6QW6.js';import {b as b$1}from'./chunk-44L64VQ2.js';function F(a){if(!a||typeof a!="object")return false;let e=a;return typeof e.kind=="string"&&e.kind.length>0}function J(a){if(!a||typeof a!="object")return [];let e=a;return e.kind==="notification-batch"?Array.isArray(e.notifications)?e.notifications.filter(F):[]:F(a)?[a]:[]}function X(a,e,c){let m=0;return {accepted:a.filter(h=>{if(!F(h))return m++,false;let R=h;return typeof R.sentAtMs=="number"&&e-R.sentAtMs>c?(m++,false):true}),rejected:m}}function Q(){return {status:null,computedValues:{},dataObjects:{},cards:{}}}function V(a){if(!a||typeof a!="object")return false;let e=a.summary;return !e||typeof e!="object"?false:Number(e.card_count||0)>0}function W(a){if(!a||typeof a!="object")return false;let e=a;return e.kind==="notification-batch"&&Array.isArray(e.notifications)}function H(a,e){if(e.kind==="status"){V(e.status)&&(a.status=e.status);return}if(e.kind==="computed_values"){a.computedValues[e.cardId]=e.values;return}if(e.kind==="data_object"){a.dataObjects[e.key]=e.payload;return}if(e.kind==="card_refreshed"){a.cards[e.cardId]=e.card;return}e.kind==="card_removed"&&(delete a.cards[e.cardId],delete a.computedValues[e.cardId]);}function Y(a,e){if(W(e)){for(let c of e.notifications)F(c)&&H(a,c);return}F(e)&&H(a,e);}function q(a,e){if(a?.status==="success")return Object.prototype.hasOwnProperty.call(a,"data")?a.data:void 0;throw a?.status==="fail"||a?.status==="error"?Object.assign(new Error(a.error||`${e} failed`),{statusCode:400}):Object.assign(new Error(`${e} returned an unexpected response`),{statusCode:500})}async function T(a,e){return q(await a,e)}function E(a$1){let e=a(a$1,"key");if(!e)throw Object.assign(new Error("MCP tool requires key"),{statusCode:400});let c=e.split(".");if(!(c.length>=2&&c.every(I=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(I))))throw Object.assign(new Error("MCP tool requires a card private key with at least two identifier segments (e.g. chat.foundry_thread_id)"),{statusCode:400});return e}function D(a,e){let c=a.__private;for(let m of e.split(".")){if(!c||typeof c!="object"||Array.isArray(c)||!Object.prototype.hasOwnProperty.call(c,m))return {exists:false,value:null};c=c[m];}return {exists:true,value:c}}function se(a$1){let{boardId:e,bootstrapBoard:c,sseHub:m,onChannelSubscribed:I,onChannelUnsubscribed:h,getMcpFacade:R,getMcpCardStoreFacade:S}=a$1;function n(o){let s=a(o,"board_id");if(!s)throw Object.assign(new Error("MCP tool requires board_id"),{statusCode:400});if(s!==e)throw Object.assign(new Error(`Unknown board_id: ${s}`),{statusCode:400})}function C(o){let s=a(o,"client_id");if(!s)throw Object.assign(new Error("MCP tool requires client_id"),{statusCode:400});return s}function k(o){n(o);let s=C(o),t=a(o,"channel_name"),r=a(o,"card_id")||void 0;if(!t)throw Object.assign(new Error("MCP tool requires channel_name"),{statusCode:400});return {clientId:s,channelName:t,...r?{cardId:r}:{}}}function g(o){n(o);let s=a(o,"card_id");if(!s)throw Object.assign(new Error("MCP tool requires card_id"),{statusCode:400});return {cardId:s}}async function _(o){await c();let{cardId:s}=g(o),t=C(o);if(!await m.subscribeChat(t,s))throw Object.assign(new Error(`SSE client not connected: ${t}`),{statusCode:404});return {status:"success",data:{boardId:e,cardId:s,clientId:t,subscribed:true}}}async function d(o){await c();let{cardId:s}=g(o),t=C(o);if(!m.unsubscribeChat(t,s))throw Object.assign(new Error(`SSE client not connected: ${t}`),{statusCode:404});return {status:"success",data:{boardId:e,cardId:s,clientId:t,subscribed:false}}}async function b(o,s){await c();let{clientId:t,channelName:r,cardId:i}=k(o);if(!m.has(t))throw Object.assign(new Error(`SSE client not connected: ${t}`),{statusCode:404});return s?(m.subscribeChannel(t,r,i),I?.(t,r,i?{cardId:i}:{})):(m.unsubscribeChannel(t,r,i),h?.(t,r,i?{cardId:i}:{})),{status:"success",data:{boardId:e,clientId:t,channelName:r,subscribed:s,...i?{cardId:i}:{}}}}async function l(o,s){let{cardId:t}=g(o);return await R().setChatProcessing({cardId:t,active:s}),{status:"success",data:{boardId:e,cardId:t,active:s}}}async function f(o){let{cardId:s}=g(o),t=await R().getChatProcessing({cardId:s});return {status:"success",data:{boardId:e,cardId:s,active:t.active}}}async function y(o){let{cardId:s}=g(o),t=E(o);if(!Object.prototype.hasOwnProperty.call(o,"value"))throw Object.assign(new Error("MCP tool requires value"),{statusCode:400});if(t.split(".").includes("visible_controlplane_only")){let r=await T(S().get({params:{id:s}}),"cardStore.get"),i=Array.isArray(r.cards)&&r.cards.length>0&&typeof r.cards[0]=="object"&&!Array.isArray(r.cards[0])?r.cards[0]:null,w=i?D(i,"visible_controlplane_only").value:void 0;if(o.value!==w)throw Object.assign(new Error("MCP tool cannot change the reserved private flag visible_controlplane_only"),{statusCode:403});return {status:"success",data:{boardId:e,cardId:s,key:t}}}return q(await S().patch({params:{id:s,path:`__private.${t}`},body:{value:o.value}}),"cardStore.patch"),{status:"success",data:{boardId:e,cardId:s,key:t}}}async function p(o){let{cardId:s}=g(o),t=E(o),r=await T(S().get({params:{id:s}}),"cardStore.get"),i=Array.isArray(r.cards)&&r.cards.length>0&&r.cards[0]&&typeof r.cards[0]=="object"&&!Array.isArray(r.cards[0])?r.cards[0]:null;if(!i)throw Object.assign(new Error(`Card "${s}" not found`),{statusCode:404});let w=D(i,t);return {status:"success",data:{boardId:e,cardId:s,key:t,exists:w.exists,value:w.value}}}return {requireCardArgs:g,subscribeChat:_,unsubscribeChat:d,watchChannel:b,setChatProcessing:l,getChatProcessing:f,setCardMeta:y,getCardMeta:p}}function ie(a){let{boardId:e,boardContexts:c,readChatRecords:m,getChatProcessing:I}=a,h=Number.isInteger(a.chatBootstrapTailTurns)&&a.chatBootstrapTailTurns>0?a.chatBootstrapTailTurns:1;function R(d){return {role:String(d.role||"system"),text:String(d.text||""),files:Array.isArray(d.files)?d.files:[],...typeof d.turn=="string"&&d.turn?{turn:d.turn}:{}}}function S(d){if(d.length===0)return null;if(d.length===1)return d[0];let b=[],l=["completed","eligible","pending","blocked","unresolved","failed","in_progress","orphan_cards"],f={};for(let p of l)f[p]=0;for(let p of d){let o=p,s=Array.isArray(o.cards)?o.cards:[];b.push(...s);for(let t of l)f[t]+=Number(o?.summary?.[t]||0);}let y=d[0];return {...y,cards:b,summary:{...y.summary||{},card_count:b.length,...f}}}async function n(){let d=[];for(let b of c)try{let l=await b.boardOps.buildSseOneShotPayload({});l.status==="success"&&l.data&&d.push(l.data);}catch{}return d}async function C(){let b=(await n()).map(l=>l.statusSnapshot).filter(Boolean);if(b.length===0){let l=c.map(f=>f.notification.status).filter(Boolean);return S(l)}return S(b)}async function k(){let d={},b=await n();for(let l of b)Object.assign(d,l.cardRuntimeById||{});if(Object.keys(d).length>0)return d;for(let l of c)for(let[f,y]of Object.entries(l.notification.computedValues)){let p=l.notification.cards[f];d[f]={schema_version:"v1",card_id:f,card_data:p?.card_data??{},computed_values:y??{}};}return d}async function g(){let d={},b=await n();for(let l of b)Object.assign(d,l.dataObjectsByToken||{});if(Object.keys(d).length===0)for(let l of c)Object.assign(d,l.notification.dataObjects||{});return d}async function _(){let d=await n(),b=d.flatMap(p=>Array.isArray(p.cardDefinitions)?p.cardDefinitions:[]),l={},f={};for(let p of d)Object.assign(l,p.dataObjectsByToken||{}),Object.assign(f,p.cardRuntimeById||{});let y={};for(let p of b){if(!p?.id)continue;let o=p.id;try{let s=await m(o,{tailTurns:h}),t=await I(o);(s.length>0||t)&&(y[o]={messages:s.map(r=>R(r)),receiving:!1,processing:t});}catch{}}return {boardId:e,cardDefinitions:b,statusSnapshot:await C(),dataObjectsByToken:l,cardRuntimeById:f,cardChatsByCardId:y}}return {readStatusSnapshot:C,readCardRuntimeArtifacts:k,readDataObjectsByToken:g,buildPublishedRuntimePayload:_}}function K(a){let e=String(a||"").trim();if(!e)return "upload.bin";let c=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return (c>=0?e.slice(c+1):e)||"upload.bin"}function ce(a){let{safeCardId:e,artifactsStores:c,cardFileMetadataStore:m,readCardFromStore:I,updateCardLocalOnly:h,writeChatRecord:R}=a;async function S(g){let _=[];try{let d=await I(g);if(!d)return _;let b=m().read(d.card_data&&typeof d.card_data=="object"?d.card_data:null);for(let l of b)_.push(String(l.stored_name??""));}catch{}return _}async function n(g,_,d,b,l){let f=e(g),y=c(g),p=K(_),o=typeof l=="number"?l:(await S(g)).length,t=`${String(o+1).padStart(3,"0")}-${p}`.slice(-36);if(!y.files)throw Object.assign(new Error(`artifactsStoreRef is not configured for card uploads: ${g}`),{statusCode:500});return await y.files.putBytes(`${f}/${t}`,new Uint8Array(b),d||"application/octet-stream"),{name:p,stored_name:t,size:b.length,mime_type:d||"application/octet-stream",uploaded_at:new Date().toISOString()}}async function C(g,_,d,b,l){if(!b.length)throw Object.assign(new Error("Empty upload body"),{statusCode:400});let f=l?.inChat===true,y=await n(g,_,d,b),p=null;if(await h(g,o=>{let s=new Date().toISOString(),t=o.card_data&&typeof o.card_data=="object"?o.card_data:{};o.card_data=t;let r=m().normalizeIncoming([{name:y.name,stored_name:y.stored_name,size:y.size,mime_type:y.mime_type,uploaded_at:y.uploaded_at||s,chat:f}],s);return p=m().merge(t,r).findIndex(w=>w.stored_name===y.stored_name),o}),f&&l?.suppressChatRecordWrite!==true){let o=typeof p=="number"&&p>=0?` #${p}`:"";await R(g,"system",`file uploaded: ${y.name} as ${y.stored_name}${o}`,[],l?.turnId??"");}return {ok:true,file:{...y,...typeof p=="number"&&p>=0?{file_idx:p}:{},chat:f},...typeof p=="number"&&p>=0?{file_idx:p}:{}}}async function k(g,_,d){if(!Array.isArray(_)||_.length===0)throw Object.assign(new Error("uploadCardFilesMultiple requires at least one file"),{statusCode:400});for(let s of _)if(!s.buffer.length)throw Object.assign(new Error("Empty upload body"),{statusCode:400});let l=(await S(g)).length,f=[];for(let s of _){let t=await n(g,s.requestedName,s.contentType,s.buffer,l);f.push(t),l+=1;}let y=typeof d?.message=="string"?d.message:"",p=[],o={};return await h(g,s=>{let t=new Date().toISOString(),r=s.card_data&&typeof s.card_data=="object"?s.card_data:{};s.card_data=r;let i=m().normalizeIncoming(f.map(P=>({name:P.name,stored_name:P.stored_name,size:P.size,mime_type:P.mime_type,uploaded_at:P.uploaded_at||t,chat:false})),t),w=m().merge(r,i);p.length=0;for(let P of f)p.push(w.findIndex(M=>M.stored_name===P.stored_name));let x=Array.isArray(r.filegroups)?r.filegroups:[];return o={message:y,file_idxs:p.slice(),created_at:t},x.push(o),r.filegroups=x,s}),{ok:true,files:f.map((s,t)=>({...s,file_idx:p[t],chat:false})),file_idxs:p.slice(),filegroup:o}}return {uploadCardFile:C,uploadCardFilesMultiple:k,readCardStoredFileNames:S}}function pe(a$1){return {"discover.source-kinds":()=>a$1.discoverSourceKinds(),"inspect.board-runtime-status":()=>a$1.inspectBoardRuntimeStatus(),"inspect.card-definition-and-runtime":e=>a$1.inspectCardDefinitionAndRuntime({cardId:a(e,"card_id")}),"inspect.chat-messages-on-cards":e=>{let c=b(e,"tail_turns"),m=b(e,"tail"),I=a(e,"turn_id"),h=e.all_turns===true,R=a(e,"tail_turns_before_id");return a$1.inspectChatMessagesOnCards({cardId:a(e,"card_id"),...c!==void 0?{lastUserTurns:c}:{},...m!==void 0?{tail:m}:{},...I?{turnId:I}:{},...h?{allTurns:true}:{},...R?{tailTurnsBeforeId:R}:{}})},"inspect.file-contents":e=>a$1.inspectFileContents({cardId:a(e,"card_id"),fileIdx:Number(b(e,"file_idx"))}),"preflight.validate-candidate-card-definition":e=>a$1.preflightValidateCandidateCardDefinition({candidateCardContent:d(e,"candidate_card_content","candidate_card_content")}),"preflight.materialize-candidate-card":e=>a$1.preflightMaterializeCandidateCard({candidateCardContent:d(e,"candidate_card_content","candidate_card_content"),mockRequires:d(e,"mock_requires","mock_requires"),mockFetchedSources:d(e,"mock_fetched_sources","mock_fetched_sources")}),"preflight.probe-single-source-in-candidate-card":e$1=>a$1.preflightProbeSingleSourceInCandidateCard({candidateCardContent:d(e$1,"candidate_card_content","candidate_card_content"),mockProjections:c(e$1,"mock_projections"),sourceIdx:e(e$1,"source_idx","source_idx")}),"preflight.run-single-source-in-candidate-card":e$1=>a$1.preflightRunSingleSourceInCandidateCard({candidateCardContent:d(e$1,"candidate_card_content","candidate_card_content"),mockProjections:c(e$1,"mock_projections"),sourceIdx:e(e$1,"source_idx","source_idx")}),"preflight.run-single-source-in-live-card":e$1=>a$1.preflightRunSingleSourceInLiveCard({cardId:a(e$1,"card_id"),sourceIdx:e(e$1,"source_idx","source_idx"),mockRequires:d(e$1,"mock_requires","mock_requires")}),"preflight.run-one-cycle-with-candidate-card":e=>a$1.preflightRunOneCycleWithCandidateCard({candidateCardContent:d(e,"candidate_card_content","candidate_card_content"),mockRequires:c(e,"mock_requires")}),"manage.read-card":e=>a$1.manageReadCard({cardId:a(e,"card_id")}),"stage-ai-response-and-any-attachments":e=>{let c=a(e,"turn_id");if(!c)throw Object.assign(new Error("stage-ai-response-and-any-attachments requires a non-empty turn_id"),{statusCode:400});return a$1.manageAddChatEntryAndAnyAttachments({cardId:a(e,"card_id"),role:"assistant",...typeof e.text=="string"?{text:e.text}:{},...c?{turn:c}:{},...Array.isArray(e.files)?{files:e.files}:{}})},"stage-ai-failure-message":e=>{let c=a(e,"turn_id"),m=a(e,"failure");if(!c)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty turn_id"),{statusCode:400});if(!m)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty failure"),{statusCode:400});return a$1.manageAddChatEntryAndAnyAttachments({cardId:a(e,"card_id"),role:"system",text:m,turn:c})},"manage.upsert-card":e=>a$1.manageUpsertCard({cardId:a(e,"card_id"),candidateCardContent:c(e,"candidate_card_content")}),"manage.remove-card":e=>a$1.manageRemoveCard({cardId:a(e,"card_id")})}}function me(a$1){return {"webhook.process-accumulated":()=>a$1.webhookProcessAccumulated(),"webhook.source-fetch-done":e=>a$1.webhookSourceFetchDone({token:a(e,"token"),ref:a(e,"ref")}),"webhook.source-fetch-failed":e=>a$1.webhookSourceFetchFailed({token:a(e,"token"),reason:a(e,"reason")})}}function fe(a$1){let{boardId:e,uploadCardFile:c$1,uploadCardFilesMultiple:m,getMcpFacade:I,controlplane:h}=a$1;function R(n,C){let k=a(n,"board_id");if(!k)throw Object.assign(new Error(`${C} requires board_id`),{statusCode:400});if(k!==e)throw Object.assign(new Error(`Unknown board_id: ${k}`),{statusCode:400})}function S(n,C){let{cardId:k}=h.requireCardArgs(n),g=a(n,"turn_id");return R(n,C),I().manageAddChatAttachment({cardId:k,role:a(n,"role")||"user",...g?{turn:g}:{},files:[{file_name:a(n,"file_name"),content_type:a(n,"content_type")||"application/octet-stream",...typeof n.text=="string"?{text:n.text}:{},...typeof n.base64=="string"?{base64:n.base64}:{},...Array.isArray(n.bytes)?{bytes:n.bytes}:{}}]})}return {"list-runtime-cards":n=>(R(n,"list-runtime-cards"),I().listRuntimeCards()),"sse.subscribe-chat":n=>h.subscribeChat(n),"sse.unsubscribe-chat":n=>h.unsubscribeChat(n),"sse.watch-channel":n=>h.watchChannel(n,true),"sse.unwatch-channel":n=>h.watchChannel(n,false),"getstate.is-chat-processing":n=>h.getChatProcessing(n),"setstate.chat-processing-started":n=>h.setChatProcessing(n,true),"setstate.chat-processing-done":n=>h.setChatProcessing(n,false),"getstate.card-private":n=>h.getCardMeta(n),"setstate.card-private":n=>h.setCardMeta(n),"manage.upload-card-file":n=>{let C=a(n,"card_id"),k=a(n,"file_name"),g=a(n,"content_type")||"application/octet-stream",_=f(n);if(R(n,"manage.upload-card-file"),!C)throw Object.assign(new Error("manage.upload-card-file requires card_id"),{statusCode:400});if(!k)throw Object.assign(new Error("manage.upload-card-file requires file_name"),{statusCode:400});if(!_)throw Object.assign(new Error("manage.upload-card-file requires args.bytes, args.text, or args.base64"),{statusCode:400});return c$1(C,k,g,_,{inChat:false})},"manage.upload-card-file-multiple":n=>{let C=a(n,"card_id"),k=a(n,"message"),g=Array.isArray(n.files)?n.files:[];if(R(n,"manage.upload-card-file-multiple"),!C)throw Object.assign(new Error("manage.upload-card-file-multiple requires card_id"),{statusCode:400});if(g.length===0)throw Object.assign(new Error("manage.upload-card-file-multiple requires a non-empty files array"),{statusCode:400});let _=g.map((d,b)=>{let l=d&&typeof d=="object"?d:{},f$1=a(l,"file_name");if(!f$1)throw Object.assign(new Error(`manage.upload-card-file-multiple files[${b}] requires file_name`),{statusCode:400});let y=f(l);if(!y)throw Object.assign(new Error(`manage.upload-card-file-multiple files[${b}] requires bytes, text, or base64`),{statusCode:400});return {requestedName:f$1,contentType:a(l,"content_type")||"application/octet-stream",buffer:y}});return m(C,_,k?{message:k}:void 0)},"manage.add-chat-attachment":n=>S(n,"manage.add-chat-attachment"),"manage.add-chat-attachement":n=>S(n,"manage.add-chat-attachement"),"manage.add-chat-entry-and-any-attachments":n=>{let{cardId:C}=h.requireCardArgs(n),k=a(n,"role")||"user",g=a(n,"turn_id");return R(n,"manage.add-chat-entry-and-any-attachments"),I().manageAddChatEntryAndAnyAttachments({cardId:C,role:k,...typeof n.text=="string"?{text:n.text}:{},...g?{turn:g}:{},...Array.isArray(n.files)?{files:n.files}:{}})},"manage.patch-card":n=>{let{cardId:C}=h.requireCardArgs(n);return R(n,"manage.patch-card"),I().managePatchCard({cardId:C,patch:c(n,"patch")},{allowControlplaneOnlyCards:true})},"manage.upsert-card":n=>{let{cardId:C}=h.requireCardArgs(n);return R(n,"manage.upsert-card"),I().manageUpsertCard({cardId:C,candidateCardContent:c(n,"candidate_card_content")},{allowControlplaneOnlyCards:true})},"manage.remove-card":n=>{let{cardId:C}=h.requireCardArgs(n);return R(n,"manage.remove-card"),I().manageRemoveCard({cardId:C},{allowControlplaneOnlyCards:true})},"manage.admin-read-card":async n=>{let{cardId:C}=h.requireCardArgs(n);return {status:"success",data:{cards:await I().adminReadCard({cardId:C})}}},"manage.admin-upsert-card":n=>{let C=a(n,"board_id"),k=a(n,"card_id");if(!C)throw Object.assign(new Error("manage.admin-upsert-card requires board_id"),{statusCode:400});if(!k)throw Object.assign(new Error("manage.admin-upsert-card requires card_id"),{statusCode:400});if(C!==e)throw Object.assign(new Error(`Unknown board_id: ${C}`),{statusCode:400});return I().adminUpsertCard({cardId:k,candidateCardContent:c(n,"candidate_card_content")})}}}function he(a){let{boardContexts:e,cardOwnerIndex:c,cardContextForCard:m,readStatusSnapshot:I,readDataObjectsByToken:h,readCardRuntimeArtifacts:R,readCardFromStore:S,readCardDefinitions:n,processAccumulatedLaneInternal:C,reportSourceFetched:k,reportSourceFetchFailure:g,uploadCardFile:_,chatStorePublic:d,serverUrl:b,apiBasePath:l}=a;function f(){return e[0]??null}function y(){return {async status(){let t=await I();return t==null?{status:"fail",error:"Board status is unavailable"}:{status:"success",data:t}},async getOutputsDataObject(t){let r=t?.params?.key;return r?{status:"success",data:(await h())[r]}:{status:"fail",error:"getOutputsDataObject requires params.key"}},async getOutputsComputedValues(t){let r=t?.params?.key;return r?{status:"success",data:(await R())[r]?.computed_values}:{status:"fail",error:"getOutputsComputedValues requires params.key"}},async getOutputsFetchedSources(t){let r=t?.params?.key;if(!r)return {status:"fail",error:"getOutputsFetchedSources requires params.key"};let i=m(r)??f();return i?i.boardOps.getOutputsFetchedSources({params:{key:r}}):{status:"fail",error:"Board context is unavailable"}},async removeCard(t){let r=t?.params?.id;if(!r)return {status:"fail",error:"removeCard requires params.id"};let i=m(r)??f();return i?i.boardOps.removeCard({params:{id:r}}):{status:"fail",error:"Board context is unavailable"}},async upsertCard(t){let r=t?.params?.cardId;if(!r)return {status:"fail",error:"upsertCard requires params.cardId"};let i=m(r)??f();if(!i)return {status:"fail",error:"Board context is unavailable"};let w=await i.boardOps.upsertCard({params:{cardId:r,restart:t.params.restart===true}});if(w.status!=="success")return w;if(a$1(i.boardAdapter)){let x=await C(true);if(x.status!=="success")return x}return w}}}function p(){let t=()=>{let r=f();if(!r?.nonCore)throw new Error("Board non-core adapter is not configured for MCP preflight/discovery tools");return r.nonCore};return {describeTaskExecutorCapabilities(r){return t().describeTaskExecutorCapabilities(r)},validateCardPreflight(r){return t().validateCardPreflight(r)},evalCardCompute(r){return t().evalCardCompute(r)},probeSourcePreflight(r){return t().probeSourcePreflight(r)},runSourcePreflight(r){return t().runSourcePreflight(r)},simulateCardCycle(r){return t().simulateCardCycle(r)}}}function o(){return {async get(t){let r=typeof t.params?.id=="string"?t.params.id:void 0;if(r){let i=await S(r);return i?{status:"success",data:{cards:[i]}}:{status:"success",data:{cards:[]}}}return {status:"success",data:{cards:await n()}}},async set(t){let r=t.body;if(r==null)return {status:"fail",error:"set requires a body (card object or array of cards)"};let i=Array.isArray(r)?r:[r];for(let w of i){let x=w,P=typeof x.id=="string"?x.id:"";if(!P)return {status:"fail",error:"each card must have a string `id` field"};let M=c.get(P)??0,L=e[M]??f();if(!L)return {status:"fail",error:"Board context is unavailable"};let U=await L.cardStoreOps.set({body:x});if(U.status!=="success")return U;c.set(P,M);}return {status:"success",data:{count:i.length}}},async del(t){let r=[t.params?.id,...t.body?.ids??[]].filter(i=>typeof i=="string"&&!!i);if(r.length===0)return {status:"fail",error:"del requires body.ids (string[]) or params.id"};for(let i of r){let w=m(i)??f();if(!w)return {status:"fail",error:"Board context is unavailable"};let x=await w.cardStoreOps.del({params:{id:i}});if(x.status!=="success")return x;c.delete(i);}return {status:"success",data:{count:r.length}}},async patch(t){let r=typeof t.params?.id=="string"?t.params.id:void 0,i=typeof t.params?.path=="string"?t.params.path:void 0;if(!r||!i)return {status:"fail",error:"patch requires params.id and params.path"};let w=m(r)??f();return w?w.cardStoreOps.patch(t):{status:"fail",error:"Board context is unavailable"}},async appendFiles(t){let r=typeof t.params?.id=="string"?t.params.id:void 0;if(!r)return {status:"fail",error:"appendFiles requires params.id"};let i=m(r)??f();return i?i.cardStoreOps.appendFiles(t):{status:"fail",error:"Board context is unavailable"}}}}function s(){return a$2({board:y(),nonCore:p(),cardStore:o(),chatStore:d,processAccumulated:()=>C(true),sourceFetchDone:({token:t,ref:r})=>k(t,r),sourceFetchFailed:({token:t,reason:r})=>g(t,r),uploadCardFile({cardId:t,fileName:r,contentType:i,bytes:w,suppressChatRecordWrite:x}){return _(t,r,i,w,{inChat:true,...x===true?{suppressChatRecordWrite:true}:{}})},buildFileDownloadUrl({cardId:t,fileIdx:r,storedName:i}){let w=`${b||""}${l}/cards/${encodeURIComponent(t)}/files/${r}`;return i?`${w}?sn=${encodeURIComponent(i)}`:w},readFetchedSourceJsonByRef({cardId:t,ref:r}){let i=m(t)??f();if(!i||a$1(i.boardAdapter))return null;let P=i.boardAdapter.resolveBlob(b$1(r)).trim();return P?JSON.parse(P):null}})}return {mcpBoardFacade:y,mcpNonCoreFacade:p,mcpCardStoreFacade:o,createMcpFacade:s}}export{J as a,X as b,Q as c,V as d,Y as e,q as f,T as g,E as h,D as i,se as j,ie as k,ce as l,pe as m,me as n,fe as o,he as p};//# sourceMappingURL=chunk-WFMVZ3LO.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-WFMVZ3LO.js.map
|
package/lib/cloud-storage.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunk6EJRZHFP_cjs=require('./chunk-6EJRZHFP.cjs'),chunkTIQ775WI_cjs=require('./chunk-TIQ775WI.cjs'),chunkCSHNTZW4_cjs=require('./chunk-CSHNTZW4.cjs');require('./chunk-C7RR2JCL.cjs'),require('./chunk-AW3COGCI.cjs'),require('./chunk-SIPLKLWU.cjs'),require('./chunk-CAID4CGO.cjs'),require('./chunk-7JVHYHT2.cjs'),require('./chunk-VQCIOKJV.cjs'),require('./chunk-VI36DRWG.cjs'),require('./chunk-7Y47QXMX.cjs'),require('./chunk-66ZZIF2L.cjs'),require('./chunk-
|
|
1
|
+
'use strict';var chunk6EJRZHFP_cjs=require('./chunk-6EJRZHFP.cjs'),chunkTIQ775WI_cjs=require('./chunk-TIQ775WI.cjs'),chunkCSHNTZW4_cjs=require('./chunk-CSHNTZW4.cjs');require('./chunk-C7RR2JCL.cjs'),require('./chunk-AW3COGCI.cjs'),require('./chunk-SIPLKLWU.cjs'),require('./chunk-CAID4CGO.cjs'),require('./chunk-7JVHYHT2.cjs'),require('./chunk-VQCIOKJV.cjs'),require('./chunk-VI36DRWG.cjs'),require('./chunk-7Y47QXMX.cjs'),require('./chunk-66ZZIF2L.cjs'),require('./chunk-3EITX4IQ.cjs'),require('./chunk-UJ7ZTV4J.cjs'),require('./chunk-2RIHC5TZ.cjs'),require('./chunk-GNFE24S7.cjs');Object.defineProperty(exports,"createAzureBlobStorage",{enumerable:true,get:function(){return chunk6EJRZHFP_cjs.d}});Object.defineProperty(exports,"createAzureQueueStorage",{enumerable:true,get:function(){return chunk6EJRZHFP_cjs.e}});Object.defineProperty(exports,"createCosmosAtomicRelayLock",{enumerable:true,get:function(){return chunk6EJRZHFP_cjs.c}});Object.defineProperty(exports,"createCosmosJournalStorage",{enumerable:true,get:function(){return chunk6EJRZHFP_cjs.b}});Object.defineProperty(exports,"createCosmosKvStorage",{enumerable:true,get:function(){return chunk6EJRZHFP_cjs.a}});Object.defineProperty(exports,"createAsyncBoardLiveCardsPublic",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.i}});Object.defineProperty(exports,"createAsyncCardStorageAdapter",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.c}});Object.defineProperty(exports,"createAsyncCardStore",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.d}});Object.defineProperty(exports,"createAsyncCardStorePublic",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.g}});Object.defineProperty(exports,"createAsyncJsonStorage",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.b}});Object.defineProperty(exports,"createAsyncQueueStoragePublic",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.h}});Object.defineProperty(exports,"createAsyncStateSnapshotAdapter",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.e}});Object.defineProperty(exports,"createAsyncStorageProvider",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.f}});Object.defineProperty(exports,"withAsyncRelayLock",{enumerable:true,get:function(){return chunkTIQ775WI_cjs.a}});Object.defineProperty(exports,"createAsyncBoardConfigStore",{enumerable:true,get:function(){return chunkCSHNTZW4_cjs.b}});Object.defineProperty(exports,"createAsyncBoardWorkerStore",{enumerable:true,get:function(){return chunkCSHNTZW4_cjs.a}});Object.defineProperty(exports,"createHostedAsyncBoardPlatformAdapter",{enumerable:true,get:function(){return chunkCSHNTZW4_cjs.c}});//# sourceMappingURL=cloud-storage.cjs.map
|
|
2
2
|
//# sourceMappingURL=cloud-storage.cjs.map
|
package/lib/cloud-storage.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as createAzureBlobStorage,e as createAzureQueueStorage,c as createCosmosAtomicRelayLock,b as createCosmosJournalStorage,a as createCosmosKvStorage}from'./chunk-QLB6PKOT.js';export{i as createAsyncBoardLiveCardsPublic,c as createAsyncCardStorageAdapter,d as createAsyncCardStore,g as createAsyncCardStorePublic,b as createAsyncJsonStorage,h as createAsyncQueueStoragePublic,e as createAsyncStateSnapshotAdapter,f as createAsyncStorageProvider,a as withAsyncRelayLock}from'./chunk-E7SDEZSI.js';export{b as createAsyncBoardConfigStore,a as createAsyncBoardWorkerStore,c as createHostedAsyncBoardPlatformAdapter}from'./chunk-PEJRTZU3.js';import'./chunk-C7OY3PYL.js';import'./chunk-FULAMLUU.js';import'./chunk-EOVTMJYZ.js';import'./chunk-QJQ53PLM.js';import'./chunk-ANKA7HEJ.js';import'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import'./chunk-QE3QXEHI.js';import'./chunk-
|
|
1
|
+
export{d as createAzureBlobStorage,e as createAzureQueueStorage,c as createCosmosAtomicRelayLock,b as createCosmosJournalStorage,a as createCosmosKvStorage}from'./chunk-QLB6PKOT.js';export{i as createAsyncBoardLiveCardsPublic,c as createAsyncCardStorageAdapter,d as createAsyncCardStore,g as createAsyncCardStorePublic,b as createAsyncJsonStorage,h as createAsyncQueueStoragePublic,e as createAsyncStateSnapshotAdapter,f as createAsyncStorageProvider,a as withAsyncRelayLock}from'./chunk-E7SDEZSI.js';export{b as createAsyncBoardConfigStore,a as createAsyncBoardWorkerStore,c as createHostedAsyncBoardPlatformAdapter}from'./chunk-PEJRTZU3.js';import'./chunk-C7OY3PYL.js';import'./chunk-FULAMLUU.js';import'./chunk-EOVTMJYZ.js';import'./chunk-QJQ53PLM.js';import'./chunk-ANKA7HEJ.js';import'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import'./chunk-QE3QXEHI.js';import'./chunk-NJCDHKPX.js';import'./chunk-MNEOJWPS.js';import'./chunk-UGB7PC4P.js';import'./chunk-FW4363Y4.js';//# sourceMappingURL=cloud-storage.js.map
|
|
2
2
|
//# sourceMappingURL=cloud-storage.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkP4WQJ7LA_cjs=require('../chunk-P4WQJ7LA.cjs'),chunkAW3COGCI_cjs=require('../chunk-AW3COGCI.cjs');require('../chunk-SIPLKLWU.cjs');var chunkVI36DRWG_cjs=require('../chunk-VI36DRWG.cjs');require('../chunk-7Y47QXMX.cjs'),require('../chunk-66ZZIF2L.cjs'),require('../chunk-
|
|
1
|
+
'use strict';var chunkP4WQJ7LA_cjs=require('../chunk-P4WQJ7LA.cjs'),chunkAW3COGCI_cjs=require('../chunk-AW3COGCI.cjs');require('../chunk-SIPLKLWU.cjs');var chunkVI36DRWG_cjs=require('../chunk-VI36DRWG.cjs');require('../chunk-7Y47QXMX.cjs'),require('../chunk-66ZZIF2L.cjs'),require('../chunk-3EITX4IQ.cjs'),require('../chunk-UJ7ZTV4J.cjs'),require('../chunk-GNFE24S7.cjs');Object.defineProperty(exports,"createCallbackHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.i}});Object.defineProperty(exports,"createFireAndForgetHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.j}});Object.defineProperty(exports,"createNoopHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.o}});Object.defineProperty(exports,"createProcessHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.l}});Object.defineProperty(exports,"createScriptHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.m}});Object.defineProperty(exports,"createShellHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.k}});Object.defineProperty(exports,"createWebhookHandler",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.n}});Object.defineProperty(exports,"getDownstream",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.e}});Object.defineProperty(exports,"getUnreachableNodes",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.c}});Object.defineProperty(exports,"getUnreachableTokens",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.b}});Object.defineProperty(exports,"getUpstream",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.d}});Object.defineProperty(exports,"inspect",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.a}});Object.defineProperty(exports,"liveCardsToReactiveGraph",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.p}});Object.defineProperty(exports,"mutateGraph",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.h}});Object.defineProperty(exports,"validateLiveGraph",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.f}});Object.defineProperty(exports,"validateReactiveGraph",{enumerable:true,get:function(){return chunkP4WQJ7LA_cjs.g}});Object.defineProperty(exports,"MemoryJournal",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.r}});Object.defineProperty(exports,"addNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.d}});Object.defineProperty(exports,"addProvides",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.h}});Object.defineProperty(exports,"addRequires",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.f}});Object.defineProperty(exports,"applyEvent",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.b}});Object.defineProperty(exports,"applyEvents",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.c}});Object.defineProperty(exports,"computeDataHash",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.s}});Object.defineProperty(exports,"createLiveGraph",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.a}});Object.defineProperty(exports,"createReactiveGraph",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.t}});Object.defineProperty(exports,"disableNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.m}});Object.defineProperty(exports,"drainTokens",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.k}});Object.defineProperty(exports,"enableNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.n}});Object.defineProperty(exports,"getNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.o}});Object.defineProperty(exports,"injectTokens",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.j}});Object.defineProperty(exports,"removeNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.e}});Object.defineProperty(exports,"removeProvides",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.i}});Object.defineProperty(exports,"removeRequires",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.g}});Object.defineProperty(exports,"resetNode",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.l}});Object.defineProperty(exports,"restore",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.q}});Object.defineProperty(exports,"snapshot",{enumerable:true,get:function(){return chunkAW3COGCI_cjs.p}});Object.defineProperty(exports,"schedule",{enumerable:true,get:function(){return chunkVI36DRWG_cjs.a}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|