@exaudeus/workrail 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/config/feature-flags.js +1 -1
  2. package/dist/di/container.js +72 -0
  3. package/dist/di/tokens.d.ts +13 -0
  4. package/dist/di/tokens.js +13 -0
  5. package/dist/manifest.json +236 -100
  6. package/dist/mcp/error-mapper.d.ts +3 -8
  7. package/dist/mcp/error-mapper.js +41 -19
  8. package/dist/mcp/handlers/session.js +25 -11
  9. package/dist/mcp/handlers/v2-execution-helpers.d.ts +99 -0
  10. package/dist/mcp/handlers/v2-execution-helpers.js +249 -0
  11. package/dist/mcp/handlers/v2-execution.d.ts +4 -0
  12. package/dist/mcp/handlers/v2-execution.js +1061 -0
  13. package/dist/mcp/handlers/v2-workflow.js +7 -7
  14. package/dist/mcp/handlers/workflow.js +21 -12
  15. package/dist/mcp/index.d.ts +1 -1
  16. package/dist/mcp/index.js +4 -1
  17. package/dist/mcp/output-schemas.d.ts +411 -4
  18. package/dist/mcp/output-schemas.js +57 -1
  19. package/dist/mcp/server.d.ts +1 -1
  20. package/dist/mcp/server.js +57 -31
  21. package/dist/mcp/tool-descriptions.js +17 -0
  22. package/dist/mcp/tools.js +12 -0
  23. package/dist/mcp/types/tool-description-types.d.ts +1 -1
  24. package/dist/mcp/types/tool-description-types.js +2 -0
  25. package/dist/mcp/types.d.ts +38 -3
  26. package/dist/mcp/types.js +32 -3
  27. package/dist/mcp/v2/tool-registry.js +16 -1
  28. package/dist/mcp/v2/tools.d.ts +45 -0
  29. package/dist/mcp/v2/tools.js +21 -1
  30. package/dist/mcp/validation/workflow-next-prevalidate.d.ts +2 -3
  31. package/dist/mcp/validation/workflow-next-prevalidate.js +38 -27
  32. package/dist/runtime/brand.d.ts +1 -3
  33. package/dist/v2/durable-core/canonical/hashing.d.ts +3 -1
  34. package/dist/v2/durable-core/canonical/hashing.js +9 -0
  35. package/dist/v2/durable-core/ids/index.d.ts +6 -0
  36. package/dist/v2/durable-core/ids/index.js +12 -0
  37. package/dist/v2/durable-core/projections/snapshot-state.d.ts +3 -0
  38. package/dist/v2/durable-core/projections/snapshot-state.js +14 -0
  39. package/dist/v2/durable-core/schemas/compiled-workflow/index.d.ts +100 -6
  40. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +18 -3
  41. package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.d.ts +1042 -0
  42. package/dist/v2/durable-core/schemas/execution-snapshot/execution-snapshot.v1.js +119 -0
  43. package/dist/v2/durable-core/schemas/execution-snapshot/index.d.ts +4 -0
  44. package/dist/v2/durable-core/schemas/execution-snapshot/index.js +17 -0
  45. package/dist/v2/durable-core/schemas/execution-snapshot/step-instance-key.d.ts +21 -0
  46. package/dist/v2/durable-core/schemas/execution-snapshot/step-instance-key.js +67 -0
  47. package/dist/v2/durable-core/schemas/session/events.d.ts +80 -50
  48. package/dist/v2/durable-core/schemas/session/events.js +27 -9
  49. package/dist/v2/durable-core/schemas/session/manifest.d.ts +2 -2
  50. package/dist/v2/durable-core/tokens/base64url.d.ts +7 -0
  51. package/dist/v2/durable-core/tokens/base64url.js +16 -0
  52. package/dist/v2/durable-core/tokens/index.d.ts +9 -0
  53. package/dist/v2/durable-core/tokens/index.js +23 -0
  54. package/dist/v2/durable-core/tokens/payloads.d.ts +210 -0
  55. package/dist/v2/durable-core/tokens/payloads.js +53 -0
  56. package/dist/v2/durable-core/tokens/token-codec.d.ts +31 -0
  57. package/dist/v2/durable-core/tokens/token-codec.js +64 -0
  58. package/dist/v2/durable-core/tokens/token-signer.d.ts +15 -0
  59. package/dist/v2/durable-core/tokens/token-signer.js +55 -0
  60. package/dist/v2/infra/local/data-dir/index.d.ts +4 -0
  61. package/dist/v2/infra/local/data-dir/index.js +12 -0
  62. package/dist/v2/infra/local/hmac-sha256/index.d.ts +5 -0
  63. package/dist/v2/infra/local/hmac-sha256/index.js +16 -0
  64. package/dist/v2/infra/local/keyring/index.d.ts +14 -0
  65. package/dist/v2/infra/local/keyring/index.js +103 -0
  66. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +3 -3
  67. package/dist/v2/infra/local/pinned-workflow-store/index.js +1 -1
  68. package/dist/v2/infra/local/session-lock/index.js +1 -1
  69. package/dist/v2/infra/local/session-store/index.d.ts +0 -1
  70. package/dist/v2/infra/local/session-store/index.js +348 -280
  71. package/dist/v2/infra/local/snapshot-store/index.d.ts +15 -0
  72. package/dist/v2/infra/local/snapshot-store/index.js +76 -0
  73. package/dist/v2/ports/data-dir.port.d.ts +4 -0
  74. package/dist/v2/ports/hmac-sha256.port.d.ts +4 -0
  75. package/dist/v2/ports/hmac-sha256.port.js +2 -0
  76. package/dist/v2/ports/keyring.port.d.ts +26 -0
  77. package/dist/v2/ports/keyring.port.js +2 -0
  78. package/dist/v2/ports/pinned-workflow-store.port.d.ts +3 -3
  79. package/dist/v2/ports/session-event-log-store.port.d.ts +1 -1
  80. package/dist/v2/ports/session-lock.port.d.ts +1 -1
  81. package/dist/v2/ports/snapshot-store.port.d.ts +17 -0
  82. package/dist/v2/ports/snapshot-store.port.js +2 -0
  83. package/dist/v2/read-only/v1-to-v2-shim.d.ts +6 -1
  84. package/dist/v2/read-only/v1-to-v2-shim.js +16 -4
  85. package/dist/v2/usecases/execution-session-gate.d.ts +3 -2
  86. package/dist/v2/usecases/execution-session-gate.js +98 -101
  87. package/package.json +2 -1
  88. package/workflows/coding-task-workflow-agentic.json +326 -69
  89. package/workflows/design-thinking-workflow-autonomous.agentic.json +1 -1
  90. package/workflows/design-thinking-workflow.json +1 -1
@@ -21,8 +21,8 @@ export declare const DomainEventEnvelopeV1Schema: z.ZodObject<{
21
21
  kind: string;
22
22
  sessionId: string;
23
23
  v: 1;
24
- eventId: string;
25
24
  eventIndex: number;
25
+ eventId: string;
26
26
  dedupeKey: string;
27
27
  data?: unknown;
28
28
  scope?: {
@@ -33,8 +33,8 @@ export declare const DomainEventEnvelopeV1Schema: z.ZodObject<{
33
33
  kind: string;
34
34
  sessionId: string;
35
35
  v: 1;
36
- eventId: string;
37
36
  eventIndex: number;
37
+ eventId: string;
38
38
  dedupeKey: string;
39
39
  data?: unknown;
40
40
  scope?: {
@@ -66,8 +66,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
66
66
  sessionId: string;
67
67
  data: {};
68
68
  v: 1;
69
- eventId: string;
70
69
  eventIndex: number;
70
+ eventId: string;
71
71
  dedupeKey: string;
72
72
  scope?: {
73
73
  runId?: string | undefined;
@@ -78,8 +78,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
78
78
  sessionId: string;
79
79
  data: {};
80
80
  v: 1;
81
- eventId: string;
82
81
  eventIndex: number;
82
+ eventId: string;
83
83
  dedupeKey: string;
84
84
  scope?: {
85
85
  runId?: string | undefined;
@@ -170,8 +170,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
170
170
  confidence: "high" | "low" | "med";
171
171
  };
172
172
  v: 1;
173
- eventId: string;
174
173
  eventIndex: number;
174
+ eventId: string;
175
175
  dedupeKey: string;
176
176
  scope?: undefined;
177
177
  }, {
@@ -192,8 +192,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
192
192
  confidence: "high" | "low" | "med";
193
193
  };
194
194
  v: 1;
195
- eventId: string;
196
195
  eventIndex: number;
196
+ eventId: string;
197
197
  dedupeKey: string;
198
198
  scope?: undefined;
199
199
  }>, z.ZodObject<{
@@ -213,12 +213,12 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
213
213
  }>;
214
214
  data: z.ZodObject<{
215
215
  workflowId: z.ZodString;
216
- workflowHash: z.ZodString;
216
+ workflowHash: z.ZodEffects<z.ZodString, never, string>;
217
217
  workflowSourceKind: z.ZodEnum<["bundled", "user", "project", "remote", "plugin"]>;
218
218
  workflowSourceRef: z.ZodString;
219
219
  }, "strip", z.ZodTypeAny, {
220
220
  workflowId: string;
221
- workflowHash: string;
221
+ workflowHash: never;
222
222
  workflowSourceKind: "bundled" | "user" | "project" | "remote" | "plugin";
223
223
  workflowSourceRef: string;
224
224
  }, {
@@ -232,13 +232,13 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
232
232
  sessionId: string;
233
233
  data: {
234
234
  workflowId: string;
235
- workflowHash: string;
235
+ workflowHash: never;
236
236
  workflowSourceKind: "bundled" | "user" | "project" | "remote" | "plugin";
237
237
  workflowSourceRef: string;
238
238
  };
239
239
  v: 1;
240
- eventId: string;
241
240
  eventIndex: number;
241
+ eventId: string;
242
242
  dedupeKey: string;
243
243
  scope: {
244
244
  runId: string;
@@ -253,8 +253,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
253
253
  workflowSourceRef: string;
254
254
  };
255
255
  v: 1;
256
- eventId: string;
257
256
  eventIndex: number;
257
+ eventId: string;
258
258
  dedupeKey: string;
259
259
  scope: {
260
260
  runId: string;
@@ -280,31 +280,31 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
280
280
  data: z.ZodObject<{
281
281
  nodeKind: z.ZodEnum<["step", "checkpoint"]>;
282
282
  parentNodeId: z.ZodNullable<z.ZodString>;
283
- workflowHash: z.ZodString;
283
+ workflowHash: z.ZodEffects<z.ZodString, never, string>;
284
284
  snapshotRef: z.ZodEffects<z.ZodString, never, string>;
285
285
  }, "strip", z.ZodTypeAny, {
286
- workflowHash: string;
286
+ snapshotRef: never;
287
+ workflowHash: never;
287
288
  nodeKind: "step" | "checkpoint";
288
289
  parentNodeId: string | null;
289
- snapshotRef: never;
290
290
  }, {
291
+ snapshotRef: string;
291
292
  workflowHash: string;
292
293
  nodeKind: "step" | "checkpoint";
293
294
  parentNodeId: string | null;
294
- snapshotRef: string;
295
295
  }>;
296
296
  }, "strip", z.ZodTypeAny, {
297
297
  kind: "node_created";
298
298
  sessionId: string;
299
299
  data: {
300
- workflowHash: string;
300
+ snapshotRef: never;
301
+ workflowHash: never;
301
302
  nodeKind: "step" | "checkpoint";
302
303
  parentNodeId: string | null;
303
- snapshotRef: never;
304
304
  };
305
305
  v: 1;
306
- eventId: string;
307
306
  eventIndex: number;
307
+ eventId: string;
308
308
  dedupeKey: string;
309
309
  scope: {
310
310
  runId: string;
@@ -314,14 +314,14 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
314
314
  kind: "node_created";
315
315
  sessionId: string;
316
316
  data: {
317
+ snapshotRef: string;
317
318
  workflowHash: string;
318
319
  nodeKind: "step" | "checkpoint";
319
320
  parentNodeId: string | null;
320
- snapshotRef: string;
321
321
  };
322
322
  v: 1;
323
- eventId: string;
324
323
  eventIndex: number;
324
+ eventId: string;
325
325
  dedupeKey: string;
326
326
  scope: {
327
327
  runId: string;
@@ -402,8 +402,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
402
402
  toNodeId: string;
403
403
  };
404
404
  v: 1;
405
- eventId: string;
406
405
  eventIndex: number;
406
+ eventId: string;
407
407
  dedupeKey: string;
408
408
  scope: {
409
409
  runId: string;
@@ -421,8 +421,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
421
421
  toNodeId: string;
422
422
  };
423
423
  v: 1;
424
- eventId: string;
425
424
  eventIndex: number;
425
+ eventId: string;
426
426
  dedupeKey: string;
427
427
  scope: {
428
428
  runId: string;
@@ -462,6 +462,12 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
462
462
  }, {
463
463
  key: string;
464
464
  kind: "context_key";
465
+ }>, z.ZodObject<{
466
+ kind: z.ZodLiteral<"context_budget">;
467
+ }, "strip", z.ZodTypeAny, {
468
+ kind: "context_budget";
469
+ }, {
470
+ kind: "context_budget";
465
471
  }>, z.ZodObject<{
466
472
  kind: z.ZodLiteral<"output_contract">;
467
473
  contractRef: z.ZodString;
@@ -498,6 +504,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
498
504
  pointer: {
499
505
  key: string;
500
506
  kind: "context_key";
507
+ } | {
508
+ kind: "context_budget";
501
509
  } | {
502
510
  kind: "output_contract";
503
511
  contractRef: string;
@@ -515,6 +523,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
515
523
  pointer: {
516
524
  key: string;
517
525
  kind: "context_key";
526
+ } | {
527
+ kind: "context_budget";
518
528
  } | {
519
529
  kind: "output_contract";
520
530
  contractRef: string;
@@ -534,6 +544,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
534
544
  pointer: {
535
545
  key: string;
536
546
  kind: "context_key";
547
+ } | {
548
+ kind: "context_budget";
537
549
  } | {
538
550
  kind: "output_contract";
539
551
  contractRef: string;
@@ -553,6 +565,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
553
565
  pointer: {
554
566
  key: string;
555
567
  kind: "context_key";
568
+ } | {
569
+ kind: "context_budget";
556
570
  } | {
557
571
  kind: "output_contract";
558
572
  contractRef: string;
@@ -572,6 +586,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
572
586
  pointer: {
573
587
  key: string;
574
588
  kind: "context_key";
589
+ } | {
590
+ kind: "context_budget";
575
591
  } | {
576
592
  kind: "output_contract";
577
593
  contractRef: string;
@@ -591,6 +607,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
591
607
  pointer: {
592
608
  key: string;
593
609
  kind: "context_key";
610
+ } | {
611
+ kind: "context_budget";
594
612
  } | {
595
613
  kind: "output_contract";
596
614
  contractRef: string;
@@ -613,6 +631,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
613
631
  pointer: {
614
632
  key: string;
615
633
  kind: "context_key";
634
+ } | {
635
+ kind: "context_budget";
616
636
  } | {
617
637
  kind: "output_contract";
618
638
  contractRef: string;
@@ -635,6 +655,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
635
655
  pointer: {
636
656
  key: string;
637
657
  kind: "context_key";
658
+ } | {
659
+ kind: "context_budget";
638
660
  } | {
639
661
  kind: "output_contract";
640
662
  contractRef: string;
@@ -670,6 +692,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
670
692
  pointer: {
671
693
  key: string;
672
694
  kind: "context_key";
695
+ } | {
696
+ kind: "context_budget";
673
697
  } | {
674
698
  kind: "output_contract";
675
699
  contractRef: string;
@@ -699,6 +723,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
699
723
  pointer: {
700
724
  key: string;
701
725
  kind: "context_key";
726
+ } | {
727
+ kind: "context_budget";
702
728
  } | {
703
729
  kind: "output_contract";
704
730
  contractRef: string;
@@ -732,6 +758,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
732
758
  pointer: {
733
759
  key: string;
734
760
  kind: "context_key";
761
+ } | {
762
+ kind: "context_budget";
735
763
  } | {
736
764
  kind: "output_contract";
737
765
  contractRef: string;
@@ -751,8 +779,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
751
779
  };
752
780
  };
753
781
  v: 1;
754
- eventId: string;
755
782
  eventIndex: number;
783
+ eventId: string;
756
784
  dedupeKey: string;
757
785
  scope: {
758
786
  runId: string;
@@ -773,6 +801,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
773
801
  pointer: {
774
802
  key: string;
775
803
  kind: "context_key";
804
+ } | {
805
+ kind: "context_budget";
776
806
  } | {
777
807
  kind: "output_contract";
778
808
  contractRef: string;
@@ -792,8 +822,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
792
822
  };
793
823
  };
794
824
  v: 1;
795
- eventId: string;
796
825
  eventIndex: number;
826
+ eventId: string;
797
827
  dedupeKey: string;
798
828
  scope: {
799
829
  runId: string;
@@ -917,8 +947,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
917
947
  supersedesOutputId?: string | undefined;
918
948
  };
919
949
  v: 1;
920
- eventId: string;
921
950
  eventIndex: number;
951
+ eventId: string;
922
952
  dedupeKey: string;
923
953
  scope: {
924
954
  runId: string;
@@ -942,8 +972,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
942
972
  supersedesOutputId?: string | undefined;
943
973
  };
944
974
  v: 1;
945
- eventId: string;
946
975
  eventIndex: number;
976
+ eventId: string;
947
977
  dedupeKey: string;
948
978
  scope: {
949
979
  runId: string;
@@ -1075,8 +1105,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1075
1105
  };
1076
1106
  };
1077
1107
  v: 1;
1078
- eventId: string;
1079
1108
  eventIndex: number;
1109
+ eventId: string;
1080
1110
  dedupeKey: string;
1081
1111
  scope: {
1082
1112
  runId: string;
@@ -1101,8 +1131,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1101
1131
  };
1102
1132
  };
1103
1133
  v: 1;
1104
- eventId: string;
1105
1134
  eventIndex: number;
1135
+ eventId: string;
1106
1136
  dedupeKey: string;
1107
1137
  scope: {
1108
1138
  runId: string;
@@ -1138,28 +1168,28 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1138
1168
  probeStepId: z.ZodString;
1139
1169
  result: z.ZodEnum<["success", "failure"]>;
1140
1170
  }, "strip", z.ZodTypeAny, {
1141
- result: "success" | "failure";
1142
1171
  probeTemplateId: string;
1143
1172
  probeStepId: string;
1144
- }, {
1145
1173
  result: "success" | "failure";
1174
+ }, {
1146
1175
  probeTemplateId: string;
1147
1176
  probeStepId: string;
1177
+ result: "success" | "failure";
1148
1178
  }>;
1149
1179
  }, "strip", z.ZodTypeAny, {
1150
1180
  kind: "probe_step";
1151
1181
  detail: {
1152
- result: "success" | "failure";
1153
1182
  probeTemplateId: string;
1154
1183
  probeStepId: string;
1184
+ result: "success" | "failure";
1155
1185
  };
1156
1186
  enforcementGrade: "strong";
1157
1187
  }, {
1158
1188
  kind: "probe_step";
1159
1189
  detail: {
1160
- result: "success" | "failure";
1161
1190
  probeTemplateId: string;
1162
1191
  probeStepId: string;
1192
+ result: "success" | "failure";
1163
1193
  };
1164
1194
  enforcementGrade: "strong";
1165
1195
  }>, z.ZodObject<{
@@ -1229,9 +1259,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1229
1259
  provenance: {
1230
1260
  kind: "probe_step";
1231
1261
  detail: {
1232
- result: "success" | "failure";
1233
1262
  probeTemplateId: string;
1234
1263
  probeStepId: string;
1264
+ result: "success" | "failure";
1235
1265
  };
1236
1266
  enforcementGrade: "strong";
1237
1267
  } | {
@@ -1257,9 +1287,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1257
1287
  provenance: {
1258
1288
  kind: "probe_step";
1259
1289
  detail: {
1260
- result: "success" | "failure";
1261
1290
  probeTemplateId: string;
1262
1291
  probeStepId: string;
1292
+ result: "success" | "failure";
1263
1293
  };
1264
1294
  enforcementGrade: "strong";
1265
1295
  } | {
@@ -1285,9 +1315,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1285
1315
  provenance: {
1286
1316
  kind: "probe_step";
1287
1317
  detail: {
1288
- result: "success" | "failure";
1289
1318
  probeTemplateId: string;
1290
1319
  probeStepId: string;
1320
+ result: "success" | "failure";
1291
1321
  };
1292
1322
  enforcementGrade: "strong";
1293
1323
  } | {
@@ -1313,9 +1343,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1313
1343
  provenance: {
1314
1344
  kind: "probe_step";
1315
1345
  detail: {
1316
- result: "success" | "failure";
1317
1346
  probeTemplateId: string;
1318
1347
  probeStepId: string;
1348
+ result: "success" | "failure";
1319
1349
  };
1320
1350
  enforcementGrade: "strong";
1321
1351
  } | {
@@ -1345,9 +1375,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1345
1375
  provenance: {
1346
1376
  kind: "probe_step";
1347
1377
  detail: {
1348
- result: "success" | "failure";
1349
1378
  probeTemplateId: string;
1350
1379
  probeStepId: string;
1380
+ result: "success" | "failure";
1351
1381
  };
1352
1382
  enforcementGrade: "strong";
1353
1383
  } | {
@@ -1368,8 +1398,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1368
1398
  };
1369
1399
  };
1370
1400
  v: 1;
1371
- eventId: string;
1372
1401
  eventIndex: number;
1402
+ eventId: string;
1373
1403
  dedupeKey: string;
1374
1404
  scope: {
1375
1405
  runId: string;
@@ -1385,9 +1415,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1385
1415
  provenance: {
1386
1416
  kind: "probe_step";
1387
1417
  detail: {
1388
- result: "success" | "failure";
1389
1418
  probeTemplateId: string;
1390
1419
  probeStepId: string;
1420
+ result: "success" | "failure";
1391
1421
  };
1392
1422
  enforcementGrade: "strong";
1393
1423
  } | {
@@ -1408,8 +1438,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1408
1438
  };
1409
1439
  };
1410
1440
  v: 1;
1411
- eventId: string;
1412
1441
  eventIndex: number;
1442
+ eventId: string;
1413
1443
  dedupeKey: string;
1414
1444
  scope: {
1415
1445
  runId: string;
@@ -1523,9 +1553,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1523
1553
  category: "unexpected";
1524
1554
  detail: "invariant_violation" | "storage_corruption_detected";
1525
1555
  };
1556
+ gapId: string;
1526
1557
  severity: "warning" | "info" | "critical";
1527
1558
  summary: string;
1528
- gapId: string;
1529
1559
  resolution: {
1530
1560
  kind: "unresolved";
1531
1561
  } | {
@@ -1553,9 +1583,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1553
1583
  category: "unexpected";
1554
1584
  detail: "invariant_violation" | "storage_corruption_detected";
1555
1585
  };
1586
+ gapId: string;
1556
1587
  severity: "warning" | "info" | "critical";
1557
1588
  summary: string;
1558
- gapId: string;
1559
1589
  resolution: {
1560
1590
  kind: "unresolved";
1561
1591
  } | {
@@ -1587,9 +1617,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1587
1617
  category: "unexpected";
1588
1618
  detail: "invariant_violation" | "storage_corruption_detected";
1589
1619
  };
1620
+ gapId: string;
1590
1621
  severity: "warning" | "info" | "critical";
1591
1622
  summary: string;
1592
- gapId: string;
1593
1623
  resolution: {
1594
1624
  kind: "unresolved";
1595
1625
  } | {
@@ -1605,8 +1635,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1605
1635
  })[] | undefined;
1606
1636
  };
1607
1637
  v: 1;
1608
- eventId: string;
1609
1638
  eventIndex: number;
1639
+ eventId: string;
1610
1640
  dedupeKey: string;
1611
1641
  scope: {
1612
1642
  runId: string;
@@ -1629,9 +1659,9 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1629
1659
  category: "unexpected";
1630
1660
  detail: "invariant_violation" | "storage_corruption_detected";
1631
1661
  };
1662
+ gapId: string;
1632
1663
  severity: "warning" | "info" | "critical";
1633
1664
  summary: string;
1634
- gapId: string;
1635
1665
  resolution: {
1636
1666
  kind: "unresolved";
1637
1667
  } | {
@@ -1647,8 +1677,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1647
1677
  })[] | undefined;
1648
1678
  };
1649
1679
  v: 1;
1650
- eventId: string;
1651
1680
  eventIndex: number;
1681
+ eventId: string;
1652
1682
  dedupeKey: string;
1653
1683
  scope: {
1654
1684
  runId: string;
@@ -1698,8 +1728,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1698
1728
  relatedStepId?: string | undefined;
1699
1729
  };
1700
1730
  v: 1;
1701
- eventId: string;
1702
1731
  eventIndex: number;
1732
+ eventId: string;
1703
1733
  dedupeKey: string;
1704
1734
  scope: {
1705
1735
  runId: string;
@@ -1715,8 +1745,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1715
1745
  relatedStepId?: string | undefined;
1716
1746
  };
1717
1747
  v: 1;
1718
- eventId: string;
1719
1748
  eventIndex: number;
1749
+ eventId: string;
1720
1750
  dedupeKey: string;
1721
1751
  scope: {
1722
1752
  runId: string;
@@ -1782,8 +1812,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1782
1812
  traceId: string;
1783
1813
  };
1784
1814
  v: 1;
1785
- eventId: string;
1786
1815
  eventIndex: number;
1816
+ eventId: string;
1787
1817
  dedupeKey: string;
1788
1818
  scope: {
1789
1819
  runId: string;
@@ -1801,8 +1831,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
1801
1831
  traceId: string;
1802
1832
  };
1803
1833
  v: 1;
1804
- eventId: string;
1805
1834
  eventIndex: number;
1835
+ eventId: string;
1806
1836
  dedupeKey: string;
1807
1837
  scope: {
1808
1838
  runId: string;
@@ -8,6 +8,9 @@ const sha256DigestSchema = zod_1.z
8
8
  .string()
9
9
  .regex(/^sha256:[0-9a-f]{64}$/, 'Expected sha256:<64 hex chars>')
10
10
  .describe('sha256 digest in WorkRail v2 format');
11
+ const workflowHashSchema = sha256DigestSchema
12
+ .transform((v) => (0, index_js_1.asWorkflowHash)((0, index_js_1.asSha256Digest)(v)))
13
+ .describe('WorkflowHash (sha256 digest of workflow definition)');
11
14
  const snapshotRefSchema = sha256DigestSchema
12
15
  .transform((v) => (0, index_js_1.asSnapshotRef)((0, index_js_1.asSha256Digest)(v)))
13
16
  .describe('SnapshotRef (content-addressed sha256 ref)');
@@ -29,7 +32,7 @@ exports.DomainEventEnvelopeV1Schema = zod_1.z.object({
29
32
  const WorkflowSourceKindSchema = zod_1.z.enum(['bundled', 'user', 'project', 'remote', 'plugin']);
30
33
  const RunStartedDataV1Schema = zod_1.z.object({
31
34
  workflowId: zod_1.z.string().min(1),
32
- workflowHash: sha256DigestSchema,
35
+ workflowHash: workflowHashSchema,
33
36
  workflowSourceKind: WorkflowSourceKindSchema,
34
37
  workflowSourceRef: zod_1.z.string().min(1),
35
38
  });
@@ -37,7 +40,7 @@ const NodeKindSchema = zod_1.z.enum(['step', 'checkpoint']);
37
40
  const NodeCreatedDataV1Schema = zod_1.z.object({
38
41
  nodeKind: NodeKindSchema,
39
42
  parentNodeId: zod_1.z.string().min(1).nullable(),
40
- workflowHash: sha256DigestSchema,
43
+ workflowHash: workflowHashSchema,
41
44
  snapshotRef: snapshotRefSchema,
42
45
  });
43
46
  const EdgeKindSchema = zod_1.z.enum(['acked_step', 'checkpoint']);
@@ -101,6 +104,7 @@ const BlockerCodeSchema = zod_1.z.enum([
101
104
  ]);
102
105
  const BlockerPointerSchema = zod_1.z.discriminatedUnion('kind', [
103
106
  zod_1.z.object({ kind: zod_1.z.literal('context_key'), key: zod_1.z.string().min(1) }),
107
+ zod_1.z.object({ kind: zod_1.z.literal('context_budget') }),
104
108
  zod_1.z.object({ kind: zod_1.z.literal('output_contract'), contractRef: zod_1.z.string().min(1) }),
105
109
  zod_1.z.object({ kind: zod_1.z.literal('capability'), capability: zod_1.z.enum(['delegation', 'web_browsing']) }),
106
110
  zod_1.z.object({ kind: zod_1.z.literal('workflow_step'), stepId: zod_1.z.string().min(1) }),
@@ -118,13 +122,27 @@ const BlockerReportV1Schema = zod_1.z
118
122
  .superRefine((v, ctx) => {
119
123
  const keyFor = (b) => {
120
124
  const p = b.pointer;
121
- const ptrStable = p.kind === 'context_key'
122
- ? p.key
123
- : p.kind === 'output_contract'
124
- ? p.contractRef
125
- : p.kind === 'capability'
126
- ? p.capability
127
- : p.stepId;
125
+ let ptrStable;
126
+ switch (p.kind) {
127
+ case 'context_key':
128
+ ptrStable = p.key;
129
+ break;
130
+ case 'output_contract':
131
+ ptrStable = p.contractRef;
132
+ break;
133
+ case 'capability':
134
+ ptrStable = p.capability;
135
+ break;
136
+ case 'workflow_step':
137
+ ptrStable = p.stepId;
138
+ break;
139
+ case 'context_budget':
140
+ ptrStable = '';
141
+ break;
142
+ default:
143
+ const _exhaustive = p;
144
+ ptrStable = _exhaustive;
145
+ }
128
146
  return `${b.code}|${p.kind}|${String(ptrStable)}`;
129
147
  };
130
148
  for (let i = 1; i < v.blockers.length; i++) {
@@ -41,17 +41,17 @@ export declare const ManifestRecordV1Schema: z.ZodDiscriminatedUnion<"kind", [z.
41
41
  kind: "snapshot_pinned";
42
42
  sessionId: string;
43
43
  v: 1;
44
+ manifestIndex: number;
44
45
  eventIndex: number;
45
46
  snapshotRef: string;
46
- manifestIndex: number;
47
47
  createdByEventId: string;
48
48
  }, {
49
49
  kind: "snapshot_pinned";
50
50
  sessionId: string;
51
51
  v: 1;
52
+ manifestIndex: number;
52
53
  eventIndex: number;
53
54
  snapshotRef: string;
54
- manifestIndex: number;
55
55
  createdByEventId: string;
56
56
  }>]>;
57
57
  export type ManifestRecordV1 = z.infer<typeof ManifestRecordV1Schema>;
@@ -0,0 +1,7 @@
1
+ import type { Result } from 'neverthrow';
2
+ export type Base64UrlError = {
3
+ readonly code: 'BASE64URL_INVALID';
4
+ readonly message: string;
5
+ };
6
+ export declare function encodeBase64Url(bytes: Uint8Array): string;
7
+ export declare function decodeBase64Url(input: string): Result<Uint8Array, Base64UrlError>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeBase64Url = encodeBase64Url;
4
+ exports.decodeBase64Url = decodeBase64Url;
5
+ const neverthrow_1 = require("neverthrow");
6
+ function encodeBase64Url(bytes) {
7
+ return Buffer.from(bytes).toString('base64url');
8
+ }
9
+ function decodeBase64Url(input) {
10
+ try {
11
+ return (0, neverthrow_1.ok)(new Uint8Array(Buffer.from(input, 'base64url')));
12
+ }
13
+ catch {
14
+ return (0, neverthrow_1.err)({ code: 'BASE64URL_INVALID', message: 'Invalid base64url string' });
15
+ }
16
+ }
@@ -0,0 +1,9 @@
1
+ export { encodeBase64Url, decodeBase64Url } from './base64url.js';
2
+ export { TokenPayloadV1Schema, StateTokenPayloadV1Schema, AckTokenPayloadV1Schema, CheckpointTokenPayloadV1Schema, expectedPrefixForTokenKind, } from './payloads.js';
3
+ export type { TokenPayloadV1, StateTokenPayloadV1, AckTokenPayloadV1, CheckpointTokenPayloadV1 } from './payloads.js';
4
+ export { encodeTokenPayloadV1, encodeUnsignedTokenV1, parseTokenV1 } from './token-codec.js';
5
+ export type { TokenDecodeErrorV2, ParsedTokenV1 } from './token-codec.js';
6
+ export { signTokenV1, verifyTokenSignatureV1, assertTokenScopeMatchesState } from './token-signer.js';
7
+ export type { TokenVerifyErrorV2 } from './token-signer.js';
8
+ export type { AttemptId, OutputId } from '../ids/index.js';
9
+ export { asAttemptId, asOutputId } from '../ids/index.js';