@makaio/framework 1.0.0-dev-1790772200584 → 1.0.0-dev-1791396836202

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 (71) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/artifact-BbNQHNDL.mjs +1 -0
  3. package/dist/bus/index.d.mts +39 -9
  4. package/dist/bus/index.mjs +1 -1
  5. package/dist/{bus--m38BS3i.mjs → bus-CtT6XeB_.mjs} +4 -4
  6. package/dist/contracts/artifact/index.d.mts +3 -3
  7. package/dist/contracts/artifact/index.mjs +1 -1
  8. package/dist/contracts/capabilities/index.d.mts +1 -1
  9. package/dist/contracts/client/index.d.mts +1 -1
  10. package/dist/contracts/extension/index.d.mts +2 -2
  11. package/dist/contracts/index.d.mts +32 -32
  12. package/dist/contracts/index.mjs +1 -1
  13. package/dist/contracts/materialization/index.d.mts +2 -2
  14. package/dist/contracts/materialization/index.mjs +1 -1
  15. package/dist/contracts/session/index.d.mts +2 -2
  16. package/dist/contracts/worker/index.d.mts +1 -1
  17. package/dist/contracts/worker/index.mjs +1 -1
  18. package/dist/contracts/workflow/index.d.mts +2 -2
  19. package/dist/contracts/workflow/index.mjs +1 -1
  20. package/dist/fast-connection-FG3yAA7o.mjs +1 -0
  21. package/dist/{framework-packages-blqho6Nk.mjs → framework-packages-CdpSqDeo.mjs} +1 -1
  22. package/dist/inbound-hooks/fast-connection.d.mts +1 -1
  23. package/dist/inbound-hooks/fast-connection.mjs +1 -1
  24. package/dist/inbound-hooks/index.mjs +1 -1
  25. package/dist/{index-CBzHX2vt.d.mts → index-BXaNt9GP.d.mts} +1 -1
  26. package/dist/{index-21Tx9_N1.d.mts → index-CgcMrxhm.d.mts} +24 -24
  27. package/dist/{index-Dj60LBqi2.d.mts → index-ChwEMUbc2.d.mts} +3 -3
  28. package/dist/{index-DeSmhDs9.d.mts → index-CjM6Fi-N.d.mts} +1 -1
  29. package/dist/{index-v1-To1jx.d.mts → index-D5eIy_qx.d.mts} +4 -4
  30. package/dist/{index-CMmUS-p2.d.mts → index-DBkmFhrn.d.mts} +160 -38
  31. package/dist/{index-DulipRwg.d.mts → index-DnsMV2xK.d.mts} +10 -10
  32. package/dist/{index-vARKBSt9.d.mts → index-Rd9Teoza.d.mts} +16 -16
  33. package/dist/{index-Bxm5RUGG2.d.mts → index-chwNKVMu2.d.mts} +33 -33
  34. package/dist/{index-BPoX2Q9Z.d.mts → index-y6zuCdvH.d.mts} +58 -58
  35. package/dist/kernel/extension/index.d.mts +2 -2
  36. package/dist/kernel/index.d.mts +2 -2
  37. package/dist/kernel/observability/index.d.mts +1 -1
  38. package/dist/{materialization-BzSgnv2R.mjs → materialization-C1qlFBV2.mjs} +1 -1
  39. package/dist/{namespace-u4eoUCLp.d.mts → namespace-DZooy1DW.d.mts} +18 -18
  40. package/dist/node/transports/index.mjs +2 -2
  41. package/dist/package.json +1 -1
  42. package/dist/packages-BOM7wECe.mjs +1 -0
  43. package/dist/{packages-Fy4a6vQy.d.mts → packages-g6BtlUF9.d.mts} +9 -6
  44. package/dist/{schemas-BKE3qw_w.d.mts → schemas-DnrIc9g7.d.mts} +49 -10
  45. package/dist/{schemas-BQhtYuCM.d.mts → schemas-Y3EJu698.d.mts} +8 -8
  46. package/dist/{schemas-BvDsO8Is.mjs → schemas-uNzmiLso.mjs} +1 -1
  47. package/dist/services/filesystem/namespace.d.mts +6 -6
  48. package/dist/services/filesystem/schemas.d.mts +3 -3
  49. package/dist/services/index.d.mts +9 -9
  50. package/dist/services/index.mjs +1 -1
  51. package/dist/services/materialization/index.d.mts +1 -1
  52. package/dist/services/materialization/index.mjs +1 -1
  53. package/dist/services/session/index.d.mts +1 -1
  54. package/dist/services/session/session-events/namespace.d.mts +1 -1
  55. package/dist/services/settings/namespace.d.mts +8 -8
  56. package/dist/services/subagent-template/index.d.mts +1 -1
  57. package/dist/services/subagent-template/schemas.d.mts +1 -1
  58. package/dist/services/tools/index.mjs +1 -1
  59. package/dist/services/workflow-transitions/index.mjs +1 -1
  60. package/dist/{tools-Cbuj-ClQ.mjs → tools-EK2HiPee.mjs} +1 -1
  61. package/dist/{transition-DNNBGMtx.d.mts → transition-yohyGRmc.d.mts} +1 -1
  62. package/dist/{types-DsZBnL7z.d.mts → types-CRKyrt5_.d.mts} +12 -12
  63. package/dist/{view-builder-HU_v1Jg7.d.mts → view-builder-BjVjGZAI.d.mts} +2 -2
  64. package/dist/{worker-toBnRJ0A.mjs → worker-DulBFC0P.mjs} +1 -1
  65. package/dist/{workflow-BDDB6EJi.mjs → workflow-Dvv_8Xu6.mjs} +1 -1
  66. package/dist/workflow-engine/index.d.mts +39 -39
  67. package/dist/{workflow-transitions-CvT6P03B.mjs → workflow-transitions-ztq90FUj.mjs} +1 -1
  68. package/package.json +1 -1
  69. package/dist/artifact-XE82Q2bH.mjs +0 -1
  70. package/dist/fast-connection-CIZ6nL7o.mjs +0 -1
  71. package/dist/packages-CZ2x-Ver.mjs +0 -1
@@ -836,8 +836,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
836
836
  completed: "completed";
837
837
  cancelled: "cancelled";
838
838
  failed: "failed";
839
- paused: "paused";
840
839
  running: "running";
840
+ paused: "paused";
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
- paused: "paused";
882
881
  running: "running";
882
+ paused: "paused";
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
- paused: "paused";
931
930
  running: "running";
931
+ paused: "paused";
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
- paused: "paused";
1271
1270
  running: "running";
1271
+ paused: "paused";
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
- paused: "paused";
1469
1468
  running: "running";
1469
+ paused: "paused";
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
- paused: "paused";
1493
1492
  running: "running";
1493
+ paused: "paused";
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
- paused: "paused";
1546
1545
  running: "running";
1546
+ paused: "paused";
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>>;
@@ -1604,8 +1604,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1604
1604
  cancelled: "cancelled";
1605
1605
  failed: "failed";
1606
1606
  running: "running";
1607
- skipped: "skipped";
1608
1607
  waiting: "waiting";
1608
+ skipped: "skipped";
1609
1609
  }>;
1610
1610
  attempt: z.ZodDefault<z.ZodNumber>;
1611
1611
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1650,8 +1650,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1650
1650
  cancelled: "cancelled";
1651
1651
  failed: "failed";
1652
1652
  running: "running";
1653
- skipped: "skipped";
1654
1653
  waiting: "waiting";
1654
+ skipped: "skipped";
1655
1655
  }>;
1656
1656
  attempt: z.ZodDefault<z.ZodNumber>;
1657
1657
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1693,8 +1693,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1693
1693
  cancelled: "cancelled";
1694
1694
  failed: "failed";
1695
1695
  running: "running";
1696
- skipped: "skipped";
1697
1696
  waiting: "waiting";
1697
+ skipped: "skipped";
1698
1698
  }>;
1699
1699
  attempt: z.ZodDefault<z.ZodNumber>;
1700
1700
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -1722,8 +1722,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1722
1722
  status: z.ZodEnum<{
1723
1723
  cancelled: "cancelled";
1724
1724
  rejected: "rejected";
1725
- resumed: "resumed";
1726
1725
  waiting: "waiting";
1726
+ resumed: "resumed";
1727
1727
  "timed-out": "timed-out";
1728
1728
  }>;
1729
1729
  autoAction: z.ZodEnum<{
@@ -1857,8 +1857,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1857
1857
  status: z.ZodEnum<{
1858
1858
  cancelled: "cancelled";
1859
1859
  rejected: "rejected";
1860
- resumed: "resumed";
1861
1860
  waiting: "waiting";
1861
+ resumed: "resumed";
1862
1862
  "timed-out": "timed-out";
1863
1863
  }>;
1864
1864
  autoAction: z.ZodEnum<{
@@ -1882,8 +1882,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1882
1882
  status: z.ZodOptional<z.ZodEnum<{
1883
1883
  cancelled: "cancelled";
1884
1884
  rejected: "rejected";
1885
- resumed: "resumed";
1886
1885
  waiting: "waiting";
1886
+ resumed: "resumed";
1887
1887
  "timed-out": "timed-out";
1888
1888
  }>>;
1889
1889
  limit: z.ZodDefault<z.ZodNumber>;
@@ -1899,8 +1899,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1899
1899
  status: z.ZodEnum<{
1900
1900
  cancelled: "cancelled";
1901
1901
  rejected: "rejected";
1902
- resumed: "resumed";
1903
1902
  waiting: "waiting";
1903
+ resumed: "resumed";
1904
1904
  "timed-out": "timed-out";
1905
1905
  }>;
1906
1906
  autoAction: z.ZodEnum<{
@@ -1935,8 +1935,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
1935
1935
  status: z.ZodEnum<{
1936
1936
  cancelled: "cancelled";
1937
1937
  rejected: "rejected";
1938
- resumed: "resumed";
1939
1938
  waiting: "waiting";
1939
+ resumed: "resumed";
1940
1940
  "timed-out": "timed-out";
1941
1941
  }>;
1942
1942
  autoAction: z.ZodEnum<{
@@ -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" | "paused" | "running" | "finalizing";
3068
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "paused" | "finalizing";
3069
3069
  driverParam: string;
3070
3070
  notNull: true;
3071
3071
  hasDefault: false;
@@ -3392,7 +3392,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3392
3392
  tableName: "workflow_execution_frames";
3393
3393
  dataType: "string";
3394
3394
  columnType: "SQLiteText";
3395
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
3395
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
3396
3396
  driverParam: string;
3397
3397
  notNull: true;
3398
3398
  hasDefault: true;
@@ -3405,7 +3405,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3405
3405
  generated: undefined;
3406
3406
  }, {}, {
3407
3407
  length: number | undefined;
3408
- $type: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
3408
+ $type: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
3409
3409
  }>;
3410
3410
  attempt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3411
3411
  name: string;
@@ -3694,7 +3694,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3694
3694
  tableName: "workflow_gate_instances";
3695
3695
  dataType: "string";
3696
3696
  columnType: "SQLiteText";
3697
- data: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
3697
+ data: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
3698
3698
  driverParam: string;
3699
3699
  notNull: true;
3700
3700
  hasDefault: true;
@@ -3707,7 +3707,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
3707
3707
  generated: undefined;
3708
3708
  }, {}, {
3709
3709
  length: number | undefined;
3710
- $type: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
3710
+ $type: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
3711
3711
  }>;
3712
3712
  autoAction: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
3713
3713
  name: "auto_action";
@@ -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" | "paused" | "running" | "finalizing";
4947
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "paused" | "finalizing";
4948
4948
  driverParam: string;
4949
4949
  notNull: true;
4950
4950
  hasDefault: false;
@@ -5206,7 +5206,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
5206
5206
  tableName: "worklog_frame_entries";
5207
5207
  dataType: "string";
5208
5208
  columnType: "SQLiteText";
5209
- data: "pending" | "completed" | "cancelled" | "failed" | "running" | "skipped" | "waiting";
5209
+ data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
5210
5210
  driverParam: string;
5211
5211
  notNull: true;
5212
5212
  hasDefault: false;
@@ -5640,7 +5640,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
5640
5640
  tableName: "worklog_gate_events";
5641
5641
  dataType: "string";
5642
5642
  columnType: "SQLiteText";
5643
- data: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
5643
+ data: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
5644
5644
  driverParam: string;
5645
5645
  notNull: true;
5646
5646
  hasDefault: false;
@@ -5653,7 +5653,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
5653
5653
  generated: undefined;
5654
5654
  }, {}, {
5655
5655
  length: number | undefined;
5656
- $type: "cancelled" | "rejected" | "resumed" | "waiting" | "timed-out";
5656
+ $type: "cancelled" | "rejected" | "waiting" | "resumed" | "timed-out";
5657
5657
  }>;
5658
5658
  prompt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
5659
5659
  name: "prompt";
@@ -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
- paused: "paused";
6489
6488
  running: "running";
6489
+ paused: "paused";
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
- paused: "paused";
6531
6530
  running: "running";
6531
+ paused: "paused";
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
- paused: "paused";
6580
6579
  running: "running";
6580
+ paused: "paused";
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
- paused: "paused";
6920
6919
  running: "running";
6920
+ paused: "paused";
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
- paused: "paused";
7118
7117
  running: "running";
7118
+ paused: "paused";
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
- paused: "paused";
7142
7141
  running: "running";
7142
+ paused: "paused";
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
- paused: "paused";
7195
7194
  running: "running";
7195
+ paused: "paused";
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>>;
@@ -7253,8 +7253,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7253
7253
  cancelled: "cancelled";
7254
7254
  failed: "failed";
7255
7255
  running: "running";
7256
- skipped: "skipped";
7257
7256
  waiting: "waiting";
7257
+ skipped: "skipped";
7258
7258
  }>;
7259
7259
  attempt: z.ZodDefault<z.ZodNumber>;
7260
7260
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -7299,8 +7299,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7299
7299
  cancelled: "cancelled";
7300
7300
  failed: "failed";
7301
7301
  running: "running";
7302
- skipped: "skipped";
7303
7302
  waiting: "waiting";
7303
+ skipped: "skipped";
7304
7304
  }>;
7305
7305
  attempt: z.ZodDefault<z.ZodNumber>;
7306
7306
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -7342,8 +7342,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7342
7342
  cancelled: "cancelled";
7343
7343
  failed: "failed";
7344
7344
  running: "running";
7345
- skipped: "skipped";
7346
7345
  waiting: "waiting";
7346
+ skipped: "skipped";
7347
7347
  }>;
7348
7348
  attempt: z.ZodDefault<z.ZodNumber>;
7349
7349
  iteration: z.ZodOptional<z.ZodNumber>;
@@ -7371,8 +7371,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7371
7371
  status: z.ZodEnum<{
7372
7372
  cancelled: "cancelled";
7373
7373
  rejected: "rejected";
7374
- resumed: "resumed";
7375
7374
  waiting: "waiting";
7375
+ resumed: "resumed";
7376
7376
  "timed-out": "timed-out";
7377
7377
  }>;
7378
7378
  autoAction: z.ZodEnum<{
@@ -7506,8 +7506,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7506
7506
  status: z.ZodEnum<{
7507
7507
  cancelled: "cancelled";
7508
7508
  rejected: "rejected";
7509
- resumed: "resumed";
7510
7509
  waiting: "waiting";
7510
+ resumed: "resumed";
7511
7511
  "timed-out": "timed-out";
7512
7512
  }>;
7513
7513
  autoAction: z.ZodEnum<{
@@ -7531,8 +7531,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7531
7531
  status: z.ZodOptional<z.ZodEnum<{
7532
7532
  cancelled: "cancelled";
7533
7533
  rejected: "rejected";
7534
- resumed: "resumed";
7535
7534
  waiting: "waiting";
7535
+ resumed: "resumed";
7536
7536
  "timed-out": "timed-out";
7537
7537
  }>>;
7538
7538
  limit: z.ZodDefault<z.ZodNumber>;
@@ -7548,8 +7548,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7548
7548
  status: z.ZodEnum<{
7549
7549
  cancelled: "cancelled";
7550
7550
  rejected: "rejected";
7551
- resumed: "resumed";
7552
7551
  waiting: "waiting";
7552
+ resumed: "resumed";
7553
7553
  "timed-out": "timed-out";
7554
7554
  }>;
7555
7555
  autoAction: z.ZodEnum<{
@@ -7584,8 +7584,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
7584
7584
  status: z.ZodEnum<{
7585
7585
  cancelled: "cancelled";
7586
7586
  rejected: "rejected";
7587
- resumed: "resumed";
7588
7587
  waiting: "waiting";
7588
+ resumed: "resumed";
7589
7589
  "timed-out": "timed-out";
7590
7590
  }>;
7591
7591
  autoAction: z.ZodEnum<{
@@ -1 +1 @@
1
- import{u as e}from"./framework-packages-blqho6Nk.mjs";function t(){let t=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(i,a,o){let s=o.getService(e);if(!s)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${e.name}' is started before extensions with transitionRules or transitionActions.`);let c=a.transitionRules?.rules??[],l=a.transitionActions?.actions,u=c.length>0,d=l!==void 0;u&&n(i,c),d&&r(i,l);let f=!1,p=!1;try{u&&(s.ruleRegistry.register(i,c),f=!0),d&&(s.actionRegistry.register(i,l),p=!0)}catch(e){throw f&&s.ruleRegistry.deregister(i),p&&s.actionRegistry.deregister(i),e}t.set(i,()=>{u&&s.ruleRegistry.deregister(i),d&&s.actionRegistry.deregister(i)})},async processStopped(e){let n=t.get(e);if(n){try{n()}catch(t){console.error(`[TransitionContributionProcessor] Deregister error for "${e}":`,t)}t.delete(e)}}}}function n(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function r(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}export{t};
1
+ import{u as e}from"./framework-packages-CdpSqDeo.mjs";function t(){let t=new Map;return{filter:e=>!!(e.transitionRules?.rules?.length||e.transitionActions?.actions),async processActivated(i,a,o){let s=o.getService(e);if(!s)throw Error(`TransitionContributionProcessor: TransitionPipelineService is not available — ensure '${e.name}' is started before extensions with transitionRules or transitionActions.`);let c=a.transitionRules?.rules??[],l=a.transitionActions?.actions,u=c.length>0,d=l!==void 0;u&&n(i,c),d&&r(i,l);let f=!1,p=!1;try{u&&(s.ruleRegistry.register(i,c),f=!0),d&&(s.actionRegistry.register(i,l),p=!0)}catch(e){throw f&&s.ruleRegistry.deregister(i),p&&s.actionRegistry.deregister(i),e}t.set(i,()=>{u&&s.ruleRegistry.deregister(i),d&&s.actionRegistry.deregister(i)})},async processStopped(e){let n=t.get(e);if(n){try{n()}catch(t){console.error(`[TransitionContributionProcessor] Deregister error for "${e}":`,t)}t.delete(e)}}}}function n(e,t){let n=`${e}.`;for(let e of t)if(!e.id.startsWith(n))throw Error(`TransitionContributionProcessor: rule '${e.id}' must be namespaced by extension '${n}'`)}function r(e,t){let n=`${e}.`;for(let e of Object.keys(t))if(!e.startsWith(n))throw Error(`TransitionContributionProcessor: action type '${e}' must be namespaced by extension '${n}'`)}export{t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1790772200584",
3
+ "version": "1.0.0-dev-1791396836202",
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-BvDsO8Is.mjs";import{C as se,M as ce,a as p,d as m,h as le,k as ue,r as de,s as h,t as g,x as fe}from"./kind-registration-CdjmVxY_.mjs";import{t as pe}from"./zod-json-schema-ZUmGtQhT.mjs";import{t as me}from"./ajv-Cvnmw2yn.mjs";import{t as he}from"./2020-CRfgqanb.mjs";import{t as ge}from"./dist-onY7e-pd.mjs";import{z as _}from"zod";import{createBusNamespace as _e}from"@makaio/framework/core";const ve=_.strictObject({evidence:i}),v=_.strictObject({kind:_.literal(`text`),text:_.string()}),[ye,be,xe]=i.options,Se=_.union([ye.pick({source:!0,location:!0}).extend({content:v}),be.pick({source:!0,location:!0}).extend({content:v}),xe.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 Ce(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 we(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 Te(e,t,n,r){if(typeof t.$ref!=`string`)return!1;if(r)return!0;let i=Ce(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`||Te(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 Ee=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=Ce(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=we(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 De(e,t,n){return new Ee(e,n.matchesSchema).extract(t)}function Oe(e){let{dataSchema:t,hooks:n,...r}=e,i={$schema:`https://json-schema.org/draft/2020-12/schema`,...pe(t)};ue(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)=>{Object.hasOwn(e,`slug`)&&t.addIssue({code:`custom`,path:[fe],message:se});try{ce(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 ke=e(me(),1),Ae=e(he(),1),je=e(ge(),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 Ae.default(t):new ke.default(t);return(0,je.default)(n),n.addKeyword({keyword:ae,schemaType:`string`,valid:!0}),n.compile(e.dataSchema)}function Me(e){return e.replace(/~1/gu,`/`).replace(/~0/gu,`~`)}function Ne(e){let t=e.instancePath.split(`/`).slice(1).map(Me),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 Pe(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 Fe=n.array();function Ie(e){if(e.keyword!==`enum`)return;let t=Fe.safeParse(e.params.allowedValues);return t.success?t.data:void 0}function Le(e){return(e??[]).map(e=>{let t=Pe(e),n=Ie(e);return{path:Ne(e),reason:e.message??`violates ${e.keyword}`,...t===void 0?{}:{expectedType:t},...n===void 0?{}:{allowedValues:n}}})}function w(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`slug`)}const Re={path:fe,reason:se};function ze(e){let t=C(e);return e=>t(e)&&!w(e)}function Be(e){let t=C(e);return e=>{let n=t(e)?[]:Le(t.errors);return w(e)&&n.push(Re),n.length===0?{valid:!0}:{valid:!1,issues:n}}}function Ve(e){return{hooks:[...e.hooks]}}const He=[`inline`,`summary`,`link`,`omit`],Ue=[`outbound`,`inbound`],T=_.string().min(1),E=_.enum(Ue),We=_.object({kinds:_.array(_.string().min(1)).optional(),hint:T.optional(),depth:_.number().int().min(1).max(20).optional(),nested:_.lazy(()=>D).optional(),direction:E.optional()}),D=_.record(_.string().min(1),We);function O(e){return JSON.stringify([e.kind,e.id,e.revision])}const Ge=_.enum([`not-selected`,`not-found`,`depth-exceeded`,`unsupported-ref-class`,`cycle-detected`]),Ke=_.object({target:d,sourceRef:f,relationType:_.string().min(1),sourceLocalId:c.shape.sourceLocalId,direction:E.optional(),hint:T,status:_.enum([`resolved`,`unresolved`]),reason:Ge.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`})}),k=_.object({rootRef:f,refs:_.array(Ke),resolved:_.array(l)}).superRefine((e,t)=>{let n=new Set(e.resolved.map(O));n.has(O(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(O(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(O(e.target))||t.addIssue({code:_.ZodIssueCode.custom,path:[`refs`,r,`target`],message:`resolved artifact context refs must have a matching revision in resolved`}))})});function qe(e){let t=k.parse(e),n=new Map(t.resolved.map(e=>[O(e),e])),r=new Map;for(let e of t.refs){let t=O(e.sourceRef),n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}let i=n.get(O(t.rootRef));if(!i)throw Error(`Resolved artifact context is missing root artifact '${O(t.rootRef)}'`);let a=Je(t.rootRef,i,`inline`,r,n);return{root:a,flatten(){let e=[];return Ze(a,e),e}}}function Je(e,t,n,r,i){return{status:`resolved`,ref:e,artifact:t,hint:n,children:Xe(e,r,i,new Set([O(e)]))}}function Ye(e,t,n,r,i,a,o,s,c){let l=O(e),u=new Set(c);return u.add(l),{status:`resolved`,ref:e,artifact:t,relation:n,sourceLocalId:r,direction:i,hint:a,children:Xe(e,o,s,u)}}function Xe(e,t,n,r){return(t.get(O(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=O(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`}:Ye(e.target,a,e.relationType,e.sourceLocalId,e.direction,e.hint,t,n,r)})}function Ze(e,t){if(e.status!==`unresolved`){t.push(e.artifact);for(let n of e.children)Ze(n,t)}}const A=[`$set`,`$unset`,`$push`,`$pull`],j=`[A-Za-z_$][A-Za-z0-9_$]*`,M=`[A-Za-z_$][A-Za-z0-9_$-]*`,Qe=`(?:0|[1-9][0-9]*)`,$e=`(?:${`\\$\\[${j}\\]`}|${Qe}|${M})`,et=RegExp(`^${M}(?:\\.${$e})*$`),tt=RegExp(`^${j}(?:\\.${M})*$`),nt=RegExp(`^${Qe}$`),rt=RegExp(`^\\$\\[(${j})\\]$`),N=_.string().regex(et,`Expected a data-relative path of object properties, array positions, or $[filter] placeholders`);function it(e){let t=rt.exec(e);return t?.[1]===void 0?nt.test(e)?{kind:`index`,index:Number(e)}:{kind:`property`,name:e}:{kind:`filter`,placeholder:t[1]}}function at(e){return e.split(`.`).map(it)}function ot(e){return at(e).flatMap(e=>e.kind===`filter`?[e.placeholder]:[])}const st=r(_.record(_.string().regex(tt,`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 ct(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 P(e,t){return r(_.record(N,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 lt=_.literal(!0),ut=_.strictObject({$set:P(`$set`,n).optional(),$unset:P(`$unset`,lt).optional(),$push:P(`$push`,n).optional(),$pull:P(`$pull`,n).optional(),arrayFilters:_.array(st).optional()});function F(e){return A.flatMap(t=>Object.entries(e[t]??{}).map(([e,n])=>({operator:t,path:e,value:n})))}function dt(e,t){let n=F(e),r=new Map;(e.arrayFilters??[]).forEach((e,n)=>{let i=ct(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 ot(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 ft=ut.superRefine(dt).superRefine((e,t)=>{F(e).length===0&&t.addIssue({code:`custom`,message:`Declare at least one of ${A.join(`, `)}`})}),pt=ut.superRefine(dt),mt=_.strictObject({kind:f.shape.kind,id:f.shape.id}),ht=_.strictObject({ref:mt,baseRevision:f.shape.revision,patch:pt,dryRun:_.boolean().optional(),schemaVersion:m.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&&F(e.patch).length===0&&t.addIssue({code:`custom`,path:[`patch`],message:`Declare at least one of ${A.join(`, `)}, or name a schemaVersion to migrate a payload that already fits`})}),gt=[`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`],_t=_.strictObject({path:_.string(),reason:_.string().min(1),expectedType:_.string().min(1).optional(),allowedValues:_.array(n).optional()}),vt=_.strictObject({code:_.enum(gt),message:_.string().min(1),operator:_.enum(A).optional(),path:N.optional(),currentRevision:f.shape.revision.optional(),issues:_.array(_t).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`]})}),yt=_.strictObject({operator:_.enum(A),path:N,matched:_.number().int().positive()}),bt=_.strictObject({from:m,to:m}).refine(e=>e.to>e.from,{path:[`to`],message:`A migration moves the artifact forward to a newer schema version`}),xt=_.strictObject({ok:_.literal(!0),base:f,operations:_.array(yt),migration:bt.optional()});function St(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 Ct=xt.extend({dryRun:_.literal(!0)}).superRefine(St),wt=xt.extend({dryRun:_.literal(!1),artifact:f}).superRefine(St),Tt=_.discriminatedUnion(`dryRun`,[Ct,wt]),Et=_.strictObject({ok:_.literal(!1),error:vt}),Dt=_.union([Tt,Et]),Ot=_.object({ref:oe}),kt=_.union([_.strictObject({ok:_.literal(!0),ref:oe,areaPath:de,part:t}),_.strictObject({ok:_.literal(!1),error:le})]),I=f.pick({kind:!0,id:!0}),L=_.number().int().positive(),R=L,z={knowledge:`valid`,commitment:`proposed`,interaction:`open`},B=_.discriminatedUnion(`category`,[_.strictObject({category:_.literal(`knowledge`),state:_.enum(g.knowledge),version:R}),_.strictObject({category:_.literal(`commitment`),state:_.enum(g.commitment),version:R}),_.strictObject({category:_.literal(`interaction`),state:_.enum(g.interaction),version:R})]).superRefine((e,t)=>{e.version===1&&e.state!==z[e.category]&&t.addIssue({code:`custom`,path:[`state`],message:`Lifecycle version 1 is reserved for the category initial state`})}),V=_.union([B,_.strictObject({category:_.literal(`record`)})]),H=_.string().trim().min(1),At=_.strictObject({kind:H,ref:H}),U=_.discriminatedUnion(`kind`,[_.strictObject({kind:_.literal(`revision-assessment`),assessedRevision:f.shape.revision,source:At.optional()}),_.strictObject({kind:_.literal(`handover`),source:At})]),jt={artifact:I,expectedVersion:R,state:h,situation:U,reason:H.optional()},W=_.strictObject(jt),Mt=_.strictObject({...jt,actor:re}),Nt={valid:[`retired`],retired:[`valid`],proposed:[`decided`],decided:[`fulfilled`,`revoked`],fulfilled:[],revoked:[],open:[`resolved`,`closed-without-resolution`],resolved:[],"closed-without-resolution":[]};function G(e,t){return Nt[e].includes(t)}const Pt={artifact:I,lifecycle:B,actor:re,timestamp:_.number().int().nonnegative(),observedRevision:f.shape.revision},Ft=_.strictObject({...Pt,operation:_.literal(`initialized`)}).superRefine((e,t)=>{(e.lifecycle.version!==1||e.lifecycle.state!==z[e.lifecycle.category])&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`Initialization requires the category initial state and version 1`})});function It(e,t){return t===`retired`||e===`retired`&&t===`valid`}const Lt=`Retiring or reinstating knowledge requires a reason`,K=_.strictObject({...Pt,operation:_.literal(`transitioned`),previousState:h,situation:U,reason:W.shape.reason}).superRefine((e,t)=>{(!G(e.previousState,e.lifecycle.state)||e.lifecycle.version<=1)&&t.addIssue({code:`custom`,path:[`lifecycle`],message:`History requires a category-compatible transition after initialization`}),It(e.previousState,e.lifecycle.state)&&!e.reason&&t.addIssue({code:`custom`,path:[`reason`],message:Lt}),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`})}),Rt=_.discriminatedUnion(`operation`,[Ft,K]),q=_.discriminatedUnion(`reason`,[_.strictObject({reason:_.literal(`lifecycle-version-conflict`),expectedVersion:R,current:B,requestedState:h}),_.strictObject({reason:_.literal(`content-basis-conflict`),assessedRevision:f.shape.revision,currentRevision:f.shape.revision}),_.strictObject({reason:_.literal(`invalid-transition`),current:V,requestedState:h}),_.strictObject({reason:_.literal(`precondition-failed`),current:B,requestedState:h})]),J=`artifact-lifecycle-rejected`;var Y=class extends Error{code=J;data;constructor(e,t){super(e),this.name=`ArtifactLifecycleError`,this.data=q.parse(t)}};function zt(e){return e===`record`?{category:`record`}:B.parse({category:e,state:z[e],version:1})}function Bt(e){let t=V.parse(e.current),n=f.shape.revision.parse(e.currentRevision),r=Mt.parse(e.command);if(t.category===`record`)throw new Y(`Record artifacts do not have a lifecycle`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(r.expectedVersion!==t.version)throw new Y(`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 Y(`Assessed content revision is no longer current`,{reason:`content-basis-conflict`,assessedRevision:r.situation.assessedRevision,currentRevision:n});if(!G(t.state,r.state))throw new Y(`Artifact lifecycle transition is not allowed`,{reason:`invalid-transition`,current:t,requestedState:r.state});if(It(t.state,r.state)&&!r.reason)throw new Y(Lt,{reason:`precondition-failed`,current:t,requestedState:r.state});return B.parse({...t,state:r.state,version:t.version+1})}const Vt=_.strictObject({artifact:I}),Ht=_.strictObject({lifecycle:V}),Ut=_.strictObject({artifact:I,afterVersion:L.optional(),limit:_.number().int().min(1).max(100).default(50)}),Wt=_.strictObject({entries:_.array(Rt).max(100),nextCursor:L.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`})}),X=_.strictObject({entry:K}),Gt=X,Kt=_.strictObject({code:_.literal(J),message:_.string().min(1),data:q});function qt(e){return{code:e.code,message:e.message,data:e.data}}function Jt(e,t){switch(t.reason){case`content-basis-conflict`:return Xt(e,t);case`lifecycle-version-conflict`:return[...Z(e,t),...Yt(e,t)];case`invalid-transition`:case`precondition-failed`:return[...Z(e,t),...Zt(e,t)]}}function Z(e,t){return t.requestedState===e.state?[]:[{path:[`requestedState`],message:`Rejection requestedState must match the rejected transition`}]}function Yt(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 Xt(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 Zt(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=G(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 Qt=_.strictObject({transition:W,error:Kt}).superRefine(({transition:e,error:t},n)=>{for(let r of Jt(e,t.data))n.addIssue({code:`custom`,path:[`error`,`data`,...r.path],message:r.message})}),$t={"lifecycle.get":{request:Vt,response:Ht},"lifecycle.history":{request:Ut,response:Wt},"lifecycle.transition":{request:W,response:X},"lifecycle.committed":Gt,"lifecycle.rejected":Qt},en=l.omit({id:!0,slug:!0,revision:!0,timestamp:!0}),tn={...$t,"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:en.extend({id:f.shape.id.optional(),slug:l.shape.slug.optional()}),response:_.object({artifact:l})},revise:{request:_.object({previous:f,statusPath:te.optional(),revision:en}),response:_.object({artifact:l})},patch:{request:ht,response:Dt},resolve:{request:_.object({ref:f}),response:_.object({artifact:l.nullable()})},resolvePart:{request:Ot,response:kt},query:{request:o,response:_.object({artifacts:_.array(l)})},compare:{request:ee,response:ne},"evidence.resolve":{request:ve,response:Se},resolveContext:{request:_.object({ref:f,selectors:D.optional(),maxDepth:_.number().int().min(1).max(20).default(5)}),response:_.object({context:k})},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:m})},nn=_e(`artifact`,tn),rn=nn.subjects,an=_.discriminatedUnion(`refClass`,[f.omit({revision:!0}),a]);function Q(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 on(e){return e.refClass===`artifact`?`artifact:${e.kind}/${e.id}`:`entity:${e.entityType}/${e.id}`}const sn=[`relation-target`,`data`];function cn(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())(!sn.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 ln(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n)||!Object.hasOwn(n,e))return;n=Reflect.get(n,e)}return{value:n}}function un(e,t,n,r){let{path:i}=e,a=ln(t,i);if(a===void 0||a.value===null||a.value===void 0)return{ruleIndex:n,selectorIndex:r,reason:`missing-value`,dataPath:i,message:`rule #${n}, selector #${r}, data path '${i}': no value found`};let{value:o}=a;return typeof o!=`string`&&typeof o!=`number`&&typeof o!=`boolean`?{ruleIndex:n,selectorIndex:r,reason:`unsupported-value-type`,dataPath:i,message:`rule #${n}, selector #${r}, data path '${i}': value must be a scalar (string, number, or boolean)`}:{path:i,value:o}}function dn(e,t,n,r,i){if(e.kind===`data`)return un(e,n,r,i);let{relationType:a}=e,o=t.filter(e=>e.type===a&&e.sourceLocalId===void 0),s=new Set,c,l;for(let e of o){let t=Q(e.target);if(t===void 0){l=e.target.refClass;break}s.add($(t)),c=t}return l===void 0?c===void 0?{ruleIndex:r,selectorIndex:i,reason:`missing-target`,relationType:a,message:`rule #${r}, selector #${i}, relation '${a}': no relations of this type found`}:s.size>1?{ruleIndex:r,selectorIndex:i,reason:`ambiguous-target`,relationType:a,message:`rule #${r}, selector #${i}, relation '${a}': ${s.size} distinct targets; expected exactly one`}:{type:a,target:c}:{ruleIndex:r,selectorIndex:i,reason:`unsupported-target`,relationType:a,message:`rule #${r}, selector #${i}, relation '${a}': found a relation with refClass '${l}'; only artifact and entity targets are supported`}}function fn(e){return`target`in e?[`relation-target`,e.type,$(e.target)]:[`data`,e.path,e.value]}function pn(e,t,n){let r=[],i=[];for(let[a,o]of e.entries()){let e=o.by.map((e,r)=>dn(e,t,n,a,r)),s=e.filter(e=>`reason`in e);if(s.length>0){i.push(...s);continue}let c=e.filter(e=>!(`reason`in e)),l=JSON.stringify(c.map(e=>fn(e)));r.push({rule:o,ruleIndex:a,parts:c,serialized:l})}return{keys:r,issues:i}}function mn(e){return e.parts.map(e=>`target`in e?`${e.type} → ${on(e.target)}`:`${e.path} → ${JSON.stringify(e.value)}`).join(`; `)}function hn(e,t,n){let r=[];for(let[i,a]of(e??[]).entries()){if(!gn(a,n))continue;let e=_n(a,t);e<a.minItems&&r.push({index:i,requirement:a,reason:`below-min-items`,count:e}),a.maxItems!==void 0&&e>a.maxItems&&r.push({index:i,requirement:a,reason:`above-max-items`,count:e})}return r}function gn(e,t){return e.when===void 0?!0:ln(t,e.when.path)?.value===e.when.equals}function _n(e,t){let n=new Set;for(let r of t){if(r.sourceLocalId!==void 0||r.type!==e.relationType)continue;let t=Q(r.target);t?.refClass===`artifact`&&(e.targetKinds?.length&&!e.targetKinds.includes(t.kind)||n.add($(t)))}return n.size}export{Dt as $,B as A,gt as B,V as C,ve as Ct,Ft as D,I as E,Bt as F,vt as G,st as H,zt as I,bt as J,Et as K,G as L,W as M,K as N,q as O,L as P,ht as Q,Ot as R,J as S,De as St,Rt as T,ft as U,A as V,Ct as W,N as X,yt as Y,wt as Z,Wt as _,D as _t,an as a,it as at,X as b,ze as bt,$ as c,Ke as ct,rn as d,O as dt,Tt as et,Gt as f,Ue as ft,Ut as g,T as gt,Ht as h,We as ht,mn as i,ot as it,Mt as j,U as k,nn as l,Ge as lt,Vt as m,E as mt,cn as n,ct as nt,Q as o,at as ot,Kt as p,He as pt,_t as q,pn as r,F as rt,on as s,qe as st,hn as t,mt as tt,tn as u,k as ut,Qt as v,Ve as vt,Y as w,Se as wt,qt as x,Oe as xt,$t as y,Be as yt,kt as z};
@@ -1 +0,0 @@
1
- import{createBusInstance as e}from"@makaio/framework/bus";import{HmacAuth as t,WebSocketClientTransport as n}from"@makaio/framework/node/transports";function r(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?e:250}function i(e){let t=performance.now()+e;return()=>Math.max(0,t-performance.now())}function a(e){try{e()}catch{}}const o=`ws://127.0.0.1:6252/bus`;async function s(i){let o;try{let r=i.busUrl?.trim()||process.env.MAKAIO_BUS_URL?.trim()||`ws://127.0.0.1:6252/bus`,a=(i.secret??process.env.MAKAIO_BUS_SECRET)?.trim(),s=a?new t({secret:a}):void 0;o=e({transports:[new n({url:r,name:i.name,autoReconnect:!1,auth:s,debug:i.debug??process.env.MAKAIO_DEBUG===`true`,debugLog:e=>{process.stderr.write(`${e}\n`)}})]})}catch{return null}let s;try{let e=o.connect();return e.catch(()=>void 0),await Promise.race([e,new Promise((e,t)=>{s=setTimeout(()=>{t(Error(`hook bus connect timeout`))},r(i.timeoutMs))})]),{bus:o,dispose:()=>a(()=>o.disconnect())}}catch{return a(()=>o.disconnect()),null}finally{clearTimeout(s)}}export{i,s as n,r,o as t};
@@ -1 +0,0 @@
1
- import{canonicalStringify as e}from"@makaio/framework/utils";import{ArtifactKindRegistrationSchema as t,ArtifactSubjects as n,ArtifactViewModelSchema as r,ArtifactViewResolveRequestSchema as i,MaterializationSubjects as a,dep as o,extensionToken as s}from"@makaio/framework/contracts";import{BaseService as c}from"@makaio/framework/service-base";import{compileArtifactDataSchema as l,readArtifactTitle as u}from"@makaio/framework/contracts/artifact";import{MaterializationSubjects as d}from"@makaio/framework/contracts/materialization";function f(e){try{l(e)}catch(t){throw Error(`Invalid data schema for artifact kind '${e.kind}' version '${e.schemaVersion}': ${t instanceof Error?t.message:String(t)}`,{cause:t})}}const p=[{type:`supersedes`,symmetry:`asymmetric`},{type:`contradicts`,symmetry:`symmetric`},{type:`derives_from`,symmetry:`asymmetric`},{type:`responds_to`,symmetry:`asymmetric`},{type:`contains`,symmetry:`asymmetric`},{type:`refines`,symmetry:`asymmetric`},{type:`scopes`,symmetry:`asymmetric`},{type:`references`,symmetry:`asymmetric`},{type:`evidenced_by`,symmetry:`asymmetric`}],m={extension:0,"factory-repo":1,"target-repo":2},h={source:`extension`,ownerKey:`extension:bus`};function g(e){return`${e.source}:${e.ownerKey}`}function _(e,t){return e.source===t.source&&e.ownerKey===t.ownerKey}function v(e){return structuredClone(e)}function y(e,t){return`${e}@${t}`}var b=class extends c{kinds=new Map;kindContributions=new Map;nextKindContributionOrder=0;relationTypes=new Map;constructor(e){super(e)}async onInit(){for(let e of p)this.relationTypes.set(e.type,e);this.registerHandler(n.kind.register,e=>{this.registerKind(e.payload),e.setResult({registered:!0})}),this.registerHandler(n.kind.list,e=>{let{kind:t}=e.payload,n=[...this.kinds.values()].filter(e=>!t||e.kind===t).map(v);e.setResult({kinds:n})}),this.registerHandler(n[`relation-type`].register,e=>{this.storeRelationType(e.payload),e.setResult({registered:!0})}),this.registerHandler(n[`relation-type`].list,e=>{let{type:t}=e.payload,n=[...this.relationTypes.values()].filter(e=>!t||e.type===t).map(v);e.setResult({relationTypes:n})})}compareKindContributions(e,t){let n=m[e.owner.source]-m[t.owner.source];return n===0?e.owner.source===`extension`?t.order-e.order:e.order-t.order:n}findSameTierRepoConflict(e,t,n){return[...e.values()].find(e=>!_(e.owner,t)&&e.owner.source===t.source&&t.source!==`extension`&&e.order<=n)}recomputeKindWinner(e){let t=this.kindContributions.get(e),r=this.kinds.get(e);if(t===void 0||t.size===0){this.kindContributions.delete(e),this.kinds.delete(e),this.emitKindChangedFromKey(e,r);return}let i;for(let e of t.values())(i===void 0||this.compareKindContributions(e,i)<0)&&(i=e);let a=i;this.kinds.set(e,v(a.registration)),JSON.stringify(r)!==JSON.stringify(a.registration)&&this.bus.emit(n.kind.changed,{kind:a.registration.kind,schemaVersion:a.registration.schemaVersion})}emitKindChangedFromKey(e,t){t!==void 0&&this.bus.emit(n.kind.changed,{kind:t.kind,schemaVersion:t.schemaVersion})}registerKind(e,n=h){e=t.parse(e),f(e);let r=y(e.kind,e.schemaVersion),i=this.kindContributions.get(r)??new Map,a=g(n),o=i.get(a),s=n.source===`extension`?this.nextKindContributionOrder:o?.order??this.nextKindContributionOrder,c=this.findSameTierRepoConflict(i,n,s);if(c!==void 0){console.warn(`[ArtifactSchemaRegistry] Artifact kind '${r}' is already registered by '${c.owner.ownerKey}' at the same priority; keeping the existing owner.`);return}i.set(a,{owner:n,registration:v(e),order:n.source===`extension`||o===void 0?this.nextKindContributionOrder++:o.order}),this.kindContributions.set(r,i),this.recomputeKindWinner(r)}deregisterKind(e,t,n=h){let r=y(e,t),i=this.kindContributions.get(r);i!==void 0&&(i.delete(g(n)),this.recomputeKindWinner(r))}replaceKindRegistrationsForOwner(e,n){let r=n.map(e=>t.parse(e));for(let e of r)f(e);let i=new Set,a=g(e),o=new Map;for(let[e,t]of this.kindContributions.entries()){let n=t.get(a);n!==void 0&&(o.set(e,n.order),t.delete(a),i.add(e))}for(let t of r){let n=y(t.kind,t.schemaVersion),r=this.kindContributions.get(n)??new Map,s=e.source===`extension`?void 0:o.get(n),c=s??this.nextKindContributionOrder,l=this.findSameTierRepoConflict(r,e,c);if(l!==void 0){console.warn(`[ArtifactSchemaRegistry] Artifact kind '${n}' is already registered by '${l.owner.ownerKey}' at the same priority; keeping the existing owner.`);continue}r.set(a,{owner:e,registration:v(t),order:s??this.nextKindContributionOrder++}),this.kindContributions.set(n,r),i.add(n)}for(let e of i)this.recomputeKindWinner(e)}storeRelationType(e){let t=this.relationTypes.get(e.type);if(t){if(t.symmetry!==e.symmetry)throw Error(`Relation type '${e.type}' is already registered with different symmetry (existing: '${t.symmetry}', new: '${e.symmetry}')`);return}this.relationTypes.set(e.type,v(e))}getKind(e,t){let n=this.kinds.get(y(e,t));return n?v(n):void 0}getRelationType(e){let t=this.relationTypes.get(e);return t?v(t):void 0}onDestroy(){this.kinds.clear(),this.kindContributions.clear(),this.relationTypes.clear(),this.nextKindContributionOrder=0}};const x=s(`artifact-schema-registry`),S={name:x.name,displayName:`Artifact Schema Registry`,version:`0.1.0`,critical:!0,create:e=>new b(e.bus)};function C(e,t){return JSON.stringify([e,t])}function w(e){return Object.freeze({kind:e.kind,schemaVersion:e.schemaVersion,version:e.version,build:e.build})}var T=class extends Error{key;incomingOwner;existingOwner;constructor(e,t,n){let r=t===n?`Duplicate builder key '${e}' within owner '${t}'`:`Builder key '${e}' from owner '${t}' collides with owner '${n}'`;super(r),this.key=e,this.incomingOwner=t,this.existingOwner=n,this.name=`ArtifactViewBuilderCollisionError`}},E=class{owners=new Map;globalIndex=new Map;getBuilder(e,t){return this.globalIndex.get(C(e,t))?.builder}replaceBuildersForOwner(e,t){for(let n of t)if(!Number.isInteger(n.version)||n.version<1)throw Error(`Builder for '${C(n.kind,n.schemaVersion)}' from owner '${e}' has non-positive version ${String(n.version)}`);let n=new Map;for(let r of t){let t=C(r.kind,r.schemaVersion);if(n.has(t))throw new T(t,e,e);n.set(t,w(r))}for(let t of n.keys()){let n=this.globalIndex.get(t);if(n&&n.owner!==e)throw new T(t,e,n.owner)}n.size===0?this.owners.delete(e):this.owners.set(e,[...n.values()]),this.rebuildGlobalIndex()}removeBuildersForOwner(e){this.owners.has(e)&&(this.owners.delete(e),this.rebuildGlobalIndex())}getBuildersForOwner(e){let t=this.owners.get(e);if(t)return[...t]}clear(){this.owners.clear(),this.globalIndex.clear()}destroy(){this.clear()}rebuildGlobalIndex(){let e=new Map;for(let[t,n]of this.owners)for(let r of n){let n=C(r.kind,r.schemaVersion);e.set(n,{owner:t,builder:r})}this.globalIndex=e}};const D=5;function O(e){if(e.target.refClass===`artifact`)return{artifactId:e.target.id,label:`[${e.target.kind}] ${e.target.id}`,...e.sourceLocalId===void 0?{}:{sourceLocalId:e.sourceLocalId}}}function k(e){let t=new Map;for(let n of e){let e=O(n);if(!e)continue;let r=t.get(n.type)??[];r.push(e),t.set(n.type,r)}if(t.size!==0)return{type:`relations`,title:`Relations`,groups:[...t.entries()].map(([e,t])=>({type:e,items:t}))}}function A(e){let t=[],n=new Set;for(let r of e){let e=O(r);if(!e)continue;let i=JSON.stringify([e.artifactId,e.sourceLocalId]);n.has(i)||(n.add(i),t.push(e))}return{breadcrumbs:[],related:t}}function j(e){if(!e.confidence?.basis)return;let t=[];for(let n of e.confidence.basis){let e=n.evidenceRef;e?.refClass===`evidence`&&t.push({kind:e.kind,id:e.id,...e.locator?{locator:e.locator}:{}})}if(t.length!==0)return{type:`evidence`,title:`Evidence`,items:t}}function M(e,t,n){let r=[];if(n===`full`){let t=k(e.relations);t&&r.push(t);let n=j(e);n&&r.push(n)}return{title:u(e.data,t.titlePath),artifact:{id:e.id,kind:e.kind,revision:e.revision},navigation:A(e.relations),sections:r,links:{}}}var N=class extends c{schemaRegistry;builderRegistry;constructor(e,t,n){super(e),this.schemaRegistry=t,this.builderRegistry=n}async onInit(){this.registerHandler(a.artifact.view.resolve,async e=>{let{ref:t,level:n,affordance:r,params:a}=i.parse(e.payload),o=await this.resolve(t,n,r,a);e.setResult(o)})}async resolve(e,t,i,a){let o=await this.bus.requestOptional(n.resolve,{ref:e});if(!o.handled||o.data.artifact===null)return{status:`artifact-not-found`,view:null};let s=o.data.artifact,c=this.schemaRegistry.getKind(s.kind,s.schemaVersion);if(c===void 0)return{status:`not-rendered`,view:null};let l=this.builderRegistry.getBuilder(s.kind,s.schemaVersion);if(l===void 0)return{status:`not-rendered`,view:null};let u=M(s,c,t),d=u.sections,f=u.navigation,p=l.version,m=await l.build({artifact:s,level:t,affordance:i,params:a,genericSections:u.sections,genericNavigation:u.navigation,relations:s.relations});if(m!==void 0){if(`render`in m&&m.render===!1)return{status:`not-rendered`,view:null};`sections`in m&&(d=m.sections??d),`navigation`in m&&(f=m.navigation??f)}let h={title:u.title,artifact:u.artifact,navigation:f,sections:[...d],links:u.links};return{status:`ok`,view:r.parse(h),builderVersion:p,sourceRevision:e.revision}}};function P(e){return structuredClone(e)}var F=class extends c{bindings=new Map;constructor(e){super(e)}async onInit(){this.registerHandler(d.surfaceBinding.register,e=>{this.registerBinding(e.payload),e.setResult({registered:!0})}),this.registerHandler(d.surfaceBinding.list,e=>{let{id:t,provider:n,namespace:r}=e.payload,i=[...this.bindings.values()].filter(e=>(!t||e.id===t)&&(!n||e.provider===n)&&(!r||e.namespace===r)).map(P);e.setResult({bindings:i})})}registerBinding(t){let n=this.bindings.get(t.id);if(n){if(e(n)!==e(t))throw Error(`Surface binding '${t.id}' is already registered with a different definition`);return}this.bindings.set(t.id,P(t)),this.bus.emit(d.surfaceBinding.changed,{id:t.id,provider:t.provider})}deregisterBinding(e){let t=this.bindings.get(e);t&&(this.bindings.delete(e),this.bus.emit(d.surfaceBinding.changed,{id:e,provider:t.provider}))}getBinding(e){let t=this.bindings.get(e);return t?P(t):void 0}onDestroy(){this.bindings.clear()}},I=class{queues=new Map;activeLeases=new Map;pendingAcquisitions=new Set;authorizedRequests=new Map;consumedAuthorizedRequestIds=new Set;acceptingAcquisitions=!0;destroyPromise;destroy(){return this.acceptingAcquisitions=!1,this.destroyPromise??=this.drain(),this.destroyPromise}acquire(e){if(!this.acceptingAcquisitions)return Promise.reject(Error(`Materialization operation coordinator is destroyed`));let t=this.acquireAdmitted(e);return this.pendingAcquisitions.add(t),t.then(()=>this.pendingAcquisitions.delete(t),()=>this.pendingAcquisitions.delete(t)),t}async acquireAdmitted(e){let t=L(e),n=new Set,r=[];for(let e of R(t))r.push(await this.acquireKey(e)),n.add(e);let i={id:crypto.randomUUID(),scope:t},a,o=new Promise(e=>{a=e});return this.activeLeases.set(i.id,{lease:i,heldKeys:n,releases:r,settled:o,settle:a,released:!1}),i}release(e){let t=this.requireActiveLease(e);t.released=!0,this.activeLeases.delete(e.id);for(let e of t.releases.reverse())e();t.settle()}async extend(e,t){let n=this.requireActiveLease(e),r=L(t);if(r.artifactId!==e.scope.artifactId)throw Error(`A materialization operation lease cannot be extended to another artifact`);let i=R(r).filter(e=>!n.heldKeys.has(e)),a=[...n.heldKeys].filter(e=>e.startsWith(`provider:`)).at(-1);if(a&&i.some(e=>B(e,a)<0))throw Error(`Materialization operation lease extension violates lock ordering`);for(let e of i)n.releases.push(await this.acquireKey(e)),n.heldKeys.add(e)}async runExclusive(e,t,n,r){let i=L(e);if(n){if(this.consumedAuthorizedRequestIds.has(n))throw Error(`Materialization operation authorization has already been consumed`);let e=this.authorizedRequests.get(n);if(e){this.authorizedRequests.delete(n),this.consumedAuthorizedRequestIds.add(n);let a=this.activeLeases.get(e.leaseId);if(!r?.local||!a||e.scopeKey!==V(i))throw Error(`Materialization operation authorization does not match this scope`);return t(a.lease)}}let a=await this.acquire(i);try{return await t(a)}finally{this.release(a)}}async runAuthorizedRequest(e,t,n){let r=this.requireActiveLease(e),i=L(t);if(!R(i).every(e=>r.heldKeys.has(e)))throw Error(`Materialization operation authorization requires a lease for the full scope`);let a=crypto.randomUUID();this.authorizedRequests.set(a,{leaseId:e.id,scopeKey:V(i)});try{return await n(a)}finally{this.authorizedRequests.delete(a),this.consumedAuthorizedRequestIds.delete(a)}}requireActiveLease(e){let t=this.activeLeases.get(e.id);if(!t||t.released||t.lease!==e)throw Error(`Materialization operation lease is no longer active`);return t}async acquireKey(e){let t=this.queues.get(e)??Promise.resolve(),n,r=new Promise(e=>{n=e}),i=t.then(()=>r);return this.queues.set(e,i),await t,()=>{n(),this.queues.get(e)===i&&this.queues.delete(e)}}async drain(){for(;this.pendingAcquisitions.size>0||this.activeLeases.size>0;)await Promise.allSettled([...this.pendingAcquisitions,...[...this.activeLeases.values()].map(e=>e.settled)])}};function L(e){if(!e.artifactId)throw Error(`Materialization operation scope requires an artifactId`);let t=[...new Map((e.providerObjects??[]).map(e=>[z(e),e])).values()].sort((e,t)=>B(z(e),z(t)));return t.length>0?{artifactId:e.artifactId,providerObjects:t}:{artifactId:e.artifactId}}function R(e){return[`artifact:${e.artifactId}`,...(e.providerObjects??[]).map(z)]}function z(e){if(!e.provider||!e.externalId)throw Error(`Materialization provider objects require provider and externalId`);return`provider:${JSON.stringify([e.provider,e.externalId])}`}function B(e,t){return e===t?0:e<t?-1:1}function V(e){return JSON.stringify(R(e))}const H=s(`surface-binding-registry`),U=s(`artifact-view-builder-registry`),W=s(`artifact-view-service`),G=s(`materialization-operation-coordinator`),K={name:G.name,displayName:`Materialization Operation Coordinator`,version:`0.1.0`,critical:!0,create:()=>new I},q={name:H.name,displayName:`Surface Binding Registry`,version:`0.1.0`,critical:!0,create:e=>new F(e.bus)},J={name:U.name,displayName:`Artifact View Builder Registry`,version:`0.1.0`,critical:!0,create:()=>new E},Y={name:W.name,displayName:`Artifact View Service`,version:`0.1.0`,critical:!0,dependencies:[o(x.name),o(U.name)],create:e=>{let t=e.getService(x),n=e.getService(U);if(t===void 0)throw Error(`ArtifactSchemaRegistry is not available for ArtifactViewService`);if(n===void 0)throw Error(`ArtifactViewBuilderRegistry is not available for ArtifactViewService`);return new N(e.bus,t,n)}};export{S as _,J as a,q as c,N as d,D as f,x as g,E as h,H as i,I as l,T as m,W as n,Y as o,M as p,G as r,K as s,U as t,F as u,b as v};