@makaio/framework 1.0.0-dev-1781443723575 → 1.0.0-dev-1781457526466
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/dist/.makaio-build.json +2 -2
- package/dist/adapters/index.d.mts +1 -1
- package/dist/bus/index.mjs +1 -1
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/config/index.d.mts +6 -6
- package/dist/contracts/extension/index.d.mts +3 -3
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +399 -65
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/provider/index.d.mts +1 -1
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/shared/index.d.mts +1 -1
- package/dist/contracts/skill/index.d.mts +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/{definition-CPc6oKaF.d.mts → definition-DSq5ErZD.d.mts} +1 -1
- package/dist/{index-BSFmBEDL.d.mts → index-B19U8IjG.d.mts} +9 -9
- package/dist/{index-BZuF4I8O.d.mts → index-B3mq3Qjf.d.mts} +1 -1
- package/dist/{index-Doy13wLW.d.mts → index-BQ8H7cvY.d.mts} +15 -15
- package/dist/{index-CQuLV3jj.d.mts → index-BVf5D_xQ.d.mts} +8 -8
- package/dist/{index-D7oEYudM.d.mts → index-B_Z1Mgko.d.mts} +1 -1
- package/dist/{index-CtVy1e5h.d.mts → index-C7DEqbEy.d.mts} +16 -16
- package/dist/{index-BDnI2oqX.d.mts → index-CEdOq5Om.d.mts} +1 -1
- package/dist/{index-N7JtH6hX.d.mts → index-CmnQr7_x.d.mts} +3 -3
- package/dist/{index-gYlNeEGH.d.mts → index-Cs1JVq0D.d.mts} +16 -16
- package/dist/{index-DWRwbJjQ.d.mts → index-DLPjliGd.d.mts} +1 -1
- package/dist/{index-DsAfeVbS.d.mts → index-DacXw2sg.d.mts} +24 -24
- package/dist/{index-iRe4CsR5.d.mts → index-DfNIhEm_.d.mts} +20 -20
- package/dist/{index-C2tDMYm0.d.mts → index-DmZxKuwh.d.mts} +5 -5
- package/dist/{index-DWBpxSGQ.d.mts → index-DpeRgR7z.d.mts} +134 -134
- package/dist/{index-GuspCNLR.d.mts → index-DyqZej9j.d.mts} +8 -8
- package/dist/{index-BM_y78ZA2.d.mts → index-iXawmtSH2.d.mts} +6 -6
- package/dist/{index-bLWdMu_T.d.mts → index-p0Gs2cHX.d.mts} +22 -22
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/{namespace-vfKj-JHx.d.mts → namespace-B1Bldc48.d.mts} +9 -9
- package/dist/{namespace-CK50FeCH.d.mts → namespace-DB6RC_Pn.d.mts} +2 -2
- package/dist/{namespace-thr1fR3_.d.mts → namespace-D_ZXa76m.d.mts} +32 -32
- package/dist/{namespace-D63jVkzY.d.mts → namespace-DphMg7CF.d.mts} +5 -5
- package/dist/{namespace-DWT6hqxX.d.mts → namespace-u_b7D-p2.d.mts} +58 -58
- package/dist/package-CBjoefAW.mjs +1 -0
- package/dist/{package-BEbo1-6S.d.mts → package-fwIv7zzj.d.mts} +1 -1
- package/dist/package.json +1 -1
- package/dist/primitive-runtime-BHSEOIH6.mjs +1 -0
- package/dist/{schema-CXgFk-dK.d.mts → schema-BDQID7HI.d.mts} +3 -3
- package/dist/{schemas-BS8xAZ2y2.d.mts → schemas-Bxc0-SF62.d.mts} +4 -4
- package/dist/{schemas-DZfBym73.d.mts → schemas-Bxjfpl2Y.d.mts} +7 -7
- package/dist/{schemas-DMl7IKG-.d.mts → schemas-ByBtBmoL.d.mts} +3 -3
- package/dist/{schemas-CRS7tkFP.d.mts → schemas-D2IRKPJN.d.mts} +4 -4
- package/dist/{schemas-YFBpHbzr.d.mts → schemas-DdHltfZX.d.mts} +3 -3
- package/dist/services/adapter-subsystem/index.d.mts +2 -2
- package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +11 -11
- package/dist/services/filesystem/namespace.d.mts +12 -12
- package/dist/services/filesystem/schemas.d.mts +6 -6
- package/dist/services/index.d.mts +51 -51
- package/dist/services/log-import/browser.d.mts +2 -2
- package/dist/services/log-import/index.d.mts +2 -2
- package/dist/services/log-import/log-import.d.mts +1 -1
- package/dist/services/log-import/namespace.d.mts +2 -2
- package/dist/services/log-import/schemas.d.mts +1 -1
- package/dist/services/preferences/index.d.mts +2 -2
- package/dist/services/preferences/schemas.d.mts +1 -1
- package/dist/services/preferences/storage-namespace.d.mts +2 -2
- package/dist/services/session/index.d.mts +5 -5
- package/dist/services/session/messages/namespace.d.mts +1 -1
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +7 -7
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
- package/dist/services/subagent-template/index.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tray-menu/index.d.mts +2 -2
- package/dist/services/tray-menu/namespace.d.mts +1 -1
- package/dist/services/tray-menu/schemas.d.mts +1 -1
- package/dist/{session-lineage-CJgqfkMj.d.mts → session-lineage-DFkJgYt5.d.mts} +1 -1
- package/dist/{storage-namespace-gey7EUhM.d.mts → storage-namespace-Cd5XzgVC.d.mts} +10 -10
- package/dist/{types-bPzpZb7_.d.mts → types-BB8iIAjZ.d.mts} +1 -1
- package/dist/{types-8q9G9p34.d.mts → types-BC3nHLuk.d.mts} +51 -51
- package/dist/ui-kernel/index.d.mts +4 -4
- package/dist/ui-kernel/pages/namespace.d.mts +4 -4
- package/dist/ui-kernel/pages/schemas.d.mts +1 -1
- package/dist/workflow-engine/index.d.mts +127 -23
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.d.mts +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/package.json +1 -1
- package/dist/package-Dvk8-Gfd.mjs +0 -1
- package/dist/primitive-runtime-UEzX4Ayu.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,K as l,L as u,M as d,N as f,O as ee,P as te,R as ne,S as re,T as ie,U as ae,V as oe,W as se,_ as ce,a as le,b as p,c as ue,d as de,f as fe,g as pe,h as me,i as he,j as ge,k as _e,l as ve,m as ye,n as be,p as m,q as h,s as xe,t as Se,v as Ce,w as we,x as Te,y as Ee,z as De}from"./primitive-runtime-BHSEOIH6.mjs";import{matchesFilter as Oe,matchesSubscription as ke}from"@makaio/framework/bus";import{ArtifactSubjects as Ae,EXECUTION_LIST_DEFAULT_LIMIT as je,EXECUTION_LIST_MAX_LIMIT as g,EXECUTION_LIST_MIN_LIMIT as _,ExecutionHintsSchema as Me,ExecutionsByArtifactRefsQuerySchema as Ne,JsonPatchOperationSchema as Pe,JsonValueSchema as Fe,SessionSubjects as Ie,WORKFLOW_CANCELLED_REASON as v,WorkflowNamespace as Le,WorkflowSubjects as y,createWorkflowCancelSubject as Re,dep as ze,extensionToken as Be,serializeArtifactRef as Ve}from"@makaio/framework/contracts";import{BaseService as He}from"@makaio/framework/service-base";import{defineDialectSchema as Ue,executeTransaction as b,getDatabaseDialect as We,registerDrizzleHandlers as Ge,resolveSchema as x}from"@makaio/framework/storage/drizzle";import{and as S,asc as C,count as Ke,desc as w,eq as T,getTableColumns as qe,gte as Je,isNotNull as Ye,lt as Xe,lte as Ze,or as Qe,sql as E,sum as D}from"drizzle-orm";import{compile as $e}from"@makaio/framework/expression";import*as et from"node:os";import{SessionToken as tt}from"@makaio/framework/services";const nt=re.postgres,rt=d.postgres,it=we.postgres,at=te.postgres,ot=ne.postgres,st=i.postgres,ct=c.postgres,lt=l.postgres,ut=s.postgres,dt=t.postgres,ft=se.postgres,pt=ee.postgres,mt=e.postgres,O=Ue({workflowDefinitions:Te,workflowExecutions:ge,workflowExecutionFrames:n,workflowGateInstances:f,workflowStepSpans:u,workflowExecutionLinks:ie,workflowRunContexts:a,worklogSummaries:o,worklogFrameEntries:oe,worklogArtifactWrites:De,worklogGateEvents:ae,workflowExecutionState:r,workflowExecutionStateEvents:_e},{workflowDefinitions:nt,workflowExecutions:rt,workflowExecutionFrames:it,workflowGateInstances:at,workflowStepSpans:ot,workflowExecutionLinks:st,workflowRunContexts:ct,worklogSummaries:lt,worklogFrameEntries:ut,worklogArtifactWrites:dt,worklogGateEvents:ft,workflowExecutionState:pt,workflowExecutionStateEvents:mt});function k(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function A(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function ht(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=k(t);return[T(e.scopeType,n),T(e.scopeKind,r),T(e.scopeId,i)]}function j(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:A(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executionHints:e.executionHints??void 0}}function gt(e,t){let n=k(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executionHints:e.executionHints??null,createdAt:t,updatedAt:t,...n}}function _t(e,t){let{workflowDefinitions:n}=x(t,O),r=qe(n),i=e.on(p.get,async e=>{let r=await t.select().from(n).where(T(n.id,e.payload.id)).limit(1);e.setResult({workflow:r[0]?j(r[0]):null})}),a=e.on(p.set,async i=>{let a=i.payload.workflow,o=Date.now(),s=gt(a,o),c=await t.insert(n).values(s).onConflictDoNothing({target:n.id}).returning();if(c.length>0){await e.emit(h.definition.created,j(c[0])),i.setResult({id:a.id});return}let[l]=await t.update(n).set({name:s.name,root:s.root,updatedAt:o,createdAt:E`COALESCE(${r.createdAt}, ${o})`,description:s.description===null?E`${r.description}`:s.description,inputSchema:s.inputSchema===null?E`${r.inputSchema}`:s.inputSchema,configSchema:s.configSchema===null?E`${r.configSchema}`:s.configSchema,outputSchema:s.outputSchema===null?E`${r.outputSchema}`:s.outputSchema,state:s.state,artifact:s.artifact===null?E`${r.artifact}`:s.artifact,triggers:s.triggers===null?E`${r.triggers}`:s.triggers,canvasLayout:s.canvasLayout===null?E`${r.canvasLayout}`:s.canvasLayout,source:s.source===null?E`${r.source}`:s.source,executionHints:s.executionHints===null?E`${r.executionHints}`:s.executionHints,...k(a.scope)}).where(T(n.id,a.id)).returning();l&&await e.emit(h.definition.updated,j(l)),i.setResult({id:a.id})}),o=e.on(p.delete,async r=>{let i=(await t.delete(n).where(T(n.id,r.payload.id)).returning()).length>0;i&&await e.emit(h.definition.deleted,{id:r.payload.id}),r.setResult({deleted:i})}),s=e.on(p.list,async e=>{let r=e.payload,i=r.scope?ht(n,r.scope):[],a=i.length>0?await t.select().from(n).where(S(...i)):await t.select().from(n);e.setResult({workflows:a.map(j)})});return()=>{i(),a(),o(),s()}}function vt(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function yt(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function bt(e,t){let{workflowExecutionFrames:n}=x(t,O),r=e.on(p.setFrame,async e=>{let{executionId:r,frame:i}=e.payload,a=yt(r,i);await t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a}),e.setResult({frameId:i.frameId})}),i=e.on(p.getFrame,async e=>{let r=await t.select().from(n).where(T(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?vt(r[0]):null})}),a=e.on(p.listFrames,async e=>{let r=await t.select().from(n).where(T(n.executionId,e.payload.executionId)).orderBy(C(n.startedAt),C(n.frameId));e.setResult({frames:r.map(vt)})});return()=>{r(),i(),a()}}function xt(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function M(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function N(e){return{id:xt(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function St(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??je;if(!Number.isInteger(i)||i<_||i>g)throw Error(`Gate instance list limit must be an integer between ${_} and ${g}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[T(r.executionId,e)],...t===void 0?[]:[T(r.status,t)]]}}function Ct(e,t){let{workflowExecutions:n,workflowGateInstances:r}=x(t,O),i=e.on(p.setGateInstance,async e=>{let n=e.payload.gate,i=N(n);await t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i}),e.setResult({id:i.id})}),a=e.on(p.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=N(n),a=await t.update(r).set(i).where(S(T(r.id,i.id),T(r.status,`waiting`))).returning({id:r.id});e.setResult({accepted:a.length===1})}),o=e.on(p.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload,o=[T(r.executionId,n),T(r.nodeId,i)];a!==void 0&&o.push(T(r.frameId,a));let s=await t.select().from(r).where(S(...o)).limit(1);e.setResult({gate:s[0]?M(s[0]):null})}),s=e.on(p.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=St(n,i,a,r),c=await t.select().from(r).where(S(...s)).orderBy(w(r.createdAt),w(r.id)).limit(o);e.setResult({gates:c.map(M)})}),c=e.on(p.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,T(r.executionId,n.id)).where(S(T(r.status,`waiting`),T(n.status,`paused`),Ye(r.timeoutMs)));e.setResult({gates:i.map(e=>M(e.gate))})});return()=>{i(),a(),o(),s(),c()}}function wt(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function Tt(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function Et(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=x(t,O),i=e.on(p.setSpan,async e=>{let{span:r}=e.payload;await t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r}),e.setResult({id:`${r.executionId}:${r.frameId}`})}),a=e.on(p.listSpans,async e=>{let r=await t.select().from(n).where(T(n.executionId,e.payload.executionId)).orderBy(C(n.startedAt),C(n.stepId),C(n.frameId));e.setResult({spans:r.map(wt)})}),o=e.on(p.setExecutionLink,async e=>{let{link:n}=e.payload;await t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n}),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),s=e.on(p.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[T(r.sourceExecutionId,n)],...i===void 0?[]:[T(r.targetExecutionId,i)]],o=t.select().from(r).where(S(...a));e.setResult({links:(await o).map(Tt)})});return()=>{i(),a(),o(),s()}}function Dt(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function Ot(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function kt(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:Ot(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:A(e),...e.executionHints===null?{}:{executionHints:e.executionHints},...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`}}function At(e){let t=Dt(e.source),n=k(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,artifactRef:e.artifactRef??null,executionHints:e.executionHints??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy}}async function jt(e,t,n){let r=At(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function Mt(e,t){let{workflowRunContexts:n}=x(t,O),r=e.on(p.setRunContext,async e=>{let r=e.payload.runContext;await jt(t,r,n),e.setResult({executionId:r.executionId})}),i=e.on(p.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(T(n.executionId,r)),a=i[0]?kt(i[0]):null;e.setResult({runContext:a})});return()=>{r(),i()}}function P(e,t){return t===null?We(e)===`postgres`?E`'null'::jsonb`:E`'null'`:t}async function Nt(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=x(e,O),a=Date.now(),o=P(e,n);await b(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function Pt(e,t){let{workflowExecutionState:n}=x(e,O),r=(await e.select().from(n).where(T(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function Ft(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=x(e,O),i=Date.now(),a=P(e,t.nextValue);return b(e,async e=>{let o=(await e.select().from(n).where(T(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=Ce(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(S(T(n.executionId,t.executionId),T(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function It(e,t){let n=e.on(p.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await Nt(t,n,r),e.setResult({})}),r=e.on(p.getState,async e=>{let{executionId:n}=e.payload,r=await Pt(t,n);e.setResult({state:r})}),i=e.on(p.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await Ft(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function Lt(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function F(e,t){let{worklogSummaries:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:t})}async function I(e,t){let{worklogSummaries:n}=x(e,O),r=await e.select().from(n).where(T(n.executionId,t)).limit(1);return r[0]?Lt(r[0]):null}async function Rt(e,t={}){let{worklogSummaries:n}=x(e,O),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[T(n.workflowId,r)],...i===void 0?[]:[T(n.status,i)]],c=s.length>0?S(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(w(n.startedAt)).limit(a).offset(o),e.select({count:Ke()}).from(n).where(c)]);return{items:l.map(Lt),total:u[0]?.count??0}}async function L(e,t){let{worklogFrameEntries:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t})}async function R(e,t){let{worklogFrameEntries:n}=x(e,O);return(await e.select().from(n).where(T(n.frameId,t)).limit(1))[0]??null}async function zt(e,t){let{worklogArtifactWrites:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function Bt(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function z(e,t){let{worklogGateEvents:n}=x(e,O);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function Vt(e,t){let{worklogGateEvents:n}=x(e,O);return(await e.select().from(n).where(T(n.id,t)).limit(1))[0]??null}function B(e,t,n){return`${e}:${t}:${n}`}async function Ht(e,t){let{worklogFrameEntries:n}=x(e,O),[r]=await e.select({totalInputTokens:D(n.inputTokens),totalOutputTokens:D(n.outputTokens),totalEstimatedCost:D(n.estimatedCost)}).from(n).where(T(n.executionId,t));return{totalInputTokens:r?.totalInputTokens===null?0:Number(r?.totalInputTokens),totalOutputTokens:r?.totalOutputTokens===null?0:Number(r?.totalOutputTokens),totalEstimatedCost:r?.totalEstimatedCost===null?0:Number(r?.totalEstimatedCost)}}async function Ut(e,t={}){let{worklogSummaries:n}=x(e,O),{workflowId:r,since:i,until:a}=t,o=[...r===void 0?[]:[T(n.workflowId,r)],...i===void 0?[]:[Je(n.startedAt,i)],...a===void 0?[]:[Ze(n.startedAt,a)]],s=o.length>0?S(...o):void 0,[c,l]=await Promise.all([e.select({status:n.status,count:Ke()}).from(n).where(s).groupBy(n.status),e.select({totalDurationMs:D(n.durationMs),totalInputTokens:D(n.totalInputTokens),totalOutputTokens:D(n.totalOutputTokens),totalEstimatedCost:D(n.totalEstimatedCost)}).from(n).where(s)]),u={pending:0,running:0,paused:0,completed:0,failed:0,cancelled:0},d=0;for(let e of c)u[e.status]=e.count,d+=e.count;let f=l[0];return{total:d,byStatus:u,totalDurationMs:Number(f?.totalDurationMs??0),totalInputTokens:Number(f?.totalInputTokens??0),totalOutputTokens:Number(f?.totalOutputTokens??0),totalEstimatedCost:Number(f?.totalEstimatedCost??0)}}async function Wt(e,t,n,r,i){let a=await R(t,n);if(a===null||i===void 0)return null;let o=await e.requestOptional(Ae.resolve,{ref:{refClass:`artifact`,kind:r.kind,id:r.id,revision:i}}).catch(()=>void 0);if(o===void 0||!o.handled||o.data.artifact===null)return null;let{kind:s,schemaVersion:c,scope:l}=o.data.artifact;return{nodeId:a.nodeId,artifact:{kind:s,schemaVersion:c,scope:l}}}async function V(e,t){try{await t()}catch(t){console.error(`[WorklogProjection] Write failed (${e}):`,t)}}async function H(e,t){try{await e.emit(h.worklog.changed,{executionId:t})}catch(e){console.error(`[WorklogProjection] worklog.changed emit failed for ${t}:`,e)}}async function Gt(e,t,n){await F(t,{executionId:n.executionId,workflowId:n.workflowId,workflowName:null,status:`running`,startedAt:n.startedAt??Date.now(),completedAt:null,durationMs:null,totalInputTokens:null,totalOutputTokens:null,totalEstimatedCost:null,error:null,failedNodeId:null}),await H(e,n.executionId)}async function Kt(e,t,n){let r=n.completedAt??Date.now(),i=await I(t,n.executionId);await F(t,{executionId:n.executionId,workflowId:i?.workflowId??n.executionId,workflowName:i?.workflowName??null,status:`completed`,startedAt:i?.startedAt??r-n.totalDuration,completedAt:r,durationMs:n.totalDuration,totalInputTokens:i?.totalInputTokens??null,totalOutputTokens:i?.totalOutputTokens??null,totalEstimatedCost:i?.totalEstimatedCost??null,error:null,failedNodeId:null}),await H(e,n.executionId)}async function qt(e,t,n,r,i,a,o){let s=await I(t,n),c=s?.startedAt??o;await F(t,{executionId:n,workflowId:s?.workflowId??n,workflowName:s?.workflowName??null,status:r,startedAt:c,completedAt:o,durationMs:o-c,totalInputTokens:s?.totalInputTokens??null,totalOutputTokens:s?.totalOutputTokens??null,totalEstimatedCost:s?.totalEstimatedCost??null,error:i,failedNodeId:a}),await H(e,n)}async function Jt(e,t,n){let r=await Ht(t,n);if(r.totalInputTokens>0||r.totalOutputTokens>0||r.totalEstimatedCost>0){let e=await I(t,n);e&&await F(t,{executionId:n,workflowId:e.workflowId,workflowName:e.workflowName??null,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??null,durationMs:e.durationMs??null,totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost,error:e.error??null,failedNodeId:e.failedNodeId??null})}}function Yt(e,t){return[e.on(h.execution.started,async n=>{let{executionId:r}=n.payload;await V(`execution.started[${r}]`,()=>Gt(e,t,n.payload))}),e.on(h.execution.completed,async n=>{let{executionId:r}=n.payload;await V(`execution.completed[${r}]`,()=>Kt(e,t,n.payload))}),e.on(h.execution.failed,async n=>{let{executionId:r,error:i,failedStepId:a}=n.payload,o=n.payload.completedAt??Date.now();await V(`execution.failed[${r}]`,()=>qt(e,t,r,`failed`,i,a??null,o))}),e.on(h.execution.cancelled,async n=>{let{executionId:r}=n.payload,i=n.payload.completedAt??Date.now();await V(`execution.cancelled[${r}]`,()=>qt(e,t,r,`cancelled`,null,null,i))})]}function Xt(e,t,n){return e===null?{nodeId:t,nodeType:`station`,path:[],attempt:0,iteration:null,branchKey:null,startedAt:n,inputTokens:null,outputTokens:null,estimatedCost:null}:{nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,attempt:e.attempt,iteration:e.iteration,branchKey:e.branchKey,startedAt:e.startedAt,inputTokens:e.inputTokens,outputTokens:e.outputTokens,estimatedCost:e.estimatedCost}}async function Zt(e,t,n,r,i,a,o){let s=o??Date.now();await L(t,{frameId:r,executionId:n,...Xt(await R(t,r),i,a===void 0?null:s-a),status:`completed`,completedAt:s,durationMs:a??null,error:null}),await Jt(e,t,n),await H(e,n)}async function Qt(e,t,n,r,i,a,o,s){let c=s??Date.now();await L(t,{frameId:r,executionId:n,...Xt(await R(t,r),i,o===void 0?null:c-o),status:`failed`,completedAt:c,durationMs:o??null,error:a}),await H(e,n)}function $t(e,t){return[e.on(h.frame.started,async n=>{let{executionId:r,frameId:i,nodeId:a,nodeType:o,path:s,startedAt:c}=n.payload;await V(`frame.started[${i}]`,async()=>{await L(t,{frameId:i,executionId:r,nodeId:a,nodeType:o,path:s,status:`running`,attempt:0,iteration:null,branchKey:null,startedAt:c??Date.now(),completedAt:null,durationMs:null,inputTokens:null,outputTokens:null,estimatedCost:null,error:null}),await H(e,r)})}),e.on(h.frame.completed,async n=>{let{executionId:r,frameId:i,nodeId:a,duration:o,completedAt:s}=n.payload;await V(`frame.completed[${i}]`,()=>Zt(e,t,r,i,a,o,s))}),e.on(h.frame.failed,async n=>{let{executionId:r,frameId:i,nodeId:a,error:o,duration:s,completedAt:c}=n.payload;await V(`frame.failed[${i}]`,()=>Qt(e,t,r,i,a,o,s,c))})]}const en={user:`rejected`,timeout:`timed-out`,cancelled:`cancelled`};function tn(e,t){return[e.on(h.gate.suspended,async n=>{let{executionId:r,frameId:i,nodeId:a,prompt:o}=n.payload;await V(`gate.suspended[${i}]`,async()=>{await z(t,{id:B(r,a,i),executionId:r,nodeId:a,frameId:i,status:`waiting`,prompt:o??null,openedAt:Date.now(),resolvedAt:null,resumeData:null}),await H(e,r)})}),e.on(h.gate.resumed,async n=>{let{executionId:r,frameId:i,nodeId:a,resumeData:o}=n.payload;await V(`gate.resumed[${i}]`,async()=>{let n=B(r,a,i),s=await Vt(t,n),c=Date.now();await z(t,{id:n,executionId:r,nodeId:a,frameId:i,status:`resumed`,prompt:s?.prompt??null,openedAt:s?.openedAt??c,resolvedAt:c,resumeData:o}),await H(e,r)})}),e.on(h.gate.resolved,async n=>nn(n.payload,e,t)),e.on(h.artifact.updated,async n=>{let{executionId:r,frameId:i,artifactRef:a,revision:o}=n.payload;await V(`artifact.updated[${r}:${i}]`,async()=>{let n=await Wt(e,t,i,a,o);if(n===null)return;let s=Date.now();await zt(t,{id:Bt(r,i,a.kind,a.id,s),executionId:r,frameId:i,nodeId:n.nodeId,artifact:n.artifact,revision:o??null,writtenAt:s}),await H(e,r)})})]}async function nn(e,t,n){let{executionId:r,frameId:i,stepId:a,source:o}=e;o===`user`&&e.action===`approve`||await V(`gate.resolved[${i}]`,async()=>{let s=B(r,a,i),c=await Vt(n,s),l=Date.now();await z(n,{id:s,executionId:r,nodeId:a,frameId:i,status:o!==`cancelled`&&e.action===`approve`?`resumed`:en[o],prompt:c?.prompt??null,openedAt:c?.openedAt??l,resolvedAt:l,resumeData:c?.resumeData??null}),await H(t,r)})}function rn(e,t){let n=[...Yt(e,t),...$t(e,t),...tn(e,t),e.on(h.worklog.get,async e=>{let{executionId:n}=e.payload,r=await I(t,n);e.setResult({summary:r})}),e.on(h.worklog.list,async e=>{let{workflowId:n,status:r,limit:i,offset:a}=e.payload,o=await Rt(t,{workflowId:n,status:r,limit:i,offset:a});e.setResult(o)}),e.on(h.worklog.stats,async e=>{let{workflowId:n,since:r,until:i}=e.payload,a=await Ut(t,{workflowId:n,since:r,until:i});e.setResult({stats:a})})];return()=>{for(let e of n)e()}}function U(e){return{id:e.id,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId??void 0,status:e.status,inputs:e.inputs,config:{},error:e.error??void 0,reason:e.reason??void 0,startedAt:e.startedAt,completedAt:e.completedAt??void 0,triggerPayload:e.triggerPayload??void 0,...e.artifactKind!==null&&e.artifactId!==null?{artifactRef:{kind:e.artifactKind,id:e.artifactId}}:{},scope:A(e)}}function an(e){let t=k(e.scope);return{id:e.id,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId??null,status:e.status,inputs:e.inputs,error:e.error??null,reason:e.reason??null,startedAt:e.startedAt,completedAt:e.completedAt??null,triggerPayload:e.triggerPayload??null,artifactKind:e.artifactRef?.kind??null,artifactId:e.artifactRef?.id??null,...t}}function on(e,t,n,r,i,a){let o=[...e?[T(a.workflowId,e)]:[],...n?[T(a.status,n)]:[],...i===void 0?[]:[T(a.artifactKind,i.kind),T(a.artifactId,i.id)]];if(t&&o.push(...ht(a,t)),r){let e=Qe(Xe(a.startedAt,r.startedAt),S(T(a.startedAt,r.startedAt),Xe(a.id,r.id)));e&&o.push(e)}return o}async function sn(e,t,n,r){if(n.executionId!==t.id)throw Error(`setExecutionStart requires execution.id to match runContext.executionId`);let{workflowExecutions:i,workflowRunContexts:a,workflowExecutionState:o,workflowExecutionStateEvents:s}=x(e,O),c=an(t);await b(e,async l=>{await l.insert(i).values(c).onConflictDoUpdate({target:i.id,set:c});let u=(n.dispatchMetadata===void 0?await l.select({dispatchMetadata:a.dispatchMetadata}).from(a).where(T(a.executionId,n.executionId)).limit(1):[])[0]?.dispatchMetadata;if(await jt(l,n.dispatchMetadata===void 0&&u!=null?{...n,dispatchMetadata:u}:n,a),r!==void 0){let n=Date.now(),i=P(e,r);await l.insert(o).values({executionId:t.id,sequence:0,value:i,updatedAt:n}).onConflictDoNothing(),await l.insert(s).values({executionId:t.id,sequence:0,patch:[],value:i,createdAt:n}).onConflictDoNothing()}})}async function cn(e,t,n){if(n.executionId!==t.id)throw Error(`restorePausedGateResumeState requires execution.id to match gate.executionId`);if(t.status!==`paused`||n.status!==`waiting`)throw Error(`restorePausedGateResumeState requires a paused execution and waiting gate`);let{workflowExecutions:r,workflowGateInstances:i}=x(e,O),a=an(t),o=N(n);await b(e,async e=>{await e.insert(r).values(a).onConflictDoUpdate({target:r.id,set:a}),await e.insert(i).values(o).onConflictDoUpdate({target:i.id,set:o})})}async function ln(e,t,n,r){let{workflowExecutions:i,workflowGateInstances:a}=x(e,O);return b(e,async e=>{if((await e.select().from(i).where(T(i.id,t)).limit(1))[0]?.status!==`paused`)return{cancelled:!1,gates:[]};let o=(await e.select().from(a).where(S(T(a.executionId,t),T(a.status,`waiting`)))).map(e=>({...M(e),status:`cancelled`,resolvedAt:n}));await e.update(i).set({status:`cancelled`,completedAt:n,reason:r??null}).where(T(i.id,t));for(let t of o){let n=N(t);await e.update(a).set(n).where(T(a.id,n.id))}return{cancelled:!0,gates:o}})}async function un(e,t,n,r,i,a){let{workflowExecutions:o}=x(e,O);return b(e,async e=>{if((await e.select({id:o.id}).from(o).where(T(o.id,t)).limit(1))[0]===void 0)return!1;let s={};return n!==void 0&&(s.status=n),r!==void 0&&(s.error=r),i!==void 0&&(s.reason=i),a!==void 0&&(s.completedAt=a),Object.keys(s).length>0&&await e.update(o).set(s).where(T(o.id,t)),!0})}function dn(e,t){let{workflowExecutions:n}=x(t,O),r=e.on(p.getExecution,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(T(n.id,r));e.setResult({execution:i[0]?U(i[0]):null})}),i=e.on(p.setExecution,async e=>{let r=e.payload.execution,i=an(r);await t.insert(n).values(i).onConflictDoUpdate({target:n.id,set:i}),e.setResult({id:r.id})}),a=e.on(p.setExecutionStart,async e=>{let n=e.payload.execution,r=e.payload.runContext;await sn(t,n,r,e.payload.initialState),e.setResult({id:n.id,executionId:n.id})}),o=e.on(p.restorePausedGateResumeState,async e=>{let n=e.payload.execution,r=e.payload.gate;await cn(t,n,r),e.setResult({executionId:n.id,gateId:r.nodeId})}),s=e.on(p.updateExecution,async e=>{let{executionId:n,status:r,error:i,reason:a,completedAt:o}=e.payload,s=await un(t,n,r,i,a,o);e.setResult({success:s})}),c=e.on(p.cancelPausedExecution,async e=>{let{executionId:n,completedAt:r,reason:i}=e.payload;e.setResult(await ln(t,n,r,i))});return()=>{r(),i(),a(),o(),s(),c()}}function fn(e,t){let{workflowExecutions:n}=x(t,O),r=e.on(p.listExecutions,async e=>{let{workflowId:r,scope:i,status:a,limit:o,cursor:s,artifactRef:c}=e.payload;if(r===void 0&&i===void 0&&c===void 0)throw Error(`Either workflowId, scope, or artifactRef is required to list executions.`);let l=on(r,i,a,s,c,n),u=o??je;if(!Number.isInteger(u)||u<_||u>g)throw Error(`Execution list limit must be an integer between ${_} and ${g}.`);let d=await t.select().from(n).where(S(...l)).orderBy(w(n.startedAt),w(n.id)).limit(u);e.setResult({executions:d.map(U)})}),i=e.on(p.listExecutionsByArtifactRefs,async e=>{let r=Ne.safeParse(e.payload);if(!r.success)throw Error(`Invalid listExecutionsByArtifactRefs query: ${r.error.message}`);let{refs:i,limitPerRef:a}=r.data,o={};for(let e of i){let r=await t.select().from(n).where(S(T(n.artifactKind,e.kind),T(n.artifactId,e.id))).orderBy(w(n.startedAt),w(n.id)).limit(a);r.length>0&&(o[Ve(e)]=r.map(U))}e.setResult({executionsByRef:o})});return()=>{r(),i()}}function W(e,t){let n=_t(e,t),r=dn(e,t),i=fn(e,t),a=bt(e,t),o=Ct(e,t),s=Et(e,t),c=Mt(e,t),l=It(e,t),u=rn(e,t);return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}}function G(e,t){if(e.origin.local)return!0;let n=e.transport?.peer;return n?.authenticated!==!0||n.id!==t?!1:n.kind===`workflow-execution`?!0:n.kind===`e2e`&&n.encrypted===!0}async function pn(e,t){let{runContext:n}=await e.request(p.getRunContext,{executionId:t});if(n===null)throw Error(`Run context not found for execution: ${t}`);if(n.definitionSnapshot!==void 0)return n.definitionSnapshot;let{workflow:r}=await e.request(p.get,{id:n.workflowId});return r??void 0}function mn(e){return[e.on(h.getDefinition,async t=>{let n=await e.request(p.get,{id:t.payload.id});t.setResult(n)}),e.on(h.setDefinition,async t=>{let n=await e.request(p.set,{workflow:t.payload.workflow});t.setResult(n)}),e.on(h.deleteDefinition,async t=>{let n=await e.request(p.delete,{id:t.payload.id});t.setResult(n)}),e.on(h.listDefinitions,async t=>{let n=await e.request(p.list,t.payload);t.setResult(n)}),e.on(h.getExecution,async t=>{let n=await e.request(p.getExecution,{executionId:t.payload.executionId});t.setResult(n)}),e.on(h.listExecutions,async t=>{let n=await e.request(p.listExecutions,t.payload);t.setResult(n)}),e.on(h.listExecutionsByArtifactRefs,async t=>{let n=await e.request(p.listExecutionsByArtifactRefs,t.payload);t.setResult(n)}),e.on(h.listSpans,async t=>{let n=await e.request(p.listSpans,{executionId:t.payload.executionId});t.setResult(n)}),e.on(h.listFrames,async t=>{let n=await e.request(p.listFrames,{executionId:t.payload.executionId});t.setResult(n)}),e.on(h.listGateInstances,async t=>{let n=await e.request(p.listGateInstances,t.payload);t.setResult(n)}),e.on(h.setExecutionLink,async t=>{let n=await e.request(p.setExecutionLink,{link:t.payload.link});t.setResult(n)}),e.on(h.listExecutionLinks,async t=>{let n=await e.request(p.listExecutionLinks,t.payload);t.setResult(n)}),e.on(h.getRunContext,async t=>{let{executionId:n}=t.payload;if(!G(t,n))throw Error(`Unauthorized: caller is not permitted to read run context for execution: ${n}`);let{runContext:r}=await e.request(p.getRunContext,{executionId:n});if(!r)throw Error(`Run context not found for execution: ${n}`);t.setResult(r)})]}function hn(e){return[e.on(h.state.get,async t=>{let{executionId:n}=t.payload;if(!G(t,n))throw Error(`Unauthorized: caller is not permitted to read state for execution: ${n}`);let{state:r}=await e.request(p.getState,{executionId:n});if(r===null)throw Error(`no workflow state for execution ${n}`);t.setResult(r)}),e.on(h.state.patch,async t=>{let{executionId:n,expectedSequence:r,patch:i,nextValue:a}=t.payload;if(!G(t,n))throw Error(`Unauthorized: caller is not permitted to patch state for execution: ${n}`);if(r===void 0)throw Error(`expectedSequence is required to patch workflow state`);let o=await pn(e,n);o!==void 0&&pe(o,a,`next`),Pe.array().parse(i);let s=await e.request(p.patchState,{executionId:n,expectedSequence:r,nextValue:a});e.emit(h.state.updated,{executionId:s.executionId,sequence:s.sequence,patch:s.patch,value:s.value,updatedAt:Date.now()}).catch(()=>{}),t.setResult({executionId:s.executionId,sequence:s.sequence,value:s.value})})]}function gn(e,t){return[e.on(h.listTriggerTypes,e=>{let n=t()?.getAll()??[];e.setResult({triggerTypes:n})})]}var _n=class{bus;resumePausedExecution;handles=new Map;constructor(e,t){this.bus=e,this.resumePausedExecution=t}dispose(){for(let e of this.handles.values())clearTimeout(e);this.handles.clear()}clear(e,t,n){let r=this.makeKey(e,t,n),i=this.handles.get(r);i!==void 0&&(clearTimeout(i),this.handles.delete(r))}schedule(e){e.timeoutMs!==null&&(this.clear(e.executionId,e.nodeId,e.frameId),this.scheduleNextWakeup({...e,timeoutMs:e.timeoutMs}))}scheduleNextWakeup(e){let t=this.makeKey(e.executionId,e.nodeId,e.frameId),n=Math.max(0,e.openedAt+e.timeoutMs-Date.now()),r=setTimeout(()=>{if(this.handles.delete(t),Date.now()<e.openedAt+e.timeoutMs){this.scheduleNextWakeup(e);return}this.handleExpiredWakeup(e)},Math.min(n,2147483647));this.handles.set(t,r)}scheduleNextWakeupAfterDelay(e,t){let n=this.makeKey(e.executionId,e.nodeId,e.frameId),r=setTimeout(()=>{this.handles.delete(n),this.handleExpiredWakeup(e)},t);this.handles.set(n,r)}async handleExpiredWakeup(e){try{await this.resumeTimedOutPausedGate(e)===`retry`&&this.scheduleNextWakeupAfterDelay(e,25)}catch(t){this.scheduleFailedWakeupRetry(e,t)}}scheduleFailedWakeupRetry(e,t){let n=(e.failedWakeupAttempts??0)+1;if(n>4){console.error(`[WorkflowExecutor] Giving up on timed-out gate '${e.nodeId}' after 4 failed wakeup retries:`,t);return}let r=Math.min(250*2**(n-1),2e3);console.error(`[WorkflowExecutor] Failed to resume timed-out gate '${e.nodeId}', retrying in ${r} ms:`,t),this.scheduleNextWakeupAfterDelay({...e,failedWakeupAttempts:n},r)}makeKey(e,t,n){return`${e}:${t}:${n}`}async resumeTimedOutPausedGate(e){this.clear(e.executionId,e.nodeId,e.frameId);let{gate:t}=await this.bus.request(p.getGateInstance,{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId});if(t===null||t.status!==`waiting`)return`settled`;let{execution:n}=await this.bus.request(p.getExecution,{executionId:e.executionId});return n?.status===`running`?`retry`:n?.status===`paused`?(await this.resumePausedExecution(e.executionId),`resumed`):`settled`}};function vn(e){if(e!==void 0)return Fe.parse(e)}function yn(e){if(e!==void 0)return Me.parse(e)}function bn(e,t){return{repoPath:t,makaioHome:e.makaioHome??process.env.MAKAIO_HOME??`${et.homedir()}/.makaio`,os:fe(process.platform),arch:process.arch}}function xn(e,t){return{executionId:e.executionId,workflowId:e.workflowId,source:e.source,...e.definitionSnapshot===void 0?{}:{definitionSnapshot:e.definitionSnapshot},workerManifest:{packages:[]},inputs:e.inputs,config:e.config,scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:`workflow.${e.executionId}.cancel`,context:bn(t,e.workspaceRoot),env:t.platformDefaults.env??{},createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy??`wait-in-process`}}function Sn(e){return e?.status===`paused`}function Cn(e){return e?.status===`waiting`}async function wn(e,t,n,r,i,a,o){t.delete(i.id),n.delete(i.id),r.delete(i.id);try{await e.request(p.restorePausedGateResumeState,{execution:i,gate:a})}catch(e){console.error(`[WorkflowExecutor] Failed to restore paused gate '${o}' after resume launch failure:`,e)}}async function Tn(e,t){if(t.suspensionStrategy===`wait-in-process`)return;let{frames:n}=await e.request(p.listFrames,{executionId:t.executionId});if(n.length===0)throw Error(`[WorkflowExecutor] Missing resume frames for paused execution: ${t.executionId}`)}function En(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,timeoutMs:e.timeoutMs,openedAt:e.createdAt}}async function Dn(e,t){if(t.frameId!==void 0){let{gate:n}=await e.request(p.getGateInstance,t);return Cn(n)?n:null}let{gates:n}=await e.request(p.listGateInstances,{executionId:t.executionId}),r=n.filter(e=>e.nodeId===t.nodeId&&e.status===`waiting`);return r.length===1?r[0]:null}var On=class extends He{static storage={drizzle:W};config;activeExecutions=new Map;executionTasks=new Map;shellAbortControllers=new Map;activeRunnerSteps=new Map;gateTimeoutScheduler;resumeDispatches=new Set;workflowAbortControllers=new Map;workflowRunner;triggerTypeRegistry;constructor(e,t,n){super(e),this.config={...ce,...t},this.workflowRunner=n,this.gateTimeoutScheduler=new _n(e,e=>this.resumePausedExecution(e))}setTriggerTypeRegistry(e){this.triggerTypeRegistry=e}getTriggerTypeRegistry(){return this.triggerTypeRegistry}async onInit(){this.registerExecutionHandlers();for(let e of mn(this.bus))this.addCleanup(e);for(let e of hn(this.bus))this.addCleanup(e);for(let e of gn(this.bus,()=>this.triggerTypeRegistry))this.addCleanup(e);await this.rehydratePausedGateTimeouts()}async onDestroy(){let e=this.buildFinalizerDeps();await Promise.allSettled([...this.activeExecutions.keys()].map(async t=>{await m(e,t,`Workflow engine shutdown`)&&(this.workflowAbortControllers.get(t)?.abort(),this.workflowAbortControllers.delete(t))}));for(let e of this.workflowAbortControllers.values())e.abort();this.workflowAbortControllers.clear(),await Promise.allSettled(this.executionTasks.values());for(let e of this.shellAbortControllers.values())e.abort();this.shellAbortControllers.clear();for(let e of this.activeRunnerSteps.values())e.hardKillTimer&&clearTimeout(e.hardKillTimer);this.activeRunnerSteps.clear(),this.gateTimeoutScheduler.dispose(),await this.workflowRunner?.dispose?.(),this.activeExecutions.clear()}buildFinalizerDeps(){return{bus:this.bus,activeExecutions:this.activeExecutions,shellAbortControllers:this.shellAbortControllers,activeRunnerSteps:this.activeRunnerSteps,cancelTimeoutMs:this.config.cancelTimeoutMs}}buildRunnerTaskDeps(e){return{workflowRunner:e,workflowAbortControllers:this.workflowAbortControllers,executionTasks:this.executionTasks,activeExecutions:this.activeExecutions,buildFinalizerDeps:()=>this.buildFinalizerDeps(),resolveWorkflowContext:e=>bn(this.config,e),config:this.config}}async resolveExecutionWorkspaceRoot(e){if(!e)return this.config.platformDefaults.cwd;let{session:t}=await this.bus.request(Ie.get,{sessionId:e});return t?.targetWorkingDirectory??this.config.platformDefaults.cwd}buildStartDeps(){return{bus:this.bus,config:this.config,activeExecutions:this.activeExecutions,executionTasks:this.executionTasks,workflowRunner:this.workflowRunner,buildRunContext:e=>xn(e,this.config),buildRunnerTaskDeps:e=>this.buildRunnerTaskDeps(e),buildFinalizerDeps:()=>this.buildFinalizerDeps(),resolveExecutionWorkspaceRoot:e=>this.resolveExecutionWorkspaceRoot(e),runExecution:e=>this.runExecution(e)}}registerExecutionHandlers(){this.registerHandler(h.start,async e=>{let{workflowId:t,input:n,config:r,parentSessionId:i,triggerPayload:a,artifactRef:o,scope:s,executionHints:c}=e.payload,l=typeof r==`object`&&r&&!Array.isArray(r)?r:{};try{let r=await xe(this.buildStartDeps(),t,{input:vn(n),config:l,parentSessionId:i,triggerPayload:a,artifactRef:o,executionHints:yn(c),scopeOverride:s});e.setResult({executionId:r})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow: ${t}`)}}),this.registerHandler(h.runFile,async e=>{if(this.workflowRunner===void 0)throw Error(`workflow.runFile requires a workflow runner — configure a ThinWorkflowPiscinaRunner or equivalent.`);let{filePath:t,triggerPayload:n,scope:r}=e.payload;try{let i=await ue(this.buildStartDeps(),t,{triggerPayload:n,scopeOverride:r});e.setResult({executionId:i})}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to start workflow file: ${t}`)}}),this.registerHandler(h.cancel,async e=>{let{executionId:t,reason:n}=e.payload;await this.bus.emit(Re(`workflow.${t}.cancel`),{executionId:t,reason:n}).catch(e=>{console.error(`[WorkflowExecutor] Failed to emit workflow cancel for ${t}:`,e)});let r=this.workflowAbortControllers.get(t);if(r){r.abort(n??v);let i=await m(this.buildFinalizerDeps(),t,n);e.setResult({cancelled:i});return}let i=await m(this.buildFinalizerDeps(),t,n);e.setResult({cancelled:i})}),this.registerGateTimeoutHandlers(),this.addCleanup(this.bus.on(h.gate.respond,async e=>{let{executionId:t,gateId:n,frameId:r,action:i,resumeData:a,reason:o}=e.payload,s=await this.respondToPausedGate({executionId:t,gateId:n,frameId:r,action:i,resumeData:a,reason:o});e.setResult({accepted:s})},{priority:-100}))}registerGateTimeoutHandlers(){this.addCleanup(this.bus.on(h.gate.suspended,e=>{this.gateTimeoutScheduler.schedule(e.payload)})),this.addCleanup(this.bus.on(h.gate.resolved,e=>{this.gateTimeoutScheduler.clear(e.payload.executionId,e.payload.stepId,e.payload.frameId)}))}async rehydratePausedGateTimeouts(){let{gates:e}=await this.bus.request(p.listPausedGateTimeouts,{});for(let t of e)this.gateTimeoutScheduler.schedule(En(t))}async runExecution(e){let t=this.activeExecutions.get(e);if(!t)return;let n=new AbortController;this.workflowAbortControllers.set(e,n);try{let r;try{let i=await he({definition:t.workflow,execution:t.execution,runContext:t.runContext,bus:this.bus}),a=new le(e,t.workflow.id,t.workflow,t.execution,t.runtimeHandlers,this.bus,n.signal,void 0,i,{context:t.runContext.context,env:t.runContext.env}),o=a.buildExpressionContext();r=await Se(t.workflow.root,a,o)}catch(r){if(n.signal.aborted||t.execution.status===`cancelled`){await m(this.buildFinalizerDeps(),e,v);return}let i=r instanceof Error?r.message:String(r);await ye(this.buildFinalizerDeps(),t.execution,e,i);return}let i=this.buildFinalizerDeps();r.status===`cancelled`||n.signal.aborted||t.execution.status===`cancelled`?await m(i,e,v):r.status===`failed`?await ye(i,t.execution,e,r.error):r.status===`paused`?(t.execution.status=`paused`,await this.bus.request(p.setExecution,{execution:t.execution}),this.activeExecutions.delete(e)):await me(i,t.execution,e,t.execution.startedAt)}finally{this.workflowAbortControllers.delete(e)}}async respondToPausedGate(e){let{executionId:t,gateId:n,frameId:r,resumeData:i,reason:a}=e,{execution:o}=await this.bus.request(p.getExecution,{executionId:t});if(!Sn(o))return!1;let s=await Dn(this.bus,{executionId:t,nodeId:n,frameId:r});if(s===null||!be(n,s.schema,i).valid)return!1;let{runContext:c}=await this.bus.request(p.getRunContext,{executionId:t});if(c===null)throw Error(`[WorkflowExecutor] Run context not found for paused execution: ${t}`);await Tn(this.bus,c);let{accepted:l}=await this.bus.request(p.resolveWaitingGateInstance,{gate:{...s,status:e.action===`reject`?`rejected`:`resumed`,resumeData:i,...a===void 0?{}:{reason:a},resolvedAt:Date.now()}});if(!l)return!1;try{await this.resumePausedExecution(o.id)}catch(e){throw await wn(this.bus,this.activeExecutions,this.executionTasks,this.workflowAbortControllers,o,s,n),e}return this.gateTimeoutScheduler.clear(t,n,s.frameId),!0}async resumePausedExecution(e){if(!this.resumeDispatches.has(e)){this.resumeDispatches.add(e);try{await this.dispatchPausedExecutionResume(e)||this.resumeDispatches.delete(e)}catch(t){throw this.resumeDispatches.delete(e),t}}}async dispatchPausedExecutionResume(e){let{runContext:t}=await this.bus.request(p.getRunContext,{executionId:e});if(t===null)throw Error(`[WorkflowExecutor] Run context not found for paused execution: ${e}`);let n=t.definitionSnapshot??(await this.bus.request(p.get,{id:t.workflowId})).workflow??(()=>{throw Error(`[WorkflowExecutor] Workflow definition not found for paused execution: ${e}`)})(),{execution:r}=await this.bus.request(p.getExecution,{executionId:e});if(r===null)throw Error(`[WorkflowExecutor] Execution not found for paused execution: ${e}`);if(r.status!==`paused`)return!1;await Tn(this.bus,t),await this.bus.request(p.setExecution,{execution:{...r,status:`running`}}),this.activeExecutions.set(e,{execution:{...r,status:`running`},workflow:n,runContext:t,runtimeHandlers:new Map});let i=de(t,n,{resume:!0}),a=ve(this.buildStartDeps(),i).finally(()=>{this.resumeDispatches.delete(e)});return this.executionTasks.set(e,a),!0}};function kn(e,t){try{return $e(e)}catch(n){console.error(`[BusEventTriggerEvaluator] Invalid trigger.filterExpression for workflow "${t}": "${e}"`,n);return}}function An(e){let t=e.indexOf(`.`),n=e.indexOf(`:`),r=t===-1?n:n===-1?t:Math.min(t,n);return r===-1?e:e.slice(0,r)}function jn(e){return{subject:`*`,$meta:{namespace:e,isRequest:!1}}}var Mn=class{bus;cleanupFns=[];initialized=!1;triggerIndex=new Map;subscribedNamespaces=new Set;constructor(e){this.bus=e}async init(){if(!this.initialized)try{this.cleanupFns.push(this.bus.on(y.definition.created,e=>{this.indexWorkflow(e.payload)}),this.bus.on(y.definition.updated,e=>{this.removeWorkflow(e.payload.id),this.indexWorkflow(e.payload)}),this.bus.on(y.definition.deleted,e=>{this.removeWorkflow(e.payload.id)})),await this.loadExistingTriggers(),this.initialized=!0}catch(e){throw this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.triggerIndex.clear(),this.subscribedNamespaces.clear(),e}}destroy(){this.initialized&&=(this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.triggerIndex.clear(),this.subscribedNamespaces.clear(),!1)}getTestState(){return{initialized:this.initialized,cleanupFns:[...this.cleanupFns],subscribedNamespaces:new Set(this.subscribedNamespaces)}}async loadExistingTriggers(){let{workflows:e}=await this.bus.request(p.list,{});for(let t of e)this.indexWorkflow(t)}indexWorkflow(e){let t=e.triggers??[],n=[];for(let r of t){if(r.type!==`bus-event`)continue;let t=typeof r.filterExpression==`string`?kn(r.filterExpression,e.id):void 0;typeof r.filterExpression==`string`&&t===void 0||(n.push({workflowId:e.id,subject:r.subject,filter:r.filter,compiledFilterExpr:t}),this.ensureNamespaceSubscribed(An(r.subject)))}n.length>0&&this.triggerIndex.set(e.id,n)}removeWorkflow(e){this.triggerIndex.delete(e)}ensureNamespaceSubscribed(e){if(this.subscribedNamespaces.has(e))return;let t=jn(e),n=this.bus.on(t,e=>{if(e.isRequest)return;let t=typeof e.payload==`object`&&e.payload!==null?e.payload:{};this.handleBusEvent(e.subject,t)});this.cleanupFns.push(n),this.subscribedNamespaces.add(e)}handleBusEvent(e,t){for(let n of this.triggerIndex.values())for(let r of n)if(ke(e,r.subject)&&!(r.filter&&!Oe(t,r.filter))){if(r.compiledFilterExpr){let n;try{n=r.compiledFilterExpr.evalSync({payload:t})}catch(n){console.error(`[BusEventTriggerEvaluator] filterExpression eval failed for workflow "${r.workflowId}" on subject "${e}" payload keys: [${Object.keys(t).join(`, `)}]`,n);continue}if(!n)continue}this.bus.request(y.start,{workflowId:r.workflowId,triggerPayload:t}).catch(t=>{console.error(`[BusEventTriggerEvaluator] Failed to start workflow "${r.workflowId}" triggered by "${e}":`,t)})}}};function K(e,t,n,r,i,a,o,s){return K.fromTZ(K.tp(e,t,n,r,i,a,o),s)}K.fromTZISO=(e,t,n)=>K.fromTZ(Nn(e,t),n),K.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=q(e.tz,n),i=new Date(n.getTime()-r),a=q(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=q(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},K.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},K.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function q(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function Nn(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?K.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):K.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}K.minitz=K;var J=32,Y=31|J,Pn=[1,2,4,8,16],Fn=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new Z(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,Y),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|J;else if(t===Y)this.dayOfWeek[e]=Y;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|Pn[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},In=[31,28,31,30,31,30,31,31,30,31,30,31],X=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],Z=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&Y&&Pn[a-1]&r)return!0;if(r&J){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=K.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>In[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=K.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(K.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():In[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&Y)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,s-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,X[n][0],e,X[n][2]);if(r>1){let i=n+1;for(;i<X.length;)this[X[i][0]]=-X[i][2],i++;if(r===3)return this[X[n][1]]++,this[X[n][0]]=-X[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=X.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):K.fromTZ(K.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function Ln(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new Z(e.startAt,e.timezone),e.stopAt&&=new Z(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function Q(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function Rn(e){return Q(e)}function zn(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Bn=30*1e3,$=[],Vn=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(Q(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(Q(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=Ln(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new Fn(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new Z(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new Fn(e,this.options.timezone),this.name){if($.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);$.push(this)}return i!==void 0&&Rn(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof Z||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new Z(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=$.indexOf(this);e>=0&&$.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Bn&&(t=Bn),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&zn(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new Z(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){Q(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new Z(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&Q(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new Z(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new Z(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new Z(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new Z(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}};function Hn(e,t){return`${e}:${t}`}function Un(e){return e??`UTC`}var Wn=class{bus;cleanupFns=[];initialized=!1;jobs=new Map;constructor(e){this.bus=e}async init(){if(!this.initialized)try{this.cleanupFns.push(this.bus.on(y.definition.created,e=>{this.scheduleWorkflow(e.payload)}),this.bus.on(y.definition.updated,e=>{this.unscheduleWorkflow(e.payload.id),this.scheduleWorkflow(e.payload)}),this.bus.on(y.definition.deleted,e=>{this.unscheduleWorkflow(e.payload.id)})),await this.loadExistingTriggers(),this.initialized=!0}catch(e){throw this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.stopAllJobs(),e}}destroy(){this.initialized&&=(this.cleanupFns.forEach(e=>e()),this.cleanupFns.length=0,this.stopAllJobs(),!1)}activeJobCount(){return this.jobs.size}async loadExistingTriggers(){let{workflows:e}=await this.bus.request(p.list,{});for(let t of e)this.scheduleWorkflow(t)}scheduleWorkflow(e){if(e.scope.type===`global`)return;let t=e.triggers??[];for(let n=0;n<t.length;n++){let r=t[n];if(r.type!==`cron`)continue;let i=Hn(e.id,n);this.stopJob(i);try{let t=Un(r.timezone),a=new Vn(r.schedule,{timezone:t},()=>{this.fireTrigger(e.id,n)});this.jobs.set(i,{workflowId:e.id,triggerIndex:n,job:a})}catch(t){console.warn(`[CronTriggerEvaluator] Skipping invalid cron trigger key="${i}" workflowId="${e.id}" triggerIndex=${n} schedule="${r.schedule}" timezone="${r.timezone??`UTC`}"`,t)}}}unscheduleWorkflow(e){for(let[t,n]of this.jobs)n.workflowId===e&&(n.job.stop(),this.jobs.delete(t))}stopJob(e){let t=this.jobs.get(e);t&&(t.job.stop(),this.jobs.delete(e))}stopAllJobs(){for(let e of this.jobs.values())e.job.stop();this.jobs.clear()}fireTrigger(e,t){this.bus.request(y.start,{workflowId:e,triggerPayload:{firedAt:Date.now(),triggerIndex:t}}).catch(n=>{console.error(`[CronTriggerEvaluator] Failed to start workflow "${e}" for cron trigger index ${t}:`,n)})}},Gn=class extends He{workflowExecutor;busEventTriggerEvaluator;cronTriggerEvaluator;constructor(e,t){super(e),this.workflowExecutor=new On(e,t?.executorConfig,t?.workflowRunner),this.busEventTriggerEvaluator=new Mn(e),this.cronTriggerEvaluator=new Wn(e)}get executor(){return this.workflowExecutor}get cronTriggers(){return this.cronTriggerEvaluator}setTriggerTypeRegistry(e){this.workflowExecutor.setTriggerTypeRegistry(e)}getTriggerTypeRegistry(){return this.workflowExecutor.getTriggerTypeRegistry()}async onInit(){this.addCleanup(()=>this.destroyOwnedServices()),await this.workflowExecutor.init(),await this.busEventTriggerEvaluator.init(),await this.cronTriggerEvaluator.init()}async destroyOwnedServices(){let e=[];for(let t of[()=>this.cronTriggerEvaluator.destroy(),()=>this.busEventTriggerEvaluator.destroy(),()=>this.workflowExecutor.destroy()])try{await t()}catch(t){e.push(t)}if(e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Workflow engine service teardown failed`)}};const Kn=Be(`makaio.workflow-engine`);function qn(e){return{name:Kn.name,displayName:`Workflow Engine`,version:`0.1.0`,dependencies:[ze(tt.name)],critical:!0,namespaces:[Le,Ee],storage:{registerHandlers:Ge(W)},create:t=>new Gn(t.bus,e)}}const Jn=qn();export{On as a,Nt as c,Gn as i,Ft as l,qn as n,W as o,Jn as r,Pt as s,Kn as t};
|
|
@@ -10,7 +10,7 @@ import { MakaioDatabase } from "@makaio/framework/storage/drizzle";
|
|
|
10
10
|
*
|
|
11
11
|
* Handles:
|
|
12
12
|
* - Definition CRUD: get, set, delete, list
|
|
13
|
-
* - Execution CRUD: getExecution, setExecution, updateExecution, listExecutions
|
|
13
|
+
* - Execution CRUD: getExecution, setExecution, updateExecution, listExecutions, listExecutionsByArtifactRefs
|
|
14
14
|
* - Frame CRUD: setFrame, getFrame, listFrames
|
|
15
15
|
* - Gate instance CRUD: setGateInstance, getGateInstance, listGateInstances
|
|
16
16
|
* - Span CRUD: setSpan, listSpans
|
package/dist/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{t}from"./ajv-Cx19PP7Q.mjs";import{z as n}from"zod";import{execFile as r}from"node:child_process";import{isAbsolute as i,relative as a,resolve as o}from"node:path";import{realpathSync as s}from"node:fs";import{localSubject as c}from"@makaio/framework/core";import{NoHandlerError as l}from"@makaio/framework/bus";import{AgentSubjects as u,ArtifactSubjects as d,ExecutionLinkListQuerySchema as f,ExecutionLinkSchema as p,ExecutionListQuerySchema as m,ExecutionStatusSchema as h,ExecutionsByArtifactRefsQuerySchema as g,GateInstanceListQuerySchema as _,JsonPatchOperationSchema as v,JsonValueSchema as y,SessionSubjects as b,SpanRecordSchema as x,SubagentSubjects as S,WORKFLOW_CANCELLED_REASON as C,WorkerNodeSubjects as ee,WorkflowDefinitionSchema as te,WorkflowExecutionSchema as w,WorkflowFrameStateSchema as ne,WorkflowGateInstanceSchema as T,WorkflowListQuerySchema as re,WorkflowRunContextSchema as E,WorkflowSchemas as ie,WorkflowSubjects as ae,WorkflowSubjects as D,WorkflowWorkerSourceSchema as oe,createStepCancelSubject as se}from"@makaio/framework/contracts";import{createStorageNamespaceDefinition as ce}from"@makaio/framework/storage";import{index as O,primaryKey as le,uniqueIndex as ue}from"drizzle-orm/sqlite-core";import{index as k,primaryKey as A,uniqueIndex as de}from"drizzle-orm/pg-core";import{defineDualTable as j}from"@makaio/framework/storage/drizzle";import{sql as fe}from"drizzle-orm";import{evaluateSync as M,resolveTemplate as N}from"@makaio/framework/expression";import*as pe from"node:os";function me(e){return{scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``)}}const he=j(`workflow_definitions`,e=>({id:e.text(`id`).primaryKey(),name:e.text(`name`).notNull(),description:e.text(`description`),root:e.jsonCol(`root`).notNull(),inputSchema:e.jsonCol(`input_schema`),configSchema:e.jsonCol(`config_schema`),outputSchema:e.jsonCol(`output_schema`),state:e.jsonCol(`state`),artifact:e.jsonCol(`artifact`),triggers:e.jsonCol(`triggers`),...me(e),createdAt:e.epochMs(`created_at`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull(),canvasLayout:e.jsonCol(`canvas_layout`),source:e.jsonCol(`source`),executionHints:e.jsonCol(`execution_hints`)}),{sqlite:e=>[ue(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),O(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)],postgres:e=>[de(`uniq_workflow_definitions_name_scope`).on(e.name,e.scopeType,e.scopeKind,e.scopeId),k(`idx_workflow_definitions_scope`).on(e.scopeType,e.scopeKind,e.scopeId)]}),ge=he.sqlite,P=j(`workflow_executions`,e=>({id:e.text(`id`).primaryKey(),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),inputs:e.jsonCol(`inputs`),error:e.text(`error`),reason:e.text(`reason`),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),triggerPayload:e.jsonCol(`trigger_payload`),artifactKind:e.text(`artifact_kind`),artifactId:e.text(`artifact_id`),...me(e)}),{sqlite:e=>[O(`idx_workflow_executions_status`).on(e.status),O(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),O(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),O(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)],postgres:e=>[k(`idx_workflow_executions_status`).on(e.status),k(`idx_workflow_executions_scope_started`).on(e.scopeType,e.scopeKind,e.scopeId,e.startedAt),k(`idx_workflow_executions_workflow_started`).on(e.workflowId,e.startedAt),k(`idx_workflow_executions_artifact`).on(e.artifactKind,e.artifactId,e.startedAt)]}),_e=P.sqlite,ve=j(`workflow_execution_frames`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),parentFrameId:e.text(`parent_frame_id`),status:e.text(`status`).notNull().default(`pending`).$type(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),output:e.jsonCol(`output`),outputPresent:e.bool(`output_present`).notNull().default(!1),error:e.text(`error`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`)}),{sqlite:e=>[O(`idx_workflow_execution_frames_execution`).on(e.executionId),O(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)],postgres:e=>[k(`idx_workflow_execution_frames_execution`).on(e.executionId),k(`idx_workflow_execution_frames_parent`).on(e.parentFrameId)]}),ye=ve.sqlite,be=j(`workflow_gate_instances`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),schema:e.jsonCol(`schema`).notNull(),prompt:e.text(`prompt`),status:e.text(`status`).notNull().default(`waiting`).$type(),autoAction:e.textEnum(`auto_action`,{enum:[`approve`,`reject`]}).notNull().default(`reject`),timeoutMs:e.int4(`timeout_ms`),resumeData:e.jsonCol(`resume_data`),reason:e.text(`reason`),resumeDataPresent:e.bool(`resume_data_present`).notNull().default(!1),createdAt:e.epochMs(`created_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`)}),{sqlite:e=>[O(`idx_workflow_gate_instances_execution`).on(e.executionId),O(`idx_workflow_gate_instances_frame`).on(e.frameId)],postgres:e=>[k(`idx_workflow_gate_instances_execution`).on(e.executionId),k(`idx_workflow_gate_instances_frame`).on(e.frameId)]}),xe=be.sqlite,Se=j(`workflow_step_spans`,e=>({executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),stepId:e.text(`step_id`).notNull(),stepType:e.text(`step_type`).notNull(),status:e.text(`status`).$type().notNull(),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),toolCallCount:e.int4(`tool_call_count`),input:e.text(`input`),output:e.text(`output`)}),{sqlite:e=>[le({columns:[e.executionId,e.frameId]}),O(`idx_workflow_step_spans_status`).on(e.status)],postgres:e=>[A({columns:[e.executionId,e.frameId]}),k(`idx_workflow_step_spans_status`).on(e.status)]}),Ce=Se.sqlite,we=j(`workflow_execution_links`,e=>({sourceExecutionId:e.text(`source_execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),targetExecutionId:e.text(`target_execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),linkType:e.text(`link_type`).$type().notNull(),metadata:e.jsonCol(`metadata`)}),{sqlite:e=>[le({columns:[e.sourceExecutionId,e.targetExecutionId]}),O(`idx_workflow_execution_links_target`).on(e.targetExecutionId)],postgres:e=>[A({columns:[e.sourceExecutionId,e.targetExecutionId]}),k(`idx_workflow_execution_links_target`).on(e.targetExecutionId)]}),Te=we.sqlite,Ee=j(`workflow_run_contexts`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),coordinatorSessionId:e.text(`coordinator_session_id`).notNull(),sourceKind:e.text(`source_kind`).notNull(),sourcePath:e.text(`source_path`),sourceFilename:e.text(`source_filename`),sourceCode:e.text(`source_code`),definitionSnapshot:e.jsonCol(`definition_snapshot`),workerManifest:e.jsonCol(`worker_manifest`).notNull(),inputs:e.jsonCol(`inputs`),config:e.jsonCol(`config`).notNull().default(fe`'{}'`),triggerPayload:e.jsonCol(`trigger_payload`).notNull(),artifactRef:e.jsonCol(`artifact_ref`),executionHints:e.jsonCol(`execution_hints`),dispatchMetadata:e.jsonCol(`dispatch_metadata`),scopeType:e.textEnum(`scope_type`,{enum:[`global`,`workspace`,`session`,`external`]}).notNull().default(`global`).$type(),scopeKind:e.text(`scope_kind`).notNull().default(``),scopeId:e.text(`scope_id`).notNull().default(``),cancelSubject:e.text(`cancel_subject`).notNull(),context:e.jsonCol(`context`).notNull(),env:e.jsonCol(`env`).notNull(),createdAt:e.epochMs(`created_at`).notNull(),suspensionStrategy:e.text(`suspension_strategy`).$type()}),{sqlite:e=>[O(`idx_run_contexts_workflow`).on(e.workflowId)],postgres:e=>[k(`idx_run_contexts_workflow`).on(e.workflowId)]}),De=Ee.sqlite,Oe=j(`worklog_summaries`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),workflowId:e.text(`workflow_id`).notNull(),workflowName:e.text(`workflow_name`),status:e.textEnum(`status`,{enum:[`pending`,`running`,`paused`,`completed`,`failed`,`cancelled`]}).notNull(),startedAt:e.epochMs(`started_at`).notNull(),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),totalInputTokens:e.int4(`total_input_tokens`),totalOutputTokens:e.int4(`total_output_tokens`),totalEstimatedCost:e.float8(`total_estimated_cost`),error:e.text(`error`),failedNodeId:e.text(`failed_node_id`)}),{sqlite:e=>[O(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),O(`idx_worklog_summaries_status`).on(e.status)],postgres:e=>[k(`idx_worklog_summaries_workflow_started`).on(e.workflowId,e.startedAt),k(`idx_worklog_summaries_status`).on(e.status)]}),ke=Oe.sqlite,Ae=j(`worklog_frame_entries`,e=>({frameId:e.text(`frame_id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),nodeType:e.text(`node_type`).notNull().$type(),path:e.jsonCol(`path`).notNull(),status:e.textEnum(`status`,{enum:[`pending`,`running`,`waiting`,`completed`,`failed`,`skipped`,`cancelled`]}).notNull(),attempt:e.int4(`attempt`).notNull().default(0),iteration:e.int4(`iteration`),branchKey:e.text(`branch_key`),startedAt:e.epochMs(`started_at`),completedAt:e.epochMs(`completed_at`),durationMs:e.int4(`duration_ms`),inputTokens:e.int4(`input_tokens`),outputTokens:e.int4(`output_tokens`),estimatedCost:e.float8(`estimated_cost`),error:e.text(`error`)}),{sqlite:e=>[O(`idx_worklog_frame_entries_execution`).on(e.executionId)],postgres:e=>[k(`idx_worklog_frame_entries_execution`).on(e.executionId)]}),je=Ae.sqlite,Me=j(`worklog_artifact_writes`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),frameId:e.text(`frame_id`).notNull(),nodeId:e.text(`node_id`).notNull(),artifact:e.jsonCol(`artifact`).notNull(),revision:e.text(`revision`),writtenAt:e.epochMs(`written_at`).notNull()}),{sqlite:e=>[O(`idx_worklog_artifact_writes_execution`).on(e.executionId)],postgres:e=>[k(`idx_worklog_artifact_writes_execution`).on(e.executionId)]}),Ne=Me.sqlite,Pe=j(`worklog_gate_events`,e=>({id:e.text(`id`).primaryKey(),executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),nodeId:e.text(`node_id`).notNull(),frameId:e.text(`frame_id`).notNull(),status:e.textEnum(`status`,{enum:[`waiting`,`resumed`,`rejected`,`timed-out`,`cancelled`]}).notNull().$type(),prompt:e.text(`prompt`),openedAt:e.epochMs(`opened_at`).notNull(),resolvedAt:e.epochMs(`resolved_at`),resumeData:e.jsonCol(`resume_data`)}),{sqlite:e=>[O(`idx_worklog_gate_events_execution`).on(e.executionId),O(`idx_worklog_gate_events_status`).on(e.status)],postgres:e=>[k(`idx_worklog_gate_events_execution`).on(e.executionId),k(`idx_worklog_gate_events_status`).on(e.status)]}),Fe=Pe.sqlite,Ie=j(`workflow_execution_state`,e=>({executionId:e.text(`execution_id`).primaryKey().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),sequence:e.int4(`sequence`).notNull().default(0),value:e.jsonCol(`value`).notNull(),updatedAt:e.epochMs(`updated_at`).notNull()})),Le=Ie.sqlite,Re=j(`workflow_execution_state_events`,e=>({executionId:e.text(`execution_id`).notNull().references(()=>P.columnPair(`id`),{onDelete:`cascade`}),sequence:e.int4(`sequence`).notNull(),patch:e.jsonCol(`patch`).notNull(),value:e.jsonCol(`value`).notNull(),createdAt:e.epochMs(`created_at`).notNull()}),{sqlite:e=>[le({columns:[e.executionId,e.sequence]})],postgres:e=>[A({columns:[e.executionId,e.sequence]})]}),ze=Re.sqlite,Be=n.object({executionId:n.string().min(1),status:h.optional(),error:n.string().nullable().optional(),reason:n.string().nullable().optional(),completedAt:n.number().nullable().optional()}),Ve=ce(`workflow`,{schemas:{get:{request:n.object({id:n.string()}),response:n.object({workflow:te.nullable()})},set:{request:n.object({workflow:te}),response:n.object({id:n.string()})},delete:{request:n.object({id:n.string()}),response:n.object({deleted:n.boolean()})},list:{request:re,response:n.object({workflows:n.array(te)})},getExecution:{request:n.object({executionId:n.string()}),response:n.object({execution:w.nullable()})},setExecution:{request:n.object({execution:w}),response:n.object({id:n.string()})},setExecutionStart:{request:n.object({execution:w,runContext:E,initialState:y.optional()}),response:n.object({id:n.string(),executionId:n.string()})},updateExecution:{request:Be,response:n.object({success:n.boolean()})},cancelPausedExecution:{request:n.object({executionId:n.string().min(1),completedAt:n.number(),reason:n.string().optional()}),response:n.object({cancelled:n.boolean(),gates:n.array(T.extend({status:n.literal(`cancelled`)}))})},listExecutions:{request:m,response:n.object({executions:n.array(w)})},listExecutionsByArtifactRefs:{request:g,response:n.object({executionsByRef:n.record(n.string(),n.array(w))})},setFrame:{request:n.object({executionId:n.string().min(1),frame:ne}),response:n.object({frameId:n.string()})},getFrame:{request:n.object({frameId:n.string().min(1)}),response:n.object({frame:ne.nullable()})},listFrames:{request:n.object({executionId:n.string().min(1)}),response:n.object({frames:n.array(ne)})},setGateInstance:{request:n.object({gate:T}),response:n.object({id:n.string()})},resolveWaitingGateInstance:{request:n.object({gate:T.extend({status:n.enum([`resumed`,`rejected`])})}),response:n.object({accepted:n.boolean()})},restorePausedGateResumeState:{request:n.object({execution:w.extend({status:n.literal(`paused`)}),gate:T.extend({status:n.literal(`waiting`)})}),response:n.object({executionId:n.string(),gateId:n.string()})},getGateInstance:{request:n.object({executionId:n.string().min(1),nodeId:n.string().min(1),frameId:n.string().min(1).optional()}),response:n.object({gate:T.nullable()})},listGateInstances:{request:_,response:n.object({gates:n.array(T)})},listPausedGateTimeouts:c({request:n.object({}),response:n.object({gates:n.array(T)})}),setSpan:{request:n.object({span:x}),response:n.object({id:n.string()})},listSpans:{request:n.object({executionId:n.string()}),response:n.object({spans:n.array(x)})},setExecutionLink:{request:n.object({link:p}),response:n.object({id:n.string()})},listExecutionLinks:{request:f,response:n.object({links:n.array(p)})},setRunContext:c({request:n.object({runContext:E}),response:n.object({executionId:n.string()})}),getRunContext:c({request:n.object({executionId:n.string().min(1)}),response:n.object({runContext:E.nullable()})}),initializeState:c({request:n.object({executionId:n.string().min(1),initialValue:y}),response:n.object({})}),getState:c({request:n.object({executionId:n.string().min(1)}),response:n.object({state:n.object({executionId:n.string().min(1),sequence:n.number().int().nonnegative(),value:y}).nullable()})}),patchState:c({request:n.object({executionId:n.string().min(1),expectedSequence:n.number().int().nonnegative(),nextValue:y}),response:n.object({executionId:n.string().min(1),sequence:n.number().int().positive(),patch:n.array(v),value:y})})},extensions:{drizzle:{workflowDefinitions:ge,workflowExecutions:_e,workflowExecutionFrames:ye,workflowGateInstances:xe,workflowStepSpans:Ce,workflowExecutionLinks:Te,workflowRunContexts:De,worklogSummaries:ke,worklogFrameEntries:je,worklogArtifactWrites:Ne,worklogGateEvents:Fe,workflowExecutionState:Le,workflowExecutionStateEvents:ze}}}),F=Ve.subjects;var He=e(t(),1);function Ue(e,t){let n=[];return We(n,``,e,t),n}function We(e,t,n,r){if(Array.isArray(n)&&Array.isArray(r)){Ke(e,t,n,r);return}if(qe(n)&&qe(r)){Ge(e,t,n,r);return}Xe(n,r)||e.push({op:`replace`,path:t,value:r})}function Ge(e,t,n,r){let i=Array.from(new Set([...Object.keys(n),...Object.keys(r)])).sort();for(let a of i){let i=Je(n,a),o=Je(r,a),s=`${t}/${Ye(a)}`;if(!i&&o){e.push({op:`add`,path:s,value:r[a]});continue}if(i&&!o){e.push({op:`remove`,path:s});continue}We(e,s,n[a],r[a])}}function Ke(e,t,n,r){let i=Math.min(n.length,r.length);for(let a=0;a<i;a++)We(e,`${t}/${String(a)}`,n[a],r[a]);for(let i=n.length-1;i>=r.length;i--)e.push({op:`remove`,path:`${t}/${String(i)}`});for(let i=n.length;i<r.length;i++)e.push({op:`add`,path:`${t}/${String(i)}`,value:r[i]})}function qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Je(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ye(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function Xe(e,t){return Object.is(e,t)}const Ze={stepTimeoutMs:300*1e3,stepCooldownMs:500,busAuth:{kind:`none`},platformDefaults:{cwd:process.cwd()},cancelTimeoutMs:1e4},Qe=new He.default({allErrors:!0,strict:!1}),$e=new Map,et=new Map;function tt(e){let t=e.$id;return typeof t==`string`?t:void 0}function nt(e,t,n){let r=tt(t);return r===void 0?`workflow:${e}:${n}`:`schema-id:${r}`}function rt(e,t){try{return JSON.stringify(it(t))}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Workflow '${e}' state schema is invalid: ${n}`)}}function it(e){if(Array.isArray(e))return e.map(it);if(typeof e!=`object`||!e)return e;let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,it(t[e])]))}function at(e,t,n){let r=et.get(t);if(r!==void 0&&r!==n)throw Error(`Workflow '${e}' state schema reuses JSON Schema $id '${t}' with different content`);return Qe.getSchema(t)}function ot(e){return e==null||e.length===0?`schema validation failed`:e.map(e=>`${e.instancePath.length>0?e.instancePath:`<root>`} ${e.message??`is invalid`}`).join(`; `)}function st(e,t){let n=rt(e,t),r=nt(e,t,n),i=$e.get(r);if(i!==void 0)return i;let a=tt(t);if(a!==void 0){let t=at(e,a,n);if(t!==void 0)return $e.set(r,t),t}try{let e=Qe.compile(t);return $e.set(r,e),a!==void 0&&et.set(a,n),e}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Workflow '${e}' state schema is invalid: ${n}`)}}function ct(e,t,n){if(e.state===void 0)return;let r=st(e.id,e.state.schema);if(r(t))return;let i=n===`initial`?`initial state`:`next state`;throw Error(`Workflow '${e.id}' ${i} does not match workflow state schema: ${ot(r.errors)}`)}function lt(e){if(e.state===void 0)return;let t=e.state.initial===void 0?{}:e.state.initial;return ct(e,t,`initial`),t}async function ut(e,t,n){if(!(await e.request(F.updateExecution,{executionId:t.id,status:n.status,error:n.error,reason:n.reason,completedAt:n.completedAt})).success)throw Error(`Workflow execution not found: ${t.id}`)}async function dt(e,t,n,r){t.status=`completed`,t.completedAt=Date.now();try{await ut(e.bus,t,{status:t.status,completedAt:t.completedAt}),await e.bus.emit(D.execution.completed,{executionId:n,workflowId:t.workflowId,totalDuration:t.completedAt-r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}async function I(e,t,n,r,i){t.status=`failed`,t.error=r,t.completedAt=Date.now();try{await ut(e.bus,t,{status:t.status,error:t.error,completedAt:t.completedAt});try{await i?.()}catch(e){console.error(`[WorkflowFinalizer] Failed to run failure pre-emit hook:`,e)}await e.bus.emit(D.execution.failed,{executionId:n,workflowId:t.workflowId,error:r,completedAt:t.completedAt})}finally{e.activeExecutions.delete(n)}}function ft(e,t,n){let{activeRunnerSteps:r,bus:i}=e,a=`${t}:`;for(let[e,o]of r){if(!e.startsWith(a))continue;let r=e.slice(a.length);o.controller.abort(),i.emit(se(o.cancelSubject),{executionId:t,stepId:r,reason:n}).catch(t=>{console.error(`[WorkflowFinalizer] Failed to emit cancellation for ${e}:`,t)})}}async function pt(e,t,n){let r=await e.bus.request(F.getExecution,{executionId:t});if(r.execution==null)return!1;let i=r.execution.workflowId;if(i===void 0)throw Error(`Paused execution ${t} is missing stored workflowId`);let a=Date.now(),{cancelled:o,gates:s}=await e.bus.request(F.cancelPausedExecution,{executionId:t,completedAt:a,reason:n});if(!o)return!1;for(let n of s)await e.bus.emit(D.gate.resolved,{executionId:t,stepId:n.nodeId,stepType:`gate`,frameId:n.frameId,source:`cancelled`}).catch(e=>{console.error(`[WorkflowFinalizer] Failed to emit cancelled gate resolution for ${n.frameId}:`,e)});return await e.bus.emit(D.execution.cancelled,{executionId:t,workflowId:i,reason:n,completedAt:a}),e.activeExecutions.delete(t),!0}async function L(e,t,n){let r=e.activeExecutions.get(t);if(!r||r.execution.status!==`running`)return pt(e,t,n);let{execution:i}=r;i.status=`cancelled`,i.reason=n,i.completedAt=Date.now();try{for(let[n,r]of e.shellAbortControllers)n.startsWith(`${t}:`)&&(r.abort(),e.shellAbortControllers.delete(n));ft(e,t,n),await ut(e.bus,i,{status:i.status,reason:n,completedAt:i.completedAt}),await e.bus.emit(D.execution.cancelled,{executionId:t,workflowId:i.workflowId,reason:n,completedAt:i.completedAt})}finally{e.activeExecutions.delete(t)}return!0}const mt=[`darwin`,`linux`,`win32`];function ht(e){return mt.find(t=>t===e)??`linux`}function gt(e,t){return t}function _t(e,t){return{...t}}function vt(e){return e.reason instanceof Error?e.reason.message:typeof e.reason==`string`&&e.reason.length>0?e.reason:C}async function yt(e,t,n){let r=e.activeExecutions.get(t);if(!r||r.execution.status!==`running`)return;let i=e.buildFinalizerDeps(),{execution:a}=await i.bus.request(F.getExecution,{executionId:t});a?.status===`running`&&(r.execution=a,await L(i,t,vt(n))||console.error(`[WorkflowExecutor] Failed to persist runner cancellation for ${t}: execution not active`))}async function bt(e,t){if(t.pausedAtGateId===void 0||t.pausedAtFrameId===void 0)throw Error(`Paused runner result for '${t.executionId}' is missing gate identity`);let{bus:n}=e.buildFinalizerDeps(),{execution:r}=await n.request(F.getExecution,{executionId:t.executionId});if(r?.status!==`running`){let n=e.activeExecutions.get(t.executionId);n!==void 0&&r?.status===`paused`&&(n.execution.status=`paused`,e.activeExecutions.delete(t.executionId));return}let i={...r,status:`paused`};await n.request(F.setExecution,{execution:i});let a=e.activeExecutions.get(t.executionId);a!==void 0&&(a.execution=i),await n.emit(D.execution.paused,{executionId:t.executionId,workflowId:t.workflowId,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}),e.activeExecutions.delete(t.executionId)}async function xt(e,t){let n=e.activeExecutions.get(t.executionId);if(!n||n.execution.status!==`running`)return;let r=e.buildFinalizerDeps(),{execution:i}=await r.bus.request(F.getExecution,{executionId:t.executionId});if(i?.status===`running`){if(n.execution=i,t.status===`completed`){await dt(r,n.execution,t.executionId,n.execution.startedAt);return}if(t.status===`cancelled`){await L(r,t.executionId,t.reason??C);return}if(t.status===`failed`){await I(r,n.execution,t.executionId,t.error);return}}}function St(e,t){let{executionId:n,workflowId:r,filePath:i,coordinatorSessionId:a,sanitizedTriggerPayload:o,scope:s,workspaceRoot:c}=t,{workflowRunner:l,workflowAbortControllers:u,executionTasks:d,activeExecutions:f,config:p}=e,m=new AbortController;u.set(n,m);let h={source:{kind:`path`,path:i},executionId:n,workflowId:r,triggerPayload:o,inputs:{},config:{},scope:s,busUrl:p.busUrl,busAuth:p.busAuth,context:e.resolveWorkflowContext(c),env:p.platformDefaults.env??{},coordinatorSessionId:a,cancelSubject:`workflow.${n}.cancel`,suspensionStrategy:`wait-in-process`};return Promise.resolve().then(()=>l.run(h,m.signal)).then(async t=>{if(t.status===`paused`){await bt(e,t);return}await xt(e,t)}).catch(async t=>{if(m.signal.aborted){await yt(e,n,m.signal).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist file runner cancellation for ${n}:`,e)});return}let r=f.get(n);if(r){let i=t instanceof Error?t.message:String(t);await I(e.buildFinalizerDeps(),r.execution,n,i).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist file runner boot failure for ${n}:`,e)})}}).finally(()=>{u.delete(n),d.delete(n),f.delete(n)})}function Ct(e,t){let{config:n}=e;return{source:t.source,...t.source.kind===`definition`?{definition:t.workflow}:{},executionId:t.executionId,workflowId:t.workflowId,triggerPayload:t.sanitizedTriggerPayload,inputs:t.boundInputs,config:t.boundConfig,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},...t.executionHints===void 0?{}:{executionHints:t.executionHints},scope:t.scope,busUrl:n.busUrl,busAuth:n.busAuth,context:e.resolveWorkflowContext(t.workspaceRoot),env:n.platformDefaults.env??{},coordinatorSessionId:t.coordinatorSessionId,cancelSubject:`workflow.${t.executionId}.cancel`,suspensionStrategy:t.suspensionStrategy??`wait-in-process`}}function wt(e,t){let{executionId:n}=t,{workflowRunner:r,workflowAbortControllers:i,executionTasks:a,activeExecutions:o}=e,s=new AbortController;i.set(n,s);let c=Ct(e,t),l=t.dispatchMetadata===void 0?void 0:{dispatchMetadata:t.dispatchMetadata};return Promise.resolve().then(()=>r.run(c,s.signal,void 0,l)).then(async t=>{if(t.status===`paused`){await bt(e,t);return}await xt(e,t)}).catch(async t=>{if(s.signal.aborted){await yt(e,n,s.signal).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist runner cancellation for ${n}:`,e)});return}let r=o.get(n);if(r){let i=t instanceof Error?t.message:String(t);await I(e.buildFinalizerDeps(),r.execution,n,i).catch(e=>{console.error(`[WorkflowExecutor] Failed to persist runner boot failure for ${n}:`,e)})}}).finally(()=>{i.delete(n),a.delete(n),o.delete(n)})}function Tt(e,t,n={}){let r=Et(e,n);return{executionId:e.executionId,workflowId:e.workflowId,workflow:t,source:e.source,coordinatorSessionId:e.coordinatorSessionId,sanitizedTriggerPayload:e.triggerPayload,boundInputs:e.inputs,boundConfig:e.config??{},...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},scope:e.scope,workspaceRoot:e.context.repoPath,suspensionStrategy:e.suspensionStrategy,...r===void 0?{}:{dispatchMetadata:r}}}function Et(e,t){return t.resume===!0?{...e.dispatchMetadata,resume:!0}:e.dispatchMetadata}function Dt(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ot(e,t,n){let r=e?N(e,n):t,c=o(t),l=o(i(r)?r:o(t,r)),u,d;try{u=s(c),d=s(l)}catch{return null}let f=a(process.platform===`win32`?u.toLowerCase():u,process.platform===`win32`?d.toLowerCase():d);return f===``||!f.startsWith(`..`)&&!i(f)?d:null}function kt(e){return e instanceof Error&&(`code`in e||`killed`in e)}function At(e){let t=e[0];return t===void 0||t.trim()===``?null:t}function jt(e){let{command:t,cwd:n,env:i,timeoutMs:a,signal:o}=e,s=At(t);if(s===null)return Promise.reject(Error(`Shell step command is empty`));let c=t.slice(1);return new Promise((e,t)=>{let l=null,u=!1,d=r(s,c,{cwd:n,env:{...process.env,...i},timeout:0,maxBuffer:10*1024*1024,shell:!1},(n,r,i)=>{n?t(Object.assign(n,{stdout:r,stderr:i,aborted:u})):e({stdout:r,stderr:i})}),f=()=>{d.exitCode===null&&(d.kill(`SIGTERM`),l=setTimeout(()=>{d.exitCode===null&&d.kill(`SIGKILL`)},5e3))},p=setTimeout(()=>{f()},a);if(d.on(`close`,()=>{clearTimeout(p),l!==null&&clearTimeout(l)}),o){let e=()=>{u=!0,f()};o.aborted?e():(o.addEventListener(`abort`,e,{once:!0}),d.on(`close`,()=>o.removeEventListener(`abort`,e)))}})}async function Mt(e){let{step:t,workspaceRoot:n,expressionContext:r,signal:i}=e,a=Ot(t.cwd,n,r);if(a===null)return{status:`failed`,error:`Shell step cwd '${t.cwd}' is outside workspace root '${n}'`};let o=t.command.map(e=>N(e,r));if(At(o)===null)return{status:`failed`,error:`Shell step command is empty`};let s=Object.fromEntries(Object.entries(t.env??{}).map(([e,t])=>[e,N(t,r)])),c=t.timeoutMs??3e5;try{let{stdout:e}=await jt({command:o,cwd:a,env:s,timeoutMs:c,signal:i});return{status:`completed`,stdout:e}}catch(e){if(!kt(e))return{status:`failed`,error:String(e)};let t=e.aborted===!0,n=!t&&(e.killed===!0||e.signal!=null);return{status:`failed`,error:t?`Command cancelled`:n?`Command timed out after ${c}ms`:e.stderr?.trim()||e.stdout?.trim()||e.message}}}const Nt=/(?:^|[_-])(authorization|token|cookie|password|set[_-]?cookie|api[_-]?key|secret|credential|private[_-]?key|api[_-]?secret)(?:$|[_-])/i;function Pt(e){if(!e)return;let t={remainingBytes:65536},n={},r=Object.entries(e).slice(0,100);for(let[e,i]of r){if(t.remainingBytes<=0)break;let r=Ft(e,i,0,t);r!==void 0&&(n[e]=r)}return Object.keys(n).length>0?n:void 0}function Ft(e,t,n,r){if(!(r.remainingBytes<=0||n>6)&&(r.remainingBytes-=e.length,!(r.remainingBytes<=0))){if(Nt.test(e))return r.remainingBytes-=10,`[REDACTED]`;if(t===null)return r.remainingBytes-=4,null;if(typeof t==`string`){let e=t.slice(0,2e3);return r.remainingBytes-=e.length,e}if(typeof t==`number`||typeof t==`boolean`)return r.remainingBytes-=String(t).length,t;if(Array.isArray(t)){let i=[];for(let a of t.slice(0,100)){if(r.remainingBytes<=0)break;let t=Ft(e,a,n+1,r);t!==void 0&&i.push(t)}return i}if(typeof t==`object`){let e={},i=Object.entries(t).slice(0,100);for(let[t,a]of i){if(r.remainingBytes<=0)break;let i=Ft(t,a,n+1,r);i!==void 0&&(e[t]=i)}return e}}}function It(e,t,n){let r=t?.requirements?.capabilities??[];if(r.length!==0)return{run:(t,i)=>e.request(ee.dispatch,{config:t,requirements:{customCapabilities:r},...n===void 0?{}:{metadata:n}},{signal:i})}}function Lt(e,t){let n=It(e.bus,t.executionHints,t.dispatchMetadata);return n===void 0?e.workflowRunner===void 0?e.runExecution(t.executionId).finally(()=>{e.executionTasks.delete(t.executionId)}):wt(e.buildRunnerTaskDeps(e.workflowRunner),t):wt(e.buildRunnerTaskDeps(n),t)}async function Rt(e,t,n,r){let i=lt(r);await e.request(F.setExecutionStart,{execution:t,runContext:n,initialState:i})}async function zt(e,t){try{await e.emit(D.execution.started,t)}catch(e){console.error(`[WorkflowExecutor] execution.started listener failed:`,e)}}async function Bt(e,t){await e.request(b.close,{sessionId:t}).catch(e=>{console.error(`[WorkflowExecutor] Failed to close coordinator session "${t}" after launch failure:`,e)})}function Vt(e,t,n,r,i,a,o,s,c){let l={id:t,workflowId:n.id,coordinatorSessionId:r,status:`running`,inputs:i,config:a,startedAt:Date.now(),triggerPayload:o,...c.artifactRef===void 0?{}:{artifactRef:c.artifactRef},scope:s};return e.set(t,{execution:l,workflow:n,runContext:c,runtimeHandlers:new Map}),l}async function Ht(e,t,n,r){await e.request(F.setExecutionStart,{execution:t,runContext:n,initialState:r})}function Ut(e,t){let n=e?.source;if(n===void 0)return;let r=oe.parse(n);return r.kind===`path`&&!i(r.path)?{...r,path:o(t,r.path)}:r}function Wt(e,t,n){return Ut(t,n)??{kind:`definition`,workflowId:e}}async function Gt(e,t,n,r){return e.set(t,n),await r,t}async function Kt(e,t){let{workflow:n}=await e.request(F.get,{id:t});if(!n)throw Error(`Workflow not found: ${t}`);return n}function qt(e,t){if(e===void 0&&t===void 0)return;let n=[...new Set([...e?.capabilities??[],...t?.capabilities??[]])];return{...e,...t,...n.length>0&&{capabilities:n}}}function Jt(e,t){if(e===void 0&&t===void 0)return;let n=qt(e?.requirements,t?.requirements),r=e?.providers!==void 0||t?.providers!==void 0?{...e?.providers,...t?.providers}:void 0;return{...e,...t,...n!==void 0&&{requirements:n},...r!==void 0&&{providers:r}}}async function Yt(e,t,n,r){let{sessionId:i}=await e.request(b.create,{parentSessionId:t,branchKind:`coordinator`,title:`Workflow: ${n}`,targetWorkingDirectory:r});return i}async function Xt(e,t,n={}){let{bus:r,activeExecutions:i,executionTasks:a}=e,{parentSessionId:o,triggerPayload:s,artifactRef:c,executionHints:l,scopeOverride:u}=n,d=n.input===void 0?{}:n.input,f=n.config??{},p=await Kt(r,t),m=Dt(`wfx`),h=Pt(s),g=gt(p,d),_=_t(p,f),v=u??p.scope,y=Jt(p.executionHints,l),b=await e.resolveExecutionWorkspaceRoot(o),x=Wt(t,y,b),S=await Yt(r,o,p.name,b),C=!1;try{let n=e.buildRunContext({executionId:m,workflowId:t,coordinatorSessionId:S,source:x,...x.kind===`definition`?{definitionSnapshot:p}:{},inputs:g,config:_,scope:v,triggerPayload:h??{},...c===void 0?{}:{artifactRef:c},...y===void 0?{}:{executionHints:y},workspaceRoot:b}),o=Vt(i,m,p,S,g,_,h,v,n);await Ht(r,o,n,x.kind===`definition`?lt(p):void 0);let s=o.startedAt,l=zt(r,{executionId:m,workflowId:t,coordinatorSessionId:S,startedAt:s,...c===void 0?{}:{artifactRef:c}}),u=Lt(e,{executionId:m,workflowId:t,workflow:p,source:x,coordinatorSessionId:S,sanitizedTriggerPayload:h??{},boundInputs:g,boundConfig:_,scope:v,...c===void 0?{}:{artifactRef:c},...y===void 0?{}:{executionHints:y},workspaceRoot:b,suspensionStrategy:n.suspensionStrategy});return C=!0,Gt(a,m,u,l)}catch(e){throw C||(i.delete(m),a.delete(m),await Bt(r,S)),e}}function Zt(e,t,n,r,i){e.set(t.id,{execution:t,workflow:{id:t.workflowId,name:n,scope:r,root:{id:`${t.workflowId}-root`,type:`sequence`,nodes:[]}},runContext:i,runtimeHandlers:new Map})}async function Qt(e,t,n={}){let{bus:r,config:i,activeExecutions:a,executionTasks:o}=e,{triggerPayload:s,scopeOverride:c}=n,l=Dt(`wfx`),u=Pt(s),d=c??{type:`global`},f=i.platformDefaults.cwd,{sessionId:p}=await r.request(b.create,{branchKind:`coordinator`,title:`Workflow: ${t}`,targetWorkingDirectory:f}),m=l,h={id:l,workflowId:m,coordinatorSessionId:p,status:`running`,inputs:{},config:{},startedAt:Date.now(),triggerPayload:u,scope:d},g=!1;try{let{workflowRunner:n}=e;if(n===void 0)throw Error(`[WorkflowExecutor] startFileExecution called without a workflow runner`);let i=e.buildRunContext({executionId:l,workflowId:m,coordinatorSessionId:p,source:{kind:`path`,path:t},inputs:{},config:{},scope:d,triggerPayload:u??{},workspaceRoot:f});await Ht(r,h,i,void 0),Zt(a,h,t,d,i);let s=zt(r,{executionId:l,workflowId:m,coordinatorSessionId:p,startedAt:h.startedAt}),c=St(e.buildRunnerTaskDeps(n),{executionId:l,workflowId:m,filePath:t,coordinatorSessionId:p,sanitizedTriggerPayload:u??{},scope:d,workspaceRoot:f});return g=!0,Gt(o,l,c,s)}catch(e){throw g||(a.delete(l),o.delete(l),await Bt(r,p)),e}}function $t(e){let t={};for(let[n,r]of Object.entries(e))r.status===`completed`?t[n]={status:`completed`,output:r.output}:r.status===`skipped`&&(t[n]={status:`skipped`});return t}function R(e){let t={...e,input:e.inputs,steps:e.frames};return{...t,ctx:t}}function en(){return{context:{repoPath:process.cwd(),makaioHome:process.env.MAKAIO_HOME??`${pe.homedir()}/.makaio`,os:process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`,arch:process.arch},env:{}}}function tn(e){return{...e,path:[...e.path]}}function nn(e){if(e===`station`||e===`delegate-agent`||e===`delegate-role`||e===`gate`)return e}function rn(e,t){let n=nn(t.nodeType);if(n===void 0||t.status!==`running`&&t.status!==`completed`&&t.status!==`failed`&&t.status!==`skipped`)return;let r=t.startedAt!==void 0&&t.completedAt!==void 0?Math.max(0,t.completedAt-t.startedAt):void 0;return{executionId:e,frameId:t.frameId,stepId:t.nodeId,stepType:n,status:t.status,...t.startedAt===void 0?{}:{startedAt:t.startedAt},...t.completedAt===void 0?{}:{completedAt:t.completedAt},...r===void 0?{}:{durationMs:r},...t.output===void 0?{}:{output:JSON.stringify(t.output)}}}var an=class e{executionId;workflowId;definition;execution;runtimeHandlers;bus;signal;frameRegistry;framePersistenceTasks=new Map;artifactBinding;constructor(e,t,n,r,i,a,o,s,c,l=en(),u={}){this.executionId=e,this.workflowId=t,this.definition=n,this.execution=r,this.runtimeHandlers=i,this.bus=a,this.signal=o,this.frameRegistry=s??new Map,this.artifactBinding=c,this.platformContext=l.context,this.env=l.env,this.suspensionStrategy=u.suspensionStrategy??`wait-in-process`,this.resumeFrames=u.resumeFrames}platformContext;env;suspensionStrategy;resumeFrames;withSignal(t){return new e(this.executionId,this.workflowId,this.definition,this.execution,this.runtimeHandlers,this.bus,t,this.frameRegistry,this.artifactBinding,{context:this.platformContext,env:this.env},{suspensionStrategy:this.suspensionStrategy,resumeFrames:this.resumeFrames})}buildExpressionContext(){return{inputs:this.execution.inputs,config:this.execution.config??{},trigger:this.execution.triggerPayload??{},frames:{},previousSteps:{}}}createFrame(e){let t=Dt(`frm`),n=[...e.path,t],r={frameId:t,nodeId:e.nodeId,nodeType:e.nodeType,path:n,parentFrameId:e.parentFrameId,status:`pending`,attempt:0,iteration:e.iteration,branchKey:e.branchKey};return this.frameRegistry.set(t,r),this.persistFrame(r).catch(()=>void 0),r}async persistFrame(e,t={}){let n=t.requireFrameStorage===!0||this.suspensionStrategy!==`wait-in-process`,r=tn(e),i=rn(this.executionId,r),a=(this.framePersistenceTasks.get(e.frameId)??Promise.resolve()).catch(()=>void 0).then(async()=>{n?await this.bus.request(F.setFrame,{executionId:this.executionId,frame:r}):await this.bus.requestOptional(F.setFrame,{executionId:this.executionId,frame:r}),i!==void 0&&await this.bus.requestOptional(F.setSpan,{span:i})}).catch(t=>{if(n)throw t;console.warn(`[RuntimeContext] Failed to persist frame ${e.frameId}:`,t)});this.framePersistenceTasks.set(e.frameId,a);try{await a}finally{this.framePersistenceTasks.get(e.frameId)===a&&this.framePersistenceTasks.delete(e.frameId)}}async updateFrame(e,t,n={}){let r=this.frameRegistry.get(e);if(!r)throw Error(`Frame not found: ${e}`);Object.assign(r,t),await this.persistFrame(r,n)}getFrame(e){return this.frameRegistry.get(e)}getFramesByNodeId(e){let t=[];for(let n of this.frameRegistry.values())n.nodeId===e&&t.push(n);return t.sort((e,t)=>(e.startedAt??0)-(t.startedAt??0))}async emitFrameStarted(e){try{await this.bus.emit(D.frame.started,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId,startedAt:e.startedAt})}catch(t){console.error(`[RuntimeContext] frame.started observer failed for ${e.frameId}:`,t)}}async emitFrameCompleted(e,t){try{await this.bus.emit(D.frame.completed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,output:e.output,duration:t,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.completed observer failed for ${e.frameId}:`,t)}}async emitFrameFailed(e,t,n){try{await this.bus.emit(D.frame.failed,{executionId:this.executionId,frameId:e.frameId,nodeId:e.nodeId,error:t,duration:n,completedAt:e.completedAt})}catch(t){console.error(`[RuntimeContext] frame.failed observer failed for ${e.frameId}:`,t)}}};function on(e){return{kind:`workflow-execution`,id:e,displayName:`Workflow Engine`}}function sn(e,t,n){return{inputs:n.inputs,config:n.config??{},trigger:n.triggerPayload,scope:n.scope,context:n.context,env:n.env,execution:{id:t.id,workflowId:t.workflowId,scope:t.scope},workflow:{id:e.id,name:e.name,scope:e.scope}}}function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ln(e){if(e!=null){if(cn(e)&&typeof e.kind==`string`&&typeof e.id==`string`)return{kind:e.kind,id:e.id};throw Error(`Artifact resolve expression must return an object with string kind and id fields.`)}}function un(e){if(e!==void 0){if(cn(e))return e;throw Error(`Artifact create expression must return an object.`)}}async function dn(e){let{bindingOptions:t,binding:n,existingArtifactRef:r,executionId:i,scope:a,initialData:o,bus:s}=e,c=null;if(r!==void 0){let e=await s.request(d.query,{kind:r.kind,ids:[r.id],currentOnly:!0});if(e.artifacts.length>0)c=e.artifacts[0];else return}else c=(await s.request(d.create,{kind:n.kind,schemaVersion:n.schemaVersion,scope:a??n.scope,data:o??{},relations:[],actor:on(i)})).artifact;return{current:c,schemaVersion:n.schemaVersion,statusPath:t.statusPath,zodSchema:t.schema}}async function fn(e){let{definition:t,execution:n,runContext:r,zodSchema:i,bus:a}=e,o=t.artifact;if(o===void 0)return;let s=sn(t,n,r),c=r.artifactRef??(o.resolve===void 0?void 0:ln(M(o.resolve,s))),l=c===void 0&&o.create!==void 0?un(M(o.create,s)):void 0,u=await dn({bindingOptions:{kind:o.kind,schemaVersion:o.schemaVersion,scope:o.scope,...o.resolve===void 0?{}:{resolve:o.resolve},...o.create===void 0?{}:{create:o.create},...o.statusPath===void 0?{}:{statusPath:o.statusPath},...i===void 0?{}:{schema:i}},binding:o,existingArtifactRef:c,executionId:n.id,scope:o.scope,initialData:l,bus:a});if(u===void 0)throw Error(`Workflow artifact binding could not be resolved for the configured artifact reference.`);return u}const pn=new WeakMap;function mn(e,t){let n=(pn.get(e)??Promise.resolve()).catch(()=>void 0).then(t);return pn.set(e,n.then(()=>void 0,()=>void 0)),n}function hn(e,t){switch(t.operation){case`set`:return t.data;case`merge`:return{...e,...t.data};case`append`:{let n={...e};for(let[r,i]of Object.entries(t.data)){let t=e[r];Array.isArray(t)&&Array.isArray(i)?n[r]=[...t,...i]:n[r]=i}return n}}}function gn(e,t,n){let[r,...i]=t;if(i.length===0)return{...e,[r]:n};let a=e[r]!==null&&typeof e[r]==`object`&&!Array.isArray(e[r])?e[r]:{};return{...e,[r]:gn(a,i,n)}}function _n(e,t,n){return gn(e,t.startsWith(`/`)?t.slice(1).split(`/`):t.split(`.`),n)}function vn(e,t,n){if(n===`set`||n===`functional`)return[];let r=[];for(let n of Object.keys(t))e[n]!==t[n]&&r.push(`/${n}`);return r}async function yn(e,t){if(typeof t==`function`)return{nextData:await t(Object.freeze({...e})),operationLabel:`functional`,changedPaths:[]};let n=hn(e,t),r=vn(e,n,t.operation);return{nextData:n,operationLabel:t.operation,changedPaths:r}}function bn(e){let{executionId:t,frameId:n,bindingState:r,bus:i}=e,a=Object.freeze({...r.current.data}),o=async e=>mn(r,async()=>{let a=r.current,{nextData:o,operationLabel:s,changedPaths:c}=await yn(a.data,e);if(r.zodSchema!==void 0){let e=r.zodSchema.safeParse(o);if(!e.success)throw Error(`Artifact data validation failed: ${e.error.message}`)}let l=await i.request(d.revise,{previous:{refClass:`artifact`,kind:a.kind,id:a.id,revision:a.revision},revision:{kind:a.kind,schemaVersion:r.schemaVersion,scope:a.scope,data:o,relations:a.relations,actor:on(t)}});r.current=l.artifact;let u=l.artifact.revision;return i.emit(ae.artifact.updated,{executionId:t,frameId:n,artifactRef:{kind:l.artifact.kind,id:l.artifact.id},paths:c,operation:s,revision:u}).catch(e=>{console.error(`[ArtifactContext] Failed to emit artifact.updated event:`,e)}),u});return{data:a,updateArtifact:o,updateStatus:async e=>{if(r.statusPath===void 0)throw Error(`updateStatus() called but no statusPath is configured on the artifact binding. Set statusPath in the .artifact() builder call to use updateStatus().`);let t=r.statusPath;return o(n=>_n(n,t,e))}}}function xn(e,t){return{async get(){return(await t.request(D.state.get,{executionId:e})).value},async update(n){let r=await t.request(D.state.get,{executionId:e}),i=structuredClone(r.value),a=await n(i),o=a===void 0?i:a,s=Ue(r.value,o);return(await t.request(D.state.patch,{executionId:e,expectedSequence:r.sequence,patch:s,nextValue:o})).value}}}async function Sn(e,t,n){if(t.signal.aborted)return{status:`cancelled`};let r=await t.bus.requestOptional(D.resolveRole,{roleId:e.roleId});if(!r.handled)return{status:`failed`,error:e.unresolvedRoleError};let i=N(e.prompt,R(n)),a=e.completion===void 0?r.data:{...r.data,completion:e.completion};return z({...e,task:i,resolvedConfig:a},t)}async function z(e,t){if(t.signal.aborted)return{status:`cancelled`};let n=await t.bus.requestOptional(S.spawn,{parentSessionId:t.execution.coordinatorSessionId??t.executionId,depth:1,config:Dn(e.task,e.resolvedConfig,e.outputSchema)});if(!n.handled)return{status:`failed`,error:e.unavailableRuntimeError};let r=await Cn(e,t,n.data.subagentId,{attempts:5}),i=await On(e,t,n.data.subagentId);return i===`aborted`?{status:`cancelled`}:(r||await Cn(e,t,n.data.subagentId,{attempts:1}),i.handled?t.signal.aborted||i.data.status===`cancelled`?{status:`cancelled`}:i.data.status===`completed`?{status:`completed`,output:i.data.result??null}:{status:`failed`,error:`${e.nodeLabel} '${e.nodeId}' subagent ${i.data.status}: ${i.data.error??`no result`}`}:{status:`failed`,error:e.unavailableAwaitError})}async function Cn(e,t,n,r){if(e.frameId===void 0)return!0;try{let i=await wn(t,n,r.attempts);return i===void 0?!1:(await t.bus.emit(D.frame.sessionLinked,{executionId:t.executionId,frameId:e.frameId,sessionId:i}),!0)}catch(t){return console.warn(`[workflow-engine] Failed to emit frame.sessionLinked for frame '${e.frameId}' and subagent '${n}'`,t),!1}}async function wn(e,t,n){for(let r=0;r<n;r+=1){if(e.signal?.aborted)return;let i=await Tn(e,t);if(i===void 0||!i.handled)return;if(i.data.childSessionId!==void 0)return i.data.childSessionId;if(r<n-1&&!await En(e.signal,20))return}}async function Tn(e,t){try{return await e.bus.requestOptional(S.getStatus,{subagentId:t},{timeout:25,signal:e.signal})}catch{return}}function En(e,t){return e.aborted?Promise.resolve(!1):new Promise(n=>{let r,i=t=>{r!==void 0&&(clearTimeout(r),r=void 0),e.removeEventListener(`abort`,a),n(t)},a=()=>i(!1);r=setTimeout(()=>i(!0),t),e.addEventListener(`abort`,a,{once:!0}),e.aborted&&i(!1)})}function Dn(e,t,n){return{task:e,adapterName:t.adapterName,...t.model===void 0?{}:{model:t.model},...t.reasoningEffort===void 0?{}:{reasoningEffort:t.reasoningEffort},...t.harnessId===void 0?{}:{harnessId:t.harnessId},...t.systemPrompt===void 0?{}:{systemPrompt:t.systemPrompt},...t.contextMode===void 0?{}:{contextMode:t.contextMode},...t.providerContext===void 0?{}:{providerContext:t.providerContext},...t.completion===void 0?{}:{completion:t.completion},...n===void 0?{}:{responseSchema:n}}}async function On(e,t,n){if(t.signal.aborted)return await B(e,t,n),`aborted`;let r=t.bus.requestOptional(S.await,{subagentId:n,...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}},{timeout:0});if(t.signal.aborted)return await B(e,t,n),`aborted`;let i,a=new Promise(e=>{i=()=>e(`aborted`),t.signal.addEventListener(`abort`,i,{once:!0})}),o=await Promise.race([r,a]);return i!==void 0&&t.signal.removeEventListener(`abort`,i),o===`aborted`&&await B(e,t,n),o}async function B(e,t,n){try{await t.bus.requestOptional(S.kill,{subagentId:n,reason:`Workflow execution '${t.executionId}' cancelled ${e.cancellationLabel} '${e.nodeId}'`})}catch(t){console.warn(`[workflow-engine] Best-effort subagent kill failed for '${n}' (${e.cancellationLabel} '${e.nodeId}')`,t)}}async function kn(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=$t(n.frames),a=t.runtimeHandlers.get(e.id);if(a===void 0)return An(e,t,n,r);let o=t.artifactBinding!==void 0&&r!==void 0?bn({executionId:t.executionId,frameId:r,bindingState:t.artifactBinding,bus:t.bus}):void 0,s=t.definition.state===void 0?void 0:xn(t.executionId,t.bus);async function c(n){if(r===void 0){console.warn(`[station-node] updateProgress called without frameId for node '${e.id}'; skipping emit`);return}let i=ie[`execution.progress`].parse({executionId:t.executionId,workflowId:t.workflowId,frameId:r,nodeId:e.id,progress:n,emittedAt:Date.now()});try{await t.bus.emit(D.execution.progress,i)}catch(t){console.error(`[station-node] execution.progress observer failed for ${e.id}:`,t)}}let l;try{l=await a({...t.platformContext,env:t.env,executionId:t.executionId,workflowId:t.workflowId,inputs:t.execution.inputs,config:t.execution.config??{},trigger:t.execution.triggerPayload??{},previousSteps:i,...n.item!==void 0&&{item:n.item},...n.index!==void 0&&{index:n.index},...n.previous!==void 0&&{previous:n.previous},signal:t.signal,...o!==void 0&&{artifact:o},...s!==void 0&&{state:s},bus:t.bus,updateProgress:c})}catch(e){return{status:`failed`,error:e instanceof Error?e.message:String(e)}}return{status:`completed`,output:l}}async function An(e,t,n,r){if(e.role===void 0)return{status:`failed`,error:`No handler registered for station node '${e.id}'`};let i=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return Sn({nodeId:e.id,nodeLabel:`Station node`,roleId:e.role,prompt:e.prompt,...i===void 0?{}:{outputSchema:i},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.completion===void 0?{}:{completion:e.completion},unresolvedRoleError:`No runtime handler registered for station node '${e.id}', and role '${e.role}' could not be resolved`,unavailableRuntimeError:`Subagent runtime is not available for station node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await station node '${e.id}'`,cancellationLabel:`station`,...r===void 0?{}:{frameId:r}},t,n)}async function jn(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=await t.bus.requestOptional(D.resolveAgent,{agentId:e.agentId});if(!i.handled)return{status:`failed`,error:`Agent '${e.agentId}' could not be resolved for delegate-agent node '${e.id}'`};if(t.signal.aborted)return{status:`cancelled`};let a=Wn(e,n);if(a.status===`failed`)return a;let o=e.outputSchema===void 0?void 0:{schema:e.outputSchema};return z({nodeId:e.id,nodeLabel:`Delegate-agent node`,task:a.task,resolvedConfig:i.data,...o===void 0?{}:{outputSchema:o},unavailableRuntimeError:`Subagent runtime is not available for delegate-agent node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-agent node '${e.id}'`,cancellationLabel:`delegate-agent`,...r===void 0?{}:{frameId:r}},t)}async function Mn(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=await t.bus.requestOptional(D.resolveRole,{roleId:e.role});if(!i.handled)return{status:`failed`,error:`Role '${e.role}' could not be resolved for delegate-role node '${e.id}'`};let a=e.outputSchema===void 0?void 0:{schema:e.outputSchema},o=N(e.prompt,R(n)),s=Bn(e,i.data),c={node:e,task:o,resolvedRole:s,...a===void 0?{}:{outputSchema:a},...r===void 0?{}:{frameId:r}};return Vn(s)?Nn(c,t):z({nodeId:e.id,nodeLabel:`Delegate-role node`,task:o,resolvedConfig:s,...a===void 0?{}:{outputSchema:a},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},unavailableRuntimeError:`Subagent runtime is not available for delegate-role node '${e.id}'`,unavailableAwaitError:`Subagent runtime cannot await delegate-role node '${e.id}'`,cancellationLabel:`delegate-role`,...r===void 0?{}:{frameId:r}},t)}async function Nn(e,t){let{node:n}=e,r=n.timeoutMs??3e5,i,a=Un(t.signal);try{let n=await Pn(e,t);return`status`in n?n:(i=n.sessionId,t.signal.aborted?{status:`cancelled`}:await Fn(e,t,{abortLink:a,childSessionId:i,timeoutMs:r}))}catch(e){if(t.signal.aborted)return{status:`cancelled`};let r=e instanceof Error?e.message:String(e);return{status:`failed`,error:`Delegate-role node '${n.id}' session turn failed: ${r}`}}finally{a.controller.abort(),a.cleanup(),i!==void 0&&await V(t,n.id,i)}}async function Pn(e,t){let n=await t.bus.requestOptional(b.create,{sessionId:Rn(t,e),parentSessionId:t.execution.coordinatorSessionId??t.executionId,branchKind:`subagent`,title:`Workflow delegate-role '${e.node.id}'`});if(!n.handled)return{status:`failed`,error:`Session runtime is not available for delegate-role node '${e.node.id}'`};let r=n.data.sessionId;return await Hn(e,t,r),(await t.bus.requestOptional(b.agent.attach,{sessionId:r,agent:zn(e.resolvedRole),role:`lead`},{signal:t.signal}).catch(async n=>{throw await V(t,e.node.id,r),n})).handled?{sessionId:r}:(await V(t,e.node.id,r),{status:`failed`,error:`Session runtime cannot attach delegate-role node '${e.node.id}'`})}async function Fn(e,t,n){let r=t.bus.once(u.complete,{timeoutMs:n.timeoutMs,filter:{sessionId:n.childSessionId},signal:n.abortLink.controller.signal});r.catch(()=>void 0);let i=await In(e,t,n);if(`status`in i)return i;let a=await Ln(e,t,n,i.turnId);if(a.status===`failed`)return a;let o=await r;return t.signal.aborted?{status:`cancelled`}:o.payload.outcome===`error`?{status:`failed`,error:`Delegate-role node '${e.node.id}' agent error: ${o.payload.error??`no result`}`}:{status:`completed`,output:o.payload.message??null}}async function In(e,t,n){let r=await t.bus.requestOptional(b.sendMessage,{sessionId:n.childSessionId,message:e.task,...e.outputSchema===void 0?{}:{responseSchema:e.outputSchema},source:`system`},{signal:t.signal});return r.handled?{turnId:r.data.turnId}:(n.abortLink.controller.abort(),{status:`failed`,error:`Session runtime cannot send delegate-role node '${e.node.id}'`})}async function Ln(e,t,n,r){let i=await t.bus.requestOptional(b.turn.await,{sessionId:n.childSessionId,turnId:r,timeoutMs:n.timeoutMs},{timeout:0,signal:t.signal});return i.handled?i.data.completion.success?{status:`completed`}:{status:`failed`,error:`Delegate-role node '${e.node.id}' session turn failed: ${i.data.completion.error??`no result`}`}:(n.abortLink.controller.abort(),{status:`failed`,error:`Session runtime cannot await delegate-role node '${e.node.id}'`})}function Rn(e,t){return`session-workflow-${e.executionId}-${t.frameId??t.node.id}`}function zn(e){return{kind:`adapter`,adapterName:e.adapterName,...e.model===void 0?{}:{model:e.model},...e.reasoningEffort===void 0?{}:{reasoningEffort:e.reasoningEffort},...e.systemPrompt===void 0?{}:{systemPrompt:e.systemPrompt},...e.providerContext===void 0?{}:{providerConfigId:e.providerContext.providerConfigId}}}function Bn(e,t){return e.completion===void 0?t:{...t,completion:e.completion}}function Vn(e){return e.completion===`turn`&&e.harnessId===void 0&&e.contextMode===void 0}async function Hn(e,t,n){if(e.frameId!==void 0)try{await t.bus.emit(D.frame.sessionLinked,{executionId:t.executionId,frameId:e.frameId,sessionId:n})}catch(t){console.warn(`[workflow-engine] Failed to emit frame.sessionLinked for frame '${e.frameId}' and session '${n}'`,t)}}async function V(e,t,n){try{await e.bus.requestOptional(b.close,{sessionId:n})}catch(e){console.warn(`[workflow-engine] Failed to close delegate-role session '${n}' for node '${t}'`,e)}}function Un(e){let t=new AbortController;if(e.aborted)return t.abort(),{controller:t,cleanup:()=>void 0};let n=()=>t.abort();return e.addEventListener(`abort`,n,{once:!0}),{controller:t,cleanup:()=>e.removeEventListener(`abort`,n)}}function Wn(e,t){try{let n=R(t);return{status:`completed`,task:Gn(e.inputExpression===void 0?n:M(e.inputExpression,n))}}catch(t){let n=t instanceof Error?t.message:String(t);return{status:`failed`,error:`delegate-agent node '${e.id}': input expression evaluation failed: ${n}`}}}function Gn(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Kn(e,t,n,r){try{let i=M(n,R(r));return Array.isArray(i)?i:{status:`failed`,error:`${t} node '${e}': collection expression did not resolve to an array (got ${typeof i})`}}catch(n){return{status:`failed`,error:`${t} node '${e}': collection expression evaluation failed: ${n instanceof Error?n.message:String(n)}`}}}function qn(e,t,n){for(let r of[...e.nodes].reverse()){let e=n.getFramesByNodeId(r.id);for(let n of e)if(n.parentFrameId===t&&n.status===`completed`)return n.output}}function Jn(e,t,n){return qn(e.body,t,n)}function Yn(e){if(e.length===0)return;let t=new Map,n=new Map;for(let r of e){n.set(r.frameId,r);let e=t.get(r.nodeId)??[];e.push(r),t.set(r.nodeId,e)}return{byNodeId:t,byFrameId:n}}const Xn=new Set([`completed`,`skipped`,`waiting`]);function H(e,t,n){let r=e?.byNodeId.get(t)??[],i=n.statuses??Xn;return r.find(e=>e.parentFrameId===n.parentFrameId&&e.branchKey===n.branchKey&&e.iteration===n.iteration&&i.has(e.status))}function U(e,t,n){let r={...e.frames,[t]:n};return{...e,frames:r,previousSteps:$t(r),output:n.status===`completed`?n.output:e.output}}function W(e,t){if(typeof AbortSignal.any==`function`)return AbortSignal.any([e,t]);let n=new AbortController,r=()=>n.abort();return e.addEventListener(`abort`,r,{once:!0}),t.addEventListener(`abort`,r,{once:!0}),n.signal}const Zn=new Set([`completed`,`running`]);function Qn(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function $n(e,t,n,r,i,a,o=`all-settled`){if(t.signal.aborted)return{status:`cancelled`};let s=Object.entries(e.branches);if(s.length===0)return{status:`completed`,output:G({},o)};let c=new AbortController,l=new AbortController,u=t.suspensionStrategy!==`wait-in-process`,d=o===`fail-fast`?W(c.signal,l.signal):u?l.signal:void 0,f=d===void 0?t.signal:W(t.signal,d),p=f===t.signal?t:t.withSignal(f),m=s.map(([s,c])=>er(s,c,e,p,n,r,i,a,{outerSignal:t.signal,pauseSignal:o===`fail-fast`||u?l.signal:void 0}));if(o===`all-settled`){let e=await Promise.all(u?m.map(e=>e.then(e=>(e.status===`paused`&&l.abort(),e))):m),t=e.find(e=>e.status===`paused`);return t===void 0?{status:`completed`,output:G(nr(s,e),o)}:t}let h=await tr(s,m,c,l);return h.type===`cancelled`?{status:`cancelled`}:h.type===`paused`?h.outcome:h.type===`failed`?{status:`failed`,error:h.error}:{status:`completed`,output:G(nr(s,h.outcomes),o)}}async function er(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l=H(r.resumeFrames,n.id,{parentFrameId:o,branchKey:e,statuses:Zn});if(l?.status===`completed`)return{status:`completed`,...l.output===void 0?{}:{output:l.output}};let u=l??r.createFrame({nodeId:n.id,nodeType:`parallel`,path:s,parentFrameId:o,branchKey:e});if(r.signal.aborted)return Qn(u,c)||await $(u,r),{status:`cancelled`};l===void 0&&await X(u,r);let d;try{d=await a(t,r,i,u.frameId,u.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(u,r,t),{status:`failed`,error:t}}switch(d.status){case`completed`:{let e=qn(t,u.frameId,r);return await Z(u,r,e),{status:`completed`,output:e}}case`skipped`:return await Z(u,r),{status:`completed`};case`cancelled`:return Qn(u,c)||await $(u,r),{status:`cancelled`};case`paused`:return d;case`failed`:return await Q(u,r,d.error),{status:`failed`,error:d.error}}}async function tr(e,t,n,r){let i,a,o=t.map(e=>e.then(e=>(e.status===`failed`&&i===void 0?(i=e.error,n.abort()):e.status===`paused`&&a===void 0&&(a=e,r.abort()),e),e=>{let t=e instanceof Error?e.message:String(e);return i===void 0&&(i=t,n.abort()),{status:`failed`,error:t}})),s=await Promise.all(o);return a===void 0?s.some(e=>e.status===`cancelled`)&&i===void 0?{type:`cancelled`}:i===void 0?{type:`completed`,outcomes:s}:{type:`failed`,error:i}:{type:`paused`,outcome:a}}function G(e,t){return{mode:t,branches:e}}function nr(e,t){let n={};for(let r=0;r<e.length;r++){let[i]=e[r],a=t[r];n[i]=rr(a)}return n}function rr(e){switch(e.status){case`completed`:return{status:`fulfilled`,...e.output===void 0?{}:{value:e.output}};case`skipped`:return{status:`fulfilled`,value:null};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:e.pausedAtGateId,pausedAtFrameId:e.pausedAtFrameId};case`failed`:return{status:`rejected`,reason:e.error}}}const ir=new He.default({allErrors:!0,strict:!1});function K(e,t){if(t===void 0)return{status:`ok`};try{return{status:`ok`,validator:ir.compile(t)}}catch(t){return{status:`failed`,error:`Gate '${e}' has an invalid resumeSchema: ${t instanceof Error?t.message:String(t)}`}}}function ar(e,t){return e===void 0||e(t)?{valid:!0}:{valid:!1,error:sr(e.errors??[])}}function or(e,t,n){let r=K(e,t);return r.status===`failed`?{valid:!1,error:r.error}:ar(r.validator,n)}function sr(e){return e.length===0?`schema validation failed`:e.map(e=>`${e.instancePath.length>0?e.instancePath:`/`} ${e.message??`is invalid`}`).join(`; `)}const cr={action:`approve`,source:`timeout`};function lr(e){return e===void 0?{}:{reason:e}}async function ur(e,t,n,r){let i=()=>{t.value&&(t.value=!1,e.reject(`cancelled`))};n.addEventListener(`abort`,i,{once:!0}),n.aborted&&i();let a=[e.promise],o;if(r!==null){let e=mr();o=setTimeout(()=>{t.value&&(t.value=!1,n.removeEventListener(`abort`,i),e.reject(`timed-out`))},r),a.push(e.promise)}try{let e=await Promise.race(a);return n.removeEventListener(`abort`,i),o!==void 0&&clearTimeout(o),{action:e.action,resumeData:e.resumeData,timedOut:!1,wasCancelled:!1,reason:e.reason}}catch(e){return o!==void 0&&clearTimeout(o),n.removeEventListener(`abort`,i),e===`timed-out`?{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1}:{action:`reject`,resumeData:null,timedOut:!1,wasCancelled:!0}}}async function dr(e,t,n,r,i,a){let o={required:e.suspensionStrategy!==`wait-in-process`};if(a.timedOut){let a=Date.now();if(r.autoAction===`approve`){let s=ar(i,cr);return s.valid?(await q(e,{...r,status:`resumed`,resumeData:cr,resolvedAt:a},o),await J(e,t.id,n,{action:`approve`,source:`timeout`}),{status:`completed`,output:{resumeData:cr}}):(await q(e,{...r,status:`timed-out`,resolvedAt:a},o),await J(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' auto-approve timeout resume data does not match resumeSchema: ${s.error}`})}return await q(e,{...r,status:`timed-out`,resolvedAt:a},o),await J(e,t.id,n,{action:`reject`,source:`timeout`}),{status:`failed`,error:`Gate '${t.id}' timed out after ${String(r.timeoutMs)}ms and auto-rejected`}}if(a.wasCancelled||e.signal.aborted)return await q(e,{...r,status:`cancelled`,resolvedAt:Date.now()},o),await J(e,t.id,n,{source:`cancelled`}),{status:`cancelled`};let s=Date.now();await q(e,{...r,status:a.action===`reject`?`rejected`:`resumed`,resumeData:a.resumeData,...lr(a.reason),resolvedAt:s},o);try{await e.bus.emit(D.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:a.resumeData}),await J(e,t.id,n,{action:a.action,source:`user`,...lr(a.reason)})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return{status:`completed`,output:{resumeData:a.resumeData}}}async function fr(e,t,n,r){if(t.signal.aborted)return{status:`cancelled`};let i=e.resumeSchema??{};if(t.suspensionStrategy!==`wait-in-process`){let n=await _r(t,e,r);if(n!==void 0)return n}let a=K(e.id,e.resumeSchema);return a.status===`failed`?{status:`failed`,error:a.error}:pr(t,e,n,r,i,a.validator)}async function pr(e,t,n,r,i,a){let o=N(t.prompt,R(n)),s={executionId:e.executionId,nodeId:t.id,frameId:r,schema:i,prompt:o,status:`waiting`,autoAction:t.autoAction,timeoutMs:t.timeoutMs,createdAt:Date.now()},c=e.suspensionStrategy!==`wait-in-process`;if(await q(e,s,{required:c}),await e.updateFrame(r,{status:`waiting`},{requireFrameStorage:c}),c)return await hr(e,t,r,i,o,s.createdAt),{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:r};let u={value:!0},d=mr(),f=e.bus.on(D.gate.respond,async n=>{let{executionId:i,gateId:o,frameId:s,action:c,resumeData:f,reason:p}=n.payload;if(i!==e.executionId||o!==t.id||s!==void 0&&s!==r){try{await n.next()}catch(e){if(e instanceof l)n.setResult({accepted:!1});else throw e}return}if(!u.value){n.setResult({accepted:!1});return}if(!ar(a,f).valid){n.setResult({accepted:!1});return}u.value=!1,n.setResult({accepted:!0}),d.resolve({action:c,resumeData:f,reason:p})});await hr(e,t,r,i,o,s.createdAt);let p=await ur(d,u,e.signal,t.timeoutMs);return f(),dr(e,t,r,s,a,p)}function mr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function hr(e,t,n,r,i,a){try{await e.bus.emit(D.gate.suspended,{executionId:e.executionId,frameId:n,nodeId:t.id,schema:r,prompt:i,...t.title!==void 0&&{title:t.title},autoAction:t.autoAction,timeoutMs:t.timeoutMs,openedAt:a})}catch(e){console.error(`[GateNode] gate.suspended emit failed for '${t.id}':`,e)}}async function gr(e,t,n){if(e.suspensionStrategy!==`wait-in-process`)return(await e.bus.request(F.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n})).gate;let r=await e.bus.requestOptional(F.getGateInstance,{executionId:e.executionId,nodeId:t,frameId:n});return r.handled?r.data.gate:null}async function _r(e,t,n){let r=await gr(e,t.id,n);if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData!==void 0){let i=or(t.id,r.schema,r.resumeData);if(!i.valid)return{status:`failed`,error:`Gate '${t.id}' persisted resumeData is invalid: ${i.error}`};try{await e.bus.emit(D.gate.resumed,{executionId:e.executionId,frameId:n,nodeId:t.id,resumeData:r.resumeData})}catch(e){console.error(`[GateNode] gate.resumed emit failed for '${t.id}':`,e)}return await J(e,t.id,n,{action:r.status===`rejected`?`reject`:`approve`,source:`user`,...lr(r.reason)}),{status:`completed`,output:{resumeData:r.resumeData}}}if(r?.status===`waiting`){if(r.timeoutMs!==null&&Date.now()>=r.createdAt+r.timeoutMs){let i=K(t.id,r.schema);return i.status===`failed`?{status:`failed`,error:i.error}:dr(e,t,n,r,i.validator,{action:`reject`,resumeData:null,timedOut:!0,wasCancelled:!1})}return{status:`paused`,pausedAtGateId:t.id,pausedAtFrameId:n}}if((r?.status===`resumed`||r?.status===`rejected`)&&r.resumeData===void 0)return{status:`failed`,error:`Gate '${t.id}' has status '${r.status}' but resumeData is missing — cannot reconstruct output`};if(r!==null)return{status:`failed`,error:`Gate '${t.id}' cannot resume from status '${r.status}'`}}async function q(e,t,n={}){try{n.required===!0?await e.bus.request(F.setGateInstance,{gate:t}):await e.bus.requestOptional(F.setGateInstance,{gate:t})}catch(e){if(n.required===!0)throw e;console.warn(`[GateNode] Failed to upsert gate instance for '${t.nodeId}':`,e)}}async function J(e,t,n,r){try{await e.bus.emit(D.gate.resolved,{executionId:e.executionId,stepId:t,stepType:`gate`,frameId:n,...r})}catch(e){console.error(`[GateNode] gate.resolved emit failed for '${t}':`,e)}}function Y(e){return{status:`fulfilled`,...e===void 0?{}:{value:e}}}const vr=new Set([`completed`,`running`]);function yr(e,t){return e.status===`running`&&t.pauseSignal?.aborted===!0&&!t.outerSignal.aborted}async function br(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=Kn(e.id,`iterate`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:wr([])};let c=await xr(s,e,t,n,r,i,a,e.concurrency!==void 0&&e.concurrency>0?e.concurrency:0);if(t.signal.aborted&&c.every(e=>e.status===`cancelled`))return{status:`cancelled`};let l=c.find(e=>e.status===`paused`);return l===void 0?{status:`completed`,output:wr(c)}:{status:`paused`,pausedAtGateId:l.pausedAtGateId,pausedAtFrameId:l.pausedAtFrameId}}async function xr(e,t,n,r,i,a,o,s){let c=new AbortController,l=n.suspensionStrategy!==`wait-in-process`,u=l?W(n.signal,c.signal):n.signal,d=u===n.signal?n:n.withSignal(u),f={outerSignal:n.signal,...l?{pauseSignal:c.signal}:{}};if(s===0){let n=e.map((e,n)=>Cr(e,n,t,d,r,i,a,o,f));return Promise.all(l?n.map(e=>Sr(e,c)):n)}let p=Array(e.length);for(let n=0;n<e.length;n+=s){if(d.signal.aborted){for(let t=n;t<e.length;t++)p[t]={status:`cancelled`};break}let u=Math.min(n+s,e.length),m=[];for(let s=n;s<u;s++)m.push(Cr(e[s],s,t,d,r,i,a,o,f));let h=await Promise.all(l?m.map(e=>Sr(e,c)):m);for(let e=0;e<h.length;e++)p[n+e]=h[e];if(h.some(e=>e.status===`paused`)){for(let t=u;t<e.length;t++)p[t]={status:`cancelled`};break}}return p}function Sr(e,t){return e.then(e=>(e.status===`paused`&&t.abort(),e))}async function Cr(e,t,n,r,i,a,o,s,c){if(r.signal.aborted)return{status:`cancelled`};let l={...i,item:e,index:t},u=H(r.resumeFrames,n.id,{parentFrameId:o,iteration:t,statuses:vr});if(u?.status===`completed`)return Y(u.output);let d=u??r.createFrame({nodeId:n.id,nodeType:`iterate`,path:s,parentFrameId:o,iteration:t});if(r.signal.aborted)return yr(d,c)||await $(d,r),{status:`cancelled`};u===void 0&&await X(d,r);let f;try{f=await a(n.body,r,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(d,r,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=Jn(n,d.frameId,r);return await Z(d,r,e),Y(e)}case`skipped`:return await Z(d,r),Y();case`cancelled`:return yr(d,c)||await $(d,r),{status:`cancelled`};case`paused`:return f;case`failed`:return await Q(d,r,f.error),{status:`rejected`,reason:f.error}}}function wr(e){return{items:e}}const Tr=new Set([`completed`,`running`]);async function Er(e,t,n,r,i,a){if(t.signal.aborted)return{status:`cancelled`};let o=Kn(e.id,`iterate-chain`,e.collection,n);if(!Array.isArray(o))return o;let s=o;if(s.length===0)return{status:`completed`,output:Or([])};let c=[],l;for(let o=0;o<s.length;o++){if(t.signal.aborted)return{status:`cancelled`};let u=s[o],d=await Dr(u,o,l,e,t,n,r,i,a);switch(c.push(d),d.status){case`fulfilled`:l=d.value;break;case`rejected`:return{status:`failed`,error:d.reason};case`cancelled`:return{status:`cancelled`};case`paused`:return{status:`paused`,pausedAtGateId:d.pausedAtGateId,pausedAtFrameId:d.pausedAtFrameId}}}return{status:`completed`,output:Or(c)}}async function Dr(e,t,n,r,i,a,o,s,c){if(i.signal.aborted)return{status:`cancelled`};let l={...a,item:e,index:t,...n!==void 0&&{previous:n}},u=H(i.resumeFrames,r.id,{parentFrameId:s,iteration:t,statuses:Tr});if(u?.status===`completed`)return Y(u.output);let d=u??i.createFrame({nodeId:r.id,nodeType:`iterate-chain`,path:c,parentFrameId:s,iteration:t});if(i.signal.aborted)return await $(d,i),{status:`cancelled`};u===void 0&&await X(d,i);let f;try{f=await o(r.body,i,l,d.frameId,d.path)}catch(e){let t=e instanceof Error?e.message:String(e);return await Q(d,i,t),{status:`rejected`,reason:t}}switch(f.status){case`completed`:{let e=Jn(r,d.frameId,i);return await Z(d,i,e),Y(e)}case`skipped`:return await Z(d,i),Y();case`cancelled`:return await $(d,i),{status:`cancelled`};case`paused`:return f;case`failed`:return await Q(d,i,f.error),{status:`rejected`,reason:f.error}}}function Or(e){return{items:e}}async function X(e,t){e.status=`running`,e.startedAt=Date.now(),await t.persistFrame(e),await t.emitFrameStarted(e)}async function Z(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`completed`,e.output=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameCompleted(e,i)}async function Q(e,t,n){let r=Date.now(),i=e.startedAt===void 0?void 0:Math.max(0,r-e.startedAt);e.status=`failed`,e.error=n,e.completedAt=r,await t.persistFrame(e),await t.emitFrameFailed(e,n,i)}async function kr(e,t){e.status=`skipped`,e.completedAt=Date.now(),await t.persistFrame(e)}async function $(e,t){e.status=`cancelled`,e.completedAt=Date.now(),await t.persistFrame(e)}function Ar(e,t){return!!M(e,R(t))}async function jr(e,t,n,r,i,a=[]){if(t.signal.aborted)return{status:`cancelled`};switch(e.type){case`sequence`:return r(e,t,n,i,a);case`station`:return kn(e,t,n,i);case`delegate-agent`:return jn(e,t,n,i);case`delegate-role`:return Mn(e,t,n,i);case`parallel`:return $n(e,t,n,r,i??``,a,e.mode??`all-settled`);case`gate`:return fr(e,t,n,i??``);case`iterate`:return br(e,t,n,r,i??``,a);case`iterate-chain`:return Er(e,t,n,r,i??``,a);default:return{status:`failed`,error:`Unknown node type: ${String(e.type)}`}}}const Mr=new Set([`completed`,`skipped`,`waiting`,`running`]);function Nr(e){return e.type===`parallel`||e.type===`iterate`||e.type===`iterate-chain`}function Pr(e,t,n){return H(e.resumeFrames,t.id,{parentFrameId:n,...Nr(t)?{statuses:Mr}:{}})}function Fr(e,t,n){if(n?.status===`completed`)return U(e,t.id,{status:`completed`,...n.output===void 0?{}:{output:n.output}});if(n?.status===`skipped`)return U(e,t.id,{status:`skipped`})}async function Ir(e,t,n,r,i,a,o){try{return{result:Ar(e,i)}}catch(e){let i=e instanceof Error?e.message:String(e);return await Q(r.createFrame({nodeId:n.id,nodeType:n.type,path:a,parentFrameId:o}),r,`'${t}' condition evaluation failed: ${i}`),{status:`failed`,error:`'${t}' condition evaluation failed for '${n.id}': ${i}`}}}async function Lr(e,t,n,r,i,a){let o=a??t.createFrame({nodeId:e.id,nodeType:e.type,path:r,parentFrameId:i});if(t.signal.aborted)return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};a===void 0&&await X(o,t);let s;try{s=await jr(e,t,n,Rr,o.frameId,o.path)}catch(e){let r=e instanceof Error?e.message:String(e);return await Q(o,t,r),{updatedCtx:n,outcome:{status:`failed`,error:r}}}switch(s.status){case`completed`:return await Z(o,t,s.output),{updatedCtx:U(n,e.id,{status:`completed`,output:s.output})};case`skipped`:return await kr(o,t),{updatedCtx:U(n,e.id,{status:`skipped`})};case`cancelled`:return await $(o,t),{updatedCtx:n,outcome:{status:`cancelled`}};case`paused`:return{updatedCtx:n,outcome:s};case`failed`:return await Q(o,t,s.error),{updatedCtx:n,outcome:{status:`failed`,error:s.error}}}}async function Rr(e,t,n,r,i=[]){let a=n;for(let n of e.nodes){if(t.signal.aborted)return{status:`cancelled`};let e=Pr(t,n,r),o=Fr(a,n,e);if(o!==void 0){a=o;continue}if(n.when!==void 0){let e=await Ir(n.when,`when`,n,t,a,i,r);if(`status`in e)return e;if(!e.result){await kr(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=U(a,n.id,{status:`skipped`});continue}}if(n.skip!==void 0){let e=await Ir(n.skip,`skip`,n,t,a,i,r);if(`status`in e)return e;if(e.result){await kr(t.createFrame({nodeId:n.id,nodeType:n.type,path:i,parentFrameId:r}),t),a=U(a,n.id,{status:`skipped`});continue}}let s=e?.status===`waiting`&&n.type===`gate`||e?.status===`running`&&Nr(n)?e:void 0,{updatedCtx:c,outcome:l}=await Lr(n,t,a,i,r,s);if(a=c,l!==void 0)return l}return{status:`completed`}}export{Re as A,Me as B,ye as C,Le as D,we as E,De as F,ke as G,Ae as H,Ee as I,Oe as K,Ce as L,P as M,xe as N,Ie as O,be as P,Se as R,he as S,Te as T,Fe as U,je as V,Pe as W,Ze as _,an as a,F as b,Qt as c,Tt as d,ht as f,ct as g,dt as h,fn as i,_e as j,ze as k,Lt as l,I as m,or as n,Rt as o,L as p,D as q,Yn as r,Xt as s,Rr as t,Mt as u,Ue as v,ve as w,ge as x,Ve as y,Ne as z};
|
|
@@ -251,7 +251,7 @@ declare const sessions: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
|
|
|
251
251
|
tableName: "sessions";
|
|
252
252
|
dataType: "string";
|
|
253
253
|
columnType: "SQLiteText";
|
|
254
|
-
data: "closed" | "
|
|
254
|
+
data: "closed" | "discovered" | "active" | "archived";
|
|
255
255
|
driverParam: string;
|
|
256
256
|
notNull: true;
|
|
257
257
|
hasDefault: false;
|
|
@@ -365,7 +365,7 @@ declare const sessions: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
|
|
|
365
365
|
tableName: "sessions";
|
|
366
366
|
dataType: "string";
|
|
367
367
|
columnType: "SQLiteText";
|
|
368
|
-
data: "
|
|
368
|
+
data: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside";
|
|
369
369
|
driverParam: string;
|
|
370
370
|
notNull: false;
|
|
371
371
|
hasDefault: false;
|
|
@@ -1104,7 +1104,7 @@ declare const agents: _$drizzle_orm_sqlite_core0.SQLiteTableWithColumns<{
|
|
|
1104
1104
|
tableName: "agents";
|
|
1105
1105
|
dataType: "string";
|
|
1106
1106
|
columnType: "SQLiteText";
|
|
1107
|
-
data: "
|
|
1107
|
+
data: "idle" | "active" | "dead" | "disposed";
|
|
1108
1108
|
driverParam: string;
|
|
1109
1109
|
notNull: true;
|
|
1110
1110
|
hasDefault: false;
|
|
@@ -44,10 +44,10 @@ type SubagentTemplateSummary = z.infer<typeof SubagentTemplateSummarySchema>;
|
|
|
44
44
|
*/
|
|
45
45
|
declare const SubagentTemplateCreateSchema: z.ZodObject<{
|
|
46
46
|
name: z.ZodString;
|
|
47
|
-
adapterName: z.ZodString;
|
|
48
47
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
-
|
|
48
|
+
adapterName: z.ZodString;
|
|
50
49
|
providerConfigId: z.ZodOptional<z.ZodString>;
|
|
50
|
+
model: z.ZodOptional<z.ZodString>;
|
|
51
51
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
52
52
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
53
|
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -129,10 +129,10 @@ declare const SubagentTemplateSettingsSchemas: {
|
|
|
129
129
|
create: {
|
|
130
130
|
request: z.ZodObject<{
|
|
131
131
|
name: z.ZodString;
|
|
132
|
-
adapterName: z.ZodString;
|
|
133
132
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
134
|
-
|
|
133
|
+
adapterName: z.ZodString;
|
|
135
134
|
providerConfigId: z.ZodOptional<z.ZodString>;
|
|
135
|
+
model: z.ZodOptional<z.ZodString>;
|
|
136
136
|
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
137
137
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
138
|
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -13,9 +13,9 @@ declare const PreferenceKeySchema: z.ZodObject<{
|
|
|
13
13
|
scope: z.ZodString;
|
|
14
14
|
context: z.ZodOptional<z.ZodString>;
|
|
15
15
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
mobile: "mobile";
|
|
16
17
|
desktop: "desktop";
|
|
17
18
|
tablet: "tablet";
|
|
18
|
-
mobile: "mobile";
|
|
19
19
|
}>>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
type PreferenceKey = z.infer<typeof PreferenceKeySchema>;
|
|
@@ -33,9 +33,9 @@ declare const PreferenceItemSchema: z.ZodObject<{
|
|
|
33
33
|
scope: z.ZodString;
|
|
34
34
|
context: z.ZodOptional<z.ZodString>;
|
|
35
35
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
mobile: "mobile";
|
|
36
37
|
desktop: "desktop";
|
|
37
38
|
tablet: "tablet";
|
|
38
|
-
mobile: "mobile";
|
|
39
39
|
}>>;
|
|
40
40
|
}, z.core.$strip>;
|
|
41
41
|
category: z.ZodString;
|
|
@@ -67,9 +67,9 @@ declare const PreferencesSchemas: {
|
|
|
67
67
|
scope: z.ZodString;
|
|
68
68
|
context: z.ZodOptional<z.ZodString>;
|
|
69
69
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
mobile: "mobile";
|
|
70
71
|
desktop: "desktop";
|
|
71
72
|
tablet: "tablet";
|
|
72
|
-
mobile: "mobile";
|
|
73
73
|
}>>;
|
|
74
74
|
}, z.core.$strip>;
|
|
75
75
|
category: z.ZodString;
|
|
@@ -94,9 +94,9 @@ declare const PreferencesSchemas: {
|
|
|
94
94
|
scope: z.ZodString;
|
|
95
95
|
context: z.ZodOptional<z.ZodString>;
|
|
96
96
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
97
|
+
mobile: "mobile";
|
|
97
98
|
desktop: "desktop";
|
|
98
99
|
tablet: "tablet";
|
|
99
|
-
mobile: "mobile";
|
|
100
100
|
}>>;
|
|
101
101
|
}, z.core.$strip>;
|
|
102
102
|
category: z.ZodString;
|
|
@@ -122,9 +122,9 @@ declare const PreferencesSchemas: {
|
|
|
122
122
|
scope: z.ZodString;
|
|
123
123
|
context: z.ZodOptional<z.ZodString>;
|
|
124
124
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
mobile: "mobile";
|
|
125
126
|
desktop: "desktop";
|
|
126
127
|
tablet: "tablet";
|
|
127
|
-
mobile: "mobile";
|
|
128
128
|
}>>;
|
|
129
129
|
}, z.core.$strip>;
|
|
130
130
|
category: z.ZodString;
|
|
@@ -149,9 +149,9 @@ declare const PreferencesSchemas: {
|
|
|
149
149
|
scope: z.ZodOptional<z.ZodString>;
|
|
150
150
|
context: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
151
151
|
viewport: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
152
|
+
mobile: "mobile";
|
|
152
153
|
desktop: "desktop";
|
|
153
154
|
tablet: "tablet";
|
|
154
|
-
mobile: "mobile";
|
|
155
155
|
}>>>;
|
|
156
156
|
}, z.core.$strip>>;
|
|
157
157
|
category: z.ZodOptional<z.ZodString>;
|
|
@@ -166,9 +166,9 @@ declare const PreferencesSchemas: {
|
|
|
166
166
|
scope: z.ZodString;
|
|
167
167
|
context: z.ZodOptional<z.ZodString>;
|
|
168
168
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
169
|
+
mobile: "mobile";
|
|
169
170
|
desktop: "desktop";
|
|
170
171
|
tablet: "tablet";
|
|
171
|
-
mobile: "mobile";
|
|
172
172
|
}>>;
|
|
173
173
|
}, z.core.$strip>;
|
|
174
174
|
category: z.ZodString;
|
|
@@ -64,9 +64,9 @@ declare const SurfaceBindingRegistrationSchema: z.ZodObject<{
|
|
|
64
64
|
template: z.ZodString;
|
|
65
65
|
}, z.core.$strip>], "kind">;
|
|
66
66
|
appliesTo: z.ZodArray<z.ZodEnum<{
|
|
67
|
-
artifact: "artifact";
|
|
68
67
|
surface: "surface";
|
|
69
68
|
workpiece: "workpiece";
|
|
69
|
+
artifact: "artifact";
|
|
70
70
|
}>>;
|
|
71
71
|
valueMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
72
72
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -108,8 +108,8 @@ declare const ArtifactProjectionPolicySchema: z.ZodObject<{
|
|
|
108
108
|
comment: "comment";
|
|
109
109
|
}>;
|
|
110
110
|
defaultRole: z.ZodOptional<z.ZodEnum<{
|
|
111
|
-
artifact: "artifact";
|
|
112
111
|
workpiece: "workpiece";
|
|
112
|
+
artifact: "artifact";
|
|
113
113
|
}>>;
|
|
114
114
|
semanticEvents: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
115
115
|
created: "created";
|
|
@@ -141,8 +141,8 @@ declare const ArtifactMaterializationRefSchema: z.ZodObject<{
|
|
|
141
141
|
externalId: z.ZodString;
|
|
142
142
|
externalUrl: z.ZodOptional<z.ZodString>;
|
|
143
143
|
surfaceRole: z.ZodEnum<{
|
|
144
|
-
artifact: "artifact";
|
|
145
144
|
workpiece: "workpiece";
|
|
145
|
+
artifact: "artifact";
|
|
146
146
|
}>;
|
|
147
147
|
lastSyncedRevision: z.ZodOptional<z.ZodString>;
|
|
148
148
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -10,8 +10,8 @@ import { UiNavigationLevel } from "@makaio/framework/contracts";
|
|
|
10
10
|
*/
|
|
11
11
|
declare const SurfaceIdSchema: z.ZodEnum<{
|
|
12
12
|
tray: "tray";
|
|
13
|
-
mobile: "mobile";
|
|
14
13
|
web: "web";
|
|
14
|
+
mobile: "mobile";
|
|
15
15
|
electron: "electron";
|
|
16
16
|
electrobun: "electrobun";
|
|
17
17
|
}>;
|
|
@@ -101,8 +101,8 @@ declare const PageMetadataSchema: z.ZodObject<{
|
|
|
101
101
|
level: z.ZodCustom<UiNavigationLevel, UiNavigationLevel>;
|
|
102
102
|
surfaces: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodEnum<{
|
|
103
103
|
tray: "tray";
|
|
104
|
-
mobile: "mobile";
|
|
105
104
|
web: "web";
|
|
105
|
+
mobile: "mobile";
|
|
106
106
|
electron: "electron";
|
|
107
107
|
electrobun: "electrobun";
|
|
108
108
|
}>>]>>;
|
|
@@ -127,8 +127,8 @@ declare const PageSchemas: {
|
|
|
127
127
|
readonly request: z.ZodObject<{
|
|
128
128
|
surface: z.ZodOptional<z.ZodEnum<{
|
|
129
129
|
tray: "tray";
|
|
130
|
-
mobile: "mobile";
|
|
131
130
|
web: "web";
|
|
131
|
+
mobile: "mobile";
|
|
132
132
|
electron: "electron";
|
|
133
133
|
electrobun: "electrobun";
|
|
134
134
|
}>>;
|
|
@@ -147,8 +147,8 @@ declare const PageSchemas: {
|
|
|
147
147
|
level: z.ZodCustom<UiNavigationLevel, UiNavigationLevel>;
|
|
148
148
|
surfaces: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodEnum<{
|
|
149
149
|
tray: "tray";
|
|
150
|
-
mobile: "mobile";
|
|
151
150
|
web: "web";
|
|
151
|
+
mobile: "mobile";
|
|
152
152
|
electron: "electron";
|
|
153
153
|
electrobun: "electrobun";
|
|
154
154
|
}>>]>>;
|
|
@@ -26,8 +26,8 @@ declare const TrayMenuEntrySchema: z.ZodObject<{
|
|
|
26
26
|
/** A group entry inherits its owning package and section from the group. */
|
|
27
27
|
declare const TrayMenuGroupEntrySchema: z.ZodObject<{
|
|
28
28
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
-
label: z.ZodString;
|
|
30
29
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
label: z.ZodString;
|
|
31
31
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
32
32
|
entryId: z.ZodString;
|
|
33
33
|
}, z.core.$strip>;
|
|
@@ -37,8 +37,8 @@ declare const TrayMenuGroupSchema: z.ZodObject<{
|
|
|
37
37
|
groupId: z.ZodString;
|
|
38
38
|
entries: z.ZodArray<z.ZodObject<{
|
|
39
39
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
40
|
-
label: z.ZodString;
|
|
41
40
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
label: z.ZodString;
|
|
42
42
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
43
43
|
entryId: z.ZodString;
|
|
44
44
|
}, z.core.$strip>>;
|
|
@@ -109,8 +109,8 @@ declare const TrayMenuSchemas: {
|
|
|
109
109
|
groupId: z.ZodString;
|
|
110
110
|
entries: z.ZodArray<z.ZodObject<{
|
|
111
111
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
112
|
-
label: z.ZodString;
|
|
113
112
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
113
|
+
label: z.ZodString;
|
|
114
114
|
priority: z.ZodDefault<z.ZodNumber>;
|
|
115
115
|
entryId: z.ZodString;
|
|
116
116
|
}, z.core.$strip>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as ProviderConfigFileRecordSchema, _ as BindingRecord, a as CanonicalProviderConfigPatchSchema, b as EffectiveAdapterSchema, c as CreateCanonicalProviderConfigInputSchema, d as ProviderConfigFileSet, f as AdapterFileConfig, g as AdapterSubsystemSchemas, h as AdapterReadinessSchema, i as CanonicalProviderConfigPatch, l as AdapterFileConfigSet, m as AdapterReadiness, n as CanonicalProviderConfigCredentialRefsPayload, o as CreateCanonicalProviderConfigInput, p as AdapterFileConfigSchema, r as CanonicalProviderConfigCredentialRefsSchema, s as CreateCanonicalProviderConfigInputPayload, t as CanonicalProviderConfigCredentialRefs, u as IAdapterConfigRepository, v as BindingRecordSchema, x as ProviderConfigFileRecord, y as EffectiveAdapter } from "../../index-
|
|
2
|
-
import { n as AdapterSubsystemSubjects, t as AdapterSubsystemNamespace } from "../../namespace-
|
|
1
|
+
import { S as ProviderConfigFileRecordSchema, _ as BindingRecord, a as CanonicalProviderConfigPatchSchema, b as EffectiveAdapterSchema, c as CreateCanonicalProviderConfigInputSchema, d as ProviderConfigFileSet, f as AdapterFileConfig, g as AdapterSubsystemSchemas, h as AdapterReadinessSchema, i as CanonicalProviderConfigPatch, l as AdapterFileConfigSet, m as AdapterReadiness, n as CanonicalProviderConfigCredentialRefsPayload, o as CreateCanonicalProviderConfigInput, p as AdapterFileConfigSchema, r as CanonicalProviderConfigCredentialRefsSchema, s as CreateCanonicalProviderConfigInputPayload, t as CanonicalProviderConfigCredentialRefs, u as IAdapterConfigRepository, v as BindingRecordSchema, x as ProviderConfigFileRecord, y as EffectiveAdapter } from "../../index-DfNIhEm_.mjs";
|
|
2
|
+
import { n as AdapterSubsystemSubjects, t as AdapterSubsystemNamespace } from "../../namespace-D_ZXa76m.mjs";
|
|
3
3
|
export { AdapterFileConfig, AdapterFileConfigSchema, AdapterFileConfigSet, AdapterReadiness, AdapterReadinessSchema, AdapterSubsystemNamespace, AdapterSubsystemSchemas, AdapterSubsystemSubjects, BindingRecord, BindingRecordSchema, CanonicalProviderConfigCredentialRefs, CanonicalProviderConfigCredentialRefsPayload, CanonicalProviderConfigCredentialRefsSchema, CanonicalProviderConfigPatch, CanonicalProviderConfigPatchSchema, CreateCanonicalProviderConfigInput, CreateCanonicalProviderConfigInputPayload, CreateCanonicalProviderConfigInputSchema, EffectiveAdapter, EffectiveAdapterSchema, IAdapterConfigRepository, ProviderConfigFileRecord, ProviderConfigFileRecordSchema, ProviderConfigFileSet };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as AdapterSubsystemSubjects, t as AdapterSubsystemNamespace } from "../../namespace-
|
|
1
|
+
import { n as AdapterSubsystemSubjects, t as AdapterSubsystemNamespace } from "../../namespace-D_ZXa76m.mjs";
|
|
2
2
|
export { AdapterSubsystemNamespace, AdapterSubsystemSubjects };
|