rivetkit 2.0.8 → 2.0.10

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 (125) hide show
  1. package/dist/tsup/{chunk-2FAWAPRT.js → chunk-346X2XU4.js} +2 -2
  2. package/dist/tsup/{chunk-SFRRXLRM.js → chunk-7E5K3375.js} +2 -2
  3. package/dist/tsup/{chunk-3WRAGTDC.cjs → chunk-CA3X5M6H.cjs} +92 -39
  4. package/dist/tsup/{chunk-PVKV2O2E.js.map → chunk-CA3X5M6H.cjs.map} +1 -1
  5. package/dist/tsup/{chunk-L5MHM6JJ.cjs → chunk-DVPXSB4B.cjs} +12 -12
  6. package/dist/tsup/{chunk-L5MHM6JJ.cjs.map → chunk-DVPXSB4B.cjs.map} +1 -1
  7. package/dist/tsup/{chunk-DQVVH5ZK.cjs → chunk-GIFHYL7A.cjs} +5 -6
  8. package/dist/tsup/chunk-GIFHYL7A.cjs.map +1 -0
  9. package/dist/tsup/{chunk-N7OVEOMU.js → chunk-H7E2UU23.js} +38 -15
  10. package/dist/tsup/chunk-H7E2UU23.js.map +1 -0
  11. package/dist/tsup/{chunk-A6TV3QU6.js → chunk-HI55LHM3.js} +5 -6
  12. package/dist/tsup/chunk-HI55LHM3.js.map +1 -0
  13. package/dist/tsup/{chunk-FGOZELKN.cjs → chunk-I3FB346I.cjs} +112 -58
  14. package/dist/tsup/chunk-I3FB346I.cjs.map +1 -0
  15. package/dist/tsup/{chunk-DOZBWJRI.js → chunk-KGDZYQYE.js} +2 -2
  16. package/dist/tsup/{chunk-KYEEAVJO.cjs → chunk-KH5WFDUK.cjs} +6 -6
  17. package/dist/tsup/{chunk-KYEEAVJO.cjs.map → chunk-KH5WFDUK.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-WP7YG7S5.js → chunk-KL4V2ULR.js} +5 -4
  19. package/dist/tsup/chunk-KL4V2ULR.js.map +1 -0
  20. package/dist/tsup/{chunk-S6EAEZQA.js → chunk-MLQIYKAZ.js} +106 -52
  21. package/dist/tsup/chunk-MLQIYKAZ.js.map +1 -0
  22. package/dist/tsup/{chunk-3ZMJUIL3.js → chunk-N3A5GYJU.js} +3 -3
  23. package/dist/tsup/{chunk-CKSA7NOS.cjs → chunk-PDFL7FBL.cjs} +717 -380
  24. package/dist/tsup/chunk-PDFL7FBL.cjs.map +1 -0
  25. package/dist/tsup/{chunk-ESD2JX3L.cjs → chunk-PPLR53PP.cjs} +3 -3
  26. package/dist/tsup/{chunk-ESD2JX3L.cjs.map → chunk-PPLR53PP.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-6INXQCH7.cjs → chunk-PSCDCEXM.cjs} +17 -12
  28. package/dist/tsup/chunk-PSCDCEXM.cjs.map +1 -0
  29. package/dist/tsup/{chunk-PVKV2O2E.js → chunk-QRFXXTLG.js} +96 -43
  30. package/dist/tsup/chunk-QRFXXTLG.js.map +1 -0
  31. package/dist/tsup/{chunk-RM2V2IRK.js → chunk-R2S45MO6.js} +14 -9
  32. package/dist/tsup/chunk-R2S45MO6.js.map +1 -0
  33. package/dist/tsup/{chunk-QGUQB3NC.cjs → chunk-SIWYIRXP.cjs} +7 -6
  34. package/dist/tsup/chunk-SIWYIRXP.cjs.map +1 -0
  35. package/dist/tsup/{chunk-E77RVI3P.js → chunk-VJRXZPTT.js} +601 -264
  36. package/dist/tsup/chunk-VJRXZPTT.js.map +1 -0
  37. package/dist/tsup/{chunk-KDNB2BQX.cjs → chunk-VZMXAZKC.cjs} +229 -206
  38. package/dist/tsup/chunk-VZMXAZKC.cjs.map +1 -0
  39. package/dist/tsup/{chunk-TPJNKVFB.cjs → chunk-YKVTF7MP.cjs} +7 -7
  40. package/dist/tsup/{chunk-TPJNKVFB.cjs.map → chunk-YKVTF7MP.cjs.map} +1 -1
  41. package/dist/tsup/client/mod.cjs +9 -9
  42. package/dist/tsup/client/mod.d.cts +2 -2
  43. package/dist/tsup/client/mod.d.ts +2 -2
  44. package/dist/tsup/client/mod.js +8 -8
  45. package/dist/tsup/common/log.cjs +3 -3
  46. package/dist/tsup/common/log.js +2 -2
  47. package/dist/tsup/common/websocket.cjs +4 -4
  48. package/dist/tsup/common/websocket.js +3 -3
  49. package/dist/tsup/{conn-ChAuuTr0.d.cts → conn-Cc9WHuN4.d.cts} +196 -185
  50. package/dist/tsup/{conn-CjUkMEcm.d.ts → conn-DfPG71FA.d.ts} +196 -185
  51. package/dist/tsup/driver-helpers/mod.cjs +7 -5
  52. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  53. package/dist/tsup/driver-helpers/mod.d.cts +4 -2
  54. package/dist/tsup/driver-helpers/mod.d.ts +4 -2
  55. package/dist/tsup/driver-helpers/mod.js +9 -7
  56. package/dist/tsup/driver-test-suite/mod.cjs +116 -102
  57. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  58. package/dist/tsup/driver-test-suite/mod.d.cts +3 -2
  59. package/dist/tsup/driver-test-suite/mod.d.ts +3 -2
  60. package/dist/tsup/driver-test-suite/mod.js +61 -47
  61. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  62. package/dist/tsup/inspector/mod.cjs +6 -6
  63. package/dist/tsup/inspector/mod.d.cts +6 -6
  64. package/dist/tsup/inspector/mod.d.ts +6 -6
  65. package/dist/tsup/inspector/mod.js +5 -5
  66. package/dist/tsup/mod.cjs +10 -10
  67. package/dist/tsup/mod.d.cts +8 -39
  68. package/dist/tsup/mod.d.ts +8 -39
  69. package/dist/tsup/mod.js +9 -9
  70. package/dist/tsup/test/mod.cjs +11 -11
  71. package/dist/tsup/test/mod.d.cts +1 -1
  72. package/dist/tsup/test/mod.d.ts +1 -1
  73. package/dist/tsup/test/mod.js +10 -10
  74. package/dist/tsup/utils.cjs +2 -2
  75. package/dist/tsup/utils.d.cts +2 -1
  76. package/dist/tsup/utils.d.ts +2 -1
  77. package/dist/tsup/utils.js +1 -1
  78. package/package.json +4 -5
  79. package/src/actor/driver.ts +2 -2
  80. package/src/actor/instance.ts +4 -4
  81. package/src/actor/protocol/serde.ts +75 -3
  82. package/src/actor/router-endpoints.ts +6 -6
  83. package/src/actor/router.ts +2 -2
  84. package/src/client/actor-conn.ts +24 -3
  85. package/src/client/config.ts +18 -25
  86. package/src/driver-helpers/mod.ts +5 -1
  87. package/src/driver-test-suite/mod.ts +65 -43
  88. package/src/driver-test-suite/utils.ts +4 -1
  89. package/src/drivers/default.ts +11 -9
  90. package/src/drivers/engine/actor-driver.ts +40 -39
  91. package/src/drivers/engine/config.ts +9 -22
  92. package/src/drivers/engine/mod.ts +9 -8
  93. package/src/drivers/file-system/global-state.ts +4 -4
  94. package/src/engine-process/log.ts +5 -0
  95. package/src/engine-process/mod.ts +316 -0
  96. package/src/inspector/utils.ts +6 -4
  97. package/src/manager/driver.ts +3 -3
  98. package/src/manager/gateway.ts +29 -11
  99. package/src/manager/router-schema.ts +20 -0
  100. package/src/manager/router.ts +139 -58
  101. package/src/registry/mod.ts +146 -120
  102. package/src/registry/run-config.ts +116 -47
  103. package/src/registry/serve.ts +3 -1
  104. package/src/remote-manager-driver/mod.ts +3 -2
  105. package/src/serde.ts +18 -3
  106. package/src/test/config.ts +2 -2
  107. package/src/test/mod.ts +6 -3
  108. package/src/utils.ts +2 -0
  109. package/dist/tsup/chunk-3WRAGTDC.cjs.map +0 -1
  110. package/dist/tsup/chunk-6INXQCH7.cjs.map +0 -1
  111. package/dist/tsup/chunk-A6TV3QU6.js.map +0 -1
  112. package/dist/tsup/chunk-CKSA7NOS.cjs.map +0 -1
  113. package/dist/tsup/chunk-DQVVH5ZK.cjs.map +0 -1
  114. package/dist/tsup/chunk-E77RVI3P.js.map +0 -1
  115. package/dist/tsup/chunk-FGOZELKN.cjs.map +0 -1
  116. package/dist/tsup/chunk-KDNB2BQX.cjs.map +0 -1
  117. package/dist/tsup/chunk-N7OVEOMU.js.map +0 -1
  118. package/dist/tsup/chunk-QGUQB3NC.cjs.map +0 -1
  119. package/dist/tsup/chunk-RM2V2IRK.js.map +0 -1
  120. package/dist/tsup/chunk-S6EAEZQA.js.map +0 -1
  121. package/dist/tsup/chunk-WP7YG7S5.js.map +0 -1
  122. /package/dist/tsup/{chunk-2FAWAPRT.js.map → chunk-346X2XU4.js.map} +0 -0
  123. /package/dist/tsup/{chunk-SFRRXLRM.js.map → chunk-7E5K3375.js.map} +0 -0
  124. /package/dist/tsup/{chunk-DOZBWJRI.js.map → chunk-KGDZYQYE.js.map} +0 -0
  125. /package/dist/tsup/{chunk-3ZMJUIL3.js.map → chunk-N3A5GYJU.js.map} +0 -0
@@ -123,9 +123,81 @@ export function encodeDataToString(message: OutputData): string {
123
123
  }
124
124
  }
125
125
 
126
+ function base64DecodeToUint8Array(base64: string): Uint8Array {
127
+ // Check if Buffer is available (Node.js)
128
+ if (typeof Buffer !== "undefined") {
129
+ return new Uint8Array(Buffer.from(base64, "base64"));
130
+ }
131
+
132
+ // Browser environment - use atob
133
+ const binary = atob(base64);
134
+ const len = binary.length;
135
+ const bytes = new Uint8Array(len);
136
+ for (let i = 0; i < len; i++) {
137
+ bytes[i] = binary.charCodeAt(i);
138
+ }
139
+ return bytes;
140
+ }
141
+
142
+ function base64DecodeToArrayBuffer(base64: string): ArrayBuffer {
143
+ return base64DecodeToUint8Array(base64).buffer as ArrayBuffer;
144
+ }
145
+
126
146
  /** Stringifies with compat for values that BARE & CBOR supports. */
127
147
  export function jsonStringifyCompat(input: any): string {
128
- return JSON.stringify(input, (_key, value) =>
129
- typeof value === "bigint" ? value.toString() : value,
130
- );
148
+ return JSON.stringify(input, (_key, value) => {
149
+ if (typeof value === "bigint") {
150
+ return ["$BigInt", value.toString()];
151
+ } else if (value instanceof ArrayBuffer) {
152
+ return ["$ArrayBuffer", base64EncodeArrayBuffer(value)];
153
+ } else if (value instanceof Uint8Array) {
154
+ return ["$Uint8Array", base64EncodeUint8Array(value)];
155
+ }
156
+
157
+ // Escape user arrays that start with $ by prepending another $
158
+ if (
159
+ Array.isArray(value) &&
160
+ value.length === 2 &&
161
+ typeof value[0] === "string" &&
162
+ value[0].startsWith("$")
163
+ ) {
164
+ return ["$" + value[0], value[1]];
165
+ }
166
+
167
+ return value;
168
+ });
169
+ }
170
+
171
+ /** Parses JSON with compat for values that BARE & CBOR supports. */
172
+ export function jsonParseCompat(input: string): any {
173
+ return JSON.parse(input, (_key, value) => {
174
+ // Handle arrays with $ prefix
175
+ if (
176
+ Array.isArray(value) &&
177
+ value.length === 2 &&
178
+ typeof value[0] === "string" &&
179
+ value[0].startsWith("$")
180
+ ) {
181
+ // Known special types
182
+ if (value[0] === "$BigInt") {
183
+ return BigInt(value[1]);
184
+ } else if (value[0] === "$ArrayBuffer") {
185
+ return base64DecodeToArrayBuffer(value[1]);
186
+ } else if (value[0] === "$Uint8Array") {
187
+ return base64DecodeToUint8Array(value[1]);
188
+ }
189
+
190
+ // Unescape user arrays that started with $ ($$foo -> $foo)
191
+ if (value[0].startsWith("$$")) {
192
+ return [value[0].substring(1), value[1]];
193
+ }
194
+
195
+ // Unknown type starting with $ - this is an error
196
+ throw new Error(
197
+ `Unknown JSON encoding type: ${value[0]}. This may indicate corrupted data or a version mismatch.`,
198
+ );
199
+ }
200
+
201
+ return value;
202
+ });
131
203
  }
@@ -26,7 +26,7 @@ import type { UpgradeWebSocketArgs } from "@/common/inline-websocket-adapter2";
26
26
  import { deconstructError, stringifyError } from "@/common/utils";
27
27
  import type { UniversalWebSocket } from "@/common/websocket-interface";
28
28
  import { HonoWebSocketAdapter } from "@/manager/hono-websocket-adapter";
29
- import type { RunConfig } from "@/registry/run-config";
29
+ import type { RunnerConfig } from "@/registry/run-config";
30
30
  import type * as protocol from "@/schemas/client-protocol/mod";
31
31
  import {
32
32
  HTTP_ACTION_REQUEST_VERSIONED,
@@ -106,7 +106,7 @@ export interface WebSocketOpts {
106
106
  */
107
107
  export async function handleWebSocketConnect(
108
108
  req: Request | undefined,
109
- runConfig: RunConfig,
109
+ runConfig: RunnerConfig,
110
110
  actorDriver: ActorDriver,
111
111
  actorId: string,
112
112
  encoding: Encoding,
@@ -325,7 +325,7 @@ export async function handleWebSocketConnect(
325
325
  */
326
326
  export async function handleSseConnect(
327
327
  c: HonoContext,
328
- _runConfig: RunConfig,
328
+ _runConfig: RunnerConfig,
329
329
  actorDriver: ActorDriver,
330
330
  actorId: string,
331
331
  ) {
@@ -437,7 +437,7 @@ export async function handleSseConnect(
437
437
  */
438
438
  export async function handleAction(
439
439
  c: HonoContext,
440
- _runConfig: RunConfig,
440
+ _runConfig: RunnerConfig,
441
441
  actorDriver: ActorDriver,
442
442
  actionName: string,
443
443
  actorId: string,
@@ -505,7 +505,7 @@ export async function handleAction(
505
505
  */
506
506
  export async function handleConnectionMessage(
507
507
  c: HonoContext,
508
- _runConfig: RunConfig,
508
+ _runConfig: RunnerConfig,
509
509
  actorDriver: ActorDriver,
510
510
  connId: string,
511
511
  connToken: string,
@@ -542,7 +542,7 @@ export async function handleConnectionMessage(
542
542
 
543
543
  export async function handleConnectionClose(
544
544
  c: HonoContext,
545
- _runConfig: RunConfig,
545
+ _runConfig: RunnerConfig,
546
546
  actorDriver: ActorDriver,
547
547
  connId: string,
548
548
  connToken: string,
@@ -41,7 +41,7 @@ import {
41
41
  createActorInspectorRouter,
42
42
  } from "@/inspector/actor";
43
43
  import { isInspectorEnabled, secureInspector } from "@/inspector/utils";
44
- import type { RunConfig } from "@/registry/run-config";
44
+ import type { RunnerConfig } from "@/registry/run-config";
45
45
  import { ConnDriverKind } from "./conn-drivers";
46
46
  import type { ActorDriver } from "./driver";
47
47
  import { InternalError } from "./errors";
@@ -67,7 +67,7 @@ export type ActorRouter = Hono<{ Bindings: ActorRouterBindings }>;
67
67
  * Creates a router that runs on the partitioned instance.
68
68
  */
69
69
  export function createActorRouter(
70
- runConfig: RunConfig,
70
+ runConfig: RunnerConfig,
71
71
  actorDriver: ActorDriver,
72
72
  isTest: boolean,
73
73
  ): ActorRouter {
@@ -315,13 +315,34 @@ enc
315
315
  });
316
316
  });
317
317
  ws.addEventListener("message", async (ev) => {
318
- this.#handleOnMessage(ev.data);
318
+ try {
319
+ await this.#handleOnMessage(ev.data);
320
+ } catch (err) {
321
+ logger().error({
322
+ msg: "error in websocket message handler",
323
+ error: stringifyError(err),
324
+ });
325
+ }
319
326
  });
320
327
  ws.addEventListener("close", (ev) => {
321
- this.#handleOnClose(ev);
328
+ try {
329
+ this.#handleOnClose(ev);
330
+ } catch (err) {
331
+ logger().error({
332
+ msg: "error in websocket close handler",
333
+ error: stringifyError(err),
334
+ });
335
+ }
322
336
  });
323
337
  ws.addEventListener("error", (_ev) => {
324
- this.#handleOnError();
338
+ try {
339
+ this.#handleOnError();
340
+ } catch (err) {
341
+ logger().error({
342
+ msg: "error in websocket error handler",
343
+ error: stringifyError(err),
344
+ });
345
+ }
325
346
  });
326
347
  }
327
348
 
@@ -1,38 +1,32 @@
1
1
  import z from "zod";
2
2
  import { TransportSchema } from "@/actor/protocol/old";
3
3
  import { EncodingSchema } from "@/actor/protocol/serde";
4
- import { getEnvUniversal, type UpgradeWebSocket } from "@/utils";
5
-
6
- export type GetUpgradeWebSocket = () => UpgradeWebSocket;
4
+ import { type GetUpgradeWebSocket, getEnvUniversal } from "@/utils";
7
5
 
8
6
  export const ClientConfigSchema = z.object({
9
- /** Configure serving the API */
10
- api: z
11
- .object({
12
- host: z.string().default("127.0.0.1"),
13
- port: z.number().default(6420),
14
- })
15
- .default({}),
16
-
7
+ /** Endpoint to connect to for Rivet Engine or RivetKit manager API. */
8
+ endpoint: z
9
+ .string()
10
+ .optional()
11
+ .transform(
12
+ (x) =>
13
+ x ??
14
+ getEnvUniversal("RIVET_ENGINE") ??
15
+ getEnvUniversal("RIVET_ENDPOINT"),
16
+ ),
17
+
18
+ /** Token to use to authenticate with the API. */
17
19
  token: z
18
20
  .string()
19
21
  .optional()
20
22
  .transform((x) => x ?? getEnvUniversal("RIVET_TOKEN")),
21
23
 
22
- totalSlots: z.number().optional(),
23
-
24
- headers: z.record(z.string()).optional().default({}),
25
-
26
- /** Endpoint to connect to the Rivet engine. Can be configured via RIVET_ENGINE env var. */
27
- endpoint: z
28
- .string()
29
- .nullable()
30
- .default(() => getEnvUniversal("RIVET_ENGINE") ?? null),
31
-
24
+ /** Namespace to connect to. */
32
25
  namespace: z
33
26
  .string()
34
27
  .default(() => getEnvUniversal("RIVET_NAMESPACE") ?? "default"),
35
28
 
29
+ /** Name of the runner. This is used to group together runners in to different pools. */
36
30
  runnerName: z
37
31
  .string()
38
32
  .default(() => getEnvUniversal("RIVET_RUNNER") ?? "rivetkit"),
@@ -41,10 +35,9 @@ export const ClientConfigSchema = z.object({
41
35
 
42
36
  transport: TransportSchema.default("websocket"),
43
37
 
44
- // This is a function to allow for lazy configuration of upgradeWebSocket on the
45
- // fly. This is required since the dependencies that upgradeWebSocket
46
- // (specifically Node.js) can sometimes only be specified after the router is
47
- // created or must be imported async using `await import(...)`
38
+ headers: z.record(z.string()).optional().default({}),
39
+
40
+ // See RunConfig.getUpgradeWebSocket
48
41
  getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
49
42
  });
50
43
 
@@ -1,5 +1,6 @@
1
1
  export type { ActorDriver } from "@/actor/driver";
2
2
  export type { ActorInstance, AnyActorInstance } from "@/actor/instance";
3
+ export { generateRandomString } from "@/actor/utils";
3
4
  export {
4
5
  ALLOWED_PUBLIC_HEADERS,
5
6
  HEADER_ACTOR_ID,
@@ -31,5 +32,8 @@ export type {
31
32
  ManagerDisplayInformation,
32
33
  ManagerDriver,
33
34
  } from "@/manager/driver";
34
- export { DriverConfigSchema, RunConfigSchema } from "@/registry/run-config";
35
+ export {
36
+ DriverConfigSchema,
37
+ RunnerConfigSchema as RunConfigSchema,
38
+ } from "@/registry/run-config";
35
39
  export { serializeEmptyPersistData } from "./utils";
@@ -3,11 +3,16 @@ import { createNodeWebSocket, type NodeWebSocket } from "@hono/node-ws";
3
3
  import { bundleRequire } from "bundle-require";
4
4
  import invariant from "invariant";
5
5
  import { describe } from "vitest";
6
- import type { Transport } from "@/client/mod";
6
+ import type { Encoding, Transport } from "@/client/mod";
7
7
  import { configureInspectorAccessToken } from "@/inspector/utils";
8
8
  import { createManagerRouter } from "@/manager/router";
9
- import type { DriverConfig, Registry, RunConfig } from "@/mod";
10
- import { RunConfigSchema } from "@/registry/run-config";
9
+ import {
10
+ createClientWithDriver,
11
+ type DriverConfig,
12
+ type Registry,
13
+ type RunConfig,
14
+ } from "@/mod";
15
+ import { RunnerConfigSchema } from "@/registry/run-config";
11
16
  import { getPort } from "@/test/mod";
12
17
  import { logger } from "./log";
13
18
  import { runActionFeaturesTests } from "./tests/action-features";
@@ -55,6 +60,8 @@ export interface DriverTestConfig {
55
60
 
56
61
  transport?: Transport;
57
62
 
63
+ encoding?: Encoding;
64
+
58
65
  clientType: ClientType;
59
66
 
60
67
  cleanup?: () => Promise<void>;
@@ -78,68 +85,81 @@ export interface DriverDeployOutput {
78
85
 
79
86
  /** Runs all Vitest tests against the provided drivers. */
80
87
  export function runDriverTests(
81
- driverTestConfigPartial: Omit<DriverTestConfig, "clientType" | "transport">,
88
+ driverTestConfigPartial: Omit<
89
+ DriverTestConfig,
90
+ "clientType" | "transport" | "encoding"
91
+ >,
82
92
  ) {
83
93
  const clientTypes: ClientType[] = driverTestConfigPartial.skip?.inline
84
94
  ? ["http"]
85
95
  : ["http", "inline"];
86
96
  for (const clientType of clientTypes) {
87
- const driverTestConfig: DriverTestConfig = {
88
- ...driverTestConfigPartial,
89
- clientType,
90
- };
91
-
92
97
  describe(`client type (${clientType})`, () => {
93
- runActorDriverTests(driverTestConfig);
94
- runManagerDriverTests(driverTestConfig);
98
+ const encodings: Encoding[] = ["bare", "cbor", "json"];
95
99
 
96
- const transports: Transport[] = driverTestConfig.skip?.sse
97
- ? ["websocket"]
98
- : ["websocket", "sse"];
99
- for (const transport of transports) {
100
- describe(`transport (${transport})`, () => {
101
- runActorConnTests({
102
- ...driverTestConfig,
103
- transport,
104
- });
100
+ for (const encoding of encodings) {
101
+ describe(`encoding (${encoding})`, () => {
102
+ const driverTestConfig: DriverTestConfig = {
103
+ ...driverTestConfigPartial,
104
+ clientType,
105
+ encoding,
106
+ };
105
107
 
106
- runActorConnStateTests({ ...driverTestConfig, transport });
108
+ runActorDriverTests(driverTestConfig);
109
+ runManagerDriverTests(driverTestConfig);
107
110
 
108
- runActorReconnectTests({ ...driverTestConfig, transport });
111
+ const transports: Transport[] = driverTestConfig.skip?.sse
112
+ ? ["websocket"]
113
+ : ["websocket", "sse"];
114
+ for (const transport of transports) {
115
+ describe(`transport (${transport})`, () => {
116
+ runActorConnTests({
117
+ ...driverTestConfig,
118
+ transport,
119
+ });
109
120
 
110
- runRequestAccessTests({ ...driverTestConfig, transport });
121
+ runActorConnStateTests({ ...driverTestConfig, transport });
111
122
 
112
- runActorDriverTestsWithTransport({ ...driverTestConfig, transport });
113
- });
114
- }
123
+ runActorReconnectTests({ ...driverTestConfig, transport });
115
124
 
116
- runActorHandleTests(driverTestConfig);
125
+ runRequestAccessTests({ ...driverTestConfig, transport });
117
126
 
118
- runActionFeaturesTests(driverTestConfig);
127
+ runActorDriverTestsWithTransport({
128
+ ...driverTestConfig,
129
+ transport,
130
+ });
131
+ });
132
+ }
119
133
 
120
- runActorVarsTests(driverTestConfig);
134
+ runActorHandleTests(driverTestConfig);
121
135
 
122
- runActorMetadataTests(driverTestConfig);
136
+ runActionFeaturesTests(driverTestConfig);
123
137
 
124
- runActorOnStateChangeTests(driverTestConfig);
138
+ runActorVarsTests(driverTestConfig);
125
139
 
126
- runActorErrorHandlingTests(driverTestConfig);
140
+ runActorMetadataTests(driverTestConfig);
127
141
 
128
- runActorInlineClientTests(driverTestConfig);
142
+ runActorOnStateChangeTests(driverTestConfig);
129
143
 
130
- runRawHttpTests(driverTestConfig);
144
+ runActorErrorHandlingTests(driverTestConfig);
131
145
 
132
- runRawHttpRequestPropertiesTests(driverTestConfig);
146
+ runActorInlineClientTests(driverTestConfig);
133
147
 
134
- runRawWebSocketTests(driverTestConfig);
148
+ runRawHttpTests(driverTestConfig);
135
149
 
136
- // TODO: re-expose this once we can have actor queries on the gateway
137
- // runRawHttpDirectRegistryTests(driverTestConfig);
150
+ runRawHttpRequestPropertiesTests(driverTestConfig);
138
151
 
139
- // TODO: re-expose this once we can have actor queries on the gateway
140
- // runRawWebSocketDirectRegistryTests(driverTestConfig);
152
+ runRawWebSocketTests(driverTestConfig);
141
153
 
142
- runActorInspectorTests(driverTestConfig);
154
+ // TODO: re-expose this once we can have actor queries on the gateway
155
+ // runRawHttpDirectRegistryTests(driverTestConfig);
156
+
157
+ // TODO: re-expose this once we can have actor queries on the gateway
158
+ // runRawWebSocketDirectRegistryTests(driverTestConfig);
159
+
160
+ runActorInspectorTests(driverTestConfig);
161
+ });
162
+ }
143
163
  });
144
164
  }
145
165
  }
@@ -199,7 +219,7 @@ export async function createTestRuntime(
199
219
  // Build driver config
200
220
  // biome-ignore lint/style/useConst: Assigned later
201
221
  let upgradeWebSocket: any;
202
- const config: RunConfig = RunConfigSchema.parse({
222
+ const config: RunConfig = RunnerConfigSchema.parse({
203
223
  driver,
204
224
  getUpgradeWebSocket: () => upgradeWebSocket!,
205
225
  inspector: {
@@ -210,12 +230,14 @@ export async function createTestRuntime(
210
230
 
211
231
  // Create router
212
232
  const managerDriver = driver.manager(registry.config, config);
233
+ const client = createClientWithDriver(managerDriver);
213
234
  configureInspectorAccessToken(config, managerDriver);
214
235
  const { router } = createManagerRouter(
215
236
  registry.config,
216
237
  config,
217
238
  managerDriver,
218
- undefined,
239
+ driver,
240
+ client,
219
241
  );
220
242
 
221
243
  // Inject WebSocket
@@ -36,17 +36,20 @@ export async function setupDriverTest(
36
36
  namespace,
37
37
  runnerName,
38
38
  transport: driverTestConfig.transport,
39
+ encoding: driverTestConfig.encoding,
39
40
  });
40
41
  } else if (driverTestConfig.clientType === "inline") {
41
42
  // Use inline client from driver
42
43
  const transport = driverTestConfig.transport ?? "websocket";
44
+ const encoding = driverTestConfig.encoding ?? "bare";
43
45
  const managerDriver = createTestInlineClientDriver(
44
46
  endpoint,
45
- "bare",
47
+ encoding,
46
48
  transport,
47
49
  );
48
50
  const runConfig = RunConfigSchema.parse({
49
51
  transport: transport,
52
+ encoding: encoding,
50
53
  });
51
54
  client = createClientWithDriver(managerDriver, runConfig);
52
55
  } else {
@@ -2,15 +2,21 @@ import { UserError } from "@/actor/errors";
2
2
  import { loggerWithoutContext } from "@/actor/log";
3
3
  import { createEngineDriver } from "@/drivers/engine/mod";
4
4
  import { createFileSystemOrMemoryDriver } from "@/drivers/file-system/mod";
5
- import type { DriverConfig, RunConfig } from "@/registry/run-config";
5
+ import type { DriverConfig, RunnerConfig } from "@/registry/run-config";
6
6
 
7
7
  /**
8
8
  * Chooses the appropriate driver based on the run configuration.
9
9
  */
10
- export function chooseDefaultDriver(runConfig: RunConfig): DriverConfig {
10
+ export function chooseDefaultDriver(runConfig: RunnerConfig): DriverConfig {
11
11
  if (runConfig.endpoint && runConfig.driver) {
12
12
  throw new UserError(
13
- "Cannot specify both 'engine' and 'driver' in configuration",
13
+ "Cannot specify both 'endpoint' and 'driver' in configuration",
14
+ );
15
+ }
16
+
17
+ if (runConfig.runnerKind === "serverless" && !runConfig.endpoint) {
18
+ throw new UserError(
19
+ "Cannot use 'serverless' runnerKind without the 'endpoint' config set.",
14
20
  );
15
21
  }
16
22
 
@@ -18,16 +24,12 @@ export function chooseDefaultDriver(runConfig: RunConfig): DriverConfig {
18
24
  return runConfig.driver;
19
25
  }
20
26
 
21
- if (runConfig.endpoint) {
27
+ if (runConfig.endpoint || runConfig.token) {
22
28
  loggerWithoutContext().debug({
23
29
  msg: "using rivet engine driver",
24
30
  endpoint: runConfig.endpoint,
25
31
  });
26
- // TODO: Add all properties from config
27
- return createEngineDriver({
28
- endpoint: runConfig.endpoint,
29
- token: runConfig.token,
30
- });
32
+ return createEngineDriver();
31
33
  }
32
34
 
33
35
  loggerWithoutContext().debug({ msg: "using default file system driver" });