@robota-sdk/agent-cli 3.0.0-beta.79 → 3.0.0-beta.81
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/README.md +740 -55
- package/dist/node/bin.js +3 -406
- package/dist/node/bounded-output-DpjpS98g-DFgAppgl.js +2 -0
- package/dist/node/bounded-output-DpjpS98g-DFgAppgl.js.map +1 -0
- package/dist/node/bounded-output-DpjpS98g-DoRuRGhV.js +2 -0
- package/dist/node/bounded-output-DpjpS98g-yPybHprY.cjs +1 -0
- package/dist/node/cli-core-Bah38oug.js +2795 -0
- package/dist/node/command-executor-DV-H2oD6-BfKoGoFw.js +2 -0
- package/dist/node/command-executor-DV-H2oD6-OKy8pwYH.js +2 -0
- package/dist/node/command-executor-DV-H2oD6-OKy8pwYH.js.map +1 -0
- package/dist/node/command-executor-DV-H2oD6-iQAXtTLY.cjs +1 -0
- package/dist/node/headless.js +4 -0
- package/dist/node/http-executor-cWzI2svn-C7F17ZGz.cjs +1 -0
- package/dist/node/http-executor-cWzI2svn-TG_TMYKh.js +2 -0
- package/dist/node/http-executor-cWzI2svn-TG_TMYKh.js.map +1 -0
- package/dist/node/http-executor-cWzI2svn-Ype0naht.js +2 -0
- package/dist/node/index.cjs +2641 -251
- package/dist/node/index.d.cts +3421 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.d.ts +3412 -5
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2641 -251
- package/dist/node/index.js.map +1 -1
- package/dist/node/node-2-nrieFn.js +2 -0
- package/dist/node/node-2-nrieFn.js.map +1 -0
- package/dist/node/node-C-hnFnOP.js +67 -0
- package/dist/node/node-CFTax5Wl.cjs +1 -0
- package/dist/node/node-CJnrbkAS.js +14 -0
- package/dist/node/node-CJnrbkAS.js.map +1 -0
- package/dist/node/node-ChG9Tg1I.js +2 -0
- package/dist/node/node-DDl02brx.cjs +66 -0
- package/dist/node/node-DIRGC_1P.js +67 -0
- package/dist/node/node-DIRGC_1P.js.map +1 -0
- package/dist/node/node-OBnZskvR.cjs +1 -0
- package/dist/node/node-bJ0lEuNF.js +2 -0
- package/dist/node/node-bJ0lEuNF.js.map +1 -0
- package/dist/node/node-tf433Aey.cjs +13 -0
- package/dist/node/node-uwhEt6sT.js +14 -0
- package/dist/node/rolldown-runtime-C9xYM0wc.js +1 -0
- package/dist/node/rolldown-runtime-DK3Fl9T5-BIInC43l.cjs +1 -0
- package/dist/node/rolldown-runtime-DK3Fl9T5-BeX3Bzvn.js +2 -0
- package/dist/node/rolldown-runtime-DK3Fl9T5-DK3Fl9T5.js +2 -0
- package/dist/node/rolldown-runtime-DK3Fl9T5-DK3Fl9T5.js.map +1 -0
- package/dist/node/rolldown-runtime-rs7quPpn.js +2 -0
- package/dist/node/verdict-decoder-Dk_w2NG9-BKWMtxp8.js +2 -0
- package/dist/node/verdict-decoder-Dk_w2NG9-Bka7Cldj.js +2 -0
- package/dist/node/verdict-decoder-Dk_w2NG9-Bka7Cldj.js.map +1 -0
- package/dist/node/verdict-decoder-Dk_w2NG9-DNTeVdQ8.cjs +1 -0
- package/dist/web/assets/index-8_Slbxe7.css +1 -0
- package/dist/web/assets/index-Cgu5C1kn.js +77 -0
- package/dist/web/index.html +3 -3
- package/package.json +106 -39
- package/dist/node/bin.d.ts +0 -2
- package/dist/node/bin.js.map +0 -1
- package/dist/web/assets/index-DiahfakU.css +0 -2
- package/dist/web/assets/index-LMW0IDmj.js +0 -37
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{z as e}from"zod";import{zodToJsonSchema as t}from"zod-to-json-schema";function n(e,t,n,r,i,a,o){return{code:t,category:e,message:n,retryable:r,context:i,fix:a,agentHint:o}}function r(e,t,r,i,a){return n(`validation`,e,t,!1,r,i,a)}function i(e,t,r,i,a){return n(`dispatch`,e,t,!0,r,i,a)}function a(e,t,r,i,a,o){return n(`task_execution`,e,t,r,i,a,o)}function o(e){return a(`DAG_TASK_EXECUTION_CANCELLED`,`Task execution was cancelled`,!1,{taskRunId:e})}function s(e,t){let n=[],r=``,i=0,a=(e,a)=>{if(a>t-i)throw c;i+=a,r+=e,r.length>=8192&&(n.push(r),r=``)},o=e=>{a(`"`,1);for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n===34||n===92)a(`\\${e[t]}`,2);else if(n<32){let e=u[n]??`\\u${n.toString(16).padStart(4,`0`)}`;a(e,e.length)}else n<128?a(e[t],1):n<2048?a(e[t],2):n>=55296&&n<=56319&&t+1<e.length&&e.charCodeAt(t+1)>=56320&&e.charCodeAt(t+1)<=57343?(a(e.slice(t,t+2),4),t++):n>=55296&&n<=57343?a(`\\u${n.toString(16)}`,6):a(e[t],3)}a(`"`,1)},s=[],d=new Set,f=e=>{if(e===null)return a(`null`,4);if(typeof e==`string`)return o(e);if(typeof e==`boolean`)return a(e?`true`:`false`,e?4:5);if(typeof e==`number`){let t=JSON.stringify(e);return a(t,t.length)}if(typeof e!=`object`||d.has(e))throw l;if(Array.isArray(e))d.add(e),a(`[`,1),s.push({kind:`array`,value:e,index:0});else{let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw l;d.add(e),a(`{`,1),s.push({kind:`object`,value:e,keys:Object.keys(e),index:0,first:!0})}};try{for(f(e);s.length>0;){let e=s[s.length-1];if(e.kind===`array`){if(e.index===e.value.length){a(`]`,1),d.delete(e.value),s.pop();continue}e.index&&a(`,`,1);let t=Object.getOwnPropertyDescriptor(e.value,String(e.index++));if(t&&!(`value`in t))throw l;let n=t?.value;n===void 0||typeof n==`function`||typeof n==`symbol`?a(`null`,4):f(n)}else{if(e.index===e.keys.length){a(`}`,1),d.delete(e.value),s.pop();continue}let t=e.keys[e.index++],n=Object.getOwnPropertyDescriptor(e.value,t);if(!n||!(`value`in n))throw l;let r=n.value;if(r===void 0||typeof r==`function`||typeof r==`symbol`)continue;e.first||a(`,`,1),e.first=!1,o(t),a(`:`,1),f(r)}}return r&&n.push(r),n.join(``)}catch(e){if(e===c)return;throw e===l?TypeError(`Snapshot must contain plain JSON data without accessors or cycles`):e}}const c=Symbol(`snapshot limit`),l=Symbol(`invalid snapshot`),u={8:`\\b`,9:`\\t`,10:`\\n`,12:`\\f`,13:`\\r`},d=Object.freeze({inputBytes:16*1024*1024,outputBytes:16*1024*1024});function f(e=d){if(!e||!Number.isSafeInteger(e.inputBytes)||e.inputBytes<0||!Number.isSafeInteger(e.outputBytes)||e.outputBytes<0)throw RangeError(`Task snapshot limits must be nonnegative safe integers`);return Object.freeze({inputBytes:e.inputBytes,outputBytes:e.outputBytes})}function p(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t++:r<2048?t+=2:r>=55296&&r<=56319&&e.charCodeAt(n+1)>=56320&&e.charCodeAt(n+1)<=57343?(t+=4,n++):t+=3}return t}var m=class{limits;occupied={input:0,output:0};poisoned=!1;constructor(e){this.limits=f(e)}close(){this.poisoned=!0}error(e){return a(this.poisoned?`DAG_TASK_SNAPSHOT_BUDGET_CLOSED`:`DAG_TASK_SNAPSHOT_BUDGET_EXCEEDED`,this.poisoned?`Task snapshot budget is closed`:`Task ${e} snapshot budget exceeded`,!1)}encode(e,t){if(this.poisoned)return{ok:!1,error:this.error(e)};let n=this.limits[e===`input`?`inputBytes`:`outputBytes`]-this.occupied[e];try{let r=s(t,n);return r===void 0?{ok:!1,error:this.error(e)}:{ok:!0,value:{snapshot:r,bytes:p(r)}}}catch{return{ok:!1,error:a(`DAG_TASK_SNAPSHOT_INVALID`,`Task snapshot must contain plain JSON data`,!1)}}}async admitValue(e,t,n){let r=this.encode(e,t);return r.ok?this.admit(e,r.value.snapshot,()=>n(r.value.snapshot)):r}async admitRun(e,t,n){let r=this.encode(`input`,e);if(!r.ok)return r;this.occupied.input+=r.value.bytes;let i=this.encode(`input`,t);if(!i.ok)return this.occupied.input-=r.value.bytes,i;this.occupied.input+=i.value.bytes;try{return await n(r.value.snapshot,i.value.snapshot),{ok:!0,value:void 0}}catch(e){throw this.poisoned=!0,e}}async admit(e,t,n){let r=p(t),i=e===`input`?this.limits.inputBytes:this.limits.outputBytes;if(this.poisoned||r>i-this.occupied[e])return{ok:!1,error:this.error(e)};this.occupied[e]+=r;try{let t=await n();return t.applied||(this.occupied[e]-=r),{ok:!0,value:t}}catch(e){throw this.poisoned=!0,e}}},h=class{limit;committed=0;reserved=0;closed=!1;constructor(e){if(this.limit=e,e!==void 0&&(!Number.isFinite(e)||e<=0))throw RangeError(`Root credit limit must be positive and finite`)}close(){this.closed=!0}reserve(e){if(!Number.isFinite(e)||e<0)return{ok:!1,error:r(`DAG_VALIDATION_NEGATIVE_ESTIMATED_CREDITS`,`estimatedCredits must be finite and zero or positive`,{estimatedCredits:e})};if(this.closed||this.limit!==void 0&&e>this.limit-this.committed-this.reserved)return{ok:!1,error:r(`DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED`,`Estimated run credits exceeds root runCreditLimit`,{estimatedCredits:e,...this.limit===void 0?{}:{runCreditLimit:this.limit}})};this.reserved+=e;let t=!1;return{ok:!0,value:{commit:()=>(t||(t=!0,this.reserved-=e,this.committed+=e),this.committed),release:()=>{t||(t=!0,this.reserved-=e)}}}}};function g(e){if(e==null)return;if(typeof e!=`object`||Array.isArray(e))throw Error(`Invalid persisted DAG execution lineage`);let t=e,n=t.parentRunId!==void 0,r=!n||typeof t.parentRunId==`string`&&t.parentRunId.length>0;if(typeof t.rootRunId!=`string`||t.rootRunId.length===0||!r||!Number.isSafeInteger(t.depth)||t.depth<0||t.maxDepth!==void 0&&(!Number.isSafeInteger(t.maxDepth)||t.maxDepth<1)||!Array.isArray(t.ancestorCompositeNodeTypes)||!t.ancestorCompositeNodeTypes.every(e=>typeof e==`string`&&e.length>0))throw Error(`Invalid persisted DAG execution lineage`);let i=t.depth,a=t.ancestorCompositeNodeTypes.length;if(!(i===0?!n&&a===0:n&&a===i))throw Error(`Invalid persisted DAG execution lineage`);return{rootRunId:t.rootRunId,...n?{parentRunId:t.parentRunId}:{},depth:i,...t.maxDepth===void 0?{}:{maxDepth:t.maxDepth},ancestorCompositeNodeTypes:[...t.ancestorCompositeNodeTypes]}}const _=Object.freeze({maxTextRepeatOutputBytes:4*1024*1024,maxTextReplaceOutputBytes:4*1024*1024,maxTextTemplateOutputBytes:4*1024*1024,maxTextJoinOutputBytes:4*1024*1024,maxTextSplitOutputBytes:4*1024*1024,maxTextTransformOutputBytes:4*1024*1024,maxTextUpperOutputBytes:4*1024*1024,maxTextLowerOutputBytes:4*1024*1024,maxHttpResponseBodyBytes:4*1024*1024});function ee(e){let t=e===void 0?_.maxTextRepeatOutputBytes:e.maxTextRepeatOutputBytes;if(!Number.isSafeInteger(t)||t<0||t>_.maxTextRepeatOutputBytes)throw RangeError(`maxTextRepeatOutputBytes must be a safe integer between 0 and 4194304`);let n=e&&`maxTextReplaceOutputBytes`in e?e.maxTextReplaceOutputBytes:4*1024*1024;if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0||n>4*1024*1024)throw RangeError(`maxTextReplaceOutputBytes must be a safe integer between 0 and 4194304`);let r=e&&`maxTextTemplateOutputBytes`in e?e.maxTextTemplateOutputBytes:4*1024*1024;if(typeof r!=`number`||!Number.isSafeInteger(r)||r<0||r>4*1024*1024)throw RangeError(`maxTextTemplateOutputBytes must be a safe integer between 0 and 4194304`);let i=e&&`maxTextJoinOutputBytes`in e?e.maxTextJoinOutputBytes:4*1024*1024;if(typeof i!=`number`||!Number.isSafeInteger(i)||i<0||i>4*1024*1024)throw RangeError(`maxTextJoinOutputBytes must be a safe integer between 0 and 4194304`);let a=e&&`maxTextSplitOutputBytes`in e?e.maxTextSplitOutputBytes:4*1024*1024;if(typeof a!=`number`||!Number.isSafeInteger(a)||a<0||a>4*1024*1024)throw RangeError(`maxTextSplitOutputBytes must be a safe integer between 0 and 4194304`);let o=e&&`maxTextTransformOutputBytes`in e?e.maxTextTransformOutputBytes:4*1024*1024;if(typeof o!=`number`||!Number.isSafeInteger(o)||o<0||o>4*1024*1024)throw RangeError(`maxTextTransformOutputBytes must be a safe integer between 0 and 4194304`);let s=e&&`maxTextUpperOutputBytes`in e?e.maxTextUpperOutputBytes:4*1024*1024;if(typeof s!=`number`||!Number.isSafeInteger(s)||s<0||s>4*1024*1024)throw RangeError(`maxTextUpperOutputBytes must be a safe integer between 0 and 4194304`);let c=e&&`maxTextLowerOutputBytes`in e?e.maxTextLowerOutputBytes:4*1024*1024;if(typeof c!=`number`||!Number.isSafeInteger(c)||c<0||c>4*1024*1024)throw RangeError(`maxTextLowerOutputBytes must be a safe integer between 0 and 4194304`);let l=e&&`maxHttpResponseBodyBytes`in e?e.maxHttpResponseBodyBytes:4*1024*1024;if(typeof l!=`number`||!Number.isSafeInteger(l)||l<0||l>4*1024*1024)throw RangeError(`maxHttpResponseBodyBytes must be a safe integer between 0 and 4194304`);return Object.freeze({maxTextRepeatOutputBytes:t,maxTextReplaceOutputBytes:n,maxTextTemplateOutputBytes:r,maxTextJoinOutputBytes:i,maxTextSplitOutputBytes:a,maxTextTransformOutputBytes:o,maxTextUpperOutputBytes:s,maxTextLowerOutputBytes:c,maxHttpResponseBodyBytes:l})}function v(e){let t=e.lastIndexOf(`[`);if(t<=0||!e.endsWith(`]`))return;let n=e.slice(0,t),r=e.slice(t+1,e.length-1);if(/^\d+$/.test(r))return{portKey:n,index:Number.parseInt(r,10)}}const y={CREATED:`created`,QUEUED:`queued`,RUNNING:`running`,SUCCESS:`success`,FAILED:`failed`,CANCELLED:`cancelled`},b={CREATED:`created`,QUEUED:`queued`,RUNNING:`running`,SUCCESS:`success`,FAILED:`failed`,UPSTREAM_FAILED:`upstream_failed`,SKIPPED:`skipped`,CANCELLED:`cancelled`},te={STARTED:`execution.started`,COMPLETED:`execution.completed`,FAILED:`execution.failed`},ne={STARTED:`task.started`,COMPLETED:`task.completed`,FAILED:`task.failed`},re={[`${y.CREATED}:QUEUE`]:y.QUEUED,[`${y.CREATED}:CANCEL`]:y.CANCELLED,[`${y.QUEUED}:START`]:y.RUNNING,[`${y.QUEUED}:CANCEL`]:y.CANCELLED,[`${y.RUNNING}:COMPLETE_SUCCESS`]:y.SUCCESS,[`${y.RUNNING}:COMPLETE_FAILURE`]:y.FAILED,[`${y.RUNNING}:CANCEL`]:y.CANCELLED};function x(e,t){return{code:`DAG_STATE_TRANSITION_INVALID`,category:`state_transition`,message:`DagRun transition is not allowed: ${e} -> ${t}`,retryable:!1,context:{currentStatus:e,event:t}}}function ie(e){return`run.${e}`}var S=class{static transition(e,t){let n=`${e}:${t}`,r=re[n];return r?{ok:!0,value:{nextStatus:r,domainEvents:[ie(r)]}}:{ok:!1,error:x(e,t)}}};const ae={[`${b.CREATED}:QUEUE`]:b.QUEUED,[`${b.CREATED}:CANCEL`]:b.CANCELLED,[`${b.QUEUED}:START`]:b.RUNNING,[`${b.QUEUED}:UPSTREAM_FAIL`]:b.UPSTREAM_FAILED,[`${b.QUEUED}:SKIP`]:b.SKIPPED,[`${b.QUEUED}:CANCEL`]:b.CANCELLED,[`${b.RUNNING}:COMPLETE_SUCCESS`]:b.SUCCESS,[`${b.RUNNING}:COMPLETE_FAILURE`]:b.FAILED,[`${b.RUNNING}:CANCEL`]:b.CANCELLED,[`${b.FAILED}:RETRY`]:b.QUEUED,[`${b.RUNNING}:RECLAIM`]:b.QUEUED};function oe(e,t){return{code:`DAG_STATE_TRANSITION_INVALID`,category:`state_transition`,message:`TaskRun transition is not allowed: ${e} -> ${t}`,retryable:!1,context:{currentStatus:e,event:t}}}function se(e){return`task.${e}`}var C=class{static transition(e,t){let n=`${e}:${t}`,r=ae[n];return r?{ok:!0,value:{nextStatus:r,domainEvents:[se(r)]}}:{ok:!1,error:oe(e,t)}}};function w(e,t,n){e.push({path:t,message:n})}function T(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:`${e}.${t}`}function E(e,t,n){return typeof e!=`object`||!e||Array.isArray(e)?w(n,t,`expected an object, got ${P(e)}`):e}function D(e,t,n){return typeof e==`string`?e:w(n,t,`expected a string, got ${P(e)}`)}function O(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:w(n,t,`expected a finite number, got ${P(e)}`)}function k(e,t,n){return typeof e==`boolean`?e:w(n,t,`expected a boolean, got ${P(e)}`)}function A(e,t,n,r){return typeof e==`string`&&t.includes(e)?e:w(r,n,`expected one of ${t.map(e=>`'${e}'`).join(`, `)}, got ${P(e)}`)}function j(e,t,n,r){return e===void 0?void 0:r(e,t,n)}function M(e,t,n,r){if(!Array.isArray(e))return w(n,t,`expected an array, got ${P(e)}`);let i=n.length,a=e.map((e,i)=>r(e,T(t,i),n));return n.length===i?a:void 0}function N(e,t,n){return M(e,t,n,D)}function P(e){return e===null?`null`:Array.isArray(e)?`an array`:typeof e==`string`?`string '${e.length>40?`${e.slice(0,40)}…`:e}'`:typeof e}function F(e){return e.map(e=>`${e.path===``?`$`:e.path}: ${e.message}`).join(`; `)}function ce(e,t,n,i={}){return r(e,`${t}: ${F(n)}`,{...i,issueCount:n.length,firstIssuePath:n[0]?.path??``})}const le=[`draft`,`published`,`deprecated`],ue=[`string`,`number`,`boolean`,`object`,`array`,`binary`],de=[`image`,`video`,`audio`,`file`];function I(e,t={}){let n=[],r=fe(e,``,n,t);return r!==void 0&&n.length===0?{ok:!0,value:r}:{ok:!1,error:n}}function L(e,t,n,r={},i={}){let a=I(e,i);return a.ok?a:{ok:!1,error:ce(t,n,a.error,r)}}function fe(e,t,n,r){let i=E(e,t,n);if(i===void 0)return;let a=D(i.dagId,T(t,`dagId`),n),o=O(i.version,T(t,`version`),n),s=i.status===void 0&&r.absentStatus!==void 0?r.absentStatus:A(i.status,le,T(t,`status`),n),c=M(i.nodes,T(t,`nodes`),n,me),l=i.edges===void 0&&r.absentEdgesAsEmpty?[]:M(i.edges,T(t,`edges`),n,ge),u=j(i.costPolicy,T(t,`costPolicy`),n,R),d=j(i.inputSchema,T(t,`inputSchema`),n,D),f=j(i.outputSchema,T(t,`outputSchema`),n,D);if(a===void 0||o===void 0||s===void 0||c===void 0||l===void 0)return;let p={dagId:a,version:o,status:s,nodes:c,edges:l};return u!==void 0&&(p.costPolicy=u),d!==void 0&&(p.inputSchema=d),f!==void 0&&(p.outputSchema=f),p}function R(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=O(r.runCreditLimit,T(t,`runCreditLimit`),n),a=O(r.costPolicyVersion,T(t,`costPolicyVersion`),n);return i===void 0||a===void 0?void 0:{runCreditLimit:i,costPolicyVersion:a}}function pe(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=O(r.x,T(t,`x`),n),a=O(r.y,T(t,`y`),n);return i===void 0||a===void 0?void 0:{x:i,y:a}}function z(e,t,n){return e===null||[`string`,`number`,`boolean`].includes(typeof e)?e:Array.isArray(e)?M(e,t,n,z):typeof e==`object`?B(e,t,n):w(n,t,`expected a JSON value, got ${typeof e}`)}function B(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i={},a=n.length;for(let[e,a]of Object.entries(r)){let r=z(a,T(t,e),n);r!==void 0&&(i[e]=r)}return n.length===a?i:void 0}function V(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=e=>T(t,e),a=D(r.key,i(`key`),n),o=A(r.type,ue,i(`type`),n),s=k(r.required,i(`required`),n),c=j(r.label,i(`label`),n,D),l=j(r.order,i(`order`),n,O),u=j(r.description,i(`description`),n,D),d=j(r.binaryKind,i(`binaryKind`),n,(e,t,n)=>A(e,de,t,n)),f=j(r.mimeTypes,i(`mimeTypes`),n,N),p=j(r.isList,i(`isList`),n,k),m=j(r.minItems,i(`minItems`),n,O),h=j(r.maxItems,i(`maxItems`),n,O);if(a===void 0||o===void 0||s===void 0)return;let g={key:a,type:o,required:s};return c!==void 0&&(g.label=c),l!==void 0&&(g.order=l),u!==void 0&&(g.description=u),d!==void 0&&(g.binaryKind=d),f!==void 0&&(g.mimeTypes=f),p!==void 0&&(g.isList=p),m!==void 0&&(g.minItems=m),h!==void 0&&(g.maxItems=h),g}function me(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=e=>T(t,e),a=D(r.nodeId,i(`nodeId`),n),o=D(r.nodeType,i(`nodeType`),n),s=N(r.dependsOn,i(`dependsOn`),n),c=B(r.config,i(`config`),n),l=j(r.position,i(`position`),n,pe),u=j(r.triggerPolicy,i(`triggerPolicy`),n,D),d=j(r.retryPolicy,i(`retryPolicy`),n,D),f=j(r.timeoutMs,i(`timeoutMs`),n,O),p=j(r.inputs,i(`inputs`),n,(e,t,n)=>M(e,t,n,V)),m=j(r.outputs,i(`outputs`),n,(e,t,n)=>M(e,t,n,V)),h=j(r.costPolicy,i(`costPolicy`),n,R);if(a===void 0||o===void 0||s===void 0||c===void 0)return;let g={nodeId:a,nodeType:o,dependsOn:s,config:c};return l!==void 0&&(g.position=l),u!==void 0&&(g.triggerPolicy=u),d!==void 0&&(g.retryPolicy=d),f!==void 0&&(g.timeoutMs=f),p!==void 0&&(g.inputs=p),m!==void 0&&(g.outputs=m),h!==void 0&&(g.costPolicy=h),g}function he(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=D(r.outputKey,T(t,`outputKey`),n),a=D(r.inputKey,T(t,`inputKey`),n);return i===void 0||a===void 0?void 0:{outputKey:i,inputKey:a}}function ge(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=D(r.from,T(t,`from`),n),a=D(r.to,T(t,`to`),n),o=j(r.bindings,T(t,`bindings`),n,(e,t,n)=>M(e,t,n,he));if(i===void 0||a===void 0)return;let s={from:i,to:a};return o!==void 0&&(s.bindings=o),s}function _e(e){let t=[],n=Se(e,``,t);return n!==void 0&&t.length===0?{ok:!0,value:n}:{ok:!1,error:t}}function H(e,t,n){if(!Array.isArray(e)||e.length!==2)return w(n,t,`expected a [number, number] pair`);let r=O(e[0],T(t,0),n),i=O(e[1],T(t,1),n);return r===void 0||i===void 0?void 0:[r,i]}function ve(e,t,n){if(!Array.isArray(e)||e.length!==6)return w(n,t,`expected a 6-tuple [linkId, srcId, srcSlot, tgtId, tgtSlot, type]`);let r=[0,1,2,3,4].map(r=>O(e[r],T(t,r),n)),i=D(e[5],T(t,5),n);if(r.some(e=>e===void 0)||i===void 0)return;let[a,o,s,c,l]=r;return[a,o,s,c,l,i]}function ye(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=D(r.name,T(t,`name`),n),a=D(r.type,T(t,`type`),n),o=r.link,s=o===null?null:O(o,T(t,`link`),n);return i===void 0||a===void 0||s===void 0?void 0:{name:i,type:a,link:s}}function be(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=D(r.name,T(t,`name`),n),a=D(r.type,T(t,`type`),n),o=M(r.links,T(t,`links`),n,O),s=j(r.slot_index,T(t,`slot_index`),n,O);if(i===void 0||a===void 0||o===void 0)return;let c={name:i,type:a,links:o};return s!==void 0&&(c.slot_index=s),c}function xe(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=e=>T(t,e),a=O(r.id,i(`id`),n),o=D(r.type,i(`type`),n),s=H(r.pos,i(`pos`),n),c=j(r.size,i(`size`),n,H),l=j(r.flags,i(`flags`),n,E),u=j(r.order,i(`order`),n,O),d=j(r.mode,i(`mode`),n,O),f=j(r.inputs,i(`inputs`),n,(e,t,n)=>M(e,t,n,ye)),p=j(r.outputs,i(`outputs`),n,(e,t,n)=>M(e,t,n,be)),m=j(r.properties,i(`properties`),n,E),h=j(r.widgets_values,i(`widgets_values`),n,(e,t,n)=>Array.isArray(e)?e:w(n,t,`expected an array`));if(a===void 0||o===void 0||s===void 0)return;let g={id:a,type:o,pos:s};return c!==void 0&&(g.size=c),l!==void 0&&(g.flags=l),u!==void 0&&(g.order=u),d!==void 0&&(g.mode=d),f!==void 0&&(g.inputs=f),p!==void 0&&(g.outputs=p),m!==void 0&&(g.properties=m),h!==void 0&&(g.widgets_values=h),g}function Se(e,t,n){let r=E(e,t,n);if(r===void 0)return;let i=e=>T(t,e);if(`dagId`in r)return w(n,i(`dagId`),`a workflow file carries no dagId — that is a definition file`);let a=O(r.last_node_id,i(`last_node_id`),n),o=O(r.last_link_id,i(`last_link_id`),n),s=M(r.nodes,i(`nodes`),n,xe),c=M(r.links,i(`links`),n,ve),l=O(r.version,i(`version`),n),u=j(r.groups,i(`groups`),n,(e,t,n)=>Array.isArray(e)?e:w(n,t,`expected an array`)),d=j(r.config,i(`config`),n,E),f=j(r.extra,i(`extra`),n,E);if(a===void 0||o===void 0||s===void 0||c===void 0||l===void 0)return;let p={last_node_id:a,last_link_id:o,nodes:s,links:c,version:l};return u!==void 0&&(p.groups=u),d!==void 0&&(p.config=d),f!==void 0&&(p.extra=f),p}function U(e){let t=Date.parse(e);return Number.isNaN(t)?{ok:!1,error:r(`DAG_VALIDATION_INVALID_LOGICAL_DATE`,`logicalDate must be a valid ISO-8601 datetime string`,{logicalDate:e})}:{ok:!0,value:new Date(t).toISOString()}}var Ce=class{clock;constructor(e){this.clock=e}resolve(e,t){let n=this.clock.nowIso();if(e===`scheduled`){if(!t)return{ok:!1,error:r(`DAG_VALIDATION_MISSING_LOGICAL_DATE`,`scheduled trigger requires logicalDate`,{trigger:e})};let i=U(t);return i.ok?{ok:!0,value:{trigger:e,logicalDate:i.value,requestedAt:n}}:i}if(!t)return{ok:!0,value:{trigger:e,logicalDate:n,requestedAt:n}};let i=U(t);return i.ok?{ok:!0,value:{trigger:e,logicalDate:i.value,requestedAt:n}}:i}},we=class{assertWithinBudget(e,t,n){if(t<0)return{ok:!1,error:r(`DAG_VALIDATION_NEGATIVE_ESTIMATED_CREDITS`,`estimatedCredits must be zero or positive`,{nextEstimatedCredits:t})};let i=e+t;return typeof n==`number`&&i>n?{ok:!1,error:r(`DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED`,`Estimated run credits exceeds runCreditLimit`,{nextTotalCredits:i,runCreditLimit:n})}:{ok:!0,value:i}}},Te=class{lifecycleFactory;costPolicyEvaluator;constructor(e,t){this.lifecycleFactory=e,this.costPolicyEvaluator=t}async runNode(e){let t=()=>({ok:!1,error:o(e.context.taskRunId)});if(e.context.signal?.aborted)return t();let n=this.lifecycleFactory.create(e.context.nodeDefinition.nodeType);if(!n.ok)return n;let r=await n.value.initialize(e.context);if(e.context.signal?.aborted)return await n.value.dispose(e.context),t();if(!r.ok)return r;let i=await n.value.validateInput(e.input,e.context);if(e.context.signal?.aborted)return await n.value.dispose(e.context),t();if(!i.ok)return await n.value.dispose(e.context),i;let s=await n.value.estimateCost(e.input,e.context);if(e.context.signal?.aborted)return await n.value.dispose(e.context),t();if(!s.ok)return await n.value.dispose(e.context),s;let c=this.costPolicyEvaluator.assertWithinBudget(e.context.currentTotalCredits,s.value.estimatedCredits,e.context.runCreditLimit);if(!c.ok)return await n.value.dispose(e.context),c;if(e.context.reserveCredits){let r=await e.context.reserveCredits(s.value.estimatedCredits);if(!r.ok)return await n.value.dispose(e.context),r;if(e.context.signal?.aborted)return await n.value.dispose(e.context),t()}let l=e.context.rootCreditBudget?.reserve(s.value.estimatedCredits);if(l&&!l.ok)return await n.value.dispose(e.context),l;try{let r=await n.value.execute(e.input,e.context);if(e.context.signal?.aborted)return await n.value.dispose(e.context),t();if(!r.ok)return await n.value.dispose(e.context),r;let i=await n.value.validateOutput(r.value,e.context);if(e.context.signal?.aborted)return await n.value.dispose(e.context),t();if(!i.ok)return await n.value.dispose(e.context),i;let o=await n.value.dispose(e.context);return e.context.signal?.aborted?t():o.ok?(l?.value.commit(),{ok:!0,value:{output:r.value,estimatedCredits:s.value.estimatedCredits,totalCredits:c.value}}):{ok:!1,error:a(`DAG_TASK_EXECUTION_DISPOSE_FAILED`,`Node dispose step failed after execution`,!1,{nodeType:e.context.nodeDefinition.nodeType,taskRunId:e.context.taskRunId})}}finally{l?.ok&&l.value.release()}}},Ee=class{create(e){return{ok:!1,error:r(`DAG_VALIDATION_NODE_LIFECYCLE_NOT_REGISTERED`,`Node lifecycle is not registered for nodeType`,{nodeType:e})}}},De=class{nodeManifestRegistry;lineage;lifecycleFactory;runner;constructor(e,t,n){this.nodeManifestRegistry=e,this.lineage=n,this.lifecycleFactory=t??new Ee,this.runner=new Te(this.lifecycleFactory,new we)}async execute(e){if(!e.nodeDefinition)return{ok:!1,error:r(`DAG_VALIDATION_NODE_DEFINITION_MISSING`,`Task execution requires nodeDefinition in execution input`,{nodeId:e.nodeId})};let t=this.nodeManifestRegistry.getManifest(e.nodeDefinition.nodeType);if(!t)return{ok:!1,error:r(`DAG_VALIDATION_NODE_MANIFEST_NOT_FOUND`,`Node manifest is not registered for nodeType`,{nodeType:e.nodeDefinition.nodeType})};let n=await this.runner.runNode({input:e.input,context:{executionRoot:e.executionRoot,regexReplaceOperation:e.regexReplaceOperation,snapshotBudget:e.snapshotBudget,rootCreditBudget:e.rootCreditBudget,reserveCredits:e.reserveCredits,...e.byteLimits===void 0?{}:{byteLimits:e.byteLimits},...e.signal===void 0?{}:{signal:e.signal},dagId:e.dagId,dagRunId:e.dagRunId,taskRunId:e.taskRunId,nodeDefinition:e.nodeDefinition,nodeManifest:t,attempt:e.attempt,executionPath:e.executionPath,lineage:e.lineage??this.lineage??{rootRunId:e.dagRunId,depth:0,ancestorCompositeNodeTypes:[]},runCreditLimit:e.costPolicy?.runCreditLimit,currentTotalCredits:e.currentTotalCredits??0,...e.runtimeBaseUrl===void 0?{}:{runtimeBaseUrl:e.runtimeBaseUrl}}});return n.ok?{ok:!0,output:n.value.output,estimatedCredits:n.value.estimatedCredits,totalCredits:n.value.totalCredits}:n}};const Oe={root:`.workflows`,workflowExt:`.json`};function W(e,t,n){let i={result:{applied:!1,runStatus:e?.status}};if(!e)return i;if(n.kind===`transition-run`){if(e.status!==n.expectedStatus)return i;let t=S.transition(e.status,n.event);if(!t.ok)return i;let r={...e,status:t.value.nextStatus,endedAt:n.endedAt};return{dagRun:r,result:{applied:!0,runStatus:r.status}}}if(n.kind===`finalize`){if(e.status!==`running`||t.some(e=>[`created`,`queued`,`running`].includes(e.status)))return i;let r=ke(e,t);if(!r.ok)return{result:{...i.result,error:r.error}};if(r.value)return i;let a=S.transition(e.status,t.some(e=>e.status===`failed`)?`COMPLETE_FAILURE`:`COMPLETE_SUCCESS`);if(!a.ok)return i;let o=a.value.nextStatus;return{dagRun:{...e,status:o,endedAt:n.endedAt},result:{applied:!0,runStatus:o}}}if(n.kind===`admit`)return e.status!==`running`||n.taskRun.dagRunId!==e.dagRunId||t.some(e=>e.nodeId===n.taskRun.nodeId||e.taskRunId===n.taskRun.taskRunId)||!n.dependsOn.every(e=>t.some(t=>t.nodeId===e&&t.status===`success`))?i:{taskRun:n.taskRun,result:{applied:!0,runStatus:e.status,taskRun:n.taskRun}};let a=t.find(e=>e.taskRunId===n.taskRunId);if(n.kind===`cancel-task`){if(!a||![`failed`,`cancelled`].includes(e.status))return i;let t=C.transition(a.status,`CANCEL`);if(!t.ok)return i;let r={...a,status:t.value.nextStatus,leaseOwner:void 0,leaseUntil:void 0,reservedCredits:void 0,reservationAttempt:void 0,reservationOwner:void 0,errorCode:n.error?.code,errorMessage:n.error?.message};return{taskRun:r,result:{applied:!0,runStatus:e.status,taskRun:r}}}if(!a||a.status!==`running`||a.attempt!==n.attempt||a.leaseOwner!==n.leaseOwner)return i;if(e.status!==`running`){if(e.status!==`cancelled`||a.status!==`running`)return i;let t={...a,status:`cancelled`,leaseOwner:void 0,leaseUntil:void 0,reservedCredits:void 0,reservationAttempt:void 0,reservationOwner:void 0};return{taskRun:t,result:{applied:!1,runStatus:e.status,taskRun:t}}}if(n.kind===`snapshot-input`){let t={...a,inputSnapshot:n.inputSnapshot};return{taskRun:t,result:{applied:!0,runStatus:e.status,taskRun:t}}}if(n.kind===`reserve-credits`){let o=n.estimatedCredits;if(!Number.isFinite(o)||o<0||e.definitionSnapshot===void 0)return i;let s;try{s=JSON.parse(e.definitionSnapshot)}catch{return i}let c=L(s,`DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID`,`DagRun definition snapshot has invalid shape`,{dagRunId:e.dagRunId});if(!c.ok||c.value.costPolicy===void 0)return i;let l=c.value.costPolicy.runCreditLimit;if(a.reservedCredits!==void 0)return{result:{...i.result,applied:a.reservationAttempt===n.attempt&&a.reservationOwner===n.leaseOwner&&a.reservedCredits===o}};let u=G(t);if(!u.ok)return{result:{...i.result,error:u.error}};let d=u.value+t.reduce((e,t)=>e+(t.reservedCredits??0),0);if(d+o>l)return{result:{...i.result,error:r(`DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED`,`Estimated run credits exceeds runCreditLimit`,{nextTotalCredits:d+o,runCreditLimit:l})}};let f={...a,reservedCredits:o,reservationAttempt:n.attempt,reservationOwner:n.leaseOwner};return{taskRun:f,result:{applied:!0,runStatus:e.status,taskRun:f}}}let o=C.transition(a.status,n.status===`success`?`COMPLETE_SUCCESS`:`COMPLETE_FAILURE`);if(!o.ok)return i;if(n.status===`success`&&e.definitionSnapshot!==void 0){let t;try{t=JSON.parse(e.definitionSnapshot)}catch{return i}let n=L(t,`DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID`,`DagRun definition snapshot has invalid shape`,{dagRunId:e.dagRunId});if(!n.ok||n.value.costPolicy!==void 0&&a.reservedCredits===void 0)return i}if(n.status===`success`&&a.reservedCredits!==void 0&&(a.reservationAttempt!==n.attempt||a.reservationOwner!==n.leaseOwner||n.estimatedCredits!==a.reservedCredits))return i;let s=n.status===`success`&&a.reservedCredits!==void 0?G(t):void 0;if(s&&!s.ok)return{result:{...i.result,error:s.error}};let c=n.status===`failed`&&n.reserveRetry===!0,l=c?C.transition(o.value.nextStatus,`RETRY`):void 0;if(l&&!l.ok)return i;let u={...a,status:l?.ok?l.value.nextStatus:o.value.nextStatus,attempt:c?a.attempt+1:a.attempt,reservedCredits:void 0,reservationAttempt:void 0,reservationOwner:void 0,errorCode:c?void 0:n.error?.code,errorMessage:c?void 0:n.error?.message,...n.outputSnapshot===void 0?{}:{outputSnapshot:n.outputSnapshot},...n.estimatedCredits===void 0?{}:{estimatedCredits:n.estimatedCredits},...n.status!==`success`||a.reservedCredits===void 0?n.totalCredits===void 0?{}:{totalCredits:n.totalCredits}:{totalCredits:s.value+a.reservedCredits}};return{taskRun:u,result:{applied:!0,runStatus:e.status,taskRun:u}}}function G(e){let t=0,n=0;for(let r of e)if(r.status===`success`){if(r.totalCredits!==void 0){if(!Number.isFinite(r.totalCredits)||r.totalCredits<0)return K(r);n=Math.max(n,r.totalCredits)}if(r.estimatedCredits===void 0&&r.totalCredits===void 0)return K(r);if(r.estimatedCredits!==void 0){if(!Number.isFinite(r.estimatedCredits)||r.estimatedCredits<0)return K(r);t+=r.estimatedCredits}}return{ok:!0,value:Math.max(t,n)}}function K(e){return{ok:!1,error:r(`DAG_VALIDATION_CREDIT_HISTORY_AMBIGUOUS`,`Prior task credits cannot be accounted for safely`,{taskRunId:e.taskRunId})}}function ke(e,t){if(e.definitionSnapshot===void 0)return{ok:!0,value:!1};let n;try{n=JSON.parse(e.definitionSnapshot)}catch{return{ok:!1,error:r(`DAG_VALIDATION_DEFINITION_SNAPSHOT_PARSE_FAILED`,`Failed to parse DagRun definition snapshot`,{dagRunId:e.dagRunId})}}let i=L(n,`DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID`,`DagRun definition snapshot has invalid shape`,{dagRunId:e.dagRunId});return i.ok?{ok:!0,value:i.value.nodes.some(e=>!t.some(t=>t.nodeId===e.nodeId)&&e.dependsOn.every(e=>t.some(t=>t.nodeId===e&&t.status===`success`)))}:i}function Ae(e,t,n){let i=n.issues[0];return r(`DAG_VALIDATION_NODE_CONFIG_SCHEMA_INVALID`,`Node config does not satisfy schema: ${i?.path.join(`.`)??`config`} ${i?.message??`Invalid config`}`,{nodeId:t.nodeDefinition.nodeId,nodeType:e,issueCount:n.issues.length})}var je=class{defaultInputPort;defaultOutputPort;taskHandler;constructor(){this.taskHandler={initialize:async e=>{let t=this.parseNodeConfig(e);return t.ok?this.initializeWithConfig(e,t.value):t},validateInput:async(e,t)=>{let n=this.parseNodeConfig(t);return n.ok?this.validateInputWithConfig(e,t,n.value):n},estimateCost:async(e,t)=>{let n=this.parseNodeConfig(t);return n.ok?this.estimateCostWithConfig(e,t,n.value):n},execute:async(e,t)=>{let n=this.parseNodeConfig(t);return n.ok?this.executeWithConfig(e,t,n.value):n},validateOutput:async(e,t)=>{let n=this.parseNodeConfig(t);return n.ok?this.validateOutputWithConfig(e,t,n.value):n},dispose:async e=>{let t=this.parseNodeConfig(e);return t.ok?this.disposeWithConfig(e,t.value):t}}}parseNodeConfig(e){let t=this.configSchemaDefinition.safeParse(e.nodeDefinition.config);return t.success?{ok:!0,value:t.data}:{ok:!1,error:Ae(this.nodeType,e,t.error)}}async initializeWithConfig(e,t){return{ok:!0,value:void 0}}async validateInputWithConfig(e,t,n){return{ok:!0,value:void 0}}async validateOutputWithConfig(e,t,n){return{ok:!0,value:void 0}}async disposeWithConfig(e,t){return{ok:!0,value:void 0}}};const q=`asset://`;var J=class e{value;constructor(e){this.value=e}static fromAssetReference(t){return t.referenceType===`asset`?new e({referenceType:`asset`,assetId:t.assetId,mediaType:t.mediaType,name:t.name,sizeBytes:t.sizeBytes}):new e({referenceType:`uri`,uri:t.uri,mediaType:t.mediaType,name:t.name,sizeBytes:t.sizeBytes})}static fromBinary(t){if(typeof t.assetId==`string`&&t.assetId.trim().length>0)return{ok:!0,value:new e({referenceType:`asset`,assetId:t.assetId.trim(),mediaType:t.mimeType,sizeBytes:t.sizeBytes})};if(t.uri.startsWith(q)){let n=t.uri.slice(8).trim();return n.length===0?{ok:!1,error:r(`DAG_VALIDATION_MEDIA_REFERENCE_INVALID`,`Binary asset URI must include non-empty assetId`)}:{ok:!0,value:new e({referenceType:`asset`,assetId:n,mediaType:t.mimeType,sizeBytes:t.sizeBytes})}}return{ok:!0,value:new e({referenceType:`uri`,uri:t.uri,mediaType:t.mimeType,sizeBytes:t.sizeBytes})}}static fromCandidate(e,t){let n=typeof e.assetId==`string`&&(t?.allowEmptyAssetId===!0||e.assetId.trim().length>0),i=typeof e.uri==`string`&&(t?.allowEmptyUri===!0||e.uri.trim().length>0);return n===i?{ok:!1,error:r(`DAG_VALIDATION_MEDIA_REFERENCE_XOR_REQUIRED`,`Exactly one of assetId or uri must be provided`)}:e.referenceType===`asset`&&!n?{ok:!1,error:r(`DAG_VALIDATION_MEDIA_REFERENCE_TYPE_MISMATCH`,`referenceType asset requires assetId`)}:e.referenceType===`uri`&&!i?{ok:!1,error:r(`DAG_VALIDATION_MEDIA_REFERENCE_TYPE_MISMATCH`,`referenceType uri requires uri`)}:this.buildFromValidatedCandidate(e,n)}static buildFromValidatedCandidate(t,n){return n&&typeof t.assetId==`string`?{ok:!0,value:new e({referenceType:`asset`,assetId:t.assetId.trim(),mediaType:t.mediaType,name:t.name,sizeBytes:t.sizeBytes})}:typeof t.uri==`string`?{ok:!0,value:new e({referenceType:`uri`,uri:t.uri,mediaType:t.mediaType,name:t.name,sizeBytes:t.sizeBytes})}:{ok:!1,error:r(`DAG_VALIDATION_MEDIA_REFERENCE_INVALID`,`uri must be a string when referenceType is uri`)}}isAsset(){return this.value.referenceType===`asset`}isUri(){return this.value.referenceType===`uri`}assetId(){return this.value.assetId}uri(){return this.value.uri}mediaType(){return this.value.mediaType}toAssetIdOrUri(){return this.value.referenceType===`asset`&&typeof this.value.assetId==`string`?{referenceType:`asset`,assetId:this.value.assetId}:{referenceType:`uri`,uri:this.value.uri??``}}toAssetContentUrl(e){if(!(!this.isAsset()||typeof this.value.assetId!=`string`))return`${e.replace(/\/$/,``)}/view?filename=${encodeURIComponent(this.value.assetId)}`}toBinary(e,t){let n=typeof this.value.mediaType==`string`&&this.value.mediaType.trim().length>0?this.value.mediaType:t;return this.value.referenceType===`asset`&&typeof this.value.assetId==`string`?{kind:e,mimeType:n,uri:`${q}${this.value.assetId}`,referenceType:`asset`,assetId:this.value.assetId,sizeBytes:this.value.sizeBytes}:{kind:e,mimeType:n,uri:this.value.uri??``,referenceType:`uri`,sizeBytes:this.value.sizeBytes}}};function Y(e,t,n,i){if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input key must be binary payload object`,{nodeId:t,key:n,expectedType:`binary`})};let a=e;if(a.kind!==`image`&&a.kind!==`video`&&a.kind!==`audio`&&a.kind!==`file`||typeof a.mimeType!=`string`||typeof a.uri!=`string`)return{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input key must be valid binary payload`,{nodeId:t,key:n,expectedType:`binary`})};let o=a.kind;return i&&o!==i?{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input binary kind does not match expected kind`,{nodeId:t,key:n,expectedKind:i,actualKind:o})}:{ok:!0,value:{kind:o,mimeType:a.mimeType,uri:a.uri,referenceType:a.referenceType===`asset`||a.referenceType===`uri`?a.referenceType:void 0,assetId:typeof a.assetId==`string`?a.assetId:void 0,sizeBytes:typeof a.sizeBytes==`number`?a.sizeBytes:void 0}}}var Me=class{input;nodeId;output={};constructor(e,t){this.input=e,this.nodeId=t}getInput(e){return this.input[e]}requireInput(e){let t=this.getInput(e);return t===void 0?{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_MISSING`,`Node input key is missing`,{nodeId:this.nodeId,key:e})}:{ok:!0,value:t}}requireInputString(e){let t=this.requireInput(e);return t.ok?typeof t.value==`string`?{ok:!0,value:t.value}:{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input key must be string`,{nodeId:this.nodeId,key:e,expectedType:`string`})}:t}requireInputArray(e){let t=this.getInput(e);if(Array.isArray(t))return{ok:!0,value:t};let n=this.collectListHandleValues(e);return n?{ok:!0,value:n}:t===void 0?{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_MISSING`,`Node input key is missing`,{nodeId:this.nodeId,key:e})}:{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input key must be array`,{nodeId:this.nodeId,key:e,expectedType:`array`})}}requireInputBinary(e,t){let n=this.requireInput(e);return n.ok?Y(n.value,this.nodeId,e,t):n}requireInputBinaryList(e,t,n){let i=this.requireInputArray(e);if(!i.ok)return i;let a=i.value;if(typeof n?.minItems==`number`&&a.length<n.minItems)return{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_MIN_ITEMS_NOT_SATISFIED`,`Node input list does not satisfy minItems`,{nodeId:this.nodeId,key:e,minItems:n.minItems,actualItems:a.length})};if(typeof n?.maxItems==`number`&&a.length>n.maxItems)return{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_MAX_ITEMS_EXCEEDED`,`Node input list exceeds maxItems`,{nodeId:this.nodeId,key:e,maxItems:n.maxItems,actualItems:a.length})};let o=[];for(let[n,r]of a.entries()){let i=Y(r,this.nodeId,`${e}[${n}]`,t);if(!i.ok)return i;o.push(i.value)}return{ok:!0,value:o}}requireInputMediaReference(e,t){let n=this.requireInput(e);return n.ok?this.parseMediaReferenceValue(n.value,e,t):n}requireInputBinaryReference(e,t){let n=this.requireInputBinary(e,t);if(!n.ok)return n;let i=J.fromBinary(n.value);return i.ok?i:{ok:!1,error:r(i.error.code,i.error.message,{nodeId:this.nodeId,key:e,...i.error.context??{}})}}setOutput(e,t){this.output[e]=t}toOutput(){return{...this.output}}collectListHandleValues(e){let t=new Map;for(let[n,r]of Object.entries(this.input)){let i=v(n);!i||i.portKey!==e||t.set(i.index,r)}if(t.size===0)return;let n=[...t.keys()].sort((e,t)=>e-t),r=n[n.length-1]+1;if(n.length!==r)return;let i=[];for(let e=0;e<r;e+=1){let n=t.get(e);if(n===void 0)return;i.push(n)}return i}parseMediaReferenceValue(e,t,n){if(typeof e==`string`){if(n?.allowStringAssetUri===!0&&e.startsWith(`asset://`))return this.wrapMediaReferenceError(J.fromCandidate({referenceType:`asset`,assetId:e.slice(8)}),t);if(n?.allowStringUri===!0)return this.wrapMediaReferenceError(J.fromCandidate({referenceType:`uri`,uri:e}),t)}return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1,error:r(`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`,`Node input key must be media reference object`,{nodeId:this.nodeId,key:t,expectedType:`media-reference`})}:this.wrapMediaReferenceError(J.fromCandidate(e),t)}wrapMediaReferenceError(e,t){return e.ok?e:{ok:!1,error:r(e.error.code,e.error.message,{nodeId:this.nodeId,key:t,...e.error.context??{}})}}};function X(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.kind==`string`&&typeof t.mimeType==`string`&&typeof t.uri==`string`}function Z(e,t){if(e.isList)return Array.isArray(t)?t.every(t=>Z({...e,isList:!1},t)):!1;switch(e.type){case`string`:return typeof t==`string`;case`number`:return typeof t==`number`;case`boolean`:return typeof t==`boolean`;case`object`:return typeof t==`object`&&!!t&&!Array.isArray(t)&&!X(t);case`array`:return Array.isArray(t);case`binary`:return!(!X(t)||e.binaryKind&&t.kind!==e.binaryKind||e.mimeTypes&&e.mimeTypes.length>0&&!e.mimeTypes.includes(t.mimeType));default:return!1}}function Q(e,t,n,i){for(let a of t){let t=e[a.key];if(t===void 0){if(a.required)return{ok:!1,error:r(n===`input`?`DAG_VALIDATION_NODE_REQUIRED_INPUT_MISSING`:`DAG_VALIDATION_NODE_REQUIRED_OUTPUT_MISSING`,n===`input`?`Required input port "${a.key}" (${a.type}) is missing on node "${i}"`:`Required output port "${a.key}" (${a.type}) was not set by node "${i}"`,{nodeId:i,key:a.key,type:a.type},n===`input`?{action:`connect_port`,suggestion:`Connect a "${a.type}" output to the "${a.key}" input of node "${i}"`}:void 0)};continue}if(a.isList){if(!Array.isArray(t))return{ok:!1,error:r(n===`input`?`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`:`DAG_VALIDATION_NODE_OUTPUT_TYPE_MISMATCH`,n===`input`?`List input port must receive array payload`:`List output port must emit array payload`,{nodeId:i,key:a.key,type:a.type})};if(typeof a.minItems==`number`&&t.length<a.minItems)return{ok:!1,error:r(n===`input`?`DAG_VALIDATION_NODE_INPUT_MIN_ITEMS_NOT_SATISFIED`:`DAG_VALIDATION_NODE_OUTPUT_MIN_ITEMS_NOT_SATISFIED`,n===`input`?`List input port does not satisfy minItems`:`List output port does not satisfy minItems`,{nodeId:i,key:a.key,minItems:a.minItems,actualItems:t.length})};if(typeof a.maxItems==`number`&&t.length>a.maxItems)return{ok:!1,error:r(n===`input`?`DAG_VALIDATION_NODE_INPUT_MAX_ITEMS_EXCEEDED`:`DAG_VALIDATION_NODE_OUTPUT_MAX_ITEMS_EXCEEDED`,n===`input`?`List input port exceeds maxItems`:`List output port exceeds maxItems`,{nodeId:i,key:a.key,maxItems:a.maxItems,actualItems:t.length})}}if(!Z(a,t))return{ok:!1,error:r(n===`input`?`DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH`:`DAG_VALIDATION_NODE_OUTPUT_TYPE_MISMATCH`,n===`input`?`Input port "${a.key}" on node "${i}" expects type "${a.type}" but received incompatible value`:`Output port "${a.key}" on node "${i}" emitted value incompatible with type "${a.type}"`,{nodeId:i,key:a.key,type:a.type},n===`input`?{action:`check_port_type`,suggestion:`Ensure the upstream output connected to "${a.key}" produces a "${a.type}" value`}:void 0)}}return{ok:!0,value:void 0}}var Ne=class{handler;constructor(e){this.handler=e}async initialize(e){return this.handler.initialize?this.handler.initialize(e):{ok:!0,value:void 0}}async validateInput(e,t){let n=Q(e,t.nodeManifest.inputs,`input`,t.nodeDefinition.nodeId);return n.ok?this.handler.validateInput?this.handler.validateInput(e,t):{ok:!0,value:void 0}:n}async estimateCost(e,t){return this.handler.estimateCost?this.handler.estimateCost(e,t):{ok:!0,value:{estimatedCredits:0}}}async execute(e,t){return this.handler.execute(e,t)}async validateOutput(e,t){let n=Q(e,t.nodeManifest.outputs,`output`,t.nodeDefinition.nodeId);return n.ok?this.handler.validateOutput?this.handler.validateOutput(e,t):{ok:!0,value:void 0}:n}async dispose(e){return this.handler.dispose?this.handler.dispose(e):{ok:!0,value:void 0}}},Pe=class{handlersByType;constructor(e){this.handlersByType=e}getHandler(e){return this.handlersByType[e]}listNodeTypes(){return Object.keys(this.handlersByType)}},Fe=class{taskHandlerRegistry;constructor(e){this.taskHandlerRegistry=e}create(e){let t=this.taskHandlerRegistry.getHandler(e);return t?{ok:!0,value:new Ne(t)}:{ok:!1,error:r(`DAG_VALIDATION_NODE_LIFECYCLE_NOT_REGISTERED`,`Node lifecycle is not registered for nodeType`,{nodeType:e})}}},Ie=class{manifestByType=new Map;constructor(e){for(let t of e)this.manifestByType.set(t.nodeType,t)}getManifest(e){return this.manifestByType.get(e)}listManifests(){return[...this.manifestByType.values()]}};const $=e.string().trim().min(1),Le=e.object({referenceType:e.literal(`asset`),assetId:$,mediaType:e.string().optional(),name:e.string().optional(),sizeBytes:e.number().int().nonnegative().optional()}),Re=e.object({referenceType:e.literal(`uri`),uri:$,mediaType:e.string().optional(),name:e.string().optional(),sizeBytes:e.number().int().nonnegative().optional()}),ze=e.union([Le,Re]);function Be(){return e.object({asset:ze})}function Ve(t){return typeof t!=`object`||!t?!1:t instanceof e.ZodType}function He(e){return e==null?{ok:!0,value:{}}:Ve(e)?{ok:!0,value:t(e,{target:`jsonSchema7`})}:{ok:!1,error:r(`DAG_VALIDATION_CONFIG_SCHEMA_INVALID`,`configSchemaDefinition must be a Zod schema instance.`)}}function Ue(e){let t=[],n={};for(let r of e){let e=He(r.configSchemaDefinition);if(!e.ok)return e;let i={nodeType:r.nodeType,displayName:r.displayName,category:r.category,inputs:r.inputs,outputs:r.outputs,configSchema:e.value,...r.defaultInputPort===void 0?{}:{defaultInputPort:r.defaultInputPort},...r.defaultOutputPort===void 0?{}:{defaultOutputPort:r.defaultOutputPort}};t.push(i),n[i.nodeType]=r.taskHandler}return{ok:!0,value:{manifests:t,handlersByType:n}}}const We={IMAGE_PNG:{binaryKind:`image`,mimeTypes:[`image/png`]},IMAGE_COMMON:{binaryKind:`image`,mimeTypes:[`image/png`,`image/jpeg`,`image/webp`]},VIDEO_MP4:{binaryKind:`video`,mimeTypes:[`video/mp4`]},AUDIO_MPEG:{binaryKind:`audio`,mimeTypes:[`audio/mpeg`]},FILE_GENERIC:{binaryKind:`file`,mimeTypes:[]}};function Ge(e){return{key:e.key,label:e.label,order:e.order,type:`binary`,required:e.required,description:e.description,binaryKind:e.preset.binaryKind,mimeTypes:[...e.preset.mimeTypes],isList:e.isList,minItems:e.minItems,maxItems:e.maxItems}}export{v as A,r as C,g as D,L as E,f as M,_e as O,a as S,I as T,C as _,Fe as a,i as b,Ue as c,Oe as d,S as f,ne as g,h,Me as i,ee as j,F as k,Ge as l,De as m,We as n,Ie as o,te as p,J as r,Pe as s,je as t,Be as u,m as v,W as w,o as x,Ce as y};
|
|
2
|
+
//# sourceMappingURL=node-2-nrieFn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-2-nrieFn.js","names":[],"sources":["../../../dag-core/dist/node/index.js","../../../dag-node/dist/node/index.js"],"sourcesContent":["//#region src/utils/error-builders.ts\n/** Create a structured {@link IDagError} with all required fields. */\nfunction buildDagError(category, code, message, retryable, context, fix, agentHint) {\n\treturn {\n\t\tcode,\n\t\tcategory,\n\t\tmessage,\n\t\tretryable,\n\t\tcontext,\n\t\tfix,\n\t\tagentHint\n\t};\n}\n/** Shorthand for creating a non-retryable validation error. */\nfunction buildValidationError(code, message, context, fix, agentHint) {\n\treturn buildDagError(\"validation\", code, message, false, context, fix, agentHint);\n}\n/** Shorthand for creating a retryable dispatch error. */\nfunction buildDispatchError(code, message, context, fix, agentHint) {\n\treturn buildDagError(\"dispatch\", code, message, true, context, fix, agentHint);\n}\n/** Shorthand for creating a non-retryable lease error. */\nfunction buildLeaseError(code, message, context, fix, agentHint) {\n\treturn buildDagError(\"lease\", code, message, false, context, fix, agentHint);\n}\n/** Shorthand for creating a task execution error with configurable retryability. */\nfunction buildTaskExecutionError(code, message, retryable, context, fix, agentHint) {\n\treturn buildDagError(\"task_execution\", code, message, retryable, context, fix, agentHint);\n}\n/** Stable non-retryable outcome when the trusted attempt signal is aborted. */\nfunction buildTaskCancellationError(taskRunId) {\n\treturn buildTaskExecutionError(\"DAG_TASK_EXECUTION_CANCELLED\", \"Task execution was cancelled\", false, { taskRunId });\n}\n//#endregion\n//#region src/services/bounded-json-snapshot.ts\n/** Encode JSON data while bounding the final UTF-8 snapshot before it is materialized. */\nfunction encodeBoundedJsonSnapshot(value, maxBytes) {\n\tconst chunks = [];\n\tlet pending = \"\";\n\tlet bytes = 0;\n\tconst append = (part, size) => {\n\t\tif (size > maxBytes - bytes) throw LIMIT;\n\t\tbytes += size;\n\t\tpending += part;\n\t\tif (pending.length >= 8192) {\n\t\t\tchunks.push(pending);\n\t\t\tpending = \"\";\n\t\t}\n\t};\n\tconst string = (value) => {\n\t\tappend(\"\\\"\", 1);\n\t\tfor (let index = 0; index < value.length; index++) {\n\t\t\tconst code = value.charCodeAt(index);\n\t\t\tif (code === 34 || code === 92) append(`\\\\${value[index]}`, 2);\n\t\t\telse if (code < 32) {\n\t\t\t\tconst escaped = SHORT_ESCAPES[code] ?? `\\\\u${code.toString(16).padStart(4, \"0\")}`;\n\t\t\t\tappend(escaped, escaped.length);\n\t\t\t} else if (code < 128) append(value[index], 1);\n\t\t\telse if (code < 2048) append(value[index], 2);\n\t\t\telse if (code >= 55296 && code <= 56319 && index + 1 < value.length && value.charCodeAt(index + 1) >= 56320 && value.charCodeAt(index + 1) <= 57343) {\n\t\t\t\tappend(value.slice(index, index + 2), 4);\n\t\t\t\tindex++;\n\t\t\t} else if (code >= 55296 && code <= 57343) append(`\\\\u${code.toString(16)}`, 6);\n\t\t\telse append(value[index], 3);\n\t\t}\n\t\tappend(\"\\\"\", 1);\n\t};\n\tconst stack = [];\n\tconst active = /* @__PURE__ */ new Set();\n\tconst writeValue = (item) => {\n\t\tif (item === null) return append(\"null\", 4);\n\t\tif (typeof item === \"string\") return string(item);\n\t\tif (typeof item === \"boolean\") return append(item ? \"true\" : \"false\", item ? 4 : 5);\n\t\tif (typeof item === \"number\") {\n\t\t\tconst number = JSON.stringify(item);\n\t\t\treturn append(number, number.length);\n\t\t}\n\t\tif (typeof item !== \"object\" || active.has(item)) throw INVALID;\n\t\tif (Array.isArray(item)) {\n\t\t\tactive.add(item);\n\t\t\tappend(\"[\", 1);\n\t\t\tstack.push({\n\t\t\t\tkind: \"array\",\n\t\t\t\tvalue: item,\n\t\t\t\tindex: 0\n\t\t\t});\n\t\t} else {\n\t\t\tconst prototype = Object.getPrototypeOf(item);\n\t\t\tif (prototype !== Object.prototype && prototype !== null) throw INVALID;\n\t\t\tactive.add(item);\n\t\t\tappend(\"{\", 1);\n\t\t\tstack.push({\n\t\t\t\tkind: \"object\",\n\t\t\t\tvalue: item,\n\t\t\t\tkeys: Object.keys(item),\n\t\t\t\tindex: 0,\n\t\t\t\tfirst: true\n\t\t\t});\n\t\t}\n\t};\n\ttry {\n\t\twriteValue(value);\n\t\twhile (stack.length > 0) {\n\t\t\tconst frame = stack[stack.length - 1];\n\t\t\tif (frame.kind === \"array\") {\n\t\t\t\tif (frame.index === frame.value.length) {\n\t\t\t\t\tappend(\"]\", 1);\n\t\t\t\t\tactive.delete(frame.value);\n\t\t\t\t\tstack.pop();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (frame.index) append(\",\", 1);\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(frame.value, String(frame.index++));\n\t\t\t\tif (descriptor && !(\"value\" in descriptor)) throw INVALID;\n\t\t\t\tconst entry = descriptor?.value;\n\t\t\t\tif (entry === void 0 || typeof entry === \"function\" || typeof entry === \"symbol\") append(\"null\", 4);\n\t\t\t\telse writeValue(entry);\n\t\t\t} else {\n\t\t\t\tif (frame.index === frame.keys.length) {\n\t\t\t\t\tappend(\"}\", 1);\n\t\t\t\t\tactive.delete(frame.value);\n\t\t\t\t\tstack.pop();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst key = frame.keys[frame.index++];\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(frame.value, key);\n\t\t\t\tif (!descriptor || !(\"value\" in descriptor)) throw INVALID;\n\t\t\t\tconst entry = descriptor.value;\n\t\t\t\tif (entry === void 0 || typeof entry === \"function\" || typeof entry === \"symbol\") continue;\n\t\t\t\tif (!frame.first) append(\",\", 1);\n\t\t\t\tframe.first = false;\n\t\t\t\tstring(key);\n\t\t\t\tappend(\":\", 1);\n\t\t\t\twriteValue(entry);\n\t\t\t}\n\t\t}\n\t\tif (pending) chunks.push(pending);\n\t\treturn chunks.join(\"\");\n\t} catch (error) {\n\t\tif (error === LIMIT) return void 0;\n\t\tif (error === INVALID) throw new TypeError(\"Snapshot must contain plain JSON data without accessors or cycles\");\n\t\tthrow error;\n\t}\n}\nconst LIMIT = Symbol(\"snapshot limit\");\nconst INVALID = Symbol(\"invalid snapshot\");\nconst SHORT_ESCAPES = {\n\t8: \"\\\\b\",\n\t9: \"\\\\t\",\n\t10: \"\\\\n\",\n\t12: \"\\\\f\",\n\t13: \"\\\\r\"\n};\n//#endregion\n//#region src/services/task-snapshot-budget.ts\nconst DEFAULT_TASK_SNAPSHOT_BUDGET_LIMITS = Object.freeze({\n\tinputBytes: 16 * 1024 * 1024,\n\toutputBytes: 16 * 1024 * 1024\n});\nfunction resolveTaskSnapshotBudgetLimits(limits = DEFAULT_TASK_SNAPSHOT_BUDGET_LIMITS) {\n\tif (!limits || !Number.isSafeInteger(limits.inputBytes) || limits.inputBytes < 0 || !Number.isSafeInteger(limits.outputBytes) || limits.outputBytes < 0) throw new RangeError(\"Task snapshot limits must be nonnegative safe integers\");\n\treturn Object.freeze({\n\t\tinputBytes: limits.inputBytes,\n\t\toutputBytes: limits.outputBytes\n\t});\n}\nfunction utf8Bytes(text) {\n\tlet bytes = 0;\n\tfor (let index = 0; index < text.length; index++) {\n\t\tconst code = text.charCodeAt(index);\n\t\tif (code < 128) bytes++;\n\t\telse if (code < 2048) bytes += 2;\n\t\telse if (code >= 55296 && code <= 56319 && text.charCodeAt(index + 1) >= 56320 && text.charCodeAt(index + 1) <= 57343) {\n\t\t\tbytes += 4;\n\t\t\tindex++;\n\t\t} else bytes += 3;\n\t}\n\treturn bytes;\n}\n/** Cumulative accepted snapshot writes, with pending writes reserving capacity synchronously. */\nvar TaskSnapshotBudget = class {\n\tlimits;\n\toccupied = {\n\t\tinput: 0,\n\t\toutput: 0\n\t};\n\tpoisoned = false;\n\tconstructor(limits) {\n\t\tthis.limits = resolveTaskSnapshotBudgetLimits(limits);\n\t}\n\tclose() {\n\t\tthis.poisoned = true;\n\t}\n\terror(direction) {\n\t\treturn buildTaskExecutionError(this.poisoned ? \"DAG_TASK_SNAPSHOT_BUDGET_CLOSED\" : \"DAG_TASK_SNAPSHOT_BUDGET_EXCEEDED\", this.poisoned ? \"Task snapshot budget is closed\" : `Task ${direction} snapshot budget exceeded`, false);\n\t}\n\tencode(direction, value) {\n\t\tif (this.poisoned) return {\n\t\t\tok: false,\n\t\t\terror: this.error(direction)\n\t\t};\n\t\tconst remaining = this.limits[direction === \"input\" ? \"inputBytes\" : \"outputBytes\"] - this.occupied[direction];\n\t\ttry {\n\t\t\tconst snapshot = encodeBoundedJsonSnapshot(value, remaining);\n\t\t\tif (snapshot === void 0) return {\n\t\t\t\tok: false,\n\t\t\t\terror: this.error(direction)\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tsnapshot,\n\t\t\t\t\tbytes: utf8Bytes(snapshot)\n\t\t\t\t}\n\t\t\t};\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_SNAPSHOT_INVALID\", \"Task snapshot must contain plain JSON data\", false)\n\t\t\t};\n\t\t}\n\t}\n\tasync admitValue(direction, value, persist) {\n\t\tconst encoded = this.encode(direction, value);\n\t\tif (!encoded.ok) return encoded;\n\t\treturn this.admit(direction, encoded.value.snapshot, () => persist(encoded.value.snapshot));\n\t}\n\tasync admitRun(definition, input, persist) {\n\t\tconst encodedDefinition = this.encode(\"input\", definition);\n\t\tif (!encodedDefinition.ok) return encodedDefinition;\n\t\tthis.occupied.input += encodedDefinition.value.bytes;\n\t\tconst encodedInput = this.encode(\"input\", input);\n\t\tif (!encodedInput.ok) {\n\t\t\tthis.occupied.input -= encodedDefinition.value.bytes;\n\t\t\treturn encodedInput;\n\t\t}\n\t\tthis.occupied.input += encodedInput.value.bytes;\n\t\ttry {\n\t\t\tawait persist(encodedDefinition.value.snapshot, encodedInput.value.snapshot);\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: void 0\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.poisoned = true;\n\t\t\tthrow error;\n\t\t}\n\t}\n\tasync admit(direction, snapshot, persist) {\n\t\tconst bytes = utf8Bytes(snapshot);\n\t\tconst limit = direction === \"input\" ? this.limits.inputBytes : this.limits.outputBytes;\n\t\tif (this.poisoned || bytes > limit - this.occupied[direction]) return {\n\t\t\tok: false,\n\t\t\terror: this.error(direction)\n\t\t};\n\t\tthis.occupied[direction] += bytes;\n\t\ttry {\n\t\t\tconst result = await persist();\n\t\t\tif (!result.applied) this.occupied[direction] -= bytes;\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: result\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.poisoned = true;\n\t\t\tthrow error;\n\t\t}\n\t}\n};\n//#endregion\n//#region src/services/root-credit-budget.ts\nvar RootCreditBudget = class {\n\tlimit;\n\tcommitted = 0;\n\treserved = 0;\n\tclosed = false;\n\tconstructor(limit) {\n\t\tthis.limit = limit;\n\t\tif (limit !== void 0 && (!Number.isFinite(limit) || limit <= 0)) throw new RangeError(\"Root credit limit must be positive and finite\");\n\t}\n\tclose() {\n\t\tthis.closed = true;\n\t}\n\treserve(estimatedCredits) {\n\t\tif (!Number.isFinite(estimatedCredits) || estimatedCredits < 0) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NEGATIVE_ESTIMATED_CREDITS\", \"estimatedCredits must be finite and zero or positive\", { estimatedCredits })\n\t\t};\n\t\tif (this.closed || this.limit !== void 0 && estimatedCredits > this.limit - this.committed - this.reserved) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED\", \"Estimated run credits exceeds root runCreditLimit\", {\n\t\t\t\testimatedCredits,\n\t\t\t\t...this.limit === void 0 ? {} : { runCreditLimit: this.limit }\n\t\t\t})\n\t\t};\n\t\tthis.reserved += estimatedCredits;\n\t\tlet settled = false;\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tcommit: () => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tthis.reserved -= estimatedCredits;\n\t\t\t\t\t\tthis.committed += estimatedCredits;\n\t\t\t\t\t}\n\t\t\t\t\treturn this.committed;\n\t\t\t\t},\n\t\t\t\trelease: () => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tthis.reserved -= estimatedCredits;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n};\n//#endregion\n//#region src/services/dag-execution-lineage.ts\n/** Validate persisted lineage before it can authorize another composite child launch. */\nfunction decodeDagExecutionLineage(value) {\n\tif (value === void 0 || value === null) return void 0;\n\tif (typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"Invalid persisted DAG execution lineage\");\n\tconst record = value;\n\tconst hasParentRunId = record.parentRunId !== void 0;\n\tconst parentRunIdOk = !hasParentRunId || typeof record.parentRunId === \"string\" && record.parentRunId.length > 0;\n\tif (typeof record.rootRunId !== \"string\" || record.rootRunId.length === 0 || !parentRunIdOk || !Number.isSafeInteger(record.depth) || record.depth < 0 || record.maxDepth !== void 0 && (!Number.isSafeInteger(record.maxDepth) || record.maxDepth < 1) || !Array.isArray(record.ancestorCompositeNodeTypes) || !record.ancestorCompositeNodeTypes.every((type) => typeof type === \"string\" && type.length > 0)) throw new Error(\"Invalid persisted DAG execution lineage\");\n\tconst depth = record.depth;\n\tconst ancestorCount = record.ancestorCompositeNodeTypes.length;\n\tif (!(depth === 0 ? !hasParentRunId && ancestorCount === 0 : hasParentRunId && ancestorCount === depth)) throw new Error(\"Invalid persisted DAG execution lineage\");\n\treturn {\n\t\trootRunId: record.rootRunId,\n\t\t...hasParentRunId ? { parentRunId: record.parentRunId } : {},\n\t\tdepth,\n\t\t...record.maxDepth === void 0 ? {} : { maxDepth: record.maxDepth },\n\t\tancestorCompositeNodeTypes: [...record.ancestorCompositeNodeTypes]\n\t};\n}\n//#endregion\n//#region src/types/execution-byte-limits.ts\n/** Keep supported text expansion bounded even when no host policy is supplied. */\nconst DEFAULT_DAG_EXECUTION_BYTE_LIMITS = Object.freeze({\n\tmaxTextRepeatOutputBytes: 4 * 1024 * 1024,\n\tmaxTextReplaceOutputBytes: 4 * 1024 * 1024,\n\tmaxTextTemplateOutputBytes: 4 * 1024 * 1024,\n\tmaxTextJoinOutputBytes: 4 * 1024 * 1024,\n\tmaxTextSplitOutputBytes: 4 * 1024 * 1024,\n\tmaxTextTransformOutputBytes: 4 * 1024 * 1024,\n\tmaxTextUpperOutputBytes: 4 * 1024 * 1024,\n\tmaxTextLowerOutputBytes: 4 * 1024 * 1024,\n\tmaxHttpResponseBodyBytes: 4 * 1024 * 1024\n});\n/** Snapshot a trusted host policy; hosts may tighten the built-in ceiling. */\nfunction resolveDagExecutionByteLimits(limits) {\n\tconst maxTextRepeatOutputBytes = limits === void 0 ? DEFAULT_DAG_EXECUTION_BYTE_LIMITS.maxTextRepeatOutputBytes : limits.maxTextRepeatOutputBytes;\n\tif (!Number.isSafeInteger(maxTextRepeatOutputBytes) || maxTextRepeatOutputBytes < 0 || maxTextRepeatOutputBytes > DEFAULT_DAG_EXECUTION_BYTE_LIMITS.maxTextRepeatOutputBytes) throw new RangeError(\"maxTextRepeatOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextReplaceOutputBytes = limits && \"maxTextReplaceOutputBytes\" in limits ? limits.maxTextReplaceOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextReplaceOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextReplaceOutputBytes) || maxTextReplaceOutputBytes < 0 || maxTextReplaceOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextReplaceOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextTemplateOutputBytes = limits && \"maxTextTemplateOutputBytes\" in limits ? limits.maxTextTemplateOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextTemplateOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextTemplateOutputBytes) || maxTextTemplateOutputBytes < 0 || maxTextTemplateOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextTemplateOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextJoinOutputBytes = limits && \"maxTextJoinOutputBytes\" in limits ? limits.maxTextJoinOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextJoinOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextJoinOutputBytes) || maxTextJoinOutputBytes < 0 || maxTextJoinOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextJoinOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextSplitOutputBytes = limits && \"maxTextSplitOutputBytes\" in limits ? limits.maxTextSplitOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextSplitOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextSplitOutputBytes) || maxTextSplitOutputBytes < 0 || maxTextSplitOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextSplitOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextTransformOutputBytes = limits && \"maxTextTransformOutputBytes\" in limits ? limits.maxTextTransformOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextTransformOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextTransformOutputBytes) || maxTextTransformOutputBytes < 0 || maxTextTransformOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextTransformOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextUpperOutputBytes = limits && \"maxTextUpperOutputBytes\" in limits ? limits.maxTextUpperOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextUpperOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextUpperOutputBytes) || maxTextUpperOutputBytes < 0 || maxTextUpperOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextUpperOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxTextLowerOutputBytes = limits && \"maxTextLowerOutputBytes\" in limits ? limits.maxTextLowerOutputBytes : 4 * 1024 * 1024;\n\tif (typeof maxTextLowerOutputBytes !== \"number\" || !Number.isSafeInteger(maxTextLowerOutputBytes) || maxTextLowerOutputBytes < 0 || maxTextLowerOutputBytes > 4 * 1024 * 1024) throw new RangeError(\"maxTextLowerOutputBytes must be a safe integer between 0 and 4194304\");\n\tconst maxHttpResponseBodyBytes = limits && \"maxHttpResponseBodyBytes\" in limits ? limits.maxHttpResponseBodyBytes : 4 * 1024 * 1024;\n\tif (typeof maxHttpResponseBodyBytes !== \"number\" || !Number.isSafeInteger(maxHttpResponseBodyBytes) || maxHttpResponseBodyBytes < 0 || maxHttpResponseBodyBytes > 4 * 1024 * 1024) throw new RangeError(\"maxHttpResponseBodyBytes must be a safe integer between 0 and 4194304\");\n\treturn Object.freeze({\n\t\tmaxTextRepeatOutputBytes,\n\t\tmaxTextReplaceOutputBytes,\n\t\tmaxTextTemplateOutputBytes,\n\t\tmaxTextJoinOutputBytes,\n\t\tmaxTextSplitOutputBytes,\n\t\tmaxTextTransformOutputBytes,\n\t\tmaxTextUpperOutputBytes,\n\t\tmaxTextLowerOutputBytes,\n\t\tmaxHttpResponseBodyBytes\n\t});\n}\n//#endregion\n//#region src/types/domain.ts\nconst LIST_PORT_HANDLE_PREFIX_SEPARATOR = \"[\";\nconst LIST_PORT_HANDLE_SUFFIX = \"]\";\n/** Build a handle key for an indexed list port element, e.g. `\"images[0]\"`. */\nfunction buildListPortHandleKey(portKey, index) {\n\treturn `${portKey}${LIST_PORT_HANDLE_PREFIX_SEPARATOR}${index}${LIST_PORT_HANDLE_SUFFIX}`;\n}\n/** Parse a list port handle key back into its port key and index. Returns `undefined` if the key is not a valid list handle. */\nfunction parseListPortHandleKey(handleKey) {\n\tconst startIndex = handleKey.lastIndexOf(LIST_PORT_HANDLE_PREFIX_SEPARATOR);\n\tif (startIndex <= 0 || !handleKey.endsWith(LIST_PORT_HANDLE_SUFFIX)) return;\n\tconst portKey = handleKey.slice(0, startIndex);\n\tconst rawIndex = handleKey.slice(startIndex + 1, handleKey.length - 1);\n\tif (!/^\\d+$/.test(rawIndex)) return;\n\treturn {\n\t\tportKey,\n\t\tindex: Number.parseInt(rawIndex, 10)\n\t};\n}\n//#endregion\n//#region src/types/node-lifecycle.ts\nconst DEFAULT_DAG_RUNTIME_BASE_URL = \"http://127.0.0.1:3011\";\nfunction resolveRuntimeBaseUrl(context) {\n\tconst declared = context.runtimeBaseUrl?.trim();\n\tif (declared === void 0 || declared.length === 0) return DEFAULT_DAG_RUNTIME_BASE_URL;\n\treturn declared.replace(/\\/$/, \"\");\n}\n//#endregion\n//#region src/constants/status.ts\n/** Constant enum for DAG definition publication statuses. */\nconst DAG_DEFINITION_STATUS = {\n\tDRAFT: \"draft\",\n\tPUBLISHED: \"published\",\n\tDEPRECATED: \"deprecated\"\n};\n/** Constant enum for DAG run lifecycle statuses. */\nconst DAG_RUN_STATUS = {\n\tCREATED: \"created\",\n\tQUEUED: \"queued\",\n\tRUNNING: \"running\",\n\tSUCCESS: \"success\",\n\tFAILED: \"failed\",\n\tCANCELLED: \"cancelled\"\n};\n/** Constant enum for task run lifecycle statuses. */\nconst TASK_RUN_STATUS = {\n\tCREATED: \"created\",\n\tQUEUED: \"queued\",\n\tRUNNING: \"running\",\n\tSUCCESS: \"success\",\n\tFAILED: \"failed\",\n\tUPSTREAM_FAILED: \"upstream_failed\",\n\tSKIPPED: \"skipped\",\n\tCANCELLED: \"cancelled\"\n};\n//#endregion\n//#region src/constants/events.ts\n/** Event name prefix for DAG run lifecycle events. */\nconst RUN_EVENT_PREFIX = \"run\";\n/** Event name prefix for task lifecycle events. */\nconst TASK_EVENT_PREFIX = \"task\";\n/** Event name prefix for worker lifecycle events. */\nconst WORKER_EVENT_PREFIX = \"worker\";\n/** Event name prefix for scheduler lifecycle events. */\nconst SCHEDULER_EVENT_PREFIX = \"scheduler\";\n/** Event name prefix for execution progress events. */\nconst EXECUTION_EVENT_PREFIX = \"execution\";\n/** DAG run lifecycle event names. */\nconst RUN_EVENTS = {\n\tCREATED: \"created\",\n\tQUEUED: \"queued\",\n\tRUNNING: \"running\",\n\tSUCCESS: \"success\",\n\tFAILED: \"failed\",\n\tCANCELLED: \"cancelled\"\n};\n/** Task lifecycle event names. */\nconst TASK_EVENTS = {\n\tCREATED: \"created\",\n\tQUEUED: \"queued\",\n\tRUNNING: \"running\",\n\tSUCCESS: \"success\",\n\tFAILED: \"failed\",\n\tUPSTREAM_FAILED: \"upstream_failed\",\n\tSKIPPED: \"skipped\",\n\tCANCELLED: \"cancelled\"\n};\n/** Worker lifecycle event names. */\nconst WORKER_EVENTS = {\n\tLEASE_ACQUIRED: \"lease_acquired\",\n\tHEARTBEAT: \"heartbeat\",\n\tLEASE_EXPIRED: \"lease_expired\",\n\tEXECUTION_COMPLETE: \"execution_complete\"\n};\n/** Scheduler lifecycle event names. */\nconst SCHEDULER_EVENTS = {\n\tEVALUATED: \"evaluated\",\n\tTRIGGERED: \"triggered\",\n\tSKIPPED: \"skipped\"\n};\n/** Execution-level progress event names. */\nconst EXECUTION_PROGRESS_EVENTS = {\n\tSTARTED: \"execution.started\",\n\tCOMPLETED: \"execution.completed\",\n\tFAILED: \"execution.failed\"\n};\n/** Task-level progress event names. */\nconst TASK_PROGRESS_EVENTS = {\n\tSTARTED: \"task.started\",\n\tCOMPLETED: \"task.completed\",\n\tFAILED: \"task.failed\"\n};\n//#endregion\n//#region src/state-machines/dag-run-state-machine.ts\nconst DAG_RUN_TRANSITIONS = {\n\t[`${DAG_RUN_STATUS.CREATED}:QUEUE`]: DAG_RUN_STATUS.QUEUED,\n\t[`${DAG_RUN_STATUS.CREATED}:CANCEL`]: DAG_RUN_STATUS.CANCELLED,\n\t[`${DAG_RUN_STATUS.QUEUED}:START`]: DAG_RUN_STATUS.RUNNING,\n\t[`${DAG_RUN_STATUS.QUEUED}:CANCEL`]: DAG_RUN_STATUS.CANCELLED,\n\t[`${DAG_RUN_STATUS.RUNNING}:COMPLETE_SUCCESS`]: DAG_RUN_STATUS.SUCCESS,\n\t[`${DAG_RUN_STATUS.RUNNING}:COMPLETE_FAILURE`]: DAG_RUN_STATUS.FAILED,\n\t[`${DAG_RUN_STATUS.RUNNING}:CANCEL`]: DAG_RUN_STATUS.CANCELLED\n};\nfunction buildTransitionError$1(currentStatus, event) {\n\treturn {\n\t\tcode: \"DAG_STATE_TRANSITION_INVALID\",\n\t\tcategory: \"state_transition\",\n\t\tmessage: `DagRun transition is not allowed: ${currentStatus} -> ${event}`,\n\t\tretryable: false,\n\t\tcontext: {\n\t\t\tcurrentStatus,\n\t\t\tevent\n\t\t}\n\t};\n}\nfunction buildDomainEvent$1(nextStatus) {\n\treturn `run.${nextStatus}`;\n}\n/**\n* Finite state machine for DAG run status transitions.\n* Enforces valid transitions and emits domain events on state change.\n*/\nvar DagRunStateMachine = class {\n\tstatic transition(currentStatus, event) {\n\t\tconst transitionKey = `${currentStatus}:${event}`;\n\t\tconst nextStatus = DAG_RUN_TRANSITIONS[transitionKey];\n\t\tif (!nextStatus) return {\n\t\t\tok: false,\n\t\t\terror: buildTransitionError$1(currentStatus, event)\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tnextStatus,\n\t\t\t\tdomainEvents: [buildDomainEvent$1(nextStatus)]\n\t\t\t}\n\t\t};\n\t}\n};\n//#endregion\n//#region src/state-machines/task-run-state-machine.ts\nconst TASK_RUN_TRANSITIONS = {\n\t[`${TASK_RUN_STATUS.CREATED}:QUEUE`]: TASK_RUN_STATUS.QUEUED,\n\t[`${TASK_RUN_STATUS.CREATED}:CANCEL`]: TASK_RUN_STATUS.CANCELLED,\n\t[`${TASK_RUN_STATUS.QUEUED}:START`]: TASK_RUN_STATUS.RUNNING,\n\t[`${TASK_RUN_STATUS.QUEUED}:UPSTREAM_FAIL`]: TASK_RUN_STATUS.UPSTREAM_FAILED,\n\t[`${TASK_RUN_STATUS.QUEUED}:SKIP`]: TASK_RUN_STATUS.SKIPPED,\n\t[`${TASK_RUN_STATUS.QUEUED}:CANCEL`]: TASK_RUN_STATUS.CANCELLED,\n\t[`${TASK_RUN_STATUS.RUNNING}:COMPLETE_SUCCESS`]: TASK_RUN_STATUS.SUCCESS,\n\t[`${TASK_RUN_STATUS.RUNNING}:COMPLETE_FAILURE`]: TASK_RUN_STATUS.FAILED,\n\t[`${TASK_RUN_STATUS.RUNNING}:CANCEL`]: TASK_RUN_STATUS.CANCELLED,\n\t[`${TASK_RUN_STATUS.FAILED}:RETRY`]: TASK_RUN_STATUS.QUEUED,\n\t[`${TASK_RUN_STATUS.RUNNING}:RECLAIM`]: TASK_RUN_STATUS.QUEUED\n};\nfunction buildTransitionError(currentStatus, event) {\n\treturn {\n\t\tcode: \"DAG_STATE_TRANSITION_INVALID\",\n\t\tcategory: \"state_transition\",\n\t\tmessage: `TaskRun transition is not allowed: ${currentStatus} -> ${event}`,\n\t\tretryable: false,\n\t\tcontext: {\n\t\t\tcurrentStatus,\n\t\t\tevent\n\t\t}\n\t};\n}\nfunction buildDomainEvent(nextStatus) {\n\treturn `task.${nextStatus}`;\n}\n/**\n* Finite state machine for task run status transitions.\n* Enforces valid transitions (including retry from failed) and emits domain events.\n*/\nvar TaskRunStateMachine = class {\n\tstatic transition(currentStatus, event) {\n\t\tconst transitionKey = `${currentStatus}:${event}`;\n\t\tconst nextStatus = TASK_RUN_TRANSITIONS[transitionKey];\n\t\tif (!nextStatus) return {\n\t\t\tok: false,\n\t\t\terror: buildTransitionError(currentStatus, event)\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tnextStatus,\n\t\t\t\tdomainEvents: [buildDomainEvent(nextStatus)]\n\t\t\t}\n\t\t};\n\t}\n};\n//#endregion\n//#region src/state/dag-node-state.ts\nfunction createDefaultDagNodeState() {\n\treturn {\n\t\toperationStatus: \"idle\",\n\t\texecutionStatus: \"idle\"\n\t};\n}\nfunction reconcileDagNodeStateMap(definition, currentState, options) {\n\tconst nextState = {};\n\tfor (const node of definition.nodes) nextState[node.nodeId] = getStateOrDefault(currentState, node.nodeId, options);\n\treturn nextState;\n}\nfunction markDagNodeOperationStarted(currentState, nodeId, operation, options) {\n\tconst existing = getStateOrDefault(currentState, nodeId, options);\n\treturn {\n\t\t...currentState,\n\t\t[nodeId]: {\n\t\t\t...existing,\n\t\t\toperationStatus: operation.status,\n\t\t\tpendingDescription: operation.description\n\t\t}\n\t};\n}\nfunction markDagNodeOperationDone(currentState, nodeId, options) {\n\tconst existing = getStateOrDefault(currentState, nodeId, options);\n\treturn {\n\t\t...currentState,\n\t\t[nodeId]: {\n\t\t\t...existing,\n\t\t\toperationStatus: \"idle\",\n\t\t\tpendingDescription: void 0\n\t\t}\n\t};\n}\nfunction resetDagNodeExecutionStateMap(definition, currentState, options) {\n\tconst reconciled = reconcileDagNodeStateMap(definition, currentState, { createState: options?.createState });\n\tconst nextState = {};\n\tfor (const [nodeId, state] of Object.entries(reconciled)) nextState[nodeId] = {\n\t\t...state,\n\t\texecutionStatus: \"idle\",\n\t\ttrace: void 0\n\t};\n\treturn nextState;\n}\nfunction resetDagNodeExecutionStateFromNode(definition, currentState, nodeId, options) {\n\tconst affectedNodeIds = collectNodeAndDownstreamIds(definition, nodeId);\n\tconst nextState = { ...reconcileDagNodeStateMap(definition, currentState, { createState: options?.createState }) };\n\tfor (const affectedNodeId of affectedNodeIds) nextState[affectedNodeId] = {\n\t\t...getStateOrDefault(nextState, affectedNodeId, options),\n\t\texecutionStatus: \"idle\",\n\t\ttrace: void 0\n\t};\n\treturn nextState;\n}\nfunction overwriteDagNodeExecutionTrace(currentState, trace, options) {\n\tconst existing = getStateOrDefault(currentState, trace.nodeId, options);\n\treturn {\n\t\t...currentState,\n\t\t[trace.nodeId]: {\n\t\t\t...existing,\n\t\t\texecutionStatus: \"success\",\n\t\t\ttrace\n\t\t}\n\t};\n}\nfunction applyRunProgressEventToNodeStateMap(currentState, event, options) {\n\tif (!isTaskProgressEvent(event)) return currentState;\n\tconst existing = getStateOrDefault(currentState, event.nodeId, options);\n\tconst nextTrace = {\n\t\tnodeId: event.nodeId,\n\t\tinput: event.input ?? existing.trace?.input,\n\t\toutput: event.output ?? existing.trace?.output\n\t};\n\treturn {\n\t\t...currentState,\n\t\t[event.nodeId]: {\n\t\t\t...existing,\n\t\t\texecutionStatus: eventToExecutionStatus(event),\n\t\t\ttrace: nextTrace\n\t\t}\n\t};\n}\nfunction applyRunResultToNodeStateMap(currentState, result, options) {\n\tlet nextState = currentState;\n\tfor (const trace of result.traces) {\n\t\tconst existing = getStateOrDefault(nextState, trace.nodeId, options);\n\t\tnextState = {\n\t\t\t...nextState,\n\t\t\t[trace.nodeId]: {\n\t\t\t\t...existing,\n\t\t\t\texecutionStatus: \"success\",\n\t\t\t\ttrace: {\n\t\t\t\t\tnodeId: trace.nodeId,\n\t\t\t\t\tinput: trace.input,\n\t\t\t\t\toutput: trace.output\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\tfor (const nodeError of result.nodeErrors) {\n\t\tconst existing = getStateOrDefault(nextState, nodeError.nodeId, options);\n\t\tnextState = {\n\t\t\t...nextState,\n\t\t\t[nodeError.nodeId]: {\n\t\t\t\t...existing,\n\t\t\t\texecutionStatus: \"failed\"\n\t\t\t}\n\t\t};\n\t}\n\treturn nextState;\n}\nfunction resetRunResultFromNode(definition, result, nodeId) {\n\tconst affectedNodeIds = collectNodeAndDownstreamIds(definition, nodeId);\n\tconst traces = result.traces.filter((trace) => !affectedNodeIds.has(trace.nodeId));\n\tconst nodeErrors = result.nodeErrors.filter((nodeError) => !affectedNodeIds.has(nodeError.nodeId));\n\treturn {\n\t\t...result,\n\t\tstatus: nodeErrors.length > 0 ? \"failed\" : \"success\",\n\t\ttraces,\n\t\tnodeErrors,\n\t\ttotalCredits: sumTraceCredits(traces)\n\t};\n}\nfunction overwriteRunResultNodeTrace(result, trace) {\n\tconst traces = [...result.traces.filter((existingTrace) => existingTrace.nodeId !== trace.nodeId), trace];\n\tconst nodeErrors = result.nodeErrors.filter((nodeError) => nodeError.nodeId !== trace.nodeId);\n\treturn {\n\t\t...result,\n\t\tstatus: nodeErrors.length > 0 ? \"failed\" : \"success\",\n\t\ttraces,\n\t\tnodeErrors,\n\t\ttotalCredits: sumTraceCredits(traces)\n\t};\n}\nfunction isDagNodeStateMapRunnable(currentState) {\n\treturn Object.values(currentState).every((state) => state.operationStatus === \"idle\" && state.executionStatus !== \"running\");\n}\nfunction getStateOrDefault(currentState, nodeId, options) {\n\treturn currentState[nodeId] ?? options?.createState?.(nodeId) ?? createDefaultDagNodeState();\n}\nfunction isTaskProgressEvent(event) {\n\treturn event.eventType === TASK_PROGRESS_EVENTS.STARTED || event.eventType === TASK_PROGRESS_EVENTS.COMPLETED || event.eventType === TASK_PROGRESS_EVENTS.FAILED;\n}\nfunction eventToExecutionStatus(event) {\n\tif (event.eventType === TASK_PROGRESS_EVENTS.STARTED) return \"running\";\n\tif (event.eventType === TASK_PROGRESS_EVENTS.COMPLETED) return \"success\";\n\treturn \"failed\";\n}\nfunction collectNodeAndDownstreamIds(definition, nodeId) {\n\tconst affectedNodeIds = /* @__PURE__ */ new Set([nodeId]);\n\tlet changed = true;\n\twhile (changed) {\n\t\tchanged = false;\n\t\tfor (const node of definition.nodes) {\n\t\t\tif (affectedNodeIds.has(node.nodeId)) continue;\n\t\t\tconst dependsOnAffectedNode = node.dependsOn.some((dependencyId) => affectedNodeIds.has(dependencyId));\n\t\t\tconst hasIncomingAffectedEdge = definition.edges?.some((edge) => edge.to === node.nodeId && affectedNodeIds.has(edge.from)) ?? false;\n\t\t\tif (dependsOnAffectedNode || hasIncomingAffectedEdge) {\n\t\t\t\taffectedNodeIds.add(node.nodeId);\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t}\n\treturn affectedNodeIds;\n}\nfunction sumTraceCredits(traces) {\n\treturn traces.reduce((total, trace) => total + trace.totalCredits, 0);\n}\n//#endregion\n//#region src/services/definition-edge-validator.ts\nfunction findPort(ports, key) {\n\treturn ports.find((port) => port.key === key);\n}\nfunction resolveInputPort(ports, bindingInputKey) {\n\tconst directPort = findPort(ports, bindingInputKey);\n\tif (directPort) return {\n\t\tportKey: bindingInputKey,\n\t\tport: directPort\n\t};\n\tconst listHandle = parseListPortHandleKey(bindingInputKey);\n\tif (!listHandle) return {\n\t\tportKey: bindingInputKey,\n\t\tport: void 0\n\t};\n\tconst listPort = findPort(ports, listHandle.portKey);\n\tif (!listPort?.isList) return {\n\t\tportKey: listHandle.portKey,\n\t\tport: void 0\n\t};\n\treturn {\n\t\tportKey: listHandle.portKey,\n\t\tport: listPort\n\t};\n}\nfunction isPortTypeCompatible(outputPort, inputPort) {\n\tif (outputPort.type !== inputPort.type) return false;\n\tif (outputPort.type !== \"binary\" || inputPort.type !== \"binary\") return true;\n\tif (!outputPort.binaryKind || !inputPort.binaryKind) return true;\n\tif (outputPort.binaryKind !== inputPort.binaryKind) return false;\n\tif (!inputPort.mimeTypes || inputPort.mimeTypes.length === 0) return true;\n\tif (!outputPort.mimeTypes || outputPort.mimeTypes.length === 0) return false;\n\treturn outputPort.mimeTypes.some((mimeType) => inputPort.mimeTypes?.includes(mimeType));\n}\nfunction hasPortCatalog(ports) {\n\treturn Array.isArray(ports) && ports.length > 0;\n}\nfunction resolveBindingInputIdentity(inputPorts, bindingInputKey) {\n\tif (!hasPortCatalog(inputPorts)) return bindingInputKey;\n\tconst resolvedInput = resolveInputPort(inputPorts, bindingInputKey);\n\treturn resolvedInput.port?.isList ? bindingInputKey : resolvedInput.portKey;\n}\n/**\n* Validates edges, bindings, cross-edge input key conflicts, and cycle detection\n* for a DAG definition.\n*/\nfunction validateEdgesAndBindings(definition, nodeIdSet, nodeById) {\n\tconst errors = [];\n\tfor (const edge of definition.edges) {\n\t\tif (!nodeIdSet.has(edge.from)) errors.push(buildValidationError(\"DAG_VALIDATION_EDGE_FROM_NOT_FOUND\", \"edge.from must reference an existing nodeId\", { from: edge.from }));\n\t\tif (!nodeIdSet.has(edge.to)) errors.push(buildValidationError(\"DAG_VALIDATION_EDGE_TO_NOT_FOUND\", \"edge.to must reference an existing nodeId\", { to: edge.to }));\n\t\tif (!edge.bindings || edge.bindings.length === 0) {\n\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_BINDING_REQUIRED\", \"Each edge must define at least one binding\", {\n\t\t\t\tfrom: edge.from,\n\t\t\t\tto: edge.to\n\t\t\t}));\n\t\t\tcontinue;\n\t\t}\n\t\tconst fromNode = nodeById.get(edge.from);\n\t\tconst toNode = nodeById.get(edge.to);\n\t\tif (!fromNode || !toNode) continue;\n\t\tconst outputPorts = fromNode.outputs;\n\t\tconst inputPorts = toNode.inputs;\n\t\tconst inputKeysInEdge = /* @__PURE__ */ new Set();\n\t\tfor (const binding of edge.bindings) {\n\t\t\tconst outputPort = hasPortCatalog(outputPorts) ? findPort(outputPorts, binding.outputKey) : void 0;\n\t\t\tif (hasPortCatalog(outputPorts) && !outputPort) errors.push(buildValidationError(\"DAG_VALIDATION_BINDING_OUTPUT_NOT_FOUND\", \"binding.outputKey must reference an existing output port\", {\n\t\t\t\tfrom: edge.from,\n\t\t\t\toutputKey: binding.outputKey\n\t\t\t}));\n\t\t\tconst inputPort = (hasPortCatalog(inputPorts) ? resolveInputPort(inputPorts, binding.inputKey) : void 0)?.port;\n\t\t\tif (hasPortCatalog(inputPorts) && !inputPort) errors.push(buildValidationError(\"DAG_VALIDATION_BINDING_INPUT_NOT_FOUND\", \"binding.inputKey must reference an existing input port\", {\n\t\t\t\tto: edge.to,\n\t\t\t\tinputKey: binding.inputKey\n\t\t\t}));\n\t\t\tconst bindingInputIdentity = resolveBindingInputIdentity(inputPorts, binding.inputKey);\n\t\t\tif (inputKeysInEdge.has(bindingInputIdentity)) errors.push(buildValidationError(\"DAG_VALIDATION_BINDING_INPUT_KEY_DUPLICATE\", \"Each edge must not map multiple outputs to the same inputKey\", {\n\t\t\t\tto: edge.to,\n\t\t\t\tinputKey: binding.inputKey\n\t\t\t}));\n\t\t\telse inputKeysInEdge.add(bindingInputIdentity);\n\t\t\tif (outputPort && inputPort && !isPortTypeCompatible(outputPort, inputPort)) errors.push(buildValidationError(\"DAG_VALIDATION_BINDING_TYPE_MISMATCH\", \"binding port types must match\", {\n\t\t\t\tfrom: edge.from,\n\t\t\t\tto: edge.to,\n\t\t\t\toutputKey: binding.outputKey,\n\t\t\t\tinputKey: binding.inputKey,\n\t\t\t\toutputType: outputPort.type,\n\t\t\t\tinputType: inputPort.type\n\t\t\t}));\n\t\t}\n\t}\n\tconst usedInputKeysByTarget = /* @__PURE__ */ new Map();\n\tfor (const edge of definition.edges) {\n\t\tif (!edge.bindings) continue;\n\t\tconst key = edge.to;\n\t\tconst used = usedInputKeysByTarget.get(key) ?? /* @__PURE__ */ new Set();\n\t\tfor (const binding of edge.bindings) {\n\t\t\tconst bindingInputIdentity = resolveBindingInputIdentity(nodeById.get(edge.to)?.inputs, binding.inputKey);\n\t\t\tif (used.has(bindingInputIdentity)) errors.push(buildValidationError(\"DAG_VALIDATION_BINDING_INPUT_KEY_CONFLICT\", \"Multiple upstream edges map to the same inputKey\", {\n\t\t\t\tto: edge.to,\n\t\t\t\tinputKey: binding.inputKey\n\t\t\t}));\n\t\t\telse used.add(bindingInputIdentity);\n\t\t}\n\t\tusedInputKeysByTarget.set(key, used);\n\t}\n\tconst outgoingEdges = /* @__PURE__ */ new Map();\n\tfor (const edge of definition.edges) {\n\t\tconst existing = outgoingEdges.get(edge.from) ?? [];\n\t\texisting.push(edge.to);\n\t\toutgoingEdges.set(edge.from, existing);\n\t}\n\tif (hasCycleByNodeIds([...nodeIdSet], outgoingEdges)) errors.push(buildValidationError(\"DAG_VALIDATION_CYCLE_DETECTED\", \"DAG must not contain cycles\"));\n\treturn errors;\n}\nfunction hasCycleByNodeIds(nodeIds, outgoingEdges) {\n\tconst visiting = /* @__PURE__ */ new Set();\n\tconst visited = /* @__PURE__ */ new Set();\n\tconst visit = (nodeId) => {\n\t\tif (visiting.has(nodeId)) return true;\n\t\tif (visited.has(nodeId)) return false;\n\t\tvisiting.add(nodeId);\n\t\tconst nextNodeIds = outgoingEdges.get(nodeId) ?? [];\n\t\tfor (const nextNodeId of nextNodeIds) if (visit(nextNodeId)) return true;\n\t\tvisiting.delete(nodeId);\n\t\tvisited.add(nodeId);\n\t\treturn false;\n\t};\n\tfor (const nodeId of nodeIds) if (visit(nodeId)) return true;\n\treturn false;\n}\n//#endregion\n//#region src/services/definition-validator.ts\n/**\n* Validates a DAG definition for structural correctness: node IDs, edges,\n* duplicate detection, cycle detection, and edge binding constraints.\n*/\nvar DagDefinitionValidator = class {\n\tstatic validate(definition) {\n\t\tconst errors = [];\n\t\tif (definition.dagId.trim().length === 0) errors.push(buildValidationError(\"DAG_VALIDATION_EMPTY_DAG_ID\", \"dagId must not be empty\"));\n\t\tif (definition.version <= 0) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_VERSION\", \"version must be a positive integer\", { version: definition.version }));\n\t\tif (definition.nodes.length === 0) errors.push(buildValidationError(\"DAG_VALIDATION_EMPTY_NODES\", \"DAG must include at least one node\"));\n\t\tconst nodeIdSet = /* @__PURE__ */ new Set();\n\t\tconst nodeById = /* @__PURE__ */ new Map();\n\t\tfor (const node of definition.nodes) {\n\t\t\tif (node.nodeId.trim().length === 0) {\n\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_EMPTY_NODE_ID\", \"nodeId must not be empty\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (nodeIdSet.has(node.nodeId)) {\n\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_DUPLICATE_NODE_ID\", \"nodeId must be unique\", { nodeId: node.nodeId }));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnodeIdSet.add(node.nodeId);\n\t\t\tnodeById.set(node.nodeId, node);\n\t\t\tif (node.inputs) {\n\t\t\t\tconst inputKeys = /* @__PURE__ */ new Set();\n\t\t\t\tfor (const port of node.inputs) {\n\t\t\t\t\tif (port.key.trim().length === 0) {\n\t\t\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_EMPTY_INPUT_KEY\", \"input port key must not be empty\", { nodeId: node.nodeId }));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof port.order === \"number\" && (!Number.isInteger(port.order) || port.order < 0)) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_INPUT_ORDER\", \"input port order must be a non-negative integer\", {\n\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\tkey: port.key,\n\t\t\t\t\t\torder: port.order\n\t\t\t\t\t}));\n\t\t\t\t\tif (typeof port.minItems === \"number\" && (!Number.isInteger(port.minItems) || port.minItems < 0)) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_INPUT_MIN_ITEMS\", \"input port minItems must be a non-negative integer\", {\n\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\tkey: port.key,\n\t\t\t\t\t\tminItems: port.minItems\n\t\t\t\t\t}));\n\t\t\t\t\tif (typeof port.maxItems === \"number\" && (!Number.isInteger(port.maxItems) || port.maxItems < 0)) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_INPUT_MAX_ITEMS\", \"input port maxItems must be a non-negative integer\", {\n\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\tkey: port.key,\n\t\t\t\t\t\tmaxItems: port.maxItems\n\t\t\t\t\t}));\n\t\t\t\t\tif (typeof port.minItems === \"number\" && typeof port.maxItems === \"number\" && port.minItems > port.maxItems) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_INPUT_ITEM_RANGE\", \"input port minItems must be less than or equal to maxItems\", {\n\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\tkey: port.key,\n\t\t\t\t\t\tminItems: port.minItems,\n\t\t\t\t\t\tmaxItems: port.maxItems\n\t\t\t\t\t}));\n\t\t\t\t\tif (inputKeys.has(port.key)) {\n\t\t\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_DUPLICATE_INPUT_KEY\", \"input port key must be unique in a node\", {\n\t\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\t\tkey: port.key\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tinputKeys.add(port.key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.outputs) {\n\t\t\t\tconst outputKeys = /* @__PURE__ */ new Set();\n\t\t\t\tfor (const port of node.outputs) {\n\t\t\t\t\tif (port.key.trim().length === 0) {\n\t\t\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_EMPTY_OUTPUT_KEY\", \"output port key must not be empty\", { nodeId: node.nodeId }));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof port.order === \"number\" && (!Number.isInteger(port.order) || port.order < 0)) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_OUTPUT_ORDER\", \"output port order must be a non-negative integer\", {\n\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\tkey: port.key,\n\t\t\t\t\t\torder: port.order\n\t\t\t\t\t}));\n\t\t\t\t\tif (outputKeys.has(port.key)) {\n\t\t\t\t\t\terrors.push(buildValidationError(\"DAG_VALIDATION_DUPLICATE_OUTPUT_KEY\", \"output port key must be unique in a node\", {\n\t\t\t\t\t\t\tnodeId: node.nodeId,\n\t\t\t\t\t\t\tkey: port.key\n\t\t\t\t\t\t}));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\toutputKeys.add(port.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (definition.nodes.some((node) => node.nodeType === \"ok-emitter\")) {\n\t\t\tconst entryNodes = definition.nodes.filter((node) => node.dependsOn.length === 0);\n\t\t\tif (entryNodes.length !== 1) errors.push(buildValidationError(\"DAG_VALIDATION_TEST_ENTRY_NODE_COUNT_INVALID\", \"Test DAG with ok-emitter must have exactly one entry node\", { entryNodeCount: entryNodes.length }));\n\t\t\telse if (entryNodes[0]?.nodeType !== \"image-source\") errors.push(buildValidationError(\"DAG_VALIDATION_TEST_ENTRY_NODE_TYPE_INVALID\", \"Test DAG entry node must be image-source when ok-emitter exists\", { entryNodeType: entryNodes[0]?.nodeType }));\n\t\t}\n\t\terrors.push(...validateEdgesAndBindings(definition, nodeIdSet, nodeById));\n\t\tif (definition.costPolicy) {\n\t\t\tif (definition.costPolicy.runCreditLimit <= 0) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_COST_LIMIT\", \"costPolicy.runCreditLimit must be positive\", { runCreditLimit: definition.costPolicy.runCreditLimit }));\n\t\t\tif (definition.costPolicy.costPolicyVersion <= 0) errors.push(buildValidationError(\"DAG_VALIDATION_INVALID_COST_POLICY_VERSION\", \"costPolicy.costPolicyVersion must be positive\", { costPolicyVersion: definition.costPolicy.costPolicyVersion }));\n\t\t}\n\t\tif (errors.length > 0) return {\n\t\t\tok: false,\n\t\t\terror: errors\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: definition\n\t\t};\n\t}\n};\n//#endregion\n//#region src/services/dag-decode-primitives.ts\nfunction pushIssue(issues, path, message) {\n\tissues.push({\n\t\tpath,\n\t\tmessage\n\t});\n}\nfunction childPath(parent, key) {\n\treturn typeof key === \"number\" ? `${parent}[${key}]` : parent === \"\" ? key : `${parent}.${key}`;\n}\n/** A plain JSON object — arrays and `null` are rejected, since both satisfy `typeof === 'object'`. */\nfunction decodeRecord(value, path, issues) {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return pushIssue(issues, path, `expected an object, got ${describe(value)}`);\n\treturn value;\n}\nfunction decodeString(value, path, issues) {\n\treturn typeof value === \"string\" ? value : pushIssue(issues, path, `expected a string, got ${describe(value)}`);\n}\nfunction decodeNumber(value, path, issues) {\n\treturn typeof value === \"number\" && Number.isFinite(value) ? value : pushIssue(issues, path, `expected a finite number, got ${describe(value)}`);\n}\nfunction decodeBoolean(value, path, issues) {\n\treturn typeof value === \"boolean\" ? value : pushIssue(issues, path, `expected a boolean, got ${describe(value)}`);\n}\nfunction decodeLiteral(value, members, path, issues) {\n\tif (typeof value === \"string\" && members.includes(value)) return value;\n\treturn pushIssue(issues, path, `expected one of ${members.map((m) => `'${m}'`).join(\", \")}, got ${describe(value)}`);\n}\n/** Decode `value` when present; absence (`undefined`) is not an issue. */\nfunction decodeOptional(value, path, issues, decode) {\n\treturn value === void 0 ? void 0 : decode(value, path, issues);\n}\nfunction decodeArray(value, path, issues, decodeItem) {\n\tif (!Array.isArray(value)) return pushIssue(issues, path, `expected an array, got ${describe(value)}`);\n\tconst before = issues.length;\n\tconst items = value.map((item, index) => decodeItem(item, childPath(path, index), issues));\n\treturn issues.length === before ? items : void 0;\n}\nfunction decodeStringArray(value, path, issues) {\n\treturn decodeArray(value, path, issues, decodeString);\n}\n/** Human-readable description of a wrong value, without echoing large payloads. */\nfunction describe(value) {\n\tif (value === null) return \"null\";\n\tif (Array.isArray(value)) return \"an array\";\n\tif (typeof value === \"string\") return `string '${value.length > 40 ? `${value.slice(0, 40)}…` : value}'`;\n\treturn typeof value;\n}\n/** Render issues as one operator-facing line list. */\nfunction formatDagDecodeIssues(issues) {\n\treturn issues.map((issue) => `${issue.path === \"\" ? \"$\" : issue.path}: ${issue.message}`).join(\"; \");\n}\n/** Fold decode issues into the DAG error shape every port already speaks. */\nfunction dagDecodeIssuesToError(code, message, issues, context = {}) {\n\treturn buildValidationError(code, `${message}: ${formatDagDecodeIssues(issues)}`, {\n\t\t...context,\n\t\tissueCount: issues.length,\n\t\tfirstIssuePath: issues[0]?.path ?? \"\"\n\t});\n}\n//#endregion\n//#region src/services/dag-definition-decoder.ts\n/**\n* The one total decoder for a persisted `IDagDefinition` (issue #2077 / DAG-005).\n*\n* Every consumer that reads a definition off a boundary — a definition file, a run's definition\n* snapshot, a storage row, a workspace catalog entry, an instant-node's inner DAG — decodes through\n* here, so \"it parsed as JSON\" never again passes for \"it is a definition\". Lives in `dag-core` so a\n* package that depends on `dag-core` without depending on `dag-builder` can still reach it.\n*/\nconst DAG_DEFINITION_STATUSES = [\n\t\"draft\",\n\t\"published\",\n\t\"deprecated\"\n];\nconst PORT_VALUE_TYPES = [\n\t\"string\",\n\t\"number\",\n\t\"boolean\",\n\t\"object\",\n\t\"array\",\n\t\"binary\"\n];\nconst BINARY_KINDS = [\n\t\"image\",\n\t\"video\",\n\t\"audio\",\n\t\"file\"\n];\nfunction decodeDagDefinition(value, options = {}) {\n\tconst issues = [];\n\tconst definition = decodeDefinition(value, \"\", issues, options);\n\treturn definition !== void 0 && issues.length === 0 ? {\n\t\tok: true,\n\t\tvalue: definition\n\t} : {\n\t\tok: false,\n\t\terror: issues\n\t};\n}\n/** The same decode, folded into the `IDagError` every port and command already reports. */\nfunction decodeDagDefinitionAsDagError(value, code, message, context = {}, options = {}) {\n\tconst result = decodeDagDefinition(value, options);\n\treturn result.ok ? result : {\n\t\tok: false,\n\t\terror: dagDecodeIssuesToError(code, message, result.error, context)\n\t};\n}\nfunction decodeDefinition(value, path, issues, options) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst dagId = decodeString(record[\"dagId\"], childPath(path, \"dagId\"), issues);\n\tconst version = decodeNumber(record[\"version\"], childPath(path, \"version\"), issues);\n\tconst status = record[\"status\"] === void 0 && options.absentStatus !== void 0 ? options.absentStatus : decodeLiteral(record[\"status\"], DAG_DEFINITION_STATUSES, childPath(path, \"status\"), issues);\n\tconst nodes = decodeArray(record[\"nodes\"], childPath(path, \"nodes\"), issues, decodeDagNode);\n\tconst edges = record[\"edges\"] === void 0 && options.absentEdgesAsEmpty ? [] : decodeArray(record[\"edges\"], childPath(path, \"edges\"), issues, decodeEdge);\n\tconst costPolicy = decodeOptional(record[\"costPolicy\"], childPath(path, \"costPolicy\"), issues, decodeCostPolicy);\n\tconst inputSchema = decodeOptional(record[\"inputSchema\"], childPath(path, \"inputSchema\"), issues, decodeString);\n\tconst outputSchema = decodeOptional(record[\"outputSchema\"], childPath(path, \"outputSchema\"), issues, decodeString);\n\tif (dagId === void 0 || version === void 0 || status === void 0 || nodes === void 0 || edges === void 0) return;\n\tconst definition = {\n\t\tdagId,\n\t\tversion,\n\t\tstatus,\n\t\tnodes,\n\t\tedges\n\t};\n\tif (costPolicy !== void 0) definition.costPolicy = costPolicy;\n\tif (inputSchema !== void 0) definition.inputSchema = inputSchema;\n\tif (outputSchema !== void 0) definition.outputSchema = outputSchema;\n\treturn definition;\n}\nfunction decodeCostPolicy(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst runCreditLimit = decodeNumber(record[\"runCreditLimit\"], childPath(path, \"runCreditLimit\"), issues);\n\tconst costPolicyVersion = decodeNumber(record[\"costPolicyVersion\"], childPath(path, \"costPolicyVersion\"), issues);\n\treturn runCreditLimit === void 0 || costPolicyVersion === void 0 ? void 0 : {\n\t\trunCreditLimit,\n\t\tcostPolicyVersion\n\t};\n}\nfunction decodePosition(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst x = decodeNumber(record[\"x\"], childPath(path, \"x\"), issues);\n\tconst y = decodeNumber(record[\"y\"], childPath(path, \"y\"), issues);\n\treturn x === void 0 || y === void 0 ? void 0 : {\n\t\tx,\n\t\ty\n\t};\n}\n/** A config value is JSON: primitives, `null`, arrays and objects of the same, nothing else. */\nfunction decodeNodeConfigValue(value, path, issues) {\n\tif (value === null || [\n\t\t\"string\",\n\t\t\"number\",\n\t\t\"boolean\"\n\t].includes(typeof value)) return value;\n\tif (Array.isArray(value)) return decodeArray(value, path, issues, decodeNodeConfigValue);\n\tif (typeof value === \"object\") return decodeNodeConfigObject(value, path, issues);\n\treturn pushIssue(issues, path, `expected a JSON value, got ${typeof value}`);\n}\nfunction decodeNodeConfigObject(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst config = {};\n\tconst before = issues.length;\n\tfor (const [key, entry] of Object.entries(record)) {\n\t\tconst decoded = decodeNodeConfigValue(entry, childPath(path, key), issues);\n\t\tif (decoded !== void 0) config[key] = decoded;\n\t}\n\treturn issues.length === before ? config : void 0;\n}\nfunction decodePortDefinition(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst at = (key) => childPath(path, key);\n\tconst key = decodeString(record[\"key\"], at(\"key\"), issues);\n\tconst type = decodeLiteral(record[\"type\"], PORT_VALUE_TYPES, at(\"type\"), issues);\n\tconst required = decodeBoolean(record[\"required\"], at(\"required\"), issues);\n\tconst label = decodeOptional(record[\"label\"], at(\"label\"), issues, decodeString);\n\tconst order = decodeOptional(record[\"order\"], at(\"order\"), issues, decodeNumber);\n\tconst description = decodeOptional(record[\"description\"], at(\"description\"), issues, decodeString);\n\tconst binaryKind = decodeOptional(record[\"binaryKind\"], at(\"binaryKind\"), issues, (v, p, i) => decodeLiteral(v, BINARY_KINDS, p, i));\n\tconst mimeTypes = decodeOptional(record[\"mimeTypes\"], at(\"mimeTypes\"), issues, decodeStringArray);\n\tconst isList = decodeOptional(record[\"isList\"], at(\"isList\"), issues, decodeBoolean);\n\tconst minItems = decodeOptional(record[\"minItems\"], at(\"minItems\"), issues, decodeNumber);\n\tconst maxItems = decodeOptional(record[\"maxItems\"], at(\"maxItems\"), issues, decodeNumber);\n\tif (key === void 0 || type === void 0 || required === void 0) return void 0;\n\tconst port = {\n\t\tkey,\n\t\ttype,\n\t\trequired\n\t};\n\tif (label !== void 0) port.label = label;\n\tif (order !== void 0) port.order = order;\n\tif (description !== void 0) port.description = description;\n\tif (binaryKind !== void 0) port.binaryKind = binaryKind;\n\tif (mimeTypes !== void 0) port.mimeTypes = mimeTypes;\n\tif (isList !== void 0) port.isList = isList;\n\tif (minItems !== void 0) port.minItems = minItems;\n\tif (maxItems !== void 0) port.maxItems = maxItems;\n\treturn port;\n}\nfunction decodeDagNode(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst at = (key) => childPath(path, key);\n\tconst nodeId = decodeString(record[\"nodeId\"], at(\"nodeId\"), issues);\n\tconst nodeType = decodeString(record[\"nodeType\"], at(\"nodeType\"), issues);\n\tconst dependsOn = decodeStringArray(record[\"dependsOn\"], at(\"dependsOn\"), issues);\n\tconst config = decodeNodeConfigObject(record[\"config\"], at(\"config\"), issues);\n\tconst position = decodeOptional(record[\"position\"], at(\"position\"), issues, decodePosition);\n\tconst triggerPolicy = decodeOptional(record[\"triggerPolicy\"], at(\"triggerPolicy\"), issues, decodeString);\n\tconst retryPolicy = decodeOptional(record[\"retryPolicy\"], at(\"retryPolicy\"), issues, decodeString);\n\tconst timeoutMs = decodeOptional(record[\"timeoutMs\"], at(\"timeoutMs\"), issues, decodeNumber);\n\tconst inputs = decodeOptional(record[\"inputs\"], at(\"inputs\"), issues, (v, p, i) => decodeArray(v, p, i, decodePortDefinition));\n\tconst outputs = decodeOptional(record[\"outputs\"], at(\"outputs\"), issues, (v, p, i) => decodeArray(v, p, i, decodePortDefinition));\n\tconst costPolicy = decodeOptional(record[\"costPolicy\"], at(\"costPolicy\"), issues, decodeCostPolicy);\n\tif (nodeId === void 0 || nodeType === void 0 || dependsOn === void 0 || config === void 0) return;\n\tconst node = {\n\t\tnodeId,\n\t\tnodeType,\n\t\tdependsOn,\n\t\tconfig\n\t};\n\tif (position !== void 0) node.position = position;\n\tif (triggerPolicy !== void 0) node.triggerPolicy = triggerPolicy;\n\tif (retryPolicy !== void 0) node.retryPolicy = retryPolicy;\n\tif (timeoutMs !== void 0) node.timeoutMs = timeoutMs;\n\tif (inputs !== void 0) node.inputs = inputs;\n\tif (outputs !== void 0) node.outputs = outputs;\n\tif (costPolicy !== void 0) node.costPolicy = costPolicy;\n\treturn node;\n}\nfunction decodeEdgeBinding(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst outputKey = decodeString(record[\"outputKey\"], childPath(path, \"outputKey\"), issues);\n\tconst inputKey = decodeString(record[\"inputKey\"], childPath(path, \"inputKey\"), issues);\n\treturn outputKey === void 0 || inputKey === void 0 ? void 0 : {\n\t\toutputKey,\n\t\tinputKey\n\t};\n}\nfunction decodeEdge(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst from = decodeString(record[\"from\"], childPath(path, \"from\"), issues);\n\tconst to = decodeString(record[\"to\"], childPath(path, \"to\"), issues);\n\tconst bindings = decodeOptional(record[\"bindings\"], childPath(path, \"bindings\"), issues, (v, p, i) => decodeArray(v, p, i, decodeEdgeBinding));\n\tif (from === void 0 || to === void 0) return void 0;\n\tconst edge = {\n\t\tfrom,\n\t\tto\n\t};\n\tif (bindings !== void 0) edge.bindings = bindings;\n\treturn edge;\n}\n//#endregion\n//#region src/services/dag-workflow-file-decoder.ts\n/**\n* Total decoders for the `.dag.json` workflow file and its `.dag.robota.json` companion\n* (issue #2077 / DAG-005). The second on-disk DAG format, decoded field by field like the first.\n*/\nfunction decodeDagWorkflowFile(value) {\n\tconst issues = [];\n\tconst file = decodeWorkflowFile(value, \"\", issues);\n\treturn file !== void 0 && issues.length === 0 ? {\n\t\tok: true,\n\t\tvalue: file\n\t} : {\n\t\tok: false,\n\t\terror: issues\n\t};\n}\nfunction decodeDagRobotaCompanion(value) {\n\tconst issues = [];\n\tconst companion = decodeCompanion(value, \"\", issues);\n\treturn companion !== void 0 && issues.length === 0 ? {\n\t\tok: true,\n\t\tvalue: companion\n\t} : {\n\t\tok: false,\n\t\terror: issues\n\t};\n}\nfunction decodeNumberPair(value, path, issues) {\n\tif (!Array.isArray(value) || value.length !== 2) return pushIssue(issues, path, \"expected a [number, number] pair\");\n\tconst a = decodeNumber(value[0], childPath(path, 0), issues);\n\tconst b = decodeNumber(value[1], childPath(path, 1), issues);\n\treturn a === void 0 || b === void 0 ? void 0 : [a, b];\n}\nfunction decodeLink(value, path, issues) {\n\tif (!Array.isArray(value) || value.length !== 6) return pushIssue(issues, path, \"expected a 6-tuple [linkId, srcId, srcSlot, tgtId, tgtSlot, type]\");\n\tconst numbers = [\n\t\t0,\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4\n\t].map((i) => decodeNumber(value[i], childPath(path, i), issues));\n\tconst type = decodeString(value[5], childPath(path, 5), issues);\n\tif (numbers.some((n) => n === void 0) || type === void 0) return void 0;\n\tconst [a, b, c, d, e] = numbers;\n\treturn [\n\t\ta,\n\t\tb,\n\t\tc,\n\t\td,\n\t\te,\n\t\ttype\n\t];\n}\nfunction decodeNodeInput(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst name = decodeString(record[\"name\"], childPath(path, \"name\"), issues);\n\tconst type = decodeString(record[\"type\"], childPath(path, \"type\"), issues);\n\tconst rawLink = record[\"link\"];\n\tconst link = rawLink === null ? null : decodeNumber(rawLink, childPath(path, \"link\"), issues);\n\treturn name === void 0 || type === void 0 || link === void 0 ? void 0 : {\n\t\tname,\n\t\ttype,\n\t\tlink\n\t};\n}\nfunction decodeNodeOutput(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst name = decodeString(record[\"name\"], childPath(path, \"name\"), issues);\n\tconst type = decodeString(record[\"type\"], childPath(path, \"type\"), issues);\n\tconst links = decodeArray(record[\"links\"], childPath(path, \"links\"), issues, decodeNumber);\n\tconst slotIndex = decodeOptional(record[\"slot_index\"], childPath(path, \"slot_index\"), issues, decodeNumber);\n\tif (name === void 0 || type === void 0 || links === void 0) return void 0;\n\tconst output = {\n\t\tname,\n\t\ttype,\n\t\tlinks\n\t};\n\tif (slotIndex !== void 0) output.slot_index = slotIndex;\n\treturn output;\n}\nfunction decodeWorkflowNode(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst at = (key) => childPath(path, key);\n\tconst id = decodeNumber(record[\"id\"], at(\"id\"), issues);\n\tconst type = decodeString(record[\"type\"], at(\"type\"), issues);\n\tconst pos = decodeNumberPair(record[\"pos\"], at(\"pos\"), issues);\n\tconst size = decodeOptional(record[\"size\"], at(\"size\"), issues, decodeNumberPair);\n\tconst flags = decodeOptional(record[\"flags\"], at(\"flags\"), issues, decodeRecord);\n\tconst order = decodeOptional(record[\"order\"], at(\"order\"), issues, decodeNumber);\n\tconst mode = decodeOptional(record[\"mode\"], at(\"mode\"), issues, decodeNumber);\n\tconst inputs = decodeOptional(record[\"inputs\"], at(\"inputs\"), issues, (v, p, i) => decodeArray(v, p, i, decodeNodeInput));\n\tconst outputs = decodeOptional(record[\"outputs\"], at(\"outputs\"), issues, (v, p, i) => decodeArray(v, p, i, decodeNodeOutput));\n\tconst properties = decodeOptional(record[\"properties\"], at(\"properties\"), issues, decodeRecord);\n\tconst widgetsValues = decodeOptional(record[\"widgets_values\"], at(\"widgets_values\"), issues, (v, p, i) => Array.isArray(v) ? v : pushIssue(i, p, \"expected an array\"));\n\tif (id === void 0 || type === void 0 || pos === void 0) return void 0;\n\tconst node = {\n\t\tid,\n\t\ttype,\n\t\tpos\n\t};\n\tif (size !== void 0) node.size = size;\n\tif (flags !== void 0) node.flags = flags;\n\tif (order !== void 0) node.order = order;\n\tif (mode !== void 0) node.mode = mode;\n\tif (inputs !== void 0) node.inputs = inputs;\n\tif (outputs !== void 0) node.outputs = outputs;\n\tif (properties !== void 0) node.properties = properties;\n\tif (widgetsValues !== void 0) node.widgets_values = widgetsValues;\n\treturn node;\n}\nfunction decodeWorkflowFile(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst at = (key) => childPath(path, key);\n\tif (\"dagId\" in record) return pushIssue(issues, at(\"dagId\"), \"a workflow file carries no dagId — that is a definition file\");\n\tconst lastNodeId = decodeNumber(record[\"last_node_id\"], at(\"last_node_id\"), issues);\n\tconst lastLinkId = decodeNumber(record[\"last_link_id\"], at(\"last_link_id\"), issues);\n\tconst nodes = decodeArray(record[\"nodes\"], at(\"nodes\"), issues, decodeWorkflowNode);\n\tconst links = decodeArray(record[\"links\"], at(\"links\"), issues, decodeLink);\n\tconst version = decodeNumber(record[\"version\"], at(\"version\"), issues);\n\tconst groups = decodeOptional(record[\"groups\"], at(\"groups\"), issues, (v, p, i) => Array.isArray(v) ? v : pushIssue(i, p, \"expected an array\"));\n\tconst config = decodeOptional(record[\"config\"], at(\"config\"), issues, decodeRecord);\n\tconst extra = decodeOptional(record[\"extra\"], at(\"extra\"), issues, decodeRecord);\n\tif (lastNodeId === void 0 || lastLinkId === void 0 || nodes === void 0 || links === void 0 || version === void 0) return;\n\tconst file = {\n\t\tlast_node_id: lastNodeId,\n\t\tlast_link_id: lastLinkId,\n\t\tnodes,\n\t\tlinks,\n\t\tversion\n\t};\n\tif (groups !== void 0) file.groups = groups;\n\tif (config !== void 0) file.config = config;\n\tif (extra !== void 0) file.extra = extra;\n\treturn file;\n}\nfunction decodeCompanionNodeMeta(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst nodeId = decodeString(record[\"nodeId\"], childPath(path, \"nodeId\"), issues);\n\tconst retryPolicy = decodeOptional(record[\"retryPolicy\"], childPath(path, \"retryPolicy\"), issues, decodeString);\n\tconst timeoutMs = decodeOptional(record[\"timeoutMs\"], childPath(path, \"timeoutMs\"), issues, decodeNumber);\n\tconst costPolicy = decodeOptional(record[\"costPolicy\"], childPath(path, \"costPolicy\"), issues, decodeCostPolicy);\n\tif (nodeId === void 0) return void 0;\n\tconst meta = { nodeId };\n\tif (retryPolicy !== void 0) meta.retryPolicy = retryPolicy;\n\tif (timeoutMs !== void 0) meta.timeoutMs = timeoutMs;\n\tif (costPolicy !== void 0) meta.costPolicy = costPolicy;\n\treturn meta;\n}\nfunction decodeCompanion(value, path, issues) {\n\tconst record = decodeRecord(value, path, issues);\n\tif (record === void 0) return void 0;\n\tconst at = (key) => childPath(path, key);\n\tconst dagId = decodeString(record[\"dagId\"], at(\"dagId\"), issues);\n\tconst version = decodeNumber(record[\"version\"], at(\"version\"), issues);\n\tconst status = decodeLiteral(record[\"status\"], DAG_DEFINITION_STATUSES, at(\"status\"), issues);\n\tconst costPolicy = decodeOptional(record[\"costPolicy\"], at(\"costPolicy\"), issues, decodeCostPolicy);\n\tconst inputSchema = decodeOptional(record[\"inputSchema\"], at(\"inputSchema\"), issues, decodeString);\n\tconst outputSchema = decodeOptional(record[\"outputSchema\"], at(\"outputSchema\"), issues, decodeString);\n\tconst nodeFiles = decodeOptional(record[\"nodeFiles\"], at(\"nodeFiles\"), issues, decodeStringArray);\n\tconst nodesRecord = decodeRecord(record[\"nodes\"], at(\"nodes\"), issues);\n\tlet nodes;\n\tif (nodesRecord !== void 0) {\n\t\tconst before = issues.length;\n\t\tnodes = {};\n\t\tfor (const [key, entry] of Object.entries(nodesRecord)) {\n\t\t\tconst meta = decodeCompanionNodeMeta(entry, childPath(at(\"nodes\"), key), issues);\n\t\t\tif (meta !== void 0) nodes[key] = meta;\n\t\t}\n\t\tif (issues.length !== before) nodes = void 0;\n\t}\n\tif (dagId === void 0 || version === void 0 || status === void 0 || nodes === void 0) return;\n\tconst companion = {\n\t\tdagId,\n\t\tversion,\n\t\tstatus,\n\t\tnodes\n\t};\n\tif (costPolicy !== void 0) companion.costPolicy = costPolicy;\n\tif (inputSchema !== void 0) companion.inputSchema = inputSchema;\n\tif (outputSchema !== void 0) companion.outputSchema = outputSchema;\n\tif (nodeFiles !== void 0) companion.nodeFiles = nodeFiles;\n\treturn companion;\n}\n//#endregion\n//#region src/services/definition-service.ts\n/**\n* Manages DAG definition CRUD operations with validation and status transitions.\n*\n* @see DagDefinitionValidator - validation rules applied during creation\n* @see IStoragePort - persistence layer\n*/\nvar DagDefinitionService = class {\n\tstorage;\n\tconstructor(storage) {\n\t\tthis.storage = storage;\n\t}\n\tasync createDraft(definition) {\n\t\tif (await this.storage.getDefinition(definition.dagId, definition.version)) return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_DUPLICATE_VERSION\", \"A definition with the same dagId and version already exists\", {\n\t\t\t\tdagId: definition.dagId,\n\t\t\t\tversion: definition.version\n\t\t\t})]\n\t\t};\n\t\tconst draft = {\n\t\t\t...definition,\n\t\t\tstatus: \"draft\"\n\t\t};\n\t\tawait this.storage.saveDefinition(draft);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: draft\n\t\t};\n\t}\n\tasync getDefinition(dagId, version) {\n\t\treturn this.storage.getDefinition(dagId, version);\n\t}\n\tasync getDefinitionByDagId(dagId, version) {\n\t\tif (typeof version === \"number\") return this.storage.getDefinition(dagId, version);\n\t\tconst byDagId = await this.storage.listDefinitionsByDagId(dagId);\n\t\tif (byDagId.length === 0) return;\n\t\tconst draftDefinitions = byDagId.filter((definition) => definition.status === \"draft\");\n\t\tif (draftDefinitions.length > 0) return draftDefinitions[draftDefinitions.length - 1];\n\t\treturn byDagId[byDagId.length - 1];\n\t}\n\tasync listDefinitions(dagId) {\n\t\tif (typeof dagId === \"string\" && dagId.trim().length > 0) return this.storage.listDefinitionsByDagId(dagId);\n\t\treturn this.storage.listDefinitions();\n\t}\n\tasync updateDraft(definition) {\n\t\tconst existing = await this.storage.getDefinition(definition.dagId, definition.version);\n\t\tif (!existing) return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_DEFINITION_NOT_FOUND\", \"Definition does not exist\", {\n\t\t\t\tdagId: definition.dagId,\n\t\t\t\tversion: definition.version\n\t\t\t})]\n\t\t};\n\t\tif (existing.status !== \"draft\") return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_UPDATE_ONLY_DRAFT\", \"Only draft definitions can be updated\", { status: existing.status })]\n\t\t};\n\t\tconst nextDraft = {\n\t\t\t...definition,\n\t\t\tstatus: \"draft\"\n\t\t};\n\t\tawait this.storage.saveDefinition(nextDraft);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: nextDraft\n\t\t};\n\t}\n\tasync validate(dagId, version) {\n\t\tconst existing = await this.storage.getDefinition(dagId, version);\n\t\tif (!existing) return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_DEFINITION_NOT_FOUND\", \"Definition does not exist\", {\n\t\t\t\tdagId,\n\t\t\t\tversion\n\t\t\t})]\n\t\t};\n\t\treturn DagDefinitionValidator.validate(existing);\n\t}\n\tasync publish(dagId, version) {\n\t\tconst existing = await this.storage.getDefinition(dagId, version);\n\t\tif (!existing) return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_DEFINITION_NOT_FOUND\", \"Definition does not exist\", {\n\t\t\t\tdagId,\n\t\t\t\tversion\n\t\t\t})]\n\t\t};\n\t\tif (existing.status !== \"draft\") return {\n\t\t\tok: false,\n\t\t\terror: [buildValidationError(\"DAG_VALIDATION_PUBLISH_ONLY_DRAFT\", \"Only draft definitions can be published\", { status: existing.status })]\n\t\t};\n\t\tconst validated = DagDefinitionValidator.validate(existing);\n\t\tif (!validated.ok) return validated;\n\t\tconst latestVersion = (await this.storage.listDefinitionsByDagId(dagId)).reduce((currentMax, definition) => definition.version > currentMax ? definition.version : currentMax, 0);\n\t\tconst published = {\n\t\t\t...existing,\n\t\t\tversion: latestVersion + 1,\n\t\t\tstatus: \"published\"\n\t\t};\n\t\tawait this.storage.saveDefinition(published);\n\t\tconst closedDraft = {\n\t\t\t...existing,\n\t\t\tstatus: \"published\"\n\t\t};\n\t\tawait this.storage.saveDefinition(closedDraft);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: published\n\t\t};\n\t}\n};\n//#endregion\n//#region src/services/definition-summary.ts\nfunction summarizeDagDefinitions(definitions) {\n\tconst items = /* @__PURE__ */ new Map();\n\tfor (const definition of definitions) {\n\t\tconst existing = items.get(definition.dagId);\n\t\tif (!existing) {\n\t\t\titems.set(definition.dagId, {\n\t\t\t\tdagId: definition.dagId,\n\t\t\t\tlatestVersion: definition.version,\n\t\t\t\tstatuses: [definition.status]\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\titems.set(definition.dagId, {\n\t\t\tdagId: definition.dagId,\n\t\t\tlatestVersion: Math.max(existing.latestVersion, definition.version),\n\t\t\tstatuses: existing.statuses.includes(definition.status) ? existing.statuses : [...existing.statuses, definition.status]\n\t\t});\n\t}\n\treturn [...items.values()].sort((a, b) => a.dagId.localeCompare(b.dagId));\n}\n//#endregion\n//#region src/services/run-draft-decoder.ts\nfunction record(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction nonempty(value) {\n\treturn typeof value === \"string\" && value.trim().length > 0;\n}\nfunction primitive(value) {\n\treturn value === null || typeof value === \"string\" || typeof value === \"boolean\" || typeof value === \"number\" && Number.isFinite(value);\n}\nfunction portValue(value) {\n\tif (primitive(value)) return true;\n\tif (Array.isArray(value)) return value.every(portValue);\n\treturn record(value) && Object.values(value).every(primitive);\n}\nfunction payload(value) {\n\treturn record(value) && Object.values(value).every(portValue);\n}\nfunction nodeStateMap(value) {\n\treturn record(value) && Object.values(value).every((state) => record(state) && (state[\"operationStatus\"] === \"idle\" || state[\"operationStatus\"] === \"uploading\") && [\n\t\t\"idle\",\n\t\t\"running\",\n\t\t\"success\",\n\t\t\"failed\"\n\t].includes(String(state[\"executionStatus\"])) && (state[\"pendingDescription\"] === void 0 || typeof state[\"pendingDescription\"] === \"string\") && (state[\"trace\"] === void 0 || record(state[\"trace\"]) && nonempty(state[\"trace\"][\"nodeId\"]) && (state[\"trace\"][\"input\"] === void 0 || payload(state[\"trace\"][\"input\"])) && (state[\"trace\"][\"output\"] === void 0 || payload(state[\"trace\"][\"output\"]))));\n}\nfunction dagError(value) {\n\treturn record(value) && nonempty(value[\"code\"]) && nonempty(value[\"message\"]) && typeof value[\"retryable\"] === \"boolean\" && [\n\t\t\"validation\",\n\t\t\"state_transition\",\n\t\t\"lease\",\n\t\t\"dispatch\",\n\t\t\"task_execution\"\n\t].includes(String(value[\"category\"]));\n}\nfunction runResult(value) {\n\treturn record(value) && nonempty(value[\"dagRunId\"]) && (value[\"status\"] === \"success\" || value[\"status\"] === \"failed\") && typeof value[\"totalCredits\"] === \"number\" && Number.isFinite(value[\"totalCredits\"]) && Array.isArray(value[\"traces\"]) && value[\"traces\"].every((trace) => record(trace) && nonempty(trace[\"nodeId\"]) && nonempty(trace[\"nodeType\"]) && payload(trace[\"input\"]) && payload(trace[\"output\"]) && typeof trace[\"estimatedCredits\"] === \"number\" && Number.isFinite(trace[\"estimatedCredits\"]) && typeof trace[\"totalCredits\"] === \"number\" && Number.isFinite(trace[\"totalCredits\"])) && Array.isArray(value[\"nodeErrors\"]) && value[\"nodeErrors\"].every((entry) => record(entry) && nonempty(entry[\"nodeId\"]) && nonempty(entry[\"nodeType\"]) && dagError(entry[\"error\"]) && nonempty(entry[\"occurredAt\"]));\n}\nfunction received(value) {\n\tif (value === null) return \"null\";\n\tif (Array.isArray(value)) return \"array\";\n\treturn typeof value;\n}\nfunction invalid(field, expected, value) {\n\treturn {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_RUN_DRAFT_INVALID_INPUT\", `${field}: expected ${expected}; received ${received(value)}.`, {\n\t\t\tfield,\n\t\t\texpected,\n\t\t\treceived: received(value)\n\t\t})\n\t};\n}\n/** Decode external create/replace JSON once before calling a run-draft capability. */\nfunction decodeSaveRunDraftInput(value) {\n\tif (!record(value)) return invalid(\"root\", \"object\", value);\n\tif (value[\"draftId\"] !== void 0 && !nonempty(value[\"draftId\"])) return invalid(\"draftId\", \"nonempty string\", value[\"draftId\"]);\n\tconst definition = decodeDagDefinition(value[\"definition\"]);\n\tif (!definition.ok) {\n\t\tconst first = definition.error[0];\n\t\treturn invalid(`definition${first?.path ? `.${first.path}` : \"\"}`, \"valid DAG field\", value[\"definition\"]);\n\t}\n\tif (value[\"input\"] !== void 0 && !payload(value[\"input\"])) return invalid(\"input\", \"port payload object\", value[\"input\"]);\n\tif (value[\"nodeStateMap\"] !== void 0 && !nodeStateMap(value[\"nodeStateMap\"])) return invalid(\"nodeStateMap\", \"node-state map object\", value[\"nodeStateMap\"]);\n\tif (value[\"runResult\"] !== void 0 && !runResult(value[\"runResult\"])) return invalid(\"runResult\", \"run result object\", value[\"runResult\"]);\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\t...value[\"draftId\"] !== void 0 ? { draftId: value[\"draftId\"] } : {},\n\t\t\tdefinition: definition.value,\n\t\t\t...value[\"input\"] !== void 0 ? { input: value[\"input\"] } : {},\n\t\t\t...value[\"nodeStateMap\"] !== void 0 ? { nodeStateMap: value[\"nodeStateMap\"] } : {},\n\t\t\t...value[\"runResult\"] !== void 0 ? { runResult: value[\"runResult\"] } : {}\n\t\t}\n\t};\n}\n/** Decode external node-result replacement JSON. */\nfunction decodeOverwriteRunDraftNodeResultInput(value) {\n\tif (!record(value)) return invalid(\"root\", \"object\", value);\n\tif (value[\"input\"] !== void 0 && !payload(value[\"input\"])) return invalid(\"input\", \"port payload object\", value[\"input\"]);\n\tif (!payload(value[\"output\"])) return invalid(\"output\", \"port payload object\", value[\"output\"]);\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\t...value[\"input\"] !== void 0 ? { input: value[\"input\"] } : {},\n\t\t\toutput: value[\"output\"]\n\t\t}\n\t};\n}\n/** Decode an untrusted HTTP response draft, including the caller-visible state fields. */\nfunction decodeRunDraft(value) {\n\tconst input = decodeSaveRunDraftInput(value);\n\tif (!input.ok) return input;\n\tif (!record(value)) return invalid(\"root\", \"object\", value);\n\tif (!nonempty(value[\"draftId\"])) return invalid(\"draftId\", \"nonempty string\", value[\"draftId\"]);\n\tif (!payload(value[\"input\"])) return invalid(\"input\", \"port payload object\", value[\"input\"]);\n\tif (!nodeStateMap(value[\"nodeStateMap\"])) return invalid(\"nodeStateMap\", \"node-state map object\", value[\"nodeStateMap\"]);\n\tif (!nonempty(value[\"createdAt\"])) return invalid(\"createdAt\", \"nonempty string\", value[\"createdAt\"]);\n\tif (!nonempty(value[\"updatedAt\"])) return invalid(\"updatedAt\", \"nonempty string\", value[\"updatedAt\"]);\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tdraftId: value[\"draftId\"],\n\t\t\tdefinition: input.value.definition,\n\t\t\tinput: value[\"input\"],\n\t\t\tnodeStateMap: value[\"nodeStateMap\"],\n\t\t\t...input.value.runResult ? { runResult: input.value.runResult } : {},\n\t\t\tcreatedAt: value[\"createdAt\"],\n\t\t\tupdatedAt: value[\"updatedAt\"]\n\t\t}\n\t};\n}\n//#endregion\n//#region src/services/time-semantics.ts\nfunction parseToUtcIso(value) {\n\tconst epochMs = Date.parse(value);\n\tif (Number.isNaN(epochMs)) return {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_INVALID_LOGICAL_DATE\", \"logicalDate must be a valid ISO-8601 datetime string\", { logicalDate: value })\n\t};\n\treturn {\n\t\tok: true,\n\t\tvalue: new Date(epochMs).toISOString()\n\t};\n}\n/** Resolves trigger type and logical date into a normalized time context for a DAG run. */\nvar TimeSemanticsService = class {\n\tclock;\n\tconstructor(clock) {\n\t\tthis.clock = clock;\n\t}\n\tresolve(trigger, logicalDate) {\n\t\tconst requestedAt = this.clock.nowIso();\n\t\tif (trigger === \"scheduled\") {\n\t\t\tif (!logicalDate) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(\"DAG_VALIDATION_MISSING_LOGICAL_DATE\", \"scheduled trigger requires logicalDate\", { trigger })\n\t\t\t};\n\t\t\tconst parsed = parseToUtcIso(logicalDate);\n\t\t\tif (!parsed.ok) return parsed;\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: {\n\t\t\t\t\ttrigger,\n\t\t\t\t\tlogicalDate: parsed.value,\n\t\t\t\t\trequestedAt\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\tif (!logicalDate) return {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\ttrigger,\n\t\t\t\tlogicalDate: requestedAt,\n\t\t\t\trequestedAt\n\t\t\t}\n\t\t};\n\t\tconst parsed = parseToUtcIso(logicalDate);\n\t\tif (!parsed.ok) return parsed;\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\ttrigger,\n\t\t\t\tlogicalDate: parsed.value,\n\t\t\t\trequestedAt\n\t\t\t}\n\t\t};\n\t}\n};\n//#endregion\n//#region src/services/node-lifecycle-runner.ts\n/** Default cost policy evaluator that checks if the next estimated credits stays within the run budget. */\nvar RunCostPolicyEvaluator = class {\n\tassertWithinBudget(currentTotalCredits, nextEstimatedCredits, runCreditLimit) {\n\t\tif (nextEstimatedCredits < 0) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NEGATIVE_ESTIMATED_CREDITS\", \"estimatedCredits must be zero or positive\", { nextEstimatedCredits })\n\t\t};\n\t\tconst nextTotalCredits = currentTotalCredits + nextEstimatedCredits;\n\t\tif (typeof runCreditLimit === \"number\" && nextTotalCredits > runCreditLimit) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED\", \"Estimated run credits exceeds runCreditLimit\", {\n\t\t\t\tnextTotalCredits,\n\t\t\t\trunCreditLimit\n\t\t\t})\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: nextTotalCredits\n\t\t};\n\t}\n};\n/**\n* Orchestrates a node through its full lifecycle: initialize → validate → estimate cost → budget check → execute → validate output → dispose.\n*/\nvar NodeLifecycleRunner = class {\n\tlifecycleFactory;\n\tcostPolicyEvaluator;\n\tconstructor(lifecycleFactory, costPolicyEvaluator) {\n\t\tthis.lifecycleFactory = lifecycleFactory;\n\t\tthis.costPolicyEvaluator = costPolicyEvaluator;\n\t}\n\tasync runNode(input) {\n\t\tconst cancellation = () => ({\n\t\t\tok: false,\n\t\t\terror: buildTaskCancellationError(input.context.taskRunId)\n\t\t});\n\t\tif (input.context.signal?.aborted) return cancellation();\n\t\tconst lifecycle = this.lifecycleFactory.create(input.context.nodeDefinition.nodeType);\n\t\tif (!lifecycle.ok) return lifecycle;\n\t\tconst initialized = await lifecycle.value.initialize(input.context);\n\t\tif (input.context.signal?.aborted) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn cancellation();\n\t\t}\n\t\tif (!initialized.ok) return initialized;\n\t\tconst validatedInput = await lifecycle.value.validateInput(input.input, input.context);\n\t\tif (input.context.signal?.aborted) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn cancellation();\n\t\t}\n\t\tif (!validatedInput.ok) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn validatedInput;\n\t\t}\n\t\tconst estimated = await lifecycle.value.estimateCost(input.input, input.context);\n\t\tif (input.context.signal?.aborted) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn cancellation();\n\t\t}\n\t\tif (!estimated.ok) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn estimated;\n\t\t}\n\t\tconst budgetCheck = this.costPolicyEvaluator.assertWithinBudget(input.context.currentTotalCredits, estimated.value.estimatedCredits, input.context.runCreditLimit);\n\t\tif (!budgetCheck.ok) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn budgetCheck;\n\t\t}\n\t\tif (input.context.reserveCredits) {\n\t\t\tconst admitted = await input.context.reserveCredits(estimated.value.estimatedCredits);\n\t\t\tif (!admitted.ok) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn admitted;\n\t\t\t}\n\t\t\tif (input.context.signal?.aborted) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn cancellation();\n\t\t\t}\n\t\t}\n\t\tconst reserved = input.context.rootCreditBudget?.reserve(estimated.value.estimatedCredits);\n\t\tif (reserved && !reserved.ok) {\n\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\treturn reserved;\n\t\t}\n\t\ttry {\n\t\t\tconst executed = await lifecycle.value.execute(input.input, input.context);\n\t\t\tif (input.context.signal?.aborted) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn cancellation();\n\t\t\t}\n\t\t\tif (!executed.ok) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn executed;\n\t\t\t}\n\t\t\tconst validatedOutput = await lifecycle.value.validateOutput(executed.value, input.context);\n\t\t\tif (input.context.signal?.aborted) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn cancellation();\n\t\t\t}\n\t\t\tif (!validatedOutput.ok) {\n\t\t\t\tawait lifecycle.value.dispose(input.context);\n\t\t\t\treturn validatedOutput;\n\t\t\t}\n\t\t\tconst disposed = await lifecycle.value.dispose(input.context);\n\t\t\tif (input.context.signal?.aborted) return cancellation();\n\t\t\tif (!disposed.ok) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_DISPOSE_FAILED\", \"Node dispose step failed after execution\", false, {\n\t\t\t\t\tnodeType: input.context.nodeDefinition.nodeType,\n\t\t\t\t\ttaskRunId: input.context.taskRunId\n\t\t\t\t})\n\t\t\t};\n\t\t\treserved?.value.commit();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: {\n\t\t\t\t\toutput: executed.value,\n\t\t\t\t\testimatedCredits: estimated.value.estimatedCredits,\n\t\t\t\t\ttotalCredits: budgetCheck.value\n\t\t\t\t}\n\t\t\t};\n\t\t} finally {\n\t\t\tif (reserved?.ok) reserved.value.release();\n\t\t}\n\t}\n};\n/** Sentinel factory that always returns an error — used when no lifecycle factory is configured. */\nvar MissingNodeLifecycleFactory = class {\n\tcreate(nodeType) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_LIFECYCLE_NOT_REGISTERED\", \"Node lifecycle is not registered for nodeType\", { nodeType })\n\t\t};\n\t}\n};\n//#endregion\n//#region src/services/lifecycle-task-executor-port.ts\n/**\n* Adapter that implements {@link ITaskExecutorPort} by delegating to {@link NodeLifecycleRunner}.\n* Bridges the task execution input into the node lifecycle execution model.\n*/\nvar LifecycleTaskExecutorPort = class {\n\tnodeManifestRegistry;\n\tlineage;\n\tlifecycleFactory;\n\trunner;\n\tconstructor(nodeManifestRegistry, lifecycleFactory, lineage) {\n\t\tthis.nodeManifestRegistry = nodeManifestRegistry;\n\t\tthis.lineage = lineage;\n\t\tthis.lifecycleFactory = lifecycleFactory ?? new MissingNodeLifecycleFactory();\n\t\tthis.runner = new NodeLifecycleRunner(this.lifecycleFactory, new RunCostPolicyEvaluator());\n\t}\n\tasync execute(input) {\n\t\tif (!input.nodeDefinition) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_DEFINITION_MISSING\", \"Task execution requires nodeDefinition in execution input\", { nodeId: input.nodeId })\n\t\t};\n\t\tconst nodeManifest = this.nodeManifestRegistry.getManifest(input.nodeDefinition.nodeType);\n\t\tif (!nodeManifest) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_MANIFEST_NOT_FOUND\", \"Node manifest is not registered for nodeType\", { nodeType: input.nodeDefinition.nodeType })\n\t\t};\n\t\tconst executed = await this.runner.runNode({\n\t\t\tinput: input.input,\n\t\t\tcontext: {\n\t\t\t\texecutionRoot: input.executionRoot,\n\t\t\t\tregexReplaceOperation: input.regexReplaceOperation,\n\t\t\t\tsnapshotBudget: input.snapshotBudget,\n\t\t\t\trootCreditBudget: input.rootCreditBudget,\n\t\t\t\treserveCredits: input.reserveCredits,\n\t\t\t\t...input.byteLimits === void 0 ? {} : { byteLimits: input.byteLimits },\n\t\t\t\t...input.signal === void 0 ? {} : { signal: input.signal },\n\t\t\t\tdagId: input.dagId,\n\t\t\t\tdagRunId: input.dagRunId,\n\t\t\t\ttaskRunId: input.taskRunId,\n\t\t\t\tnodeDefinition: input.nodeDefinition,\n\t\t\t\tnodeManifest,\n\t\t\t\tattempt: input.attempt,\n\t\t\t\texecutionPath: input.executionPath,\n\t\t\t\tlineage: input.lineage ?? this.lineage ?? {\n\t\t\t\t\trootRunId: input.dagRunId,\n\t\t\t\t\tdepth: 0,\n\t\t\t\t\tancestorCompositeNodeTypes: []\n\t\t\t\t},\n\t\t\t\trunCreditLimit: input.costPolicy?.runCreditLimit,\n\t\t\t\tcurrentTotalCredits: input.currentTotalCredits ?? 0,\n\t\t\t\t...input.runtimeBaseUrl !== void 0 ? { runtimeBaseUrl: input.runtimeBaseUrl } : {}\n\t\t\t}\n\t\t});\n\t\tif (!executed.ok) return executed;\n\t\treturn {\n\t\t\tok: true,\n\t\t\toutput: executed.value.output,\n\t\t\testimatedCredits: executed.value.estimatedCredits,\n\t\t\ttotalCredits: executed.value.totalCredits\n\t\t};\n\t}\n};\n//#endregion\n//#region src/types/prompt-types.ts\nfunction isPromptLink(value) {\n\treturn Array.isArray(value) && value.length === 2 && typeof value[0] === \"string\" && typeof value[1] === \"number\";\n}\n//#endregion\n//#region src/types/workspace-layout.ts\n/** Default layout: a `.workflows/` workspace with flat `.json` workflow definitions. */\nconst DEFAULT_WORKSPACE_LAYOUT = {\n\troot: \".workflows\",\n\tworkflowExt: \".json\"\n};\n//#endregion\n//#region src/services/execution-commit.ts\n/** Pure decision shared by adapters; adapters MUST evaluate and apply without an intervening await. */\nfunction decideExecutionCommit(run, tasks, mutation) {\n\tconst rejected = { result: {\n\t\tapplied: false,\n\t\trunStatus: run?.status\n\t} };\n\tif (!run) return rejected;\n\tif (mutation.kind === \"transition-run\") {\n\t\tif (run.status !== mutation.expectedStatus) return rejected;\n\t\tconst transition = DagRunStateMachine.transition(run.status, mutation.event);\n\t\tif (!transition.ok) return rejected;\n\t\tconst dagRun = {\n\t\t\t...run,\n\t\t\tstatus: transition.value.nextStatus,\n\t\t\tendedAt: mutation.endedAt\n\t\t};\n\t\treturn {\n\t\t\tdagRun,\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: dagRun.status\n\t\t\t}\n\t\t};\n\t}\n\tif (mutation.kind === \"finalize\") {\n\t\tif (run.status !== \"running\" || tasks.some((task) => [\n\t\t\t\"created\",\n\t\t\t\"queued\",\n\t\t\t\"running\"\n\t\t].includes(task.status))) return rejected;\n\t\tconst pendingAdmission = hasPendingAdmission(run, tasks);\n\t\tif (!pendingAdmission.ok) return { result: {\n\t\t\t...rejected.result,\n\t\t\terror: pendingAdmission.error\n\t\t} };\n\t\tif (pendingAdmission.value) return rejected;\n\t\tconst transition = DagRunStateMachine.transition(run.status, tasks.some((task) => task.status === \"failed\") ? \"COMPLETE_FAILURE\" : \"COMPLETE_SUCCESS\");\n\t\tif (!transition.ok) return rejected;\n\t\tconst status = transition.value.nextStatus;\n\t\treturn {\n\t\t\tdagRun: {\n\t\t\t\t...run,\n\t\t\t\tstatus,\n\t\t\t\tendedAt: mutation.endedAt\n\t\t\t},\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: status\n\t\t\t}\n\t\t};\n\t}\n\tif (mutation.kind === \"admit\") {\n\t\tif (run.status !== \"running\" || mutation.taskRun.dagRunId !== run.dagRunId || tasks.some((task) => task.nodeId === mutation.taskRun.nodeId || task.taskRunId === mutation.taskRun.taskRunId) || !mutation.dependsOn.every((nodeId) => tasks.some((task) => task.nodeId === nodeId && task.status === \"success\"))) return rejected;\n\t\treturn {\n\t\t\ttaskRun: mutation.taskRun,\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: run.status,\n\t\t\t\ttaskRun: mutation.taskRun\n\t\t\t}\n\t\t};\n\t}\n\tconst task = tasks.find((candidate) => candidate.taskRunId === mutation.taskRunId);\n\tif (mutation.kind === \"cancel-task\") {\n\t\tif (!task || ![\"failed\", \"cancelled\"].includes(run.status)) return rejected;\n\t\tconst transition = TaskRunStateMachine.transition(task.status, \"CANCEL\");\n\t\tif (!transition.ok) return rejected;\n\t\tconst taskRun = {\n\t\t\t...task,\n\t\t\tstatus: transition.value.nextStatus,\n\t\t\tleaseOwner: void 0,\n\t\t\tleaseUntil: void 0,\n\t\t\treservedCredits: void 0,\n\t\t\treservationAttempt: void 0,\n\t\t\treservationOwner: void 0,\n\t\t\terrorCode: mutation.error?.code,\n\t\t\terrorMessage: mutation.error?.message\n\t\t};\n\t\treturn {\n\t\t\ttaskRun,\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: run.status,\n\t\t\t\ttaskRun\n\t\t\t}\n\t\t};\n\t}\n\tif (!task || task.status !== \"running\" || task.attempt !== mutation.attempt || task.leaseOwner !== mutation.leaseOwner) return rejected;\n\tif (run.status !== \"running\") {\n\t\tif (run.status !== \"cancelled\" || task.status !== \"running\") return rejected;\n\t\tconst taskRun = {\n\t\t\t...task,\n\t\t\tstatus: \"cancelled\",\n\t\t\tleaseOwner: void 0,\n\t\t\tleaseUntil: void 0,\n\t\t\treservedCredits: void 0,\n\t\t\treservationAttempt: void 0,\n\t\t\treservationOwner: void 0\n\t\t};\n\t\treturn {\n\t\t\ttaskRun,\n\t\t\tresult: {\n\t\t\t\tapplied: false,\n\t\t\t\trunStatus: run.status,\n\t\t\t\ttaskRun\n\t\t\t}\n\t\t};\n\t}\n\tif (mutation.kind === \"snapshot-input\") {\n\t\tconst taskRun = {\n\t\t\t...task,\n\t\t\tinputSnapshot: mutation.inputSnapshot\n\t\t};\n\t\treturn {\n\t\t\ttaskRun,\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: run.status,\n\t\t\t\ttaskRun\n\t\t\t}\n\t\t};\n\t}\n\tif (mutation.kind === \"reserve-credits\") {\n\t\tconst credits = mutation.estimatedCredits;\n\t\tif (!Number.isFinite(credits) || credits < 0 || run.definitionSnapshot === void 0) return rejected;\n\t\tlet snapshot;\n\t\ttry {\n\t\t\tsnapshot = JSON.parse(run.definitionSnapshot);\n\t\t} catch {\n\t\t\treturn rejected;\n\t\t}\n\t\tconst decoded = decodeDagDefinitionAsDagError(snapshot, \"DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID\", \"DagRun definition snapshot has invalid shape\", { dagRunId: run.dagRunId });\n\t\tif (!decoded.ok || decoded.value.costPolicy === void 0) return rejected;\n\t\tconst runCreditLimit = decoded.value.costPolicy.runCreditLimit;\n\t\tif (task.reservedCredits !== void 0) return { result: {\n\t\t\t...rejected.result,\n\t\t\tapplied: task.reservationAttempt === mutation.attempt && task.reservationOwner === mutation.leaseOwner && task.reservedCredits === credits\n\t\t} };\n\t\tconst charged = committedCreditTotal(tasks);\n\t\tif (!charged.ok) return { result: {\n\t\t\t...rejected.result,\n\t\t\terror: charged.error\n\t\t} };\n\t\tconst occupied = charged.value + tasks.reduce((sum, sibling) => sum + (sibling.reservedCredits ?? 0), 0);\n\t\tif (occupied + credits > runCreditLimit) return { result: {\n\t\t\t...rejected.result,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_CREDIT_LIMIT_EXCEEDED\", \"Estimated run credits exceeds runCreditLimit\", {\n\t\t\t\tnextTotalCredits: occupied + credits,\n\t\t\t\trunCreditLimit\n\t\t\t})\n\t\t} };\n\t\tconst taskRun = {\n\t\t\t...task,\n\t\t\treservedCredits: credits,\n\t\t\treservationAttempt: mutation.attempt,\n\t\t\treservationOwner: mutation.leaseOwner\n\t\t};\n\t\treturn {\n\t\t\ttaskRun,\n\t\t\tresult: {\n\t\t\t\tapplied: true,\n\t\t\t\trunStatus: run.status,\n\t\t\t\ttaskRun\n\t\t\t}\n\t\t};\n\t}\n\tconst transition = TaskRunStateMachine.transition(task.status, mutation.status === \"success\" ? \"COMPLETE_SUCCESS\" : \"COMPLETE_FAILURE\");\n\tif (!transition.ok) return rejected;\n\tif (mutation.status === \"success\" && run.definitionSnapshot !== void 0) {\n\t\tlet snapshot;\n\t\ttry {\n\t\t\tsnapshot = JSON.parse(run.definitionSnapshot);\n\t\t} catch {\n\t\t\treturn rejected;\n\t\t}\n\t\tconst decoded = decodeDagDefinitionAsDagError(snapshot, \"DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID\", \"DagRun definition snapshot has invalid shape\", { dagRunId: run.dagRunId });\n\t\tif (!decoded.ok) return rejected;\n\t\tif (decoded.value.costPolicy !== void 0 && task.reservedCredits === void 0) return rejected;\n\t}\n\tif (mutation.status === \"success\" && task.reservedCredits !== void 0 && (task.reservationAttempt !== mutation.attempt || task.reservationOwner !== mutation.leaseOwner || mutation.estimatedCredits !== task.reservedCredits)) return rejected;\n\tconst charged = mutation.status === \"success\" && task.reservedCredits !== void 0 ? committedCreditTotal(tasks) : void 0;\n\tif (charged && !charged.ok) return { result: {\n\t\t...rejected.result,\n\t\terror: charged.error\n\t} };\n\tconst retry = mutation.status === \"failed\" && mutation.reserveRetry === true;\n\tconst retryTransition = retry ? TaskRunStateMachine.transition(transition.value.nextStatus, \"RETRY\") : void 0;\n\tif (retryTransition && !retryTransition.ok) return rejected;\n\tconst taskRun = {\n\t\t...task,\n\t\tstatus: retryTransition?.ok ? retryTransition.value.nextStatus : transition.value.nextStatus,\n\t\tattempt: retry ? task.attempt + 1 : task.attempt,\n\t\treservedCredits: void 0,\n\t\treservationAttempt: void 0,\n\t\treservationOwner: void 0,\n\t\terrorCode: retry ? void 0 : mutation.error?.code,\n\t\terrorMessage: retry ? void 0 : mutation.error?.message,\n\t\t...mutation.outputSnapshot === void 0 ? {} : { outputSnapshot: mutation.outputSnapshot },\n\t\t...mutation.estimatedCredits === void 0 ? {} : { estimatedCredits: mutation.estimatedCredits },\n\t\t...mutation.status !== \"success\" || task.reservedCredits === void 0 ? mutation.totalCredits === void 0 ? {} : { totalCredits: mutation.totalCredits } : { totalCredits: charged.value + task.reservedCredits }\n\t};\n\treturn {\n\t\ttaskRun,\n\t\tresult: {\n\t\t\tapplied: true,\n\t\t\trunStatus: run.status,\n\t\t\ttaskRun\n\t\t}\n\t};\n}\n/** Use the larger of known charges and persisted cumulative totals as the historic floor. */\nfunction committedCreditTotal(tasks) {\n\tlet estimatedTotal = 0;\n\tlet cumulativeFloor = 0;\n\tfor (const task of tasks) {\n\t\tif (task.status !== \"success\") continue;\n\t\tif (task.totalCredits !== void 0) {\n\t\t\tif (!Number.isFinite(task.totalCredits) || task.totalCredits < 0) return ambiguousCreditHistory(task);\n\t\t\tcumulativeFloor = Math.max(cumulativeFloor, task.totalCredits);\n\t\t}\n\t\tif (task.estimatedCredits === void 0 && task.totalCredits === void 0) return ambiguousCreditHistory(task);\n\t\tif (task.estimatedCredits !== void 0) {\n\t\t\tif (!Number.isFinite(task.estimatedCredits) || task.estimatedCredits < 0) return ambiguousCreditHistory(task);\n\t\t\testimatedTotal += task.estimatedCredits;\n\t\t}\n\t}\n\treturn {\n\t\tok: true,\n\t\tvalue: Math.max(estimatedTotal, cumulativeFloor)\n\t};\n}\nfunction ambiguousCreditHistory(task) {\n\treturn {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_CREDIT_HISTORY_AMBIGUOUS\", \"Prior task credits cannot be accounted for safely\", { taskRunId: task.taskRunId })\n\t};\n}\n/** A completed frontier can still have runnable nodes that a concurrent dispatcher has not admitted. */\nfunction hasPendingAdmission(run, tasks) {\n\tif (run.definitionSnapshot === void 0) return {\n\t\tok: true,\n\t\tvalue: false\n\t};\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(run.definitionSnapshot);\n\t} catch {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_DEFINITION_SNAPSHOT_PARSE_FAILED\", \"Failed to parse DagRun definition snapshot\", { dagRunId: run.dagRunId })\n\t\t};\n\t}\n\tconst definition = decodeDagDefinitionAsDagError(parsed, \"DAG_VALIDATION_DEFINITION_SNAPSHOT_INVALID\", \"DagRun definition snapshot has invalid shape\", { dagRunId: run.dagRunId });\n\tif (!definition.ok) return definition;\n\treturn {\n\t\tok: true,\n\t\tvalue: definition.value.nodes.some((node) => !tasks.some((task) => task.nodeId === node.nodeId) && node.dependsOn.every((nodeId) => tasks.some((task) => task.nodeId === nodeId && task.status === \"success\")))\n\t};\n}\n//#endregion\n//#region src/index.ts\nconst DAG_CORE_PACKAGE_NAME = \"@robota-sdk/dag-core\";\n//#endregion\nexport { DAG_CORE_PACKAGE_NAME, DAG_DEFINITION_STATUS, DAG_DEFINITION_STATUSES, DAG_RUN_STATUS, DEFAULT_DAG_EXECUTION_BYTE_LIMITS, DEFAULT_DAG_RUNTIME_BASE_URL, DEFAULT_TASK_SNAPSHOT_BUDGET_LIMITS, DEFAULT_WORKSPACE_LAYOUT, DagDefinitionService, DagDefinitionValidator, DagRunStateMachine, EXECUTION_EVENT_PREFIX, EXECUTION_PROGRESS_EVENTS, LifecycleTaskExecutorPort, MissingNodeLifecycleFactory, NodeLifecycleRunner, RUN_EVENTS, RUN_EVENT_PREFIX, RootCreditBudget, RunCostPolicyEvaluator, SCHEDULER_EVENTS, SCHEDULER_EVENT_PREFIX, TASK_EVENTS, TASK_EVENT_PREFIX, TASK_PROGRESS_EVENTS, TASK_RUN_STATUS, TaskRunStateMachine, TaskSnapshotBudget, TimeSemanticsService, WORKER_EVENTS, WORKER_EVENT_PREFIX, applyRunProgressEventToNodeStateMap, applyRunResultToNodeStateMap, buildDagError, buildDispatchError, buildLeaseError, buildListPortHandleKey, buildTaskCancellationError, buildTaskExecutionError, buildValidationError, createDefaultDagNodeState, dagDecodeIssuesToError, decideExecutionCommit, decodeDagDefinition, decodeDagDefinitionAsDagError, decodeDagExecutionLineage, decodeDagRobotaCompanion, decodeDagWorkflowFile, decodeOverwriteRunDraftNodeResultInput, decodeRunDraft, decodeSaveRunDraftInput, formatDagDecodeIssues, isDagNodeStateMapRunnable, isPromptLink, markDagNodeOperationDone, markDagNodeOperationStarted, overwriteDagNodeExecutionTrace, overwriteRunResultNodeTrace, parseListPortHandleKey, reconcileDagNodeStateMap, resetDagNodeExecutionStateFromNode, resetDagNodeExecutionStateMap, resetRunResultFromNode, resolveDagExecutionByteLimits, resolveRuntimeBaseUrl, resolveTaskSnapshotBudgetLimits, summarizeDagDefinitions, validateEdgesAndBindings };\n\n//# sourceMappingURL=index.js.map","import { buildValidationError, parseListPortHandleKey } from \"@robota-sdk/dag-core\";\nimport { z } from \"zod\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\n//#region src/lifecycle/abstract-node-definition.ts\nfunction createConfigValidationError(nodeType, context, parseError) {\n\tconst firstIssue = parseError.issues[0];\n\treturn buildValidationError(\"DAG_VALIDATION_NODE_CONFIG_SCHEMA_INVALID\", `Node config does not satisfy schema: ${firstIssue?.path.join(\".\") ?? \"config\"} ${firstIssue?.message ?? \"Invalid config\"}`, {\n\t\tnodeId: context.nodeDefinition.nodeId,\n\t\tnodeType,\n\t\tissueCount: parseError.issues.length\n\t});\n}\n/**\n* Base class for all DAG node definitions. Handles config schema parsing via zod\n* and delegates lifecycle methods to typed `*WithConfig` overrides.\n*\n* Subclasses must implement `configSchemaDefinition`, metadata fields, and\n* at minimum `executeWithConfig`. Optional lifecycle hooks:\n* `initializeWithConfig`, `estimateCostWithConfig`, `validateInputWithConfig`,\n* `validateOutputWithConfig`, `disposeWithConfig`.\n*\n* @see IDagNodeDefinition - interface this class implements\n* @see NodeIoAccessor - helper for typed input/output access in execute methods\n*/\nvar AbstractNodeDefinition = class {\n\tdefaultInputPort;\n\tdefaultOutputPort;\n\ttaskHandler;\n\tconstructor() {\n\t\tthis.taskHandler = {\n\t\t\tinitialize: async (context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.initializeWithConfig(context, configResult.value);\n\t\t\t},\n\t\t\tvalidateInput: async (input, context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.validateInputWithConfig(input, context, configResult.value);\n\t\t\t},\n\t\t\testimateCost: async (input, context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.estimateCostWithConfig(input, context, configResult.value);\n\t\t\t},\n\t\t\texecute: async (input, context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.executeWithConfig(input, context, configResult.value);\n\t\t\t},\n\t\t\tvalidateOutput: async (output, context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.validateOutputWithConfig(output, context, configResult.value);\n\t\t\t},\n\t\t\tdispose: async (context) => {\n\t\t\t\tconst configResult = this.parseNodeConfig(context);\n\t\t\t\tif (!configResult.ok) return configResult;\n\t\t\t\treturn this.disposeWithConfig(context, configResult.value);\n\t\t\t}\n\t\t};\n\t}\n\tparseNodeConfig(context) {\n\t\tconst parseResult = this.configSchemaDefinition.safeParse(context.nodeDefinition.config);\n\t\tif (!parseResult.success) return {\n\t\t\tok: false,\n\t\t\terror: createConfigValidationError(this.nodeType, context, parseResult.error)\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: parseResult.data\n\t\t};\n\t}\n\tasync initializeWithConfig(_context, _config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t}\n\tasync validateInputWithConfig(_input, _context, _config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t}\n\tasync validateOutputWithConfig(_output, _context, _config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t}\n\tasync disposeWithConfig(_context, _config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t}\n};\n//#endregion\n//#region src/value-objects/media-reference.ts\nconst ASSET_URI_PREFIX = \"asset://\";\n/**\n* Immutable value object representing a media asset reference.\n* Normalizes asset ID and URI references into a canonical form.\n*/\nvar MediaReference = class MediaReference {\n\tvalue;\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n\tstatic fromAssetReference(reference) {\n\t\tif (reference.referenceType === \"asset\") return new MediaReference({\n\t\t\treferenceType: \"asset\",\n\t\t\tassetId: reference.assetId,\n\t\t\tmediaType: reference.mediaType,\n\t\t\tname: reference.name,\n\t\t\tsizeBytes: reference.sizeBytes\n\t\t});\n\t\treturn new MediaReference({\n\t\t\treferenceType: \"uri\",\n\t\t\turi: reference.uri,\n\t\t\tmediaType: reference.mediaType,\n\t\t\tname: reference.name,\n\t\t\tsizeBytes: reference.sizeBytes\n\t\t});\n\t}\n\tstatic fromBinary(value) {\n\t\tif (typeof value.assetId === \"string\" && value.assetId.trim().length > 0) return {\n\t\t\tok: true,\n\t\t\tvalue: new MediaReference({\n\t\t\t\treferenceType: \"asset\",\n\t\t\t\tassetId: value.assetId.trim(),\n\t\t\t\tmediaType: value.mimeType,\n\t\t\t\tsizeBytes: value.sizeBytes\n\t\t\t})\n\t\t};\n\t\tif (value.uri.startsWith(ASSET_URI_PREFIX)) {\n\t\t\tconst parsedAssetId = value.uri.slice(8).trim();\n\t\t\tif (parsedAssetId.length === 0) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(\"DAG_VALIDATION_MEDIA_REFERENCE_INVALID\", \"Binary asset URI must include non-empty assetId\")\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: new MediaReference({\n\t\t\t\t\treferenceType: \"asset\",\n\t\t\t\t\tassetId: parsedAssetId,\n\t\t\t\t\tmediaType: value.mimeType,\n\t\t\t\t\tsizeBytes: value.sizeBytes\n\t\t\t\t})\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: new MediaReference({\n\t\t\t\treferenceType: \"uri\",\n\t\t\t\turi: value.uri,\n\t\t\t\tmediaType: value.mimeType,\n\t\t\t\tsizeBytes: value.sizeBytes\n\t\t\t})\n\t\t};\n\t}\n\tstatic fromCandidate(candidate, options) {\n\t\tconst hasAssetId = typeof candidate.assetId === \"string\" && (options?.allowEmptyAssetId === true || candidate.assetId.trim().length > 0);\n\t\tconst hasUri = typeof candidate.uri === \"string\" && (options?.allowEmptyUri === true || candidate.uri.trim().length > 0);\n\t\tif (hasAssetId === hasUri) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_MEDIA_REFERENCE_XOR_REQUIRED\", \"Exactly one of assetId or uri must be provided\")\n\t\t};\n\t\tif (candidate.referenceType === \"asset\" && !hasAssetId) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_MEDIA_REFERENCE_TYPE_MISMATCH\", \"referenceType asset requires assetId\")\n\t\t};\n\t\tif (candidate.referenceType === \"uri\" && !hasUri) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_MEDIA_REFERENCE_TYPE_MISMATCH\", \"referenceType uri requires uri\")\n\t\t};\n\t\treturn this.buildFromValidatedCandidate(candidate, hasAssetId);\n\t}\n\tstatic buildFromValidatedCandidate(candidate, hasAssetId) {\n\t\tif (hasAssetId && typeof candidate.assetId === \"string\") return {\n\t\t\tok: true,\n\t\t\tvalue: new MediaReference({\n\t\t\t\treferenceType: \"asset\",\n\t\t\t\tassetId: candidate.assetId.trim(),\n\t\t\t\tmediaType: candidate.mediaType,\n\t\t\t\tname: candidate.name,\n\t\t\t\tsizeBytes: candidate.sizeBytes\n\t\t\t})\n\t\t};\n\t\tif (typeof candidate.uri !== \"string\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_MEDIA_REFERENCE_INVALID\", \"uri must be a string when referenceType is uri\")\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: new MediaReference({\n\t\t\t\treferenceType: \"uri\",\n\t\t\t\turi: candidate.uri,\n\t\t\t\tmediaType: candidate.mediaType,\n\t\t\t\tname: candidate.name,\n\t\t\t\tsizeBytes: candidate.sizeBytes\n\t\t\t})\n\t\t};\n\t}\n\tisAsset() {\n\t\treturn this.value.referenceType === \"asset\";\n\t}\n\tisUri() {\n\t\treturn this.value.referenceType === \"uri\";\n\t}\n\tassetId() {\n\t\treturn this.value.assetId;\n\t}\n\turi() {\n\t\treturn this.value.uri;\n\t}\n\tmediaType() {\n\t\treturn this.value.mediaType;\n\t}\n\ttoAssetIdOrUri() {\n\t\tif (this.value.referenceType === \"asset\" && typeof this.value.assetId === \"string\") return {\n\t\t\treferenceType: \"asset\",\n\t\t\tassetId: this.value.assetId\n\t\t};\n\t\treturn {\n\t\t\treferenceType: \"uri\",\n\t\t\turi: this.value.uri ?? \"\"\n\t\t};\n\t}\n\ttoAssetContentUrl(baseUrl) {\n\t\tif (!this.isAsset() || typeof this.value.assetId !== \"string\") return;\n\t\treturn `${baseUrl.replace(/\\/$/, \"\")}/view?filename=${encodeURIComponent(this.value.assetId)}`;\n\t}\n\ttoBinary(kind, defaultMimeType) {\n\t\tconst mimeType = typeof this.value.mediaType === \"string\" && this.value.mediaType.trim().length > 0 ? this.value.mediaType : defaultMimeType;\n\t\tif (this.value.referenceType === \"asset\" && typeof this.value.assetId === \"string\") return {\n\t\t\tkind,\n\t\t\tmimeType,\n\t\t\turi: `${ASSET_URI_PREFIX}${this.value.assetId}`,\n\t\t\treferenceType: \"asset\",\n\t\t\tassetId: this.value.assetId,\n\t\t\tsizeBytes: this.value.sizeBytes\n\t\t};\n\t\treturn {\n\t\t\tkind,\n\t\t\tmimeType,\n\t\t\turi: this.value.uri ?? \"\",\n\t\t\treferenceType: \"uri\",\n\t\t\tsizeBytes: this.value.sizeBytes\n\t\t};\n\t}\n};\n//#endregion\n//#region src/lifecycle/binary-value-parser.ts\n/**\n* Parses and validates a raw port value as a binary payload object.\n*\n* @param rawValue - The raw port value to parse.\n* @param nodeId - The node identifier (for error context).\n* @param key - The port key name (for error context).\n* @param kind - Optional expected binary kind constraint.\n* @returns A validated binary value or a validation error.\n*/\nfunction parseBinaryValue(rawValue, nodeId, key, kind) {\n\tif (typeof rawValue !== \"object\" || rawValue === null || Array.isArray(rawValue)) return {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input key must be binary payload object\", {\n\t\t\tnodeId,\n\t\t\tkey,\n\t\t\texpectedType: \"binary\"\n\t\t})\n\t};\n\tconst value = rawValue;\n\tif (!(value.kind === \"image\" || value.kind === \"video\" || value.kind === \"audio\" || value.kind === \"file\") || typeof value.mimeType !== \"string\" || typeof value.uri !== \"string\") return {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input key must be valid binary payload\", {\n\t\t\tnodeId,\n\t\t\tkey,\n\t\t\texpectedType: \"binary\"\n\t\t})\n\t};\n\tconst binaryKind = value.kind;\n\tif (kind && binaryKind !== kind) return {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input binary kind does not match expected kind\", {\n\t\t\tnodeId,\n\t\t\tkey,\n\t\t\texpectedKind: kind,\n\t\t\tactualKind: binaryKind\n\t\t})\n\t};\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tkind: binaryKind,\n\t\t\tmimeType: value.mimeType,\n\t\t\turi: value.uri,\n\t\t\treferenceType: value.referenceType === \"asset\" || value.referenceType === \"uri\" ? value.referenceType : void 0,\n\t\t\tassetId: typeof value.assetId === \"string\" ? value.assetId : void 0,\n\t\t\tsizeBytes: typeof value.sizeBytes === \"number\" ? value.sizeBytes : void 0\n\t\t}\n\t};\n}\n//#endregion\n//#region src/lifecycle/node-io-accessor.ts\n/**\n* Typed accessor for reading node inputs and building node outputs within execute methods.\n*\n* Provides `requireInput*` helpers that return `TResult` with validation errors,\n* and `setOutput` / `toOutput` for constructing the output payload.\n*\n* @see AbstractNodeDefinition - base class that uses this accessor in lifecycle hooks\n*/\nvar NodeIoAccessor = class {\n\tinput;\n\tnodeId;\n\toutput = {};\n\tconstructor(input, nodeId) {\n\t\tthis.input = input;\n\t\tthis.nodeId = nodeId;\n\t}\n\tgetInput(key) {\n\t\treturn this.input[key];\n\t}\n\trequireInput(key) {\n\t\tconst value = this.getInput(key);\n\t\tif (typeof value === \"undefined\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_MISSING\", \"Node input key is missing\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey\n\t\t\t})\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue\n\t\t};\n\t}\n\trequireInputString(key) {\n\t\tconst inputResult = this.requireInput(key);\n\t\tif (!inputResult.ok) return inputResult;\n\t\tif (typeof inputResult.value !== \"string\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input key must be string\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\texpectedType: \"string\"\n\t\t\t})\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: inputResult.value\n\t\t};\n\t}\n\trequireInputArray(key) {\n\t\tconst directValue = this.getInput(key);\n\t\tif (Array.isArray(directValue)) return {\n\t\t\tok: true,\n\t\t\tvalue: directValue\n\t\t};\n\t\tconst listHandleValues = this.collectListHandleValues(key);\n\t\tif (listHandleValues) return {\n\t\t\tok: true,\n\t\t\tvalue: listHandleValues\n\t\t};\n\t\tif (typeof directValue === \"undefined\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_MISSING\", \"Node input key is missing\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey\n\t\t\t})\n\t\t};\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input key must be array\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\texpectedType: \"array\"\n\t\t\t})\n\t\t};\n\t}\n\trequireInputBinary(key, kind) {\n\t\tconst inputResult = this.requireInput(key);\n\t\tif (!inputResult.ok) return inputResult;\n\t\treturn parseBinaryValue(inputResult.value, this.nodeId, key, kind);\n\t}\n\trequireInputBinaryList(key, kind, options) {\n\t\tconst arrayResult = this.requireInputArray(key);\n\t\tif (!arrayResult.ok) return arrayResult;\n\t\tconst values = arrayResult.value;\n\t\tif (typeof options?.minItems === \"number\" && values.length < options.minItems) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_MIN_ITEMS_NOT_SATISFIED\", \"Node input list does not satisfy minItems\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\tminItems: options.minItems,\n\t\t\t\tactualItems: values.length\n\t\t\t})\n\t\t};\n\t\tif (typeof options?.maxItems === \"number\" && values.length > options.maxItems) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_MAX_ITEMS_EXCEEDED\", \"Node input list exceeds maxItems\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\tmaxItems: options.maxItems,\n\t\t\t\tactualItems: values.length\n\t\t\t})\n\t\t};\n\t\tconst parsedValues = [];\n\t\tfor (const [index, value] of values.entries()) {\n\t\t\tconst parsedResult = parseBinaryValue(value, this.nodeId, `${key}[${index}]`, kind);\n\t\t\tif (!parsedResult.ok) return parsedResult;\n\t\t\tparsedValues.push(parsedResult.value);\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: parsedValues\n\t\t};\n\t}\n\trequireInputMediaReference(key, options) {\n\t\tconst inputResult = this.requireInput(key);\n\t\tif (!inputResult.ok) return inputResult;\n\t\treturn this.parseMediaReferenceValue(inputResult.value, key, options);\n\t}\n\trequireInputBinaryReference(key, kind) {\n\t\tconst binaryResult = this.requireInputBinary(key, kind);\n\t\tif (!binaryResult.ok) return binaryResult;\n\t\tconst parsedResult = MediaReference.fromBinary(binaryResult.value);\n\t\tif (!parsedResult.ok) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(parsedResult.error.code, parsedResult.error.message, {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\t...parsedResult.error.context ?? {}\n\t\t\t})\n\t\t};\n\t\treturn parsedResult;\n\t}\n\tsetOutput(key, value) {\n\t\tthis.output[key] = value;\n\t}\n\ttoOutput() {\n\t\treturn { ...this.output };\n\t}\n\tcollectListHandleValues(portKey) {\n\t\tconst valuesByIndex = /* @__PURE__ */ new Map();\n\t\tfor (const [handleKey, value] of Object.entries(this.input)) {\n\t\t\tconst parsed = parseListPortHandleKey(handleKey);\n\t\t\tif (!parsed || parsed.portKey !== portKey) continue;\n\t\t\tvaluesByIndex.set(parsed.index, value);\n\t\t}\n\t\tif (valuesByIndex.size === 0) return;\n\t\tconst sortedIndices = [...valuesByIndex.keys()].sort((a, b) => a - b);\n\t\tconst expectedLength = sortedIndices[sortedIndices.length - 1] + 1;\n\t\tif (sortedIndices.length !== expectedLength) return;\n\t\tconst collected = [];\n\t\tfor (let index = 0; index < expectedLength; index += 1) {\n\t\t\tconst value = valuesByIndex.get(index);\n\t\t\tif (typeof value === \"undefined\") return;\n\t\t\tcollected.push(value);\n\t\t}\n\t\treturn collected;\n\t}\n\tparseMediaReferenceValue(rawValue, key, options) {\n\t\tif (typeof rawValue === \"string\") {\n\t\t\tif (options?.allowStringAssetUri === true && rawValue.startsWith(\"asset://\")) return this.wrapMediaReferenceError(MediaReference.fromCandidate({\n\t\t\t\treferenceType: \"asset\",\n\t\t\t\tassetId: rawValue.slice(8)\n\t\t\t}), key);\n\t\t\tif (options?.allowStringUri === true) return this.wrapMediaReferenceError(MediaReference.fromCandidate({\n\t\t\t\treferenceType: \"uri\",\n\t\t\t\turi: rawValue\n\t\t\t}), key);\n\t\t}\n\t\tif (typeof rawValue !== \"object\" || rawValue === null || Array.isArray(rawValue)) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\", \"Node input key must be media reference object\", {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\texpectedType: \"media-reference\"\n\t\t\t})\n\t\t};\n\t\treturn this.wrapMediaReferenceError(MediaReference.fromCandidate(rawValue), key);\n\t}\n\twrapMediaReferenceError(result, key) {\n\t\tif (result.ok) return result;\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(result.error.code, result.error.message, {\n\t\t\t\tnodeId: this.nodeId,\n\t\t\t\tkey,\n\t\t\t\t...result.error.context ?? {}\n\t\t\t})\n\t\t};\n\t}\n};\n//#endregion\n//#region src/lifecycle/define-dag-node.ts\n/**\n* Factory that creates a DAG node class from a plain configuration object.\n*\n* Eliminates the need to subclass AbstractNodeDefinition directly.\n* The returned class can be instantiated (new NodeClass()) and registered\n* in any node registry.\n*\n* @example\n* ```typescript\n* // upper-case.dag.node.ts\n* import { defineDagNode } from '@robota-sdk/dag-node';\n*\n* export default defineDagNode({\n* nodeType: 'upper-case',\n* inputs: [{ key: 'text', label: 'Text', order: 0, type: 'string', required: true }],\n* outputs: [{ key: 'text', label: 'Text', order: 0, type: 'string', required: true }],\n* execute: async ({ text }) => ({ text: String(text).toUpperCase() }),\n* });\n* ```\n*/\nfunction defineDagNode(options) {\n\tconst resolvedSchema = options.configSchema ?? z.object({});\n\tconst resolvedDefaultInputPort = options.defaultInputPort ?? options.inputs[0]?.key;\n\tconst resolvedDefaultOutputPort = options.defaultOutputPort ?? options.outputs[0]?.key;\n\tconst resolvedDisplayName = options.displayName ?? options.nodeType;\n\treturn class DefinedDagNode extends AbstractNodeDefinition {\n\t\tnodeType = options.nodeType;\n\t\tdisplayName = resolvedDisplayName;\n\t\tcategory = options.category ?? \"Custom\";\n\t\tdefaultInputPort = resolvedDefaultInputPort;\n\t\tdefaultOutputPort = resolvedDefaultOutputPort;\n\t\tinputs = options.inputs;\n\t\toutputs = options.outputs;\n\t\tconfigSchemaDefinition = resolvedSchema;\n\t\tasync estimateCostWithConfig(input, context, config) {\n\t\t\tif (!options.estimateCreditCost) return {\n\t\t\t\tok: true,\n\t\t\t\tvalue: { estimatedCredits: 0 }\n\t\t\t};\n\t\t\tconst inputs = extractInputRecord(input, options.inputs);\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: { estimatedCredits: await Promise.resolve(options.estimateCreditCost(inputs, config)) }\n\t\t\t};\n\t\t}\n\t\tasync executeWithConfig(input, context, config) {\n\t\t\tconst io = new NodeIoAccessor(input, context.nodeDefinition.nodeId);\n\t\t\tconst inputs = extractInputRecord(input, options.inputs);\n\t\t\tlet outputRecord;\n\t\t\ttry {\n\t\t\t\toutputRecord = await Promise.resolve(options.execute(inputs, config, context));\n\t\t\t} catch (err) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\terror: buildValidationError(\"DAG_NODE_EXECUTE_ERROR\", `Node '${options.nodeType}' execute threw an error: ${message}`, {\n\t\t\t\t\t\tnodeId: context.nodeDefinition.nodeId,\n\t\t\t\t\t\tnodeType: options.nodeType\n\t\t\t\t\t})\n\t\t\t\t};\n\t\t\t}\n\t\t\tfor (const [key, value] of Object.entries(outputRecord)) io.setOutput(key, value);\n\t\t\tif (!(\"_agentSummary\" in outputRecord)) {\n\t\t\t\tconst firstKey = options.outputs[0]?.key;\n\t\t\t\tconst firstValue = firstKey !== void 0 ? outputRecord[firstKey] : void 0;\n\t\t\t\tconst summary = typeof firstValue === \"string\" ? `${resolvedDisplayName}: ${firstValue.slice(0, 120)}` : `${resolvedDisplayName} completed.`;\n\t\t\t\tio.setOutput(\"_agentSummary\", summary);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: io.toOutput()\n\t\t\t};\n\t\t}\n\t};\n}\nfunction extractInputRecord(payload, portDefs) {\n\tconst result = {};\n\tfor (const port of portDefs) {\n\t\tconst value = payload[port.key];\n\t\tif (value !== void 0) result[port.key] = value;\n\t}\n\treturn result;\n}\n//#endregion\n//#region src/lifecycle/registered-node-lifecycle.ts\nfunction isBinaryValue(value) {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\tconst candidate = value;\n\treturn typeof candidate.kind === \"string\" && typeof candidate.mimeType === \"string\" && typeof candidate.uri === \"string\";\n}\nfunction isPortValueCompatible(port, value) {\n\tif (port.isList) {\n\t\tif (!Array.isArray(value)) return false;\n\t\treturn value.every((item) => isPortValueCompatible({\n\t\t\t...port,\n\t\t\tisList: false\n\t\t}, item));\n\t}\n\tswitch (port.type) {\n\t\tcase \"string\": return typeof value === \"string\";\n\t\tcase \"number\": return typeof value === \"number\";\n\t\tcase \"boolean\": return typeof value === \"boolean\";\n\t\tcase \"object\": return typeof value === \"object\" && value !== null && !Array.isArray(value) && !isBinaryValue(value);\n\t\tcase \"array\": return Array.isArray(value);\n\t\tcase \"binary\":\n\t\t\tif (!isBinaryValue(value)) return false;\n\t\t\tif (port.binaryKind && value.kind !== port.binaryKind) return false;\n\t\t\tif (port.mimeTypes && port.mimeTypes.length > 0 && !port.mimeTypes.includes(value.mimeType)) return false;\n\t\t\treturn true;\n\t\tdefault: return false;\n\t}\n}\nfunction validateRequiredPorts(payload, ports, mode, nodeId) {\n\tfor (const port of ports) {\n\t\tconst value = payload[port.key];\n\t\tif (typeof value === \"undefined\") {\n\t\t\tif (port.required) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(mode === \"input\" ? \"DAG_VALIDATION_NODE_REQUIRED_INPUT_MISSING\" : \"DAG_VALIDATION_NODE_REQUIRED_OUTPUT_MISSING\", mode === \"input\" ? `Required input port \"${port.key}\" (${port.type}) is missing on node \"${nodeId}\"` : `Required output port \"${port.key}\" (${port.type}) was not set by node \"${nodeId}\"`, {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tkey: port.key,\n\t\t\t\t\ttype: port.type\n\t\t\t\t}, mode === \"input\" ? {\n\t\t\t\t\taction: \"connect_port\",\n\t\t\t\t\tsuggestion: `Connect a \"${port.type}\" output to the \"${port.key}\" input of node \"${nodeId}\"`\n\t\t\t\t} : void 0)\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\t\tif (port.isList) {\n\t\t\tif (!Array.isArray(value)) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(mode === \"input\" ? \"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\" : \"DAG_VALIDATION_NODE_OUTPUT_TYPE_MISMATCH\", mode === \"input\" ? \"List input port must receive array payload\" : \"List output port must emit array payload\", {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tkey: port.key,\n\t\t\t\t\ttype: port.type\n\t\t\t\t})\n\t\t\t};\n\t\t\tif (typeof port.minItems === \"number\" && value.length < port.minItems) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(mode === \"input\" ? \"DAG_VALIDATION_NODE_INPUT_MIN_ITEMS_NOT_SATISFIED\" : \"DAG_VALIDATION_NODE_OUTPUT_MIN_ITEMS_NOT_SATISFIED\", mode === \"input\" ? \"List input port does not satisfy minItems\" : \"List output port does not satisfy minItems\", {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tkey: port.key,\n\t\t\t\t\tminItems: port.minItems,\n\t\t\t\t\tactualItems: value.length\n\t\t\t\t})\n\t\t\t};\n\t\t\tif (typeof port.maxItems === \"number\" && value.length > port.maxItems) return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildValidationError(mode === \"input\" ? \"DAG_VALIDATION_NODE_INPUT_MAX_ITEMS_EXCEEDED\" : \"DAG_VALIDATION_NODE_OUTPUT_MAX_ITEMS_EXCEEDED\", mode === \"input\" ? \"List input port exceeds maxItems\" : \"List output port exceeds maxItems\", {\n\t\t\t\t\tnodeId,\n\t\t\t\t\tkey: port.key,\n\t\t\t\t\tmaxItems: port.maxItems,\n\t\t\t\t\tactualItems: value.length\n\t\t\t\t})\n\t\t\t};\n\t\t}\n\t\tif (!isPortValueCompatible(port, value)) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(mode === \"input\" ? \"DAG_VALIDATION_NODE_INPUT_TYPE_MISMATCH\" : \"DAG_VALIDATION_NODE_OUTPUT_TYPE_MISMATCH\", mode === \"input\" ? `Input port \"${port.key}\" on node \"${nodeId}\" expects type \"${port.type}\" but received incompatible value` : `Output port \"${port.key}\" on node \"${nodeId}\" emitted value incompatible with type \"${port.type}\"`, {\n\t\t\t\tnodeId,\n\t\t\t\tkey: port.key,\n\t\t\t\ttype: port.type\n\t\t\t}, mode === \"input\" ? {\n\t\t\t\taction: \"check_port_type\",\n\t\t\t\tsuggestion: `Ensure the upstream output connected to \"${port.key}\" produces a \"${port.type}\" value`\n\t\t\t} : void 0)\n\t\t};\n\t}\n\treturn {\n\t\tok: true,\n\t\tvalue: void 0\n\t};\n}\n/**\n* {@link INodeLifecycle} implementation that delegates to an {@link INodeTaskHandler}.\n* Adds default validation for required inputs, binary ports, and output ports.\n*/\nvar RegisteredNodeLifecycle = class {\n\thandler;\n\tconstructor(handler) {\n\t\tthis.handler = handler;\n\t}\n\tasync initialize(context) {\n\t\tif (!this.handler.initialize) return {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t\treturn this.handler.initialize(context);\n\t}\n\tasync validateInput(input, context) {\n\t\tconst baseValidation = validateRequiredPorts(input, context.nodeManifest.inputs, \"input\", context.nodeDefinition.nodeId);\n\t\tif (!baseValidation.ok) return baseValidation;\n\t\tif (!this.handler.validateInput) return {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t\treturn this.handler.validateInput(input, context);\n\t}\n\tasync estimateCost(input, context) {\n\t\tif (!this.handler.estimateCost) return {\n\t\t\tok: true,\n\t\t\tvalue: { estimatedCredits: 0 }\n\t\t};\n\t\treturn this.handler.estimateCost(input, context);\n\t}\n\tasync execute(input, context) {\n\t\treturn this.handler.execute(input, context);\n\t}\n\tasync validateOutput(output, context) {\n\t\tconst baseValidation = validateRequiredPorts(output, context.nodeManifest.outputs, \"output\", context.nodeDefinition.nodeId);\n\t\tif (!baseValidation.ok) return baseValidation;\n\t\tif (!this.handler.validateOutput) return {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t\treturn this.handler.validateOutput(output, context);\n\t}\n\tasync dispose(context) {\n\t\tif (!this.handler.dispose) return {\n\t\t\tok: true,\n\t\t\tvalue: void 0\n\t\t};\n\t\treturn this.handler.dispose(context);\n\t}\n};\n//#endregion\n//#region src/lifecycle/default-node-task-handlers.ts\n/** In-memory registry of task handlers, keyed by node type. */\nvar StaticNodeTaskHandlerRegistry = class {\n\thandlersByType;\n\tconstructor(handlersByType) {\n\t\tthis.handlersByType = handlersByType;\n\t}\n\tgetHandler(nodeType) {\n\t\treturn this.handlersByType[nodeType];\n\t}\n\tlistNodeTypes() {\n\t\treturn Object.keys(this.handlersByType);\n\t}\n};\n//#endregion\n//#region src/lifecycle/static-node-lifecycle-factory.ts\n/** Factory that creates {@link RegisteredNodeLifecycle} instances from a static handler registry. */\nvar StaticNodeLifecycleFactory = class {\n\ttaskHandlerRegistry;\n\tconstructor(taskHandlerRegistry) {\n\t\tthis.taskHandlerRegistry = taskHandlerRegistry;\n\t}\n\tcreate(nodeType) {\n\t\tconst handler = this.taskHandlerRegistry.getHandler(nodeType);\n\t\tif (!handler) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_NODE_LIFECYCLE_NOT_REGISTERED\", \"Node lifecycle is not registered for nodeType\", { nodeType })\n\t\t};\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: new RegisteredNodeLifecycle(handler)\n\t\t};\n\t}\n};\nfunction createStaticNodeLifecycleFactory(handlersByType) {\n\treturn new StaticNodeLifecycleFactory(new StaticNodeTaskHandlerRegistry(handlersByType));\n}\n//#endregion\n//#region src/registry/static-node-manifest-registry.ts\n/** In-memory registry of node manifests, queryable by node type. */\nvar StaticNodeManifestRegistry = class {\n\tmanifestByType = /* @__PURE__ */ new Map();\n\tconstructor(manifests) {\n\t\tfor (const manifest of manifests) this.manifestByType.set(manifest.nodeType, manifest);\n\t}\n\tgetManifest(nodeType) {\n\t\treturn this.manifestByType.get(nodeType);\n\t}\n\tlistManifests() {\n\t\treturn [...this.manifestByType.values()];\n\t}\n};\n//#endregion\n//#region src/value-objects/provider-media-output.ts\nfunction normalizeProviderMediaOutput(output, policy) {\n\tif (output.kind === \"asset\") {\n\t\tif (typeof output.assetId !== \"string\" || output.assetId.trim().length === 0) return {\n\t\t\tok: false,\n\t\t\trejection: { reason: \"asset_invalid\" }\n\t\t};\n\t\tconst mimeType = resolveMimeType(output.mimeType, policy);\n\t\tif (mimeType === void 0) return {\n\t\t\tok: false,\n\t\t\trejection: {\n\t\t\t\treason: \"media_type_invalid\",\n\t\t\t\tmimeType: output.mimeType\n\t\t\t}\n\t\t};\n\t\treturn project(MediaReference.fromCandidate({\n\t\t\tassetId: output.assetId,\n\t\t\tmediaType: mimeType,\n\t\t\tsizeBytes: output.bytes\n\t\t}), policy.kind, mimeType);\n\t}\n\tif (typeof output.uri !== \"string\" || output.uri.trim().length === 0) return {\n\t\tok: false,\n\t\trejection: { reason: \"uri_missing\" }\n\t};\n\tif (policy.parseDataUri && output.uri.startsWith(\"data:\")) {\n\t\tconst parsed = parseDataUri(output.uri);\n\t\tif (parsed === void 0 || !parsed.startsWith(policy.mediaTypePrefix)) return {\n\t\t\tok: false,\n\t\t\trejection: { reason: \"data_uri_unsupported\" }\n\t\t};\n\t\treturn project(MediaReference.fromCandidate({\n\t\t\turi: output.uri,\n\t\t\tmediaType: parsed\n\t\t}), policy.kind, parsed);\n\t}\n\tconst mimeType = resolveMimeType(output.mimeType, policy);\n\tif (mimeType === void 0) return {\n\t\tok: false,\n\t\trejection: {\n\t\t\treason: \"media_type_invalid\",\n\t\t\tmimeType: output.mimeType\n\t\t}\n\t};\n\treturn project(MediaReference.fromCandidate({\n\t\turi: output.uri,\n\t\tmediaType: mimeType,\n\t\tsizeBytes: output.bytes\n\t}), policy.kind, mimeType);\n}\nfunction resolveMimeType(rawMimeType, policy) {\n\tif (!(typeof rawMimeType === \"string\" && rawMimeType.trim().length > 0)) return policy.defaultMimeType;\n\treturn rawMimeType.startsWith(policy.mediaTypePrefix) ? rawMimeType : void 0;\n}\nfunction project(reference, kind, mimeType) {\n\tif (!reference.ok) return {\n\t\tok: false,\n\t\trejection: { reason: \"asset_invalid\" }\n\t};\n\treturn {\n\t\tok: true,\n\t\tvalue: reference.value.toBinary(kind, mimeType)\n\t};\n}\n/** Returns the MIME type of a base64 `data:` URI, or `undefined` when it is not one. */\nfunction parseDataUri(uri) {\n\tconst commaIndex = uri.indexOf(\",\");\n\tif (commaIndex < 0) return void 0;\n\tconst header = uri.slice(0, commaIndex);\n\tconst payload = uri.slice(commaIndex + 1);\n\tif (!header.startsWith(\"data:\") || !header.endsWith(\";base64\")) return void 0;\n\tconst mimeType = header.replace(\"data:\", \"\").replace(\";base64\", \"\").trim();\n\tif (mimeType.length === 0 || payload.trim().length === 0) return void 0;\n\treturn mimeType;\n}\n//#endregion\n//#region src/schemas/media-reference-schema.ts\nconst NonEmptyString = z.string().trim().min(1);\nconst AssetReferenceSchema = z.object({\n\treferenceType: z.literal(\"asset\"),\n\tassetId: NonEmptyString,\n\tmediaType: z.string().optional(),\n\tname: z.string().optional(),\n\tsizeBytes: z.number().int().nonnegative().optional()\n});\nconst UriReferenceSchema = z.object({\n\treferenceType: z.literal(\"uri\"),\n\turi: NonEmptyString,\n\tmediaType: z.string().optional(),\n\tname: z.string().optional(),\n\tsizeBytes: z.number().int().nonnegative().optional()\n});\nconst MediaReferenceSchema = z.union([AssetReferenceSchema, UriReferenceSchema]);\nfunction createMediaReferenceConfigSchema() {\n\treturn z.object({ asset: MediaReferenceSchema });\n}\n//#endregion\n//#region src/utils/node-descriptor.ts\nfunction isZodSchema(input) {\n\tif (typeof input !== \"object\" || input === null) return false;\n\treturn input instanceof z.ZodType;\n}\n/**\n* Convert a zod schema to a JSON Schema representation for node config.\n* @param configSchemaDefinition - Zod schema instance, or null/undefined for nodes with no config\n* @returns JSON Schema object or validation error\n*/\nfunction buildConfigSchema(configSchemaDefinition) {\n\tif (configSchemaDefinition == null) return {\n\t\tok: true,\n\t\tvalue: {}\n\t};\n\tif (!isZodSchema(configSchemaDefinition)) return {\n\t\tok: false,\n\t\terror: buildValidationError(\"DAG_VALIDATION_CONFIG_SCHEMA_INVALID\", \"configSchemaDefinition must be a Zod schema instance.\")\n\t};\n\treturn {\n\t\tok: true,\n\t\tvalue: zodToJsonSchema(configSchemaDefinition, { target: \"jsonSchema7\" })\n\t};\n}\n//#endregion\n//#region src/node-definition-assembly.ts\n/**\n* Build manifests and handler registry from an array of node definitions.\n* @param nodeDefinitions - Node definitions to assemble\n* @returns Assembly of manifests and handlers, or an error if config schema validation fails\n*/\nfunction buildNodeDefinitionAssembly(nodeDefinitions) {\n\tconst manifests = [];\n\tconst handlersByType = {};\n\tfor (const nodeDefinition of nodeDefinitions) {\n\t\tconst configSchemaResult = buildConfigSchema(nodeDefinition.configSchemaDefinition);\n\t\tif (!configSchemaResult.ok) return configSchemaResult;\n\t\tconst manifest = {\n\t\t\tnodeType: nodeDefinition.nodeType,\n\t\t\tdisplayName: nodeDefinition.displayName,\n\t\t\tcategory: nodeDefinition.category,\n\t\t\tinputs: nodeDefinition.inputs,\n\t\t\toutputs: nodeDefinition.outputs,\n\t\t\tconfigSchema: configSchemaResult.value,\n\t\t\t...nodeDefinition.defaultInputPort !== void 0 ? { defaultInputPort: nodeDefinition.defaultInputPort } : {},\n\t\t\t...nodeDefinition.defaultOutputPort !== void 0 ? { defaultOutputPort: nodeDefinition.defaultOutputPort } : {}\n\t\t};\n\t\tmanifests.push(manifest);\n\t\thandlersByType[manifest.nodeType] = nodeDefinition.taskHandler;\n\t}\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tmanifests,\n\t\t\thandlersByType\n\t\t}\n\t};\n}\n//#endregion\n//#region src/port-definition-helpers.ts\n/** Common binary port presets for image, video, audio, and file ports. */\nconst BINARY_PORT_PRESETS = {\n\tIMAGE_PNG: {\n\t\tbinaryKind: \"image\",\n\t\tmimeTypes: [\"image/png\"]\n\t},\n\tIMAGE_COMMON: {\n\t\tbinaryKind: \"image\",\n\t\tmimeTypes: [\n\t\t\t\"image/png\",\n\t\t\t\"image/jpeg\",\n\t\t\t\"image/webp\"\n\t\t]\n\t},\n\tVIDEO_MP4: {\n\t\tbinaryKind: \"video\",\n\t\tmimeTypes: [\"video/mp4\"]\n\t},\n\tAUDIO_MPEG: {\n\t\tbinaryKind: \"audio\",\n\t\tmimeTypes: [\"audio/mpeg\"]\n\t},\n\tFILE_GENERIC: {\n\t\tbinaryKind: \"file\",\n\t\tmimeTypes: []\n\t}\n};\n/**\n* Create an {@link IPortDefinition} for a binary port from a preset-based input.\n* @param input - Binary port specification including preset, key, and constraints\n* @returns A fully populated port definition with type `'binary'`\n*/\nfunction createBinaryPortDefinition(input) {\n\treturn {\n\t\tkey: input.key,\n\t\tlabel: input.label,\n\t\torder: input.order,\n\t\ttype: \"binary\",\n\t\trequired: input.required,\n\t\tdescription: input.description,\n\t\tbinaryKind: input.preset.binaryKind,\n\t\tmimeTypes: [...input.preset.mimeTypes],\n\t\tisList: input.isList,\n\t\tminItems: input.minItems,\n\t\tmaxItems: input.maxItems\n\t};\n}\n//#endregion\nexport { AbstractNodeDefinition, BINARY_PORT_PRESETS, MediaReference, MediaReferenceSchema, NodeIoAccessor, RegisteredNodeLifecycle, StaticNodeLifecycleFactory, StaticNodeManifestRegistry, StaticNodeTaskHandlerRegistry, buildConfigSchema, buildNodeDefinitionAssembly, createBinaryPortDefinition, createMediaReferenceConfigSchema, createStaticNodeLifecycleFactory, defineDagNode, normalizeProviderMediaOutput, parseBinaryValue };\n\n//# sourceMappingURL=index.js.map"],"mappings":"6EAEA,SAAS,EAAc,EAAU,EAAM,EAAS,EAAW,EAAS,EAAK,EAAW,CACnF,MAAO,CACN,OACA,WACA,UACA,YACA,UACA,MACA,WACD,CACD,CAEA,SAAS,EAAqB,EAAM,EAAS,EAAS,EAAK,EAAW,CACrE,OAAO,EAAc,aAAc,EAAM,EAAS,GAAO,EAAS,EAAK,CAAS,CACjF,CAEA,SAAS,EAAmB,EAAM,EAAS,EAAS,EAAK,EAAW,CACnE,OAAO,EAAc,WAAY,EAAM,EAAS,GAAM,EAAS,EAAK,CAAS,CAC9E,CAMA,SAAS,EAAwB,EAAM,EAAS,EAAW,EAAS,EAAK,EAAW,CACnF,OAAO,EAAc,iBAAkB,EAAM,EAAS,EAAW,EAAS,EAAK,CAAS,CACzF,CAEA,SAAS,EAA2B,EAAW,CAC9C,OAAO,EAAwB,+BAAgC,+BAAgC,GAAO,CAAE,WAAU,CAAC,CACpH,CAIA,SAAS,EAA0B,EAAO,EAAU,CACnD,IAAM,EAAS,CAAC,EACZ,EAAU,GACV,EAAQ,EACN,GAAU,EAAM,IAAS,CAC9B,GAAI,EAAO,EAAW,EAAO,MAAM,EACnC,GAAS,EACT,GAAW,EACP,EAAQ,QAAU,OACrB,EAAO,KAAK,CAAO,EACnB,EAAU,GAEZ,EACM,EAAU,GAAU,CACzB,EAAO,IAAM,CAAC,EACd,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAAS,CAClD,IAAM,EAAO,EAAM,WAAW,CAAK,EACnC,GAAI,IAAS,IAAM,IAAS,GAAI,EAAO,KAAK,EAAM,KAAU,CAAC,OACxD,GAAI,EAAO,GAAI,CACnB,IAAM,EAAU,EA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