yaml-flow 8.2.4 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) 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 +4 -4
  4. package/browser/live-cards.js +19 -19
  5. package/cli/{board-live-cards-lib-Iq_XAC09.d.ts → board-live-cards-lib-tjYsPt5U.d.ts} +1 -1
  6. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +3 -3
  7. package/cli/browser-api/card-store-browser-api.d.ts +1 -1
  8. package/cli/browser-api/card-store-browser-api.js +1 -1
  9. package/cli/{execution-interface-ftO1W7Po.d.ts → execution-interface-CrG5gzAx.d.ts} +116 -2
  10. package/cli/node/batch-runner-cli.d.ts +3 -0
  11. package/cli/node/batch-runner-cli.js +2 -1
  12. package/cli/node/board-live-cards-cli.js +7 -7
  13. package/cli/node/card-store-cli.js +5 -5
  14. package/cli/node/chat-store-cli.d.ts +23 -0
  15. package/cli/node/chat-store-cli.js +8 -0
  16. package/cli/node/execution-adapter.d.ts +4 -2
  17. package/cli/node/execution-adapter.js +2 -2
  18. package/cli/node/fs-board-adapter.d.ts +7 -6
  19. package/cli/node/fs-board-adapter.js +8 -8
  20. package/cli/node/source-cli-task-executor.js +4 -4
  21. package/cli/node/step-machine-cli.js +3 -3
  22. package/cli/{types--rXGWbSR.d.ts → types-PUfPBxc_.d.ts} +4 -109
  23. package/examples/board/demo-shell-with-server.html +3 -3
  24. package/examples/board/doc.html +465 -0
  25. package/examples/board/server/board-server.js +20 -81
  26. package/examples/board/server/board-worker/source_def_flows.json +2 -2
  27. package/examples/board/server/chat-flow/copilot-chat/assistant.js +44 -185
  28. package/examples/board/server/chat-flow/copilot-chat/copilot_wrapper.bat +157 -0
  29. package/examples/board/server/chat-flow/copilot-chat/copilot_wrapper_helper.ps1 +190 -0
  30. package/examples/board/server/chat-flow/flow-steps.json +122 -56
  31. package/examples/board/test/server-http-test.js +252 -220
  32. package/examples/board-local/demo-shell-localstorage.html +3 -3
  33. package/lib/{artifacts-store-lib-public-C5UL5tyG.d.cts → artifacts-store-lib-public-Cz8-kdXG.d.cts} +1 -1
  34. package/lib/{artifacts-store-lib-public-GD4H-fFp.d.ts → artifacts-store-lib-public-ksGIExhc.d.ts} +1 -1
  35. package/lib/artifacts-store-public.d.cts +2 -2
  36. package/lib/artifacts-store-public.d.ts +2 -2
  37. package/lib/board-live-cards-node.cjs +8 -8
  38. package/lib/board-live-cards-node.d.cts +26 -6
  39. package/lib/board-live-cards-node.d.ts +26 -6
  40. package/lib/board-live-cards-node.js +8 -8
  41. package/lib/{board-live-cards-public-BLXbcBNk.d.cts → board-live-cards-public-BwZYGAsF.d.cts} +1 -1
  42. package/lib/{board-live-cards-public-BZaNb2mi.d.ts → board-live-cards-public-DWpZVDXN.d.ts} +1 -1
  43. package/lib/board-live-cards-public.cjs +2 -2
  44. package/lib/board-live-cards-public.d.cts +1 -1
  45. package/lib/board-live-cards-public.d.ts +1 -1
  46. package/lib/board-live-cards-public.js +2 -2
  47. package/lib/board-live-cards-server-runtime.cjs +3 -3
  48. package/lib/board-live-cards-server-runtime.d.cts +3 -2
  49. package/lib/board-live-cards-server-runtime.d.ts +3 -2
  50. package/lib/board-live-cards-server-runtime.js +3 -3
  51. package/lib/board-worker-adapter.cjs +2 -2
  52. package/lib/board-worker-adapter.js +2 -2
  53. package/lib/card-store-public.d.cts +1 -1
  54. package/lib/card-store-public.d.ts +1 -1
  55. package/lib/chat-storage-lib-BK5Njslc.d.ts +53 -0
  56. package/lib/chat-storage-lib-C5bQ7bGe.d.cts +53 -0
  57. package/lib/chat-store-public.cjs +2 -0
  58. package/lib/chat-store-public.d.cts +128 -0
  59. package/lib/chat-store-public.d.ts +128 -0
  60. package/lib/chat-store-public.js +2 -0
  61. package/lib/execution-refs.d.cts +10 -1
  62. package/lib/execution-refs.d.ts +10 -1
  63. package/lib/server-runtime/index.cjs +3 -3
  64. package/lib/server-runtime/index.d.cts +4 -3
  65. package/lib/server-runtime/index.d.ts +4 -3
  66. package/lib/server-runtime/index.js +3 -3
  67. package/lib/{types-Bztd1KoK.d.cts → types-D9B0Vrwg.d.cts} +4 -53
  68. package/lib/{types-D-xVWPdY.d.ts → types-DNYhCFNJ.d.ts} +4 -53
  69. package/package.json +8 -2
  70. package/examples/board/.board-ws/cards/store/_index.json +0 -17
  71. package/examples/board/.board-ws/cards/store/card-market-prices.json +0 -80
  72. package/examples/board/.board-ws/cards/store/card-portfolio-value.json +0 -90
  73. package/examples/board/.board-ws/cards/store/card-portfolio.json +0 -78
  74. package/examples/board/server/chat-flow/chat-clear-processing.js +0 -41
  75. package/examples/board/server/chat-flow/chat-open-turn.js +0 -144
  76. package/examples/board/server/chat-flow/chat-write-assistant.js +0 -44
  77. package/examples/board/server/chat-flow/echo-probe/assistant.js +0 -28
@@ -1,8 +1,8 @@
1
- import*as d from'fs';import {createRequire}from'module';import'ajv-formats';import*as g from'path';import {createHash,randomUUID}from'crypto';import'proper-lockfile';import*as O from'os';import'net';import'url';import'child_process';var S="b64:";function N(r){let n=r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4),e=globalThis.Buffer;if(e)return e.from(n,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(n),t=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)t[s]=o.charCodeAt(s);return new TextDecoder().decode(t)}throw new Error("No base64 decoder available in this runtime")}function R(r){if(!r.startsWith(S))throw new Error(`Invalid ref format (expected ${S}<base64url(json)>): ${r}`);let n;try{n=JSON.parse(N(r.slice(S.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 e=n;if(typeof e.kind!="string"||typeof e.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${r}`);return {kind:e.kind,value:e.value}}var D=createRequire(import.meta.url);D("./jsonata-sync.cjs");var K=createRequire(import.meta.url);K("./jsonata-sync.cjs");function E(r,n){function e(){return r.readIndex()??{}}function o(t,s,a){let i=String(s||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...t},c=u;for(let l=0;l<i.length-1;l++){let f=i[l],p=c[f],b=p&&typeof p=="object"&&!Array.isArray(p)?{...p}:{};c[f]=b,c=b;}return c[i[i.length-1]]=a,u}return {readCard(t){let s=e()[t];return !s||!r.cardExists(s.key)?null:r.readCard(s.key)},readCardKey(t){return e()[t]?.key??null},readAllCards(){let t=[];for(let[s,a]of Object.entries(e())){if(!r.cardExists(a.key))continue;let i=r.readCard(a.key);i?t.push(i):n?.(`[card-store] could not read card "${s}" at key "${a.key}"`);}return t},readChecksumIndex(){let t={};for(let[s,a]of Object.entries(e()))t[s]=a.checksum;return t},changedSince(t){let s=e(),a=[];for(let[i,u]of Object.entries(s))t[i]!==u.checksum&&a.push(i);for(let i of Object.keys(t))s[i]||a.push(i);return a},validateUpsert(t,s){let a=e(),i=a[t],u=Object.entries(a).find(([,c])=>c.key===s);return i&&i.key!==s?{ok:false,error:`Card id "${t}" is already mapped to key "${i.key}", cannot remap to "${s}"`}:u&&u[0]!==t?{ok:false,error:`Key "${s}" is already mapped to card id "${u[0]}", cannot remap to "${t}"`}:{ok:true}},writeCard(t,s,a){let i=e(),u=a??i[t]?.key??r.defaultCardKey(t),c=r.writeCard(u,s);i[t]={key:u,checksum:c,updatedAt:new Date().toISOString()},r.writeIndex(i);},patchCard(t,s,a){let i=e(),u=i[t];if(!u||!r.cardExists(u.key))throw new Error(`card "${t}" not found`);let c=r.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${t}" is not patchable`);let l=o(c,s,a),f=r.writeCard(u.key,l);i[t]={key:u.key,checksum:f,updatedAt:new Date().toISOString()},r.writeIndex(i);},removeCard(t){let s=e();s[t]&&(delete s[t],r.writeIndex(s));},readIndex(){return e()}}}function A(r){function n(t){return {status:"success",data:t}}function e(t){return {status:"fail",error:t}}function o(t){return {status:"error",error:t instanceof Error?t.message:String(t)}}return {get(t){try{let s=t.params?.id;if(s){let a=r.readCard(s);return a?n({cards:[a]}):e(`card "${s}" not found`)}return n({cards:r.readAllCards()})}catch(s){return o(s)}},set(t){try{let s=t.body;if(s==null)return e("set requires a body (card object or array of cards)");let a=Array.isArray(s)?s:[s];for(let i of a){if(typeof i.id!="string")return e("each card must have a string `id` field");r.writeCard(i.id,i);}return n({count:a.length})}catch(s){return o(s)}},del(t){try{let s=t.body?.ids??[],a=t.params?.id,i=a?[...s,a]:s;if(i.length===0)return e("del requires body.ids (string[]) or params.id");for(let u of i)r.removeCard(u);return n({count:i.length})}catch(s){return o(s)}},patch(t){try{let s=t.params?.id,a=t.params?.path;if(!s)return e("patch requires params.id");if(!a)return e("patch requires params.path");let i=t.body,u=i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:t.body;return r.patchCard(s,a,u),n({count:1})}catch(s){return o(s)}}}}function M(r,n){if(process.platform!=="win32"){d.renameSync(r,n);return}let e=[10,20,40,80,160];for(let o=0;o<=e.length;o++)try{d.renameSync(r,n);return}catch(t){let s=t.code;if((s==="EPERM"||s==="EBUSY")&&o<e.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e[o]);continue}throw t}}function G(r){function n(o){return g.join(r,...o.split("/"))+".json"}function e(o,t,s,a){if(d.existsSync(o))for(let i of d.readdirSync(o,{withFileTypes:true})){let u=t?`${t}/${i.name}`:i.name;if(i.isDirectory()){e(g.join(o,i.name),u,s,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!s||c.startsWith(s))&&a.push(c);}}return {read(o){let t=n(o);if(!d.existsSync(t))return null;try{return JSON.parse(d.readFileSync(t,"utf-8"))}catch{return null}},write(o,t){let s=n(o),a=`${s}.${process.pid}.${randomUUID()}.tmp`;d.mkdirSync(g.dirname(s),{recursive:true}),d.writeFileSync(a,JSON.stringify(t,null,2),"utf-8"),M(a,s);},delete(o){let t=n(o);try{d.existsSync(t)&&d.unlinkSync(t);}catch{}},listKeys(o){let t=[];return e(r,"",o,t),t.sort()}}}function k(r){if(r==null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r))return `[${r.map(k).join(",")}]`;let n=r;return `{${Object.keys(n).sort().map(o=>`${JSON.stringify(o)}:${k(n[o])}`).join(",")}}`}function U(r){return createHash("sha256").update(k(r)).digest("hex")}function _(r,n){let e={...r};for(let[o,t]of Object.entries(n))t!==null&&typeof t=="object"&&!Array.isArray(t)&&e[o]!==null&&typeof e[o]=="object"&&!Array.isArray(e[o])?e[o]=_(e[o],t):e[o]=t;return e}function T(r,n,e){if(n.length===0)return r;let[o,...t]=n;if(t.length===0)return {...r,[o]:e};let s=r[o]!==null&&typeof r[o]=="object"&&!Array.isArray(r[o])?r[o]:{};return {...r,[o]:T(s,t,e)}}function H(r){let n=G(r);return {read:e=>n.read(e),get(e,o){let t=n.read(e);if(t===null)return null;let s=t;for(let a of o.split(".").filter(Boolean)){if(s===null||typeof s!="object"||Array.isArray(s))return null;s=s[a]??null;}return s??null},write:(e,o)=>n.write(e,o),delete:e=>n.delete(e),listKeys:e=>n.listKeys(e),shallowMerge(e,o){let t=n.read(e)??{};n.write(e,{...t,...o});},deepMerge(e,o){let t=n.read(e)??{};n.write(e,_(t,o));},patch(e,o,t){let s=n.read(e)??{},a=o.split(".").filter(Boolean);n.write(e,T(s,a,t));}}}function j(r){let n=H(r);return {readIndex(){return n.read("_index")},writeIndex(e){n.write("_index",e);},readCard(e){return n.read(e)},writeCard(e,o){return n.write(e,o),U(o)},cardExists(e){return n.read(e)!==null},defaultCardKey(e){return e}}}function x(...r){return g.resolve(...r)}g.join(O.tmpdir(),".board-live-cards-git-bash-cache.json");function w(r,n,e){let o=r.indexOf(n),t=o!==-1?r[o+1]:void 0;if(!t)throw new Error(`Missing ${n}
2
- Usage: ${e}`);return t}function h(r,n){let e=r.indexOf(n);return e!==-1?r[e+1]:void 0}function W(r,n){return r.includes(n)}async function I(){let r=[];for await(let n of process.stdin)r.push(Buffer.isBuffer(n)?n:Buffer.from(n));return Buffer.concat(r).toString("utf-8")}var F=["card-store \u2014 JSON/YAML read/write for a board card store",""," card-store get --store-ref <ref> [--id <card-id>] [--yaml]"," Print one card (--id) or all cards."," Default: JSON array. --yaml: YAML multi-doc.",""," card-store set --store-ref <ref> [--ref <jsonfile> | --ref-yaml <yamlfile>] [--yaml]"," Write cards into the store."," --ref <file> JSON file (array or single object)"," --ref-yaml <file> YAML multi-doc file"," --yaml treat stdin as YAML (default stdin format is JSON)"," Each card must contain a string `id` field.",""," card-store del --store-ref <ref> --id <card-id> [--id <card-id> ...]"," Delete one or more cards by ID.",""," card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"," Patch one card field by dot-path assignment."," If --value-json is omitted, stdin is parsed as JSON value."].join(`
3
- `);async function z(r){let n=r[0],e=r.slice(1);if(!n||n==="help"||n==="--help"||n==="-h"){console.error(F);return}let o=w(e,"--store-ref",`card-store ${n} --store-ref <b64-ref>`),t=R(o),s=A(E(j(t.value),i=>console.error(`[card-store] ${i}`))),a=W(e,"--yaml");if(n==="get"){let i=h(e,"--id"),u=s.get({params:i?{id:i}:{}});u.status!=="success"&&(console.error(`card-store get: ${u.error}`),process.exit(1));let c=u.data.cards;if(c.length===0)return;if(a){let{stringify:l}=await import('yaml');process.stdout.write(c.map(f=>`---
1
+ import*as d from'fs';import {createRequire}from'module';import'ajv-formats';import*as g from'path';import {createHash,randomUUID}from'crypto';import'proper-lockfile';import*as O from'os';import'net';import'url';import'child_process';var S="b64:";function N(r){let n=r.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-r.length%4)%4),e=globalThis.Buffer;if(e)return e.from(n,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(n),t=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)t[s]=o.charCodeAt(s);return new TextDecoder().decode(t)}throw new Error("No base64 decoder available in this runtime")}function b(r){if(!r.startsWith(S))throw new Error(`Invalid ref format (expected ${S}<base64url(json)>): ${r}`);let n;try{n=JSON.parse(N(r.slice(S.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 e=n;if(typeof e.kind!="string"||typeof e.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${r}`);return {kind:e.kind,value:e.value}}var D=createRequire(import.meta.url);D("./jsonata-sync.cjs");var K=createRequire(import.meta.url);K("./jsonata-sync.cjs");function E(r,n){function e(){return r.readIndex()??{}}function o(t,s,a){let i=String(s||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...t},c=u;for(let l=0;l<i.length-1;l++){let f=i[l],p=c[f],C=p&&typeof p=="object"&&!Array.isArray(p)?{...p}:{};c[f]=C,c=C;}return c[i[i.length-1]]=a,u}return {readCard(t){let s=e()[t];return !s||!r.cardExists(s.key)?null:r.readCard(s.key)},readCardKey(t){return e()[t]?.key??null},readAllCards(){let t=[];for(let[s,a]of Object.entries(e())){if(!r.cardExists(a.key))continue;let i=r.readCard(a.key);i?t.push(i):n?.(`[card-store] could not read card "${s}" at key "${a.key}"`);}return t},readChecksumIndex(){let t={};for(let[s,a]of Object.entries(e()))t[s]=a.checksum;return t},changedSince(t){let s=e(),a=[];for(let[i,u]of Object.entries(s))t[i]!==u.checksum&&a.push(i);for(let i of Object.keys(t))s[i]||a.push(i);return a},validateUpsert(t,s){let a=e(),i=a[t],u=Object.entries(a).find(([,c])=>c.key===s);return i&&i.key!==s?{ok:false,error:`Card id "${t}" is already mapped to key "${i.key}", cannot remap to "${s}"`}:u&&u[0]!==t?{ok:false,error:`Key "${s}" is already mapped to card id "${u[0]}", cannot remap to "${t}"`}:{ok:true}},writeCard(t,s,a){let i=e(),u=a??i[t]?.key??r.defaultCardKey(t),c=r.writeCard(u,s);i[t]={key:u,checksum:c,updatedAt:new Date().toISOString()},r.writeIndex(i);},patchCard(t,s,a){let i=e(),u=i[t];if(!u||!r.cardExists(u.key))throw new Error(`card "${t}" not found`);let c=r.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${t}" is not patchable`);let l=o(c,s,a),f=r.writeCard(u.key,l);i[t]={key:u.key,checksum:f,updatedAt:new Date().toISOString()},r.writeIndex(i);},removeCard(t){let s=e();s[t]&&(delete s[t],r.writeIndex(s));},readIndex(){return e()}}}function A(r){function n(t){return {status:"success",data:t}}function e(t){return {status:"fail",error:t}}function o(t){return {status:"error",error:t instanceof Error?t.message:String(t)}}return {get(t){try{let s=t.params?.id;if(s){let a=r.readCard(s);return a?n({cards:[a]}):e(`card "${s}" not found`)}return n({cards:r.readAllCards()})}catch(s){return o(s)}},set(t){try{let s=t.body;if(s==null)return e("set requires a body (card object or array of cards)");let a=Array.isArray(s)?s:[s];for(let i of a){if(typeof i.id!="string")return e("each card must have a string `id` field");r.writeCard(i.id,i);}return n({count:a.length})}catch(s){return o(s)}},del(t){try{let s=t.body?.ids??[],a=t.params?.id,i=a?[...s,a]:s;if(i.length===0)return e("del requires body.ids (string[]) or params.id");for(let u of i)r.removeCard(u);return n({count:i.length})}catch(s){return o(s)}},patch(t){try{let s=t.params?.id,a=t.params?.path;if(!s)return e("patch requires params.id");if(!a)return e("patch requires params.path");let i=t.body,u=i&&Object.prototype.hasOwnProperty.call(i,"value")?i.value:t.body;return r.patchCard(s,a,u),n({count:1})}catch(s){return o(s)}}}}function M(r,n){if(process.platform!=="win32"){d.renameSync(r,n);return}let e=[10,20,40,80,160];for(let o=0;o<=e.length;o++)try{d.renameSync(r,n);return}catch(t){let s=t.code;if((s==="EPERM"||s==="EBUSY")&&o<e.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e[o]);continue}throw t}}function G(r){function n(o){return g.join(r,...o.split("/"))+".json"}function e(o,t,s,a){if(d.existsSync(o))for(let i of d.readdirSync(o,{withFileTypes:true})){let u=t?`${t}/${i.name}`:i.name;if(i.isDirectory()){e(g.join(o,i.name),u,s,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!s||c.startsWith(s))&&a.push(c);}}return {read(o){let t=n(o);if(!d.existsSync(t))return null;try{return JSON.parse(d.readFileSync(t,"utf-8"))}catch{return null}},write(o,t){let s=n(o),a=`${s}.${process.pid}.${randomUUID()}.tmp`;d.mkdirSync(g.dirname(s),{recursive:true}),d.writeFileSync(a,JSON.stringify(t,null,2),"utf-8"),M(a,s);},delete(o){let t=n(o);try{d.existsSync(t)&&d.unlinkSync(t);}catch{}},listKeys(o){let t=[];return e(r,"",o,t),t.sort()}}}function k(r){if(r==null||typeof r!="object")return JSON.stringify(r);if(Array.isArray(r))return `[${r.map(k).join(",")}]`;let n=r;return `{${Object.keys(n).sort().map(o=>`${JSON.stringify(o)}:${k(n[o])}`).join(",")}}`}function U(r){return createHash("sha256").update(k(r)).digest("hex")}function T(r,n){let e={...r};for(let[o,t]of Object.entries(n))t!==null&&typeof t=="object"&&!Array.isArray(t)&&e[o]!==null&&typeof e[o]=="object"&&!Array.isArray(e[o])?e[o]=T(e[o],t):e[o]=t;return e}function _(r,n,e){if(n.length===0)return r;let[o,...t]=n;if(t.length===0)return {...r,[o]:e};let s=r[o]!==null&&typeof r[o]=="object"&&!Array.isArray(r[o])?r[o]:{};return {...r,[o]:_(s,t,e)}}function H(r){let n=G(r);return {read:e=>n.read(e),get(e,o){let t=n.read(e);if(t===null)return null;let s=t;for(let a of o.split(".").filter(Boolean)){if(s===null||typeof s!="object"||Array.isArray(s))return null;s=s[a]??null;}return s??null},write:(e,o)=>n.write(e,o),delete:e=>n.delete(e),listKeys:e=>n.listKeys(e),shallowMerge(e,o){let t=n.read(e)??{};n.write(e,{...t,...o});},deepMerge(e,o){let t=n.read(e)??{};n.write(e,T(t,o));},patch(e,o,t){let s=n.read(e)??{},a=o.split(".").filter(Boolean);n.write(e,_(s,a,t));}}}function j(r){let n=H(r);return {readIndex(){return n.read("_index")},writeIndex(e){n.write("_index",e);},readCard(e){return n.read(e)},writeCard(e,o){return n.write(e,o),U(o)},cardExists(e){return n.read(e)!==null},defaultCardKey(e){return e}}}function x(...r){return g.resolve(...r)}g.join(O.tmpdir(),".board-live-cards-git-bash-cache.json");function w(r,n,e){let o=r.indexOf(n),t=o!==-1?r[o+1]:void 0;if(!t)throw new Error(`Missing ${n}
2
+ Usage: ${e}`);return t}function h(r,n){let e=r.indexOf(n);return e!==-1?r[e+1]:void 0}function z(r,n){return r.includes(n)}async function I(){let r=[];for await(let n of process.stdin)r.push(Buffer.isBuffer(n)?n:Buffer.from(n));return Buffer.concat(r).toString("utf-8")}var q=["card-store \u2014 JSON/YAML read/write for a board card store",""," card-store get --store-ref <ref> [--id <card-id>] [--yaml]"," Print one card (--id) or all cards."," Default: JSON array. --yaml: YAML multi-doc.",""," card-store set --store-ref <ref> [--ref <jsonfile> | --ref-yaml <yamlfile>] [--yaml]"," Write cards into the store."," --ref <file> JSON file (array or single object)"," --ref-yaml <file> YAML multi-doc file"," --yaml treat stdin as YAML (default stdin format is JSON)"," Each card must contain a string `id` field.",""," card-store del --store-ref <ref> --id <card-id> [--id <card-id> ...]"," Delete one or more cards by ID.",""," card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"," Patch one card field by dot-path assignment."," If --value-json is omitted, stdin is parsed as JSON value."].join(`
3
+ `);async function W(r){let n=r[0],e=r.slice(1);if(!n||n==="help"||n==="--help"||n==="-h"){console.error(q);return}let o=w(e,"--store-ref",`card-store ${n} --store-ref <b64-ref>`),t=b(o),s=A(E(j(t.value),i=>console.error(`[card-store] ${i}`))),a=z(e,"--yaml");if(n==="get"){let i=h(e,"--id"),u=s.get({params:i?{id:i}:{}});u.status!=="success"&&(console.error(`card-store get: ${u.error}`),process.exit(1));let c=u.data.cards;if(c.length===0)return;if(a){let{stringify:l}=await import('yaml');process.stdout.write(c.map(f=>`---
4
4
  ${l(f)}`).join(""));}else process.stdout.write(JSON.stringify(c,null,2)+`
5
- `);return}if(n==="set"){let i=h(e,"--ref"),u=h(e,"--ref-yaml"),c;if(u){let{parseAllDocuments:f}=await import('yaml'),p=d.readFileSync(u,"utf-8");c=$(f(p));}else if(i)c=q(d.readFileSync(i,"utf-8"),i);else {let f=await I();if(f.trim()||(console.error("card-store set: no input (provide --ref, --ref-yaml, or pipe to stdin)"),process.exit(1)),a){let{parseAllDocuments:p}=await import('yaml');c=$(p(f));}else c=q(f,"stdin");}let l=s.set({body:c});l.status!=="success"&&(console.error(`card-store set: ${l.error}`),process.exit(1)),console.error(`card-store set: wrote ${l.data.count} card(s)`);return}if(n==="del"||n==="delete"){let i=[];for(let c=0;c<e.length;c++)e[c]==="--id"&&e[c+1]&&i.push(e[++c]);let u=s.del({body:{ids:i}});u.status!=="success"&&(console.error(`card-store del: ${u.error}`),process.exit(1)),console.error(`card-store del: removed ${u.data.count} card(s)`);return}if(n==="patch"){let i=w(e,"--id","card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"),u=w(e,"--path","card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"),c=h(e,"--value-json"),l;try{if(typeof c=="string")l=JSON.parse(c);else {let p=await I();p.trim()||(console.error("card-store patch: provide --value-json or JSON value via stdin"),process.exit(1)),l=JSON.parse(p);}}catch(p){console.error(`card-store patch: JSON parse error: ${p.message}`),process.exit(1);}let f=s.patch({params:{id:i,path:u},body:{value:l}});f.status!=="success"&&(console.error(`card-store patch: ${f.error}`),process.exit(1)),console.error("card-store patch: ok");return}console.error(`card-store: unknown command "${n}"
5
+ `);return}if(n==="set"){let i=h(e,"--ref"),u=h(e,"--ref-yaml"),c;if(u){let{parseAllDocuments:f}=await import('yaml'),p=d.readFileSync(u,"utf-8");c=$(f(p));}else if(i)c=F(d.readFileSync(i,"utf-8"),i);else {let f=await I();if(f.trim()||(console.error("card-store set: no input (provide --ref, --ref-yaml, or pipe to stdin)"),process.exit(1)),a){let{parseAllDocuments:p}=await import('yaml');c=$(p(f));}else c=F(f,"stdin");}let l=s.set({body:c});l.status!=="success"&&(console.error(`card-store set: ${l.error}`),process.exit(1)),console.error(`card-store set: wrote ${l.data.count} card(s)`);return}if(n==="del"||n==="delete"){let i=[];for(let c=0;c<e.length;c++)e[c]==="--id"&&e[c+1]&&i.push(e[++c]);let u=s.del({body:{ids:i}});u.status!=="success"&&(console.error(`card-store del: ${u.error}`),process.exit(1)),console.error(`card-store del: removed ${u.data.count} card(s)`);return}if(n==="patch"){let i=w(e,"--id","card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"),u=w(e,"--path","card-store patch --store-ref <ref> --id <card-id> --path <dot.path> [--value-json <json>]"),c=h(e,"--value-json"),l;try{if(typeof c=="string")l=JSON.parse(c);else {let p=await I();p.trim()||(console.error("card-store patch: provide --value-json or JSON value via stdin"),process.exit(1)),l=JSON.parse(p);}}catch(p){console.error(`card-store patch: JSON parse error: ${p.message}`),process.exit(1);}let f=s.patch({params:{id:i,path:u},body:{value:l}});f.status!=="success"&&(console.error(`card-store patch: ${f.error}`),process.exit(1)),console.error("card-store patch: ok");return}console.error(`card-store: unknown command "${n}"
6
6
 
7
- ${F}`),process.exit(1);}function $(r){return r.map((n,e)=>(n.errors.length>0&&(console.error(`card-store set: YAML parse error in document ${e+1}: ${n.errors[0]}`),process.exit(1)),n.toJS()))}function q(r,n){let e;try{e=JSON.parse(r);}catch(o){console.error(`card-store set: JSON parse error from ${n}: ${o.message}`),process.exit(1);}if(Array.isArray(e))return e;if(e&&typeof e=="object")return [e];console.error(`card-store set: JSON from ${n} must be an object or an array of objects`),process.exit(1);}var X=process.argv[1]&&x(process.argv[1])===x(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));X&&z(process.argv.slice(2)).catch(r=>{let n=r instanceof Error?r.message:String(r);console.error(n),process.exit(1);});export{z as cli};//# sourceMappingURL=card-store-cli.js.map
7
+ ${q}`),process.exit(1);}function $(r){return r.map((n,e)=>(n.errors.length>0&&(console.error(`card-store set: YAML parse error in document ${e+1}: ${n.errors[0]}`),process.exit(1)),n.toJS()))}function F(r,n){let e;try{e=JSON.parse(r);}catch(o){console.error(`card-store set: JSON parse error from ${n}: ${o.message}`),process.exit(1);}if(Array.isArray(e))return e;if(e&&typeof e=="object")return [e];console.error(`card-store set: JSON from ${n} must be an object or an array of objects`),process.exit(1);}var X=process.argv[1]&&x(process.argv[1])===x(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));X&&W(process.argv.slice(2)).catch(r=>{let n=r instanceof Error?r.message:String(r);console.error(n),process.exit(1);});export{W as cli};//# sourceMappingURL=card-store-cli.js.map
8
8
  //# sourceMappingURL=card-store-cli.js.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * chat-store-cli.ts — thin arg-parsing CLI for the chat store public API.
3
+ *
4
+ * All logic lives in chat-store-lib-public.ts.
5
+ * This file only: parses argv, reads JSON from stdin or flags, calls the public API, prints JSON.
6
+ *
7
+ * Usage (all commands read a JSON envelope from stdin unless flags override):
8
+ *
9
+ * chat-store append --board-dir <dir> --card-id <id> --role <role> --text <text> [--files-json <json>]
10
+ * chat-store read-all --board-dir <dir> --card-id <id>
11
+ * chat-store read-after --board-dir <dir> --card-id <id> [--cursor <cursor>]
12
+ * chat-store clear --board-dir <dir> --card-id <id>
13
+ * chat-store set-processing --board-dir <dir> --card-id <id> --active <true|false>
14
+ * chat-store is-processing --board-dir <dir> --card-id <id>
15
+ * chat-store get-config --board-dir <dir> --card-id <id>
16
+ * chat-store set-config --board-dir <dir> --card-id <id> [--system-prompt <text>]
17
+ *
18
+ * Alternative: pipe a JSON object with { boardDir, cardId, ... command fields } to stdin.
19
+ * The `command` field selects the operation when using stdin-only mode.
20
+ */
21
+ declare function cli(argv: string[]): Promise<void>;
22
+
23
+ export { cli };
@@ -0,0 +1,8 @@
1
+ import'child_process';import*as d from'fs';import {existsSync}from'fs';import*as O 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';function b(...e){return y.join(...e)}function w(...e){return y.resolve(...e)}y.join(O.tmpdir(),".board-live-cards-git-bash-cache.json");var $=dirname(fileURLToPath(import.meta.url)),Z=createRequire(import.meta.url);function Q(){let e=resolve($,"./jsonata-sync.cjs");return existsSync(e)?e:resolve($,"../../card-compute/jsonata-sync.cjs")}Z(Q());createRequire(import.meta.url);createRequire(import.meta.url);function ot(e,r){if(process.platform!=="win32"){d.renameSync(e,r);return}let n=[10,20,40,80,160];for(let a=0;a<=n.length;a++)try{d.renameSync(e,r);return}catch(s){let c=s.code;if((c==="EPERM"||c==="EBUSY")&&a<n.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,n[a]);continue}throw s}}function F(e){function r(a){return y.join(e,...a.split("/"))+".json"}function n(a,s,c,i){if(d.existsSync(a))for(let t of d.readdirSync(a,{withFileTypes:true})){let o=s?`${s}/${t.name}`:t.name;if(t.isDirectory()){n(y.join(a,t.name),o,c,i);continue}if(!t.isFile()||!t.name.endsWith(".json"))continue;let u=o.replace(/\.json$/,"");(!c||u.startsWith(c))&&i.push(u);}}return {read(a){let s=r(a);if(!d.existsSync(s))return null;try{return JSON.parse(d.readFileSync(s,"utf-8"))}catch{return null}},write(a,s){let c=r(a),i=`${c}.${process.pid}.${randomUUID()}.tmp`;d.mkdirSync(y.dirname(c),{recursive:true}),d.writeFileSync(i,JSON.stringify(s,null,2),"utf-8"),ot(i,c);},delete(a){let s=r(a);try{d.existsSync(s)&&d.unlinkSync(s);}catch{}},listKeys(a){let s=[];return n(e,"",a,s),s.sort()}}}function B(e){function r(){if(!d.existsSync(e))return [];let n=d.readFileSync(e,"utf-8").trim();return n?n.split(`
2
+ `).filter(Boolean).map(a=>JSON.parse(a)):[]}return {append(n){let a={id:randomUUID(),payload:n};return d.mkdirSync(y.dirname(e),{recursive:true}),d.appendFileSync(e,JSON.stringify(a)+`
3
+ `,"utf-8"),a},readAll(){return r()},readAfter(n){let a=r();if(!n)return {entries:a,newCursor:a.length>0?a[a.length-1].id:null};let s=a.findIndex(i=>i.id===n),c=s===-1?a:a.slice(s+1);return {entries:c,newCursor:c.length>0?c[c.length-1].id:n}},clear(){d.existsSync(e)&&d.truncateSync(e,0);}}}var at=createRequire(import.meta.url);at("./jsonata-sync.cjs");function D(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function q(e){let r=e.payload??{};return {id:e.id,role:typeof r.role=="string"?r.role:"system",text:typeof r.text=="string"?r.text:"",files:Array.isArray(r.files)?r.files:[],updated_at:typeof r.updated_at=="string"?r.updated_at:""}}function A(e,r){let n=s=>`chats/${D(s)}/processing`,a=s=>`chats/${D(s)}/config`;return {append(s,c,i,t=[]){return e(s).append({role:c,text:i,files:t,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(q)},readAfter(s,c){let i=e(s).readAfter(c);return {records:i.entries.map(q),cursor:i.newCursor}},clear(s){e(s).clear?.();},setProcessing(s,c){c?r.write(n(s),true):r.delete(n(s));},isProcessing(s){return r.read(n(s))===true},getConfig(s){return r.read(a(s))??{}},setConfig(s,c){let i=r.read(a(s))??{};r.write(a(s),{...i,...c});}}}var pt=createRequire(import.meta.url);pt("./jsonata-sync.cjs");function T(e){let r=F(b(e,".kv","chat"));return A(n=>{let a=String(n).replace(/[^a-zA-Z0-9_-]/g,"_");return B(b(e,"chats",`${a}.jsonl`))},r)}function I(e){function r(t){return {status:"success",data:t}}function n(t){return {status:"fail",error:t}}function a(t){return {status:"error",error:t instanceof Error?t.message:String(t)}}function s(t,o="command envelope"){let u=typeof t.cardId=="string"?t.cardId:void 0;if(!t.command)return n(`chat-store: ${o} missing "command"`);if(!u)return n(`chat-store: ${o} missing "cardId"`);if(t.command==="append")return i.append({params:{cardId:u},body:{role:t.role,text:t.text,files:t.files}});if(t.command==="read-all")return i.readAll({params:{cardId:u}});if(t.command==="read-after")return i.readAfter({params:{cardId:u},body:{cursor:t.cursor??null}});if(t.command==="clear")return i.clear({params:{cardId:u}});if(t.command==="set-processing")return i.setProcessing({params:{cardId:u},body:{active:t.active}});if(t.command==="is-processing")return i.isProcessing({params:{cardId:u}});if(t.command==="get-config")return i.getConfig({params:{cardId:u}});if(t.command==="set-config"){let{command:l,cardId:g,...m}=t;return i.setConfig({params:{cardId:u},body:m})}return n(`chat-store: unknown command "${String(t.command)}"`)}function c(t){if(!Array.isArray(t.commands)||t.commands.length===0)return n('chat-store: command envelope must include a non-empty "commands" array');let o=[];for(let u=0;u<t.commands.length;u+=1){let l=t.commands[u];if(!l||typeof l!="object"||Array.isArray(l))return n(`chat-store: command envelope entry ${u} must be an object`);let g={cardId:t.cardId,...l},m=s(g,`command envelope entry ${u}`);if(m.status!=="success")return m;o.push({index:u,command:String(g.command),data:m.data});}return r({results:o})}let i={append(t){try{let o=t.params?.cardId;if(!o)return n("append requires params.cardId");let u=t.body??{},l=typeof u.role=="string"?u.role:"",g=typeof u.text=="string"?u.text:"",m=Array.isArray(u.files)?u.files:[];if(!l)return n("append requires body.role");let H=e.append(o,l,g,m);return r({id:H})}catch(o){return a(o)}},readAll(t){try{let o=t.params?.cardId;return o?r({records:e.readAll(o)}):n("readAll requires params.cardId")}catch(o){return a(o)}},readAfter(t){try{let o=t.params?.cardId;if(!o)return n("readAfter requires params.cardId");let l=(t.body??{}).cursor??null;return r(e.readAfter(o,l))}catch(o){return a(o)}},clear(t){try{let o=t.params?.cardId;return o?(e.clear(o),r({ok:!0})):n("clear requires params.cardId")}catch(o){return a(o)}},setProcessing(t){try{let o=t.params?.cardId;if(!o)return n("setProcessing requires params.cardId");let u=t.body??{};return typeof u.active!="boolean"?n("setProcessing requires body.active (boolean)"):(e.setProcessing(o,u.active),r({ok:!0}))}catch(o){return a(o)}},isProcessing(t){try{let o=t.params?.cardId;return o?r({active:e.isProcessing(o)}):n("isProcessing requires params.cardId")}catch(o){return a(o)}},getConfig(t){try{let o=t.params?.cardId;return o?r({config:e.getConfig(o)}):n("getConfig requires params.cardId")}catch(o){return a(o)}},setConfig(t){try{let o=t.params?.cardId;if(!o)return n("setConfig requires params.cardId");let u=t.body??{};return e.setConfig(o,u),r({ok:!0})}catch(o){return a(o)}},run:s,runBatch:c};return i}function f(e,r,n){let a=e.indexOf(r),s=a!==-1?e[a+1]:void 0;if(!s)throw new Error(`Missing ${r}
4
+ Usage: ${n}`);return s}function R(e,r){let n=e.indexOf(r);return n!==-1?e[n+1]:void 0}async function K(){let e=[];for await(let r of process.stdin)e.push(Buffer.isBuffer(r)?r:Buffer.from(r));return Buffer.concat(e).toString("utf-8")}var _=["chat-store \u2014 chat history and state operations for a board card",""," chat-store append --board-dir <dir> --card-id <id> --role <role> --text <text> [--files-json <json>]"," Append a message. Prints { id } on success.",""," chat-store read-all --board-dir <dir> --card-id <id>"," Print all messages as a JSON array.",""," chat-store read-after --board-dir <dir> --card-id <id> [--cursor <cursor>]"," Print messages after cursor as { records, cursor }.",""," chat-store clear --board-dir <dir> --card-id <id>"," Remove all messages for the card.",""," chat-store set-processing --board-dir <dir> --card-id <id> --active <true|false>"," Set or clear the processing flag.",""," chat-store is-processing --board-dir <dir> --card-id <id>"," Print { active: true|false }.",""," chat-store get-config --board-dir <dir> --card-id <id>"," Print the chat config object.",""," chat-store set-config --board-dir <dir> --card-id <id> [--system-prompt <text>]"," Patch the chat config. Extra fields can be piped as JSON to stdin.",""," Alternatively, pipe a JSON object to stdin:",' { "command": "<cmd>", "boardDir": "<dir>", "cardId": "<id>", ... }'," Or pipe a command envelope with defaults plus sequential commands:",' { "boardDir": "<dir>", "cardId": "<id>", "commands": [{ "command": "append", ... }, { "command": "set-processing", ... }] }'].join(`
5
+ `);async function Ct(e){if(e.length===0||e[0]==="--stdin"){let i=await K();if(!i.trim()){console.error(_);return}let t;try{t=JSON.parse(i);}catch{console.error("chat-store: stdin is not valid JSON"),process.exit(1);}let o=t.boardDir;o||(console.error('chat-store: stdin envelope missing "boardDir"'),process.exit(1));let u=I(T(o));if(Array.isArray(t.commands)){let g=u.runBatch(bt(t));p(g);return}let l=u.run(Rt(t));p(l);return}let r=e[0],n=e.slice(1);if(!r||r==="help"||r==="--help"||r==="-h"){console.error(_);return}let a=f(n,"--board-dir",`chat-store ${r} --board-dir <dir> --card-id <id>`),s=R(n,"--card-id"),c=I(T(a));if(r==="append"){let i=f(n,"--role","chat-store append --board-dir <dir> --card-id <id> --role <role> --text <text>"),t=f(n,"--text","chat-store append --board-dir <dir> --card-id <id> --role <role> --text <text>"),o=R(n,"--files-json"),u=o?JSON.parse(o):[],l=s??f(n,"--card-id","chat-store append --board-dir <dir> --card-id <id> --role <role> --text <text>"),g=c.append({params:{cardId:l},body:{role:i,text:t,files:u}});p(g);return}if(r==="read-all"){let i=s??f(n,"--card-id","chat-store read-all --board-dir <dir> --card-id <id>"),t=c.readAll({params:{cardId:i}});p(t);return}if(r==="read-after"){let i=s??f(n,"--card-id","chat-store read-after --board-dir <dir> --card-id <id>"),t=R(n,"--cursor")??null,o=c.readAfter({params:{cardId:i},body:{cursor:t}});p(o);return}if(r==="clear"){let i=s??f(n,"--card-id","chat-store clear --board-dir <dir> --card-id <id>"),t=c.clear({params:{cardId:i}});p(t);return}if(r==="set-processing"){let i=s??f(n,"--card-id","chat-store set-processing --board-dir <dir> --card-id <id> --active <true|false>"),t=f(n,"--active","chat-store set-processing --board-dir <dir> --card-id <id> --active <true|false>");t!=="true"&&t!=="false"&&(console.error('chat-store set-processing: --active must be "true" or "false"'),process.exit(1));let o=c.setProcessing({params:{cardId:i},body:{active:t==="true"}});p(o);return}if(r==="is-processing"){let i=s??f(n,"--card-id","chat-store is-processing --board-dir <dir> --card-id <id>"),t=c.isProcessing({params:{cardId:i}});p(t);return}if(r==="get-config"){let i=s??f(n,"--card-id","chat-store get-config --board-dir <dir> --card-id <id>"),t=c.getConfig({params:{cardId:i}});p(t);return}if(r==="set-config"){let i=s??f(n,"--card-id","chat-store set-config --board-dir <dir> --card-id <id>"),t=R(n,"--system-prompt"),o={};if(t!==void 0&&(o.systemPrompt=t),!process.stdin.isTTY){let l=await K();if(l.trim())try{Object.assign(o,JSON.parse(l));}catch{}}let u=c.setConfig({params:{cardId:i},body:o});p(u);return}console.error(`chat-store: unknown command "${r}"
6
+ ${_}`),process.exit(1);}function Rt(e){let{boardDir:r,commands:n,...a}=e;return a}function bt(e){let{boardDir:r,commands:n,cardId:a}=e;return {cardId:typeof a=="string"?a:void 0,commands:Array.isArray(n)?n.map(s=>{if(!s||typeof s!="object"||Array.isArray(s))return s;let{boardDir:c,commands:i,...t}=s;return t}):[]}}function p(e){e.status!=="success"&&(console.error(`chat-store: ${e.status}: ${e.error}`),process.exit(1)),e.data!==void 0&&process.stdout.write(JSON.stringify(e.data,null,2)+`
7
+ `);}var wt=process.argv[1]&&w(process.argv[1])===w(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));wt&&Ct(process.argv.slice(2)).catch(e=>{console.error("chat-store:",e instanceof Error?e.message:String(e)),process.exit(1);});export{Ct as cli};//# sourceMappingURL=chat-store-cli.js.map
8
+ //# sourceMappingURL=chat-store-cli.js.map
@@ -1,4 +1,4 @@
1
- import { E as ExecutionRef, A as ArgsMassaging, a as ExecutionResult } from '../execution-interface-ftO1W7Po.js';
1
+ import { E as ExecutionRef, A as ArgsMassaging, K as KindValueRef, a as ExecutionResult } from '../execution-interface-CrG5gzAx.js';
2
2
 
3
3
  /**
4
4
  * cli/common/args-massaging — JSONata-based mapping from logical args to
@@ -100,6 +100,8 @@ interface ExecutionAdapterOptions {
100
100
  */
101
101
  cliDir: string;
102
102
  }
103
+ declare function resolveYamlFlowCliPath(cliFileName: string): string;
104
+ declare function resolveWhatToRunValue(whatToRun: string | KindValueRef): string;
103
105
  /**
104
106
  * Resolve an ExecutionRef to its base { command, baseArgs } for local transports.
105
107
  *
@@ -216,4 +218,4 @@ declare function localNodeExecutorRef(scriptPath: string): ExecutionRef;
216
218
  */
217
219
  declare function dispatchTaskExecutorDetached(ref: ExecutionRef, args: TaskExecutorArgs, cliDir: string): void;
218
220
 
219
- export { type BoardCliCallbackArgs, type CreateExecutionRefInvokerOptions, type ExecutionAdapter, type ExecutionAdapterOptions, type ExecutionRefInvoker, type InvokeExecutionRefOptions, type InvokeRefResult, type InvokeRefSyncOptions, type SyncTransportInvoker, type TaskExecutorArgs, type TransportInvoker, buildLocalBaseSpec, builtInBoardCliRef, builtInSourceCliExecutorRef, createExecutionAdapter, createExecutionRefInvoker, dispatchTaskExecutorDetached, evaluateArgsMassaging, invokeExecutionRef, invokeExecutionRefSync, invokeRefSync, localNodeExecutorRef };
221
+ export { type BoardCliCallbackArgs, type CreateExecutionRefInvokerOptions, type ExecutionAdapter, type ExecutionAdapterOptions, type ExecutionRefInvoker, type InvokeExecutionRefOptions, type InvokeRefResult, type InvokeRefSyncOptions, type SyncTransportInvoker, type TaskExecutorArgs, type TransportInvoker, buildLocalBaseSpec, builtInBoardCliRef, builtInSourceCliExecutorRef, createExecutionAdapter, createExecutionRefInvoker, dispatchTaskExecutorDetached, evaluateArgsMassaging, invokeExecutionRef, invokeExecutionRefSync, invokeRefSync, localNodeExecutorRef, resolveWhatToRunValue, resolveYamlFlowCliPath };
@@ -1,3 +1,3 @@
1
- import*as m from'fs';import {existsSync}from'fs';import*as g from'path';import {dirname,resolve}from'path';import {spawnSync,execFileSync,spawn,execFile}from'child_process';import {createRequire}from'module';import {fileURLToPath}from'url';import*as B from'os';import'net';import'crypto';var P=dirname(fileURLToPath(import.meta.url)),Z=createRequire(import.meta.url);function tt(){let t=resolve(P,"./jsonata-sync.cjs");return existsSync(t)?t:resolve(P,"../../card-compute/jsonata-sync.cjs")}var p=Z(tt());var k="b64:";function et(t){let n=new TextEncoder().encode(t),e=globalThis.Buffer,o;if(e)o=e.from(n).toString("base64");else if(typeof btoa=="function"){let r="";for(let s of n)r+=String.fromCharCode(s);o=btoa(r);}else throw new Error("No base64 encoder available in this runtime");return o.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function nt(t){let n=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),e=globalThis.Buffer;if(e)return e.from(n,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(n),r=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)r[s]=o.charCodeAt(s);return new TextDecoder().decode(r)}throw new Error("No base64 decoder available in this runtime")}function R(t){return `${k}${et(JSON.stringify(t))}`}function y(t){if(!t.startsWith(k))throw new Error(`Invalid ref format (expected ${k}<base64url(json)>): ${t}`);let n;try{n=JSON.parse(nt(t.slice(k.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 e=n;if(typeof e.kind!="string"||typeof e.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:e.kind,value:e.value}}function it(t){if(typeof t=="object"&&t!==null){let{command:e,args:o=[],...r}=t,s=O(e,o);return {...r,command:s.command,args:s.args}}let n=J(t);if(n.length===0)throw new Error(`Empty command spec: ${JSON.stringify(t)}`);return O(n[0],n.slice(1))}function O(t,n){return /^(node|node\.exe)$/i.test(t)?{command:process.execPath,args:n}:/\.m?js$/i.test(t)?{command:process.execPath,args:[t,...n]}:{command:t,args:n}}function J(t){let n=[],e="",o=null;for(let r of t.trim()){if(o){r===o?o=null:e+=r;continue}if(r==='"'||r==="'"){o=r;continue}if(/\s/.test(r)){e&&(n.push(e),e="");continue}e+=r;}if(o)throw new Error(`Unterminated quote in command: ${t}`);return e&&n.push(e),n}function b(t){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(t)}function S(t,n){let{command:e,args:o=[],cwd:r,env:s,timeoutMs:i}=t;return execFileSync(e,o,{shell:b(e),timeout:i,encoding:n?.encoding??"utf-8",cwd:r,windowsHide:true,env:s?{...process.env,...s}:void 0,input:n?.input})}function at(t,n){let{command:e,args:o=[],cwd:r,env:s,timeoutMs:i=3e4}=t;execFile(e,o,{shell:b(e),encoding:"utf8",windowsHide:true,timeout:i,maxBuffer:10*1024*1024,cwd:r,env:s?{...process.env,...s}:void 0},(a,d,c)=>n(a??null,d,c));}g.join(B.tmpdir(),".board-live-cards-git-bash-cache.json");function T(t){let{command:n,args:e=[]}=t;if(process.platform==="win32"){spawn(n,e,{detached:true,stdio:"ignore",windowsHide:true,shell:b(n)}).unref();return}spawn(n,e,{detached:true,stdio:"ignore"}).unref();}function A(t,n,e){let o=g.join(t,"board-live-cards-cli.js");if(m.existsSync(o))return {cmd:process.execPath,args:[o,n,...e]};let r=g.join(t,"board-live-cards-cli.ts"),s=g.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),i=g.join(t,"..","..","node_modules",".bin","tsx"),a=m.existsSync(s)?s:i;return m.existsSync(r)&&m.existsSync(a)?{cmd:process.execPath,args:[a,r,n,...e]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",r,n,...e]}}function M(){return {executeSync(t,n,e){return S({command:t,args:n,cwd:e?.cwd,timeoutMs:e?.timeout,env:e?.env},{encoding:e?.encoding,input:e?.input})},executeAsync(t,n,e){at({command:t,args:n},e);},resolveInvocation(t,n){let e=it({command:t,args:n});return {cmd:e.command,args:e.args??[]}},splitCommand:J,spawnDetached(t,n){T({command:t,args:n});}}}function j(t,n,e){if(!t||typeof t!="object")return {};let o={};if(Array.isArray(t.cmdTemplate)){let r=[];for(let s of t.cmdTemplate)try{r.push(String(p(s).evaluate(n)));}catch(i){let a=i instanceof Error?i.message:String(i);throw new Error(`[${e}] argsMassaging.cmdTemplate failed on "${s}": ${a}`)}o.cmdArgs=r;}if(typeof t.stdinTemplate=="string")try{o.stdin=p(t.stdinTemplate).evaluate(n);}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.stdinTemplate failed: ${s}`)}if(typeof t.urlTemplate=="string")try{o.url=String(p(t.urlTemplate).evaluate(n));}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.urlTemplate failed: ${s}`)}if(typeof t.headerTemplate=="string")try{let r=p(t.headerTemplate).evaluate(n);if(typeof r!="object"||r===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(r)}`);o.headers=r;}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.headerTemplate failed: ${s}`)}if(typeof t.bodyTemplate=="string")try{o.body=p(t.bodyTemplate).evaluate(n);}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.bodyTemplate failed: ${s}`)}return o}async function ct(t,n){return p(t).evaluate(n)}async function ut(t,n){let e=await ct(t,n);if(typeof e!="string")throw new Error(`argsMassaging expression did not produce a string: ${t} \u2192 ${JSON.stringify(e)}`);return e}function dt(t,n){let e=typeof t=="object"?t.value:y(t).value;switch(e){case "source-cli-task-executor":{let o=g.join(n,"source-cli-task-executor.js");if(m.existsSync(o))return {command:process.execPath,args:[o]};let r=g.join(n,"source-cli-task-executor.ts"),s=g.join(n,"..","..","node_modules","tsx","dist","cli.mjs"),i=g.join(n,"..","..","node_modules",".bin","tsx"),a=m.existsSync(s)?s:i;return m.existsSync(r)&&m.existsSync(a)?{command:process.execPath,args:[a,r]}:{command:process.execPath,args:[o]}}case "board-live-cards":{let{cmd:o,args:r}=A(n,"_",[]);return {command:o,args:r}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${e}". Supported: source-cli-task-executor, board-live-cards`)}}function E(t,n){if(t.howToRun==="built-in"){let{command:o,args:r}=dt(t.whatToRun,n);return {command:o,baseArgs:r}}let e=typeof t.whatToRun=="object"?t.whatToRun.value:y(t.whatToRun).value;switch(t.howToRun){case "local-node":return {command:process.execPath,baseArgs:[e]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[e]};case "local-process":return {command:e,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${t.howToRun}" is not a local transport`)}}function L(t,n){let e=[t.subcommand];return t.inRef&&e.push("--in-ref",t.inRef),t.outRef&&e.push("--out-ref",t.outRef),t.errRef&&e.push("--err-ref",t.errRef),n&&e.push("--extra",Buffer.from(JSON.stringify(n)).toString("base64")),e}function lt(t,n){return {subcommand:t.subcommand,...t.inRef?{inRef:t.inRef}:{},...t.outRef?{outRef:t.outRef}:{},...t.errRef?{errRef:t.errRef}:{},...n?{extra:n}:{}}}function ft(t,n){return E(t,n)}function _(t){let n=t.trim();if(!n)throw new Error("empty stdout");try{return JSON.parse(n)}catch{let e=n.split(/\r?\n/).filter(Boolean),o=e[e.length-1];return JSON.parse(o)}}function F(t){let n=t.whatToRun;return typeof n=="object"?n.value:y(n).value}function U(t,n){return {...n,whatToRun:F(t),...t.extra?{extra:t.extra}:{}}}function q(t,n,e="invokeExecutionRef"){return j(t,n,e)}function G(t){return t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.result=="string"&&t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t:{result:"success",data:t&&typeof t=="object"&&!Array.isArray(t)?t:{stdout:t}}}function x(t){return {result:"failure",data:{error:t}}}function h(t,n,e){let o=e?.label??"invokeExecutionRefSync",r=e?.cliDir??e?.cwd??process.cwd(),s;try{s=q(t.argsMassaging,U(t,n),o);}catch(u){let f=u instanceof Error?u.message:String(u);return x(f)}let i;try{i=ft(t,r);}catch(u){let f=u instanceof Error?u.message:String(u);return x(`[${o}] ref resolution failed: ${f}`)}let a=[...i.baseArgs,...s.cmdArgs??[]],d=JSON.stringify(s.stdin??n),c=M(),l;try{l=c.executeSync(i.command,a,{timeout:e?.timeoutMs??3e4,encoding:"utf-8",cwd:e?.cwd,input:d});}catch(u){let f=u,K=(f.stderr?String(f.stderr):"").trim(),V=typeof f.status=="number"?f.status:"unknown",$=K||f.message;return x(`[${o}] ref exited with status ${V}${$?`: ${$}`:""}`)}try{return G(_(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}async function H(t,n,e){let o=e?.label??"invokeExecutionRef",r;try{r=q(t.argsMassaging,U(t,n),o);}catch(c){let l=c instanceof Error?c.message:String(c);return x(l)}let s=F(t),i=r.headers?{"Content-Type":"application/json",...r.headers}:{"Content-Type":"application/json"},a=r.url??s,d;if(t.howToRun==="http:get"){let c=r.body&&typeof r.body=="object"&&!Array.isArray(r.body)?r.body:n,l=new URLSearchParams(Object.entries(c).filter(([,u])=>u!=null).map(([u,f])=>[u,String(f)]));l.size>0&&(a=`${a}${a.includes("?")?"&":"?"}${l.toString()}`);}else d=JSON.stringify(r.body??n);try{let c=await fetch(a,{method:t.howToRun==="http:get"?"GET":"POST",headers:i,body:d});if(!c.ok){let u=await c.text().catch(()=>"");return x(`[${o}] HTTP ${c.status}${u?`: ${u}`:""}`)}let l=await c.text();if(!l.trim())return {result:"success",data:{}};try{return G(_(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}catch(c){let l=c instanceof Error?c.message:String(c);return x(`[${o}] ${l}`)}}var gt={"local-node":async(t,n,e)=>h(t,n,e),"local-python":async(t,n,e)=>h(t,n,e),"local-process":async(t,n,e)=>h(t,n,e),"built-in":async(t,n,e)=>h(t,n,e),"http:post":H,"http:get":H},pt={"local-node":h,"local-python":h,"local-process":h,"built-in":h};async function mt(t,n,e){let o=e?.transports?.[t.howToRun]??gt[t.howToRun];return o?o(t,n,e):x(`[${e?.label??"invokeExecutionRef"}] unsupported howToRun: ${t.howToRun}`)}function D(t,n,e){let o=e?.syncTransports?.[t.howToRun]??pt[t.howToRun];return o?o(t,n,e):x(`[${e?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${t.howToRun}`)}function Lt(t){return {invoke(n,e){return mt(n,e,t)},invokeSync(n,e){return D(n,e,t)}}}function _t(t,n,e){return D(t,n,e)}function Ft(t){let{cliDir:n}=t;return {async invokeTaskExecutor(e,o){if(e.howToRun==="http:post"||e.howToRun==="http:get")return z(e,o);let{command:s,baseArgs:i}=E(e,n),a;if(e.argsMassaging?.cmdTemplate){let c={...o,whatToRun:e.whatToRun};a=await Promise.all(e.argsMassaging.cmdTemplate.map(u=>ut(u,c)));}else a=L(o,e.extra);let d=[...i,...a];try{return S({command:s,args:d}),{status:"success"}}catch(c){return {status:"error",error:c instanceof Error?c.message:String(c)}}},invokeBoardCliCallback(e,o){let r,s;if(e.howToRun==="built-in"){let a=A(n,o.command,o.argv),d=spawnSync(a.cmd,a.args,{encoding:"utf-8",windowsHide:true});return d.status!==0?{status:"error",error:`board CLI exited ${d.status}: ${d.stderr?.trim()}`}:{status:"success"}}({command:r,baseArgs:s}=E(e,n));let i=spawnSync(r,[...s,o.command,...o.argv],{encoding:"utf-8",windowsHide:true});return i.status!==0?{status:"error",error:`board CLI exited ${i.status}: ${i.stderr?.trim()}`}:{status:"success"}}}}async function z(t,n){let e={...n,whatToRun:t.whatToRun},o=j(t.argsMassaging,e,"_invokeTaskExecutorHttp"),r=o.url??(typeof t.whatToRun=="object"?t.whatToRun.value:y(t.whatToRun).value),s=o.body?o.body:lt(n,t.extra),i={"Content-Type":"application/json"},a=o.headers?{...i,...o.headers}:i,d=await fetch(r,{method:t.howToRun==="http:get"?"GET":"POST",headers:a,body:JSON.stringify(s)});if(!d.ok){let l=await d.text().catch(()=>"");return {status:"error",error:`HTTP ${d.status}: ${l}`}}let c=await d.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Ut(){return {meta:"task-executor",howToRun:"built-in",whatToRun:R({kind:"built-in",value:"source-cli-task-executor"})}}function qt(){return {meta:"board-live-cards",howToRun:"built-in",whatToRun:R({kind:"built-in",value:"board-live-cards"})}}function Gt(t){return {meta:"task-executor",howToRun:"local-node",whatToRun:R({kind:"fs-path",value:t})}}function Dt(t,n,e){if(t.howToRun==="http:post"||t.howToRun==="http:get"){z(t,n).catch(a=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${a.message}`);});return}let{command:r,baseArgs:s}=E(t,e),i=L(n,t.extra);T({command:r,args:[...s,...i]});}
2
- export{ft as buildLocalBaseSpec,qt as builtInBoardCliRef,Ut as builtInSourceCliExecutorRef,Ft as createExecutionAdapter,Lt as createExecutionRefInvoker,Dt as dispatchTaskExecutorDetached,q as evaluateArgsMassaging,mt as invokeExecutionRef,D as invokeExecutionRefSync,_t as invokeRefSync,Gt as localNodeExecutorRef};//# sourceMappingURL=execution-adapter.js.map
1
+ import*as w from'fs';import {existsSync}from'fs';import*as g from'path';import {dirname,resolve}from'path';import {createRequire}from'module';import {spawnSync,execFileSync,spawn,execFile}from'child_process';import {fileURLToPath}from'url';import*as J from'os';import'net';import'crypto';var I=dirname(fileURLToPath(import.meta.url)),Z=createRequire(import.meta.url);function tt(){let t=resolve(I,"./jsonata-sync.cjs");return existsSync(t)?t:resolve(I,"../../card-compute/jsonata-sync.cjs")}var m=Z(tt());var k="b64:";function et(t){let n=new TextEncoder().encode(t),e=globalThis.Buffer,o;if(e)o=e.from(n).toString("base64");else if(typeof btoa=="function"){let r="";for(let s of n)r+=String.fromCharCode(s);o=btoa(r);}else throw new Error("No base64 encoder available in this runtime");return o.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function nt(t){let n=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),e=globalThis.Buffer;if(e)return e.from(n,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(n),r=new Uint8Array(o.length);for(let s=0;s<o.length;s+=1)r[s]=o.charCodeAt(s);return new TextDecoder().decode(r)}throw new Error("No base64 decoder available in this runtime")}function v(t){return `${k}${et(JSON.stringify(t))}`}function C(t){if(!t.startsWith(k))throw new Error(`Invalid ref format (expected ${k}<base64url(json)>): ${t}`);let n;try{n=JSON.parse(nt(t.slice(k.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 e=n;if(typeof e.kind!="string"||typeof e.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:e.kind,value:e.value}}function it(t){if(typeof t=="object"&&t!==null){let{command:e,args:o=[],...r}=t,s=B(e,o);return {...r,command:s.command,args:s.args}}let n=M(t);if(n.length===0)throw new Error(`Empty command spec: ${JSON.stringify(t)}`);return B(n[0],n.slice(1))}function B(t,n){return /^(node|node\.exe)$/i.test(t)?{command:process.execPath,args:n}:/\.m?js$/i.test(t)?{command:process.execPath,args:[t,...n]}:{command:t,args:n}}function M(t){let n=[],e="",o=null;for(let r of t.trim()){if(o){r===o?o=null:e+=r;continue}if(r==='"'||r==="'"){o=r;continue}if(/\s/.test(r)){e&&(n.push(e),e="");continue}e+=r;}if(o)throw new Error(`Unterminated quote in command: ${t}`);return e&&n.push(e),n}function b(t){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(t)}function S(t,n){let{command:e,args:o=[],cwd:r,env:s,timeoutMs:i}=t;return execFileSync(e,o,{shell:b(e),timeout:i,encoding:n?.encoding??"utf-8",cwd:r,windowsHide:true,env:s?{...process.env,...s}:void 0,input:n?.input})}function at(t,n){let{command:e,args:o=[],cwd:r,env:s,timeoutMs:i=3e4}=t;execFile(e,o,{shell:b(e),encoding:"utf8",windowsHide:true,timeout:i,maxBuffer:10*1024*1024,cwd:r,env:s?{...process.env,...s}:void 0},(a,d,c)=>n(a??null,d,c));}g.join(J.tmpdir(),".board-live-cards-git-bash-cache.json");function T(t){let{command:n,args:e=[]}=t;if(process.platform==="win32"){spawn(n,e,{detached:true,stdio:"ignore",windowsHide:true,shell:b(n)}).unref();return}spawn(n,e,{detached:true,stdio:"ignore"}).unref();}function A(t,n,e){let o=g.join(t,"board-live-cards-cli.js");if(w.existsSync(o))return {cmd:process.execPath,args:[o,n,...e]};let r=g.join(t,"board-live-cards-cli.ts"),s=g.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),i=g.join(t,"..","..","node_modules",".bin","tsx"),a=w.existsSync(s)?s:i;return w.existsSync(r)&&w.existsSync(a)?{cmd:process.execPath,args:[a,r,n,...e]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",r,n,...e]}}function N(){return {executeSync(t,n,e){return S({command:t,args:n,cwd:e?.cwd,timeoutMs:e?.timeout,env:e?.env},{encoding:e?.encoding,input:e?.input})},executeAsync(t,n,e){at({command:t,args:n},e);},resolveInvocation(t,n){let e=it({command:t,args:n});return {cmd:e.command,args:e.args??[]}},splitCommand:M,spawnDetached(t,n){T({command:t,args:n});}}}function j(t,n,e){if(!t||typeof t!="object")return {};let o={};if(Array.isArray(t.cmdTemplate)){let r=[];for(let s of t.cmdTemplate)try{r.push(String(m(s).evaluate(n)));}catch(i){let a=i instanceof Error?i.message:String(i);throw new Error(`[${e}] argsMassaging.cmdTemplate failed on "${s}": ${a}`)}o.cmdArgs=r;}if(typeof t.stdinTemplate=="string")try{o.stdin=m(t.stdinTemplate).evaluate(n);}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.stdinTemplate failed: ${s}`)}if(typeof t.urlTemplate=="string")try{o.url=String(m(t.urlTemplate).evaluate(n));}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.urlTemplate failed: ${s}`)}if(typeof t.headerTemplate=="string")try{let r=m(t.headerTemplate).evaluate(n);if(typeof r!="object"||r===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(r)}`);o.headers=r;}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.headerTemplate failed: ${s}`)}if(typeof t.bodyTemplate=="string")try{o.body=m(t.bodyTemplate).evaluate(n);}catch(r){let s=r instanceof Error?r.message:String(r);throw new Error(`[${e}] argsMassaging.bodyTemplate failed: ${s}`)}return o}var ut=createRequire(import.meta.url);function dt(t){return typeof t=="object"?t:C(t)}function lt(t){let n=g.basename(String(t||"").trim());if(!n)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(t)}`);let e=g.dirname(ut.resolve("yaml-flow/package.json")),o=g.join(e,"cli","node",n);if(!w.existsSync(o))throw new Error(`resolveYamlFlowCliPath: could not find ${n} under ${g.join(e,"cli","node")}`);return o}function y(t){let n=dt(t);return n.kind==="yaml-flow-cli"?lt(n.value):n.value}async function ft(t,n){return m(t).evaluate(n)}async function gt(t,n){let e=await ft(t,n);if(typeof e!="string")throw new Error(`argsMassaging expression did not produce a string: ${t} \u2192 ${JSON.stringify(e)}`);return e}function pt(t,n){let e=y(t);switch(e){case "source-cli-task-executor":{let o=g.join(n,"source-cli-task-executor.js");if(w.existsSync(o))return {command:process.execPath,args:[o]};let r=g.join(n,"source-cli-task-executor.ts"),s=g.join(n,"..","..","node_modules","tsx","dist","cli.mjs"),i=g.join(n,"..","..","node_modules",".bin","tsx"),a=w.existsSync(s)?s:i;return w.existsSync(r)&&w.existsSync(a)?{command:process.execPath,args:[a,r]}:{command:process.execPath,args:[o]}}case "board-live-cards":{let{cmd:o,args:r}=A(n,"_",[]);return {command:o,args:r}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${e}". Supported: source-cli-task-executor, board-live-cards`)}}function E(t,n){if(t.howToRun==="built-in"){let{command:o,args:r}=pt(t.whatToRun,n);return {command:o,baseArgs:r}}let e=(typeof t.whatToRun=="object",y(t.whatToRun));switch(t.howToRun){case "local-node":return {command:process.execPath,baseArgs:[e]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[e]};case "local-process":return {command:e,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${t.howToRun}" is not a local transport`)}}function _(t,n){let e=[t.subcommand];return t.inRef&&e.push("--in-ref",t.inRef),t.outRef&&e.push("--out-ref",t.outRef),t.errRef&&e.push("--err-ref",t.errRef),n&&e.push("--extra",Buffer.from(JSON.stringify(n)).toString("base64")),e}function mt(t,n){return {subcommand:t.subcommand,...t.inRef?{inRef:t.inRef}:{},...t.outRef?{outRef:t.outRef}:{},...t.errRef?{errRef:t.errRef}:{},...n?{extra:n}:{}}}function ht(t,n){return E(t,n)}function F(t){let n=t.trim();if(!n)throw new Error("empty stdout");try{return JSON.parse(n)}catch{let e=n.split(/\r?\n/).filter(Boolean),o=e[e.length-1];return JSON.parse(o)}}function q(t,n){return {...n,whatToRun:y(t.whatToRun),...t.extra?{extra:t.extra}:{}}}function U(t,n,e="invokeExecutionRef"){return j(t,n,e)}function G(t){return t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.result=="string"&&t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t:{result:"success",data:t&&typeof t=="object"&&!Array.isArray(t)?t:{stdout:t}}}function R(t){return {result:"failure",data:{error:t}}}function x(t,n,e){let o=e?.label??"invokeExecutionRefSync",r=e?.cliDir??e?.cwd??process.cwd(),s;try{s=U(t.argsMassaging,q(t,n),o);}catch(u){let f=u instanceof Error?u.message:String(u);return R(f)}let i;try{i=ht(t,r);}catch(u){let f=u instanceof Error?u.message:String(u);return R(`[${o}] ref resolution failed: ${f}`)}let a=[...i.baseArgs,...s.cmdArgs??[]],d=JSON.stringify(s.stdin??n),c=N(),l;try{l=c.executeSync(i.command,a,{timeout:e?.timeoutMs??3e4,encoding:"utf-8",cwd:e?.cwd,input:d});}catch(u){let f=u,V=(f.stderr?String(f.stderr):"").trim(),z=typeof f.status=="number"?f.status:"unknown",$=V||f.message;return R(`[${o}] ref exited with status ${z}${$?`: ${$}`:""}`)}try{return G(F(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}async function L(t,n,e){let o=e?.label??"invokeExecutionRef",r;try{r=U(t.argsMassaging,q(t,n),o);}catch(c){let l=c instanceof Error?c.message:String(c);return R(l)}let s=y(t.whatToRun),i=r.headers?{"Content-Type":"application/json",...r.headers}:{"Content-Type":"application/json"},a=r.url??s,d;if(t.howToRun==="http:get"){let c=r.body&&typeof r.body=="object"&&!Array.isArray(r.body)?r.body:n,l=new URLSearchParams(Object.entries(c).filter(([,u])=>u!=null).map(([u,f])=>[u,String(f)]));l.size>0&&(a=`${a}${a.includes("?")?"&":"?"}${l.toString()}`);}else d=JSON.stringify(r.body??n);try{let c=await fetch(a,{method:t.howToRun==="http:get"?"GET":"POST",headers:i,body:d});if(!c.ok){let u=await c.text().catch(()=>"");return R(`[${o}] HTTP ${c.status}${u?`: ${u}`:""}`)}let l=await c.text();if(!l.trim())return {result:"success",data:{}};try{return G(F(l))}catch{return {result:"success",data:{stdout:l.trim()}}}}catch(c){let l=c instanceof Error?c.message:String(c);return R(`[${o}] ${l}`)}}var xt={"local-node":async(t,n,e)=>x(t,n,e),"local-python":async(t,n,e)=>x(t,n,e),"local-process":async(t,n,e)=>x(t,n,e),"built-in":async(t,n,e)=>x(t,n,e),"http:post":L,"http:get":L},Rt={"local-node":x,"local-python":x,"local-process":x,"built-in":x};async function yt(t,n,e){let o=e?.transports?.[t.howToRun]??xt[t.howToRun];return o?o(t,n,e):R(`[${e?.label??"invokeExecutionRef"}] unsupported howToRun: ${t.howToRun}`)}function K(t,n,e){let o=e?.syncTransports?.[t.howToRun]??Rt[t.howToRun];return o?o(t,n,e):R(`[${e?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${t.howToRun}`)}function Gt(t){return {invoke(n,e){return yt(n,e,t)},invokeSync(n,e){return K(n,e,t)}}}function Kt(t,n,e){return K(t,n,e)}function Dt(t){let{cliDir:n}=t;return {async invokeTaskExecutor(e,o){if(e.howToRun==="http:post"||e.howToRun==="http:get")return D(e,o);let{command:s,baseArgs:i}=E(e,n),a;if(e.argsMassaging?.cmdTemplate){let c={...o,whatToRun:y(e.whatToRun)};a=await Promise.all(e.argsMassaging.cmdTemplate.map(u=>gt(u,c)));}else a=_(o,e.extra);let d=[...i,...a];try{return S({command:s,args:d}),{status:"success"}}catch(c){return {status:"error",error:c instanceof Error?c.message:String(c)}}},invokeBoardCliCallback(e,o){let r,s;if(e.howToRun==="built-in"){let a=A(n,o.command,o.argv),d=spawnSync(a.cmd,a.args,{encoding:"utf-8",windowsHide:true});return d.status!==0?{status:"error",error:`board CLI exited ${d.status}: ${d.stderr?.trim()}`}:{status:"success"}}({command:r,baseArgs:s}=E(e,n));let i=spawnSync(r,[...s,o.command,...o.argv],{encoding:"utf-8",windowsHide:true});return i.status!==0?{status:"error",error:`board CLI exited ${i.status}: ${i.stderr?.trim()}`}:{status:"success"}}}}async function D(t,n){let e={...n,whatToRun:y(t.whatToRun)},o=j(t.argsMassaging,e,"_invokeTaskExecutorHttp"),r=o.url??y(t.whatToRun),s=o.body?o.body:mt(n,t.extra),i={"Content-Type":"application/json"},a=o.headers?{...i,...o.headers}:i,d=await fetch(r,{method:t.howToRun==="http:get"?"GET":"POST",headers:a,body:JSON.stringify(s)});if(!d.ok){let l=await d.text().catch(()=>"");return {status:"error",error:`HTTP ${d.status}: ${l}`}}let c=await d.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Vt(){return {meta:"task-executor",howToRun:"built-in",whatToRun:v({kind:"built-in",value:"source-cli-task-executor"})}}function zt(){return {meta:"board-live-cards",howToRun:"built-in",whatToRun:v({kind:"built-in",value:"board-live-cards"})}}function Wt(t){return {meta:"task-executor",howToRun:"local-node",whatToRun:v({kind:"fs-path",value:t})}}function Xt(t,n,e){if(t.howToRun==="http:post"||t.howToRun==="http:get"){D(t,n).catch(a=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${a.message}`);});return}let{command:r,baseArgs:s}=E(t,e),i=_(n,t.extra);T({command:r,args:[...s,...i]});}
2
+ export{ht as buildLocalBaseSpec,zt as builtInBoardCliRef,Vt as builtInSourceCliExecutorRef,Dt as createExecutionAdapter,Gt as createExecutionRefInvoker,Xt as dispatchTaskExecutorDetached,U as evaluateArgsMassaging,yt as invokeExecutionRef,K as invokeExecutionRefSync,Kt as invokeRefSync,Wt as localNodeExecutorRef,y as resolveWhatToRunValue,lt as resolveYamlFlowCliPath};//# sourceMappingURL=execution-adapter.js.map
3
3
  //# sourceMappingURL=execution-adapter.js.map
@@ -1,9 +1,10 @@
1
- import { a as CommandInput, b as CommandResult, c as BlobStorage, C as ChatStorage, K as KindValueRef, d as BoardNonCorePlatformAdapter, B as BoardPlatformAdapter, I as InvocationAdapter } from '../types--rXGWbSR.js';
2
- export { e as BoardLiveCardsNonCorePublic, f as BoardLiveCardsPublic, g as ChatConfig, h as ChatRecord, D as DescribeEnvelope, i as createBoardLiveCardsNonCorePublic, j as createBoardLiveCardsPublic, k as createChatStorage, l as createInMemoryChatStorage, p as parseRef, s as serializeRef } from '../types--rXGWbSR.js';
3
- export { E as ExecutionRef, e as executionRefFromScriptPath, p as parseExecutionRef, s as serializeExecutionRef } from '../execution-interface-ftO1W7Po.js';
4
- import { C as CardAdminStore, L as LiveCard } from '../board-live-cards-lib-Iq_XAC09.js';
5
- export { B as BOARD_GRAPH_KEY, E as EMPTY_CONFIG, S as SNAPSHOT_SCHEMA_VERSION_V1, c as createCardStore } from '../board-live-cards-lib-Iq_XAC09.js';
6
- export { CreateExecutionRefInvokerOptions, ExecutionRefInvoker, InvokeExecutionRefOptions, InvokeRefResult, SyncTransportInvoker, TransportInvoker, createExecutionRefInvoker, evaluateArgsMassaging, invokeExecutionRef, invokeExecutionRefSync, invokeRefSync } from './execution-adapter.js';
1
+ import { a as CommandInput, b as CommandResult, C as ChatStorage, c as BoardNonCorePlatformAdapter, B as BoardPlatformAdapter, I as InvocationAdapter } from '../types-PUfPBxc_.js';
2
+ 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-PUfPBxc_.js';
3
+ import { B as BlobStorage, K as KindValueRef } from '../execution-interface-CrG5gzAx.js';
4
+ export { E as ExecutionRef, e as executionRefFromScriptPath, p as parseExecutionRef, d as parseRef, s as serializeExecutionRef, f as serializeRef } from '../execution-interface-CrG5gzAx.js';
5
+ import { C as CardAdminStore, L as LiveCard } from '../board-live-cards-lib-tjYsPt5U.js';
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-tjYsPt5U.js';
7
+ export { CreateExecutionRefInvokerOptions, ExecutionRefInvoker, InvokeExecutionRefOptions, InvokeRefResult, SyncTransportInvoker, TransportInvoker, buildLocalBaseSpec, createExecutionRefInvoker, evaluateArgsMassaging, invokeExecutionRef, invokeExecutionRefSync, invokeRefSync, resolveWhatToRunValue, resolveYamlFlowCliPath } from './execution-adapter.js';
7
8
 
8
9
  /**
9
10
  * card-store-lib-public.ts