rivetkit 2.3.0-rc.5 → 2.3.0-rc.7
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/browser/client.d.ts +35 -3
- package/dist/browser/client.js +795 -200
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +4 -3
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +4 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +3 -1
- package/dist/tsup/agent-os/index.cjs +7 -5
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +35 -3
- package/dist/tsup/agent-os/index.d.ts +35 -3
- package/dist/tsup/agent-os/index.js +7 -5
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2H4ISA4Y.cjs} +10 -10
- package/dist/tsup/chunk-2H4ISA4Y.cjs.map +1 -0
- package/dist/tsup/{chunk-UXTP4EBU.js → chunk-4DJMFOSU.js} +2 -2
- package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-4LTY5TOO.js} +132 -4
- package/dist/tsup/chunk-4LTY5TOO.js.map +1 -0
- package/dist/tsup/{chunk-PGYEMIOE.js → chunk-52TPEKEC.js} +2 -2
- package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-55E7IR6D.cjs} +4 -4
- package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-55E7IR6D.cjs.map} +1 -1
- package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-63WNTDRC.cjs} +31 -10
- package/dist/tsup/chunk-63WNTDRC.cjs.map +1 -0
- package/dist/tsup/{chunk-SULB574D.js → chunk-CMV6N5OX.js} +3 -3
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-D5G75T7J.js} +3 -1
- package/dist/tsup/chunk-D5G75T7J.js.map +1 -0
- package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-FEOG44WH.cjs} +137 -9
- package/dist/tsup/chunk-FEOG44WH.cjs.map +1 -0
- package/dist/tsup/{chunk-HR547GVH.cjs → chunk-G5HUSWP4.cjs} +8 -8
- package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-G5HUSWP4.cjs.map} +1 -1
- package/dist/tsup/{chunk-N2DQSJIW.js → chunk-HERL2VQ2.js} +17 -48
- package/dist/tsup/chunk-HERL2VQ2.js.map +1 -0
- package/dist/tsup/{chunk-LELRJK66.cjs → chunk-SJLPZEA3.cjs} +3 -3
- package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-SJLPZEA3.cjs.map} +1 -1
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-SRNOPUC6.cjs} +4 -2
- package/dist/tsup/chunk-SRNOPUC6.cjs.map +1 -0
- package/dist/tsup/{chunk-K34B3OVG.js → chunk-TMLOKTRB.js} +30 -9
- package/dist/tsup/chunk-TMLOKTRB.js.map +1 -0
- package/dist/tsup/{chunk-NATOT3ET.js → chunk-VFIY6GWO.js} +4 -4
- package/dist/tsup/chunk-VFIY6GWO.js.map +1 -0
- package/dist/tsup/{chunk-JY73X7VU.js → chunk-VJ4Y4WBT.js} +692 -114
- package/dist/tsup/chunk-VJ4Y4WBT.js.map +1 -0
- package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-X6HIFXNK.cjs} +23 -54
- package/dist/tsup/chunk-X6HIFXNK.cjs.map +1 -0
- package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ZGPX6KAH.cjs} +838 -260
- package/dist/tsup/chunk-ZGPX6KAH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.d.cts +3 -4
- package/dist/tsup/client/mod.d.ts +3 -4
- package/dist/tsup/client/mod.js +6 -6
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-CvQUtDp9.d.ts → config-Ak1lv4gF.d.ts} +27 -5
- package/dist/tsup/{config-C-a9vrke.d.cts → config-DU_xj4qZ.d.cts} +27 -5
- package/dist/tsup/{context-A7R0bsZL.d.ts → context-DAAp4Lpg.d.ts} +1 -1
- package/dist/tsup/{context-CA3r-pf2.d.cts → context-Dt_L55q8.d.cts} +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +507 -308
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -5
- package/dist/tsup/mod.d.ts +4 -5
- package/dist/tsup/mod.js +432 -233
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/process-metrics-NW754INA.js +118 -0
- package/dist/tsup/process-metrics-NW754INA.js.map +1 -0
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs +118 -0
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +1 -0
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -3
- package/dist/tsup/test/mod.d.ts +2 -3
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
- package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +41 -16
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -5
- package/dist/tsup/workflow/mod.d.ts +4 -5
- package/dist/tsup/workflow/mod.js +35 -10
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +11 -10
- package/src/actor/config.ts +3 -0
- package/src/actor/errors.ts +53 -7
- package/src/agent-os/actor/session.ts +2 -2
- package/src/client/actor-conn.ts +55 -60
- package/src/client/actor-handle.ts +59 -24
- package/src/client/errors.ts +2 -1
- package/src/client/queue.ts +2 -1
- package/src/client/raw-utils.ts +2 -4
- package/src/client/utils.ts +32 -4
- package/src/common/actor-router-consts.ts +4 -0
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/client-protocol-versioned.ts +125 -18
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/native-database.test.ts +35 -0
- package/src/common/database/native-database.ts +8 -4
- package/src/common/encoding.ts +243 -5
- package/src/common/inline-websocket-adapter.ts +12 -12
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +40 -10
- package/src/common/utils.ts +9 -200
- package/src/drivers/engine/actor-driver.ts +29 -28
- package/src/engine-client/actor-websocket-client.ts +2 -1
- package/src/engine-client/mod.ts +3 -2
- package/src/registry/config/index.ts +3 -5
- package/src/registry/index.ts +90 -16
- package/src/registry/napi-runtime.ts +15 -0
- package/src/registry/native.ts +197 -255
- package/src/registry/process-metrics.ts +183 -0
- package/src/registry/runtime.ts +4 -0
- package/src/registry/wasm-runtime.ts +9 -0
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/workflow/context.ts +32 -5
- package/src/workflow/inspector.ts +2 -1
- package/dist/tsup/chunk-2GANBXVP.cjs.map +0 -1
- package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
- package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
- package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
- package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
- package/dist/tsup/chunk-LDTT6WKJ.js.map +0 -1
- package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
- package/dist/tsup/chunk-NATOT3ET.js.map +0 -1
- package/dist/tsup/chunk-NW2J4SOL.cjs.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-4DJMFOSU.js.map} +0 -0
- /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-52TPEKEC.js.map} +0 -0
- /package/dist/tsup/{chunk-SULB574D.js.map → chunk-CMV6N5OX.js.map} +0 -0
|
@@ -2,8 +2,9 @@ import { createVersionedDataHandler } from "vbare";
|
|
|
2
2
|
import * as v1 from "./bare/generated/client-protocol/v1";
|
|
3
3
|
import * as v2 from "./bare/generated/client-protocol/v2";
|
|
4
4
|
import * as v3 from "./bare/generated/client-protocol/v3";
|
|
5
|
+
import * as v4 from "./bare/generated/client-protocol/v4";
|
|
5
6
|
|
|
6
|
-
export const CURRENT_VERSION =
|
|
7
|
+
export const CURRENT_VERSION = 4;
|
|
7
8
|
|
|
8
9
|
// Converter from v1 to v2: Remove connectionToken from Init message
|
|
9
10
|
const v1ToV2 = (v1Data: v1.ToClient): v2.ToClient => {
|
|
@@ -44,17 +45,45 @@ const v2ToV1 = (v2Data: v2.ToClient): v1.ToClient => {
|
|
|
44
45
|
return v2Data as unknown as v1.ToClient;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
// Converter from v2 to v3: No changes needed for ToClient
|
|
48
|
+
// Converter from v2 to v3: No changes needed for ToClient.
|
|
48
49
|
const v2ToV3 = (v2Data: v2.ToClient): v3.ToClient => {
|
|
49
50
|
return v2Data as unknown as v3.ToClient;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
const v3ToV4 = (v3Data: v3.ToClient): v4.ToClient => {
|
|
54
|
+
if (v3Data.body.tag === "Error") {
|
|
55
|
+
return {
|
|
56
|
+
body: {
|
|
57
|
+
tag: "Error",
|
|
58
|
+
val: {
|
|
59
|
+
...v3Data.body.val,
|
|
60
|
+
actor: null,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return v3Data as unknown as v4.ToClient;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const v4ToV3 = (v4Data: v4.ToClient): v3.ToClient => {
|
|
69
|
+
if (v4Data.body.tag === "Error") {
|
|
70
|
+
const { actor: _, ...val } = v4Data.body.val;
|
|
71
|
+
return {
|
|
72
|
+
body: {
|
|
73
|
+
tag: "Error",
|
|
74
|
+
val,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return v4Data as unknown as v3.ToClient;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Converter from v3 to v2: No changes needed for ToClient.
|
|
53
82
|
const v3ToV2 = (v3Data: v3.ToClient): v2.ToClient => {
|
|
54
83
|
return v3Data as unknown as v2.ToClient;
|
|
55
84
|
};
|
|
56
85
|
|
|
57
|
-
// ToServer identity converters
|
|
86
|
+
// ToServer identity converters.
|
|
58
87
|
const v1ToServerV2 = (v1Data: v1.ToServer): v2.ToServer => {
|
|
59
88
|
return v1Data as unknown as v2.ToServer;
|
|
60
89
|
};
|
|
@@ -63,6 +92,14 @@ const v2ToServerV3 = (v2Data: v2.ToServer): v3.ToServer => {
|
|
|
63
92
|
return v2Data as unknown as v3.ToServer;
|
|
64
93
|
};
|
|
65
94
|
|
|
95
|
+
const v3ToServerV4 = (v3Data: v3.ToServer): v4.ToServer => {
|
|
96
|
+
return v3Data as unknown as v4.ToServer;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const v4ToServerV3 = (v4Data: v4.ToServer): v3.ToServer => {
|
|
100
|
+
return v4Data as unknown as v3.ToServer;
|
|
101
|
+
};
|
|
102
|
+
|
|
66
103
|
const v3ToServerV2 = (v3Data: v3.ToServer): v2.ToServer => {
|
|
67
104
|
return v3Data as unknown as v2.ToServer;
|
|
68
105
|
};
|
|
@@ -71,7 +108,21 @@ const v2ToServerV1 = (v2Data: v2.ToServer): v1.ToServer => {
|
|
|
71
108
|
return v2Data as unknown as v1.ToServer;
|
|
72
109
|
};
|
|
73
110
|
|
|
74
|
-
|
|
111
|
+
const v3HttpResponseErrorToV4 = (
|
|
112
|
+
v3Data: v3.HttpResponseError,
|
|
113
|
+
): v4.HttpResponseError => ({
|
|
114
|
+
...v3Data,
|
|
115
|
+
actor: null,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const v4HttpResponseErrorToV3 = (
|
|
119
|
+
v4Data: v4.HttpResponseError,
|
|
120
|
+
): v3.HttpResponseError => {
|
|
121
|
+
const { actor: _, ...rest } = v4Data;
|
|
122
|
+
return rest;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const CLIENT_PROTOCOL_TO_SERVER = createVersionedDataHandler<v4.ToServer>({
|
|
75
126
|
deserializeVersion: (bytes, version) => {
|
|
76
127
|
switch (version) {
|
|
77
128
|
case 1:
|
|
@@ -80,6 +131,8 @@ export const CLIENT_PROTOCOL_TO_SERVER = createVersionedDataHandler<v3.ToServer>
|
|
|
80
131
|
return v2.decodeToServer(bytes);
|
|
81
132
|
case 3:
|
|
82
133
|
return v3.decodeToServer(bytes);
|
|
134
|
+
case 4:
|
|
135
|
+
return v4.decodeToServer(bytes);
|
|
83
136
|
default:
|
|
84
137
|
throw new Error(`Unknown version ${version}`);
|
|
85
138
|
}
|
|
@@ -92,15 +145,17 @@ export const CLIENT_PROTOCOL_TO_SERVER = createVersionedDataHandler<v3.ToServer>
|
|
|
92
145
|
return v2.encodeToServer(data as v2.ToServer);
|
|
93
146
|
case 3:
|
|
94
147
|
return v3.encodeToServer(data as v3.ToServer);
|
|
148
|
+
case 4:
|
|
149
|
+
return v4.encodeToServer(data as v4.ToServer);
|
|
95
150
|
default:
|
|
96
151
|
throw new Error(`Unknown version ${version}`);
|
|
97
152
|
}
|
|
98
153
|
},
|
|
99
|
-
deserializeConverters: () => [v1ToServerV2, v2ToServerV3],
|
|
100
|
-
serializeConverters: () => [v3ToServerV2, v2ToServerV1],
|
|
154
|
+
deserializeConverters: () => [v1ToServerV2, v2ToServerV3, v3ToServerV4],
|
|
155
|
+
serializeConverters: () => [v4ToServerV3, v3ToServerV2, v2ToServerV1],
|
|
101
156
|
});
|
|
102
157
|
|
|
103
|
-
export const CLIENT_PROTOCOL_TO_CLIENT = createVersionedDataHandler<
|
|
158
|
+
export const CLIENT_PROTOCOL_TO_CLIENT = createVersionedDataHandler<v4.ToClient>({
|
|
104
159
|
deserializeVersion: (bytes, version) => {
|
|
105
160
|
switch (version) {
|
|
106
161
|
case 1:
|
|
@@ -109,6 +164,8 @@ export const CLIENT_PROTOCOL_TO_CLIENT = createVersionedDataHandler<v3.ToClient>
|
|
|
109
164
|
return v2.decodeToClient(bytes);
|
|
110
165
|
case 3:
|
|
111
166
|
return v3.decodeToClient(bytes);
|
|
167
|
+
case 4:
|
|
168
|
+
return v4.decodeToClient(bytes);
|
|
112
169
|
default:
|
|
113
170
|
throw new Error(`Unknown version ${version}`);
|
|
114
171
|
}
|
|
@@ -121,16 +178,18 @@ export const CLIENT_PROTOCOL_TO_CLIENT = createVersionedDataHandler<v3.ToClient>
|
|
|
121
178
|
return v2.encodeToClient(data as v2.ToClient);
|
|
122
179
|
case 3:
|
|
123
180
|
return v3.encodeToClient(data as v3.ToClient);
|
|
181
|
+
case 4:
|
|
182
|
+
return v4.encodeToClient(data as v4.ToClient);
|
|
124
183
|
default:
|
|
125
184
|
throw new Error(`Unknown version ${version}`);
|
|
126
185
|
}
|
|
127
186
|
},
|
|
128
|
-
deserializeConverters: () => [v1ToV2, v2ToV3],
|
|
129
|
-
serializeConverters: () => [v3ToV2, v2ToV1],
|
|
187
|
+
deserializeConverters: () => [v1ToV2, v2ToV3, v3ToV4],
|
|
188
|
+
serializeConverters: () => [v4ToV3, v3ToV2, v2ToV1],
|
|
130
189
|
});
|
|
131
190
|
|
|
132
191
|
export const HTTP_ACTION_REQUEST_VERSIONED =
|
|
133
|
-
createVersionedDataHandler<
|
|
192
|
+
createVersionedDataHandler<v4.HttpActionRequest>({
|
|
134
193
|
deserializeVersion: (bytes, version) => {
|
|
135
194
|
switch (version) {
|
|
136
195
|
case 1:
|
|
@@ -139,6 +198,8 @@ export const HTTP_ACTION_REQUEST_VERSIONED =
|
|
|
139
198
|
return v2.decodeHttpActionRequest(bytes);
|
|
140
199
|
case 3:
|
|
141
200
|
return v3.decodeHttpActionRequest(bytes);
|
|
201
|
+
case 4:
|
|
202
|
+
return v4.decodeHttpActionRequest(bytes);
|
|
142
203
|
default:
|
|
143
204
|
throw new Error(`Unknown version ${version}`);
|
|
144
205
|
}
|
|
@@ -157,6 +218,10 @@ export const HTTP_ACTION_REQUEST_VERSIONED =
|
|
|
157
218
|
return v3.encodeHttpActionRequest(
|
|
158
219
|
data as v3.HttpActionRequest,
|
|
159
220
|
);
|
|
221
|
+
case 4:
|
|
222
|
+
return v4.encodeHttpActionRequest(
|
|
223
|
+
data as v4.HttpActionRequest,
|
|
224
|
+
);
|
|
160
225
|
default:
|
|
161
226
|
throw new Error(`Unknown version ${version}`);
|
|
162
227
|
}
|
|
@@ -166,7 +231,7 @@ export const HTTP_ACTION_REQUEST_VERSIONED =
|
|
|
166
231
|
});
|
|
167
232
|
|
|
168
233
|
export const HTTP_ACTION_RESPONSE_VERSIONED =
|
|
169
|
-
createVersionedDataHandler<
|
|
234
|
+
createVersionedDataHandler<v4.HttpActionResponse>({
|
|
170
235
|
deserializeVersion: (bytes, version) => {
|
|
171
236
|
switch (version) {
|
|
172
237
|
case 1:
|
|
@@ -175,6 +240,8 @@ export const HTTP_ACTION_RESPONSE_VERSIONED =
|
|
|
175
240
|
return v2.decodeHttpActionResponse(bytes);
|
|
176
241
|
case 3:
|
|
177
242
|
return v3.decodeHttpActionResponse(bytes);
|
|
243
|
+
case 4:
|
|
244
|
+
return v4.decodeHttpActionResponse(bytes);
|
|
178
245
|
default:
|
|
179
246
|
throw new Error(`Unknown version ${version}`);
|
|
180
247
|
}
|
|
@@ -193,6 +260,10 @@ export const HTTP_ACTION_RESPONSE_VERSIONED =
|
|
|
193
260
|
return v3.encodeHttpActionResponse(
|
|
194
261
|
data as v3.HttpActionResponse,
|
|
195
262
|
);
|
|
263
|
+
case 4:
|
|
264
|
+
return v4.encodeHttpActionResponse(
|
|
265
|
+
data as v4.HttpActionResponse,
|
|
266
|
+
);
|
|
196
267
|
default:
|
|
197
268
|
throw new Error(`Unknown version ${version}`);
|
|
198
269
|
}
|
|
@@ -202,11 +273,13 @@ export const HTTP_ACTION_RESPONSE_VERSIONED =
|
|
|
202
273
|
});
|
|
203
274
|
|
|
204
275
|
export const HTTP_QUEUE_SEND_REQUEST_VERSIONED =
|
|
205
|
-
createVersionedDataHandler<
|
|
276
|
+
createVersionedDataHandler<v4.HttpQueueSendRequest>({
|
|
206
277
|
deserializeVersion: (bytes, version) => {
|
|
207
278
|
switch (version) {
|
|
208
279
|
case 3:
|
|
209
280
|
return v3.decodeHttpQueueSendRequest(bytes);
|
|
281
|
+
case 4:
|
|
282
|
+
return v4.decodeHttpQueueSendRequest(bytes);
|
|
210
283
|
default:
|
|
211
284
|
throw new Error(
|
|
212
285
|
`HttpQueueSendRequest only exists in version 3+, got version ${version}`,
|
|
@@ -219,6 +292,10 @@ export const HTTP_QUEUE_SEND_REQUEST_VERSIONED =
|
|
|
219
292
|
return v3.encodeHttpQueueSendRequest(
|
|
220
293
|
data as v3.HttpQueueSendRequest,
|
|
221
294
|
);
|
|
295
|
+
case 4:
|
|
296
|
+
return v4.encodeHttpQueueSendRequest(
|
|
297
|
+
data as v4.HttpQueueSendRequest,
|
|
298
|
+
);
|
|
222
299
|
default:
|
|
223
300
|
throw new Error(
|
|
224
301
|
`HttpQueueSendRequest only exists in version 3+, got version ${version}`,
|
|
@@ -230,11 +307,13 @@ export const HTTP_QUEUE_SEND_REQUEST_VERSIONED =
|
|
|
230
307
|
});
|
|
231
308
|
|
|
232
309
|
export const HTTP_QUEUE_SEND_RESPONSE_VERSIONED =
|
|
233
|
-
createVersionedDataHandler<
|
|
310
|
+
createVersionedDataHandler<v4.HttpQueueSendResponse>({
|
|
234
311
|
deserializeVersion: (bytes, version) => {
|
|
235
312
|
switch (version) {
|
|
236
313
|
case 3:
|
|
237
314
|
return v3.decodeHttpQueueSendResponse(bytes);
|
|
315
|
+
case 4:
|
|
316
|
+
return v4.decodeHttpQueueSendResponse(bytes);
|
|
238
317
|
default:
|
|
239
318
|
throw new Error(
|
|
240
319
|
`HttpQueueSendResponse only exists in version 3+, got version ${version}`,
|
|
@@ -247,6 +326,10 @@ export const HTTP_QUEUE_SEND_RESPONSE_VERSIONED =
|
|
|
247
326
|
return v3.encodeHttpQueueSendResponse(
|
|
248
327
|
data as v3.HttpQueueSendResponse,
|
|
249
328
|
);
|
|
329
|
+
case 4:
|
|
330
|
+
return v4.encodeHttpQueueSendResponse(
|
|
331
|
+
data as v4.HttpQueueSendResponse,
|
|
332
|
+
);
|
|
250
333
|
default:
|
|
251
334
|
throw new Error(
|
|
252
335
|
`HttpQueueSendResponse only exists in version 3+, got version ${version}`,
|
|
@@ -258,7 +341,7 @@ export const HTTP_QUEUE_SEND_RESPONSE_VERSIONED =
|
|
|
258
341
|
});
|
|
259
342
|
|
|
260
343
|
export const HTTP_RESPONSE_ERROR_VERSIONED =
|
|
261
|
-
createVersionedDataHandler<
|
|
344
|
+
createVersionedDataHandler<v4.HttpResponseError>({
|
|
262
345
|
deserializeVersion: (bytes, version) => {
|
|
263
346
|
switch (version) {
|
|
264
347
|
case 1:
|
|
@@ -267,6 +350,8 @@ export const HTTP_RESPONSE_ERROR_VERSIONED =
|
|
|
267
350
|
return v2.decodeHttpResponseError(bytes);
|
|
268
351
|
case 3:
|
|
269
352
|
return v3.decodeHttpResponseError(bytes);
|
|
353
|
+
case 4:
|
|
354
|
+
return v4.decodeHttpResponseError(bytes);
|
|
270
355
|
default:
|
|
271
356
|
throw new Error(`Unknown version ${version}`);
|
|
272
357
|
}
|
|
@@ -285,16 +370,32 @@ export const HTTP_RESPONSE_ERROR_VERSIONED =
|
|
|
285
370
|
return v3.encodeHttpResponseError(
|
|
286
371
|
data as v3.HttpResponseError,
|
|
287
372
|
);
|
|
373
|
+
case 4:
|
|
374
|
+
return v4.encodeHttpResponseError(
|
|
375
|
+
data as v4.HttpResponseError,
|
|
376
|
+
);
|
|
288
377
|
default:
|
|
289
378
|
throw new Error(`Unknown version ${version}`);
|
|
290
379
|
}
|
|
291
380
|
},
|
|
292
|
-
deserializeConverters: () => [
|
|
293
|
-
|
|
381
|
+
deserializeConverters: () => [
|
|
382
|
+
(data: v1.HttpResponseError) =>
|
|
383
|
+
data as unknown as v2.HttpResponseError,
|
|
384
|
+
(data: v2.HttpResponseError) =>
|
|
385
|
+
data as unknown as v3.HttpResponseError,
|
|
386
|
+
v3HttpResponseErrorToV4,
|
|
387
|
+
],
|
|
388
|
+
serializeConverters: () => [
|
|
389
|
+
v4HttpResponseErrorToV3,
|
|
390
|
+
(data: v3.HttpResponseError) =>
|
|
391
|
+
data as unknown as v2.HttpResponseError,
|
|
392
|
+
(data: v2.HttpResponseError) =>
|
|
393
|
+
data as unknown as v1.HttpResponseError,
|
|
394
|
+
],
|
|
294
395
|
});
|
|
295
396
|
|
|
296
397
|
export const HTTP_RESOLVE_RESPONSE_VERSIONED =
|
|
297
|
-
createVersionedDataHandler<
|
|
398
|
+
createVersionedDataHandler<v4.HttpResolveResponse>({
|
|
298
399
|
deserializeVersion: (bytes, version) => {
|
|
299
400
|
switch (version) {
|
|
300
401
|
case 1:
|
|
@@ -303,6 +404,8 @@ export const HTTP_RESOLVE_RESPONSE_VERSIONED =
|
|
|
303
404
|
return v2.decodeHttpResolveResponse(bytes);
|
|
304
405
|
case 3:
|
|
305
406
|
return v3.decodeHttpResolveResponse(bytes);
|
|
407
|
+
case 4:
|
|
408
|
+
return v4.decodeHttpResolveResponse(bytes);
|
|
306
409
|
default:
|
|
307
410
|
throw new Error(`Unknown version ${version}`);
|
|
308
411
|
}
|
|
@@ -321,6 +424,10 @@ export const HTTP_RESOLVE_RESPONSE_VERSIONED =
|
|
|
321
424
|
return v3.encodeHttpResolveResponse(
|
|
322
425
|
data as v3.HttpResolveResponse,
|
|
323
426
|
);
|
|
427
|
+
case 4:
|
|
428
|
+
return v4.encodeHttpResolveResponse(
|
|
429
|
+
data as v4.HttpResolveResponse,
|
|
430
|
+
);
|
|
324
431
|
default:
|
|
325
432
|
throw new Error(`Unknown version ${version}`);
|
|
326
433
|
}
|
|
@@ -3,6 +3,11 @@ import { z } from "zod/v4";
|
|
|
3
3
|
// Helper schemas
|
|
4
4
|
const UintSchema = z.bigint();
|
|
5
5
|
const OptionalUintSchema = UintSchema.nullable();
|
|
6
|
+
const ActorSpecifierSchema = z.object({
|
|
7
|
+
actorId: z.string(),
|
|
8
|
+
generation: z.union([z.number(), z.bigint()]),
|
|
9
|
+
key: z.string().optional(),
|
|
10
|
+
});
|
|
6
11
|
|
|
7
12
|
// MARK: Message To Client
|
|
8
13
|
export const InitSchema = z.object({
|
|
@@ -17,6 +22,7 @@ export const ErrorSchema = z.object({
|
|
|
17
22
|
message: z.string(),
|
|
18
23
|
metadata: z.unknown().optional(),
|
|
19
24
|
actionId: OptionalUintSchema,
|
|
25
|
+
actor: ActorSpecifierSchema.optional(),
|
|
20
26
|
});
|
|
21
27
|
export type Error = z.infer<typeof ErrorSchema>;
|
|
22
28
|
|
|
@@ -105,6 +111,7 @@ export const HttpResponseErrorSchema = z.object({
|
|
|
105
111
|
code: z.string(),
|
|
106
112
|
message: z.string(),
|
|
107
113
|
metadata: z.unknown().optional(),
|
|
114
|
+
actor: ActorSpecifierSchema.optional(),
|
|
108
115
|
});
|
|
109
116
|
export type HttpResponseError = z.infer<typeof HttpResponseErrorSchema>;
|
|
110
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./bare/generated/client-protocol/
|
|
1
|
+
export * from "./bare/generated/client-protocol/v4";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { BRIDGE_RIVET_ERROR_PREFIX } from "@/actor/errors";
|
|
2
3
|
import {
|
|
3
4
|
type JsNativeDatabaseLike,
|
|
4
5
|
wrapJsNativeDatabase,
|
|
@@ -64,6 +65,14 @@ class FakeNativeDatabase implements JsNativeDatabaseLike {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
rejectNext(error: unknown) {
|
|
69
|
+
const pending = this.#pending.shift();
|
|
70
|
+
if (!pending) {
|
|
71
|
+
throw new Error("no pending native execute call");
|
|
72
|
+
}
|
|
73
|
+
pending.reject(error);
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
async #startExecute(
|
|
68
77
|
sql: string,
|
|
69
78
|
params: NativeParams,
|
|
@@ -173,4 +182,30 @@ describe("wrapJsNativeDatabase", () => {
|
|
|
173
182
|
"Database is closed",
|
|
174
183
|
);
|
|
175
184
|
});
|
|
185
|
+
|
|
186
|
+
test("decodes sanitized native bridge errors without logging", async () => {
|
|
187
|
+
const native = new FakeNativeDatabase();
|
|
188
|
+
const db = wrapJsNativeDatabase(native);
|
|
189
|
+
const query = db.execute("SELECT broken", [1, "two"]);
|
|
190
|
+
const bridgeReason = `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
191
|
+
group: "rivetkit",
|
|
192
|
+
code: "internal_error",
|
|
193
|
+
message: "An internal error occurred",
|
|
194
|
+
statusCode: 500,
|
|
195
|
+
})}`;
|
|
196
|
+
|
|
197
|
+
native.rejectNext(new Error(bridgeReason));
|
|
198
|
+
|
|
199
|
+
await expect(query).rejects.toMatchObject({
|
|
200
|
+
name: "RivetError",
|
|
201
|
+
group: "rivetkit",
|
|
202
|
+
code: "internal_error",
|
|
203
|
+
message: "An internal error occurred",
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
await query.catch((error) => {
|
|
207
|
+
expect(error.stack).toContain("decodeBridgeRivetError");
|
|
208
|
+
expect(error.stack).toContain("enrichNativeDatabaseError");
|
|
209
|
+
});
|
|
210
|
+
});
|
|
176
211
|
});
|
|
@@ -92,12 +92,16 @@ function enrichNativeDatabaseError(
|
|
|
92
92
|
database: JsNativeDatabaseLike,
|
|
93
93
|
error: unknown,
|
|
94
94
|
): never {
|
|
95
|
-
const
|
|
95
|
+
const bridgeReason =
|
|
96
96
|
typeof error === "string"
|
|
97
|
-
?
|
|
97
|
+
? error
|
|
98
98
|
: error instanceof Error
|
|
99
|
-
?
|
|
100
|
-
|
|
99
|
+
? error.message
|
|
100
|
+
: undefined;
|
|
101
|
+
const bridged =
|
|
102
|
+
bridgeReason === undefined
|
|
103
|
+
? undefined
|
|
104
|
+
: decodeBridgeRivetError(bridgeReason);
|
|
101
105
|
if (bridged) {
|
|
102
106
|
throw bridged;
|
|
103
107
|
}
|