yaml-flow 8.3.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/asset-integrity.json +3 -3
- package/browser/board-livecards-localstorage.js +6 -4
- package/browser/live-cards.js +19 -25
- package/cli/browser-api/board-live-cards-browser-adapter.d.ts +2 -2
- package/cli/browser-api/board-live-cards-browser-adapter.js +3 -2
- package/cli/browser-api/card-store-browser-api.js +1 -1
- package/cli/{execution-interface-CrG5gzAx.d.ts → execution-interface-DCFBy4L8.d.ts} +36 -1
- package/cli/node/artifacts-store-cli.js +5 -5
- package/cli/node/batch-runner-cli.js +2 -2
- package/cli/node/board-live-cards-cli.js +15 -9
- package/cli/node/card-store-cli.js +6 -6
- package/cli/node/chat-store-cli.js +7 -7
- package/cli/node/execution-adapter.d.ts +1 -1
- package/cli/node/execution-adapter.js +2 -2
- package/cli/node/fs-board-adapter.d.ts +72 -73
- package/cli/node/fs-board-adapter.js +14 -10
- package/cli/node/step-machine-cli.js +3 -3
- package/cli/{types-PUfPBxc_.d.ts → types-Dc2VRMUw.d.ts} +24 -16
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board/server/board-server.js +10 -1
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/{artifacts-store-lib-public-ksGIExhc.d.ts → artifacts-store-lib-454TAuov.d.ts} +2 -32
- package/lib/{artifacts-store-lib-public-Cz8-kdXG.d.cts → artifacts-store-lib-zsGFbBV8.d.cts} +2 -32
- package/lib/artifacts-store-public.d.cts +34 -3
- package/lib/artifacts-store-public.d.ts +34 -3
- package/lib/board-live-cards-node.cjs +14 -10
- package/lib/board-live-cards-node.d.cts +24 -23
- package/lib/board-live-cards-node.d.ts +24 -23
- package/lib/board-live-cards-node.js +14 -10
- package/lib/{board-live-cards-public-BwZYGAsF.d.cts → board-live-cards-public-BM6jCEIa.d.cts} +24 -4
- package/lib/{board-live-cards-public-DWpZVDXN.d.ts → board-live-cards-public-Bz07XKRK.d.ts} +24 -4
- package/lib/board-live-cards-public.cjs +2 -2
- package/lib/board-live-cards-public.d.cts +2 -2
- package/lib/board-live-cards-public.d.ts +2 -2
- package/lib/board-live-cards-public.js +2 -2
- package/lib/board-live-cards-server-runtime.cjs +4 -4
- package/lib/board-live-cards-server-runtime.d.cts +5 -4
- package/lib/board-live-cards-server-runtime.d.ts +5 -4
- package/lib/board-live-cards-server-runtime.js +4 -4
- package/lib/card-store-public.d.cts +2 -2
- package/lib/card-store-public.d.ts +2 -2
- package/lib/{chat-storage-lib-BK5Njslc.d.ts → chat-storage-lib-DGaKrjVe.d.ts} +1 -1
- package/lib/{chat-storage-lib-C5bQ7bGe.d.cts → chat-storage-lib-OX0Q_Ttf.d.cts} +1 -1
- package/lib/chat-store-public.d.cts +3 -3
- package/lib/chat-store-public.d.ts +3 -3
- package/lib/execution-refs.cjs +1 -1
- package/lib/execution-refs.js +1 -1
- package/lib/index.d.cts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/server-runtime/index.cjs +4 -4
- package/lib/server-runtime/index.d.cts +6 -5
- package/lib/server-runtime/index.d.ts +6 -5
- package/lib/server-runtime/index.js +4 -4
- package/lib/step-machine-public/index.cjs +3 -3
- package/lib/step-machine-public/index.d.cts +1 -1
- package/lib/step-machine-public/index.d.ts +1 -1
- package/lib/step-machine-public/index.js +3 -3
- package/lib/{storage-interface-B6ecOulj.d.cts → storage-interface-B-7pDHwD.d.cts} +36 -1
- package/lib/{storage-interface-B6ecOulj.d.ts → storage-interface-B-7pDHwD.d.ts} +36 -1
- package/lib/stores/index.d.cts +1 -1
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/kv.d.cts +1 -1
- package/lib/stores/kv.d.ts +1 -1
- package/lib/{types-DNYhCFNJ.d.ts → types-Cn0b8G-i.d.ts} +15 -15
- package/lib/{types-D9B0Vrwg.d.cts → types-Dszjwfud.d.cts} +15 -15
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import*as m from'fs';import {existsSync}from'fs';import*as R from'path';import {dirname,resolve}from'path';import'ajv-formats';import {createRequire}from'module';import {fileURLToPath}from'url';import {spawn,execFile,execFileSync}from'child_process';import*as vt from'os';import'net';import {randomUUID}from'crypto';import'proper-lockfile';function q(e,t,n,r){let o=e.steps[n];if(!o)throw new Error(`Step "${n}" not found in flow configuration`);if(r.result==="failure"&&o.retry){let i=t.retryCounts[n]??0;if(i<o.retry.max_attempts)return {newState:{...t,retryCounts:{...t.retryCounts,[n]:i+1},updatedAt:Date.now()},nextStep:n,isTerminal:false,isCircuitBroken:false,shouldRetry:true}}let s=o.failure_transitions?.[r.result]??o.transitions[r.result];if(!s)throw new Error(`No transition defined for result "${r.result}" in step "${n}"`);let a=!!e.terminal_states[s];return {newState:{...t,currentStep:s,stepHistory:[...t.stepHistory,n],retryCounts:{...t.retryCounts,[n]:0},updatedAt:Date.now()},nextStep:s,isTerminal:a,isCircuitBroken:false,shouldRetry:false}}function U(e,t,n){let r=e.steps[n];if(!r?.circuit_breaker)return {broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[n]:(t.iterationCounts[n]??0)+1},updatedAt:Date.now()}};let o=t.iterationCounts[n]??0;return o>=r.circuit_breaker.max_iterations?{broken:true,redirectStep:r.circuit_breaker.on_open,newState:{...t,currentStep:r.circuit_breaker.on_open,updatedAt:Date.now()}}:{broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[n]:o+1},updatedAt:Date.now()}}}function V(e,t,n){let r=e.steps[t];if(!r)throw new Error(`Step "${t}" not found`);if(r.expects_data){let o={};for(let s of r.expects_data)o[s]=n[s];return o}return {...n}}function z(e,t){if(e===false||e===void 0)return {};if(typeof e=="string")return {[e]:t[e]};if(Array.isArray(e)){let n={};for(let r of e)n[r]=t[r];return n}return {}}function W(e,t){let n=Date.now();return {runId:t,flowId:e.id??"unnamed",currentStep:e.settings.start_step,status:"running",stepHistory:[],iterationCounts:{},retryCounts:{},startedAt:n,updatedAt:n}}var k=class{runs=new Map;data=new Map;async saveRunState(t,n){this.runs.set(t,{...n});}async loadRunState(t){let n=this.runs.get(t);return n?{...n}:null}async deleteRunState(t){this.runs.delete(t),this.data.delete(t);}async setData(t,n,r){this.data.has(t)||this.data.set(t,{});let o=this.data.get(t);o[n]=r;}async getData(t,n){return this.data.get(t)?.[n]}async getAllData(t){return {...this.data.get(t)??{}}}async clearData(t){this.data.delete(t);}async listRuns(){return Array.from(this.runs.keys())}clear(){this.runs.clear(),this.data.clear();}};function Mt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var I=class{flow;handlers;store;components;options;listeners=new Map;aborted=false;constructor(t,n,r={}){this.flow=t,this.handlers=new Map(Object.entries(n)),this.store=r.store??new k,this.components=r.components??{},this.options=r,r.signal&&r.signal.addEventListener("abort",()=>{this.aborted=true;}),this.validateFlow();}validateFlow(){let{settings:t,steps:n,terminal_states:r}=this.flow;if(!t?.start_step)throw new Error("Flow must have settings.start_step defined");if(!n||Object.keys(n).length===0)throw new Error("Flow must have at least one step defined");if(!r||Object.keys(r).length===0)throw new Error("Flow must have at least one terminal_state defined");if(!n[t.start_step]&&!r[t.start_step])throw new Error(`Start step "${t.start_step}" not found`);for(let[o,s]of Object.entries(n)){for(let[a,i]of Object.entries(s.transitions))if(!n[i]&&!r[i])throw new Error(`Step "${o}" transition "${a}" points to unknown step "${i}"`);if(s.failure_transitions){for(let[a,i]of Object.entries(s.failure_transitions))if(!n[i]&&!r[i])throw new Error(`Step "${o}" failure_transition "${a}" points to unknown step "${i}"`)}}}on(t,n){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n);}off(t,n){this.listeners.get(t)?.delete(n);}emit(t){let n=this.listeners.get(t.type);if(n)for(let r of n)try{r(t);}catch{}}sleep(t){return new Promise(n=>setTimeout(n,t))}async run(t){let n=Mt(),r=W(this.flow,n);if(await this.store.saveRunState(n,r),t)for(let[o,s]of Object.entries(t))await this.store.setData(n,o,s);this.emit({type:"flow:start",runId:n,timestamp:r.startedAt,data:{initialData:t??{}}});try{return await this.executeLoop(n,r)}catch(o){let s=o instanceof Error?o:new Error(String(o));return this.emit({type:"flow:error",runId:n,timestamp:Date.now(),data:{error:s.message}}),this.options.onError?.(s),r={...r,status:"failed",updatedAt:Date.now()},await this.store.saveRunState(n,r),{runId:n,status:"failed",data:await this.store.getAllData(n),finalStep:r.currentStep,stepHistory:r.stepHistory,durationMs:Date.now()-r.startedAt,error:s}}}async resume(t){let n=await this.store.loadRunState(t);if(!n)throw new Error(`No run found with ID: ${t}`);if(n.status==="completed"||n.status==="failed")throw new Error(`Cannot resume a ${n.status} run`);let r={...n,status:"running",pausedAt:void 0,updatedAt:Date.now()};return await this.store.saveRunState(t,r),this.emit({type:"flow:resumed",runId:t,timestamp:Date.now(),data:{currentStep:r.currentStep}}),this.executeLoop(t,r)}async pause(t){let n=await this.store.loadRunState(t);if(!n)throw new Error(`No run found with ID: ${t}`);let r={...n,status:"paused",pausedAt:Date.now(),updatedAt:Date.now()};await this.store.saveRunState(t,r),this.emit({type:"flow:paused",runId:t,timestamp:Date.now(),data:{currentStep:r.currentStep}});}async executeLoop(t,n){let r=this.flow.settings.max_total_steps??100,o=this.flow.settings.timeout_ms,s=n,a=0;for(;a<r;){if(this.aborted)return s={...s,status:"cancelled",updatedAt:Date.now()},await this.store.saveRunState(t,s),{runId:t,status:"cancelled",data:await this.store.getAllData(t),finalStep:s.currentStep,stepHistory:s.stepHistory,durationMs:Date.now()-s.startedAt};if(o&&Date.now()-s.startedAt>o)return s={...s,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,s),{runId:t,status:"timeout",intent:"timeout",data:await this.store.getAllData(t),finalStep:s.currentStep,stepHistory:s.stepHistory,durationMs:Date.now()-s.startedAt};let i=s.currentStep,u=this.flow.terminal_states[i];if(u){s={...s,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,s);let p=await this.store.getAllData(t),g={runId:t,status:"completed",intent:u.return_intent,data:z(u.return_artifacts,p),finalStep:i,stepHistory:s.stepHistory,durationMs:Date.now()-s.startedAt};return this.emit({type:"flow:complete",runId:t,timestamp:Date.now(),data:{...g}}),this.options.onComplete?.(g),g}let c=U(this.flow,s,i);if(c.broken){s=c.newState,await this.store.saveRunState(t,s),a++;continue}s=c.newState;let d=await this.store.getAllData(t),l=V(this.flow,i,d),f={runId:t,stepName:i,components:this.components,store:this.store,signal:this.options.signal,emit:(p,g)=>{this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{event:p,payload:g}});}};this.emit({type:"step:start",runId:t,timestamp:Date.now(),data:{step:i,input:l}});let h;try{let p=this.handlers.get(i);if(!p)throw new Error(`No handler registered for step "${i}"`);h=await p(l,f);}catch(p){let g=p instanceof Error?p:new Error(String(p));this.emit({type:"step:error",runId:t,timestamp:Date.now(),data:{step:i,error:g.message}}),h={result:"failure",data:{error:g.message}};}if(h.data)for(let[p,g]of Object.entries(h.data))await this.store.setData(t,p,g);this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{step:i,result:h.result}}),this.options.onStep?.(i,h);let w=q(this.flow,s,i,h);if(s=w.newState,w.shouldRetry){await this.store.saveRunState(t,s);let p=this.flow.steps[i];if(p.retry?.delay_ms){let g=s.retryCounts[i]??0,x=p.retry.backoff_multiplier?p.retry.delay_ms*Math.pow(p.retry.backoff_multiplier,g-1):p.retry.delay_ms;await this.sleep(x);}a++;continue}await this.store.saveRunState(t,s),this.emit({type:"transition",runId:t,timestamp:Date.now(),data:{from:i,to:s.currentStep,result:h.result}}),this.options.onTransition?.(i,s.currentStep),a++;}return s={...s,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,s),{runId:t,status:"max_iterations",intent:"max_iterations",data:await this.store.getAllData(t),finalStep:s.currentStep,stepHistory:s.stepHistory,durationMs:Date.now()-s.startedAt}}};function $(e,t,n){return new I(e,t,n)}async function G(e){return (await import('yaml')).parse(e)}async function Ot(e){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to load flow from ${e}: ${t.statusText}`);let n=t.headers.get("content-type")??"",r=await t.text();return n.includes("json")||e.endsWith(".json")?JSON.parse(r):G(r)}async function It(e){let n=await(await import('fs/promises')).readFile(e,"utf-8");return e.endsWith(".json")?JSON.parse(n):G(n)}function nt(e){let t=[];if(!e||typeof e!="object")return ["Flow must be an object"];let n=e;if(!n.settings||typeof n.settings!="object"?t.push('Flow must have a "settings" object'):typeof n.settings.start_step!="string"&&t.push("settings.start_step must be a string"),!n.steps||typeof n.steps!="object")t.push('Flow must have a "steps" object');else {let r=n.steps;for(let[o,s]of Object.entries(r)){if(!s||typeof s!="object"){t.push(`Step "${o}" must be an object`);continue}let a=s;(!a.transitions||typeof a.transitions!="object")&&t.push(`Step "${o}" must have a "transitions" object`),a.failure_transitions!==void 0&&typeof a.failure_transitions!="object"&&t.push(`Step "${o}" failure_transitions must be an object when provided`);}}if(!n.terminal_states||typeof n.terminal_states!="object")t.push('Flow must have a "terminal_states" object');else {let r=n.terminal_states;for(let[o,s]of Object.entries(r)){if(!s||typeof s!="object"){t.push(`Terminal state "${o}" must be an object`);continue}typeof s.return_intent!="string"&&t.push(`Terminal state "${o}" must have a "return_intent" string`);}}return t}async function H(e){let t;typeof e=="string"?e.startsWith("http://")||e.startsWith("https://")?t=await Ot(e):e.includes("{")?t=JSON.parse(e):t=await It(e):t=e;let n=nt(t);if(n.length>0)throw new Error(`Invalid step flow configuration:
|
|
1
|
+
import*as m from'fs';import {existsSync}from'fs';import*as x from'path';import {dirname,resolve}from'path';import'ajv-formats';import {createRequire}from'module';import {fileURLToPath}from'url';import {spawn,execFile,execFileSync}from'child_process';import*as vt from'os';import'net';import {randomUUID}from'crypto';import'proper-lockfile';function U(e,t,n,r){let s=e.steps[n];if(!s)throw new Error(`Step "${n}" not found in flow configuration`);if(r.result==="failure"&&s.retry){let i=t.retryCounts[n]??0;if(i<s.retry.max_attempts)return {newState:{...t,retryCounts:{...t.retryCounts,[n]:i+1},updatedAt:Date.now()},nextStep:n,isTerminal:false,isCircuitBroken:false,shouldRetry:true}}let o=s.failure_transitions?.[r.result]??s.transitions[r.result];if(!o)throw new Error(`No transition defined for result "${r.result}" in step "${n}"`);let a=!!e.terminal_states[o];return {newState:{...t,currentStep:o,stepHistory:[...t.stepHistory,n],retryCounts:{...t.retryCounts,[n]:0},updatedAt:Date.now()},nextStep:o,isTerminal:a,isCircuitBroken:false,shouldRetry:false}}function V(e,t,n){let r=e.steps[n];if(!r?.circuit_breaker)return {broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[n]:(t.iterationCounts[n]??0)+1},updatedAt:Date.now()}};let s=t.iterationCounts[n]??0;return s>=r.circuit_breaker.max_iterations?{broken:true,redirectStep:r.circuit_breaker.on_open,newState:{...t,currentStep:r.circuit_breaker.on_open,updatedAt:Date.now()}}:{broken:false,newState:{...t,iterationCounts:{...t.iterationCounts,[n]:s+1},updatedAt:Date.now()}}}function q(e,t,n){let r=e.steps[t];if(!r)throw new Error(`Step "${t}" not found`);if(r.expects_data){let s={};for(let o of r.expects_data)s[o]=n[o];return s}return {...n}}function z(e,t){if(e===false||e===void 0)return {};if(typeof e=="string")return {[e]:t[e]};if(Array.isArray(e)){let n={};for(let r of e)n[r]=t[r];return n}return {}}function W(e,t){let n=Date.now();return {runId:t,flowId:e.id??"unnamed",currentStep:e.settings.start_step,status:"running",stepHistory:[],iterationCounts:{},retryCounts:{},startedAt:n,updatedAt:n}}var k=class{runs=new Map;data=new Map;async saveRunState(t,n){this.runs.set(t,{...n});}async loadRunState(t){let n=this.runs.get(t);return n?{...n}:null}async deleteRunState(t){this.runs.delete(t),this.data.delete(t);}async setData(t,n,r){this.data.has(t)||this.data.set(t,{});let s=this.data.get(t);s[n]=r;}async getData(t,n){return this.data.get(t)?.[n]}async getAllData(t){return {...this.data.get(t)??{}}}async clearData(t){this.data.delete(t);}async listRuns(){return Array.from(this.runs.keys())}clear(){this.runs.clear(),this.data.clear();}};function Pt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}var O=class{flow;handlers;store;components;options;listeners=new Map;aborted=false;constructor(t,n,r={}){this.flow=t,this.handlers=new Map(Object.entries(n)),this.store=r.store??new k,this.components=r.components??{},this.options=r,r.signal&&r.signal.addEventListener("abort",()=>{this.aborted=true;}),this.validateFlow();}validateFlow(){let{settings:t,steps:n,terminal_states:r}=this.flow;if(!t?.start_step)throw new Error("Flow must have settings.start_step defined");if(!n||Object.keys(n).length===0)throw new Error("Flow must have at least one step defined");if(!r||Object.keys(r).length===0)throw new Error("Flow must have at least one terminal_state defined");if(!n[t.start_step]&&!r[t.start_step])throw new Error(`Start step "${t.start_step}" not found`);for(let[s,o]of Object.entries(n)){for(let[a,i]of Object.entries(o.transitions))if(!n[i]&&!r[i])throw new Error(`Step "${s}" transition "${a}" points to unknown step "${i}"`);if(o.failure_transitions){for(let[a,i]of Object.entries(o.failure_transitions))if(!n[i]&&!r[i])throw new Error(`Step "${s}" failure_transition "${a}" points to unknown step "${i}"`)}}}on(t,n){this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(n);}off(t,n){this.listeners.get(t)?.delete(n);}emit(t){let n=this.listeners.get(t.type);if(n)for(let r of n)try{r(t);}catch{}}sleep(t){return new Promise(n=>setTimeout(n,t))}async run(t){let n=Pt(),r=W(this.flow,n);if(await this.store.saveRunState(n,r),t)for(let[s,o]of Object.entries(t))await this.store.setData(n,s,o);this.emit({type:"flow:start",runId:n,timestamp:r.startedAt,data:{initialData:t??{}}});try{return await this.executeLoop(n,r)}catch(s){let o=s instanceof Error?s:new Error(String(s));return this.emit({type:"flow:error",runId:n,timestamp:Date.now(),data:{error:o.message}}),this.options.onError?.(o),r={...r,status:"failed",updatedAt:Date.now()},await this.store.saveRunState(n,r),{runId:n,status:"failed",data:await this.store.getAllData(n),finalStep:r.currentStep,stepHistory:r.stepHistory,durationMs:Date.now()-r.startedAt,error:o}}}async resume(t){let n=await this.store.loadRunState(t);if(!n)throw new Error(`No run found with ID: ${t}`);if(n.status==="completed"||n.status==="failed")throw new Error(`Cannot resume a ${n.status} run`);let r={...n,status:"running",pausedAt:void 0,updatedAt:Date.now()};return await this.store.saveRunState(t,r),this.emit({type:"flow:resumed",runId:t,timestamp:Date.now(),data:{currentStep:r.currentStep}}),this.executeLoop(t,r)}async pause(t){let n=await this.store.loadRunState(t);if(!n)throw new Error(`No run found with ID: ${t}`);let r={...n,status:"paused",pausedAt:Date.now(),updatedAt:Date.now()};await this.store.saveRunState(t,r),this.emit({type:"flow:paused",runId:t,timestamp:Date.now(),data:{currentStep:r.currentStep}});}async executeLoop(t,n){let r=this.flow.settings.max_total_steps??100,s=this.flow.settings.timeout_ms,o=n,a=0;for(;a<r;){if(this.aborted)return o={...o,status:"cancelled",updatedAt:Date.now()},await this.store.saveRunState(t,o),{runId:t,status:"cancelled",data:await this.store.getAllData(t),finalStep:o.currentStep,stepHistory:o.stepHistory,durationMs:Date.now()-o.startedAt};if(s&&Date.now()-o.startedAt>s)return o={...o,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,o),{runId:t,status:"timeout",intent:"timeout",data:await this.store.getAllData(t),finalStep:o.currentStep,stepHistory:o.stepHistory,durationMs:Date.now()-o.startedAt};let i=o.currentStep,u=this.flow.terminal_states[i];if(u){o={...o,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,o);let p=await this.store.getAllData(t),g={runId:t,status:"completed",intent:u.return_intent,data:z(u.return_artifacts,p),finalStep:i,stepHistory:o.stepHistory,durationMs:Date.now()-o.startedAt};return this.emit({type:"flow:complete",runId:t,timestamp:Date.now(),data:{...g}}),this.options.onComplete?.(g),g}let c=V(this.flow,o,i);if(c.broken){o=c.newState,await this.store.saveRunState(t,o),a++;continue}o=c.newState;let f=await this.store.getAllData(t),l=q(this.flow,i,f),d={runId:t,stepName:i,components:this.components,store:this.store,signal:this.options.signal,emit:(p,g)=>{this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{event:p,payload:g}});}};this.emit({type:"step:start",runId:t,timestamp:Date.now(),data:{step:i,input:l}});let h;try{let p=this.handlers.get(i);if(!p)throw new Error(`No handler registered for step "${i}"`);h=await p(l,d);}catch(p){let g=p instanceof Error?p:new Error(String(p));this.emit({type:"step:error",runId:t,timestamp:Date.now(),data:{step:i,error:g.message}}),h={result:"failure",data:{error:g.message}};}if(h.data)for(let[p,g]of Object.entries(h.data))await this.store.setData(t,p,g);this.emit({type:"step:complete",runId:t,timestamp:Date.now(),data:{step:i,result:h.result}}),this.options.onStep?.(i,h);let w=U(this.flow,o,i,h);if(o=w.newState,w.shouldRetry){await this.store.saveRunState(t,o);let p=this.flow.steps[i];if(p.retry?.delay_ms){let g=o.retryCounts[i]??0,R=p.retry.backoff_multiplier?p.retry.delay_ms*Math.pow(p.retry.backoff_multiplier,g-1):p.retry.delay_ms;await this.sleep(R);}a++;continue}await this.store.saveRunState(t,o),this.emit({type:"transition",runId:t,timestamp:Date.now(),data:{from:i,to:o.currentStep,result:h.result}}),this.options.onTransition?.(i,o.currentStep),a++;}return o={...o,status:"completed",updatedAt:Date.now()},await this.store.saveRunState(t,o),{runId:t,status:"max_iterations",intent:"max_iterations",data:await this.store.getAllData(t),finalStep:o.currentStep,stepHistory:o.stepHistory,durationMs:Date.now()-o.startedAt}}};function $(e,t,n){return new O(e,t,n)}async function G(e){return (await import('yaml')).parse(e)}async function _t(e){let t=await fetch(e);if(!t.ok)throw new Error(`Failed to load flow from ${e}: ${t.statusText}`);let n=t.headers.get("content-type")??"",r=await t.text();return n.includes("json")||e.endsWith(".json")?JSON.parse(r):G(r)}async function Ot(e){let n=await(await import('fs/promises')).readFile(e,"utf-8");return e.endsWith(".json")?JSON.parse(n):G(n)}function nt(e){let t=[];if(!e||typeof e!="object")return ["Flow must be an object"];let n=e;if(!n.settings||typeof n.settings!="object"?t.push('Flow must have a "settings" object'):typeof n.settings.start_step!="string"&&t.push("settings.start_step must be a string"),!n.steps||typeof n.steps!="object")t.push('Flow must have a "steps" object');else {let r=n.steps;for(let[s,o]of Object.entries(r)){if(!o||typeof o!="object"){t.push(`Step "${s}" must be an object`);continue}let a=o;(!a.transitions||typeof a.transitions!="object")&&t.push(`Step "${s}" must have a "transitions" object`),a.failure_transitions!==void 0&&typeof a.failure_transitions!="object"&&t.push(`Step "${s}" failure_transitions must be an object when provided`);}}if(!n.terminal_states||typeof n.terminal_states!="object")t.push('Flow must have a "terminal_states" object');else {let r=n.terminal_states;for(let[s,o]of Object.entries(r)){if(!o||typeof o!="object"){t.push(`Terminal state "${s}" must be an object`);continue}typeof o.return_intent!="string"&&t.push(`Terminal state "${s}" must have a "return_intent" string`);}}return t}async function I(e){let t;typeof e=="string"?e.startsWith("http://")||e.startsWith("https://")?t=await _t(e):e.includes("{")?t=JSON.parse(e):t=await Ot(e):t=e;let n=nt(t);if(n.length>0)throw new Error(`Invalid step flow configuration:
|
|
2
2
|
- ${n.join(`
|
|
3
|
-
- `)}`);return t}function Y(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rt(e){return atob(e.replace(/-/g,"+").replace(/_/g,"/"))}var C=class{constructor(t){this.kv=t;}kv;stateKey(t){return `state_${Y(t)}`}dataPrefix(t){return `data_${Y(t)}_`}dataKey(t,n){return `${this.dataPrefix(t)}${Y(n)}`}async saveRunState(t,n){this.kv.write(this.stateKey(t),n);}async loadRunState(t){let n=this.kv.read(this.stateKey(t));return n!=null&&typeof n=="object"?n:null}async deleteRunState(t){this.kv.delete(this.stateKey(t));for(let n of this.kv.listKeys(this.dataPrefix(t)))this.kv.delete(n);}async setData(t,n,r){this.kv.write(this.dataKey(t,n),r);}async getData(t,n){return this.kv.read(this.dataKey(t,n))}async getAllData(t){let n=this.dataPrefix(t),r={};for(let o of this.kv.listKeys(n))r[rt(o.slice(n.length))]=this.kv.read(o);return r}async clearData(t){for(let n of this.kv.listKeys(this.dataPrefix(t)))this.kv.delete(n);}async listRuns(){return this.kv.listKeys("state_").map(t=>rt(t.slice(6)))}};var st=dirname(fileURLToPath(import.meta.url)),Bt=createRequire(import.meta.url);function Nt(){let e=resolve(st,"./jsonata-sync.cjs");return existsSync(e)?e:resolve(st,"../card-compute/jsonata-sync.cjs")}var P=Bt(Nt());function it(e,t){if(!e||typeof e!="object")throw new Error(`[step-machine-public] Step "${t}" returned a non-object result.`);let n=e,r=n.result??n.status;if(typeof r=="string"&&r.trim().length>0){let o=n.data&&typeof n.data=="object"&&!Array.isArray(n.data)?{...n.data}:{},s=typeof n.error=="string"?n.error:void 0;return s&&!("error"in o)&&(o.error=s),{result:r,data:o,...s?{error:s}:{}}}return {result:"success",data:{...n}}}function at(e,t){if(!t||t.length===0)return e;let n={};for(let r of t)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function X(e,t){return async(n,r)=>{let o=await e(n,r),s=it(o,r?.stepName??"unknown");return {result:s.result,data:at(s.data,t),...s.error?{error:s.error}:{}}}}function ct(e,t,n){if(!t||t.length===0)return null;for(let r of t)try{if(!P(r).evaluate(e))return {result:"failure",data:{error:`[${n}] input validation failed: ${r}`}}}catch(o){let s=o instanceof Error?o.message:String(o);return {result:"failure",data:{error:`[${n}] input validation error on "${r}": ${s}`}}}return null}function Q(e,t,n){return !t||t.length===0?e:async(r,o)=>{let s=ct(r,t,n);return s||e(r,o)}}var lt=dirname(fileURLToPath(import.meta.url)),Vt=createRequire(import.meta.url);function zt(){let e=resolve(lt,"./jsonata-sync.cjs");return existsSync(e)?e:resolve(lt,"../../card-compute/jsonata-sync.cjs")}var v=Vt(zt());function pt(e,t,n){if(!e||typeof e!="object")return {};let r={};if(Array.isArray(e.cmdTemplate)){let o=[];for(let s of e.cmdTemplate)try{o.push(String(v(s).evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${n}] argsMassaging.cmdTemplate failed on "${s}": ${i}`)}r.cmdArgs=o;}if(typeof e.stdinTemplate=="string")try{r.stdin=v(e.stdinTemplate).evaluate(t);}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`[${n}] argsMassaging.stdinTemplate failed: ${s}`)}if(typeof e.urlTemplate=="string")try{r.url=String(v(e.urlTemplate).evaluate(t));}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`[${n}] argsMassaging.urlTemplate failed: ${s}`)}if(typeof e.headerTemplate=="string")try{let o=v(e.headerTemplate).evaluate(t);if(typeof o!="object"||o===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(o)}`);r.headers=o;}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`[${n}] argsMassaging.headerTemplate failed: ${s}`)}if(typeof e.bodyTemplate=="string")try{r.body=v(e.bodyTemplate).evaluate(t);}catch(o){let s=o instanceof Error?o.message:String(o);throw new Error(`[${n}] argsMassaging.bodyTemplate failed: ${s}`)}return r}function dt(e,t,n){if(!e||typeof e!="object")return t;let r={output:t},o=t.result,s=t.data,a=t.error;if(typeof e.resultExpr=="string")try{let i=v(e.resultExpr).evaluate(r);if(typeof i!="string"||!i.trim())throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(i)})`);o=i;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.resultExpr failed: ${u}`)}if(typeof e.dataTemplate=="string")try{let i=v(e.dataTemplate).evaluate(r);if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(i)})`);s=i;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.dataTemplate failed: ${u}`)}if(typeof e.errorExpr=="string")try{let i=v(e.errorExpr).evaluate(r);a=i!=null?String(i):void 0;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.errorExpr failed: ${u}`)}return a!==void 0?{result:o,data:s,error:a}:{result:o,data:s}}var _="b64:";function Wt(e){let t=new TextEncoder().encode(e),n=globalThis.Buffer,r;if(n)r=n.from(t).toString("base64");else if(typeof btoa=="function"){let o="";for(let s of t)o+=String.fromCharCode(s);r=btoa(o);}else throw new Error("No base64 encoder available in this runtime");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Gt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),n=globalThis.Buffer;if(n)return n.from(t,"base64").toString("utf8");if(typeof atob=="function"){let r=atob(t),o=new Uint8Array(r.length);for(let s=0;s<r.length;s+=1)o[s]=r.charCodeAt(s);return new TextDecoder().decode(o)}throw new Error("No base64 decoder available in this runtime")}function J(e){return `${_}${Wt(JSON.stringify(e))}`}function ft(e){if(!e.startsWith(_))throw new Error(`Invalid ref format (expected ${_}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Gt(e.slice(_.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let n=t;if(typeof n.kind!="string"||typeof n.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:n.kind,value:n.value}}function gt(e){return !!e&&typeof e=="object"&&e.type==="compute-jsonata"&&Array.isArray(e.expr)&&e.expr.length>0}function mt(e){if(!e||typeof e!="object")return false;let t=e;if(t.type!=="ref"||typeof t.howToRun!="string")return false;if(typeof t.whatToRun=="string")return true;if(t.whatToRun&&typeof t.whatToRun=="object"){let n=t.whatToRun;return typeof n.kind=="string"&&typeof n.value=="string"}return false}function Yt(e){if(typeof e=="string"){let t=e.indexOf("=");if(t<1)throw new Error(`[step-machine-public] Invalid compute expression (missing "="): "${e}"`);return {bindTo:e.slice(0,t).trim(),expr:e.slice(t+1).trim()}}if(e&&typeof e=="object"&&typeof e.bindTo=="string"&&typeof e.expr=="string")return e;throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(e)}`)}function Xt(e,t,n){let r=t.split("."),o=e;for(let s=0;s<r.length-1;s++){let a=r[s];(o[a]==null||typeof o[a]!="object")&&(o[a]={}),o=o[a];}o[r[r.length-1]]=n;}function ht(e,t,n){let r=e.expr.map(Yt);return async o=>{let s=o&&typeof o=="object"&&!Array.isArray(o)?{...o}:{},a={},i={expects_data:s,data:a,...n?{config:n}:{}},u,c;for(let d of r)try{let l=P(d.expr).evaluate(i);if(d.bindTo==="result")u=l!=null?String(l):"success";else if(d.bindTo==="error")c=l!=null?String(l):void 0;else if(d.bindTo.startsWith("data."))Xt(a,d.bindTo.slice(5),l);else return {result:"failure",data:{},error:`[${t}] invalid bindTo "${d.bindTo}": must be "result", "error", or start with "data."`}}catch(l){let f=l instanceof Error?l.message:String(l);return {result:"failure",data:{},error:`[${t}] compute "${d.bindTo}" failed: ${f}`}}return u===void 0?{result:"failure",data:{},error:`[${t}] compute-jsonata: no "result" binding declared \u2014 add '- result = "success"' to expr`}:c?{result:u,data:a,error:c}:{result:u,data:a}}}function yt(e,t,n,r){let{type:o,...s}=e,a={...s,whatToRun:typeof s.whatToRun=="object"?J(s.whatToRun):s.whatToRun};return async i=>{let u=i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{};r&&(u.config=r);try{let c=await n(a,u);if(!e.outputTransforms)return c;try{return dt(e.outputTransforms,c,t)}catch(d){let l=d instanceof Error?d.message:String(d);return {result:"failure",data:{},error:l}}}catch(c){let d=c instanceof Error?c.message:String(c);return {result:"failure",data:{error:`[step-machine-public] step "${t}" invoke threw: ${d}`}}}}}function wt(){return async e=>({result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{}})}function Qt(e,t,n){return async(r,o)=>{let s=r?.[t.items];if(!Array.isArray(s))return {result:"failure",data:{},error:`[${n}] forEach: "${t.items}" is not an array (got ${typeof s})`};let a=s,i=t.collectAs??`${t.items}_results`;if(a.length===0)return {result:"success",data:{[i]:[]}};let{[t.items]:u,...c}=r,d=Math.max(1,t.concurrency??1),l=new Array(a.length),f=0,h=0,w=0;return await new Promise(p=>{function g(){for(;f<d&&h<a.length;){let x=h++;f++;let M={...c,[t.as]:a[x]};e(M,o).then(S=>{l[x]=S;}).catch(S=>{let y=S instanceof Error?S.message:String(S);l[x]={result:"failure",data:{},error:y};}).finally(()=>{f--,l[x]?.result==="failure"&&w++,h>=a.length&&f===0?p():g();});}f===0&&h>=a.length&&p();}g();}),w>0?{result:"failure",data:{errors:l.filter(g=>g.result==="failure").map(g=>g.error)},error:`[${n}] forEach: ${w}/${a.length} items failed`}:{result:"success",data:{[i]:l.map(p=>p.data)}}}}function St(e,t,n){let r=Array.isArray(t?.produces_data)?t?.produces_data:void 0,o=Array.isArray(t?.input_validations)?t?.input_validations:void 0,s=t?.config??void 0,a=t?.handler,i;return gt(a)?i=ht(a,e,s):mt(a)?i=yt(a,e,n.invoke,s):i=wt(),t?.forEach&&(i=Qt(i,t.forEach,e)),Q(X(i,r),o,e)}function D(e,t){let n={};for(let[r,o]of Object.entries(e.steps??{}))n[r]=St(r,o,t);return n}function ne(e){if(typeof e=="object"&&e!==null){let{command:n,args:r=[],...o}=e,s=xt(n,r);return {...o,command:s.command,args:s.args}}let t=kt(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return xt(t[0],t.slice(1))}function xt(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function kt(e){let t=[],n="",r=null;for(let o of e.trim()){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n&&(t.push(n),n="");continue}n+=o;}if(r)throw new Error(`Unterminated quote in command: ${e}`);return n&&t.push(n),t}function Z(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function bt(e,t){let{command:n,args:r=[],cwd:o,env:s,timeoutMs:a}=e;return execFileSync(n,r,{shell:Z(n),timeout:a,encoding:t?.encoding??"utf-8",cwd:o,windowsHide:true,env:s?{...process.env,...s}:void 0,input:t?.input})}function re(e,t){let{command:n,args:r=[],cwd:o,env:s,timeoutMs:a=3e4}=e;execFile(n,r,{shell:Z(n),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:o,env:s?{...process.env,...s}:void 0},(i,u,c)=>t(i??null,u,c));}R.join(vt.tmpdir(),".board-live-cards-git-bash-cache.json");function Et(e){let{command:t,args:n=[]}=e;if(process.platform==="win32"){spawn(t,n,{detached:true,stdio:"ignore",windowsHide:true,shell:Z(t)}).unref();return}spawn(t,n,{detached:true,stdio:"ignore"}).unref();}function At(e,t,n){let r=R.join(e,"board-live-cards-cli.js");if(m.existsSync(r))return {cmd:process.execPath,args:[r,t,...n]};let o=R.join(e,"board-live-cards-cli.ts"),s=R.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=R.join(e,"..","..","node_modules",".bin","tsx"),i=m.existsSync(s)?s:a;return m.existsSync(o)&&m.existsSync(i)?{cmd:process.execPath,args:[i,o,t,...n]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",o,t,...n]}}function jt(){return {executeSync(e,t,n){return bt({command:e,args:t,cwd:n?.cwd,timeoutMs:n?.timeout,env:n?.env},{encoding:n?.encoding,input:n?.input})},executeAsync(e,t,n){re({command:e,args:t},n);},resolveInvocation(e,t){let n=ne({command:e,args:t});return {cmd:n.command,args:n.args??[]}},splitCommand:kt,spawnDetached(e,t){Et({command:e,args:t});}}}var se=createRequire(import.meta.url);function ie(e){return typeof e=="object"?e:ft(e)}function ae(e){let t=R.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let n=R.dirname(se.resolve("yaml-flow/package.json")),r=R.join(n,"cli","node",t);if(!m.existsSync(r))throw new Error(`resolveYamlFlowCliPath: could not find ${t} under ${R.join(n,"cli","node")}`);return r}function K(e){let t=ie(e);return t.kind==="yaml-flow-cli"?ae(t.value):t.value}function ce(e,t){let n=K(e);switch(n){case "source-cli-task-executor":{let r=R.join(t,"source-cli-task-executor.js");if(m.existsSync(r))return {command:process.execPath,args:[r]};let o=R.join(t,"source-cli-task-executor.ts"),s=R.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=R.join(t,"..","..","node_modules",".bin","tsx"),i=m.existsSync(s)?s:a;return m.existsSync(o)&&m.existsSync(i)?{command:process.execPath,args:[i,o]}:{command:process.execPath,args:[r]}}case "board-live-cards":{let{cmd:r,args:o}=At(t,"_",[]);return {command:r,args:o}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${n}". Supported: source-cli-task-executor, board-live-cards`)}}function ue(e,t){if(e.howToRun==="built-in"){let{command:r,args:o}=ce(e.whatToRun,t);return {command:r,baseArgs:o}}let n=(typeof e.whatToRun=="object",K(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[n]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[n]};case "local-process":return {command:n,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function le(e,t){return ue(e,t)}function pe(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let n=t.split(/\r?\n/).filter(Boolean),r=n[n.length-1];return JSON.parse(r)}}function de(e,t){return {...t,whatToRun:K(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function fe(e,t,n="invokeExecutionRef"){return pt(e,t,n)}function ge(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function N(e){return {result:"failure",data:{error:e}}}function B(e,t,n){let r=n?.label??"invokeExecutionRefSync",o=n?.cliDir??n?.cwd??process.cwd(),s;try{s=fe(e.argsMassaging,de(e,t),r);}catch(l){let f=l instanceof Error?l.message:String(l);return N(f)}let a;try{a=le(e,o);}catch(l){let f=l instanceof Error?l.message:String(l);return N(`[${r}] ref resolution failed: ${f}`)}let i=[...a.baseArgs,...s.cmdArgs??[]],u=JSON.stringify(s.stdin??t),c=jt(),d;try{d=c.executeSync(a.command,i,{timeout:n?.timeoutMs??3e4,encoding:"utf-8",cwd:n?.cwd,input:u});}catch(l){let f=l,h=(f.stderr?String(f.stderr):"").trim(),w=typeof f.status=="number"?f.status:"unknown",p=h||f.message;return N(`[${r}] ref exited with status ${w}${p?`: ${p}`:""}`)}try{return ge(pe(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}var me={"local-node":B,"local-python":B,"local-process":B,"built-in":B};function he(e,t,n){let r=n?.syncTransports?.[e.howToRun]??me[e.howToRun];return r?r(e,t,n):N(`[${n?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Ct(e,t,n){return he(e,t,n)}function we(e,t){if(process.platform!=="win32"){m.renameSync(e,t);return}let n=[10,20,40,80,160];for(let r=0;r<=n.length;r++)try{m.renameSync(e,t);return}catch(o){let s=o.code;if((s==="EPERM"||s==="EBUSY")&&r<n.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,n[r]);continue}throw o}}function Tt(e){function t(r){return R.join(e,...r.split("/"))+".json"}function n(r,o,s,a){if(m.existsSync(r))for(let i of m.readdirSync(r,{withFileTypes:true})){let u=o?`${o}/${i.name}`:i.name;if(i.isDirectory()){n(R.join(r,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(r){let o=t(r);if(!m.existsSync(o))return null;try{return JSON.parse(m.readFileSync(o,"utf-8"))}catch{return null}},write(r,o){let s=t(r),a=`${s}.${process.pid}.${randomUUID()}.tmp`;m.mkdirSync(R.dirname(s),{recursive:true}),m.writeFileSync(a,JSON.stringify(o,null,2),"utf-8"),we(a,s);},delete(r){let o=t(r);try{m.existsSync(o)&&m.unlinkSync(o);}catch{}},listKeys(r){let o=[];return n(e,"",r,o),o.sort()}}}var L=class extends Error{constructor(n,r){super(r);this.code=n;this.name="CliExitError";}code},Se=".pause";async function nr(e){let t=Re(e);if(t.help||e.length===0)throw Ce(),new L(e.length===0?1:0);let{flowArg:n,dataArg:r,storeArg:o,storeDirArg:s,resumeRequested:a,pauseRequested:i,statusRequested:u}=t;if((i||u)&&(r||a||n))throw new Error("[step-machine-cli] --pause and --status are store-level operations. Do not provide flow, data, or --resume.");if(a&&r)throw new Error("[step-machine-cli] --initial-data cannot be combined with --resume.");let c=xe(o,s);if(u){await be(c);return}if(i){await ve(c);return}if(!n)throw new Error("[step-machine-cli] Flow path is required for run/resume operations.");let d=Pt(n),l=R.dirname(d),f=Ee(r),{store:h}=c,w=await H(d),p=je(w,l);Ft(c);let g=new AbortController,x=false,M=$(w,p,{store:h,signal:g.signal,onStep:()=>{!x&&et(c)&&(x=true,g.abort());}}),S;if(a){if(S=await $t(c),!S){console.warn("[step-machine-cli] No paused run found in store directory."),console.log(JSON.stringify({status:"noop",reason:"no-paused-run"},null,2));return}}else c.storeType==="file"&&!f&&(S=await $t(c));let y=S?await M.resume(S):await M.run(f);if(x&&y.status==="cancelled"){let O=await ke(h,y.runId);Ft(c),console.log(JSON.stringify({runId:y.runId,status:"paused",currentStep:O?.currentStep,pausedAt:O?.pausedAt,stepHistory:y.stepHistory,data:y.data},null,2));return}if(y.status!=="completed"){let O=y.error?.message??y.intent??y.status;throw console.error(`[step-machine-cli] Run failed: ${O}`),new L(1)}console.log(JSON.stringify({runId:y.runId,status:y.status,intent:y.intent,finalStep:y.finalStep,stepHistory:y.stepHistory,data:y.data},null,2));}function Re(e){let t=new Set(["--initial-data","--store","--store-dir"]),n={},r=[],o=false,s=false,a=false,i=false;for(let u=0;u<e.length;u++){let c=e[u];if(c==="-h"||c==="--help"){o=true;continue}if(c==="--resume"){s=true;continue}if(c==="--pause"){a=true;continue}if(c==="--status"){i=true;continue}if(t.has(c)){let d=e[u+1];if(!d||d.startsWith("--"))throw new Error(`[step-machine-cli] Missing value for ${c}.`);n[c]=d,u++;continue}if(c.startsWith("--"))throw new Error(`[step-machine-cli] Unknown flag: ${c}`);r.push(c);}if([s,a,i].filter(Boolean).length>1)throw new Error("[step-machine-cli] Use only one of --resume, --pause, or --status at a time.");return {help:o,flowArg:r[0],dataArg:n["--initial-data"],storeArg:String(n["--store"]??"memory").toLowerCase(),storeDirArg:n["--store-dir"],resumeRequested:s,pauseRequested:a,statusRequested:i}}function Pt(e){return R.isAbsolute(e)?e:R.resolve(process.cwd(),e)}function xe(e,t){if(e!=="memory"&&e!=="file")throw new Error(`[step-machine-cli] Invalid --store value "${e}". Expected "memory" or "file".`);if(e==="memory")return {storeType:e,storeDir:void 0,pauseFilePath:void 0,store:new k};if(!t||t.trim().length===0)throw new Error("[step-machine-cli] --store file requires --store-dir <directory>.");let n=Pt(t);return {storeType:e,storeDir:n,pauseFilePath:R.join(n,Se),store:new C(Tt(n))}}async function tt(e){if(!e.listRuns)return [];let t=await e.listRuns(),n=[];for(let r of t){let o=await e.loadRunState(r);o&&n.push(o);}return n.sort((r,o)=>(o.updatedAt??o.startedAt??0)-(r.updatedAt??r.startedAt??0)),n}function et(e){return e.storeType!=="file"||!e.pauseFilePath?false:m.existsSync(e.pauseFilePath)}function Ft(e){et(e)&&m.unlinkSync(e.pauseFilePath);}async function ve(e){if(e.storeType!=="file"||!e.pauseFilePath)throw new Error("[step-machine-cli] --pause requires --store file --store-dir <directory>.");let t=await tt(e.store);if(t.length===0){console.warn("[step-machine-cli] No runs found in store directory. Pause is a no-op."),console.log(JSON.stringify({status:"noop",reason:"no-runs"},null,2));return}if(!t.find(r=>r.status==="running")){console.warn("[step-machine-cli] No running run found. Pause is a no-op."),console.log(JSON.stringify({status:"noop",reason:"no-running-run"},null,2));return}m.mkdirSync(e.storeDir,{recursive:true}),m.writeFileSync(e.pauseFilePath,JSON.stringify({requestedAt:Date.now()}),"utf-8"),console.log(JSON.stringify({status:"pause-requested",storeDir:e.storeDir},null,2));}async function $t(e){let n=(await tt(e.store)).filter(r=>r.status==="paused");if(n.length!==0)return n.length>1&&console.warn("[step-machine-cli] Multiple paused runs found; resuming the most recently updated run."),n[0].runId}async function ke(e,t){let n=await e.loadRunState(t);if(!n)return null;let r={...n,status:"paused",pausedAt:Date.now(),updatedAt:Date.now()};return await e.saveRunState(t,r),r}async function be(e){if(e.storeType!=="file")throw new Error("[step-machine-cli] --status requires --store file --store-dir <directory>.");let t=await tt(e.store),n={store:"file",storeDir:e.storeDir,pauseRequested:et(e),totalRuns:t.length,runs:t.map(r=>({runId:r.runId,status:r.status,currentStep:r.currentStep,startedAt:r.startedAt,updatedAt:r.updatedAt,pausedAt:r.pausedAt}))};console.log(JSON.stringify(n,null,2));}function Ee(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Initial data must be a JSON object.");return t}catch(t){let n=t instanceof Error?t.message:String(t);throw new Error(`[step-machine-cli] Invalid --initial-data value: ${n}`)}}function Ae(e){if(!e||typeof e!="object")return e;let t=e;if(typeof t.whatToRun!="string"||!t.whatToRun.startsWith("b64:"))return e;try{let n=t.whatToRun.slice(4),r=n+"=".repeat((4-n.length%4)%4),o=Buffer.from(r.replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf8"),s=JSON.parse(o);return !s||typeof s!="object"||typeof s.value!="string"?e:{...t,whatToRun:s}}catch{return e}}function je(e,t){return D(e,{invoke:(r,o)=>Ct(Ae(r),o,{cliDir:t,cwd:t})})}function Ce(){console.error("Usage: step-machine-cli <step-flow.yaml> [--initial-data <json>] [--store <memory|file>] [--store-dir <directory>] [--resume]"),console.error(" step-machine-cli --store file --store-dir <directory> --pause"),console.error(" step-machine-cli --store file --store-dir <directory> --status"),console.error(""),console.error("Example:"),console.error(' step-machine-cli examples/cli/step-machine-demo/two-step-math.flow.yaml --initial-data "{"a":3,"b":4}"'),console.error(" step-machine-cli ./flow.yaml --store file --store-dir ./.runs"),console.error(" step-machine-cli ./flow.yaml --store file --store-dir ./.runs --resume"),console.error(" step-machine-cli --store file --store-dir ./.runs --pause"),console.error(" step-machine-cli --store file --store-dir ./.runs --status");}
|
|
4
|
-
export{
|
|
3
|
+
- `)}`);return t}function Y(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rt(e){return atob(e.replace(/-/g,"+").replace(/_/g,"/"))}var F=class{constructor(t){this.kv=t;}kv;stateKey(t){return `state_${Y(t)}`}dataPrefix(t){return `data_${Y(t)}_`}dataKey(t,n){return `${this.dataPrefix(t)}${Y(n)}`}async saveRunState(t,n){this.kv.write(this.stateKey(t),n);}async loadRunState(t){let n=this.kv.read(this.stateKey(t));return n!=null&&typeof n=="object"?n:null}async deleteRunState(t){this.kv.delete(this.stateKey(t));for(let n of this.kv.listKeys(this.dataPrefix(t)))this.kv.delete(n);}async setData(t,n,r){this.kv.write(this.dataKey(t,n),r);}async getData(t,n){return this.kv.read(this.dataKey(t,n))}async getAllData(t){let n=this.dataPrefix(t),r={};for(let s of this.kv.listKeys(n))r[rt(s.slice(n.length))]=this.kv.read(s);return r}async clearData(t){for(let n of this.kv.listKeys(this.dataPrefix(t)))this.kv.delete(n);}async listRuns(){return this.kv.listKeys("state_").map(t=>rt(t.slice(6)))}};var ot=dirname(fileURLToPath(import.meta.url)),Dt=createRequire(import.meta.url);function Nt(){let e=resolve(ot,"./jsonata-sync.cjs");return existsSync(e)?e:resolve(ot,"../card-compute/jsonata-sync.cjs")}var M=Dt(Nt());function it(e,t){if(!e||typeof e!="object")throw new Error(`[step-machine-public] Step "${t}" returned a non-object result.`);let n=e,r=n.result??n.status;if(typeof r=="string"&&r.trim().length>0){let s=n.data&&typeof n.data=="object"&&!Array.isArray(n.data)?{...n.data}:{},o=typeof n.error=="string"?n.error:void 0;return o&&!("error"in s)&&(s.error=o),{result:r,data:s,...o?{error:o}:{}}}return {result:"success",data:{...n}}}function at(e,t){if(!t||t.length===0)return e;let n={};for(let r of t)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function X(e,t){return async(n,r)=>{let s=await e(n,r),o=it(s,r?.stepName??"unknown");return {result:o.result,data:at(o.data,t),...o.error?{error:o.error}:{}}}}function ct(e,t,n){if(!t||t.length===0)return null;for(let r of t)try{if(!M(r).evaluate(e))return {result:"failure",data:{error:`[${n}] input validation failed: ${r}`}}}catch(s){let o=s instanceof Error?s.message:String(s);return {result:"failure",data:{error:`[${n}] input validation error on "${r}": ${o}`}}}return null}function Z(e,t,n){return !t||t.length===0?e:async(r,s)=>{let o=ct(r,t,n);return o||e(r,s)}}var lt=dirname(fileURLToPath(import.meta.url)),qt=createRequire(import.meta.url);function zt(){let e=resolve(lt,"./jsonata-sync.cjs");return existsSync(e)?e:resolve(lt,"../../card-compute/jsonata-sync.cjs")}var v=qt(zt());function pt(e,t,n){if(!e||typeof e!="object")return {};let r={};if(Array.isArray(e.cmdTemplate)){let s=[];for(let o of e.cmdTemplate)try{s.push(String(v(o).evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${n}] argsMassaging.cmdTemplate failed on "${o}": ${i}`)}r.cmdArgs=s;}if(typeof e.stdinTemplate=="string")try{r.stdin=v(e.stdinTemplate).evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${n}] argsMassaging.stdinTemplate failed: ${o}`)}if(typeof e.urlTemplate=="string")try{r.url=String(v(e.urlTemplate).evaluate(t));}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${n}] argsMassaging.urlTemplate failed: ${o}`)}if(typeof e.headerTemplate=="string")try{let s=v(e.headerTemplate).evaluate(t);if(typeof s!="object"||s===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(s)}`);r.headers=s;}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${n}] argsMassaging.headerTemplate failed: ${o}`)}if(typeof e.bodyTemplate=="string")try{r.body=v(e.bodyTemplate).evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${n}] argsMassaging.bodyTemplate failed: ${o}`)}return r}function ft(e,t,n){if(!e||typeof e!="object")return t;let r={output:t},s=t.result,o=t.data,a=t.error;if(typeof e.resultExpr=="string")try{let i=v(e.resultExpr).evaluate(r);if(typeof i!="string"||!i.trim())throw new Error(`resultExpr did not produce a non-empty string (got ${JSON.stringify(i)})`);s=i;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.resultExpr failed: ${u}`)}if(typeof e.dataTemplate=="string")try{let i=v(e.dataTemplate).evaluate(r);if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`dataTemplate did not produce an object (got ${JSON.stringify(i)})`);o=i;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.dataTemplate failed: ${u}`)}if(typeof e.errorExpr=="string")try{let i=v(e.errorExpr).evaluate(r);a=i!=null?String(i):void 0;}catch(i){let u=i instanceof Error?i.message:String(i);throw new Error(`[${n}] outputTransforms.errorExpr failed: ${u}`)}return a!==void 0?{result:s,data:o,error:a}:{result:s,data:o}}var H="b64:";function Wt(e){let t=new TextEncoder().encode(e),n=globalThis.Buffer,r;if(n)r=n.from(t).toString("base64");else if(typeof btoa=="function"){let s="";for(let o of t)s+=String.fromCharCode(o);r=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Gt(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),n=globalThis.Buffer;if(n)return n.from(t,"base64").toString("utf8");if(typeof atob=="function"){let r=atob(t),s=new Uint8Array(r.length);for(let o=0;o<r.length;o+=1)s[o]=r.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function J(e){return `${H}${Wt(JSON.stringify(e))}`}function dt(e){if(!e.startsWith(H))throw new Error(`Invalid ref format (expected ${H}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(Gt(e.slice(H.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let n=t;if(typeof n.kind!="string"||typeof n.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:n.kind,value:n.value}}function gt(e){return !!e&&typeof e=="object"&&e.type==="compute-jsonata"&&Array.isArray(e.expr)&&e.expr.length>0}function mt(e){if(!e||typeof e!="object")return false;let t=e;if(t.type!=="ref"||typeof t.howToRun!="string")return false;if(typeof t.whatToRun=="string")return true;if(t.whatToRun&&typeof t.whatToRun=="object"){let n=t.whatToRun;return typeof n.kind=="string"&&typeof n.value=="string"}return false}function Yt(e){if(typeof e=="string"){let t=e.indexOf("=");if(t<1)throw new Error(`[step-machine-public] Invalid compute expression (missing "="): "${e}"`);return {bindTo:e.slice(0,t).trim(),expr:e.slice(t+1).trim()}}if(e&&typeof e=="object"&&typeof e.bindTo=="string"&&typeof e.expr=="string")return e;throw new Error(`[step-machine-public] Invalid compute step: ${JSON.stringify(e)}`)}function Xt(e,t,n){let r=t.split("."),s=e;for(let o=0;o<r.length-1;o++){let a=r[o];(s[a]==null||typeof s[a]!="object")&&(s[a]={}),s=s[a];}s[r[r.length-1]]=n;}function ht(e,t,n){let r=e.expr.map(Yt);return async s=>{let o=s&&typeof s=="object"&&!Array.isArray(s)?{...s}:{},a={},i={expects_data:o,data:a,...n?{config:n}:{}},u,c;for(let f of r)try{let l=M(f.expr).evaluate(i);if(f.bindTo==="result")u=l!=null?String(l):"success";else if(f.bindTo==="error")c=l!=null?String(l):void 0;else if(f.bindTo.startsWith("data."))Xt(a,f.bindTo.slice(5),l);else return {result:"failure",data:{},error:`[${t}] invalid bindTo "${f.bindTo}": must be "result", "error", or start with "data."`}}catch(l){let d=l instanceof Error?l.message:String(l);return {result:"failure",data:{},error:`[${t}] compute "${f.bindTo}" failed: ${d}`}}return u===void 0?{result:"failure",data:{},error:`[${t}] compute-jsonata: no "result" binding declared \u2014 add '- result = "success"' to expr`}:c?{result:u,data:a,error:c}:{result:u,data:a}}}function yt(e,t,n,r){let{type:s,...o}=e,a={...o,whatToRun:typeof o.whatToRun=="object"?J(o.whatToRun):o.whatToRun};return async i=>{let u=i&&typeof i=="object"&&!Array.isArray(i)?{...i}:{};r&&(u.config=r);try{let c=await n(a,u);if(!e.outputTransforms)return c;try{return ft(e.outputTransforms,c,t)}catch(f){let l=f instanceof Error?f.message:String(f);return {result:"failure",data:{},error:l}}}catch(c){let f=c instanceof Error?c.message:String(c);return {result:"failure",data:{error:`[step-machine-public] step "${t}" invoke threw: ${f}`}}}}}function wt(){return async e=>({result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{}})}function Zt(e,t,n){return async(r,s)=>{let o=r?.[t.items];if(!Array.isArray(o))return {result:"failure",data:{},error:`[${n}] forEach: "${t.items}" is not an array (got ${typeof o})`};let a=o,i=t.collectAs??`${t.items}_results`;if(a.length===0)return {result:"success",data:{[i]:[]}};let{[t.items]:u,...c}=r,f=Math.max(1,t.concurrency??1),l=new Array(a.length),d=0,h=0,w=0;return await new Promise(p=>{function g(){for(;d<f&&h<a.length;){let R=h++;d++;let P={...c,[t.as]:a[R]};e(P,s).then(S=>{l[R]=S;}).catch(S=>{let y=S instanceof Error?S.message:String(S);l[R]={result:"failure",data:{},error:y};}).finally(()=>{d--,l[R]?.result==="failure"&&w++,h>=a.length&&d===0?p():g();});}d===0&&h>=a.length&&p();}g();}),w>0?{result:"failure",data:{errors:l.filter(g=>g.result==="failure").map(g=>g.error)},error:`[${n}] forEach: ${w}/${a.length} items failed`}:{result:"success",data:{[i]:l.map(p=>p.data)}}}}function St(e,t,n){let r=Array.isArray(t?.produces_data)?t?.produces_data:void 0,s=Array.isArray(t?.input_validations)?t?.input_validations:void 0,o=t?.config??void 0,a=t?.handler,i;return gt(a)?i=ht(a,e,o):mt(a)?i=yt(a,e,n.invoke,o):i=wt(),t?.forEach&&(i=Zt(i,t.forEach,e)),Z(X(i,r),s,e)}function B(e,t){let n={};for(let[r,s]of Object.entries(e.steps??{}))n[r]=St(r,s,t);return n}function ne(e){if(typeof e=="object"&&e!==null){let{command:n,args:r=[],...s}=e,o=Rt(n,r);return {...s,command:o.command,args:o.args}}let t=kt(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return Rt(t[0],t.slice(1))}function Rt(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function kt(e){let t=[],n="",r=null;for(let s of e.trim()){if(r){s===r?r=null:n+=s;continue}if(s==='"'||s==="'"){r=s;continue}if(/\s/.test(s)){n&&(t.push(n),n="");continue}n+=s;}if(r)throw new Error(`Unterminated quote in command: ${e}`);return n&&t.push(n),t}function Q(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function bt(e,t){let{command:n,args:r=[],cwd:s,env:o,timeoutMs:a}=e;return execFileSync(n,r,{shell:Q(n),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function re(e,t){let{command:n,args:r=[],cwd:s,env:o,timeoutMs:a=3e4}=e;execFile(n,r,{shell:Q(n),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:s,env:o?{...process.env,...o}:void 0},(i,u,c)=>t(i??null,u,c));}x.join(vt.tmpdir(),".board-live-cards-git-bash-cache.json");function Et(e){let{command:t,args:n=[]}=e;if(process.platform==="win32"){spawn(t,n,{detached:true,stdio:"ignore",windowsHide:true,shell:Q(t)}).unref();return}spawn(t,n,{detached:true,stdio:"ignore"}).unref();}function At(e,t,n){let r=x.join(e,"board-live-cards-cli.js");if(m.existsSync(r))return {cmd:process.execPath,args:[r,t,...n]};let s=x.join(e,"board-live-cards-cli.ts"),o=x.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),a=x.join(e,"..","..","node_modules",".bin","tsx"),i=m.existsSync(o)?o:a;return m.existsSync(s)&&m.existsSync(i)?{cmd:process.execPath,args:[i,s,t,...n]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...n]}}function jt(){return {executeSync(e,t,n){return bt({command:e,args:t,cwd:n?.cwd,timeoutMs:n?.timeout,env:n?.env},{encoding:n?.encoding,input:n?.input})},executeAsync(e,t,n){re({command:e,args:t},n);},resolveInvocation(e,t){let n=ne({command:e,args:t});return {cmd:n.command,args:n.args??[]}},splitCommand:kt,spawnDetached(e,t){Et({command:e,args:t});}}}var oe=createRequire(import.meta.url);function ie(e){return typeof e=="object"?e:dt(e)}function ae(e){let t=x.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let n=x.dirname(oe.resolve("yaml-flow/package.json")),r=x.join(n,"cli","node",t);if(!m.existsSync(r))throw new Error(`resolveYamlFlowCliPath: could not find ${t} under ${x.join(n,"cli","node")}`);return r}function L(e){let t=ie(e);return t.kind==="yaml-flow-cli"?ae(t.value):t.value}function ce(e,t){let n=L(e);switch(n){case "source-cli-task-executor":{let r=x.join(t,"source-cli-task-executor.js");if(m.existsSync(r))return {command:process.execPath,args:[r]};let s=x.join(t,"source-cli-task-executor.ts"),o=x.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=x.join(t,"..","..","node_modules",".bin","tsx"),i=m.existsSync(o)?o:a;return m.existsSync(s)&&m.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[r]}}case "board-live-cards":{let{cmd:r,args:s}=At(t,"_",[]);return {command:r,args:s}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${n}". Supported: source-cli-task-executor, board-live-cards`)}}function ue(e,t){if(e.howToRun==="built-in"){let{command:r,args:s}=ce(e.whatToRun,t);return {command:r,baseArgs:s}}let n=(typeof e.whatToRun=="object",L(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[n]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[n]};case "local-process":return {command:n,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function le(e,t){return ue(e,t)}function pe(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let n=t.split(/\r?\n/).filter(Boolean),r=n[n.length-1];return JSON.parse(r)}}function fe(e,t){return {...t,whatToRun:L(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function de(e,t,n="invokeExecutionRef"){return pt(e,t,n)}function ge(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function N(e){return {result:"failure",data:{error:e}}}function D(e,t,n){let r=n?.label??"invokeExecutionRefSync",s=n?.cliDir??n?.cwd??process.cwd(),o;try{o=de(e.argsMassaging,fe(e,t),r);}catch(l){let d=l instanceof Error?l.message:String(l);return N(d)}let a;try{a=le(e,s);}catch(l){let d=l instanceof Error?l.message:String(l);return N(`[${r}] ref resolution failed: ${d}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=jt(),f;try{f=c.executeSync(a.command,i,{timeout:n?.timeoutMs??3e4,encoding:"utf-8",cwd:n?.cwd,input:u});}catch(l){let d=l,h=(d.stderr?String(d.stderr):"").trim(),w=typeof d.status=="number"?d.status:"unknown",p=h||d.message;return N(`[${r}] ref exited with status ${w}${p?`: ${p}`:""}`)}try{return ge(pe(f))}catch{return {result:"success",data:{stdout:f.trim()}}}}var me={"local-node":D,"local-python":D,"local-process":D,"built-in":D};function he(e,t,n){let r=n?.syncTransports?.[e.howToRun]??me[e.howToRun];return r?r(e,t,n):N(`[${n?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Ft(e,t,n){return he(e,t,n)}function we(e,t){if(process.platform!=="win32"){m.renameSync(e,t);return}let n=[10,20,40,80,160];for(let r=0;r<=n.length;r++)try{m.renameSync(e,t);return}catch(s){let o=s.code;if((o==="EPERM"||o==="EBUSY")&&r<n.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,n[r]);continue}throw s}}function Ct(e){function t(r){return x.join(e,...r.split("/"))+".json"}function n(r,s,o,a){if(m.existsSync(r))for(let i of m.readdirSync(r,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){n(x.join(r,i.name),u,o,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!o||c.startsWith(o))&&a.push(c);}}return {read(r){let s=t(r);if(!m.existsSync(s))return null;try{return JSON.parse(m.readFileSync(s,"utf-8"))}catch{return null}},write(r,s){let o=t(r),a=`${o}.${process.pid}.${randomUUID()}.tmp`;m.mkdirSync(x.dirname(o),{recursive:true}),m.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),we(a,o);},delete(r){let s=t(r);try{m.existsSync(s)&&m.unlinkSync(s);}catch{}},listKeys(r){let s=[];return n(e,"",r,s),s.sort()}}}var K=class extends Error{constructor(n,r){super(r);this.code=n;this.name="CliExitError";}code},Se=".pause";async function sr(e){let t=xe(e);if(t.help||e.length===0)throw Fe(),new K(e.length===0?1:0);let{flowArg:n,dataArg:r,storeArg:s,storeDirArg:o,resumeRequested:a,pauseRequested:i,statusRequested:u}=t;if((i||u)&&(r||a||n))throw new Error("[step-machine-cli] --pause and --status are store-level operations. Do not provide flow, data, or --resume.");if(a&&r)throw new Error("[step-machine-cli] --initial-data cannot be combined with --resume.");let c=Re(s,o);if(u){await be(c);return}if(i){await ve(c);return}if(!n)throw new Error("[step-machine-cli] Flow path is required for run/resume operations.");let f=Mt(n),l=x.dirname(f),d=Ee(r),{store:h}=c,w=await I(f),p=je(w,l);Tt(c);let g=new AbortController,R=false,P=$(w,p,{store:h,signal:g.signal,onStep:()=>{!R&&et(c)&&(R=true,g.abort());}}),S;if(a){if(S=await $t(c),!S){console.warn("[step-machine-cli] No paused run found in store directory."),console.log(JSON.stringify({status:"noop",reason:"no-paused-run"},null,2));return}}else c.storeType==="file"&&!d&&(S=await $t(c));let y=S?await P.resume(S):await P.run(d);if(R&&y.status==="cancelled"){let _=await ke(h,y.runId);Tt(c),console.log(JSON.stringify({runId:y.runId,status:"paused",currentStep:_?.currentStep,pausedAt:_?.pausedAt,stepHistory:y.stepHistory,data:y.data},null,2));return}if(y.status!=="completed"){let _=y.error?.message??y.intent??y.status;throw console.error(`[step-machine-cli] Run failed: ${_}`),new K(1)}console.log(JSON.stringify({runId:y.runId,status:y.status,intent:y.intent,finalStep:y.finalStep,stepHistory:y.stepHistory,data:y.data},null,2));}function xe(e){let t=new Set(["--initial-data","--store","--store-dir"]),n={},r=[],s=false,o=false,a=false,i=false;for(let u=0;u<e.length;u++){let c=e[u];if(c==="-h"||c==="--help"){s=true;continue}if(c==="--resume"){o=true;continue}if(c==="--pause"){a=true;continue}if(c==="--status"){i=true;continue}if(t.has(c)){let f=e[u+1];if(!f||f.startsWith("--"))throw new Error(`[step-machine-cli] Missing value for ${c}.`);n[c]=f,u++;continue}if(c.startsWith("--"))throw new Error(`[step-machine-cli] Unknown flag: ${c}`);r.push(c);}if([o,a,i].filter(Boolean).length>1)throw new Error("[step-machine-cli] Use only one of --resume, --pause, or --status at a time.");return {help:s,flowArg:r[0],dataArg:n["--initial-data"],storeArg:String(n["--store"]??"memory").toLowerCase(),storeDirArg:n["--store-dir"],resumeRequested:o,pauseRequested:a,statusRequested:i}}function Mt(e){return x.isAbsolute(e)?e:x.resolve(process.cwd(),e)}function Re(e,t){if(e!=="memory"&&e!=="file")throw new Error(`[step-machine-cli] Invalid --store value "${e}". Expected "memory" or "file".`);if(e==="memory")return {storeType:e,storeDir:void 0,pauseFilePath:void 0,store:new k};if(!t||t.trim().length===0)throw new Error("[step-machine-cli] --store file requires --store-dir <directory>.");let n=Mt(t);return {storeType:e,storeDir:n,pauseFilePath:x.join(n,Se),store:new F(Ct(n))}}async function tt(e){if(!e.listRuns)return [];let t=await e.listRuns(),n=[];for(let r of t){let s=await e.loadRunState(r);s&&n.push(s);}return n.sort((r,s)=>(s.updatedAt??s.startedAt??0)-(r.updatedAt??r.startedAt??0)),n}function et(e){return e.storeType!=="file"||!e.pauseFilePath?false:m.existsSync(e.pauseFilePath)}function Tt(e){et(e)&&m.unlinkSync(e.pauseFilePath);}async function ve(e){if(e.storeType!=="file"||!e.pauseFilePath)throw new Error("[step-machine-cli] --pause requires --store file --store-dir <directory>.");let t=await tt(e.store);if(t.length===0){console.warn("[step-machine-cli] No runs found in store directory. Pause is a no-op."),console.log(JSON.stringify({status:"noop",reason:"no-runs"},null,2));return}if(!t.find(r=>r.status==="running")){console.warn("[step-machine-cli] No running run found. Pause is a no-op."),console.log(JSON.stringify({status:"noop",reason:"no-running-run"},null,2));return}m.mkdirSync(e.storeDir,{recursive:true}),m.writeFileSync(e.pauseFilePath,JSON.stringify({requestedAt:Date.now()}),"utf-8"),console.log(JSON.stringify({status:"pause-requested",storeDir:e.storeDir},null,2));}async function $t(e){let n=(await tt(e.store)).filter(r=>r.status==="paused");if(n.length!==0)return n.length>1&&console.warn("[step-machine-cli] Multiple paused runs found; resuming the most recently updated run."),n[0].runId}async function ke(e,t){let n=await e.loadRunState(t);if(!n)return null;let r={...n,status:"paused",pausedAt:Date.now(),updatedAt:Date.now()};return await e.saveRunState(t,r),r}async function be(e){if(e.storeType!=="file")throw new Error("[step-machine-cli] --status requires --store file --store-dir <directory>.");let t=await tt(e.store),n={store:"file",storeDir:e.storeDir,pauseRequested:et(e),totalRuns:t.length,runs:t.map(r=>({runId:r.runId,status:r.status,currentStep:r.currentStep,startedAt:r.startedAt,updatedAt:r.updatedAt,pausedAt:r.pausedAt}))};console.log(JSON.stringify(n,null,2));}function Ee(e){if(e)try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Initial data must be a JSON object.");return t}catch(t){let n=t instanceof Error?t.message:String(t);throw new Error(`[step-machine-cli] Invalid --initial-data value: ${n}`)}}function Ae(e){if(!e||typeof e!="object")return e;let t=e;if(typeof t.whatToRun!="string"||!t.whatToRun.startsWith("b64:"))return e;try{let n=t.whatToRun.slice(4),r=n+"=".repeat((4-n.length%4)%4),s=Buffer.from(r.replace(/-/g,"+").replace(/_/g,"/"),"base64").toString("utf8"),o=JSON.parse(s);return !o||typeof o!="object"||typeof o.value!="string"?e:{...t,whatToRun:o}}catch{return e}}function je(e,t){return B(e,{invoke:(r,s)=>Ft(Ae(r),s,{cliDir:t,cwd:t})})}function Fe(){console.error("Usage: step-machine-cli <step-flow.yaml> [--initial-data <json>] [--store <memory|file>] [--store-dir <directory>] [--resume]"),console.error(" step-machine-cli --store file --store-dir <directory> --pause"),console.error(" step-machine-cli --store file --store-dir <directory> --status"),console.error(""),console.error("Example:"),console.error(' step-machine-cli examples/cli/step-machine-demo/two-step-math.flow.yaml --initial-data "{"a":3,"b":4}"'),console.error(" step-machine-cli ./flow.yaml --store file --store-dir ./.runs"),console.error(" step-machine-cli ./flow.yaml --store file --store-dir ./.runs --resume"),console.error(" step-machine-cli --store file --store-dir ./.runs --pause"),console.error(" step-machine-cli --store file --store-dir ./.runs --status");}
|
|
4
|
+
export{K as CliExitError,sr as cli};//# sourceMappingURL=step-machine-cli.js.map
|
|
5
5
|
//# sourceMappingURL=step-machine-cli.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as KVStorage, B as BlobStorage, c as AtomicRelayLock, E as ExecutionRef, K as KindValueRef, J as JournalStorage } from './execution-interface-
|
|
1
|
+
import { b as KVStorage, B as BlobStorage, S as ScratchStorage, c as ArchiveFactory, d as AtomicRelayLock, E as ExecutionRef, K as KindValueRef, J as JournalStorage } from './execution-interface-DCFBy4L8.js';
|
|
2
2
|
import { L as LiveCard, B as BoardStatusObject, J as JournalStorageAdapter, O as OutputStoreEvent } from './board-live-cards-lib-tjYsPt5U.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -76,6 +76,22 @@ interface BoardPlatformAdapter {
|
|
|
76
76
|
* '' — root-scoped blob access (for resolving arbitrary KindValueRef blobs)
|
|
77
77
|
*/
|
|
78
78
|
blobStorage(namespace: string): BlobStorage;
|
|
79
|
+
/**
|
|
80
|
+
* Ephemeral scratch store for transient I/O staging (probe in/out/err,
|
|
81
|
+
* dispatchExecution argv/out/err). Default scope is board-local; if the
|
|
82
|
+
* config has a 'scratch-store-ref' set, scratchStorageForRef(ref) is used
|
|
83
|
+
* instead.
|
|
84
|
+
*/
|
|
85
|
+
scratchStorage(): ScratchStorage;
|
|
86
|
+
scratchStorageForRef(ref: string): ScratchStorage;
|
|
87
|
+
/**
|
|
88
|
+
* Archive factory — long-lived tracking / audit store. Default scope is
|
|
89
|
+
* board-local; if the config has an 'archive-store-ref' set,
|
|
90
|
+
* archiveFactoryForRef(ref) is used instead so archives can live on a
|
|
91
|
+
* different backend / path than the main board runtime.
|
|
92
|
+
*/
|
|
93
|
+
archiveFactory(): ArchiveFactory;
|
|
94
|
+
archiveFactoryForRef(ref: string): ArchiveFactory;
|
|
79
95
|
/**
|
|
80
96
|
* Journal storage adapter (append-only log).
|
|
81
97
|
* Uses the lib's JournalStorageAdapter interface.
|
|
@@ -154,6 +170,12 @@ interface BoardLiveCardsPublic {
|
|
|
154
170
|
getOutputsStoreRef(input: CommandInput): CommandResult<{
|
|
155
171
|
storeRef: string;
|
|
156
172
|
}>;
|
|
173
|
+
getScratchStoreRef(input: CommandInput): CommandResult<{
|
|
174
|
+
storeRef: string | null;
|
|
175
|
+
}>;
|
|
176
|
+
getArchiveStoreRef(input: CommandInput): CommandResult<{
|
|
177
|
+
storeRef: string | null;
|
|
178
|
+
}>;
|
|
157
179
|
getConfig(input: CommandInput): CommandResult<{
|
|
158
180
|
value: unknown;
|
|
159
181
|
}>;
|
|
@@ -190,9 +212,7 @@ interface BoardNonCorePlatformAdapter extends BoardPlatformAdapter {
|
|
|
190
212
|
ok: boolean;
|
|
191
213
|
errors: string[];
|
|
192
214
|
};
|
|
193
|
-
/**
|
|
194
|
-
makeTempFilePath(label: string, ext?: string): string;
|
|
195
|
-
/** Absolute-path blob I/O for temp files and card file references. */
|
|
215
|
+
/** Absolute-path blob I/O for resolving arbitrary KindValueRef blobs. */
|
|
196
216
|
absoluteBlob: BlobStorage;
|
|
197
217
|
/**
|
|
198
218
|
* Default timeouts (ms) for synchronous executor invocations.
|
|
@@ -311,18 +331,6 @@ interface ChatStorage {
|
|
|
311
331
|
declare function createChatStorage(journalFactory: (cardId: string) => JournalStorage, kv: KVStorage): ChatStorage;
|
|
312
332
|
declare function createInMemoryChatStorage(): ChatStorage;
|
|
313
333
|
|
|
314
|
-
/**
|
|
315
|
-
* server-runtime/types.ts
|
|
316
|
-
*
|
|
317
|
-
* Platform-free adapter interfaces for the board server runtime.
|
|
318
|
-
*
|
|
319
|
-
* The runtime (index.ts) imports ONLY this file and board-live-cards-public
|
|
320
|
-
* for its dependencies — no node:fs, node:net, node:child_process, etc.
|
|
321
|
-
*
|
|
322
|
-
* Hosts (demo-server, Azure Function, Firebase Function) provide implementations
|
|
323
|
-
* of these interfaces when constructing the runtime.
|
|
324
|
-
*/
|
|
325
|
-
|
|
326
334
|
interface InvocationAdapter {
|
|
327
335
|
/**
|
|
328
336
|
* Fire-and-forget invocation of an ExecutionRef with args.
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
20
20
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
21
21
|
<script src="https://cdn.jsdelivr.net/npm/leader-line/leader-line.min.js"></script>
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
22
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/live-cards.js"></script>
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/board-livecards-client.js"></script>
|
|
24
24
|
</head>
|
|
25
25
|
<body class="bg-light">
|
|
26
26
|
<div class="container-fluid py-3">
|
package/examples/board/doc.html
CHANGED
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
38
38
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
39
39
|
<script src="https://cdn.jsdelivr.net/npm/leader-line/leader-line.min.js"></script>
|
|
40
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
41
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
40
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/live-cards.js"></script>
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/board-livecards-client.js"></script>
|
|
42
42
|
</head>
|
|
43
43
|
<body class="bg-light">
|
|
44
44
|
<div class="container-fluid py-3">
|
|
@@ -292,6 +292,11 @@ function buildBoardContextConfig(label, boardDir, taskExecPath, chatHandlerFlow,
|
|
|
292
292
|
const runtimeCardsDir = path.join(path.dirname(boardDir), 'cards');
|
|
293
293
|
const runtimeCardStoreDir = path.join(runtimeCardsDir, 'store');
|
|
294
294
|
fs.mkdirSync(runtimeCardStoreDir, { recursive: true });
|
|
295
|
+
const runtimeOutDir = path.join(path.dirname(boardDir), 'runtime-out');
|
|
296
|
+
const scratchDir = path.join(runtimeOutDir, '.tmp');
|
|
297
|
+
const archiveDir = path.join(runtimeOutDir, 'archive');
|
|
298
|
+
fs.mkdirSync(scratchDir, { recursive: true });
|
|
299
|
+
fs.mkdirSync(archiveDir, { recursive: true });
|
|
295
300
|
|
|
296
301
|
const notifyChannel = `yaml-flow-server-${label}-${boardId}-${process.pid}`;
|
|
297
302
|
const baseRef = parseRef(serializeRef({ kind: 'fs-path', value: boardDir }));
|
|
@@ -301,6 +306,8 @@ function buildBoardContextConfig(label, boardDir, taskExecPath, chatHandlerFlow,
|
|
|
301
306
|
const artifactsRef = parseRef(serializeRef({ kind: 'fs-path', value: runtimeCardsDir }));
|
|
302
307
|
const artifactsAdapter = createFsBoardPlatformAdapter(artifactsRef, { suppressSpawn: true });
|
|
303
308
|
const cardStoreRef = serializeRef({ kind: 'fs-path', value: runtimeCardStoreDir });
|
|
309
|
+
const scratchStoreRef = serializeRef({ kind: 'fs-path', value: scratchDir });
|
|
310
|
+
const archiveStoreRef = serializeRef({ kind: 'fs-path', value: archiveDir });
|
|
304
311
|
|
|
305
312
|
return {
|
|
306
313
|
label,
|
|
@@ -308,7 +315,9 @@ function buildBoardContextConfig(label, boardDir, taskExecPath, chatHandlerFlow,
|
|
|
308
315
|
artifactsAdapter,
|
|
309
316
|
baseRef,
|
|
310
317
|
cardStoreRef,
|
|
311
|
-
outputsStoreRef: serializeRef({ kind: 'fs-path', value:
|
|
318
|
+
outputsStoreRef: serializeRef({ kind: 'fs-path', value: runtimeOutDir }),
|
|
319
|
+
scratchStoreRef,
|
|
320
|
+
archiveStoreRef,
|
|
312
321
|
notifyRef: { kind: 'named-pipe', value: namedPipePath(notifyChannel) },
|
|
313
322
|
taskExecutorRef: makeExecutionRef(taskExecPath, executionExtra),
|
|
314
323
|
chatHandlerFlow,
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<title>Example Board Demo (LocalStorage Runtime)</title>
|
|
7
7
|
<link rel="icon" type="image/svg+xml" href="../../browser/favicon.svg" />
|
|
8
8
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
9
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
9
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/compute-jsonata.js"></script>
|
|
10
10
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
12
12
|
<script src="https://cdn.jsdelivr.net/npm/dompurify/dist/purify.min.js"></script>
|
|
13
13
|
<script src="https://cdn.jsdelivr.net/npm/leader-line/leader-line.min.js"></script>
|
|
14
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/live-cards.js"></script>
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/yaml-flow@8.4.1/browser/board-livecards-localstorage.js"></script>
|
|
16
16
|
</head>
|
|
17
17
|
<body class="bg-light">
|
|
18
18
|
<div class="container-fluid py-3">
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BlobStorage } from './storage-interface-B6ecOulj.js';
|
|
1
|
+
import { B as BlobStorage } from './storage-interface-B-7pDHwD.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* artifacts-store-lib.ts
|
|
@@ -59,33 +58,4 @@ declare function createArtifactsStore(blob: BlobStorage): ArtifactsStore;
|
|
|
59
58
|
declare function createFileArtifactsStore(store: ArtifactsStore): FileArtifactsStore;
|
|
60
59
|
declare function createCardFileMetadataStore(): CardFileMetadataStore;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
* artifacts-store-lib-public.ts
|
|
64
|
-
*
|
|
65
|
-
* Public API wrapper for ArtifactsStore, following CommandInput/CommandResult.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
interface ArtifactsStorePublic {
|
|
69
|
-
list(input: CommandInput): CommandResult<{
|
|
70
|
-
artifacts: ArtifactInfo[];
|
|
71
|
-
}>;
|
|
72
|
-
head(input: CommandInput): CommandResult<{
|
|
73
|
-
artifact: ArtifactInfo | null;
|
|
74
|
-
}>;
|
|
75
|
-
put(input: CommandInput): CommandResult<{
|
|
76
|
-
artifact: ArtifactInfo;
|
|
77
|
-
}>;
|
|
78
|
-
get(input: CommandInput): CommandResult<{
|
|
79
|
-
key: string;
|
|
80
|
-
contentType?: string;
|
|
81
|
-
size?: number;
|
|
82
|
-
text?: string;
|
|
83
|
-
bytes?: number[];
|
|
84
|
-
}>;
|
|
85
|
-
del(input: CommandInput): CommandResult<{
|
|
86
|
-
ok: true;
|
|
87
|
-
}>;
|
|
88
|
-
}
|
|
89
|
-
declare function createArtifactsStorePublic(store: ArtifactsStore): ArtifactsStorePublic;
|
|
90
|
-
|
|
91
|
-
export { type ArtifactsStorePublic as A, createArtifactsStorePublic as a, createCardFileMetadataStore as b, createArtifactsStore as c, createFileArtifactsStore as d };
|
|
61
|
+
export { type ArtifactInfo as A, type ArtifactsStore as a, createCardFileMetadataStore as b, createArtifactsStore as c, createFileArtifactsStore as d };
|
package/lib/{artifacts-store-lib-public-Cz8-kdXG.d.cts → artifacts-store-lib-zsGFbBV8.d.cts}
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as BlobStorage } from './storage-interface-B6ecOulj.cjs';
|
|
1
|
+
import { B as BlobStorage } from './storage-interface-B-7pDHwD.cjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* artifacts-store-lib.ts
|
|
@@ -59,33 +58,4 @@ declare function createArtifactsStore(blob: BlobStorage): ArtifactsStore;
|
|
|
59
58
|
declare function createFileArtifactsStore(store: ArtifactsStore): FileArtifactsStore;
|
|
60
59
|
declare function createCardFileMetadataStore(): CardFileMetadataStore;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
* artifacts-store-lib-public.ts
|
|
64
|
-
*
|
|
65
|
-
* Public API wrapper for ArtifactsStore, following CommandInput/CommandResult.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
interface ArtifactsStorePublic {
|
|
69
|
-
list(input: CommandInput): CommandResult<{
|
|
70
|
-
artifacts: ArtifactInfo[];
|
|
71
|
-
}>;
|
|
72
|
-
head(input: CommandInput): CommandResult<{
|
|
73
|
-
artifact: ArtifactInfo | null;
|
|
74
|
-
}>;
|
|
75
|
-
put(input: CommandInput): CommandResult<{
|
|
76
|
-
artifact: ArtifactInfo;
|
|
77
|
-
}>;
|
|
78
|
-
get(input: CommandInput): CommandResult<{
|
|
79
|
-
key: string;
|
|
80
|
-
contentType?: string;
|
|
81
|
-
size?: number;
|
|
82
|
-
text?: string;
|
|
83
|
-
bytes?: number[];
|
|
84
|
-
}>;
|
|
85
|
-
del(input: CommandInput): CommandResult<{
|
|
86
|
-
ok: true;
|
|
87
|
-
}>;
|
|
88
|
-
}
|
|
89
|
-
declare function createArtifactsStorePublic(store: ArtifactsStore): ArtifactsStorePublic;
|
|
90
|
-
|
|
91
|
-
export { type ArtifactsStorePublic as A, createArtifactsStorePublic as a, createCardFileMetadataStore as b, createArtifactsStore as c, createFileArtifactsStore as d };
|
|
61
|
+
export { type ArtifactInfo as A, type ArtifactsStore as a, createCardFileMetadataStore as b, createArtifactsStore as c, createFileArtifactsStore as d };
|
|
@@ -1,5 +1,36 @@
|
|
|
1
|
-
import './board-live-cards-public-
|
|
2
|
-
|
|
3
|
-
import './storage-interface-
|
|
1
|
+
import { C as CommandInput, a as CommandResult } from './board-live-cards-public-BM6jCEIa.cjs';
|
|
2
|
+
import { A as ArtifactInfo, a as ArtifactsStore } from './artifacts-store-lib-zsGFbBV8.cjs';
|
|
3
|
+
import './storage-interface-B-7pDHwD.cjs';
|
|
4
4
|
import './execution-refs.cjs';
|
|
5
5
|
import './types-BBhqYGhE.cjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* artifacts-store-lib-public.ts
|
|
9
|
+
*
|
|
10
|
+
* Public API wrapper for ArtifactsStore, following CommandInput/CommandResult.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface ArtifactsStorePublic {
|
|
14
|
+
list(input: CommandInput): CommandResult<{
|
|
15
|
+
artifacts: ArtifactInfo[];
|
|
16
|
+
}>;
|
|
17
|
+
head(input: CommandInput): CommandResult<{
|
|
18
|
+
artifact: ArtifactInfo | null;
|
|
19
|
+
}>;
|
|
20
|
+
put(input: CommandInput): CommandResult<{
|
|
21
|
+
artifact: ArtifactInfo;
|
|
22
|
+
}>;
|
|
23
|
+
get(input: CommandInput): CommandResult<{
|
|
24
|
+
key: string;
|
|
25
|
+
contentType?: string;
|
|
26
|
+
size?: number;
|
|
27
|
+
text?: string;
|
|
28
|
+
bytes?: number[];
|
|
29
|
+
}>;
|
|
30
|
+
del(input: CommandInput): CommandResult<{
|
|
31
|
+
ok: true;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
declare function createArtifactsStorePublic(store: ArtifactsStore): ArtifactsStorePublic;
|
|
35
|
+
|
|
36
|
+
export { type ArtifactsStorePublic, createArtifactsStorePublic };
|
|
@@ -1,5 +1,36 @@
|
|
|
1
|
-
import './board-live-cards-public-
|
|
2
|
-
|
|
3
|
-
import './storage-interface-
|
|
1
|
+
import { C as CommandInput, a as CommandResult } from './board-live-cards-public-Bz07XKRK.js';
|
|
2
|
+
import { A as ArtifactInfo, a as ArtifactsStore } from './artifacts-store-lib-454TAuov.js';
|
|
3
|
+
import './storage-interface-B-7pDHwD.js';
|
|
4
4
|
import './execution-refs.js';
|
|
5
5
|
import './types-BBhqYGhE.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* artifacts-store-lib-public.ts
|
|
9
|
+
*
|
|
10
|
+
* Public API wrapper for ArtifactsStore, following CommandInput/CommandResult.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface ArtifactsStorePublic {
|
|
14
|
+
list(input: CommandInput): CommandResult<{
|
|
15
|
+
artifacts: ArtifactInfo[];
|
|
16
|
+
}>;
|
|
17
|
+
head(input: CommandInput): CommandResult<{
|
|
18
|
+
artifact: ArtifactInfo | null;
|
|
19
|
+
}>;
|
|
20
|
+
put(input: CommandInput): CommandResult<{
|
|
21
|
+
artifact: ArtifactInfo;
|
|
22
|
+
}>;
|
|
23
|
+
get(input: CommandInput): CommandResult<{
|
|
24
|
+
key: string;
|
|
25
|
+
contentType?: string;
|
|
26
|
+
size?: number;
|
|
27
|
+
text?: string;
|
|
28
|
+
bytes?: number[];
|
|
29
|
+
}>;
|
|
30
|
+
del(input: CommandInput): CommandResult<{
|
|
31
|
+
ok: true;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
declare function createArtifactsStorePublic(store: ArtifactsStore): ArtifactsStorePublic;
|
|
35
|
+
|
|
36
|
+
export { type ArtifactsStorePublic, createArtifactsStorePublic };
|