rivetkit 2.3.0-rc.9 → 2.3.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 (222) hide show
  1. package/dist/browser/client.d.ts +498 -62
  2. package/dist/browser/client.js +227 -171
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +50 -20
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +2 -2
  7. package/dist/tsup/actor/errors.d.cts +1 -1
  8. package/dist/tsup/actor/errors.d.ts +1 -1
  9. package/dist/tsup/actor/errors.js +1 -1
  10. package/dist/tsup/agent-os/index.cjs +2163 -2087
  11. package/dist/tsup/agent-os/index.cjs.map +1 -1
  12. package/dist/tsup/agent-os/index.d.cts +496 -69
  13. package/dist/tsup/agent-os/index.d.ts +496 -69
  14. package/dist/tsup/agent-os/index.js +2163 -2087
  15. package/dist/tsup/agent-os/index.js.map +1 -1
  16. package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
  17. package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
  18. package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
  19. package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
  20. package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
  21. package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
  22. package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
  23. package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
  24. package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
  25. package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
  27. package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
  28. package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
  29. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
  30. package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
  31. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
  32. package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
  33. package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
  34. package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
  35. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
  36. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  37. package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
  38. package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
  39. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  40. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  41. package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
  42. package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
  43. package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
  44. package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
  45. package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
  46. package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
  47. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
  48. package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
  49. package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
  50. package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
  51. package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
  52. package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
  53. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
  54. package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
  55. package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
  56. package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
  57. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
  58. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
  59. package/dist/tsup/client/mod.cjs +9 -9
  60. package/dist/tsup/client/mod.d.cts +5 -5
  61. package/dist/tsup/client/mod.d.ts +5 -5
  62. package/dist/tsup/client/mod.js +8 -8
  63. package/dist/tsup/common/log.cjs +3 -3
  64. package/dist/tsup/common/log.js +2 -2
  65. package/dist/tsup/common/websocket.cjs +4 -4
  66. package/dist/tsup/common/websocket.js +3 -3
  67. package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
  68. package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
  69. package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
  70. package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
  71. package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
  72. package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
  73. package/dist/tsup/db/drizzle.cjs +3 -3
  74. package/dist/tsup/db/drizzle.d.cts +1 -1
  75. package/dist/tsup/db/drizzle.d.ts +1 -1
  76. package/dist/tsup/db/drizzle.js +1 -1
  77. package/dist/tsup/db/mod.cjs +2 -2
  78. package/dist/tsup/db/mod.d.cts +2 -2
  79. package/dist/tsup/db/mod.d.ts +2 -2
  80. package/dist/tsup/db/mod.js +1 -1
  81. package/dist/tsup/dynamic/mod.cjs +24 -0
  82. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  83. package/dist/tsup/dynamic/mod.d.cts +37 -0
  84. package/dist/tsup/dynamic/mod.d.ts +37 -0
  85. package/dist/tsup/dynamic/mod.js +24 -0
  86. package/dist/tsup/dynamic/mod.js.map +1 -0
  87. package/dist/tsup/inspector/mod.cjs +6 -6
  88. package/dist/tsup/inspector/mod.js +5 -5
  89. package/dist/tsup/inspector-tab/mod.cjs +173 -0
  90. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  91. package/dist/tsup/inspector-tab/mod.d.cts +250 -0
  92. package/dist/tsup/inspector-tab/mod.d.ts +250 -0
  93. package/dist/tsup/inspector-tab/mod.js +173 -0
  94. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  95. package/dist/tsup/mod.cjs +730 -336
  96. package/dist/tsup/mod.cjs.map +1 -1
  97. package/dist/tsup/mod.d.cts +5 -5
  98. package/dist/tsup/mod.d.ts +5 -5
  99. package/dist/tsup/mod.js +633 -239
  100. package/dist/tsup/mod.js.map +1 -1
  101. package/dist/tsup/test/mod.cjs +21 -18
  102. package/dist/tsup/test/mod.cjs.map +1 -1
  103. package/dist/tsup/test/mod.d.cts +4 -4
  104. package/dist/tsup/test/mod.d.ts +4 -4
  105. package/dist/tsup/test/mod.js +18 -15
  106. package/dist/tsup/test/mod.js.map +1 -1
  107. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
  108. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
  109. package/dist/tsup/utils.cjs +3 -3
  110. package/dist/tsup/utils.d.cts +1 -1
  111. package/dist/tsup/utils.d.ts +1 -1
  112. package/dist/tsup/utils.js +2 -2
  113. package/dist/tsup/workflow/mod.cjs +307 -282
  114. package/dist/tsup/workflow/mod.cjs.map +1 -1
  115. package/dist/tsup/workflow/mod.d.cts +6 -6
  116. package/dist/tsup/workflow/mod.d.ts +6 -6
  117. package/dist/tsup/workflow/mod.js +501 -476
  118. package/dist/tsup/workflow/mod.js.map +1 -1
  119. package/package.json +32 -11
  120. package/src/actor/config.ts +159 -51
  121. package/src/actor/contexts/index.ts +7 -2
  122. package/src/actor/definition.ts +17 -19
  123. package/src/actor/driver.ts +3 -3
  124. package/src/actor/errors.ts +9 -3
  125. package/src/actor/instance/mod.ts +26 -34
  126. package/src/actor/keys.ts +1 -1
  127. package/src/actor/mod.ts +22 -20
  128. package/src/actor/schema.ts +2 -2
  129. package/src/agent-os/actor/index.ts +38 -18
  130. package/src/agent-os/actor/preview.ts +1 -2
  131. package/src/agent-os/actor/session.ts +2 -2
  132. package/src/agent-os/config.ts +1 -1
  133. package/src/agent-os/fs/database-vfs.ts +1 -1
  134. package/src/agent-os/index.ts +16 -15
  135. package/src/client/actor-common.ts +87 -54
  136. package/src/client/actor-conn.ts +8 -36
  137. package/src/client/actor-handle.ts +69 -51
  138. package/src/client/actor-query.ts +5 -5
  139. package/src/client/errors.ts +1 -1
  140. package/src/client/lifecycle-errors.ts +2 -4
  141. package/src/client/query.ts +1 -1
  142. package/src/client/queue.ts +8 -3
  143. package/src/client/raw-utils.ts +8 -6
  144. package/src/client/resolve-gateway-target.ts +1 -1
  145. package/src/client/utils.ts +2 -7
  146. package/src/common/actor-websocket.ts +3 -1
  147. package/src/common/bare/actor-persist/v1.ts +205 -163
  148. package/src/common/bare/actor-persist/v2.ts +265 -213
  149. package/src/common/bare/actor-persist/v3.ts +176 -172
  150. package/src/common/bare/actor-persist/v4.ts +254 -253
  151. package/src/common/bare/transport/v1.ts +659 -543
  152. package/src/common/client-protocol-versioned.ts +66 -64
  153. package/src/common/database/config.ts +2 -8
  154. package/src/common/database/native-database.ts +1 -1
  155. package/src/common/database/shared.ts +1 -0
  156. package/src/common/encoding.ts +250 -16
  157. package/src/common/engine.ts +28 -1
  158. package/src/common/eventsource.ts +1 -1
  159. package/src/common/inline-websocket-adapter.ts +14 -13
  160. package/src/common/log.ts +1 -0
  161. package/src/common/router.ts +13 -17
  162. package/src/common/utils.ts +1 -150
  163. package/src/common/websocket-interface.ts +1 -1
  164. package/src/db/mod.ts +1 -1
  165. package/src/devtools-loader/index.ts +4 -7
  166. package/src/devtools-loader/serve-devtools.ts +26 -0
  167. package/src/drivers/engine/actor-driver.ts +58 -56
  168. package/src/dynamic/instance.ts +32 -0
  169. package/src/dynamic/internal.ts +50 -0
  170. package/src/dynamic/isolate-runtime.ts +66 -0
  171. package/src/dynamic/mod.ts +32 -0
  172. package/src/engine-client/actor-http-client.ts +3 -3
  173. package/src/engine-client/actor-websocket-client.ts +6 -5
  174. package/src/engine-client/api-endpoints.ts +51 -2
  175. package/src/engine-client/api-utils.ts +2 -2
  176. package/src/engine-client/driver.ts +1 -1
  177. package/src/engine-client/mod.ts +6 -3
  178. package/src/engine-client/ws-proxy.ts +9 -4
  179. package/src/inspector/client.browser.ts +5 -11
  180. package/src/inspector/mod.ts +1 -3
  181. package/src/inspector-tab/mod.ts +315 -0
  182. package/src/registry/config/envoy.ts +1 -2
  183. package/src/registry/config/index.ts +40 -16
  184. package/src/registry/index.ts +154 -74
  185. package/src/registry/napi-runtime.ts +13 -2
  186. package/src/registry/native-validation.ts +10 -12
  187. package/src/registry/native.ts +367 -181
  188. package/src/registry/process-metrics.ts +250 -0
  189. package/src/registry/runtime.ts +41 -1
  190. package/src/registry/wasm-runtime.ts +18 -2
  191. package/src/registry/write-through-proxy.ts +40 -0
  192. package/src/serde.ts +2 -2
  193. package/src/serverless/configure.ts +18 -7
  194. package/src/test/mod.ts +11 -8
  195. package/src/utils/endpoint-parser.ts +1 -1
  196. package/src/utils/env-vars.ts +6 -0
  197. package/src/utils/router.ts +1 -1
  198. package/src/utils/serve.ts +4 -5
  199. package/src/utils.ts +1 -2
  200. package/src/workflow/context.ts +61 -33
  201. package/src/workflow/driver.ts +4 -6
  202. package/src/workflow/inspector.ts +4 -3
  203. package/src/workflow/mod.ts +15 -17
  204. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  205. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  206. package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
  207. package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
  208. package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
  209. package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
  210. package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
  211. package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
  212. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  213. package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
  214. package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
  215. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  216. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  217. package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
  218. package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
  219. package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
  220. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  221. package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
  222. /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
@@ -1,6 +1,5 @@
1
1
  import type { AnyActorDefinition } from "@/actor/definition";
2
2
  import type { ActorSpecifier } from "@/actor/errors";
3
- import type { Encoding } from "@/common/encoding";
4
3
  import {
5
4
  HEADER_CONN_PARAMS,
6
5
  HEADER_ENCODING,
@@ -12,7 +11,6 @@ import {
12
11
  HTTP_ACTION_RESPONSE_VERSIONED,
13
12
  HTTP_RESPONSE_ERROR_VERSIONED,
14
13
  } from "@/common/client-protocol-versioned";
15
- import { AsyncMutex } from "@/common/database/shared";
16
14
  import {
17
15
  type HttpActionRequest as HttpActionRequestJson,
18
16
  HttpActionRequestSchema,
@@ -21,16 +19,22 @@ import {
21
19
  type HttpResponseError as HttpResponseErrorJson,
22
20
  HttpResponseErrorSchema,
23
21
  } from "@/common/client-protocol-zod";
22
+ import { AsyncMutex } from "@/common/database/shared";
23
+ import type { Encoding, JsonCompatValue } from "@/common/encoding";
24
24
  import { deconstructError } from "@/common/utils";
25
25
  import type { EngineControlClient } from "@/engine-client/driver";
26
- import { decodeCborCompat, deserializeWithEncoding, encodeCborCompat } from "@/serde";
26
+ import {
27
+ decodeCborCompat,
28
+ deserializeWithEncoding,
29
+ encodeCborCompat,
30
+ } from "@/serde";
27
31
  import { bufferToArrayBuffer } from "@/utils";
28
32
  import type {
29
33
  ActorActionOptions,
30
34
  ActorConnectOptions,
31
35
  ActorDefinitionActions,
32
- ActorFetchInit,
33
36
  ActorDefinitionQueueSend,
37
+ ActorFetchInit,
34
38
  ActorGatewayOptions,
35
39
  ActorWebSocketOptions,
36
40
  } from "./actor-common";
@@ -147,7 +151,8 @@ export class ActorHandleRaw {
147
151
  useQueryTarget,
148
152
  gatewayOptions,
149
153
  );
150
- actorId = "directId" in target ? target.directId : undefined;
154
+ actorId =
155
+ "directId" in target ? target.directId : undefined;
151
156
 
152
157
  return await createQueueSender({
153
158
  encoding: this.#encoding,
@@ -161,10 +166,8 @@ export class ActorHandleRaw {
161
166
  },
162
167
  }).send(name, body, options as any);
163
168
  } catch (err) {
164
- const { group, code, message, metadata, actor } = deconstructError(
165
- err,
166
- true,
167
- );
169
+ const { group, code, message, metadata, actor } =
170
+ deconstructError(err, true);
168
171
 
169
172
  if (
170
173
  this.#shouldRetryQueueDispatchOverload(
@@ -207,19 +210,25 @@ export class ActorHandleRaw {
207
210
  continue;
208
211
  }
209
212
 
210
- const invalidated = this.#invalidateResolvedActorId(group, code);
213
+ const invalidated = this.#invalidateResolvedActorId(
214
+ group,
215
+ code,
216
+ );
211
217
  if (invalidated && attempt < maxAttempts - 1) {
212
218
  useQueryTarget =
213
- (code === "starting" ||
214
- code === "stopping" ||
215
- code.startsWith("destroyed_"));
219
+ code === "starting" ||
220
+ code === "stopping" ||
221
+ code.startsWith("destroyed_");
216
222
  if (useQueryTarget) {
217
223
  await this.#waitForRetryWindow();
218
224
  }
219
225
  continue;
220
226
  }
221
227
 
222
- throw new ActorError(group, code, message, { metadata, actor });
228
+ throw new ActorError(group, code, message, {
229
+ metadata,
230
+ actor,
231
+ });
223
232
  }
224
233
  }
225
234
 
@@ -234,13 +243,12 @@ export class ActorHandleRaw {
234
243
  * @template Args - The type of arguments to pass to the action function.
235
244
  * @template Response - The type of the response returned by the action function.
236
245
  */
237
- async action<
238
- Args extends Array<unknown> = unknown[],
239
- Response = unknown,
240
- >(opts: {
241
- name: string;
242
- args: Args;
243
- } & ActorActionOptions): Promise<Response> {
246
+ async action<Args extends Array<unknown> = unknown[], Response = unknown>(
247
+ opts: {
248
+ name: string;
249
+ args: Args;
250
+ } & ActorActionOptions,
251
+ ): Promise<Response> {
244
252
  if (
245
253
  typeof opts === "string" ||
246
254
  typeof opts !== "object" ||
@@ -259,10 +267,12 @@ export class ActorHandleRaw {
259
267
  return await retryOnLifecycleBoundary(run, { signal: opts.signal });
260
268
  }
261
269
 
262
- async #sendActionNow(opts: {
263
- name: string;
264
- args: unknown[];
265
- } & ActorActionOptions): Promise<unknown> {
270
+ async #sendActionNow(
271
+ opts: {
272
+ name: string;
273
+ args: unknown[];
274
+ } & ActorActionOptions,
275
+ ): Promise<unknown> {
266
276
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
267
277
  let useQueryTarget = false;
268
278
  const gatewayOptions = resolveActorGatewayOptions(
@@ -325,16 +335,20 @@ export class ActorHandleRaw {
325
335
  requestVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
326
336
  requestVersionedDataHandler: HTTP_ACTION_REQUEST_VERSIONED,
327
337
  responseVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
328
- responseVersionedDataHandler: HTTP_ACTION_RESPONSE_VERSIONED,
338
+ responseVersionedDataHandler:
339
+ HTTP_ACTION_RESPONSE_VERSIONED,
329
340
  requestZodSchema: HttpActionRequestSchema,
330
341
  responseZodSchema: HttpActionResponseSchema,
331
342
  requestToJson: (args): HttpActionRequestJson => ({
332
343
  args,
333
344
  }),
334
345
  requestToBare: (args): protocol.HttpActionRequest => ({
335
- args: bufferToArrayBuffer(encodeCborCompat(args)),
346
+ args: bufferToArrayBuffer(
347
+ encodeCborCompat(args as JsonCompatValue),
348
+ ),
336
349
  }),
337
- responseFromJson: (json): Response => json.output as Response,
350
+ responseFromJson: (json): Response =>
351
+ json.output as Response,
338
352
  responseFromBare: (bare): Response =>
339
353
  decodeCborCompat(new Uint8Array(bare.output)),
340
354
  });
@@ -343,10 +357,8 @@ export class ActorHandleRaw {
343
357
  }
344
358
  return output;
345
359
  } catch (err) {
346
- const { group, code, message, metadata, actor } = deconstructError(
347
- err,
348
- true,
349
- );
360
+ const { group, code, message, metadata, actor } =
361
+ deconstructError(err, true);
350
362
 
351
363
  if (
352
364
  await this.#shouldRetrySchedulingError(
@@ -390,14 +402,19 @@ export class ActorHandleRaw {
390
402
  );
391
403
  }
392
404
 
393
- const invalidated = this.#invalidateResolvedActorId(group, code);
405
+ const invalidated = this.#invalidateResolvedActorId(
406
+ group,
407
+ code,
408
+ );
394
409
  if (invalidated && attempt < maxAttempts - 1) {
395
410
  if (
396
411
  group === "actor" &&
397
412
  (code === "starting" || code === "stopping")
398
413
  ) {
399
414
  useQueryTarget = true;
400
- await new Promise((resolve) => setTimeout(resolve, 100));
415
+ await new Promise((resolve) =>
416
+ setTimeout(resolve, 100),
417
+ );
401
418
  }
402
419
  continue;
403
420
  }
@@ -662,10 +679,8 @@ export class ActorHandleRaw {
662
679
  }
663
680
  return response;
664
681
  } catch (err) {
665
- const { group, code, message, metadata, actor } = deconstructError(
666
- err,
667
- true,
668
- );
682
+ const { group, code, message, metadata, actor } =
683
+ deconstructError(err, true);
669
684
 
670
685
  if (
671
686
  await this.#shouldRetrySchedulingError(
@@ -695,12 +710,15 @@ export class ActorHandleRaw {
695
710
  continue;
696
711
  }
697
712
 
698
- const invalidated = this.#invalidateResolvedActorId(group, code);
713
+ const invalidated = this.#invalidateResolvedActorId(
714
+ group,
715
+ code,
716
+ );
699
717
  if (invalidated && attempt < maxAttempts - 1) {
700
718
  useQueryTarget =
701
- (code === "starting" ||
702
- code === "stopping" ||
703
- code.startsWith("destroyed_"));
719
+ code === "starting" ||
720
+ code === "stopping" ||
721
+ code.startsWith("destroyed_");
704
722
  if (useQueryTarget) {
705
723
  await this.#waitForRetryWindow();
706
724
  }
@@ -719,13 +737,10 @@ export class ActorHandleRaw {
719
737
  actorId: string | undefined,
720
738
  attempt: number,
721
739
  maxAttempts: number,
722
- ): Promise<
723
- | {
724
- useQueryTarget: boolean;
725
- waitForRetryWindow: boolean;
726
- }
727
- | null
728
- > {
740
+ ): Promise<{
741
+ useQueryTarget: boolean;
742
+ waitForRetryWindow: boolean;
743
+ } | null> {
729
744
  if (response.ok || !isDynamicActorQuery(this.#actorResolutionState)) {
730
745
  return null;
731
746
  }
@@ -857,8 +872,9 @@ export class ActorHandleRaw {
857
872
  this.#gatewayOptions,
858
873
  options,
859
874
  );
875
+ const useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
860
876
  const target = await this.#resolveGatewayRequestTarget(
861
- false,
877
+ useQueryTarget,
862
878
  gatewayOptions,
863
879
  );
864
880
  return await rawWebSocket(
@@ -884,7 +900,9 @@ export class ActorHandleRaw {
884
900
  return target.directId;
885
901
  }
886
902
 
887
- throw new Error("dynamic actor resolution did not produce a direct actor id");
903
+ throw new Error(
904
+ "dynamic actor resolution did not produce a direct actor id",
905
+ );
888
906
  }
889
907
 
890
908
  /**
@@ -1,11 +1,11 @@
1
1
  import * as errors from "@/actor/errors";
2
+ import type { ActorQuery } from "@/client/query";
2
3
  import { stringifyError } from "@/common/utils";
3
- import {
4
- type GatewayTarget,
5
- type EngineControlClient,
4
+ import type {
5
+ EngineControlClient,
6
+ GatewayTarget,
6
7
  } from "@/engine-client/driver";
7
- import type { ActorQuery } from "@/client/query";
8
- import { actorSchedulingError, type ActorSchedulingError } from "./errors";
8
+ import { type ActorSchedulingError, actorSchedulingError } from "./errors";
9
9
  import { logger } from "./log";
10
10
 
11
11
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
+ type ActorSpecifier,
2
3
  INTERNAL_ERROR_CODE,
3
4
  RivetError,
4
- type ActorSpecifier,
5
5
  type RivetErrorLike,
6
6
  UserError,
7
7
  } from "@/actor/errors";
@@ -162,6 +162,7 @@ function classifyActorError(
162
162
  function isRetryableGuardGatewayHttpError(code: string): boolean {
163
163
  return (
164
164
  code === "service_unavailable" ||
165
+ code === "actor_wake_retries_exceeded" ||
165
166
  code === "actor_stopped_while_waiting" ||
166
167
  code === "tunnel_request_aborted" ||
167
168
  code === "tunnel_message_timeout" ||
@@ -299,10 +300,7 @@ export async function retryOnLifecycleBoundary<T>(
299
300
  break;
300
301
  }
301
302
 
302
- const delayMs = Math.min(
303
- initialDelayMs * 2 ** attempt,
304
- maxDelayMs,
305
- );
303
+ const delayMs = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);
306
304
  await waitWithSignal(delayMs, opts?.signal);
307
305
  }
308
306
  }
@@ -1,11 +1,11 @@
1
1
  import { z } from "zod/v4";
2
- import { EncodingSchema } from "@/common/encoding";
3
2
  import {
4
3
  HEADER_ACTOR_ID,
5
4
  HEADER_ACTOR_QUERY,
6
5
  HEADER_CONN_PARAMS,
7
6
  HEADER_ENCODING,
8
7
  } from "@/common/actor-router-consts";
8
+ import { EncodingSchema } from "@/common/encoding";
9
9
 
10
10
  // Maximum size of a key component in bytes
11
11
  // Set to 128 bytes to allow for separators and escape characters in the full key
@@ -1,5 +1,7 @@
1
- import type { Encoding } from "@/common/encoding";
2
- import { HEADER_CONN_PARAMS, HEADER_ENCODING } from "@/common/actor-router-consts";
1
+ import {
2
+ HEADER_CONN_PARAMS,
3
+ HEADER_ENCODING,
4
+ } from "@/common/actor-router-consts";
3
5
  import type * as protocol from "@/common/client-protocol";
4
6
  import {
5
7
  CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
@@ -12,6 +14,7 @@ import {
12
14
  type HttpQueueSendResponse as HttpQueueSendResponseJson,
13
15
  HttpQueueSendResponseSchema,
14
16
  } from "@/common/client-protocol-zod";
17
+ import type { Encoding, JsonCompatValue } from "@/common/encoding";
15
18
  import { decodeCborCompat, encodeCborCompat } from "@/serde";
16
19
  import { bufferToArrayBuffer } from "@/utils";
17
20
  import { sendHttpRequest } from "./utils";
@@ -111,7 +114,9 @@ export function createQueueSender(
111
114
  }),
112
115
  requestToBare: (value): protocol.HttpQueueSendRequest => ({
113
116
  name: value.name ?? name,
114
- body: bufferToArrayBuffer(encodeCborCompat(value.body)),
117
+ body: bufferToArrayBuffer(
118
+ encodeCborCompat(value.body as JsonCompatValue),
119
+ ),
115
120
  wait: value.wait ?? false,
116
121
  timeout:
117
122
  value.timeout !== undefined ? BigInt(value.timeout) : null,
@@ -1,11 +1,13 @@
1
- import { PATH_WEBSOCKET_PREFIX } from "@/common/actor-router-consts";
2
- import { deconstructError } from "@/common/utils";
3
1
  import {
4
- type GatewayTarget,
5
- type EngineControlClient,
6
- type GatewayRequestOptions,
2
+ HEADER_CONN_PARAMS,
3
+ PATH_WEBSOCKET_PREFIX,
4
+ } from "@/common/actor-router-consts";
5
+ import { deconstructError } from "@/common/utils";
6
+ import type {
7
+ EngineControlClient,
8
+ GatewayRequestOptions,
9
+ GatewayTarget,
7
10
  } from "@/engine-client/driver";
8
- import { HEADER_CONN_PARAMS } from "@/common/actor-router-consts";
9
11
  import { ActorError } from "./errors";
10
12
  import { logger } from "./log";
11
13
 
@@ -1,7 +1,7 @@
1
1
  import { actorNotFound, invalidRequest } from "@/actor/errors";
2
2
  import type {
3
- GatewayTarget,
4
3
  EngineControlClient,
4
+ GatewayTarget,
5
5
  } from "@/engine-client/driver";
6
6
 
7
7
  /**
@@ -1,19 +1,14 @@
1
1
  import invariant from "invariant";
2
2
  import type { VersionedDataHandler } from "vbare";
3
3
  import type { z } from "zod/v4";
4
+ import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
5
+ import { HttpResponseErrorSchema } from "@/common/client-protocol-zod";
4
6
  import type { Encoding } from "@/common/encoding";
5
7
  import { assertUnreachable } from "@/common/utils";
6
- import type { HttpResponseError } from "@/common/client-protocol";
7
- import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
8
- import {
9
- type HttpResponseError as HttpResponseErrorJson,
10
- HttpResponseErrorSchema,
11
- } from "@/common/client-protocol-zod";
12
8
  import {
13
9
  contentTypeForEncoding,
14
10
  decodeCborCompat,
15
11
  deserializeWithEncoding,
16
- encodingIsBinary,
17
12
  serializeWithEncoding,
18
13
  } from "@/serde";
19
14
  import { httpUserAgent } from "@/utils";
@@ -30,7 +30,9 @@ export function parseWebSocketProtocols(
30
30
  let ackHookTokenRaw: string | undefined;
31
31
 
32
32
  if (protocols) {
33
- for (const protocol of protocols.split(",").map((value) => value.trim())) {
33
+ for (const protocol of protocols
34
+ .split(",")
35
+ .map((value) => value.trim())) {
34
36
  if (protocol.startsWith(WS_PROTOCOL_ENCODING)) {
35
37
  encodingRaw = protocol.substring(WS_PROTOCOL_ENCODING.length);
36
38
  } else if (protocol.startsWith(WS_PROTOCOL_CONN_PARAMS)) {