yaml-flow 8.11.7 → 8.11.8
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 +4 -0
- package/browser/server-runtime-controlface.js +4 -4
- package/examples/board/cards/card-rebalance-sim.json +4 -1
- 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 +6 -6
- package/lib/board-live-cards-node.js +6 -6
- 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.d.cts +6 -0
- package/lib/card-compute/index.d.ts +6 -0
- 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-NOAERAOE.cjs → chunk-36KKCQVE.cjs} +2 -2
- package/lib/chunk-3DWVFRQD.cjs +3 -0
- package/lib/chunk-3SLSRX6Q.js +3 -0
- package/lib/{chunk-EHREWADE.js → chunk-4NWVZ7AW.js} +2 -2
- package/lib/chunk-543ZEGP7.cjs +2 -0
- package/lib/{chunk-YAPTL2MP.cjs → chunk-6SPWFJRG.cjs} +2 -2
- package/lib/{chunk-HKPVF5UI.js → chunk-BA25VGJP.js} +3 -3
- package/lib/chunk-BRYV6CDD.js +3 -0
- package/lib/chunk-EGZPROOH.cjs +3 -0
- package/lib/{chunk-GHUW6P4G.cjs → chunk-ESTFYRHF.cjs} +2 -2
- package/lib/{chunk-52XPRCZC.cjs → chunk-HOS2ZUFZ.cjs} +2 -2
- package/lib/chunk-JOQWJ3VR.cjs +2 -0
- package/lib/chunk-MRESV3MD.js +2 -0
- package/lib/chunk-MRIFSG7L.cjs +3 -0
- package/lib/{chunk-6M3RIGUH.js → chunk-NN52BT3Q.js} +2 -2
- package/lib/{chunk-TUQ6JBER.cjs → chunk-OR6B2H2Y.cjs} +3 -3
- package/lib/{chunk-I3ZOFU3F.js → chunk-PIPXFUEA.js} +2 -2
- package/lib/chunk-REZO2QJD.js +3 -0
- package/lib/{chunk-23PEDGFN.js → chunk-ROIYEFSE.js} +2 -2
- package/lib/chunk-UJQ7IML5.js +2 -0
- package/lib/chunk-YOY2JM5N.js +2 -0
- package/lib/chunk-ZV35WD6K.cjs +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/server-runtime/index.cjs +1 -1
- package/lib/server-runtime/index.js +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.js +1 -1
- package/package.json +1 -1
- package/schema/live-cards.schema.json +4 -0
- package/lib/chunk-2LGCYN35.js +0 -2
- package/lib/chunk-3XPY7CCM.cjs +0 -3
- package/lib/chunk-ATOQP3BD.js +0 -2
- package/lib/chunk-CPJXGK2T.cjs +0 -2
- package/lib/chunk-J7KE7SPA.cjs +0 -2
- package/lib/chunk-K5TEZRZK.cjs +0 -3
- package/lib/chunk-QBEQL4TL.cjs +0 -2
- package/lib/chunk-QEHKMLHA.cjs +0 -3
- package/lib/chunk-RKLEBQUG.js +0 -3
- package/lib/chunk-WGYS2L4V.js +0 -2
- package/lib/chunk-X32SJDLT.js +0 -3
- package/lib/chunk-YT76JNKE.js +0 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {a as a$3}from'./chunk-Y4WK7HE4.js';export{a as createChatStorage,c as createInMemoryChatStorage}from'./chunk-Y4WK7HE4.js';import {a as a$6}from'./chunk-
|
|
1
|
+
import {a as a$3}from'./chunk-Y4WK7HE4.js';export{a as createChatStorage,c as createInMemoryChatStorage}from'./chunk-Y4WK7HE4.js';import {a as a$6}from'./chunk-UJQ7IML5.js';import {a as a$4}from'./chunk-O5UYCGIN.js';export{a as createArtifactsStore,c as createCardFileMetadataStore,b as createFileArtifactsStore}from'./chunk-O5UYCGIN.js';import {a as a$5}from'./chunk-RKKSVOP2.js';export{a as createBoardWorkerStore,b as createQueueLaneRegistry}from'./chunk-RKKSVOP2.js';import {h}from'./chunk-J4MHQ7JF.js';import {a as a$1}from'./chunk-VGDLSS2H.js';export{a as createBoardContainerLifecycle}from'./chunk-F3A3ZNF6.js';import'./chunk-QLB6PKOT.js';import'./chunk-REZO2QJD.js';import {b as b$1}from'./chunk-PEJRTZU3.js';import {d,e}from'./chunk-BRYV6CDD.js';export{f as createBoardLiveCardsNonCorePublic,e as createBoardLiveCardsPublic,b as createHttpBoardCallbackTransport,c as createInProcessBoardCallbackTransport,d as createLocalNodeBoardCallbackTransport}from'./chunk-BRYV6CDD.js';import'./chunk-FULAMLUU.js';import'./chunk-EOVTMJYZ.js';export{a as createBoardLiveCardsMcp}from'./chunk-NN52BT3Q.js';export{q as BOARD_GRAPH_KEY,D as EMPTY_CONFIG,p as SNAPSHOT_SCHEMA_VERSION_V1,m as createCardStore,H as createCardStorePublic}from'./chunk-MRESV3MD.js';export{a as executionRefFromScriptPath,c as parseExecutionRef,b as serializeExecutionRef}from'./chunk-ANKA7HEJ.js';import {a as a$2,b}from'./chunk-44L64VQ2.js';export{b as parseRef,a as serializeRef}from'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import {a as a$7}from'./chunk-YOY2JM5N.js';import {d as d$1}from'./chunk-3SLSRX6Q.js';import'./chunk-MNEOJWPS.js';export{a as createQueueStoragePublic}from'./chunk-BJGK5FNL.js';export{a as createArtifactsStorePublic}from'./chunk-X3LC4LII.js';import'./chunk-UGB7PC4P.js';import'./chunk-FW4363Y4.js';import {spawn,spawnSync,execFile,execFileSync}from'child_process';import*as a from'fs';import a__default from'fs';import*as Je from'os';import*as v from'path';import v__default from'path';import*as Ke from'net';import {fileURLToPath}from'url';import {randomUUID,createHash}from'crypto';import {createRequire}from'module';import {lockSync}from'proper-lockfile';function P(...e){return v.join(...e)}function We(e){return v.isAbsolute(e)}function pe(){return randomUUID()}function He(e){return createHash("sha256").update(e).digest("hex")}function Ve(e){return v.dirname(fileURLToPath(e))}function Qt(e){if(typeof e=="object"&&e!==null){let{command:r,args:o=[],...n}=e,s=De(r,o);return {...n,command:s.command,args:s.args}}let t=Ue(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return De(t[0],t.slice(1))}function De(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function Ue(e){let t=[],r="",o=null;for(let n of e.trim()){if(o){n===o?o=null:r+=n;continue}if(n==='"'||n==="'"){o=n;continue}if(/\s/.test(n)){r&&(t.push(r),r="");continue}r+=n;}if(o)throw new Error(`Unterminated quote in command: ${e}`);return r&&t.push(r),t}function ze(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Ge(e,t){let{command:r,args:o=[],cwd:n,env:s,timeoutMs:d}=e;return execFileSync(r,o,{shell:ze(r),timeout:d,encoding:t?.encoding??"utf-8",cwd:n,windowsHide:true,env:s?{...process.env,...s}:void 0,input:t?.input})}function Dt(e,t){let{command:r,args:o=[],cwd:n,env:s,timeoutMs:d=3e4}=e;execFile(r,o,{shell:ze(r),encoding:"utf8",windowsHide:true,timeout:d,maxBuffer:10*1024*1024,cwd:n,env:s?{...process.env,...s}:void 0},(g,x,u)=>t(g??null,x,u));}function Ye(e,t,r){let o=v.join(e,"board-live-cards-cli.js");if(a.existsSync(o))return {cmd:process.execPath,args:[o,t,...r]};let n=v.join(e,"board-live-cards-cli.ts"),d=[v.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),v.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),v.join(e,"..","..","..","node_modules",".bin","tsx"),v.join(e,"..","..","node_modules",".bin","tsx")].find(x=>a.existsSync(x));return a.existsSync(n)&&d?{cmd:process.execPath,args:[d,n,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",n,t,...r]}}function Ze(e){let t=v.join(e,"board-live-cards-cli.mjs");if(a.existsSync(t))return t;let r=v.join(e,"..","..","..","dev","board-live-cards-cli.js");if(a.existsSync(r))return r;let o=v.join(e,"..","..","dev","board-live-cards-cli.js");if(a.existsSync(o))return o;let n=v.join(e,"board-live-cards-cli.js");if(a.existsSync(n))return n;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper, ${n}, or ${t})`)}function Jt(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:v.join(Je.tmpdir(),`${e}.sock`)}var fe=new Map;function Xe(e,t,r){if(t.length===0)return;let o=t.map(g=>JSON.stringify(g)).join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`,n=de.get(e);if(n&&!n.socket.destroyed){n.ready?n.socket.write(o):n.queue.push(o);return}let s=Qt(e),d=De.createConnection(s);n={socket:d,ready:false,queue:[o]},de.set(e,n),d.on("connect",()=>{n.ready=true;for(let g of n.queue)d.write(g);n.queue.length=0;}),d.on("error",g=>{r?.(`[named-pipe publish] ${s}: ${g instanceof Error?g.message:String(g)}`),de.delete(e);}),d.on("close",()=>{de.delete(e);});}function Ze(){return {executeSync(e,t,r){return Ue({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){qt({command:e,args:t},r);},resolveInvocation(e,t){let r=Nt({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:He}}function be(e){return {id:e.id??"board-worker",pollIntervalMs:e.pollIntervalMs,visibilityMs:e.visibilityMs,concurrency:e.concurrency,maxAttempts:e.maxAttempts,async lease(t){return e.workerStore.leaseRequests(t).map(r=>({id:r.messageId,attempt:r.attempt,message:r.request,ack:()=>e.workerStore.ackRequest(r.messageId,r.leaseToken),nack:o=>e.workerStore.nackRequest(r.messageId,r.leaseToken,o)}))},async handle(t){await e.handleRequest(t.args,t);},onError:e.onError}}function ve(e){return {id:e.id,pollIntervalMs:e.pollIntervalMs,visibilityMs:e.visibilityMs,concurrency:e.concurrency,maxAttempts:e.maxAttempts,async lease(t){return e.queueStorage.lease(t).map(r=>({id:r.id,attempt:r.attempt,message:r.body,ack:()=>e.queueStorage.ack(r.id,r.leaseToken),nack:o=>e.queueStorage.nack(r.id,r.leaseToken,o)}))},handle:e.handleMessage,onError:e.onError}}async function Xe(e,t){try{await e.handle(t.message,t),await t.ack();}catch(r){let o=t.attempt>=Math.max(1,Math.floor(e.maxAttempts??5));await t.nack({dead:o,reason:r instanceof Error?r.message:String(r)}),e.onError?.(r,t);}}function et(e){let t=Math.max(1,Math.floor(e.pollIntervalMs??250)),r=Math.max(1,Math.floor(e.visibilityMs??6e4)),o=Math.max(1,Math.floor(e.concurrency??1)),n=false,s=false;async function d(){if(!(n||s)){s=true;try{let x=await e.lease({max:o,visibilityMs:r});for(let u of x)await Xe(e,u);}finally{s=false;}}}let g=setInterval(()=>{d();},t);return typeof g.unref=="function"&&g.unref(),d(),()=>{n=true,clearInterval(g);}}async function Dt(e){let t=Math.max(1,Math.floor(e.visibilityMs??6e4)),r=Math.max(1,Math.floor(e.concurrency??1)),o=await e.lease({max:r,visibilityMs:t});for(let n of o)await Xe(e,n);return o.length}async function fe(e,t){let r=Math.max(1,Math.floor(t?.maxPasses??256)),o=0;for(let n=0;n<r;n+=1){let s=await Dt(e);if(o+=s,s<=0)return o}throw new Error(`drainQueueLaneToIdle exceeded ${r} passes for lane "${e.id}"`)}function Jt(e){let r=(Array.isArray(e)?e:e.lanes).map(o=>et(o));return ()=>{for(let o of r)o();}}var Wt=createRequire(import.meta.url);function Ht(e){return typeof e=="object"?e:b(e)}function rt(e){let t=v.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=v.dirname(Wt.resolve("yaml-flow/package.json")),o=t.replace(/\.[^.]+$/,""),n=v.join(r,"cli","bundled",`${o}.mjs`);if(a.existsSync(n))return n;let s=v.join(r,"cli","node",t);if(a.existsSync(s))return s;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function q(e){let t=Ht(e);return t.kind==="yaml-flow-cli"?rt(t.value):t.value}function Vt(e,t){let r=q(e);switch(r){case "source-cli-task-executor":{let o=v.join(t,"source-cli-task-executor.js");if(a.existsSync(o))return {command:process.execPath,args:[o]};let n=v.join(t,"source-cli-task-executor.ts"),s=v.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),d=v.join(t,"..","..","node_modules",".bin","tsx"),g=a.existsSync(s)?s:d;return a.existsSync(n)&&a.existsSync(g)?{command:process.execPath,args:[g,n]}:{command:process.execPath,args:[o]}}case "board-live-cards":{let{cmd:o,args:n}=ze(t,"_",[]);return {command:o,args:n}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Ut(e,t){if(e.howToRun==="built-in"){let{command:o,args:n}=Vt(e.whatToRun,t);return {command:o,baseArgs:n}}let r=(typeof e.whatToRun=="object",q(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function pe(e,t){return Ut(e,t)}var Ae=new Map;function zt(e,t){let r=String(e||"").trim();if(!r)throw new Error("registerInProcessExecutionHandler: key is required");Ae.set(r,t);}function Gt(e){let t=String(e||"").trim();t&&Ae.delete(t);}function nt(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),o=r[r.length-1];return JSON.parse(o)}}function ot(e,t){return {...t,whatToRun:q(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function Te(e,t,r="invokeExecutionRef"){return a$1(e,t,r)}function st(e,t){if(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data))return {...e,...t||{}};if(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.status=="string"){let o=e,n=o.status==="success"?"success":o.status==="fail"?"failure":o.status,s=o.data&&typeof o.data=="object"&&!Array.isArray(o.data)?o.data:o.data===void 0?{}:{stdout:o.data};return {result:n,data:s,...typeof o.error=="string"?{error:o.error}:{},...t||{}}}return {result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e},...t||{}}}function N(e){return {result:"failure",data:{error:e}}}function G(e,t,r){let o=r?.label??"invokeExecutionRefSync",n=r?.cliDir??r?.cwd??process.cwd(),s;try{s=Te(e.argsMassaging,ot(e,t),o);}catch(h){let R=h instanceof Error?h.message:String(h);return N(R)}let d;try{d=pe(e,n);}catch(h){let R=h instanceof Error?h.message:String(h);return N(`[${o}] ref resolution failed: ${R}`)}let g=[...d.baseArgs,...s.cmdArgs??[]],x=JSON.stringify(s.stdin??t),u=Ze(),p;try{p=u.executeSync(d.command,g,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:x});}catch(h){let R=h,y=(R.stderr?String(R.stderr):"").trim(),l=typeof R.status=="number"?R.status:"unknown",f=y||R.message;return N(`[${o}] ref exited with status ${l}${f?`: ${f}`:""}`)}try{return st(nt(p))}catch{return {result:"success",data:{stdout:p.trim()}}}}async function tt(e,t,r){let o=r?.label??"invokeExecutionRef",n;try{n=Te(e.argsMassaging,ot(e,t),o);}catch(h){let R=h instanceof Error?h.message:String(h);return N(R)}let s=q(e.whatToRun),d=n.headers?{"Content-Type":"application/json",...n.headers}:{"Content-Type":"application/json"},g=n.url??s,x;if(e.howToRun==="http:get"){let h=n.body&&typeof n.body=="object"&&!Array.isArray(n.body)?n.body:t,R=new URLSearchParams(Object.entries(h).filter(([,y])=>y!=null).map(([y,l])=>[y,String(l)]));R.size>0&&(g=`${g}${g.includes("?")?"&":"?"}${R.toString()}`);}else x=JSON.stringify(n.body??t);let u={method:e.howToRun==="http:get"?"GET":"POST",headers:d,body:x},p=0;for(;;)try{let h=await fetch(g,u);if(!h.ok){let f=await h.text().catch(()=>"");return N(`[${o}] HTTP ${h.status}${f?`: ${f}`:""}`)}let R={};h.headers.forEach((f,m)=>{R[m]=f;});let y=new Uint8Array(await h.arrayBuffer());if(y.byteLength===0)return {result:"success",data:{},headers:R};let l=new TextDecoder().decode(y);try{return st(nt(l),{headers:R})}catch{return {result:"success",data:{stdout:l},headers:R}}}catch(h){let R=h?.cause,y=R&&typeof R=="object"&&"code"in R?String(R.code||""):"";if((y==="ECONNRESET"||y==="UND_ERR_SOCKET")&&p===0){p+=1;continue}let f=h instanceof Error?h.message:String(h),m=R instanceof Error?`${R.name}: ${R.message}${y?` [${y}]`:""}`:R?String(R):"",S=n.url??s??"",c=`${f}${m?` (cause: ${m})`:""}${S?` url=${S}`:""}`;return N(`[${o}] ${c}`)}}async function Yt(e,t,r){let o=r?.label??"invokeExecutionRef",n=q(e.whatToRun).trim();if(!n)return N(`[${o}] in-process-loop requires a non-empty handler key`);let s=Ae.get(n);if(!s)return N(`[${o}] no in-process handler registered for: ${n}`);try{return await s(e,t,r)}catch(d){let g=d instanceof Error?d.message:String(d);return N(`[${o}] ${g}`)}}var Zt={"local-node":async(e,t,r)=>G(e,t,r),"local-python":async(e,t,r)=>G(e,t,r),"local-process":async(e,t,r)=>G(e,t,r),"built-in":async(e,t,r)=>G(e,t,r),"http:post":tt,"http:get":tt,"in-process-loop":Yt},Xt={"local-node":G,"local-python":G,"local-process":G,"built-in":G};async function te(e,t,r){let o=r?.transports?.[e.howToRun]??Zt[e.howToRun];return o?o(e,t,r):N(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function Ee(e,t,r){let o=r?.syncTransports?.[e.howToRun]??Xt[e.howToRun];return o?o(e,t,r):N(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function er(e){return {invoke(t,r){return te(t,r,e)},invokeSync(t,r){return Ee(t,r,e)}}}function tr(e,t,r){return Ee(e,t,r)}function Ce(e={}){let t=e.resolveRef??(r=>r);return {...e.executorTimeouts?{executorTimeouts:e.executorTimeouts}:{},async invokeExecutor(r,o,n){let s=t(r);if(s.howToRun==="queue-storage")throw new Error("queue-storage does not support inline executor request/response");if(s.howToRun==="http:post"||s.howToRun==="in-process-loop"){let p=await h(s,{subcommand:o,...n?.input!==void 0?{input:n.input}:{}});return typeof p=="string"?p:p&&typeof p=="object"&&!Array.isArray(p)&&typeof p.stdout=="string"?String(p.stdout):JSON.stringify(p??{})}if(s.howToRun==="http:get"){let p=await te(s,{subcommand:o,...n?.input!==void 0?{input:n.input}:{},...s.extra?{extra:s.extra}:{}},{cwd:process.cwd(),timeoutMs:n?.timeout??3e4,label:`invokeExecutor:${o}`});if(p.result!=="success"){let h=typeof p.data?.error=="string"?p.data.error:p.error;throw new Error(h||`executor request failed: ${p.result}`)}return typeof p.data?.stdout=="string"?p.data.stdout:JSON.stringify(p.data??{})}if(!e.resolveCliDir)throw new Error(`createNonCoreExecutorDispatcher: ref.howToRun="${s.howToRun}" requires opts.resolveCliDir`);let{command:d,baseArgs:g}=pe(s,e.resolveCliDir()),x=s.extra?["--extra",Buffer.from(JSON.stringify(s.extra)).toString("base64")]:[],u=[...g,o,...x];return await new Promise((p,h)=>{let R=spawn(d,u,{cwd:process.cwd(),stdio:"pipe",windowsHide:true,shell:process.platform==="win32"&&/\.(cmd|bat)$/i.test(d)}),y=[],l=[],f=false,m=null,S=i=>{f||(f=true,m&&clearTimeout(m),h(i));},c=i=>{f||(f=true,m&&clearTimeout(m),p(i));};R.stdout.on("data",i=>{y.push(Buffer.from(i));}),R.stderr.on("data",i=>{l.push(Buffer.from(i));}),R.on("error",i=>{let k=i;k.stdout=Buffer.concat(y).toString("utf-8"),k.stderr=Buffer.concat(l).toString("utf-8"),S(k);}),R.on("close",i=>{let k=Buffer.concat(y).toString("utf-8"),w=Buffer.concat(l).toString("utf-8");if(i===0){c(k);return}let b=new Error(w.trim()||`executor exited with status ${i}`);b.stdout=k,b.stderr=w,S(b);}),n?.timeout&&n.timeout>0&&(m=setTimeout(()=>{R.kill();let i=new Error(`executor timed out after ${n.timeout}ms`);i.stdout=Buffer.concat(y).toString("utf-8"),i.stderr=Buffer.concat(l).toString("utf-8"),S(i);},n.timeout)),n?.input!==void 0?R.stdin.end(n.input):R.stdin.end();})}}}function $(e,t){if(process.platform!=="win32"){a.renameSync(e,t);return}let r=[10,20,40,80,160];for(let o=0;o<=r.length;o++)try{a.renameSync(e,t);return}catch(n){let s=n.code;if((s==="EPERM"||s==="EBUSY")&&o<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[o]);continue}throw n}}function Y(e){function t(n){return v.join(e,...n.split("/"))}function r(n){return v.relative(e,n).replace(/\\/g,"/")}function o(n,s){if(a.existsSync(n))for(let d of a.readdirSync(n,{withFileTypes:true})){let g=v.join(n,d.name);if(d.isDirectory()){o(g,s);continue}d.isFile()&&s.push(r(g));}}return {read(n){let s=t(n);if(!a.existsSync(s))return null;try{return a.readFileSync(s,"utf-8")}catch{return null}},write(n,s){let d=t(n),g=`${d}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(d),{recursive:true}),a.writeFileSync(g,s,"utf-8"),$(g,d);},exists(n){return a.existsSync(t(n))},remove(n){let s=t(n);try{a.existsSync(s)&&a.unlinkSync(s);}catch{}},readBytes(n){let s=t(n);if(!a.existsSync(s))return null;try{return new Uint8Array(a.readFileSync(s))}catch{return null}},writeBytes(n,s){let d=t(n),g=`${d}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(d),{recursive:true}),a.writeFileSync(g,Buffer.from(s)),$(g,d);},listKeys(n){let s=[];o(e,s);let d=s.sort();return n?d.filter(g=>g.startsWith(n)):d},stat(n){let s=t(n);if(!a.existsSync(s))return null;try{let d=a.statSync(s);return {key:n,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},keyRef(n){return {kind:"fs-path",value:t(n)}},renameKey(n,s){let d=t(n);if(!a.existsSync(d))return false;let g=t(s);return a.mkdirSync(v.dirname(g),{recursive:true}),$(d,g),true}}}function Pe(){return {read(e){if(!a.existsSync(e))return null;try{return a.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,t,"utf-8"),$(r,e);},exists(e){return a.existsSync(e)},remove(e){try{a.existsSync(e)&&a.unlinkSync(e);}catch{}},readBytes(e){if(!a.existsSync(e))return null;try{return new Uint8Array(a.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,Buffer.from(t)),$(r,e);},stat(e){if(!a.existsSync(e))return null;try{let t=a.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []},renameKey(e,t){return a.existsSync(e)?(a.mkdirSync(v.dirname(t),{recursive:true}),$(e,t),true):false}}}function W(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,JSON.stringify(t,null,2),"utf-8"),$(r,e);}function Q(e){if(!a.existsSync(e))return null;try{return JSON.parse(a.readFileSync(e,"utf-8"))}catch{return null}}function re(e){return a.existsSync(e)?a.readdirSync(e).filter(t=>t.endsWith(".json")).sort().map(t=>v.join(e,t)):[]}function ne(e){return {id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}}function sr(e){return {...ne(e),leaseToken:String(e.leaseToken||""),leaseExpiresAt:String(e.leaseExpiresAt||"")}}function ir(e){return {...ne(e),reason:e.reason}}function Fe(e){let t=v.join(e,"active"),r=v.join(e,"leased"),o=v.join(e,"done"),n=v.join(e,"dead"),s=v.join(e,"staged");for(let l of [t,r,o,n,s])a.mkdirSync(l,{recursive:true});let d=0;function g(l){let f=l.replace(/[:.]/g,"-"),m=String(d++).padStart(6,"0");return `${f}-${m}`}function x(l){let f=l.activeOrderKey||g(String(l.enqueuedAt||new Date().toISOString()));return v.join(t,`${f}-${l.id}.json`)}function u(l){return v.join(r,`${l}.json`)}function p(l){return v.join(o,`${l}.json`)}function h(l){return v.join(n,`${l}.json`)}function R(l){return v.join(s,`${l}.json`)}function y(){let l=Date.now();for(let f of re(r)){let m=Q(f);if(!m?.leaseExpiresAt)continue;let S=Date.parse(m.leaseExpiresAt);if(Number.isNaN(S)||S>l)continue;let c={id:m.id,body:m.body,enqueuedAt:m.enqueuedAt,attempt:m.attempt,activeOrderKey:m.activeOrderKey};W(x(c),c);try{a.unlinkSync(f);}catch{}}}return {enqueue(l){let f={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0};return f.activeOrderKey=g(f.enqueuedAt),W(x(f),f),ne(f)},enqueueMany(l){return l.map(f=>this.enqueue(f))},enqueueIfAbsent(l,f){y();for(let S of [t,r,s])for(let c of re(S))if(Q(c)?.dedupKey===f)return null;let m={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:f};return m.activeOrderKey=g(m.enqueuedAt),W(x(m),m),ne(m)},lease(l){y();let f=Math.max(1,Math.floor(l?.max??1)),m=Math.max(1,Math.floor(l?.visibilityMs??6e4)),S=[];for(let c of re(t)){if(S.length>=f)break;let i=Q(c);if(!i)continue;let k=u(i.id);try{$(c,k);}catch{continue}let w={...i,attempt:(Number(i.attempt)||0)+1,leaseToken:randomUUID(),leaseExpiresAt:new Date(Date.now()+m).toISOString()};W(k,w),S.push(sr(w));}return S},ack(l,f){let m=u(l),S=Q(m);if(!S||S.leaseToken!==f)return false;try{$(m,p(l));}catch{return false}return true},nack(l,f,m){let S=u(l),c=Q(S);if(!c||c.leaseToken!==f)return false;let i={id:c.id,body:c.body,enqueuedAt:c.enqueuedAt,attempt:c.attempt,activeOrderKey:c.activeOrderKey};m?.dead?(i.reason=m.reason,W(h(l),i)):W(x(i),i);try{a.unlinkSync(S);}catch{}return true},peekActive(l){return y(),re(t).map(f=>Q(f)).filter(f=>!!f).map(ne)},peekDeadLetter(l){return re(n).map(f=>Q(f)).filter(f=>!!f).map(ir)},stage(l,f){let m=f?.dedupKey;if(m){y();for(let c of [t,r,s])for(let i of re(c))if(Q(i)?.dedupKey===m)return null}let S={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0,...m?{dedupKey:m}:{}};return W(R(S.id),S),ne(S)},commitStaged(l){let f=R(l),m=Q(f);if(!m)return false;let S=new Date().toISOString(),c={...m,attempt:0,enqueuedAt:S,activeOrderKey:g(S)};W(x(c),c);try{a.unlinkSync(f);}catch{}return true},discardStaged(l,f){let m=R(l),S=Q(m);if(!S)return false;let c={id:S.id,body:S.body,enqueuedAt:S.enqueuedAt,attempt:S.attempt,reason:f};W(h(l),c);try{a.unlinkSync(m);}catch{}return true},peekStaged(l){return re(s).map(f=>Q(f)).filter(f=>!!f).map(ne)}}}var je="__scratch-marker",Be="__scratch-config.json",ar=1440*60*1e3,cr=720*60*1e3,ur=500;function it(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function ie(e){a.mkdirSync(e,{recursive:true});let t=v.join(e,je),r=v.join(e,Be),o=!a.existsSync(t);if(o)try{a.writeFileSync(t,`scratch-store
|
|
3
|
+
`,n=fe.get(e);if(n&&!n.socket.destroyed){n.ready?n.socket.write(o):n.queue.push(o);return}let s=Jt(e),d=Ke.createConnection(s);n={socket:d,ready:false,queue:[o]},fe.set(e,n),d.on("connect",()=>{n.ready=true;for(let g of n.queue)d.write(g);n.queue.length=0;}),d.on("error",g=>{r?.(`[named-pipe publish] ${s}: ${g instanceof Error?g.message:String(g)}`),fe.delete(e);}),d.on("close",()=>{fe.delete(e);});}function et(){return {executeSync(e,t,r){return Ge({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Dt({command:e,args:t},r);},resolveInvocation(e,t){let r=Qt({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Ue}}function Ae(e){return {id:e.id??"board-worker",pollIntervalMs:e.pollIntervalMs,visibilityMs:e.visibilityMs,concurrency:e.concurrency,maxAttempts:e.maxAttempts,async lease(t){return e.workerStore.leaseRequests(t).map(r=>({id:r.messageId,attempt:r.attempt,message:r.request,ack:()=>e.workerStore.ackRequest(r.messageId,r.leaseToken),nack:o=>e.workerStore.nackRequest(r.messageId,r.leaseToken,o)}))},async handle(t){await e.handleRequest(t.args,t);},onError:e.onError}}function Te(e){return {id:e.id,pollIntervalMs:e.pollIntervalMs,visibilityMs:e.visibilityMs,concurrency:e.concurrency,maxAttempts:e.maxAttempts,async lease(t){return e.queueStorage.lease(t).map(r=>({id:r.id,attempt:r.attempt,message:r.body,ack:()=>e.queueStorage.ack(r.id,r.leaseToken),nack:o=>e.queueStorage.nack(r.id,r.leaseToken,o)}))},handle:e.handleMessage,onError:e.onError}}async function tt(e,t){try{await e.handle(t.message,t),await t.ack();}catch(r){let o=t.attempt>=Math.max(1,Math.floor(e.maxAttempts??5));await t.nack({dead:o,reason:r instanceof Error?r.message:String(r)}),e.onError?.(r,t);}}function rt(e){let t=Math.max(1,Math.floor(e.pollIntervalMs??250)),r=Math.max(1,Math.floor(e.visibilityMs??6e4)),o=Math.max(1,Math.floor(e.concurrency??1)),n=false,s=false;async function d(){if(!(n||s)){s=true;try{let x=await e.lease({max:o,visibilityMs:r});for(let u of x)await tt(e,u);}finally{s=false;}}}let g=setInterval(()=>{d();},t);return typeof g.unref=="function"&&g.unref(),d(),()=>{n=true,clearInterval(g);}}async function Kt(e){let t=Math.max(1,Math.floor(e.visibilityMs??6e4)),r=Math.max(1,Math.floor(e.concurrency??1)),o=await e.lease({max:r,visibilityMs:t});for(let n of o)await tt(e,n);return o.length}async function ge(e,t){let r=Math.max(1,Math.floor(t?.maxPasses??256)),o=0;for(let n=0;n<r;n+=1){let s=await Kt(e);if(o+=s,s<=0)return o}throw new Error(`drainQueueLaneToIdle exceeded ${r} passes for lane "${e.id}"`)}function Wt(e){let r=(Array.isArray(e)?e:e.lanes).map(o=>rt(o));return ()=>{for(let o of r)o();}}var Vt=createRequire(import.meta.url);function Ut(e){return typeof e=="object"?e:b(e)}function ot(e){let t=v.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=v.dirname(Vt.resolve("yaml-flow/package.json")),o=t.replace(/\.[^.]+$/,""),n=v.join(r,"cli","bundled",`${o}.mjs`);if(a.existsSync(n))return n;let s=v.join(r,"cli","node",t);if(a.existsSync(s))return s;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function q(e){let t=Ut(e);return t.kind==="yaml-flow-cli"?ot(t.value):t.value}function zt(e,t){let r=q(e);switch(r){case "source-cli-task-executor":{let o=v.join(t,"source-cli-task-executor.js");if(a.existsSync(o))return {command:process.execPath,args:[o]};let n=v.join(t,"source-cli-task-executor.ts"),s=v.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),d=v.join(t,"..","..","node_modules",".bin","tsx"),g=a.existsSync(s)?s:d;return a.existsSync(n)&&a.existsSync(g)?{command:process.execPath,args:[g,n]}:{command:process.execPath,args:[o]}}case "board-live-cards":{let{cmd:o,args:n}=Ye(t,"_",[]);return {command:o,args:n}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Gt(e,t){if(e.howToRun==="built-in"){let{command:o,args:n}=zt(e.whatToRun,t);return {command:o,baseArgs:n}}let r=(typeof e.whatToRun=="object",q(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function me(e,t){return Gt(e,t)}var Ee=new Map;function Yt(e,t){let r=String(e||"").trim();if(!r)throw new Error("registerInProcessExecutionHandler: key is required");Ee.set(r,t);}function Zt(e){let t=String(e||"").trim();t&&Ee.delete(t);}function st(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),o=r[r.length-1];return JSON.parse(o)}}function it(e,t){return {...t,whatToRun:q(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function Ce(e,t,r="invokeExecutionRef"){return a$1(e,t,r)}function at(e,t){if(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data))return {...e,...t||{}};if(e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.status=="string"){let o=e,n=o.status==="success"?"success":o.status==="fail"?"failure":o.status,s=o.data&&typeof o.data=="object"&&!Array.isArray(o.data)?o.data:o.data===void 0?{}:{stdout:o.data};return {result:n,data:s,...typeof o.error=="string"?{error:o.error}:{},...t||{}}}return {result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e},...t||{}}}function N(e){return {result:"failure",data:{error:e}}}function G(e,t,r){let o=r?.label??"invokeExecutionRefSync",n=r?.cliDir??r?.cwd??process.cwd(),s;try{s=Ce(e.argsMassaging,it(e,t),o);}catch(h){let R=h instanceof Error?h.message:String(h);return N(R)}let d;try{d=me(e,n);}catch(h){let R=h instanceof Error?h.message:String(h);return N(`[${o}] ref resolution failed: ${R}`)}let g=[...d.baseArgs,...s.cmdArgs??[]],x=JSON.stringify(s.stdin??t),u=et(),p;try{p=u.executeSync(d.command,g,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:x});}catch(h){let R=h,y=(R.stderr?String(R.stderr):"").trim(),l=typeof R.status=="number"?R.status:"unknown",f=y||R.message;return N(`[${o}] ref exited with status ${l}${f?`: ${f}`:""}`)}try{return at(st(p))}catch{return {result:"success",data:{stdout:p.trim()}}}}async function nt(e,t,r){let o=r?.label??"invokeExecutionRef",n;try{n=Ce(e.argsMassaging,it(e,t),o);}catch(h){let R=h instanceof Error?h.message:String(h);return N(R)}let s=q(e.whatToRun),d=n.headers?{"Content-Type":"application/json",...n.headers}:{"Content-Type":"application/json"},g=n.url??s,x;if(e.howToRun==="http:get"){let h=n.body&&typeof n.body=="object"&&!Array.isArray(n.body)?n.body:t,R=new URLSearchParams(Object.entries(h).filter(([,y])=>y!=null).map(([y,l])=>[y,String(l)]));R.size>0&&(g=`${g}${g.includes("?")?"&":"?"}${R.toString()}`);}else x=JSON.stringify(n.body??t);let u={method:e.howToRun==="http:get"?"GET":"POST",headers:d,body:x},p=0;for(;;)try{let h=await fetch(g,u);if(!h.ok){let f=await h.text().catch(()=>"");return N(`[${o}] HTTP ${h.status}${f?`: ${f}`:""}`)}let R={};h.headers.forEach((f,m)=>{R[m]=f;});let y=new Uint8Array(await h.arrayBuffer());if(y.byteLength===0)return {result:"success",data:{},headers:R};let l=new TextDecoder().decode(y);try{return at(st(l),{headers:R})}catch{return {result:"success",data:{stdout:l},headers:R}}}catch(h){let R=h?.cause,y=R&&typeof R=="object"&&"code"in R?String(R.code||""):"";if((y==="ECONNRESET"||y==="UND_ERR_SOCKET")&&p===0){p+=1;continue}let f=h instanceof Error?h.message:String(h),m=R instanceof Error?`${R.name}: ${R.message}${y?` [${y}]`:""}`:R?String(R):"",S=n.url??s??"",c=`${f}${m?` (cause: ${m})`:""}${S?` url=${S}`:""}`;return N(`[${o}] ${c}`)}}async function Xt(e,t,r){let o=r?.label??"invokeExecutionRef",n=q(e.whatToRun).trim();if(!n)return N(`[${o}] in-process-loop requires a non-empty handler key`);let s=Ee.get(n);if(!s)return N(`[${o}] no in-process handler registered for: ${n}`);try{return await s(e,t,r)}catch(d){let g=d instanceof Error?d.message:String(d);return N(`[${o}] ${g}`)}}var er={"local-node":async(e,t,r)=>G(e,t,r),"local-python":async(e,t,r)=>G(e,t,r),"local-process":async(e,t,r)=>G(e,t,r),"built-in":async(e,t,r)=>G(e,t,r),"http:post":nt,"http:get":nt,"in-process-loop":Xt},tr={"local-node":G,"local-python":G,"local-process":G,"built-in":G};async function re(e,t,r){let o=r?.transports?.[e.howToRun]??er[e.howToRun];return o?o(e,t,r):N(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function je(e,t,r){let o=r?.syncTransports?.[e.howToRun]??tr[e.howToRun];return o?o(e,t,r):N(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function rr(e){return {invoke(t,r){return re(t,r,e)},invokeSync(t,r){return je(t,r,e)}}}function nr(e,t,r){return je(e,t,r)}function Be(e={}){let t=e.resolveRef??(r=>r);return {...e.executorTimeouts?{executorTimeouts:e.executorTimeouts}:{},async invokeExecutor(r,o,n){let s=t(r);if(s.howToRun==="queue-storage")throw new Error("queue-storage does not support inline executor request/response");if(s.howToRun==="http:post"||s.howToRun==="in-process-loop"){let p=await h(s,{subcommand:o,...n?.input!==void 0?{input:n.input}:{}});return typeof p=="string"?p:p&&typeof p=="object"&&!Array.isArray(p)&&typeof p.stdout=="string"?String(p.stdout):JSON.stringify(p??{})}if(s.howToRun==="http:get"){let p=await re(s,{subcommand:o,...n?.input!==void 0?{input:n.input}:{},...s.extra?{extra:s.extra}:{}},{cwd:process.cwd(),timeoutMs:n?.timeout??3e4,label:`invokeExecutor:${o}`});if(p.result!=="success"){let h=typeof p.data?.error=="string"?p.data.error:p.error;throw new Error(h||`executor request failed: ${p.result}`)}return typeof p.data?.stdout=="string"?p.data.stdout:JSON.stringify(p.data??{})}if(!e.resolveCliDir)throw new Error(`createNonCoreExecutorDispatcher: ref.howToRun="${s.howToRun}" requires opts.resolveCliDir`);let{command:d,baseArgs:g}=me(s,e.resolveCliDir()),x=s.extra?["--extra",Buffer.from(JSON.stringify(s.extra)).toString("base64")]:[],u=[...g,o,...x];return await new Promise((p,h)=>{let R=spawn(d,u,{cwd:process.cwd(),stdio:"pipe",windowsHide:true,shell:process.platform==="win32"&&/\.(cmd|bat)$/i.test(d)}),y=[],l=[],f=false,m=null,S=i=>{f||(f=true,m&&clearTimeout(m),h(i));},c=i=>{f||(f=true,m&&clearTimeout(m),p(i));};R.stdout.on("data",i=>{y.push(Buffer.from(i));}),R.stderr.on("data",i=>{l.push(Buffer.from(i));}),R.on("error",i=>{let k=i;k.stdout=Buffer.concat(y).toString("utf-8"),k.stderr=Buffer.concat(l).toString("utf-8"),S(k);}),R.on("close",i=>{let k=Buffer.concat(y).toString("utf-8"),w=Buffer.concat(l).toString("utf-8");if(i===0){c(k);return}let b=new Error(w.trim()||`executor exited with status ${i}`);b.stdout=k,b.stderr=w,S(b);}),n?.timeout&&n.timeout>0&&(m=setTimeout(()=>{R.kill();let i=new Error(`executor timed out after ${n.timeout}ms`);i.stdout=Buffer.concat(y).toString("utf-8"),i.stderr=Buffer.concat(l).toString("utf-8"),S(i);},n.timeout)),n?.input!==void 0?R.stdin.end(n.input):R.stdin.end();})}}}function $(e,t){if(process.platform!=="win32"){a.renameSync(e,t);return}let r=[10,20,40,80,160];for(let o=0;o<=r.length;o++)try{a.renameSync(e,t);return}catch(n){let s=n.code;if((s==="EPERM"||s==="EBUSY")&&o<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[o]);continue}throw n}}function Y(e){function t(n){return v.join(e,...n.split("/"))}function r(n){return v.relative(e,n).replace(/\\/g,"/")}function o(n,s){if(a.existsSync(n))for(let d of a.readdirSync(n,{withFileTypes:true})){let g=v.join(n,d.name);if(d.isDirectory()){o(g,s);continue}d.isFile()&&s.push(r(g));}}return {read(n){let s=t(n);if(!a.existsSync(s))return null;try{return a.readFileSync(s,"utf-8")}catch{return null}},write(n,s){let d=t(n),g=`${d}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(d),{recursive:true}),a.writeFileSync(g,s,"utf-8"),$(g,d);},exists(n){return a.existsSync(t(n))},remove(n){let s=t(n);try{a.existsSync(s)&&a.unlinkSync(s);}catch{}},readBytes(n){let s=t(n);if(!a.existsSync(s))return null;try{return new Uint8Array(a.readFileSync(s))}catch{return null}},writeBytes(n,s){let d=t(n),g=`${d}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(d),{recursive:true}),a.writeFileSync(g,Buffer.from(s)),$(g,d);},listKeys(n){let s=[];o(e,s);let d=s.sort();return n?d.filter(g=>g.startsWith(n)):d},stat(n){let s=t(n);if(!a.existsSync(s))return null;try{let d=a.statSync(s);return {key:n,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},keyRef(n){return {kind:"fs-path",value:t(n)}},renameKey(n,s){let d=t(n);if(!a.existsSync(d))return false;let g=t(s);return a.mkdirSync(v.dirname(g),{recursive:true}),$(d,g),true}}}function $e(){return {read(e){if(!a.existsSync(e))return null;try{return a.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,t,"utf-8"),$(r,e);},exists(e){return a.existsSync(e)},remove(e){try{a.existsSync(e)&&a.unlinkSync(e);}catch{}},readBytes(e){if(!a.existsSync(e))return null;try{return new Uint8Array(a.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,Buffer.from(t)),$(r,e);},stat(e){if(!a.existsSync(e))return null;try{let t=a.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []},renameKey(e,t){return a.existsSync(e)?(a.mkdirSync(v.dirname(t),{recursive:true}),$(e,t),true):false}}}function H(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(e),{recursive:true}),a.writeFileSync(r,JSON.stringify(t,null,2),"utf-8"),$(r,e);}function Q(e){if(!a.existsSync(e))return null;try{return JSON.parse(a.readFileSync(e,"utf-8"))}catch{return null}}function ne(e){return a.existsSync(e)?a.readdirSync(e).filter(t=>t.endsWith(".json")).sort().map(t=>v.join(e,t)):[]}function oe(e){return {id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}}function ar(e){return {...oe(e),leaseToken:String(e.leaseToken||""),leaseExpiresAt:String(e.leaseExpiresAt||"")}}function cr(e){return {...oe(e),reason:e.reason}}function Me(e){let t=v.join(e,"active"),r=v.join(e,"leased"),o=v.join(e,"done"),n=v.join(e,"dead"),s=v.join(e,"staged");for(let l of [t,r,o,n,s])a.mkdirSync(l,{recursive:true});let d=0;function g(l){let f=l.replace(/[:.]/g,"-"),m=String(d++).padStart(6,"0");return `${f}-${m}`}function x(l){let f=l.activeOrderKey||g(String(l.enqueuedAt||new Date().toISOString()));return v.join(t,`${f}-${l.id}.json`)}function u(l){return v.join(r,`${l}.json`)}function p(l){return v.join(o,`${l}.json`)}function h(l){return v.join(n,`${l}.json`)}function R(l){return v.join(s,`${l}.json`)}function y(){let l=Date.now();for(let f of ne(r)){let m=Q(f);if(!m?.leaseExpiresAt)continue;let S=Date.parse(m.leaseExpiresAt);if(Number.isNaN(S)||S>l)continue;let c={id:m.id,body:m.body,enqueuedAt:m.enqueuedAt,attempt:m.attempt,activeOrderKey:m.activeOrderKey};H(x(c),c);try{a.unlinkSync(f);}catch{}}}return {enqueue(l){let f={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0};return f.activeOrderKey=g(f.enqueuedAt),H(x(f),f),oe(f)},enqueueMany(l){return l.map(f=>this.enqueue(f))},enqueueIfAbsent(l,f){y();for(let S of [t,r,s])for(let c of ne(S))if(Q(c)?.dedupKey===f)return null;let m={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:f};return m.activeOrderKey=g(m.enqueuedAt),H(x(m),m),oe(m)},lease(l){y();let f=Math.max(1,Math.floor(l?.max??1)),m=Math.max(1,Math.floor(l?.visibilityMs??6e4)),S=[];for(let c of ne(t)){if(S.length>=f)break;let i=Q(c);if(!i)continue;let k=u(i.id);try{$(c,k);}catch{continue}let w={...i,attempt:(Number(i.attempt)||0)+1,leaseToken:randomUUID(),leaseExpiresAt:new Date(Date.now()+m).toISOString()};H(k,w),S.push(ar(w));}return S},ack(l,f){let m=u(l),S=Q(m);if(!S||S.leaseToken!==f)return false;try{$(m,p(l));}catch{return false}return true},nack(l,f,m){let S=u(l),c=Q(S);if(!c||c.leaseToken!==f)return false;let i={id:c.id,body:c.body,enqueuedAt:c.enqueuedAt,attempt:c.attempt,activeOrderKey:c.activeOrderKey};m?.dead?(i.reason=m.reason,H(h(l),i)):H(x(i),i);try{a.unlinkSync(S);}catch{}return true},peekActive(l){return y(),ne(t).map(f=>Q(f)).filter(f=>!!f).map(oe)},peekDeadLetter(l){return ne(n).map(f=>Q(f)).filter(f=>!!f).map(cr)},stage(l,f){let m=f?.dedupKey;if(m){y();for(let c of [t,r,s])for(let i of ne(c))if(Q(i)?.dedupKey===m)return null}let S={id:randomUUID(),body:l,enqueuedAt:new Date().toISOString(),attempt:0,...m?{dedupKey:m}:{}};return H(R(S.id),S),oe(S)},commitStaged(l){let f=R(l),m=Q(f);if(!m)return false;let S=new Date().toISOString(),c={...m,attempt:0,enqueuedAt:S,activeOrderKey:g(S)};H(x(c),c);try{a.unlinkSync(f);}catch{}return true},discardStaged(l,f){let m=R(l),S=Q(m);if(!S)return false;let c={id:S.id,body:S.body,enqueuedAt:S.enqueuedAt,attempt:S.attempt,reason:f};H(h(l),c);try{a.unlinkSync(m);}catch{}return true},peekStaged(l){return ne(s).map(f=>Q(f)).filter(f=>!!f).map(oe)}}}var Ie="__scratch-marker",Pe="__scratch-config.json",ur=1440*60*1e3,dr=720*60*1e3,lr=500;function ct(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function ce(e){a.mkdirSync(e,{recursive:true});let t=v.join(e,Ie),r=v.join(e,Pe),o=!a.existsSync(t);if(o)try{a.writeFileSync(t,`scratch-store
|
|
4
4
|
${new Date().toISOString()}
|
|
5
|
-
`,"utf-8");}catch{}function n(){if(!a.existsSync(r))return {};try{let u=a.readFileSync(r,"utf-8"),p=JSON.parse(u);return p&&typeof p=="object"&&!Array.isArray(p)?p:{}}catch{return {}}}function s(u){let p=`${r}.${process.pid}.${randomUUID()}.tmp`;try{a.writeFileSync(p,JSON.stringify(u,null,2),"utf-8"),$(p,r);}catch{}}if(o){let u=n();typeof u["retention.lastSweepAt"]!="number"&&(u["retention.lastSweepAt"]=Date.now(),s(u));}function d(){if(!a.existsSync(t))return;let u=n(),p=typeof u["retention.maxAgeMs"]=="number"?u["retention.maxAgeMs"]:
|
|
5
|
+
`,"utf-8");}catch{}function n(){if(!a.existsSync(r))return {};try{let u=a.readFileSync(r,"utf-8"),p=JSON.parse(u);return p&&typeof p=="object"&&!Array.isArray(p)?p:{}}catch{return {}}}function s(u){let p=`${r}.${process.pid}.${randomUUID()}.tmp`;try{a.writeFileSync(p,JSON.stringify(u,null,2),"utf-8"),$(p,r);}catch{}}if(o){let u=n();typeof u["retention.lastSweepAt"]!="number"&&(u["retention.lastSweepAt"]=Date.now(),s(u));}function d(){if(!a.existsSync(t))return;let u=n(),p=typeof u["retention.maxAgeMs"]=="number"?u["retention.maxAgeMs"]:ur,h=typeof u["retention.sweepIntervalMs"]=="number"?u["retention.sweepIntervalMs"]:dr;if(p<=0||h<=0)return;let R=typeof u["retention.lastSweepAt"]=="number"?u["retention.lastSweepAt"]:0,y=Date.now();if(y-R<h)return;u["retention.lastSweepAt"]=y,s(u);let l=y;try{let f=a.readdirSync(e,{withFileTypes:!0});for(let m of f){if(Date.now()-l>lr)break;if(!m.isFile()||m.name===Ie||m.name===Pe)continue;let S=v.join(e,m.name);try{let c=a.statSync(S);if(y-c.mtimeMs>p)try{a.unlinkSync(S);}catch{}}catch{}}}catch{}}function g(u,p){let h=ct(u,"scratch"),R=ct(p,".json"),y=R.startsWith(".")?R:`.${R}`,l=`${h}-${Date.now()}-${randomUUID().slice(0,8)}${y}`;return v.join(e,l)}function x(u,p){let h=`${u}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(u),{recursive:true}),a.writeFileSync(h,p,"utf-8"),$(h,u);}return {read(u){if(!a.existsSync(u))return null;try{return a.readFileSync(u,"utf-8")}catch{return null}},write(u,p){x(u,p);try{d();}catch{}},exists(u){return a.existsSync(u)},remove(u){try{a.existsSync(u)&&a.unlinkSync(u);}catch{}},readBytes(u){if(!a.existsSync(u))return null;try{return new Uint8Array(a.readFileSync(u))}catch{return null}},writeBytes(u,p){let h=`${u}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(u),{recursive:true}),a.writeFileSync(h,Buffer.from(p)),$(h,u);try{d();}catch{}},stat(u){if(!a.existsSync(u))return null;try{let p=a.statSync(u);return {key:u,size:Number(p.size||0),updatedAt:new Date(p.mtimeMs).toISOString()}}catch{return null}},listKeys(u){try{let p=a.readdirSync(e,{withFileTypes:!0}),h=[];for(let R of p){if(!R.isFile()||R.name===Ie||R.name===Pe)continue;let y=v.join(e,R.name);(!u||y.startsWith(u))&&h.push(y);}return h.sort()}catch{return []}},getUniqueKey(u,p){return g(u,p)},create(u,p,h){let R=g(p,h);x(R,u);try{d();}catch{}return R},keyRef(u){return {kind:"fs-path",value:u}},renameKey(u,p){return a.existsSync(u)?(a.mkdirSync(v.dirname(p),{recursive:true}),$(u,p),true):false},config:{get(u){return n()[u]??null},set(u,p){let h=n();p==null?delete h[u]:h[u]=p,s(h);}}}}var fr="__archive-marker",pr="__archive-config.json",ye="streams",he="blobs",gr=500;function ut(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function Re(e){a.mkdirSync(e,{recursive:true}),a.mkdirSync(v.join(e,ye),{recursive:true}),a.mkdirSync(v.join(e,he),{recursive:true});let t=v.join(e,fr),r=v.join(e,pr);if(!a.existsSync(t))try{a.writeFileSync(t,`archive-store
|
|
6
6
|
${new Date().toISOString()}
|
|
7
|
-
`,"utf-8");}catch{}function o(){if(!a.existsSync(r))return {};try{let d=a.readFileSync(r,"utf-8"),g=JSON.parse(d);return g&&typeof g=="object"&&!Array.isArray(g)?g:{}}catch{return {}}}function n(d){let g=`${r}.${process.pid}.${randomUUID()}.tmp`;try{a.writeFileSync(g,JSON.stringify(d,null,2),"utf-8"),$(g,r);}catch{}}function s(){if(!a.existsSync(t))return;let d=o(),g=typeof d["retention.maxAgeMs"]=="number"?d["retention.maxAgeMs"]:0,x=typeof d["retention.sweepIntervalMs"]=="number"?d["retention.sweepIntervalMs"]:0;if(g<=0||x<=0)return;let u=typeof d["retention.lastSweepAt"]=="number"?d["retention.lastSweepAt"]:0,p=Date.now();if(p-u<x)return;d["retention.lastSweepAt"]=p,n(d);let h=p,R=y=>{let l;try{l=a.readdirSync(y,{withFileTypes:!0});}catch{return}for(let f of l){if(Date.now()-h>
|
|
7
|
+
`,"utf-8");}catch{}function o(){if(!a.existsSync(r))return {};try{let d=a.readFileSync(r,"utf-8"),g=JSON.parse(d);return g&&typeof g=="object"&&!Array.isArray(g)?g:{}}catch{return {}}}function n(d){let g=`${r}.${process.pid}.${randomUUID()}.tmp`;try{a.writeFileSync(g,JSON.stringify(d,null,2),"utf-8"),$(g,r);}catch{}}function s(){if(!a.existsSync(t))return;let d=o(),g=typeof d["retention.maxAgeMs"]=="number"?d["retention.maxAgeMs"]:0,x=typeof d["retention.sweepIntervalMs"]=="number"?d["retention.sweepIntervalMs"]:0;if(g<=0||x<=0)return;let u=typeof d["retention.lastSweepAt"]=="number"?d["retention.lastSweepAt"]:0,p=Date.now();if(p-u<x)return;d["retention.lastSweepAt"]=p,n(d);let h=p,R=y=>{let l;try{l=a.readdirSync(y,{withFileTypes:!0});}catch{return}for(let f of l){if(Date.now()-h>gr)return;let m=v.join(y,f.name);if(f.isDirectory()){R(m);continue}if(f.isFile())try{let S=a.statSync(m);if(p-S.mtimeMs>g)try{a.unlinkSync(m);}catch{}}catch{}}};R(v.join(e,ye)),R(v.join(e,he));}return {stream(d){let g=ut(d),x=v.join(e,ye,`${g}.jsonl`),u=Se(x);return {append(p){let h=u.append(p);try{s();}catch{}return h},readAll:()=>u.readAll(),readAfter:p=>u.readAfter(p),clear:()=>{u.clear&&u.clear();}}},blob(d){let g=ut(d),x=v.join(e,he,g);a.mkdirSync(x,{recursive:true});let u=Y(x);return {read:p=>u.read(p),write:(p,h)=>{u.write(p,h);try{s();}catch{}},exists:p=>u.exists(p),remove:p=>u.remove(p),readBytes:u.readBytes?p=>u.readBytes(p):void 0,writeBytes:u.writeBytes?(p,h)=>{u.writeBytes(p,h);try{s();}catch{}}:void 0,listKeys:p=>u.listKeys(p),stat:u.stat?p=>u.stat(p):void 0,renameKey:(p,h)=>u.renameKey(p,h)}},listStreams(d){let g=v.join(e,ye);try{return a.readdirSync(g,{withFileTypes:!0}).filter(x=>x.isFile()&&x.name.endsWith(".jsonl")).map(x=>x.name.slice(0,-6)).filter(x=>!d||x.startsWith(d)).sort()}catch{return []}},listBlobs(d){let g=v.join(e,he);try{return a.readdirSync(g,{withFileTypes:!0}).filter(x=>x.isDirectory()).map(x=>x.name).filter(x=>!d||x.startsWith(d)).sort()}catch{return []}},config:{get(d){return o()[d]??null},set(d,g){let x=o();g==null?delete x[d]:x[d]=g,n(x);}}}}function ue(e){function t(o){return v.join(e,...o.split("/"))+".json"}function r(o,n,s,d){if(a.existsSync(o))for(let g of a.readdirSync(o,{withFileTypes:true})){let x=n?`${n}/${g.name}`:g.name;if(g.isDirectory()){r(v.join(o,g.name),x,s,d);continue}if(!g.isFile()||!g.name.endsWith(".json"))continue;let u=x.replace(/\.json$/,"");(!s||u.startsWith(s))&&d.push(u);}}return {read(o){let n=t(o);if(!a.existsSync(n))return null;try{return JSON.parse(a.readFileSync(n,"utf-8"))}catch{return null}},write(o,n){let s=t(o),d=`${s}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(v.dirname(s),{recursive:true}),a.writeFileSync(d,JSON.stringify(n,null,2),"utf-8"),$(d,s);},delete(o){let n=t(o);try{a.existsSync(n)&&a.unlinkSync(n);}catch{}},listKeys(o){let n=[];return r(e,"",o,n),n.sort()}}}function Se(e){function t(){if(!a.existsSync(e))return [];let r=a.readFileSync(e,"utf-8").trim();return r?r.split(`
|
|
8
8
|
`).filter(Boolean).map(o=>JSON.parse(o)):[]}return {append(r){let o={id:randomUUID(),payload:r};return a.mkdirSync(v.dirname(e),{recursive:true}),a.appendFileSync(e,JSON.stringify(o)+`
|
|
9
|
-
`,"utf-8"),o},readAll(){return t()},readAfter(r){let o=t();if(!r)return {entries:o,newCursor:o.length>0?o[o.length-1].id:null};let n=o.findIndex(d=>d.id===r),s=n===-1?o:o.slice(n+1);return {entries:s,newCursor:s.length>0?s[s.length-1].id:r}},clear(){a.existsSync(e)&&a.truncateSync(e,0);}}}function
|
|
9
|
+
`,"utf-8"),o},readAll(){return t()},readAfter(r){let o=t();if(!r)return {entries:o,newCursor:o.length>0?o[o.length-1].id:null};let n=o.findIndex(d=>d.id===r),s=n===-1?o:o.slice(n+1);return {entries:s,newCursor:s.length>0?s[s.length-1].id:r}},clear(){a.existsSync(e)&&a.truncateSync(e,0);}}}function Fe(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(Fe).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(o=>`${JSON.stringify(o)}:${Fe(t[o])}`).join(",")}}`}function dt(e){return createHash("sha256").update(Fe(e)).digest("hex")}function Oe(e){let t=v.join(e,"board-journal.jsonl");return {readAllEntries(){if(!a.existsSync(t))return [];let r=a.readFileSync(t,"utf-8").trim();return r?r.split(`
|
|
10
10
|
`).filter(Boolean).map(o=>JSON.parse(o)):[]},appendEntry(r){a.appendFileSync(t,JSON.stringify(r)+`
|
|
11
|
-
`,"utf-8");},generateId(){return randomUUID()}}}function ut(e){return {tryAcquire(){try{if(!a.existsSync(e)){a.mkdirSync(v.dirname(e),{recursive:!0});try{a.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}function dt(e,t){if(e?.kind!=="fs-path"||typeof e.value!="string"||!e.value.trim())throw new Error(`${t} must be an fs-path ref`);return v__default.normalize(e.value)}function Re(e){a__default.existsSync(e)||a__default.mkdirSync(e,{recursive:true});}function pr(e=new Date){let t=r=>String(r).padStart(2,"0");return `${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function lt(e){return a__default.existsSync(e)?JSON.parse(a__default.readFileSync(e,"utf8")):null}function gr(e){let t=e.registry??{},r=dt(t.boardsIndexRef,"registry.boardsIndexRef"),o=dt(t.boardsLayoutRef,"registry.boardsLayoutRef"),n=t.deprecatedContainerRef?.kind==="fs-path"&&typeof t.deprecatedContainerRef.value=="string"&&t.deprecatedContainerRef.value.trim()?v__default.normalize(t.deprecatedContainerRef.value):"";function s(i){return v__default.join(r,`${i}.json`)}function d(i){return v__default.join(o,`${i}.json`)}function g(i){Re(n);let k=pr(),w="",b=1;for(;;){let A=`${i}-${k}${w}`,C=v__default.join(n,`${A}.json`),E=v__default.join(n,`${A}.layout.json`),j=v__default.join(n,A);if(!a__default.existsSync(C)&&!a__default.existsSync(E)&&!a__default.existsSync(j))return {archiveBase:A,archiveRecordPath:C,archiveLayoutPath:E,archiveWorkspaceDir:j};b+=1,w=`-${b}`;}}function x(i,k){if(!i||!a__default.existsSync(i))return "";let w=10;for(let b=1;b<=w;b+=1)try{return a__default.renameSync(i,k),k}catch(A){let C=A&&typeof A=="object"&&"code"in A?String(A.code??""):"";if(!(C==="EPERM"||C==="EBUSY"||C==="EACCES"||C==="ENOTEMPTY")||b===w)return "";}return ""}async function u(){if(!a__default.existsSync(r))return [];let i=[];for(let k of a__default.readdirSync(r)){if(!k.endsWith(".json"))continue;let w=k.slice(0,-5),b=JSON.parse(a__default.readFileSync(v__default.join(r,k),"utf8"));i.push({id:w,record:b});}return i}async function p(i){return lt(s(i))}async function h(i){return a__default.existsSync(s(i))}async function R(i,k){Re(r),a__default.writeFileSync(s(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"wx"});}async function y(i,k){Re(r),a__default.writeFileSync(s(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"w"});}async function l(i){return lt(d(i))}async function f(i,k){Re(o),a__default.writeFileSync(d(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"w"});}async function m(i){let k=d(i);a__default.existsSync(k)&&a__default.unlinkSync(k);}async function S(i,k,w={}){if(await R(i,k),w.layout==null){await m(i);return}await f(i,w.layout);}async function c(i,k={}){let w=s(i),b=d(i);if(!a__default.existsSync(w))return null;let A=typeof k.workspaceDir=="string"&&k.workspaceDir.trim()?v__default.normalize(k.workspaceDir):"";if(!n){if(a__default.rmSync(w,{force:true}),a__default.existsSync(b)&&a__default.rmSync(b,{force:true}),A&&a__default.existsSync(A))try{a__default.rmSync(A,{recursive:!0,force:!0});}catch{}return {archiveId:"",archiveRecordPath:"",archiveWorkspaceDir:"",archiveLayoutPath:""}}let{archiveBase:C,archiveRecordPath:E,archiveLayoutPath:j,archiveWorkspaceDir:J}=g(i);a__default.renameSync(w,E),a__default.existsSync(b)&&a__default.renameSync(b,j);let V=x(A,J);return {archiveId:C,archiveRecordPath:E,archiveWorkspaceDir:V,archiveLayoutPath:a__default.existsSync(j)?j:""}}return {kind:"fs-board-container",list:u,get:p,has:h,put:R,set:y,getLayout:l,setLayout:f,removeLayout:m,provision:S,archive:c}}function Z(e){return {status:"success",data:e}}function D(e){return {status:"fail",error:e}}function oe(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function mr(e,t={}){let r=()=>b$1(e.kvStorage("config")),o=t.unsupportedLabel??"hosted async runtime";async function n(){return t.taskExecutorRef?t.taskExecutorRef:await r().readTaskExecutorRef().catch(()=>{})}async function s(y,l,f){let m=await n();if(!m||!t.invokeExecutor)throw new Error(`${y} is not supported on the ${o} yet`);let c=(await t.invokeExecutor(m,y,{...l!==void 0?{input:typeof l=="string"?l:JSON.stringify(l)}:{},...f!==void 0?{timeout:f}:{}})).trim();return c?se(JSON.parse(c)):{}}async function d(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("validateCardPreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=a$6(f),c=Array.isArray(f.source_defs)&&f.source_defs.length>0,i=[...S.issues];if(c)if(t.invokeExecutor&&await n())for(let k of f.source_defs){let w=typeof k.bindTo=="string"?k.bindTo:"(unknown)";try{let b=await s("validate-source-def",k,1e4);if(b.ok!==!0&&Array.isArray(b.errors))for(let A of b.errors)typeof A=="string"&&A&&i.push(`source "${w}": ${A}`);}catch(b){i.push(`source "${w}": executor validate-source-def failed \u2014 ${b instanceof Error?b.message:String(b)}`);}}else await n()&&i.push(`executor-backed source_def preflight is not supported on the ${o} yet`);return Z({cardId:m,isValid:i.length===0,issues:i})}catch(l){return oe(l)}}function g(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("evalCardCompute requires a JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=l["mock-fetched-sources"]??{},c=l["mock-requires"]??{},i=f.compute;if(!i||!Array.isArray(i)||i.length===0)return Z({cardId:m,ok:!0,computed_values:{},errors:[]});let k={id:m,card_data:f.card_data??{},requires:c,source_defs:f.source_defs,compute:i},w=a$7.runSync(k,{sourcesData:S});return Z({cardId:m,ok:(w.errors??[]).length===0,computed_values:w.node.computed_values??{},errors:w.errors??[]})}catch(l){return oe(l)}}async function x(y){return D(`${y} is not supported on the ${o} yet`)}async function u(){try{return t.invokeExecutor&&await n()?Z(await s("describe-capabilities",void 0,1e4)):await x("describeTaskExecutorCapabilities")}catch(y){return oe(y)}}async function p(y){try{if(!t.invokeExecutor||!await n())return await x("probeSourcePreflight");if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("probeSourcePreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=se(l["mock-projections"]??{}),S=y.params?.sourceIdx,c=Array.isArray(f.source_defs)?f.source_defs:[];if(S===void 0)return D("probeSourcePreflight requires params.sourceIdx");if(S<0||S>=c.length)return D(`sourceIdx ${S} out of range (card has ${c.length} source(s))`);let i=c[S],k=typeof i.bindTo=="string"?i.bindTo:"source",w=await s("probe-source-preflight",{...i,_projections:m},i.timeout??6e4);return w.ok!==!0?D(typeof w.error=="string"?w.error:"Preflight probe failed"):Z({bindTo:k,reachable:w.reachable,latencyMs:w.latencyMs,...typeof w.note=="string"?{note:w.note}:{}})}catch(l){return oe(l)}}async function h(y){try{if(!t.invokeExecutor||!await n())return await x("runSourcePreflight");if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("runSourcePreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=se(l["mock-projections"]??{}),S=y.params?.sourceIdx,c=Array.isArray(f.source_defs)?f.source_defs:[];if(S===void 0)return D("runSourcePreflight requires params.sourceIdx");if(S<0||S>=c.length)return D(`sourceIdx ${S} out of range (card has ${c.length} source(s))`);let i=c[S],k=typeof i.bindTo=="string"?i.bindTo:"source",w=await s("run-source-preflight",{...i,_projections:m},i.timeout??6e4);return w.ok!==!0?Z({bindTo:k,ok:!1,result:null,issues:[typeof w.error=="string"?w.error:"Preflight run failed"]}):Z({bindTo:k,ok:!0,result:Object.prototype.hasOwnProperty.call(w,"resultValue")?w.resultValue:null,issues:[]})}catch(l){return oe(l)}}async function R(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("simulateCardCycle requires a JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=se(l["mock-fetched-sources"]??{}),c=se(l["mock-requires"]??{}),i=await d({body:{"card-content":f}}),k=i.status==="success"?{isValid:i.data.isValid,issues:i.data.issues}:{isValid:!1,issues:[i.status==="fail"?i.error:"internal error"]},w=Array.isArray(f.source_defs)?f.source_defs:[],b=se(f.card_data??{}),A=[],C=[];if(w.length>0){A=a$7.enrichSourcesSync(w,{card_data:b,requires:c});for(let P of A){let M=P.projections,U=P._projections;if(M&&U){for(let O of Object.keys(M))if(U[O]===void 0){let gt=typeof P.bindTo=="string"?P.bindTo:"(unknown)";C.push({bindTo:gt,key:O,error:`Projection "${O}" resolved to undefined`});}}}}let E=[],j={...S};for(let P=0;P<A.length;P+=1){let M=A[P],U=typeof M.bindTo=="string"?M.bindTo:`source_${P}`;if(!t.invokeExecutor||!await n()){E.push({bindTo:U,skipped:!0,error:"No task executor configured"});continue}try{let O=await s("run-source-preflight",M,M.timeout??6e4);O.ok===!0&&!Object.prototype.hasOwnProperty.call(S,U)&&Object.prototype.hasOwnProperty.call(O,"resultValue")&&(j[U]=O.resultValue),E.push({bindTo:U,reachable:O.reachable,latencyMs:O.latencyMs,...O.ok===!0?{}:{error:typeof O.error=="string"?O.error:"Preflight run failed"}});}catch{E.push({bindTo:U,skipped:!0,error:"Executor does not support run-source-preflight"});}}let J=f.compute,V={},X=[];if(J&&Array.isArray(J)&&J.length>0){let P={id:m,card_data:b,requires:c,source_defs:f.source_defs,compute:J},M=a$7.runSync(P,{sourcesData:j});V=M.node.computed_values??{},X=M.errors??[];}return Z({cardId:m,ok:k.isValid&&C.length===0&&X.length===0&&E.every(P=>!P.error),validation:k,source_probes:E,projection_errors:C,fetched_sources:j,computed_values:V,compute_errors:X})}catch(l){return oe(l)}}return {describeTaskExecutorCapabilities:u,validateCardPreflight:d,evalCardCompute:g,probeSourcePreflight:p,runSourcePreflight:h,simulateCardCycle:R}}function hn(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let s=e.whatToRun;r=q(s);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let o={...t},n=Buffer.from(JSON.stringify(o)).toString("base64");try{return spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",n],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(s){return {dispatched:false,error:s instanceof Error?s.message:String(s)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=q(r);}catch{t="";}if(!t)return null;try{let r=spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var Rr=".board.lock";function ft(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function Sr(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function xr(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function pt(e){if(e)return e;let t=We(import.meta.url),r=[t,I(t,"..","cli","node"),I(t,"..","..","cli","node")];for(let o of r)try{return Ge(o),o}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function wr(e$1,t,r){let{cliDir:o,opts:n}=Sr(t,r),s=e$1.value,d$1=null,g,x=null,u;function p(){return u||(u=pt(o)),u}function h(c){let i=n?.queueStoreRef;if(!i)throw new Error(`createFsBoardPlatformAdapter: ${c} requires opts.queueStoreRef`);return i}function R(c){let i=n?.boardRuntimeStoreRef;if(!i)throw new Error(`createFsBoardPlatformAdapter: ${c} requires opts.boardRuntimeStoreRef`);return i}let y=n?.callbackTransport??d({notifyChannel:n?.notifyChannel,boardRuntimeStoreRef:n?.boardRuntimeStoreRef,queueStoreRef:n?.queueStoreRef}),l;function f(c){return l.queueStorageForRef(h(`internal lane "${c}"`),c)}function m(c){return a$5(f(c))}function S(){if(n?.suppressSpawn||d$1)return;let c=be({id:"task-executor",workerStore:m("task-executor"),handleRequest:async(i,k)=>{let w=await te(k.ref,k.args,{cliDir:p(),cwd:process.cwd(),label:"fsBoardAdapter.boardWorker"});if(w.result!=="success"){let b=typeof w.data?.error=="string"?w.data.error:w.error;throw new Error(b||w.result)}}});d$1=fe(c).catch(i=>{n?.onWarn?.(`[board-worker] in-process queue drain failed: ${i instanceof Error?i.message:String(i)}`);}).finally(()=>{d$1=null,f("task-executor").peekActive().length>0&&S();});}return l={kvStorage:c=>ae(I(s,`.${c}`)),blobStorage:c=>c?Y(I(s,c)):Y(s),blobStorageForRef:c=>Y(b(c).value),chatStorageForRef:c=>kr(b(c).value),queueStorageForRef:(c,i)=>Fe(I(b(c).value,i)),scratchStorage:()=>ie(I(s,".tmp")),scratchStorageForRef:c=>ie(b(c).value),archiveFactory:()=>ye(I(s,"archive")),archiveFactoryForRef:c=>ye(b(c).value),journalAdapter:()=>$e(s),journalAdapterForRef:c=>$e(b(c).value),lock:ut(I(s,Rr)),callbackTransport:y,async dispatchExecution(c,i){let k=!!i.output?.ref;if(c.howToRun==="queue-storage")try{let b=m("task-executor"),A=typeof c.extra?.boardId=="string"?c.extra.boardId:void 0;if(k)return b.enqueueRequest({boardId:A,ref:c,args:i}),{dispatched:!0};let C=i.source_def?.bindTo??le().slice(0,8),E=ie(I(s,".tmp")),j=E.create(JSON.stringify(i,null,2),`exec-in-${C}`,".json"),J=E.getUniqueKey(`exec-out-${C}`,".json"),V=E.getUniqueKey(`exec-err-${C}`,".txt"),X=a$2(E.keyRef(j)),P=a$2(E.keyRef(J)),M=a$2(E.keyRef(V));return b.enqueueRequest({boardId:A,ref:c,args:{subcommand:"run-source-fetch",inRef:X,outRef:P,errRef:M}}),{dispatched:!0}}catch(b){return {dispatched:false,error:b instanceof Error?b.message:String(b)}}if(k&&(c.howToRun==="http:post"||c.howToRun==="in-process-loop"))try{if(c.howToRun==="http:post"){let C=q(c.whatToRun),E=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,...c.extra?{extra:c.extra}:{}})});if(!E.ok){let j=await E.text().catch(()=>"");return {dispatched:!1,error:`HTTP ${E.status}: ${j}`}}return {dispatched:!0}}let b=await te(c,i,{cwd:process.cwd(),label:"dispatchExecution.directHostedWorker"});return b.result==="success"?{dispatched:!0}:{dispatched:!1,error:(typeof b.data?.error=="string"?b.data.error:b.error)||b.result}}catch(b){return {dispatched:false,error:b instanceof Error?b.message:String(b)}}let w=c.howToRun==="local-node"||c.howToRun==="local-process"||c.howToRun==="local-python"||c.howToRun==="built-in";if(n?.suppressSpawn&&w)return {dispatched:false};try{let b=i.source_def?.bindTo??le().slice(0,8),A=ie(I(s,".tmp")),C=A.create(JSON.stringify(i,null,2),`exec-in-${b}`,".json"),E=A.getUniqueKey(`exec-out-${b}`,".json"),j=A.getUniqueKey(`exec-err-${b}`,".txt"),J=a$2(A.keyRef(C)),V=a$2(A.keyRef(E)),X=a$2(A.keyRef(j)),P=m("task-executor"),M=typeof c.extra?.boardId=="string"?c.extra.boardId:void 0;return P.enqueueRequest({boardId:M,ref:c,args:{subcommand:"run-source-fetch",inRef:J,outRef:V,errRef:X}}),S(),{dispatched:!0}}catch(b){let A=b instanceof Error?b.message:String(b);try{let C=ye(I(s,"archive")),E=new Date().toISOString().replace(/[:.]/g,"-"),j=i.source_def?.bindTo??"unknown";C.blob("exec-failures").write(`${E}-${j}.json`,JSON.stringify({error:A,args:i,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:A}}},supportsDirectSourceOutput(c){return c.howToRun==="queue-storage"||c.howToRun==="http:post"||c.howToRun==="in-process-loop"},resolveBlob(c){let i=Je(c.value)?Pe().read(c.value):Y(s).read(c.value);if(i===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return i},hashFn:ct,genId:()=>Ke(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>ae(b(c).value),requestProcessAccumulated(){if(n?.suppressSpawn||x)return;let c=this,i=g??=e(e$1,c,{boardRuntimeStoreRef:R("requestProcessAccumulated")}),k=ve({id:"process-accumulated",queueStorage:f("process-accumulated"),handleMessage:async()=>{let w=await i.processAccumulatedEvents({});if(w.status!=="success")throw new Error(w.error||`processAccumulatedEvents returned ${w.status}`)}});x=fe(k).catch(w=>{n?.onWarn?.(`[process-accumulated] in-process queue drain failed: ${w instanceof Error?w.message:String(w)}`);}).finally(()=>{x=null,f("process-accumulated").peekActive().length>0&&c.requestProcessAccumulated?.();});},publishBoardChangeNotifications(c){if(!n?.notifyChannel||c.length===0)return;let i=c.map(k=>({id:le(),ts:new Date().toISOString(),boardRef:a$2(e$1),notification:k}));Ye(n.notifyChannel,i,n.onWarn);},onWarn:n?.onWarn},l}function Rn(e,t,r){let{cliDir:o,opts:n}=xr(t,r),s,d=()=>(s||(s=pt(o)),s),g=wr(e,o,n),x=Ce({resolveCliDir:d,...n?.resolveRef?{resolveRef:n.resolveRef}:{}});return {...g,invokeExecutor:x.invokeExecutor,validateSchema(u){let p=d$1(u);return {ok:p.errors.length===0,errors:p.errors}},absoluteBlob:Pe()}}function Sn(e,t={}){let r=t.chatsSubdir??"chats",o=t.kvSubdir??".kv",n=o?[o,"chat"]:["chat"],s=r&&!ft(e,r)?I(e,r):e,d=ae(I(e,...n));return a$3(g=>{let u=`${String(g).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,p=I(s,u);return he(p)},d)}function kr(e){return a$3(t=>{let o=`${String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`;return he(I(e,"journal",o))},ae(I(e,"kv")))}function xn(e,t={}){let r=t.filesSubdir??"files",o=r&&!ft(e,r)?I(e,r):e;return a$4(Y(o))}function wn(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}export{pe as buildLocalBaseSpec,be as createBoardWorkerQueueLane,er as createExecutionRefInvoker,Y as createFsBlobStorage,Sn as createFsBoardChatStorage,gr as createFsBoardContainerStorage,xn as createFsBoardFileArtifactsStore,Rn as createFsBoardNonCorePlatformAdapter,wr as createFsBoardPlatformAdapter,kr as createFsChatStorageForRefRoot,Fe as createFsQueueStorage,mr as createHostedAsyncBoardNonCorePublic,hn as createNodeSpawnInvocationAdapter,Ce as createNonCoreExecutorDispatcher,ve as createQueueStorageLane,wn as decodeBoardRefFromToken,fe as drainQueueLaneToIdle,Te as evaluateArgsMassaging,te as invokeExecutionRef,Ee as invokeExecutionRefSync,tr as invokeRefSync,zt as registerInProcessExecutionHandler,q as resolveWhatToRunValue,rt as resolveYamlFlowCliPath,et as startQueueLaneRunner,Jt as startQueueLaneRunners,Gt as unregisterInProcessExecutionHandler};//# sourceMappingURL=board-live-cards-node.js.map
|
|
11
|
+
`,"utf-8");},generateId(){return randomUUID()}}}function lt(e){return {tryAcquire(){try{if(!a.existsSync(e)){a.mkdirSync(v.dirname(e),{recursive:!0});try{a.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}function ft(e,t){if(e?.kind!=="fs-path"||typeof e.value!="string"||!e.value.trim())throw new Error(`${t} must be an fs-path ref`);return v__default.normalize(e.value)}function xe(e){a__default.existsSync(e)||a__default.mkdirSync(e,{recursive:true});}function mr(e=new Date){let t=r=>String(r).padStart(2,"0");return `${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function pt(e){return a__default.existsSync(e)?JSON.parse(a__default.readFileSync(e,"utf8")):null}function yr(e){let t=e.registry??{},r=ft(t.boardsIndexRef,"registry.boardsIndexRef"),o=ft(t.boardsLayoutRef,"registry.boardsLayoutRef"),n=t.deprecatedContainerRef?.kind==="fs-path"&&typeof t.deprecatedContainerRef.value=="string"&&t.deprecatedContainerRef.value.trim()?v__default.normalize(t.deprecatedContainerRef.value):"";function s(i){return v__default.join(r,`${i}.json`)}function d(i){return v__default.join(o,`${i}.json`)}function g(i){xe(n);let k=mr(),w="",b=1;for(;;){let A=`${i}-${k}${w}`,C=v__default.join(n,`${A}.json`),E=v__default.join(n,`${A}.layout.json`),j=v__default.join(n,A);if(!a__default.existsSync(C)&&!a__default.existsSync(E)&&!a__default.existsSync(j))return {archiveBase:A,archiveRecordPath:C,archiveLayoutPath:E,archiveWorkspaceDir:j};b+=1,w=`-${b}`;}}function x(i,k){if(!i||!a__default.existsSync(i))return "";let w=10;for(let b=1;b<=w;b+=1)try{return a__default.renameSync(i,k),k}catch(A){let C=A&&typeof A=="object"&&"code"in A?String(A.code??""):"";if(!(C==="EPERM"||C==="EBUSY"||C==="EACCES"||C==="ENOTEMPTY")||b===w)return "";}return ""}async function u(){if(!a__default.existsSync(r))return [];let i=[];for(let k of a__default.readdirSync(r)){if(!k.endsWith(".json"))continue;let w=k.slice(0,-5),b=JSON.parse(a__default.readFileSync(v__default.join(r,k),"utf8"));i.push({id:w,record:b});}return i}async function p(i){return pt(s(i))}async function h(i){return a__default.existsSync(s(i))}async function R(i,k){xe(r),a__default.writeFileSync(s(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"wx"});}async function y(i,k){xe(r),a__default.writeFileSync(s(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"w"});}async function l(i){return pt(d(i))}async function f(i,k){xe(o),a__default.writeFileSync(d(i),JSON.stringify(k,null,2),{encoding:"utf8",flag:"w"});}async function m(i){let k=d(i);a__default.existsSync(k)&&a__default.unlinkSync(k);}async function S(i,k,w={}){if(await R(i,k),w.layout==null){await m(i);return}await f(i,w.layout);}async function c(i,k={}){let w=s(i),b=d(i);if(!a__default.existsSync(w))return null;let A=typeof k.workspaceDir=="string"&&k.workspaceDir.trim()?v__default.normalize(k.workspaceDir):"";if(!n){if(a__default.rmSync(w,{force:true}),a__default.existsSync(b)&&a__default.rmSync(b,{force:true}),A&&a__default.existsSync(A))try{a__default.rmSync(A,{recursive:!0,force:!0});}catch{}return {archiveId:"",archiveRecordPath:"",archiveWorkspaceDir:"",archiveLayoutPath:""}}let{archiveBase:C,archiveRecordPath:E,archiveLayoutPath:j,archiveWorkspaceDir:X}=g(i);a__default.renameSync(w,E),a__default.existsSync(b)&&a__default.renameSync(b,j);let K=x(A,X);return {archiveId:C,archiveRecordPath:E,archiveWorkspaceDir:K,archiveLayoutPath:a__default.existsSync(j)?j:""}}return {kind:"fs-board-container",list:u,get:p,has:h,put:R,set:y,getLayout:l,setLayout:f,removeLayout:m,provision:S,archive:c}}function Z(e){return {status:"success",data:e}}function D(e){return {status:"fail",error:e}}function ie(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function ae(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function hr(e,t={}){let r=()=>b$1(e.kvStorage("config")),o=t.unsupportedLabel??"hosted async runtime";async function n(){return t.taskExecutorRef?t.taskExecutorRef:await r().readTaskExecutorRef().catch(()=>{})}async function s(y,l,f){let m=await n();if(!m||!t.invokeExecutor)throw new Error(`${y} is not supported on the ${o} yet`);let c=(await t.invokeExecutor(m,y,{...l!==void 0?{input:typeof l=="string"?l:JSON.stringify(l)}:{},...f!==void 0?{timeout:f}:{}})).trim();return c?ae(JSON.parse(c)):{}}async function d(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("validateCardPreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=a$6(f),c=Array.isArray(f.source_defs)&&f.source_defs.length>0,i=[...S.issues];if(c)if(t.invokeExecutor&&await n())for(let k of f.source_defs){let w=typeof k.bindTo=="string"?k.bindTo:"(unknown)";try{let b=await s("validate-source-def",k,1e4);if(b.ok!==!0&&Array.isArray(b.errors))for(let A of b.errors)typeof A=="string"&&A&&i.push(`source "${w}": ${A}`);}catch(b){i.push(`source "${w}": executor validate-source-def failed \u2014 ${b instanceof Error?b.message:String(b)}`);}}else await n()&&i.push(`executor-backed source_def preflight is not supported on the ${o} yet`);return Z({cardId:m,isValid:i.length===0,issues:i})}catch(l){return ie(l)}}function g(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("evalCardCompute requires a JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=l["mock-fetched-sources"]??{},c=l["mock-requires"]??{},i=f.compute;if(!i||!Array.isArray(i)||i.length===0)return Z({cardId:m,ok:!0,computed_values:{},errors:[]});let k={id:m,card_data:f.card_data??{},requires:c,source_defs:f.source_defs,compute:i},w=a$7.runSync(k,{sourcesData:S});return Z({cardId:m,ok:(w.errors??[]).length===0,computed_values:w.node.computed_values??{},errors:w.errors??[]})}catch(l){return ie(l)}}async function x(y){return D(`${y} is not supported on the ${o} yet`)}async function u(){try{return t.invokeExecutor&&await n()?Z(await s("describe-capabilities",void 0,1e4)):await x("describeTaskExecutorCapabilities")}catch(y){return ie(y)}}async function p(y){try{if(!t.invokeExecutor||!await n())return await x("probeSourcePreflight");if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("probeSourcePreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=ae(l["mock-projections"]??{}),S=y.params?.sourceIdx,c=Array.isArray(f.source_defs)?f.source_defs:[];if(S===void 0)return D("probeSourcePreflight requires params.sourceIdx");if(S<0||S>=c.length)return D(`sourceIdx ${S} out of range (card has ${c.length} source(s))`);let i=c[S],k=typeof i.bindTo=="string"?i.bindTo:"source",w=await s("probe-source-preflight",{...i,_projections:m},i.timeout??6e4);return w.ok!==!0?D(typeof w.error=="string"?w.error:"Preflight probe failed"):Z({bindTo:k,reachable:w.reachable,latencyMs:w.latencyMs,...typeof w.note=="string"?{note:w.note}:{}})}catch(l){return ie(l)}}async function h(y){try{if(!t.invokeExecutor||!await n())return await x("runSourcePreflight");if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("runSourcePreflight requires card JSON object in body");let l=y.body,f=l["card-content"]??l,m=ae(l["mock-projections"]??{}),S=y.params?.sourceIdx,c=Array.isArray(f.source_defs)?f.source_defs:[];if(S===void 0)return D("runSourcePreflight requires params.sourceIdx");if(S<0||S>=c.length)return D(`sourceIdx ${S} out of range (card has ${c.length} source(s))`);let i=c[S],k=typeof i.bindTo=="string"?i.bindTo:"source",w=await s("run-source-preflight",{...i,_projections:m},i.timeout??6e4);return w.ok!==!0?Z({bindTo:k,ok:!1,result:null,issues:[typeof w.error=="string"?w.error:"Preflight run failed"]}):Z({bindTo:k,ok:!0,result:Object.prototype.hasOwnProperty.call(w,"resultValue")?w.resultValue:null,issues:[]})}catch(l){return ie(l)}}async function R(y){try{if(!y.body||typeof y.body!="object"||Array.isArray(y.body))return D("simulateCardCycle requires a JSON object in body");let l=y.body,f=l["card-content"]??l,m=typeof f.id=="string"?f.id:"(unknown)",S=ae(l["mock-fetched-sources"]??{}),c=ae(l["mock-requires"]??{}),i=await d({body:{"card-content":f}}),k=i.status==="success"?{isValid:i.data.isValid,issues:i.data.issues}:{isValid:!1,issues:[i.status==="fail"?i.error:"internal error"]},w=Array.isArray(f.source_defs)?f.source_defs:[],b=ae(f.card_data??{}),A=[],C=[],E=[];if(w.length>0){A=a$7.enrichSourcesSync(w,{card_data:b,requires:c}),C=A.filter(B=>B._skip!==!0);for(let B of C){let O=B.projections,W=B._projections;if(O&&W){for(let M of Object.keys(O))if(W[M]===void 0){let yt=typeof B.bindTo=="string"?B.bindTo:"(unknown)";E.push({bindTo:yt,key:M,error:`Projection "${M}" resolved to undefined`});}}}}let j=[],X=new Set(C.map(B=>typeof B.bindTo=="string"?B.bindTo:"")),K=Object.fromEntries(Object.entries(S).filter(([B])=>X.has(B)));for(let B=0;B<A.length;B+=1){let O=A[B],W=typeof O.bindTo=="string"?O.bindTo:`source_${B}`;if(O._skip===!0){j.push({bindTo:W,skipped:!0});continue}if(!t.invokeExecutor||!await n()){j.push({bindTo:W,skipped:!0,error:"No task executor configured"});continue}try{let M=await s("run-source-preflight",O,O.timeout??6e4);M.ok===!0&&!Object.prototype.hasOwnProperty.call(S,W)&&Object.prototype.hasOwnProperty.call(M,"resultValue")&&(K[W]=M.resultValue),j.push({bindTo:W,reachable:M.reachable,latencyMs:M.latencyMs,...M.ok===!0?{}:{error:typeof M.error=="string"?M.error:"Preflight run failed"}});}catch{j.push({bindTo:W,skipped:!0,error:"Executor does not support run-source-preflight"});}}let U=f.compute,se={},ee=[];if(U&&Array.isArray(U)&&U.length>0){let B={id:m,card_data:b,requires:c,source_defs:f.source_defs,compute:U},O=a$7.runSync(B,{sourcesData:K});se=O.node.computed_values??{},ee=O.errors??[];}return Z({cardId:m,ok:k.isValid&&E.length===0&&ee.length===0&&j.every(B=>!B.error),validation:k,source_probes:j,projection_errors:E,fetched_sources:K,computed_values:se,compute_errors:ee})}catch(l){return ie(l)}}return {describeTaskExecutorCapabilities:u,validateCardPreflight:d,evalCardCompute:g,probeSourcePreflight:p,runSourcePreflight:h,simulateCardCycle:R}}function Sn(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let s=e.whatToRun;r=q(s);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let o={...t},n=Buffer.from(JSON.stringify(o)).toString("base64");try{return spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",n],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(s){return {dispatched:false,error:s instanceof Error?s.message:String(s)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=q(r);}catch{t="";}if(!t)return null;try{let r=spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var xr=".board.lock";function gt(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function wr(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function kr(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function mt(e){if(e)return e;let t=Ve(import.meta.url),r=[t,P(t,"..","cli","node"),P(t,"..","..","cli","node")];for(let o of r)try{return Ze(o),o}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function br(e$1,t,r){let{cliDir:o,opts:n}=wr(t,r),s=e$1.value,d$1=null,g,x=null,u;function p(){return u||(u=mt(o)),u}function h(c){let i=n?.queueStoreRef;if(!i)throw new Error(`createFsBoardPlatformAdapter: ${c} requires opts.queueStoreRef`);return i}function R(c){let i=n?.boardRuntimeStoreRef;if(!i)throw new Error(`createFsBoardPlatformAdapter: ${c} requires opts.boardRuntimeStoreRef`);return i}let y=n?.callbackTransport??d({notifyChannel:n?.notifyChannel,boardRuntimeStoreRef:n?.boardRuntimeStoreRef,queueStoreRef:n?.queueStoreRef}),l;function f(c){return l.queueStorageForRef(h(`internal lane "${c}"`),c)}function m(c){return a$5(f(c))}function S(){if(n?.suppressSpawn||d$1)return;let c=Ae({id:"task-executor",workerStore:m("task-executor"),handleRequest:async(i,k)=>{let w=await re(k.ref,k.args,{cliDir:p(),cwd:process.cwd(),label:"fsBoardAdapter.boardWorker"});if(w.result!=="success"){let b=typeof w.data?.error=="string"?w.data.error:w.error;throw new Error(b||w.result)}}});d$1=ge(c).catch(i=>{n?.onWarn?.(`[board-worker] in-process queue drain failed: ${i instanceof Error?i.message:String(i)}`);}).finally(()=>{d$1=null,f("task-executor").peekActive().length>0&&S();});}return l={kvStorage:c=>ue(P(s,`.${c}`)),blobStorage:c=>c?Y(P(s,c)):Y(s),blobStorageForRef:c=>Y(b(c).value),chatStorageForRef:c=>vr(b(c).value),queueStorageForRef:(c,i)=>Me(P(b(c).value,i)),scratchStorage:()=>ce(P(s,".tmp")),scratchStorageForRef:c=>ce(b(c).value),archiveFactory:()=>Re(P(s,"archive")),archiveFactoryForRef:c=>Re(b(c).value),journalAdapter:()=>Oe(s),journalAdapterForRef:c=>Oe(b(c).value),lock:lt(P(s,xr)),callbackTransport:y,async dispatchExecution(c,i){let k=!!i.output?.ref;if(c.howToRun==="queue-storage")try{let b=m("task-executor"),A=typeof c.extra?.boardId=="string"?c.extra.boardId:void 0;if(k)return b.enqueueRequest({boardId:A,ref:c,args:i}),{dispatched:!0};let C=i.source_def?.bindTo??pe().slice(0,8),E=ce(P(s,".tmp")),j=E.create(JSON.stringify(i,null,2),`exec-in-${C}`,".json"),X=E.getUniqueKey(`exec-out-${C}`,".json"),K=E.getUniqueKey(`exec-err-${C}`,".txt"),U=a$2(E.keyRef(j)),se=a$2(E.keyRef(X)),ee=a$2(E.keyRef(K));return b.enqueueRequest({boardId:A,ref:c,args:{subcommand:"run-source-fetch",inRef:U,outRef:se,errRef:ee}}),{dispatched:!0}}catch(b){return {dispatched:false,error:b instanceof Error?b.message:String(b)}}if(k&&(c.howToRun==="http:post"||c.howToRun==="in-process-loop"))try{if(c.howToRun==="http:post"){let C=q(c.whatToRun),E=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,...c.extra?{extra:c.extra}:{}})});if(!E.ok){let j=await E.text().catch(()=>"");return {dispatched:!1,error:`HTTP ${E.status}: ${j}`}}return {dispatched:!0}}let b=await re(c,i,{cwd:process.cwd(),label:"dispatchExecution.directHostedWorker"});return b.result==="success"?{dispatched:!0}:{dispatched:!1,error:(typeof b.data?.error=="string"?b.data.error:b.error)||b.result}}catch(b){return {dispatched:false,error:b instanceof Error?b.message:String(b)}}let w=c.howToRun==="local-node"||c.howToRun==="local-process"||c.howToRun==="local-python"||c.howToRun==="built-in";if(n?.suppressSpawn&&w)return {dispatched:false};try{let b=i.source_def?.bindTo??pe().slice(0,8),A=ce(P(s,".tmp")),C=A.create(JSON.stringify(i,null,2),`exec-in-${b}`,".json"),E=A.getUniqueKey(`exec-out-${b}`,".json"),j=A.getUniqueKey(`exec-err-${b}`,".txt"),X=a$2(A.keyRef(C)),K=a$2(A.keyRef(E)),U=a$2(A.keyRef(j)),se=m("task-executor"),ee=typeof c.extra?.boardId=="string"?c.extra.boardId:void 0;return se.enqueueRequest({boardId:ee,ref:c,args:{subcommand:"run-source-fetch",inRef:X,outRef:K,errRef:U}}),S(),{dispatched:!0}}catch(b){let A=b instanceof Error?b.message:String(b);try{let C=Re(P(s,"archive")),E=new Date().toISOString().replace(/[:.]/g,"-"),j=i.source_def?.bindTo??"unknown";C.blob("exec-failures").write(`${E}-${j}.json`,JSON.stringify({error:A,args:i,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:A}}},supportsDirectSourceOutput(c){return c.howToRun==="queue-storage"||c.howToRun==="http:post"||c.howToRun==="in-process-loop"},resolveBlob(c){let i=We(c.value)?$e().read(c.value):Y(s).read(c.value);if(i===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return i},hashFn:dt,genId:()=>He(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>ue(b(c).value),requestProcessAccumulated(){if(n?.suppressSpawn||x)return;let c=this,i=g??=e(e$1,c,{boardRuntimeStoreRef:R("requestProcessAccumulated")}),k=Te({id:"process-accumulated",queueStorage:f("process-accumulated"),handleMessage:async()=>{let w=await i.processAccumulatedEvents({});if(w.status!=="success")throw new Error(w.error||`processAccumulatedEvents returned ${w.status}`)}});x=ge(k).catch(w=>{n?.onWarn?.(`[process-accumulated] in-process queue drain failed: ${w instanceof Error?w.message:String(w)}`);}).finally(()=>{x=null,f("process-accumulated").peekActive().length>0&&c.requestProcessAccumulated?.();});},publishBoardChangeNotifications(c){if(!n?.notifyChannel||c.length===0)return;let i=c.map(k=>({id:pe(),ts:new Date().toISOString(),boardRef:a$2(e$1),notification:k}));Xe(n.notifyChannel,i,n.onWarn);},onWarn:n?.onWarn},l}function xn(e,t,r){let{cliDir:o,opts:n}=kr(t,r),s,d=()=>(s||(s=mt(o)),s),g=br(e,o,n),x=Be({resolveCliDir:d,...n?.resolveRef?{resolveRef:n.resolveRef}:{}});return {...g,invokeExecutor:x.invokeExecutor,validateSchema(u){let p=d$1(u);return {ok:p.errors.length===0,errors:p.errors}},absoluteBlob:$e()}}function wn(e,t={}){let r=t.chatsSubdir??"chats",o=t.kvSubdir??".kv",n=o?[o,"chat"]:["chat"],s=r&&!gt(e,r)?P(e,r):e,d=ue(P(e,...n));return a$3(g=>{let u=`${String(g).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,p=P(s,u);return Se(p)},d)}function vr(e){return a$3(t=>{let o=`${String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`;return Se(P(e,"journal",o))},ue(P(e,"kv")))}function kn(e,t={}){let r=t.filesSubdir??"files",o=r&&!gt(e,r)?P(e,r):e;return a$4(Y(o))}function bn(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}export{me as buildLocalBaseSpec,Ae as createBoardWorkerQueueLane,rr as createExecutionRefInvoker,Y as createFsBlobStorage,wn as createFsBoardChatStorage,yr as createFsBoardContainerStorage,kn as createFsBoardFileArtifactsStore,xn as createFsBoardNonCorePlatformAdapter,br as createFsBoardPlatformAdapter,vr as createFsChatStorageForRefRoot,Me as createFsQueueStorage,hr as createHostedAsyncBoardNonCorePublic,Sn as createNodeSpawnInvocationAdapter,Be as createNonCoreExecutorDispatcher,Te as createQueueStorageLane,bn as decodeBoardRefFromToken,ge as drainQueueLaneToIdle,Ce as evaluateArgsMassaging,re as invokeExecutionRef,je as invokeExecutionRefSync,nr as invokeRefSync,Yt as registerInProcessExecutionHandler,q as resolveWhatToRunValue,ot as resolveYamlFlowCliPath,rt as startQueueLaneRunner,Wt as startQueueLaneRunners,Zt as unregisterInProcessExecutionHandler};//# sourceMappingURL=board-live-cards-node.js.map
|
|
12
12
|
//# sourceMappingURL=board-live-cards-node.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkEGZPROOH_cjs=require('./chunk-EGZPROOH.cjs');require('./chunk-AW3COGCI.cjs'),require('./chunk-SIPLKLWU.cjs');var chunkJOQWJ3VR_cjs=require('./chunk-JOQWJ3VR.cjs');require('./chunk-7JVHYHT2.cjs'),require('./chunk-VQCIOKJV.cjs'),require('./chunk-VI36DRWG.cjs'),require('./chunk-7Y47QXMX.cjs'),require('./chunk-ZV35WD6K.cjs'),require('./chunk-3DWVFRQD.cjs'),require('./chunk-UJ7ZTV4J.cjs'),require('./chunk-2RIHC5TZ.cjs'),require('./chunk-GNFE24S7.cjs');Object.defineProperty(exports,"createBoardLiveCardsNonCorePublic",{enumerable:true,get:function(){return chunkEGZPROOH_cjs.f}});Object.defineProperty(exports,"createBoardLiveCardsPublic",{enumerable:true,get:function(){return chunkEGZPROOH_cjs.e}});Object.defineProperty(exports,"BOARD_GRAPH_KEY",{enumerable:true,get:function(){return chunkJOQWJ3VR_cjs.q}});Object.defineProperty(exports,"EMPTY_CONFIG",{enumerable:true,get:function(){return chunkJOQWJ3VR_cjs.D}});Object.defineProperty(exports,"SNAPSHOT_SCHEMA_VERSION_V1",{enumerable:true,get:function(){return chunkJOQWJ3VR_cjs.p}});//# sourceMappingURL=board-live-cards-public.cjs.map
|
|
2
2
|
//# sourceMappingURL=board-live-cards-public.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{f as createBoardLiveCardsNonCorePublic,e as createBoardLiveCardsPublic}from'./chunk-
|
|
1
|
+
export{f as createBoardLiveCardsNonCorePublic,e as createBoardLiveCardsPublic}from'./chunk-BRYV6CDD.js';import'./chunk-FULAMLUU.js';import'./chunk-EOVTMJYZ.js';export{q as BOARD_GRAPH_KEY,D as EMPTY_CONFIG,p as SNAPSHOT_SCHEMA_VERSION_V1}from'./chunk-MRESV3MD.js';import'./chunk-ANKA7HEJ.js';import'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import'./chunk-YOY2JM5N.js';import'./chunk-3SLSRX6Q.js';import'./chunk-MNEOJWPS.js';import'./chunk-UGB7PC4P.js';import'./chunk-FW4363Y4.js';//# sourceMappingURL=board-live-cards-public.js.map
|
|
2
2
|
//# sourceMappingURL=board-live-cards-public.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkOR6B2H2Y_cjs=require('./chunk-OR6B2H2Y.cjs');require('./chunk-LFVMX23W.cjs'),require('./chunk-NM6O35RY.cjs'),require('./chunk-NBJTYAYN.cjs'),require('./chunk-36KKCQVE.cjs');var chunkU5BGE52X_cjs=require('./chunk-U5BGE52X.cjs');require('./chunk-BQUQTOPB.cjs'),require('./chunk-GPCMBPLK.cjs'),require('./chunk-7FGPOGRV.cjs'),require('./chunk-LPXVVMQT.cjs'),require('./chunk-272IYUKT.cjs'),require('./chunk-MRIFSG7L.cjs'),require('./chunk-CSHNTZW4.cjs'),require('./chunk-EGZPROOH.cjs'),require('./chunk-AW3COGCI.cjs'),require('./chunk-SIPLKLWU.cjs'),require('./chunk-ESTFYRHF.cjs'),require('./chunk-JOQWJ3VR.cjs'),require('./chunk-7JVHYHT2.cjs'),require('./chunk-VQCIOKJV.cjs'),require('./chunk-VI36DRWG.cjs'),require('./chunk-7Y47QXMX.cjs'),require('./chunk-ZV35WD6K.cjs'),require('./chunk-3DWVFRQD.cjs'),require('./chunk-UJ7ZTV4J.cjs'),require('./chunk-SDJ3747Q.cjs'),require('./chunk-OF4FPYNI.cjs'),require('./chunk-2RIHC5TZ.cjs'),require('./chunk-GNFE24S7.cjs');Object.defineProperty(exports,"createMultiBoardServerRuntime",{enumerable:true,get:function(){return chunkOR6B2H2Y_cjs.b}});Object.defineProperty(exports,"createSingleBoardServerRuntime",{enumerable:true,get:function(){return chunkOR6B2H2Y_cjs.a}});Object.defineProperty(exports,"createHostedBoardQueueLaneRegistry",{enumerable:true,get:function(){return chunkU5BGE52X_cjs.a}});//# sourceMappingURL=board-live-cards-server-runtime.cjs.map
|
|
2
2
|
//# sourceMappingURL=board-live-cards-server-runtime.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as createMultiBoardServerRuntime,a as createSingleBoardServerRuntime}from'./chunk-
|
|
1
|
+
export{b as createMultiBoardServerRuntime,a as createSingleBoardServerRuntime}from'./chunk-BA25VGJP.js';import'./chunk-JB4Q2W7I.js';import'./chunk-XYN5D3GL.js';import'./chunk-O5UYCGIN.js';import'./chunk-PIPXFUEA.js';export{a as createHostedBoardQueueLaneRegistry}from'./chunk-AN7MLI7X.js';import'./chunk-FOFGEABN.js';import'./chunk-RKKSVOP2.js';import'./chunk-NTICU4OK.js';import'./chunk-O7NOHKVR.js';import'./chunk-ZJ5M5COT.js';import'./chunk-REZO2QJD.js';import'./chunk-PEJRTZU3.js';import'./chunk-BRYV6CDD.js';import'./chunk-FULAMLUU.js';import'./chunk-EOVTMJYZ.js';import'./chunk-NN52BT3Q.js';import'./chunk-MRESV3MD.js';import'./chunk-ANKA7HEJ.js';import'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import'./chunk-YOY2JM5N.js';import'./chunk-3SLSRX6Q.js';import'./chunk-MNEOJWPS.js';import'./chunk-BJGK5FNL.js';import'./chunk-NIBLKYXN.js';import'./chunk-UGB7PC4P.js';import'./chunk-FW4363Y4.js';//# sourceMappingURL=board-live-cards-server-runtime.js.map
|
|
2
2
|
//# sourceMappingURL=board-live-cards-server-runtime.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk6SPWFJRG_cjs=require('../chunk-6SPWFJRG.cjs');require('../chunk-AW3COGCI.cjs'),require('../chunk-SIPLKLWU.cjs'),require('../chunk-VI36DRWG.cjs'),require('../chunk-7Y47QXMX.cjs'),require('../chunk-ZV35WD6K.cjs'),require('../chunk-3DWVFRQD.cjs'),require('../chunk-UJ7ZTV4J.cjs'),require('../chunk-GNFE24S7.cjs');Object.defineProperty(exports,"LocalStorageService",{enumerable:true,get:function(){return chunk6SPWFJRG_cjs.a}});Object.defineProperty(exports,"buildBrowserArtifactsFromRuntime",{enumerable:true,get:function(){return chunk6SPWFJRG_cjs.e}});Object.defineProperty(exports,"createBoardLiveGraphRuntime",{enumerable:true,get:function(){return chunk6SPWFJRG_cjs.b}});Object.defineProperty(exports,"selectAllLiveCardModels",{enumerable:true,get:function(){return chunk6SPWFJRG_cjs.d}});Object.defineProperty(exports,"selectLiveCardModel",{enumerable:true,get:function(){return chunk6SPWFJRG_cjs.c}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as LocalStorageService,e as buildBrowserArtifactsFromRuntime,b as createBoardLiveGraphRuntime,d as selectAllLiveCardModels,c as selectLiveCardModel}from'../chunk-
|
|
1
|
+
export{a as LocalStorageService,e as buildBrowserArtifactsFromRuntime,b as createBoardLiveGraphRuntime,d as selectAllLiveCardModels,c as selectLiveCardModel}from'../chunk-4NWVZ7AW.js';import'../chunk-FULAMLUU.js';import'../chunk-EOVTMJYZ.js';import'../chunk-Q444D72R.js';import'../chunk-R7SQQSDX.js';import'../chunk-YOY2JM5N.js';import'../chunk-3SLSRX6Q.js';import'../chunk-MNEOJWPS.js';import'../chunk-FW4363Y4.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkZV35WD6K_cjs=require('../chunk-ZV35WD6K.cjs'),chunk3DWVFRQD_cjs=require('../chunk-3DWVFRQD.cjs');require('../chunk-UJ7ZTV4J.cjs'),require('../chunk-GNFE24S7.cjs');Object.defineProperty(exports,"CardCompute",{enumerable:true,get:function(){return chunkZV35WD6K_cjs.a}});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return chunkZV35WD6K_cjs.b}});Object.defineProperty(exports,"validateLiveCard",{enumerable:true,get:function(){return chunk3DWVFRQD_cjs.c}});Object.defineProperty(exports,"validateLiveCardDefinition",{enumerable:true,get:function(){return chunk3DWVFRQD_cjs.d}});Object.defineProperty(exports,"validateLiveCardRuntimeExpressions",{enumerable:true,get:function(){return chunk3DWVFRQD_cjs.b}});Object.defineProperty(exports,"validateLiveCardSchema",{enumerable:true,get:function(){return chunk3DWVFRQD_cjs.a}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -64,9 +64,15 @@ interface ComputeSource {
|
|
|
64
64
|
outputFile: string;
|
|
65
65
|
cli?: string;
|
|
66
66
|
script?: string;
|
|
67
|
+
/** JSONata expression evaluated against { card_data, requires }. Truthy => skip this source for the current cycle. */
|
|
68
|
+
skip_when?: string;
|
|
67
69
|
/** Named data projections: each key maps to a JSONata expression rooted at card_data or requires.
|
|
68
70
|
* The engine evaluates these before spawning the executor and passes results as _projections. */
|
|
69
71
|
projections?: Record<string, string>;
|
|
72
|
+
/** Ephemeral: resolved projections for the current cycle. */
|
|
73
|
+
_projections?: Record<string, unknown>;
|
|
74
|
+
/** Ephemeral: resolved skip decision for the current cycle. */
|
|
75
|
+
_skip?: boolean;
|
|
70
76
|
[key: string]: unknown;
|
|
71
77
|
}
|
|
72
78
|
/** Options for CardCompute.run() */
|
|
@@ -64,9 +64,15 @@ interface ComputeSource {
|
|
|
64
64
|
outputFile: string;
|
|
65
65
|
cli?: string;
|
|
66
66
|
script?: string;
|
|
67
|
+
/** JSONata expression evaluated against { card_data, requires }. Truthy => skip this source for the current cycle. */
|
|
68
|
+
skip_when?: string;
|
|
67
69
|
/** Named data projections: each key maps to a JSONata expression rooted at card_data or requires.
|
|
68
70
|
* The engine evaluates these before spawning the executor and passes results as _projections. */
|
|
69
71
|
projections?: Record<string, string>;
|
|
72
|
+
/** Ephemeral: resolved projections for the current cycle. */
|
|
73
|
+
_projections?: Record<string, unknown>;
|
|
74
|
+
/** Ephemeral: resolved skip decision for the current cycle. */
|
|
75
|
+
_skip?: boolean;
|
|
70
76
|
[key: string]: unknown;
|
|
71
77
|
}
|
|
72
78
|
/** Options for CardCompute.run() */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as CardCompute,b as default}from'../chunk-
|
|
1
|
+
export{a as CardCompute,b as default}from'../chunk-YOY2JM5N.js';export{c as validateLiveCard,d as validateLiveCardDefinition,b as validateLiveCardRuntimeExpressions,a as validateLiveCardSchema}from'../chunk-3SLSRX6Q.js';import'../chunk-MNEOJWPS.js';import'../chunk-FW4363Y4.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkJOQWJ3VR_cjs=require('./chunk-JOQWJ3VR.cjs');require('./chunk-7JVHYHT2.cjs'),require('./chunk-VQCIOKJV.cjs'),require('./chunk-VI36DRWG.cjs'),require('./chunk-7Y47QXMX.cjs'),require('./chunk-ZV35WD6K.cjs'),require('./chunk-3DWVFRQD.cjs'),require('./chunk-UJ7ZTV4J.cjs'),require('./chunk-2RIHC5TZ.cjs'),require('./chunk-GNFE24S7.cjs');Object.defineProperty(exports,"createCardStorePublic",{enumerable:true,get:function(){return chunkJOQWJ3VR_cjs.H}});//# sourceMappingURL=card-store-public.cjs.map
|
|
2
2
|
//# sourceMappingURL=card-store-public.cjs.map
|
package/lib/card-store-public.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{H as createCardStorePublic}from'./chunk-
|
|
1
|
+
export{H as createCardStorePublic}from'./chunk-MRESV3MD.js';import'./chunk-ANKA7HEJ.js';import'./chunk-44L64VQ2.js';import'./chunk-Q444D72R.js';import'./chunk-R7SQQSDX.js';import'./chunk-YOY2JM5N.js';import'./chunk-3SLSRX6Q.js';import'./chunk-MNEOJWPS.js';import'./chunk-UGB7PC4P.js';import'./chunk-FW4363Y4.js';//# sourceMappingURL=card-store-public.js.map
|
|
2
2
|
//# sourceMappingURL=card-store-public.js.map
|
package/lib/card-validation.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk543ZEGP7_cjs=require('./chunk-543ZEGP7.cjs');require('./chunk-3DWVFRQD.cjs'),require('./chunk-UJ7ZTV4J.cjs'),require('./chunk-GNFE24S7.cjs');Object.defineProperty(exports,"validateCardPreflight",{enumerable:true,get:function(){return chunk543ZEGP7_cjs.a}});//# sourceMappingURL=card-validation.cjs.map
|
|
2
2
|
//# sourceMappingURL=card-validation.cjs.map
|
package/lib/card-validation.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as validateCardPreflight}from'./chunk-
|
|
1
|
+
export{a as validateCardPreflight}from'./chunk-UJQ7IML5.js';import'./chunk-3SLSRX6Q.js';import'./chunk-MNEOJWPS.js';import'./chunk-FW4363Y4.js';//# sourceMappingURL=card-validation.js.map
|
|
2
2
|
//# sourceMappingURL=card-validation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkBQUQTOPB_cjs=require('./chunk-BQUQTOPB.cjs'),chunkLPXVVMQT_cjs=require('./chunk-LPXVVMQT.cjs'),chunkGHUW6P4G_cjs=require('./chunk-GHUW6P4G.cjs'),chunkVQCIOKJV_cjs=require('./chunk-VQCIOKJV.cjs');function M(a){if(!a||typeof a!="object")return false;let t=a;return typeof t.kind=="string"&&t.kind.length>0}function J(a){if(!a||typeof a!="object")return [];let t=a;return t.kind==="notification-batch"?Array.isArray(t.notifications)?t.notifications.filter(M):[]:M(a)?[a]:[]}function X(a,t,i){let c=0;return {accepted:a.filter(_=>{if(!M(_))return c++,false;let S=_;return typeof S.sentAtMs=="number"&&t-S.sentAtMs>i?(c++,false):true}),rejected:c}}function Q(){return {status:null,computedValues:{},dataObjects:{},cards:{}}}function z(a){if(!a||typeof a!="object")return false;let t=a.summary;return !t||typeof t!="object"?false:Number(t.card_count||0)>0}function W(a){if(!a||typeof a!="object")return false;let t=a;return t.kind==="notification-batch"&&Array.isArray(t.notifications)}function V(a,t){if(t.kind==="status"){z(t.status)&&(a.status=t.status);return}if(t.kind==="computed_values"){a.computedValues[t.cardId]=t.values;return}if(t.kind==="data_object"){a.dataObjects[t.key]=t.payload;return}if(t.kind==="card_refreshed"){a.cards[t.cardId]=t.card;return}t.kind==="card_removed"&&(delete a.cards[t.cardId],delete a.computedValues[t.cardId]);}function Y(a,t){if(W(t)){for(let i of t.notifications)M(i)&&V(a,i);return}M(t)&&V(a,t);}function j(a,t){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||`${t} failed`),{statusCode:400}):Object.assign(new Error(`${t} returned an unexpected response`),{statusCode:500})}async function N(a,t){return j(await a,t)}function T(a){let t=chunkLPXVVMQT_cjs.a(a,"key");if(!t)throw Object.assign(new Error("MCP tool requires key"),{statusCode:400});let i=t.split(".");if(!(i.length>=2&&i.every(g=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(g))))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 t}function q(a,t){let i=a.__private;for(let c of t.split(".")){if(!i||typeof i!="object"||Array.isArray(i)||!Object.prototype.hasOwnProperty.call(i,c))return {exists:false,value:null};i=i[c];}return {exists:true,value:i}}function ot(a){let{boardId:t,bootstrapBoard:i,sseHub:c,onChannelSubscribed:g,onChannelUnsubscribed:_,getMcpFacade:S,getMcpCardStoreFacade:n}=a;function f(s){let d=chunkLPXVVMQT_cjs.a(s,"board_id");if(!d)throw Object.assign(new Error("MCP tool requires board_id"),{statusCode:400});if(d!==t)throw Object.assign(new Error(`Unknown board_id: ${d}`),{statusCode:400})}function h(s){let d=chunkLPXVVMQT_cjs.a(s,"client_id");if(!d)throw Object.assign(new Error("MCP tool requires client_id"),{statusCode:400});return d}function w(s){f(s);let d=h(s),e=chunkLPXVVMQT_cjs.a(s,"channel_name"),r=chunkLPXVVMQT_cjs.a(s,"card_id")||void 0;if(!e)throw Object.assign(new Error("MCP tool requires channel_name"),{statusCode:400});return {clientId:d,channelName:e,...r?{cardId:r}:{}}}function R(s){f(s);let d=chunkLPXVVMQT_cjs.a(s,"card_id");if(!d)throw Object.assign(new Error("MCP tool requires card_id"),{statusCode:400});return {cardId:d}}async function I(s){await i();let{cardId:d}=R(s),e=h(s);if(!await c.subscribeChat(e,d))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return {status:"success",data:{boardId:t,cardId:d,clientId:e,subscribed:true}}}async function u(s){await i();let{cardId:d}=R(s),e=h(s);if(!c.unsubscribeChat(e,d))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return {status:"success",data:{boardId:t,cardId:d,clientId:e,subscribed:false}}}async function b(s,d){await i();let{clientId:e,channelName:r,cardId:o}=w(s);if(!c.has(e))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return d?(c.subscribeChannel(e,r,o),g?.(e,r,o?{cardId:o}:{})):(c.unsubscribeChannel(e,r,o),_?.(e,r,o?{cardId:o}:{})),{status:"success",data:{boardId:t,clientId:e,channelName:r,subscribed:d,...o?{cardId:o}:{}}}}async function m(s,d){let{cardId:e}=R(s);return await S().setChatProcessing({cardId:e,active:d}),{status:"success",data:{boardId:t,cardId:e,active:d}}}async function p(s){let{cardId:d}=R(s),e=await S().getChatProcessing({cardId:d});return {status:"success",data:{boardId:t,cardId:d,active:e.active}}}async function y(s){let{cardId:d}=R(s),e=T(s);if(!Object.prototype.hasOwnProperty.call(s,"value"))throw Object.assign(new Error("MCP tool requires value"),{statusCode:400});if(e.split(".").includes("visible_controlplane_only")){let r=await N(n().get({params:{id:d}}),"cardStore.get"),o=Array.isArray(r.cards)&&r.cards.length>0&&typeof r.cards[0]=="object"&&!Array.isArray(r.cards[0])?r.cards[0]:null,k=o?q(o,"visible_controlplane_only").value:void 0;if(s.value!==k)throw Object.assign(new Error("MCP tool cannot change the reserved private flag visible_controlplane_only"),{statusCode:403});return {status:"success",data:{boardId:t,cardId:d,key:e}}}return j(await n().patch({params:{id:d,path:`__private.${e}`},body:{value:s.value}}),"cardStore.patch"),{status:"success",data:{boardId:t,cardId:d,key:e}}}async function C(s){let{cardId:d}=R(s),e=T(s),r=await N(n().get({params:{id:d}}),"cardStore.get"),o=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(!o)throw Object.assign(new Error(`Card "${d}" not found`),{statusCode:404});let k=q(o,e);return {status:"success",data:{boardId:t,cardId:d,key:e,exists:k.exists,value:k.value}}}return {requireCardArgs:R,subscribeChat:I,unsubscribeChat:u,watchChannel:b,setChatProcessing:m,getChatProcessing:p,setCardMeta:y,getCardMeta:C}}function it(a){let{boardId:t,boardContexts:i,readChatRecords:c,getChatProcessing:g}=a,_=Number.isInteger(a.chatBootstrapTailTurns)&&a.chatBootstrapTailTurns>0?a.chatBootstrapTailTurns:1;function S(u){return {role:String(u.role||"system"),text:String(u.text||""),files:Array.isArray(u.files)?u.files:[],...typeof u.turn=="string"&&u.turn?{turn:u.turn}:{}}}function n(u){if(u.length===0)return null;if(u.length===1)return u[0];let b=[],m=["completed","eligible","pending","blocked","unresolved","failed","in_progress","orphan_cards"],p={};for(let C of m)p[C]=0;for(let C of u){let s=C,d=Array.isArray(s.cards)?s.cards:[];b.push(...d);for(let e of m)p[e]+=Number(s?.summary?.[e]||0);}let y=u[0];return {...y,cards:b,summary:{...y.summary||{},card_count:b.length,...p}}}async function f(){let u=[];for(let b of i)try{let m=await b.boardOps.buildSseOneShotPayload({});m.status==="success"&&m.data&&u.push(m.data);}catch{}return u}async function h(){let b=(await f()).map(m=>m.statusSnapshot).filter(Boolean);if(b.length===0){let m=i.map(p=>p.notification.status).filter(Boolean);return n(m)}return n(b)}async function w(){let u={},b=await f();for(let m of b)Object.assign(u,m.cardRuntimeById||{});if(Object.keys(u).length>0)return u;for(let m of i)for(let[p,y]of Object.entries(m.notification.computedValues)){let C=m.notification.cards[p];u[p]={schema_version:"v1",card_id:p,card_data:C?.card_data??{},computed_values:y??{}};}return u}async function R(){let u={},b=await f();for(let m of b)Object.assign(u,m.dataObjectsByToken||{});if(Object.keys(u).length===0)for(let m of i)Object.assign(u,m.notification.dataObjects||{});return u}async function I(){let u=await f(),b=u.flatMap(C=>Array.isArray(C.cardDefinitions)?C.cardDefinitions:[]),m={},p={};for(let C of u)Object.assign(m,C.dataObjectsByToken||{}),Object.assign(p,C.cardRuntimeById||{});let y={};for(let C of b){if(!C?.id)continue;let s=C.id;try{let d=await c(s,{tailTurns:_}),e=await g(s);(d.length>0||e)&&(y[s]={messages:d.map(r=>S(r)),receiving:!1,processing:e});}catch{}}return {boardId:t,cardDefinitions:b,statusSnapshot:await h(),dataObjectsByToken:m,cardRuntimeById:p,cardChatsByCardId:y}}return {readStatusSnapshot:h,readCardRuntimeArtifacts:w,readDataObjectsByToken:R,buildPublishedRuntimePayload:I}}function K(a){let t=String(a||"").trim();if(!t)return "upload.bin";let i=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (i>=0?t.slice(i+1):t)||"upload.bin"}function ct(a){let{safeCardId:t,artifactsStores:i,cardFileMetadataStore:c,readCardFromStore:g,updateCardLocalOnly:_,writeChatRecord:S}=a;async function n(w){let R=[];try{let I=await g(w);if(!I)return R;let u=c().read(I.card_data&&typeof I.card_data=="object"?I.card_data:null);for(let b of u)R.push(String(b.stored_name??""));}catch{}return R}async function f(w,R,I,u){let b=t(w),m=i(w),p=K(R),y=await n(w),s=`${String(y.length+1).padStart(3,"0")}-${p}`.slice(-36);if(!m.files)throw Object.assign(new Error(`artifactsStoreRef is not configured for card uploads: ${w}`),{statusCode:500});return await m.files.putBytes(`${b}/${s}`,new Uint8Array(u),I||"application/octet-stream"),{name:p,stored_name:s,size:u.length,mime_type:I||"application/octet-stream",uploaded_at:new Date().toISOString()}}async function h(w,R,I,u,b){if(!u.length)throw Object.assign(new Error("Empty upload body"),{statusCode:400});let m=b?.inChat===true,p=await f(w,R,I,u),y=null;if(await _(w,C=>{let s=new Date().toISOString(),d=C.card_data&&typeof C.card_data=="object"?C.card_data:{};C.card_data=d;let e=c().normalizeIncoming([{name:p.name,stored_name:p.stored_name,size:p.size,mime_type:p.mime_type,uploaded_at:p.uploaded_at||s,chat:m}],s);return y=c().merge(d,e).findIndex(o=>o.stored_name===p.stored_name),C}),m&&b?.suppressChatRecordWrite!==true){let C=typeof y=="number"&&y>=0?` #${y}`:"";await S(w,"system",`file uploaded: ${p.name} as ${p.stored_name}${C}`,[],b?.turnId??"");}return {ok:true,file:{...p,...typeof y=="number"&&y>=0?{file_idx:y}:{},chat:m},...typeof y=="number"&&y>=0?{file_idx:y}:{}}}return {uploadCardFile:h,readCardStoredFileNames:n}}function pt(a){return {"discover.source-kinds":()=>a.discoverSourceKinds(),"inspect.board-runtime-status":()=>a.inspectBoardRuntimeStatus(),"inspect.card-definition-and-runtime":t=>a.inspectCardDefinitionAndRuntime({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")}),"inspect.chat-messages-on-cards":t=>{let i=chunkLPXVVMQT_cjs.b(t,"tail_turns"),c=chunkLPXVVMQT_cjs.b(t,"tail"),g=chunkLPXVVMQT_cjs.a(t,"turn_id"),_=t.all_turns===true,S=chunkLPXVVMQT_cjs.a(t,"tail_turns_before_id");return a.inspectChatMessagesOnCards({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),...i!==void 0?{lastUserTurns:i}:{},...c!==void 0?{tail:c}:{},...g?{turnId:g}:{},..._?{allTurns:true}:{},...S?{tailTurnsBeforeId:S}:{}})},"inspect.file-contents":t=>a.inspectFileContents({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),fileIdx:Number(chunkLPXVVMQT_cjs.b(t,"file_idx"))}),"preflight.validate-candidate-card-definition":t=>a.preflightValidateCandidateCardDefinition({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content")}),"preflight.materialize-candidate-card":t=>a.preflightMaterializeCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockRequires:chunkLPXVVMQT_cjs.d(t,"mock_requires","mock_requires"),mockFetchedSources:chunkLPXVVMQT_cjs.d(t,"mock_fetched_sources","mock_fetched_sources")}),"preflight.probe-single-source-in-candidate-card":t=>a.preflightProbeSingleSourceInCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockProjections:chunkLPXVVMQT_cjs.c(t,"mock_projections"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx")}),"preflight.run-single-source-in-candidate-card":t=>a.preflightRunSingleSourceInCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockProjections:chunkLPXVVMQT_cjs.c(t,"mock_projections"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx")}),"preflight.run-single-source-in-live-card":t=>a.preflightRunSingleSourceInLiveCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx"),mockRequires:chunkLPXVVMQT_cjs.d(t,"mock_requires","mock_requires")}),"preflight.run-one-cycle-with-candidate-card":t=>a.preflightRunOneCycleWithCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockRequires:chunkLPXVVMQT_cjs.c(t,"mock_requires")}),"manage.read-card":t=>a.manageReadCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")}),"stage-ai-response-and-any-attachments":t=>{let i=chunkLPXVVMQT_cjs.a(t,"turn_id");if(!i)throw Object.assign(new Error("stage-ai-response-and-any-attachments requires a non-empty turn_id"),{statusCode:400});return a.manageAddChatEntryAndAnyAttachments({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),role:"assistant",...typeof t.text=="string"?{text:t.text}:{},...i?{turn:i}:{},...Array.isArray(t.files)?{files:t.files}:{}})},"stage-ai-failure-message":t=>{let i=chunkLPXVVMQT_cjs.a(t,"turn_id"),c=chunkLPXVVMQT_cjs.a(t,"failure");if(!i)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty turn_id"),{statusCode:400});if(!c)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty failure"),{statusCode:400});return a.manageAddChatEntryAndAnyAttachments({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),role:"system",text:c,turn:i})},"manage.upsert-card":t=>a.manageUpsertCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),candidateCardContent:chunkLPXVVMQT_cjs.c(t,"candidate_card_content")}),"manage.remove-card":t=>a.manageRemoveCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")})}}function mt(a){return {"webhook.process-accumulated":()=>a.webhookProcessAccumulated(),"webhook.source-fetch-done":t=>a.webhookSourceFetchDone({token:chunkLPXVVMQT_cjs.a(t,"token"),ref:chunkLPXVVMQT_cjs.a(t,"ref")}),"webhook.source-fetch-failed":t=>a.webhookSourceFetchFailed({token:chunkLPXVVMQT_cjs.a(t,"token"),reason:chunkLPXVVMQT_cjs.a(t,"reason")})}}function ft(a){let{boardId:t,uploadCardFile:i,getMcpFacade:c,controlplane:g}=a;function _(n,f){let h=chunkLPXVVMQT_cjs.a(n,"board_id");if(!h)throw Object.assign(new Error(`${f} requires board_id`),{statusCode:400});if(h!==t)throw Object.assign(new Error(`Unknown board_id: ${h}`),{statusCode:400})}function S(n,f){let{cardId:h}=g.requireCardArgs(n),w=chunkLPXVVMQT_cjs.a(n,"turn_id");return _(n,f),c().manageAddChatAttachment({cardId:h,role:chunkLPXVVMQT_cjs.a(n,"role")||"user",...w?{turn:w}:{},files:[{file_name:chunkLPXVVMQT_cjs.a(n,"file_name"),content_type:chunkLPXVVMQT_cjs.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=>(_(n,"list-runtime-cards"),c().listRuntimeCards()),"sse.subscribe-chat":n=>g.subscribeChat(n),"sse.unsubscribe-chat":n=>g.unsubscribeChat(n),"sse.watch-channel":n=>g.watchChannel(n,true),"sse.unwatch-channel":n=>g.watchChannel(n,false),"getstate.is-chat-processing":n=>g.getChatProcessing(n),"setstate.chat-processing-started":n=>g.setChatProcessing(n,true),"setstate.chat-processing-done":n=>g.setChatProcessing(n,false),"getstate.card-private":n=>g.getCardMeta(n),"setstate.card-private":n=>g.setCardMeta(n),"manage.upload-card-file":n=>{let f=chunkLPXVVMQT_cjs.a(n,"card_id"),h=chunkLPXVVMQT_cjs.a(n,"file_name"),w=chunkLPXVVMQT_cjs.a(n,"content_type")||"application/octet-stream",R=chunkLPXVVMQT_cjs.f(n);if(_(n,"manage.upload-card-file"),!f)throw Object.assign(new Error("manage.upload-card-file requires card_id"),{statusCode:400});if(!h)throw Object.assign(new Error("manage.upload-card-file requires file_name"),{statusCode:400});if(!R)throw Object.assign(new Error("manage.upload-card-file requires args.bytes, args.text, or args.base64"),{statusCode:400});return i(f,h,w,R,{inChat:false})},"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:f}=g.requireCardArgs(n),h=chunkLPXVVMQT_cjs.a(n,"role")||"user",w=chunkLPXVVMQT_cjs.a(n,"turn_id");return _(n,"manage.add-chat-entry-and-any-attachments"),c().manageAddChatEntryAndAnyAttachments({cardId:f,role:h,...typeof n.text=="string"?{text:n.text}:{},...w?{turn:w}:{},...Array.isArray(n.files)?{files:n.files}:{}})},"manage.patch-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.patch-card"),c().managePatchCard({cardId:f,patch:chunkLPXVVMQT_cjs.c(n,"patch")},{allowControlplaneOnlyCards:true})},"manage.upsert-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.upsert-card"),c().manageUpsertCard({cardId:f,candidateCardContent:chunkLPXVVMQT_cjs.c(n,"candidate_card_content")},{allowControlplaneOnlyCards:true})},"manage.remove-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.remove-card"),c().manageRemoveCard({cardId:f},{allowControlplaneOnlyCards:true})},"manage.admin-read-card":async n=>{let{cardId:f}=g.requireCardArgs(n);return {status:"success",data:{cards:await c().adminReadCard({cardId:f})}}},"manage.admin-upsert-card":n=>{let f=chunkLPXVVMQT_cjs.a(n,"board_id"),h=chunkLPXVVMQT_cjs.a(n,"card_id");if(!f)throw Object.assign(new Error("manage.admin-upsert-card requires board_id"),{statusCode:400});if(!h)throw Object.assign(new Error("manage.admin-upsert-card requires card_id"),{statusCode:400});if(f!==t)throw Object.assign(new Error(`Unknown board_id: ${f}`),{statusCode:400});return c().adminUpsertCard({cardId:h,candidateCardContent:chunkLPXVVMQT_cjs.c(n,"candidate_card_content")})}}}function yt(a){let{boardContexts:t,cardOwnerIndex:i,cardContextForCard:c,readStatusSnapshot:g,readDataObjectsByToken:_,readCardRuntimeArtifacts:S,readCardFromStore:n,readCardDefinitions:f,processAccumulatedLaneInternal:h,reportSourceFetched:w,reportSourceFetchFailure:R,uploadCardFile:I,chatStorePublic:u,serverUrl:b,apiBasePath:m}=a;function p(){return t[0]??null}function y(){return {async status(){let e=await g();return e==null?{status:"fail",error:"Board status is unavailable"}:{status:"success",data:e}},async getOutputsDataObject(e){let r=e?.params?.key;return r?{status:"success",data:(await _())[r]}:{status:"fail",error:"getOutputsDataObject requires params.key"}},async getOutputsComputedValues(e){let r=e?.params?.key;return r?{status:"success",data:(await S())[r]?.computed_values}:{status:"fail",error:"getOutputsComputedValues requires params.key"}},async getOutputsFetchedSources(e){let r=e?.params?.key;if(!r)return {status:"fail",error:"getOutputsFetchedSources requires params.key"};let o=c(r)??p();return o?o.boardOps.getOutputsFetchedSources({params:{key:r}}):{status:"fail",error:"Board context is unavailable"}},async removeCard(e){let r=e?.params?.id;if(!r)return {status:"fail",error:"removeCard requires params.id"};let o=c(r)??p();return o?o.boardOps.removeCard({params:{id:r}}):{status:"fail",error:"Board context is unavailable"}},async upsertCard(e){let r=e?.params?.cardId;if(!r)return {status:"fail",error:"upsertCard requires params.cardId"};let o=c(r)??p();if(!o)return {status:"fail",error:"Board context is unavailable"};let k=await o.boardOps.upsertCard({params:{cardId:r,restart:e.params.restart===true}});if(k.status!=="success")return k;if(chunkBQUQTOPB_cjs.a(o.boardAdapter)){let P=await h(true);if(P.status!=="success")return P}return k}}}function C(){let e=()=>{let r=p();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 e().describeTaskExecutorCapabilities(r)},validateCardPreflight(r){return e().validateCardPreflight(r)},evalCardCompute(r){return e().evalCardCompute(r)},probeSourcePreflight(r){return e().probeSourcePreflight(r)},runSourcePreflight(r){return e().runSourcePreflight(r)},simulateCardCycle(r){return e().simulateCardCycle(r)}}}function s(){return {async get(e){let r=typeof e.params?.id=="string"?e.params.id:void 0;if(r){let o=await n(r);return o?{status:"success",data:{cards:[o]}}:{status:"success",data:{cards:[]}}}return {status:"success",data:{cards:await f()}}},async set(e){let r=e.body;if(r==null)return {status:"fail",error:"set requires a body (card object or array of cards)"};let o=Array.isArray(r)?r:[r];for(let k of o){let P=k,A=typeof P.id=="string"?P.id:"";if(!A)return {status:"fail",error:"each card must have a string `id` field"};let E=i.get(A)??0,D=t[E]??p();if(!D)return {status:"fail",error:"Board context is unavailable"};let L=await D.cardStoreOps.set({body:P});if(L.status!=="success")return L;i.set(A,E);}return {status:"success",data:{count:o.length}}},async del(e){let r=[e.params?.id,...e.body?.ids??[]].filter(o=>typeof o=="string"&&!!o);if(r.length===0)return {status:"fail",error:"del requires body.ids (string[]) or params.id"};for(let o of r){let k=c(o)??p();if(!k)return {status:"fail",error:"Board context is unavailable"};let P=await k.cardStoreOps.del({params:{id:o}});if(P.status!=="success")return P;i.delete(o);}return {status:"success",data:{count:r.length}}},async patch(e){let r=typeof e.params?.id=="string"?e.params.id:void 0,o=typeof e.params?.path=="string"?e.params.path:void 0;if(!r||!o)return {status:"fail",error:"patch requires params.id and params.path"};let k=c(r)??p();return k?k.cardStoreOps.patch(e):{status:"fail",error:"Board context is unavailable"}},async appendFiles(e){let r=typeof e.params?.id=="string"?e.params.id:void 0;if(!r)return {status:"fail",error:"appendFiles requires params.id"};let o=c(r)??p();return o?o.cardStoreOps.appendFiles(e):{status:"fail",error:"Board context is unavailable"}}}}function d(){return chunkGHUW6P4G_cjs.a({board:y(),nonCore:C(),cardStore:s(),chatStore:u,processAccumulated:()=>h(true),sourceFetchDone:({token:e,ref:r})=>w(e,r),sourceFetchFailed:({token:e,reason:r})=>R(e,r),uploadCardFile({cardId:e,fileName:r,contentType:o,bytes:k,suppressChatRecordWrite:P}){return I(e,r,o,k,{inChat:true,...P===true?{suppressChatRecordWrite:true}:{}})},buildFileDownloadUrl({cardId:e,fileIdx:r,storedName:o}){let k=`${b||""}${m}/cards/${encodeURIComponent(e)}/files/${r}`;return o?`${k}?sn=${encodeURIComponent(o)}`:k},readFetchedSourceJsonByRef({cardId:e,ref:r}){let o=c(e)??p();if(!o||chunkBQUQTOPB_cjs.a(o.boardAdapter))return null;let A=o.boardAdapter.resolveBlob(chunkVQCIOKJV_cjs.b(r)).trim();return A?JSON.parse(A):null}})}return {mcpBoardFacade:y,mcpNonCoreFacade:C,mcpCardStoreFacade:s,createMcpFacade:d}}exports.a=J;exports.b=X;exports.c=Q;exports.d=z;exports.e=Y;exports.f=j;exports.g=N;exports.h=T;exports.i=q;exports.j=ot;exports.k=it;exports.l=ct;exports.m=pt;exports.n=mt;exports.o=ft;exports.p=yt;//# sourceMappingURL=chunk-NOAERAOE.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunkBQUQTOPB_cjs=require('./chunk-BQUQTOPB.cjs'),chunkLPXVVMQT_cjs=require('./chunk-LPXVVMQT.cjs'),chunkESTFYRHF_cjs=require('./chunk-ESTFYRHF.cjs'),chunkVQCIOKJV_cjs=require('./chunk-VQCIOKJV.cjs');function M(a){if(!a||typeof a!="object")return false;let t=a;return typeof t.kind=="string"&&t.kind.length>0}function J(a){if(!a||typeof a!="object")return [];let t=a;return t.kind==="notification-batch"?Array.isArray(t.notifications)?t.notifications.filter(M):[]:M(a)?[a]:[]}function X(a,t,i){let c=0;return {accepted:a.filter(_=>{if(!M(_))return c++,false;let S=_;return typeof S.sentAtMs=="number"&&t-S.sentAtMs>i?(c++,false):true}),rejected:c}}function Q(){return {status:null,computedValues:{},dataObjects:{},cards:{}}}function z(a){if(!a||typeof a!="object")return false;let t=a.summary;return !t||typeof t!="object"?false:Number(t.card_count||0)>0}function W(a){if(!a||typeof a!="object")return false;let t=a;return t.kind==="notification-batch"&&Array.isArray(t.notifications)}function V(a,t){if(t.kind==="status"){z(t.status)&&(a.status=t.status);return}if(t.kind==="computed_values"){a.computedValues[t.cardId]=t.values;return}if(t.kind==="data_object"){a.dataObjects[t.key]=t.payload;return}if(t.kind==="card_refreshed"){a.cards[t.cardId]=t.card;return}t.kind==="card_removed"&&(delete a.cards[t.cardId],delete a.computedValues[t.cardId]);}function Y(a,t){if(W(t)){for(let i of t.notifications)M(i)&&V(a,i);return}M(t)&&V(a,t);}function j(a,t){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||`${t} failed`),{statusCode:400}):Object.assign(new Error(`${t} returned an unexpected response`),{statusCode:500})}async function N(a,t){return j(await a,t)}function T(a){let t=chunkLPXVVMQT_cjs.a(a,"key");if(!t)throw Object.assign(new Error("MCP tool requires key"),{statusCode:400});let i=t.split(".");if(!(i.length>=2&&i.every(g=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(g))))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 t}function q(a,t){let i=a.__private;for(let c of t.split(".")){if(!i||typeof i!="object"||Array.isArray(i)||!Object.prototype.hasOwnProperty.call(i,c))return {exists:false,value:null};i=i[c];}return {exists:true,value:i}}function ot(a){let{boardId:t,bootstrapBoard:i,sseHub:c,onChannelSubscribed:g,onChannelUnsubscribed:_,getMcpFacade:S,getMcpCardStoreFacade:n}=a;function f(s){let d=chunkLPXVVMQT_cjs.a(s,"board_id");if(!d)throw Object.assign(new Error("MCP tool requires board_id"),{statusCode:400});if(d!==t)throw Object.assign(new Error(`Unknown board_id: ${d}`),{statusCode:400})}function h(s){let d=chunkLPXVVMQT_cjs.a(s,"client_id");if(!d)throw Object.assign(new Error("MCP tool requires client_id"),{statusCode:400});return d}function w(s){f(s);let d=h(s),e=chunkLPXVVMQT_cjs.a(s,"channel_name"),r=chunkLPXVVMQT_cjs.a(s,"card_id")||void 0;if(!e)throw Object.assign(new Error("MCP tool requires channel_name"),{statusCode:400});return {clientId:d,channelName:e,...r?{cardId:r}:{}}}function R(s){f(s);let d=chunkLPXVVMQT_cjs.a(s,"card_id");if(!d)throw Object.assign(new Error("MCP tool requires card_id"),{statusCode:400});return {cardId:d}}async function I(s){await i();let{cardId:d}=R(s),e=h(s);if(!await c.subscribeChat(e,d))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return {status:"success",data:{boardId:t,cardId:d,clientId:e,subscribed:true}}}async function u(s){await i();let{cardId:d}=R(s),e=h(s);if(!c.unsubscribeChat(e,d))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return {status:"success",data:{boardId:t,cardId:d,clientId:e,subscribed:false}}}async function b(s,d){await i();let{clientId:e,channelName:r,cardId:o}=w(s);if(!c.has(e))throw Object.assign(new Error(`SSE client not connected: ${e}`),{statusCode:404});return d?(c.subscribeChannel(e,r,o),g?.(e,r,o?{cardId:o}:{})):(c.unsubscribeChannel(e,r,o),_?.(e,r,o?{cardId:o}:{})),{status:"success",data:{boardId:t,clientId:e,channelName:r,subscribed:d,...o?{cardId:o}:{}}}}async function m(s,d){let{cardId:e}=R(s);return await S().setChatProcessing({cardId:e,active:d}),{status:"success",data:{boardId:t,cardId:e,active:d}}}async function p(s){let{cardId:d}=R(s),e=await S().getChatProcessing({cardId:d});return {status:"success",data:{boardId:t,cardId:d,active:e.active}}}async function y(s){let{cardId:d}=R(s),e=T(s);if(!Object.prototype.hasOwnProperty.call(s,"value"))throw Object.assign(new Error("MCP tool requires value"),{statusCode:400});if(e.split(".").includes("visible_controlplane_only")){let r=await N(n().get({params:{id:d}}),"cardStore.get"),o=Array.isArray(r.cards)&&r.cards.length>0&&typeof r.cards[0]=="object"&&!Array.isArray(r.cards[0])?r.cards[0]:null,k=o?q(o,"visible_controlplane_only").value:void 0;if(s.value!==k)throw Object.assign(new Error("MCP tool cannot change the reserved private flag visible_controlplane_only"),{statusCode:403});return {status:"success",data:{boardId:t,cardId:d,key:e}}}return j(await n().patch({params:{id:d,path:`__private.${e}`},body:{value:s.value}}),"cardStore.patch"),{status:"success",data:{boardId:t,cardId:d,key:e}}}async function C(s){let{cardId:d}=R(s),e=T(s),r=await N(n().get({params:{id:d}}),"cardStore.get"),o=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(!o)throw Object.assign(new Error(`Card "${d}" not found`),{statusCode:404});let k=q(o,e);return {status:"success",data:{boardId:t,cardId:d,key:e,exists:k.exists,value:k.value}}}return {requireCardArgs:R,subscribeChat:I,unsubscribeChat:u,watchChannel:b,setChatProcessing:m,getChatProcessing:p,setCardMeta:y,getCardMeta:C}}function it(a){let{boardId:t,boardContexts:i,readChatRecords:c,getChatProcessing:g}=a,_=Number.isInteger(a.chatBootstrapTailTurns)&&a.chatBootstrapTailTurns>0?a.chatBootstrapTailTurns:1;function S(u){return {role:String(u.role||"system"),text:String(u.text||""),files:Array.isArray(u.files)?u.files:[],...typeof u.turn=="string"&&u.turn?{turn:u.turn}:{}}}function n(u){if(u.length===0)return null;if(u.length===1)return u[0];let b=[],m=["completed","eligible","pending","blocked","unresolved","failed","in_progress","orphan_cards"],p={};for(let C of m)p[C]=0;for(let C of u){let s=C,d=Array.isArray(s.cards)?s.cards:[];b.push(...d);for(let e of m)p[e]+=Number(s?.summary?.[e]||0);}let y=u[0];return {...y,cards:b,summary:{...y.summary||{},card_count:b.length,...p}}}async function f(){let u=[];for(let b of i)try{let m=await b.boardOps.buildSseOneShotPayload({});m.status==="success"&&m.data&&u.push(m.data);}catch{}return u}async function h(){let b=(await f()).map(m=>m.statusSnapshot).filter(Boolean);if(b.length===0){let m=i.map(p=>p.notification.status).filter(Boolean);return n(m)}return n(b)}async function w(){let u={},b=await f();for(let m of b)Object.assign(u,m.cardRuntimeById||{});if(Object.keys(u).length>0)return u;for(let m of i)for(let[p,y]of Object.entries(m.notification.computedValues)){let C=m.notification.cards[p];u[p]={schema_version:"v1",card_id:p,card_data:C?.card_data??{},computed_values:y??{}};}return u}async function R(){let u={},b=await f();for(let m of b)Object.assign(u,m.dataObjectsByToken||{});if(Object.keys(u).length===0)for(let m of i)Object.assign(u,m.notification.dataObjects||{});return u}async function I(){let u=await f(),b=u.flatMap(C=>Array.isArray(C.cardDefinitions)?C.cardDefinitions:[]),m={},p={};for(let C of u)Object.assign(m,C.dataObjectsByToken||{}),Object.assign(p,C.cardRuntimeById||{});let y={};for(let C of b){if(!C?.id)continue;let s=C.id;try{let d=await c(s,{tailTurns:_}),e=await g(s);(d.length>0||e)&&(y[s]={messages:d.map(r=>S(r)),receiving:!1,processing:e});}catch{}}return {boardId:t,cardDefinitions:b,statusSnapshot:await h(),dataObjectsByToken:m,cardRuntimeById:p,cardChatsByCardId:y}}return {readStatusSnapshot:h,readCardRuntimeArtifacts:w,readDataObjectsByToken:R,buildPublishedRuntimePayload:I}}function K(a){let t=String(a||"").trim();if(!t)return "upload.bin";let i=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (i>=0?t.slice(i+1):t)||"upload.bin"}function ct(a){let{safeCardId:t,artifactsStores:i,cardFileMetadataStore:c,readCardFromStore:g,updateCardLocalOnly:_,writeChatRecord:S}=a;async function n(w){let R=[];try{let I=await g(w);if(!I)return R;let u=c().read(I.card_data&&typeof I.card_data=="object"?I.card_data:null);for(let b of u)R.push(String(b.stored_name??""));}catch{}return R}async function f(w,R,I,u){let b=t(w),m=i(w),p=K(R),y=await n(w),s=`${String(y.length+1).padStart(3,"0")}-${p}`.slice(-36);if(!m.files)throw Object.assign(new Error(`artifactsStoreRef is not configured for card uploads: ${w}`),{statusCode:500});return await m.files.putBytes(`${b}/${s}`,new Uint8Array(u),I||"application/octet-stream"),{name:p,stored_name:s,size:u.length,mime_type:I||"application/octet-stream",uploaded_at:new Date().toISOString()}}async function h(w,R,I,u,b){if(!u.length)throw Object.assign(new Error("Empty upload body"),{statusCode:400});let m=b?.inChat===true,p=await f(w,R,I,u),y=null;if(await _(w,C=>{let s=new Date().toISOString(),d=C.card_data&&typeof C.card_data=="object"?C.card_data:{};C.card_data=d;let e=c().normalizeIncoming([{name:p.name,stored_name:p.stored_name,size:p.size,mime_type:p.mime_type,uploaded_at:p.uploaded_at||s,chat:m}],s);return y=c().merge(d,e).findIndex(o=>o.stored_name===p.stored_name),C}),m&&b?.suppressChatRecordWrite!==true){let C=typeof y=="number"&&y>=0?` #${y}`:"";await S(w,"system",`file uploaded: ${p.name} as ${p.stored_name}${C}`,[],b?.turnId??"");}return {ok:true,file:{...p,...typeof y=="number"&&y>=0?{file_idx:y}:{},chat:m},...typeof y=="number"&&y>=0?{file_idx:y}:{}}}return {uploadCardFile:h,readCardStoredFileNames:n}}function pt(a){return {"discover.source-kinds":()=>a.discoverSourceKinds(),"inspect.board-runtime-status":()=>a.inspectBoardRuntimeStatus(),"inspect.card-definition-and-runtime":t=>a.inspectCardDefinitionAndRuntime({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")}),"inspect.chat-messages-on-cards":t=>{let i=chunkLPXVVMQT_cjs.b(t,"tail_turns"),c=chunkLPXVVMQT_cjs.b(t,"tail"),g=chunkLPXVVMQT_cjs.a(t,"turn_id"),_=t.all_turns===true,S=chunkLPXVVMQT_cjs.a(t,"tail_turns_before_id");return a.inspectChatMessagesOnCards({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),...i!==void 0?{lastUserTurns:i}:{},...c!==void 0?{tail:c}:{},...g?{turnId:g}:{},..._?{allTurns:true}:{},...S?{tailTurnsBeforeId:S}:{}})},"inspect.file-contents":t=>a.inspectFileContents({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),fileIdx:Number(chunkLPXVVMQT_cjs.b(t,"file_idx"))}),"preflight.validate-candidate-card-definition":t=>a.preflightValidateCandidateCardDefinition({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content")}),"preflight.materialize-candidate-card":t=>a.preflightMaterializeCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockRequires:chunkLPXVVMQT_cjs.d(t,"mock_requires","mock_requires"),mockFetchedSources:chunkLPXVVMQT_cjs.d(t,"mock_fetched_sources","mock_fetched_sources")}),"preflight.probe-single-source-in-candidate-card":t=>a.preflightProbeSingleSourceInCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockProjections:chunkLPXVVMQT_cjs.c(t,"mock_projections"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx")}),"preflight.run-single-source-in-candidate-card":t=>a.preflightRunSingleSourceInCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockProjections:chunkLPXVVMQT_cjs.c(t,"mock_projections"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx")}),"preflight.run-single-source-in-live-card":t=>a.preflightRunSingleSourceInLiveCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),sourceIdx:chunkLPXVVMQT_cjs.e(t,"source_idx","source_idx"),mockRequires:chunkLPXVVMQT_cjs.d(t,"mock_requires","mock_requires")}),"preflight.run-one-cycle-with-candidate-card":t=>a.preflightRunOneCycleWithCandidateCard({candidateCardContent:chunkLPXVVMQT_cjs.d(t,"candidate_card_content","candidate_card_content"),mockRequires:chunkLPXVVMQT_cjs.c(t,"mock_requires")}),"manage.read-card":t=>a.manageReadCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")}),"stage-ai-response-and-any-attachments":t=>{let i=chunkLPXVVMQT_cjs.a(t,"turn_id");if(!i)throw Object.assign(new Error("stage-ai-response-and-any-attachments requires a non-empty turn_id"),{statusCode:400});return a.manageAddChatEntryAndAnyAttachments({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),role:"assistant",...typeof t.text=="string"?{text:t.text}:{},...i?{turn:i}:{},...Array.isArray(t.files)?{files:t.files}:{}})},"stage-ai-failure-message":t=>{let i=chunkLPXVVMQT_cjs.a(t,"turn_id"),c=chunkLPXVVMQT_cjs.a(t,"failure");if(!i)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty turn_id"),{statusCode:400});if(!c)throw Object.assign(new Error("stage-ai-failure-message requires a non-empty failure"),{statusCode:400});return a.manageAddChatEntryAndAnyAttachments({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),role:"system",text:c,turn:i})},"manage.upsert-card":t=>a.manageUpsertCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id"),candidateCardContent:chunkLPXVVMQT_cjs.c(t,"candidate_card_content")}),"manage.remove-card":t=>a.manageRemoveCard({cardId:chunkLPXVVMQT_cjs.a(t,"card_id")})}}function mt(a){return {"webhook.process-accumulated":()=>a.webhookProcessAccumulated(),"webhook.source-fetch-done":t=>a.webhookSourceFetchDone({token:chunkLPXVVMQT_cjs.a(t,"token"),ref:chunkLPXVVMQT_cjs.a(t,"ref")}),"webhook.source-fetch-failed":t=>a.webhookSourceFetchFailed({token:chunkLPXVVMQT_cjs.a(t,"token"),reason:chunkLPXVVMQT_cjs.a(t,"reason")})}}function ft(a){let{boardId:t,uploadCardFile:i,getMcpFacade:c,controlplane:g}=a;function _(n,f){let h=chunkLPXVVMQT_cjs.a(n,"board_id");if(!h)throw Object.assign(new Error(`${f} requires board_id`),{statusCode:400});if(h!==t)throw Object.assign(new Error(`Unknown board_id: ${h}`),{statusCode:400})}function S(n,f){let{cardId:h}=g.requireCardArgs(n),w=chunkLPXVVMQT_cjs.a(n,"turn_id");return _(n,f),c().manageAddChatAttachment({cardId:h,role:chunkLPXVVMQT_cjs.a(n,"role")||"user",...w?{turn:w}:{},files:[{file_name:chunkLPXVVMQT_cjs.a(n,"file_name"),content_type:chunkLPXVVMQT_cjs.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=>(_(n,"list-runtime-cards"),c().listRuntimeCards()),"sse.subscribe-chat":n=>g.subscribeChat(n),"sse.unsubscribe-chat":n=>g.unsubscribeChat(n),"sse.watch-channel":n=>g.watchChannel(n,true),"sse.unwatch-channel":n=>g.watchChannel(n,false),"getstate.is-chat-processing":n=>g.getChatProcessing(n),"setstate.chat-processing-started":n=>g.setChatProcessing(n,true),"setstate.chat-processing-done":n=>g.setChatProcessing(n,false),"getstate.card-private":n=>g.getCardMeta(n),"setstate.card-private":n=>g.setCardMeta(n),"manage.upload-card-file":n=>{let f=chunkLPXVVMQT_cjs.a(n,"card_id"),h=chunkLPXVVMQT_cjs.a(n,"file_name"),w=chunkLPXVVMQT_cjs.a(n,"content_type")||"application/octet-stream",R=chunkLPXVVMQT_cjs.f(n);if(_(n,"manage.upload-card-file"),!f)throw Object.assign(new Error("manage.upload-card-file requires card_id"),{statusCode:400});if(!h)throw Object.assign(new Error("manage.upload-card-file requires file_name"),{statusCode:400});if(!R)throw Object.assign(new Error("manage.upload-card-file requires args.bytes, args.text, or args.base64"),{statusCode:400});return i(f,h,w,R,{inChat:false})},"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:f}=g.requireCardArgs(n),h=chunkLPXVVMQT_cjs.a(n,"role")||"user",w=chunkLPXVVMQT_cjs.a(n,"turn_id");return _(n,"manage.add-chat-entry-and-any-attachments"),c().manageAddChatEntryAndAnyAttachments({cardId:f,role:h,...typeof n.text=="string"?{text:n.text}:{},...w?{turn:w}:{},...Array.isArray(n.files)?{files:n.files}:{}})},"manage.patch-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.patch-card"),c().managePatchCard({cardId:f,patch:chunkLPXVVMQT_cjs.c(n,"patch")},{allowControlplaneOnlyCards:true})},"manage.upsert-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.upsert-card"),c().manageUpsertCard({cardId:f,candidateCardContent:chunkLPXVVMQT_cjs.c(n,"candidate_card_content")},{allowControlplaneOnlyCards:true})},"manage.remove-card":n=>{let{cardId:f}=g.requireCardArgs(n);return _(n,"manage.remove-card"),c().manageRemoveCard({cardId:f},{allowControlplaneOnlyCards:true})},"manage.admin-read-card":async n=>{let{cardId:f}=g.requireCardArgs(n);return {status:"success",data:{cards:await c().adminReadCard({cardId:f})}}},"manage.admin-upsert-card":n=>{let f=chunkLPXVVMQT_cjs.a(n,"board_id"),h=chunkLPXVVMQT_cjs.a(n,"card_id");if(!f)throw Object.assign(new Error("manage.admin-upsert-card requires board_id"),{statusCode:400});if(!h)throw Object.assign(new Error("manage.admin-upsert-card requires card_id"),{statusCode:400});if(f!==t)throw Object.assign(new Error(`Unknown board_id: ${f}`),{statusCode:400});return c().adminUpsertCard({cardId:h,candidateCardContent:chunkLPXVVMQT_cjs.c(n,"candidate_card_content")})}}}function yt(a){let{boardContexts:t,cardOwnerIndex:i,cardContextForCard:c,readStatusSnapshot:g,readDataObjectsByToken:_,readCardRuntimeArtifacts:S,readCardFromStore:n,readCardDefinitions:f,processAccumulatedLaneInternal:h,reportSourceFetched:w,reportSourceFetchFailure:R,uploadCardFile:I,chatStorePublic:u,serverUrl:b,apiBasePath:m}=a;function p(){return t[0]??null}function y(){return {async status(){let e=await g();return e==null?{status:"fail",error:"Board status is unavailable"}:{status:"success",data:e}},async getOutputsDataObject(e){let r=e?.params?.key;return r?{status:"success",data:(await _())[r]}:{status:"fail",error:"getOutputsDataObject requires params.key"}},async getOutputsComputedValues(e){let r=e?.params?.key;return r?{status:"success",data:(await S())[r]?.computed_values}:{status:"fail",error:"getOutputsComputedValues requires params.key"}},async getOutputsFetchedSources(e){let r=e?.params?.key;if(!r)return {status:"fail",error:"getOutputsFetchedSources requires params.key"};let o=c(r)??p();return o?o.boardOps.getOutputsFetchedSources({params:{key:r}}):{status:"fail",error:"Board context is unavailable"}},async removeCard(e){let r=e?.params?.id;if(!r)return {status:"fail",error:"removeCard requires params.id"};let o=c(r)??p();return o?o.boardOps.removeCard({params:{id:r}}):{status:"fail",error:"Board context is unavailable"}},async upsertCard(e){let r=e?.params?.cardId;if(!r)return {status:"fail",error:"upsertCard requires params.cardId"};let o=c(r)??p();if(!o)return {status:"fail",error:"Board context is unavailable"};let k=await o.boardOps.upsertCard({params:{cardId:r,restart:e.params.restart===true}});if(k.status!=="success")return k;if(chunkBQUQTOPB_cjs.a(o.boardAdapter)){let P=await h(true);if(P.status!=="success")return P}return k}}}function C(){let e=()=>{let r=p();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 e().describeTaskExecutorCapabilities(r)},validateCardPreflight(r){return e().validateCardPreflight(r)},evalCardCompute(r){return e().evalCardCompute(r)},probeSourcePreflight(r){return e().probeSourcePreflight(r)},runSourcePreflight(r){return e().runSourcePreflight(r)},simulateCardCycle(r){return e().simulateCardCycle(r)}}}function s(){return {async get(e){let r=typeof e.params?.id=="string"?e.params.id:void 0;if(r){let o=await n(r);return o?{status:"success",data:{cards:[o]}}:{status:"success",data:{cards:[]}}}return {status:"success",data:{cards:await f()}}},async set(e){let r=e.body;if(r==null)return {status:"fail",error:"set requires a body (card object or array of cards)"};let o=Array.isArray(r)?r:[r];for(let k of o){let P=k,A=typeof P.id=="string"?P.id:"";if(!A)return {status:"fail",error:"each card must have a string `id` field"};let E=i.get(A)??0,D=t[E]??p();if(!D)return {status:"fail",error:"Board context is unavailable"};let L=await D.cardStoreOps.set({body:P});if(L.status!=="success")return L;i.set(A,E);}return {status:"success",data:{count:o.length}}},async del(e){let r=[e.params?.id,...e.body?.ids??[]].filter(o=>typeof o=="string"&&!!o);if(r.length===0)return {status:"fail",error:"del requires body.ids (string[]) or params.id"};for(let o of r){let k=c(o)??p();if(!k)return {status:"fail",error:"Board context is unavailable"};let P=await k.cardStoreOps.del({params:{id:o}});if(P.status!=="success")return P;i.delete(o);}return {status:"success",data:{count:r.length}}},async patch(e){let r=typeof e.params?.id=="string"?e.params.id:void 0,o=typeof e.params?.path=="string"?e.params.path:void 0;if(!r||!o)return {status:"fail",error:"patch requires params.id and params.path"};let k=c(r)??p();return k?k.cardStoreOps.patch(e):{status:"fail",error:"Board context is unavailable"}},async appendFiles(e){let r=typeof e.params?.id=="string"?e.params.id:void 0;if(!r)return {status:"fail",error:"appendFiles requires params.id"};let o=c(r)??p();return o?o.cardStoreOps.appendFiles(e):{status:"fail",error:"Board context is unavailable"}}}}function d(){return chunkESTFYRHF_cjs.a({board:y(),nonCore:C(),cardStore:s(),chatStore:u,processAccumulated:()=>h(true),sourceFetchDone:({token:e,ref:r})=>w(e,r),sourceFetchFailed:({token:e,reason:r})=>R(e,r),uploadCardFile({cardId:e,fileName:r,contentType:o,bytes:k,suppressChatRecordWrite:P}){return I(e,r,o,k,{inChat:true,...P===true?{suppressChatRecordWrite:true}:{}})},buildFileDownloadUrl({cardId:e,fileIdx:r,storedName:o}){let k=`${b||""}${m}/cards/${encodeURIComponent(e)}/files/${r}`;return o?`${k}?sn=${encodeURIComponent(o)}`:k},readFetchedSourceJsonByRef({cardId:e,ref:r}){let o=c(e)??p();if(!o||chunkBQUQTOPB_cjs.a(o.boardAdapter))return null;let A=o.boardAdapter.resolveBlob(chunkVQCIOKJV_cjs.b(r)).trim();return A?JSON.parse(A):null}})}return {mcpBoardFacade:y,mcpNonCoreFacade:C,mcpCardStoreFacade:s,createMcpFacade:d}}exports.a=J;exports.b=X;exports.c=Q;exports.d=z;exports.e=Y;exports.f=j;exports.g=N;exports.h=T;exports.i=q;exports.j=ot;exports.k=it;exports.l=ct;exports.m=pt;exports.n=mt;exports.o=ft;exports.p=yt;//# sourceMappingURL=chunk-36KKCQVE.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-36KKCQVE.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 b={$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)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},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"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],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"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}}}}},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}}},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 N=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-3DWVFRQD.cjs', document.baseURI).href))),S=N("./jsonata-sync.cjs"),m=null;var _=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,E=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function O(e){let t=new Set,s;for(_.lastIndex=0;(s=_.exec(e))!==null;)t.add(s[1]);return t}function w(e){let t=E.exec(e);return t?t[1]:null}function h(e,t,s,o){try{S(e);}catch(n){let d=n instanceof Error?n.message:String(n);o.push(`${t}: invalid JSONata expression (${d})`);return}let i=O(e);for(let n of i)s.has(n)||o.push(`${t}: disallowed namespace "${n}" in expression`);}function g(e,t,s){if(Array.isArray(e)){e.forEach((i,n)=>{g(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))g(n,`${t}/${i}`,s);}function T(){if(m)return m;let e=new v.default({allErrors:true});return $__default.default(e),m=e.compile(b),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((c,l)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let r=c;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 F(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,p)=>{if(!r||typeof r!="object"||Array.isArray(r))return;let a=r.expr;typeof a!="string"||a.trim().length===0||h(a,`/compute/${p}/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,p)=>{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/${p}/ref: path "${a}" must start with a valid namespace (${[...i].join(", ")})`):i.has(u)||t.push(`/provides/${p}/ref: disallowed namespace "${u}" in path "${a}" (valid: ${[...i].join(", ")})`);});let d=s.view;d&&typeof d=="object"&&!Array.isArray(d)&&g(d,"/view",t);let c=new Set(["card_data","requires"]),l=s.source_defs;return Array.isArray(l)&&l.forEach((r,p)=>{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/${p}/skip_when`,c,t);let f=a.projections;if(!(!f||typeof f!="object"||Array.isArray(f)))for(let[x,y]of Object.entries(f))typeof y!="string"||y.trim().length===0||h(y,`/source_defs/${p}/projections/${x}`,c,t);}),{ok:t.length===0,errors:t}}function L(e){return P(e)}function P(e){let t=R(e);if(!t.ok)return t;let s=F(e);return s.ok?{ok:true,errors:[]}:{ok:false,errors:s.errors}}
|
|
2
|
+
exports.a=R;exports.b=F;exports.c=L;exports.d=P;//# sourceMappingURL=chunk-3DWVFRQD.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-3DWVFRQD.cjs.map
|