@exaudeus/workrail 2.0.0 → 3.0.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.
- package/dist/application/services/compiler/template-registry.d.ts +4 -2
- package/dist/application/services/compiler/template-registry.js +97 -5
- package/dist/application/services/workflow-compiler.d.ts +5 -1
- package/dist/application/services/workflow-compiler.js +20 -7
- package/dist/application/use-cases/raw-workflow-file-scanner.d.ts +1 -1
- package/dist/application/use-cases/raw-workflow-file-scanner.js +2 -0
- package/dist/application/use-cases/validate-workflow-registry.js +2 -1
- package/dist/config/feature-flags.js +8 -0
- package/dist/di/container.js +10 -1
- package/dist/di/tokens.d.ts +1 -0
- package/dist/di/tokens.js +1 -0
- package/dist/engine/engine-factory.d.ts +3 -0
- package/dist/engine/engine-factory.js +295 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +12 -0
- package/dist/engine/types.d.ts +130 -0
- package/dist/engine/types.js +18 -0
- package/dist/infrastructure/storage/file-workflow-storage.d.ts +1 -0
- package/dist/infrastructure/storage/file-workflow-storage.js +18 -3
- package/dist/infrastructure/storage/workflow-resolution.d.ts +9 -6
- package/dist/infrastructure/storage/workflow-resolution.js +14 -1
- package/dist/manifest.json +166 -94
- package/dist/mcp/handlers/shared/request-workflow-reader.d.ts +19 -0
- package/dist/mcp/handlers/shared/request-workflow-reader.js +50 -0
- package/dist/mcp/handlers/v2-checkpoint.d.ts +31 -1
- package/dist/mcp/handlers/v2-checkpoint.js +76 -64
- package/dist/mcp/handlers/v2-execution/continue-advance.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-advance.js +5 -5
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +17 -22
- package/dist/mcp/handlers/v2-execution/index.d.ts +10 -17
- package/dist/mcp/handlers/v2-execution/index.js +44 -54
- package/dist/mcp/handlers/v2-execution/replay.d.ts +4 -15
- package/dist/mcp/handlers/v2-execution/replay.js +52 -128
- package/dist/mcp/handlers/v2-execution/start.d.ts +4 -3
- package/dist/mcp/handlers/v2-execution/start.js +32 -49
- package/dist/mcp/handlers/v2-token-ops.d.ts +45 -24
- package/dist/mcp/handlers/v2-token-ops.js +372 -32
- package/dist/mcp/handlers/v2-workflow.d.ts +1 -1
- package/dist/mcp/handlers/v2-workflow.js +25 -4
- package/dist/mcp/output-schemas.d.ts +104 -283
- package/dist/mcp/output-schemas.js +24 -22
- package/dist/mcp/server.js +8 -0
- package/dist/mcp/tool-descriptions.js +9 -2
- package/dist/mcp/types.d.ts +4 -0
- package/dist/mcp/v2/tools.d.ts +32 -53
- package/dist/mcp/v2/tools.js +27 -37
- package/dist/mcp/v2-response-formatter.js +12 -16
- package/dist/runtime/runtime-mode.d.ts +2 -0
- package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
- package/dist/v2/durable-core/domain/prompt-renderer.js +5 -3
- package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +14 -14
- package/dist/v2/durable-core/schemas/session/events.d.ts +4 -4
- package/dist/v2/durable-core/schemas/session/validation-event.d.ts +2 -2
- package/dist/v2/durable-core/tokens/payloads.d.ts +32 -32
- package/dist/v2/durable-core/tokens/short-token.d.ts +38 -0
- package/dist/v2/durable-core/tokens/short-token.js +126 -0
- package/dist/v2/durable-core/tokens/token-patterns.d.ts +4 -0
- package/dist/v2/durable-core/tokens/token-patterns.js +9 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.d.ts +11 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.js +38 -0
- package/dist/v2/infra/local/data-dir/index.d.ts +1 -0
- package/dist/v2/infra/local/data-dir/index.js +3 -0
- package/dist/v2/infra/local/token-alias-store/index.d.ts +16 -0
- package/dist/v2/infra/local/token-alias-store/index.js +117 -0
- package/dist/v2/ports/data-dir.port.d.ts +1 -0
- package/dist/v2/ports/token-alias-store.port.d.ts +33 -0
- package/dist/v2/ports/token-alias-store.port.js +2 -0
- package/package.json +8 -1
- package/workflows/coding-task-workflow-agentic.lean.v2.json +224 -0
- package/workflows/routines/philosophy-alignment.json +12 -12
- package/workflows/routines/tension-driven-design.json +63 -0
|
@@ -889,8 +889,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
889
889
|
}>;
|
|
890
890
|
}, "strict", z.ZodTypeAny, {
|
|
891
891
|
contractRef: string;
|
|
892
|
-
validationId: string;
|
|
893
892
|
attemptId: string;
|
|
893
|
+
validationId: string;
|
|
894
894
|
result: {
|
|
895
895
|
issues: readonly string[];
|
|
896
896
|
valid: boolean;
|
|
@@ -898,8 +898,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
898
898
|
};
|
|
899
899
|
}, {
|
|
900
900
|
contractRef: string;
|
|
901
|
-
validationId: string;
|
|
902
901
|
attemptId: string;
|
|
902
|
+
validationId: string;
|
|
903
903
|
result: {
|
|
904
904
|
issues: readonly string[];
|
|
905
905
|
valid: boolean;
|
|
@@ -911,8 +911,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
911
911
|
sessionId: string;
|
|
912
912
|
data: {
|
|
913
913
|
contractRef: string;
|
|
914
|
-
validationId: string;
|
|
915
914
|
attemptId: string;
|
|
915
|
+
validationId: string;
|
|
916
916
|
result: {
|
|
917
917
|
issues: readonly string[];
|
|
918
918
|
valid: boolean;
|
|
@@ -932,8 +932,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
932
932
|
sessionId: string;
|
|
933
933
|
data: {
|
|
934
934
|
contractRef: string;
|
|
935
|
-
validationId: string;
|
|
936
935
|
attemptId: string;
|
|
936
|
+
validationId: string;
|
|
937
937
|
result: {
|
|
938
938
|
issues: readonly string[];
|
|
939
939
|
valid: boolean;
|
|
@@ -4385,8 +4385,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
4385
4385
|
sessionId: string;
|
|
4386
4386
|
data: {
|
|
4387
4387
|
contractRef: string;
|
|
4388
|
-
validationId: string;
|
|
4389
4388
|
attemptId: string;
|
|
4389
|
+
validationId: string;
|
|
4390
4390
|
result: {
|
|
4391
4391
|
issues: readonly string[];
|
|
4392
4392
|
valid: boolean;
|
|
@@ -4897,8 +4897,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
4897
4897
|
sessionId: string;
|
|
4898
4898
|
data: {
|
|
4899
4899
|
contractRef: string;
|
|
4900
|
-
validationId: string;
|
|
4901
4900
|
attemptId: string;
|
|
4901
|
+
validationId: string;
|
|
4902
4902
|
result: {
|
|
4903
4903
|
issues: readonly string[];
|
|
4904
4904
|
valid: boolean;
|
|
@@ -6011,8 +6011,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6011
6011
|
}>;
|
|
6012
6012
|
}, "strict", z.ZodTypeAny, {
|
|
6013
6013
|
contractRef: string;
|
|
6014
|
-
validationId: string;
|
|
6015
6014
|
attemptId: string;
|
|
6015
|
+
validationId: string;
|
|
6016
6016
|
result: {
|
|
6017
6017
|
issues: readonly string[];
|
|
6018
6018
|
valid: boolean;
|
|
@@ -6020,8 +6020,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6020
6020
|
};
|
|
6021
6021
|
}, {
|
|
6022
6022
|
contractRef: string;
|
|
6023
|
-
validationId: string;
|
|
6024
6023
|
attemptId: string;
|
|
6024
|
+
validationId: string;
|
|
6025
6025
|
result: {
|
|
6026
6026
|
issues: readonly string[];
|
|
6027
6027
|
valid: boolean;
|
|
@@ -6033,8 +6033,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6033
6033
|
sessionId: string;
|
|
6034
6034
|
data: {
|
|
6035
6035
|
contractRef: string;
|
|
6036
|
-
validationId: string;
|
|
6037
6036
|
attemptId: string;
|
|
6037
|
+
validationId: string;
|
|
6038
6038
|
result: {
|
|
6039
6039
|
issues: readonly string[];
|
|
6040
6040
|
valid: boolean;
|
|
@@ -6054,8 +6054,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6054
6054
|
sessionId: string;
|
|
6055
6055
|
data: {
|
|
6056
6056
|
contractRef: string;
|
|
6057
|
-
validationId: string;
|
|
6058
6057
|
attemptId: string;
|
|
6058
|
+
validationId: string;
|
|
6059
6059
|
result: {
|
|
6060
6060
|
issues: readonly string[];
|
|
6061
6061
|
valid: boolean;
|
|
@@ -9507,8 +9507,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
9507
9507
|
sessionId: string;
|
|
9508
9508
|
data: {
|
|
9509
9509
|
contractRef: string;
|
|
9510
|
-
validationId: string;
|
|
9511
9510
|
attemptId: string;
|
|
9511
|
+
validationId: string;
|
|
9512
9512
|
result: {
|
|
9513
9513
|
issues: readonly string[];
|
|
9514
9514
|
valid: boolean;
|
|
@@ -10019,8 +10019,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
10019
10019
|
sessionId: string;
|
|
10020
10020
|
data: {
|
|
10021
10021
|
contractRef: string;
|
|
10022
|
-
validationId: string;
|
|
10023
10022
|
attemptId: string;
|
|
10023
|
+
validationId: string;
|
|
10024
10024
|
result: {
|
|
10025
10025
|
issues: readonly string[];
|
|
10026
10026
|
valid: boolean;
|
|
@@ -10560,8 +10560,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
10560
10560
|
sessionId: string;
|
|
10561
10561
|
data: {
|
|
10562
10562
|
contractRef: string;
|
|
10563
|
-
validationId: string;
|
|
10564
10563
|
attemptId: string;
|
|
10564
|
+
validationId: string;
|
|
10565
10565
|
result: {
|
|
10566
10566
|
issues: readonly string[];
|
|
10567
10567
|
valid: boolean;
|
|
@@ -11089,8 +11089,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
11089
11089
|
sessionId: string;
|
|
11090
11090
|
data: {
|
|
11091
11091
|
contractRef: string;
|
|
11092
|
-
validationId: string;
|
|
11093
11092
|
attemptId: string;
|
|
11093
|
+
validationId: string;
|
|
11094
11094
|
result: {
|
|
11095
11095
|
issues: readonly string[];
|
|
11096
11096
|
valid: boolean;
|
|
@@ -874,8 +874,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
874
874
|
}>;
|
|
875
875
|
}, "strict", z.ZodTypeAny, {
|
|
876
876
|
contractRef: string;
|
|
877
|
-
validationId: string;
|
|
878
877
|
attemptId: string;
|
|
878
|
+
validationId: string;
|
|
879
879
|
result: {
|
|
880
880
|
issues: readonly string[];
|
|
881
881
|
valid: boolean;
|
|
@@ -883,8 +883,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
883
883
|
};
|
|
884
884
|
}, {
|
|
885
885
|
contractRef: string;
|
|
886
|
-
validationId: string;
|
|
887
886
|
attemptId: string;
|
|
887
|
+
validationId: string;
|
|
888
888
|
result: {
|
|
889
889
|
issues: readonly string[];
|
|
890
890
|
valid: boolean;
|
|
@@ -896,8 +896,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
896
896
|
sessionId: string;
|
|
897
897
|
data: {
|
|
898
898
|
contractRef: string;
|
|
899
|
-
validationId: string;
|
|
900
899
|
attemptId: string;
|
|
900
|
+
validationId: string;
|
|
901
901
|
result: {
|
|
902
902
|
issues: readonly string[];
|
|
903
903
|
valid: boolean;
|
|
@@ -917,8 +917,8 @@ export declare const DomainEventV1Schema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
917
917
|
sessionId: string;
|
|
918
918
|
data: {
|
|
919
919
|
contractRef: string;
|
|
920
|
-
validationId: string;
|
|
921
920
|
attemptId: string;
|
|
921
|
+
validationId: string;
|
|
922
922
|
result: {
|
|
923
923
|
issues: readonly string[];
|
|
924
924
|
valid: boolean;
|
|
@@ -47,8 +47,8 @@ export declare const ValidationPerformedDataV1Schema: z.ZodObject<{
|
|
|
47
47
|
}>;
|
|
48
48
|
}, "strict", z.ZodTypeAny, {
|
|
49
49
|
contractRef: string;
|
|
50
|
-
validationId: string;
|
|
51
50
|
attemptId: string;
|
|
51
|
+
validationId: string;
|
|
52
52
|
result: {
|
|
53
53
|
issues: readonly string[];
|
|
54
54
|
valid: boolean;
|
|
@@ -56,8 +56,8 @@ export declare const ValidationPerformedDataV1Schema: z.ZodObject<{
|
|
|
56
56
|
};
|
|
57
57
|
}, {
|
|
58
58
|
contractRef: string;
|
|
59
|
-
validationId: string;
|
|
60
59
|
attemptId: string;
|
|
60
|
+
validationId: string;
|
|
61
61
|
result: {
|
|
62
62
|
issues: readonly string[];
|
|
63
63
|
valid: boolean;
|
|
@@ -17,24 +17,24 @@ export declare const StateTokenPayloadV1Schema: z.ZodObject<{
|
|
|
17
17
|
sessionId: string & {
|
|
18
18
|
readonly __brand: "v2.SessionId";
|
|
19
19
|
};
|
|
20
|
+
tokenKind: "state";
|
|
20
21
|
runId: string & {
|
|
21
22
|
readonly __brand: "v2.RunId";
|
|
22
23
|
};
|
|
23
24
|
nodeId: string & {
|
|
24
25
|
readonly __brand: "v2.NodeId";
|
|
25
26
|
};
|
|
26
|
-
tokenVersion: 1;
|
|
27
|
-
tokenKind: "state";
|
|
28
27
|
workflowHashRef: string & {
|
|
29
28
|
readonly __brand: "v2.WorkflowHashRef";
|
|
30
29
|
};
|
|
30
|
+
tokenVersion: 1;
|
|
31
31
|
}, {
|
|
32
32
|
sessionId: string;
|
|
33
|
+
tokenKind: "state";
|
|
33
34
|
runId: string;
|
|
34
35
|
nodeId: string;
|
|
35
|
-
tokenVersion: 1;
|
|
36
|
-
tokenKind: "state";
|
|
37
36
|
workflowHashRef: string;
|
|
37
|
+
tokenVersion: 1;
|
|
38
38
|
}>;
|
|
39
39
|
export type StateTokenPayloadV1 = z.infer<typeof StateTokenPayloadV1Schema> & {
|
|
40
40
|
readonly tokenVersion: TokenVersionV1;
|
|
@@ -55,24 +55,24 @@ export declare const AckTokenPayloadV1Schema: z.ZodObject<{
|
|
|
55
55
|
sessionId: string & {
|
|
56
56
|
readonly __brand: "v2.SessionId";
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
readonly __brand: "v2.AttemptId";
|
|
60
|
-
};
|
|
58
|
+
tokenKind: "ack";
|
|
61
59
|
runId: string & {
|
|
62
60
|
readonly __brand: "v2.RunId";
|
|
63
61
|
};
|
|
64
62
|
nodeId: string & {
|
|
65
63
|
readonly __brand: "v2.NodeId";
|
|
66
64
|
};
|
|
65
|
+
attemptId: string & {
|
|
66
|
+
readonly __brand: "v2.AttemptId";
|
|
67
|
+
};
|
|
67
68
|
tokenVersion: 1;
|
|
68
|
-
tokenKind: "ack";
|
|
69
69
|
}, {
|
|
70
70
|
sessionId: string;
|
|
71
|
-
|
|
71
|
+
tokenKind: "ack";
|
|
72
72
|
runId: string;
|
|
73
73
|
nodeId: string;
|
|
74
|
+
attemptId: string;
|
|
74
75
|
tokenVersion: 1;
|
|
75
|
-
tokenKind: "ack";
|
|
76
76
|
}>;
|
|
77
77
|
export type AckTokenPayloadV1 = z.infer<typeof AckTokenPayloadV1Schema> & {
|
|
78
78
|
readonly tokenVersion: TokenVersionV1;
|
|
@@ -93,24 +93,24 @@ export declare const CheckpointTokenPayloadV1Schema: z.ZodObject<{
|
|
|
93
93
|
sessionId: string & {
|
|
94
94
|
readonly __brand: "v2.SessionId";
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
readonly __brand: "v2.AttemptId";
|
|
98
|
-
};
|
|
96
|
+
tokenKind: "checkpoint";
|
|
99
97
|
runId: string & {
|
|
100
98
|
readonly __brand: "v2.RunId";
|
|
101
99
|
};
|
|
102
100
|
nodeId: string & {
|
|
103
101
|
readonly __brand: "v2.NodeId";
|
|
104
102
|
};
|
|
103
|
+
attemptId: string & {
|
|
104
|
+
readonly __brand: "v2.AttemptId";
|
|
105
|
+
};
|
|
105
106
|
tokenVersion: 1;
|
|
106
|
-
tokenKind: "checkpoint";
|
|
107
107
|
}, {
|
|
108
108
|
sessionId: string;
|
|
109
|
-
|
|
109
|
+
tokenKind: "checkpoint";
|
|
110
110
|
runId: string;
|
|
111
111
|
nodeId: string;
|
|
112
|
+
attemptId: string;
|
|
112
113
|
tokenVersion: 1;
|
|
113
|
-
tokenKind: "checkpoint";
|
|
114
114
|
}>;
|
|
115
115
|
export type CheckpointTokenPayloadV1 = z.infer<typeof CheckpointTokenPayloadV1Schema> & {
|
|
116
116
|
readonly tokenVersion: TokenVersionV1;
|
|
@@ -131,24 +131,24 @@ export declare const TokenPayloadV1Schema: z.ZodDiscriminatedUnion<"tokenKind",
|
|
|
131
131
|
sessionId: string & {
|
|
132
132
|
readonly __brand: "v2.SessionId";
|
|
133
133
|
};
|
|
134
|
+
tokenKind: "state";
|
|
134
135
|
runId: string & {
|
|
135
136
|
readonly __brand: "v2.RunId";
|
|
136
137
|
};
|
|
137
138
|
nodeId: string & {
|
|
138
139
|
readonly __brand: "v2.NodeId";
|
|
139
140
|
};
|
|
140
|
-
tokenVersion: 1;
|
|
141
|
-
tokenKind: "state";
|
|
142
141
|
workflowHashRef: string & {
|
|
143
142
|
readonly __brand: "v2.WorkflowHashRef";
|
|
144
143
|
};
|
|
144
|
+
tokenVersion: 1;
|
|
145
145
|
}, {
|
|
146
146
|
sessionId: string;
|
|
147
|
+
tokenKind: "state";
|
|
147
148
|
runId: string;
|
|
148
149
|
nodeId: string;
|
|
149
|
-
tokenVersion: 1;
|
|
150
|
-
tokenKind: "state";
|
|
151
150
|
workflowHashRef: string;
|
|
151
|
+
tokenVersion: 1;
|
|
152
152
|
}>, z.ZodObject<{
|
|
153
153
|
tokenVersion: z.ZodLiteral<1>;
|
|
154
154
|
tokenKind: z.ZodLiteral<"ack">;
|
|
@@ -160,24 +160,24 @@ export declare const TokenPayloadV1Schema: z.ZodDiscriminatedUnion<"tokenKind",
|
|
|
160
160
|
sessionId: string & {
|
|
161
161
|
readonly __brand: "v2.SessionId";
|
|
162
162
|
};
|
|
163
|
-
|
|
164
|
-
readonly __brand: "v2.AttemptId";
|
|
165
|
-
};
|
|
163
|
+
tokenKind: "ack";
|
|
166
164
|
runId: string & {
|
|
167
165
|
readonly __brand: "v2.RunId";
|
|
168
166
|
};
|
|
169
167
|
nodeId: string & {
|
|
170
168
|
readonly __brand: "v2.NodeId";
|
|
171
169
|
};
|
|
170
|
+
attemptId: string & {
|
|
171
|
+
readonly __brand: "v2.AttemptId";
|
|
172
|
+
};
|
|
172
173
|
tokenVersion: 1;
|
|
173
|
-
tokenKind: "ack";
|
|
174
174
|
}, {
|
|
175
175
|
sessionId: string;
|
|
176
|
-
|
|
176
|
+
tokenKind: "ack";
|
|
177
177
|
runId: string;
|
|
178
178
|
nodeId: string;
|
|
179
|
+
attemptId: string;
|
|
179
180
|
tokenVersion: 1;
|
|
180
|
-
tokenKind: "ack";
|
|
181
181
|
}>, z.ZodObject<{
|
|
182
182
|
tokenVersion: z.ZodLiteral<1>;
|
|
183
183
|
tokenKind: z.ZodLiteral<"checkpoint">;
|
|
@@ -189,24 +189,24 @@ export declare const TokenPayloadV1Schema: z.ZodDiscriminatedUnion<"tokenKind",
|
|
|
189
189
|
sessionId: string & {
|
|
190
190
|
readonly __brand: "v2.SessionId";
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
readonly __brand: "v2.AttemptId";
|
|
194
|
-
};
|
|
192
|
+
tokenKind: "checkpoint";
|
|
195
193
|
runId: string & {
|
|
196
194
|
readonly __brand: "v2.RunId";
|
|
197
195
|
};
|
|
198
196
|
nodeId: string & {
|
|
199
197
|
readonly __brand: "v2.NodeId";
|
|
200
198
|
};
|
|
199
|
+
attemptId: string & {
|
|
200
|
+
readonly __brand: "v2.AttemptId";
|
|
201
|
+
};
|
|
201
202
|
tokenVersion: 1;
|
|
202
|
-
tokenKind: "checkpoint";
|
|
203
203
|
}, {
|
|
204
204
|
sessionId: string;
|
|
205
|
-
|
|
205
|
+
tokenKind: "checkpoint";
|
|
206
206
|
runId: string;
|
|
207
207
|
nodeId: string;
|
|
208
|
+
attemptId: string;
|
|
208
209
|
tokenVersion: 1;
|
|
209
|
-
tokenKind: "checkpoint";
|
|
210
210
|
}>]>;
|
|
211
211
|
export type TokenPayloadV1 = StateTokenPayloadV1 | AckTokenPayloadV1 | CheckpointTokenPayloadV1;
|
|
212
212
|
export type TokenPrefixV1 = 'st' | 'ack' | 'chk';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { HmacSha256PortV2 } from '../../ports/hmac-sha256.port.js';
|
|
3
|
+
import type { Base64UrlPortV2 } from '../../ports/base64url.port.js';
|
|
4
|
+
import type { KeyringV1 } from '../../ports/keyring.port.js';
|
|
5
|
+
export type ShortTokenKind = 'state' | 'ack' | 'checkpoint' | 'continue';
|
|
6
|
+
export declare const SHORT_TOKEN_NONCE_BYTES = 12;
|
|
7
|
+
export declare const SHORT_TOKEN_HMAC_BYTES = 6;
|
|
8
|
+
export declare const SHORT_TOKEN_PAYLOAD_BYTES: number;
|
|
9
|
+
export type ShortTokenError = {
|
|
10
|
+
readonly code: 'SHORT_TOKEN_UNKNOWN_PREFIX';
|
|
11
|
+
readonly raw: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly code: 'SHORT_TOKEN_INVALID_LENGTH';
|
|
14
|
+
readonly expected: number;
|
|
15
|
+
readonly actual: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly code: 'SHORT_TOKEN_INVALID_ENCODING';
|
|
18
|
+
readonly message: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly code: 'SHORT_TOKEN_BAD_SIGNATURE';
|
|
21
|
+
} | {
|
|
22
|
+
readonly code: 'SHORT_TOKEN_SIGNING_FAILED';
|
|
23
|
+
readonly message: string;
|
|
24
|
+
};
|
|
25
|
+
export interface ParsedShortToken {
|
|
26
|
+
readonly kind: ShortTokenKind;
|
|
27
|
+
readonly nonce: Uint8Array;
|
|
28
|
+
readonly hmac6: Uint8Array;
|
|
29
|
+
readonly nonceHex: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function mintShortToken(kind: ShortTokenKind, nonce: Uint8Array, keyring: KeyringV1, hmac: HmacSha256PortV2, base64url: Base64UrlPortV2): Result<string, ShortTokenError>;
|
|
32
|
+
export declare function parseShortToken(raw: string, base64url: Base64UrlPortV2): Result<ParsedShortToken, ShortTokenError>;
|
|
33
|
+
export declare function verifyShortTokenHmac(parsed: ParsedShortToken, keyring: KeyringV1, hmac: HmacSha256PortV2, base64url: Base64UrlPortV2): Result<void, ShortTokenError>;
|
|
34
|
+
export interface NativeParsedShortToken {
|
|
35
|
+
readonly kind: ShortTokenKind;
|
|
36
|
+
readonly nonceHex: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function parseShortTokenNative(raw: string): NativeParsedShortToken | null;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHORT_TOKEN_PAYLOAD_BYTES = exports.SHORT_TOKEN_HMAC_BYTES = exports.SHORT_TOKEN_NONCE_BYTES = void 0;
|
|
4
|
+
exports.mintShortToken = mintShortToken;
|
|
5
|
+
exports.parseShortToken = parseShortToken;
|
|
6
|
+
exports.verifyShortTokenHmac = verifyShortTokenHmac;
|
|
7
|
+
exports.parseShortTokenNative = parseShortTokenNative;
|
|
8
|
+
const neverthrow_1 = require("neverthrow");
|
|
9
|
+
const KIND_PREFIXES = {
|
|
10
|
+
state: 'st_',
|
|
11
|
+
ack: 'ak_',
|
|
12
|
+
checkpoint: 'ck_',
|
|
13
|
+
continue: 'ct_',
|
|
14
|
+
};
|
|
15
|
+
const PREFIX_TO_KIND = {
|
|
16
|
+
'st_': 'state',
|
|
17
|
+
'ak_': 'ack',
|
|
18
|
+
'ck_': 'checkpoint',
|
|
19
|
+
'ct_': 'continue',
|
|
20
|
+
};
|
|
21
|
+
const KIND_BYTES = {
|
|
22
|
+
state: 0x01,
|
|
23
|
+
ack: 0x02,
|
|
24
|
+
checkpoint: 0x03,
|
|
25
|
+
continue: 0x04,
|
|
26
|
+
};
|
|
27
|
+
exports.SHORT_TOKEN_NONCE_BYTES = 12;
|
|
28
|
+
exports.SHORT_TOKEN_HMAC_BYTES = 6;
|
|
29
|
+
exports.SHORT_TOKEN_PAYLOAD_BYTES = exports.SHORT_TOKEN_NONCE_BYTES + exports.SHORT_TOKEN_HMAC_BYTES;
|
|
30
|
+
function mintShortToken(kind, nonce, keyring, hmac, base64url) {
|
|
31
|
+
if (nonce.length !== exports.SHORT_TOKEN_NONCE_BYTES) {
|
|
32
|
+
return (0, neverthrow_1.err)({
|
|
33
|
+
code: 'SHORT_TOKEN_INVALID_LENGTH',
|
|
34
|
+
expected: exports.SHORT_TOKEN_NONCE_BYTES,
|
|
35
|
+
actual: nonce.length,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const keyResult = decodeKey(keyring.current.keyBase64Url, base64url);
|
|
39
|
+
if (keyResult.isErr())
|
|
40
|
+
return (0, neverthrow_1.err)(keyResult.error);
|
|
41
|
+
const key = keyResult.value;
|
|
42
|
+
const hmacInput = buildHmacInput(nonce, kind);
|
|
43
|
+
const hmacFull = hmac.hmacSha256(key, hmacInput);
|
|
44
|
+
const hmac6 = hmacFull.slice(0, exports.SHORT_TOKEN_HMAC_BYTES);
|
|
45
|
+
const payload = new Uint8Array(exports.SHORT_TOKEN_PAYLOAD_BYTES);
|
|
46
|
+
payload.set(nonce, 0);
|
|
47
|
+
payload.set(hmac6, exports.SHORT_TOKEN_NONCE_BYTES);
|
|
48
|
+
const encoded = base64url.encodeBase64Url(payload);
|
|
49
|
+
return (0, neverthrow_1.ok)(`${KIND_PREFIXES[kind]}${encoded}`);
|
|
50
|
+
}
|
|
51
|
+
function parseShortToken(raw, base64url) {
|
|
52
|
+
const prefix = raw.slice(0, 3);
|
|
53
|
+
const kind = PREFIX_TO_KIND[prefix];
|
|
54
|
+
if (!kind) {
|
|
55
|
+
return (0, neverthrow_1.err)({ code: 'SHORT_TOKEN_UNKNOWN_PREFIX', raw });
|
|
56
|
+
}
|
|
57
|
+
const encoded = raw.slice(3);
|
|
58
|
+
const decoded = base64url.decodeBase64Url(encoded);
|
|
59
|
+
if (decoded.isErr()) {
|
|
60
|
+
return (0, neverthrow_1.err)({ code: 'SHORT_TOKEN_INVALID_ENCODING', message: decoded.error.message });
|
|
61
|
+
}
|
|
62
|
+
const bytes = decoded.value;
|
|
63
|
+
if (bytes.length !== exports.SHORT_TOKEN_PAYLOAD_BYTES) {
|
|
64
|
+
return (0, neverthrow_1.err)({
|
|
65
|
+
code: 'SHORT_TOKEN_INVALID_LENGTH',
|
|
66
|
+
expected: exports.SHORT_TOKEN_PAYLOAD_BYTES,
|
|
67
|
+
actual: bytes.length,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const nonce = bytes.slice(0, exports.SHORT_TOKEN_NONCE_BYTES);
|
|
71
|
+
const hmac6 = bytes.slice(exports.SHORT_TOKEN_NONCE_BYTES);
|
|
72
|
+
const nonceHex = bufToHex(nonce);
|
|
73
|
+
return (0, neverthrow_1.ok)({ kind, nonce, hmac6, nonceHex });
|
|
74
|
+
}
|
|
75
|
+
function verifyShortTokenHmac(parsed, keyring, hmac, base64url) {
|
|
76
|
+
const hmacInput = buildHmacInput(parsed.nonce, parsed.kind);
|
|
77
|
+
if (checkHmac(parsed.hmac6, hmacInput, keyring.current.keyBase64Url, hmac, base64url)) {
|
|
78
|
+
return (0, neverthrow_1.ok)(undefined);
|
|
79
|
+
}
|
|
80
|
+
if (keyring.previous) {
|
|
81
|
+
if (checkHmac(parsed.hmac6, hmacInput, keyring.previous.keyBase64Url, hmac, base64url)) {
|
|
82
|
+
return (0, neverthrow_1.ok)(undefined);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return (0, neverthrow_1.err)({ code: 'SHORT_TOKEN_BAD_SIGNATURE' });
|
|
86
|
+
}
|
|
87
|
+
function buildHmacInput(nonce, kind) {
|
|
88
|
+
const input = new Uint8Array(exports.SHORT_TOKEN_NONCE_BYTES + 1);
|
|
89
|
+
input.set(nonce, 0);
|
|
90
|
+
input[exports.SHORT_TOKEN_NONCE_BYTES] = KIND_BYTES[kind];
|
|
91
|
+
return input;
|
|
92
|
+
}
|
|
93
|
+
function checkHmac(expected6, hmacInput, keyBase64Url, hmac, base64url) {
|
|
94
|
+
const keyResult = decodeKey(keyBase64Url, base64url);
|
|
95
|
+
if (keyResult.isErr())
|
|
96
|
+
return false;
|
|
97
|
+
const full = hmac.hmacSha256(keyResult.value, hmacInput);
|
|
98
|
+
const truncated = full.slice(0, exports.SHORT_TOKEN_HMAC_BYTES);
|
|
99
|
+
return hmac.timingSafeEqual(truncated, expected6);
|
|
100
|
+
}
|
|
101
|
+
function decodeKey(keyBase64Url, base64url) {
|
|
102
|
+
const r = base64url.decodeBase64Url(keyBase64Url);
|
|
103
|
+
if (r.isErr())
|
|
104
|
+
return (0, neverthrow_1.err)({ code: 'SHORT_TOKEN_SIGNING_FAILED', message: r.error.message });
|
|
105
|
+
return (0, neverthrow_1.ok)(r.value);
|
|
106
|
+
}
|
|
107
|
+
function bufToHex(bytes) {
|
|
108
|
+
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
109
|
+
}
|
|
110
|
+
function parseShortTokenNative(raw) {
|
|
111
|
+
const prefix = raw.slice(0, 3);
|
|
112
|
+
const kind = PREFIX_TO_KIND[prefix];
|
|
113
|
+
if (!kind)
|
|
114
|
+
return null;
|
|
115
|
+
const encoded = raw.slice(3);
|
|
116
|
+
try {
|
|
117
|
+
const bytes = Buffer.from(encoded, 'base64url');
|
|
118
|
+
if (bytes.length !== exports.SHORT_TOKEN_PAYLOAD_BYTES)
|
|
119
|
+
return null;
|
|
120
|
+
const nonceHex = Buffer.from(bytes.slice(0, exports.SHORT_TOKEN_NONCE_BYTES)).toString('hex');
|
|
121
|
+
return { kind, nonceHex };
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTINUE_TOKEN_PATTERN = exports.CHECKPOINT_TOKEN_PATTERN = exports.ACK_TOKEN_PATTERN = exports.STATE_TOKEN_PATTERN = void 0;
|
|
4
|
+
const BECH32_CHARS = '[023456789acdefghjklmnpqrstuvwxyz]+';
|
|
5
|
+
const BASE64URL_24 = '[A-Za-z0-9_-]{24}';
|
|
6
|
+
exports.STATE_TOKEN_PATTERN = new RegExp(`^(st1${BECH32_CHARS}|st_${BASE64URL_24})$`);
|
|
7
|
+
exports.ACK_TOKEN_PATTERN = new RegExp(`^(ack1${BECH32_CHARS}|ak_${BASE64URL_24})$`);
|
|
8
|
+
exports.CHECKPOINT_TOKEN_PATTERN = new RegExp(`^(chk1${BECH32_CHARS}|ck_${BASE64URL_24})$`);
|
|
9
|
+
exports.CONTINUE_TOKEN_PATTERN = new RegExp(`^ct_${BASE64URL_24}$`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResultAsync } from 'neverthrow';
|
|
2
|
+
import type { TokenAliasStorePortV2, TokenAliasEntryV2, TokenAliasRegistrationError, TokenAliasLoadError } from '../../../ports/token-alias-store.port.js';
|
|
3
|
+
import type { ShortTokenKind } from '../../../durable-core/tokens/short-token.js';
|
|
4
|
+
export declare class InMemoryTokenAliasStoreV2 implements TokenAliasStorePortV2 {
|
|
5
|
+
private readonly index;
|
|
6
|
+
private readonly positionIndex;
|
|
7
|
+
register(entry: TokenAliasEntryV2): ResultAsync<void, TokenAliasRegistrationError>;
|
|
8
|
+
lookup(nonceHex: string): TokenAliasEntryV2 | null;
|
|
9
|
+
lookupByPosition(tokenKind: ShortTokenKind, sessionId: string, nodeId: string, attemptId?: string, aliasSlot?: 'retry'): TokenAliasEntryV2 | null;
|
|
10
|
+
loadIndex(): ResultAsync<void, TokenAliasLoadError>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryTokenAliasStoreV2 = void 0;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
function positionKey(tokenKind, sessionId, nodeId, attemptId, aliasSlot) {
|
|
6
|
+
return `${tokenKind}:${aliasSlot ?? ''}:${sessionId}:${nodeId}:${attemptId ?? ''}`;
|
|
7
|
+
}
|
|
8
|
+
class InMemoryTokenAliasStoreV2 {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.index = new Map();
|
|
11
|
+
this.positionIndex = new Map();
|
|
12
|
+
}
|
|
13
|
+
register(entry) {
|
|
14
|
+
if (this.index.has(entry.nonceHex)) {
|
|
15
|
+
return (0, neverthrow_1.errAsync)({
|
|
16
|
+
code: 'ALIAS_DUPLICATE_NONCE',
|
|
17
|
+
nonceHex: entry.nonceHex,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
this.index.set(entry.nonceHex, entry);
|
|
21
|
+
this.positionIndex.set(positionKey(entry.tokenKind, entry.sessionId, entry.nodeId, entry.attemptId, entry.aliasSlot), entry.nonceHex);
|
|
22
|
+
return (0, neverthrow_1.okAsync)(undefined);
|
|
23
|
+
}
|
|
24
|
+
lookup(nonceHex) {
|
|
25
|
+
return this.index.get(nonceHex) ?? null;
|
|
26
|
+
}
|
|
27
|
+
lookupByPosition(tokenKind, sessionId, nodeId, attemptId, aliasSlot) {
|
|
28
|
+
const key = positionKey(tokenKind, sessionId, nodeId, attemptId, aliasSlot);
|
|
29
|
+
const nonceHex = this.positionIndex.get(key);
|
|
30
|
+
if (!nonceHex)
|
|
31
|
+
return null;
|
|
32
|
+
return this.index.get(nonceHex) ?? null;
|
|
33
|
+
}
|
|
34
|
+
loadIndex() {
|
|
35
|
+
return (0, neverthrow_1.okAsync)(undefined);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.InMemoryTokenAliasStoreV2 = InMemoryTokenAliasStoreV2;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ResultAsync } from 'neverthrow';
|
|
2
|
+
import type { DataDirPortV2 } from '../../../ports/data-dir.port.js';
|
|
3
|
+
import type { FileSystemPortV2 } from '../../../ports/fs.port.js';
|
|
4
|
+
import type { TokenAliasStorePortV2, TokenAliasEntryV2, TokenAliasRegistrationError, TokenAliasLoadError } from '../../../ports/token-alias-store.port.js';
|
|
5
|
+
import type { ShortTokenKind } from '../../../durable-core/tokens/short-token.js';
|
|
6
|
+
export declare class LocalTokenAliasStoreV2 implements TokenAliasStorePortV2 {
|
|
7
|
+
private readonly dataDir;
|
|
8
|
+
private readonly fs;
|
|
9
|
+
private readonly index;
|
|
10
|
+
private readonly positionIndex;
|
|
11
|
+
constructor(dataDir: DataDirPortV2, fs: FileSystemPortV2);
|
|
12
|
+
register(entry: TokenAliasEntryV2): ResultAsync<void, TokenAliasRegistrationError>;
|
|
13
|
+
lookup(nonceHex: string): TokenAliasEntryV2 | null;
|
|
14
|
+
lookupByPosition(tokenKind: ShortTokenKind, sessionId: string, nodeId: string, attemptId?: string, aliasSlot?: 'retry'): TokenAliasEntryV2 | null;
|
|
15
|
+
loadIndex(): ResultAsync<void, TokenAliasLoadError>;
|
|
16
|
+
}
|