yaml-flow 8.4.8 → 8.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/browser/asset-integrity.json +3 -3
  2. package/browser/board-livecards-client.js +1 -1
  3. package/browser/board-livecards-localstorage.js +6 -6
  4. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
  5. package/cli/node/board-live-cards-cli.js +13 -13
  6. package/cli/node/chat-store-cli.js +3 -3
  7. package/cli/node/fs-board-adapter.d.ts +2 -2
  8. package/cli/node/fs-board-adapter.js +13 -13
  9. package/cli/{types-BkJvnXVD.d.ts → types-BbQ75HLf.d.ts} +3 -1
  10. package/examples/board/demo-shell-with-server.html +2 -2
  11. package/examples/board/doc.html +2 -2
  12. package/examples/board/server/board-worker/source_def_flows.json +2 -1
  13. package/examples/board/server/board-worker/task-executor.js +88 -2
  14. package/examples/board-local/demo-shell-localstorage.html +3 -3
  15. package/lib/artifacts-store-public.d.cts +1 -1
  16. package/lib/artifacts-store-public.d.ts +1 -1
  17. package/lib/board-live-cards-node.cjs +13 -13
  18. package/lib/board-live-cards-node.d.cts +4 -4
  19. package/lib/board-live-cards-node.d.ts +4 -4
  20. package/lib/board-live-cards-node.js +13 -13
  21. package/lib/{board-live-cards-public-Crjm8KWn.d.ts → board-live-cards-public-C81ZEkF-.d.ts} +3 -1
  22. package/lib/{board-live-cards-public-CU8VVw3v.d.cts → board-live-cards-public-wbWRD1nO.d.cts} +3 -1
  23. package/lib/board-live-cards-public.cjs +2 -2
  24. package/lib/board-live-cards-public.d.cts +1 -1
  25. package/lib/board-live-cards-public.d.ts +1 -1
  26. package/lib/board-live-cards-public.js +2 -2
  27. package/lib/board-live-cards-server-runtime.cjs +3 -3
  28. package/lib/board-live-cards-server-runtime.d.cts +2 -2
  29. package/lib/board-live-cards-server-runtime.d.ts +2 -2
  30. package/lib/board-live-cards-server-runtime.js +3 -3
  31. package/lib/card-store-public.d.cts +1 -1
  32. package/lib/card-store-public.d.ts +1 -1
  33. package/lib/chat-store-public.d.cts +1 -1
  34. package/lib/chat-store-public.d.ts +1 -1
  35. package/lib/server-runtime/index.cjs +3 -3
  36. package/lib/server-runtime/index.d.cts +3 -3
  37. package/lib/server-runtime/index.d.ts +3 -3
  38. package/lib/server-runtime/index.js +3 -3
  39. package/lib/{types-Dc70aHzf.d.cts → types-D5E1YmeB.d.cts} +1 -1
  40. package/lib/{types-YXF9Oai2.d.ts → types-D_WD7RYH.d.ts} +1 -1
  41. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import'child_process';import*as d from'fs';import {existsSync}from'fs';import*as T from'os';import*as y from'path';import {dirname,resolve}from'path';import'net';import {fileURLToPath}from'url';import {randomUUID}from'crypto';import {createRequire}from'module';import'proper-lockfile';import'ajv-formats';var b="b64:";function H(t){let n=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),r=globalThis.Buffer;if(r)return r.from(n,"base64").toString("utf8");if(typeof atob=="function"){let s=atob(n),o=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)o[c]=s.charCodeAt(c);return new TextDecoder().decode(o)}throw new Error("No base64 decoder available in this runtime")}function S(t){if(!t.startsWith(b))throw new Error(`Invalid ref format (expected ${b}<base64url(json)>): ${t}`);let n;try{n=JSON.parse(H(t.slice(b.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!n||typeof n!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let r=n;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:r.kind,value:r.value}}function C(...t){return y.join(...t)}function v(...t){return y.resolve(...t)}y.join(T.tmpdir(),".board-live-cards-git-bash-cache.json");var _=dirname(fileURLToPath(import.meta.url)),Q=createRequire(import.meta.url);function tt(){let t=resolve(_,"./jsonata-sync.cjs");return existsSync(t)?t:resolve(_,"../../card-compute/jsonata-sync.cjs")}Q(tt());createRequire(import.meta.url);function ot(t,n){if(process.platform!=="win32"){d.renameSync(t,n);return}let r=[10,20,40,80,160];for(let s=0;s<=r.length;s++)try{d.renameSync(t,n);return}catch(o){let c=o.code;if((c==="EPERM"||c==="EBUSY")&&s<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[s]);continue}throw o}}function F(t){function n(s){return y.join(t,...s.split("/"))+".json"}function r(s,o,c,i){if(d.existsSync(s))for(let e of d.readdirSync(s,{withFileTypes:true})){let a=o?`${o}/${e.name}`:e.name;if(e.isDirectory()){r(y.join(s,e.name),a,c,i);continue}if(!e.isFile()||!e.name.endsWith(".json"))continue;let u=a.replace(/\.json$/,"");(!c||u.startsWith(c))&&i.push(u);}}return {read(s){let o=n(s);if(!d.existsSync(o))return null;try{return JSON.parse(d.readFileSync(o,"utf-8"))}catch{return null}},write(s,o){let c=n(s),i=`${c}.${process.pid}.${randomUUID()}.tmp`;d.mkdirSync(y.dirname(c),{recursive:true}),d.writeFileSync(i,JSON.stringify(o,null,2),"utf-8"),ot(i,c);},delete(s){let o=n(s);try{d.existsSync(o)&&d.unlinkSync(o);}catch{}},listKeys(s){let o=[];return r(t,"",s,o),o.sort()}}}function P(t){function n(){if(!d.existsSync(t))return [];let r=d.readFileSync(t,"utf-8").trim();return r?r.split(`
1
+ import'child_process';import*as d from'fs';import {existsSync}from'fs';import*as T from'os';import*as y from'path';import {dirname,resolve}from'path';import'net';import {fileURLToPath}from'url';import {randomUUID}from'crypto';import {createRequire}from'module';import'proper-lockfile';import'ajv-formats';var b="b64:";function H(t){let n=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),r=globalThis.Buffer;if(r)return r.from(n,"base64").toString("utf8");if(typeof atob=="function"){let s=atob(n),o=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)o[c]=s.charCodeAt(c);return new TextDecoder().decode(o)}throw new Error("No base64 decoder available in this runtime")}function k(t){if(!t.startsWith(b))throw new Error(`Invalid ref format (expected ${b}<base64url(json)>): ${t}`);let n;try{n=JSON.parse(H(t.slice(b.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!n||typeof n!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let r=n;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:r.kind,value:r.value}}function C(...t){return y.join(...t)}function v(...t){return y.resolve(...t)}y.join(T.tmpdir(),".board-live-cards-git-bash-cache.json");var _=dirname(fileURLToPath(import.meta.url)),Q=createRequire(import.meta.url);function tt(){let t=resolve(_,"./jsonata-sync.cjs");return existsSync(t)?t:resolve(_,"../../card-compute/jsonata-sync.cjs")}Q(tt());createRequire(import.meta.url);function ot(t,n){if(process.platform!=="win32"){d.renameSync(t,n);return}let r=[10,20,40,80,160];for(let s=0;s<=r.length;s++)try{d.renameSync(t,n);return}catch(o){let c=o.code;if((c==="EPERM"||c==="EBUSY")&&s<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[s]);continue}throw o}}function F(t){function n(s){return y.join(t,...s.split("/"))+".json"}function r(s,o,c,i){if(d.existsSync(s))for(let e of d.readdirSync(s,{withFileTypes:true})){let a=o?`${o}/${e.name}`:e.name;if(e.isDirectory()){r(y.join(s,e.name),a,c,i);continue}if(!e.isFile()||!e.name.endsWith(".json"))continue;let u=a.replace(/\.json$/,"");(!c||u.startsWith(c))&&i.push(u);}}return {read(s){let o=n(s);if(!d.existsSync(o))return null;try{return JSON.parse(d.readFileSync(o,"utf-8"))}catch{return null}},write(s,o){let c=n(s),i=`${c}.${process.pid}.${randomUUID()}.tmp`;d.mkdirSync(y.dirname(c),{recursive:true}),d.writeFileSync(i,JSON.stringify(o,null,2),"utf-8"),ot(i,c);},delete(s){let o=n(s);try{d.existsSync(o)&&d.unlinkSync(o);}catch{}},listKeys(s){let o=[];return r(t,"",s,o),o.sort()}}}function P(t){function n(){if(!d.existsSync(t))return [];let r=d.readFileSync(t,"utf-8").trim();return r?r.split(`
2
2
  `).filter(Boolean).map(s=>JSON.parse(s)):[]}return {append(r){let s={id:randomUUID(),payload:r};return d.mkdirSync(y.dirname(t),{recursive:true}),d.appendFileSync(t,JSON.stringify(s)+`
3
- `,"utf-8"),s},readAll(){return n()},readAfter(r){let s=n();if(!r)return {entries:s,newCursor:s.length>0?s[s.length-1].id:null};let o=s.findIndex(i=>i.id===r),c=o===-1?s:s.slice(o+1);return {entries:c,newCursor:c.length>0?c[c.length-1].id:r}},clear(){d.existsSync(t)&&d.truncateSync(t,0);}}}var at=createRequire(import.meta.url);at("./jsonata-sync.cjs");function $(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function N(t){let n=t.payload??{};return {id:t.id,role:typeof n.role=="string"?n.role:"system",text:typeof n.text=="string"?n.text:"",files:Array.isArray(n.files)?n.files:[],updated_at:typeof n.updated_at=="string"?n.updated_at:""}}function E(t,n){let r=o=>`chats/${$(o)}/processing`,s=o=>`chats/${$(o)}/config`;return {append(o,c,i,e=[]){return t(o).append({role:c,text:i,files:e,updated_at:new Date().toISOString()}).id},readAll(o){return t(o).readAll().map(N)},readAfter(o,c){let i=t(o).readAfter(c);return {records:i.entries.map(N),cursor:i.newCursor}},clear(o){t(o).clear?.();},setProcessing(o,c){c?n.write(r(o),true):n.delete(r(o));},isProcessing(o){return n.read(r(o))===true},getConfig(o){return n.read(s(o))??{}},setConfig(o,c){let i=n.read(s(o))??{};n.write(s(o),{...i,...c});}}}var pt=createRequire(import.meta.url);pt("./jsonata-sync.cjs");function Ct(t,n){if(!t||!n)return false;let r=String(t).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===n}function M(t,n={}){let r=n.chatsSubdir??"chats",s=n.kvSubdir??".kv",o=s?[s,"chat"]:["chat"],c=r&&!Ct(t,r)?C(t,r):t,i=F(C(t,...o));return E(e=>{let u=`${String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,l=C(c,u);return P(l)},i)}function J(t){function n(e){return {status:"success",data:e}}function r(e){return {status:"fail",error:e}}function s(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function o(e,a="command envelope"){let u=typeof e.cardId=="string"?e.cardId:void 0;if(!e.command)return r(`chat-store: ${a} missing "command"`);if(!u)return r(`chat-store: ${a} missing "cardId"`);if(e.command==="append")return i.append({params:{cardId:u},body:{role:e.role,text:e.text,files:e.files}});if(e.command==="read-all")return i.readAll({params:{cardId:u}});if(e.command==="read-after")return i.readAfter({params:{cardId:u},body:{cursor:e.cursor??null}});if(e.command==="clear")return i.clear({params:{cardId:u}});if(e.command==="set-processing")return i.setProcessing({params:{cardId:u},body:{active:e.active}});if(e.command==="is-processing")return i.isProcessing({params:{cardId:u}});if(e.command==="get-config")return i.getConfig({params:{cardId:u}});if(e.command==="set-config"){let{command:l,cardId:k,...g}=e;return i.setConfig({params:{cardId:u},body:g})}return r(`chat-store: unknown command "${String(e.command)}"`)}function c(e){if(!Array.isArray(e.commands)||e.commands.length===0)return r('chat-store: command envelope must include a non-empty "commands" array');let a=[];for(let u=0;u<e.commands.length;u+=1){let l=e.commands[u];if(!l||typeof l!="object"||Array.isArray(l))return r(`chat-store: command envelope entry ${u} must be an object`);let k={cardId:e.cardId,...l},g=o(k,`command envelope entry ${u}`);if(g.status!=="success")return g;a.push({index:u,command:String(k.command),data:g.data});}return n({results:a})}let i={append(e){try{let a=e.params?.cardId;if(!a)return r("append requires params.cardId");let u=e.body??{},l=typeof u.role=="string"?u.role:"",k=typeof u.text=="string"?u.text:"",g=Array.isArray(u.files)?u.files:[];if(!l)return r("append requires body.role");let U=t.append(a,l,k,g);return n({id:U})}catch(a){return s(a)}},readAll(e){try{let a=e.params?.cardId;return a?n({records:t.readAll(a)}):r("readAll requires params.cardId")}catch(a){return s(a)}},readAfter(e){try{let a=e.params?.cardId;if(!a)return r("readAfter requires params.cardId");let l=(e.body??{}).cursor??null;return n(t.readAfter(a,l))}catch(a){return s(a)}},clear(e){try{let a=e.params?.cardId;return a?(t.clear(a),n({ok:!0})):r("clear requires params.cardId")}catch(a){return s(a)}},setProcessing(e){try{let a=e.params?.cardId;if(!a)return r("setProcessing requires params.cardId");let u=e.body??{};return typeof u.active!="boolean"?r("setProcessing requires body.active (boolean)"):(t.setProcessing(a,u.active),n({ok:!0}))}catch(a){return s(a)}},isProcessing(e){try{let a=e.params?.cardId;return a?n({active:t.isProcessing(a)}):r("isProcessing requires params.cardId")}catch(a){return s(a)}},getConfig(e){try{let a=e.params?.cardId;return a?n({config:t.getConfig(a)}):r("getConfig requires params.cardId")}catch(a){return s(a)}},setConfig(e){try{let a=e.params?.cardId;if(!a)return r("setConfig requires params.cardId");let u=e.body??{};return t.setConfig(a,u),n({ok:!0})}catch(a){return s(a)}},run:o,runBatch:c};return i}function f(t,n,r){let s=t.indexOf(n),o=s!==-1?t[s+1]:void 0;if(!o)throw new Error(`Missing ${n}
3
+ `,"utf-8"),s},readAll(){return n()},readAfter(r){let s=n();if(!r)return {entries:s,newCursor:s.length>0?s[s.length-1].id:null};let o=s.findIndex(i=>i.id===r),c=o===-1?s:s.slice(o+1);return {entries:c,newCursor:c.length>0?c[c.length-1].id:r}},clear(){d.existsSync(t)&&d.truncateSync(t,0);}}}var at=createRequire(import.meta.url);at("./jsonata-sync.cjs");function $(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function N(t){let n=t.payload??{};return {id:t.id,role:typeof n.role=="string"?n.role:"system",text:typeof n.text=="string"?n.text:"",files:Array.isArray(n.files)?n.files:[],updated_at:typeof n.updated_at=="string"?n.updated_at:""}}function E(t,n){let r=o=>`chats/${$(o)}/processing`,s=o=>`chats/${$(o)}/config`;return {append(o,c,i,e=[]){return t(o).append({role:c,text:i,files:e,updated_at:new Date().toISOString()}).id},readAll(o){return t(o).readAll().map(N)},readAfter(o,c){let i=t(o).readAfter(c);return {records:i.entries.map(N),cursor:i.newCursor}},clear(o){t(o).clear?.();},setProcessing(o,c){c?n.write(r(o),true):n.delete(r(o));},isProcessing(o){return n.read(r(o))===true},getConfig(o){return n.read(s(o))??{}},setConfig(o,c){let i=n.read(s(o))??{};n.write(s(o),{...i,...c});}}}var pt=createRequire(import.meta.url);pt("./jsonata-sync.cjs");function Ct(t,n){if(!t||!n)return false;let r=String(t).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===n}function G(t,n={}){let r=n.chatsSubdir??"chats",s=n.kvSubdir??".kv",o=s?[s,"chat"]:["chat"],c=r&&!Ct(t,r)?C(t,r):t,i=F(C(t,...o));return E(e=>{let u=`${String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,l=C(c,u);return P(l)},i)}function J(t){function n(e){return {status:"success",data:e}}function r(e){return {status:"fail",error:e}}function s(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function o(e,a="command envelope"){let u=typeof e.cardId=="string"?e.cardId:void 0;if(!e.command)return r(`chat-store: ${a} missing "command"`);if(!u)return r(`chat-store: ${a} missing "cardId"`);if(e.command==="append")return i.append({params:{cardId:u},body:{role:e.role,text:e.text,files:e.files}});if(e.command==="read-all")return i.readAll({params:{cardId:u}});if(e.command==="read-after")return i.readAfter({params:{cardId:u},body:{cursor:e.cursor??null}});if(e.command==="clear")return i.clear({params:{cardId:u}});if(e.command==="set-processing")return i.setProcessing({params:{cardId:u},body:{active:e.active}});if(e.command==="is-processing")return i.isProcessing({params:{cardId:u}});if(e.command==="get-config")return i.getConfig({params:{cardId:u}});if(e.command==="set-config"){let{command:l,cardId:S,...g}=e;return i.setConfig({params:{cardId:u},body:g})}return r(`chat-store: unknown command "${String(e.command)}"`)}function c(e){if(!Array.isArray(e.commands)||e.commands.length===0)return r('chat-store: command envelope must include a non-empty "commands" array');let a=[];for(let u=0;u<e.commands.length;u+=1){let l=e.commands[u];if(!l||typeof l!="object"||Array.isArray(l))return r(`chat-store: command envelope entry ${u} must be an object`);let S={cardId:e.cardId,...l},g=o(S,`command envelope entry ${u}`);if(g.status!=="success")return g;a.push({index:u,command:String(S.command),data:g.data});}return n({results:a})}let i={append(e){try{let a=e.params?.cardId;if(!a)return r("append requires params.cardId");let u=e.body??{},l=typeof u.role=="string"?u.role:"",S=typeof u.text=="string"?u.text:"",g=Array.isArray(u.files)?u.files:[];if(!l)return r("append requires body.role");let U=t.append(a,l,S,g);return n({id:U})}catch(a){return s(a)}},readAll(e){try{let a=e.params?.cardId;return a?n({records:t.readAll(a)}):r("readAll requires params.cardId")}catch(a){return s(a)}},readAfter(e){try{let a=e.params?.cardId;if(!a)return r("readAfter requires params.cardId");let l=(e.body??{}).cursor??null;return n(t.readAfter(a,l))}catch(a){return s(a)}},clear(e){try{let a=e.params?.cardId;return a?(t.clear(a),n({ok:!0})):r("clear requires params.cardId")}catch(a){return s(a)}},setProcessing(e){try{let a=e.params?.cardId;if(!a)return r("setProcessing requires params.cardId");let u=e.body??{};return typeof u.active!="boolean"?r("setProcessing requires body.active (boolean)"):(t.setProcessing(a,u.active),n({ok:!0}))}catch(a){return s(a)}},isProcessing(e){try{let a=e.params?.cardId;return a?n({active:t.isProcessing(a)}):r("isProcessing requires params.cardId")}catch(a){return s(a)}},getConfig(e){try{let a=e.params?.cardId;return a?n({config:t.getConfig(a)}):r("getConfig requires params.cardId")}catch(a){return s(a)}},setConfig(e){try{let a=e.params?.cardId;if(!a)return r("setConfig requires params.cardId");let u=e.body??{};return t.setConfig(a,u),n({ok:!0})}catch(a){return s(a)}},run:o,runBatch:c};return i}function f(t,n,r){let s=t.indexOf(n),o=s!==-1?t[s+1]:void 0;if(!o)throw new Error(`Missing ${n}
4
4
  Usage: ${r}`);return o}function w(t,n){let r=t.indexOf(n);return r!==-1?t[r+1]:void 0}async function V(){let t=[];for await(let n of process.stdin)t.push(Buffer.isBuffer(n)?n:Buffer.from(n));return Buffer.concat(t).toString("utf-8")}var A=["chat-store \u2014 chat history and state operations for a board card",""," chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text> [--files-json <json>]"," Append a message. Prints { id } on success.",""," chat-store read-all --store-ref <ref> --card-id <id>"," Print all messages as a JSON array.",""," chat-store read-after --store-ref <ref> --card-id <id> [--cursor <cursor>]"," Print messages after cursor as { records, cursor }.",""," chat-store clear --store-ref <ref> --card-id <id>"," Remove all messages for the card.",""," chat-store set-processing --store-ref <ref> --card-id <id> --active <true|false>"," Set or clear the processing flag.",""," chat-store is-processing --store-ref <ref> --card-id <id>"," Print { active: true|false }.",""," chat-store get-config --store-ref <ref> --card-id <id>"," Print the chat config object.",""," chat-store set-config --store-ref <ref> --card-id <id> [--system-prompt <text>]"," Patch the chat config. Extra fields can be piped as JSON to stdin.",""," Alternatively, use --stdin and pipe a JSON object to stdin:",' { "command": "<cmd>", "storeRef": "<ref>", "cardId": "<id>", ... }'," Or pipe a command envelope with defaults plus sequential commands:",' { "storeRef": "<ref>", "cardId": "<id>", "commands": [{ "command": "append", ... }, { "command": "set-processing", ... }] }'].join(`
5
- `);function K(t){return J(M(S(t).value))}async function wt(t){if(t[0]==="--stdin"){let i=await V();if(!i.trim()){console.error(A);return}let e;try{e=JSON.parse(i);}catch{console.error("chat-store: stdin is not valid JSON"),process.exit(1);}let a=e.storeRef;a||(console.error('chat-store: stdin envelope missing "storeRef"'),process.exit(1));let u=K(a);if(Array.isArray(e.commands)){p(u.runBatch(vt(e)));return}p(u.run(bt(e)));return}let n=t[0],r=t.slice(1);if(!n||n==="help"||n==="--help"||n==="-h"){console.error(A);return}let s=f(r,"--store-ref",`chat-store ${n} --store-ref <b64-ref> --card-id <id>`),o=w(r,"--card-id"),c=K(s);if(n==="append"){let i=f(r,"--role","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>"),e=f(r,"--text","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>"),a=w(r,"--files-json"),u=a?JSON.parse(a):[],l=o??f(r,"--card-id","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>");p(c.append({params:{cardId:l},body:{role:i,text:e,files:u}}));return}if(n==="read-all"){let i=o??f(r,"--card-id","chat-store read-all --store-ref <ref> --card-id <id>");p(c.readAll({params:{cardId:i}}));return}if(n==="read-after"){let i=o??f(r,"--card-id","chat-store read-after --store-ref <ref> --card-id <id>"),e=w(r,"--cursor")??null;p(c.readAfter({params:{cardId:i},body:{cursor:e}}));return}if(n==="clear"){let i=o??f(r,"--card-id","chat-store clear --store-ref <ref> --card-id <id>");p(c.clear({params:{cardId:i}}));return}if(n==="set-processing"){let i=o??f(r,"--card-id","chat-store set-processing --store-ref <ref> --card-id <id> --active <true|false>"),e=f(r,"--active","chat-store set-processing --store-ref <ref> --card-id <id> --active <true|false>");e!=="true"&&e!=="false"&&(console.error('chat-store set-processing: --active must be "true" or "false"'),process.exit(1)),p(c.setProcessing({params:{cardId:i},body:{active:e==="true"}}));return}if(n==="is-processing"){let i=o??f(r,"--card-id","chat-store is-processing --store-ref <ref> --card-id <id>");p(c.isProcessing({params:{cardId:i}}));return}if(n==="get-config"){let i=o??f(r,"--card-id","chat-store get-config --store-ref <ref> --card-id <id>");p(c.getConfig({params:{cardId:i}}));return}if(n==="set-config"){let i=o??f(r,"--card-id","chat-store set-config --store-ref <ref> --card-id <id>"),e=w(r,"--system-prompt"),a={};if(e!==void 0&&(a.systemPrompt=e),!process.stdin.isTTY){let u=await V();if(u.trim())try{Object.assign(a,JSON.parse(u));}catch{}}p(c.setConfig({params:{cardId:i},body:a}));return}console.error(`chat-store: unknown command "${n}"
5
+ `);function K(t){return J(G(k(t).value))}async function wt(t){if(t[0]==="--stdin"){let i=await V();if(!i.trim()){console.error(A);return}let e;try{e=JSON.parse(i);}catch{console.error("chat-store: stdin is not valid JSON"),process.exit(1);}let a=e.storeRef;a||(console.error('chat-store: stdin envelope missing "storeRef"'),process.exit(1));let u=K(a);if(Array.isArray(e.commands)){p(u.runBatch(vt(e)));return}p(u.run(bt(e)));return}let n=t[0],r=t.slice(1);if(!n||n==="help"||n==="--help"||n==="-h"){console.error(A);return}let s=f(r,"--store-ref",`chat-store ${n} --store-ref <b64-ref> --card-id <id>`),o=w(r,"--card-id"),c=K(s);if(n==="append"){let i=f(r,"--role","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>"),e=f(r,"--text","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>"),a=w(r,"--files-json"),u=a?JSON.parse(a):[],l=o??f(r,"--card-id","chat-store append --store-ref <ref> --card-id <id> --role <role> --text <text>");p(c.append({params:{cardId:l},body:{role:i,text:e,files:u}}));return}if(n==="read-all"){let i=o??f(r,"--card-id","chat-store read-all --store-ref <ref> --card-id <id>");p(c.readAll({params:{cardId:i}}));return}if(n==="read-after"){let i=o??f(r,"--card-id","chat-store read-after --store-ref <ref> --card-id <id>"),e=w(r,"--cursor")??null;p(c.readAfter({params:{cardId:i},body:{cursor:e}}));return}if(n==="clear"){let i=o??f(r,"--card-id","chat-store clear --store-ref <ref> --card-id <id>");p(c.clear({params:{cardId:i}}));return}if(n==="set-processing"){let i=o??f(r,"--card-id","chat-store set-processing --store-ref <ref> --card-id <id> --active <true|false>"),e=f(r,"--active","chat-store set-processing --store-ref <ref> --card-id <id> --active <true|false>");e!=="true"&&e!=="false"&&(console.error('chat-store set-processing: --active must be "true" or "false"'),process.exit(1)),p(c.setProcessing({params:{cardId:i},body:{active:e==="true"}}));return}if(n==="is-processing"){let i=o??f(r,"--card-id","chat-store is-processing --store-ref <ref> --card-id <id>");p(c.isProcessing({params:{cardId:i}}));return}if(n==="get-config"){let i=o??f(r,"--card-id","chat-store get-config --store-ref <ref> --card-id <id>");p(c.getConfig({params:{cardId:i}}));return}if(n==="set-config"){let i=o??f(r,"--card-id","chat-store set-config --store-ref <ref> --card-id <id>"),e=w(r,"--system-prompt"),a={};if(e!==void 0&&(a.systemPrompt=e),!process.stdin.isTTY){let u=await V();if(u.trim())try{Object.assign(a,JSON.parse(u));}catch{}}p(c.setConfig({params:{cardId:i},body:a}));return}console.error(`chat-store: unknown command "${n}"
6
6
  ${A}`),process.exit(1);}function bt(t){let{storeRef:n,commands:r,...s}=t;return s}function vt(t){let{storeRef:n,commands:r,cardId:s}=t;return {cardId:typeof s=="string"?s:void 0,commands:Array.isArray(r)?r.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return o;let{storeRef:c,commands:i,...e}=o;return e}):[]}}function p(t){t.status!=="success"&&(console.error(`chat-store: ${t.status}: ${t.error}`),process.exit(1)),t.data!==void 0&&process.stdout.write(JSON.stringify(t.data,null,2)+`
7
7
  `);}var xt=process.argv[1]&&v(process.argv[1])===v(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));xt&&wt(process.argv.slice(2)).catch(t=>{console.error("chat-store:",t instanceof Error?t.message:String(t)),process.exit(1);});export{wt as cli};//# sourceMappingURL=chat-store-cli.js.map
8
8
  //# sourceMappingURL=chat-store-cli.js.map
@@ -1,7 +1,7 @@
1
1
  import { B as BlobStorage, K as KindValueRef } from '../execution-interface-DCFBy4L8.js';
2
2
  export { E as ExecutionRef, e as executionRefFromScriptPath, p as parseExecutionRef, f as parseRef, s as serializeExecutionRef, g as serializeRef } from '../execution-interface-DCFBy4L8.js';
3
- import { a as CommandInput, b as CommandResult, C as ChatStorage, c as BoardNonCorePlatformAdapter, B as BoardPlatformAdapter, I as InvocationAdapter } from '../types-BkJvnXVD.js';
4
- export { d as BoardLiveCardsNonCorePublic, e as BoardLiveCardsPublic, f as ChatConfig, g as ChatRecord, D as DescribeEnvelope, h as createBoardLiveCardsNonCorePublic, i as createBoardLiveCardsPublic, j as createChatStorage, k as createInMemoryChatStorage } from '../types-BkJvnXVD.js';
3
+ import { a as CommandInput, b as CommandResult, C as ChatStorage, c as BoardNonCorePlatformAdapter, B as BoardPlatformAdapter, I as InvocationAdapter } from '../types-BbQ75HLf.js';
4
+ export { d as BoardLiveCardsNonCorePublic, e as BoardLiveCardsPublic, f as ChatConfig, g as ChatRecord, D as DescribeEnvelope, h as createBoardLiveCardsNonCorePublic, i as createBoardLiveCardsPublic, j as createChatStorage, k as createInMemoryChatStorage } from '../types-BbQ75HLf.js';
5
5
  import { C as CardAdminStore, L as LiveCard } from '../board-live-cards-lib-COi4bSpk.js';
6
6
  export { a as BOARD_GRAPH_KEY, E as EMPTY_CONFIG, S as SNAPSHOT_SCHEMA_VERSION_V1, c as createCardStore } from '../board-live-cards-lib-COi4bSpk.js';
7
7
  export { CreateExecutionRefInvokerOptions, ExecutionRefInvoker, InvokeExecutionRefOptions, InvokeRefResult, SyncTransportInvoker, TransportInvoker, buildLocalBaseSpec, createExecutionRefInvoker, evaluateArgsMassaging, invokeExecutionRef, invokeExecutionRefSync, invokeRefSync, resolveWhatToRunValue, resolveYamlFlowCliPath } from './execution-adapter.js';