yaml-flow 8.7.1 → 8.8.5
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/live-cards.js +6 -6
- 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/server/chat-flow/flow-steps.json +5 -5
- package/examples/board/test/server-http-test.js +726 -87
- 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 +70 -15
- package/lib/board-live-cards-node.d.ts +70 -15
- 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-livegraph-runtime/index.cjs +1 -1
- package/lib/board-livegraph-runtime/index.d.cts +1 -0
- package/lib/board-livegraph-runtime/index.d.ts +1 -0
- package/lib/board-livegraph-runtime/index.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-35N7ONTH.js +2 -0
- package/lib/chunk-36QUKFL7.cjs +3 -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-YGKDQLYP.js → chunk-4HIEOBJC.js} +2 -2
- 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-7QQFDYBM.js +3 -0
- package/lib/chunk-7QZ267XP.cjs +2 -0
- package/lib/chunk-ABAVFLDP.js +7 -0
- package/lib/{chunk-XQRNDX4Q.js → chunk-ANKA7HEJ.js} +2 -2
- package/lib/{chunk-KAWQPLIE.cjs → chunk-BQUQTOPB.cjs} +2 -2
- 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-H22NK6KH.cjs +7 -0
- package/lib/chunk-H4TYOSMD.cjs +45 -0
- package/lib/chunk-HFW7E2Z7.cjs +4 -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-NNSBBO5R.js +2 -0
- package/lib/chunk-NU5NO5NM.js +2 -0
- package/lib/chunk-O5UYCGIN.js +2 -0
- package/lib/chunk-O6II7S4M.js +3 -0
- package/lib/chunk-PN5D32NP.cjs +3 -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-S6DRP2HX.cjs → chunk-XQAHHUZO.cjs} +2 -2
- package/lib/chunk-Y4WK7HE4.js +2 -0
- package/lib/chunk-ZENTBLLA.cjs +3 -0
- package/lib/chunk-ZK3E7L4Y.cjs +2 -0
- package/lib/chunk-ZWVT24YW.js +3 -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 -21
- package/lib/firestore-storage/index.d.ts +12 -21
- package/lib/firestore-storage/index.js +2 -2
- package/lib/index.cjs +2 -2
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +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-BDjWI7JR.d.cts +63 -0
- package/lib/sse-hub-DM8bw-dO.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-BsfXZyI3.d.ts} +64 -29
- package/lib/{types-Ba8H5_Wo.d.cts → types-CPnYv7RC.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/examples/board/test/sse-worker.js +0 -49
- 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-HEEDJEKM.js +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-PBCDDO4V.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,3 +1,3 @@
|
|
|
1
|
-
var FirebaseStorage=(function(exports){'use strict';var h=new
|
|
2
|
-
exports.createFirebaseStorageBlobStore=
|
|
1
|
+
var FirebaseStorage=(function(exports){'use strict';var b="b64:";function h(r){let n=r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4),o=globalThis.Buffer;if(o)return o.from(n,"base64").toString("utf8");if(typeof atob=="function"){let i=atob(n),s=new Uint8Array(i.length);for(let a=0;a<i.length;a+=1)s[a]=i.charCodeAt(a);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function k(r){if(!r.startsWith(b))throw new Error(`Invalid ref format (expected ${b}<base64url(json)>): ${r}`);let n;try{n=JSON.parse(h(r.slice(b.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${r}`)}if(!n||typeof n!="object")throw new Error(`Invalid ref format (expected object payload): ${r}`);let o=n;if(typeof o.kind!="string"||typeof o.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${r}`);return {kind:o.kind,value:o.value}}var m=new TextEncoder;function p(r){let n="";for(let i of m.encode(String(r)))n+=String.fromCharCode(i);return (typeof btoa=="function"?btoa(n):Buffer.from(n,"binary").toString("base64")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function x(r){let n=String(r).replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-String(r).length%4)%4),o=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),i=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)i[s]=o.charCodeAt(s);return new TextDecoder().decode(i)}function d(...r){return r.map(n=>String(n??"").trim()).filter(Boolean).join("/")}function u(r){return !!(r&&typeof r=="object"&&r.code==="storage/object-not-found")}function w(r,n){let o=r.ref(n);function i(e){return o.child(p(e))}async function s(e){let t=await e.getDownloadURL(),c=await fetch(t,{cache:"no-store"});if(!c.ok)throw new Error(`Failed to fetch storage object ${e.fullPath}: ${c.status}`);return c.text()}async function a(e){let t=await e.getDownloadURL(),c=await fetch(t,{cache:"no-store"});if(!c.ok)throw new Error(`Failed to fetch storage object ${e.fullPath}: ${c.status}`);return new Uint8Array(await c.arrayBuffer())}async function g(){let e=[];async function t(c){let f=await c.listAll();for(let l of f.prefixes)await t(l);for(let l of f.items){let y=l.name||l.fullPath.slice(o.fullPath.length+1);e.push(x(y));}}try{await t(o);}catch(c){if(u(c))return [];throw c}return e.sort()}return {async read(e){try{return await s(i(e))}catch(t){if(u(t))return null;throw t}},async write(e,t){await i(e).putString(String(t),"raw",{contentType:"text/plain; charset=utf-8"});},async exists(e){try{return await i(e).getMetadata(),!0}catch(t){if(u(t))return false;throw t}},async remove(e){try{await i(e).delete();}catch(t){if(!u(t))throw t}},async readBytes(e){try{return await a(i(e))}catch(t){if(u(t))return null;throw t}},async writeBytes(e,t){await i(e).put(t,{contentType:"application/octet-stream"});},async listKeys(e=""){let t=await g();return e?t.filter(c=>c.startsWith(e)):t},async stat(e){try{let t=await i(e).getMetadata();return {key:e,size:Number(t.size??0),updatedAt:t.updated??void 0,contentType:t.contentType??void 0}}catch(t){if(u(t))return null;throw t}},keyRef(e){return {kind:"firebase-storage",value:d(n,p(e))}},async renameKey(e,t){let c=i(e),f,l;try{l=await c.getMetadata(),f=await a(c);}catch(y){if(u(y))return false;throw y}await i(t).put(f,{contentType:l.contentType??"application/octet-stream"});try{await c.delete();}catch{}return true}}}function S(r,n){let o=w(r,n);async function i(s="scratch-",a=""){let g=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return `${s}${g}${a}`}return {...o,getUniqueKey:i,async create(s,a="scratch-",g=""){let e=await i(a,g);return await o.write(e,s),e},keyRef(s){return {kind:"firebase-storage",value:d(n,p(s))}},config:{async get(s){let a=await o.read(`__config__/${s}`);if(a==null)return null;try{return JSON.parse(a)}catch{return a}},async set(s,a){await o.write(`__config__/${s}`,JSON.stringify(a));}}}}function T(r,n,o){let i=d("boards",o,"blobs"),s=d("boards",o,"scratch");return {...r,blobStorage(a){return w(n,d(i,a||"root"))},blobStorageForRef(a){let g=k(a);return g.kind==="firebase-storage"?w(n,g.value):r.blobStorageForRef(a)},scratchStorage(){return S(n,s)},scratchStorageForRef(){return S(n,s)},async resolveBlob(a){if(a?.kind==="firebase-storage"&&typeof a.value=="string"){let g=await n.ref(a.value).getDownloadURL(),e=await fetch(g,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to resolve storage blob ${a.value}: ${e.status}`);return e.text()}return typeof r.resolveBlob=="function"?r.resolveBlob(a):null}}}
|
|
2
|
+
exports.createFirebaseStorageBlobStore=w;exports.createFirebaseStorageScratchStore=S;exports.wrapWithFirebaseStorageBlobs=T;return exports;})({});//# sourceMappingURL=firebase-storage.js.map
|
|
3
3
|
//# sourceMappingURL=firebase-storage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var FirestoreStorage=(function(exports){'use strict';var V="b64:";function Ne(e){let t=new TextEncoder().encode(e),r=globalThis.Buffer,n;if(r)n=r.from(t).toString("base64");else if(typeof btoa=="function"){let o="";for(let s of t)o+=String.fromCharCode(s);n=btoa(o);}else throw new Error("No base64 encoder available in this runtime");return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function $e(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let n=atob(t),o=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)o[s]=n.charCodeAt(s);return new TextDecoder().decode(o)}throw new Error("No base64 decoder available in this runtime")}function I(e){return `${V}${Ne(JSON.stringify(e))}`}function q(e){if(!e.startsWith(V))throw new Error(`Invalid ref format (expected ${V}<base64url(json)>): ${e}`);let t;try{t=JSON.parse($e(e.slice(V.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}function M(){return function(e){if(e==="./jsonata-sync.cjs")return typeof globalThis<"u"&&globalThis.__jsonataSync||typeof globalThis<"u"&&globalThis.jsonataSync;throw new Error("Unsupported require in browser bundle: "+e)}}var ue={$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"},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"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},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"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},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:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",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 by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",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 ce=void 0;var de=void 0;var Ve=M(),Me=Ve("./jsonata-sync.cjs"),J=null;var le=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Je=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Ge(e){let t=new Set,r;for(le.lastIndex=0;(r=le.exec(e))!==null;)t.add(r[1]);return t}function fe(e){let t=Je.exec(e);return t?t[1]:null}function ge(e,t,r,n){try{Me(e);}catch(s){let i=s instanceof Error?s.message:String(s);n.push(`${t}: invalid JSONata expression (${i})`);return}let o=Ge(e);for(let s of o)r.has(s)||n.push(`${t}: disallowed namespace "${s}" in expression`);}function Y(e,t,r){if(Array.isArray(e)){e.forEach((o,s)=>{Y(o,`${t}/${s}`,r);});return}if(typeof e=="string"){let o=fe(e);if(!o)return;new Set(["card_data","requires","computed_values"]).has(o)||r.push(`${t}: disallowed namespace "${o}" in view reference`);return}if(!e||typeof e!="object")return;let n=e;for(let[o,s]of Object.entries(n))Y(s,`${t}/${o}`,r);}function He(){if(J)return J;let e=new ce({allErrors:true});return de(e),J=e.compile(ue),J}function pe(e){let t=He(),r=t(e),n=(t.errors??[]).map(o=>`${o.instancePath||"/"}: ${o.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let o=e.source_defs;if(Array.isArray(o)){let s=new Set,i=new Set;o.forEach((a,f)=>{if(!a||typeof a!="object"||Array.isArray(a))return;let l=a;typeof l.bindTo=="string"&&l.bindTo&&(s.has(l.bindTo)&&n.push(`/source_defs/${f}/bindTo: bindTo "${l.bindTo}" must be unique across all source_defs`),s.add(l.bindTo)),typeof l.outputFile=="string"&&l.outputFile&&(i.has(l.outputFile)&&n.push(`/source_defs/${f}/outputFile: outputFile "${l.outputFile}" must be unique across all source_defs`),i.add(l.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function me(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let r=e,n=r.compute;Array.isArray(n)&&n.forEach((l,S)=>{if(!l||typeof l!="object"||Array.isArray(l))return;let m=l.expr;typeof m!="string"||m.trim().length===0||ge(m,`/compute/${S}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let o=new Set(["card_data","requires","fetched_sources","computed_values"]),s=r.provides;Array.isArray(s)&&s.forEach((l,S)=>{if(!l||typeof l!="object"||Array.isArray(l))return;let m=l.ref;if(typeof m!="string"||m.trim().length===0)return;let u=fe(m);u===null?t.push(`/provides/${S}/ref: path "${m}" must start with a valid namespace (${[...o].join(", ")})`):o.has(u)||t.push(`/provides/${S}/ref: disallowed namespace "${u}" in path "${m}" (valid: ${[...o].join(", ")})`);});let i=r.view;i&&typeof i=="object"&&!Array.isArray(i)&&Y(i,"/view",t);let a=new Set(["card_data","requires"]),f=r.source_defs;return Array.isArray(f)&&f.forEach((l,S)=>{if(!l||typeof l!="object"||Array.isArray(l))return;let m=l.projections;if(!(!m||typeof m!="object"||Array.isArray(m)))for(let[u,c]of Object.entries(m))typeof c!="string"||c.trim().length===0||ge(c,`/source_defs/${S}/projections/${u}`,a,t);}),{ok:t.length===0,errors:t}}function X(e){let t=pe(e);if(!t.ok)return t;let r=me(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}var Ue=M(),G=Ue("./jsonata-sync.cjs"),he=G;function ye(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let o=0;o<r.length;o++){if(n==null)return;n=n[r[o]];}return n}function Se(e,t,r){let n=t.split("."),o=e;for(let s=0;s<n.length-1;s++)(o[n[s]]==null||typeof o[n[s]]!="object")&&(o[n[s]]={}),o=o[n[s]];o[n[n.length-1]]=r;}async function Qe(e,t){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let o of e.compute)try{let s=await G(o.expr).evaluate(n);Se(e.computed_values,o.bindTo,s),n.computed_values=e.computed_values;}catch{}return e}function We(e,t){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},o=[];for(let s of e.compute)try{let i=he(s.expr).evaluate(n);Se(e.computed_values,s.bindTo,i),n.computed_values=e.computed_values;}catch(i){let a=i instanceof Error?i.message:String(i);o.push({bindTo:s.bindTo,error:a});}return o.length>0?{ok:true,node:e,errors:o}:{ok:true,node:e}}async function ze(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return G(e).evaluate(n)}function Ye(e,t){return t.startsWith("fetched_sources.")?ye(e._sourcesData??{},t.slice(16)):ye(e,t)}var ke=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),Xe=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function Ze(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let r=e;(typeof r.id!="string"||!r.id)&&t.push("id: required, must be a non-empty string");for(let n of Object.keys(r))Xe.has(n)||t.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&t.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))t.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&t.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&t.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&t.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,o)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`provides[${o}]: must be an object with bindTo and ref`);else {let s=n;(typeof s.bindTo!="string"||!s.bindTo)&&t.push(`provides[${o}]: missing required "bindTo" string`),(typeof s.ref!="string"||!s.ref)&&t.push(`provides[${o}]: missing required "ref" string`);}}):t.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,o)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`compute[${o}]: must be a compute step object`);else {let s=n;(typeof s.bindTo!="string"||!s.bindTo)&&t.push(`compute[${o}]: missing required "bindTo" property`),(typeof s.expr!="string"||!s.expr)&&t.push(`compute[${o}]: missing required "expr" string (JSONata expression)`);}}):t.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))t.push("source_defs: must be an array");else {let n=new Set,o=new Set;r.source_defs.forEach((s,i)=>{if(!s||typeof s!="object"||Array.isArray(s))t.push(`source_defs[${i}]: must be an object`);else {let a=s;typeof a.bindTo!="string"||!a.bindTo?t.push(`source_defs[${i}]: missing required "bindTo" property`):(n.has(a.bindTo)&&t.push(`source_defs[${i}]: bindTo "${a.bindTo}" is not unique across source_defs`),n.add(a.bindTo)),typeof a.outputFile!="string"||!a.outputFile?t.push(`source_defs[${i}]: missing required "outputFile" property`):(o.has(a.outputFile)&&t.push(`source_defs[${i}]: outputFile "${a.outputFile}" is not unique across source_defs`),o.add(a.outputFile)),a.optionalForCompletionGating!=null&&typeof a.optionalForCompletionGating!="boolean"&&t.push(`source_defs[${i}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))t.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?t.push("view.elements: required, must be a non-empty array"):n.elements.forEach((o,s)=>{if(!o||typeof o!="object"){t.push(`view.elements[${s}]: must be an object`);return}!o.kind||typeof o.kind!="string"?t.push(`view.elements[${s}].kind: required, must be a string`):ke.has(o.kind)||t.push(`view.elements[${s}].kind: unknown kind "${o.kind}". Valid: ${[...ke].join(", ")}`),o.data!=null&&(typeof o.data!="object"||Array.isArray(o.data))&&t.push(`view.elements[${s}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&t.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&t.push("view.features: must be an object");}return {ok:t.length===0,errors:t}}async function et(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return Promise.all(e.map(async n=>{let o={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[s,i]of Object.entries(n.projections))if(typeof i=="string"&&i.trim().length>0)try{o[s]=await G(i).evaluate(r);}catch{o[s]=void 0;}}return {...n,_projections:o}}))}function tt(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return e.map(n=>{let o={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[s,i]of Object.entries(n.projections))if(typeof i=="string"&&i.trim().length>0)try{o[s]=he(i).evaluate(r);}catch{o[s]=void 0;}}return {...n,_projections:o}})}var O={run:Qe,runSync:We,eval:ze,resolve:Ye,validate:Ze,enrichSources:et,enrichSourcesSync:tt};function be(e){let t=X(e);return {isValid:t.ok,issues:t.errors}}function Z(e){return JSON.stringify(e)}function ee(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}function te(e){return {messageId:e.id,enqueuedAt:e.enqueuedAt,attempt:e.attempt,request:e.body}}function nt(e){return typeof e=="string"?e.startsWith("b64:")?q(e).value:e:e.value}function $(e){return {async enqueueRequest(t){return (await e.enqueue(t)).id},async leaseRequests(t){return (await e.lease(t)).map(r=>({...te(r),leaseToken:r.leaseToken,leaseExpiresAt:r.leaseExpiresAt}))},ackRequest(t,r){return e.ack(t,r)},nackRequest(t,r,n){return e.nack(t,r,n)},async peekActive(){return (await e.peekActive()).map(te)},async peekDeadLetter(){return (await e.peekDeadLetter()).map(t=>({...te(t),reason:t.reason}))}}}function H(e){async function t(r){let n=await e.read(r);return n==null?null:typeof n=="string"?n:JSON.stringify(n)}return {async readTaskExecutorRef(){let r=await t("task-executor");if(r?.trim())return ee(r.trim())},writeTaskExecutorRef(r){return e.write("task-executor",Z(r))},readChatHandlerFlow(){return e.read("chat-handler-flow")},writeChatHandlerFlow(r){return e.write("chat-handler-flow",r)},readCardStoreRef(){return t("card-store-ref")},writeCardStoreRef(r){return e.write("card-store-ref",r)},readOutputsStoreRef(){return t("outputs-store-ref")},writeOutputsStoreRef(r){return e.write("outputs-store-ref",r)},readScratchStoreRef(){return t("scratch-store-ref")},writeScratchStoreRef(r){return e.write("scratch-store-ref",r)},readArchiveStoreRef(){return t("archive-store-ref")},writeArchiveStoreRef(r){return e.write("archive-store-ref",r)},readChatStoreRef(){return t("chat-store-ref")},writeChatStoreRef(r){return e.write("chat-store-ref",r)},readArtifactsStoreRef(){return t("artifacts-store-ref")},writeArtifactsStoreRef(r){return e.write("artifacts-store-ref",r)}}}function re(e){let t,r,n,o=e.callbackTransport,s=e.resolveBlob??(async a=>{let f=await e.blobStorage("").read(a.value);if(f==null)throw new Error(`Blob not found for ref ${a.kind}:${a.value}`);return f});async function i(a,f){if(a.howToRun==="queue-storage"){let l=e.boardWorkerStore??t??(e.queueStorage?$(e.queueStorage):void 0);return l?(t||(t=l),await l.enqueueRequest({boardId:typeof a.extra?.boardId=="string"?a.extra.boardId:e.boardId,ref:a,args:f}),{dispatched:true}):{dispatched:false,error:"queue-storage dispatch requires queueStorage or boardWorkerStore"}}if(a.howToRun==="http:post"){let l=e.fetch??globalThis.fetch;if(!l)return {dispatched:false,error:"http:post dispatch requires fetch support"};let S=await l(nt(a.whatToRun),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...f,...a.extra?{extra:a.extra}:{}})});if(!S.ok){let m=await S.text().catch(()=>"");return {dispatched:false,error:`HTTP ${S.status}: ${m}`}}return {dispatched:true}}return {dispatched:false,error:`Unsupported hosted async transport "${a.howToRun}"`}}return {kvStorage:e.kvStorage,kvStorageForRef:e.kvStorageForRef,blobStorage:e.blobStorage,scratchStorage:e.scratchStorage,scratchStorageForRef:e.scratchStorageForRef,archiveFactory:e.archiveFactory,archiveFactoryForRef:e.archiveFactoryForRef,journalStorage:e.journalStorage,boardWorkerStore:()=>{if(!t)if(e.boardWorkerStore)t=e.boardWorkerStore;else if(e.queueStorage)t=$(e.queueStorage);else throw new Error("Hosted async board adapter requires queueStorage or boardWorkerStore");return t},chatAgentStore:()=>{if(!r)if(e.chatAgentStore)r=e.chatAgentStore;else if(e.chatAgentQueueStorage)r=$(e.chatAgentQueueStorage);else if(e.boardWorkerStore)r=e.boardWorkerStore;else if(e.queueStorage)r=$(e.queueStorage);else throw new Error("Hosted async board adapter requires chatAgentStore, chatAgentQueueStorage, queueStorage, or boardWorkerStore");return r},processAccumulatedStore:()=>{if(n||(n=e.processAccumulatedStore??e.processAccumulatedQueueStorage??e.queueStorage),!n)throw new Error("Hosted async board adapter requires processAccumulatedStore, processAccumulatedQueueStorage, or queueStorage");return n},lock:e.lock,get callbackTransport(){return o},set callbackTransport(a){o=a;},dispatchExecution:(a,f)=>e.dispatchExecution?.(a,f)??i(a,f),supportsDirectSourceOutput:e.supportsDirectSourceOutput,resolveBlob:s,hashFn:e.hashFn,genId:e.genId,requestProcessAccumulated:e.requestProcessAccumulated,publishBoardChangeNotifications:e.publishBoardChangeNotifications,warn:e.onWarn}}function ne(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(ne).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${ne(t[n])}`).join(",")}}`}function U(e,t){let r=t>>>0;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r}function Ee(e){let t=ne(e),r=U(t,2166136261),n=U(t,3735928559),o=U(t,19088743),s=U(t,4277009102);return [r,n,o,s].map(i=>i.toString(16).padStart(8,"0")).join("")}function P(e){return {status:"success",data:e}}function R(e){return {status:"fail",error:e}}function B(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Rt(e,t={}){let r=()=>H(e.kvStorage("config"));async function n(){return await r().readTaskExecutorRef().catch(()=>{})}async function o(u,c,d){if(!t.nonCoreTaskExecutor)throw new Error(`${u} is not supported on the hosted Firestore runtime yet`);let k=await t.nonCoreTaskExecutor({subcommand:u,...c!==void 0?{input:typeof c=="string"?c:JSON.stringify(c)}:{},...d!==void 0?{timeoutMs:d}:{}});return L(k)}async function s(u){try{if(!u.body||typeof u.body!="object"||Array.isArray(u.body))return R("validateCardPreflight requires card JSON object in body");let c=u.body,d=c["card-content"]??c,k=typeof d.id=="string"?d.id:"(unknown)",y=be(d),h=Array.isArray(d.source_defs)&&d.source_defs.length>0,g=[...y.issues];if(h)if(t.nonCoreTaskExecutor)for(let b of d.source_defs){let p=typeof b.bindTo=="string"?b.bindTo:"(unknown)";try{let A=await o("validate-source-def",b,1e4);if(A.ok!==!0&&Array.isArray(A.errors))for(let T of A.errors)typeof T=="string"&&T&&g.push(`source "${p}": ${T}`);}catch(A){g.push(`source "${p}": executor validate-source-def failed \u2014 ${A instanceof Error?A.message:String(A)}`);}}else await n()&&g.push("executor-backed source_def preflight is not supported on the hosted Firestore runtime yet");return P({cardId:k,isValid:g.length===0,issues:g})}catch(c){return B(c)}}function i(u){try{if(!u.body||typeof u.body!="object"||Array.isArray(u.body))return R("evalCardCompute requires a JSON object in body");let c=u.body,d=c["card-content"]??c,k=typeof d.id=="string"?d.id:"(unknown)",y=c["mock-fetched-sources"]??{},h=c["mock-requires"]??{},g=d.compute;if(!g||!Array.isArray(g)||g.length===0)return P({cardId:k,ok:!0,computed_values:{},errors:[]});let b={id:k,card_data:d.card_data??{},requires:h,source_defs:d.source_defs,compute:g},p=O.runSync(b,{sourcesData:y});return P({cardId:k,ok:(p.errors??[]).length===0,computed_values:p.node.computed_values??{},errors:p.errors??[]})}catch(c){return B(c)}}async function a(u){return await n(),R(`${u} is not supported on the hosted Firestore runtime yet`)}async function f(){try{return t.nonCoreTaskExecutor?P(await o("describe-capabilities",void 0,1e4)):await a("describeTaskExecutorCapabilities")}catch(u){return B(u)}}async function l(u){try{if(!t.nonCoreTaskExecutor)return await a("probeSourcePreflight");if(!u.body||typeof u.body!="object"||Array.isArray(u.body))return R("probeSourcePreflight requires card JSON object in body");let c=u.body,d=c["card-content"]??c,k=L(c["mock-projections"]??{}),y=u.params?.sourceIdx,h=Array.isArray(d.source_defs)?d.source_defs:[];if(y===void 0)return R("probeSourcePreflight requires params.sourceIdx");if(y<0||y>=h.length)return R(`sourceIdx ${y} out of range (card has ${h.length} source(s))`);let g=h[y],b=typeof g.bindTo=="string"?g.bindTo:"source",p=await o("probe-source-preflight",{...g,_projections:k},g.timeout??6e4);return p.ok!==!0?R(typeof p.error=="string"?p.error:"Preflight probe failed"):P({bindTo:b,reachable:p.reachable,latencyMs:p.latencyMs,...typeof p.note=="string"?{note:p.note}:{}})}catch(c){return B(c)}}async function S(u){try{if(!t.nonCoreTaskExecutor)return await a("runSourcePreflight");if(!u.body||typeof u.body!="object"||Array.isArray(u.body))return R("runSourcePreflight requires card JSON object in body");let c=u.body,d=c["card-content"]??c,k=L(c["mock-projections"]??{}),y=u.params?.sourceIdx,h=Array.isArray(d.source_defs)?d.source_defs:[];if(y===void 0)return R("runSourcePreflight requires params.sourceIdx");if(y<0||y>=h.length)return R(`sourceIdx ${y} out of range (card has ${h.length} source(s))`);let g=h[y],b=typeof g.bindTo=="string"?g.bindTo:"source",p=await o("run-source-preflight",{...g,_projections:k},g.timeout??6e4);return p.ok!==!0?P({bindTo:b,ok:!1,result:null,issues:[typeof p.error=="string"?p.error:"Preflight run failed"]}):P({bindTo:b,ok:!0,result:Object.prototype.hasOwnProperty.call(p,"resultValue")?p.resultValue:null,issues:[]})}catch(c){return B(c)}}async function m(u){try{if(!u.body||typeof u.body!="object"||Array.isArray(u.body))return R("simulateCardCycle requires a JSON object in body");let c=u.body,d=c["card-content"]??c,k=typeof d.id=="string"?d.id:"(unknown)",y=L(c["mock-fetched-sources"]??{}),h=L(c["mock-requires"]??{}),g=await s({body:{"card-content":d}}),b=g.status==="success"?{isValid:g.data.isValid,issues:g.data.issues}:{isValid:!1,issues:[g.status==="fail"?g.error:"internal error"]},p=Array.isArray(d.source_defs)?d.source_defs:[],A=L(d.card_data??{}),T=[],Q=[];if(p.length>0){T=O.enrichSourcesSync(p,{card_data:A,requires:h});for(let w of T){let x=w.projections,E=w._projections;if(x&&E){for(let C of Object.keys(x))if(E[C]===void 0){let De=typeof w.bindTo=="string"?w.bindTo:"(unknown)";Q.push({bindTo:De,key:C,error:`Projection "${C}" resolved to undefined`});}}}}let N=[],W={...y};for(let w=0;w<T.length;w+=1){let x=T[w],E=typeof x.bindTo=="string"?x.bindTo:`source_${w}`;if(!t.nonCoreTaskExecutor){N.push({bindTo:E,skipped:!0,error:"No task executor configured"});continue}try{let C=await o("run-source-preflight",x,x.timeout??6e4);C.ok===!0&&!Object.prototype.hasOwnProperty.call(y,E)&&Object.prototype.hasOwnProperty.call(C,"resultValue")&&(W[E]=C.resultValue),N.push({bindTo:E,reachable:C.reachable,latencyMs:C.latencyMs,...C.ok===!0?{}:{error:typeof C.error=="string"?C.error:"Preflight run failed"}});}catch{N.push({bindTo:E,skipped:!0,error:"Executor does not support run-source-preflight"});}}let K=d.compute,ie={},z=[];if(K&&Array.isArray(K)&&K.length>0){let w={id:k,card_data:A,requires:h,source_defs:d.source_defs,compute:K},x=O.runSync(w,{sourcesData:W});ie=x.node.computed_values??{},z=x.errors??[];}return P({cardId:k,ok:b.isValid&&Q.length===0&&z.length===0&&N.every(w=>!w.error),validation:b,source_probes:N,projection_errors:Q,fetched_sources:W,computed_values:ie,compute_errors:z})}catch(c){return B(c)}}return {describeTaskExecutorCapabilities:f,validateCardPreflight:s,evalCardCompute:i,probeSourcePreflight:l,runSourcePreflight:S,simulateCardCycle:m}}function Fe(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function vt(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function At(e){let t=new TextEncoder().encode(e);return Fe(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function xt(e){return Ee(e).slice(0,16)}function qe(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}function v(e){return At(String(e))}function D(){let e=String(Date.now()).padStart(13,"0"),t=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `${e}-${t}`}function Be(e){try{return q(e)}catch{return null}}function Ie(e,t){let r=Be(e);return r?.kind==="firestore"&&r.value?r.value:t}function F(e){if(e===void 0)return null;if(Array.isArray(e))return e.map(t=>F(t===void 0?null:t));if(e&&typeof e=="object"){let t=Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>[r,F(n)]);return Object.fromEntries(t)}return e}function Le(e,t){return e.collection("boards").doc(t)}function _(e,t,r){return Le(e,t).collection(r)}function se(e){return {kind:"firestore",value:String(e)}}function j(e){return I(se(e))}function Tt(e){return {baseRef:se(`boards/${e}`),cardStoreRef:j(`boards/${e}/cards`),outputsStoreRef:j(`boards/${e}/runtime-out`),scratchStoreRef:j(`boards/${e}/scratch`),archiveStoreRef:j(`boards/${e}/archive`),chatStoreRef:j(`boards/${e}/chat`),artifactsStoreRef:j(`boards/${e}/files`)}}function Pe(e){return {async read(t){let r=await e.doc(v(t)).get();return r.exists?r.data()?.value??null:null},async write(t,r){await e.doc(v(t)).set(F({k:t,value:r}));},async delete(t){await e.doc(v(t)).delete();},async listKeys(t=""){return (await(t?e.where("k",">=",t).where("k","<",`${t}\uF8FF`).orderBy("k"):e.orderBy("k")).get()).docs.map(o=>o.data()?.k??o.id)}}}function je(e){return {async append(t){let r=D();return await e.doc(r).set(F({id:r,createdAt:new Date().toISOString(),payload:t})),{id:r,payload:t}},async readAll(){return (await e.orderBy("id").get()).docs.map(r=>{let n=r.data()??{};return {id:String(n.id??r.id),payload:n.payload}})},async readAfter(t){let o=(await(t?e.where("id",">",t).orderBy("id"):e.orderBy("id")).get()).docs.map(s=>{let i=s.data()??{};return {id:String(i.id??s.id),payload:i.payload}});return {entries:o,newCursor:o.length>0?o[o.length-1].id:t}},async clear(){let t=await e.get();if(typeof e.firestore.batch=="function"){let r=e.firestore.batch();for(let n of t.docs)r.delete(e.doc(n.id));await r.commit();return}await Promise.all(t.docs.map(r=>e.doc(r.id).delete()));}}}function ae(e){return {async read(t){let r=await e.doc(v(t)).get();return r.exists?r.data()?.content??null:null},async write(t,r){await e.doc(v(t)).set({k:t,content:r});},async exists(t){return (await e.doc(v(t)).get()).exists},async remove(t){await e.doc(v(t)).delete();},async readBytes(t){let r=await e.doc(v(t)).get();if(!r.exists)return null;let n=r.data()??{};return typeof n.bytesBase64=="string"?vt(n.bytesBase64):typeof n.content=="string"?new TextEncoder().encode(n.content):null},async writeBytes(t,r){await e.doc(v(t)).set({k:t,bytesBase64:Fe(r)});},async listKeys(t=""){return (await(t?e.where("k",">=",t).where("k","<",`${t}\uF8FF`).orderBy("k"):e.orderBy("k")).get()).docs.map(o=>o.data()?.k??o.id)},async stat(t){let r=await e.doc(v(t)).get();if(!r.exists)return null;let n=r.data()??{},o=typeof n.bytesBase64=="string"?Math.floor(n.bytesBase64.length*3/4):typeof n.content=="string"?n.content.length:0;return {key:t,size:o,contentType:String(n.contentType??"application/octet-stream")}}}}function _e(e){let t=ae(e);return {...t,async getUniqueKey(r="scratch-",n=""){return `${r}${D()}${n}`},async create(r,n="scratch-",o=""){let s=`${n}${D()}${o}`;return await t.write(s,r),s},keyRef(r){return se(`${e.path}/${v(r)}`)},config:{async get(r){let n=await t.read(`__config__/${r}`);if(n==null)return null;try{return JSON.parse(n)}catch{return n}},async set(r,n){await t.write(`__config__/${r}`,JSON.stringify(n));}}}}function Oe(e,t){let r=Le(e,t);return {stream(n){return je(r.collection(`archive-stream-${n}`))},blob(n){return ae(r.collection(`archive-blob-${n}`))},async listStreams(n=""){return typeof r.listCollections!="function"?[]:(await r.listCollections()).map(s=>s.path.split("/").at(-1)??"").filter(s=>s.startsWith(`archive-stream-${n}`)).map(s=>s.slice(15))},async listBlobs(n=""){return typeof r.listCollections!="function"?[]:(await r.listCollections()).map(s=>s.path.split("/").at(-1)??"").filter(s=>s.startsWith(`archive-blob-${n}`)).map(s=>s.slice(13))},config:{async get(n){let o=await r.collection("archive-config").doc("main").get();return o.exists?o.data()?.[n]??null:null},async set(n,o){await r.collection("archive-config").doc("main").set(F({[n]:o}),{merge:true});}}}}function Et(e,t={}){let r=t.holderId??qe(),n=t.ttlMs??3e4;return {async tryAcquire(){try{await e.firestore.runTransaction(async o=>{let s=await o.get(e),i=new Date().toISOString();if(s.exists){let a=s.data()??{};if(a.held===!0&&typeof a.expiresAt=="string"&&a.expiresAt>i)throw Object.assign(new Error("locked"),{code:"locked"})}o.set(e,{held:!0,holderId:r,acquiredAt:i,expiresAt:new Date(Date.now()+n).toISOString()});});}catch(o){if(o?.code==="locked")return null;throw o}return async()=>{try{await e.firestore.runTransaction(async o=>{let s=await o.get(e);if(!s.exists)return;(s.data()??{}).holderId===r&&o.update(e,{held:!1,holderId:null});});}catch{}}}}}function oe(e,t={}){let r=t.defaultVisibilityMs??3e4;return {async enqueue(n){let o=D(),s=new Date().toISOString();return await e.doc(o).set(F({id:o,body:n,enqueuedAt:s,attempt:0,visibleAfter:s,leaseToken:null,leaseExpiresAt:null,dead:false,deadReason:null})),{id:o,body:n,enqueuedAt:s,attempt:0}},async enqueueIfAbsent(n,o){if((await e.where("dedupKey","==",o).where("dead","==",false).limit(1).get()).docs.length>0)return null;let i=D(),a=new Date().toISOString();return await e.doc(i).set(F({id:i,body:n,dedupKey:o,enqueuedAt:a,attempt:0,visibleAfter:a,leaseToken:null,leaseExpiresAt:null,dead:false,deadReason:null})),{id:i,body:n,enqueuedAt:a,attempt:0}},async lease(n={}){let o=Math.max(1,Number(n.max??1)),s=Math.max(1,Number(n.visibilityMs??r)),i=new Date().toISOString(),a=await e.where("dead","==",false).where("visibleAfter","<=",i).orderBy("visibleAfter").limit(o*4).get(),f=[];for(let l of a.docs){if(f.length>=o)break;let S=e.doc(l.id);try{let m=null;await e.firestore.runTransaction(async u=>{let c=await u.get(S);if(!c.exists)throw new Error("gone");let d=c.data()??{},k=new Date().toISOString();if(d.dead===!0)throw new Error("dead");if(typeof d.visibleAfter=="string"&&d.visibleAfter>k)throw new Error("hidden");if(d.leaseToken&&typeof d.leaseExpiresAt=="string"&&d.leaseExpiresAt>k)throw new Error("leased");let y=qe(),h=new Date(Date.now()+s).toISOString(),g=Number(d.attempt??0)+1;u.update(S,{leaseToken:y,leaseExpiresAt:h,attempt:g}),m={id:String(d.id??l.id),body:d.body,enqueuedAt:String(d.enqueuedAt??k),attempt:g,leaseToken:y,leaseExpiresAt:h};}),m&&f.push(m);}catch{}}return f},async ack(n,o){try{return await e.firestore.runTransaction(async s=>{let i=e.doc(n),a=await s.get(i);if(!a.exists)return;if((a.data()??{}).leaseToken!==o)throw new Error("token mismatch");s.delete(i);}),!0}catch{return false}},async nack(n,o,s={}){try{return await e.firestore.runTransaction(async i=>{let a=e.doc(n),f=await i.get(a);if(!f.exists)return;if((f.data()??{}).leaseToken!==o)throw new Error("token mismatch");s.dead===!0?i.update(a,{dead:!0,deadReason:s.reason??"nacked",leaseToken:null,leaseExpiresAt:null}):i.update(a,{leaseToken:null,leaseExpiresAt:null,visibleAfter:new Date().toISOString()});}),!0}catch{return false}},async peekActive(n=""){return (await e.where("dead","==",false).orderBy("enqueuedAt").get()).docs.map(s=>s.data()??{}).filter(s=>!n||String(s.id??"").startsWith(n)).map(s=>({id:String(s.id??""),body:s.body,enqueuedAt:String(s.enqueuedAt??""),attempt:Number(s.attempt??0)}))},async peekDeadLetter(n=""){return (await e.where("dead","==",true).orderBy("enqueuedAt").get()).docs.map(s=>s.data()??{}).filter(s=>!n||String(s.id??"").startsWith(n)).map(s=>({id:String(s.id??""),body:s.body,enqueuedAt:String(s.enqueuedAt??""),attempt:Number(s.attempt??0),reason:s.deadReason}))}}}function It(e,t,r={}){return re({boardId:t,kvStorage(n){return Pe(_(e,t,`kv-${n||"root"}`))},kvStorageForRef(n){return Pe(e.collection(Ie(n,`boards/${t}/kv-root`)))},blobStorage(n){return ae(_(e,t,`blobs-${n||"root"}`))},scratchStorage(){return _e(_(e,t,"scratch"))},scratchStorageForRef(n){return _e(e.collection(Ie(n,`boards/${t}/scratch`)))},archiveFactory(){return Oe(e,t)},archiveFactoryForRef(n){let o=Be(n),s=o?.kind==="firestore-board"?o.value:t;return Oe(e,s)},journalStorage(){return je(_(e,t,"journal"))},queueStorage:oe(_(e,t,"worker-queue")),chatAgentQueueStorage:oe(_(e,t,"chat-queue")),processAccumulatedQueueStorage:oe(_(e,t,"process-queue")),lock:Et(_(e,t,"locks").doc("board-lock"),{holderId:r.holderId}),hashFn(n){return xt(n)},genId(){return D()},supportsDirectSourceOutput(n){return n.howToRun==="queue-storage"||n.howToRun==="http:post"},requestProcessAccumulated:r.requestProcessAccumulated,publishBoardChangeNotifications:r.publishBoardChangeNotifications,onWarn:n=>console.warn(`[firestore-board-adapter:${t}] ${n}`)})}function bo(e,t,r={}){let n={...Tt(t),...r.refs??{}},o=It(e,t,r);return {refs:n,boardAdapter:o,nonCore:Rt(o,r)}}
|
|
2
|
-
exports.createFirestoreArchiveFactory=
|
|
1
|
+
var FirestoreStorage=(function(exports){'use strict';var k="b64:";function ne(e){let t=new TextEncoder().encode(e),o=globalThis.Buffer,r;if(o)r=o.from(t).toString("base64");else if(typeof btoa=="function"){let n="";for(let s of t)n+=String.fromCharCode(s);r=btoa(n);}else throw new Error("No base64 encoder available in this runtime");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function oe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),o=globalThis.Buffer;if(o)return o.from(t,"base64").toString("utf8");if(typeof atob=="function"){let r=atob(t),n=new Uint8Array(r.length);for(let s=0;s<r.length;s+=1)n[s]=r.charCodeAt(s);return new TextDecoder().decode(n)}throw new Error("No base64 decoder available in this runtime")}function l(e){return `${k}${ne(JSON.stringify(e))}`}function m(e){if(!e.startsWith(k))throw new Error(`Invalid ref format (expected ${k}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(oe(e.slice(k.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let o=t;if(typeof o.kind!="string"||typeof o.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:o.kind,value:o.value}}function x(e){return {messageId:e.id,enqueuedAt:e.enqueuedAt,attempt:e.attempt,request:e.body}}function ue(e){return typeof e=="string"?e.startsWith("b64:")?m(e).value:e:e.value}function j(e){return {async enqueueRequest(t){return (await e.enqueue(t)).id},async leaseRequests(t){return (await e.lease(t)).map(o=>({...x(o),leaseToken:o.leaseToken,leaseExpiresAt:o.leaseExpiresAt}))},ackRequest(t,o){return e.ack(t,o)},nackRequest(t,o,r){return e.nack(t,o,r)},async peekActive(){return (await e.peekActive()).map(x)},async peekDeadLetter(){return (await e.peekDeadLetter()).map(t=>({...x(t),reason:t.reason}))}}}function T(e){let t=e.callbackTransport,o=e.resolveBlob??(async n=>{let s=await e.blobStorage("").read(n.value);if(s==null)throw new Error(`Blob not found for ref ${n.kind}:${n.value}`);return s});async function r(n,s){if(n.howToRun==="queue-storage")return e.queueStoreRef?(await j(e.queueStorageForRef(e.queueStoreRef,"task-executor")).enqueueRequest({boardId:typeof n.extra?.boardId=="string"?n.extra.boardId:e.boardId,ref:n,args:s}),{dispatched:true}):{dispatched:false,error:"queue-storage dispatch requires queueStoreRef"};if(n.howToRun==="http:post"){let a=e.fetch??globalThis.fetch;if(!a)return {dispatched:false,error:"http:post dispatch requires fetch support"};let i=await a(ue(n.whatToRun),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,...n.extra?{extra:n.extra}:{}})});if(!i.ok){let u=await i.text().catch(()=>"");return {dispatched:false,error:`HTTP ${i.status}: ${u}`}}return {dispatched:true}}return {dispatched:false,error:`Unsupported hosted async transport "${n.howToRun}"`}}return {kvStorage:e.kvStorage,kvStorageForRef:e.kvStorageForRef,blobStorage:e.blobStorage,blobStorageForRef:e.blobStorageForRef,chatStorageForRef:e.chatStorageForRef,queueStorageForRef:e.queueStorageForRef,scratchStorage:e.scratchStorage,scratchStorageForRef:e.scratchStorageForRef,archiveFactory:e.archiveFactory,archiveFactoryForRef:e.archiveFactoryForRef,journalStorage:e.journalStorage,journalStorageForRef:e.journalStorageForRef,lock:e.lock,get callbackTransport(){return t},set callbackTransport(n){t=n;},dispatchExecution:(n,s)=>e.dispatchExecution?.(n,s)??r(n,s),supportsDirectSourceOutput:e.supportsDirectSourceOutput,resolveBlob:o,hashFn:e.hashFn,genId:e.genId,requestProcessAccumulated:e.requestProcessAccumulated,publishBoardChangeNotifications:e.publishBoardChangeNotifications,warn:e.onWarn}}function E(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(E).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${E(t[r])}`).join(",")}}`}function w(e,t){let o=t>>>0;for(let r=0;r<e.length;r++)o^=e.charCodeAt(r),o=Math.imul(o,16777619)>>>0;return o}function U(e){let t=E(e),o=w(t,2166136261),r=w(t,3735928559),n=w(t,19088743),s=w(t,4277009102);return [o,r,n,s].map(a=>a.toString(16).padStart(8,"0")).join("")}function H(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function Q(e){let t=e.payload??{};return {id:e.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function W(e,t){let o=n=>`chats/${H(n)}/processing`,r=n=>`chats/${H(n)}/config`;return {async append(n,s,a,i=[],u=""){return (await e(n).append({role:s,text:a,files:i,turn:u,updated_at:new Date().toISOString()})).id},async readAll(n){return (await e(n).readAll()).map(Q)},async readAfter(n,s){let a=await e(n).readAfter(s);return {records:a.entries.map(Q),cursor:a.newCursor}},async clear(n){await e(n).clear?.();},async setProcessing(n,s){s?await t.write(o(n),true):await t.delete(o(n));},async isProcessing(n){return await t.read(o(n))===true},async getConfig(n){return await t.read(r(n))??{}},async setConfig(n,s){let a=await t.read(r(n))??{};await t.write(r(n),{...a,...s});}}}function Fe(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function X(e){let t="";for(let o=0;o<e.length;o++)t+=String.fromCharCode(e[o]);return btoa(t)}function Oe(e){let t=atob(e),o=new Uint8Array(t.length);for(let r=0;r<t.length;r++)o[r]=t.charCodeAt(r);return o}function _e(e){let t=new TextEncoder().encode(e);return X(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function qe(e){return U(e).slice(0,16)}function Z(){return globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}function c(e){return _e(String(e))}function p(){let e=String(Date.now()).padStart(13,"0"),t=Math.random().toString(36).slice(2,10).padEnd(8,"0");return `${e}-${t}`}function ee(e){try{return m(e)}catch{return null}}function y(e,t){let o=ee(e);return o?.kind==="firestore"&&o.value?o.value:t}function f(e){if(e===void 0)return null;if(Array.isArray(e))return e.map(t=>f(t===void 0?null:t));if(e&&typeof e=="object"){let t=Object.entries(e).filter(([,o])=>o!==void 0).map(([o,r])=>[o,f(r)]);return Object.fromEntries(t)}return e}function te(e,t){return e.collection("boards").doc(t)}function S(e,t,o){return te(e,t).collection(o)}function P(e){return {kind:"firestore",value:String(e)}}function g(e){return l(P(e))}function re(e){return {baseRef:P(`boards/${e}`),boardRuntimeStoreRef:g(`boards/${e}/runtime-board`),cardStoreRef:g(`boards/${e}/cards`),outputsStoreRef:g(`boards/${e}/runtime-out`),queueStoreRef:g(`boards/${e}/runtime`),scratchStoreRef:g(`boards/${e}/scratch`),chatStoreRef:g(`boards/${e}/chat`),artifactsStoreRef:g(`boards/${e}/files`),fetchedSourcesStoreRef:g(`boards/${e}/sources`)}}function I(e){return {async read(t){let o=await e.doc(c(t)).get();return o.exists?o.data()?.value??null:null},async write(t,o){await e.doc(c(t)).set(f({k:t,value:o}));},async delete(t){await e.doc(c(t)).delete();},async listKeys(t=""){return (await(t?e.where("k",">=",t).where("k","<",`${t}\uF8FF`).orderBy("k"):e.orderBy("k")).get()).docs.map(n=>n.data()?.k??n.id)}}}function C(e){return {async append(t){let o=p();return await e.doc(o).set(f({id:o,createdAt:new Date().toISOString(),payload:t})),{id:o,payload:t}},async readAll(){return (await e.orderBy("id").get()).docs.map(o=>{let r=o.data()??{};return {id:String(r.id??o.id),payload:r.payload}})},async readAfter(t){let n=(await(t?e.where("id",">",t).orderBy("id"):e.orderBy("id")).get()).docs.map(s=>{let a=s.data()??{};return {id:String(a.id??s.id),payload:a.payload}});return {entries:n,newCursor:n.length>0?n[n.length-1].id:t}},async clear(){let t=await e.get();if(typeof e.firestore.batch=="function"){let o=e.firestore.batch();for(let r of t.docs)o.delete(e.doc(r.id));await o.commit();return}await Promise.all(t.docs.map(o=>e.doc(o.id).delete()));}}}function b(e){return {async read(t){let o=await e.doc(c(t)).get();return o.exists?o.data()?.content??null:null},async write(t,o){await e.doc(c(t)).set({k:t,content:o});},async exists(t){return (await e.doc(c(t)).get()).exists},async remove(t){await e.doc(c(t)).delete();},async readBytes(t){let o=await e.doc(c(t)).get();if(!o.exists)return null;let r=o.data()??{};return typeof r.bytesBase64=="string"?Oe(r.bytesBase64):typeof r.content=="string"?new TextEncoder().encode(r.content):null},async writeBytes(t,o){await e.doc(c(t)).set({k:t,bytesBase64:X(o)});},async listKeys(t=""){return (await(t?e.where("k",">=",t).where("k","<",`${t}\uF8FF`).orderBy("k"):e.orderBy("k")).get()).docs.map(n=>n.data()?.k??n.id)},async stat(t){let o=await e.doc(c(t)).get();if(!o.exists)return null;let r=o.data()??{},n=typeof r.bytesBase64=="string"?Math.floor(r.bytesBase64.length*3/4):typeof r.content=="string"?r.content.length:0;return {key:t,size:n,contentType:String(r.contentType??"application/octet-stream")}},async renameKey(t,o){let r=await e.doc(c(t)).get();if(!r.exists)return false;let n=r.data()??{};return await e.doc(c(o)).set({...n,k:o}),await e.doc(c(t)).delete(),true}}}function z(e){let t=b(e);return {...t,async getUniqueKey(o="scratch-",r=""){return `${o}${p()}${r}`},async create(o,r="scratch-",n=""){let s=`${r}${p()}${n}`;return await t.write(s,o),s},keyRef(o){return P(`${e.path}/${c(o)}`)},config:{async get(o){let r=await t.read(`__config__/${o}`);if(r==null)return null;try{return JSON.parse(r)}catch{return r}},async set(o,r){await t.write(`__config__/${o}`,JSON.stringify(r));}}}}function Y(e,t){let o=te(e,t);return {stream(r){return C(o.collection(`archive-stream-${r}`))},blob(r){return b(o.collection(`archive-blob-${r}`))},async listStreams(r=""){return typeof o.listCollections!="function"?[]:(await o.listCollections()).map(s=>s.path.split("/").at(-1)??"").filter(s=>s.startsWith(`archive-stream-${r}`)).map(s=>s.slice(15))},async listBlobs(r=""){return typeof o.listCollections!="function"?[]:(await o.listCollections()).map(s=>s.path.split("/").at(-1)??"").filter(s=>s.startsWith(`archive-blob-${r}`)).map(s=>s.slice(13))},config:{async get(r){let n=await o.collection("archive-config").doc("main").get();return n.exists?n.data()?.[r]??null:null},async set(r,n){await o.collection("archive-config").doc("main").set(f({[r]:n}),{merge:true});}}}}function Be(e,t={}){let o=t.holderId??Z(),r=t.ttlMs??3e4;return {async tryAcquire(){try{await e.firestore.runTransaction(async n=>{let s=await n.get(e),a=new Date().toISOString();if(s.exists){let i=s.data()??{};if(i.held===!0&&typeof i.expiresAt=="string"&&i.expiresAt>a)throw Object.assign(new Error("locked"),{code:"locked"})}n.set(e,{held:!0,holderId:o,acquiredAt:a,expiresAt:new Date(Date.now()+r).toISOString()});});}catch(n){if(n?.code==="locked")return null;throw n}return async()=>{try{await e.firestore.runTransaction(async n=>{let s=await n.get(e);if(!s.exists)return;(s.data()??{}).holderId===o&&n.update(e,{held:!1,holderId:null});});}catch{}}}}}function Le(e,t={}){let o=t.defaultVisibilityMs??3e4;return {async enqueue(r){let n=p(),s=new Date().toISOString();return await e.doc(n).set(f({id:n,body:r,enqueuedAt:s,attempt:0,staged:false,visibleAfter:s,leaseToken:null,leaseExpiresAt:null,dead:false,deadReason:null})),{id:n,body:r,enqueuedAt:s,attempt:0}},async enqueueMany(r){let n=[];for(let s of r)n.push(await this.enqueue(s));return n},async enqueueIfAbsent(r,n){if((await e.where("dedupKey","==",n).where("dead","==",false).limit(1).get()).docs.length>0)return null;let a=p(),i=new Date().toISOString();return await e.doc(a).set(f({id:a,body:r,dedupKey:n,enqueuedAt:i,attempt:0,staged:false,visibleAfter:i,leaseToken:null,leaseExpiresAt:null,dead:false,deadReason:null})),{id:a,body:r,enqueuedAt:i,attempt:0}},async stage(r,n={}){if(n.dedupKey&&(await e.where("dedupKey","==",n.dedupKey).where("dead","==",false).limit(1).get()).docs.length>0)return null;let s=p(),a=new Date().toISOString();return await e.doc(s).set(f({id:s,body:r,dedupKey:n.dedupKey,enqueuedAt:a,attempt:0,staged:true,visibleAfter:null,leaseToken:null,leaseExpiresAt:null,dead:false,deadReason:null})),{id:s,body:r,enqueuedAt:a,attempt:0}},async commitStaged(r){try{return await e.firestore.runTransaction(async n=>{let s=e.doc(r),a=await n.get(s);if(!a.exists)throw new Error("missing");let i=a.data()??{};if(i.dead===!0||i.staged!==!0)throw new Error("not-staged");n.update(s,{staged:!1,enqueuedAt:new Date().toISOString(),attempt:0,visibleAfter:new Date().toISOString()});}),!0}catch{return false}},async discardStaged(r,n){try{return await e.firestore.runTransaction(async s=>{let a=e.doc(r),i=await s.get(a);if(!i.exists)throw new Error("missing");let u=i.data()??{};if(u.dead===!0||u.staged!==!0)throw new Error("not-staged");s.update(a,{staged:!1,dead:!0,deadReason:n??"discarded"});}),!0}catch{return false}},async peekStaged(r=""){return (await e.where("dead","==",false).where("staged","==",true).orderBy("enqueuedAt").get()).docs.map(s=>s.data()??{}).filter(s=>!r||String(s.id??"").startsWith(r)).map(s=>({id:String(s.id??""),body:s.body,enqueuedAt:String(s.enqueuedAt??""),attempt:Number(s.attempt??0)}))},async lease(r={}){let n=Math.max(1,Number(r.max??1)),s=Math.max(1,Number(r.visibilityMs??o)),a=new Date().toISOString(),i=await e.where("dead","==",false).where("staged","==",false).where("visibleAfter","<=",a).orderBy("visibleAfter").limit(n*4).get(),u=[];for(let h of i.docs){if(u.length>=n)break;let F=e.doc(h.id);try{let v=null;await e.firestore.runTransaction(async O=>{let _=await O.get(F);if(!_.exists)throw new Error("gone");let d=_.data()??{},A=new Date().toISOString();if(d.dead===!0)throw new Error("dead");if(d.staged===!0)throw new Error("staged");if(typeof d.visibleAfter=="string"&&d.visibleAfter>A)throw new Error("hidden");if(d.leaseToken&&typeof d.leaseExpiresAt=="string"&&d.leaseExpiresAt>A)throw new Error("leased");let q=Z(),B=new Date(Date.now()+s).toISOString(),L=Number(d.attempt??0)+1;O.update(F,{leaseToken:q,leaseExpiresAt:B,attempt:L}),v={id:String(d.id??h.id),body:d.body,enqueuedAt:String(d.enqueuedAt??A),attempt:L,leaseToken:q,leaseExpiresAt:B};}),v&&u.push(v);}catch{}}return u},async ack(r,n){try{return await e.firestore.runTransaction(async s=>{let a=e.doc(r),i=await s.get(a);if(!i.exists)return;if((i.data()??{}).leaseToken!==n)throw new Error("token mismatch");s.delete(a);}),!0}catch{return false}},async nack(r,n,s={}){try{return await e.firestore.runTransaction(async a=>{let i=e.doc(r),u=await a.get(i);if(!u.exists)return;if((u.data()??{}).leaseToken!==n)throw new Error("token mismatch");s.dead===!0?a.update(i,{dead:!0,deadReason:s.reason??"nacked",leaseToken:null,leaseExpiresAt:null}):a.update(i,{leaseToken:null,leaseExpiresAt:null,visibleAfter:new Date().toISOString()});}),!0}catch{return false}},async peekActive(r=""){return (await e.where("dead","==",false).where("staged","==",false).orderBy("enqueuedAt").get()).docs.map(s=>s.data()??{}).filter(s=>!r||String(s.id??"").startsWith(r)).map(s=>({id:String(s.id??""),body:s.body,enqueuedAt:String(s.enqueuedAt??""),attempt:Number(s.attempt??0)}))},async peekDeadLetter(r=""){return (await e.where("dead","==",true).orderBy("enqueuedAt").get()).docs.map(s=>s.data()??{}).filter(s=>!r||String(s.id??"").startsWith(r)).map(s=>({id:String(s.id??""),body:s.body,enqueuedAt:String(s.enqueuedAt??""),attempt:Number(s.attempt??0),reason:s.deadReason}))}}}function De(e,t,o={}){return T({boardId:t,kvStorage(r){return I(S(e,t,`kv-${r||"root"}`))},kvStorageForRef(r){return I(e.collection(y(r,`boards/${t}/kv-root`)))},blobStorage(r){return b(S(e,t,`blobs-${r||"root"}`))},blobStorageForRef(r){return b(e.collection(y(r,`boards/${t}/blobs-root`)))},chatStorageForRef(r){let n=y(r,`boards/${t}/chat`);return W(s=>C(e.collection(`${n}-journal-${Fe(s)}`)),I(e.collection(`${n}-kv`)))},queueStoreRef:re(t).queueStoreRef,queueStorageForRef(r,n){let s=y(r,`boards/${t}/runtime`);return Le(e.collection(`${s}-${n}`))},scratchStorage(){return z(S(e,t,"scratch"))},scratchStorageForRef(r){return z(e.collection(y(r,`boards/${t}/scratch`)))},archiveFactory(){return Y(e,t)},archiveFactoryForRef(r){let n=ee(r),s=n?.kind==="firestore-board"?n.value:t;return Y(e,s)},journalStorage(){return C(S(e,t,"journal"))},journalStorageForRef(r){let n=y(r,`boards/${t}/runtime-board`);return C(e.collection(`${n}-journal`))},lock:Be(S(e,t,"locks").doc("board-lock"),{holderId:o.holderId}),hashFn(r){return qe(r)},genId(){return p()},supportsDirectSourceOutput(r){return r.howToRun==="queue-storage"||r.howToRun==="http:post"},requestProcessAccumulated:o.requestProcessAccumulated,publishBoardChangeNotifications:o.publishBoardChangeNotifications,onWarn:r=>console.warn(`[firestore-board-adapter:${t}] ${r}`)})}function Tn(e,t,o={}){let r={...re(t),...o.refs??{}},n=De(e,t,o);return {refs:r,boardAdapter:n}}
|
|
2
|
+
exports.createFirestoreArchiveFactory=Y;exports.createFirestoreBlobStorage=b;exports.createFirestoreBoardAdapter=De;exports.createFirestoreBoardRefs=re;exports.createFirestoreBoardRuntimeBundle=Tn;exports.createFirestoreJournalStorage=C;exports.createFirestoreKvStorage=I;exports.createFirestoreLock=Be;exports.createFirestoreQueueStorage=Le;exports.createFirestoreScratchStorage=z;exports.makeFirestoreRef=P;exports.serializeFirestoreRef=g;return exports;})({});//# sourceMappingURL=firestore-storage.js.map
|
|
3
3
|
//# sourceMappingURL=firestore-storage.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var LocalStorageStorage=(function(exports){'use strict';var A="b64:";function
|
|
2
|
-
${new Date().toISOString()}`);}catch{}function
|
|
3
|
-
${new Date().toISOString()}`);}catch{}function a(){let o=globalThis.localStorage.getItem(e);if(o===null)return {};try{let d=JSON.parse(o);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function u(o){try{globalThis.localStorage.setItem(e,JSON.stringify(o));}catch{}}function i(){if(globalThis.localStorage.getItem(r)===null)return;let o=a(),d=typeof o["retention.maxAgeMs"]=="number"?o["retention.maxAgeMs"]:0,l=typeof o["retention.sweepIntervalMs"]=="number"?o["retention.sweepIntervalMs"]:0;if(d<=0||l<=0)return;let g=typeof o["retention.lastSweepAt"]=="number"?o["retention.lastSweepAt"]:0,s=Date.now();if(s-g<l)return;o["retention.lastSweepAt"]=s,u(o);let c=`${t}${F}`;for(let f=0;f<globalThis.localStorage.length;f++){let p=globalThis.localStorage.key(f);if(!p||!p.startsWith(c))continue;let m=globalThis.localStorage.getItem(p);if(m)try{let y=JSON.parse(m),k=y.filter(h=>typeof h.__ts!="number"||s-h.__ts<=d);k.length!==y.length&&globalThis.localStorage.setItem(p,JSON.stringify(k));}catch{}}}return {stream(o){let d=H(o),l=n(d);function g(){let c=globalThis.localStorage.getItem(l);if(!c)return [];try{return JSON.parse(c)}catch{return []}}function s(c){try{globalThis.localStorage.setItem(l,JSON.stringify(c));}catch{}}return {append(c){let f={id:globalThis.crypto.randomUUID(),payload:c,__ts:Date.now()},p=g();p.push(f),s(p);try{i();}catch{}return {id:f.id,payload:f.payload}},readAll(){return g().map(c=>({id:c.id,payload:c.payload}))},readAfter(c){let f=g();if(!c){let k=f.map(h=>({id:h.id,payload:h.payload}));return {entries:k,newCursor:k.length>0?k[k.length-1].id:null}}let p=f.findIndex(k=>k.id===c),y=(p===-1?f:f.slice(p+1)).map(k=>({id:k.id,payload:k.payload}));return {entries:y,newCursor:y.length>0?y[y.length-1].id:c}},clear(){try{globalThis.localStorage.removeItem(l);}catch{}}}},blob(o){let d=H(o),l=I(`${t}${U}${d}`);return {read:g=>l.read(g),write:(g,s)=>{l.write(g,s);try{i();}catch{}},exists:g=>l.exists(g),remove:g=>l.remove(g),readBytes:l.readBytes?g=>l.readBytes(g):void 0,writeBytes:l.writeBytes?(g,s)=>{l.writeBytes(g,s);try{i();}catch{}}:void 0,listKeys:g=>l.listKeys(g),stat:l.stat?g=>l.stat(g):void 0}},listStreams(o){let d=`${t}${F}`,l=[];for(let g=0;g<globalThis.localStorage.length;g++){let s=globalThis.localStorage.key(g);if(!s||!s.startsWith(d))continue;let c=s.slice(d.length);(!o||c.startsWith(o))&&l.push(c);}return l.sort()},listBlobs(o){let d=`${t}${U}`,l=new Set;for(let g=0;g<globalThis.localStorage.length;g++){let s=globalThis.localStorage.key(g);if(!s||!s.startsWith(d))continue;let c=s.slice(d.length),f=c.indexOf(":"),p=f===-1?c:c.slice(0,f);(!o||p.startsWith(o))&&l.add(p);}return Array.from(l).sort()},config:{get(o){return a()[o]??null},set(o,d){let l=a();d==null?delete l[o]:l[o]=d,u(l);}}}}function Y(t){function r(e){return `${t}:kv:${e}`}return {read(e){let n=globalThis.localStorage.getItem(r(e));if(n===null)return null;try{return JSON.parse(n)}catch{return null}},write(e,n){globalThis.localStorage.setItem(r(e),JSON.stringify(n));},delete(e){globalThis.localStorage.removeItem(r(e));},listKeys(e){let n=r(e??""),a=[];for(let u=0;u<globalThis.localStorage.length;u++){let i=globalThis.localStorage.key(u);i!==null&&i.startsWith(n)&&a.push(i.slice(r("").length));}return a}}}function X(t){function r(){let n=globalThis.localStorage.getItem(t);if(!n)return [];try{return JSON.parse(n)}catch{return []}}function e(n){globalThis.localStorage.setItem(t,JSON.stringify(n));}return {readAllEntries(){return r()},appendEntry(n){let a=r();a.push(n),e(a);},generateId(){return globalThis.crypto.randomUUID()}}}function Ke(){let t=false;return {async tryAcquire(){return t?null:(t=true,()=>{t=false;})}}}function B(){let t=new Map,r=new Map;return {async enqueue(e){let n={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,body:e,enqueuedAt:new Date().toISOString(),attempt:0};return t.set(n.id,n),n},async enqueueIfAbsent(e,n){for(let u of t.values())if(u.dedupKey===n)return null;let a={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,body:e,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:n};return t.set(a.id,a),a},async lease(e){let n=Math.max(1,Math.floor(e?.max??1)),a=Math.max(1,Math.floor(e?.visibilityMs??6e4)),u=Date.now();for(let o of t.values())o.leaseExpiresAt&&Date.parse(o.leaseExpiresAt)<=u&&(delete o.leaseToken,delete o.leaseExpiresAt);let i=[];for(let o of t.values()){if(i.length>=n)break;o.leaseToken||(o.attempt+=1,o.leaseToken=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,o.leaseExpiresAt=new Date(Date.now()+a).toISOString(),i.push({id:o.id,body:o.body,enqueuedAt:o.enqueuedAt,attempt:o.attempt,leaseToken:o.leaseToken,leaseExpiresAt:o.leaseExpiresAt}));}return i},async ack(e,n){let a=t.get(e);return !a||a.leaseToken!==n?false:(t.delete(e),true)},async nack(e,n,a){let u=t.get(e);return !u||u.leaseToken!==n?false:(delete u.leaseToken,delete u.leaseExpiresAt,a?.dead&&(t.delete(e),r.set(e,{...u,reason:a.reason})),true)},async peekActive(e=""){return Array.from(t.values()).filter(n=>!n.leaseToken).filter(n=>!e||n.id.startsWith(e)).map(n=>({id:n.id,body:n.body,enqueuedAt:n.enqueuedAt,attempt:n.attempt}))},async peekDeadLetter(e=""){return Array.from(r.values()).filter(n=>!e||n.id.startsWith(e)).map(n=>({id:n.id,body:n.body,enqueuedAt:n.enqueuedAt,attempt:n.attempt,reason:n.reason}))}}}function Z(t){let r=Y(t);return {async read(e){return r.read(e)},async write(e,n){r.write(e,n);},async delete(e){r.delete(e);},async listKeys(e){return r.listKeys(e)}}}function $e(t){let r=I(t);return {async read(e){return r.read(e)},async write(e,n){r.write(e,n);},async exists(e){return r.exists(e)},async remove(e){r.remove(e);},async readBytes(e){return r.readBytes?.(e)??null},async writeBytes(e,n){await r.writeBytes?.(e,n);},async listKeys(e){return r.listKeys(e)},async stat(e){return r.stat?.(e)??null}}}function ee(t){let r=W(t);return {async read(e){return r.read(e)},async write(e,n){r.write(e,n);},async exists(e){return r.exists(e)},async remove(e){r.remove(e);},async readBytes(e){return r.readBytes?.(e)??null},async writeBytes(e,n){await r.writeBytes?.(e,n);},async listKeys(e){return r.listKeys(e)},async stat(e){return r.stat?.(e)??null},async getUniqueKey(e,n){return r.getUniqueKey(e,n)},async create(e,n,a){return r.create(e,n,a)},keyRef(e){return r.keyRef(e)},config:{async get(e){return r.config.get(e)},async set(e,n){r.config.set(e,n);}}}}function Ve(t){let r=X(t);function e(n){return {id:n.id,payload:n.event}}return {async append(n){let a={id:r.generateId(),event:n};return r.appendEntry(a),e(a)},async readAll(){return r.readAllEntries().map(e)},async readAfter(n){let a=r.readAllEntries().map(e);if(!n)return {entries:a,newCursor:a.length>0?a[a.length-1].id:null};let u=a.findIndex(o=>o.id===n),i=u===-1?a:a.slice(u+1);return {entries:i,newCursor:i.length>0?i[i.length-1].id:n}}}}function te(t){let r=z(t);return {stream(e){let n=r.stream(e);return {async append(a){return n.append(a)},async readAll(){return n.readAll()},async readAfter(a){return n.readAfter(a)},async clear(){n.clear?.();}}},blob(e){let n=r.blob(e);return {async read(a){return n.read(a)},async write(a,u){n.write(a,u);},async exists(a){return n.exists(a)},async remove(a){n.remove(a);},async readBytes(a){return n.readBytes?.(a)??null},async writeBytes(a,u){await n.writeBytes?.(a,u);},async listKeys(a){return n.listKeys(a)},async stat(a){return n.stat?.(a)??null}}},async listStreams(e){return r.listStreams(e)},async listBlobs(e){return r.listBlobs(e)},config:{async get(e){return r.config.get(e)},async set(e,n){r.config.set(e,n);}}}}function re(t){return String(t||"").trim()}function ne(t){return {kind:"local-storage",value:re(t)}}function b(t){return S(ne(t))}function oe(t){let r=`boards:${t}`;return {baseRef:ne(r),cardStoreRef:b(`${r}:cards`),outputsStoreRef:b(`${r}:runtime-out`),scratchStoreRef:b(`${r}:scratch`),archiveStoreRef:b(`${r}:archive`),chatStoreRef:b(`${r}:chat`),artifactsStoreRef:b(`${r}:files`)}}function L(t,r){try{let e=C(t);if(e?.kind==="local-storage"&&e.value)return re(e.value)}catch{}return r}function Me(t,r={}){let e=oe(t),n=B(),a=B(),u=B();return _({boardId:t,kvStorage(i){return Z(`${e.baseRef.value}:${i||"root"}`)},kvStorageForRef(i){return Z(L(i,`${e.baseRef.value}:root`))},blobStorage(i){return $e(i?`${e.baseRef.value}:${i}`:e.baseRef.value)},scratchStorage(){return ee(`${e.baseRef.value}:scratch`)},scratchStorageForRef(i){return ee(L(i,`${e.baseRef.value}:scratch`))},archiveFactory(){return te(`${e.baseRef.value}:archive`)},archiveFactoryForRef(i){return te(L(i,`${e.baseRef.value}:archive`))},journalStorage(){return Ve(`${e.baseRef.value}:journal`)},queueStorage:n,chatAgentQueueStorage:a,processAccumulatedQueueStorage:u,lock:Ke(),resolveBlob:async i=>{let o=i?.kind==="local-storage"?i:null;if(!o?.value)throw new Error(`Unsupported localStorage ref: ${S(i)}`);let d=I(o.value),l=await Promise.resolve(d.read(""));if(l===null)throw new Error(`Blob not found: ${S(i)}`);try{let g=JSON.parse(l);if(g?.__kind==="bytes-b64"&&typeof g.data=="string"){let s=await Promise.resolve(d.readBytes?.(""));if(s)return new TextDecoder().decode(s)}}catch{}return l},hashFn:Q,genId:()=>(globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`).replace(/-/g,""),requestProcessAccumulated:r.requestProcessAccumulated,publishBoardChangeNotifications:r.publishBoardChangeNotifications,onWarn:i=>console.warn(`[localstorage-board-adapter:${t}] ${i}`)})}function On(t,r={}){return {refs:{...oe(t),...r.refs??{}},boardAdapter:Me(t,r)}}exports.createLocalStorageBoardAdapter=Me;exports.createLocalStorageBoardRefs=oe;exports.createLocalStorageBoardRuntimeBundle=On;exports.makeLocalStorageRef=ne;exports.serializeLocalStorageRef=b;return exports;})({});//# sourceMappingURL=localstorage-storage.js.map
|
|
1
|
+
var LocalStorageStorage=(function(exports){'use strict';var A="b64:";function ce(r){let t=new TextEncoder().encode(r),n=globalThis.Buffer,o;if(n)o=n.from(t).toString("base64");else if(typeof btoa=="function"){let e="";for(let s of t)e+=String.fromCharCode(s);o=btoa(e);}else throw new Error("No base64 encoder available in this runtime");return o.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function de(r){let t=r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4),n=globalThis.Buffer;if(n)return n.from(t,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(t),e=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)e[s]=o.charCodeAt(s);return new TextDecoder().decode(e)}throw new Error("No base64 decoder available in this runtime")}function h(r){return `${A}${ce(JSON.stringify(r))}`}function v(r){if(!r.startsWith(A))throw new Error(`Invalid ref format (expected ${A}<base64url(json)>): ${r}`);let t;try{t=JSON.parse(de(r.slice(A.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${r}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${r}`);let n=t;if(typeof n.kind!="string"||typeof n.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${r}`);return {kind:n.kind,value:n.value}}function _(r){return {messageId:r.id,enqueuedAt:r.enqueuedAt,attempt:r.attempt,request:r.body}}function pe(r){return typeof r=="string"?r.startsWith("b64:")?v(r).value:r:r.value}function j(r){return {async enqueueRequest(t){return (await r.enqueue(t)).id},async leaseRequests(t){return (await r.lease(t)).map(n=>({..._(n),leaseToken:n.leaseToken,leaseExpiresAt:n.leaseExpiresAt}))},ackRequest(t,n){return r.ack(t,n)},nackRequest(t,n,o){return r.nack(t,n,o)},async peekActive(){return (await r.peekActive()).map(_)},async peekDeadLetter(){return (await r.peekDeadLetter()).map(t=>({..._(t),reason:t.reason}))}}}function O(r){let t=r.callbackTransport,n=r.resolveBlob??(async e=>{let s=await r.blobStorage("").read(e.value);if(s==null)throw new Error(`Blob not found for ref ${e.kind}:${e.value}`);return s});async function o(e,s){if(e.howToRun==="queue-storage")return r.queueStoreRef?(await j(r.queueStorageForRef(r.queueStoreRef,"task-executor")).enqueueRequest({boardId:typeof e.extra?.boardId=="string"?e.extra.boardId:r.boardId,ref:e,args:s}),{dispatched:true}):{dispatched:false,error:"queue-storage dispatch requires queueStoreRef"};if(e.howToRun==="http:post"){let u=r.fetch??globalThis.fetch;if(!u)return {dispatched:false,error:"http:post dispatch requires fetch support"};let a=await u(pe(e.whatToRun),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,...e.extra?{extra:e.extra}:{}})});if(!a.ok){let c=await a.text().catch(()=>"");return {dispatched:false,error:`HTTP ${a.status}: ${c}`}}return {dispatched:true}}return {dispatched:false,error:`Unsupported hosted async transport "${e.howToRun}"`}}return {kvStorage:r.kvStorage,kvStorageForRef:r.kvStorageForRef,blobStorage:r.blobStorage,blobStorageForRef:r.blobStorageForRef,chatStorageForRef:r.chatStorageForRef,queueStorageForRef:r.queueStorageForRef,scratchStorage:r.scratchStorage,scratchStorageForRef:r.scratchStorageForRef,archiveFactory:r.archiveFactory,archiveFactoryForRef:r.archiveFactoryForRef,journalStorage:r.journalStorage,journalStorageForRef:r.journalStorageForRef,lock:r.lock,get callbackTransport(){return t},set callbackTransport(e){t=e;},dispatchExecution:(e,s)=>r.dispatchExecution?.(e,s)??o(e,s),supportsDirectSourceOutput:r.supportsDirectSourceOutput,resolveBlob:n,hashFn:r.hashFn,genId:r.genId,requestProcessAccumulated:r.requestProcessAccumulated,publishBoardChangeNotifications:r.publishBoardChangeNotifications,warn:r.onWarn}}function F(r){if(r==null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r))return `[${r.map(F).join(",")}]`;let t=r;return `{${Object.keys(t).sort().map(o=>`${JSON.stringify(o)}:${F(t[o])}`).join(",")}}`}function T(r,t){let n=t>>>0;for(let o=0;o<r.length;o++)n^=r.charCodeAt(o),n=Math.imul(n,16777619)>>>0;return n}function W(r){let t=F(r),n=T(t,2166136261),o=T(t,3735928559),e=T(t,19088743),s=T(t,4277009102);return [n,o,e,s].map(u=>u.toString(16).padStart(8,"0")).join("")}function I(r){function t(s){return `${r}:blob:${s}`}let n=new TextEncoder;function o(s){if(typeof btoa=="function"){let u="";for(let a=0;a<s.length;a++)u+=String.fromCharCode(s[a]);return btoa(u)}return ""}function e(s){if(typeof atob=="function"){let u=atob(s),a=new Uint8Array(u.length);for(let c=0;c<u.length;c++)a[c]=u.charCodeAt(c);return a}return new Uint8Array}return {read(s){return globalThis.localStorage.getItem(t(s))},write(s,u){globalThis.localStorage.setItem(t(s),u);},exists(s){return globalThis.localStorage.getItem(t(s))!==null},remove(s){globalThis.localStorage.removeItem(t(s));},readBytes(s){let u=globalThis.localStorage.getItem(t(s));if(u===null)return null;try{let a=JSON.parse(u);if(a&&a.__kind==="bytes-b64"&&typeof a.data=="string")return e(a.data)}catch{}return n.encode(u)},writeBytes(s,u){let a=JSON.stringify({__kind:"bytes-b64",data:o(u)});globalThis.localStorage.setItem(t(s),a);},listKeys(s){let u=t(s??""),a=[];for(let c=0;c<globalThis.localStorage.length;c++){let l=globalThis.localStorage.key(c);l&&l.startsWith(u)&&a.push(l.slice(t("").length));}return a.sort()},stat(s){let u=globalThis.localStorage.getItem(t(s));if(u===null)return null;let a=n.encode(u).byteLength;try{let c=JSON.parse(u);c&&c.__kind==="bytes-b64"&&typeof c.data=="string"&&(a=e(c.data).byteLength);}catch{}return {key:s,size:a}},renameKey(s,u){let a=globalThis.localStorage.getItem(t(s));return a===null?false:(globalThis.localStorage.setItem(t(u),a),globalThis.localStorage.removeItem(t(s)),true)}}}var De=":scratch-marker",je=":scratch-config",E=":scratch:",Ke=1440*60*1e3,Ne=720*60*1e3,$e=200;function U(r,t){if(!r)return t;let n=r.replace(/[^A-Za-z0-9._-]/g,"_");return n.length>0?n:t}function z(r){let t=`${r}${De}`,n=`${r}${je}`,o=i=>`${r}${E}${i}`,e=i=>`${r}${E}${i}:__ts`,s=globalThis.localStorage.getItem(t)===null;if(s)try{globalThis.localStorage.setItem(t,`scratch-store
|
|
2
|
+
${new Date().toISOString()}`);}catch{}function u(){let i=globalThis.localStorage.getItem(n);if(i===null)return {};try{let d=JSON.parse(i);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function a(i){try{globalThis.localStorage.setItem(n,JSON.stringify(i));}catch{}}if(s){let i=u();typeof i["retention.lastSweepAt"]!="number"&&(i["retention.lastSweepAt"]=Date.now(),a(i));}function c(){if(globalThis.localStorage.getItem(t)===null)return;let i=u(),d=typeof i["retention.maxAgeMs"]=="number"?i["retention.maxAgeMs"]:Ke,g=typeof i["retention.sweepIntervalMs"]=="number"?i["retention.sweepIntervalMs"]:Ne;if(d<=0||g<=0)return;let p=typeof i["retention.lastSweepAt"]=="number"?i["retention.lastSweepAt"]:0,m=Date.now();if(m-p<g)return;i["retention.lastSweepAt"]=m,a(i);let y=m,S=`${r}${E}`,k=[];for(let b=0;b<globalThis.localStorage.length;b++){let w=globalThis.localStorage.key(b);w&&w.startsWith(S)&&!w.endsWith(":__ts")&&k.push(w);}for(let b of k){if(Date.now()-y>$e)break;let w=globalThis.localStorage.getItem(`${b}:__ts`),P=w===null?0:Number(w);if(Number.isFinite(P)&&P>0&&m-P>d){try{globalThis.localStorage.removeItem(b);}catch{}try{globalThis.localStorage.removeItem(`${b}:__ts`);}catch{}}}}function l(i,d){let g=U(i,"scratch"),p=U(d,".json"),m=p.startsWith(".")?p:`.${p}`,y=Math.random().toString(36).slice(2,10);return `${g}-${Date.now()}-${y}${m}`}function f(i,d){globalThis.localStorage.setItem(o(i),d),globalThis.localStorage.setItem(e(i),String(Date.now()));}return {read(i){return globalThis.localStorage.getItem(o(i))},write(i,d){f(i,d);try{c();}catch{}},exists(i){return globalThis.localStorage.getItem(o(i))!==null},remove(i){try{globalThis.localStorage.removeItem(o(i));}catch{}try{globalThis.localStorage.removeItem(e(i));}catch{}},readBytes(i){let d=globalThis.localStorage.getItem(o(i));return d===null?null:new TextEncoder().encode(d)},writeBytes(i,d){let g="";for(let p=0;p<d.length;p++)g+=String.fromCharCode(d[p]);f(i,g);try{c();}catch{}},stat(i){let d=globalThis.localStorage.getItem(o(i));if(d===null)return null;let g=globalThis.localStorage.getItem(e(i)),p=g===null?null:Number(g);return {key:i,size:new TextEncoder().encode(d).byteLength,updatedAt:p!==null&&Number.isFinite(p)?new Date(p).toISOString():void 0}},listKeys(i){let d=`${r}${E}`,g=[];for(let p=0;p<globalThis.localStorage.length;p++){let m=globalThis.localStorage.key(p);if(m&&m.startsWith(d)&&!m.endsWith(":__ts")){let y=m.slice(d.length);(!i||y.startsWith(i))&&g.push(y);}}return g.sort()},getUniqueKey(i,d){return l(i,d)},create(i,d,g){let p=l(d,g);f(p,i);try{c();}catch{}return p},keyRef(i){return {kind:"local-storage-scratch",value:i,extra:{prefix:r}}},renameKey(i,d){let g=globalThis.localStorage.getItem(o(i));if(g===null)return false;f(d,g);try{globalThis.localStorage.removeItem(o(i));}catch{}try{globalThis.localStorage.removeItem(e(i));}catch{}return true},config:{get(i){return u()[i]??null},set(i,d){let g=u();d==null?delete g[i]:g[i]=d,a(g);}}}}var Ve=":archive-marker",Me=":archive-config",q=":archive:stream:",H=":archive:blob:";function Q(r){let t=r.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function Y(r){let t=`${r}${Ve}`,n=`${r}${Me}`,o=a=>`${r}${q}${a}`;if(globalThis.localStorage.getItem(t)===null)try{globalThis.localStorage.setItem(t,`archive-store
|
|
3
|
+
${new Date().toISOString()}`);}catch{}function e(){let a=globalThis.localStorage.getItem(n);if(a===null)return {};try{let c=JSON.parse(a);return c&&typeof c=="object"&&!Array.isArray(c)?c:{}}catch{return {}}}function s(a){try{globalThis.localStorage.setItem(n,JSON.stringify(a));}catch{}}function u(){if(globalThis.localStorage.getItem(t)===null)return;let a=e(),c=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:0,l=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:0;if(c<=0||l<=0)return;let f=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,i=Date.now();if(i-f<l)return;a["retention.lastSweepAt"]=i,s(a);let d=`${r}${q}`;for(let g=0;g<globalThis.localStorage.length;g++){let p=globalThis.localStorage.key(g);if(!p||!p.startsWith(d))continue;let m=globalThis.localStorage.getItem(p);if(m)try{let y=JSON.parse(m),S=y.filter(k=>typeof k.__ts!="number"||i-k.__ts<=c);S.length!==y.length&&globalThis.localStorage.setItem(p,JSON.stringify(S));}catch{}}}return {stream(a){let c=Q(a),l=o(c);function f(){let d=globalThis.localStorage.getItem(l);if(!d)return [];try{return JSON.parse(d)}catch{return []}}function i(d){try{globalThis.localStorage.setItem(l,JSON.stringify(d));}catch{}}return {append(d){let g={id:globalThis.crypto.randomUUID(),payload:d,__ts:Date.now()},p=f();p.push(g),i(p);try{u();}catch{}return {id:g.id,payload:g.payload}},readAll(){return f().map(d=>({id:d.id,payload:d.payload}))},readAfter(d){let g=f();if(!d){let S=g.map(k=>({id:k.id,payload:k.payload}));return {entries:S,newCursor:S.length>0?S[S.length-1].id:null}}let p=g.findIndex(S=>S.id===d),y=(p===-1?g:g.slice(p+1)).map(S=>({id:S.id,payload:S.payload}));return {entries:y,newCursor:y.length>0?y[y.length-1].id:d}},clear(){try{globalThis.localStorage.removeItem(l);}catch{}}}},blob(a){let c=Q(a),l=I(`${r}${H}${c}`);return {read:f=>l.read(f),write:(f,i)=>{l.write(f,i);try{u();}catch{}},exists:f=>l.exists(f),remove:f=>l.remove(f),readBytes:l.readBytes?f=>l.readBytes(f):void 0,writeBytes:l.writeBytes?(f,i)=>{l.writeBytes(f,i);try{u();}catch{}}:void 0,listKeys:f=>l.listKeys(f),stat:l.stat?f=>l.stat(f):void 0,renameKey:(f,i)=>l.renameKey(f,i)}},listStreams(a){let c=`${r}${q}`,l=[];for(let f=0;f<globalThis.localStorage.length;f++){let i=globalThis.localStorage.key(f);if(!i||!i.startsWith(c))continue;let d=i.slice(c.length);(!a||d.startsWith(a))&&l.push(d);}return l.sort()},listBlobs(a){let c=`${r}${H}`,l=new Set;for(let f=0;f<globalThis.localStorage.length;f++){let i=globalThis.localStorage.key(f);if(!i||!i.startsWith(c))continue;let d=i.slice(c.length),g=d.indexOf(":"),p=g===-1?d:d.slice(0,g);(!a||p.startsWith(a))&&l.add(p);}return Array.from(l).sort()},config:{get(a){return e()[a]??null},set(a,c){let l=e();c==null?delete l[a]:l[a]=c,s(l);}}}}function X(r){function t(n){return `${r}:kv:${n}`}return {read(n){let o=globalThis.localStorage.getItem(t(n));if(o===null)return null;try{return JSON.parse(o)}catch{return null}},write(n,o){globalThis.localStorage.setItem(t(n),JSON.stringify(o));},delete(n){globalThis.localStorage.removeItem(t(n));},listKeys(n){let o=t(n??""),e=[];for(let s=0;s<globalThis.localStorage.length;s++){let u=globalThis.localStorage.key(s);u!==null&&u.startsWith(o)&&e.push(u.slice(t("").length));}return e}}}function Z(r){function t(){let o=globalThis.localStorage.getItem(r);if(!o)return [];try{return JSON.parse(o)}catch{return []}}function n(o){globalThis.localStorage.setItem(r,JSON.stringify(o));}return {readAllEntries(){return t()},appendEntry(o){let e=t();e.push(o),n(e);},generateId(){return globalThis.crypto.randomUUID()}}}function ee(r){return String(r).replace(/[^a-zA-Z0-9_-]/g,"_")}function te(r){let t=r.payload??{};return {id:r.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function re(r,t){let n=e=>`chats/${ee(e)}/processing`,o=e=>`chats/${ee(e)}/config`;return {async append(e,s,u,a=[],c=""){return (await r(e).append({role:s,text:u,files:a,turn:c,updated_at:new Date().toISOString()})).id},async readAll(e){return (await r(e).readAll()).map(te)},async readAfter(e,s){let u=await r(e).readAfter(s);return {records:u.entries.map(te),cursor:u.newCursor}},async clear(e){await r(e).clear?.();},async setProcessing(e,s){s?await t.write(n(e),true):await t.delete(n(e));},async isProcessing(e){return await t.read(n(e))===true},async getConfig(e){return await t.read(o(e))??{}},async setConfig(e,s){let u=await t.read(o(e))??{};await t.write(o(e),{...u,...s});}}}function Je(){let r=false;return {async tryAcquire(){return r?null:(r=true,()=>{r=false;})}}}function Ge(){let r=new Map,t=new Map,n=new Map;return {async enqueue(o){let e={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,body:o,enqueuedAt:new Date().toISOString(),attempt:0};return r.set(e.id,e),e},async enqueueMany(o){let e=[];for(let s of o)e.push(await this.enqueue(s));return e},async enqueueIfAbsent(o,e){for(let u of r.values())if(u.dedupKey===e)return null;for(let u of t.values())if(u.dedupKey===e)return null;let s={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,body:o,enqueuedAt:new Date().toISOString(),attempt:0,dedupKey:e};return r.set(s.id,s),s},async stage(o,e){let s=e?.dedupKey;if(s){for(let a of r.values())if(a.dedupKey===s)return null;for(let a of t.values())if(a.dedupKey===s)return null}let u={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,body:o,enqueuedAt:new Date().toISOString(),attempt:0,...s?{dedupKey:s}:{}};return t.set(u.id,u),u},async commitStaged(o){let e=t.get(o);return e?(t.delete(o),r.set(o,{...e,enqueuedAt:new Date().toISOString(),attempt:0}),true):false},async discardStaged(o,e){let s=t.get(o);return s?(t.delete(o),n.set(o,{...s,reason:e}),true):false},async peekStaged(o=""){return Array.from(t.values()).filter(e=>!o||e.id.startsWith(o)).map(e=>({id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}))},async lease(o){let e=Math.max(1,Math.floor(o?.max??1)),s=Math.max(1,Math.floor(o?.visibilityMs??6e4)),u=Date.now();for(let c of r.values())c.leaseExpiresAt&&Date.parse(c.leaseExpiresAt)<=u&&(delete c.leaseToken,delete c.leaseExpiresAt);let a=[];for(let c of r.values()){if(a.length>=e)break;c.leaseToken||(c.attempt+=1,c.leaseToken=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,c.leaseExpiresAt=new Date(Date.now()+s).toISOString(),a.push({id:c.id,body:c.body,enqueuedAt:c.enqueuedAt,attempt:c.attempt,leaseToken:c.leaseToken,leaseExpiresAt:c.leaseExpiresAt}));}return a},async ack(o,e){let s=r.get(o);return !s||s.leaseToken!==e?false:(r.delete(o),true)},async nack(o,e,s){let u=r.get(o);return !u||u.leaseToken!==e?false:(delete u.leaseToken,delete u.leaseExpiresAt,s?.dead&&(r.delete(o),n.set(o,{...u,reason:s.reason})),true)},async peekActive(o=""){return Array.from(r.values()).filter(e=>!e.leaseToken).filter(e=>!o||e.id.startsWith(o)).map(e=>({id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt}))},async peekDeadLetter(o=""){return Array.from(n.values()).filter(e=>!o||e.id.startsWith(o)).map(e=>({id:e.id,body:e.body,enqueuedAt:e.enqueuedAt,attempt:e.attempt,reason:e.reason}))}}}function B(r){let t=X(r);return {async read(n){return t.read(n)},async write(n,o){t.write(n,o);},async delete(n){t.delete(n);},async listKeys(n){return t.listKeys(n)}}}function ne(r){let t=I(r);return {async read(n){return t.read(n)},async write(n,o){t.write(n,o);},async exists(n){return t.exists(n)},async remove(n){t.remove(n);},async readBytes(n){return t.readBytes?.(n)??null},async writeBytes(n,o){await t.writeBytes?.(n,o);},async listKeys(n){return t.listKeys(n)},async stat(n){return t.stat?.(n)??null},async renameKey(n,o){let e=await t.read(n);return e==null?false:(t.write(o,e),t.remove(n),true)}}}function oe(r){let t=z(r);return {async read(n){return t.read(n)},async write(n,o){t.write(n,o);},async exists(n){return t.exists(n)},async remove(n){t.remove(n);},async readBytes(n){return t.readBytes?.(n)??null},async writeBytes(n,o){await t.writeBytes?.(n,o);},async listKeys(n){return t.listKeys(n)},async stat(n){return t.stat?.(n)??null},async getUniqueKey(n,o){return t.getUniqueKey(n,o)},async create(n,o,e){return t.create(n,o,e)},keyRef(n){return t.keyRef(n)},async renameKey(n,o){let e=t.read(n);return e==null?false:(t.write(o,e),t.remove(n),true)},config:{async get(n){return t.config.get(n)},async set(n,o){t.config.set(n,o);}}}}function L(r){let t=Z(r);function n(o){return {id:o.id,payload:o.event}}return {async append(o){let e={id:t.generateId(),event:o};return t.appendEntry(e),n(e)},async readAll(){return t.readAllEntries().map(n)},async readAfter(o){let e=t.readAllEntries().map(n);if(!o)return {entries:e,newCursor:e.length>0?e[e.length-1].id:null};let s=e.findIndex(a=>a.id===o),u=s===-1?e:e.slice(s+1);return {entries:u,newCursor:u.length>0?u[u.length-1].id:o}}}}function se(r){let t=Y(r);return {stream(n){let o=t.stream(n);return {async append(e){return o.append(e)},async readAll(){return o.readAll()},async readAfter(e){return o.readAfter(e)},async clear(){o.clear?.();}}},blob(n){let o=t.blob(n);return {async read(e){return o.read(e)},async write(e,s){o.write(e,s);},async exists(e){return o.exists(e)},async remove(e){o.remove(e);},async readBytes(e){return o.readBytes?.(e)??null},async writeBytes(e,s){await o.writeBytes?.(e,s);},async listKeys(e){return o.listKeys(e)},async stat(e){return o.stat?.(e)??null},async renameKey(e,s){let u=o.read(e);return u==null?false:(o.write(s,u),o.remove(e),true)}}},async listStreams(n){return t.listStreams(n)},async listBlobs(n){return t.listBlobs(n)},config:{async get(n){return t.config.get(n)},async set(n,o){t.config.set(n,o);}}}}function ae(r){return String(r||"").trim()}function Ue(r){return String(r).replace(/[^a-zA-Z0-9_-]/g,"_")}function ie(r){return {kind:"local-storage",value:ae(r)}}function R(r){return h(ie(r))}function ue(r){let t=`boards:${r}`;return {baseRef:ie(t),boardRuntimeStoreRef:R(`${t}:runtime-board`),cardStoreRef:R(`${t}:cards`),outputsStoreRef:R(`${t}:runtime-out`),queueStoreRef:R(`${t}:runtime`),scratchStoreRef:R(`${t}:scratch`),chatStoreRef:R(`${t}:chat`),artifactsStoreRef:R(`${t}:files`),fetchedSourcesStoreRef:R(`${t}:sources`)}}function C(r,t){try{let n=v(r);if(n?.kind==="local-storage"&&n.value)return ae(n.value)}catch{}return t}function He(r,t={}){let n=ue(r),o=new Map;return O({boardId:r,kvStorage(e){return B(`${n.baseRef.value}:${e||"root"}`)},kvStorageForRef(e){return B(C(e,`${n.baseRef.value}:root`))},blobStorage(e){return ne(e?`${n.baseRef.value}:${e}`:n.baseRef.value)},blobStorageForRef(e){return ne(C(e,n.baseRef.value))},chatStorageForRef(e){let s=C(e,`${n.baseRef.value}:chat`);return re(u=>L(`${s}:journal:${Ue(u)}`),B(s))},queueStoreRef:n.queueStoreRef,queueStorageForRef(e,s){let u=`${C(e,`${n.baseRef.value}:runtime`)}:queue:${s}`,a=o.get(u);return a||(a=Ge(),o.set(u,a)),a},scratchStorage(){return oe(`${n.baseRef.value}:scratch`)},scratchStorageForRef(e){return oe(C(e,`${n.baseRef.value}:scratch`))},archiveFactory(){return se(`${n.baseRef.value}:archive`)},archiveFactoryForRef(e){return se(C(e,`${n.baseRef.value}:archive`))},journalStorage(){return L(`${n.baseRef.value}:journal`)},journalStorageForRef(e){return L(`${C(e,`${n.baseRef.value}:runtime-board`)}:journal`)},lock:Je(),resolveBlob:async e=>{let s=e?.kind==="local-storage"?e:null;if(!s?.value)throw new Error(`Unsupported localStorage ref: ${h(e)}`);let u=I(s.value),a=await Promise.resolve(u.read(""));if(a===null)throw new Error(`Blob not found: ${h(e)}`);try{let c=JSON.parse(a);if(c?.__kind==="bytes-b64"&&typeof c.data=="string"){let l=await Promise.resolve(u.readBytes?.(""));if(l)return new TextDecoder().decode(l)}}catch{}return a},hashFn:W,genId:()=>(globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2,10)}`).replace(/-/g,""),requestProcessAccumulated:t.requestProcessAccumulated,publishBoardChangeNotifications:t.publishBoardChangeNotifications,onWarn:e=>console.warn(`[localstorage-board-adapter:${r}] ${e}`)})}function Bn(r,t={}){return {refs:{...ue(r),...t.refs??{}},boardAdapter:He(r,t)}}exports.createLocalStorageBoardAdapter=He;exports.createLocalStorageBoardRefs=ue;exports.createLocalStorageBoardRuntimeBundle=Bn;exports.makeLocalStorageRef=ie;exports.serializeLocalStorageRef=R;return exports;})({});//# sourceMappingURL=localstorage-storage.js.map
|
|
4
4
|
//# sourceMappingURL=localstorage-storage.js.map
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-06-
|
|
2
|
+
"generatedAt": "2026-06-04T15:03:48.421Z",
|
|
3
3
|
"algorithm": "sha256",
|
|
4
4
|
"files": {
|
|
5
|
-
"browser/board-livecards-client.js": {
|
|
6
|
-
"sha256": "sha256-OzqYS0wVXEYOZydAwyqGY+YJr6cMlsAn6EPO1bUGthc=",
|
|
7
|
-
"bytes": 19408
|
|
8
|
-
},
|
|
9
5
|
"browser/server-runtime-controlface.js": {
|
|
10
|
-
"sha256": "sha256-
|
|
11
|
-
"bytes":
|
|
6
|
+
"sha256": "sha256-le+6NG30x+2SXq38Uu0aalQabkTU8ZcE5E98Lxf81ig=",
|
|
7
|
+
"bytes": 178914
|
|
12
8
|
},
|
|
13
9
|
"browser/adapters/firestore-storage.js": {
|
|
14
|
-
"sha256": "sha256-
|
|
15
|
-
"bytes":
|
|
10
|
+
"sha256": "sha256-23NHBmU3VyuiV9sj7C+InL0hnjILiSfaRlIP4qo4DK8=",
|
|
11
|
+
"bytes": 17529
|
|
16
12
|
},
|
|
17
13
|
"browser/adapters/localstorage-storage.js": {
|
|
18
|
-
"sha256": "sha256-
|
|
19
|
-
"bytes":
|
|
14
|
+
"sha256": "sha256-owYf8HAvQDzaum2TmQInZ6kcPJ0Tp+0x1KLEIr0pxUM=",
|
|
15
|
+
"bytes": 22189
|
|
20
16
|
},
|
|
21
17
|
"browser/adapters/firebase-storage.js": {
|
|
22
|
-
"sha256": "sha256-
|
|
23
|
-
"bytes":
|
|
18
|
+
"sha256": "sha256-luv3dI9cncRpeu7kYFnIPg5cIlKXi+nPOzCAQSEjfHc=",
|
|
19
|
+
"bytes": 4872
|
|
24
20
|
},
|
|
25
21
|
"browser/live-cards.schema.json": {
|
|
26
22
|
"sha256": "sha256-uO3o9KxAKr/hQcsna4otVM2zJLlgXvZchu2PpkF+4k8=",
|