@makaio/framework 1.0.0-dev-1787949057928 → 1.0.0-dev-1788511348215
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/attempt-record-codec-dC9LSFUE.mjs +1 -0
- package/dist/authority-state-bootstrap-eitx6Ukn.mjs +1 -0
- package/dist/bus/index.mjs +1 -1
- package/dist/capabilities-DEvmD9VJ.mjs +1 -0
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/capabilities/index.d.mts +2 -2
- package/dist/contracts/capabilities/index.mjs +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +2 -2
- package/dist/contracts/index.d.mts +12 -12
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/worker/index.d.mts +2 -0
- package/dist/contracts/worker/index.mjs +1 -0
- package/dist/contracts/workflow/index.d.mts +1 -1
- package/dist/contracts/workflow/index.mjs +1 -1
- package/dist/{execution-attempt-repository-BJ2W6wwx.d.mts → execution-attempt-repository-DY4KTptE.d.mts} +359 -57
- package/dist/{index-8NdPPzUh2.d.mts → index-6trZYnUP2.d.mts} +12 -12
- package/dist/{index-CPi0UpRh.d.mts → index-B_8bA2JW.d.mts} +1 -1
- package/dist/{index-DfUpqwBa2.d.mts → index-BmilK-co2.d.mts} +53 -53
- package/dist/{index-CMekqu_D.d.mts → index-C6aSnO8m.d.mts} +42 -42
- package/dist/{index-BUwDmh1I.d.mts → index-CDud4NAm.d.mts} +10 -10
- package/dist/{index-CYjgoYeX.d.mts → index-DHH-93YD.d.mts} +1 -1
- package/dist/{index-B9io6JAL.d.mts → index-DI2lS7VT.d.mts} +1 -1
- package/dist/{index-cLB38AWX.d.mts → index-DNI6UF9h.d.mts} +60 -60
- package/dist/{index-NUByQvlg.d.mts → index-DXtQRehh.d.mts} +14 -14
- package/dist/{index-CVNbBtA-.d.mts → index-Wbd_syN2.d.mts} +112 -112
- 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-C06lJSuj.d.mts → namespace-K23m4b0n.d.mts} +6 -6
- package/dist/package-Cgjpm9om.mjs +7 -0
- package/dist/{package-BNFTUFLB.d.mts → package-efR90JGe.d.mts} +59 -30
- package/dist/package.json +1 -1
- package/dist/runtime-node/index.d.mts +1 -1
- package/dist/runtime-node/index.mjs +1 -1
- package/dist/runtime-node/makaio-config.d.mts +2 -2
- package/dist/runtime-node/makaio-config.mjs +1 -1
- package/dist/runtime-node/workflow-execution-bus-access.mjs +1 -1
- package/dist/runtime-node/workflow-worker/index.d.mts +2 -2
- package/dist/runtime-node/workflow-worker/index.mjs +1 -1
- package/dist/{schemas-OWvBn7AH.d.mts → schemas-BCXvEWyF.d.mts} +4 -4
- package/dist/{schemas-BAv9RB9M.d.mts → schemas-D7EeKBDJ.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/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/index.d.mts +9 -9
- package/dist/services/provider-context/index.d.mts +1 -1
- package/dist/services/session/index.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +2 -2
- package/dist/services/subagent-template/index.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/worker-CARV52hT.mjs +1 -0
- package/dist/worker-CLsRbzpk.mjs +1 -0
- package/dist/workflow-BomH9DBB.mjs +1 -0
- package/dist/workflow-engine/execution-attempt-repository.d.mts +2 -2
- package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
- package/dist/workflow-engine/index.d.mts +178 -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/testing/index.d.mts +30 -9
- package/dist/workflow-engine/testing/index.mjs +1 -1
- package/dist/workflow-engine/testing/sqlite.d.mts +3 -2
- package/dist/workflow-engine/testing/sqlite.mjs +20 -20
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/workflow-worker-Dul-wcOR.mjs +1 -0
- package/package.json +4 -4
- package/dist/attempt-record-codec-BYfYkj4M.mjs +0 -1
- package/dist/authority-state-bootstrap-CLYus369.mjs +0 -1
- package/dist/capabilities-BUwuA7XX.mjs +0 -1
- package/dist/contracts/worker-node/index.d.mts +0 -2
- package/dist/contracts/worker-node/index.mjs +0 -1
- package/dist/package-B01gmu75.mjs +0 -7
- package/dist/worker-node-CjuQb9hl.mjs +0 -1
- package/dist/worker-node-Dtf9ilsR.mjs +0 -1
- package/dist/workflow-C4mck_NW.mjs +0 -1
- package/dist/workflow-worker-aNbdgqml.mjs +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as IngestCompletedTurnResult, $n as runExclusiveStart, $t as resolveAdapterNameById, A as registerDrizzleMessageStorage, An as FreshWithHistoryRecoveryPlan, At as SESSION_OWNERSHIP_CLAIM_LOCK_NAMESPACE, B as importCursorsDual, Bn as resolveTargetAgents, Bt as AgentStorageNamespace, C as registerDrizzleMessageRoutingStorage, Cn as ensureAgentCwd, Ct as fetchAgentsBySession, D as SelectMessage, Dn as buildPlannedRecoveryContext, Dt as parseForkTransforms, E as InsertMessage, En as verifyAndRecoverAgents, Et as mapRowToSession, F as registerMemoryTurnStorage, Fn as recoveryPlanResumeTarget, Ft as registerMemoryAgentStorage, G as ObservedSessionIngestionPolicyInput, Gn as ISessionOrchestrator, Gt as assembleForkContext, H as OBSERVED_SESSION_INGESTION_POLICY_CAPABILITY_ID, Hn as normalizeToBlocks, Ht as SessionExtensionContextImpl, I as registerDrizzleTurnStorage, In as StartReservationRequest, It as registerDrizzleSessionStorage, J as ObservedSessionIngestionService, Jn as assessClaimOwner, Jt as CONNECTOR_SWAP_DEFAULT_PIPELINE, K as registerObservedSessionIngestionPolicyProvider, Kn as SessionOrchestrator, Kt as FallbackRuntimeOptions, L as EmbeddingIndexManager, Ln as reserveStartFor, Lt as registerMemorySessionStorage, M as SelectTurn, Mn as RecoveryPlan, Mt as registerDrizzleSessionOwnershipStorage, N as turns, Nn as planAgentRecovery, Nt as registerMemorySessionOwnershipStorage, O as messages, On as buildRecoveryContext, Ot as registerFtsSearchHandler, P as turnsDual, Pn as recoveryPlanRequiresHistory, Pt as registerDrizzleAgentStorage, Q as IngestCompletedTurnParams, Qn as peekInFlightStart, Qt as normalizeSelectionString, R as registerDrizzleImportCursorStorage, Rn as findTurnByAgent, Rt as SessionStorageMemoryState, S as messageRoutingDual, Sn as buildRecoveryContextWithPipeline, St as SearchSessionRow, T as MessageRoutingSubjects, Tn as recoverAgent, Tt as fetchPreviewBySession, U as ObservedSessionIngestionPolicyDecision, Un as TurnContextEnricher, Ut as createSessionExtensionContext, V as IObservedSessionIngestionPolicyProvider, Vn as extractTextContent, Vt as AgentStorageSubjects, W as ObservedSessionIngestionPolicyImportStatus, Wn as AdapterRegistry, Wt as SessionBridge, X as isTrackingStub, Xn as enqueueAgentSettle, Xt as SelectionRefusalContext, Y as isPolicyDiscoveredObservedSession, Yn as mintClaimToken, Yt as NamedSelectionInstance, Z as LogImportTriggerSubjects, Zn as InFlightStart, Zt as describeHalfNamedInstanceRefusal, _ as MakaioSessionConfig, _n as LeadTransition, _t as SessionPreviewMaps, a as resolveSessionResumeIdentity, an as registerResumeHandler, at as SessionUserMessageSentPayload, b as SelectMessageRouting, bn as RecoveryConfig, bt as mapToSession, c as BuildContextOptions, cn as ContextWindowTrackerConfig, ct as emitSessionUserMessageSent, d as toSessionLineage, dn as resolveSelectionOwnedInstance, dt as registerMemorySessionEventStorage, en as registerListActionsHandler, er as registerAdapterSessionMovementObserver, et as IngestTurnMessage, f as registerSessionDiscoveredHandler, fn as startLeadAgent, ft as InsertSessionEvent, g as MakaioSession, gn as LeadStartResult, gt as getSessionAncestorChain, h as registerParentResolver, hn as LeadStartRequest, ht as sessionEventsDual, i as SessionResumeIdentity, in as registerGetStatusCountsHandler, ir as MakaioSessionServiceOptions, it as SessionTurnStartedPayload, j as InsertTurn, jn as NativeResumeRecoveryPlan, jt as ownershipClaimTransactionLock, k as registerMemoryMessageStorage, kn as FRESH_WITH_HISTORY_RECOVERY_PLAN, kt as OwnershipClaimKey, l as ContextAssemblyResult, ln as SessionContextWindowState, lt as registerSessionLifecycleEventWriters, m as registerCompressLineageResolver, mn as LeadStartDispatchRequest, mt as sessionEvents, n as NativeLocalityIntent, nn as resetBuiltInActionsRegistration, nr as registerSessionOwnershipAuthority, nt as EventTransform, o as getFullConversation, on as ContextWindowTracker, ot as appendSessionLifecycleEvent, p as registerSpawningToolCallResolver, pn as LeadStartDispatch, pt as SelectSessionEvent, q as unregisterObservedSessionIngestionPolicyProvider, qn as registerCoreSessionServiceHandlers, qt as pickFallbackRuntimeOptions, r as evaluateNativeLocality, rn as actionRegistry, rr as MakaioSessionService, rt as SessionLifecycleEventArgs, s as buildSessionContext, sn as AgentContextState, st as emitSessionTurnStarted, t as NativeLocalityInput, tn as registerBuiltInActions, tr as SessionOwnershipAuthorityDeps, tt as ingestCompletedTurn, u as kindToBranchKind, un as SelectionInstanceContext, ut as registerDrizzleSessionEventStorage, v as StartTurnOptions, vn as buildTurnInitiator, vt as fetchSessionPreviewMaps, w as MessageRoutingNamespace, wn as ensureAgentModel, wt as fetchMessageCountsBySession, x as messageRouting, xn as VerifiedAgents, xt as SearchFilters, y as InsertMessageRouting, yn as AgentRecoveryOutcome, yt as mapAgentsBySession, z as importCursors, zn as getOrCreateSession, zt as createSessionStorageMemoryState } from "../../index-BNzUyVwV.mjs";
|
|
2
2
|
import { C as SessionTurnManager, D as TurnPairStateChange, E as TurnContext, O as TurnPairTerminalOutcome, S as resolveOwnedAdapterInstance, T as TurnConfig, _ as OwnedAdapterInstanceTarget, a as InFlightStartResolution, b as resolveExecutionTarget, c as registerMergeHandler, d as registerAttachHandler, f as registerAbandonHandler, g as OwnedAdapterInstance, h as MachineScopedAdapterInstance, i as refuseTotalDeferral, k as TurnResult, l as registerForkHandler, m as SessionStartFailureCode, n as routeToAgents, o as StartResolution, p as SessionStartError, r as admitFreshStartTargets, s as resolveInFlightStarts, t as routeToAgentsCore, u as registerCompressHandler, v as resolveAdapterId, w as Turn, x as resolveModelCapabilities, y as resolveAnnouncedAdapterInstance } from "../../index-B0yMCJW8.mjs";
|
|
3
|
-
import { l as resolveRuntimeProviderContext } from "../../index-
|
|
3
|
+
import { l as resolveRuntimeProviderContext } from "../../index-B_8bA2JW.mjs";
|
|
4
4
|
import { i as SessionStorageSubjects, r as SessionStorageNamespace } from "../../namespace-BRuHzhPo.mjs";
|
|
5
5
|
import { _ as sessionsDual, c as adapterSessionClaims, d as agentsDual, g as sessions, l as adapterSessionClaimsDual, u as agents } from "../../schema-B3Pf7JP7.mjs";
|
|
6
6
|
import { n as SessionEventStorageSubjects, t as SessionEventStorageNamespace } from "../../namespace-DOezqDti.mjs";
|
|
@@ -513,6 +513,7 @@ declare const SubagentTemplateSettingsNamespace: _$_makaio_core0.BusNamespaceDef
|
|
|
513
513
|
name: _$zod.ZodString;
|
|
514
514
|
enabled: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
515
515
|
providerConfigId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
516
|
+
adapterName: _$zod.ZodString;
|
|
516
517
|
model: _$zod.ZodOptional<_$zod.ZodString>;
|
|
517
518
|
systemPrompt: _$zod.ZodOptional<_$zod.ZodString>;
|
|
518
519
|
allowedTools: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
@@ -522,7 +523,6 @@ declare const SubagentTemplateSettingsNamespace: _$_makaio_core0.BusNamespaceDef
|
|
|
522
523
|
fork: "fork";
|
|
523
524
|
fresh: "fresh";
|
|
524
525
|
}>>;
|
|
525
|
-
adapterName: _$zod.ZodString;
|
|
526
526
|
}, _$zod_v4_core0.$strip>;
|
|
527
527
|
response: _$zod.ZodObject<{
|
|
528
528
|
id: _$zod.ZodString;
|
|
@@ -604,6 +604,7 @@ declare const SubagentTemplateSettingsSubjects: _$_makaio_core0.BusSubjects<_$_m
|
|
|
604
604
|
name: _$zod.ZodString;
|
|
605
605
|
enabled: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
606
606
|
providerConfigId: _$zod.ZodOptional<_$zod.ZodString>;
|
|
607
|
+
adapterName: _$zod.ZodString;
|
|
607
608
|
model: _$zod.ZodOptional<_$zod.ZodString>;
|
|
608
609
|
systemPrompt: _$zod.ZodOptional<_$zod.ZodString>;
|
|
609
610
|
allowedTools: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
@@ -613,7 +614,6 @@ declare const SubagentTemplateSettingsSubjects: _$_makaio_core0.BusSubjects<_$_m
|
|
|
613
614
|
fork: "fork";
|
|
614
615
|
fresh: "fresh";
|
|
615
616
|
}>>;
|
|
616
|
-
adapterName: _$zod.ZodString;
|
|
617
617
|
}, _$zod_v4_core0.$strip>;
|
|
618
618
|
response: _$zod.ZodObject<{
|
|
619
619
|
id: _$zod.ZodString;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as SubagentTemplateUpdate, a as SubagentTemplateInstance, c as SubagentTemplateInstanceStatusSchema, d as SubagentTemplateSettingsSchemas, f as SubagentTemplateSpawnRequest, g as SubagentTemplateSummarySchema, h as SubagentTemplateSummary, i as SubagentTemplateCreateSchema, l as SubagentTemplateKernelSchemas, m as SubagentTemplateSpawnedEventSchema, n as SubagentTemplateCompletedEventSchema, o as SubagentTemplateInstanceSchema, p as SubagentTemplateSpawnRequestSchema, r as SubagentTemplateCreate, s as SubagentTemplateInstanceStatus, t as SubagentTemplate, u as SubagentTemplateSchema, v as SubagentTemplateUpdateSchema } from "../../schemas-
|
|
1
|
+
import { _ as SubagentTemplateUpdate, a as SubagentTemplateInstance, c as SubagentTemplateInstanceStatusSchema, d as SubagentTemplateSettingsSchemas, f as SubagentTemplateSpawnRequest, g as SubagentTemplateSummarySchema, h as SubagentTemplateSummary, i as SubagentTemplateCreateSchema, l as SubagentTemplateKernelSchemas, m as SubagentTemplateSpawnedEventSchema, n as SubagentTemplateCompletedEventSchema, o as SubagentTemplateInstanceSchema, p as SubagentTemplateSpawnRequestSchema, r as SubagentTemplateCreate, s as SubagentTemplateInstanceStatus, t as SubagentTemplate, u as SubagentTemplateSchema, v as SubagentTemplateUpdateSchema } from "../../schemas-D7EeKBDJ.mjs";
|
|
2
2
|
import { n as SubagentTemplateSubjects, t as SubagentTemplateKernelNamespace } from "../../namespace-BGRHcrmp.mjs";
|
|
3
3
|
export { type SubagentTemplate, SubagentTemplateCompletedEventSchema, type SubagentTemplateCreate, SubagentTemplateCreateSchema, type SubagentTemplateInstance, SubagentTemplateInstanceSchema, type SubagentTemplateInstanceStatus, SubagentTemplateInstanceStatusSchema, SubagentTemplateKernelNamespace, SubagentTemplateKernelSchemas, SubagentTemplateSchema, SubagentTemplateSettingsSchemas, type SubagentTemplateSpawnRequest, SubagentTemplateSpawnRequestSchema, SubagentTemplateSpawnedEventSchema, SubagentTemplateSubjects, type SubagentTemplateSummary, SubagentTemplateSummarySchema, type SubagentTemplateUpdate, SubagentTemplateUpdateSchema };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as SubagentTemplateUpdate, a as SubagentTemplateInstance, c as SubagentTemplateInstanceStatusSchema, d as SubagentTemplateSettingsSchemas, f as SubagentTemplateSpawnRequest, g as SubagentTemplateSummarySchema, h as SubagentTemplateSummary, i as SubagentTemplateCreateSchema, l as SubagentTemplateKernelSchemas, m as SubagentTemplateSpawnedEventSchema, n as SubagentTemplateCompletedEventSchema, o as SubagentTemplateInstanceSchema, p as SubagentTemplateSpawnRequestSchema, r as SubagentTemplateCreate, s as SubagentTemplateInstanceStatus, t as SubagentTemplate, u as SubagentTemplateSchema, v as SubagentTemplateUpdateSchema } from "../../schemas-
|
|
1
|
+
import { _ as SubagentTemplateUpdate, a as SubagentTemplateInstance, c as SubagentTemplateInstanceStatusSchema, d as SubagentTemplateSettingsSchemas, f as SubagentTemplateSpawnRequest, g as SubagentTemplateSummarySchema, h as SubagentTemplateSummary, i as SubagentTemplateCreateSchema, l as SubagentTemplateKernelSchemas, m as SubagentTemplateSpawnedEventSchema, n as SubagentTemplateCompletedEventSchema, o as SubagentTemplateInstanceSchema, p as SubagentTemplateSpawnRequestSchema, r as SubagentTemplateCreate, s as SubagentTemplateInstanceStatus, t as SubagentTemplate, u as SubagentTemplateSchema, v as SubagentTemplateUpdateSchema } from "../../schemas-D7EeKBDJ.mjs";
|
|
2
2
|
export { SubagentTemplate, SubagentTemplateCompletedEventSchema, SubagentTemplateCreate, SubagentTemplateCreateSchema, SubagentTemplateInstance, SubagentTemplateInstanceSchema, SubagentTemplateInstanceStatus, SubagentTemplateInstanceStatusSchema, SubagentTemplateKernelSchemas, SubagentTemplateSchema, SubagentTemplateSettingsSchemas, SubagentTemplateSpawnRequest, SubagentTemplateSpawnRequestSchema, SubagentTemplateSpawnedEventSchema, SubagentTemplateSummary, SubagentTemplateSummarySchema, SubagentTemplateUpdate, SubagentTemplateUpdateSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./json-value-BBZ6uGwc.mjs";import{A as t,_ as n,x as r}from"./worker-CLsRbzpk.mjs";import{G as i,H as a,V as o}from"./workflow-BomH9DBB.mjs";import{z as s}from"zod";import{createBusNamespace as c}from"@makaio/framework/core";const l=s.object({executionAttemptId:s.string().min(1),executionId:s.string().min(1),environment:s.string().min(1),metadata:e.optional()}),u=s.object({executionAttemptId:s.string().min(1),config:i,manifest:o.optional(),requirements:t.optional(),metadata:e.optional()}),d=s.object({executionAttemptId:s.string().min(1),allocationRef:r}).strict(),f={dispatch:{request:u,response:d},"control.attempt-ready":s.object({executionAttemptId:s.string().min(1),executionId:s.string().min(1),adapters:s.array(s.string().min(1)).default([])}).strict(),"control.outcome.submit":{request:s.object({executionAttemptId:s.string().min(1),executionId:s.string().min(1),result:a}).strict().superRefine((e,t)=>{e.result.executionId!==e.executionId&&t.addIssue({code:s.ZodIssueCode.custom,path:[`result`,`executionId`],message:`result.executionId must match executionId`})}),response:s.object({decision:n}).strict()},"control.bootstrap.claim":{request:s.object({executionId:s.string().min(1),executionAttemptId:s.string().min(1)}).strict(),response:s.object({busUrl:s.string().min(1),busAuthSecret:s.string().min(1)}).strict()},"lifecycle.provisioning":l,"lifecycle.booting":l,"lifecycle.ready":l.extend({adapters:s.array(s.string().min(1)).default([])}),"lifecycle.busy":l,"lifecycle.completed":l,"lifecycle.failed":l.extend({error:s.string().min(1)}),"lifecycle.terminated":l.extend({reason:s.string().optional()}),"lifecycle.paused":l.extend({pausedAtGateId:s.string().min(1),pausedAtFrameId:s.string().min(1)})},p=`worker-bootstrap`,m=c(`worker`,f),h=m.subjects;export{d as a,u as i,m as n,f as o,h as r,p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./json-value-BBZ6uGwc.mjs";import{n as t}from"./capability-j3NekkIu.mjs";import{z as n}from"zod";const r=n.enum([`wait-in-process`,`exit-and-redispatch`,`exit-and-resume`]),i=`worker`,a=`makaio.runtime-node.piscina-local`,o=1,s=n.object({version:n.literal(1),providerId:n.string().min(1),providerData:e}).strict(),c={source:128,code:64,summary:512,observedAt:64},l=n.object({source:n.string().min(1).max(c.source),summary:n.string().min(1).max(c.summary),observedAt:n.iso.datetime({offset:!0}).max(c.observedAt),code:n.string().min(1).max(c.code).optional()}).strict(),u=`exhaustive-search-unavailable`,d=`no-allocation-observed`,f=`ambiguous-allocation-match`,p=`pre-request-rejection`,m=[`unknown`,`provisioning`,`ready`,`running`,`suspended`,`terminal`,`absent`],h=n.enum(m),g=n.object({state:h,allocationRef:s,evidence:e.optional()}),_=[`local-directory`,`workspace-snapshot`],v=n.enum(_),y=n.string().min(1).refine(e=>!e.startsWith(`/`)&&!/^[A-Za-z]:[/\\]/.test(e),{message:`sourcePath must be relative (no leading / or drive letter)`}),b=n.object({kind:n.literal(`local-directory`),workspaceId:n.string().min(1),rootDigest:n.string().min(1),sourcePath:y}).strict(),x=n.object({kind:n.literal(`workspace-snapshot`),snapshotId:n.string().min(1),digest:n.string().min(1),sourcePath:y}).strict(),S=n.discriminatedUnion(`kind`,[b,x]),C=/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,w=n.object({packageName:n.string().min(1),version:n.string().min(1),entrypoint:n.string().min(1).refine(e=>!e.includes(`node_modules`)&&!e.startsWith(`/`)&&!/^[A-Za-z]:[/\\]/.test(e),{message:`entrypoint must be package-relative (no node_modules, no absolute path)`}),integrity:n.string().min(1).refine(e=>C.test(e),{message:`integrity must be a valid SRI hash (sha256-..., sha384-..., or sha512-...)`})}).strict(),T=n.object({maxRuntimeMs:n.number().int().positive().optional(),persistentStorage:n.boolean(),customCapabilities:n.array(n.string().min(1)).default([]),suspensionStrategy:r.default(`wait-in-process`),supportsRecovery:n.boolean().default(!1),materializationModes:n.array(v).min(1).default([`local-directory`])}),E=n.object({maxRuntimeMs:n.number().int().positive().optional(),persistentStorage:n.boolean().optional(),customCapabilities:n.array(n.string().min(1)).default([]),recoverableAllocation:n.boolean().optional(),materializationModes:n.array(v).optional()}),D=[`provisioner-process-bound`,`provider-managed`],O=n.enum(D),k=[`found`,`confirmed-absent`,`unknown`],A=n.discriminatedUnion(`kind`,[n.object({kind:n.literal(`found`),allocationRef:s}).strict(),n.object({kind:n.literal(`confirmed-absent`),evidence:l}).strict(),n.object({kind:n.literal(`unknown`),evidence:l}).strict()]),j=n.enum([`accepted`,`duplicate`,`conflict`,`fenced`]);var M=class extends Error{constructor(e){super(e),this.name=`ProviderAllocationRefError`}};function N(e,t){let n=s.shape.providerId.parse(e);return{build:e=>{let r=t.parse(e);return{version:1,providerId:n,providerData:s.shape.providerData.parse(r)}},parse:e=>{if(e.version!==1)throw new M(`Unsupported allocation ref version ${String(e.version)}, expected 1`);if(e.providerId!==n)throw new M(`Allocation ref provider '${e.providerId}' does not match this provider '${n}'`);let r=t.safeParse(e.providerData);if(!r.success)throw new M(`Invalid provider data in allocation ref: ${r.error.message}`);return r.data}}}function P(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.charCodeAt(n.length-1);return`${r>=55296&&r<=56319?n.slice(0,-1):n}…`}function F(e,t,n){let r=c.summary;return l.parse({source:e,summary:P(n,r),observedAt:new Date().toISOString(),...t===void 0?{}:{code:t}})}function I(e,n){return e.emit(t.register,{capabilityId:i,provider:n})}function L(e,n){return e.emit(t.unregister,{capabilityId:i,providerId:n})}export{E as A,c as C,T as D,O as E,r as M,w as O,A as S,i as T,j as _,N as a,k as b,g as c,l as d,u as f,d as g,v as h,M as i,x as j,S as k,h as l,_ as m,L as n,m as o,b as p,F as r,f as s,I as t,a as u,p as v,D as w,s as x,o as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,m as t,s as n}from"./schemas-C3kyQWGf.mjs";import{a as r,i,n as a,o}from"./json-value-BBZ6uGwc.mjs";import{t as s}from"./zod-json-schema-Dixc-B1T.mjs";import"./artifact-Btbuib48.mjs";import{a as c}from"./visibility-DtDLRBdr.mjs";import"./model-DrzPt3ou.mjs";import{t as l}from"./provider-context-zTDSH2x9.mjs";import{a as u,o as d}from"./schemas-QWDnauKX.mjs";import{A as f,M as ee,O as te,k as p}from"./worker-CLsRbzpk.mjs";import{r as ne}from"./schemas-BfO5jkrL.mjs";import{z as m}from"zod";import{createBusNamespace as h,getFullSubjectForSubjectDefinition as re,observability as g,splitSubjectKey as ie}from"@makaio/framework/core";const _=m.object({kind:m.string().min(1),id:m.string().min(1)});function ae(e){return`${se(e.kind)}:${se(e.id)}`}function oe(e){let t=ce(e);if(t<1)throw Error(`Invalid artifact ref key: ${e}`);let n=le(e.slice(t+1));if(n.length===0)throw Error(`Invalid artifact ref key (empty id): ${e}`);return{kind:le(e.slice(0,t)),id:n}}function se(e){return e.replace(/\\/g,`\\\\`).replace(/:/g,`\\:`)}function ce(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(t){t=!1;continue}if(r===`\\`){t=!0;continue}if(r===`:`)return n}return-1}function le(e){let t=``,n=!1;for(let r of e){if(n){if(r!==`\\`&&r!==`:`)throw Error(`Invalid artifact ref key component: ${e}`);t+=r,n=!1;continue}if(r===`\\`){n=!0;continue}t+=r}if(n)throw Error(`Invalid artifact ref key component: ${e}`);return t}const ue=m.enum([`completed`,`failed`,`cancelled`]),de=m.object({status:ue,completedAt:m.number().int().nonnegative(),error:m.string().min(1).optional(),reason:m.string().min(1).optional()}).strict(),fe=m.object({executionId:m.string().min(1),workflowId:m.string().min(1),finalizerId:m.string().min(1),transitionKey:m.string().min(1),claimToken:m.string().min(1),intent:de,claimedAt:m.number().int().nonnegative()}).strict(),pe=m.object({accepted:m.boolean()}).strict(),me=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,v=m.string().regex(me,`Workflow finalizer IDs must be lowercase dot, dash, or underscore separated names.`),y=m.string().regex(me,`Workflow delegate result finalizer IDs must be lowercase dot, dash, or underscore separated names.`),he=m.object({toolName:m.string().min(1),outcome:m.enum([`success`,`failure`]).optional(),artifact:m.object({kind:m.string().min(1),id:m.string().min(1),revision:m.string().min(1)}).strict().optional()}).strict().superRefine((e,t)=>{e.artifact!==void 0&&e.outcome!==`success`&&t.addIssue({code:`custom`,path:[`artifact`],message:`requires an explicit successful outcome`})}),ge=m.object({durationMs:m.number().int().nonnegative(),inputTokens:m.number().int().nonnegative().optional(),outputTokens:m.number().int().nonnegative().optional(),cachedInputTokens:m.number().int().nonnegative().optional(),toolCallCount:m.number().int().nonnegative().optional(),binding:m.object({adapterName:m.string().min(1),providerConfigId:m.string().min(1).optional(),providerDefinitionId:m.string().min(1).optional(),model:m.string().min(1).optional(),auth:m.object({mode:m.enum([`explicit`,`inferred`,`none`]),owner:m.enum([`provider`,`client`]),methodId:m.string().min(1)}).strict().optional()}).strict()}).strict(),b=m.object({executionId:m.string().min(1),workflowId:m.string().min(1),frameId:m.string().min(1),nodeId:m.string().min(1),nodeType:m.enum([`delegate-agent`,`delegate-role`]),rawResult:o,toolObservations:m.array(he),economics:ge.optional()}).strict(),_e=b.extend({finalizerId:y}).strict(),x=m.object({output:o}).strict();function ve(e){if(!v.safeParse(e).success)throw Error(`Invalid workflow finalizer ID: "${e}"`);let t=`workflow-finalizer:${e}`,n=h(t,{finalize:{request:fe,response:pe}});return{namespaceDomain:t,namespace:n,subjects:n.subjects}}function ye(e){if(!y.safeParse(e).success)throw Error(`Invalid workflow delegate result finalizer ID: "${e}"`);let t=`workflow-delegate-finalizer:${e}`,n=h(t,{finalize:{request:b,response:x}});return{namespaceDomain:t,namespace:n,subjects:n.subjects}}const S=m.union([m.string(),m.number(),m.boolean(),m.null()]),be=m.union([S,m.object({$in:m.array(S)}).strict(),m.object({$ne:S}).strict(),m.object({$exists:m.boolean()}).strict(),m.object({$startsWith:m.string()}).strict(),m.object({$endsWith:m.string()}).strict()]),xe=m.record(m.string(),be),Se=m.object({kind:ne,params:i,filter:xe.optional(),filterExpression:m.string().optional()}),C=m.discriminatedUnion(`type`,[m.object({type:m.literal(`global`)}).strict(),m.object({type:m.literal(`workspace`),id:m.string().min(1)}).strict(),m.object({type:m.literal(`session`),id:m.string().min(1)}).strict(),m.object({type:m.literal(`external`),kind:m.string().min(1),id:m.string().min(1)}).strict()]),w=m.string().min(1),T=m.object({kind:m.string().min(1),schemaVersion:m.string().min(1),scope:e,resolve:m.string().min(1).optional(),create:m.string().min(1).optional(),statusPath:m.string().min(1).optional()}),Ce=m.object({kind:m.string().min(1),schemaVersion:m.string().min(1),scope:e,dataExpression:m.string().optional()}),we=m.object({file:m.string().min(1),line:m.number().int().positive().optional(),column:m.number().int().positive().optional()}),E=m.enum([`station`,`delegate-agent`,`delegate-role`,`parallel`,`gate`,`iterate`,`iterate-chain`,`loop`,`sequence`]),Te=m.enum([`all-settled`,`fail-fast`]),D=m.object({id:m.string().min(1),when:w.optional(),skip:w.optional(),writes:m.array(Ce).optional()}),O=m.lazy(()=>m.discriminatedUnion(`type`,[A,Ee,De,Oe,ke,Ae,je,Ne,k])),k=D.extend({type:m.literal(`sequence`),nodes:m.lazy(()=>m.array(O))}),A=D.extend({type:m.literal(`station`),prompt:m.string().min(1),role:m.string().min(1).optional(),outputSchema:r.optional(),timeoutMs:m.number().int().positive().optional(),completion:u.optional()}),Ee=D.extend({type:m.literal(`delegate-agent`),agentId:m.string().min(1),inputExpression:m.string().optional(),outputSchema:r.optional(),allowedTools:m.array(m.string()).optional(),completion:u.optional(),resultFinalizerId:y.optional()}),De=D.extend({type:m.literal(`delegate-role`),role:m.string().min(1),prompt:m.string().min(1),outputSchema:r.optional(),allowedTools:m.array(m.string()).optional(),resultFinalizerId:y.optional(),timeoutMs:m.number().int().positive().optional(),completion:u.optional()}),Oe=D.extend({type:m.literal(`parallel`),mode:Te.optional(),branches:m.record(m.string().min(1),m.lazy(()=>k))}),ke=D.extend({type:m.literal(`gate`),prompt:m.string().min(1),title:m.string().optional(),autoAction:m.enum([`approve`,`reject`]),timeoutMs:m.number().int().positive().nullable(),resumeSchema:r.optional()}),Ae=D.extend({type:m.literal(`iterate`),collection:m.string().min(1),body:m.lazy(()=>k),concurrency:m.number().int().nonnegative().optional()}),je=D.extend({type:m.literal(`iterate-chain`),collection:m.string().min(1),body:m.lazy(()=>k)}),Me=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`pass`)}).strict(),m.object({kind:m.literal(`loop`)}).strict(),m.object({kind:m.literal(`escalate`),reason:m.string().min(1)}).strict()]),Ne=D.extend({type:m.literal(`loop`),maxRounds:m.number().int().positive(),body:m.lazy(()=>k),gate:m.object({handler:m.string().min(1),input:m.string().min(1).optional(),config:o.optional(),escalation:m.object({title:m.string().optional(),prompt:m.string().min(1),resumeSchema:r.optional(),autoAction:m.enum([`approve`,`reject`]).default(`reject`),timeoutMs:m.number().int().positive().nullable().default(null)}).strict().optional()}).strict()}),Pe=m.object({factoryId:m.string().min(1),preview:m.array(m.lazy(()=>O)).optional(),sourceLocation:we.optional()}),Fe=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`editor`)}).strict(),m.object({kind:m.literal(`extension`),extension:m.string().min(1),externalId:m.string().min(1).optional(),syncedAt:m.string().datetime().optional(),metadata:a.default({})}).strict()]),Ie=m.object({schema:r,initial:o.optional()}),Le=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`path`),path:m.string().min(1)}).strict(),m.object({kind:m.literal(`source`),filename:m.string().min(1),source:m.string()}).strict(),m.object({kind:m.literal(`definition`),workflowId:m.string().min(1)}).strict()]),j=m.object({id:m.string().min(1),name:m.string().optional(),description:m.string().optional(),inputSchema:r.optional(),configSchema:r.optional(),outputSchema:r.optional(),state:Ie.optional(),artifact:T.optional(),root:k,triggers:m.array(Se).optional(),scope:C.default({type:`global`}),canvasLayout:m.record(m.string(),o).optional(),source:Fe.optional(),executableSource:Le.optional(),requirements:f.optional(),successFinalizerId:v.optional()}),M=m.enum([`pending`,`running`,`paused`,`finalizing`,`completed`,`failed`,`cancelled`]),N=m.object({id:m.string(),workflowId:m.string(),coordinatorSessionId:m.string().optional(),status:M,inputs:o,config:a.optional(),startedAt:m.number(),completedAt:m.number().optional(),error:m.string().optional(),reason:m.string().optional(),triggerPayload:a.optional(),scope:C,artifactRef:_.optional()}),Re=m.object({frameId:m.string(),nodeId:m.string(),nodeType:E,path:m.array(m.string()),parentFrameId:m.string().optional(),status:m.enum([`pending`,`running`,`waiting`,`completed`,`failed`,`skipped`,`cancelled`]),attempt:m.number().int().nonnegative().default(0),iteration:m.number().int().nonnegative().optional(),branchKey:m.string().optional(),output:o.optional(),error:m.string().optional(),startedAt:m.number().optional(),completedAt:m.number().optional()}),P=m.enum([`waiting`,`resumed`,`rejected`,`timed-out`,`cancelled`]),ze=m.object({executionId:m.string(),nodeId:m.string(),frameId:m.string(),schema:r,prompt:m.string().optional(),status:P,autoAction:m.enum([`approve`,`reject`]),timeoutMs:m.number().int().positive().nullable(),resumeData:o.optional(),reason:m.string().optional(),createdAt:m.number(),resolvedAt:m.number().optional()}),F=m.object({adapterName:m.string().min(1),providerConfigId:m.string().min(1).optional(),model:m.string().optional(),reasoningEffort:c.optional(),harnessId:m.string().optional(),systemPrompt:m.string().optional(),contextMode:d.optional(),providerContext:l.optional(),adapterConfig:a.optional(),tools:m.array(m.string()).optional(),disallowedTools:m.array(m.string()).optional(),allowedDirectories:m.array(m.string()).optional(),completion:u.optional()}),Be=F,Ve=m.object({scope:C.optional()}),He=m.object({startedAt:m.number(),id:m.string()}),Ue=1,We=500,Ge=50,Ke=m.object({workflowId:m.string().min(1).optional(),scope:C.optional(),status:M.optional(),artifactRef:_.optional(),limit:m.number().int().min(1).max(500).default(50),cursor:He.optional()}).refine(e=>e.workflowId!==void 0||e.scope!==void 0||e.artifactRef!==void 0,{message:`Either workflowId, scope, or artifactRef is required.`}),qe=200,Je=100,Ye=10,Xe=m.object({refs:m.array(_).min(1).max(200),limitPerRef:m.number().int().min(1).max(100).default(10)}),Ze=m.object({executionId:m.string().min(1).optional(),status:P.optional(),limit:m.number().int().min(1).max(500).default(50)}).refine(e=>e.executionId!==void 0||e.status!==void 0,{message:`Either executionId or status is required.`}),I=m.enum([`station`,`delegate-agent`,`delegate-role`,`gate`]),Qe=m.enum([`station`]),$e=m.object({input:m.number().int().nonnegative(),output:m.number().int().nonnegative(),cached:m.number().int().nonnegative().optional()}),et=m.object({duration:m.number().nonnegative(),tokenUsage:$e.optional(),estimatedCost:m.number().nonnegative().optional(),toolCalls:m.number().int().nonnegative().optional()}),tt=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`none`)}).strict(),m.object({kind:m.literal(`hmac`),secret:m.string().min(1)}).strict()]),nt=m.object({cwd:m.string().min(1),env:m.record(m.string(),m.string()).optional()}),rt=m.object({executionId:m.string().min(1),stepId:m.string().min(1),reason:m.string().optional()});function it(e){let t=ie(e);if(t===void 0)throw Error(`Invalid step cancel subject: ${e}`);return{subject:t.subject,$meta:{namespace:t.namespace,isRequest:!1,payload:{},local:!1,channel:!1}}}const at=m.object({executionId:m.string().min(1),reason:m.string().optional()});function ot(e){let t=ie(e);if(t===void 0)throw Error(`Invalid workflow cancel subject: ${e}`);return{subject:t.subject,$meta:{namespace:t.namespace,isRequest:!1,payload:{},local:!1,channel:!1}}}const st=m.object({stepId:m.string().min(1),executionId:m.string().min(1),workflowId:m.string().min(1),coordinatorSessionId:m.string().min(1),stepType:Qe,stepDefinition:A,resolvedInputs:a,busUrl:m.string().optional(),busAuth:tt.default({kind:`none`}),platformDefaults:nt,cancelSubject:m.string().min(1)}).superRefine((e,t)=>{e.stepType!==e.stepDefinition.type&&t.addIssue({code:`custom`,path:[`stepDefinition`,`type`],message:`stepDefinition.type must match stepType (${e.stepType})`})}),ct=`Workflow cancelled`,lt=m.object({status:m.enum([`completed`,`failed`]),output:o.optional(),error:m.string().optional(),telemetry:et}),ut=m.enum([`running`,`completed`,`failed`,`skipped`]),dt=m.object({executionId:m.string().min(1),frameId:m.string().min(1),stepId:m.string().min(1),stepType:I,status:ut,startedAt:m.number().optional(),completedAt:m.number().optional(),durationMs:m.number().nonnegative().optional(),inputTokens:m.number().int().nonnegative().optional(),outputTokens:m.number().int().nonnegative().optional(),estimatedCost:m.number().nonnegative().optional(),toolCallCount:m.number().int().nonnegative().optional(),input:m.string().optional(),output:m.string().optional()}),ft=m.enum([`triggered-by`,`feedback-loop`,`rerun-of`]),L=m.object({sourceExecutionId:m.string().min(1),targetExecutionId:m.string().min(1),linkType:ft,metadata:m.record(m.string(),m.unknown()).optional()}),pt=m.object({sourceExecutionId:m.string().min(1).optional(),targetExecutionId:m.string().min(1).optional()}).refine(e=>e.sourceExecutionId!==void 0||e.targetExecutionId!==void 0,{message:`Either sourceExecutionId or targetExecutionId is required.`}),mt={RUN_CONTEXT_NOT_FOUND:`WORKFLOW_RUN_CONTEXT_NOT_FOUND`,SNAPSHOT_UNAVAILABLE:`WORKFLOW_SNAPSHOT_UNAVAILABLE`,SOURCE_MISMATCH:`WORKFLOW_SOURCE_MISMATCH`,NOT_EXECUTABLE:`WORKFLOW_NOT_EXECUTABLE`,HANDLER_UNAVAILABLE:`WORKFLOW_HANDLER_UNAVAILABLE`};var ht=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkflowError`}};const R=m.string().refine(e=>e===``||e.startsWith(`/`),{message:`JSON Patch paths must be empty or start with "/".`}),gt=m.object({op:m.enum([`add`,`replace`,`test`]),path:R,value:o}).strict(),_t=m.object({op:m.literal(`remove`),path:R}).strict(),vt=m.object({op:m.enum([`move`,`copy`]),path:R,from:R}).strict(),z=m.discriminatedUnion(`op`,[gt,_t,vt]),yt=m.object({type:m.literal(`artifact-query`),query:n,select:m.enum([`latest`,`all`]),optional:m.boolean().optional()}),bt=m.object({type:m.literal(`bus-request`),subject:m.string().min(1),payload:m.record(m.string(),m.unknown()).optional(),optional:m.boolean().optional()}),xt=m.discriminatedUnion(`type`,[yt,bt]),St=m.object({type:m.literal(`artifact`),kind:m.string().min(1),schemaVersion:m.string().min(1),scope:e,metadata:m.record(m.string(),m.unknown()).optional()}),Ct=m.object({type:m.literal(`bus-event`),subject:m.string().min(1),payload:m.record(m.string(),m.unknown()).optional()}),wt=m.discriminatedUnion(`type`,[St,Ct]),Tt=m.object({content:m.string(),metadata:m.record(m.string(),m.unknown()).optional()}),Et=m.object({sources:m.record(m.string(),Tt)}),Dt=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`none`)}).strict(),m.object({kind:m.literal(`hmac`),secret:m.string().min(1)}).strict()]),Ot=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`path`),path:m.string().min(1)}).strict(),m.object({kind:m.literal(`source`),filename:m.string().min(1),source:m.string()}).strict(),m.object({kind:m.literal(`definition`),workflowId:m.string().min(1)}).strict()]),B=m.enum([`immediate`,`await-trigger`]),kt=m.object({source:Ot,definition:j.optional(),executionId:m.string().min(1),workflowId:m.string().min(1),triggerPayload:a.default({}),triggerMode:B.optional(),inputs:o.default({}),config:a.optional(),artifactRef:_.optional(),scope:C.default({type:`global`}),busUrl:m.string().optional(),busAuth:Dt.default({kind:`none`}),env:m.record(m.string(),m.string()).default({}),coordinatorSessionId:m.string().min(1),cancelSubject:m.string().min(1),suspensionStrategy:ee.default(`wait-in-process`),terminalAuthority:m.enum([`worker`,`authority`]).optional(),materializationSpec:p.optional()}),V=m.object({executionId:m.string().min(1),workflowId:m.string().min(1)}),At=m.discriminatedUnion(`status`,[V.extend({status:m.literal(`completed`),artifact:t.optional()}).strict(),V.extend({status:m.literal(`failed`),error:m.string().min(1)}).strict(),V.extend({status:m.literal(`cancelled`),reason:m.string().min(1).optional()}).strict(),V.extend({status:m.literal(`paused`),pausedAtGateId:m.string().min(1),pausedAtFrameId:m.string().min(1)}).strict()]),jt=m.object({contributionRefs:m.array(te)}).strict(),Mt=m.discriminatedUnion(`kind`,[m.object({kind:m.literal(`path`),path:m.string().min(1).refine(e=>!e.startsWith(`/`)&&!/^[A-Za-z]:[/\\]/.test(e),{message:`path must be workspace-relative (no leading / or drive letter)`})}).strict(),m.object({kind:m.literal(`source`),filename:m.string().min(1),source:m.string()}).strict(),m.object({kind:m.literal(`definition`),workflowId:m.string().min(1)}).strict()]),Nt=m.object({executionId:m.string().min(1),workflowId:m.string().min(1),source:Mt,definitionSnapshot:j.optional(),workerManifest:jt.default({contributionRefs:[]}),inputs:o.default({}),config:a.optional(),scope:C.default({type:`global`}),triggerPayload:a.default({}),triggerMode:B.optional(),artifactRef:_.optional(),coordinatorSessionId:m.string().min(1),dispatchMetadata:a.optional(),cancelSubject:m.string().min(1),env:m.record(m.string(),m.string()).default({}),createdAt:m.number(),suspensionStrategy:ee.default(`wait-in-process`),terminalAuthority:m.enum([`worker`,`authority`]).optional(),materializationSpec:p.optional()}).superRefine((e,t)=>{e.source.kind===`definition`&&e.definitionSnapshot===void 0&&t.addIssue({code:m.ZodIssueCode.custom,path:[`definitionSnapshot`],message:`definitionSnapshot is required when source.kind is "definition"`}),e.source.kind===`path`?e.materializationSpec===void 0?t.addIssue({code:m.ZodIssueCode.custom,path:[`materializationSpec`],message:`materializationSpec is required when source.kind is "path"`}):e.materializationSpec.sourcePath!==e.source.path&&t.addIssue({code:m.ZodIssueCode.custom,path:[`materializationSpec`,`sourcePath`],message:`materializationSpec.sourcePath must match source.path`}):e.materializationSpec!==void 0&&t.addIssue({code:m.ZodIssueCode.custom,path:[`materializationSpec`],message:`materializationSpec is only valid when source.kind is "path"`})}),H=m.object({executionId:m.string().min(1),workflowId:m.string().min(1),workflowName:m.string().optional(),status:m.enum([`pending`,`running`,`paused`,`finalizing`,`completed`,`failed`,`cancelled`]),startedAt:m.number(),completedAt:m.number().optional(),durationMs:m.number().nonnegative().optional(),totalInputTokens:m.number().int().nonnegative().optional(),totalOutputTokens:m.number().int().nonnegative().optional(),totalEstimatedCost:m.number().nonnegative().optional(),error:m.string().optional(),failedNodeId:m.string().optional()}),Pt=m.object({executionId:m.string().min(1),frameId:m.string().min(1),nodeId:m.string().min(1),nodeType:E,path:m.array(m.string()),status:m.enum([`pending`,`running`,`waiting`,`completed`,`failed`,`skipped`,`cancelled`]),attempt:m.number().int().nonnegative(),iteration:m.number().int().nonnegative().optional(),branchKey:m.string().optional(),startedAt:m.number().optional(),completedAt:m.number().optional(),durationMs:m.number().nonnegative().optional(),inputTokens:m.number().int().nonnegative().optional(),outputTokens:m.number().int().nonnegative().optional(),estimatedCost:m.number().nonnegative().optional(),error:m.string().optional()}),Ft=m.object({executionId:m.string().min(1),frameId:m.string().min(1),nodeId:m.string().min(1),artifact:T,revision:m.string().min(1).optional(),writtenAt:m.number()}),It=m.object({executionId:m.string().min(1),nodeId:m.string().min(1),frameId:m.string().min(1),status:m.enum([`waiting`,`resumed`,`rejected`,`timed-out`,`cancelled`]),prompt:m.string().optional(),openedAt:m.number(),resolvedAt:m.number().optional(),resumeData:o.optional()}),Lt=m.object({executionId:m.string().min(1),inputTokens:m.number().int().nonnegative(),outputTokens:m.number().int().nonnegative(),cachedTokens:m.number().int().nonnegative().optional(),estimatedCost:m.number().nonnegative(),byModel:m.record(m.string(),m.object({inputTokens:m.number().int().nonnegative(),outputTokens:m.number().int().nonnegative(),estimatedCost:m.number().nonnegative()})).optional()}),Rt=m.object({total:m.number().int().nonnegative(),byStatus:m.object({pending:m.number().int().nonnegative(),running:m.number().int().nonnegative(),paused:m.number().int().nonnegative(),finalizing:m.number().int().nonnegative(),completed:m.number().int().nonnegative(),failed:m.number().int().nonnegative(),cancelled:m.number().int().nonnegative()}),totalDurationMs:m.number().nonnegative(),totalInputTokens:m.number().int().nonnegative(),totalOutputTokens:m.number().int().nonnegative(),totalEstimatedCost:m.number().nonnegative()}),zt=m.object({executionId:m.string().min(1),frameId:m.string().min(1),factoryId:m.string().min(1),materializedNodeIds:m.array(m.string().min(1)),factoryInput:r.optional(),materializedAt:m.number()}),Bt=`wfx-ext-`,Vt=m.object({frameId:m.string().min(1).optional(),nodeId:m.string().min(1),nodeType:I,path:m.array(m.string().min(1)).optional(),attempt:m.number().int().nonnegative().default(0),iteration:m.number().int().nonnegative().optional(),branchKey:m.string().min(1).optional(),startedAt:m.number().int().nonnegative().optional()}).strict(),Ht=m.object({frameId:m.string().min(1),nodeId:m.string().min(1),nodeType:I,path:m.array(m.string().min(1)),attempt:m.number().int().nonnegative().default(0),iteration:m.number().int().nonnegative().optional(),branchKey:m.string().min(1).optional(),startedAt:m.number().int().nonnegative(),durationMs:m.number().int().nonnegative().optional()}).strict(),Ut=m.object({executionId:m.string().startsWith(Bt,{message:`executionId must use the wfx-ext- prefix`}).optional(),name:m.string().min(1),startedAt:m.number().int().nonnegative().optional(),scope:C.optional(),artifactRef:_.optional(),input:o.optional(),triggerPayload:a.optional(),frame:Vt.optional()}).superRefine((e,t)=>{e.executionId!==void 0&&e.startedAt===void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`startedAt is required when executionId is supplied`,path:[`startedAt`]})}),Wt=m.object({executionId:m.string().min(1),status:m.enum([`completed`,`failed`,`cancelled`]),error:m.string().min(1).optional(),reason:m.string().min(1).optional(),completedAt:m.number().nonnegative().overwrite(e=>Math.trunc(e)).optional(),frame:Ht.optional()}).superRefine((e,t)=>{if(e.status===`failed`&&e.error===void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`status 'failed' requires a non-empty 'error' message`,path:[`error`]}),e.status===`cancelled`&&e.reason===void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`status 'cancelled' requires a non-empty 'reason' string`,path:[`reason`]}),e.status===`completed`&&e.error!==void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`status 'completed' must not carry an 'error'`,path:[`error`]}),e.status===`completed`&&e.reason!==void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`status 'completed' must not carry a 'reason'`,path:[`reason`]}),e.frame!==void 0&&e.completedAt===void 0&&t.addIssue({code:m.ZodIssueCode.custom,message:`completedAt is required when frame metadata is supplied`,path:[`completedAt`]}),e.frame!==void 0&&e.completedAt!==void 0){let n=e.completedAt-e.frame.startedAt;n<0&&t.addIssue({code:m.ZodIssueCode.custom,message:`completedAt must not precede frame.startedAt`,path:[`completedAt`]}),e.frame.durationMs!==void 0&&e.frame.durationMs!==n&&t.addIssue({code:m.ZodIssueCode.custom,message:`frame.durationMs must equal completedAt - frame.startedAt`,path:[`frame`,`durationMs`]})}}),Gt=m.object({message:m.string().min(1),details:m.string().min(1).optional(),kind:m.string().min(1).optional(),metadata:o.optional()}).strict(),U=m.object({executionId:m.string(),stepId:m.string(),stepType:m.enum([`station`,`delegate-agent`,`delegate-role`,`gate`])}),W=U.extend({stepType:m.literal(`gate`)}),Kt=m.discriminatedUnion(`source`,[W.extend({frameId:m.string(),action:m.enum([`approve`,`reject`]),source:m.literal(`user`),reason:m.string().optional()}),W.extend({frameId:m.string(),action:m.enum([`approve`,`reject`]),source:m.literal(`timeout`)}),W.extend({frameId:m.string(),source:m.literal(`cancelled`)})]),qt=W.extend({workflowId:m.string(),workflowName:m.string(),title:m.string(),message:m.string(),autoAction:m.enum([`approve`,`reject`]),timeoutMs:m.number().nullable(),openedAt:m.number()}),Jt={getDefinition:{request:m.object({id:m.string()}),response:m.object({workflow:j.nullable()})},setDefinition:{request:m.object({workflow:j}),response:m.object({id:m.string()})},deleteDefinition:{request:m.object({id:m.string()}),response:m.object({deleted:m.boolean()})},listDefinitions:{request:Ve,response:m.object({workflows:m.array(j)})},"definition.created":j,"definition.updated":j,"definition.deleted":m.object({id:m.string()}),start:{request:m.object({workflowId:m.string(),input:o.optional(),config:o.optional(),artifactRef:_.optional(),scope:C.optional(),parentSessionId:m.string().optional(),triggerPayload:a.optional()}),response:m.object({executionId:m.string()})},rerun:{request:m.object({executionId:m.string().min(1),mode:m.enum([`snapshot`,`current`]),input:o.optional(),config:o.optional(),artifactRef:_.optional(),scope:C.optional(),parentSessionId:m.string().optional(),triggerPayload:a.optional(),reason:m.string().min(1).optional()}),response:m.object({executionId:m.string()})},cancel:{request:m.object({executionId:m.string(),reason:m.string().optional()}),response:m.object({cancelled:m.boolean()})},bootstrapAuthorityState:{request:m.object({executionId:m.string().min(1),terminalAuthority:m.literal(`authority`),definition:j}).strict(),response:m.object({persisted:m.boolean()})},acceptAuthorityRunnerResult:{request:m.object({executionId:m.string().min(1),result:At.refine(e=>e.status!==`paused`,{message:`Authority runner results must be terminal`})}).strict().superRefine((e,t)=>{e.result.executionId!==e.executionId&&t.addIssue({code:m.ZodIssueCode.custom,path:[`result`,`executionId`],message:`result.executionId must match executionId`})}),response:m.object({accepted:m.boolean(),status:M})},finalizeDelegateResult:{request:_e,response:x},getExecution:{request:m.object({executionId:m.string()}),response:m.object({execution:N.nullable()})},listExecutions:{request:Ke,response:m.object({executions:m.array(N)})},listExecutionsByArtifactRefs:{request:Xe,response:m.object({executionsByRef:m.record(m.string(),m.array(N))})},listSpans:{request:m.object({executionId:m.string()}),response:m.object({spans:m.array(dt)})},listGateInstances:{request:Ze,response:m.object({gates:m.array(ze)})},setExecutionLink:{request:m.object({link:L}),response:m.object({id:m.string()})},listExecutionLinks:{request:pt,response:m.object({links:m.array(L)})},listFrames:{request:m.object({executionId:m.string().min(1)}),response:m.object({frames:m.array(Re)})},runFile:{request:m.object({filePath:m.string().min(1),materializationSpec:p.optional(),triggerPayload:a.optional(),triggerMode:B.default(`immediate`),scope:C.optional()}),response:m.object({executionId:m.string()})},registerExternalExecution:{request:Ut,response:m.object({executionId:m.string(),frameId:m.string().optional()})},completeExternalExecution:{request:Wt,response:m.object({success:m.boolean()})},resolveRole:{request:m.object({roleId:m.string().min(1)}),response:F},resolveAgent:{request:m.object({agentId:m.string().min(1)}),response:Be},getRunContext:{request:m.object({executionId:m.string().min(1)}),response:Nt},"execution.started":m.object({executionId:m.string(),workflowId:m.string(),coordinatorSessionId:m.string().optional(),startedAt:m.number().nonnegative().optional(),artifactRef:_.optional()}),"execution.completed":m.object({executionId:m.string(),workflowId:m.string(),totalDuration:m.number(),completedAt:m.number().nonnegative().optional(),transitionKey:m.string().min(1).optional()}),"execution.failed":m.object({executionId:m.string(),workflowId:m.string(),error:m.string(),failedStepId:m.string().optional(),completedAt:m.number().nonnegative().optional(),transitionKey:m.string().min(1).optional()}),"execution.cancelled":m.object({executionId:m.string(),workflowId:m.string(),reason:m.string().optional(),completedAt:m.number().nonnegative().optional(),transitionKey:m.string().min(1).optional()}),"execution.progress":m.object({executionId:m.string().min(1),workflowId:m.string().min(1),frameId:m.string().min(1),nodeId:m.string().min(1),progress:Gt,emittedAt:m.number().int().nonnegative()}),"execution.paused":g.schema(m.object({executionId:m.string(),workflowId:m.string(),pausedAtGateId:m.string().min(1),pausedAtFrameId:m.string().min(1)}),{traceAll:!0}),"step.beforeStart":U,"step.started":U.extend({sessionId:m.string().optional(),subagentId:m.string().optional()}),"step.completed":U.extend({result:o.optional(),duration:m.number()}),"step.failed":U.extend({error:m.string()}),"step.skipped":U.extend({reason:m.string().optional(),condition:m.string().optional()}),"gate.requested":qt,"gate.awaitApproval":{request:qt,response:m.object({action:m.enum([`approve`,`reject`]),source:m.enum([`user`,`timeout`]),reason:m.string().optional()})},"gate.respond":{request:m.object({executionId:m.string(),gateId:m.string(),action:m.enum([`approve`,`reject`]),frameId:m.string().optional(),resumeData:o,reason:m.string().optional()}),response:m.object({accepted:m.boolean()})},"gate.resolved":Kt,"frame.started":m.object({executionId:m.string(),frameId:m.string(),nodeId:m.string(),nodeType:E,path:m.array(m.string()),parentFrameId:m.string().optional(),startedAt:m.number().nonnegative().optional()}),"frame.completed":m.object({executionId:m.string(),frameId:m.string(),nodeId:m.string(),output:o.optional(),duration:m.number().nonnegative().optional(),completedAt:m.number().nonnegative().optional()}),"frame.failed":m.object({executionId:m.string(),frameId:m.string(),nodeId:m.string(),error:m.string(),duration:m.number().nonnegative().optional(),completedAt:m.number().nonnegative().optional()}),"frame.sessionLinked":m.object({executionId:g.attribute(m.string(),`makaio.execution.id`),frameId:g.attribute(m.string(),`makaio.frame.id`),sessionId:g.attribute(m.string(),`makaio.session.id`)}).strict(),"gate.suspended":m.object({executionId:m.string(),frameId:m.string(),nodeId:m.string(),schema:r,prompt:m.string().optional(),title:m.string().optional(),autoAction:m.enum([`approve`,`reject`]),timeoutMs:m.number().nullable(),openedAt:m.number()}),"gate.resumed":m.object({executionId:m.string(),frameId:m.string(),nodeId:m.string(),resumeData:o}),"dynamic.materialized":m.object({executionId:m.string(),frameId:m.string(),factoryId:m.string().min(1),materializedNodes:m.number().int().nonnegative()}),"artifact.updated":m.object({executionId:m.string(),frameId:m.string(),artifactRef:m.object({kind:m.string().min(1),id:m.string().min(1)}),paths:m.array(m.string()),operation:m.string().min(1),revision:m.string().min(1).optional()}),"worklog.get":{request:m.object({executionId:m.string().min(1)}),response:m.object({summary:H.nullable()})},"worklog.frame.get":{request:m.object({frameId:m.string().min(1)}),response:m.object({frame:Pt.nullable()})},"worklog.list":{request:m.object({workflowId:m.string().min(1).optional(),status:M.optional(),limit:m.number().int().positive().optional(),offset:m.number().int().nonnegative().optional()}),response:m.object({items:m.array(H),total:m.number().int().nonnegative()})},"worklog.stats":{request:m.object({workflowId:m.string().min(1).optional(),since:m.number().int().nonnegative().optional(),until:m.number().int().nonnegative().optional()}),response:m.object({stats:Rt})},"worklog.changed":m.object({executionId:m.string().min(1)}),"state.get":{request:m.object({executionId:m.string().min(1)}),response:m.object({executionId:m.string().min(1),sequence:m.number().int().nonnegative(),value:o})},"state.patch":{request:m.object({executionId:m.string().min(1),expectedSequence:m.number().int().nonnegative(),patch:m.array(z),nextValue:o}),response:m.object({executionId:m.string().min(1),sequence:m.number().int().positive(),value:o})},"state.updated":m.object({executionId:m.string().min(1),sequence:m.number().int().positive(),patch:m.array(z),value:o,updatedAt:m.number().int().positive()})},Yt=h(`workflow`,Jt),Xt=Yt.subjects;function Zt(e,t){G(e,t,void 0,0,[],`root`,void 0,void 0)}function G(e,t,n,r,i,a,o,s){let c={parent:n,depth:r,ancestors:i,relationship:a,...o!==void 0&&{index:o},...s!==void 0&&{branchKey:s}};if(t.enter?.(e,c)===!1)return;let l=[...i,e.id],u=r+1;switch(e.type){case`sequence`:{let n=e;for(let r=0;r<n.nodes.length;r++)G(n.nodes[r],t,e,u,l,`sequence-child`,r,void 0);break}case`parallel`:{let n=e;for(let[r,i]of Object.entries(n.branches))G(i,t,e,u,l,`parallel-branch`,void 0,r);break}case`iterate`:G(e.body,t,e,u,l,`iterate-body`,void 0,void 0);break;case`iterate-chain`:G(e.body,t,e,u,l,`iterate-chain-body`,void 0,void 0);break;case`loop`:G(e.body,t,e,u,l,`loop-body`,void 0,void 0);break}t.leave?.(e,c)}function Qt(e){switch(e){case`station`:case`delegate-agent`:case`delegate-role`:case`gate`:return`leaf`;case`parallel`:case`iterate`:case`iterate-chain`:case`loop`:return`control`;case`sequence`:return`structural`}}function $t(e,t,n){return e===`parallel-branch`&&t!==void 0?[{kind:`branch`,key:t}]:e===`sequence-child`&&n!==void 0?[{kind:`index`,value:n}]:e===`iterate-body`||e===`iterate-chain-body`||e===`loop-body`?[{kind:`body`}]:[]}function en(e){return e.replace(/\\/g,`\\\\`).replace(/\//g,`\\/`)}function tn(e){return e.map(e=>{switch(e.kind){case`node`:return`n:${en(e.id)}`;case`branch`:return`b:${en(e.key)}`;case`index`:return`i:${e.value}`;case`body`:return`body`}}).join(`/`)}function nn(e){let t=[],n=[],r=new Map,i=[],a=[],o=[];return Zt(e.root,{enter(e,s){let c=$t(s.relationship,s.branchKey,s.index),l={kind:`node`,id:e.id};i.push(...c,l),o.push(c.length+1);let u=[...i],d=tn(u),f=a.at(-1);if(t.push({key:d,nodeId:e.id,type:e.type,role:Qt(e.type),path:u,parentKey:f,...s.branchKey!==void 0&&{branchKey:s.branchKey}}),f!==void 0&&s.parent!==void 0)switch(s.parent.type){case`sequence`:{n.push({sourceKey:f,targetKey:d,kind:`contains`});let e=r.get(f);e!==void 0&&n.push({sourceKey:e,targetKey:d,kind:`sequence`}),r.set(f,d);break}case`parallel`:n.push({sourceKey:f,targetKey:d,kind:`branch`});break;case`iterate`:case`iterate-chain`:case`loop`:n.push({sourceKey:f,targetKey:d,kind:`body`});break;default:n.push({sourceKey:f,targetKey:d,kind:`contains`});break}a.push(d)},leave(){let e=o.pop()??0;i.splice(i.length-e,e),a.pop()}}),{nodes:t,edges:n}}const rn=`makaio.bus-event`,an=`makaio.cron`,on=`UTC`;function K(e,t,n){return{kind:e,params:t,...n.filter!==void 0&&{filter:n.filter},...n.filterExpression!==void 0&&{filterExpression:n.filterExpression}}}function sn(e,t){let n=i.parse(t.params);return e.paramsSchema.parse(n),K(e.kind,n,t)}function cn(e){return K(rn,{subject:re(e.subject)},e)}const ln=m.object({schedule:m.string().min(1),timezone:m.string().min(1).default(`UTC`)});function un(e){return K(an,ln.parse(e),{})}function q(e){return J(e.body.nodes,e.id)}function J(e,t){for(let n of e){if(n.type===`loop`)return`Nested loop '${n.id}' found inside loop '${t}' — V1 does not support nested loops`;if(n.type===`sequence`){let e=J(n.nodes,t);if(e)return e}if(n.type===`parallel`)for(let e of Object.values(n.branches)){let n=J(e.nodes,t);if(n)return n}if(n.type===`iterate`||n.type===`iterate-chain`){let e=n.body,r=J(e.nodes,t);if(r)return r}}}const Y=new WeakMap,dn=new WeakMap;function X(e,t,n){let r=Y.get(e);if(r!==void 0&&t.set(e.id,r),e.type===`sequence`)for(let r of e.nodes)X(r,t,n);else if(e.type===`parallel`)for(let r of Object.values(e.branches))X(r,t,n);else if(e.type===`iterate`)X(e.body,t,n);else if(e.type===`iterate-chain`)X(e.body,t,n);else if(e.type===`loop`){if(n!==void 0){let t=dn.get(e);t!==void 0&&n.set(e.gate.handler,t)}X(e.body,t,n)}}function fn(e,t,n){let r={id:e,type:`station`,prompt:e,...n?.when!==void 0&&{when:n.when},...n?.skip!==void 0&&{skip:n.skip}};return Y.set(r,t),r}function pn(e,t,n){return{id:e,type:`delegate-agent`,agentId:t.agentId,...t.inputExpression!==void 0&&{inputExpression:t.inputExpression},...t.outputSchema!==void 0&&{outputSchema:t.outputSchema},...t.allowedTools!==void 0&&{allowedTools:t.allowedTools},...t.completion!==void 0&&{completion:t.completion},...t.resultFinalizerId!==void 0&&{resultFinalizerId:t.resultFinalizerId},...n?.when!==void 0&&{when:n.when},...n?.skip!==void 0&&{skip:n.skip}}}function mn(e,t,n){return{id:e,type:`delegate-role`,role:t,prompt:n?.prompt??e,...n?.when!==void 0&&{when:n.when},...n?.skip!==void 0&&{skip:n.skip},...n?.outputSchema!==void 0&&{outputSchema:n.outputSchema},...n?.timeoutMs!==void 0&&{timeoutMs:n.timeoutMs},...n?.completion!==void 0&&{completion:n.completion},...n?.allowedTools!==void 0&&{allowedTools:n.allowedTools},...n?.resultFinalizerId!==void 0&&{resultFinalizerId:n.resultFinalizerId}}}function hn(e,t){return{id:e,type:`gate`,prompt:t.prompt,autoAction:t.autoAction,timeoutMs:t.timeoutMs,...t.title!==void 0&&{title:t.title},...t.resume!==void 0&&{resumeSchema:s(t.resume)}}}function gn(e,t,n){let r=`${e}__item`,i={id:r,type:`station`,prompt:r},a={id:e,type:`iterate`,collection:n.collection,body:{id:`${e}__body`,type:`sequence`,nodes:[i]},...n.concurrency!==void 0&&{concurrency:n.concurrency},...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}};return Y.set(i,t),a}function _n(e,t,n){return{id:e,type:`iterate-chain`,collection:n.collection,body:{id:`${e}__body`,type:`sequence`,nodes:t},...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}}}function vn(e,t,n){let r={id:e,type:`loop`,maxRounds:n.maxRounds,body:{id:`${e}__body`,type:`sequence`,nodes:t},gate:yn(n),...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}},i=q(r);if(i!==void 0)throw Error(i);return dn.set(r,n.gate.evaluate),r}function yn(e){let t=e.gate.escalation;return{handler:e.gate.handler,...e.gate.input!==void 0&&{input:e.gate.input},...e.gate.config!==void 0&&{config:e.gate.config},...t!==void 0&&{escalation:{prompt:t.prompt,autoAction:t.autoAction??`reject`,timeoutMs:t.timeoutMs??null,...t.title!==void 0&&{title:t.title},...t.resumeSchema!==void 0&&{resumeSchema:t.resumeSchema}}}}}function Z(e,t){if(e.has(t))throw Error(`Duplicate step ID: ${t}`);e.add(t)}function Q(e,t){if(Z(e,t.id),t.type===`sequence`)for(let n of t.nodes)Q(e,n);else if(t.type===`parallel`)for(let n of Object.values(t.branches))Q(e,n);else (t.type===`iterate`||t.type===`iterate-chain`||t.type===`loop`)&&Q(e,t.body)}function bn(e,t,n,r,i){let a={};return t.forEach((t,o)=>{if(t.id.length===0)throw Error(`parallel branch at index ${o} has an empty ID`);let s=t.id,c=`${e}__${s}`;Q(n,t),Z(n,c),X(t,r,i),a[s]={id:c,type:`sequence`,nodes:[t]}}),a}function xn(e,t,n,r,i){let a=`${e}__body`,o=`${e}__item`;Z(r,a),Z(r,o),i.set(o,t);let s={id:o,type:`station`,prompt:o};return{id:e,type:`iterate`,collection:n.collection,body:{id:a,type:`sequence`,nodes:[s]},...n.concurrency!==void 0&&{concurrency:n.concurrency},...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}}}function Sn(e,t,n){return t.resume!==void 0&&(n[e]=t.resume),{id:e,type:`gate`,prompt:t.prompt,autoAction:t.autoAction,timeoutMs:t.timeoutMs,...t.title!==void 0&&{title:t.title},...t.resume!==void 0&&{resumeSchema:s(t.resume)}}}function Cn(e,t,n,r,i,a){let o=`${e}__body`;Z(r,o);for(let e of t)Q(r,e),X(e,i,a);return{id:e,type:`iterate-chain`,collection:n.collection,body:{id:o,type:`sequence`,nodes:t},...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}}}function wn(e,t,n,r,i,a){let o=`${e}__body`;Z(r,o);for(let e of t)Q(r,e),X(e,i,a);let s={id:e,type:`loop`,maxRounds:n.maxRounds,body:{id:o,type:`sequence`,nodes:t},gate:yn(n),...n.when!==void 0&&{when:n.when},...n.skip!==void 0&&{skip:n.skip}},c=q(s);if(c!==void 0)throw Error(c);return a.set(n.gate.handler,n.gate.evaluate),s}function Tn(e,t){e.input=n=>(t.zodSchemas.input=n,t.definition.inputSchema=s(n),e),e.config=n=>(t.zodSchemas.config=n,t.definition.configSchema=s(n),e),e.output=n=>(t.zodSchemas.output=n,t.definition.outputSchema=s(n),e),e.artifact=n=>(n.schema!==void 0&&(t.zodSchemas.artifact=n.schema),t.definition.artifact={kind:n.kind,schemaVersion:n.schemaVersion,scope:n.scope,...n.resolve!==void 0&&{resolve:n.resolve},...n.create!==void 0&&{create:n.create},...n.statusPath!==void 0&&{statusPath:n.statusPath}},e),e.state=e=>(t.definition.state={schema:e.schema,...e.initial!==void 0&&{initial:e.initial}},$(t))}function En(e,t){let{rootNodes:n,runtimeHandlers:r,runtimeLoopGates:i,registeredIds:a,zodGates:o}=t;e.station=(t,i,o)=>(Z(a,t),n.push({id:t,type:`station`,prompt:t,...o?.when!==void 0&&{when:o.when},...o?.skip!==void 0&&{skip:o.skip}}),r.set(t,i),e),e.delegateToAgent=(t,r,i)=>(Z(a,t),n.push(pn(t,r,i)),e),e.delegateToRole=(t,r,i)=>(Z(a,t),n.push(mn(t,r,i)),e),e.parallel=(t,o,s)=>(Z(a,t),n.push({id:t,type:`parallel`,mode:o.mode??`all-settled`,branches:bn(t,s,a,r,i),...o.when!==void 0&&{when:o.when},...o.skip!==void 0&&{skip:o.skip}}),e),e.gate=(t,r)=>(Z(a,t),n.push(Sn(t,r,o)),e),e.iterate=(t,i,o)=>(Z(a,t),n.push(xn(t,i,o,a,r)),e),e.iterateChain=(t,o,s)=>(Z(a,t),n.push(Cn(t,o,s,a,r,i)),e),e.loop=(t,o,s)=>(Z(a,t),n.push(wn(t,o,s,a,r,i)),e),e.addNode=e=>Dn(e,a,r,i,n)}function Dn(e,t,n,r,i){Q(t,e),X(e,n,r),i.push(e)}function $(e){let t={id:e.definition.id,definition:e.definition,runtimeHandlers:e.runtimeHandlers,runtimeFactories:e.runtimeFactories,runtimeLoopGates:e.runtimeLoopGates,source:void 0,get zodSchemas(){return e.zodSchemas},addTrigger(t){return e.triggers.push(t),$(e)}};return Tn(t,e),En(t,e),t}function On(e,t){let n=[],r=new Map,i=new Map,a=new Set,o={},s={gates:o},c=new Map,l=t?.triggers?[...t.triggers]:[];return $({rootNodes:n,runtimeHandlers:r,runtimeFactories:c,runtimeLoopGates:i,registeredIds:a,zodGates:o,zodSchemas:s,definition:{id:e,...t?.name!==void 0&&{name:t.name},...t?.description!==void 0&&{description:t.description},...t?.successFinalizerId!==void 0&&{successFinalizerId:v.parse(t.successFinalizerId)},root:{id:`${e}__root`,type:`sequence`,nodes:n},triggers:l,scope:{type:`global`}},triggers:l})}function kn(e){if(e.workflows.length===0)throw Error(`defineWorkflowBundle: workflows must not be empty`);return{workflows:Object.freeze([...e.workflows])}}const An=m.enum([`artifact.created`,`artifact.revised`,`artifact.status.changed`]),jn=m.record(m.string(),o),Mn=m.object({type:m.string().min(1),input:m.record(m.string(),o).optional()}),Nn=m.object({id:m.string().min(1),description:m.string().optional(),on:An,when:jn.optional(),action:Mn,enabled:m.boolean().default(!0)});export{xt as $,D as $t,Ht as A,M as At,Nt as B,Ee as Bt,Zt as C,_ as Cn,Je as Ct,Xt as D,Ue as Dt,Jt as E,We as Et,H as F,Ce as Ft,kt as G,Re as Gt,At as H,Pe as Ht,Pt as I,Se as It,yt as J,P as Jt,Ot as K,ze as Kt,It as L,w as Lt,Ut as M,Ze as Mt,Ft as N,Me as Nt,Wt as O,He as Ot,zt as P,T as Pt,wt as Q,Ne as Qt,Rt as R,Fe as Rt,nn as S,ve as Sn,Ye as St,Gt as T,ae as Tn,Ge as Tt,B as U,N as Ut,jt as V,De as Vt,Dt as W,C as Wt,bt as X,Ae as Xt,Ct as Y,je as Yt,Et as Z,Ve as Zt,cn as _,pe as _n,at as _t,kn as a,F as an,L as at,un as b,ue as bn,it as bt,mn as c,Ie as cn,ut as ct,_n as d,_e as dn,lt as dt,O as en,Tt as et,vn as f,b as fn,tt as ft,rn as g,fe as gn,ct as gt,sn as h,he as hn,$e as ht,Nn as i,Be as in,pt as it,Vt as j,Xe as jt,Bt as k,Ke as kt,hn as l,A as ln,rt as lt,q as m,y as mn,et as mt,jn as n,Te as nn,ht as nt,On as o,k as on,ft as ot,fn as p,x as pn,nt as pt,St as q,ke as qt,An as r,Oe as rn,mt as rt,pn as s,we as sn,dt as st,Mn as t,E as tn,z as tt,gn as u,ge as un,st as ut,an as v,de as vn,Qe as vt,Yt as w,oe as wn,qe as wt,on as x,ye as xn,ot as xt,ln as y,v as yn,I as yt,Lt as z,j as zt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { AllocationRecordingDecision, AllocationRefEvolution, AllocationRefEvolutionDecision, AllocationTerminationDecision, BeginProvisioningInput, DiscoveredAllocationDecision, DuplicateExecutionAttemptError, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptCreate, ExecutionAttemptOutcomeCommit, ExecutionAttemptOutcomeDecision, ExecutionAttemptRecord, ExecutionAttemptRecoveryOperations, ExecutionAttemptRepository, ExecutionAttemptSettlementKind, ExecutionAttemptStatus, HandoffProviderOperationInput, InfrastructureFailureDecision, PendingAttemptAbandonmentDecision, ProvisionerIncarnationLossDecision, ProvisioningAbsenceDecision, ProvisioningClaimDecision, RecordAllocationInput, RecordAllocationTerminatedInput, RecordInfrastructureFailureInput, RecordProviderOperationUncertaintyInput, RecordProvisionerIncarnationLostInput, RecordProvisioningAbsentInput, RecoverableAttemptRecord, RenewProviderOperationClaimInput, TakeOverProviderOperationInput, sameAllocationRef,
|
|
1
|
+
import { A as RecordProviderOperationUncertaintyInput, C as PendingAttemptAbandonmentDecision, D as RecordAllocationInput, E as ProvisioningClaimDecision, F as TakeOverProviderOperationInput, I as decodeDurableOutcome, L as durableOutcome, M as RecordProvisioningAbsentInput, N as RecoverableAttemptRecord, O as RecordAllocationTerminatedInput, P as RenewProviderOperationClaimInput, R as sameAllocationRef, S as OutcomeCodec, T as ProvisioningAbsenceDecision, _ as ExecutionAttemptSettlementKind, a as BeginProvisioningInput, b as HandoffProviderOperationInput, c as DurableOutcome, d as ExecutionAttemptCreate, f as ExecutionAttemptOutcomeCommit, g as ExecutionAttemptRepository, h as ExecutionAttemptRecoveryOperations, i as AllocationTerminationDecision, j as RecordProvisionerIncarnationLostInput, k as RecordInfrastructureFailureInput, l as EXECUTION_ATTEMPT_SETTLEMENT_KINDS, m as ExecutionAttemptRecord, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptOutcomeDecision, r as AllocationRefEvolutionDecision, s as DuplicateExecutionAttemptError, t as AllocationRecordingDecision, u as EXECUTION_ATTEMPT_STATUSES, v as ExecutionAttemptStatus, w as ProvisionerIncarnationLossDecision, x as InfrastructureFailureDecision, y as ExecutionOwnerId, z as sameDurableOutcome } from "../execution-attempt-repository-DY4KTptE.mjs";
|
|
2
|
+
export { AllocationRecordingDecision, AllocationRefEvolution, AllocationRefEvolutionDecision, AllocationTerminationDecision, BeginProvisioningInput, DiscoveredAllocationDecision, DuplicateExecutionAttemptError, DurableOutcome, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptCreate, ExecutionAttemptOutcomeCommit, ExecutionAttemptOutcomeDecision, ExecutionAttemptRecord, ExecutionAttemptRecoveryOperations, ExecutionAttemptRepository, ExecutionAttemptSettlementKind, ExecutionAttemptStatus, ExecutionOwnerId, HandoffProviderOperationInput, InfrastructureFailureDecision, OutcomeCodec, PendingAttemptAbandonmentDecision, ProvisionerIncarnationLossDecision, ProvisioningAbsenceDecision, ProvisioningClaimDecision, RecordAllocationInput, RecordAllocationTerminatedInput, RecordInfrastructureFailureInput, RecordProviderOperationUncertaintyInput, RecordProvisionerIncarnationLostInput, RecordProvisioningAbsentInput, RecoverableAttemptRecord, RenewProviderOperationClaimInput, TakeOverProviderOperationInput, decodeDurableOutcome, durableOutcome, sameAllocationRef, sameDurableOutcome };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{canonicalStringify as e}from"@makaio/framework/utils";const t=[`pending`,`provisioning`,`allocated`,`settled`],n=[`outcome`,`abandoned`,`infrastructure-failure`];function r(t,n){return e(t)===e(n)}function i(t,n){return e(t)===e(n)}
|
|
1
|
+
import{canonicalStringify as e}from"@makaio/framework/utils";const t=[`pending`,`provisioning`,`allocated`,`settled`],n=[`outcome`,`abandoned`,`infrastructure-failure`];function r(t,n){return e(t)===e(n)}function i(t,n){return e(JSON.parse(t))===e(JSON.parse(n))}function a(e,t){let n=e.serialize(e.parse(t));return{text:n,outcome:o(e,n)}}function o(e,t){return e.parse(JSON.parse(t))}var s=class extends Error{executionAttemptId;constructor(e,t){super(`Execution attempt '${e}' already exists`,t),this.name=`DuplicateExecutionAttemptError`,this.executionAttemptId=e}};export{s as DuplicateExecutionAttemptError,n as EXECUTION_ATTEMPT_SETTLEMENT_KINDS,t as EXECUTION_ATTEMPT_STATUSES,o as decodeDurableOutcome,a as durableOutcome,r as sameAllocationRef,i as sameDurableOutcome};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { a as ProviderOperationClaim, c as ProviderOperationObligation, i as ProcessBoundProvisionerLossProof, l as ProviderOperationOwnershipRecord, n as InitialProviderOperationClaimContextSource, o as ProviderOperationClaimDecision, r as PROVIDER_OPERATION_OBLIGATIONS, s as ProviderOperationMutationDecision, t as InitialProviderOperationClaimContext } from "../provider-operation-DbdyFwNm.mjs";
|
|
2
|
-
import { A as
|
|
3
|
-
import { a as WorkflowEngineServiceOptions, c as ExecutionAttemptAuthority, d as WorkflowWorkspaceRootResolver, f as registerDrizzleWorkflowStorage, i as WorkflowEngineService, l as WorkflowMaterializationSpecResolution, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowMaterializationSpecResolver } from "../package-
|
|
2
|
+
import { A as RecordProviderOperationUncertaintyInput, C as PendingAttemptAbandonmentDecision, D as RecordAllocationInput, E as ProvisioningClaimDecision, F as TakeOverProviderOperationInput, I as decodeDurableOutcome, L as durableOutcome, M as RecordProvisioningAbsentInput, N as RecoverableAttemptRecord, O as RecordAllocationTerminatedInput, P as RenewProviderOperationClaimInput, R as sameAllocationRef, S as OutcomeCodec, T as ProvisioningAbsenceDecision, _ as ExecutionAttemptSettlementKind, a as BeginProvisioningInput, b as HandoffProviderOperationInput, c as DurableOutcome, d as ExecutionAttemptCreate, f as ExecutionAttemptOutcomeCommit, g as ExecutionAttemptRepository, h as ExecutionAttemptRecoveryOperations, i as AllocationTerminationDecision, j as RecordProvisionerIncarnationLostInput, k as RecordInfrastructureFailureInput, l as EXECUTION_ATTEMPT_SETTLEMENT_KINDS, m as ExecutionAttemptRecord, n as AllocationRefEvolution, o as DiscoveredAllocationDecision, p as ExecutionAttemptOutcomeDecision, r as AllocationRefEvolutionDecision, s as DuplicateExecutionAttemptError, t as AllocationRecordingDecision, u as EXECUTION_ATTEMPT_STATUSES, v as ExecutionAttemptStatus, w as ProvisionerIncarnationLossDecision, x as InfrastructureFailureDecision, y as ExecutionOwnerId, z as sameDurableOutcome } from "../execution-attempt-repository-DY4KTptE.mjs";
|
|
3
|
+
import { a as WorkflowEngineServiceOptions, c as ExecutionAttemptAuthority, d as WorkflowWorkspaceRootResolver, f as registerDrizzleWorkflowStorage, i as WorkflowEngineService, l as WorkflowMaterializationSpecResolution, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowMaterializationSpecResolver } from "../package-efR90JGe.mjs";
|
|
4
4
|
import { WorkflowTriggerPayloadPredicate, assertWorkflowTriggerPayload, compileWorkflowTriggerBindingFilter } from "./workflow-trigger-binding-consumer.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import * as _$_makaio_core0 from "@makaio/framework/core";
|
|
7
7
|
import { IMakaioBus } from "@makaio/framework/bus";
|
|
8
8
|
import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
|
|
9
|
-
import { JsonPatchOperation, JsonValue, WorkflowAutomationTriggerBinding, WorkflowExecution, WorkflowExecutionSchema, WorkflowListQuerySchema, WorkflowRunResult,
|
|
9
|
+
import { JsonPatchOperation, JsonValue, WorkflowAutomationTriggerBinding, WorkflowExecution, WorkflowExecutionSchema, WorkflowListQuerySchema, WorkflowRunResult, createWorkflowFinalizerNamespace } from "@makaio/framework/contracts";
|
|
10
10
|
import * as _$drizzle_orm_sqlite_core0 from "drizzle-orm/sqlite-core";
|
|
11
11
|
import * as _$drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
12
12
|
import * as _$_makaio_storage_drizzle0 from "@makaio/framework/storage/drizzle";
|
|
@@ -26,26 +26,181 @@ interface WorkflowSuccessFinalizer {
|
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region subsystems/workflow-engine/src/authority-dispatch-runner.d.ts
|
|
28
28
|
/**
|
|
29
|
-
* Inputs for dispatching an Authority-owned
|
|
29
|
+
* Inputs for dispatching an Authority-owned attempt.
|
|
30
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
30
31
|
*/
|
|
31
|
-
interface AuthorityDispatchRunnerOptions {
|
|
32
|
+
interface AuthorityDispatchRunnerOptions<TOutcome> {
|
|
32
33
|
/** Authority that persists and owns the execution attempt. */
|
|
33
|
-
readonly authority: ExecutionAttemptAuthority
|
|
34
|
-
/**
|
|
35
|
-
readonly executionId:
|
|
34
|
+
readonly authority: ExecutionAttemptAuthority<TOutcome>;
|
|
35
|
+
/** Owner identifier of the aggregate that owns the attempt. */
|
|
36
|
+
readonly executionId: ExecutionOwnerId;
|
|
36
37
|
/** Dispatch operation whose successful return acknowledges acceptance. */
|
|
37
38
|
readonly dispatch: (executionAttemptId: string) => Promise<unknown>;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
|
-
* Dispatch an Authority-owned attempt and await its canonical
|
|
41
|
+
* Dispatch an Authority-owned attempt and await its canonical outcome.
|
|
41
42
|
*
|
|
42
43
|
* A rejected dispatch operation is not proof that no provider received the
|
|
43
44
|
* request. The pending-abandonment CAS distinguishes a confirmed pre-allocation
|
|
44
45
|
* failure from a lost acknowledgement after provisioning, allocation, or settlement.
|
|
45
|
-
* @param options - Authority,
|
|
46
|
-
* @returns The Authority-committed
|
|
46
|
+
* @param options - Authority, owner identity, and dispatch operation.
|
|
47
|
+
* @returns The Authority-committed outcome.
|
|
47
48
|
*/
|
|
48
|
-
declare function runAuthorityDispatchedAttempt(options: AuthorityDispatchRunnerOptions): Promise<
|
|
49
|
+
declare function runAuthorityDispatchedAttempt<TOutcome>(options: AuthorityDispatchRunnerOptions<TOutcome>): Promise<TOutcome>;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region subsystems/workflow-engine/src/outcome-convergence.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Input handed to {@link OutcomeConvergence.converge}.
|
|
54
|
+
*
|
|
55
|
+
* Named rather than inlined so an owner-side realization can state the shape
|
|
56
|
+
* it implements against, and so a consumer can pin it from the public surface.
|
|
57
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
58
|
+
*/
|
|
59
|
+
interface OutcomeConvergenceInput<TOutcome> {
|
|
60
|
+
/** Owner identifier the attempt belongs to. */
|
|
61
|
+
readonly executionId: ExecutionOwnerId;
|
|
62
|
+
/** Authority-created attempt identifier. */
|
|
63
|
+
readonly executionAttemptId: string;
|
|
64
|
+
/** The canonical committed outcome, never the submitter's copy of it. */
|
|
65
|
+
readonly outcome: TOutcome;
|
|
66
|
+
/** The durable decision that produced the committed outcome. */
|
|
67
|
+
readonly decision: 'accepted' | 'duplicate';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Owner-side convergence of a committed attempt outcome.
|
|
71
|
+
*
|
|
72
|
+
* Runs after the durable commit and before waiter settlement and ACK. It is
|
|
73
|
+
* idempotent by contract: it is re-entered for every duplicate retry, because
|
|
74
|
+
* a worker whose first submission committed but did not converge resubmits
|
|
75
|
+
* the same outcome, receives `duplicate`, and must converge again.
|
|
76
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
77
|
+
*/
|
|
78
|
+
interface OutcomeConvergence<TOutcome> {
|
|
79
|
+
/**
|
|
80
|
+
* Converge owner state with the committed outcome.
|
|
81
|
+
* @param input - Attempt identity, the canonical committed outcome, and the
|
|
82
|
+
* durable decision that produced it.
|
|
83
|
+
*/
|
|
84
|
+
converge(input: OutcomeConvergenceInput<TOutcome>): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Owner-side validation that runs before the durable commit.
|
|
88
|
+
*
|
|
89
|
+
* Performs reads only: an outcome it rejects never becomes an immutable
|
|
90
|
+
* attempt outcome, so a corrected retry is not answered as a conflict. What
|
|
91
|
+
* it inspects is the canonical outcome the attempt will hold, obtained from
|
|
92
|
+
* `ExecutionAttemptAuthority.canonicalizeOutcome` before the commit.
|
|
93
|
+
*
|
|
94
|
+
* **A realization must be retry-stable.** {@link submitAttemptOutcome} runs it
|
|
95
|
+
* ahead of every commit, including the retry of a submission that already
|
|
96
|
+
* committed, so its verdict may depend only on the submission itself and on
|
|
97
|
+
* owner facts no convergence step rewrites — never on owner state convergence
|
|
98
|
+
* moves forward. A validator that read, say, a mutable lifecycle status would
|
|
99
|
+
* reject the identical retry of an outcome its own convergence already
|
|
100
|
+
* committed, and the waiter for that outcome would never settle.
|
|
101
|
+
*
|
|
102
|
+
* Retry-stable is measured on the outcome, not on its text. A retry need not
|
|
103
|
+
* render the same text as the first commit: `sameDurableOutcome` judges
|
|
104
|
+
* two texts the same outcome whatever member order they carry and answers
|
|
105
|
+
* `duplicate` for such a retry, while the validator sees the retry's own
|
|
106
|
+
* canonical rendering, never the stored one. Its verdict may therefore turn
|
|
107
|
+
* only on what `sameDurableOutcome` compares — the members and their values
|
|
108
|
+
* — and never on member order or any other detail of one particular
|
|
109
|
+
* rendering. A validator that keyed on which member comes first would reject
|
|
110
|
+
* the retry the repository is about to report as `duplicate`, and the
|
|
111
|
+
* committed-but-unconverged waiter could never recover. Validating the stored
|
|
112
|
+
* representation instead is not an option, for the reason the next paragraph
|
|
113
|
+
* gives: validation runs ahead of the commit, where the retry's rendering is
|
|
114
|
+
* the only one there is.
|
|
115
|
+
*
|
|
116
|
+
* The rule is stated here rather than worked around downstream because the
|
|
117
|
+
* order it constrains is the one that keeps a spoofed outcome out of durable
|
|
118
|
+
* storage: validation cannot move behind the commit without committing what
|
|
119
|
+
* it exists to reject. The workflow adapter's `validateOutcomeExecutionIdentity`
|
|
120
|
+
* satisfies it by correlating the submitted result against immutable durable
|
|
121
|
+
* identity — the execution's own id and workflow id, and the run context's
|
|
122
|
+
* terminal-authority binding, none of which outcome convergence touches.
|
|
123
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
124
|
+
*/
|
|
125
|
+
interface OutcomePreCommitValidation<TOutcome> {
|
|
126
|
+
/**
|
|
127
|
+
* Validate an outcome against owner state.
|
|
128
|
+
*
|
|
129
|
+
* Called again for every retry of the same submission, so the same outcome
|
|
130
|
+
* owes the same verdict — the same as `sameDurableOutcome` reads it,
|
|
131
|
+
* which ignores member order and every other rendering detail, not the
|
|
132
|
+
* same text.
|
|
133
|
+
*
|
|
134
|
+
* The outcome handed over is the canonical one — what the attempt will
|
|
135
|
+
* hold and what {@link OutcomeConvergence.converge} will receive — not the
|
|
136
|
+
* submitter's copy of it. A codec may normalize while serializing, so
|
|
137
|
+
* validating the copy would let an outcome the validator would have
|
|
138
|
+
* rejected become the immutable committed one.
|
|
139
|
+
* @param executionId - Owner identifier the attempt belongs to.
|
|
140
|
+
* @param outcome - Canonical outcome about to be committed.
|
|
141
|
+
* @throws When the outcome must not be committed.
|
|
142
|
+
*/
|
|
143
|
+
validate(executionId: ExecutionOwnerId, outcome: TOutcome): Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Dependencies of {@link submitAttemptOutcome}.
|
|
147
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
148
|
+
*/
|
|
149
|
+
interface AttemptOutcomeSubmissionDeps<TOutcome> {
|
|
150
|
+
/** Authority that commits the outcome and holds the in-process waiter. */
|
|
151
|
+
readonly authority: ExecutionAttemptAuthority<TOutcome>;
|
|
152
|
+
/** Owner convergence that runs for `accepted` and `duplicate` decisions. */
|
|
153
|
+
readonly convergence: OutcomeConvergence<TOutcome>;
|
|
154
|
+
/** Optional owner validation that runs before the durable commit. */
|
|
155
|
+
readonly validation?: OutcomePreCommitValidation<TOutcome>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Input of {@link submitAttemptOutcome}.
|
|
159
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
160
|
+
*/
|
|
161
|
+
interface AttemptOutcomeSubmission<TOutcome> {
|
|
162
|
+
/** Owner identifier the attempt belongs to. */
|
|
163
|
+
readonly executionId: ExecutionOwnerId;
|
|
164
|
+
/** Authority-created attempt identifier. */
|
|
165
|
+
readonly executionAttemptId: string;
|
|
166
|
+
/** Outcome the worker submitted. */
|
|
167
|
+
readonly outcome: TOutcome;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Submit an attempt outcome through the generic owner boundary.
|
|
171
|
+
*
|
|
172
|
+
* Order: one canonicalization of the submitted outcome, optional pre-commit
|
|
173
|
+
* validation of that canonical value, durable commit of that same rendering
|
|
174
|
+
* through the authority, owner convergence for `accepted` and `duplicate`,
|
|
175
|
+
* then waiter settlement on a fresh decode of the text the decision reports
|
|
176
|
+
* as committed. The decision kind is returned for the caller's
|
|
177
|
+
* acknowledgement.
|
|
178
|
+
*
|
|
179
|
+
* Invariants this function keeps:
|
|
180
|
+
* - the submission is rendered exactly once, and the submitter's object is
|
|
181
|
+
* never read again after that: an outcome the caller mutates while an await
|
|
182
|
+
* is pending can reach neither the validation nor the durable write;
|
|
183
|
+
* - validation and convergence see one and the same value: the canonical
|
|
184
|
+
* outcome the attempt holds, never the submitter's copy of it;
|
|
185
|
+
* - convergence only ever sees `decision.outcome`, the repository's own
|
|
186
|
+
* committed object;
|
|
187
|
+
* - the waiter settles on a value decoded afresh from the text the attempt
|
|
188
|
+
* stores — the decision's own text, which for a `duplicate` is the first
|
|
189
|
+
* commit's rather than the retry's — so what a runner receives is the
|
|
190
|
+
* committed outcome even when convergence mutated the object it was handed;
|
|
191
|
+
* - a throwing convergence leaves the outcome durably committed and the
|
|
192
|
+
* waiter pending, so the worker's retry yields `duplicate` and converges
|
|
193
|
+
* again; nothing is rejected or deleted here. That recovery path runs the
|
|
194
|
+
* validation again first, which is why {@link OutcomePreCommitValidation}
|
|
195
|
+
* owes a retry-stable verdict;
|
|
196
|
+
* - `conflict` and `fenced` skip convergence and settlement; their waiter
|
|
197
|
+
* rejection already happened inside `ExecutionAttemptAuthority.commitOutcome`.
|
|
198
|
+
* @param deps - Authority, convergence, and optional validation.
|
|
199
|
+
* @param input - Attempt identity and submitted outcome.
|
|
200
|
+
* @returns The durable decision kind.
|
|
201
|
+
* @typeParam TOutcome - Owner-specific outcome type committed per attempt.
|
|
202
|
+
*/
|
|
203
|
+
declare function submitAttemptOutcome<TOutcome>(deps: AttemptOutcomeSubmissionDeps<TOutcome>, input: AttemptOutcomeSubmission<TOutcome>): Promise<'accepted' | 'duplicate' | 'conflict' | 'fenced'>;
|
|
49
204
|
//#endregion
|
|
50
205
|
//#region subsystems/workflow-engine/src/storage/namespace.d.ts
|
|
51
206
|
/**
|
|
@@ -700,8 +855,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
700
855
|
"exit-and-resume": "exit-and-resume";
|
|
701
856
|
}>>;
|
|
702
857
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
703
|
-
authority: "authority";
|
|
704
858
|
worker: "worker";
|
|
859
|
+
authority: "authority";
|
|
705
860
|
}>>;
|
|
706
861
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
707
862
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -1795,8 +1950,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1795
1950
|
"exit-and-resume": "exit-and-resume";
|
|
1796
1951
|
}>>;
|
|
1797
1952
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
1798
|
-
authority: "authority";
|
|
1799
1953
|
worker: "worker";
|
|
1954
|
+
authority: "authority";
|
|
1800
1955
|
}>>;
|
|
1801
1956
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1802
1957
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -1982,8 +2137,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1982
2137
|
"exit-and-resume": "exit-and-resume";
|
|
1983
2138
|
}>>;
|
|
1984
2139
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
1985
|
-
authority: "authority";
|
|
1986
2140
|
worker: "worker";
|
|
2141
|
+
authority: "authority";
|
|
1987
2142
|
}>>;
|
|
1988
2143
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1989
2144
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -4382,7 +4537,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
4382
4537
|
tableName: "workflow_run_contexts";
|
|
4383
4538
|
dataType: "string";
|
|
4384
4539
|
columnType: "SQLiteText";
|
|
4385
|
-
data: "
|
|
4540
|
+
data: "worker" | "authority" | undefined;
|
|
4386
4541
|
driverParam: string;
|
|
4387
4542
|
notNull: false;
|
|
4388
4543
|
hasDefault: false;
|
|
@@ -4395,7 +4550,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
4395
4550
|
generated: undefined;
|
|
4396
4551
|
}, {}, {
|
|
4397
4552
|
length: number | undefined;
|
|
4398
|
-
$type: "
|
|
4553
|
+
$type: "worker" | "authority" | undefined;
|
|
4399
4554
|
}>;
|
|
4400
4555
|
materializationSpec: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
|
|
4401
4556
|
name: string;
|
|
@@ -6323,8 +6478,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6323
6478
|
"exit-and-resume": "exit-and-resume";
|
|
6324
6479
|
}>>;
|
|
6325
6480
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
6326
|
-
authority: "authority";
|
|
6327
6481
|
worker: "worker";
|
|
6482
|
+
authority: "authority";
|
|
6328
6483
|
}>>;
|
|
6329
6484
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6330
6485
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -7418,8 +7573,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
7418
7573
|
"exit-and-resume": "exit-and-resume";
|
|
7419
7574
|
}>>;
|
|
7420
7575
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
7421
|
-
authority: "authority";
|
|
7422
7576
|
worker: "worker";
|
|
7577
|
+
authority: "authority";
|
|
7423
7578
|
}>>;
|
|
7424
7579
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7425
7580
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -7605,8 +7760,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
7605
7760
|
"exit-and-resume": "exit-and-resume";
|
|
7606
7761
|
}>>;
|
|
7607
7762
|
terminalAuthority: z.ZodOptional<z.ZodEnum<{
|
|
7608
|
-
authority: "authority";
|
|
7609
7763
|
worker: "worker";
|
|
7764
|
+
authority: "authority";
|
|
7610
7765
|
}>>;
|
|
7611
7766
|
materializationSpec: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7612
7767
|
kind: z.ZodLiteral<"local-directory">;
|
|
@@ -7767,7 +7922,7 @@ declare const workflowDefinitionsDual: _$_makaio_storage_drizzle0.DualTable<"wor
|
|
|
7767
7922
|
}>>;
|
|
7768
7923
|
/**
|
|
7769
7924
|
* Portable executable source for worker dispatch (JSON).
|
|
7770
|
-
* Tells the runtime where to load the workflow module on a worker
|
|
7925
|
+
* Tells the runtime where to load the workflow module on a worker.
|
|
7771
7926
|
*/
|
|
7772
7927
|
executableSource: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextJsonBuilderInitial<string>, {
|
|
7773
7928
|
kind: "path";
|
|
@@ -7791,7 +7946,7 @@ declare const workflowDefinitionsDual: _$_makaio_storage_drizzle0.DualTable<"wor
|
|
|
7791
7946
|
workflowId: string;
|
|
7792
7947
|
}>>;
|
|
7793
7948
|
/**
|
|
7794
|
-
* Resource requirements for
|
|
7949
|
+
* Resource requirements for Worker provider selection (JSON).
|
|
7795
7950
|
* Constrains pool/provider matching during dispatch.
|
|
7796
7951
|
*/
|
|
7797
7952
|
requirements: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextJsonBuilderInitial<string>, {
|
|
@@ -8067,4 +8222,4 @@ declare function patchWorkflowState(db: MakaioDatabase, params: {
|
|
|
8067
8222
|
value: JsonValue;
|
|
8068
8223
|
}>;
|
|
8069
8224
|
//#endregion
|
|
8070
|
-
export { type AllocationRecordingDecision, type AllocationRefEvolution, type AllocationRefEvolutionDecision, type AllocationTerminationDecision, type AuthorityDispatchRunnerOptions, type BeginProvisioningInput, type DiscoveredAllocationDecision, DuplicateExecutionAttemptError, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptAuthority, type ExecutionAttemptCreate, type ExecutionAttemptOutcomeCommit, type ExecutionAttemptOutcomeDecision, type ExecutionAttemptRecord, type ExecutionAttemptRecoveryOperations, type ExecutionAttemptRepository, type ExecutionAttemptSettlementKind, type ExecutionAttemptStatus, type HandoffProviderOperationInput, type InfrastructureFailureDecision, type InitialProviderOperationClaimContext, type InitialProviderOperationClaimContextSource, PROVIDER_OPERATION_OBLIGATIONS, type PendingAttemptAbandonmentDecision, type ProcessBoundProvisionerLossProof, type ProviderOperationClaim, type ProviderOperationClaimDecision, type ProviderOperationMutationDecision, type ProviderOperationObligation, type ProviderOperationOwnershipRecord, type ProvisionerIncarnationLossDecision, type ProvisioningAbsenceDecision, type ProvisioningClaimDecision, type RecordAllocationInput, type RecordAllocationTerminatedInput, type RecordInfrastructureFailureInput, type RecordProviderOperationUncertaintyInput, type RecordProvisionerIncarnationLostInput, type RecordProvisioningAbsentInput, type RecoverableAttemptRecord, type RenewProviderOperationClaimInput, type TakeOverProviderOperationInput, WorkflowEngineService, type WorkflowEngineServiceOptions, WorkflowEngineToken, WorkflowExecutor, type WorkflowMaterializationSpecResolution, type WorkflowMaterializationSpecResolver, WorkflowStorageNamespace, WorkflowStorageSubjects, type WorkflowSuccessFinalizer, type WorkflowTriggerPayloadPredicate, WorkflowTriggerReconciler, type WorkflowWorkspaceRootResolver, assertWorkflowTriggerPayload, buildWorkflowExpressionContextFromResolvedInputs, compileWorkflowTriggerBindingFilter, createWorkflowEnginePackage, getWorkflowState, initializeWorkflowState, patchWorkflowState, registerDrizzleWorkflowStorage, runAuthorityDispatchedAttempt, runShellStep, sameAllocationRef,
|
|
8225
|
+
export { type AllocationRecordingDecision, type AllocationRefEvolution, type AllocationRefEvolutionDecision, type AllocationTerminationDecision, type AttemptOutcomeSubmission, type AttemptOutcomeSubmissionDeps, type AuthorityDispatchRunnerOptions, type BeginProvisioningInput, type DiscoveredAllocationDecision, DuplicateExecutionAttemptError, type DurableOutcome, EXECUTION_ATTEMPT_SETTLEMENT_KINDS, EXECUTION_ATTEMPT_STATUSES, ExecutionAttemptAuthority, type ExecutionAttemptCreate, type ExecutionAttemptOutcomeCommit, type ExecutionAttemptOutcomeDecision, type ExecutionAttemptRecord, type ExecutionAttemptRecoveryOperations, type ExecutionAttemptRepository, type ExecutionAttemptSettlementKind, type ExecutionAttemptStatus, type ExecutionOwnerId, type HandoffProviderOperationInput, type InfrastructureFailureDecision, type InitialProviderOperationClaimContext, type InitialProviderOperationClaimContextSource, type OutcomeCodec, type OutcomeConvergence, type OutcomeConvergenceInput, type OutcomePreCommitValidation, PROVIDER_OPERATION_OBLIGATIONS, type PendingAttemptAbandonmentDecision, type ProcessBoundProvisionerLossProof, type ProviderOperationClaim, type ProviderOperationClaimDecision, type ProviderOperationMutationDecision, type ProviderOperationObligation, type ProviderOperationOwnershipRecord, type ProvisionerIncarnationLossDecision, type ProvisioningAbsenceDecision, type ProvisioningClaimDecision, type RecordAllocationInput, type RecordAllocationTerminatedInput, type RecordInfrastructureFailureInput, type RecordProviderOperationUncertaintyInput, type RecordProvisionerIncarnationLostInput, type RecordProvisioningAbsentInput, type RecoverableAttemptRecord, type RenewProviderOperationClaimInput, type TakeOverProviderOperationInput, WorkflowEngineService, type WorkflowEngineServiceOptions, WorkflowEngineToken, WorkflowExecutor, type WorkflowMaterializationSpecResolution, type WorkflowMaterializationSpecResolver, WorkflowStorageNamespace, WorkflowStorageSubjects, type WorkflowSuccessFinalizer, type WorkflowTriggerPayloadPredicate, WorkflowTriggerReconciler, type WorkflowWorkspaceRootResolver, assertWorkflowTriggerPayload, buildWorkflowExpressionContextFromResolvedInputs, compileWorkflowTriggerBindingFilter, createWorkflowEnginePackage, decodeDurableOutcome, durableOutcome, getWorkflowState, initializeWorkflowState, patchWorkflowState, registerDrizzleWorkflowStorage, runAuthorityDispatchedAttempt, runShellStep, sameAllocationRef, sameDurableOutcome, submitAttemptOutcome, workflowDefinitionsDual, workflowEnginePackage, workflowExecutionStateDual, workflowExecutionStateEventsDual, workflowExecutionsDual, workflowFinalizationsDual, workflowStepSpansDual, worklogFrameEntriesDual, worklogSummariesDual };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,H as t,M as n,P as r,T as i,W as a,X as o,et as s,g as c,it as l,j as u,ot as d}from"../authority-state-bootstrap-
|
|
1
|
+
import{B as e,H as t,M as n,P as r,T as i,W as a,X as o,et as s,g as c,it as l,j as u,ot as d}from"../authority-state-bootstrap-eitx6Ukn.mjs";import{a as f,c as p,d as m,f as h,i as g,l as _,n as v,o as y,r as b,s as x,t as S,u as C}from"../package-Cgjpm9om.mjs";import{assertWorkflowTriggerPayload as w,compileWorkflowTriggerBindingFilter as T}from"./workflow-trigger-binding-consumer.mjs";import{DuplicateExecutionAttemptError as E,EXECUTION_ATTEMPT_SETTLEMENT_KINDS as D,EXECUTION_ATTEMPT_STATUSES as O,decodeDurableOutcome as k,durableOutcome as A,sameAllocationRef as j,sameDurableOutcome as M}from"./execution-attempt-repository.mjs";import{PROVIDER_OPERATION_OBLIGATIONS as N}from"./provider-operation.mjs";import{JsonValueSchema as P,WorkflowFrameStateSchema as F}from"@makaio/framework/contracts";const I=new Set([...F.shape.status.options]);function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){if(!L(e))return!1;for(let t of Object.values(e))if(!L(t)||typeof t.status!=`string`||!I.has(t.status)||`result`in t&&t.result!==void 0&&!P.safeParse(t.result).success)return!1;return!0}function z(e){let t={trigger:L(e.trigger)?e.trigger:{},steps:R(e.steps)?e.steps:{},inputs:P.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{E as DuplicateExecutionAttemptError,D as EXECUTION_ATTEMPT_SETTLEMENT_KINDS,O as EXECUTION_ATTEMPT_STATUSES,f as ExecutionAttemptAuthority,N as PROVIDER_OPERATION_OBLIGATIONS,g as WorkflowEngineService,S as WorkflowEngineToken,x as WorkflowExecutor,u as WorkflowStorageNamespace,n as WorkflowStorageSubjects,y as WorkflowTriggerReconciler,w as assertWorkflowTriggerPayload,z as buildWorkflowExpressionContextFromResolvedInputs,T as compileWorkflowTriggerBindingFilter,v as createWorkflowEnginePackage,k as decodeDurableOutcome,A as durableOutcome,C as getWorkflowState,m as initializeWorkflowState,h as patchWorkflowState,_ as registerDrizzleWorkflowStorage,c as runAuthorityDispatchedAttempt,i as runShellStep,j as sameAllocationRef,M as sameDurableOutcome,p as submitAttemptOutcome,r as workflowDefinitionsDual,b as workflowEnginePackage,e as workflowExecutionStateDual,t as workflowExecutionStateEventsDual,a as workflowExecutionsDual,d as workflowFinalizationsDual,o as workflowStepSpansDual,s as worklogFrameEntriesDual,l as worklogSummariesDual};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-
|
|
1
|
+
import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-efR90JGe.mjs";
|
|
2
2
|
export { WorkflowEngineToken, createWorkflowEnginePackage, workflowEnginePackage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"../package-
|
|
1
|
+
import{n as e,r as t,t as n}from"../package-Cgjpm9om.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
|