yaml-flow 8.4.11 → 8.4.13
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/live-cards.schema.json +4 -0
- package/cli/bundled/board-live-cards-cli.mjs +12 -12
- package/examples/board/demo-shell-with-server.html +2 -2
- package/examples/board/doc.html +2 -2
- package/examples/board-local/demo-shell-localstorage.html +3 -3
- package/lib/board-live-cards-node.cjs +6 -6
- package/lib/board-live-cards-node.js +6 -6
- package/lib/card-compute/index.cjs +1 -1
- package/lib/card-compute/index.js +1 -1
- package/lib/card-validation.cjs +1 -1
- package/lib/card-validation.js +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/schema/live-cards.schema.json +4 -0
package/lib/index.cjs
CHANGED
|
@@ -20,6 +20,6 @@ ${a.slice(1).map(i=>`${n} ${i.trimStart()?i:""}`).filter(Boolean).join(`
|
|
|
20
20
|
`);if(typeof t=="object"){let s=Object.entries(t);return s.length===0?"{}":s.map(([o,a])=>{if(a===void 0)return "";let i=on(a,e,r+1);return typeof a=="object"&&a!==null&&!Array.isArray(a)&&Object.keys(a).length>0?`${n}${o}:
|
|
21
21
|
${i}`:Array.isArray(a)&&a.length>0&&!a.every(c=>typeof c=="string"||typeof c=="number"||typeof c=="boolean")?`${n}${o}:
|
|
22
22
|
${i}`:`${n}${o}: ${i}`}).filter(Boolean).join(`
|
|
23
|
-
`)}return String(t)}function lg(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function pg(t,e){let r={};for(let[n,s]of Object.entries(t)){r[n]=new Set;for(let o of O(s))for(let a of e[o]||[])a!==n&&r[n].add(a);}return r}function fg(t,e){let o={},a={},i=[];for(let u of t)o[u]=0,a[u]=null;function c(u){o[u]=1;for(let l of e[u]||[])if(o[l]===1){let d=[l],m=u;for(;m!==l;)d.push(m),m=a[m];d.push(l),d.reverse(),i.push(d);}else o[l]===0&&(a[l]=u,c(l));o[u]=2;}for(let u of t)o[u]===0&&c(u);return i}function Bc(t){let e=[],r=G(t),n=Object.keys(r);if(n.length===0)return e.push({severity:"error",code:"EMPTY_GRAPH",message:"Graph has no tasks"}),Vc(e);let s=lg(r),o=pg(r,s);for(let[c,u]of Object.entries(r))for(let l of O(u))s[l]||e.push({severity:"error",code:"DANGLING_REQUIRES",message:`Task "${c}" requires token "${l}" but no task produces it`,tasks:[c],tokens:[l]});let a=fg(n,o);for(let c of a)e.push({severity:"error",code:"CIRCULAR_DEPENDENCY",message:`Circular dependency: ${c.join(" \u2192 ")}`,tasks:c.filter((u,l)=>l<c.length-1)});for(let[c,u]of Object.entries(r)){let l=O(u),d=E(u),m=l.filter(p=>d.includes(p));m.length>0&&e.push({severity:"error",code:"SELF_DEPENDENCY",message:`Task "${c}" requires tokens it provides itself: [${m.join(", ")}]`,tasks:[c],tokens:m});}for(let[c,u]of Object.entries(s))u.length>1&&e.push({severity:"warning",code:"PROVIDE_CONFLICT",message:`Token "${c}" is produced by multiple tasks: [${u.join(", ")}]. This requires a conflict strategy.`,tasks:u,tokens:[c]});if(t.settings.completion==="goal-reached"&&t.settings.goal)for(let c of t.settings.goal)s[c]||e.push({severity:"error",code:"UNREACHABLE_GOAL",message:`Goal token "${c}" cannot be produced by any task`,tokens:[c]});if(n.length>1)for(let[c,u]of Object.entries(r)){let l=E(u),d=u.on?Object.values(u.on).flat():[],m=u.on_failure||[];l.length===0&&d.length===0&&m.length===0&&e.push({severity:"warning",code:"DEAD_END_TASK",message:`Task "${c}" has no provides \u2014 it cannot unblock any downstream task`,tasks:[c]});}let i=new Set;for(let c of Object.values(r))for(let u of O(c))i.add(u);for(let[c,u]of Object.entries(r)){let l=O(u),d=E(u),m=u.on?Object.values(u.on).flat():[],p=[...d,...m],h=l.length===0,f=p.some(g=>i.has(g));h&&!f&&n.length>1&&(t.settings.completion==="goal-reached"&&t.settings.goal?.some(k=>p.includes(k))||e.push({severity:"info",code:"ISOLATED_TASK",message:`Task "${c}" is disconnected \u2014 it has no requires and nothing depends on its provides`,tasks:[c]}));}return t.settings.completion==="goal-reached"&&!t.settings.goal&&e.push({severity:"error",code:"MISSING_GOAL",message:'Completion strategy is "goal-reached" but no goal tokens are defined'}),Vc(e)}function Vc(t){let e=t.filter(n=>n.severity==="error"),r=t.filter(n=>n.severity==="warning");return {valid:e.length===0,issues:t,errors:e,warnings:r}}var Kc={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://github.com/yaml-flow/schema/event-graph.json",title:"Event Graph Configuration",description:"Schema for stateless event-graph (DAG) workflow definitions in yaml-flow",type:"object",required:["settings","tasks"],additionalProperties:false,properties:{id:{type:"string",description:"Optional graph identifier"},settings:{$ref:"#/definitions/settings"},tasks:{type:"object",description:"Task definitions keyed by name",minProperties:1,additionalProperties:{$ref:"#/definitions/task"}}},definitions:{settings:{type:"object",required:["completion"],properties:{completion:{type:"string",enum:["all-tasks-done","all-outputs-done","only-resolved","goal-reached","manual"],description:"Completion strategy"},conflict_strategy:{type:"string",enum:["alphabetical","priority-first","duration-first","cost-optimized","resource-aware","random-select","user-choice","parallel-all","skip-conflicts","round-robin"],description:"Conflict resolution strategy"},execution_mode:{type:"string",enum:["dependency-mode","eligibility-mode"],description:"Execution mode"},goal:{type:"array",items:{type:"string"},minItems:1,description:"Goal outputs \u2014 required when completion is 'goal-reached'"},max_iterations:{type:"integer",minimum:1,description:"Max scheduler iterations (safety limit, default: 1000)"},timeout_ms:{type:"integer",minimum:0,description:"Timeout in ms (declared for drivers, not enforced by pure engine)"},refreshStrategy:{$ref:"#/definitions/refresh_strategy",description:"Default refresh strategy for all tasks (default: 'data-changed')"}},additionalProperties:false,if:{properties:{completion:{const:"goal-reached"}}},then:{required:["completion","goal"]}},task:{type:"object",required:["provides"],properties:{requires:{type:"array",items:{type:"string"},description:"Tokens this task needs to become eligible"},provides:{type:"array",items:{type:"string"},description:"Tokens this task produces on successful completion"},on:{type:"object",description:"Conditional provides based on handler result key",additionalProperties:{type:"array",items:{type:"string"}}},on_failure:{type:"array",items:{type:"string"},description:"Tokens to inject when this task fails"},method:{type:"string",description:"Task execution method (informational \u2014 driver concern)"},config:{type:"object",description:"Arbitrary task configuration (driver concern)"},priority:{type:"number",description:"Higher = preferred in conflict resolution"},estimatedDuration:{type:"number",minimum:0,description:"Estimated duration in ms (used by duration-first strategy)"},estimatedCost:{type:"number",minimum:0,description:"Estimated cost (used by cost-optimized strategy)"},estimatedResources:{type:"object",additionalProperties:{type:"number"},description:"Resource requirements (used by resource-aware strategy)"},retry:{$ref:"#/definitions/task_retry"},refreshStrategy:{$ref:"#/definitions/refresh_strategy",description:"Task-level refresh strategy (overrides settings default)"},refreshInterval:{type:"number",minimum:0,description:"Interval in seconds for time-based refresh strategy"},maxExecutions:{type:"integer",minimum:1,description:"Maximum number of times this task can execute"},circuit_breaker:{$ref:"#/definitions/task_circuit_breaker"},description:{type:"string",description:"Human-readable description"},inference:{$ref:"#/definitions/inference_hints"}},additionalProperties:false},task_retry:{type:"object",required:["max_attempts"],properties:{max_attempts:{type:"integer",minimum:1,description:"Maximum retry attempts"},delay_ms:{type:"integer",minimum:0,description:"Delay between retries in ms"},backoff_multiplier:{type:"number",minimum:1,description:"Backoff multiplier (e.g., 2 for exponential)"}},additionalProperties:false},refresh_strategy:{type:"string",enum:["data-changed","epoch-changed","time-based","manual","once"],description:"Strategy for determining when a completed task should re-run"},task_circuit_breaker:{type:"object",required:["max_executions","on_break"],properties:{max_executions:{type:"integer",minimum:1,description:"Max executions before breaker trips"},on_break:{type:"array",items:{type:"string"},minItems:1,description:"Tokens to inject when breaker trips"}},additionalProperties:false},inference_hints:{type:"object",description:"LLM inference hints \u2014 opt-in metadata for AI-assisted completion detection",properties:{criteria:{type:"string",description:"Human-readable completion criteria"},keywords:{type:"array",items:{type:"string"},description:"Keywords to help the LLM understand the domain"},suggestedChecks:{type:"array",items:{type:"string"},description:"Suggested checks for verification"},autoDetectable:{type:"boolean",description:"Whether the LLM should attempt to auto-detect completion (default: false)"}},additionalProperties:false}}};var zc=lr(Xr());var an=null;function gg(){if(an)return an;let t=new zc.default({allErrors:true});return zh__default.default(t),an=t.compile(Kc),an}function Jc(t){let e=gg();return e(t)?{ok:true,errors:[]}:{ok:false,errors:(e.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`)}}function To(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wc(t){return atob(t.replace(/-/g,"+").replace(/_/g,"/"))}var Eo=class{constructor(e){this.kv=e;}kv;stateKey(e){return `state_${To(e)}`}dataPrefix(e){return `data_${To(e)}_`}dataKey(e,r){return `${this.dataPrefix(e)}${To(r)}`}async saveRunState(e,r){this.kv.write(this.stateKey(e),r);}async loadRunState(e){let r=this.kv.read(this.stateKey(e));return r!=null&&typeof r=="object"?r:null}async deleteRunState(e){this.kv.delete(this.stateKey(e));for(let r of this.kv.listKeys(this.dataPrefix(e)))this.kv.delete(r);}async setData(e,r,n){this.kv.write(this.dataKey(e,r),n);}async getData(e,r){return this.kv.read(this.dataKey(e,r))}async getAllData(e){let r=this.dataPrefix(e),n={};for(let s of this.kv.listKeys(r))n[Wc(s.slice(r.length))]=this.kv.read(s);return n}async clearData(e){for(let r of this.kv.listKeys(this.dataPrefix(e)))this.kv.delete(r);}async listRuns(){return this.kv.listKeys("state_").map(e=>Wc(e.slice(6)))}};async function Yc(t,e){let{concurrency:r=5,processor:n,onItemComplete:s,onItemError:o,onProgress:a,signal:i}=e,c=t.length,u=new Array(c),l=Date.now(),d=0,m=0,p=0;function h(f){let g=d+m;return {completed:d,failed:m,active:f,pending:c-g-f,total:c,percent:c===0?100:Math.round(g/c*100),elapsedMs:Date.now()-l}}return c===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(f=>{let g=0;function k(){for(;g<r&&p<c;){if(i?.aborted){for(;p<c;){let v=p++;u[v]={item:t[v],index:v,status:"failed",error:new Error("Batch aborted"),durationMs:0},m++;}g===0&&d+m===c&&f({items:u,completed:d,failed:m,total:c,durationMs:Date.now()-l});break}let _=p++,y=t[_];g++;let S=Date.now();n(y,_).then(v=>{u[_]={item:y,index:_,status:"completed",result:v,durationMs:Date.now()-S},d++,s?.(y,v,_);}).catch(v=>{let R=v instanceof Error?v:new Error(String(v));u[_]={item:y,index:_,status:"failed",error:R,durationMs:Date.now()-S},m++,o?.(y,R,_);}).finally(()=>{g--,a?.(h(g)),d+m===c?f({items:u,completed:d,failed:m,total:c,durationMs:Date.now()-l}):k();});}}k();})}function yg(t,e){return t.replace(/\$\{([^}]+)\}/g,(r,n)=>{let s=e[n.trim()];return s!==void 0?String(s):r})}function Co(t,e){if(typeof t=="string")return yg(t,e);if(Array.isArray(t))return t.map(r=>Co(r,e));if(t!==null&&typeof t=="object"){let r={};for(let[n,s]of Object.entries(t))r[n]=Co(s,e);return r}return t}function Xc(t,e){return Co(t,e)}function vg(t,e){let r={...t};for(let[n,s]of Object.entries(e))n!=="config-template"&&(s!==null&&typeof s=="object"&&!Array.isArray(s)&&r[n]!==null&&typeof r[n]=="object"&&!Array.isArray(r[n])?r[n]={...r[n],...s}:r[n]=s);return r}function Qc(t){let e=t.configTemplates??t["config-templates"]??{},r="tasks"in t?"tasks":"steps"in t?"steps":null;if(!r)return t;let n=t[r];if(!n||typeof n!="object")return t;let s={};for(let[a,i]of Object.entries(n)){let c=i.config,u=c?.["config-template"];if(!u||!c){s[a]=i;continue}let l=e[u];if(!l){let{"config-template":d,...m}=c;s[a]={...i,config:m};continue}s[a]={...i,config:vg(l,c)};}let o={...t,[r]:s};return delete o.configTemplates,delete o["config-templates"],o}function cn(t,e){let r=e??`live-${Date.now()}`,n={};for(let o of Object.keys(t.tasks))n[o]=gn();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:t.settings.execution_mode??"eligibility-mode",conflictStrategy:t.settings.conflict_strategy??"alphabetical",completionStrategy:t.settings.completion}};return {config:t,state:s}}function un(t,e){let{config:r,state:n}=t;if("executionId"in e&&e.executionId&&e.executionId!==n.executionId)return t;switch(e.type){case "task-started":return {config:r,state:Xt(n,e.taskName,r)};case "task-completed":return {config:r,state:Qt(n,r,e.taskName,e.result,e.dataHash,e.data)};case "task-failed":return {config:r,state:Zt(n,r,e.taskName,e.error)};case "task-progress":return {config:r,state:er(n,e.taskName,e.message,e.progress)};case "task-restart":return {config:r,state:tr(n,e.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...e.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:_g(n,e.action)};case "task-upsert":return rr(t,e.taskName,e.taskConfig);case "task-removal":return nr(t,e.taskName);case "node-requires-add":return sr(t,e.nodeName,e.tokens);case "node-requires-remove":return or(t,e.nodeName,e.tokens);case "node-provides-add":return ar(t,e.nodeName,e.tokens);case "node-provides-remove":return ir(t,e.nodeName,e.tokens);default:return t}}function yt(t,e){return e.reduce((r,n)=>un(r,n),t)}function rr(t,e,r){let n=!!t.config.tasks[e];return {config:{...t.config,tasks:{...t.config.tasks,[e]:r}},state:{...t.state,tasks:{...t.state.tasks,[e]:n?t.state.tasks[e]:gn()},lastUpdated:new Date().toISOString()}}}function nr(t,e){if(!t.config.tasks[e])return t;let{[e]:r,...n}=t.config.tasks,{[e]:s,...o}=t.state.tasks;return {config:{...t.config,tasks:n},state:{...t.state,tasks:o,lastUpdated:new Date().toISOString()}}}function sr(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=O(n),o=r.filter(a=>!s.includes(a));return o.length===0?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,requires:[...s,...o]}}},state:t.state}}function or(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=O(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,requires:o}}},state:t.state}}function ar(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=E(n),o=r.filter(a=>!s.includes(a));return o.length===0?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,provides:[...s,...o]}}},state:t.state}}function ir(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=E(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,provides:o}}},state:t.state}}function dn(t,e){return un(t,{type:"inject-tokens",tokens:e,timestamp:new Date().toISOString()})}function ln(t,e){let r=new Set(e),n=t.state.availableOutputs.filter(s=>!r.has(s));return n.length===t.state.availableOutputs.length?t:{config:t.config,state:{...t.state,availableOutputs:n,lastUpdated:new Date().toISOString()}}}function pn(t,e){return !t.config.tasks[e]||!t.state.tasks[e]?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:gn()},lastUpdated:new Date().toISOString()}}}function fn(t,e){let r=t.state.tasks[e];return !r||r.status==="inactivated"?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:{...r,status:"inactivated",lastUpdated:new Date().toISOString()}},lastUpdated:new Date().toISOString()}}}function mn(t,e){let r=t.state.tasks[e];return !r||r.status!=="inactivated"?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:{...r,status:"not-started",lastUpdated:new Date().toISOString()}},lastUpdated:new Date().toISOString()}}}function Zc(t,e){let r=t.config.tasks[e];if(!r)return;let n=t.state.tasks[e]??gn();return {name:e,config:r,state:n}}function hn(t){return {version:1,config:t.config,state:t.state,snapshotAt:new Date().toISOString()}}function eu(t){if(!t||typeof t!="object")throw new Error("Invalid snapshot: expected an object");let e=t;if(!e.config||typeof e.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!e.state||typeof e.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=e.config,n=e.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function gn(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function _g(t,e){let r=new Date().toISOString();switch(e){case "stop":return {...t,status:"stopped",lastUpdated:r};case "pause":return {...t,status:"paused",lastUpdated:r};case "resume":return {...t,status:"running",lastUpdated:r};default:return t}}function cr(t){let{config:e,state:r}=t,n=G(e);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=kg(n),a=ue(e,r.tasks),i=new Set([...a,...r.availableOutputs]),c=[],u=[],l=[],d=[];for(let[p,h]of Object.entries(n)){let f=r.tasks[p],g=Je(h,e.settings),k=g!=="once";if(f?.status===P.RUNNING||X(f))continue;let _=gt(h);if(_!==void 0&&f&&f.executionCount>=_||h.circuit_breaker&&f&&f.executionCount>=h.circuit_breaker.max_executions||!k&&f?.status===P.COMPLETED)continue;if(k&&f?.status===P.COMPLETED){let w=O(h),T=false;switch(g){case "data-changed":{w.length>0&&w.some(F=>{for(let[U,W]of Object.entries(n))if(E(W).includes(F)){let z=r.tasks[U];if(!z)continue;let Sn=f.lastConsumedHashes?.[F];return z.lastDataHash==null?z.executionCount>f.lastEpoch:z.lastDataHash!==Sn}return false})||(T=true);break}case "epoch-changed":{w.length>0&&w.some(F=>{for(let[U,W]of Object.entries(n))if(E(W).includes(F)){let z=r.tasks[U];if(z&&z.executionCount>f.lastEpoch)return true}return false})||(T=true);break}case "time-based":{let J=h.refreshInterval??0;if(J<=0){T=true;break}let F=f.completedAt;if(!F){T=true;break}(Date.now()-Date.parse(F))/1e3<J&&(T=true);break}case "manual":T=true;break}if(T)continue}let y=O(h);if(y.length===0){c.push(p);continue}let S=[],v=[],R=[];for(let w of y){if(i.has(w))continue;let T=o[w]||[];T.length===0?S.push(w):T.every(F=>X(r.tasks[F]))?R.push({token:w,failedProducer:T[0]}):v.push(w);}S.length>0?l.push({taskName:p,missingTokens:S}):R.length>0?d.push({taskName:p,failedTokens:R.map(w=>w.token),failedProducers:[...new Set(R.map(w=>w.failedProducer))]}):v.length>0?u.push({taskName:p,waitingOn:v}):c.push(p);}let m={};if(c.length>1){let p=qe(c,n);for(let[h,f]of Object.entries(p))f.length>1&&(m[h]=f);}return {eligible:c,pending:u,unresolved:l,blocked:d,conflicts:m}}function kg(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function tu(t){let{config:e,state:r}=t,n=G(e),s=Object.keys(n),o=0,a=0,i=0,c=0,u=0,l=0;for(let _ of s){let y=r.tasks[_];if(!y||y.status===P.NOT_STARTED)u++;else switch(y.status){case P.RUNNING:o++;break;case P.COMPLETED:a++;break;case P.FAILED:i++;break;case "inactivated":l++;break;default:c++;}}let d={};for(let[_,y]of Object.entries(n)){for(let S of E(y))d[S]||(d[S]=[]),d[S].push(_);if(y.on)for(let S of Object.values(y.on))for(let v of S)d[v]||(d[v]=[]),d[v].includes(_)||d[v].push(_);if(y.on_failure)for(let S of y.on_failure)d[S]||(d[S]=[]),d[S].includes(_)||d[S].push(_);}let m=new Set,p=0,h=0;for(let[_,y]of Object.entries(n)){let S=r.tasks[_];if(S?.status===P.COMPLETED||S?.status===P.RUNNING)continue;let v=false,R=false;for(let w of O(y)){let T=d[w]||[];T.length===0?(m.add(w),v=true):T.every(F=>{let U=r.tasks[F];return U?.status===P.FAILED||U?.status==="inactivated"})&&(R=true);}v&&p++,R&&!v&&h++;}let f=[];for(let[_,y]of Object.entries(d))y.length>1&&f.push(_);let g=bg(n,d),k=Sg(s,g);return {totalNodes:s.length,running:o,completed:a,failed:i,waiting:c,notStarted:u,disabled:l,unresolvedCount:p,blockedCount:h,openDependencies:[...m],cycles:k,conflictTokens:f}}function bg(t,e){let r={};for(let[n,s]of Object.entries(t)){r[n]=new Set;for(let o of O(s))for(let a of e[o]||[])a!==n&&r[n].add(a);}return r}function Sg(t,e){let o={},a={},i=[];for(let u of t)o[u]=0,a[u]=null;function c(u){o[u]=1;for(let l of e[u]||[])if(o[l]===1){let d=[l],m=u;for(;m!==l;)d.push(m),m=a[m];d.push(l),d.reverse(),i.push(d);}else o[l]===0&&(a[l]=u,c(l));o[u]=2;}for(let u of t)o[u]===0&&c(u);return i}function ru(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function xo(t){let{config:e,state:r}=t,n=G(e),s=ru(n),o=new Set([...r.availableOutputs]);for(let[d,m]of Object.entries(r.tasks))if(m.status==="completed"){let p=n[d];p&&E(p).forEach(h=>o.add(h));}let a=new Set;for(let d of Object.values(n))for(let m of O(d))a.add(m);let i=new Set,c=new Set;for(let d of a){if(o.has(d))continue;(s[d]||[]).length===0&&i.add(d);}let u=true;for(;u;){u=false;for(let[d,m]of Object.entries(n)){if(c.has(d))continue;let p=r.tasks[d];if(p?.status==="completed")continue;let h=X(p),g=O(m).some(k=>i.has(k));(h||g)&&(c.has(d)||(c.add(d),u=true));}for(let d of a){if(i.has(d)||o.has(d))continue;let m=s[d]||[],p=m.length>0&&m.every(h=>c.has(h)||X(r.tasks[h]));(m.length===0||p)&&(i.has(d)||(i.add(d),u=true));}}let l=[];for(let d of i){let m=s[d]||[],p;m.length===0?p="no-producer":p=m.every(f=>X(r.tasks[f]))?"all-producers-failed":"transitive",l.push({token:d,reason:p,producers:m});}return {tokens:l}}function nu(t){let{config:e,state:r}=t,n=G(e),{tokens:s}=xo(t),o=new Set(s.map(i=>i.token)),a=[];for(let[i,c]of Object.entries(n)){let u=r.tasks[i];if(u?.status==="completed")continue;let d=O(c).filter(m=>o.has(m));d.length>0?a.push({nodeName:i,missingTokens:d}):X(u)&&a.push({nodeName:i,missingTokens:[]});}return {nodes:a}}function su(t,e){let r=G(t.config);if(!r[e])return {nodeName:e,nodes:[],tokens:[]};let n=ru(r),s=new Set,o=new Set,a=new Map;function i(u){let l=r[u];if(l)for(let d of O(l)){let m=n[d]||[];for(let p of m)p!==e&&(o.add(d),a.has(p)||a.set(p,new Set),a.get(p).add(d),s.has(p)||(s.add(p),i(p)));}}i(e);let c=[...a.entries()].map(([u,l])=>({nodeName:u,providesTokens:[...l]}));return {nodeName:e,nodes:c,tokens:[...o]}}function ou(t,e){let r=G(t.config);if(!r[e])return {nodeName:e,nodes:[],tokens:[]};let n={};for(let[u,l]of Object.entries(r))for(let d of O(l))n[d]||(n[d]=[]),n[d].push(u);let s=new Set,o=new Set,a=new Map;function i(u){let l=r[u];if(l)for(let d of E(l)){let m=n[d]||[];for(let p of m)p!==e&&(o.add(d),a.has(p)||a.set(p,new Set),a.get(p).add(d),s.has(p)||(s.add(p),i(p)));}}i(e);let c=[...a.entries()].map(([u,l])=>({nodeName:u,requiresTokens:[...l]}));return {nodeName:e,nodes:c,tokens:[...o]}}var We=class{buffer=[];append(e){this.buffer.push(e);}drain(){let e=this.buffer;return this.buffer=[],e}get size(){return this.buffer.length}};function yn(t){let e=jo(t);return wg(e)}function jo(t){if(t==null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return "["+t.map(jo).join(",")+"]";let e=t;return "{"+Object.keys(e).sort().map(n=>JSON.stringify(n)+":"+jo(e[n])).join(",")+"}"}function wg(t){let e=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<t.length;s++)e^=BigInt(t.charCodeAt(s)),e=e*r&n;return e.toString(16).padStart(16,"0")}function $g(t){if(typeof Buffer<"u")return Buffer.from(t,"utf8").toString("base64url");if(typeof btoa=="function"){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Rg(t){if(typeof Buffer<"u")return Buffer.from(t,"base64url").toString("utf8");if(typeof atob=="function"){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e+"=".repeat((4-e.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function au(t){let e=JSON.stringify({t,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return $g(e)}function Tg(t){try{let e=JSON.parse(Rg(t));return typeof e?.t=="string"?{taskName:e.t}:null}catch{return null}}function vt(t,e,r){let{handlers:n,onDrain:s}=e,o=new We,a="state"in t&&"config"in t?t:cn(t,r),i=false,c=new Set,u=new Map(Object.entries(n)),l=new We,d=false,m=false;function p(){if(!i){if(d){m=true;return}d=true;try{do m=!1,h();while(m)}finally{d=false;}}}function h(){let _=l.drain(),y=o.drain(),S=[..._,...y];S.length>0&&(a=yt(a,S));let v=cr(a);S.length>0&&s?.(S,a,v);for(let R of v.eligible)k(R);for(let R of S)if(R.type==="task-progress"){let{taskName:w,update:T}=R;if(!a.config.tasks[w])continue;let F=a.state.tasks[w];if(!F||F.status!=="running")continue;let U=au(w),W=g(w,U,T).catch(z=>{i||(l.append({type:"task-failed",taskName:w,error:z.message??String(z),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(W);});c.add(W);}}function f(_){let S=a.config.tasks[_].requires??[],v=new Map;for(let[w,T]of Object.entries(a.config.tasks))for(let J of T.provides??[])v.set(J,w);let R={};for(let w of S){let T=v.get(w);T?R[w]=a.state.tasks[T]?.data:R[w]=void 0;}return R}async function g(_,y,S){let v=a.config.tasks[_],R=v.taskHandlers??[],w=f(_);for(let T of R){let J=u.get(T);if(!J)throw new Error(`Handler '${T}' not found in registry (task '${_}')`);let F={nodeId:_,state:w,taskState:a.state.tasks[_],config:v,callbackToken:y,update:S};if(await J(F)==="task-initiate-failure")throw new Error(`Handler '${T}' returned task-initiate-failure (task '${_}')`)}}function k(_){let S=a.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),p();let v=au(_),R=g(_,v).catch(w=>{i||(l.append({type:"task-failed",taskName:_,error:w.message??String(w),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(R);});c.add(R);}return {push(_){i||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:yn(_.data)}),o.append(_),p());},pushAll(_){if(!i){for(let y of _)y.type==="task-completed"&&y.data&&!y.dataHash?o.append({...y,dataHash:yn(y.data)}):o.append(y);p();}},resolveCallback(_,y,S){if(i)return;let v=Tg(_);if(!v)return;let{taskName:R}=v;if(a.config.tasks[R]){if(S&&S.length>0)o.append({type:"task-failed",taskName:R,error:S.join("; "),timestamp:new Date().toISOString()});else {let w=y&&Object.keys(y).length>0?yn(y):void 0;o.append({type:"task-completed",taskName:R,data:y,dataHash:w,timestamp:new Date().toISOString()});}p();}},addNode(_,y){i||(o.append({type:"task-upsert",taskName:_,taskConfig:y,timestamp:new Date().toISOString()}),p());},removeNode(_){i||(o.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),p());},addRequires(_,y){i||(o.append({type:"node-requires-add",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},removeRequires(_,y){i||(o.append({type:"node-requires-remove",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},addProvides(_,y){i||(o.append({type:"node-provides-add",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},removeProvides(_,y){i||(o.append({type:"node-provides-remove",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},registerHandler(_,y){u.set(_,y);},unregisterHandler(_){u.delete(_);},retrigger(_){i||a.config.tasks[_]&&(o.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),p());},retriggerAll(_){if(!i){for(let y of _)a.config.tasks[y]&&o.append({type:"task-restart",taskName:y,timestamp:new Date().toISOString()});p();}},snapshot(){return hn(a)},getState(){return a},getSchedule(){return cr(a)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),i=true;}}}function Po(t){let e=[],{config:r,state:n}=t,s=G(r),o=Object.keys(s);for(let u of o)n.tasks[u]||e.push({severity:"error",code:"MISSING_STATE",message:`Task "${u}" exists in config but has no state entry`,tasks:[u]});for(let u of Object.keys(n.tasks))s[u]||e.push({severity:"warning",code:"ORPHAN_STATE",message:`State entry "${u}" has no corresponding task config`,tasks:[u]});for(let u of o){let l=n.tasks[u];l&&(l.status===P.RUNNING&&!l.startedAt&&e.push({severity:"warning",code:"RUNNING_WITHOUT_START",message:`Task "${u}" is running but has no startedAt timestamp`,tasks:[u]}),l.status===P.COMPLETED&&!l.completedAt&&e.push({severity:"warning",code:"COMPLETED_WITHOUT_TIMESTAMP",message:`Task "${u}" is completed but has no completedAt timestamp`,tasks:[u]}),l.status===P.FAILED&&(l.failedAt||e.push({severity:"warning",code:"FAILED_WITHOUT_INFO",message:`Task "${u}" is failed but has no failedAt timestamp`,tasks:[u]}),l.error||e.push({severity:"info",code:"FAILED_WITHOUT_INFO",message:`Task "${u}" is failed but has no error message`,tasks:[u]})));}let a=new Set;for(let u of o)if(n.tasks[u]?.status===P.COMPLETED)for(let d of E(s[u]))a.add(d);let i=new Set(n.availableOutputs),c=new Set;for(let u of Object.values(s)){for(let l of E(u))c.add(l);if(u.on)for(let l of Object.values(u.on))for(let d of l)c.add(d);if(u.on_failure)for(let l of u.on_failure)c.add(l);}for(let u of i)!a.has(u)&&!c.has(u)&&e.push({severity:"info",code:"INJECTED_TOKEN",message:`Token "${u}" is available but no task in the graph can produce it (likely injected)`,tokens:[u]});for(let u of a)i.has(u)||e.push({severity:"warning",code:"MISSING_OUTPUT",message:`Token "${u}" should be available (its producer completed) but is not in availableOutputs`,tokens:[u]});for(let u of o){let l=n.tasks[u];if(!l)continue;l.executionCount<0&&e.push({severity:"error",code:"INVALID_EXECUTION_COUNT",message:`Task "${u}" has negative execution count: ${l.executionCount}`,tasks:[u]});let d=s[u].maxExecutions;d!==void 0&&l.executionCount>d&&e.push({severity:"error",code:"EXCEEDED_MAX_EXECUTIONS",message:`Task "${u}" executed ${l.executionCount} times, exceeding maxExecutions of ${d}`,tasks:[u]});}return cu(e)}function iu(t){let{graph:e,handlers:r}=t,n=e.getState(),s=[],o=G(n.config),a=Object.keys(o),i=new Set(Object.keys(r)),c=new Set;for(let l of a){let d=o[l].taskHandlers;if(d)for(let m of d)c.add(m);}for(let l of a){let d=o[l].taskHandlers;if(d)for(let m of d)r[m]||s.push({severity:"error",code:"MISSING_HANDLER",message:`Task "${l}" references handler "${m}" but it is not in the registry`,tasks:[l]});}for(let l of i)c.has(l)||s.push({severity:"warning",code:"ORPHAN_HANDLER",message:`Handler "${l}" is registered but not referenced by any task's taskHandlers`,tasks:[l]});let u=Po(n);return s.push(...u.issues),cu(s)}function cu(t){let e=t.filter(n=>n.severity==="error"),r=t.filter(n=>n.severity==="warning");return {valid:e.length===0,issues:t,errors:e,warnings:r}}function uu(t,e){let r=t;for(let n of e)r=Eg(r,n);return r}function Eg(t,e){switch(e.type){case "add-node":return rr(t,e.name,e.config);case "remove-node":return nr(t,e.name);case "add-requires":return sr(t,e.taskName,e.tokens);case "remove-requires":return or(t,e.taskName,e.tokens);case "add-provides":return ar(t,e.taskName,e.tokens);case "remove-provides":return ir(t,e.taskName,e.tokens);case "inject-tokens":return dn(t,e.tokens);case "drain-tokens":return ln(t,e.tokens);case "reset-node":return pn(t,e.name);case "disable-node":return fn(t,e.name);case "enable-node":return mn(t,e.name);case "apply-events":return yt(t,e.events);default:throw new Error(`Unknown mutation type: ${e.type}`)}}function du(t,e){return async r=>{let{callbackToken:n}=r;return Promise.resolve(t(r)).then(s=>e()(n,s)).catch(s=>e()(n,{},[s instanceof Error?s.message:String(s)])),"task-initiated"}}function lu(t,e){return async r=>{let{callbackToken:n}=r;return Promise.resolve(t(r)).then(()=>e()(n,{})).catch(()=>e()(n,{})),"task-initiated"}}function pu(t){let{command:e,cwd:r,env:n,timeoutMs:s=3e4,exitCodeMap:o,captureOutput:a=false,getResolve:i}=t;return async c=>{let{callbackToken:u,nodeId:l}=c,d=e.replace(/\$\{taskName\}/g,l);return child_process.exec(d,{cwd:r,env:n?{...process.env,...n}:void 0,timeout:s,maxBuffer:10*1024*1024},(m,p,h)=>{let f=m?.code??(m?1:0);if(f!==0&&!o?.[f]){i()(u,{},[`Command exited with code ${f}: ${h||m?.message}`]);return}let g={};a&&(g.stdout=p,g.stderr=h,g.exitCode=f),i()(u,g);}),"task-initiated"}}function Oo(t){let{command:e,args:r=[],cwd:n,env:s,timeoutMs:o=3e4,exitCodeMap:a,captureOutput:i=false,getResolve:c}=t;return async u=>{let{callbackToken:l,nodeId:d}=u,m=e.replace(/\$\{taskName\}/g,d),p=r.map(h=>h.replace(/\$\{taskName\}/g,d));return child_process.execFile(m,p,{cwd:n,env:s?{...process.env,...s}:void 0,timeout:o,maxBuffer:10*1024*1024,encoding:"utf8",windowsHide:true},(h,f,g)=>{let k=h?.code??(h?1:0);if(k!==0&&!a?.[k]){c()(l,{},[`Process exited with code ${k}: ${g||h?.message}`]);return}let _={};i&&(_.stdout=f,_.stderr=g,_.exitCode=k),c()(l,_);}),"task-initiated"}}function jg(t){return t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".ts")?"node":t.endsWith(".py")?"python3":(t.endsWith(".sh"),"bash")}function fu(t){let{scriptPath:e,runtime:r,args:n=[],cwd:s,timeoutMs:o=6e4,captureOutput:a=false,getResolve:i}=t,c=r??jg(e),u=c==="node"?process.execPath:c;return Oo({command:u,args:[e,"${taskName}",...n],cwd:s,timeoutMs:o,captureOutput:a,getResolve:i})}function mu(t){let{url:e,method:r="POST",headers:n={},timeoutMs:s=3e4,failOnNon2xx:o=true,getResolve:a}=t;return async i=>{let{callbackToken:c,nodeId:u,config:l}=i,d=e.replace(/\$\{taskName\}/g,u),m=JSON.stringify({taskName:u,callbackToken:c,config:l}),p=new AbortController,h=setTimeout(()=>p.abort(),s);return fetch(d,{method:r,headers:{"Content-Type":"application/json",...n},body:m,signal:p.signal}).then(async f=>{if(clearTimeout(h),o&&!f.ok){let k=await f.text().catch(()=>"");a()(c,{},[`HTTP ${f.status}: ${k}`]);return}let g=await f.json().catch(()=>({}));a()(c,g);}).catch(f=>{clearTimeout(h),a()(c,{},[f instanceof Error?f.message:String(f)]);}),"task-initiated"}}function hu(t,e){return async r=>(t()(r.callbackToken,e??{}),"task-initiated")}var gu={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var _u=lr(Xr());var Ng=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),qg=Ng("./jsonata-sync.cjs"),vn=null;var yu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Ig=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Mg(t){let e=new Set,r;for(yu.lastIndex=0;(r=yu.exec(t))!==null;)e.add(r[1]);return e}function ku(t){let e=Ig.exec(t);return e?e[1]:null}function vu(t,e,r,n){try{qg(t);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${e}: invalid JSONata expression (${a})`);return}let s=Mg(t);for(let o of s)r.has(o)||n.push(`${e}: disallowed namespace "${o}" in expression`);}function Ao(t,e,r){if(Array.isArray(t)){t.forEach((s,o)=>{Ao(s,`${e}/${o}`,r);});return}if(typeof t=="string"){let s=ku(t);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${e}: disallowed namespace "${s}" in view reference`);return}if(!t||typeof t!="object")return;let n=t;for(let[s,o]of Object.entries(n))Ao(o,`${e}/${s}`,r);}function Dg(){if(vn)return vn;let t=new _u.default({allErrors:true});return zh__default.default(t),vn=t.compile(gu),vn}function No(t){let e=Dg(),r=e(t),n=(e.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(t&&typeof t=="object"&&!Array.isArray(t)){let s=t.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,c)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let u=i;typeof u.bindTo=="string"&&u.bindTo&&(o.has(u.bindTo)&&n.push(`/source_defs/${c}/bindTo: bindTo "${u.bindTo}" must be unique across all source_defs`),o.add(u.bindTo)),typeof u.outputFile=="string"&&u.outputFile&&(a.has(u.outputFile)&&n.push(`/source_defs/${c}/outputFile: outputFile "${u.outputFile}" must be unique across all source_defs`),a.add(u.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function qo(t){let e=[];if(!t||typeof t!="object"||Array.isArray(t))return {ok:true,errors:[]};let r=t,n=r.compute;Array.isArray(n)&&n.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.expr;typeof d!="string"||d.trim().length===0||vu(d,`/compute/${l}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),e);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.ref;if(typeof d!="string"||d.trim().length===0)return;let m=ku(d);m===null?e.push(`/provides/${l}/ref: path "${d}" must start with a valid namespace (${[...s].join(", ")})`):s.has(m)||e.push(`/provides/${l}/ref: disallowed namespace "${m}" in path "${d}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Ao(a,"/view",e);let i=new Set(["card_data","requires"]),c=r.source_defs;return Array.isArray(c)&&c.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.projections;if(!(!d||typeof d!="object"||Array.isArray(d)))for(let[m,p]of Object.entries(d))typeof p!="string"||p.trim().length===0||vu(p,`/source_defs/${l}/projections/${m}`,i,e);}),{ok:e.length===0,errors:e}}function bu(t){return Io(t)}function Io(t){let e=No(t);if(!e.ok)return e;let r=qo(t);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}var Lg=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),_n=Lg("./jsonata-sync.cjs"),$u=_n;function Su(t,e){if(!e||!t)return;let r=e.split("."),n=t;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function Ru(t,e,r){let n=e.split("."),s=t;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Fg(t,e){if(!t?.compute?.length)return t;t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=e?.sourcesData??{};let r=t.requires??{},n={card_data:t.card_data,requires:r,expects_data:r,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values};for(let s of t.compute)try{let o=await _n(s.expr).evaluate(n);Ru(t.computed_values,s.bindTo,o),n.computed_values=t.computed_values;}catch{}return t}function Hg(t,e){if(!t?.compute?.length)return {ok:true,node:t};t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=e?.sourcesData??{};let r=t.requires??{},n={card_data:t.card_data,requires:r,expects_data:r,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values},s=[];for(let o of t.compute)try{let a=$u(o.expr).evaluate(n);Ru(t.computed_values,o.bindTo,a),n.computed_values=t.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:t,errors:s}:{ok:true,node:t}}async function Ug(t,e,r){let n={...r??{},card_data:e.card_data??{},requires:e.requires??{},fetched_sources:e._sourcesData??{},computed_values:e.computed_values??{}};return _n(t).evaluate(n)}function Vg(t,e){return e.startsWith("fetched_sources.")?Su(t._sourcesData??{},e.slice(16)):Su(t,e)}var wu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),Bg=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function Kg(t){let e=[];if(!t||typeof t!="object"||Array.isArray(t))return {ok:false,errors:["Node must be a non-null object"]};let r=t;(typeof r.id!="string"||!r.id)&&e.push("id: required, must be a non-empty string");for(let n of Object.keys(r))Bg.has(n)||e.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&e.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))e.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&e.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&e.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&e.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))e.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&e.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&e.push(`provides[${s}]: missing required "ref" string`);}}):e.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))e.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&e.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&e.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):e.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))e.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))e.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?e.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&e.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?e.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&e.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&e.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))e.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?e.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){e.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?e.push(`view.elements[${o}].kind: required, must be a string`):wu.has(s.kind)||e.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...wu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&e.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&e.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&e.push("view.features: must be an object");}return {ok:e.length===0,errors:e}}async function zg(t,e){if(!t||t.length===0)return [];let r={card_data:e.card_data??{},requires:e.requires??{}};return Promise.all(t.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await _n(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function Jg(t,e){if(!t||t.length===0)return [];let r={card_data:e.card_data??{},requires:e.requires??{}};return t.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=$u(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var Ye={run:Fg,runSync:Hg,eval:Ug,resolve:Vg,validate:Kg,enrichSources:zg,enrichSourcesSync:Jg};function Tu(t,e={}){let r,n={},s;if(!Array.isArray(t)&&"nodes"in t){let v=t;r=v.nodes,s=v.id,n=v.settings??{};}else r=t;let{sourceHandlers:o={},defaultSourceHandler:a,cardHandlers:i={},reactiveOptions:c={},graphSettings:u={},executionId:l}=e,d=new Map;for(let v of r){if(d.has(v.id))throw new Error(`Duplicate card ID: "${v.id}"`);d.set(v.id,v);}let m=e.sharedState??new Map,p={},h=new Set,f=new Map;for(let v of r)for(let R of v.provides??[{bindTo:v.id,ref:"card_data"}])h.add(R.bindTo),f.set(R.bindTo,v.id);for(let v of r){let R=v.requires??[];for(let w of R)if(!h.has(w))throw new Error(`Card "${v.id}" requires "${w}" but no card provides that token`);p[v.id]={requires:R.length>0?R:void 0,provides:(v.provides??[{bindTo:v.id,ref:"card_data"}]).map(w=>w.bindTo),taskHandlers:[v.id],description:v.meta?.title??v.id};}let g={id:s??`live-cards-${Date.now()}`,settings:{completion:"manual",execution_mode:"eligibility-mode",...n,...u},tasks:p},k={},_=null,y=()=>(v,R,w)=>{_.resolveCallback(v,R,w);};for(let v of r)v.source_defs&&v.source_defs.length>0?k[v.id]=Wg(v,o,a,m,y):k[v.id]=Yg(v,i,m,d,f,y);let S=vt(g,{...c,handlers:k},l);return _=S,{graph:S,config:g,handlers:k,cards:d,sharedState:m}}function Wg(t,e,r,n,s){if(e[t.id]){let o=e[t.id];return async a=>o(a)}if(r){let o=r(t);return async a=>o(a)}return async o=>{let a={...t.card_data};return n.set(t.id,a),s()(o.callbackToken,a),"task-initiated"}}function Yg(t,e,r,n,s,o){if(e[t.id]){let a=e[t.id];return async i=>a(i)}return async a=>{let i={},c=t.requires??[];for(let m of c){let p=s.get(m)??m,h=r.get(p);h&&(i[m]=h[m]??h);}let u={id:t.id,card_data:{...t.card_data},requires:i,compute:t.compute};await Ye.run(u);let l;if(t.provides&&t.provides.length>0){l={};for(let{bindTo:m,ref:p}of t.provides)l[m]=Ye.resolve(u,p);}else l={...u.card_data,...u.computed_values};let d={...u.card_data,...u.computed_values};return r.set(t.id,d),o()(a.callbackToken,l),"task-initiated"}}function Ie(t){return JSON.parse(JSON.stringify(t))}function Mo(t){let e=t.provides&&t.provides.length>0?t.provides.map(r=>r.bindTo):[t.id];return {requires:t.requires&&t.requires.length>0?[...t.requires]:void 0,provides:e,taskHandlers:[t.id],description:t.meta?.title??t.id}}function Xg(t){let e=new Map;for(let[r,n]of t.entries()){let s=n.provides&&n.provides.length>0?n.provides:[{bindTo:r,ref:"card_data"}];for(let o of s)e.set(o.bindTo,r);}return e}function Do(t,e){let r=Xg(t),n=t.get(e);if(n){for(let s of n.requires??[])if(!r.has(s))throw new Error(`Card "${e}" requires token "${s}" but no card provides it`)}}function Qg(t,e={}){let r=Array.isArray(t)?{}:{id:t.id,title:t.title,mode:t.mode,positions:t.positions,settings:t.settings},n=Array.isArray(t)?t:t.nodes,s=new Map;for(let y of n){if(s.has(y.id))throw new Error(`Duplicate card ID: "${y.id}"`);s.set(y.id,Ie(y));}let o=new Set,a=e.taskExecutor,i=e.sourceAdapters??{},c=e.defaultSourceAdapter,u=null,l=(y,S)=>{let v={events:y,graph:S,nodes:k()};for(let R of o)R(v);},d=y=>async S=>{let v=s.get(y);if(!v)return "task-initiate-failure";let R={};for(let U of v.requires??[]){let W=S.state[U];if(!W||typeof W!="object")continue;let z=W.provides_data;!z||typeof z!="object"||Object.prototype.hasOwnProperty.call(z,U)&&(R[U]=z[U]);}let w={};if(v.source_defs&&v.source_defs.length>0){let U=i[y]??c,W=a?await a({card:v,input:S}):U?await U({card:v,input:S}):void 0;if(W&&typeof W=="object")for(let z of v.source_defs)Object.prototype.hasOwnProperty.call(W,z.bindTo)?w[z.bindTo]=W[z.bindTo]:v.source_defs.length===1&&(w[z.bindTo]=W);}let T={id:v.id,card_data:Ie(v.card_data??{}),requires:R,source_defs:v.source_defs,compute:v.compute};T._sourcesData=w,T.compute&&T.compute.length>0&&await Ye.run(T,{sourcesData:w});let J={};if(v.provides&&v.provides.length>0)for(let{bindTo:U,ref:W}of v.provides)J[U]=Ye.resolve(T,W);else J[v.id]={...T.card_data??{},...T.computed_values??{},...T._sourcesData??{}};let F={provides_data:J,card_data:T.card_data??{},computed_values:T.computed_values??{},fetched_sources:w,requires:R};return u?.resolveCallback(S.callbackToken,F),"task-initiated"},m={},p={};for(let[y,S]of s.entries())Do(s,y),m[y]=Mo(S),p[y]=d(y);let h={id:r.id??`browser-board-${Date.now()}`,settings:{completion:"manual",execution_mode:"eligibility-mode",...r.settings??{},...e.graphSettings??{}},tasks:m},f=e.reactiveOptions?.onDrain,g=vt(h,{...e.reactiveOptions??{},handlers:p,onDrain:(y,S,v)=>{f?.(y,S,v),l(y,S);}},e.executionId);u=g;function k(){let y=g.getState(),S=[];for(let[v,R]of s.entries()){let w=y.state.tasks[v]?.data,T=y.state.tasks[v],J={...R.card_data??{},...w&&typeof w.card_data=="object"?w.card_data:{}},F=T?.status==="running"?"loading":T?.status,U={...J,...F?{status:F}:{},...T?.lastUpdated?{lastRun:T.lastUpdated}:{},...T?.status==="failed"&&T.error?{error:T.error}:{}};S.push({id:v,card:Ie(R),card_data:U,requires:w&&typeof w.requires=="object"?Ie(w.requires):{},computed_values:w&&typeof w.computed_values=="object"?Ie(w.computed_values):{},runtime_state:T?Ie(T):{}});}return S}return {getGraph:()=>g,getState:()=>g.getState(),getSchedule:()=>g.getSchedule(),getNodes:()=>k(),getBoard:()=>({...r,nodes:k()}),subscribe(y){return o.add(y),y({events:[],graph:g.getState(),nodes:k()}),()=>o.delete(y)},addCard(y){if(s.has(y.id))throw new Error(`Card "${y.id}" already exists`);s.set(y.id,Ie(y)),Do(s,y.id),g.registerHandler(y.id,d(y.id)),g.addNode(y.id,Mo(y));},upsertCard(y){s.set(y.id,Ie(y)),Do(s,y.id),g.registerHandler(y.id,d(y.id)),g.addNode(y.id,Mo(y));},removeCard(y){s.delete(y),g.unregisterHandler(y),g.removeNode(y);},patchCardState(y,S){let v=s.get(y);if(!v)throw new Error(`Card "${y}" not found`);v.card_data={...v.card_data??{},...S},g.retrigger(y);},retrigger(y){g.retrigger(y);},retriggerAll(){g.retriggerAll(Array.from(s.keys()));},push(y){g.push(y);},pushAll(y){g.pushAll(y);},dispose(){o.clear(),g.dispose();}}}var Eu={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://yaml-flow.dev/schema/board-status.schema.json",title:"Board Status Object",type:"object",additionalProperties:false,required:["schema_version","meta","summary","cards"],properties:{schema_version:{type:"string",const:"v1"},meta:{type:"object",additionalProperties:false,required:["board"],properties:{board:{type:"object",additionalProperties:false,required:["path"],properties:{path:{type:"string"}}}}},summary:{type:"object",additionalProperties:false,required:["card_count","completed","eligible","pending","blocked","unresolved"],properties:{card_count:{type:"integer",minimum:0},completed:{type:"integer",minimum:0},eligible:{type:"integer",minimum:0},pending:{type:"integer",minimum:0},blocked:{type:"integer",minimum:0},unresolved:{type:"integer",minimum:0},failed:{type:"integer",minimum:0},in_progress:{type:"integer",minimum:0},orphan_cards:{type:"integer",minimum:0},topology:{type:"object",additionalProperties:false,required:["edge_count","max_fan_out_card","max_fan_out"],properties:{edge_count:{type:"integer",minimum:0},max_fan_out_card:{type:["string","null"]},max_fan_out:{type:"integer",minimum:0}}}}},cards:{type:"array",items:{type:"object",additionalProperties:false,required:["name","status","requires","requires_satisfied","requires_missing","provides_declared","provides_runtime","blocked_by","unblocks","runtime"],properties:{name:{type:"string"},status:{type:"string"},error:{type:"object",additionalProperties:false,required:["message"],properties:{message:{type:"string"},code:{type:"string"},at:{type:["string","null"]},source:{type:"string"}}},requires:{type:"array",items:{type:"string"}},requires_satisfied:{type:"array",items:{type:"string"}},requires_missing:{type:"array",items:{type:"string"}},provides_declared:{type:"array",items:{type:"string"}},provides_runtime:{type:"array",items:{type:"string"}},blocked_by:{type:"array",items:{type:"string"}},unblocks:{type:"array",items:{type:"string"}},runtime:{type:"object",additionalProperties:false,required:["attempt_count","restart_count","in_progress_since","last_transition_at","last_completed_at","last_restarted_at","status_age_ms"],properties:{attempt_count:{type:"integer",minimum:0},restart_count:{type:"integer",minimum:0},in_progress_since:{type:["string","null"]},last_transition_at:{type:["string","null"]},last_completed_at:{type:["string","null"]},last_restarted_at:{type:["string","null"]},status_age_ms:{type:["integer","null"],minimum:0}}}}}}}};var Cu={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://yaml-flow.dev/schema/card-runtime.schema.json",title:"Card Runtime Computed Artifact",description:"Published per-card runtime artifact written to runtime-out/cards/<card-id>.computed.json. Contains only values produced by the compute step.",type:"object",required:["schema_version","card_id","computed_values"],additionalProperties:false,properties:{schema_version:{type:"string",const:"v1",description:"Artifact schema version."},card_id:{type:"string",description:"The ID of the card this artifact belongs to."},computed_values:{type:"object",description:"Key/value map of outputs produced by the card's JSONata compute steps.",additionalProperties:true}}};var od=lr(sd());var kn=null,bn=null;function ad(){let t=new od.default({allErrors:true,strict:false});return zh__default.default(t),t}function id(t){return {ok:false,errors:(t.errors??[]).map(r=>`${r.instancePath||"/"}: ${r.message??"unknown error"}`)}}function mv(){return kn||(kn=ad().compile(Eu),kn)}function hv(){return bn||(bn=ad().compile(Cu),bn)}function cd(t){let e=mv();return e(t)?{ok:true,errors:[]}:id(e)}function ud(t){let e=hv();return e(t)?{ok:true,errors:[]}:id(e)}
|
|
23
|
+
`)}return String(t)}function lg(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function pg(t,e){let r={};for(let[n,s]of Object.entries(t)){r[n]=new Set;for(let o of O(s))for(let a of e[o]||[])a!==n&&r[n].add(a);}return r}function fg(t,e){let o={},a={},i=[];for(let u of t)o[u]=0,a[u]=null;function c(u){o[u]=1;for(let l of e[u]||[])if(o[l]===1){let d=[l],m=u;for(;m!==l;)d.push(m),m=a[m];d.push(l),d.reverse(),i.push(d);}else o[l]===0&&(a[l]=u,c(l));o[u]=2;}for(let u of t)o[u]===0&&c(u);return i}function Bc(t){let e=[],r=G(t),n=Object.keys(r);if(n.length===0)return e.push({severity:"error",code:"EMPTY_GRAPH",message:"Graph has no tasks"}),Vc(e);let s=lg(r),o=pg(r,s);for(let[c,u]of Object.entries(r))for(let l of O(u))s[l]||e.push({severity:"error",code:"DANGLING_REQUIRES",message:`Task "${c}" requires token "${l}" but no task produces it`,tasks:[c],tokens:[l]});let a=fg(n,o);for(let c of a)e.push({severity:"error",code:"CIRCULAR_DEPENDENCY",message:`Circular dependency: ${c.join(" \u2192 ")}`,tasks:c.filter((u,l)=>l<c.length-1)});for(let[c,u]of Object.entries(r)){let l=O(u),d=E(u),m=l.filter(p=>d.includes(p));m.length>0&&e.push({severity:"error",code:"SELF_DEPENDENCY",message:`Task "${c}" requires tokens it provides itself: [${m.join(", ")}]`,tasks:[c],tokens:m});}for(let[c,u]of Object.entries(s))u.length>1&&e.push({severity:"warning",code:"PROVIDE_CONFLICT",message:`Token "${c}" is produced by multiple tasks: [${u.join(", ")}]. This requires a conflict strategy.`,tasks:u,tokens:[c]});if(t.settings.completion==="goal-reached"&&t.settings.goal)for(let c of t.settings.goal)s[c]||e.push({severity:"error",code:"UNREACHABLE_GOAL",message:`Goal token "${c}" cannot be produced by any task`,tokens:[c]});if(n.length>1)for(let[c,u]of Object.entries(r)){let l=E(u),d=u.on?Object.values(u.on).flat():[],m=u.on_failure||[];l.length===0&&d.length===0&&m.length===0&&e.push({severity:"warning",code:"DEAD_END_TASK",message:`Task "${c}" has no provides \u2014 it cannot unblock any downstream task`,tasks:[c]});}let i=new Set;for(let c of Object.values(r))for(let u of O(c))i.add(u);for(let[c,u]of Object.entries(r)){let l=O(u),d=E(u),m=u.on?Object.values(u.on).flat():[],p=[...d,...m],h=l.length===0,f=p.some(g=>i.has(g));h&&!f&&n.length>1&&(t.settings.completion==="goal-reached"&&t.settings.goal?.some(k=>p.includes(k))||e.push({severity:"info",code:"ISOLATED_TASK",message:`Task "${c}" is disconnected \u2014 it has no requires and nothing depends on its provides`,tasks:[c]}));}return t.settings.completion==="goal-reached"&&!t.settings.goal&&e.push({severity:"error",code:"MISSING_GOAL",message:'Completion strategy is "goal-reached" but no goal tokens are defined'}),Vc(e)}function Vc(t){let e=t.filter(n=>n.severity==="error"),r=t.filter(n=>n.severity==="warning");return {valid:e.length===0,issues:t,errors:e,warnings:r}}var Kc={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://github.com/yaml-flow/schema/event-graph.json",title:"Event Graph Configuration",description:"Schema for stateless event-graph (DAG) workflow definitions in yaml-flow",type:"object",required:["settings","tasks"],additionalProperties:false,properties:{id:{type:"string",description:"Optional graph identifier"},settings:{$ref:"#/definitions/settings"},tasks:{type:"object",description:"Task definitions keyed by name",minProperties:1,additionalProperties:{$ref:"#/definitions/task"}}},definitions:{settings:{type:"object",required:["completion"],properties:{completion:{type:"string",enum:["all-tasks-done","all-outputs-done","only-resolved","goal-reached","manual"],description:"Completion strategy"},conflict_strategy:{type:"string",enum:["alphabetical","priority-first","duration-first","cost-optimized","resource-aware","random-select","user-choice","parallel-all","skip-conflicts","round-robin"],description:"Conflict resolution strategy"},execution_mode:{type:"string",enum:["dependency-mode","eligibility-mode"],description:"Execution mode"},goal:{type:"array",items:{type:"string"},minItems:1,description:"Goal outputs \u2014 required when completion is 'goal-reached'"},max_iterations:{type:"integer",minimum:1,description:"Max scheduler iterations (safety limit, default: 1000)"},timeout_ms:{type:"integer",minimum:0,description:"Timeout in ms (declared for drivers, not enforced by pure engine)"},refreshStrategy:{$ref:"#/definitions/refresh_strategy",description:"Default refresh strategy for all tasks (default: 'data-changed')"}},additionalProperties:false,if:{properties:{completion:{const:"goal-reached"}}},then:{required:["completion","goal"]}},task:{type:"object",required:["provides"],properties:{requires:{type:"array",items:{type:"string"},description:"Tokens this task needs to become eligible"},provides:{type:"array",items:{type:"string"},description:"Tokens this task produces on successful completion"},on:{type:"object",description:"Conditional provides based on handler result key",additionalProperties:{type:"array",items:{type:"string"}}},on_failure:{type:"array",items:{type:"string"},description:"Tokens to inject when this task fails"},method:{type:"string",description:"Task execution method (informational \u2014 driver concern)"},config:{type:"object",description:"Arbitrary task configuration (driver concern)"},priority:{type:"number",description:"Higher = preferred in conflict resolution"},estimatedDuration:{type:"number",minimum:0,description:"Estimated duration in ms (used by duration-first strategy)"},estimatedCost:{type:"number",minimum:0,description:"Estimated cost (used by cost-optimized strategy)"},estimatedResources:{type:"object",additionalProperties:{type:"number"},description:"Resource requirements (used by resource-aware strategy)"},retry:{$ref:"#/definitions/task_retry"},refreshStrategy:{$ref:"#/definitions/refresh_strategy",description:"Task-level refresh strategy (overrides settings default)"},refreshInterval:{type:"number",minimum:0,description:"Interval in seconds for time-based refresh strategy"},maxExecutions:{type:"integer",minimum:1,description:"Maximum number of times this task can execute"},circuit_breaker:{$ref:"#/definitions/task_circuit_breaker"},description:{type:"string",description:"Human-readable description"},inference:{$ref:"#/definitions/inference_hints"}},additionalProperties:false},task_retry:{type:"object",required:["max_attempts"],properties:{max_attempts:{type:"integer",minimum:1,description:"Maximum retry attempts"},delay_ms:{type:"integer",minimum:0,description:"Delay between retries in ms"},backoff_multiplier:{type:"number",minimum:1,description:"Backoff multiplier (e.g., 2 for exponential)"}},additionalProperties:false},refresh_strategy:{type:"string",enum:["data-changed","epoch-changed","time-based","manual","once"],description:"Strategy for determining when a completed task should re-run"},task_circuit_breaker:{type:"object",required:["max_executions","on_break"],properties:{max_executions:{type:"integer",minimum:1,description:"Max executions before breaker trips"},on_break:{type:"array",items:{type:"string"},minItems:1,description:"Tokens to inject when breaker trips"}},additionalProperties:false},inference_hints:{type:"object",description:"LLM inference hints \u2014 opt-in metadata for AI-assisted completion detection",properties:{criteria:{type:"string",description:"Human-readable completion criteria"},keywords:{type:"array",items:{type:"string"},description:"Keywords to help the LLM understand the domain"},suggestedChecks:{type:"array",items:{type:"string"},description:"Suggested checks for verification"},autoDetectable:{type:"boolean",description:"Whether the LLM should attempt to auto-detect completion (default: false)"}},additionalProperties:false}}};var zc=lr(Xr());var an=null;function gg(){if(an)return an;let t=new zc.default({allErrors:true});return zh__default.default(t),an=t.compile(Kc),an}function Jc(t){let e=gg();return e(t)?{ok:true,errors:[]}:{ok:false,errors:(e.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`)}}function To(t){return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wc(t){return atob(t.replace(/-/g,"+").replace(/_/g,"/"))}var Eo=class{constructor(e){this.kv=e;}kv;stateKey(e){return `state_${To(e)}`}dataPrefix(e){return `data_${To(e)}_`}dataKey(e,r){return `${this.dataPrefix(e)}${To(r)}`}async saveRunState(e,r){this.kv.write(this.stateKey(e),r);}async loadRunState(e){let r=this.kv.read(this.stateKey(e));return r!=null&&typeof r=="object"?r:null}async deleteRunState(e){this.kv.delete(this.stateKey(e));for(let r of this.kv.listKeys(this.dataPrefix(e)))this.kv.delete(r);}async setData(e,r,n){this.kv.write(this.dataKey(e,r),n);}async getData(e,r){return this.kv.read(this.dataKey(e,r))}async getAllData(e){let r=this.dataPrefix(e),n={};for(let s of this.kv.listKeys(r))n[Wc(s.slice(r.length))]=this.kv.read(s);return n}async clearData(e){for(let r of this.kv.listKeys(this.dataPrefix(e)))this.kv.delete(r);}async listRuns(){return this.kv.listKeys("state_").map(e=>Wc(e.slice(6)))}};async function Yc(t,e){let{concurrency:r=5,processor:n,onItemComplete:s,onItemError:o,onProgress:a,signal:i}=e,c=t.length,u=new Array(c),l=Date.now(),d=0,m=0,p=0;function h(f){let g=d+m;return {completed:d,failed:m,active:f,pending:c-g-f,total:c,percent:c===0?100:Math.round(g/c*100),elapsedMs:Date.now()-l}}return c===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(f=>{let g=0;function k(){for(;g<r&&p<c;){if(i?.aborted){for(;p<c;){let v=p++;u[v]={item:t[v],index:v,status:"failed",error:new Error("Batch aborted"),durationMs:0},m++;}g===0&&d+m===c&&f({items:u,completed:d,failed:m,total:c,durationMs:Date.now()-l});break}let _=p++,y=t[_];g++;let S=Date.now();n(y,_).then(v=>{u[_]={item:y,index:_,status:"completed",result:v,durationMs:Date.now()-S},d++,s?.(y,v,_);}).catch(v=>{let R=v instanceof Error?v:new Error(String(v));u[_]={item:y,index:_,status:"failed",error:R,durationMs:Date.now()-S},m++,o?.(y,R,_);}).finally(()=>{g--,a?.(h(g)),d+m===c?f({items:u,completed:d,failed:m,total:c,durationMs:Date.now()-l}):k();});}}k();})}function yg(t,e){return t.replace(/\$\{([^}]+)\}/g,(r,n)=>{let s=e[n.trim()];return s!==void 0?String(s):r})}function Co(t,e){if(typeof t=="string")return yg(t,e);if(Array.isArray(t))return t.map(r=>Co(r,e));if(t!==null&&typeof t=="object"){let r={};for(let[n,s]of Object.entries(t))r[n]=Co(s,e);return r}return t}function Xc(t,e){return Co(t,e)}function vg(t,e){let r={...t};for(let[n,s]of Object.entries(e))n!=="config-template"&&(s!==null&&typeof s=="object"&&!Array.isArray(s)&&r[n]!==null&&typeof r[n]=="object"&&!Array.isArray(r[n])?r[n]={...r[n],...s}:r[n]=s);return r}function Qc(t){let e=t.configTemplates??t["config-templates"]??{},r="tasks"in t?"tasks":"steps"in t?"steps":null;if(!r)return t;let n=t[r];if(!n||typeof n!="object")return t;let s={};for(let[a,i]of Object.entries(n)){let c=i.config,u=c?.["config-template"];if(!u||!c){s[a]=i;continue}let l=e[u];if(!l){let{"config-template":d,...m}=c;s[a]={...i,config:m};continue}s[a]={...i,config:vg(l,c)};}let o={...t,[r]:s};return delete o.configTemplates,delete o["config-templates"],o}function cn(t,e){let r=e??`live-${Date.now()}`,n={};for(let o of Object.keys(t.tasks))n[o]=gn();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:t.settings.execution_mode??"eligibility-mode",conflictStrategy:t.settings.conflict_strategy??"alphabetical",completionStrategy:t.settings.completion}};return {config:t,state:s}}function un(t,e){let{config:r,state:n}=t;if("executionId"in e&&e.executionId&&e.executionId!==n.executionId)return t;switch(e.type){case "task-started":return {config:r,state:Xt(n,e.taskName,r)};case "task-completed":return {config:r,state:Qt(n,r,e.taskName,e.result,e.dataHash,e.data)};case "task-failed":return {config:r,state:Zt(n,r,e.taskName,e.error)};case "task-progress":return {config:r,state:er(n,e.taskName,e.message,e.progress)};case "task-restart":return {config:r,state:tr(n,e.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...e.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:_g(n,e.action)};case "task-upsert":return rr(t,e.taskName,e.taskConfig);case "task-removal":return nr(t,e.taskName);case "node-requires-add":return sr(t,e.nodeName,e.tokens);case "node-requires-remove":return or(t,e.nodeName,e.tokens);case "node-provides-add":return ar(t,e.nodeName,e.tokens);case "node-provides-remove":return ir(t,e.nodeName,e.tokens);default:return t}}function yt(t,e){return e.reduce((r,n)=>un(r,n),t)}function rr(t,e,r){let n=!!t.config.tasks[e];return {config:{...t.config,tasks:{...t.config.tasks,[e]:r}},state:{...t.state,tasks:{...t.state.tasks,[e]:n?t.state.tasks[e]:gn()},lastUpdated:new Date().toISOString()}}}function nr(t,e){if(!t.config.tasks[e])return t;let{[e]:r,...n}=t.config.tasks,{[e]:s,...o}=t.state.tasks;return {config:{...t.config,tasks:n},state:{...t.state,tasks:o,lastUpdated:new Date().toISOString()}}}function sr(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=O(n),o=r.filter(a=>!s.includes(a));return o.length===0?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,requires:[...s,...o]}}},state:t.state}}function or(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=O(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,requires:o}}},state:t.state}}function ar(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=E(n),o=r.filter(a=>!s.includes(a));return o.length===0?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,provides:[...s,...o]}}},state:t.state}}function ir(t,e,r){let n=t.config.tasks[e];if(!n)return t;let s=E(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?t:{config:{...t.config,tasks:{...t.config.tasks,[e]:{...n,provides:o}}},state:t.state}}function dn(t,e){return un(t,{type:"inject-tokens",tokens:e,timestamp:new Date().toISOString()})}function ln(t,e){let r=new Set(e),n=t.state.availableOutputs.filter(s=>!r.has(s));return n.length===t.state.availableOutputs.length?t:{config:t.config,state:{...t.state,availableOutputs:n,lastUpdated:new Date().toISOString()}}}function pn(t,e){return !t.config.tasks[e]||!t.state.tasks[e]?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:gn()},lastUpdated:new Date().toISOString()}}}function fn(t,e){let r=t.state.tasks[e];return !r||r.status==="inactivated"?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:{...r,status:"inactivated",lastUpdated:new Date().toISOString()}},lastUpdated:new Date().toISOString()}}}function mn(t,e){let r=t.state.tasks[e];return !r||r.status!=="inactivated"?t:{config:t.config,state:{...t.state,tasks:{...t.state.tasks,[e]:{...r,status:"not-started",lastUpdated:new Date().toISOString()}},lastUpdated:new Date().toISOString()}}}function Zc(t,e){let r=t.config.tasks[e];if(!r)return;let n=t.state.tasks[e]??gn();return {name:e,config:r,state:n}}function hn(t){return {version:1,config:t.config,state:t.state,snapshotAt:new Date().toISOString()}}function eu(t){if(!t||typeof t!="object")throw new Error("Invalid snapshot: expected an object");let e=t;if(!e.config||typeof e.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!e.state||typeof e.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=e.config,n=e.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function gn(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function _g(t,e){let r=new Date().toISOString();switch(e){case "stop":return {...t,status:"stopped",lastUpdated:r};case "pause":return {...t,status:"paused",lastUpdated:r};case "resume":return {...t,status:"running",lastUpdated:r};default:return t}}function cr(t){let{config:e,state:r}=t,n=G(e);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=kg(n),a=ue(e,r.tasks),i=new Set([...a,...r.availableOutputs]),c=[],u=[],l=[],d=[];for(let[p,h]of Object.entries(n)){let f=r.tasks[p],g=Je(h,e.settings),k=g!=="once";if(f?.status===P.RUNNING||X(f))continue;let _=gt(h);if(_!==void 0&&f&&f.executionCount>=_||h.circuit_breaker&&f&&f.executionCount>=h.circuit_breaker.max_executions||!k&&f?.status===P.COMPLETED)continue;if(k&&f?.status===P.COMPLETED){let w=O(h),T=false;switch(g){case "data-changed":{w.length>0&&w.some(F=>{for(let[U,W]of Object.entries(n))if(E(W).includes(F)){let z=r.tasks[U];if(!z)continue;let Sn=f.lastConsumedHashes?.[F];return z.lastDataHash==null?z.executionCount>f.lastEpoch:z.lastDataHash!==Sn}return false})||(T=true);break}case "epoch-changed":{w.length>0&&w.some(F=>{for(let[U,W]of Object.entries(n))if(E(W).includes(F)){let z=r.tasks[U];if(z&&z.executionCount>f.lastEpoch)return true}return false})||(T=true);break}case "time-based":{let J=h.refreshInterval??0;if(J<=0){T=true;break}let F=f.completedAt;if(!F){T=true;break}(Date.now()-Date.parse(F))/1e3<J&&(T=true);break}case "manual":T=true;break}if(T)continue}let y=O(h);if(y.length===0){c.push(p);continue}let S=[],v=[],R=[];for(let w of y){if(i.has(w))continue;let T=o[w]||[];T.length===0?S.push(w):T.every(F=>X(r.tasks[F]))?R.push({token:w,failedProducer:T[0]}):v.push(w);}S.length>0?l.push({taskName:p,missingTokens:S}):R.length>0?d.push({taskName:p,failedTokens:R.map(w=>w.token),failedProducers:[...new Set(R.map(w=>w.failedProducer))]}):v.length>0?u.push({taskName:p,waitingOn:v}):c.push(p);}let m={};if(c.length>1){let p=qe(c,n);for(let[h,f]of Object.entries(p))f.length>1&&(m[h]=f);}return {eligible:c,pending:u,unresolved:l,blocked:d,conflicts:m}}function kg(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function tu(t){let{config:e,state:r}=t,n=G(e),s=Object.keys(n),o=0,a=0,i=0,c=0,u=0,l=0;for(let _ of s){let y=r.tasks[_];if(!y||y.status===P.NOT_STARTED)u++;else switch(y.status){case P.RUNNING:o++;break;case P.COMPLETED:a++;break;case P.FAILED:i++;break;case "inactivated":l++;break;default:c++;}}let d={};for(let[_,y]of Object.entries(n)){for(let S of E(y))d[S]||(d[S]=[]),d[S].push(_);if(y.on)for(let S of Object.values(y.on))for(let v of S)d[v]||(d[v]=[]),d[v].includes(_)||d[v].push(_);if(y.on_failure)for(let S of y.on_failure)d[S]||(d[S]=[]),d[S].includes(_)||d[S].push(_);}let m=new Set,p=0,h=0;for(let[_,y]of Object.entries(n)){let S=r.tasks[_];if(S?.status===P.COMPLETED||S?.status===P.RUNNING)continue;let v=false,R=false;for(let w of O(y)){let T=d[w]||[];T.length===0?(m.add(w),v=true):T.every(F=>{let U=r.tasks[F];return U?.status===P.FAILED||U?.status==="inactivated"})&&(R=true);}v&&p++,R&&!v&&h++;}let f=[];for(let[_,y]of Object.entries(d))y.length>1&&f.push(_);let g=bg(n,d),k=Sg(s,g);return {totalNodes:s.length,running:o,completed:a,failed:i,waiting:c,notStarted:u,disabled:l,unresolvedCount:p,blockedCount:h,openDependencies:[...m],cycles:k,conflictTokens:f}}function bg(t,e){let r={};for(let[n,s]of Object.entries(t)){r[n]=new Set;for(let o of O(s))for(let a of e[o]||[])a!==n&&r[n].add(a);}return r}function Sg(t,e){let o={},a={},i=[];for(let u of t)o[u]=0,a[u]=null;function c(u){o[u]=1;for(let l of e[u]||[])if(o[l]===1){let d=[l],m=u;for(;m!==l;)d.push(m),m=a[m];d.push(l),d.reverse(),i.push(d);}else o[l]===0&&(a[l]=u,c(l));o[u]=2;}for(let u of t)o[u]===0&&c(u);return i}function ru(t){let e={};for(let[r,n]of Object.entries(t)){for(let s of E(n))e[s]||(e[s]=[]),e[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)e[o]||(e[o]=[]),e[o].includes(r)||e[o].push(r);if(n.on_failure)for(let s of n.on_failure)e[s]||(e[s]=[]),e[s].includes(r)||e[s].push(r);}return e}function xo(t){let{config:e,state:r}=t,n=G(e),s=ru(n),o=new Set([...r.availableOutputs]);for(let[d,m]of Object.entries(r.tasks))if(m.status==="completed"){let p=n[d];p&&E(p).forEach(h=>o.add(h));}let a=new Set;for(let d of Object.values(n))for(let m of O(d))a.add(m);let i=new Set,c=new Set;for(let d of a){if(o.has(d))continue;(s[d]||[]).length===0&&i.add(d);}let u=true;for(;u;){u=false;for(let[d,m]of Object.entries(n)){if(c.has(d))continue;let p=r.tasks[d];if(p?.status==="completed")continue;let h=X(p),g=O(m).some(k=>i.has(k));(h||g)&&(c.has(d)||(c.add(d),u=true));}for(let d of a){if(i.has(d)||o.has(d))continue;let m=s[d]||[],p=m.length>0&&m.every(h=>c.has(h)||X(r.tasks[h]));(m.length===0||p)&&(i.has(d)||(i.add(d),u=true));}}let l=[];for(let d of i){let m=s[d]||[],p;m.length===0?p="no-producer":p=m.every(f=>X(r.tasks[f]))?"all-producers-failed":"transitive",l.push({token:d,reason:p,producers:m});}return {tokens:l}}function nu(t){let{config:e,state:r}=t,n=G(e),{tokens:s}=xo(t),o=new Set(s.map(i=>i.token)),a=[];for(let[i,c]of Object.entries(n)){let u=r.tasks[i];if(u?.status==="completed")continue;let d=O(c).filter(m=>o.has(m));d.length>0?a.push({nodeName:i,missingTokens:d}):X(u)&&a.push({nodeName:i,missingTokens:[]});}return {nodes:a}}function su(t,e){let r=G(t.config);if(!r[e])return {nodeName:e,nodes:[],tokens:[]};let n=ru(r),s=new Set,o=new Set,a=new Map;function i(u){let l=r[u];if(l)for(let d of O(l)){let m=n[d]||[];for(let p of m)p!==e&&(o.add(d),a.has(p)||a.set(p,new Set),a.get(p).add(d),s.has(p)||(s.add(p),i(p)));}}i(e);let c=[...a.entries()].map(([u,l])=>({nodeName:u,providesTokens:[...l]}));return {nodeName:e,nodes:c,tokens:[...o]}}function ou(t,e){let r=G(t.config);if(!r[e])return {nodeName:e,nodes:[],tokens:[]};let n={};for(let[u,l]of Object.entries(r))for(let d of O(l))n[d]||(n[d]=[]),n[d].push(u);let s=new Set,o=new Set,a=new Map;function i(u){let l=r[u];if(l)for(let d of E(l)){let m=n[d]||[];for(let p of m)p!==e&&(o.add(d),a.has(p)||a.set(p,new Set),a.get(p).add(d),s.has(p)||(s.add(p),i(p)));}}i(e);let c=[...a.entries()].map(([u,l])=>({nodeName:u,requiresTokens:[...l]}));return {nodeName:e,nodes:c,tokens:[...o]}}var We=class{buffer=[];append(e){this.buffer.push(e);}drain(){let e=this.buffer;return this.buffer=[],e}get size(){return this.buffer.length}};function yn(t){let e=jo(t);return wg(e)}function jo(t){if(t==null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return "["+t.map(jo).join(",")+"]";let e=t;return "{"+Object.keys(e).sort().map(n=>JSON.stringify(n)+":"+jo(e[n])).join(",")+"}"}function wg(t){let e=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<t.length;s++)e^=BigInt(t.charCodeAt(s)),e=e*r&n;return e.toString(16).padStart(16,"0")}function $g(t){if(typeof Buffer<"u")return Buffer.from(t,"utf8").toString("base64url");if(typeof btoa=="function"){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Rg(t){if(typeof Buffer<"u")return Buffer.from(t,"base64url").toString("utf8");if(typeof atob=="function"){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e+"=".repeat((4-e.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function au(t){let e=JSON.stringify({t,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return $g(e)}function Tg(t){try{let e=JSON.parse(Rg(t));return typeof e?.t=="string"?{taskName:e.t}:null}catch{return null}}function vt(t,e,r){let{handlers:n,onDrain:s}=e,o=new We,a="state"in t&&"config"in t?t:cn(t,r),i=false,c=new Set,u=new Map(Object.entries(n)),l=new We,d=false,m=false;function p(){if(!i){if(d){m=true;return}d=true;try{do m=!1,h();while(m)}finally{d=false;}}}function h(){let _=l.drain(),y=o.drain(),S=[..._,...y];S.length>0&&(a=yt(a,S));let v=cr(a);S.length>0&&s?.(S,a,v);for(let R of v.eligible)k(R);for(let R of S)if(R.type==="task-progress"){let{taskName:w,update:T}=R;if(!a.config.tasks[w])continue;let F=a.state.tasks[w];if(!F||F.status!=="running")continue;let U=au(w),W=g(w,U,T).catch(z=>{i||(l.append({type:"task-failed",taskName:w,error:z.message??String(z),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(W);});c.add(W);}}function f(_){let S=a.config.tasks[_].requires??[],v=new Map;for(let[w,T]of Object.entries(a.config.tasks))for(let J of T.provides??[])v.set(J,w);let R={};for(let w of S){let T=v.get(w);T?R[w]=a.state.tasks[T]?.data:R[w]=void 0;}return R}async function g(_,y,S){let v=a.config.tasks[_],R=v.taskHandlers??[],w=f(_);for(let T of R){let J=u.get(T);if(!J)throw new Error(`Handler '${T}' not found in registry (task '${_}')`);let F={nodeId:_,state:w,taskState:a.state.tasks[_],config:v,callbackToken:y,update:S};if(await J(F)==="task-initiate-failure")throw new Error(`Handler '${T}' returned task-initiate-failure (task '${_}')`)}}function k(_){let S=a.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),p();let v=au(_),R=g(_,v).catch(w=>{i||(l.append({type:"task-failed",taskName:_,error:w.message??String(w),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(R);});c.add(R);}return {push(_){i||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:yn(_.data)}),o.append(_),p());},pushAll(_){if(!i){for(let y of _)y.type==="task-completed"&&y.data&&!y.dataHash?o.append({...y,dataHash:yn(y.data)}):o.append(y);p();}},resolveCallback(_,y,S){if(i)return;let v=Tg(_);if(!v)return;let{taskName:R}=v;if(a.config.tasks[R]){if(S&&S.length>0)o.append({type:"task-failed",taskName:R,error:S.join("; "),timestamp:new Date().toISOString()});else {let w=y&&Object.keys(y).length>0?yn(y):void 0;o.append({type:"task-completed",taskName:R,data:y,dataHash:w,timestamp:new Date().toISOString()});}p();}},addNode(_,y){i||(o.append({type:"task-upsert",taskName:_,taskConfig:y,timestamp:new Date().toISOString()}),p());},removeNode(_){i||(o.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),p());},addRequires(_,y){i||(o.append({type:"node-requires-add",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},removeRequires(_,y){i||(o.append({type:"node-requires-remove",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},addProvides(_,y){i||(o.append({type:"node-provides-add",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},removeProvides(_,y){i||(o.append({type:"node-provides-remove",nodeName:_,tokens:y,timestamp:new Date().toISOString()}),p());},registerHandler(_,y){u.set(_,y);},unregisterHandler(_){u.delete(_);},retrigger(_){i||a.config.tasks[_]&&(o.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),p());},retriggerAll(_){if(!i){for(let y of _)a.config.tasks[y]&&o.append({type:"task-restart",taskName:y,timestamp:new Date().toISOString()});p();}},snapshot(){return hn(a)},getState(){return a},getSchedule(){return cr(a)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),i=true;}}}function Po(t){let e=[],{config:r,state:n}=t,s=G(r),o=Object.keys(s);for(let u of o)n.tasks[u]||e.push({severity:"error",code:"MISSING_STATE",message:`Task "${u}" exists in config but has no state entry`,tasks:[u]});for(let u of Object.keys(n.tasks))s[u]||e.push({severity:"warning",code:"ORPHAN_STATE",message:`State entry "${u}" has no corresponding task config`,tasks:[u]});for(let u of o){let l=n.tasks[u];l&&(l.status===P.RUNNING&&!l.startedAt&&e.push({severity:"warning",code:"RUNNING_WITHOUT_START",message:`Task "${u}" is running but has no startedAt timestamp`,tasks:[u]}),l.status===P.COMPLETED&&!l.completedAt&&e.push({severity:"warning",code:"COMPLETED_WITHOUT_TIMESTAMP",message:`Task "${u}" is completed but has no completedAt timestamp`,tasks:[u]}),l.status===P.FAILED&&(l.failedAt||e.push({severity:"warning",code:"FAILED_WITHOUT_INFO",message:`Task "${u}" is failed but has no failedAt timestamp`,tasks:[u]}),l.error||e.push({severity:"info",code:"FAILED_WITHOUT_INFO",message:`Task "${u}" is failed but has no error message`,tasks:[u]})));}let a=new Set;for(let u of o)if(n.tasks[u]?.status===P.COMPLETED)for(let d of E(s[u]))a.add(d);let i=new Set(n.availableOutputs),c=new Set;for(let u of Object.values(s)){for(let l of E(u))c.add(l);if(u.on)for(let l of Object.values(u.on))for(let d of l)c.add(d);if(u.on_failure)for(let l of u.on_failure)c.add(l);}for(let u of i)!a.has(u)&&!c.has(u)&&e.push({severity:"info",code:"INJECTED_TOKEN",message:`Token "${u}" is available but no task in the graph can produce it (likely injected)`,tokens:[u]});for(let u of a)i.has(u)||e.push({severity:"warning",code:"MISSING_OUTPUT",message:`Token "${u}" should be available (its producer completed) but is not in availableOutputs`,tokens:[u]});for(let u of o){let l=n.tasks[u];if(!l)continue;l.executionCount<0&&e.push({severity:"error",code:"INVALID_EXECUTION_COUNT",message:`Task "${u}" has negative execution count: ${l.executionCount}`,tasks:[u]});let d=s[u].maxExecutions;d!==void 0&&l.executionCount>d&&e.push({severity:"error",code:"EXCEEDED_MAX_EXECUTIONS",message:`Task "${u}" executed ${l.executionCount} times, exceeding maxExecutions of ${d}`,tasks:[u]});}return cu(e)}function iu(t){let{graph:e,handlers:r}=t,n=e.getState(),s=[],o=G(n.config),a=Object.keys(o),i=new Set(Object.keys(r)),c=new Set;for(let l of a){let d=o[l].taskHandlers;if(d)for(let m of d)c.add(m);}for(let l of a){let d=o[l].taskHandlers;if(d)for(let m of d)r[m]||s.push({severity:"error",code:"MISSING_HANDLER",message:`Task "${l}" references handler "${m}" but it is not in the registry`,tasks:[l]});}for(let l of i)c.has(l)||s.push({severity:"warning",code:"ORPHAN_HANDLER",message:`Handler "${l}" is registered but not referenced by any task's taskHandlers`,tasks:[l]});let u=Po(n);return s.push(...u.issues),cu(s)}function cu(t){let e=t.filter(n=>n.severity==="error"),r=t.filter(n=>n.severity==="warning");return {valid:e.length===0,issues:t,errors:e,warnings:r}}function uu(t,e){let r=t;for(let n of e)r=Eg(r,n);return r}function Eg(t,e){switch(e.type){case "add-node":return rr(t,e.name,e.config);case "remove-node":return nr(t,e.name);case "add-requires":return sr(t,e.taskName,e.tokens);case "remove-requires":return or(t,e.taskName,e.tokens);case "add-provides":return ar(t,e.taskName,e.tokens);case "remove-provides":return ir(t,e.taskName,e.tokens);case "inject-tokens":return dn(t,e.tokens);case "drain-tokens":return ln(t,e.tokens);case "reset-node":return pn(t,e.name);case "disable-node":return fn(t,e.name);case "enable-node":return mn(t,e.name);case "apply-events":return yt(t,e.events);default:throw new Error(`Unknown mutation type: ${e.type}`)}}function du(t,e){return async r=>{let{callbackToken:n}=r;return Promise.resolve(t(r)).then(s=>e()(n,s)).catch(s=>e()(n,{},[s instanceof Error?s.message:String(s)])),"task-initiated"}}function lu(t,e){return async r=>{let{callbackToken:n}=r;return Promise.resolve(t(r)).then(()=>e()(n,{})).catch(()=>e()(n,{})),"task-initiated"}}function pu(t){let{command:e,cwd:r,env:n,timeoutMs:s=3e4,exitCodeMap:o,captureOutput:a=false,getResolve:i}=t;return async c=>{let{callbackToken:u,nodeId:l}=c,d=e.replace(/\$\{taskName\}/g,l);return child_process.exec(d,{cwd:r,env:n?{...process.env,...n}:void 0,timeout:s,maxBuffer:10*1024*1024},(m,p,h)=>{let f=m?.code??(m?1:0);if(f!==0&&!o?.[f]){i()(u,{},[`Command exited with code ${f}: ${h||m?.message}`]);return}let g={};a&&(g.stdout=p,g.stderr=h,g.exitCode=f),i()(u,g);}),"task-initiated"}}function Oo(t){let{command:e,args:r=[],cwd:n,env:s,timeoutMs:o=3e4,exitCodeMap:a,captureOutput:i=false,getResolve:c}=t;return async u=>{let{callbackToken:l,nodeId:d}=u,m=e.replace(/\$\{taskName\}/g,d),p=r.map(h=>h.replace(/\$\{taskName\}/g,d));return child_process.execFile(m,p,{cwd:n,env:s?{...process.env,...s}:void 0,timeout:o,maxBuffer:10*1024*1024,encoding:"utf8",windowsHide:true},(h,f,g)=>{let k=h?.code??(h?1:0);if(k!==0&&!a?.[k]){c()(l,{},[`Process exited with code ${k}: ${g||h?.message}`]);return}let _={};i&&(_.stdout=f,_.stderr=g,_.exitCode=k),c()(l,_);}),"task-initiated"}}function jg(t){return t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".ts")?"node":t.endsWith(".py")?"python3":(t.endsWith(".sh"),"bash")}function fu(t){let{scriptPath:e,runtime:r,args:n=[],cwd:s,timeoutMs:o=6e4,captureOutput:a=false,getResolve:i}=t,c=r??jg(e),u=c==="node"?process.execPath:c;return Oo({command:u,args:[e,"${taskName}",...n],cwd:s,timeoutMs:o,captureOutput:a,getResolve:i})}function mu(t){let{url:e,method:r="POST",headers:n={},timeoutMs:s=3e4,failOnNon2xx:o=true,getResolve:a}=t;return async i=>{let{callbackToken:c,nodeId:u,config:l}=i,d=e.replace(/\$\{taskName\}/g,u),m=JSON.stringify({taskName:u,callbackToken:c,config:l}),p=new AbortController,h=setTimeout(()=>p.abort(),s);return fetch(d,{method:r,headers:{"Content-Type":"application/json",...n},body:m,signal:p.signal}).then(async f=>{if(clearTimeout(h),o&&!f.ok){let k=await f.text().catch(()=>"");a()(c,{},[`HTTP ${f.status}: ${k}`]);return}let g=await f.json().catch(()=>({}));a()(c,g);}).catch(f=>{clearTimeout(h),a()(c,{},[f instanceof Error?f.message:String(f)]);}),"task-initiated"}}function hu(t,e){return async r=>(t()(r.callbackToken,e??{}),"task-initiated")}var gu={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var _u=lr(Xr());var Ng=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),qg=Ng("./jsonata-sync.cjs"),vn=null;var yu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Ig=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Mg(t){let e=new Set,r;for(yu.lastIndex=0;(r=yu.exec(t))!==null;)e.add(r[1]);return e}function ku(t){let e=Ig.exec(t);return e?e[1]:null}function vu(t,e,r,n){try{qg(t);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${e}: invalid JSONata expression (${a})`);return}let s=Mg(t);for(let o of s)r.has(o)||n.push(`${e}: disallowed namespace "${o}" in expression`);}function Ao(t,e,r){if(Array.isArray(t)){t.forEach((s,o)=>{Ao(s,`${e}/${o}`,r);});return}if(typeof t=="string"){let s=ku(t);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${e}: disallowed namespace "${s}" in view reference`);return}if(!t||typeof t!="object")return;let n=t;for(let[s,o]of Object.entries(n))Ao(o,`${e}/${s}`,r);}function Dg(){if(vn)return vn;let t=new _u.default({allErrors:true});return zh__default.default(t),vn=t.compile(gu),vn}function No(t){let e=Dg(),r=e(t),n=(e.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(t&&typeof t=="object"&&!Array.isArray(t)){let s=t.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,c)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let u=i;typeof u.bindTo=="string"&&u.bindTo&&(o.has(u.bindTo)&&n.push(`/source_defs/${c}/bindTo: bindTo "${u.bindTo}" must be unique across all source_defs`),o.add(u.bindTo)),typeof u.outputFile=="string"&&u.outputFile&&(a.has(u.outputFile)&&n.push(`/source_defs/${c}/outputFile: outputFile "${u.outputFile}" must be unique across all source_defs`),a.add(u.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function qo(t){let e=[];if(!t||typeof t!="object"||Array.isArray(t))return {ok:true,errors:[]};let r=t,n=r.compute;Array.isArray(n)&&n.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.expr;typeof d!="string"||d.trim().length===0||vu(d,`/compute/${l}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),e);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.ref;if(typeof d!="string"||d.trim().length===0)return;let m=ku(d);m===null?e.push(`/provides/${l}/ref: path "${d}" must start with a valid namespace (${[...s].join(", ")})`):s.has(m)||e.push(`/provides/${l}/ref: disallowed namespace "${m}" in path "${d}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Ao(a,"/view",e);let i=new Set(["card_data","requires"]),c=r.source_defs;return Array.isArray(c)&&c.forEach((u,l)=>{if(!u||typeof u!="object"||Array.isArray(u))return;let d=u.projections;if(!(!d||typeof d!="object"||Array.isArray(d)))for(let[m,p]of Object.entries(d))typeof p!="string"||p.trim().length===0||vu(p,`/source_defs/${l}/projections/${m}`,i,e);}),{ok:e.length===0,errors:e}}function bu(t){return Io(t)}function Io(t){let e=No(t);if(!e.ok)return e;let r=qo(t);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}var Lg=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),_n=Lg("./jsonata-sync.cjs"),$u=_n;function Su(t,e){if(!e||!t)return;let r=e.split("."),n=t;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function Ru(t,e,r){let n=e.split("."),s=t;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Fg(t,e){if(!t?.compute?.length)return t;t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=e?.sourcesData??{};let r=t.requires??{},n={card_data:t.card_data,requires:r,expects_data:r,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values};for(let s of t.compute)try{let o=await _n(s.expr).evaluate(n);Ru(t.computed_values,s.bindTo,o),n.computed_values=t.computed_values;}catch{}return t}function Hg(t,e){if(!t?.compute?.length)return {ok:true,node:t};t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=e?.sourcesData??{};let r=t.requires??{},n={card_data:t.card_data,requires:r,expects_data:r,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values},s=[];for(let o of t.compute)try{let a=$u(o.expr).evaluate(n);Ru(t.computed_values,o.bindTo,a),n.computed_values=t.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:t,errors:s}:{ok:true,node:t}}async function Ug(t,e,r){let n={...r??{},card_data:e.card_data??{},requires:e.requires??{},fetched_sources:e._sourcesData??{},computed_values:e.computed_values??{}};return _n(t).evaluate(n)}function Vg(t,e){return e.startsWith("fetched_sources.")?Su(t._sourcesData??{},e.slice(16)):Su(t,e)}var wu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),Bg=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function Kg(t){let e=[];if(!t||typeof t!="object"||Array.isArray(t))return {ok:false,errors:["Node must be a non-null object"]};let r=t;(typeof r.id!="string"||!r.id)&&e.push("id: required, must be a non-empty string");for(let n of Object.keys(r))Bg.has(n)||e.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&e.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))e.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&e.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&e.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&e.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))e.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&e.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&e.push(`provides[${s}]: missing required "ref" string`);}}):e.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))e.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&e.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&e.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):e.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))e.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))e.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?e.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&e.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?e.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&e.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&e.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))e.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?e.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){e.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?e.push(`view.elements[${o}].kind: required, must be a string`):wu.has(s.kind)||e.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...wu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&e.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&e.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&e.push("view.features: must be an object");}return {ok:e.length===0,errors:e}}async function zg(t,e){if(!t||t.length===0)return [];let r={card_data:e.card_data??{},requires:e.requires??{}};return Promise.all(t.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await _n(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function Jg(t,e){if(!t||t.length===0)return [];let r={card_data:e.card_data??{},requires:e.requires??{}};return t.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=$u(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var Ye={run:Fg,runSync:Hg,eval:Ug,resolve:Vg,validate:Kg,enrichSources:zg,enrichSourcesSync:Jg};function Tu(t,e={}){let r,n={},s;if(!Array.isArray(t)&&"nodes"in t){let v=t;r=v.nodes,s=v.id,n=v.settings??{};}else r=t;let{sourceHandlers:o={},defaultSourceHandler:a,cardHandlers:i={},reactiveOptions:c={},graphSettings:u={},executionId:l}=e,d=new Map;for(let v of r){if(d.has(v.id))throw new Error(`Duplicate card ID: "${v.id}"`);d.set(v.id,v);}let m=e.sharedState??new Map,p={},h=new Set,f=new Map;for(let v of r)for(let R of v.provides??[{bindTo:v.id,ref:"card_data"}])h.add(R.bindTo),f.set(R.bindTo,v.id);for(let v of r){let R=v.requires??[];for(let w of R)if(!h.has(w))throw new Error(`Card "${v.id}" requires "${w}" but no card provides that token`);p[v.id]={requires:R.length>0?R:void 0,provides:(v.provides??[{bindTo:v.id,ref:"card_data"}]).map(w=>w.bindTo),taskHandlers:[v.id],description:v.meta?.title??v.id};}let g={id:s??`live-cards-${Date.now()}`,settings:{completion:"manual",execution_mode:"eligibility-mode",...n,...u},tasks:p},k={},_=null,y=()=>(v,R,w)=>{_.resolveCallback(v,R,w);};for(let v of r)v.source_defs&&v.source_defs.length>0?k[v.id]=Wg(v,o,a,m,y):k[v.id]=Yg(v,i,m,d,f,y);let S=vt(g,{...c,handlers:k},l);return _=S,{graph:S,config:g,handlers:k,cards:d,sharedState:m}}function Wg(t,e,r,n,s){if(e[t.id]){let o=e[t.id];return async a=>o(a)}if(r){let o=r(t);return async a=>o(a)}return async o=>{let a={...t.card_data};return n.set(t.id,a),s()(o.callbackToken,a),"task-initiated"}}function Yg(t,e,r,n,s,o){if(e[t.id]){let a=e[t.id];return async i=>a(i)}return async a=>{let i={},c=t.requires??[];for(let m of c){let p=s.get(m)??m,h=r.get(p);h&&(i[m]=h[m]??h);}let u={id:t.id,card_data:{...t.card_data},requires:i,compute:t.compute};await Ye.run(u);let l;if(t.provides&&t.provides.length>0){l={};for(let{bindTo:m,ref:p}of t.provides)l[m]=Ye.resolve(u,p);}else l={...u.card_data,...u.computed_values};let d={...u.card_data,...u.computed_values};return r.set(t.id,d),o()(a.callbackToken,l),"task-initiated"}}function Ie(t){return JSON.parse(JSON.stringify(t))}function Mo(t){let e=t.provides&&t.provides.length>0?t.provides.map(r=>r.bindTo):[t.id];return {requires:t.requires&&t.requires.length>0?[...t.requires]:void 0,provides:e,taskHandlers:[t.id],description:t.meta?.title??t.id}}function Xg(t){let e=new Map;for(let[r,n]of t.entries()){let s=n.provides&&n.provides.length>0?n.provides:[{bindTo:r,ref:"card_data"}];for(let o of s)e.set(o.bindTo,r);}return e}function Do(t,e){let r=Xg(t),n=t.get(e);if(n){for(let s of n.requires??[])if(!r.has(s))throw new Error(`Card "${e}" requires token "${s}" but no card provides it`)}}function Qg(t,e={}){let r=Array.isArray(t)?{}:{id:t.id,title:t.title,mode:t.mode,positions:t.positions,settings:t.settings},n=Array.isArray(t)?t:t.nodes,s=new Map;for(let y of n){if(s.has(y.id))throw new Error(`Duplicate card ID: "${y.id}"`);s.set(y.id,Ie(y));}let o=new Set,a=e.taskExecutor,i=e.sourceAdapters??{},c=e.defaultSourceAdapter,u=null,l=(y,S)=>{let v={events:y,graph:S,nodes:k()};for(let R of o)R(v);},d=y=>async S=>{let v=s.get(y);if(!v)return "task-initiate-failure";let R={};for(let U of v.requires??[]){let W=S.state[U];if(!W||typeof W!="object")continue;let z=W.provides_data;!z||typeof z!="object"||Object.prototype.hasOwnProperty.call(z,U)&&(R[U]=z[U]);}let w={};if(v.source_defs&&v.source_defs.length>0){let U=i[y]??c,W=a?await a({card:v,input:S}):U?await U({card:v,input:S}):void 0;if(W&&typeof W=="object")for(let z of v.source_defs)Object.prototype.hasOwnProperty.call(W,z.bindTo)?w[z.bindTo]=W[z.bindTo]:v.source_defs.length===1&&(w[z.bindTo]=W);}let T={id:v.id,card_data:Ie(v.card_data??{}),requires:R,source_defs:v.source_defs,compute:v.compute};T._sourcesData=w,T.compute&&T.compute.length>0&&await Ye.run(T,{sourcesData:w});let J={};if(v.provides&&v.provides.length>0)for(let{bindTo:U,ref:W}of v.provides)J[U]=Ye.resolve(T,W);else J[v.id]={...T.card_data??{},...T.computed_values??{},...T._sourcesData??{}};let F={provides_data:J,card_data:T.card_data??{},computed_values:T.computed_values??{},fetched_sources:w,requires:R};return u?.resolveCallback(S.callbackToken,F),"task-initiated"},m={},p={};for(let[y,S]of s.entries())Do(s,y),m[y]=Mo(S),p[y]=d(y);let h={id:r.id??`browser-board-${Date.now()}`,settings:{completion:"manual",execution_mode:"eligibility-mode",...r.settings??{},...e.graphSettings??{}},tasks:m},f=e.reactiveOptions?.onDrain,g=vt(h,{...e.reactiveOptions??{},handlers:p,onDrain:(y,S,v)=>{f?.(y,S,v),l(y,S);}},e.executionId);u=g;function k(){let y=g.getState(),S=[];for(let[v,R]of s.entries()){let w=y.state.tasks[v]?.data,T=y.state.tasks[v],J={...R.card_data??{},...w&&typeof w.card_data=="object"?w.card_data:{}},F=T?.status==="running"?"loading":T?.status,U={...J,...F?{status:F}:{},...T?.lastUpdated?{lastRun:T.lastUpdated}:{},...T?.status==="failed"&&T.error?{error:T.error}:{}};S.push({id:v,card:Ie(R),card_data:U,requires:w&&typeof w.requires=="object"?Ie(w.requires):{},computed_values:w&&typeof w.computed_values=="object"?Ie(w.computed_values):{},runtime_state:T?Ie(T):{}});}return S}return {getGraph:()=>g,getState:()=>g.getState(),getSchedule:()=>g.getSchedule(),getNodes:()=>k(),getBoard:()=>({...r,nodes:k()}),subscribe(y){return o.add(y),y({events:[],graph:g.getState(),nodes:k()}),()=>o.delete(y)},addCard(y){if(s.has(y.id))throw new Error(`Card "${y.id}" already exists`);s.set(y.id,Ie(y)),Do(s,y.id),g.registerHandler(y.id,d(y.id)),g.addNode(y.id,Mo(y));},upsertCard(y){s.set(y.id,Ie(y)),Do(s,y.id),g.registerHandler(y.id,d(y.id)),g.addNode(y.id,Mo(y));},removeCard(y){s.delete(y),g.unregisterHandler(y),g.removeNode(y);},patchCardState(y,S){let v=s.get(y);if(!v)throw new Error(`Card "${y}" not found`);v.card_data={...v.card_data??{},...S},g.retrigger(y);},retrigger(y){g.retrigger(y);},retriggerAll(){g.retriggerAll(Array.from(s.keys()));},push(y){g.push(y);},pushAll(y){g.pushAll(y);},dispose(){o.clear(),g.dispose();}}}var Eu={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://yaml-flow.dev/schema/board-status.schema.json",title:"Board Status Object",type:"object",additionalProperties:false,required:["schema_version","meta","summary","cards"],properties:{schema_version:{type:"string",const:"v1"},meta:{type:"object",additionalProperties:false,required:["board"],properties:{board:{type:"object",additionalProperties:false,required:["path"],properties:{path:{type:"string"}}}}},summary:{type:"object",additionalProperties:false,required:["card_count","completed","eligible","pending","blocked","unresolved"],properties:{card_count:{type:"integer",minimum:0},completed:{type:"integer",minimum:0},eligible:{type:"integer",minimum:0},pending:{type:"integer",minimum:0},blocked:{type:"integer",minimum:0},unresolved:{type:"integer",minimum:0},failed:{type:"integer",minimum:0},in_progress:{type:"integer",minimum:0},orphan_cards:{type:"integer",minimum:0},topology:{type:"object",additionalProperties:false,required:["edge_count","max_fan_out_card","max_fan_out"],properties:{edge_count:{type:"integer",minimum:0},max_fan_out_card:{type:["string","null"]},max_fan_out:{type:"integer",minimum:0}}}}},cards:{type:"array",items:{type:"object",additionalProperties:false,required:["name","status","requires","requires_satisfied","requires_missing","provides_declared","provides_runtime","blocked_by","unblocks","runtime"],properties:{name:{type:"string"},status:{type:"string"},error:{type:"object",additionalProperties:false,required:["message"],properties:{message:{type:"string"},code:{type:"string"},at:{type:["string","null"]},source:{type:"string"}}},requires:{type:"array",items:{type:"string"}},requires_satisfied:{type:"array",items:{type:"string"}},requires_missing:{type:"array",items:{type:"string"}},provides_declared:{type:"array",items:{type:"string"}},provides_runtime:{type:"array",items:{type:"string"}},blocked_by:{type:"array",items:{type:"string"}},unblocks:{type:"array",items:{type:"string"}},runtime:{type:"object",additionalProperties:false,required:["attempt_count","restart_count","in_progress_since","last_transition_at","last_completed_at","last_restarted_at","status_age_ms"],properties:{attempt_count:{type:"integer",minimum:0},restart_count:{type:"integer",minimum:0},in_progress_since:{type:["string","null"]},last_transition_at:{type:["string","null"]},last_completed_at:{type:["string","null"]},last_restarted_at:{type:["string","null"]},status_age_ms:{type:["integer","null"],minimum:0}}}}}}}};var Cu={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://yaml-flow.dev/schema/card-runtime.schema.json",title:"Card Runtime Computed Artifact",description:"Published per-card runtime artifact written to runtime-out/cards/<card-id>.computed.json. Contains only values produced by the compute step.",type:"object",required:["schema_version","card_id","computed_values"],additionalProperties:false,properties:{schema_version:{type:"string",const:"v1",description:"Artifact schema version."},card_id:{type:"string",description:"The ID of the card this artifact belongs to."},computed_values:{type:"object",description:"Key/value map of outputs produced by the card's JSONata compute steps.",additionalProperties:true}}};var od=lr(sd());var kn=null,bn=null;function ad(){let t=new od.default({allErrors:true,strict:false});return zh__default.default(t),t}function id(t){return {ok:false,errors:(t.errors??[]).map(r=>`${r.instancePath||"/"}: ${r.message??"unknown error"}`)}}function mv(){return kn||(kn=ad().compile(Eu),kn)}function hv(){return bn||(bn=ad().compile(Cu),bn)}function cd(t){let e=mv();return e(t)?{ok:true,errors:[]}:id(e)}function ud(t){let e=hv();return e(t)?{ok:true,errors:[]}:id(e)}
|
|
24
24
|
exports.COMPLETION_STRATEGIES=Rc;exports.CONFLICT_STRATEGIES=Ec;exports.CardCompute=Ye;exports.DEFAULTS=Cc;exports.EXECUTION_MODES=Tc;exports.EXECUTION_STATUS=$c;exports.FlowEngine=Qe;exports.KVStorageStore=Eo;exports.MemoryJournal=We;exports.MemoryStore=bt;exports.StepMachine=Qe;exports.TASK_STATUS=P;exports.addDynamicTask=Nc;exports.addNode=rr;exports.addProvides=ar;exports.addRequires=sr;exports.apply=wo;exports.applyAll=Mc;exports.applyEvent=un;exports.applyEvents=yt;exports.applyStepResult=pr;exports.batch=Yc;exports.checkCircuitBreaker=fr;exports.computeAvailableOutputs=ue;exports.computeStepInput=mr;exports.createBoardLiveGraphRuntime=Qg;exports.createCallbackHandler=du;exports.createDefaultGraphEngineStore=Yt;exports.createEngine=wn;exports.createFireAndForgetHandler=lu;exports.createInitialExecutionState=Zr;exports.createInitialState=gr;exports.createLiveGraph=cn;exports.createNoopHandler=hu;exports.createProcessHandler=Oo;exports.createReactiveGraph=vt;exports.createScriptHandler=fu;exports.createShellHandler=pu;exports.createStepMachine=wn;exports.createWebhookHandler=mu;exports.detectStuckState=nn;exports.disableNode=fn;exports.drainTokens=ln;exports.enableNode=mn;exports.exportGraphConfig=Ro;exports.exportGraphConfigToFile=Uc;exports.extractReturnData=hr;exports.flowToMermaid=Lc;exports.getAllTasks=G;exports.getCandidateTasks=So;exports.getDownstream=ou;exports.getMaxExecutions=gt;exports.getNode=Zc;exports.getProvides=E;exports.getRefreshStrategy=Je;exports.getRequires=O;exports.getTask=xc;exports.getUnreachableNodes=nu;exports.getUnreachableTokens=xo;exports.getUpstream=su;exports.graphToMermaid=Gc;exports.hasTask=jc;exports.injectTokens=dn;exports.inspect=tu;exports.isExecutionComplete=rn;exports.isNonActiveTask=X;exports.isRerunnable=Ac;exports.isTaskCompleted=Pc;exports.isTaskRunning=Oc;exports.liveCardsToReactiveGraph=Tu;exports.loadGraphConfig=Hc;exports.loadStepFlow=na;exports.mutateGraph=uu;exports.next=Ic;exports.planExecution=Dc;exports.removeNode=nr;exports.removeProvides=ir;exports.removeRequires=or;exports.resetNode=pn;exports.resolveConfigTemplates=Qc;exports.resolveVariables=Xc;exports.restore=eu;exports.schedule=cr;exports.snapshot=hn;exports.validateBoardStatusSchema=cd;exports.validateCardRuntimeSchema=ud;exports.validateFlowSchema=wc;exports.validateGraph=Bc;exports.validateGraphConfig=$o;exports.validateGraphSchema=Jc;exports.validateLiveCard=bu;exports.validateLiveCardDefinition=Io;exports.validateLiveCardRuntimeExpressions=qo;exports.validateLiveCardSchema=No;exports.validateLiveGraph=Po;exports.validateReactiveGraph=iu;exports.validateStepFlowConfig=Rn;//# sourceMappingURL=index.cjs.map
|
|
25
25
|
//# sourceMappingURL=index.cjs.map
|