@makaio/framework 1.0.0-dev-1788811230746 → 1.0.0-dev-1788832451167

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 (103) hide show
  1. package/dist/.makaio-build.json +2 -2
  2. package/dist/{artifact-Btbuib48.mjs → artifact-ClvHqL3w.mjs} +1 -1
  3. package/dist/bus/index.mjs +1 -1
  4. package/dist/{context-resolution-C2VBZhaR.d.mts → context-resolution-BrtoXnez.d.mts} +99 -20
  5. package/dist/contracts/adapter/index.d.mts +1 -1
  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 +64 -64
  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/{execution-attempt-repository-OryBjQQI.d.mts → execution-attempt-repository-CgB7uiYD.d.mts} +12 -1
  21. package/dist/execution-attempt-repository-D0cCU7dI.mjs +1 -0
  22. package/dist/{index-CXH1Bk0W.d.mts → index-BADuMxcP.d.mts} +134 -134
  23. package/dist/{index-BhOMZWZa2.d.mts → index-BDAfOYSw2.d.mts} +24 -24
  24. package/dist/{index-CAYbui7g.d.mts → index-BakMNLkB.d.mts} +110 -22
  25. package/dist/{index-CnGHGFMC.d.mts → index-Bsr4rZl0.d.mts} +4 -4
  26. package/dist/{index-DEpAI8CY.d.mts → index-BvgLFm-U.d.mts} +1 -1
  27. package/dist/{index-9PUmCySn.d.mts → index-BxOFB25y.d.mts} +5 -4
  28. package/dist/{index-BTCodvXA.d.mts → index-C1PfDEIV.d.mts} +50 -50
  29. package/dist/{index-C-cnB1Te.d.mts → index-CGJgZGqN.d.mts} +8 -8
  30. package/dist/{index-B6Kr3cxD2.d.mts → index-CiKzWCW02.d.mts} +30 -6
  31. package/dist/{index-DsjUnKyr.d.mts → index-DZXpKlyB.d.mts} +19 -19
  32. package/dist/{index-DrO6QLwf2.d.mts → index-DZnb56vt2.d.mts} +1 -1
  33. package/dist/{index-BDDavX2S.d.mts → index-LOh6AEqx.d.mts} +9 -9
  34. package/dist/{index-BxTM9lY0.d.mts → index-LryUXslm.d.mts} +1 -1
  35. package/dist/{index-CgqEyk9R.d.mts → index-rygpcDBV.d.mts} +1 -1
  36. package/dist/{index-Df9L5wwp.d.mts → index-vXmPEZ5O.d.mts} +388 -88
  37. package/dist/kernel/extension/index.d.mts +1 -1
  38. package/dist/kernel/index.d.mts +2 -2
  39. package/dist/kernel/observability/index.d.mts +1 -1
  40. package/dist/{materialization-lVd9_-jr.mjs → materialization-B_LA9pfy.mjs} +1 -1
  41. package/dist/{namespace-BkOvOAU5.d.mts → namespace-BMG3RCdr.d.mts} +6 -6
  42. package/dist/{namespace-2qvc6E2Y.d.mts → namespace-BoyqQiW9.d.mts} +2 -2
  43. package/dist/{namespace-CirognbA.d.mts → namespace-BymM0nl_.d.mts} +27 -27
  44. package/dist/{namespace-DAINF1II.d.mts → namespace-DdqVQSyc.d.mts} +2 -2
  45. package/dist/{namespace-DokogwAZ.d.mts → namespace-DlrX8feY.d.mts} +45 -45
  46. package/dist/{namespace-CxXNlHpn.d.mts → namespace-Dw5H_KCF.d.mts} +4 -4
  47. package/dist/{package-DEYXB80d.mjs → package-CzKoZ1k0.mjs} +1 -1
  48. package/dist/{package-eOEt1w6u.d.mts → package-DkpF17X_.d.mts} +14 -6
  49. package/dist/package.json +1 -1
  50. package/dist/runtime-node/index.d.mts +1 -1
  51. package/dist/runtime-node/index.mjs +1 -1
  52. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  53. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  54. package/dist/{schema-zSyY22Ck.d.mts → schema-C9PauHXt.d.mts} +2 -2
  55. package/dist/{schemas-DuJs6Iqj.d.mts → schemas-B2UbGJpJ.d.mts} +10 -10
  56. package/dist/{schemas-Dn1JDTPw.d.mts → schemas-BDZFd3Wb.d.mts} +2 -2
  57. package/dist/{schemas-DqnA42bw.d.mts → schemas-CBpjAhut.d.mts} +4 -4
  58. package/dist/schemas-CNkUEbIr.mjs +1 -0
  59. package/dist/{schemas-D0_kfoDf.d.mts → schemas-Wqo3_F6-.d.mts} +1 -1
  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/execution-target/index.d.mts +2 -2
  67. package/dist/services/execution-target/namespace.d.mts +1 -1
  68. package/dist/services/execution-target/schemas.d.mts +1 -1
  69. package/dist/services/filesystem/namespace.d.mts +6 -6
  70. package/dist/services/filesystem/schemas.d.mts +3 -3
  71. package/dist/services/index.d.mts +30 -30
  72. package/dist/services/index.mjs +1 -1
  73. package/dist/services/provider-context/index.d.mts +1 -1
  74. package/dist/services/session/handlers/index.d.mts +1 -1
  75. package/dist/services/session/index.d.mts +7 -7
  76. package/dist/services/session/messages/namespace.d.mts +1 -1
  77. package/dist/services/session/session-events/namespace.d.mts +1 -1
  78. package/dist/services/session/storage/namespace.d.mts +1 -1
  79. package/dist/services/session/storage/schema.d.mts +1 -1
  80. package/dist/services/settings/namespace.d.mts +10 -10
  81. package/dist/services/subagent-template/index.d.mts +1 -1
  82. package/dist/services/subagent-template/schemas.d.mts +1 -1
  83. package/dist/{transition-BB138WkK.d.mts → transition-DFA_ckdP.d.mts} +1 -1
  84. package/dist/{types-CR23FzmK.d.mts → types-DkfDRSTr.d.mts} +48 -48
  85. package/dist/{view-builder-qIGQrZfs.d.mts → view-builder-CYW_9n4A.d.mts} +1 -1
  86. package/dist/{worker-DPTYFyNP.mjs → worker-B4nD_Erm.mjs} +1 -1
  87. package/dist/{workflow-BomH9DBB.mjs → workflow-H8hsEikC.mjs} +1 -1
  88. package/dist/workflow-engine/execution-attempt-repository.d.mts +2 -2
  89. package/dist/workflow-engine/execution-attempt-repository.mjs +1 -1
  90. package/dist/workflow-engine/index.d.mts +4 -4
  91. package/dist/workflow-engine/index.mjs +1 -1
  92. package/dist/workflow-engine/package.d.mts +1 -1
  93. package/dist/workflow-engine/package.mjs +1 -1
  94. package/dist/workflow-engine/testing/conformance.d.mts +1 -1
  95. package/dist/workflow-engine/testing/conformance.mjs +1 -1
  96. package/dist/workflow-engine/testing/index.d.mts +1 -1
  97. package/dist/workflow-engine/testing/index.mjs +1 -1
  98. package/dist/workflow-engine/testing/sqlite.d.mts +1 -1
  99. package/dist/workflow-engine/testing/sqlite.mjs +32 -32
  100. package/dist/{workflow-worker-BW3CE0YG.mjs → workflow-worker-CmIkKnpF.mjs} +2 -2
  101. package/package.json +1 -1
  102. package/dist/execution-attempt-repository-Djg3qDRv.mjs +0 -1
  103. package/dist/schemas-C3kyQWGf.mjs +0 -1
@@ -88,7 +88,7 @@ declare const SessionStorageNamespace$1: {
88
88
  tableName: "sessions";
89
89
  dataType: "string";
90
90
  columnType: "SQLiteText";
91
- data: "closed" | "discovered" | "active" | "archived";
91
+ data: "closed" | "discovered" | "archived" | "active";
92
92
  driverParam: string;
93
93
  notNull: true;
94
94
  hasDefault: false;
@@ -202,7 +202,7 @@ declare const SessionStorageNamespace$1: {
202
202
  tableName: "sessions";
203
203
  dataType: "string";
204
204
  columnType: "SQLiteText";
205
- data: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside";
205
+ data: "fork" | "subagent" | "compress" | "branch" | "aside" | "rewrite" | "coordinator";
206
206
  driverParam: string;
207
207
  notNull: false;
208
208
  hasDefault: false;
@@ -1240,8 +1240,8 @@ declare const SessionStorageNamespace$1: {
1240
1240
  status: _$zod.ZodEnum<{
1241
1241
  closed: "closed";
1242
1242
  discovered: "discovered";
1243
- active: "active";
1244
1243
  archived: "archived";
1244
+ active: "active";
1245
1245
  }>;
1246
1246
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
1247
1247
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1256,9 +1256,9 @@ declare const SessionStorageNamespace$1: {
1256
1256
  subagent: "subagent";
1257
1257
  compress: "compress";
1258
1258
  branch: "branch";
1259
+ aside: "aside";
1259
1260
  rewrite: "rewrite";
1260
1261
  coordinator: "coordinator";
1261
- aside: "aside";
1262
1262
  }>>;
1263
1263
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
1264
1264
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1382,8 +1382,8 @@ declare const SessionStorageNamespace$1: {
1382
1382
  status: _$zod.ZodEnum<{
1383
1383
  closed: "closed";
1384
1384
  discovered: "discovered";
1385
- active: "active";
1386
1385
  archived: "archived";
1386
+ active: "active";
1387
1387
  }>;
1388
1388
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
1389
1389
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1398,9 +1398,9 @@ declare const SessionStorageNamespace$1: {
1398
1398
  subagent: "subagent";
1399
1399
  compress: "compress";
1400
1400
  branch: "branch";
1401
+ aside: "aside";
1401
1402
  rewrite: "rewrite";
1402
1403
  coordinator: "coordinator";
1403
- aside: "aside";
1404
1404
  }>>;
1405
1405
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
1406
1406
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1487,8 +1487,8 @@ declare const SessionStorageNamespace$1: {
1487
1487
  all: "all";
1488
1488
  closed: "closed";
1489
1489
  discovered: "discovered";
1490
- active: "active";
1491
1490
  archived: "archived";
1491
+ active: "active";
1492
1492
  }>>;
1493
1493
  limit: _$zod.ZodOptional<_$zod.ZodNumber>;
1494
1494
  offset: _$zod.ZodOptional<_$zod.ZodNumber>;
@@ -1549,8 +1549,8 @@ declare const SessionStorageNamespace$1: {
1549
1549
  status: _$zod.ZodEnum<{
1550
1550
  closed: "closed";
1551
1551
  discovered: "discovered";
1552
- active: "active";
1553
1552
  archived: "archived";
1553
+ active: "active";
1554
1554
  }>;
1555
1555
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
1556
1556
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1565,9 +1565,9 @@ declare const SessionStorageNamespace$1: {
1565
1565
  subagent: "subagent";
1566
1566
  compress: "compress";
1567
1567
  branch: "branch";
1568
+ aside: "aside";
1568
1569
  rewrite: "rewrite";
1569
1570
  coordinator: "coordinator";
1570
- aside: "aside";
1571
1571
  }>>;
1572
1572
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
1573
1573
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1654,9 +1654,9 @@ declare const SessionStorageNamespace$1: {
1654
1654
  subagent: "subagent";
1655
1655
  compress: "compress";
1656
1656
  branch: "branch";
1657
+ aside: "aside";
1657
1658
  rewrite: "rewrite";
1658
1659
  coordinator: "coordinator";
1659
- aside: "aside";
1660
1660
  }>>;
1661
1661
  messageCount: _$zod.ZodNumber;
1662
1662
  hasChildren: _$zod.ZodBoolean;
@@ -1672,8 +1672,8 @@ declare const SessionStorageNamespace$1: {
1672
1672
  all: "all";
1673
1673
  closed: "closed";
1674
1674
  discovered: "discovered";
1675
- active: "active";
1676
1675
  archived: "archived";
1676
+ active: "active";
1677
1677
  }>>;
1678
1678
  isImported: _$zod.ZodOptional<_$zod.ZodBoolean>;
1679
1679
  }, _$zod_v4_core0.$strip>;
@@ -1731,8 +1731,8 @@ declare const SessionStorageNamespace$1: {
1731
1731
  status: _$zod.ZodEnum<{
1732
1732
  closed: "closed";
1733
1733
  discovered: "discovered";
1734
- active: "active";
1735
1734
  archived: "archived";
1735
+ active: "active";
1736
1736
  }>;
1737
1737
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
1738
1738
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1747,9 +1747,9 @@ declare const SessionStorageNamespace$1: {
1747
1747
  subagent: "subagent";
1748
1748
  compress: "compress";
1749
1749
  branch: "branch";
1750
+ aside: "aside";
1750
1751
  rewrite: "rewrite";
1751
1752
  coordinator: "coordinator";
1752
- aside: "aside";
1753
1753
  }>>;
1754
1754
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
1755
1755
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1828,14 +1828,14 @@ declare const SessionStorageNamespace$1: {
1828
1828
  status: _$zod.ZodOptional<_$zod.ZodEnum<{
1829
1829
  closed: "closed";
1830
1830
  discovered: "discovered";
1831
- active: "active";
1832
1831
  archived: "archived";
1832
+ active: "active";
1833
1833
  }>>;
1834
1834
  expectedStatus: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodEnum<{
1835
1835
  closed: "closed";
1836
1836
  discovered: "discovered";
1837
- active: "active";
1838
1837
  archived: "archived";
1838
+ active: "active";
1839
1839
  }>>>;
1840
1840
  parentSessionId: _$zod.ZodOptional<_$zod.ZodNullable<_$zod.ZodString>>;
1841
1841
  contextInheritance: _$zod.ZodOptional<_$zod.ZodEnum<{
@@ -1849,9 +1849,9 @@ declare const SessionStorageNamespace$1: {
1849
1849
  subagent: "subagent";
1850
1850
  compress: "compress";
1851
1851
  branch: "branch";
1852
+ aside: "aside";
1852
1853
  rewrite: "rewrite";
1853
1854
  coordinator: "coordinator";
1854
- aside: "aside";
1855
1855
  }>>;
1856
1856
  isOrchestrated: _$zod.ZodOptional<_$zod.ZodBoolean>;
1857
1857
  clientId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1955,8 +1955,8 @@ declare const SessionStorageNamespace$1: {
1955
1955
  status: _$zod.ZodEnum<{
1956
1956
  closed: "closed";
1957
1957
  discovered: "discovered";
1958
- active: "active";
1959
1958
  archived: "archived";
1959
+ active: "active";
1960
1960
  }>;
1961
1961
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
1962
1962
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1971,9 +1971,9 @@ declare const SessionStorageNamespace$1: {
1971
1971
  subagent: "subagent";
1972
1972
  compress: "compress";
1973
1973
  branch: "branch";
1974
+ aside: "aside";
1974
1975
  rewrite: "rewrite";
1975
1976
  coordinator: "coordinator";
1976
- aside: "aside";
1977
1977
  }>>;
1978
1978
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
1979
1979
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2247,8 +2247,8 @@ declare const SessionStorageNamespace$1: {
2247
2247
  status: _$zod.ZodEnum<{
2248
2248
  closed: "closed";
2249
2249
  discovered: "discovered";
2250
- active: "active";
2251
2250
  archived: "archived";
2251
+ active: "active";
2252
2252
  }>;
2253
2253
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
2254
2254
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2263,9 +2263,9 @@ declare const SessionStorageNamespace$1: {
2263
2263
  subagent: "subagent";
2264
2264
  compress: "compress";
2265
2265
  branch: "branch";
2266
+ aside: "aside";
2266
2267
  rewrite: "rewrite";
2267
2268
  coordinator: "coordinator";
2268
- aside: "aside";
2269
2269
  }>>;
2270
2270
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
2271
2271
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2396,8 +2396,8 @@ declare const SessionStorageNamespace$1: {
2396
2396
  status: _$zod.ZodEnum<{
2397
2397
  closed: "closed";
2398
2398
  discovered: "discovered";
2399
- active: "active";
2400
2399
  archived: "archived";
2400
+ active: "active";
2401
2401
  }>;
2402
2402
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
2403
2403
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2412,9 +2412,9 @@ declare const SessionStorageNamespace$1: {
2412
2412
  subagent: "subagent";
2413
2413
  compress: "compress";
2414
2414
  branch: "branch";
2415
+ aside: "aside";
2415
2416
  rewrite: "rewrite";
2416
2417
  coordinator: "coordinator";
2417
- aside: "aside";
2418
2418
  }>>;
2419
2419
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
2420
2420
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2566,8 +2566,8 @@ declare const SessionStorageNamespace$1: {
2566
2566
  status: _$zod.ZodEnum<{
2567
2567
  closed: "closed";
2568
2568
  discovered: "discovered";
2569
- active: "active";
2570
2569
  archived: "archived";
2570
+ active: "active";
2571
2571
  }>;
2572
2572
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
2573
2573
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2582,9 +2582,9 @@ declare const SessionStorageNamespace$1: {
2582
2582
  subagent: "subagent";
2583
2583
  compress: "compress";
2584
2584
  branch: "branch";
2585
+ aside: "aside";
2585
2586
  rewrite: "rewrite";
2586
2587
  coordinator: "coordinator";
2587
- aside: "aside";
2588
2588
  }>>;
2589
2589
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
2590
2590
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2708,8 +2708,8 @@ declare const SessionStorageNamespace$1: {
2708
2708
  status: _$zod.ZodEnum<{
2709
2709
  closed: "closed";
2710
2710
  discovered: "discovered";
2711
- active: "active";
2712
2711
  archived: "archived";
2712
+ active: "active";
2713
2713
  }>;
2714
2714
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
2715
2715
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2724,9 +2724,9 @@ declare const SessionStorageNamespace$1: {
2724
2724
  subagent: "subagent";
2725
2725
  compress: "compress";
2726
2726
  branch: "branch";
2727
+ aside: "aside";
2727
2728
  rewrite: "rewrite";
2728
2729
  coordinator: "coordinator";
2729
- aside: "aside";
2730
2730
  }>>;
2731
2731
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
2732
2732
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2813,8 +2813,8 @@ declare const SessionStorageNamespace$1: {
2813
2813
  all: "all";
2814
2814
  closed: "closed";
2815
2815
  discovered: "discovered";
2816
- active: "active";
2817
2816
  archived: "archived";
2817
+ active: "active";
2818
2818
  }>>;
2819
2819
  limit: _$zod.ZodOptional<_$zod.ZodNumber>;
2820
2820
  offset: _$zod.ZodOptional<_$zod.ZodNumber>;
@@ -2875,8 +2875,8 @@ declare const SessionStorageNamespace$1: {
2875
2875
  status: _$zod.ZodEnum<{
2876
2876
  closed: "closed";
2877
2877
  discovered: "discovered";
2878
- active: "active";
2879
2878
  archived: "archived";
2879
+ active: "active";
2880
2880
  }>;
2881
2881
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
2882
2882
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2891,9 +2891,9 @@ declare const SessionStorageNamespace$1: {
2891
2891
  subagent: "subagent";
2892
2892
  compress: "compress";
2893
2893
  branch: "branch";
2894
+ aside: "aside";
2894
2895
  rewrite: "rewrite";
2895
2896
  coordinator: "coordinator";
2896
- aside: "aside";
2897
2897
  }>>;
2898
2898
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
2899
2899
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2980,9 +2980,9 @@ declare const SessionStorageNamespace$1: {
2980
2980
  subagent: "subagent";
2981
2981
  compress: "compress";
2982
2982
  branch: "branch";
2983
+ aside: "aside";
2983
2984
  rewrite: "rewrite";
2984
2985
  coordinator: "coordinator";
2985
- aside: "aside";
2986
2986
  }>>;
2987
2987
  messageCount: _$zod.ZodNumber;
2988
2988
  hasChildren: _$zod.ZodBoolean;
@@ -2998,8 +2998,8 @@ declare const SessionStorageNamespace$1: {
2998
2998
  all: "all";
2999
2999
  closed: "closed";
3000
3000
  discovered: "discovered";
3001
- active: "active";
3002
3001
  archived: "archived";
3002
+ active: "active";
3003
3003
  }>>;
3004
3004
  isImported: _$zod.ZodOptional<_$zod.ZodBoolean>;
3005
3005
  }, _$zod_v4_core0.$strip>;
@@ -3057,8 +3057,8 @@ declare const SessionStorageNamespace$1: {
3057
3057
  status: _$zod.ZodEnum<{
3058
3058
  closed: "closed";
3059
3059
  discovered: "discovered";
3060
- active: "active";
3061
3060
  archived: "archived";
3061
+ active: "active";
3062
3062
  }>;
3063
3063
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
3064
3064
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3073,9 +3073,9 @@ declare const SessionStorageNamespace$1: {
3073
3073
  subagent: "subagent";
3074
3074
  compress: "compress";
3075
3075
  branch: "branch";
3076
+ aside: "aside";
3076
3077
  rewrite: "rewrite";
3077
3078
  coordinator: "coordinator";
3078
- aside: "aside";
3079
3079
  }>>;
3080
3080
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
3081
3081
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3154,14 +3154,14 @@ declare const SessionStorageNamespace$1: {
3154
3154
  status: _$zod.ZodOptional<_$zod.ZodEnum<{
3155
3155
  closed: "closed";
3156
3156
  discovered: "discovered";
3157
- active: "active";
3158
3157
  archived: "archived";
3158
+ active: "active";
3159
3159
  }>>;
3160
3160
  expectedStatus: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodEnum<{
3161
3161
  closed: "closed";
3162
3162
  discovered: "discovered";
3163
- active: "active";
3164
3163
  archived: "archived";
3164
+ active: "active";
3165
3165
  }>>>;
3166
3166
  parentSessionId: _$zod.ZodOptional<_$zod.ZodNullable<_$zod.ZodString>>;
3167
3167
  contextInheritance: _$zod.ZodOptional<_$zod.ZodEnum<{
@@ -3175,9 +3175,9 @@ declare const SessionStorageNamespace$1: {
3175
3175
  subagent: "subagent";
3176
3176
  compress: "compress";
3177
3177
  branch: "branch";
3178
+ aside: "aside";
3178
3179
  rewrite: "rewrite";
3179
3180
  coordinator: "coordinator";
3180
- aside: "aside";
3181
3181
  }>>;
3182
3182
  isOrchestrated: _$zod.ZodOptional<_$zod.ZodBoolean>;
3183
3183
  clientId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3281,8 +3281,8 @@ declare const SessionStorageNamespace$1: {
3281
3281
  status: _$zod.ZodEnum<{
3282
3282
  closed: "closed";
3283
3283
  discovered: "discovered";
3284
- active: "active";
3285
3284
  archived: "archived";
3285
+ active: "active";
3286
3286
  }>;
3287
3287
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
3288
3288
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3297,9 +3297,9 @@ declare const SessionStorageNamespace$1: {
3297
3297
  subagent: "subagent";
3298
3298
  compress: "compress";
3299
3299
  branch: "branch";
3300
+ aside: "aside";
3300
3301
  rewrite: "rewrite";
3301
3302
  coordinator: "coordinator";
3302
- aside: "aside";
3303
3303
  }>>;
3304
3304
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
3305
3305
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3573,8 +3573,8 @@ declare const SessionStorageNamespace$1: {
3573
3573
  status: _$zod.ZodEnum<{
3574
3574
  closed: "closed";
3575
3575
  discovered: "discovered";
3576
- active: "active";
3577
3576
  archived: "archived";
3577
+ active: "active";
3578
3578
  }>;
3579
3579
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
3580
3580
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3589,9 +3589,9 @@ declare const SessionStorageNamespace$1: {
3589
3589
  subagent: "subagent";
3590
3590
  compress: "compress";
3591
3591
  branch: "branch";
3592
+ aside: "aside";
3592
3593
  rewrite: "rewrite";
3593
3594
  coordinator: "coordinator";
3594
- aside: "aside";
3595
3595
  }>>;
3596
3596
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
3597
3597
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3722,8 +3722,8 @@ declare const SessionStorageNamespace$1: {
3722
3722
  status: _$zod.ZodEnum<{
3723
3723
  closed: "closed";
3724
3724
  discovered: "discovered";
3725
- active: "active";
3726
3725
  archived: "archived";
3726
+ active: "active";
3727
3727
  }>;
3728
3728
  leadAgentId: _$zod.ZodOptional<_$zod.ZodString>;
3729
3729
  parentSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3738,9 +3738,9 @@ declare const SessionStorageNamespace$1: {
3738
3738
  subagent: "subagent";
3739
3739
  compress: "compress";
3740
3740
  branch: "branch";
3741
+ aside: "aside";
3741
3742
  rewrite: "rewrite";
3742
3743
  coordinator: "coordinator";
3743
- aside: "aside";
3744
3744
  }>>;
3745
3745
  adapterName: _$zod.ZodOptional<_$zod.ZodString>;
3746
3746
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -3836,7 +3836,7 @@ declare const SessionStorageNamespace$1: {
3836
3836
  options?: _$_makaio_core0.NamespaceRegistrationOptions;
3837
3837
  defaultTransports?: _$_makaio_core0.TransportRoutingDefault;
3838
3838
  __filterPayload?: {
3839
- [x: string]: string | number | boolean | Record<string, _$_makaio_contracts0.JsonValue> | ("closed" | "discovered" | "active" | "archived")[] | {
3839
+ [x: string]: string | number | boolean | Record<string, _$_makaio_contracts0.JsonValue> | ("closed" | "discovered" | "archived" | "active")[] | {
3840
3840
  clientId: string;
3841
3841
  source: string;
3842
3842
  kind: string;
@@ -3875,13 +3875,13 @@ declare const SessionStorageNamespace$1: {
3875
3875
  clientId?: string | undefined;
3876
3876
  compressionMode?: "auto" | "manual" | "off" | undefined;
3877
3877
  }[];
3878
- status: "closed" | "discovered" | "active" | "archived";
3878
+ status: "closed" | "discovered" | "archived" | "active";
3879
3879
  leadAgentId?: string | undefined;
3880
3880
  parentSessionId?: string | undefined;
3881
3881
  contextInheritance?: "none" | "parent-history" | undefined;
3882
3882
  rootSessionId?: string | undefined;
3883
3883
  forkPointMessageId?: string | undefined;
3884
- branchKind?: "fork" | "subagent" | "compress" | "branch" | "rewrite" | "coordinator" | "aside" | undefined;
3884
+ branchKind?: "fork" | "subagent" | "compress" | "branch" | "aside" | "rewrite" | "coordinator" | undefined;
3885
3885
  adapterName?: string | undefined;
3886
3886
  adapterSessionId?: string | undefined;
3887
3887
  currentAdapterSessionId?: string | undefined;
@@ -335,8 +335,8 @@ declare const MessageStorageNamespace$1: {
335
335
  isError: _$zod.ZodOptional<_$zod.ZodBoolean>;
336
336
  }, _$zod_v4_core0.$strip>], "type">>;
337
337
  agentId: _$zod.ZodOptional<_$zod.ZodString>;
338
- turnId: _$zod.ZodNullable<_$zod.ZodString>;
339
338
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
339
+ turnId: _$zod.ZodNullable<_$zod.ZodString>;
340
340
  timestamp: _$zod.ZodNumber;
341
341
  contentText: _$zod.ZodString;
342
342
  adapterMessageId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -1120,8 +1120,8 @@ declare const MessageStorageNamespace$1: {
1120
1120
  isError: _$zod.ZodOptional<_$zod.ZodBoolean>;
1121
1121
  }, _$zod_v4_core0.$strip>], "type">>;
1122
1122
  agentId: _$zod.ZodOptional<_$zod.ZodString>;
1123
- turnId: _$zod.ZodNullable<_$zod.ZodString>;
1124
1123
  adapterSessionId: _$zod.ZodOptional<_$zod.ZodString>;
1124
+ turnId: _$zod.ZodNullable<_$zod.ZodString>;
1125
1125
  timestamp: _$zod.ZodNumber;
1126
1126
  contentText: _$zod.ZodString;
1127
1127
  adapterMessageId: _$zod.ZodOptional<_$zod.ZodString>;
@@ -2030,10 +2030,10 @@ declare const MessageStorageNamespace$1: {
2030
2030
  })[];
2031
2031
  messageId: string;
2032
2032
  agentId: never;
2033
- turnId: string | null;
2034
2033
  adapterSessionId: never;
2035
- timestamp: number;
2034
+ turnId: string | null;
2036
2035
  limit: never;
2036
+ timestamp: number;
2037
2037
  query: string;
2038
2038
  contentText: string;
2039
2039
  adapterMessageId: string;
@@ -1,4 +1,4 @@
1
- import{$ as e,A as t,B as n,D as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as ee,R as te,U as ne,V as re,W as ie,X as ae,Y as oe,Z as se,_t as ce,a as le,at as ue,c as de,ct as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as m,l as we,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,st as Le,tt as Re,u as ze,ut as Be,v as Ve,vt as h,z as g}from"./authority-state-bootstrap-7Cgb9TR2.mjs";import{a as He}from"./execution-attempt-repository-Djg3qDRv.mjs";import{assertWorkflowTriggerPayload as Ue,compileWorkflowTriggerBindingFilter as We}from"./workflow-engine/workflow-trigger-binding-consumer.mjs";import{SerialLane as Ge}from"@makaio/framework/utils";import{ArtifactSubjects as Ke,AutomationTriggerSubjects as qe,CRON_AUTOMATION_TRIGGER_KIND as Je,EXECUTION_LIST_DEFAULT_LIMIT as Ye,EXECUTION_LIST_MAX_LIMIT as _,EXECUTION_LIST_MIN_LIMIT as v,EXTERNAL_EXECUTION_ID_PREFIX as y,ExecutionAttemptSchemas as b,ExecutionAttemptSubjects as x,ExecutionsByArtifactRefsQuerySchema as Xe,JsonPatchOperationSchema as Ze,JsonValueSchema as Qe,SessionSubjects as $e,WORKFLOW_CANCELLED_REASON as et,WorkLogFrameEntrySchema as tt,WorkerSubjects as nt,WorkflowAutomationTriggerBindingSchema as rt,WorkflowError as S,WorkflowErrorCode as it,WorkflowNamespace as at,WorkflowRunContextSchema as ot,WorkflowRunResultSchema as st,WorkflowStepTypeSchema as ct,WorkflowSubjects as C,createWorkflowCancelSubject as lt,createWorkflowDelegateResultFinalizerNamespace as ut,createWorkflowFinalizerNamespace as dt,dep as ft,extensionToken as pt,serializeArtifactRef as mt,walkWorkflowDefinition as ht}from"@makaio/framework/contracts";import{BaseService as gt}from"@makaio/framework/service-base";import{defineDialectSchema as _t,executeTransaction as w,getDatabaseDialect as vt,registerDrizzleHandlers as yt,resolveSchema as T,serializeDatabaseOperation as E}from"@makaio/framework/storage/drizzle";import{and as D,asc as O,count as k,desc as A,eq as j,getTableColumns as bt,gte as xt,isNotNull as St,isNull as M,lt as Ct,lte as wt,notInArray as Tt,or as Et,sql as N,sum as P}from"drizzle-orm";import{SessionToken as Dt}from"@makaio/framework/services";import{AutomationTriggerBindingRuntimeToken as Ot}from"@makaio/framework/services/automation-trigger";const kt=ie.postgres,At=me.postgres,jt=c.postgres,Mt=ke.postgres,Nt=je.postgres,Pt=s.postgres,Ft=Se.postgres,It=De.postgres,Lt=Be.postgres,Rt=fe.postgres,zt=ge.postgres,Bt=ae.postgres,Vt=ee.postgres,Ht=ve.postgres,F=_t({workflowDefinitions:ne,workflowExecutions:e,workflowExecutionFrames:i,workflowGateInstances:Re,workflowStepSpans:ue,workflowExecutionLinks:Pe,workflowRunContexts:Ie,worklogSummaries:Ne,worklogFrameEntries:Te,worklogArtifactWrites:Le,worklogGateEvents:pe,workflowExecutionState:oe,workflowExecutionStateEvents:se,workflowFinalizations:be},{workflowDefinitions:kt,workflowExecutions:At,workflowExecutionFrames:jt,workflowGateInstances:Mt,workflowStepSpans:Nt,workflowExecutionLinks:Pt,workflowRunContexts:Ft,worklogSummaries:It,worklogFrameEntries:Lt,worklogArtifactWrites:Rt,worklogGateEvents:zt,workflowExecutionState:Bt,workflowExecutionStateEvents:Vt,workflowFinalizations:Ht});function I(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function L(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function Ut(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=I(t);return[j(e.scopeType,n),j(e.scopeKind,r),j(e.scopeId,i)]}function R(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:L(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executableSource:e.executableSource??void 0,requirements:e.requirements??void 0,successFinalizerId:e.successFinalizerId??void 0}}function Wt(e,t){let n=I(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executableSource:e.executableSource??null,requirements:e.requirements??null,successFinalizerId:e.successFinalizerId??null,createdAt:t,updatedAt:t,...n}}function Gt(e,t){let{workflowDefinitions:n}=T(t,F),r=bt(n),i=e.on(a.get,async e=>{let r=await t.select().from(n).where(j(n.id,e.payload.id)).limit(1);e.setResult({workflow:r[0]?R(r[0]):null})}),o=e.on(a.set,async i=>{let a=i.payload.workflow,o=Date.now(),s=Wt(a,o),c=await E(t,async()=>{let e=await t.insert(n).values(s).onConflictDoNothing({target:n.id}).returning();if(e.length>0)return{kind:`created`,row:e[0]};let[i]=await t.update(n).set({name:s.name,root:s.root,updatedAt:o,createdAt:N`COALESCE(${r.createdAt}, ${o})`,description:s.description===null?N`${r.description}`:s.description,inputSchema:s.inputSchema===null?N`${r.inputSchema}`:s.inputSchema,configSchema:s.configSchema===null?N`${r.configSchema}`:s.configSchema,outputSchema:s.outputSchema===null?N`${r.outputSchema}`:s.outputSchema,state:s.state,artifact:s.artifact===null?N`${r.artifact}`:s.artifact,triggers:s.triggers===null?N`${r.triggers}`:s.triggers,canvasLayout:s.canvasLayout===null?N`${r.canvasLayout}`:s.canvasLayout,source:s.source===null?N`${r.source}`:s.source,executableSource:s.executableSource,requirements:s.requirements,successFinalizerId:s.successFinalizerId,...I(a.scope)}).where(j(n.id,a.id)).returning();return i?{kind:`updated`,row:i}:void 0});c&&await e.emit(c.kind===`created`?h.definition.created:h.definition.updated,R(c.row)),i.setResult({id:a.id})}),s=e.on(a.delete,async r=>{let i=(await E(t,()=>t.delete(n).where(j(n.id,r.payload.id)).returning())).length>0;i&&await e.emit(h.definition.deleted,{id:r.payload.id}),r.setResult({deleted:i})}),c=e.on(a.list,async e=>{let r=e.payload,i=r.scope?Ut(n,r.scope):[],a=i.length>0?await t.select().from(n).where(D(...i)):await t.select().from(n);e.setResult({workflows:a.map(R)})});return()=>{i(),o(),s(),c()}}function Kt(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function qt(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function Jt(e,t){let{workflowExecutionFrames:n}=T(t,F),r=e.on(a.setFrame,async e=>{let{executionId:r,frame:i}=e.payload;if(!g(e,r))throw Error(`Unauthorized: caller is not permitted to write frames for execution: ${r}`);let a=qt(r,i);await E(t,()=>t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a})),e.setResult({frameId:i.frameId})}),i=e.on(a.getFrame,async e=>{let r=await t.select().from(n).where(j(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?Kt(r[0]):null})}),o=e.on(a.listFrames,async e=>{if(!g(e,e.payload.executionId))throw Error(`Unauthorized: caller is not permitted to list frames for execution: ${e.payload.executionId}`);let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.frameId));e.setResult({frames:r.map(Kt)})});return()=>{r(),i(),o()}}function Yt(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function z(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function B(e){return{id:Yt(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function Xt(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??Ye;if(!Number.isInteger(i)||i<v||i>_)throw Error(`Gate instance list limit must be an integer between ${v} and ${_}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[j(r.executionId,e)],...t===void 0?[]:[j(r.status,t)]]}}function Zt(e,t){let{workflowExecutions:n,workflowGateInstances:r}=T(t,F),i=e.on(a.setGateInstance,async e=>{let n=e.payload.gate;if(!g(e,n.executionId))throw Error(`Unauthorized: caller is not permitted to write gates for execution: ${n.executionId}`);let i=B(n);await E(t,()=>t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i})),e.setResult({id:i.id})}),o=e.on(a.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=B(n),a=await E(t,()=>t.update(r).set(i).where(D(j(r.id,i.id),j(r.status,`waiting`))).returning({id:r.id}));e.setResult({accepted:a.length===1})}),s=e.on(a.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload;if(!g(e,n))throw Error(`Unauthorized: caller is not permitted to read gates for execution: ${n}`);let o=[j(r.executionId,n),j(r.nodeId,i)];a!==void 0&&o.push(j(r.frameId,a));let s=await t.select().from(r).where(D(...o)).limit(1);e.setResult({gate:s[0]?z(s[0]):null})}),c=e.on(a.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=Xt(n,i,a,r),c=await t.select().from(r).where(D(...s)).orderBy(A(r.createdAt),A(r.id)).limit(o);e.setResult({gates:c.map(z)})}),l=e.on(a.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,j(r.executionId,n.id)).where(D(j(r.status,`waiting`),j(n.status,`paused`),St(r.timeoutMs)));e.setResult({gates:i.map(e=>z(e.gate))})});return()=>{i(),o(),s(),c(),l()}}function Qt(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function $t(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function en(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=T(t,F),i=e.on(a.setSpan,async e=>{let{span:r}=e.payload;if(!g(e,r.executionId))throw Error(`Unauthorized: caller is not permitted to write spans for execution: ${r.executionId}`);await E(t,()=>t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r})),e.setResult({id:`${r.executionId}:${r.frameId}`})}),o=e.on(a.listSpans,async e=>{let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.stepId),O(n.frameId));e.setResult({spans:r.map(Qt)})}),s=e.on(a.setExecutionLink,async e=>{let{link:n}=e.payload;await E(t,()=>t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n})),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),c=e.on(a.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[j(r.sourceExecutionId,n)],...i===void 0?[]:[j(r.targetExecutionId,i)]],o=t.select().from(r).where(D(...a));e.setResult({links:(await o).map($t)})});return()=>{i(),o(),s(),c()}}function V(e,t){return t===null?vt(e)===`postgres`?N`'null'::jsonb`:N`'null'`:t}function tn(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function nn(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function rn(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:nn(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:L(e),...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===null?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===null?{}:{materializationSpec:e.materializationSpec}}}function an(e){let t=tn(e.source),n=I(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,artifactRef:e.artifactRef??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy,terminalAuthority:e.terminalAuthority??null,materializationSpec:e.materializationSpec??null}}async function on(e,t,n){let r=an(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function sn(e,t){let{workflowRunContexts:n,workflowExecutionState:r,workflowExecutionStateEvents:i}=T(t,F),o=e.on(a.setRunContext,async e=>{let a=e.payload.runContext,o=e.payload.initialState;await w(t,async e=>{if(await on(e,a,n),o===void 0)return;let s=Date.now(),c=V(t,o);await e.insert(r).values({executionId:a.executionId,sequence:0,value:c,updatedAt:s}).onConflictDoNothing(),await e.insert(i).values({executionId:a.executionId,sequence:0,patch:[],value:c,createdAt:s}).onConflictDoNothing()}),e.setResult({executionId:a.executionId})}),s=e.on(a.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(j(n.executionId,r)),a=i[0]?rn(i[0]):null;e.setResult({runContext:a})});return()=>{o(),s()}}async function cn(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=T(e,F),a=Date.now(),o=V(e,n);await w(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function ln(e,t){let{workflowExecutionState:n}=T(e,F),r=(await e.select().from(n).where(j(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function un(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=T(e,F),i=Date.now(),a=V(e,t.nextValue);return w(e,async e=>{let o=(await e.select().from(n).where(j(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=te(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(D(j(n.executionId,t.executionId),j(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function dn(e,t){let n=e.on(a.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await cn(t,n,r),e.setResult({})}),r=e.on(a.getState,async e=>{let{executionId:n}=e.payload,r=await ln(t,n);e.setResult({state:r})}),i=e.on(a.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await un(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function fn(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function pn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function mn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:hn(t),setWhere:Tt(n.status,[`completed`,`failed`,`cancelled`])})}function hn(e){return{workflowId:e.workflowId,workflowName:e.workflowName,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,error:e.error,failedNodeId:e.failedNodeId}}async function H(e,t){let{worklogSummaries:n}=T(e,F),r=await e.select().from(n).where(j(n.executionId,t)).limit(1);return r[0]?fn(r[0]):null}async function gn(e,t={}){let{worklogSummaries:n}=T(e,F),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[j(n.workflowId,r)],...i===void 0?[]:[j(n.status,i)]],c=s.length>0?D(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(A(n.startedAt)).limit(a).offset(o),e.select({count:k()}).from(n).where(c)]);return{items:l.map(fn),total:u[0]?.count??0}}async function _n(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function vn(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t,setWhere:Tt(n.status,[`completed`,`failed`,`skipped`,`cancelled`])})}async function U(e,t){let{worklogFrameEntries:n}=T(e,F);return(await e.select().from(n).where(j(n.frameId,t)).limit(1))[0]??null}async function yn(e,t){let n=await U(e,t);return n===null?null:tt.parse({executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??void 0,branchKey:n.branchKey??void 0,startedAt:n.startedAt??void 0,completedAt:n.completedAt??void 0,durationMs:n.durationMs??void 0,inputTokens:n.inputTokens??void 0,outputTokens:n.outputTokens??void 0,estimatedCost:n.estimatedCost??void 0,error:n.error??void 0})}async function bn(e,t){let{worklogArtifactWrites:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function xn(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function W(e,t){let{worklogGateEvents:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function Sn(e,t){let{worklogGateEvents:n}=T(e,F);return(await e.select().from(n).where(j(n.id,t)).limit(1))[0]??null}function G(e,t,n){return`${e}:${t}:${n}`}async function Cn(e,t,n){let[r]=await e.update(t).set({totalInputTokens:t.totalInputTokens}).where(j(t.executionId,n)).returning();return r}async function wn(e,t,n){let[r]=await e.select({totalInputTokens:P(t.inputTokens),totalOutputTokens:P(t.outputTokens),totalEstimatedCost:P(t.estimatedCost),measuredInputTokens:k(t.inputTokens),measuredOutputTokens:k(t.outputTokens),measuredCosts:k(t.estimatedCost)}).from(t).where(j(t.executionId,n));return{totalInputTokens:Number(r?.totalInputTokens??0),totalOutputTokens:Number(r?.totalOutputTokens??0),totalEstimatedCost:Number(r?.totalEstimatedCost??0),hasMeasurements:Number(r?.measuredInputTokens??0)>0||Number(r?.measuredOutputTokens??0)>0||Number(r?.measuredCosts??0)>0}}function Tn(e){return e.hasMeasurements}async function En(e,t,n,r){await e.update(t).set({totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost}).where(j(t.executionId,n))}async function Dn(e,t,n,r){let i=N`coalesce((select sum(${n.inputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,a=N`coalesce((select sum(${n.outputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,o=N`coalesce((select sum(${n.estimatedCost}) from ${n} where ${n.executionId} = ${r}), 0)`,s=N`exists(
1
+ import{$ as e,A as t,B as n,D as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as ee,R as te,U as ne,V as re,W as ie,X as ae,Y as oe,Z as se,_t as ce,a as le,at as ue,c as de,ct as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as m,l as we,lt as Te,m as Ee,mt as De,n as Oe,nt as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,r as Fe,rt as Ie,st as Le,tt as Re,u as ze,ut as Be,v as Ve,vt as h,z as g}from"./authority-state-bootstrap-7Cgb9TR2.mjs";import{a as He}from"./execution-attempt-repository-D0cCU7dI.mjs";import{assertWorkflowTriggerPayload as Ue,compileWorkflowTriggerBindingFilter as We}from"./workflow-engine/workflow-trigger-binding-consumer.mjs";import{SerialLane as Ge}from"@makaio/framework/utils";import{ArtifactSubjects as Ke,AutomationTriggerSubjects as qe,CRON_AUTOMATION_TRIGGER_KIND as Je,EXECUTION_LIST_DEFAULT_LIMIT as Ye,EXECUTION_LIST_MAX_LIMIT as _,EXECUTION_LIST_MIN_LIMIT as v,EXTERNAL_EXECUTION_ID_PREFIX as y,ExecutionAttemptSchemas as b,ExecutionAttemptSubjects as x,ExecutionsByArtifactRefsQuerySchema as Xe,JsonPatchOperationSchema as Ze,JsonValueSchema as Qe,SessionSubjects as $e,WORKFLOW_CANCELLED_REASON as et,WorkLogFrameEntrySchema as tt,WorkerSubjects as nt,WorkflowAutomationTriggerBindingSchema as rt,WorkflowError as S,WorkflowErrorCode as it,WorkflowNamespace as at,WorkflowRunContextSchema as ot,WorkflowRunResultSchema as st,WorkflowStepTypeSchema as ct,WorkflowSubjects as C,createWorkflowCancelSubject as lt,createWorkflowDelegateResultFinalizerNamespace as ut,createWorkflowFinalizerNamespace as dt,dep as ft,extensionToken as pt,serializeArtifactRef as mt,walkWorkflowDefinition as ht}from"@makaio/framework/contracts";import{BaseService as gt}from"@makaio/framework/service-base";import{defineDialectSchema as _t,executeTransaction as w,getDatabaseDialect as vt,registerDrizzleHandlers as yt,resolveSchema as T,serializeDatabaseOperation as E}from"@makaio/framework/storage/drizzle";import{and as D,asc as O,count as k,desc as A,eq as j,getTableColumns as bt,gte as xt,isNotNull as St,isNull as M,lt as Ct,lte as wt,notInArray as Tt,or as Et,sql as N,sum as P}from"drizzle-orm";import{SessionToken as Dt}from"@makaio/framework/services";import{AutomationTriggerBindingRuntimeToken as Ot}from"@makaio/framework/services/automation-trigger";const kt=ie.postgres,At=me.postgres,jt=c.postgres,Mt=ke.postgres,Nt=je.postgres,Pt=s.postgres,Ft=Se.postgres,It=De.postgres,Lt=Be.postgres,Rt=fe.postgres,zt=ge.postgres,Bt=ae.postgres,Vt=ee.postgres,Ht=ve.postgres,F=_t({workflowDefinitions:ne,workflowExecutions:e,workflowExecutionFrames:i,workflowGateInstances:Re,workflowStepSpans:ue,workflowExecutionLinks:Pe,workflowRunContexts:Ie,worklogSummaries:Ne,worklogFrameEntries:Te,worklogArtifactWrites:Le,worklogGateEvents:pe,workflowExecutionState:oe,workflowExecutionStateEvents:se,workflowFinalizations:be},{workflowDefinitions:kt,workflowExecutions:At,workflowExecutionFrames:jt,workflowGateInstances:Mt,workflowStepSpans:Nt,workflowExecutionLinks:Pt,workflowRunContexts:Ft,worklogSummaries:It,worklogFrameEntries:Lt,worklogArtifactWrites:Rt,worklogGateEvents:zt,workflowExecutionState:Bt,workflowExecutionStateEvents:Vt,workflowFinalizations:Ht});function I(e){return e.type===`global`?{scopeType:`global`,scopeKind:``,scopeId:``}:e.type===`external`?{scopeType:`external`,scopeKind:e.kind,scopeId:e.id}:{scopeType:e.type,scopeKind:``,scopeId:e.id}}function L(e){switch(e.scopeType){case`global`:return{type:`global`};case`external`:if(!e.scopeKind||!e.scopeId)throw Error(`Invalid external workflow scope row: scopeKind and scopeId are required`);return{type:`external`,kind:e.scopeKind,id:e.scopeId};case`workspace`:case`session`:if(!e.scopeId)throw Error(`Invalid ${e.scopeType} workflow scope row: scopeId is required`);return{type:e.scopeType,id:e.scopeId};default:{let t=e.scopeType;throw Error(`Unknown scope type: ${String(t)}`)}}}function Ut(e,t){let{scopeType:n,scopeKind:r,scopeId:i}=I(t);return[j(e.scopeType,n),j(e.scopeKind,r),j(e.scopeId,i)]}function R(e){return{id:e.id,name:e.name,description:e.description??void 0,root:e.root,inputSchema:e.inputSchema??void 0,configSchema:e.configSchema??void 0,outputSchema:e.outputSchema??void 0,state:e.state??void 0,artifact:e.artifact??void 0,triggers:e.triggers??void 0,scope:L(e),canvasLayout:e.canvasLayout??void 0,source:e.source??void 0,executableSource:e.executableSource??void 0,requirements:e.requirements??void 0,successFinalizerId:e.successFinalizerId??void 0}}function Wt(e,t){let n=I(e.scope);return{id:e.id,name:e.name??e.id,root:e.root,description:e.description??null,inputSchema:e.inputSchema??null,configSchema:e.configSchema??null,outputSchema:e.outputSchema??null,state:e.state??null,artifact:e.artifact??null,triggers:e.triggers??null,canvasLayout:e.canvasLayout??null,source:e.source??null,executableSource:e.executableSource??null,requirements:e.requirements??null,successFinalizerId:e.successFinalizerId??null,createdAt:t,updatedAt:t,...n}}function Gt(e,t){let{workflowDefinitions:n}=T(t,F),r=bt(n),i=e.on(a.get,async e=>{let r=await t.select().from(n).where(j(n.id,e.payload.id)).limit(1);e.setResult({workflow:r[0]?R(r[0]):null})}),o=e.on(a.set,async i=>{let a=i.payload.workflow,o=Date.now(),s=Wt(a,o),c=await E(t,async()=>{let e=await t.insert(n).values(s).onConflictDoNothing({target:n.id}).returning();if(e.length>0)return{kind:`created`,row:e[0]};let[i]=await t.update(n).set({name:s.name,root:s.root,updatedAt:o,createdAt:N`COALESCE(${r.createdAt}, ${o})`,description:s.description===null?N`${r.description}`:s.description,inputSchema:s.inputSchema===null?N`${r.inputSchema}`:s.inputSchema,configSchema:s.configSchema===null?N`${r.configSchema}`:s.configSchema,outputSchema:s.outputSchema===null?N`${r.outputSchema}`:s.outputSchema,state:s.state,artifact:s.artifact===null?N`${r.artifact}`:s.artifact,triggers:s.triggers===null?N`${r.triggers}`:s.triggers,canvasLayout:s.canvasLayout===null?N`${r.canvasLayout}`:s.canvasLayout,source:s.source===null?N`${r.source}`:s.source,executableSource:s.executableSource,requirements:s.requirements,successFinalizerId:s.successFinalizerId,...I(a.scope)}).where(j(n.id,a.id)).returning();return i?{kind:`updated`,row:i}:void 0});c&&await e.emit(c.kind===`created`?h.definition.created:h.definition.updated,R(c.row)),i.setResult({id:a.id})}),s=e.on(a.delete,async r=>{let i=(await E(t,()=>t.delete(n).where(j(n.id,r.payload.id)).returning())).length>0;i&&await e.emit(h.definition.deleted,{id:r.payload.id}),r.setResult({deleted:i})}),c=e.on(a.list,async e=>{let r=e.payload,i=r.scope?Ut(n,r.scope):[],a=i.length>0?await t.select().from(n).where(D(...i)):await t.select().from(n);e.setResult({workflows:a.map(R)})});return()=>{i(),o(),s(),c()}}function Kt(e){return{frameId:e.frameId,nodeId:e.nodeId,nodeType:e.nodeType,path:e.path,parentFrameId:e.parentFrameId??void 0,status:e.status,attempt:e.attempt,iteration:e.iteration??void 0,branchKey:e.branchKey??void 0,...e.outputPresent?{output:e.output}:{},error:e.error??void 0,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0}}function qt(e,t){return{frameId:t.frameId,executionId:e,nodeId:t.nodeId,nodeType:t.nodeType,path:t.path,parentFrameId:t.parentFrameId??null,status:t.status,attempt:t.attempt,iteration:t.iteration??null,branchKey:t.branchKey??null,output:t.output===void 0?null:t.output,outputPresent:t.output!==void 0,error:t.error??null,startedAt:t.startedAt??null,completedAt:t.completedAt??null}}function Jt(e,t){let{workflowExecutionFrames:n}=T(t,F),r=e.on(a.setFrame,async e=>{let{executionId:r,frame:i}=e.payload;if(!g(e,r))throw Error(`Unauthorized: caller is not permitted to write frames for execution: ${r}`);let a=qt(r,i);await E(t,()=>t.insert(n).values(a).onConflictDoUpdate({target:n.frameId,set:a})),e.setResult({frameId:i.frameId})}),i=e.on(a.getFrame,async e=>{let r=await t.select().from(n).where(j(n.frameId,e.payload.frameId)).limit(1);e.setResult({frame:r[0]?Kt(r[0]):null})}),o=e.on(a.listFrames,async e=>{if(!g(e,e.payload.executionId))throw Error(`Unauthorized: caller is not permitted to list frames for execution: ${e.payload.executionId}`);let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.frameId));e.setResult({frames:r.map(Kt)})});return()=>{r(),i(),o()}}function Yt(e){return`${e.executionId}:${e.nodeId}:${e.frameId}`}function z(e){return{executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??void 0,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs??null,...e.resumeDataPresent?{resumeData:e.resumeData}:{},...e.reason===null?{}:{reason:e.reason},createdAt:e.createdAt,resolvedAt:e.resolvedAt??void 0}}function B(e){return{id:Yt(e),executionId:e.executionId,nodeId:e.nodeId,frameId:e.frameId,schema:e.schema,prompt:e.prompt??null,status:e.status,autoAction:e.autoAction,timeoutMs:e.timeoutMs,resumeData:e.resumeData===void 0?null:e.resumeData,reason:e.reason??null,resumeDataPresent:e.resumeData!==void 0,createdAt:e.createdAt,resolvedAt:e.resolvedAt??null}}function Xt(e,t,n,r){if(e===void 0&&t===void 0)throw Error(`Either executionId or status is required to list gate instances.`);let i=n??Ye;if(!Number.isInteger(i)||i<v||i>_)throw Error(`Gate instance list limit must be an integer between ${v} and ${_}.`);return{resolvedLimit:i,predicates:[...e===void 0?[]:[j(r.executionId,e)],...t===void 0?[]:[j(r.status,t)]]}}function Zt(e,t){let{workflowExecutions:n,workflowGateInstances:r}=T(t,F),i=e.on(a.setGateInstance,async e=>{let n=e.payload.gate;if(!g(e,n.executionId))throw Error(`Unauthorized: caller is not permitted to write gates for execution: ${n.executionId}`);let i=B(n);await E(t,()=>t.insert(r).values(i).onConflictDoUpdate({target:r.id,set:i})),e.setResult({id:i.id})}),o=e.on(a.resolveWaitingGateInstance,async e=>{let n=e.payload.gate,i=B(n),a=await E(t,()=>t.update(r).set(i).where(D(j(r.id,i.id),j(r.status,`waiting`))).returning({id:r.id}));e.setResult({accepted:a.length===1})}),s=e.on(a.getGateInstance,async e=>{let{executionId:n,nodeId:i,frameId:a}=e.payload;if(!g(e,n))throw Error(`Unauthorized: caller is not permitted to read gates for execution: ${n}`);let o=[j(r.executionId,n),j(r.nodeId,i)];a!==void 0&&o.push(j(r.frameId,a));let s=await t.select().from(r).where(D(...o)).limit(1);e.setResult({gate:s[0]?z(s[0]):null})}),c=e.on(a.listGateInstances,async e=>{let{executionId:n,status:i,limit:a}=e.payload,{resolvedLimit:o,predicates:s}=Xt(n,i,a,r),c=await t.select().from(r).where(D(...s)).orderBy(A(r.createdAt),A(r.id)).limit(o);e.setResult({gates:c.map(z)})}),l=e.on(a.listPausedGateTimeouts,async e=>{let i=await t.select({gate:r}).from(r).innerJoin(n,j(r.executionId,n.id)).where(D(j(r.status,`waiting`),j(n.status,`paused`),St(r.timeoutMs)));e.setResult({gates:i.map(e=>z(e.gate))})});return()=>{i(),o(),s(),c(),l()}}function Qt(e){return{executionId:e.executionId,frameId:e.frameId,stepId:e.stepId,stepType:e.stepType,status:e.status,startedAt:e.startedAt??void 0,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,inputTokens:e.inputTokens??void 0,outputTokens:e.outputTokens??void 0,estimatedCost:e.estimatedCost??void 0,toolCallCount:e.toolCallCount??void 0,input:e.input??void 0,output:e.output??void 0}}function $t(e){return{sourceExecutionId:e.sourceExecutionId,targetExecutionId:e.targetExecutionId,linkType:e.linkType,metadata:e.metadata??void 0}}function en(e,t){let{workflowStepSpans:n,workflowExecutionLinks:r}=T(t,F),i=e.on(a.setSpan,async e=>{let{span:r}=e.payload;if(!g(e,r.executionId))throw Error(`Unauthorized: caller is not permitted to write spans for execution: ${r.executionId}`);await E(t,()=>t.insert(n).values(r).onConflictDoUpdate({target:[n.executionId,n.frameId],set:r})),e.setResult({id:`${r.executionId}:${r.frameId}`})}),o=e.on(a.listSpans,async e=>{let r=await t.select().from(n).where(j(n.executionId,e.payload.executionId)).orderBy(O(n.startedAt),O(n.stepId),O(n.frameId));e.setResult({spans:r.map(Qt)})}),s=e.on(a.setExecutionLink,async e=>{let{link:n}=e.payload;await E(t,()=>t.insert(r).values(n).onConflictDoUpdate({target:[r.sourceExecutionId,r.targetExecutionId],set:n})),e.setResult({id:`${n.sourceExecutionId}:${n.targetExecutionId}`})}),c=e.on(a.listExecutionLinks,async e=>{let{sourceExecutionId:n,targetExecutionId:i}=e.payload;if(n===void 0&&i===void 0)throw Error(`Either sourceExecutionId or targetExecutionId is required to list execution links.`);let a=[...n===void 0?[]:[j(r.sourceExecutionId,n)],...i===void 0?[]:[j(r.targetExecutionId,i)]],o=t.select().from(r).where(D(...a));e.setResult({links:(await o).map($t)})});return()=>{i(),o(),s(),c()}}function V(e,t){return t===null?vt(e)===`postgres`?N`'null'::jsonb`:N`'null'`:t}function tn(e){switch(e.kind){case`path`:return{sourceKind:`path`,sourcePath:e.path,sourceFilename:null,sourceCode:null};case`source`:return{sourceKind:`source`,sourcePath:null,sourceFilename:e.filename,sourceCode:e.source};case`definition`:return{sourceKind:`definition`,sourcePath:null,sourceFilename:null,sourceCode:null}}}function nn(e){switch(e.sourceKind){case`path`:if(!e.sourcePath)throw Error(`Invalid run context row: sourcePath required for kind=path`);return{kind:`path`,path:e.sourcePath};case`source`:if(!e.sourceFilename)throw Error(`Invalid run context row: sourceFilename required for kind=source`);return{kind:`source`,filename:e.sourceFilename,source:e.sourceCode??``};case`definition`:return{kind:`definition`,workflowId:e.workflowId};default:throw Error(`Unknown run context source kind: ${String(e.sourceKind)}`)}}function rn(e){return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,source:nn(e),definitionSnapshot:e.definitionSnapshot??void 0,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode,...e.artifactRef===null?{}:{artifactRef:e.artifactRef},scope:L(e),...e.dispatchMetadata===null?{}:{dispatchMetadata:e.dispatchMetadata},cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy??`wait-in-process`,...e.terminalAuthority===null?{}:{terminalAuthority:e.terminalAuthority},...e.materializationSpec===null?{}:{materializationSpec:e.materializationSpec}}}function an(e){let t=tn(e.source),n=I(e.scope);return{executionId:e.executionId,workflowId:e.workflowId,coordinatorSessionId:e.coordinatorSessionId,...t,definitionSnapshot:e.definitionSnapshot??null,workerManifest:e.workerManifest,inputs:e.inputs,config:e.config??{},triggerPayload:e.triggerPayload,triggerMode:e.triggerMode??`immediate`,artifactRef:e.artifactRef??null,dispatchMetadata:e.dispatchMetadata??null,...n,cancelSubject:e.cancelSubject,env:e.env,createdAt:e.createdAt,suspensionStrategy:e.suspensionStrategy,terminalAuthority:e.terminalAuthority??null,materializationSpec:e.materializationSpec??null}}async function on(e,t,n){let r=an(t);await e.insert(n).values(r).onConflictDoUpdate({target:n.executionId,set:r})}function sn(e,t){let{workflowRunContexts:n,workflowExecutionState:r,workflowExecutionStateEvents:i}=T(t,F),o=e.on(a.setRunContext,async e=>{let a=e.payload.runContext,o=e.payload.initialState;await w(t,async e=>{if(await on(e,a,n),o===void 0)return;let s=Date.now(),c=V(t,o);await e.insert(r).values({executionId:a.executionId,sequence:0,value:c,updatedAt:s}).onConflictDoNothing(),await e.insert(i).values({executionId:a.executionId,sequence:0,patch:[],value:c,createdAt:s}).onConflictDoNothing()}),e.setResult({executionId:a.executionId})}),s=e.on(a.getRunContext,async e=>{let{executionId:r}=e.payload,i=await t.select().from(n).where(j(n.executionId,r)),a=i[0]?rn(i[0]):null;e.setResult({runContext:a})});return()=>{o(),s()}}async function cn(e,t,n){let{workflowExecutionState:r,workflowExecutionStateEvents:i}=T(e,F),a=Date.now(),o=V(e,n);await w(e,async e=>{await e.insert(r).values({executionId:t,sequence:0,value:o,updatedAt:a}).onConflictDoNothing(),await e.insert(i).values({executionId:t,sequence:0,patch:[],value:o,createdAt:a}).onConflictDoNothing()})}async function ln(e,t){let{workflowExecutionState:n}=T(e,F),r=(await e.select().from(n).where(j(n.executionId,t)).limit(1))[0];return r?{executionId:r.executionId,sequence:r.sequence,value:r.value}:null}async function un(e,t){let{workflowExecutionState:n,workflowExecutionStateEvents:r}=T(e,F),i=Date.now(),a=V(e,t.nextValue);return w(e,async e=>{let o=(await e.select().from(n).where(j(n.executionId,t.executionId)).limit(1))[0];if(!o)throw Error(`no workflow state for execution ${t.executionId}`);if(t.expectedSequence===void 0)throw Error(`expectedSequence is required to patch workflow state`);let s=o.sequence+1,c=te(o.value,t.nextValue);if((await e.update(n).set({sequence:s,value:a,updatedAt:i}).where(D(j(n.executionId,t.executionId),j(n.sequence,t.expectedSequence))).returning()).length===0)throw Error(`state sequence conflict: expected ${String(t.expectedSequence)}, got ${String(o.sequence)}`);return await e.insert(r).values({executionId:t.executionId,sequence:s,patch:c,value:a,createdAt:i}),{executionId:t.executionId,sequence:s,patch:c,value:t.nextValue}})}function dn(e,t){let n=e.on(a.initializeState,async e=>{let{executionId:n,initialValue:r}=e.payload;await cn(t,n,r),e.setResult({})}),r=e.on(a.getState,async e=>{let{executionId:n}=e.payload,r=await ln(t,n);e.setResult({state:r})}),i=e.on(a.patchState,async e=>{let{executionId:n,expectedSequence:r,nextValue:i}=e.payload,a=await un(t,{executionId:n,expectedSequence:r,nextValue:i});e.setResult(a)});return()=>{n(),r(),i()}}function fn(e){return{executionId:e.executionId,workflowId:e.workflowId,workflowName:e.workflowName??void 0,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt??void 0,durationMs:e.durationMs??void 0,totalInputTokens:e.totalInputTokens??void 0,totalOutputTokens:e.totalOutputTokens??void 0,totalEstimatedCost:e.totalEstimatedCost??void 0,error:e.error??void 0,failedNodeId:e.failedNodeId??void 0}}async function pn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function mn(e,t){let{worklogSummaries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.executionId,set:hn(t),setWhere:Tt(n.status,[`completed`,`failed`,`cancelled`])})}function hn(e){return{workflowId:e.workflowId,workflowName:e.workflowName,status:e.status,startedAt:e.startedAt,completedAt:e.completedAt,durationMs:e.durationMs,error:e.error,failedNodeId:e.failedNodeId}}async function H(e,t){let{worklogSummaries:n}=T(e,F),r=await e.select().from(n).where(j(n.executionId,t)).limit(1);return r[0]?fn(r[0]):null}async function gn(e,t={}){let{worklogSummaries:n}=T(e,F),{workflowId:r,status:i,limit:a=50,offset:o=0}=t,s=[...r===void 0?[]:[j(n.workflowId,r)],...i===void 0?[]:[j(n.status,i)]],c=s.length>0?D(...s):void 0,[l,u]=await Promise.all([e.select().from(n).where(c).orderBy(A(n.startedAt)).limit(a).offset(o),e.select({count:k()}).from(n).where(c)]);return{items:l.map(fn),total:u[0]?.count??0}}async function _n(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoNothing()}async function vn(e,t){let{worklogFrameEntries:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.frameId,set:t,setWhere:Tt(n.status,[`completed`,`failed`,`skipped`,`cancelled`])})}async function U(e,t){let{worklogFrameEntries:n}=T(e,F);return(await e.select().from(n).where(j(n.frameId,t)).limit(1))[0]??null}async function yn(e,t){let n=await U(e,t);return n===null?null:tt.parse({executionId:n.executionId,frameId:n.frameId,nodeId:n.nodeId,nodeType:n.nodeType,path:n.path,status:n.status,attempt:n.attempt,iteration:n.iteration??void 0,branchKey:n.branchKey??void 0,startedAt:n.startedAt??void 0,completedAt:n.completedAt??void 0,durationMs:n.durationMs??void 0,inputTokens:n.inputTokens??void 0,outputTokens:n.outputTokens??void 0,estimatedCost:n.estimatedCost??void 0,error:n.error??void 0})}async function bn(e,t){let{worklogArtifactWrites:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}function xn(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${i}`}async function W(e,t){let{worklogGateEvents:n}=T(e,F);await e.insert(n).values(t).onConflictDoUpdate({target:n.id,set:t})}async function Sn(e,t){let{worklogGateEvents:n}=T(e,F);return(await e.select().from(n).where(j(n.id,t)).limit(1))[0]??null}function G(e,t,n){return`${e}:${t}:${n}`}async function Cn(e,t,n){let[r]=await e.update(t).set({totalInputTokens:t.totalInputTokens}).where(j(t.executionId,n)).returning();return r}async function wn(e,t,n){let[r]=await e.select({totalInputTokens:P(t.inputTokens),totalOutputTokens:P(t.outputTokens),totalEstimatedCost:P(t.estimatedCost),measuredInputTokens:k(t.inputTokens),measuredOutputTokens:k(t.outputTokens),measuredCosts:k(t.estimatedCost)}).from(t).where(j(t.executionId,n));return{totalInputTokens:Number(r?.totalInputTokens??0),totalOutputTokens:Number(r?.totalOutputTokens??0),totalEstimatedCost:Number(r?.totalEstimatedCost??0),hasMeasurements:Number(r?.measuredInputTokens??0)>0||Number(r?.measuredOutputTokens??0)>0||Number(r?.measuredCosts??0)>0}}function Tn(e){return e.hasMeasurements}async function En(e,t,n,r){await e.update(t).set({totalInputTokens:r.totalInputTokens,totalOutputTokens:r.totalOutputTokens,totalEstimatedCost:r.totalEstimatedCost}).where(j(t.executionId,n))}async function Dn(e,t,n,r){let i=N`coalesce((select sum(${n.inputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,a=N`coalesce((select sum(${n.outputTokens}) from ${n} where ${n.executionId} = ${r}), 0)`,o=N`coalesce((select sum(${n.estimatedCost}) from ${n} where ${n.executionId} = ${r}), 0)`,s=N`exists(
2
2
  select 1 from ${n}
3
3
  where ${n.executionId} = ${r}
4
4
  and (${n.inputTokens} is not null
@@ -1,5 +1,5 @@
1
1
  import { l as ProviderOperationOwnershipRecord, o as ProviderOperationClaimDecision, s as ProviderOperationMutationDecision } from "./provider-operation-B2wQST6N.mjs";
2
- import { $ as RuntimeReadinessDecision, A as MarkRuntimeReadyInput, B as ReadBootstrapStartStateInput, C as ExecutionAttemptRepository, D as GetInstructionInput, E as ExecutionOwnerId, F as PendingAttemptAbandonmentDecision, G as RecordProvisionerIncarnationLostInput, H as RecordAllocationTerminatedInput, J as RegisterRuntimeInput, K as RecordProvisioningAbsentInput, L as ProvisionerIncarnationLossDecision, M as OperationCompletionDecision, N as OperationReportDecision, O as HandoffProviderOperationInput, P as OutcomeCodec, R as ProvisioningAbsenceDecision, U as RecordInfrastructureFailureInput, V as RecordAllocationInput, W as RecordProviderOperationUncertaintyInput, X as ReportOperationInput, Y as RenewProviderOperationClaimInput, Z as RuntimeOutcomeFence, a as AllocationRefEvolutionDecision, b as ExecutionAttemptOutcomeDecision, et as RuntimeRegistrationDecision, f as CompleteOperationInput, h as DurableOutcome, i as AllocationRefEvolution, j as OperationAdmissionDecision, k as InfrastructureFailureDecision, n as AdmitOperationInput, o as AllocationTerminationDecision, p as DiscoveredAllocationDecision, q as RecoverableAttemptRecord, r as AllocationRecordingDecision, s as AttemptControlState, tt as TakeOverProviderOperationInput, u as BeginProvisioningInput, x as ExecutionAttemptRecord, z as ProvisioningClaimDecision } from "./execution-attempt-repository-OryBjQQI.mjs";
2
+ import { $ as RuntimeReadinessDecision, A as MarkRuntimeReadyInput, B as ReadBootstrapStartStateInput, C as ExecutionAttemptRepository, D as GetInstructionInput, E as ExecutionOwnerId, F as PendingAttemptAbandonmentDecision, G as RecordProvisionerIncarnationLostInput, H as RecordAllocationTerminatedInput, J as RegisterRuntimeInput, K as RecordProvisioningAbsentInput, L as ProvisionerIncarnationLossDecision, M as OperationCompletionDecision, N as OperationReportDecision, O as HandoffProviderOperationInput, P as OutcomeCodec, R as ProvisioningAbsenceDecision, U as RecordInfrastructureFailureInput, V as RecordAllocationInput, W as RecordProviderOperationUncertaintyInput, X as ReportOperationInput, Y as RenewProviderOperationClaimInput, Z as RuntimeOutcomeFence, a as AllocationRefEvolutionDecision, b as ExecutionAttemptOutcomeDecision, et as RuntimeRegistrationDecision, f as CompleteOperationInput, h as DurableOutcome, i as AllocationRefEvolution, j as OperationAdmissionDecision, k as InfrastructureFailureDecision, n as AdmitOperationInput, o as AllocationTerminationDecision, p as DiscoveredAllocationDecision, q as RecoverableAttemptRecord, r as AllocationRecordingDecision, s as AttemptControlState, tt as TakeOverProviderOperationInput, u as BeginProvisioningInput, x as ExecutionAttemptRecord, z as ProvisioningClaimDecision } from "./execution-attempt-repository-CgB7uiYD.mjs";
3
3
  import { z } from "zod";
4
4
  import { IMakaioBus } from "@makaio/framework/bus";
5
5
  import * as _$_makaio_contracts0 from "@makaio/framework/contracts";
@@ -735,7 +735,11 @@ declare const WorkflowAttemptOutcomeSchema: z.ZodUnion<readonly [z.ZodDiscrimina
735
735
  id: z.ZodString;
736
736
  revision: z.ZodOptional<z.ZodString>;
737
737
  locator: z.ZodOptional<z.ZodString>;
738
- }, z.core.$strip>], "refClass">>;
738
+ }, z.core.$strip>, z.ZodObject<{
739
+ refClass: z.ZodLiteral<"entity">;
740
+ entityType: z.ZodString;
741
+ id: z.ZodString;
742
+ }, z.core.$strict>], "refClass">>;
739
743
  }, z.core.$strip>>;
740
744
  confidence: z.ZodOptional<z.ZodObject<{
741
745
  level: z.ZodEnum<{
@@ -774,7 +778,11 @@ declare const WorkflowAttemptOutcomeSchema: z.ZodUnion<readonly [z.ZodDiscrimina
774
778
  id: z.ZodString;
775
779
  revision: z.ZodOptional<z.ZodString>;
776
780
  locator: z.ZodOptional<z.ZodString>;
777
- }, z.core.$strip>], "refClass">>>;
781
+ }, z.core.$strip>, z.ZodObject<{
782
+ refClass: z.ZodLiteral<"entity">;
783
+ entityType: z.ZodString;
784
+ id: z.ZodString;
785
+ }, z.core.$strict>], "refClass">>>;
778
786
  }, z.core.$strip>>;
779
787
  }, z.core.$strip>>;
780
788
  representations: z.ZodOptional<z.ZodObject<{
@@ -809,9 +817,9 @@ declare const WorkflowAttemptOutcomeSchema: z.ZodUnion<readonly [z.ZodDiscrimina
809
817
  }, z.core.$strict>], "status">, z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
810
818
  kind: z.ZodLiteral<"technical-failure">;
811
819
  stage: z.ZodEnum<{
812
- startup: "startup";
813
820
  "workspace-preparation": "workspace-preparation";
814
821
  "workload-invocation": "workload-invocation";
822
+ startup: "startup";
815
823
  }>;
816
824
  message: z.ZodString;
817
825
  }, z.core.$strict>, z.ZodObject<{
@@ -822,14 +830,14 @@ declare const WorkflowAttemptOutcomeSchema: z.ZodUnion<readonly [z.ZodDiscrimina
822
830
  reason: z.ZodOptional<z.ZodString>;
823
831
  }, z.core.$strict>], "kind">, z.ZodTransform<{
824
832
  kind: "technical-failure";
825
- stage: "startup" | "workspace-preparation" | "workload-invocation";
833
+ stage: "workspace-preparation" | "workload-invocation" | "startup";
826
834
  message: string;
827
835
  } | {
828
836
  kind: "cancelled";
829
837
  reason?: string | undefined;
830
838
  }, {
831
839
  kind: "technical-failure";
832
- stage: "startup" | "workspace-preparation" | "workload-invocation";
840
+ stage: "workspace-preparation" | "workload-invocation" | "startup";
833
841
  message: string;
834
842
  } | {
835
843
  kind: "workload-result";
package/dist/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@makaio/framework",
3
- "version": "1.0.0-dev-1788811230746",
3
+ "version": "1.0.0-dev-1788832451167",
4
4
  "type": "module"
5
5
  }