@makaio/framework 1.0.0-dev-1790248497521 → 1.0.0-dev-1790535947927

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.
Files changed (90) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/adapters/claude/index.d.mts +24 -24
  3. package/dist/artifact-C4J_FDq8.mjs +1 -0
  4. package/dist/bus/index.mjs +1 -1
  5. package/dist/bus-DzEgIHGt.mjs +9 -0
  6. package/dist/clients/index.d.mts +5 -5
  7. package/dist/contracts/adapter/index.d.mts +1 -1
  8. package/dist/contracts/artifact/index.d.mts +3 -3
  9. package/dist/contracts/artifact/index.mjs +1 -1
  10. package/dist/contracts/capabilities/index.d.mts +1 -1
  11. package/dist/contracts/client/index.d.mts +1 -1
  12. package/dist/contracts/extension/index.d.mts +3 -3
  13. package/dist/contracts/extension/index.mjs +1 -1
  14. package/dist/contracts/harness/index.d.mts +1 -1
  15. package/dist/contracts/index.d.mts +46 -46
  16. package/dist/contracts/index.mjs +1 -1
  17. package/dist/contracts/materialization/index.d.mts +2 -2
  18. package/dist/contracts/materialization/index.mjs +1 -1
  19. package/dist/contracts/session/index.d.mts +2 -2
  20. package/dist/contracts/shared/index.d.mts +1 -1
  21. package/dist/contracts/variant/index.d.mts +1 -1
  22. package/dist/contracts/worker/index.d.mts +1 -1
  23. package/dist/contracts/worker/index.mjs +1 -1
  24. package/dist/contracts/workflow/index.d.mts +2 -2
  25. package/dist/contracts/workflow/index.mjs +1 -1
  26. package/dist/{extension-C6ANjR33.mjs → extension-BOMfXdko.mjs} +1 -1
  27. package/dist/{index-D5Lw1UsO.d.mts → index-B1iXL1pW.d.mts} +8 -8
  28. package/dist/{index-DDCixELI.d.mts → index-BUxs65tf.d.mts} +1 -1
  29. package/dist/{index-rkN_9bde.d.mts → index-BVN64wQx.d.mts} +24 -24
  30. package/dist/{index-Bon00c4i.d.mts → index-Bc4u4rD8.d.mts} +5 -5
  31. package/dist/{index-CEX9qfLa.d.mts → index-Bgz81LHZ.d.mts} +1 -1
  32. package/dist/{index-BrMihjbI.d.mts → index-CEy4pCZ0.d.mts} +76 -76
  33. package/dist/{index-DJLRXASA.d.mts → index-CMsQnCAu.d.mts} +38 -38
  34. package/dist/{index-BM53WQaQ.d.mts → index-CVRQS5jk.d.mts} +1 -1
  35. package/dist/{index-Dcwee5Cl.d.mts → index-CWry0rks.d.mts} +195 -89
  36. package/dist/{index-6UlianLY2.d.mts → index-CnQw9he92.d.mts} +8 -8
  37. package/dist/{index-CydQ1dLS2.d.mts → index-DIOmmpkx2.d.mts} +6 -3
  38. package/dist/{index-C4VB63lu.d.mts → index-DPc-Lstu.d.mts} +95 -77
  39. package/dist/{index-D5BLD2Pw.d.mts → index-DqN1u0Y2.d.mts} +6 -6
  40. package/dist/{index-LCumcYK12.d.mts → index-DzOTNzZv2.d.mts} +38 -38
  41. package/dist/{index-wGlFWRXg.d.mts → index-aAo9ugCm.d.mts} +4 -4
  42. package/dist/{index-QgSmUedN.d.mts → index-lSpH5lvV.d.mts} +5 -5
  43. package/dist/{index-BZQ3OviE.d.mts → index-oE2q0pTG.d.mts} +1 -1
  44. package/dist/kernel/extension/index.d.mts +2 -2
  45. package/dist/kernel/index.d.mts +2 -2
  46. package/dist/kernel/observability/index.d.mts +1 -1
  47. package/dist/kind-registration-DdbhhvaT.mjs +1 -0
  48. package/dist/{materialization-CIrHHspa.mjs → materialization-CxV6fpuB.mjs} +1 -1
  49. package/dist/{namespace-C5tKjqgb.d.mts → namespace-B9iQN3FQ.d.mts} +4 -4
  50. package/dist/{namespace-BEi98VfQ.d.mts → namespace-Bz0ZDWhE.d.mts} +18 -18
  51. package/dist/{namespace-D8oTiLLo.d.mts → namespace-C1-ZAKEG.d.mts} +6 -6
  52. package/dist/{namespace-D6W4Erwp.d.mts → namespace-DAzOxaux.d.mts} +2 -2
  53. package/dist/{package-BswWlFSn.d.mts → package-DT1Jaweg.d.mts} +2 -1
  54. package/dist/package.json +1 -1
  55. package/dist/{schemas-CU2NE5Lg.d.mts → schemas-B-2yBaGk.d.mts} +11 -7
  56. package/dist/{schemas-Cb9OJ9va.d.mts → schemas-CBDNnyz4.d.mts} +1 -1
  57. package/dist/{schemas-CrOeGZHg.d.mts → schemas-Dec5VtBU.d.mts} +10 -10
  58. package/dist/{schemas-__oTCzF6.d.mts → schemas-Dyp3rHZ7.d.mts} +4 -4
  59. package/dist/schemas-W3nT06vH.mjs +1 -0
  60. package/dist/services/adapter-runtime/index.d.mts +3 -3
  61. package/dist/services/adapter-runtime/namespace.d.mts +1 -1
  62. package/dist/services/adapter-runtime/schemas.d.mts +1 -1
  63. package/dist/services/adapter-subsystem/index.d.mts +2 -2
  64. package/dist/services/adapter-subsystem/namespace.d.mts +1 -1
  65. package/dist/services/context-rules/index.d.mts +3 -3
  66. package/dist/services/filesystem/namespace.d.mts +6 -6
  67. package/dist/services/filesystem/schemas.d.mts +3 -3
  68. package/dist/services/git/namespace.d.mts +2 -2
  69. package/dist/services/git/schemas.d.mts +1 -1
  70. package/dist/services/harness/index.d.mts +3 -3
  71. package/dist/services/index.d.mts +25 -25
  72. package/dist/services/provider-context/index.d.mts +1 -1
  73. package/dist/services/session/index.d.mts +4 -4
  74. package/dist/services/session/messages/namespace.d.mts +1 -1
  75. package/dist/services/session/session-events/namespace.d.mts +1 -1
  76. package/dist/services/settings/namespace.d.mts +10 -10
  77. package/dist/services/subagent-template/index.d.mts +1 -1
  78. package/dist/services/subagent-template/schemas.d.mts +1 -1
  79. package/dist/{transition-CSN6QoMp.d.mts → transition-DH313MFE.d.mts} +1 -1
  80. package/dist/{types-BP_P1izV.d.mts → types-qna5Bcs8.d.mts} +16 -16
  81. package/dist/{view-builder-2cR7vI7R.d.mts → view-builder-D6W7fBUv.d.mts} +8 -8
  82. package/dist/{worker-YKEWHrx5.mjs → worker-zHq43Iyk.mjs} +1 -1
  83. package/dist/{workflow-01evBylF.mjs → workflow-BFAraH3Y.mjs} +1 -1
  84. package/dist/workflow-engine/index.d.mts +18 -18
  85. package/dist/workflow-engine/package.d.mts +1 -1
  86. package/package.json +1 -1
  87. package/dist/artifact-DF2UJsjP.mjs +0 -1
  88. package/dist/bus-DgpPEPoM.mjs +0 -9
  89. package/dist/kind-registration-Dzfo6kyb.mjs +0 -1
  90. package/dist/schemas-CHM0wMq4.mjs +0 -1
@@ -1,5 +1,5 @@
1
1
  import { $ as InitialProviderOperationClaimContextSource, $t as AttemptSettlementSnapshot, A as OperationReportDecision, At as evaluateRuntimeReadiness, B as RecordProvisioningAbsentInput, Bt as snapshotRequestExecutionCancellationInput, C as ExecutionAttemptStatus, Ct as RuntimeOutcomeFenceMismatchError, D as MarkRuntimeReadyInput, Dt as evaluateOperationCompletion, E as InfrastructureFailureDecision, Et as evaluateOperationAdmission, F as ReadBootstrapStartStateInput, Ft as RequestAttemptCancellationInput, G as RuntimeRegistrationDecision, Gt as ReadAttemptCancellationControlInput, H as RegisterRuntimeInput, Ht as AttemptControlEvidence, I as RecordAllocationInput, It as RequestExecutionCancellationInput, J as sameAllocationRef, Jt as evaluateAttemptControlReceipt, K as decodeDurableOutcome, Kt as RecordAttemptControlReceiptInput, L as RecordAllocationTerminatedInput, Lt as evaluateAttemptCancellation, M as PendingAttemptAbandonmentDecision, Mt as AttemptOutcomeControlObservation, Nt as ExecutionAttemptCancellationDecision, O as OperationAdmissionDecision, Ot as evaluatePreparationReport, P as ProvisioningClaimDecision, Pt as ExecutionAttemptCancellationIntent, Q as InitialProviderOperationClaimContext, Qt as AttemptSettlementRead, R as RecordInfrastructureFailureInput, Rt as snapshotAttemptOutcomeControl, S as ExecutionAttemptSettlementKind, St as RuntimeOutcomeFence, T as GetInstructionInput, Tt as evaluateAttemptReachability, U as ReportOperationInput, Ut as AttemptControlEvidenceDecision, V as RecoverableAttemptRecord, Vt as AttemptCancellationControlState, W as RuntimeReadinessDecision, Wt as AttemptControlEvidenceRepository, X as CompleteProviderOperationInput, Xt as snapshotAttemptControlReceipt, Y as sameDurableOutcome, Yt as evaluateAttemptControlReport, Z as HandoffProviderOperationInput, Zt as snapshotAttemptControlReport, _ as EXECUTION_ATTEMPT_STATUSES, _t as isProviderOperationResolved, a as AllocationRefEvolutionDecision, an as replayEnsuredAttempt, at as ProviderOperationClaimDecision, b as ExecutionAttemptRecoveryOperations, bt as AttemptReachability, cn as snapshotReadAttemptSettlementInput, ct as ProviderOperationLeaseRenewal, d as BootstrapStartState, dt as ProviderOperationOwnershipRecord, en as EnsureExecutionAttemptDecision, et as ListOpenProviderOperationsInput, f as CompleteOperationInput, ft as ProvisionerIncarnationLossDecision, g as EXECUTION_ATTEMPT_SETTLEMENT_KINDS, gt as TakeOverProviderOperationInput, h as DurableOutcome, ht as RenewProviderOperationClaimInput, i as AllocationRefEvolution, in as readAttemptSettlementSnapshot, it as ProviderOperationClaim, j as OutcomeCodec, jt as evaluateRuntimeRegistration, k as OperationCompletionDecision, kt as evaluateProvisionerIncarnationLoss, l as AttemptOperationStartGate, lt as ProviderOperationMutationDecision, m as DuplicateExecutionAttemptError, mt as RecordProviderOperationUncertaintyInput, n as AdmitOperationInput, nn as EnsureExecutionAttemptPersistenceInput, nt as PROVIDER_OPERATION_OBLIGATIONS, o as AllocationTerminationDecision, on as snapshotEnsureExecutionAttemptInput, ot as ProviderOperationCompletionDecision, p as DiscoveredAllocationDecision, pt as ProvisioningAbsenceDecision, q as durableOutcome, qt as ReportAttemptControlInput, r as AllocationRecordingDecision, rn as ReadAttemptSettlementInput, rt as ProcessBoundProvisionerLossProof, s as AttemptControlState, sn as snapshotEnsureExecutionAttemptPersistenceInput, st as ProviderOperationLeasePolicy, t as ATTEMPT_OPERATION_START_GATES, tn as EnsureExecutionAttemptInput, tt as OpenProviderOperationRecord, u as BeginProvisioningInput, ut as ProviderOperationObligation, v as ExecutionAttemptCreate, vt as ExecutionAttemptOutcomeCommit, w as ExecutionOwnerId, wt as assertRuntimeOutcomeFence, x as ExecutionAttemptRepository, xt as AttemptReachabilityDecision, y as ExecutionAttemptRecord, yt as ExecutionAttemptOutcomeDecision, z as RecordProvisionerIncarnationLostInput, zt as snapshotRequestAttemptCancellationInput } from "../execution-attempt-repository-C2XKRZ3O.mjs";
2
- import { A as BootstrapStartOptions, C as OutcomeAcceptance, D as submitAttemptOutcome, E as OutcomePreCommitValidation, M as WorkflowMaterializationSpecResolver, N as WorkflowWorkspaceRootResolver, O as ExecutionAttemptAuthority, P as registerDrizzleWorkflowStorage, S as AttemptOutcomeSubmissionDeps, T as OutcomeConvergenceInput, _ as AttemptOutcomeDecodingInput, a as WorkflowEngineServiceOptions, b as AcceptedAttemptOutcome, c as CommittedWorkflowOutcomeIdentity, d as WorkflowAttemptOutcomeSchema, f as WorkflowAttemptTechnicalFailure, g as workflowAttemptOutcomeCodec, h as toCommittedWorkflowRunnerResult, i as WorkflowEngineService, j as WorkflowMaterializationSpecResolution, k as BootstrapStartAuthority, l as WorkflowAttemptCancellation, m as toCommittedWorkflowRunnerCompletion, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, p as decodeWorkflowAttemptOutcome, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowAttemptOutcome, v as ExecutionAttemptHandlersDeps, w as OutcomeConvergence, x as AttemptOutcomeSubmission, y as registerExecutionAttemptHandlers } from "../package-BswWlFSn.mjs";
2
+ import { A as BootstrapStartOptions, C as OutcomeAcceptance, D as submitAttemptOutcome, E as OutcomePreCommitValidation, M as WorkflowMaterializationSpecResolver, N as WorkflowWorkspaceRootResolver, O as ExecutionAttemptAuthority, P as registerDrizzleWorkflowStorage, S as AttemptOutcomeSubmissionDeps, T as OutcomeConvergenceInput, _ as AttemptOutcomeDecodingInput, a as WorkflowEngineServiceOptions, b as AcceptedAttemptOutcome, c as CommittedWorkflowOutcomeIdentity, d as WorkflowAttemptOutcomeSchema, f as WorkflowAttemptTechnicalFailure, g as workflowAttemptOutcomeCodec, h as toCommittedWorkflowRunnerResult, i as WorkflowEngineService, j as WorkflowMaterializationSpecResolution, k as BootstrapStartAuthority, l as WorkflowAttemptCancellation, m as toCommittedWorkflowRunnerCompletion, n as createWorkflowEnginePackage, o as WorkflowTriggerReconciler, p as decodeWorkflowAttemptOutcome, r as workflowEnginePackage, s as WorkflowExecutor, t as WorkflowEngineToken, u as WorkflowAttemptOutcome, v as ExecutionAttemptHandlersDeps, w as OutcomeConvergence, x as AttemptOutcomeSubmission, y as registerExecutionAttemptHandlers } from "../package-DT1Jaweg.mjs";
3
3
  import { WorkflowTriggerPayloadPredicate, assertWorkflowTriggerPayload, compileWorkflowTriggerBindingFilter } from "./workflow-trigger-binding-consumer.mjs";
4
4
  import { z } from "zod";
5
5
  import * as _$_makaio_core0 from "@makaio/framework/core";
@@ -836,8 +836,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
836
836
  completed: "completed";
837
837
  cancelled: "cancelled";
838
838
  failed: "failed";
839
- running: "running";
840
839
  paused: "paused";
840
+ running: "running";
841
841
  finalizing: "finalizing";
842
842
  }>;
843
843
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -878,8 +878,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
878
878
  completed: "completed";
879
879
  cancelled: "cancelled";
880
880
  failed: "failed";
881
- running: "running";
882
881
  paused: "paused";
882
+ running: "running";
883
883
  finalizing: "finalizing";
884
884
  }>;
885
885
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -927,8 +927,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
927
927
  completed: "completed";
928
928
  cancelled: "cancelled";
929
929
  failed: "failed";
930
- running: "running";
931
930
  paused: "paused";
931
+ running: "running";
932
932
  finalizing: "finalizing";
933
933
  }>;
934
934
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -1267,8 +1267,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1267
1267
  completed: "completed";
1268
1268
  cancelled: "cancelled";
1269
1269
  failed: "failed";
1270
- running: "running";
1271
1270
  paused: "paused";
1271
+ running: "running";
1272
1272
  finalizing: "finalizing";
1273
1273
  }>>;
1274
1274
  error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1465,8 +1465,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1465
1465
  completed: "completed";
1466
1466
  cancelled: "cancelled";
1467
1467
  failed: "failed";
1468
- running: "running";
1469
1468
  paused: "paused";
1469
+ running: "running";
1470
1470
  finalizing: "finalizing";
1471
1471
  }>>;
1472
1472
  artifactRef: z.ZodOptional<z.ZodObject<{
@@ -1489,8 +1489,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1489
1489
  completed: "completed";
1490
1490
  cancelled: "cancelled";
1491
1491
  failed: "failed";
1492
- running: "running";
1493
1492
  paused: "paused";
1493
+ running: "running";
1494
1494
  finalizing: "finalizing";
1495
1495
  }>;
1496
1496
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -1542,8 +1542,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1542
1542
  completed: "completed";
1543
1543
  cancelled: "cancelled";
1544
1544
  failed: "failed";
1545
- running: "running";
1546
1545
  paused: "paused";
1546
+ running: "running";
1547
1547
  finalizing: "finalizing";
1548
1548
  }>;
1549
1549
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -3065,7 +3065,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3065
3065
  tableName: "workflow_executions";
3066
3066
  dataType: "string";
3067
3067
  columnType: "SQLiteText";
3068
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "paused" | "finalizing";
3068
+ data: "pending" | "completed" | "cancelled" | "failed" | "paused" | "running" | "finalizing";
3069
3069
  driverParam: string;
3070
3070
  notNull: true;
3071
3071
  hasDefault: false;
@@ -4944,7 +4944,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
4944
4944
  tableName: "worklog_summaries";
4945
4945
  dataType: "string";
4946
4946
  columnType: "SQLiteText";
4947
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "paused" | "finalizing";
4947
+ data: "pending" | "completed" | "cancelled" | "failed" | "paused" | "running" | "finalizing";
4948
4948
  driverParam: string;
4949
4949
  notNull: true;
4950
4950
  hasDefault: false;
@@ -6040,7 +6040,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
6040
6040
  tableName: "workflow_finalizations";
6041
6041
  dataType: "string";
6042
6042
  columnType: "SQLiteText";
6043
- data: "failed" | "acknowledged" | "claimed";
6043
+ data: "acknowledged" | "failed" | "claimed";
6044
6044
  driverParam: string;
6045
6045
  notNull: true;
6046
6046
  hasDefault: false;
@@ -6485,8 +6485,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6485
6485
  completed: "completed";
6486
6486
  cancelled: "cancelled";
6487
6487
  failed: "failed";
6488
- running: "running";
6489
6488
  paused: "paused";
6489
+ running: "running";
6490
6490
  finalizing: "finalizing";
6491
6491
  }>;
6492
6492
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -6527,8 +6527,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6527
6527
  completed: "completed";
6528
6528
  cancelled: "cancelled";
6529
6529
  failed: "failed";
6530
- running: "running";
6531
6530
  paused: "paused";
6531
+ running: "running";
6532
6532
  finalizing: "finalizing";
6533
6533
  }>;
6534
6534
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -6576,8 +6576,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6576
6576
  completed: "completed";
6577
6577
  cancelled: "cancelled";
6578
6578
  failed: "failed";
6579
- running: "running";
6580
6579
  paused: "paused";
6580
+ running: "running";
6581
6581
  finalizing: "finalizing";
6582
6582
  }>;
6583
6583
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -6916,8 +6916,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
6916
6916
  completed: "completed";
6917
6917
  cancelled: "cancelled";
6918
6918
  failed: "failed";
6919
- running: "running";
6920
6919
  paused: "paused";
6920
+ running: "running";
6921
6921
  finalizing: "finalizing";
6922
6922
  }>>;
6923
6923
  error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -7114,8 +7114,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7114
7114
  completed: "completed";
7115
7115
  cancelled: "cancelled";
7116
7116
  failed: "failed";
7117
- running: "running";
7118
7117
  paused: "paused";
7118
+ running: "running";
7119
7119
  finalizing: "finalizing";
7120
7120
  }>>;
7121
7121
  artifactRef: z.ZodOptional<z.ZodObject<{
@@ -7138,8 +7138,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7138
7138
  completed: "completed";
7139
7139
  cancelled: "cancelled";
7140
7140
  failed: "failed";
7141
- running: "running";
7142
7141
  paused: "paused";
7142
+ running: "running";
7143
7143
  finalizing: "finalizing";
7144
7144
  }>;
7145
7145
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -7191,8 +7191,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7191
7191
  completed: "completed";
7192
7192
  cancelled: "cancelled";
7193
7193
  failed: "failed";
7194
- running: "running";
7195
7194
  paused: "paused";
7195
+ running: "running";
7196
7196
  finalizing: "finalizing";
7197
7197
  }>;
7198
7198
  inputs: z.ZodType<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, _$_makaio_contracts0.JsonValue>>;
@@ -1,2 +1,2 @@
1
- import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-BswWlFSn.mjs";
1
+ import { n as createWorkflowEnginePackage, r as workflowEnginePackage, t as WorkflowEngineToken } from "../package-DT1Jaweg.mjs";
2
2
  export { WorkflowEngineToken, createWorkflowEnginePackage, workflowEnginePackage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1790248497521",
3
+ "version": "1.0.0-dev-1790535947927",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/makaio-ai/makaio-framework.git",
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{n as t,o as n,s as r}from"./json-value-DM-EjTC1.mjs";import{C as i,_ as a,a as o,b as s,c,d as l,i as u,l as d,n as ee,p as te,r as ne,t as re,u as ie,w as f,x as ae,y as oe}from"./schemas-CHM0wMq4.mjs";import{C as se,a as p,b as ce,m as le,r as ue,s as m,t as h,u as g}from"./kind-registration-Dzfo6kyb.mjs";import{t as de}from"./zod-json-schema-ZUmGtQhT.mjs";import{t as fe}from"./ajv-Cvnmw2yn.mjs";import{t as pe}from"./2020-CRfgqanb.mjs";import{t as me}from"./dist-onY7e-pd.mjs";import{z as _}from"zod";import{createBusNamespace as he}from"@makaio/framework/core";const ge=_.strictObject({evidence:i}),v=_.strictObject({kind:_.literal(`text`),text:_.string()}),[_e,ve,ye]=i.options,be=_.union([_e.pick({source:!0,location:!0}).extend({content:v}),ve.pick({source:!0,location:!0}).extend({content:v}),ye.pick({source:!0,location:!0}).extend({content:v})]);function y(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function b(e){return e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}function xe(e,t){if(t===`#`)return{node:e,pointer:``};if(!t.startsWith(`#/`))return;let n;try{n=decodeURIComponent(t.slice(1))}catch{return}let r=e;for(let e of n.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(t)||Number(t)>=r.length)return;r=r[Number(t)]}else{let e=y(r);if(!e||!Object.hasOwn(e,t))return;r=e[t]}}let i=typeof r==`boolean`?r:y(r);return i===void 0?void 0:{node:i,pointer:n}}function x(e,t){if(t===``)return!1;let n=e;for(let e of t.slice(1).split(`/`)){let t=e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`);if(n=Array.isArray(n)?n[Number(t)]:y(n)?.[t],typeof y(n)?.$id==`string`)return!0}return!1}function Se(e,t,n){if(e[`x-makaio-value-type`]!==`evidence/v1`)return;let r=i.safeParse(t);if(!r.success)throw Error(`Invalid schema-declared evidence at ${n}`);return{evidence:r.data,dataPath:n}}function Ce(e,t,n,r){if(typeof t.$ref!=`string`)return!1;if(r)return!0;let i=xe(e,t.$ref);return i===void 0?!0:typeof i.node!=`boolean`&&S(e,i.node,n,x(e,i.pointer))}function S(e,t,n=new WeakSet,r=!1){let i=y(t);if(!i||n.has(i))return!1;n.add(i);let a=r||i!==e&&typeof i.$id==`string`;if(i[`x-makaio-value-type`]===`evidence/v1`||typeof i.$dynamicRef==`string`||Ce(e,i,n,a)||[`additionalItems`,`additionalProperties`,`contains`,`else`,`if`,`items`,`then`,`unevaluatedItems`,`unevaluatedProperties`].some(t=>S(e,i[t],n,a))||[`allOf`,`anyOf`,`oneOf`,`prefixItems`].some(t=>Array.isArray(i[t])&&i[t].some(t=>S(e,t,n,a)))||Array.isArray(i.items)&&i.items.some(t=>S(e,t,n,a)))return!0;for(let t of[`dependentSchemas`,`dependencies`,`patternProperties`,`properties`]){let r=y(i[t]);if(r&&Object.values(r).some(t=>S(e,t,n,a)))return!0}return!1}var we=class{dataSchema;matchesSchema;occurrences=new Map;visited=new WeakMap;constructor(e,t){this.dataSchema=e,this.matchesSchema=t}extract(e){return this.visit(this.dataSchema,e,`/data`),[...this.occurrences.values()]}visit(e,t,n,r=``){let i=this.visited.get(e)??new Set;if(i.has(n))return;if(i.add(n),this.visited.set(e,i),typeof e.$dynamicRef==`string`)throw Error(`Evidence discovery does not support active $dynamicRef at ${n}`);if(typeof e.$ref==`string`){if(x(this.dataSchema,r))throw Error(`Evidence discovery does not support local $ref inside nested $id resource at ${n}`);let i=xe(this.dataSchema,e.$ref);if(i===void 0)throw Error(`Cannot resolve local schema reference ${e.$ref} at ${n}`);if(typeof i.node!=`boolean`&&this.visit(i.node,t,n,i.pointer),this.dataSchema.$schema!==`https://json-schema.org/draft/2020-12/schema`)return}let a=Se(e,t,n);if(a){this.occurrences.set(n,a);return}this.visitCombiners(e,t,n,r),this.visitConditional(e,t,n,r),this.visitDependencies(e,t,n,r),this.assertSupportedApplicators(e,n,r),Array.isArray(t)?this.visitArray(e,t,n,r):typeof t==`object`&&t&&this.visitObject(e,t,n,r)}visitCombiners(e,t,n,r){for(let i of[`allOf`,`anyOf`,`oneOf`]){let a=e[i];if(Array.isArray(a))for(let[e,o]of a.entries()){let a=y(o),s=`${r}/${i}/${e}`;a&&(i===`allOf`||this.matchesSchema(this.dataSchema,s,t))&&this.visit(a,t,n,s)}}}visitConditional(e,t,n,r){let i=typeof e.if==`boolean`?e.if:y(e.if);if(i===void 0)return;let a=`${r}/if`,o=this.matchesSchema(this.dataSchema,a,t);o&&typeof i!=`boolean`&&this.visit(i,t,n,a);let s=o?`then`:`else`,c=y(e[s]);c&&this.visit(c,t,n,`${r}/${s}`)}visitDependencies(e,t,n,r){if(!(typeof t!=`object`||!t||Array.isArray(t)))for(let i of[`dependentSchemas`,`dependencies`]){let a=y(e[i]);if(a)for(let[e,o]of Object.entries(a)){let a=y(o);Object.hasOwn(t,e)&&a&&this.visit(a,t,n,`${r}/${i}/${b(e)}`)}}}assertSupportedApplicators(e,t,n){for(let r of[`unevaluatedProperties`,`unevaluatedItems`])if(S(this.dataSchema,e[r],void 0,x(this.dataSchema,n)))throw Error(`Evidence under unsupported ${r} applicator at ${t}`)}visitArray(e,t,n,r){let i=Array.isArray(e.prefixItems),a=i?e.prefixItems:Array.isArray(e.items)?e.items:[];a.forEach((e,a)=>{let o=y(e),s=i?`prefixItems`:`items`;o&&a<t.length&&this.visit(o,t[a],`${n}/${a}`,`${r}/${s}/${a}`)});let o=Array.isArray(e.items)?y(e.additionalItems):y(e.items);if(o){let i=Array.isArray(e.items)?`additionalItems`:`items`;t.slice(a.length).forEach((e,t)=>this.visit(o,e,`${n}/${a.length+t}`,`${r}/${i}`))}this.visitContains(e,t,n,r)}visitContains(e,t,n,r){let i=y(e.contains);if(!i)return;let a=`${r}/contains`;t.forEach((e,t)=>{this.matchesSchema(this.dataSchema,a,e)&&this.visit(i,e,`${n}/${t}`,a)})}visitObject(e,t,n,r){let i=y(e.properties),a=y(e.patternProperties);for(let[o,s]of Object.entries(t)){let t=b(o),c=i!==void 0&&Object.hasOwn(i,o),l=y(i?.[o]);l&&this.visit(l,s,`${n}/${t}`,`${r}/properties/${t}`);let u=this.visitPatterns(a,o,s,`${n}/${t}`,r),d=y(e.additionalProperties);!c&&!u&&d&&this.visit(d,s,`${n}/${t}`,`${r}/additionalProperties`)}}visitPatterns(e,t,n,r,i){let a=!1;for(let[o,s]of Object.entries(e??{})){if(!new RegExp(o,`u`).test(t))continue;a=!0;let e=y(s);e&&this.visit(e,n,r,`${i}/patternProperties/${b(o)}`)}return a}};function Te(e,t,n){return new we(e,n.matchesSchema).extract(t)}function Ee(e){let{dataSchema:t,hooks:n,...r}=e,i={$schema:`https://json-schema.org/draft/2020-12/schema`,...de(t)};ce(i);let a=p.parse({...r,dataSchema:i});if(a.kind!==e.kind)throw Error(`Artifact kind identifiers must not contain surrounding whitespace`);let o=_.fromJSONSchema(a.dataSchema),s=_.unknown().superRefine((e,t)=>{let n=o.safeParse(e);if(!n.success)for(let e of n.error.issues)t.addIssue({code:`custom`,path:e.path,message:e.message})}).pipe(t).superRefine((e,t)=>{try{se(e,a.titlePath)}catch(e){t.addIssue({code:`custom`,path:a.titlePath.split(`.`),message:e instanceof Error?e.message:`Artifact title must be a nonblank string`})}});return{...structuredClone(a),kind:e.kind,schemaVersion:e.schemaVersion,dataSchema:s,...n?{hooks:n}:{},toRegistration:()=>structuredClone(a)}}var De=e(fe(),1),Oe=e(pe(),1),ke=e(me(),1);function C(e){let t={allErrors:!0,strict:!1,strictSchema:!0},n=e.dataSchema.$schema===`https://json-schema.org/draft/2020-12/schema`?new Oe.default(t):new De.default(t);return(0,ke.default)(n),n.addKeyword({keyword:ae,schemaType:`string`,valid:!0}),n.compile(e.dataSchema)}function Ae(e){return e.replace(/~1/gu,`/`).replace(/~0/gu,`~`)}function je(e){let t=e.instancePath.split(`/`).slice(1).map(Ae),n=e.keyword===`required`?e.params.missingProperty:e.params.additionalProperty;return typeof n==`string`&&(e.keyword===`required`||e.keyword===`additionalProperties`)&&t.push(n),t.join(`.`)}function Me(e){if(e.keyword!==`type`)return;let t=e.params.type;if(typeof t==`string`)return t;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.join(` | `)}const Ne=n.array();function Pe(e){if(e.keyword!==`enum`)return;let t=Ne.safeParse(e.params.allowedValues);return t.success?t.data:void 0}function Fe(e){return(e??[]).map(e=>{let t=Me(e),n=Pe(e);return{path:je(e),reason:e.message??`violates ${e.keyword}`,...t===void 0?{}:{expectedType:t},...n===void 0?{}:{allowedValues:n}}})}function Ie(e){return C(e)}function Le(e){let t=C(e);return e=>t(e)?{valid:!0}:{valid:!1,issues:Fe(t.errors)}}function Re(e){return{hooks:[...e.hooks]}}const ze=[`inline`,`summary`,`link`,`omit`],w=[`outbound`,`inbound`],T=_.string().min(1),E=_.enum(w),D=_.object({kinds:_.array(_.string().min(1)).optional(),hint:T.optional(),depth:_.number().int().min(1).max(20).optional(),nested:_.lazy(()=>O).optional(),direction:E.optional()}),O=_.record(_.string().min(1),D);function k(e){return JSON.stringify([e.kind,e.id,e.revision])}const Be=_.enum([`not-selected`,`not-found`,`depth-exceeded`,`unsupported-ref-class`,`cycle-detected`]),Ve=_.object({target:d,sourceRef:f,relationType:_.string().min(1),sourceLocalId:c.shape.sourceLocalId,direction:E.optional(),hint:T,status:_.enum([`resolved`,`unresolved`]),reason:Be.optional()}).superRefine((e,t)=>{e.status===`unresolved`&&e.reason===void 0&&t.addIssue({code:_.ZodIssueCode.custom,path:[`reason`],message:`reason is required for unresolved artifact context refs`}),e.status===`resolved`&&e.reason!==void 0&&t.addIssue({code:_.ZodIssueCode.custom,path:[`reason`],message:`reason must be omitted for resolved artifact context refs`}),e.status===`resolved`&&e.target.refClass!==`artifact`&&t.addIssue({code:_.ZodIssueCode.custom,path:[`target`],message:`resolved artifact context refs must target an artifact revision`})}),A=_.object({rootRef:f,refs:_.array(Ve),resolved:_.array(l)}).superRefine((e,t)=>{let n=new Set(e.resolved.map(k));n.has(k(e.rootRef))||t.addIssue({code:_.ZodIssueCode.custom,path:[`resolved`],message:`resolved artifact context wire payloads must include the root artifact revision`}),e.refs.forEach((e,r)=>{n.has(k(e.sourceRef))||t.addIssue({code:_.ZodIssueCode.custom,path:[`refs`,r,`sourceRef`],message:`artifact context ref sources must have a matching revision in resolved`}),!(e.status!==`resolved`||e.target.refClass!==`artifact`)&&(n.has(k(e.target))||t.addIssue({code:_.ZodIssueCode.custom,path:[`refs`,r,`target`],message:`resolved artifact context refs must have a matching revision in resolved`}))})});function He(e){let t=A.parse(e),n=new Map(t.resolved.map(e=>[k(e),e])),r=new Map;for(let e of t.refs){let t=k(e.sourceRef),n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}let i=n.get(k(t.rootRef));if(!i)throw Error(`Resolved artifact context is missing root artifact '${k(t.rootRef)}'`);let a=Ue(t.rootRef,i,`inline`,r,n);return{root:a,flatten(){let e=[];return Ke(a,e),e}}}function Ue(e,t,n,r,i){return{status:`resolved`,ref:e,artifact:t,hint:n,children:Ge(e,r,i,new Set([k(e)]))}}function We(e,t,n,r,i,a,o,s,c){let l=k(e),u=new Set(c);return u.add(l),{status:`resolved`,ref:e,artifact:t,relation:n,sourceLocalId:r,direction:i,hint:a,children:Ge(e,o,s,u)}}function Ge(e,t,n,r){return(t.get(k(e))??[]).map(e=>{if(e.status===`unresolved`)return{status:`unresolved`,target:e.target,relation:e.relationType,sourceLocalId:e.sourceLocalId,direction:e.direction,hint:e.hint,reason:e.reason};if(e.target.refClass!==`artifact`)throw Error(`Resolved artifact context refs must target an artifact revision`);let i=k(e.target),a=n.get(i);if(!a)throw Error(`Resolved artifact context is missing target artifact '${i}'`);return r.has(i)?{status:`unresolved`,target:e.target,relation:e.relationType,sourceLocalId:e.sourceLocalId,direction:e.direction,hint:e.hint,reason:`cycle-detected`}:We(e.target,a,e.relationType,e.sourceLocalId,e.direction,e.hint,t,n,r)})}function Ke(e,t){if(e.status!==`unresolved`){t.push(e.artifact);for(let n of e.children)Ke(n,t)}}const j=[`$set`,`$unset`,`$push`,`$pull`],M=`[A-Za-z_$][A-Za-z0-9_$]*`,N=`[A-Za-z_$][A-Za-z0-9_$-]*`,qe=`(?:0|[1-9][0-9]*)`,Je=`(?:${`\\$\\[${M}\\]`}|${qe}|${N})`,Ye=RegExp(`^${N}(?:\\.${Je})*$`),Xe=RegExp(`^${M}(?:\\.${N})*$`),Ze=RegExp(`^${qe}$`),Qe=RegExp(`^\\$\\[(${M})\\]$`),P=_.string().regex(Ye,`Expected a data-relative path of object properties, array positions, or $[filter] placeholders`);function $e(e){let t=Qe.exec(e);return t?.[1]===void 0?Ze.test(e)?{kind:`index`,index:Number(e)}:{kind:`property`,name:e}:{kind:`filter`,placeholder:t[1]}}function et(e){return e.split(`.`).map($e)}function tt(e){return et(e).flatMap(e=>e.kind===`filter`?[e.placeholder]:[])}const nt=r(_.record(_.string().regex(Xe,`Expected a filter key of the form name or name.field.path`),n),{prototypeKey:`an array filter cannot compare a __proto__ key, which JSON transport drops`,nonPlainObject:`an array filter must be a plain object of comparison keys`,symbolKey:`an array filter cannot carry symbol-keyed comparisons`,nonEnumerableKey:`an array filter cannot carry non-enumerable comparison keys`,extraArrayKey:`an array filter must be a plain object, not an array`});function rt(e){let t=new Set(Object.keys(e).map(e=>e.split(`.`)[0]));if(t.size!==1)return;let[n]=t;return n!==void 0&&n.length>0?n:void 0}function F(e,t){return r(_.record(P,t),{prototypeKey:`${e} cannot address __proto__, which JSON transport drops`,nonPlainObject:`${e} must be a plain object of path instructions`,symbolKey:`${e} cannot carry symbol-keyed instructions`,nonEnumerableKey:`${e} cannot carry non-enumerable instructions`,extraArrayKey:`${e} must be a plain object, not an array`})}const it=_.literal(!0),at=_.strictObject({$set:F(`$set`,n).optional(),$unset:F(`$unset`,it).optional(),$push:F(`$push`,n).optional(),$pull:F(`$pull`,n).optional(),arrayFilters:_.array(nt).optional()});function I(e){return j.flatMap(t=>Object.entries(e[t]??{}).map(([e,n])=>({operator:t,path:e,value:n})))}function ot(e,t){let n=I(e),r=new Map;(e.arrayFilters??[]).forEach((e,n)=>{let i=rt(e);if(i===void 0){t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`An array filter must bind exactly one placeholder name across all of its keys`});return}if(r.has(i)){t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`Array filter placeholder ${i} is already bound by another filter`});return}r.set(i,n)});let i=new Set;for(let{operator:e,path:a}of n)for(let n of tt(a))i.add(n),r.has(n)||t.addIssue({code:`custom`,path:[e,a],message:`Path uses placeholder $[${n}] without a matching entry in arrayFilters`});for(let[e,n]of r)i.has(e)||t.addIssue({code:`custom`,path:[`arrayFilters`,n],message:`Array filter binds placeholder ${e}, which no path uses`})}const st=at.superRefine(ot).superRefine((e,t)=>{I(e).length===0&&t.addIssue({code:`custom`,message:`Declare at least one of ${j.join(`, `)}`})}),ct=at.superRefine(ot),lt=_.strictObject({kind:f.shape.kind,id:f.shape.id}),ut=_.strictObject({ref:lt,baseRevision:f.shape.revision,patch:ct,dryRun:_.boolean().optional(),schemaVersion:g.optional().describe(`Target schema version for the patched revision; defaults to the base revision's. Use it to migrate an artifact left at an older version by a kind bump.`),statusPath:te.optional(),representations:ie.strict().nullable().optional().describe(`Rendering hints (markdown, summary, plaintext) for the new revision. Omit to keep the previous revision's hints. An object replaces all of them, it does not merge: send every hint you want to keep. null clears them.`)}).superRefine((e,t)=>{e.schemaVersion===void 0&&I(e.patch).length===0&&t.addIssue({code:`custom`,path:[`patch`],message:`Declare at least one of ${j.join(`, `)}, or name a schemaVersion to migrate a payload that already fits`})}),dt=[`ARTIFACT_NOT_FOUND`,`BASE_REVISION_CONFLICT`,`KIND_NOT_REGISTERED`,`SCHEMA_VERSION_MISMATCH`,`PATH_NOT_DECLARED`,`PATH_NOT_RESOLVABLE`,`TARGET_NOT_A_COLLECTION`,`UNSUPPORTED_TARGET`,`NO_MATCH`,`SCHEMA_VALIDATION_FAILED`,`PAYLOAD_INVARIANT_FAILED`,`NO_CHANGE`,`STORE_REJECTED`,`HOST_FAILED`],ft=_.strictObject({path:_.string(),reason:_.string().min(1),expectedType:_.string().min(1).optional(),allowedValues:_.array(n).optional()}),pt=_.strictObject({code:_.enum(dt),message:_.string().min(1),operator:_.enum(j).optional(),path:P.optional(),currentRevision:f.shape.revision.optional(),issues:_.array(ft).optional(),repair:_.string().min(1)}).superRefine((e,t)=>{e.code===`BASE_REVISION_CONFLICT`&&e.currentRevision===void 0&&t.addIssue({code:_.ZodIssueCode.custom,message:`A BASE_REVISION_CONFLICT must name the revision the artifact carries.`,path:[`currentRevision`]})}),mt=_.strictObject({operator:_.enum(j),path:P,matched:_.number().int().positive()}),ht=_.strictObject({from:g,to:g}).refine(e=>e.to>e.from,{path:[`to`],message:`A migration moves the artifact forward to a newer schema version`}),gt=_.strictObject({ok:_.literal(!0),base:f,operations:_.array(mt),migration:ht.optional()});function _t(e,t){e.operations.length===0&&e.migration===void 0&&t.addIssue({code:`custom`,path:[`operations`],message:`A success without a migration must report at least one applied instruction`})}const vt=gt.extend({dryRun:_.literal(!0)}).superRefine(_t),yt=gt.extend({dryRun:_.literal(!1),artifact:f}).superRefine(_t),bt=_.discriminatedUnion(`dryRun`,[vt,yt]),xt=_.strictObject({ok:_.literal(!1),error:pt}),St=_.union([bt,xt]),Ct=_.object({ref:oe}),wt=_.union([_.strictObject({ok:_.literal(!0),ref:oe,areaPath:ue,part:t}),_.strictObject({ok:_.literal(!1),error:le})]),L=f.pick({kind:!0,id:!0}),R=_.number().int().positive(),z=R,B={knowledge:`valid`,commitment:`proposed`,interaction:`open`},V=_.discriminatedUnion(`category`,[_.strictObject({category:_.literal(`knowledge`),state:_.enum(h.knowledge),version:z}),_.strictObject({category:_.literal(`commitment`),state:_.enum(h.commitment),version:z}),_.strictObject({category:_.literal(`interaction`),state:_.enum(h.interaction),version:z})]).superRefine((e,t)=>{e.version===1&&e.state!==B[e.category]&&t.addIssue({code:`custom`,path:[`state`],message:`Lifecycle version 1 is reserved for the category initial state`})}),H=_.union([V,_.strictObject({category:_.literal(`record`)})]),U=_.string().trim().min(1),Tt=_.strictObject({kind:U,ref:U}),W=_.discriminatedUnion(`kind`,[_.strictObject({kind:_.literal(`revision-assessment`),assessedRevision:f.shape.revision,source:Tt.optional()}),_.strictObject({kind:_.literal(`handover`),source:Tt})]),Et={artifact:L,expectedVersion:z,state:m,situation:W,reason:U.optional()},G=_.strictObject(Et),Dt=_.strictObject({...Et,actor:re}),Ot={valid:[`retired`],retired:[`valid`],proposed:[`decided`],decided:[`fulfilled`,`revoked`],fulfilled:[],revoked:[],open:[`resolved`,`closed-without-resolution`],resolved:[],"closed-without-resolution":[]};function K(e,t){return Ot[e].includes(t)}const kt={artifact:L,lifecycle:V,actor:re,timestamp:_.number().int().nonnegative(),observedRevision:f.shape.revision},At=_.strictObject({...kt,operation:_.literal(`initialized`)}).superRefine((e,t)=>{(e.lifecycle.version!==1||e.lifecycle.state!==B[e.lifecycle.category])&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`Initialization requires the category initial state and version 1`})});function jt(e,t){return t===`retired`||e===`retired`&&t===`valid`}const Mt=`Retiring or reinstating knowledge requires a reason`,q=_.strictObject({...kt,operation:_.literal(`transitioned`),previousState:m,situation:W,reason:G.shape.reason}).superRefine((e,t)=>{(!K(e.previousState,e.lifecycle.state)||e.lifecycle.version<=1)&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`History requires a category-compatible transition after initialization`}),jt(e.previousState,e.lifecycle.state)&&!e.reason&&t.addIssue({code:`custom`,path:[`reason`],message:Mt}),e.situation.kind===`revision-assessment`&&e.situation.assessedRevision!==e.observedRevision&&t.addIssue({code:`custom`,path:[`situation`],message:`An assessment cannot authorize a different observed content revision`})}),Nt=_.discriminatedUnion(`operation`,[At,q]),J=_.discriminatedUnion(`reason`,[_.strictObject({reason:_.literal(`lifecycle-version-conflict`),expectedVersion:z,current:V,requestedState:m}),_.strictObject({reason:_.literal(`content-basis-conflict`),assessedRevision:f.shape.revision,currentRevision:f.shape.revision}),_.strictObject({reason:_.literal(`invalid-transition`),current:H,requestedState:m}),_.strictObject({reason:_.literal(`precondition-failed`),current:V,requestedState:m})]),Y=`artifact-lifecycle-rejected`;var X=class extends Error{code=Y;data;constructor(e,t){super(e),this.name=`ArtifactLifecycleError`,this.data=J.parse(t)}};function Pt(e){return e===`record`?{category:`record`}:V.parse({category:e,state:B[e],version:1})}function Ft(e){let t=H.parse(e.current),n=f.shape.revision.parse(e.currentRevision),r=Dt.parse(e.command);if(t.category===`record`)throw new X(`Record artifacts do not have a lifecycle`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(r.expectedVersion!==t.version)throw new X(`Artifact lifecycle changed since the supplied baseline`,{reason:`lifecycle-version-conflict`,expectedVersion:r.expectedVersion,current:t,requestedState:r.state});if(r.situation.kind===`revision-assessment`&&r.situation.assessedRevision!==n)throw new X(`Assessed content revision is no longer current`,{reason:`content-basis-conflict`,assessedRevision:r.situation.assessedRevision,currentRevision:n});if(!K(t.state,r.state))throw new X(`Artifact lifecycle transition is not allowed`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(jt(t.state,r.state)&&!r.reason)throw new X(Mt,{reason:`precondition-failed`,current:t,requestedState:r.state});return V.parse({...t,state:r.state,version:t.version+1})}const It=_.strictObject({artifact:L}),Lt=_.strictObject({lifecycle:H}),Rt=_.strictObject({artifact:L,afterVersion:R.optional(),limit:_.number().int().min(1).max(100).default(50)}),zt=_.strictObject({entries:_.array(Nt).max(100),nextCursor:R.optional()}).superRefine(({entries:e,nextCursor:t},n)=>{let r=e[0],i;for(let[t,a]of e.entries()){let e=a.artifact.kind===r?.artifact.kind&&a.artifact.id===r?.artifact.id,o=i===void 0||a.lifecycle.version===i.lifecycle.version+1,s=i===void 0||a.operation===`transitioned`&&a.lifecycle.category===i.lifecycle.category&&a.previousState===i.lifecycle.state;if(!e||!o||!s){n.addIssue({code:`custom`,path:[`entries`,t],message:`History pages contain one artifact in contiguous ascending, state-linked order`});break}i=a}t!==void 0&&t!==i?.lifecycle.version&&n.addIssue({code:`custom`,path:[`nextCursor`],message:`nextCursor must equal the last returned lifecycle version`})}),Z=_.strictObject({entry:q}),Bt=Z,Vt=_.strictObject({code:_.literal(Y),message:_.string().min(1),data:J});function Ht(e){return{code:e.code,message:e.message,data:e.data}}function Ut(e,t){switch(t.reason){case`content-basis-conflict`:return Kt(e,t);case`lifecycle-version-conflict`:return[...Wt(e,t),...Gt(e,t)];case`invalid-transition`:case`precondition-failed`:return[...Wt(e,t),...qt(e,t)]}}function Wt(e,t){return t.requestedState===e.state?[]:[{path:[`requestedState`],message:`Rejection requestedState must match the rejected transition`}]}function Gt(e,t){let n=[];return t.expectedVersion!==e.expectedVersion&&n.push({path:[`expectedVersion`],message:`Version conflict baseline must match the rejected transition`}),t.current.version===e.expectedVersion&&n.push({path:[`current`,`version`],message:`Version conflict requires a current version different from the supplied baseline`}),n}function Kt(e,t){let n=[];return(e.situation.kind!==`revision-assessment`||t.assessedRevision!==e.situation.assessedRevision)&&n.push({path:[`assessedRevision`],message:`Content conflict must identify the rejected revision assessment`}),t.currentRevision===t.assessedRevision&&n.push({path:[`currentRevision`],message:`Content conflict requires a current revision different from the assessed revision`}),n}function qt(e,t){if(t.current.category===`record`)return[];let n=[];t.current.version!==e.expectedVersion&&n.push({path:[`current`,`version`],message:`A rejection after the version check must report the supplied baseline version`});let r=K(t.current.state,t.requestedState);return t.reason===`invalid-transition`&&r&&n.push({path:[`reason`],message:`invalid-transition requires a transition the lifecycle matrix disallows`}),t.reason===`precondition-failed`&&!r&&n.push({path:[`reason`],message:`precondition-failed requires a transition the lifecycle matrix allows`}),n}const Jt=_.strictObject({transition:G,error:Vt}).superRefine(({transition:e,error:t},n)=>{for(let r of Ut(e,t.data))n.addIssue({code:`custom`,path:[`error`,`data`,...r.path],message:r.message})}),Q={"lifecycle.get":{request:It,response:Lt},"lifecycle.history":{request:Rt,response:zt},"lifecycle.transition":{request:G,response:Z},"lifecycle.committed":Bt,"lifecycle.rejected":Jt},Yt={...Q,"kind.register":{request:p,response:_.object({registered:_.boolean()})},"kind.list":{request:_.object({kind:_.string().min(1).optional()}),response:_.object({kinds:_.array(p)})},"relation-type.register":{request:s,response:_.object({registered:_.boolean()})},"relation-type.list":{request:_.object({type:_.string().min(1).optional()}),response:_.object({relationTypes:_.array(s)})},create:{request:l.omit({id:!0,revision:!0,timestamp:!0}).extend({id:f.shape.id.optional()}),response:_.object({artifact:l})},revise:{request:_.object({previous:f,statusPath:te.optional(),revision:l.omit({id:!0,revision:!0,timestamp:!0})}),response:_.object({artifact:l})},patch:{request:ut,response:St},resolve:{request:_.object({ref:f}),response:_.object({artifact:l.nullable()})},resolvePart:{request:Ct,response:wt},query:{request:o,response:_.object({artifacts:_.array(l)})},compare:{request:ee,response:ne},"evidence.resolve":{request:ge,response:be},resolveContext:{request:_.object({ref:f,selectors:O.optional(),maxDepth:_.number().int().min(1).max(20).default(5)}),response:_.object({context:A})},created:_.object({artifact:l}),revised:_.object({previous:f,artifact:l}),"relation.added":_.object({artifact:f,relation:c}),"observation.added":_.object({artifact:f,observation:u}),"status.changed":_.object({artifact:f,path:_.string().min(1),previous:_.unknown().optional(),current:_.unknown().optional()}),"kind.changed":_.object({kind:_.string().min(1),schemaVersion:g})},Xt=he(`artifact`,Yt),Zt=Xt.subjects,Qt=_.discriminatedUnion(`refClass`,[f.omit({revision:!0}),a]);function $t(e){if(e.refClass===`artifact`)return{refClass:`artifact`,kind:e.kind,id:e.id};if(e.refClass===`entity`)return{refClass:`entity`,entityType:e.entityType,id:e.id}}function $(e){return e.refClass===`artifact`?JSON.stringify([`artifact`,e.kind,e.id]):JSON.stringify([`entity`,e.entityType,e.id])}function en(e){return e.refClass===`artifact`?`artifact:${e.kind}/${e.id}`:`entity:${e.entityType}/${e.id}`}const tn=[`relation-target`];function nn(e,t){if(!e||e.length===0)return{ok:!0,rules:[]};let n=[];for(let[r,i]of e.entries()){for(let[e,a]of i.by.entries())(!tn.includes(a.kind)||!t.includes(a.kind))&&n.push({ruleIndex:r,selectorIndex:e,capability:a.kind,message:`rule #${r}, selector #${e}: '${a.kind}' selectors are not supported`});i.lifecycleStates!==void 0&&!t.includes(`lifecycle-states`)&&n.push({ruleIndex:r,capability:`lifecycle-states`,message:`rule #${r}: lifecycleStates is declared but 'lifecycle-states' is not a supported capability`})}return n.length>0?{ok:!1,issues:n}:{ok:!0,rules:e}}function rn(e,t,n,r){if(e.kind===`data`)return{ruleIndex:n,selectorIndex:r,reason:`unsupported-selector`,message:`rule #${n}, selector #${r}: data-path selectors cannot be derived from relations`};let{relationType:i}=e,a=t.filter(e=>e.type===i&&e.sourceLocalId===void 0),o=new Set,s,c;for(let e of a){let t=$t(e.target);if(t===void 0){c=e.target.refClass;break}o.add($(t)),s=t}return c===void 0?s===void 0?{ruleIndex:n,selectorIndex:r,reason:`missing-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': no relations of this type found`}:o.size>1?{ruleIndex:n,selectorIndex:r,reason:`ambiguous-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': ${o.size} distinct targets; expected exactly one`}:{type:i,target:s}:{ruleIndex:n,selectorIndex:r,reason:`unsupported-target`,relationType:i,message:`rule #${n}, selector #${r}, relation '${i}': found a relation with refClass '${c}'; only artifact and entity targets are supported`}}function an(e,t){let n=[],r=[];for(let[i,a]of e.entries()){let e=a.by.map((e,n)=>rn(e,t,i,n)),o=e.filter(e=>`reason`in e);if(o.length>0){r.push(...o);continue}let s=e.filter(e=>!(`reason`in e)),c=JSON.stringify(s.map(e=>[e.type,$(e.target)]));n.push({rule:a,ruleIndex:i,parts:s,serialized:c})}return{keys:n,issues:r}}function on(e){return e.parts.map(e=>`${e.type} → ${en(e.target)}`).join(`; `)}export{bt as $,Dt as A,j as B,X as C,be as Ct,J as D,At as E,Pt as F,xt as G,st as H,K as I,mt as J,ft as K,Ct as L,q as M,R as N,W as O,Ft as P,St as Q,wt as R,H as S,ge as St,L as T,vt as U,nt as V,pt as W,yt as X,P as Y,ut as Z,Jt as _,Re as _t,$t as a,et as at,Ht as b,Ee as bt,Xt as c,Be as ct,Bt as d,w as dt,lt as et,Vt as f,ze as ft,zt as g,O as gt,Rt as h,T as ht,Qt as i,$e as it,G as j,V as k,Yt as l,A as lt,Lt as m,D as mt,an as n,I as nt,en as o,He as ot,It as p,E as pt,ht as q,on as r,tt as rt,$ as s,Ve as st,nn as t,rt as tt,Zt as u,k as ut,Q as v,Le as vt,Nt as w,Y as x,Te as xt,Z as y,Ie as yt,dt as z};