yaml-flow 8.7.1 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/adapters/firebase-storage.js +2 -2
- package/browser/adapters/firestore-storage.js +2 -2
- package/browser/adapters/localstorage-storage.js +3 -3
- package/browser/asset-integrity.json +9 -13
- package/browser/server-runtime-controlface.js +5 -5
- package/examples/ARCHITECTURE.md +0 -27
- package/examples/board/server/board-server.js +150 -100
- package/examples/board/server/board-worker/source_def_flows.json +0 -8
- package/examples/board/server/board-worker/task-executor.js +1 -3
- package/examples/board/test/server-http-test.js +108 -73
- package/examples/board-firestore/server/worker.js +8 -0
- package/examples/portfolio-tracker/portfolio-tracker.js +11 -1
- package/examples/portfolio-tracker/test/portfolio-t4.js +12 -2
- package/lib/{artifacts-store-lib-D9nMkVcE.d.cts → artifacts-store-lib-C6qBpMfU.d.cts} +1 -1
- package/lib/{artifacts-store-lib-DSSMqVL2.d.ts → artifacts-store-lib-D4qf7Q-7.d.ts} +1 -1
- package/lib/artifacts-store-public.d.cts +3 -3
- package/lib/artifacts-store-public.d.ts +3 -3
- package/lib/board-live-cards-mcp.cjs +1 -1
- package/lib/board-live-cards-mcp.d.cts +6 -7
- package/lib/board-live-cards-mcp.d.ts +6 -7
- package/lib/board-live-cards-mcp.js +1 -1
- package/lib/board-live-cards-node.cjs +8 -8
- package/lib/board-live-cards-node.d.cts +15 -14
- package/lib/board-live-cards-node.d.ts +15 -14
- package/lib/board-live-cards-node.js +8 -8
- package/lib/{board-live-cards-public-LlVUQPL2.d.cts → board-live-cards-public-BT5HrgqZ.d.cts} +82 -59
- package/lib/{board-live-cards-public-JNRKfBZy.d.ts → board-live-cards-public-DSRamFm8.d.ts} +82 -59
- package/lib/{board-live-cards-public-async-Di9QB141.d.cts → board-live-cards-public-async-CYjr4mgX.d.cts} +18 -8
- package/lib/{board-live-cards-public-async-fwd1QI82.d.ts → board-live-cards-public-async-DlyC3PgC.d.ts} +18 -8
- package/lib/board-live-cards-public.cjs +1 -1
- package/lib/board-live-cards-public.d.cts +2 -2
- package/lib/board-live-cards-public.d.ts +2 -2
- 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.d.cts +6 -8
- package/lib/board-live-cards-server-runtime.d.ts +6 -8
- package/lib/board-live-cards-server-runtime.js +1 -1
- package/lib/{board-platform-adapter-async-BfHmHdx2.d.cts → board-platform-adapter-async-BZIftm36.d.cts} +18 -14
- package/lib/{board-platform-adapter-async-DYahVzIK.d.ts → board-platform-adapter-async-JP9V-U5E.d.ts} +18 -14
- package/lib/board-worker-adapter.cjs +1 -24
- package/lib/board-worker-adapter.d.cts +68 -3
- package/lib/board-worker-adapter.d.ts +68 -3
- package/lib/board-worker-adapter.js +1 -24
- package/lib/card-store-public.d.cts +2 -2
- package/lib/card-store-public.d.ts +2 -2
- package/lib/chat-store-public.cjs +1 -1
- package/lib/chat-store-public.d.cts +20 -20
- package/lib/chat-store-public.d.ts +20 -20
- package/lib/chat-store-public.js +1 -1
- package/lib/chunk-2GSI6C45.js +7 -0
- package/lib/chunk-35N7ONTH.js +2 -0
- package/lib/chunk-37HDEW26.cjs +2 -0
- package/lib/{chunk-PMUSJQSR.cjs → chunk-3CZCGNY4.cjs} +2 -2
- package/lib/{chunk-BQS3EIEK.js → chunk-44L64VQ2.js} +3 -3
- package/lib/chunk-6OPXQPSC.js +2 -0
- package/lib/chunk-7BTZCOT5.js +2 -0
- package/lib/{chunk-U2N6MCD5.cjs → chunk-7JVHYHT2.cjs} +2 -2
- package/lib/chunk-7QZ267XP.cjs +2 -0
- package/lib/{chunk-XQRNDX4Q.js → chunk-ANKA7HEJ.js} +2 -2
- package/lib/{chunk-KAWQPLIE.cjs → chunk-BQUQTOPB.cjs} +2 -2
- package/lib/chunk-CMFD27ZC.cjs +3 -0
- package/lib/chunk-DOFNXJ4C.js +3 -0
- package/lib/chunk-ETW3BXHD.cjs +2 -0
- package/lib/{chunk-SGV7PU4H.js → chunk-FOFGEABN.js} +2 -2
- package/lib/chunk-GPCMBPLK.cjs +2 -0
- package/lib/chunk-GU3T75C4.js +3 -0
- package/lib/chunk-H3EHFCDZ.js +3 -0
- package/lib/chunk-H4TYOSMD.cjs +45 -0
- package/lib/chunk-HFW7E2Z7.cjs +4 -0
- package/lib/chunk-IQIZA7TN.cjs +7 -0
- package/lib/chunk-J4MHQ7JF.js +45 -0
- package/lib/chunk-MCPADH33.cjs +2 -0
- package/lib/chunk-NBJTYAYN.cjs +2 -0
- package/lib/chunk-NDAKMJQK.cjs +3 -0
- package/lib/chunk-NNSBBO5R.js +2 -0
- package/lib/chunk-NU5NO5NM.js +2 -0
- package/lib/chunk-O4RKTQBP.cjs +3 -0
- package/lib/chunk-O5UYCGIN.js +2 -0
- package/lib/chunk-Q3OTUDIE.js +2 -0
- package/lib/chunk-R44X3RQB.cjs +2 -0
- package/lib/chunk-RKKSVOP2.js +2 -0
- package/lib/chunk-UB54HZA4.cjs +2 -0
- package/lib/{chunk-CIAJNUR4.js → chunk-VGDLSS2H.js} +2 -2
- package/lib/{chunk-SFVO2LB2.cjs → chunk-VQCIOKJV.cjs} +3 -3
- package/lib/chunk-VS3BXEYK.js +4 -0
- package/lib/chunk-Y4WK7HE4.js +2 -0
- package/lib/chunk-ZK3E7L4Y.cjs +2 -0
- package/lib/cloud-storage.cjs +1 -1
- package/lib/cloud-storage.d.cts +6 -6
- package/lib/cloud-storage.d.ts +6 -6
- package/lib/cloud-storage.js +1 -1
- package/lib/execution-refs.cjs +1 -1
- package/lib/execution-refs.js +1 -1
- package/lib/firebase-storage/index.cjs +2 -2
- package/lib/firebase-storage/index.d.cts +2 -2
- package/lib/firebase-storage/index.d.ts +2 -2
- package/lib/firebase-storage/index.js +2 -2
- package/lib/firestore-storage/index.cjs +2 -2
- package/lib/firestore-storage/index.d.cts +12 -10
- package/lib/firestore-storage/index.d.ts +12 -10
- package/lib/firestore-storage/index.js +2 -2
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/localstorage-storage/index.cjs +1 -1
- package/lib/localstorage-storage/index.d.cts +10 -6
- package/lib/localstorage-storage/index.d.ts +10 -6
- package/lib/localstorage-storage/index.js +1 -1
- package/lib/{mcp-tool-registries-W3TRj6O5.d.cts → mcp-tool-registries-CRtea2x4.d.cts} +3 -0
- package/lib/{mcp-tool-registries-BBObLYga.d.ts → mcp-tool-registries-D3rWSppt.d.ts} +3 -0
- package/lib/server-jobs-queue-runner/index.cjs +1 -1
- package/lib/server-jobs-queue-runner/index.d.cts +12 -9
- package/lib/server-jobs-queue-runner/index.d.ts +12 -9
- package/lib/server-jobs-queue-runner/index.js +1 -1
- package/lib/server-runtime/index.cjs +1 -1
- package/lib/server-runtime/index.d.cts +7 -9
- package/lib/server-runtime/index.d.ts +7 -9
- package/lib/server-runtime/index.js +1 -1
- package/lib/server-runtime-agentface/index.d.cts +7 -9
- package/lib/server-runtime-agentface/index.d.ts +7 -9
- package/lib/server-runtime-controlface/index.cjs +1 -1
- package/lib/server-runtime-controlface/index.d.cts +8 -9
- package/lib/server-runtime-controlface/index.d.ts +8 -9
- package/lib/server-runtime-controlface/index.js +1 -1
- package/lib/server-runtime-core/index.cjs +1 -1
- package/lib/server-runtime-core/index.d.cts +59 -21
- package/lib/server-runtime-core/index.d.ts +59 -21
- package/lib/server-runtime-core/index.js +1 -1
- package/lib/server-runtime-watchers/index.cjs +1 -1
- package/lib/server-runtime-watchers/index.d.cts +9 -65
- package/lib/server-runtime-watchers/index.d.ts +9 -65
- package/lib/server-runtime-watchers/index.js +1 -1
- package/lib/server-runtime-webhooks/index.d.cts +7 -9
- package/lib/server-runtime-webhooks/index.d.ts +7 -9
- package/lib/sse-hub-CYXisfXJ.d.cts +63 -0
- package/lib/sse-hub-Dodwtc3_.d.ts +63 -0
- package/lib/step-machine-public/index.cjs +1 -1
- package/lib/step-machine-public/index.d.cts +1 -1
- package/lib/step-machine-public/index.d.ts +1 -1
- package/lib/step-machine-public/index.js +1 -1
- package/lib/{storage-async-interface-BRR4eBjx.d.cts → storage-async-interface-CG0bMqvE.d.ts} +20 -1
- package/lib/{storage-async-interface-DhlOVPSp.d.ts → storage-async-interface-CyO-zwVQ.d.cts} +20 -1
- package/lib/{storage-interface-BFiD3kyB.d.ts → storage-interface-D-iEiTJA.d.cts} +45 -1
- package/lib/{storage-interface-BFiD3kyB.d.cts → storage-interface-D-iEiTJA.d.ts} +45 -1
- package/lib/stores/index.d.cts +1 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/kv.d.cts +1 -1
- package/lib/stores/kv.d.ts +1 -1
- package/lib/{types-SO5OZm4s.d.ts → types-BtH3scgE.d.ts} +64 -29
- package/lib/{types-Ba8H5_Wo.d.cts → types-Ch0u3FKP.d.cts} +64 -29
- package/package.json +4 -5
- package/browser/board-livecards-client.js +0 -2
- package/examples/board/demo-shell-with-server.html +0 -272
- package/examples/board/doc.html +0 -465
- package/examples/board/server-config.json +0 -24
- package/lib/chat-storage-lib-B9Q34Dyv.d.cts +0 -54
- package/lib/chat-storage-lib-DB9iSai2.d.ts +0 -54
- package/lib/chunk-5XHOHTLZ.cjs +0 -2
- package/lib/chunk-6APH25VI.js +0 -2
- package/lib/chunk-76C7N4YT.js +0 -3
- package/lib/chunk-76ON3V7R.js +0 -2
- package/lib/chunk-7ICPAABP.cjs +0 -7
- package/lib/chunk-ASR44K7H.cjs +0 -3
- package/lib/chunk-CPAXTVBQ.cjs +0 -2
- package/lib/chunk-EGRHWZRV.js +0 -2
- package/lib/chunk-EZENHAVZ.cjs +0 -2
- package/lib/chunk-GL2OHR2E.cjs +0 -2
- package/lib/chunk-GYQXDNNI.cjs +0 -2
- package/lib/chunk-IPLSRN6P.cjs +0 -4
- package/lib/chunk-J6EGN6S4.cjs +0 -3
- package/lib/chunk-JH37NJGP.js +0 -3
- package/lib/chunk-JJL5VOQZ.cjs +0 -3
- package/lib/chunk-NJJ7WEDT.cjs +0 -2
- package/lib/chunk-NKIQRCOM.cjs +0 -2
- package/lib/chunk-PBOQ4HYB.cjs +0 -2
- package/lib/chunk-PRKRXAVN.js +0 -3
- package/lib/chunk-QJVR3FWQ.js +0 -2
- package/lib/chunk-S44QZUDX.js +0 -2
- package/lib/chunk-TSN3RTXT.js +0 -4
- package/lib/chunk-VXJHBWK3.js +0 -2
- package/lib/chunk-WHDEBJLT.js +0 -7
- package/lib/chunk-YGALANRO.js +0 -2
- package/lib/chunk-ZCNN6XPV.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import {a as a$2}from'./chunk-Y4WK7HE4.js';export{a as createChatStorage,c as createInMemoryChatStorage}from'./chunk-Y4WK7HE4.js';import {a as a$3}from'./chunk-O5UYCGIN.js';export{a as createArtifactsStore,c as createCardFileMetadataStore,b as createFileArtifactsStore}from'./chunk-O5UYCGIN.js';import {a as a$4}from'./chunk-RKKSVOP2.js';export{a as createBoardWorkerStore,b as createQueueLaneRegistry}from'./chunk-RKKSVOP2.js';import {a}from'./chunk-VGDLSS2H.js';import'./chunk-HEEDJEKM.js';import {g,y}from'./chunk-DOFNXJ4C.js';export{n as BOARD_GRAPH_KEY,u as EMPTY_CONFIG,m as SNAPSHOT_SCHEMA_VERSION_V1,z as createBoardLiveCardsNonCorePublic,y as createBoardLiveCardsPublic,l as createCardStore,e as createHttpBoardCallbackTransport,f as createInProcessBoardCallbackTransport,g as createLocalNodeBoardCallbackTransport}from'./chunk-DOFNXJ4C.js';export{a as executionRefFromScriptPath,c as parseExecutionRef,b as serializeExecutionRef}from'./chunk-ANKA7HEJ.js';import {a as a$1,b}from'./chunk-44L64VQ2.js';export{b as parseRef,a as serializeRef}from'./chunk-44L64VQ2.js';import'./chunk-VGT3TRQG.js';import'./chunk-WDPOGXTY.js';export{a as createBoardLiveCardsMcp}from'./chunk-35N7ONTH.js';import'./chunk-JMDHDY6M.js';import {d}from'./chunk-3KC6LBOG.js';import'./chunk-MNEOJWPS.js';export{a as createCardStorePublic}from'./chunk-KBELAKIY.js';export{a as createArtifactsStorePublic}from'./chunk-X3LC4LII.js';import {h}from'./chunk-J4MHQ7JF.js';import'./chunk-FW4363Y4.js';import {spawnSync,spawn,execFile,execFileSync}from'child_process';import*as i from'fs';import*as Be from'os';import*as S from'path';import*as Ie from'net';import {fileURLToPath}from'url';import {randomUUID,createHash}from'crypto';import {createRequire}from'module';import {lockSync}from'proper-lockfile';function T(...e){return S.join(...e)}function Fe(e){return S.isAbsolute(e)}function Z(){return randomUUID()}function Ce(e){return createHash("sha256").update(e).digest("hex")}function je(e){return S.dirname(fileURLToPath(e))}function vt(e){if(typeof e=="object"&&e!==null){let{command:r,args:o=[],...n}=e,s=Te(r,o);return {...n,command:s.command,args:s.args}}let t=Me(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Te(t[0],t.slice(1))}function Te(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 Me(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 $e(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Pe(e,t){let{command:r,args:o=[],cwd:n,env:s,timeoutMs:c}=e;return execFileSync(r,o,{shell:$e(r),timeout:c,encoding:t?.encoding??"utf-8",cwd:n,windowsHide:true,env:s?{...process.env,...s}:void 0,input:t?.input})}function kt(e,t){let{command:r,args:o=[],cwd:n,env:s,timeoutMs:c=3e4}=e;execFile(r,o,{shell:$e(r),encoding:"utf8",windowsHide:true,timeout:c,maxBuffer:10*1024*1024,cwd:n,env:s?{...process.env,...s}:void 0},(l,y,a)=>t(l??null,y,a));}function Le(e,t,r){let o=S.join(e,"board-live-cards-cli.js");if(i.existsSync(o))return {cmd:process.execPath,args:[o,t,...r]};let n=S.join(e,"board-live-cards-cli.ts"),c=[S.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),S.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),S.join(e,"..","..","..","node_modules",".bin","tsx"),S.join(e,"..","..","node_modules",".bin","tsx")].find(y=>i.existsSync(y));return i.existsSync(n)&&c?{cmd:process.execPath,args:[c,n,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",n,t,...r]}}function qe(e){let t=S.join(e,"board-live-cards-cli.mjs");if(i.existsSync(t))return t;let r=S.join(e,"..","..","..","dev","board-live-cards-cli.js");if(i.existsSync(r))return r;let o=S.join(e,"..","..","dev","board-live-cards-cli.js");if(i.existsSync(o))return o;let n=S.join(e,"board-live-cards-cli.js");if(i.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 bt(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:S.join(Be.tmpdir(),`${e}.sock`)}var Y=new Map;function Oe(e,t,r){if(t.length===0)return;let o=t.map(l=>JSON.stringify(l)).join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`,o=Z.get(e);if(o&&!o.socket.destroyed){o.ready?o.socket.write(n):o.queue.push(n);return}let s=vt(e),u=Te.createConnection(s);o={socket:u,ready:false,queue:[n]},Z.set(e,o),u.on("connect",()=>{o.ready=true;for(let l of o.queue)u.write(l);o.queue.length=0;}),u.on("error",l=>{r?.(`[named-pipe publish] ${s}: ${l instanceof Error?l.message:String(l)}`),Z.delete(e);}),u.on("close",()=>{Z.delete(e);});}function Le(){return {executeSync(e,t,r){return je({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){wt({command:e,args:t},r);},resolveInvocation(e,t){let r=kt({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Me}}function fe(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:n=>e.workerStore.nackRequest(r.messageId,r.leaseToken,n)}))},async handle(t){await e.handleRequest(t.args,t);},onError:e.onError}}function pe(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:n=>e.queueStorage.nack(r.id,r.leaseToken,n)}))},handle:e.handleMessage,onError:e.onError}}async function Qe(e,t){try{await e.handle(t.message,t),await t.ack();}catch(r){let n=t.attempt>=Math.max(1,Math.floor(e.maxAttempts??5));await t.nack({dead:n,reason:r instanceof Error?r.message:String(r)}),e.onError?.(r,t);}}function Oe(e){let t=Math.max(1,Math.floor(e.pollIntervalMs??250)),r=Math.max(1,Math.floor(e.visibilityMs??6e4)),n=Math.max(1,Math.floor(e.concurrency??1)),o=false,s=false;async function u(){if(!(o||s)){s=true;try{let g=await e.lease({max:n,visibilityMs:r});for(let i of g)await Qe(e,i);}finally{s=false;}}}let l=setInterval(()=>{u();},t);return typeof l.unref=="function"&&l.unref(),u(),()=>{o=true,clearInterval(l);}}async function bt(e){let t=Math.max(1,Math.floor(e.visibilityMs??6e4)),r=Math.max(1,Math.floor(e.concurrency??1)),n=await e.lease({max:r,visibilityMs:t});for(let o of n)await Qe(e,o);return n.length}async function ee(e,t){let r=Math.max(1,Math.floor(t?.maxPasses??256)),n=0;for(let o=0;o<r;o+=1){let s=await bt(e);if(n+=s,s<=0)return n}throw new Error(`drainQueueLaneToIdle exceeded ${r} passes for lane "${e.id}"`)}function At(e){let r=(Array.isArray(e)?e:e.lanes).map(n=>Oe(n));return ()=>{for(let n of r)n();}}var Tt=createRequire(import.meta.url);function Bt(e){return typeof e=="object"?e:b$1(e)}function _e(e){let t=y.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=y.dirname(Tt.resolve("yaml-flow/package.json")),n=t.replace(/\.[^.]+$/,""),o=y.join(r,"cli","bundled",`${n}.mjs`);if(a.existsSync(o))return o;let s=y.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 $(e){let t=Bt(e);return t.kind==="yaml-flow-cli"?_e(t.value):t.value}function It(e,t){let r=$(e);switch(r){case "source-cli-task-executor":{let n=y.join(t,"source-cli-task-executor.js");if(a.existsSync(n))return {command:process.execPath,args:[n]};let o=y.join(t,"source-cli-task-executor.ts"),s=y.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),u=y.join(t,"..","..","node_modules",".bin","tsx"),l=a.existsSync(s)?s:u;return a.existsSync(o)&&a.existsSync(l)?{command:process.execPath,args:[l,o]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:o}=$e(t,"_",[]);return {command:n,args:o}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Ct(e,t){if(e.howToRun==="built-in"){let{command:n,args:o}=It(e.whatToRun,t);return {command:n,baseArgs:o}}let r=(typeof e.whatToRun=="object",$(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 te(e,t){return Ct(e,t)}var ge=new Map;function Mt(e,t){let r=String(e||"").trim();if(!r)throw new Error("registerInProcessExecutionHandler: key is required");ge.set(r,t);}function Ft(e){let t=String(e||"").trim();t&&ge.delete(t);}function Ne(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),n=r[r.length-1];return JSON.parse(n)}}function Je(e,t){return {...t,whatToRun:$(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function me(e,t,r="invokeExecutionRef"){return a$1(e,t,r)}function De(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 n=e,o=n.status==="success"?"success":n.status==="fail"?"failure":n.status,s=n.data&&typeof n.data=="object"&&!Array.isArray(n.data)?n.data:n.data===void 0?{}:{stdout:n.data};return {result:o,data:s,...typeof n.error=="string"?{error:n.error}:{},...t||{}}}return {result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e},...t||{}}}function j(e){return {result:"failure",data:{error:e}}}function L(e,t,r){let n=r?.label??"invokeExecutionRefSync",o=r?.cliDir??r?.cwd??process.cwd(),s;try{s=me(e.argsMassaging,Je(e,t),n);}catch(d){let f=d instanceof Error?d.message:String(d);return j(f)}let u;try{u=te(e,o);}catch(d){let f=d instanceof Error?d.message:String(d);return j(`[${n}] ref resolution failed: ${f}`)}let l=[...u.baseArgs,...s.cmdArgs??[]],g=JSON.stringify(s.stdin??t),i=Le(),c;try{c=i.executeSync(u.command,l,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:g});}catch(d){let f=d,m=(f.stderr?String(f.stderr):"").trim(),S=typeof f.status=="number"?f.status:"unknown",h=m||f.message;return j(`[${n}] ref exited with status ${S}${h?`: ${h}`:""}`)}try{return De(Ne(c))}catch{return {result:"success",data:{stdout:c.trim()}}}}async function We(e,t,r){let n=r?.label??"invokeExecutionRef",o;try{o=me(e.argsMassaging,Je(e,t),n);}catch(d){let f=d instanceof Error?d.message:String(d);return j(f)}let s=$(e.whatToRun),u=o.headers?{"Content-Type":"application/json",...o.headers}:{"Content-Type":"application/json"},l=o.url??s,g;if(e.howToRun==="http:get"){let d=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:t,f=new URLSearchParams(Object.entries(d).filter(([,m])=>m!=null).map(([m,S])=>[m,String(S)]));f.size>0&&(l=`${l}${l.includes("?")?"&":"?"}${f.toString()}`);}else g=JSON.stringify(o.body??t);let i={method:e.howToRun==="http:get"?"GET":"POST",headers:u,body:g},c=0;for(;;)try{let d=await fetch(l,i);if(!d.ok){let h=await d.text().catch(()=>"");return j(`[${n}] HTTP ${d.status}${h?`: ${h}`:""}`)}let f={};d.headers.forEach((h,w)=>{f[w]=h;});let m=new Uint8Array(await d.arrayBuffer());if(m.byteLength===0)return {result:"success",data:{},headers:f};let S=new TextDecoder().decode(m);try{return De(Ne(S),{headers:f})}catch{return {result:"success",data:{stdout:S},headers:f}}}catch(d){let f=d?.cause,m=f&&typeof f=="object"&&"code"in f?String(f.code||""):"";if((m==="ECONNRESET"||m==="UND_ERR_SOCKET")&&c===0){c+=1;continue}let h=d instanceof Error?d.message:String(d),w=f instanceof Error?`${f.name}: ${f.message}${m?` [${m}]`:""}`:f?String(f):"",p=o.url??s??"",x=`${h}${w?` (cause: ${w})`:""}${p?` url=${p}`:""}`;return j(`[${n}] ${x}`)}}async function jt(e,t,r){let n=r?.label??"invokeExecutionRef",o=$(e.whatToRun).trim();if(!o)return j(`[${n}] in-process-loop requires a non-empty handler key`);let s=ge.get(o);if(!s)return j(`[${n}] no in-process handler registered for: ${o}`);try{return await s(e,t,r)}catch(u){let l=u instanceof Error?u.message:String(u);return j(`[${n}] ${l}`)}}var $t={"local-node":async(e,t,r)=>L(e,t,r),"local-python":async(e,t,r)=>L(e,t,r),"local-process":async(e,t,r)=>L(e,t,r),"built-in":async(e,t,r)=>L(e,t,r),"http:post":We,"http:get":We,"in-process-loop":jt},Pt={"local-node":L,"local-python":L,"local-process":L,"built-in":L};async function H(e,t,r){let n=r?.transports?.[e.howToRun]??$t[e.howToRun];return n?n(e,t,r):j(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function ye(e,t,r){let n=r?.syncTransports?.[e.howToRun]??Pt[e.howToRun];return n?n(e,t,r):j(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function qt(e){return {invoke(t,r){return H(t,r,e)},invokeSync(t,r){return ye(t,r,e)}}}function Lt(e,t,r){return ye(e,t,r)}function he(e){return {messageId:e.id,enqueuedAt:e.enqueuedAt,attempt:e.attempt,request:e.body}}function Qt(e){return {...he(e),leaseToken:e.leaseToken,leaseExpiresAt:e.leaseExpiresAt}}function Ot(e){return {...he(e),reason:e.reason}}function K(e){return {enqueueRequest(t){return e.enqueue(t).id},enqueueRequestIfAbsent:e.enqueueIfAbsent?(t,r)=>{let n=e.enqueueIfAbsent(t,r);return n?n.id:null}:void 0,leaseRequests(t){return e.lease(t).map(Qt)},ackRequest(t,r){return e.ack(t,r)},nackRequest(t,r,n){return e.nack(t,r,n)},peekActive(){return e.peekActive().map(he)},peekDeadLetter(){return e.peekDeadLetter().map(Ot)}}}function C(e,t){if(process.platform!=="win32"){a.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{a.renameSync(e,t);return}catch(o){let s=o.code;if((s==="EPERM"||s==="EBUSY")&&n<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[n]);continue}throw o}}function N(e){function t(o){return y.join(e,...o.split("/"))}function r(o){return y.relative(e,o).replace(/\\/g,"/")}function n(o,s){if(a.existsSync(o))for(let u of a.readdirSync(o,{withFileTypes:true})){let l=y.join(o,u.name);if(u.isDirectory()){n(l,s);continue}u.isFile()&&s.push(r(l));}}return {read(o){let s=t(o);if(!a.existsSync(s))return null;try{return a.readFileSync(s,"utf-8")}catch{return null}},write(o,s){let u=t(o),l=`${u}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(y.dirname(u),{recursive:true}),a.writeFileSync(l,s,"utf-8"),C(l,u);},exists(o){return a.existsSync(t(o))},remove(o){let s=t(o);try{a.existsSync(s)&&a.unlinkSync(s);}catch{}},readBytes(o){let s=t(o);if(!a.existsSync(s))return null;try{return new Uint8Array(a.readFileSync(s))}catch{return null}},writeBytes(o,s){let u=t(o),l=`${u}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(y.dirname(u),{recursive:true}),a.writeFileSync(l,Buffer.from(s)),C(l,u);},listKeys(o){let s=[];n(e,s);let u=s.sort();return o?u.filter(l=>l.startsWith(o)):u},stat(o){let s=t(o);if(!a.existsSync(s))return null;try{let u=a.statSync(s);return {key:o,size:Number(u.size||0),updatedAt:new Date(u.mtimeMs).toISOString()}}catch{return null}},keyRef(o){return {kind:"fs-path",value:t(o)}}}}function ke(){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(y.dirname(e),{recursive:true}),a.writeFileSync(r,t,"utf-8"),C(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(y.dirname(e),{recursive:true}),a.writeFileSync(r,Buffer.from(t)),C(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 []}}}function U(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;a.mkdirSync(y.dirname(e),{recursive:true}),a.writeFileSync(r,JSON.stringify(t,null,2),"utf-8"),C(r,e);}function _(e){if(!a.existsSync(e))return null;try{return JSON.parse(a.readFileSync(e,"utf-8"))}catch{return null}}function V(e){return a.existsSync(e)?a.readdirSync(e).filter(t=>t.endsWith(".json")).sort().map(t=>y.join(e,t)):[]}function z(e){return {id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}}function Nt(e){return {...z(e),leaseToken:String(e.leaseToken||""),leaseExpiresAt:String(e.leaseExpiresAt||"")}}function Jt(e){return {...z(e),reason:e.reason}}function J(e){let t=y.join(e,"active"),r=y.join(e,"leased"),n=y.join(e,"done"),o=y.join(e,"dead");for(let c of [t,r,n,o])a.mkdirSync(c,{recursive:true});function s(c){let d=String(c.enqueuedAt||new Date().toISOString()).replace(/[:.]/g,"-");return y.join(t,`${d}-${c.id}.json`)}function u(c){return y.join(r,`${c}.json`)}function l(c){return y.join(n,`${c}.json`)}function g(c){return y.join(o,`${c}.json`)}function i(){let c=Date.now();for(let d of V(r)){let f=_(d);if(!f?.leaseExpiresAt)continue;let m=Date.parse(f.leaseExpiresAt);if(Number.isNaN(m)||m>c)continue;let S={id:f.id,body:f.body,enqueuedAt:f.enqueuedAt,attempt:f.attempt};U(s(S),S);try{a.unlinkSync(d);}catch{}}}return {enqueue(c){let d={id:randomUUID(),body:c,enqueuedAt:new Date().toISOString(),attempt:0};return U(s(d),d),z(d)},enqueueIfAbsent(c,d){i();for(let m of [t,r])for(let S of V(m))if(_(S)?.dedupKey===d)return null;let f={id:randomUUID(),body:c,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:d};return U(s(f),f),z(f)},lease(c){i();let d=Math.max(1,Math.floor(c?.max??1)),f=Math.max(1,Math.floor(c?.visibilityMs??6e4)),m=[];for(let S of V(t)){if(m.length>=d)break;let h=_(S);if(!h)continue;let w=u(h.id);try{C(S,w);}catch{continue}let p={...h,attempt:(Number(h.attempt)||0)+1,leaseToken:randomUUID(),leaseExpiresAt:new Date(Date.now()+f).toISOString()};U(w,p),m.push(Nt(p));}return m},ack(c,d){let f=u(c),m=_(f);if(!m||m.leaseToken!==d)return false;try{C(f,l(c));}catch{return false}return true},nack(c,d,f){let m=u(c),S=_(m);if(!S||S.leaseToken!==d)return false;let h={id:S.id,body:S.body,enqueuedAt:S.enqueuedAt,attempt:S.attempt};f?.dead?(h.reason=f.reason,U(g(c),h)):U(s(h),h);try{a.unlinkSync(m);}catch{}return true},peekActive(c){return i(),V(t).map(d=>_(d)).filter(d=>!!d).map(z)},peekDeadLetter(c){return V(o).map(d=>_(d)).filter(d=>!!d).map(Jt)}}}var Se="__scratch-marker",Re="__scratch-config.json",Dt=1440*60*1e3,Ht=720*60*1e3,Kt=500;function He(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function G(e){a.mkdirSync(e,{recursive:true});let t=y.join(e,Se),r=y.join(e,Re),n=!a.existsSync(t);if(n)try{a.writeFileSync(t,`scratch-store
|
|
3
|
+
`,n=Y.get(e);if(n&&!n.socket.destroyed){n.ready?n.socket.write(o):n.queue.push(o);return}let s=bt(e),c=Ie.createConnection(s);n={socket:c,ready:false,queue:[o]},Y.set(e,n),c.on("connect",()=>{n.ready=true;for(let l of n.queue)c.write(l);n.queue.length=0;}),c.on("error",l=>{r?.(`[named-pipe publish] ${s}: ${l instanceof Error?l.message:String(l)}`),Y.delete(e);}),c.on("close",()=>{Y.delete(e);});}function Qe(){return {executeSync(e,t,r){return Pe({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){kt({command:e,args:t},r);},resolveInvocation(e,t){let r=vt({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:Me}}function pe(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 ge(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 _e(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 Ne(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 c(){if(!(n||s)){s=true;try{let y=await e.lease({max:o,visibilityMs:r});for(let a of y)await _e(e,a);}finally{s=false;}}}let l=setInterval(()=>{c();},t);return typeof l.unref=="function"&&l.unref(),c(),()=>{n=true,clearInterval(l);}}async function At(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 _e(e,n);return o.length}async function X(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 At(e);if(o+=s,s<=0)return o}throw new Error(`drainQueueLaneToIdle exceeded ${r} passes for lane "${e.id}"`)}function Et(e){let r=(Array.isArray(e)?e:e.lanes).map(o=>Ne(o));return ()=>{for(let o of r)o();}}var Bt=createRequire(import.meta.url);function It(e){return typeof e=="object"?e:b(e)}function We(e){let t=S.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=S.dirname(Bt.resolve("yaml-flow/package.json")),o=t.replace(/\.[^.]+$/,""),n=S.join(r,"cli","bundled",`${o}.mjs`);if(i.existsSync(n))return n;let s=S.join(r,"cli","node",t);if(i.existsSync(s))return s;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function P(e){let t=It(e);return t.kind==="yaml-flow-cli"?We(t.value):t.value}function Ft(e,t){let r=P(e);switch(r){case "source-cli-task-executor":{let o=S.join(t,"source-cli-task-executor.js");if(i.existsSync(o))return {command:process.execPath,args:[o]};let n=S.join(t,"source-cli-task-executor.ts"),s=S.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),c=S.join(t,"..","..","node_modules",".bin","tsx"),l=i.existsSync(s)?s:c;return i.existsSync(n)&&i.existsSync(l)?{command:process.execPath,args:[l,n]}:{command:process.execPath,args:[o]}}case "board-live-cards":{let{cmd:o,args:n}=Le(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 Ct(e,t){if(e.howToRun==="built-in"){let{command:o,args:n}=Ft(e.whatToRun,t);return {command:o,baseArgs:n}}let r=(typeof e.whatToRun=="object",P(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 ee(e,t){return Ct(e,t)}var me=new Map;function jt(e,t){let r=String(e||"").trim();if(!r)throw new Error("registerInProcessExecutionHandler: key is required");me.set(r,t);}function Mt(e){let t=String(e||"").trim();t&&me.delete(t);}function De(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 Ke(e,t){return {...t,whatToRun:P(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function ye(e,t,r="invokeExecutionRef"){return a(e,t,r)}function He(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 $(e){return {result:"failure",data:{error:e}}}function N(e,t,r){let o=r?.label??"invokeExecutionRefSync",n=r?.cliDir??r?.cwd??process.cwd(),s;try{s=ye(e.argsMassaging,Ke(e,t),o);}catch(m){let u=m instanceof Error?m.message:String(m);return $(u)}let c;try{c=ee(e,n);}catch(m){let u=m instanceof Error?m.message:String(m);return $(`[${o}] ref resolution failed: ${u}`)}let l=[...c.baseArgs,...s.cmdArgs??[]],y=JSON.stringify(s.stdin??t),a=Qe(),d;try{d=a.executeSync(c.command,l,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:y});}catch(m){let u=m,p=(u.stderr?String(u.stderr):"").trim(),h=typeof u.status=="number"?u.status:"unknown",g=p||u.message;return $(`[${o}] ref exited with status ${h}${g?`: ${g}`:""}`)}try{return He(De(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function Je(e,t,r){let o=r?.label??"invokeExecutionRef",n;try{n=ye(e.argsMassaging,Ke(e,t),o);}catch(m){let u=m instanceof Error?m.message:String(m);return $(u)}let s=P(e.whatToRun),c=n.headers?{"Content-Type":"application/json",...n.headers}:{"Content-Type":"application/json"},l=n.url??s,y;if(e.howToRun==="http:get"){let m=n.body&&typeof n.body=="object"&&!Array.isArray(n.body)?n.body:t,u=new URLSearchParams(Object.entries(m).filter(([,p])=>p!=null).map(([p,h])=>[p,String(h)]));u.size>0&&(l=`${l}${l.includes("?")?"&":"?"}${u.toString()}`);}else y=JSON.stringify(n.body??t);let a={method:e.howToRun==="http:get"?"GET":"POST",headers:c,body:y},d=0;for(;;)try{let m=await fetch(l,a);if(!m.ok){let g=await m.text().catch(()=>"");return $(`[${o}] HTTP ${m.status}${g?`: ${g}`:""}`)}let u={};m.headers.forEach((g,R)=>{u[R]=g;});let p=new Uint8Array(await m.arrayBuffer());if(p.byteLength===0)return {result:"success",data:{},headers:u};let h=new TextDecoder().decode(p);try{return He(De(h),{headers:u})}catch{return {result:"success",data:{stdout:h},headers:u}}}catch(m){let u=m?.cause,p=u&&typeof u=="object"&&"code"in u?String(u.code||""):"";if((p==="ECONNRESET"||p==="UND_ERR_SOCKET")&&d===0){d+=1;continue}let g=m instanceof Error?m.message:String(m),R=u instanceof Error?`${u.name}: ${u.message}${p?` [${p}]`:""}`:u?String(u):"",w=n.url??s??"",f=`${g}${R?` (cause: ${R})`:""}${w?` url=${w}`:""}`;return $(`[${o}] ${f}`)}}async function $t(e,t,r){let o=r?.label??"invokeExecutionRef",n=P(e.whatToRun).trim();if(!n)return $(`[${o}] in-process-loop requires a non-empty handler key`);let s=me.get(n);if(!s)return $(`[${o}] no in-process handler registered for: ${n}`);try{return await s(e,t,r)}catch(c){let l=c instanceof Error?c.message:String(c);return $(`[${o}] ${l}`)}}var Pt={"local-node":async(e,t,r)=>N(e,t,r),"local-python":async(e,t,r)=>N(e,t,r),"local-process":async(e,t,r)=>N(e,t,r),"built-in":async(e,t,r)=>N(e,t,r),"http:post":Je,"http:get":Je,"in-process-loop":$t},Lt={"local-node":N,"local-python":N,"local-process":N,"built-in":N};async function U(e,t,r){let o=r?.transports?.[e.howToRun]??Pt[e.howToRun];return o?o(e,t,r):$(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function he(e,t,r){let o=r?.syncTransports?.[e.howToRun]??Lt[e.howToRun];return o?o(e,t,r):$(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function qt(e){return {invoke(t,r){return U(t,r,e)},invokeSync(t,r){return he(t,r,e)}}}function Ot(e,t,r){return he(e,t,r)}function F(e,t){if(process.platform!=="win32"){i.renameSync(e,t);return}let r=[10,20,40,80,160];for(let o=0;o<=r.length;o++)try{i.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 J(e){function t(n){return S.join(e,...n.split("/"))}function r(n){return S.relative(e,n).replace(/\\/g,"/")}function o(n,s){if(i.existsSync(n))for(let c of i.readdirSync(n,{withFileTypes:true})){let l=S.join(n,c.name);if(c.isDirectory()){o(l,s);continue}c.isFile()&&s.push(r(l));}}return {read(n){let s=t(n);if(!i.existsSync(s))return null;try{return i.readFileSync(s,"utf-8")}catch{return null}},write(n,s){let c=t(n),l=`${c}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(c),{recursive:true}),i.writeFileSync(l,s,"utf-8"),F(l,c);},exists(n){return i.existsSync(t(n))},remove(n){let s=t(n);try{i.existsSync(s)&&i.unlinkSync(s);}catch{}},readBytes(n){let s=t(n);if(!i.existsSync(s))return null;try{return new Uint8Array(i.readFileSync(s))}catch{return null}},writeBytes(n,s){let c=t(n),l=`${c}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(c),{recursive:true}),i.writeFileSync(l,Buffer.from(s)),F(l,c);},listKeys(n){let s=[];o(e,s);let c=s.sort();return n?c.filter(l=>l.startsWith(n)):c},stat(n){let s=t(n);if(!i.existsSync(s))return null;try{let c=i.statSync(s);return {key:n,size:Number(c.size||0),updatedAt:new Date(c.mtimeMs).toISOString()}}catch{return null}},keyRef(n){return {kind:"fs-path",value:t(n)}},renameKey(n,s){let c=t(n);if(!i.existsSync(c))return false;let l=t(s);return i.mkdirSync(S.dirname(l),{recursive:true}),F(c,l),true}}}function we(){return {read(e){if(!i.existsSync(e))return null;try{return i.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(e),{recursive:true}),i.writeFileSync(r,t,"utf-8"),F(r,e);},exists(e){return i.existsSync(e)},remove(e){try{i.existsSync(e)&&i.unlinkSync(e);}catch{}},readBytes(e){if(!i.existsSync(e))return null;try{return new Uint8Array(i.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(e),{recursive:true}),i.writeFileSync(r,Buffer.from(t)),F(r,e);},stat(e){if(!i.existsSync(e))return null;try{let t=i.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 i.existsSync(e)?(i.mkdirSync(S.dirname(t),{recursive:true}),F(e,t),true):false}}}function Q(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(e),{recursive:true}),i.writeFileSync(r,JSON.stringify(t,null,2),"utf-8"),F(r,e);}function L(e){if(!i.existsSync(e))return null;try{return JSON.parse(i.readFileSync(e,"utf-8"))}catch{return null}}function K(e){return i.existsSync(e)?i.readdirSync(e).filter(t=>t.endsWith(".json")).sort().map(t=>S.join(e,t)):[]}function H(e){return {id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}}function Nt(e){return {...H(e),leaseToken:String(e.leaseToken||""),leaseExpiresAt:String(e.leaseExpiresAt||"")}}function Jt(e){return {...H(e),reason:e.reason}}function ve(e){let t=S.join(e,"active"),r=S.join(e,"leased"),o=S.join(e,"done"),n=S.join(e,"dead"),s=S.join(e,"staged");for(let u of [t,r,o,n,s])i.mkdirSync(u,{recursive:true});function c(u){let p=String(u.enqueuedAt||new Date().toISOString()).replace(/[:.]/g,"-");return S.join(t,`${p}-${u.id}.json`)}function l(u){return S.join(r,`${u}.json`)}function y(u){return S.join(o,`${u}.json`)}function a(u){return S.join(n,`${u}.json`)}function d(u){return S.join(s,`${u}.json`)}function m(){let u=Date.now();for(let p of K(r)){let h=L(p);if(!h?.leaseExpiresAt)continue;let g=Date.parse(h.leaseExpiresAt);if(Number.isNaN(g)||g>u)continue;let R={id:h.id,body:h.body,enqueuedAt:h.enqueuedAt,attempt:h.attempt};Q(c(R),R);try{i.unlinkSync(p);}catch{}}}return {enqueue(u){let p={id:randomUUID(),body:u,enqueuedAt:new Date().toISOString(),attempt:0};return Q(c(p),p),H(p)},enqueueMany(u){return u.map(p=>this.enqueue(p))},enqueueIfAbsent(u,p){m();for(let g of [t,r,s])for(let R of K(g))if(L(R)?.dedupKey===p)return null;let h={id:randomUUID(),body:u,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:p};return Q(c(h),h),H(h)},lease(u){m();let p=Math.max(1,Math.floor(u?.max??1)),h=Math.max(1,Math.floor(u?.visibilityMs??6e4)),g=[];for(let R of K(t)){if(g.length>=p)break;let w=L(R);if(!w)continue;let f=l(w.id);try{F(R,f);}catch{continue}let x={...w,attempt:(Number(w.attempt)||0)+1,leaseToken:randomUUID(),leaseExpiresAt:new Date(Date.now()+h).toISOString()};Q(f,x),g.push(Nt(x));}return g},ack(u,p){let h=l(u),g=L(h);if(!g||g.leaseToken!==p)return false;try{F(h,y(u));}catch{return false}return true},nack(u,p,h){let g=l(u),R=L(g);if(!R||R.leaseToken!==p)return false;let w={id:R.id,body:R.body,enqueuedAt:R.enqueuedAt,attempt:R.attempt};h?.dead?(w.reason=h.reason,Q(a(u),w)):Q(c(w),w);try{i.unlinkSync(g);}catch{}return true},peekActive(u){return m(),K(t).map(p=>L(p)).filter(p=>!!p).map(H)},peekDeadLetter(u){return K(n).map(p=>L(p)).filter(p=>!!p).map(Jt)},stage(u,p){let h=p?.dedupKey;if(h){m();for(let R of [t,r,s])for(let w of K(R))if(L(w)?.dedupKey===h)return null}let g={id:randomUUID(),body:u,enqueuedAt:new Date().toISOString(),attempt:0,...h?{dedupKey:h}:{}};return Q(d(g.id),g),H(g)},commitStaged(u){let p=d(u),h=L(p);if(!h)return false;let g={...h,attempt:0,enqueuedAt:new Date().toISOString()};Q(c(g),g);try{i.unlinkSync(p);}catch{}return true},discardStaged(u,p){let h=d(u),g=L(h);if(!g)return false;let R={id:g.id,body:g.body,enqueuedAt:g.enqueuedAt,attempt:g.attempt,reason:p};Q(a(u),R);try{i.unlinkSync(h);}catch{}return true},peekStaged(u){return K(s).map(p=>L(p)).filter(p=>!!p).map(H)}}}var Se="__scratch-marker",Re="__scratch-config.json",Wt=1440*60*1e3,Dt=720*60*1e3,Kt=500;function Ue(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function z(e){i.mkdirSync(e,{recursive:true});let t=S.join(e,Se),r=S.join(e,Re),o=!i.existsSync(t);if(o)try{i.writeFileSync(t,`scratch-store
|
|
4
4
|
${new Date().toISOString()}
|
|
5
|
-
`,"utf-8");}catch{}function
|
|
5
|
+
`,"utf-8");}catch{}function n(){if(!i.existsSync(r))return {};try{let a=i.readFileSync(r,"utf-8"),d=JSON.parse(a);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function s(a){let d=`${r}.${process.pid}.${randomUUID()}.tmp`;try{i.writeFileSync(d,JSON.stringify(a,null,2),"utf-8"),F(d,r);}catch{}}if(o){let a=n();typeof a["retention.lastSweepAt"]!="number"&&(a["retention.lastSweepAt"]=Date.now(),s(a));}function c(){if(!i.existsSync(t))return;let a=n(),d=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:Wt,m=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:Dt;if(d<=0||m<=0)return;let u=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,p=Date.now();if(p-u<m)return;a["retention.lastSweepAt"]=p,s(a);let h=p;try{let g=i.readdirSync(e,{withFileTypes:!0});for(let R of g){if(Date.now()-h>Kt)break;if(!R.isFile()||R.name===Se||R.name===Re)continue;let w=S.join(e,R.name);try{let f=i.statSync(w);if(p-f.mtimeMs>d)try{i.unlinkSync(w);}catch{}}catch{}}}catch{}}function l(a,d){let m=Ue(a,"scratch"),u=Ue(d,".json"),p=u.startsWith(".")?u:`.${u}`,h=`${m}-${Date.now()}-${randomUUID().slice(0,8)}${p}`;return S.join(e,h)}function y(a,d){let m=`${a}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(a),{recursive:true}),i.writeFileSync(m,d,"utf-8"),F(m,a);}return {read(a){if(!i.existsSync(a))return null;try{return i.readFileSync(a,"utf-8")}catch{return null}},write(a,d){y(a,d);try{c();}catch{}},exists(a){return i.existsSync(a)},remove(a){try{i.existsSync(a)&&i.unlinkSync(a);}catch{}},readBytes(a){if(!i.existsSync(a))return null;try{return new Uint8Array(i.readFileSync(a))}catch{return null}},writeBytes(a,d){let m=`${a}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(a),{recursive:true}),i.writeFileSync(m,Buffer.from(d)),F(m,a);try{c();}catch{}},stat(a){if(!i.existsSync(a))return null;try{let d=i.statSync(a);return {key:a,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},listKeys(a){try{let d=i.readdirSync(e,{withFileTypes:!0}),m=[];for(let u of d){if(!u.isFile()||u.name===Se||u.name===Re)continue;let p=S.join(e,u.name);(!a||p.startsWith(a))&&m.push(p);}return m.sort()}catch{return []}},getUniqueKey(a,d){return l(a,d)},create(a,d,m){let u=l(d,m);y(u,a);try{c();}catch{}return u},keyRef(a){return {kind:"fs-path",value:a}},renameKey(a,d){return i.existsSync(a)?(i.mkdirSync(S.dirname(d),{recursive:true}),F(a,d),true):false},config:{get(a){return n()[a]??null},set(a,d){let m=n();d==null?delete m[a]:m[a]=d,s(m);}}}}var Ht="__archive-marker",Ut="__archive-config.json",te="streams",re="blobs",zt=500;function ze(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 ne(e){i.mkdirSync(e,{recursive:true}),i.mkdirSync(S.join(e,te),{recursive:true}),i.mkdirSync(S.join(e,re),{recursive:true});let t=S.join(e,Ht),r=S.join(e,Ut);if(!i.existsSync(t))try{i.writeFileSync(t,`archive-store
|
|
6
6
|
${new Date().toISOString()}
|
|
7
|
-
`,"utf-8");}catch{}function
|
|
8
|
-
`).filter(Boolean).map(
|
|
9
|
-
`,"utf-8"),
|
|
10
|
-
`).filter(Boolean).map(
|
|
11
|
-
`,"utf-8");},generateId(){return randomUUID()}}}function ze(e){return {tryAcquire(){try{if(!a.existsSync(e)){a.mkdirSync(y.dirname(e),{recursive:!0});try{a.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}function Lr(){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=$(s);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let n={...t},o=Buffer.from(JSON.stringify(n)).toString("base64");try{return spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",o],{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=$(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 Yt=".board.lock";function Ye(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 Zt(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Xt(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ze(e){if(e)return e;let t=Ce(import.meta.url),r=[t,b(t,"..","cli","node"),b(t,"..","..","cli","node")];for(let n of r)try{return Pe(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function er(e,t,r){let{cliDir:n,opts:o}=Zt(t,r),s=e.value,u,l=null,g$1,i,c,d=null,f;function m(){return f||(f=Ze(n)),f}let S=o?.callbackTransport??g(o?.notifyChannel),h;function w(){if(o?.suppressSpawn||l)return;let p=fe({id:"task-executor",workerStore:h.boardWorkerStore(),handleRequest:async(x,B)=>{let v=await H(B.ref,B.args,{cliDir:m(),cwd:process.cwd(),label:"fsBoardAdapter.boardWorker"});if(v.result!=="success"){let R=typeof v.data?.error=="string"?v.data.error:v.error;throw new Error(R||v.result)}}});l=ee(p).catch(x=>{o?.onWarn?.(`[board-worker] in-process queue drain failed: ${x instanceof Error?x.message:String(x)}`);}).finally(()=>{l=null,h.boardWorkerStore().peekActive().length>0&&w();});}return h={kvStorage:p=>se(b(s,`.${p}`)),blobStorage:p=>p?N(b(s,p)):N(s),scratchStorage:()=>G(b(s,".tmp")),scratchStorageForRef:p=>G(b$1(p).value),archiveFactory:()=>oe(b(s,"archive")),archiveFactoryForRef:p=>oe(b$1(p).value),journalAdapter:()=>Ve(s),boardWorkerStore:()=>(u||(u=K(J(b(s,".board-worker-queue")))),u),chatAgentStore:()=>(g$1||(g$1=K(J(b(s,".chat-agent-queue")))),g$1),processAccumulatedStore:()=>(i||(i=J(b(s,".process-accumulated-queue"))),i),lock:ze(b(s,Yt)),callbackTransport:S,async dispatchExecution(p,x){let B=!!x.output?.ref;if(p.howToRun==="queue-storage")try{let R=u??K(J(b(s,".board-worker-queue")));u||(u=R);let E=typeof p.extra?.boardId=="string"?p.extra.boardId:void 0;if(B)return R.enqueueRequest({boardId:E,ref:p,args:x}),{dispatched:!0};let M=x.source_def?.bindTo??X().slice(0,8),k=G(b(s,".tmp")),I=k.create(JSON.stringify(x,null,2),`exec-in-${M}`,".json"),D=k.getUniqueKey(`exec-out-${M}`,".json"),Q=k.getUniqueKey(`exec-err-${M}`,".txt"),ae=a$2(k.keyRef(I)),Y=a$2(k.keyRef(D)),ie=a$2(k.keyRef(Q));return R.enqueueRequest({boardId:E,ref:p,args:{subcommand:"run-source-fetch",inRef:ae,outRef:Y,errRef:ie}}),{dispatched:!0}}catch(R){return {dispatched:false,error:R instanceof Error?R.message:String(R)}}if(B&&(p.howToRun==="http:post"||p.howToRun==="in-process-loop"))try{if(p.howToRun==="http:post"){let M=$(p.whatToRun),k=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,...p.extra?{extra:p.extra}:{}})});if(!k.ok){let I=await k.text().catch(()=>"");return {dispatched:!1,error:`HTTP ${k.status}: ${I}`}}return {dispatched:!0}}let R=await H(p,x,{cwd:process.cwd(),label:"dispatchExecution.directHostedWorker"});return R.result==="success"?{dispatched:!0}:{dispatched:!1,error:(typeof R.data?.error=="string"?R.data.error:R.error)||R.result}}catch(R){return {dispatched:false,error:R instanceof Error?R.message:String(R)}}let v=p.howToRun==="local-node"||p.howToRun==="local-process"||p.howToRun==="local-python"||p.howToRun==="built-in";if(o?.suppressSpawn&&v)return {dispatched:false};try{let R=x.source_def?.bindTo??X().slice(0,8),E=G(b(s,".tmp")),M=E.create(JSON.stringify(x,null,2),`exec-in-${R}`,".json"),k=E.getUniqueKey(`exec-out-${R}`,".json"),I=E.getUniqueKey(`exec-err-${R}`,".txt"),D=a$2(E.keyRef(M)),Q=a$2(E.keyRef(k)),ae=a$2(E.keyRef(I)),Y=u??K(J(b(s,".board-worker-queue")));u||(u=Y);let ie=typeof p.extra?.boardId=="string"?p.extra.boardId:void 0;return Y.enqueueRequest({boardId:ie,ref:p,args:{subcommand:"run-source-fetch",inRef:D,outRef:Q,errRef:ae}}),w(),{dispatched:!0}}catch(R){let E=R instanceof Error?R.message:String(R);try{let M=oe(b(s,"archive")),k=new Date().toISOString().replace(/[:.]/g,"-"),I=x.source_def?.bindTo??"unknown";M.blob("exec-failures").write(`${k}-${I}.json`,JSON.stringify({error:E,args:x,ref:p,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:E}}},supportsDirectSourceOutput(p){return p.howToRun==="queue-storage"||p.howToRun==="http:post"||p.howToRun==="in-process-loop"},resolveBlob(p){let x=Be(p.value)?ke().read(p.value):N(s).read(p.value);if(x===null)throw new Error(`resolveBlob: blob not found: ::${p.kind}::${p.value}`);return x},hashFn:Ue,genId:()=>Ie(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:p=>se(b$1(p).value),requestProcessAccumulated(){if(o?.suppressSpawn||d)return;let p=this,x=c??=y$1(e,p),B=pe({id:"process-accumulated",queueStorage:p.processAccumulatedStore(),handleMessage:async()=>{let v=await x.processAccumulatedEvents({});if(v.status!=="success")throw new Error(v.error||`processAccumulatedEvents returned ${v.status}`)}});d=ee(B).catch(v=>{o?.onWarn?.(`[process-accumulated] in-process queue drain failed: ${v instanceof Error?v.message:String(v)}`);}).finally(()=>{d=null,p.processAccumulatedStore().peekActive().length>0&&p.requestProcessAccumulated?.();});},publishBoardChangeNotifications(p){if(!o?.notifyChannel||p.length===0)return;let x=p.map(B=>({id:X(),ts:new Date().toISOString(),boardRef:a$2(e),notification:B}));qe(o.notifyChannel,x,o.onWarn);},onWarn:o?.onWarn},h}function Qr(e,t,r){let{cliDir:n,opts:o}=Xt(t,r),s,u=()=>(s||(s=Ze(n)),s);return {...er(e,n,o),async invokeExecutor(g,i,c){if(g.howToRun==="queue-storage")throw new Error("queue-storage does not support inline executor request/response");if(g.howToRun==="http:post"||g.howToRun==="http:get"||g.howToRun==="in-process-loop"){let h=await H(g,{subcommand:i,...c?.input!==void 0?{input:c.input}:{},...g.extra?{extra:g.extra}:{}},{cwd:process.cwd(),timeoutMs:c?.timeout??3e4,label:`invokeExecutor:${i}`});if(h.result!=="success"){let w=typeof h.data?.error=="string"?h.data.error:h.error;throw new Error(w||`executor request failed: ${h.result}`)}return typeof h.data?.stdout=="string"?h.data.stdout:JSON.stringify(h.data??{})}let{command:d,baseArgs:f}=te(g,u()),m=g.extra?["--extra",Buffer.from(JSON.stringify(g.extra)).toString("base64")]:[],S=[...f,i,...m];return await new Promise((h,w)=>{let p=spawn(d,S,{cwd:process.cwd(),stdio:"pipe",windowsHide:true,shell:process.platform==="win32"&&/\.(cmd|bat)$/i.test(d)}),x=[],B=[],v=false,R=null,E=k=>{v||(v=true,R&&clearTimeout(R),w(k));},M=k=>{v||(v=true,R&&clearTimeout(R),h(k));};p.stdout.on("data",k=>{x.push(Buffer.from(k));}),p.stderr.on("data",k=>{B.push(Buffer.from(k));}),p.on("error",k=>{let I=k;I.stdout=Buffer.concat(x).toString("utf-8"),I.stderr=Buffer.concat(B).toString("utf-8"),E(I);}),p.on("close",k=>{let I=Buffer.concat(x).toString("utf-8"),D=Buffer.concat(B).toString("utf-8");if(k===0){M(I);return}let Q=new Error(D.trim()||`executor exited with status ${k}`);Q.stdout=I,Q.stderr=D,E(Q);}),c?.timeout&&c.timeout>0&&(R=setTimeout(()=>{p.kill();let k=new Error(`executor timed out after ${c.timeout}ms`);k.stdout=Buffer.concat(x).toString("utf-8"),k.stderr=Buffer.concat(B).toString("utf-8"),E(k);},c.timeout)),c?.input!==void 0?p.stdin.end(c.input):p.stdin.end();})},validateSchema(g){let i=d(g);return {ok:i.errors.length===0,errors:i.errors}},absoluteBlob:ke()}}function Or(e,t={}){let r=t.chatsSubdir??"chats",n=t.kvSubdir??".kv",o=n?[n,"chat"]:["chat"],s=r&&!Ye(e,r)?b(e,r):e,u=se(b(e,...o));return a$3(l=>{let i=`${String(l).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,c=b(s,i);return we(c)},u)}function Wr(e,t={}){let r=t.filesSubdir??"files",n=r&&!Ye(e,r)?b(e,r):e;return c(N(n))}function _r(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}export{te as buildLocalBaseSpec,fe as createBoardWorkerQueueLane,K as createBoardWorkerStore,qt as createExecutionRefInvoker,N as createFsBlobStorage,Or as createFsBoardChatStorage,Wr as createFsBoardFileArtifactsStore,Qr as createFsBoardNonCorePlatformAdapter,er as createFsBoardPlatformAdapter,J as createFsQueueStorage,Lr as createNodeSpawnInvocationAdapter,pe as createQueueStorageLane,_r as decodeBoardRefFromToken,ee as drainQueueLaneToIdle,me as evaluateArgsMassaging,H as invokeExecutionRef,ye as invokeExecutionRefSync,Lt as invokeRefSync,Mt as registerInProcessExecutionHandler,$ as resolveWhatToRunValue,_e as resolveYamlFlowCliPath,Oe as startQueueLaneRunner,At as startQueueLaneRunners,Ft as unregisterInProcessExecutionHandler};//# sourceMappingURL=board-live-cards-node.js.map
|
|
7
|
+
`,"utf-8");}catch{}function o(){if(!i.existsSync(r))return {};try{let c=i.readFileSync(r,"utf-8"),l=JSON.parse(c);return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return {}}}function n(c){let l=`${r}.${process.pid}.${randomUUID()}.tmp`;try{i.writeFileSync(l,JSON.stringify(c,null,2),"utf-8"),F(l,r);}catch{}}function s(){if(!i.existsSync(t))return;let c=o(),l=typeof c["retention.maxAgeMs"]=="number"?c["retention.maxAgeMs"]:0,y=typeof c["retention.sweepIntervalMs"]=="number"?c["retention.sweepIntervalMs"]:0;if(l<=0||y<=0)return;let a=typeof c["retention.lastSweepAt"]=="number"?c["retention.lastSweepAt"]:0,d=Date.now();if(d-a<y)return;c["retention.lastSweepAt"]=d,n(c);let m=d,u=p=>{let h;try{h=i.readdirSync(p,{withFileTypes:!0});}catch{return}for(let g of h){if(Date.now()-m>zt)return;let R=S.join(p,g.name);if(g.isDirectory()){u(R);continue}if(g.isFile())try{let w=i.statSync(R);if(d-w.mtimeMs>l)try{i.unlinkSync(R);}catch{}}catch{}}};u(S.join(e,te)),u(S.join(e,re));}return {stream(c){let l=ze(c),y=S.join(e,te,`${l}.jsonl`),a=oe(y);return {append(d){let m=a.append(d);try{s();}catch{}return m},readAll:()=>a.readAll(),readAfter:d=>a.readAfter(d),clear:()=>{a.clear&&a.clear();}}},blob(c){let l=ze(c),y=S.join(e,re,l);i.mkdirSync(y,{recursive:true});let a=J(y);return {read:d=>a.read(d),write:(d,m)=>{a.write(d,m);try{s();}catch{}},exists:d=>a.exists(d),remove:d=>a.remove(d),readBytes:a.readBytes?d=>a.readBytes(d):void 0,writeBytes:a.writeBytes?(d,m)=>{a.writeBytes(d,m);try{s();}catch{}}:void 0,listKeys:d=>a.listKeys(d),stat:a.stat?d=>a.stat(d):void 0,renameKey:(d,m)=>a.renameKey(d,m)}},listStreams(c){let l=S.join(e,te);try{return i.readdirSync(l,{withFileTypes:!0}).filter(y=>y.isFile()&&y.name.endsWith(".jsonl")).map(y=>y.name.slice(0,-6)).filter(y=>!c||y.startsWith(c)).sort()}catch{return []}},listBlobs(c){let l=S.join(e,re);try{return i.readdirSync(l,{withFileTypes:!0}).filter(y=>y.isDirectory()).map(y=>y.name).filter(y=>!c||y.startsWith(c)).sort()}catch{return []}},config:{get(c){return o()[c]??null},set(c,l){let y=o();l==null?delete y[c]:y[c]=l,n(y);}}}}function V(e){function t(o){return S.join(e,...o.split("/"))+".json"}function r(o,n,s,c){if(i.existsSync(o))for(let l of i.readdirSync(o,{withFileTypes:true})){let y=n?`${n}/${l.name}`:l.name;if(l.isDirectory()){r(S.join(o,l.name),y,s,c);continue}if(!l.isFile()||!l.name.endsWith(".json"))continue;let a=y.replace(/\.json$/,"");(!s||a.startsWith(s))&&c.push(a);}}return {read(o){let n=t(o);if(!i.existsSync(n))return null;try{return JSON.parse(i.readFileSync(n,"utf-8"))}catch{return null}},write(o,n){let s=t(o),c=`${s}.${process.pid}.${randomUUID()}.tmp`;i.mkdirSync(S.dirname(s),{recursive:true}),i.writeFileSync(c,JSON.stringify(n,null,2),"utf-8"),F(c,s);},delete(o){let n=t(o);try{i.existsSync(n)&&i.unlinkSync(n);}catch{}},listKeys(o){let n=[];return r(e,"",o,n),n.sort()}}}function oe(e){function t(){if(!i.existsSync(e))return [];let r=i.readFileSync(e,"utf-8").trim();return r?r.split(`
|
|
8
|
+
`).filter(Boolean).map(o=>JSON.parse(o)):[]}return {append(r){let o={id:randomUUID(),payload:r};return i.mkdirSync(S.dirname(e),{recursive:true}),i.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(c=>c.id===r),s=n===-1?o:o.slice(n+1);return {entries:s,newCursor:s.length>0?s[s.length-1].id:r}},clear(){i.existsSync(e)&&i.truncateSync(e,0);}}}function xe(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(xe).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(o=>`${JSON.stringify(o)}:${xe(t[o])}`).join(",")}}`}function Ve(e){return createHash("sha256").update(xe(e)).digest("hex")}function ke(e){let t=S.join(e,"board-journal.jsonl");return {readAllEntries(){if(!i.existsSync(t))return [];let r=i.readFileSync(t,"utf-8").trim();return r?r.split(`
|
|
10
|
+
`).filter(Boolean).map(o=>JSON.parse(o)):[]},appendEntry(r){i.appendFileSync(t,JSON.stringify(r)+`
|
|
11
|
+
`,"utf-8");},generateId(){return randomUUID()}}}function Ge(e){return {tryAcquire(){try{if(!i.existsSync(e)){i.mkdirSync(S.dirname(e),{recursive:!0});try{i.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}function qr(){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=P(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=P(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 Gt=".board.lock";function Ze(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 Yt(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Zt(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Xe(e){if(e)return e;let t=je(import.meta.url),r=[t,T(t,"..","cli","node"),T(t,"..","..","cli","node")];for(let o of r)try{return qe(o),o}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function Xt(e,t,r){let{cliDir:o,opts:n}=Yt(t,r),s=e.value,c=null,l,y$1=null,a;function d(){return a||(a=Xe(o)),a}function m(f){let x=n?.queueStoreRef;if(!x)throw new Error(`createFsBoardPlatformAdapter: ${f} requires opts.queueStoreRef`);return x}function u(f){let x=n?.boardRuntimeStoreRef;if(!x)throw new Error(`createFsBoardPlatformAdapter: ${f} requires opts.boardRuntimeStoreRef`);return x}let p=n?.callbackTransport??g({notifyChannel:n?.notifyChannel,boardRuntimeStoreRef:n?.boardRuntimeStoreRef,queueStoreRef:n?.queueStoreRef}),h;function g$1(f){return h.queueStorageForRef(m(`internal lane "${f}"`),f)}function R(f){return a$4(g$1(f))}function w(){if(n?.suppressSpawn||c)return;let f=pe({id:"task-executor",workerStore:R("task-executor"),handleRequest:async(x,C)=>{let b=await U(C.ref,C.args,{cliDir:d(),cwd:process.cwd(),label:"fsBoardAdapter.boardWorker"});if(b.result!=="success"){let v=typeof b.data?.error=="string"?b.data.error:b.error;throw new Error(v||b.result)}}});c=X(f).catch(x=>{n?.onWarn?.(`[board-worker] in-process queue drain failed: ${x instanceof Error?x.message:String(x)}`);}).finally(()=>{c=null,g$1("task-executor").peekActive().length>0&&w();});}return h={kvStorage:f=>V(T(s,`.${f}`)),blobStorage:f=>f?J(T(s,f)):J(s),blobStorageForRef:f=>J(b(f).value),chatStorageForRef:f=>er(b(f).value),queueStorageForRef:(f,x)=>ve(T(b(f).value,x)),scratchStorage:()=>z(T(s,".tmp")),scratchStorageForRef:f=>z(b(f).value),archiveFactory:()=>ne(T(s,"archive")),archiveFactoryForRef:f=>ne(b(f).value),journalAdapter:()=>ke(s),journalAdapterForRef:f=>ke(b(f).value),lock:Ge(T(s,Gt)),callbackTransport:p,async dispatchExecution(f,x){let C=!!x.output?.ref;if(f.howToRun==="queue-storage")try{let v=R("task-executor"),I=typeof f.extra?.boardId=="string"?f.extra.boardId:void 0;if(C)return v.enqueueRequest({boardId:I,ref:f,args:x}),{dispatched:!0};let k=x.source_def?.bindTo??Z().slice(0,8),A=z(T(s,".tmp")),q=A.create(JSON.stringify(x,null,2),`exec-in-${k}`,".json"),W=A.getUniqueKey(`exec-out-${k}`,".json"),se=A.getUniqueKey(`exec-err-${k}`,".txt"),ie=a$1(A.keyRef(q)),ae=a$1(A.keyRef(W)),ce=a$1(A.keyRef(se));return v.enqueueRequest({boardId:I,ref:f,args:{subcommand:"run-source-fetch",inRef:ie,outRef:ae,errRef:ce}}),{dispatched:!0}}catch(v){return {dispatched:false,error:v instanceof Error?v.message:String(v)}}if(C&&(f.howToRun==="http:post"||f.howToRun==="in-process-loop"))try{if(f.howToRun==="http:post"){let k=P(f.whatToRun),A=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,...f.extra?{extra:f.extra}:{}})});if(!A.ok){let q=await A.text().catch(()=>"");return {dispatched:!1,error:`HTTP ${A.status}: ${q}`}}return {dispatched:!0}}let v=await U(f,x,{cwd:process.cwd(),label:"dispatchExecution.directHostedWorker"});return v.result==="success"?{dispatched:!0}:{dispatched:!1,error:(typeof v.data?.error=="string"?v.data.error:v.error)||v.result}}catch(v){return {dispatched:false,error:v instanceof Error?v.message:String(v)}}let b=f.howToRun==="local-node"||f.howToRun==="local-process"||f.howToRun==="local-python"||f.howToRun==="built-in";if(n?.suppressSpawn&&b)return {dispatched:false};try{let v=x.source_def?.bindTo??Z().slice(0,8),I=z(T(s,".tmp")),k=I.create(JSON.stringify(x,null,2),`exec-in-${v}`,".json"),A=I.getUniqueKey(`exec-out-${v}`,".json"),q=I.getUniqueKey(`exec-err-${v}`,".txt"),W=a$1(I.keyRef(k)),se=a$1(I.keyRef(A)),ie=a$1(I.keyRef(q)),ae=R("task-executor"),ce=typeof f.extra?.boardId=="string"?f.extra.boardId:void 0;return ae.enqueueRequest({boardId:ce,ref:f,args:{subcommand:"run-source-fetch",inRef:W,outRef:se,errRef:ie}}),w(),{dispatched:!0}}catch(v){let I=v instanceof Error?v.message:String(v);try{let k=ne(T(s,"archive")),A=new Date().toISOString().replace(/[:.]/g,"-"),q=x.source_def?.bindTo??"unknown";k.blob("exec-failures").write(`${A}-${q}.json`,JSON.stringify({error:I,args:x,ref:f,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:I}}},supportsDirectSourceOutput(f){return f.howToRun==="queue-storage"||f.howToRun==="http:post"||f.howToRun==="in-process-loop"},resolveBlob(f){let x=Fe(f.value)?we().read(f.value):J(s).read(f.value);if(x===null)throw new Error(`resolveBlob: blob not found: ::${f.kind}::${f.value}`);return x},hashFn:Ve,genId:()=>Ce(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:f=>V(b(f).value),requestProcessAccumulated(){if(n?.suppressSpawn||y$1)return;let f=this,x=l??=y(e,f,{boardRuntimeStoreRef:u("requestProcessAccumulated")}),C=ge({id:"process-accumulated",queueStorage:g$1("process-accumulated"),handleMessage:async()=>{let b=await x.processAccumulatedEvents({});if(b.status!=="success")throw new Error(b.error||`processAccumulatedEvents returned ${b.status}`)}});y$1=X(C).catch(b=>{n?.onWarn?.(`[process-accumulated] in-process queue drain failed: ${b instanceof Error?b.message:String(b)}`);}).finally(()=>{y$1=null,g$1("process-accumulated").peekActive().length>0&&f.requestProcessAccumulated?.();});},publishBoardChangeNotifications(f){if(!n?.notifyChannel||f.length===0)return;let x=f.map(C=>({id:Z(),ts:new Date().toISOString(),boardRef:a$1(e),notification:C}));Oe(n.notifyChannel,x,n.onWarn);},onWarn:n?.onWarn},h}function Or(e,t,r){let{cliDir:o,opts:n}=Zt(t,r),s,c=()=>(s||(s=Xe(o)),s);return {...Xt(e,o,n),async invokeExecutor(y,a,d){if(y.howToRun==="queue-storage")throw new Error("queue-storage does not support inline executor request/response");if(y.howToRun==="http:post"||y.howToRun==="in-process-loop"){let g=await h(y,{subcommand:a,...d?.input!==void 0?{input:d.input}:{}});return typeof g=="string"?g:g&&typeof g=="object"&&!Array.isArray(g)&&typeof g.stdout=="string"?String(g.stdout):JSON.stringify(g??{})}if(y.howToRun==="http:get"){let g=await U(y,{subcommand:a,...d?.input!==void 0?{input:d.input}:{},...y.extra?{extra:y.extra}:{}},{cwd:process.cwd(),timeoutMs:d?.timeout??3e4,label:`invokeExecutor:${a}`});if(g.result!=="success"){let R=typeof g.data?.error=="string"?g.data.error:g.error;throw new Error(R||`executor request failed: ${g.result}`)}return typeof g.data?.stdout=="string"?g.data.stdout:JSON.stringify(g.data??{})}let{command:m,baseArgs:u}=ee(y,c()),p=y.extra?["--extra",Buffer.from(JSON.stringify(y.extra)).toString("base64")]:[],h$1=[...u,a,...p];return await new Promise((g,R)=>{let w=spawn(m,h$1,{cwd:process.cwd(),stdio:"pipe",windowsHide:true,shell:process.platform==="win32"&&/\.(cmd|bat)$/i.test(m)}),f=[],x=[],C=false,b=null,v=k=>{C||(C=true,b&&clearTimeout(b),R(k));},I=k=>{C||(C=true,b&&clearTimeout(b),g(k));};w.stdout.on("data",k=>{f.push(Buffer.from(k));}),w.stderr.on("data",k=>{x.push(Buffer.from(k));}),w.on("error",k=>{let A=k;A.stdout=Buffer.concat(f).toString("utf-8"),A.stderr=Buffer.concat(x).toString("utf-8"),v(A);}),w.on("close",k=>{let A=Buffer.concat(f).toString("utf-8"),q=Buffer.concat(x).toString("utf-8");if(k===0){I(A);return}let W=new Error(q.trim()||`executor exited with status ${k}`);W.stdout=A,W.stderr=q,v(W);}),d?.timeout&&d.timeout>0&&(b=setTimeout(()=>{w.kill();let k=new Error(`executor timed out after ${d.timeout}ms`);k.stdout=Buffer.concat(f).toString("utf-8"),k.stderr=Buffer.concat(x).toString("utf-8"),v(k);},d.timeout)),d?.input!==void 0?w.stdin.end(d.input):w.stdin.end();})},validateSchema(y){let a=d(y);return {ok:a.errors.length===0,errors:a.errors}},absoluteBlob:we()}}function Qr(e,t={}){let r=t.chatsSubdir??"chats",o=t.kvSubdir??".kv",n=o?[o,"chat"]:["chat"],s=r&&!Ze(e,r)?T(e,r):e,c=V(T(e,...n));return a$2(l=>{let a=`${String(l).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,d=T(s,a);return oe(d)},c)}function er(e){return a$2(t=>{let o=`${String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`;return oe(T(e,"journal",o))},V(T(e,"kv")))}function _r(e,t={}){let r=t.filesSubdir??"files",o=r&&!Ze(e,r)?T(e,r):e;return a$3(J(o))}function Nr(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}export{ee as buildLocalBaseSpec,pe as createBoardWorkerQueueLane,qt as createExecutionRefInvoker,J as createFsBlobStorage,Qr as createFsBoardChatStorage,_r as createFsBoardFileArtifactsStore,Or as createFsBoardNonCorePlatformAdapter,Xt as createFsBoardPlatformAdapter,er as createFsChatStorageForRefRoot,ve as createFsQueueStorage,qr as createNodeSpawnInvocationAdapter,ge as createQueueStorageLane,Nr as decodeBoardRefFromToken,X as drainQueueLaneToIdle,ye as evaluateArgsMassaging,U as invokeExecutionRef,he as invokeExecutionRefSync,Ot as invokeRefSync,jt as registerInProcessExecutionHandler,P as resolveWhatToRunValue,We as resolveYamlFlowCliPath,Ne as startQueueLaneRunner,Et as startQueueLaneRunners,Mt as unregisterInProcessExecutionHandler};//# sourceMappingURL=board-live-cards-node.js.map
|
|
12
12
|
//# sourceMappingURL=board-live-cards-node.js.map
|
package/lib/{board-live-cards-public-LlVUQPL2.d.cts → board-live-cards-public-BT5HrgqZ.d.cts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as
|
|
1
|
+
import { g as JournalStorage, K as KVStorage, B as BlobStorage, S as ScratchStorage, A as ArchiveFactory, f as QueueStorage, h as AtomicRelayLock, a as KindValueRef } from './storage-interface-D-iEiTJA.cjs';
|
|
2
2
|
import { ExecutionRef } from './execution-refs.cjs';
|
|
3
3
|
import { f as GraphEvent, G as GraphConfig } from './types-BBhqYGhE.cjs';
|
|
4
4
|
|
|
@@ -140,6 +140,58 @@ interface BoardStatusObject {
|
|
|
140
140
|
}
|
|
141
141
|
declare const EMPTY_CONFIG: GraphConfig;
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* chat-storage-lib.ts
|
|
145
|
+
*
|
|
146
|
+
* ChatStorage interface + factories backed by JournalStorage (history) and
|
|
147
|
+
* KVStorage (processing state and config).
|
|
148
|
+
*
|
|
149
|
+
* Platform-free — no node:fs or node:crypto imports.
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
type Awaitable<T> = T | Promise<T>;
|
|
153
|
+
interface ChatRecord {
|
|
154
|
+
/** Journal entry id — also used as SSE cursor. */
|
|
155
|
+
id: string;
|
|
156
|
+
role: string;
|
|
157
|
+
text: string;
|
|
158
|
+
files: unknown[];
|
|
159
|
+
turn: string;
|
|
160
|
+
updated_at: string;
|
|
161
|
+
}
|
|
162
|
+
interface ChatConfig {
|
|
163
|
+
systemPrompt?: string;
|
|
164
|
+
}
|
|
165
|
+
interface ChatReadAfterResult {
|
|
166
|
+
records: ChatRecord[];
|
|
167
|
+
/** Pass as cursor on the next call. Null when the journal is empty. */
|
|
168
|
+
cursor: string | null;
|
|
169
|
+
}
|
|
170
|
+
interface ChatStorage {
|
|
171
|
+
/** Append a message; returns the new entry id (usable as a cursor). */
|
|
172
|
+
append(cardId: string, role: string, text: string, files?: unknown[], turn?: string): Awaitable<string>;
|
|
173
|
+
/** Read all messages in insertion order. */
|
|
174
|
+
readAll(cardId: string): Awaitable<ChatRecord[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Read messages appended after cursor.
|
|
177
|
+
* Pass null to read from the beginning.
|
|
178
|
+
*/
|
|
179
|
+
readAfter(cardId: string, cursor: string | null): Awaitable<ChatReadAfterResult>;
|
|
180
|
+
/** Remove all messages for this card. */
|
|
181
|
+
clear(cardId: string): Awaitable<void>;
|
|
182
|
+
setProcessing(cardId: string, active: boolean): Awaitable<void>;
|
|
183
|
+
isProcessing(cardId: string): Awaitable<boolean>;
|
|
184
|
+
getConfig(cardId: string): Awaitable<ChatConfig>;
|
|
185
|
+
setConfig(cardId: string, patch: Partial<ChatConfig>): Awaitable<void>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create a ChatStorage backed by:
|
|
189
|
+
* - journalFactory(cardId) → JournalStorage (one per-card journal for history)
|
|
190
|
+
* - kv → KVStorage (shared processing flags + config)
|
|
191
|
+
*/
|
|
192
|
+
declare function createChatStorage(journalFactory: (cardId: string) => JournalStorage, kv: KVStorage): ChatStorage;
|
|
193
|
+
declare function createInMemoryChatStorage(): ChatStorage;
|
|
194
|
+
|
|
143
195
|
interface BoardTaskCallback {
|
|
144
196
|
token: string;
|
|
145
197
|
via: ExecutionRef;
|
|
@@ -149,42 +201,11 @@ interface BoardCallbackTransport {
|
|
|
149
201
|
}
|
|
150
202
|
declare function createHttpBoardCallbackTransport(baseUrl: string): BoardCallbackTransport;
|
|
151
203
|
declare function createInProcessBoardCallbackTransport(handlerKey: string): BoardCallbackTransport;
|
|
152
|
-
declare function createLocalNodeBoardCallbackTransport(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
args: Record<string, unknown>;
|
|
158
|
-
}
|
|
159
|
-
interface BoardWorkerQueuedRequest {
|
|
160
|
-
messageId: string;
|
|
161
|
-
enqueuedAt: string;
|
|
162
|
-
attempt: number;
|
|
163
|
-
request: BoardWorkerRequest;
|
|
164
|
-
}
|
|
165
|
-
interface BoardWorkerLeasedRequest extends BoardWorkerQueuedRequest {
|
|
166
|
-
leaseToken: string;
|
|
167
|
-
leaseExpiresAt: string;
|
|
168
|
-
}
|
|
169
|
-
interface BoardWorkerDeadLetterRequest extends BoardWorkerQueuedRequest {
|
|
170
|
-
reason?: string;
|
|
171
|
-
}
|
|
172
|
-
interface BoardWorkerStore {
|
|
173
|
-
enqueueRequest(request: BoardWorkerRequest): string;
|
|
174
|
-
enqueueRequestIfAbsent?(request: BoardWorkerRequest, dedupKey: string): string | null;
|
|
175
|
-
leaseRequests(opts?: {
|
|
176
|
-
max?: number;
|
|
177
|
-
visibilityMs?: number;
|
|
178
|
-
}): BoardWorkerLeasedRequest[];
|
|
179
|
-
ackRequest(messageId: string, leaseToken: string): boolean;
|
|
180
|
-
nackRequest(messageId: string, leaseToken: string, opts?: {
|
|
181
|
-
dead?: boolean;
|
|
182
|
-
reason?: string;
|
|
183
|
-
}): boolean;
|
|
184
|
-
peekActive(): BoardWorkerQueuedRequest[];
|
|
185
|
-
peekDeadLetter(): BoardWorkerDeadLetterRequest[];
|
|
186
|
-
}
|
|
187
|
-
declare function createBoardWorkerStore(queue: QueueStorage): BoardWorkerStore;
|
|
204
|
+
declare function createLocalNodeBoardCallbackTransport(opts?: string | {
|
|
205
|
+
notifyChannel?: string;
|
|
206
|
+
boardRuntimeStoreRef?: string;
|
|
207
|
+
queueStoreRef?: string;
|
|
208
|
+
}): BoardCallbackTransport;
|
|
188
209
|
|
|
189
210
|
/**
|
|
190
211
|
* board-live-cards-public.ts
|
|
@@ -215,7 +236,6 @@ declare function createBoardWorkerStore(queue: QueueStorage): BoardWorkerStore;
|
|
|
215
236
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
216
237
|
*
|
|
217
238
|
* const board = createBoardLiveCardsPublic(baseRef, adapter);
|
|
218
|
-
* const result = await board.processAccumulatedEvents();
|
|
219
239
|
* const status = board.status();
|
|
220
240
|
*/
|
|
221
241
|
|
|
@@ -257,10 +277,11 @@ interface BoardPlatformAdapter {
|
|
|
257
277
|
/**
|
|
258
278
|
* Blob storage factory — scoped by namespace.
|
|
259
279
|
* Namespaces used by the public layer:
|
|
260
|
-
* 'sources' — fetched source data files (keyed by cardId/outputFile)
|
|
261
280
|
* '' — root-scoped blob access (for resolving arbitrary KindValueRef blobs)
|
|
262
281
|
*/
|
|
263
282
|
blobStorage(namespace: string): BlobStorage;
|
|
283
|
+
blobStorageForRef(ref: string): BlobStorage;
|
|
284
|
+
chatStorageForRef(ref: string): ChatStorage;
|
|
264
285
|
/**
|
|
265
286
|
* Ephemeral scratch store for transient I/O staging (probe in/out/err,
|
|
266
287
|
* dispatchExecution argv/out/err). Default scope is board-local; if the
|
|
@@ -283,22 +304,12 @@ interface BoardPlatformAdapter {
|
|
|
283
304
|
* One journal per board — no namespace parameter needed.
|
|
284
305
|
*/
|
|
285
306
|
journalAdapter(): JournalStorageAdapter;
|
|
307
|
+
journalAdapterForRef(ref: string): JournalStorageAdapter;
|
|
286
308
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*/
|
|
290
|
-
boardWorkerStore(): BoardWorkerStore;
|
|
291
|
-
/**
|
|
292
|
-
* Semantic queue for chat-agent dispatch requests.
|
|
293
|
-
* Kept separate from task execution so chat work can be drained independently.
|
|
294
|
-
*/
|
|
295
|
-
chatAgentStore(): BoardWorkerStore;
|
|
296
|
-
/**
|
|
297
|
-
* Queue of board wake-up requests for processAccumulatedEvents scheduling.
|
|
298
|
-
* Implementations should use enqueueIfAbsent when they want single-pending
|
|
299
|
-
* drain semantics.
|
|
309
|
+
* Queue storage lane resolved from an explicit queue store ref.
|
|
310
|
+
* The adapter chooses the backend from the ref; lane chooses the internal queue.
|
|
300
311
|
*/
|
|
301
|
-
|
|
312
|
+
queueStorageForRef(ref: string, lane: string): QueueStorage;
|
|
302
313
|
/**
|
|
303
314
|
* AtomicRelayLock — non-blocking try-acquire with relay-on-busy semantics.
|
|
304
315
|
* Guards processAccumulatedEvents drain cycle.
|
|
@@ -369,6 +380,9 @@ interface BoardPlatformAdapter {
|
|
|
369
380
|
interface BoardLiveCardsPublic {
|
|
370
381
|
init(input: CommandInput): CommandResult;
|
|
371
382
|
status(input: CommandInput): CommandResult<BoardStatusObject>;
|
|
383
|
+
getBoardRuntimeStoreRef(input: CommandInput): CommandResult<{
|
|
384
|
+
storeRef: string | null;
|
|
385
|
+
}>;
|
|
372
386
|
getCardStoreRef(input: CommandInput): CommandResult<{
|
|
373
387
|
storeRef: string;
|
|
374
388
|
}>;
|
|
@@ -378,15 +392,15 @@ interface BoardLiveCardsPublic {
|
|
|
378
392
|
getScratchStoreRef(input: CommandInput): CommandResult<{
|
|
379
393
|
storeRef: string | null;
|
|
380
394
|
}>;
|
|
381
|
-
getArchiveStoreRef(input: CommandInput): CommandResult<{
|
|
382
|
-
storeRef: string | null;
|
|
383
|
-
}>;
|
|
384
395
|
getChatStoreRef(input: CommandInput): CommandResult<{
|
|
385
396
|
storeRef: string | null;
|
|
386
397
|
}>;
|
|
387
398
|
getArtifactsStoreRef(input: CommandInput): CommandResult<{
|
|
388
399
|
storeRef: string | null;
|
|
389
400
|
}>;
|
|
401
|
+
getFetchedSourcesStoreRef(input: CommandInput): CommandResult<{
|
|
402
|
+
storeRef: string | null;
|
|
403
|
+
}>;
|
|
390
404
|
getConfig(input: CommandInput): CommandResult<{
|
|
391
405
|
value: unknown;
|
|
392
406
|
}>;
|
|
@@ -422,7 +436,13 @@ type BoardChangeNotification = OutputStoreEvent | {
|
|
|
422
436
|
kind: 'card_removed';
|
|
423
437
|
cardId: string;
|
|
424
438
|
};
|
|
425
|
-
|
|
439
|
+
interface BoardLiveCardsPublicOptions {
|
|
440
|
+
boardRuntimeStoreRef?: string;
|
|
441
|
+
scratchStoreRef?: string;
|
|
442
|
+
taskExecutorRef?: ExecutionRef;
|
|
443
|
+
chatHandlerFlow?: unknown;
|
|
444
|
+
}
|
|
445
|
+
declare function createBoardLiveCardsPublic(baseRef: KindValueRef, adapter: BoardPlatformAdapter, options?: BoardLiveCardsPublicOptions): BoardLiveCardsPublic;
|
|
426
446
|
interface BoardNonCorePlatformAdapter extends BoardPlatformAdapter {
|
|
427
447
|
/**
|
|
428
448
|
* Invoke a task executor subcommand and return stdout.
|
|
@@ -501,6 +521,9 @@ interface BoardLiveCardsNonCorePublic {
|
|
|
501
521
|
}>;
|
|
502
522
|
}>;
|
|
503
523
|
}
|
|
504
|
-
declare function createBoardLiveCardsNonCorePublic(baseRef: KindValueRef, adapter: BoardNonCorePlatformAdapter
|
|
524
|
+
declare function createBoardLiveCardsNonCorePublic(baseRef: KindValueRef, adapter: BoardNonCorePlatformAdapter, opts?: {
|
|
525
|
+
boardRuntimeStoreRef?: string;
|
|
526
|
+
taskExecutorRef?: ExecutionRef;
|
|
527
|
+
}): BoardLiveCardsNonCorePublic;
|
|
505
528
|
|
|
506
|
-
export { type BoardChangeNotification as B, type CommandInput as C, EMPTY_CONFIG as E, type LiveCard as L, type StateSnapshotReadView as S, type CommandResult as a, type CardAdminStore as b, type BoardLiveCardsPublic as c, type BoardNonCorePlatformAdapter as d, type BoardPlatformAdapter as e, type
|
|
529
|
+
export { type BoardChangeNotification as B, type CommandInput as C, EMPTY_CONFIG as E, type LiveCard as L, type StateSnapshotReadView as S, type CommandResult as a, type CardAdminStore as b, type BoardLiveCardsPublic as c, type BoardNonCorePlatformAdapter as d, type BoardPlatformAdapter as e, type ChatStorage as f, type ChatRecord as g, type ChatReadAfterResult as h, type ChatConfig as i, type BoardStatusObject as j, type BoardCallbackTransport as k, type BoardLiveCardsNonCorePublic as l, type CardChecksumIndex as m, type CardUpsertValidation as n, type CardIndex as o, BOARD_GRAPH_KEY as p, SNAPSHOT_SCHEMA_VERSION_V1 as q, createBoardLiveCardsNonCorePublic as r, createBoardLiveCardsPublic as s, createCardStore as t, createChatStorage as u, createHttpBoardCallbackTransport as v, createInMemoryChatStorage as w, createInProcessBoardCallbackTransport as x, createLocalNodeBoardCallbackTransport as y, type BoardLiveCardsPublicOptions as z };
|