rivetkit 2.3.0-rc.5 → 2.3.0-rc.6

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 (113) hide show
  1. package/dist/browser/client.d.ts +21 -18
  2. package/dist/browser/client.js +735 -170
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +4 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -74
  9. package/dist/tsup/actor/errors.d.ts +1 -74
  10. package/dist/tsup/actor/errors.js +3 -1
  11. package/dist/tsup/agent-os/index.cjs +1 -1
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +18 -7
  14. package/dist/tsup/agent-os/index.d.ts +18 -7
  15. package/dist/tsup/agent-os/index.js +1 -1
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2G64KSZQ.cjs} +10 -10
  18. package/dist/tsup/{chunk-2GANBXVP.cjs.map → chunk-2G64KSZQ.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-N2DQSJIW.js → chunk-6S25NVAP.js} +13 -46
  20. package/dist/tsup/chunk-6S25NVAP.js.map +1 -0
  21. package/dist/tsup/{chunk-NATOT3ET.js → chunk-CAF6JDJE.js} +4 -4
  22. package/dist/tsup/{chunk-PGYEMIOE.js → chunk-DEO7MMWQ.js} +2 -2
  23. package/dist/tsup/{chunk-SULB574D.js → chunk-EMO6E3PJ.js} +3 -3
  24. package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ENK7C66G.cjs} +838 -236
  25. package/dist/tsup/chunk-ENK7C66G.cjs.map +1 -0
  26. package/dist/tsup/{chunk-JY73X7VU.js → chunk-FLODVLYW.js} +690 -88
  27. package/dist/tsup/chunk-FLODVLYW.js.map +1 -0
  28. package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-HTR4YLNT.cjs} +4 -4
  29. package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-HTR4YLNT.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-LELRJK66.cjs → chunk-JALSAX7Z.cjs} +3 -3
  31. package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-JALSAX7Z.cjs.map} +1 -1
  32. package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-K5BA2LEO.cjs} +19 -52
  33. package/dist/tsup/chunk-K5BA2LEO.cjs.map +1 -0
  34. package/dist/tsup/{chunk-K34B3OVG.js → chunk-KIWH5H3K.js} +30 -9
  35. package/dist/tsup/chunk-KIWH5H3K.js.map +1 -0
  36. package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-LIXXFXVR.cjs} +5 -5
  37. package/dist/tsup/{chunk-NW2J4SOL.cjs.map → chunk-LIXXFXVR.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-HR547GVH.cjs → chunk-M5C7YNI5.cjs} +8 -8
  39. package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-M5C7YNI5.cjs.map} +1 -1
  40. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-QAZLM4WT.cjs} +31 -10
  41. package/dist/tsup/chunk-QAZLM4WT.cjs.map +1 -0
  42. package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-RTC2AZGB.js} +2 -2
  43. package/dist/tsup/{chunk-UXTP4EBU.js → chunk-ZI5QJMKO.js} +2 -2
  44. package/dist/tsup/client/mod.cjs +7 -7
  45. package/dist/tsup/client/mod.d.cts +3 -4
  46. package/dist/tsup/client/mod.d.ts +3 -4
  47. package/dist/tsup/client/mod.js +6 -6
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{config-CvQUtDp9.d.ts → config-0Ta55UV0.d.ts} +10 -9
  53. package/dist/tsup/{config-C-a9vrke.d.cts → config-Ca8dN4cS.d.cts} +10 -9
  54. package/dist/tsup/{context-A7R0bsZL.d.ts → context-B_IWbWne.d.ts} +1 -1
  55. package/dist/tsup/{context-CA3r-pf2.d.cts → context-CUrQ9MHc.d.cts} +1 -1
  56. package/dist/tsup/inspector/mod.cjs +6 -6
  57. package/dist/tsup/inspector/mod.js +5 -5
  58. package/dist/tsup/mod.cjs +252 -207
  59. package/dist/tsup/mod.cjs.map +1 -1
  60. package/dist/tsup/mod.d.cts +4 -5
  61. package/dist/tsup/mod.d.ts +4 -5
  62. package/dist/tsup/mod.js +183 -138
  63. package/dist/tsup/mod.js.map +1 -1
  64. package/dist/tsup/test/mod.cjs +10 -10
  65. package/dist/tsup/test/mod.d.cts +2 -3
  66. package/dist/tsup/test/mod.d.ts +2 -3
  67. package/dist/tsup/test/mod.js +6 -6
  68. package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
  69. package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
  70. package/dist/tsup/utils.cjs +3 -3
  71. package/dist/tsup/utils.d.cts +1 -1
  72. package/dist/tsup/utils.d.ts +1 -1
  73. package/dist/tsup/utils.js +2 -2
  74. package/dist/tsup/workflow/mod.cjs +9 -9
  75. package/dist/tsup/workflow/mod.d.cts +4 -5
  76. package/dist/tsup/workflow/mod.d.ts +4 -5
  77. package/dist/tsup/workflow/mod.js +5 -5
  78. package/package.json +8 -8
  79. package/src/actor/errors.ts +53 -7
  80. package/src/client/actor-conn.ts +52 -29
  81. package/src/client/actor-handle.ts +57 -23
  82. package/src/client/errors.ts +2 -1
  83. package/src/client/raw-utils.ts +2 -4
  84. package/src/client/utils.ts +32 -3
  85. package/src/common/actor-router-consts.ts +4 -0
  86. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  87. package/src/common/client-protocol-versioned.ts +125 -18
  88. package/src/common/client-protocol-zod.ts +7 -0
  89. package/src/common/client-protocol.ts +1 -1
  90. package/src/common/database/native-database.test.ts +35 -0
  91. package/src/common/database/native-database.ts +8 -4
  92. package/src/common/router.ts +38 -8
  93. package/src/common/utils.ts +9 -52
  94. package/src/drivers/engine/actor-driver.ts +18 -17
  95. package/src/registry/config/index.ts +3 -5
  96. package/src/registry/index.ts +156 -19
  97. package/src/registry/napi-runtime.ts +44 -6
  98. package/src/registry/native.ts +5 -152
  99. package/src/registry/runtime.ts +16 -5
  100. package/src/registry/wasm-runtime.ts +22 -2
  101. package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
  102. package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
  103. package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
  104. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  105. package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
  106. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  107. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  108. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  109. /package/dist/tsup/{chunk-NATOT3ET.js.map → chunk-CAF6JDJE.js.map} +0 -0
  110. /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-DEO7MMWQ.js.map} +0 -0
  111. /package/dist/tsup/{chunk-SULB574D.js.map → chunk-EMO6E3PJ.js.map} +0 -0
  112. /package/dist/tsup/{chunk-LDTT6WKJ.js.map → chunk-RTC2AZGB.js.map} +0 -0
  113. /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-ZI5QJMKO.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 = 3;
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
- // Converter from v3 to v2: No changes needed for ToClient
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 (ToServer is identical across v1, v2, and v3)
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
- export const CLIENT_PROTOCOL_TO_SERVER = createVersionedDataHandler<v3.ToServer>({
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<v3.ToClient>({
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<v3.HttpActionRequest>({
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<v3.HttpActionResponse>({
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<v3.HttpQueueSendRequest>({
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<v3.HttpQueueSendResponse>({
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<v3.HttpResponseError>({
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
- serializeConverters: () => [],
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<v3.HttpResolveResponse>({
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/v3";
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 bridged =
95
+ const bridgeReason =
96
96
  typeof error === "string"
97
- ? decodeBridgeRivetError(error)
97
+ ? error
98
98
  : error instanceof Error
99
- ? decodeBridgeRivetError(error.message)
100
- : undefined;
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
  }
@@ -1,5 +1,11 @@
1
1
  import type { Context as HonoContext, Next } from "hono";
2
2
  import * as envoyProtocol from "@rivetkit/engine-envoy-protocol";
3
+ import type { ActorSpecifier } from "@/actor/errors";
4
+ import {
5
+ HEADER_ACTOR_GENERATION,
6
+ HEADER_ACTOR_ID,
7
+ HEADER_ACTOR_KEY,
8
+ } from "@/common/actor-router-consts";
3
9
  import type { Encoding } from "@/common/encoding";
4
10
  import {
5
11
  getRequestEncoding,
@@ -61,16 +67,22 @@ export function handleRouteNotFound(c: HonoContext) {
61
67
  export function handleRouteError(error: unknown, c: HonoContext) {
62
68
  const exposeInternalError = getRequestExposeInternalError(c.req.raw);
63
69
 
64
- const { statusCode, group, code, message, metadata } = deconstructError(
70
+ const { statusCode, group, code, message, metadata, actor } = deconstructError(
65
71
  error,
66
- logger(),
67
- {
68
- method: c.req.method,
69
- path: c.req.path,
70
- },
71
72
  exposeInternalError,
72
73
  );
73
74
 
75
+ if (actor) {
76
+ logger().warn({
77
+ msg: "actor http error response",
78
+ actorId: actor.actorId,
79
+ generation: actor.generation,
80
+ actorKey: actor.key,
81
+ group,
82
+ code,
83
+ });
84
+ }
85
+
74
86
  let encoding: Encoding;
75
87
  try {
76
88
  encoding = getRequestEncoding(c.req);
@@ -78,7 +90,7 @@ export function handleRouteError(error: unknown, c: HonoContext) {
78
90
  encoding = "json";
79
91
  }
80
92
 
81
- const errorData = { group, code, message, metadata };
93
+ const errorData = { group, code, message, metadata, actor };
82
94
  const output = serializeWithEncoding(
83
95
  encoding,
84
96
  errorData,
@@ -91,6 +103,7 @@ export function handleRouteError(error: unknown, c: HonoContext) {
91
103
  code: value.code,
92
104
  message: value.message,
93
105
  metadata: value.metadata,
106
+ actor: value.actor,
94
107
  }),
95
108
  // BARE/CBOR: metadata needs to be CBOR-encoded to ArrayBuffer
96
109
  (value): protocol.HttpResponseError => ({
@@ -100,11 +113,28 @@ export function handleRouteError(error: unknown, c: HonoContext) {
100
113
  metadata: value.metadata
101
114
  ? bufferToArrayBuffer(encodeCborCompat(value.metadata))
102
115
  : null,
116
+ actor: value.actor
117
+ ? {
118
+ actorId: value.actor.actorId,
119
+ generation: BigInt(value.actor.generation),
120
+ key: value.actor.key ?? null,
121
+ }
122
+ : null,
103
123
  }),
104
124
  );
105
125
 
126
+ const headers = actor ? actorResponseHeaders(actor) : undefined;
127
+
106
128
  // TODO: Remove any
107
- return c.body(output as any, { status: statusCode });
129
+ return c.body(output as any, { status: statusCode, headers });
130
+ }
131
+
132
+ function actorResponseHeaders(actor: ActorSpecifier): Record<string, string> {
133
+ return {
134
+ [HEADER_ACTOR_ID]: actor.actorId,
135
+ [HEADER_ACTOR_GENERATION]: String(actor.generation),
136
+ ...(actor.key ? { [HEADER_ACTOR_KEY]: actor.key } : {}),
137
+ };
108
138
  }
109
139
 
110
140
  export type MetadataEnvoyKind =
@@ -1,9 +1,7 @@
1
1
  import type { Next } from "hono";
2
2
  import type { ContentfulStatusCode } from "hono/utils/http-status";
3
3
  import * as errors from "@/actor/errors";
4
- import { EXTRA_ERROR_LOG } from "@/utils";
5
4
  import { getLogErrorStack } from "@/utils/env-vars";
6
- import type { Logger } from "./log";
7
5
 
8
6
  export function assertUnreachable(x: never): never {
9
7
  throw new Error(`Unreachable case: ${x}`);
@@ -195,6 +193,7 @@ export interface DeconstructedError {
195
193
  code: string;
196
194
  message: string;
197
195
  metadata?: unknown;
196
+ actor?: errors.ActorSpecifier;
198
197
  }
199
198
 
200
199
  function isCanonicalStructuredRivetError(
@@ -221,19 +220,16 @@ function isCanonicalStructuredRivetError(
221
220
  */
222
221
  export function deconstructError(
223
222
  error: unknown,
224
- logger: Logger,
225
- extraLog: Record<string, unknown>,
226
223
  exposeInternalError = false,
227
224
  ): DeconstructedError {
228
225
  // Build response error information. Only return errors if flagged as public in order to prevent leaking internal behavior.
229
- //
230
- // We log the error here instead of after generating the code & message because we need to log the original error, not the masked internal error.
231
226
  let statusCode: ContentfulStatusCode;
232
227
  let public_: boolean;
233
228
  let group: string;
234
229
  let code: string;
235
230
  let message: string;
236
231
  let metadata: unknown;
232
+ let actor: errors.ActorSpecifier | undefined;
237
233
  // Structured errors from core or from pre-built `RivetError` instances are canonical.
238
234
  // Only unstructured errors go through the classifier below.
239
235
  if (isCanonicalStructuredRivetError(error)) {
@@ -249,15 +245,7 @@ export function deconstructError(
249
245
  code = error.code;
250
246
  message = error.message;
251
247
  metadata = error.metadata;
252
-
253
- logger.info({
254
- msg: "structured error passthrough",
255
- group,
256
- code,
257
- message,
258
- ...EXTRA_ERROR_LOG,
259
- ...extraLog,
260
- });
248
+ actor = error.actor;
261
249
  } else if (errors.ActorError.isActorError(error) && error.public) {
262
250
  // Check if error has statusCode (could be ActorError instance or DeconstructedError)
263
251
  statusCode = (
@@ -268,15 +256,7 @@ export function deconstructError(
268
256
  code = error.code;
269
257
  message = getErrorMessage(error);
270
258
  metadata = error.metadata;
271
-
272
- logger.info({
273
- msg: "public error",
274
- group,
275
- code,
276
- message,
277
- ...EXTRA_ERROR_LOG,
278
- ...extraLog,
279
- });
259
+ actor = error.actor;
280
260
  } else if (exposeInternalError) {
281
261
  if (errors.ActorError.isActorError(error)) {
282
262
  statusCode = 500;
@@ -285,32 +265,13 @@ export function deconstructError(
285
265
  code = error.code;
286
266
  message = getErrorMessage(error);
287
267
  metadata = error.metadata;
288
-
289
- logger.info({
290
- msg: "internal error",
291
- group,
292
- code,
293
- message,
294
- stack: (error as Error)?.stack,
295
- ...EXTRA_ERROR_LOG,
296
- ...extraLog,
297
- });
268
+ actor = error.actor;
298
269
  } else {
299
270
  statusCode = 500;
300
271
  public_ = false;
301
272
  group = "rivetkit";
302
273
  code = errors.INTERNAL_ERROR_CODE;
303
274
  message = getErrorMessage(error);
304
-
305
- logger.info({
306
- msg: "internal error",
307
- group,
308
- code,
309
- message,
310
- stack: (error as Error)?.stack,
311
- ...EXTRA_ERROR_LOG,
312
- ...extraLog,
313
- });
314
275
  }
315
276
  } else {
316
277
  statusCode = 500;
@@ -318,17 +279,12 @@ export function deconstructError(
318
279
  group = "rivetkit";
319
280
  code = errors.INTERNAL_ERROR_CODE;
320
281
  message = errors.INTERNAL_ERROR_DESCRIPTION;
282
+ if (errors.ActorError.isActorError(error)) {
283
+ actor = error.actor;
284
+ }
321
285
  metadata = {
322
286
  //url: `https://hub.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
323
287
  } satisfies errors.InternalErrorMetadata;
324
-
325
- logger.warn({
326
- msg: "internal error",
327
- error: getErrorMessage(error),
328
- stack: (error as Error)?.stack,
329
- ...EXTRA_ERROR_LOG,
330
- ...extraLog,
331
- });
332
288
  }
333
289
 
334
290
  return {
@@ -339,6 +295,7 @@ export function deconstructError(
339
295
  code,
340
296
  message,
341
297
  metadata,
298
+ actor,
342
299
  };
343
300
  }
344
301