rivetkit 2.0.5 → 2.0.7-rc.1

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 (178) hide show
  1. package/dist/schemas/actor-persist/v1.ts +0 -6
  2. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.cts +28 -0
  3. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.ts +28 -0
  4. package/dist/tsup/{chunk-5YTI25C3.cjs → chunk-3MBP4WNC.cjs} +7 -7
  5. package/dist/tsup/{chunk-5YTI25C3.cjs.map → chunk-3MBP4WNC.cjs.map} +1 -1
  6. package/dist/tsup/chunk-3Y45CIF4.cjs +3726 -0
  7. package/dist/tsup/chunk-3Y45CIF4.cjs.map +1 -0
  8. package/dist/tsup/chunk-4GP7BZSR.js +102 -0
  9. package/dist/tsup/chunk-4GP7BZSR.js.map +1 -0
  10. package/dist/tsup/chunk-5ZOHIKWG.cjs +4071 -0
  11. package/dist/tsup/chunk-5ZOHIKWG.cjs.map +1 -0
  12. package/dist/tsup/{chunk-WADSS5X4.cjs → chunk-6EUWRXLT.cjs} +21 -7
  13. package/dist/tsup/chunk-6EUWRXLT.cjs.map +1 -0
  14. package/dist/tsup/{chunk-D7NWUCRK.cjs → chunk-6OVKCDSH.cjs} +6 -6
  15. package/dist/tsup/{chunk-D7NWUCRK.cjs.map → chunk-6OVKCDSH.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-I5VTWPHW.js → chunk-7N56ZUC7.js} +3 -3
  17. package/dist/tsup/{chunk-LZIBTLEY.cjs → chunk-B3TLRM4Q.cjs} +13 -25
  18. package/dist/tsup/chunk-B3TLRM4Q.cjs.map +1 -0
  19. package/dist/tsup/chunk-BW5DPM6Z.js +4071 -0
  20. package/dist/tsup/chunk-BW5DPM6Z.js.map +1 -0
  21. package/dist/tsup/chunk-DFS77KAA.cjs +1046 -0
  22. package/dist/tsup/chunk-DFS77KAA.cjs.map +1 -0
  23. package/dist/tsup/{chunk-PG3K2LI7.js → chunk-E4UVJKSV.js} +2 -2
  24. package/dist/tsup/chunk-G4ABMAQY.cjs +102 -0
  25. package/dist/tsup/chunk-G4ABMAQY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-CKA54YQN.js → chunk-GZVBFXBI.js} +3 -15
  27. package/dist/tsup/chunk-GZVBFXBI.js.map +1 -0
  28. package/dist/tsup/chunk-HPT3I7UU.js +3726 -0
  29. package/dist/tsup/chunk-HPT3I7UU.js.map +1 -0
  30. package/dist/tsup/chunk-JD54PXWP.js +1046 -0
  31. package/dist/tsup/chunk-JD54PXWP.js.map +1 -0
  32. package/dist/tsup/{chunk-PHSQJ6QI.cjs → chunk-K4ENQCC4.cjs} +3 -3
  33. package/dist/tsup/{chunk-PHSQJ6QI.cjs.map → chunk-K4ENQCC4.cjs.map} +1 -1
  34. package/dist/tsup/{chunk-WNGOBAA7.js → chunk-PUSQNDJG.js} +2 -2
  35. package/dist/tsup/{chunk-CFFKMUYH.js → chunk-RVP5RUSC.js} +20 -6
  36. package/dist/tsup/chunk-RVP5RUSC.js.map +1 -0
  37. package/dist/tsup/chunk-SAZCNSVY.cjs +259 -0
  38. package/dist/tsup/chunk-SAZCNSVY.cjs.map +1 -0
  39. package/dist/tsup/{chunk-YW6Y6VNE.js → chunk-SBKRVQS2.js} +9 -5
  40. package/dist/tsup/chunk-SBKRVQS2.js.map +1 -0
  41. package/dist/tsup/{chunk-FGFT4FVX.cjs → chunk-TZGUSEIJ.cjs} +14 -10
  42. package/dist/tsup/chunk-TZGUSEIJ.cjs.map +1 -0
  43. package/dist/tsup/chunk-YQ4XQYPM.js +259 -0
  44. package/dist/tsup/chunk-YQ4XQYPM.js.map +1 -0
  45. package/dist/tsup/client/mod.cjs +9 -9
  46. package/dist/tsup/client/mod.d.cts +7 -8
  47. package/dist/tsup/client/mod.d.ts +7 -8
  48. package/dist/tsup/client/mod.js +8 -8
  49. package/dist/tsup/common/log.cjs +3 -3
  50. package/dist/tsup/common/log.js +2 -2
  51. package/dist/tsup/common/websocket.cjs +4 -4
  52. package/dist/tsup/common/websocket.js +3 -3
  53. package/dist/tsup/{connection-BvE-Oq7t.d.ts → conn-DCSQgIlw.d.ts} +1605 -1353
  54. package/dist/tsup/{connection-DTzmWwU5.d.cts → conn-DdzHTm2E.d.cts} +1605 -1353
  55. package/dist/tsup/driver-helpers/mod.cjs +31 -5
  56. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  57. package/dist/tsup/driver-helpers/mod.d.cts +7 -8
  58. package/dist/tsup/driver-helpers/mod.d.ts +7 -8
  59. package/dist/tsup/driver-helpers/mod.js +33 -7
  60. package/dist/tsup/driver-test-suite/mod.cjs +319 -216
  61. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  62. package/dist/tsup/driver-test-suite/mod.d.cts +7 -7
  63. package/dist/tsup/driver-test-suite/mod.d.ts +7 -7
  64. package/dist/tsup/driver-test-suite/mod.js +588 -485
  65. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  66. package/dist/tsup/inspector/mod.cjs +17 -5
  67. package/dist/tsup/inspector/mod.cjs.map +1 -1
  68. package/dist/tsup/inspector/mod.d.cts +34 -7
  69. package/dist/tsup/inspector/mod.d.ts +34 -7
  70. package/dist/tsup/inspector/mod.js +20 -8
  71. package/dist/tsup/mod.cjs +10 -17
  72. package/dist/tsup/mod.cjs.map +1 -1
  73. package/dist/tsup/mod.d.cts +56 -9
  74. package/dist/tsup/mod.d.ts +56 -9
  75. package/dist/tsup/mod.js +17 -24
  76. package/dist/tsup/test/mod.cjs +11 -9
  77. package/dist/tsup/test/mod.cjs.map +1 -1
  78. package/dist/tsup/test/mod.d.cts +6 -7
  79. package/dist/tsup/test/mod.d.ts +6 -7
  80. package/dist/tsup/test/mod.js +10 -8
  81. package/dist/tsup/utils.cjs +4 -2
  82. package/dist/tsup/utils.cjs.map +1 -1
  83. package/dist/tsup/utils.d.cts +11 -1
  84. package/dist/tsup/utils.d.ts +11 -1
  85. package/dist/tsup/utils.js +3 -1
  86. package/package.json +8 -4
  87. package/src/actor/action.ts +1 -1
  88. package/src/actor/config.ts +1 -1
  89. package/src/actor/conn-drivers.ts +205 -0
  90. package/src/actor/conn-socket.ts +6 -0
  91. package/src/actor/{connection.ts → conn.ts} +78 -84
  92. package/src/actor/context.ts +1 -1
  93. package/src/actor/driver.ts +4 -43
  94. package/src/actor/instance.ts +162 -86
  95. package/src/actor/mod.ts +6 -14
  96. package/src/actor/persisted.ts +2 -5
  97. package/src/actor/protocol/old.ts +1 -1
  98. package/src/actor/router-endpoints.ts +147 -138
  99. package/src/actor/router.ts +89 -52
  100. package/src/actor/utils.ts +5 -1
  101. package/src/client/actor-conn.ts +163 -31
  102. package/src/client/actor-handle.ts +0 -1
  103. package/src/client/client.ts +2 -2
  104. package/src/client/config.ts +7 -0
  105. package/src/client/raw-utils.ts +1 -1
  106. package/src/client/utils.ts +1 -1
  107. package/src/common/actor-router-consts.ts +59 -0
  108. package/src/common/router.ts +2 -1
  109. package/src/common/versioned-data.ts +5 -5
  110. package/src/driver-helpers/mod.ts +15 -2
  111. package/src/driver-test-suite/mod.ts +11 -2
  112. package/src/driver-test-suite/test-inline-client-driver.ts +40 -22
  113. package/src/driver-test-suite/tests/actor-conn-state.ts +66 -22
  114. package/src/driver-test-suite/tests/actor-conn.ts +65 -126
  115. package/src/driver-test-suite/tests/actor-reconnect.ts +160 -0
  116. package/src/driver-test-suite/tests/actor-sleep.ts +0 -1
  117. package/src/driver-test-suite/tests/raw-websocket.ts +0 -35
  118. package/src/driver-test-suite/utils.ts +8 -3
  119. package/src/drivers/default.ts +8 -7
  120. package/src/drivers/engine/actor-driver.ts +67 -44
  121. package/src/drivers/engine/config.ts +4 -0
  122. package/src/drivers/file-system/actor.ts +0 -6
  123. package/src/drivers/file-system/global-state.ts +3 -14
  124. package/src/drivers/file-system/manager.ts +12 -8
  125. package/src/inspector/actor.ts +4 -3
  126. package/src/inspector/config.ts +10 -1
  127. package/src/inspector/mod.ts +1 -0
  128. package/src/inspector/utils.ts +23 -4
  129. package/src/manager/driver.ts +12 -2
  130. package/src/manager/gateway.ts +407 -0
  131. package/src/manager/protocol/query.ts +1 -1
  132. package/src/manager/router.ts +269 -468
  133. package/src/manager-api/actors.ts +61 -0
  134. package/src/manager-api/common.ts +4 -0
  135. package/src/mod.ts +1 -1
  136. package/src/registry/mod.ts +126 -12
  137. package/src/registry/serve.ts +8 -3
  138. package/src/remote-manager-driver/actor-http-client.ts +30 -19
  139. package/src/remote-manager-driver/actor-websocket-client.ts +45 -18
  140. package/src/remote-manager-driver/api-endpoints.ts +19 -21
  141. package/src/remote-manager-driver/api-utils.ts +10 -1
  142. package/src/remote-manager-driver/mod.ts +53 -53
  143. package/src/remote-manager-driver/ws-proxy.ts +2 -9
  144. package/src/test/mod.ts +6 -2
  145. package/src/utils.ts +21 -2
  146. package/dist/tsup/chunk-2MD57QF4.js +0 -1794
  147. package/dist/tsup/chunk-2MD57QF4.js.map +0 -1
  148. package/dist/tsup/chunk-B2QGJGZQ.js +0 -338
  149. package/dist/tsup/chunk-B2QGJGZQ.js.map +0 -1
  150. package/dist/tsup/chunk-CFFKMUYH.js.map +0 -1
  151. package/dist/tsup/chunk-CKA54YQN.js.map +0 -1
  152. package/dist/tsup/chunk-FGFT4FVX.cjs.map +0 -1
  153. package/dist/tsup/chunk-IRMBWX36.cjs +0 -1794
  154. package/dist/tsup/chunk-IRMBWX36.cjs.map +0 -1
  155. package/dist/tsup/chunk-L7QRXNWP.js +0 -6562
  156. package/dist/tsup/chunk-L7QRXNWP.js.map +0 -1
  157. package/dist/tsup/chunk-LZIBTLEY.cjs.map +0 -1
  158. package/dist/tsup/chunk-MRZS2J4X.cjs +0 -6562
  159. package/dist/tsup/chunk-MRZS2J4X.cjs.map +0 -1
  160. package/dist/tsup/chunk-RM2SVURR.cjs +0 -338
  161. package/dist/tsup/chunk-RM2SVURR.cjs.map +0 -1
  162. package/dist/tsup/chunk-WADSS5X4.cjs.map +0 -1
  163. package/dist/tsup/chunk-YW6Y6VNE.js.map +0 -1
  164. package/dist/tsup/common-CXCe7s6i.d.cts +0 -218
  165. package/dist/tsup/common-CXCe7s6i.d.ts +0 -218
  166. package/dist/tsup/router-endpoints-CctffZNL.d.cts +0 -65
  167. package/dist/tsup/router-endpoints-DFm1BglJ.d.ts +0 -65
  168. package/src/actor/generic-conn-driver.ts +0 -246
  169. package/src/common/fake-event-source.ts +0 -267
  170. package/src/manager-api/routes/actors-create.ts +0 -16
  171. package/src/manager-api/routes/actors-delete.ts +0 -4
  172. package/src/manager-api/routes/actors-get-by-id.ts +0 -7
  173. package/src/manager-api/routes/actors-get-or-create-by-id.ts +0 -29
  174. package/src/manager-api/routes/actors-get.ts +0 -7
  175. package/src/manager-api/routes/common.ts +0 -18
  176. /package/dist/tsup/{chunk-I5VTWPHW.js.map → chunk-7N56ZUC7.js.map} +0 -0
  177. /package/dist/tsup/{chunk-PG3K2LI7.js.map → chunk-E4UVJKSV.js.map} +0 -0
  178. /package/dist/tsup/{chunk-WNGOBAA7.js.map → chunk-PUSQNDJG.js.map} +0 -0
@@ -1,34 +1,46 @@
1
1
  import {
2
2
  getPort
3
- } from "../chunk-YW6Y6VNE.js";
3
+ } from "../chunk-SBKRVQS2.js";
4
4
  import {
5
- createClient
6
- } from "../chunk-I5VTWPHW.js";
7
- import {
8
- ActorError,
9
5
  actor,
10
- createClientWithDriver,
11
6
  createManagerRouter
12
- } from "../chunk-L7QRXNWP.js";
7
+ } from "../chunk-HPT3I7UU.js";
13
8
  import {
9
+ configureInspectorAccessToken,
14
10
  createActorInspectorClient,
15
11
  createManagerInspectorClient
16
- } from "../chunk-CKA54YQN.js";
12
+ } from "../chunk-4GP7BZSR.js";
13
+ import {
14
+ createClient
15
+ } from "../chunk-7N56ZUC7.js";
16
+ import {
17
+ ActorError,
18
+ createClientWithDriver
19
+ } from "../chunk-BW5DPM6Z.js";
20
+ import "../chunk-GZVBFXBI.js";
17
21
  import {
18
22
  importWebSocket
19
- } from "../chunk-PG3K2LI7.js";
23
+ } from "../chunk-E4UVJKSV.js";
20
24
  import {
21
25
  RunConfigSchema
22
- } from "../chunk-B2QGJGZQ.js";
26
+ } from "../chunk-JD54PXWP.js";
23
27
  import {
24
28
  HEADER_ACTOR_ID,
25
29
  HEADER_ACTOR_QUERY,
30
+ WS_PROTOCOL_ACTOR,
31
+ WS_PROTOCOL_CONN_PARAMS,
32
+ WS_PROTOCOL_ENCODING,
33
+ WS_PROTOCOL_PATH,
34
+ WS_PROTOCOL_TARGET,
35
+ WS_PROTOCOL_TRANSPORT,
26
36
  assertUnreachable
27
- } from "../chunk-2MD57QF4.js";
37
+ } from "../chunk-YQ4XQYPM.js";
28
38
  import {
29
39
  getLogger
30
- } from "../chunk-WNGOBAA7.js";
31
- import "../chunk-CFFKMUYH.js";
40
+ } from "../chunk-PUSQNDJG.js";
41
+ import {
42
+ promiseWithResolvers
43
+ } from "../chunk-RVP5RUSC.js";
32
44
  import {
33
45
  INTERNAL_ERROR_CODE,
34
46
  INTERNAL_ERROR_DESCRIPTION
@@ -39,7 +51,7 @@ import { serve as honoServe } from "@hono/node-server";
39
51
  import { createNodeWebSocket } from "@hono/node-ws";
40
52
  import { bundleRequire } from "bundle-require";
41
53
  import invariant from "invariant";
42
- import { describe as describe20 } from "vitest";
54
+ import { describe as describe21 } from "vitest";
43
55
 
44
56
  // src/driver-test-suite/log.ts
45
57
  function logger() {
@@ -100,7 +112,8 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
100
112
  method: actorRequest.method,
101
113
  headers,
102
114
  body: actorRequest.body,
103
- signal: actorRequest.signal
115
+ signal: actorRequest.signal,
116
+ duplex: "half"
104
117
  })
105
118
  );
106
119
  if (!response.ok && ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json"))) {
@@ -125,38 +138,46 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
125
138
  }
126
139
  return response;
127
140
  },
128
- async openWebSocket(path, actorId, encoding2, params) {
141
+ async openWebSocket(path, actorId, encoding2, params, connId, connToken) {
129
142
  const WebSocket2 = await importWebSocket();
130
143
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
131
- logger().debug({
132
- msg: "creating websocket connection via test inline driver"
133
- });
134
144
  const wsUrl = new URL(
135
145
  `${endpoint}/.test/inline-driver/connect-websocket/ws`
136
146
  );
137
- wsUrl.searchParams.set("path", normalizedPath);
138
- wsUrl.searchParams.set("actorId", actorId);
139
- if (params !== void 0)
140
- wsUrl.searchParams.set("params", JSON.stringify(params));
141
- wsUrl.searchParams.set("encodingKind", encoding2);
147
+ logger().debug({
148
+ msg: "creating websocket connection via test inline driver",
149
+ url: wsUrl.toString()
150
+ });
142
151
  const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
143
- const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}${wsUrl.search}`;
152
+ const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
144
153
  logger().debug({ msg: "connecting to websocket", url: finalWsUrl });
145
- const ws = new WebSocket2(finalWsUrl, [
146
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
147
- "rivetkit"
148
- ]);
154
+ const protocols = [];
155
+ protocols.push(`${WS_PROTOCOL_TARGET}actor`);
156
+ protocols.push(`${WS_PROTOCOL_ACTOR}${actorId}`);
157
+ protocols.push(`${WS_PROTOCOL_ENCODING}${encoding2}`);
158
+ protocols.push(`${WS_PROTOCOL_TRANSPORT}${transport}`);
159
+ protocols.push(
160
+ `${WS_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
161
+ );
162
+ if (params !== void 0) {
163
+ protocols.push(
164
+ `${WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
165
+ );
166
+ }
167
+ const ws = new WebSocket2(finalWsUrl, protocols);
149
168
  return ws;
150
169
  },
151
170
  async proxyRequest(c, actorRequest, actorId) {
152
171
  return await this.sendRequest(actorId, actorRequest);
153
172
  },
154
- proxyWebSocket(_c, _path, _actorId, _encoding, _params, _authData) {
173
+ proxyWebSocket(_c, _path, _actorId, _encoding, _params) {
155
174
  throw "UNIMPLEMENTED";
156
175
  },
157
176
  displayInformation() {
158
177
  return { name: "Test Inline", properties: {} };
159
- }
178
+ },
179
+ // TODO:
180
+ getOrCreateInspectorAccessToken: () => ""
160
181
  // action: async <Args extends Array<unknown> = unknown[], Response = unknown>(
161
182
  // _c: HonoContext | undefined,
162
183
  // actorQuery: ActorQuery,
@@ -492,7 +513,8 @@ async function makeInlineRequest(endpoint, encoding, transport, method, args) {
492
513
  transport,
493
514
  method,
494
515
  args
495
- })
516
+ }),
517
+ duplex: "half"
496
518
  });
497
519
  if (!response.ok) {
498
520
  throw new Error(`Failed to call inline ${method}: ${response.statusText}`);
@@ -533,12 +555,16 @@ async function setupDriverTest(c, driverTestConfig) {
533
555
  transport: driverTestConfig.transport
534
556
  });
535
557
  } else if (driverTestConfig.clientType === "inline") {
558
+ const transport = driverTestConfig.transport ?? "websocket";
536
559
  const managerDriver = createTestInlineClientDriver(
537
560
  endpoint,
538
561
  "bare",
539
- driverTestConfig.transport ?? "websocket"
562
+ transport
540
563
  );
541
- client = createClientWithDriver(managerDriver);
564
+ const runConfig = RunConfigSchema.parse({
565
+ transport
566
+ });
567
+ client = createClientWithDriver(managerDriver, runConfig);
542
568
  } else {
543
569
  assertUnreachable(driverTestConfig.clientType);
544
570
  }
@@ -641,7 +667,7 @@ function runActionFeaturesTests(driverTestConfig) {
641
667
  }
642
668
 
643
669
  // src/driver-test-suite/tests/actor-conn.ts
644
- import { describe as describe2, expect as expect2, test as test2 } from "vitest";
670
+ import { describe as describe2, expect as expect2, test as test2, vi as vi2 } from "vitest";
645
671
  function runActorConnTests(driverTestConfig) {
646
672
  describe2("Actor Connection Tests", () => {
647
673
  describe2("Connection Methods", () => {
@@ -688,17 +714,19 @@ function runActorConnTests(driverTestConfig) {
688
714
  const handle = client.counter.getOrCreate(["test-mixed-rpc-ws"]);
689
715
  const connection = handle.connect();
690
716
  const receivedEvents = [];
691
- const receivedEventsPromise = new Promise((resolve) => {
692
- connection.on("newCount", (count) => {
693
- receivedEvents.push(count);
694
- if (receivedEvents.includes(1) && receivedEvents.includes(6) && receivedEvents.includes(9))
695
- resolve(void 0);
696
- });
717
+ connection.on("newCount", (count) => {
718
+ receivedEvents.push(count);
719
+ });
720
+ await vi2.waitFor(async () => {
721
+ await connection.setCount(1);
722
+ expect2(receivedEvents).includes(1);
723
+ });
724
+ await handle.setCount(2);
725
+ await handle.setCount(3);
726
+ await vi2.waitFor(() => {
727
+ expect2(receivedEvents).includes(2);
728
+ expect2(receivedEvents).includes(3);
697
729
  });
698
- await connection.increment(1);
699
- await handle.increment(5);
700
- await handle.increment(3);
701
- await receivedEventsPromise;
702
730
  await connection.dispose();
703
731
  });
704
732
  test2("should receive events via broadcast", async (c) => {
@@ -709,10 +737,15 @@ function runActorConnTests(driverTestConfig) {
709
737
  connection.on("newCount", (count) => {
710
738
  receivedEvents.push(count);
711
739
  });
712
- await connection.increment(5);
713
- await connection.increment(3);
714
- expect2(receivedEvents).toContain(5);
715
- expect2(receivedEvents).toContain(8);
740
+ await vi2.waitFor(
741
+ async () => {
742
+ await connection.setCount(5);
743
+ await connection.setCount(8);
744
+ expect2(receivedEvents).toContain(5);
745
+ expect2(receivedEvents).toContain(8);
746
+ },
747
+ { timeout: 1e4 }
748
+ );
716
749
  await connection.dispose();
717
750
  });
718
751
  test2("should handle one-time events with once()", async (c) => {
@@ -725,8 +758,10 @@ function runActorConnTests(driverTestConfig) {
725
758
  });
726
759
  await connection.increment(5);
727
760
  await connection.increment(3);
728
- expect2(receivedEvents).toEqual([5]);
729
- expect2(receivedEvents).not.toContain(8);
761
+ await vi2.waitFor(() => {
762
+ expect2(receivedEvents).toEqual([5]);
763
+ expect2(receivedEvents).not.toContain(8);
764
+ });
730
765
  await connection.dispose();
731
766
  });
732
767
  test2("should unsubscribe from events", async (c) => {
@@ -737,10 +772,12 @@ function runActorConnTests(driverTestConfig) {
737
772
  const unsubscribe = connection.on("newCount", (count) => {
738
773
  receivedEvents.push(count);
739
774
  });
740
- await connection.increment(5);
775
+ await vi2.waitFor(async () => {
776
+ await connection.setCount(5);
777
+ expect2(receivedEvents).toEqual([5]);
778
+ });
741
779
  unsubscribe();
742
- await connection.increment(3);
743
- expect2(receivedEvents).toEqual([5]);
780
+ await connection.setCount(8);
744
781
  expect2(receivedEvents).not.toContain(8);
745
782
  await connection.dispose();
746
783
  });
@@ -766,7 +803,9 @@ function runActorConnTests(driverTestConfig) {
766
803
  });
767
804
  });
768
805
  describe2("Lifecycle Hooks", () => {
769
- test2("should trigger lifecycle hooks", async (c) => {
806
+ test2.skipIf(
807
+ driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
808
+ )("should trigger lifecycle hooks", async (c) => {
770
809
  const { client } = await setupDriverTest(c, driverTestConfig);
771
810
  const connHandle = client.counterWithLifecycle.getOrCreate(
772
811
  ["test-lifecycle"],
@@ -778,81 +817,30 @@ function runActorConnTests(driverTestConfig) {
778
817
  const events = await connection.getEvents();
779
818
  expect2(events).toEqual(["onStart", "onBeforeConnect", "onConnect"]);
780
819
  await connection.dispose();
781
- const handle = client.counterWithLifecycle.getOrCreate([
782
- "test-lifecycle"
783
- ]);
784
- const finalEvents = await handle.getEvents();
785
- expect2(finalEvents).toBeOneOf([
786
- // Still active
787
- ["onStart", "onBeforeConnect", "onConnect", "onDisconnect"],
788
- // Went to sleep and woke back up
789
- [
790
- "onStart",
791
- "onBeforeConnect",
792
- "onConnect",
793
- "onDisconnect",
794
- "onStart"
795
- ]
796
- ]);
797
- });
798
- });
799
- describe2("Connection Liveness", () => {
800
- test2.skip("should return correct liveness status for connections", async (c) => {
801
- const { client } = await setupDriverTest(c, driverTestConfig);
802
- const handle = client.connLivenessActor.getOrCreate([
803
- "test-liveness-status"
804
- ]);
805
- const connA = handle.connect();
806
- const connB = handle.connect();
807
- const connAId = await connA.getConnectionId();
808
- const connBId = await connB.getConnectionId();
809
- await connA.increment(5);
810
- await connB.increment(5);
811
- const counter = await handle.getCounter();
812
- expect2(counter).toBe(10);
813
- const connectionsStatusBeforeKill = await handle.getWsConnectionsLiveness();
814
- expect2(connectionsStatusBeforeKill).toHaveLength(2);
815
- expect2(connectionsStatusBeforeKill).toContainEqual(
816
- expect2.objectContaining({
817
- id: connAId,
818
- status: "connected",
819
- lastSeen: FAKE_TIME.getTime()
820
- })
821
- );
822
- expect2(connectionsStatusBeforeKill).toContainEqual(
823
- expect2.objectContaining({
824
- id: connBId,
825
- status: "connected",
826
- lastSeen: FAKE_TIME.getTime()
827
- })
828
- );
829
- await handle.kill(connAId);
830
- const connectionsStatusAfterKill = await handle.getWsConnectionsLiveness();
831
- expect2(connectionsStatusAfterKill).toEqual(
832
- expect2.arrayContaining([
833
- expect2.objectContaining({
834
- id: connAId,
835
- status: "reconnecting",
836
- lastSeen: FAKE_TIME.getTime()
837
- }),
838
- expect2.objectContaining({
839
- id: connBId,
840
- status: "connected",
841
- lastSeen: FAKE_TIME.getTime()
842
- })
843
- ])
844
- );
845
- await waitFor(driverTestConfig, 5e3);
846
- const connectionsStatusAfterCleanup = await handle.getWsConnectionsLiveness();
847
- expect2(connectionsStatusAfterCleanup).not.toContainEqual(
848
- expect2.objectContaining({
849
- id: connAId
850
- })
851
- );
852
- expect2(connectionsStatusAfterCleanup).toContainEqual(
853
- expect2.objectContaining({
854
- id: connBId
855
- })
820
+ await vi2.waitFor(
821
+ async () => {
822
+ const handle = client.counterWithLifecycle.getOrCreate([
823
+ "test-lifecycle"
824
+ ]);
825
+ const finalEvents = await handle.getEvents();
826
+ expect2(finalEvents).toBeOneOf([
827
+ // Still active
828
+ ["onStart", "onBeforeConnect", "onConnect", "onDisconnect"],
829
+ // Went to sleep and woke back up
830
+ [
831
+ "onStart",
832
+ "onBeforeConnect",
833
+ "onConnect",
834
+ "onDisconnect",
835
+ "onStart"
836
+ ]
837
+ ]);
838
+ },
839
+ // NOTE: High timeout required for Cloudflare Workers
840
+ {
841
+ timeout: 1e4,
842
+ interval: 100
843
+ }
856
844
  );
857
845
  });
858
846
  });
@@ -860,7 +848,7 @@ function runActorConnTests(driverTestConfig) {
860
848
  }
861
849
 
862
850
  // src/driver-test-suite/tests/actor-conn-state.ts
863
- import { describe as describe3, expect as expect3, test as test3, vi as vi2 } from "vitest";
851
+ import { describe as describe3, expect as expect3, test as test3, vi as vi3 } from "vitest";
864
852
  function runActorConnStateTests(driverTestConfig) {
865
853
  describe3("Actor Connection State Tests", () => {
866
854
  describe3("Connection State Initialization", () => {
@@ -940,21 +928,57 @@ function runActorConnStateTests(driverTestConfig) {
940
928
  });
941
929
  });
942
930
  describe3("Connection Lifecycle", () => {
943
- test3("should track connection and disconnection events", async (c) => {
931
+ test3.skipIf(
932
+ driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
933
+ )("should track connection and disconnection events", async (c) => {
944
934
  const { client } = await setupDriverTest(c, driverTestConfig);
945
- const handle = client.connStateActor.getOrCreate();
946
- const conn = handle.connect();
935
+ const debugHandle = client.connStateActor.getOrCreate(void 0, {
936
+ params: { noCount: true }
937
+ });
938
+ const conn = client.connStateActor.getOrCreate().connect();
947
939
  const connState = await conn.getConnectionState();
948
- const connectionIds = await conn.getConnectionIds();
949
- expect3(connectionIds).toContain(connState.id);
950
- const initialDisconnections = await conn.getDisconnectionCount();
940
+ await vi3.waitFor(async () => {
941
+ const connectionIds = await debugHandle.getConnectionIds();
942
+ expect3(connectionIds).toContain(connState.id);
943
+ });
944
+ await vi3.waitFor(async () => {
945
+ const disconnects = await debugHandle.getDisconnectionCount();
946
+ expect3(disconnects).toBe(0);
947
+ });
951
948
  await conn.dispose();
952
- const newConn = handle.connect();
953
- await vi2.waitFor(async () => {
954
- const newDisconnections = await newConn.getDisconnectionCount();
955
- expect3(newDisconnections).toBeGreaterThan(initialDisconnections);
949
+ await vi3.waitFor(
950
+ async () => {
951
+ console.log("disconnects before");
952
+ const disconnects = await debugHandle.getDisconnectionCount();
953
+ console.log("disconnects", disconnects);
954
+ expect3(disconnects).toBe(1);
955
+ },
956
+ // SSE takes a long time to disconnect on CF Workers
957
+ {
958
+ timeout: 1e4,
959
+ interval: 100
960
+ }
961
+ );
962
+ const newConn = client.connStateActor.getOrCreate().connect();
963
+ await vi3.waitFor(async () => {
964
+ const connectionIds = await debugHandle.getConnectionIds();
965
+ console.log("conn ids", connectionIds);
966
+ expect3(connectionIds.length).toBe(1);
956
967
  });
957
968
  await newConn.dispose();
969
+ await vi3.waitFor(
970
+ async () => {
971
+ console.log("A");
972
+ const disconnects = await debugHandle.getDisconnectionCount();
973
+ console.log(`B ${disconnects}`);
974
+ expect3(disconnects).toBe(2);
975
+ },
976
+ // SSE takes a long time to disconnect on CF Workers
977
+ {
978
+ timeout: 1e4,
979
+ interval: 100
980
+ }
981
+ );
958
982
  });
959
983
  test3("should update connection state", async (c) => {
960
984
  const { client } = await setupDriverTest(c, driverTestConfig);
@@ -985,14 +1009,16 @@ function runActorConnStateTests(driverTestConfig) {
985
1009
  conn2.on("directMessage", (data) => {
986
1010
  receivedMessages.push(data);
987
1011
  });
988
- const success = await conn1.sendToConnection(
989
- state2.id,
990
- "Hello from conn1"
991
- );
992
- expect3(success).toBe(true);
993
- expect3(receivedMessages.length).toBe(1);
994
- expect3(receivedMessages[0].from).toBe(state1.id);
995
- expect3(receivedMessages[0].message).toBe("Hello from conn1");
1012
+ await vi3.waitFor(async () => {
1013
+ const success = await conn1.sendToConnection(
1014
+ state2.id,
1015
+ "Hello from conn1"
1016
+ );
1017
+ expect3(success).toBe(true);
1018
+ expect3(receivedMessages.length).toBe(1);
1019
+ expect3(receivedMessages[0].from).toBe(state1.id);
1020
+ expect3(receivedMessages[0].message).toBe("Hello from conn1");
1021
+ });
996
1022
  await conn1.dispose();
997
1023
  await conn2.dispose();
998
1024
  });
@@ -1112,7 +1138,7 @@ var sleepWithLongRpc = actor({
1112
1138
  },
1113
1139
  longRunningRpc: async (c) => {
1114
1140
  c.log.info("starting long running rpc");
1115
- c.vars.longRunningResolve = Promise.withResolvers();
1141
+ c.vars.longRunningResolve = promiseWithResolvers();
1116
1142
  c.broadcast("waiting");
1117
1143
  await c.vars.longRunningResolve.promise;
1118
1144
  c.log.info("finished long running rpc");
@@ -1439,7 +1465,6 @@ function runActorSleepTests(driverTestConfig) {
1439
1465
  expect5(counts.sleepCount).toBe(0);
1440
1466
  expect5(counts.startCount).toBe(1);
1441
1467
  ws.close();
1442
- await new Promise((resolve) => setTimeout(resolve, 100));
1443
1468
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 100);
1444
1469
  {
1445
1470
  const { startCount, sleepCount } = await sleepActor.getCounts();
@@ -2507,117 +2532,214 @@ function runActorOnStateChangeTests(driverTestConfig) {
2507
2532
  });
2508
2533
  }
2509
2534
 
2535
+ // src/driver-test-suite/tests/actor-reconnect.ts
2536
+ import { describe as describe14, expect as expect13, test as test13, vi as vi4 } from "vitest";
2537
+ function runActorReconnectTests(driverTestConfig) {
2538
+ describe14("Actor Reconnection Tests", () => {
2539
+ test13("should reconnect and preserve connection state after non-clean disconnect", async (c) => {
2540
+ const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2541
+ const handle = client.counterConn.getOrCreate(["test-reconnect"]);
2542
+ const connection = handle.connect();
2543
+ await connection.increment(5);
2544
+ const connCount1 = await connection.getConnectionCount();
2545
+ expect13(connCount1).toBe(1);
2546
+ const connRaw = connection;
2547
+ await forceUncleanDisconnect(
2548
+ endpoint,
2549
+ connRaw.actorId,
2550
+ connRaw.connectionId
2551
+ );
2552
+ await vi4.waitFor(
2553
+ async () => {
2554
+ const countAfterReconnect = await connection.getCount();
2555
+ expect13(countAfterReconnect).toBe(5);
2556
+ },
2557
+ { timeout: 5e3, interval: 100 }
2558
+ );
2559
+ const connCount2 = await connection.getConnectionCount();
2560
+ expect13(connCount2).toBe(1);
2561
+ const newCount = await connection.getCount();
2562
+ expect13(newCount).toBe(5);
2563
+ await connection.dispose();
2564
+ });
2565
+ test13("should not preserve connection state after clean disconnect", async (c) => {
2566
+ const { client } = await setupDriverTest(c, driverTestConfig);
2567
+ const handle = client.counterConn.getOrCreate(["test-clean-disconnect"]);
2568
+ const connection = handle.connect();
2569
+ await connection.increment(10);
2570
+ const connCount1 = await connection.getConnectionCount();
2571
+ expect13(connCount1).toBe(1);
2572
+ await connection.dispose();
2573
+ await vi4.waitFor(
2574
+ async () => {
2575
+ const handle2 = client.counterConn.get(["test-clean-disconnect"]);
2576
+ const connCount = await handle2.getConnectionCount();
2577
+ expect13(connCount).toBe(1);
2578
+ },
2579
+ { timeout: 5e3 }
2580
+ );
2581
+ const connection2 = handle.connect();
2582
+ const countNewConnection = await connection2.getCount();
2583
+ expect13(countNewConnection).toBe(0);
2584
+ const connCount3 = await connection2.getConnectionCount();
2585
+ expect13(connCount3).toBe(1);
2586
+ await connection2.dispose();
2587
+ });
2588
+ test13("should handle multiple non-clean disconnects and reconnects", async (c) => {
2589
+ const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2590
+ const handle = client.counterConn.getOrCreate([
2591
+ "test-multiple-reconnect"
2592
+ ]);
2593
+ const connection = handle.connect();
2594
+ await connection.setCount(100);
2595
+ for (let i = 0; i < 3; i++) {
2596
+ await connection.increment(1);
2597
+ const connRaw = connection;
2598
+ await forceUncleanDisconnect(
2599
+ endpoint,
2600
+ connRaw.actorId,
2601
+ connRaw.connectionId
2602
+ );
2603
+ await vi4.waitFor(
2604
+ async () => {
2605
+ const countAfter = await connection.getCount();
2606
+ expect13(countAfter).toBe(101 + i);
2607
+ },
2608
+ { timeout: 5e3 }
2609
+ );
2610
+ const connCount = await connection.getConnectionCount();
2611
+ expect13(connCount).toBe(1);
2612
+ }
2613
+ const finalCount = await connection.getCount();
2614
+ expect13(finalCount).toBe(103);
2615
+ await connection.dispose();
2616
+ });
2617
+ });
2618
+ }
2619
+ async function forceUncleanDisconnect(endpoint, actorId, connId) {
2620
+ const response = await fetch(
2621
+ `${endpoint}/.test/force-disconnect?actor=${actorId}&conn=${connId}`,
2622
+ {
2623
+ method: "POST"
2624
+ }
2625
+ );
2626
+ if (!response.ok) {
2627
+ const text = await response.text();
2628
+ throw new Error(`Failed to force disconnect: ${text}`);
2629
+ }
2630
+ }
2631
+
2510
2632
  // src/driver-test-suite/tests/actor-vars.ts
2511
- import { describe as describe14, expect as expect13, test as test13 } from "vitest";
2633
+ import { describe as describe15, expect as expect14, test as test14 } from "vitest";
2512
2634
  function runActorVarsTests(driverTestConfig) {
2513
- describe14("Actor Variables", () => {
2514
- describe14("Static vars", () => {
2515
- test13("should provide access to static vars", async (c) => {
2635
+ describe15("Actor Variables", () => {
2636
+ describe15("Static vars", () => {
2637
+ test14("should provide access to static vars", async (c) => {
2516
2638
  const { client } = await setupDriverTest(c, driverTestConfig);
2517
2639
  const instance = client.staticVarActor.getOrCreate();
2518
2640
  const result = await instance.getVars();
2519
- expect13(result).toEqual({ counter: 42, name: "test-actor" });
2641
+ expect14(result).toEqual({ counter: 42, name: "test-actor" });
2520
2642
  const name = await instance.getName();
2521
- expect13(name).toBe("test-actor");
2643
+ expect14(name).toBe("test-actor");
2522
2644
  });
2523
2645
  });
2524
- describe14("Deep cloning of static vars", () => {
2525
- test13("should deep clone static vars between actor instances", async (c) => {
2646
+ describe15("Deep cloning of static vars", () => {
2647
+ test14("should deep clone static vars between actor instances", async (c) => {
2526
2648
  const { client } = await setupDriverTest(c, driverTestConfig);
2527
2649
  const instance1 = client.nestedVarActor.getOrCreate(["instance1"]);
2528
2650
  const instance2 = client.nestedVarActor.getOrCreate(["instance2"]);
2529
2651
  const modifiedVars = await instance1.modifyNested();
2530
- expect13(modifiedVars.nested.value).toBe("modified");
2531
- expect13(modifiedVars.nested.array).toContain(4);
2532
- expect13(modifiedVars.nested.obj.key).toBe("new-value");
2652
+ expect14(modifiedVars.nested.value).toBe("modified");
2653
+ expect14(modifiedVars.nested.array).toContain(4);
2654
+ expect14(modifiedVars.nested.obj.key).toBe("new-value");
2533
2655
  const instance2Vars = await instance2.getVars();
2534
- expect13(instance2Vars.nested.value).toBe("original");
2535
- expect13(instance2Vars.nested.array).toEqual([1, 2, 3]);
2536
- expect13(instance2Vars.nested.obj.key).toBe("value");
2656
+ expect14(instance2Vars.nested.value).toBe("original");
2657
+ expect14(instance2Vars.nested.array).toEqual([1, 2, 3]);
2658
+ expect14(instance2Vars.nested.obj.key).toBe("value");
2537
2659
  });
2538
2660
  });
2539
- describe14("createVars", () => {
2540
- test13("should support dynamic vars creation", async (c) => {
2661
+ describe15("createVars", () => {
2662
+ test14("should support dynamic vars creation", async (c) => {
2541
2663
  const { client } = await setupDriverTest(c, driverTestConfig);
2542
2664
  const instance = client.dynamicVarActor.getOrCreate();
2543
2665
  const vars = await instance.getVars();
2544
- expect13(vars).toHaveProperty("random");
2545
- expect13(vars).toHaveProperty("computed");
2546
- expect13(typeof vars.random).toBe("number");
2547
- expect13(typeof vars.computed).toBe("string");
2548
- expect13(vars.computed).toMatch(/^Actor-\d+$/);
2666
+ expect14(vars).toHaveProperty("random");
2667
+ expect14(vars).toHaveProperty("computed");
2668
+ expect14(typeof vars.random).toBe("number");
2669
+ expect14(typeof vars.computed).toBe("string");
2670
+ expect14(vars.computed).toMatch(/^Actor-\d+$/);
2549
2671
  });
2550
- test13("should create different vars for different instances", async (c) => {
2672
+ test14("should create different vars for different instances", async (c) => {
2551
2673
  const { client } = await setupDriverTest(c, driverTestConfig);
2552
2674
  const instance1 = client.uniqueVarActor.getOrCreate(["test1"]);
2553
2675
  const instance2 = client.uniqueVarActor.getOrCreate(["test2"]);
2554
2676
  const vars1 = await instance1.getVars();
2555
2677
  const vars2 = await instance2.getVars();
2556
- expect13(vars1.id).not.toBe(vars2.id);
2678
+ expect14(vars1.id).not.toBe(vars2.id);
2557
2679
  });
2558
2680
  });
2559
- describe14("Driver Context", () => {
2560
- test13("should provide access to driver context", async (c) => {
2681
+ describe15("Driver Context", () => {
2682
+ test14("should provide access to driver context", async (c) => {
2561
2683
  const { client } = await setupDriverTest(c, driverTestConfig);
2562
2684
  const instance = client.driverCtxActor.getOrCreate();
2563
2685
  const vars = await instance.getVars();
2564
- expect13(vars).toHaveProperty("hasDriverCtx");
2686
+ expect14(vars).toHaveProperty("hasDriverCtx");
2565
2687
  });
2566
2688
  });
2567
2689
  });
2568
2690
  }
2569
2691
 
2570
2692
  // src/driver-test-suite/tests/manager-driver.ts
2571
- import { describe as describe15, expect as expect14, test as test14 } from "vitest";
2693
+ import { describe as describe16, expect as expect15, test as test15 } from "vitest";
2572
2694
  function runManagerDriverTests(driverTestConfig) {
2573
- describe15("Manager Driver Tests", () => {
2574
- describe15("Client Connection Methods", () => {
2575
- test14("connect() - finds or creates a actor", async (c) => {
2695
+ describe16("Manager Driver Tests", () => {
2696
+ describe16("Client Connection Methods", () => {
2697
+ test15("connect() - finds or creates a actor", async (c) => {
2576
2698
  const { client } = await setupDriverTest(c, driverTestConfig);
2577
2699
  const counterA = client.counter.getOrCreate();
2578
2700
  await counterA.increment(5);
2579
2701
  const counterAAgain = client.counter.getOrCreate();
2580
2702
  const count = await counterAAgain.increment(0);
2581
- expect14(count).toBe(5);
2703
+ expect15(count).toBe(5);
2582
2704
  const counterB = client.counter.getOrCreate(["counter-b", "testing"]);
2583
2705
  await counterB.increment(10);
2584
2706
  const countB = await counterB.increment(0);
2585
- expect14(countB).toBe(10);
2707
+ expect15(countB).toBe(10);
2586
2708
  });
2587
- test14("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
2709
+ test15("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
2588
2710
  const { client } = await setupDriverTest(c, driverTestConfig);
2589
2711
  const uniqueKey = ["duplicate-actor-test", crypto.randomUUID()];
2590
2712
  const counter = client.counter.getOrCreate(uniqueKey);
2591
2713
  await counter.increment(5);
2592
2714
  try {
2593
2715
  await client.counter.create(uniqueKey);
2594
- expect14.fail("did not error on duplicate create");
2716
+ expect15.fail("did not error on duplicate create");
2595
2717
  } catch (err) {
2596
- expect14(err.group).toBe("actor");
2597
- expect14(err.code).toBe("already_exists");
2718
+ expect15(err.group).toBe("actor");
2719
+ expect15(err.code).toBe("already_exists");
2598
2720
  }
2599
2721
  const count = await counter.increment(0);
2600
- expect14(count).toBe(5);
2722
+ expect15(count).toBe(5);
2601
2723
  });
2602
2724
  });
2603
- describe15("Connection Options", () => {
2604
- test14("get without create prevents actor creation", async (c) => {
2725
+ describe16("Connection Options", () => {
2726
+ test15("get without create prevents actor creation", async (c) => {
2605
2727
  const { client } = await setupDriverTest(c, driverTestConfig);
2606
2728
  const nonexistentId = `nonexistent-${crypto.randomUUID()}`;
2607
2729
  try {
2608
2730
  await client.counter.get([nonexistentId]).resolve();
2609
- expect14.fail("did not error for get");
2731
+ expect15.fail("did not error for get");
2610
2732
  } catch (err) {
2611
- expect14(err.group).toBe("actor");
2612
- expect14(err.code).toBe("not_found");
2733
+ expect15(err.group).toBe("actor");
2734
+ expect15(err.code).toBe("not_found");
2613
2735
  }
2614
2736
  const createdCounter = client.counter.getOrCreate(nonexistentId);
2615
2737
  await createdCounter.increment(3);
2616
2738
  const retrievedCounter = client.counter.get(nonexistentId);
2617
2739
  const count = await retrievedCounter.increment(0);
2618
- expect14(count).toBe(3);
2740
+ expect15(count).toBe(3);
2619
2741
  });
2620
- test14("connection params are passed to actors", async (c) => {
2742
+ test15("connection params are passed to actors", async (c) => {
2621
2743
  const { client } = await setupDriverTest(c, driverTestConfig);
2622
2744
  const counter = client.counter.getOrCreate(void 0, {
2623
2745
  params: {
@@ -2628,20 +2750,20 @@ function runManagerDriverTests(driverTestConfig) {
2628
2750
  });
2629
2751
  await counter.increment(1);
2630
2752
  const count = await counter.increment(0);
2631
- expect14(count).toBe(1);
2753
+ expect15(count).toBe(1);
2632
2754
  });
2633
2755
  });
2634
- describe15("Actor Creation & Retrieval", () => {
2635
- test14("creates and retrieves actors by ID", async (c) => {
2756
+ describe16("Actor Creation & Retrieval", () => {
2757
+ test15("creates and retrieves actors by ID", async (c) => {
2636
2758
  const { client } = await setupDriverTest(c, driverTestConfig);
2637
2759
  const uniqueId = `test-counter-${crypto.randomUUID()}`;
2638
2760
  const counter = client.counter.getOrCreate([uniqueId]);
2639
2761
  await counter.increment(10);
2640
2762
  const retrievedCounter = client.counter.getOrCreate([uniqueId]);
2641
2763
  const count = await retrievedCounter.increment(0);
2642
- expect14(count).toBe(10);
2764
+ expect15(count).toBe(10);
2643
2765
  });
2644
- test14("passes input to actor during creation", async (c) => {
2766
+ test15("passes input to actor during creation", async (c) => {
2645
2767
  const { client } = await setupDriverTest(c, driverTestConfig);
2646
2768
  const testInput = {
2647
2769
  name: "test-actor",
@@ -2652,17 +2774,17 @@ function runManagerDriverTests(driverTestConfig) {
2652
2774
  input: testInput
2653
2775
  });
2654
2776
  const inputs = await actor2.getInputs();
2655
- expect14(inputs.initialInput).toEqual(testInput);
2656
- expect14(inputs.onCreateInput).toEqual(testInput);
2777
+ expect15(inputs.initialInput).toEqual(testInput);
2778
+ expect15(inputs.onCreateInput).toEqual(testInput);
2657
2779
  });
2658
- test14("input is undefined when not provided", async (c) => {
2780
+ test15("input is undefined when not provided", async (c) => {
2659
2781
  const { client } = await setupDriverTest(c, driverTestConfig);
2660
2782
  const actor2 = await client.inputActor.create();
2661
2783
  const inputs = await actor2.getInputs();
2662
- expect14(inputs.initialInput).toBeUndefined();
2663
- expect14(inputs.onCreateInput).toBeUndefined();
2784
+ expect15(inputs.initialInput).toBeUndefined();
2785
+ expect15(inputs.onCreateInput).toBeUndefined();
2664
2786
  });
2665
- test14("getOrCreate passes input to actor during creation", async (c) => {
2787
+ test15("getOrCreate passes input to actor during creation", async (c) => {
2666
2788
  const { client } = await setupDriverTest(c, driverTestConfig);
2667
2789
  const uniqueKey = [`input-test-${crypto.randomUUID()}`];
2668
2790
  const testInput = {
@@ -2674,16 +2796,16 @@ function runManagerDriverTests(driverTestConfig) {
2674
2796
  createWithInput: testInput
2675
2797
  });
2676
2798
  const inputs = await actor2.getInputs();
2677
- expect14(inputs.initialInput).toEqual(testInput);
2678
- expect14(inputs.onCreateInput).toEqual(testInput);
2799
+ expect15(inputs.initialInput).toEqual(testInput);
2800
+ expect15(inputs.onCreateInput).toEqual(testInput);
2679
2801
  const existingActor = client.inputActor.getOrCreate(uniqueKey);
2680
2802
  const existingInputs = await existingActor.getInputs();
2681
- expect14(existingInputs.initialInput).toEqual(testInput);
2682
- expect14(existingInputs.onCreateInput).toEqual(testInput);
2803
+ expect15(existingInputs.initialInput).toEqual(testInput);
2804
+ expect15(existingInputs.onCreateInput).toEqual(testInput);
2683
2805
  });
2684
2806
  });
2685
- describe15("Key Matching", () => {
2686
- test14("matches actors only with exactly the same keys", async (c) => {
2807
+ describe16("Key Matching", () => {
2808
+ test15("matches actors only with exactly the same keys", async (c) => {
2687
2809
  const { client } = await setupDriverTest(c, driverTestConfig);
2688
2810
  const originalCounter = client.counter.getOrCreate([
2689
2811
  "counter-match",
@@ -2697,37 +2819,37 @@ function runManagerDriverTests(driverTestConfig) {
2697
2819
  "us-east"
2698
2820
  ]);
2699
2821
  const exactMatchCount = await exactMatchCounter.increment(0);
2700
- expect14(exactMatchCount).toBe(10);
2822
+ expect15(exactMatchCount).toBe(10);
2701
2823
  const subsetMatchCounter = client.counter.getOrCreate([
2702
2824
  "counter-match",
2703
2825
  "test"
2704
2826
  ]);
2705
2827
  const subsetMatchCount = await subsetMatchCounter.increment(0);
2706
- expect14(subsetMatchCount).toBe(0);
2828
+ expect15(subsetMatchCount).toBe(0);
2707
2829
  const singleKeyCounter = client.counter.getOrCreate(["counter-match"]);
2708
2830
  const singleKeyCount = await singleKeyCounter.increment(0);
2709
- expect14(singleKeyCount).toBe(0);
2831
+ expect15(singleKeyCount).toBe(0);
2710
2832
  });
2711
- test14("string key matches array with single string key", async (c) => {
2833
+ test15("string key matches array with single string key", async (c) => {
2712
2834
  const { client } = await setupDriverTest(c, driverTestConfig);
2713
2835
  const stringKeyCounter = client.counter.getOrCreate("string-key-test");
2714
2836
  await stringKeyCounter.increment(7);
2715
2837
  const arrayKeyCounter = client.counter.getOrCreate(["string-key-test"]);
2716
2838
  const count = await arrayKeyCounter.increment(0);
2717
- expect14(count).toBe(7);
2839
+ expect15(count).toBe(7);
2718
2840
  });
2719
- test14("undefined key matches empty array key and no key", async (c) => {
2841
+ test15("undefined key matches empty array key and no key", async (c) => {
2720
2842
  const { client } = await setupDriverTest(c, driverTestConfig);
2721
2843
  const undefinedKeyCounter = client.counter.getOrCreate(void 0);
2722
2844
  await undefinedKeyCounter.increment(12);
2723
2845
  const emptyArrayKeyCounter = client.counter.getOrCreate([]);
2724
2846
  const emptyArrayCount = await emptyArrayKeyCounter.increment(0);
2725
- expect14(emptyArrayCount).toBe(12);
2847
+ expect15(emptyArrayCount).toBe(12);
2726
2848
  const noKeyCounter = client.counter.getOrCreate();
2727
2849
  const noKeyCount = await noKeyCounter.increment(0);
2728
- expect14(noKeyCount).toBe(12);
2850
+ expect15(noKeyCount).toBe(12);
2729
2851
  });
2730
- test14("no keys does not match actors with keys", async (c) => {
2852
+ test15("no keys does not match actors with keys", async (c) => {
2731
2853
  const { client } = await setupDriverTest(c, driverTestConfig);
2732
2854
  const keyedCounter = client.counter.getOrCreate([
2733
2855
  "counter-with-keys",
@@ -2736,9 +2858,9 @@ function runManagerDriverTests(driverTestConfig) {
2736
2858
  await keyedCounter.increment(15);
2737
2859
  const noKeysCounter = client.counter.getOrCreate();
2738
2860
  const count = await noKeysCounter.increment(10);
2739
- expect14(count).toBe(10);
2861
+ expect15(count).toBe(10);
2740
2862
  });
2741
- test14("actors with keys match actors with no keys", async (c) => {
2863
+ test15("actors with keys match actors with no keys", async (c) => {
2742
2864
  const { client } = await setupDriverTest(c, driverTestConfig);
2743
2865
  const noKeysCounter = client.counter.getOrCreate();
2744
2866
  await noKeysCounter.increment(25);
@@ -2747,11 +2869,11 @@ function runManagerDriverTests(driverTestConfig) {
2747
2869
  "prod"
2748
2870
  ]);
2749
2871
  const keyedCount = await keyedCounter.increment(0);
2750
- expect14(keyedCount).toBe(0);
2872
+ expect15(keyedCount).toBe(0);
2751
2873
  });
2752
2874
  });
2753
- describe15("Multiple Actor Instances", () => {
2754
- test14("creates multiple actor instances of the same type", async (c) => {
2875
+ describe16("Multiple Actor Instances", () => {
2876
+ test15("creates multiple actor instances of the same type", async (c) => {
2755
2877
  const { client } = await setupDriverTest(c, driverTestConfig);
2756
2878
  const instance1 = client.counter.getOrCreate(["multi-1"]);
2757
2879
  const instance2 = client.counter.getOrCreate(["multi-2"]);
@@ -2762,35 +2884,35 @@ function runManagerDriverTests(driverTestConfig) {
2762
2884
  const retrieved1 = client.counter.getOrCreate(["multi-1"]);
2763
2885
  const retrieved2 = client.counter.getOrCreate(["multi-2"]);
2764
2886
  const retrieved3 = client.counter.getOrCreate(["multi-3"]);
2765
- expect14(await retrieved1.increment(0)).toBe(1);
2766
- expect14(await retrieved2.increment(0)).toBe(2);
2767
- expect14(await retrieved3.increment(0)).toBe(3);
2887
+ expect15(await retrieved1.increment(0)).toBe(1);
2888
+ expect15(await retrieved2.increment(0)).toBe(2);
2889
+ expect15(await retrieved3.increment(0)).toBe(3);
2768
2890
  });
2769
- test14("handles default instance with no explicit ID", async (c) => {
2891
+ test15("handles default instance with no explicit ID", async (c) => {
2770
2892
  const { client } = await setupDriverTest(c, driverTestConfig);
2771
2893
  const defaultCounter = client.counter.getOrCreate();
2772
2894
  await defaultCounter.increment(5);
2773
2895
  const sameDefaultCounter = client.counter.getOrCreate();
2774
2896
  const count = await sameDefaultCounter.increment(0);
2775
- expect14(count).toBe(5);
2897
+ expect15(count).toBe(5);
2776
2898
  });
2777
2899
  });
2778
2900
  });
2779
2901
  }
2780
2902
 
2781
2903
  // src/driver-test-suite/tests/raw-http.ts
2782
- import { describe as describe16, expect as expect15, test as test15 } from "vitest";
2904
+ import { describe as describe17, expect as expect16, test as test16 } from "vitest";
2783
2905
  function runRawHttpTests(driverTestConfig) {
2784
- describe16("raw http", () => {
2785
- test15("should handle raw HTTP GET requests", async (c) => {
2906
+ describe17("raw http", () => {
2907
+ test16("should handle raw HTTP GET requests", async (c) => {
2786
2908
  const { client } = await setupDriverTest(c, driverTestConfig);
2787
2909
  const actor2 = client.rawHttpActor.getOrCreate(["test"]);
2788
2910
  const helloResponse = await actor2.fetch("api/hello");
2789
- expect15(helloResponse.ok).toBe(true);
2911
+ expect16(helloResponse.ok).toBe(true);
2790
2912
  const helloData = await helloResponse.json();
2791
- expect15(helloData).toEqual({ message: "Hello from actor!" });
2913
+ expect16(helloData).toEqual({ message: "Hello from actor!" });
2792
2914
  });
2793
- test15("should handle raw HTTP POST requests with echo", async (c) => {
2915
+ test16("should handle raw HTTP POST requests with echo", async (c) => {
2794
2916
  const { client } = await setupDriverTest(c, driverTestConfig);
2795
2917
  const actor2 = client.rawHttpActor.getOrCreate(["test"]);
2796
2918
  const testData = { test: "data", number: 123 };
@@ -2801,22 +2923,22 @@ function runRawHttpTests(driverTestConfig) {
2801
2923
  },
2802
2924
  body: JSON.stringify(testData)
2803
2925
  });
2804
- expect15(echoResponse.ok).toBe(true);
2926
+ expect16(echoResponse.ok).toBe(true);
2805
2927
  const echoData = await echoResponse.json();
2806
- expect15(echoData).toEqual(testData);
2928
+ expect16(echoData).toEqual(testData);
2807
2929
  });
2808
- test15("should track state across raw HTTP requests", async (c) => {
2930
+ test16("should track state across raw HTTP requests", async (c) => {
2809
2931
  const { client } = await setupDriverTest(c, driverTestConfig);
2810
2932
  const actor2 = client.rawHttpActor.getOrCreate(["state-test"]);
2811
2933
  await actor2.fetch("api/hello");
2812
2934
  await actor2.fetch("api/hello");
2813
2935
  await actor2.fetch("api/state");
2814
2936
  const stateResponse = await actor2.fetch("api/state");
2815
- expect15(stateResponse.ok).toBe(true);
2937
+ expect16(stateResponse.ok).toBe(true);
2816
2938
  const stateData = await stateResponse.json();
2817
- expect15(stateData.requestCount).toBe(4);
2939
+ expect16(stateData.requestCount).toBe(4);
2818
2940
  });
2819
- test15("should pass headers correctly", async (c) => {
2941
+ test16("should pass headers correctly", async (c) => {
2820
2942
  const { client } = await setupDriverTest(c, driverTestConfig);
2821
2943
  const actor2 = client.rawHttpActor.getOrCreate(["headers-test"]);
2822
2944
  const customHeaders = {
@@ -2826,40 +2948,40 @@ function runRawHttpTests(driverTestConfig) {
2826
2948
  const response = await actor2.fetch("api/headers", {
2827
2949
  headers: customHeaders
2828
2950
  });
2829
- expect15(response.ok).toBe(true);
2951
+ expect16(response.ok).toBe(true);
2830
2952
  const headers = await response.json();
2831
- expect15(headers["x-custom-header"]).toBe("test-value");
2832
- expect15(headers["x-another-header"]).toBe("another-value");
2953
+ expect16(headers["x-custom-header"]).toBe("test-value");
2954
+ expect16(headers["x-another-header"]).toBe("another-value");
2833
2955
  });
2834
- test15("should return 404 for unhandled paths", async (c) => {
2956
+ test16("should return 404 for unhandled paths", async (c) => {
2835
2957
  const { client } = await setupDriverTest(c, driverTestConfig);
2836
2958
  const actor2 = client.rawHttpActor.getOrCreate(["404-test"]);
2837
2959
  const response = await actor2.fetch("api/nonexistent");
2838
- expect15(response.ok).toBe(false);
2839
- expect15(response.status).toBe(404);
2960
+ expect16(response.ok).toBe(false);
2961
+ expect16(response.status).toBe(404);
2840
2962
  });
2841
- test15("should return 404 when no onFetch handler defined", async (c) => {
2963
+ test16("should return 404 when no onFetch handler defined", async (c) => {
2842
2964
  const { client } = await setupDriverTest(c, driverTestConfig);
2843
2965
  const actor2 = client.rawHttpNoHandlerActor.getOrCreate(["no-handler"]);
2844
2966
  const response = await actor2.fetch("api/anything");
2845
- expect15(response.ok).toBe(false);
2846
- expect15(response.status).toBe(404);
2967
+ expect16(response.ok).toBe(false);
2968
+ expect16(response.status).toBe(404);
2847
2969
  });
2848
- test15("should return 500 error when onFetch returns void", async (c) => {
2970
+ test16("should return 500 error when onFetch returns void", async (c) => {
2849
2971
  const { client } = await setupDriverTest(c, driverTestConfig);
2850
2972
  const actor2 = client.rawHttpVoidReturnActor.getOrCreate(["void-return"]);
2851
2973
  const response = await actor2.fetch("api/anything");
2852
- expect15(response.ok).toBe(false);
2853
- expect15(response.status).toBe(500);
2974
+ expect16(response.ok).toBe(false);
2975
+ expect16(response.status).toBe(500);
2854
2976
  try {
2855
2977
  const errorData = await response.json();
2856
- expect15(errorData.message).toContain(
2978
+ expect16(errorData.message).toContain(
2857
2979
  "onFetch handler must return a Response"
2858
2980
  );
2859
2981
  } catch {
2860
2982
  }
2861
2983
  });
2862
- test15("should handle different HTTP methods", async (c) => {
2984
+ test16("should handle different HTTP methods", async (c) => {
2863
2985
  const { client } = await setupDriverTest(c, driverTestConfig);
2864
2986
  const actor2 = client.rawHttpActor.getOrCreate(["methods-test"]);
2865
2987
  const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
@@ -2869,17 +2991,17 @@ function runRawHttpTests(driverTestConfig) {
2869
2991
  body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
2870
2992
  });
2871
2993
  if (method === "POST") {
2872
- expect15(response.ok).toBe(true);
2994
+ expect16(response.ok).toBe(true);
2873
2995
  const data = await response.json();
2874
- expect15(data).toEqual({ method });
2996
+ expect16(data).toEqual({ method });
2875
2997
  } else if (method === "GET") {
2876
- expect15(response.status).toBe(404);
2998
+ expect16(response.status).toBe(404);
2877
2999
  } else {
2878
- expect15(response.status).toBe(404);
3000
+ expect16(response.status).toBe(404);
2879
3001
  }
2880
3002
  }
2881
3003
  });
2882
- test15("should handle binary data", async (c) => {
3004
+ test16("should handle binary data", async (c) => {
2883
3005
  const { client } = await setupDriverTest(c, driverTestConfig);
2884
3006
  const actor2 = client.rawHttpActor.getOrCreate(["binary-test"]);
2885
3007
  const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
@@ -2890,82 +3012,82 @@ function runRawHttpTests(driverTestConfig) {
2890
3012
  },
2891
3013
  body: binaryData
2892
3014
  });
2893
- expect15(response.ok).toBe(true);
3015
+ expect16(response.ok).toBe(true);
2894
3016
  const responseBuffer = await response.arrayBuffer();
2895
3017
  const responseArray = new Uint8Array(responseBuffer);
2896
- expect15(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
3018
+ expect16(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
2897
3019
  });
2898
- test15("should work with Hono router using createVars", async (c) => {
3020
+ test16("should work with Hono router using createVars", async (c) => {
2899
3021
  const { client } = await setupDriverTest(c, driverTestConfig);
2900
3022
  const actor2 = client.rawHttpHonoActor.getOrCreate(["hono-test"]);
2901
3023
  const rootResponse = await actor2.fetch("/");
2902
- expect15(rootResponse.ok).toBe(true);
3024
+ expect16(rootResponse.ok).toBe(true);
2903
3025
  const rootData = await rootResponse.json();
2904
- expect15(rootData).toEqual({ message: "Welcome to Hono actor!" });
3026
+ expect16(rootData).toEqual({ message: "Welcome to Hono actor!" });
2905
3027
  const usersResponse = await actor2.fetch("/users");
2906
- expect15(usersResponse.ok).toBe(true);
3028
+ expect16(usersResponse.ok).toBe(true);
2907
3029
  const users = await usersResponse.json();
2908
- expect15(users).toEqual([
3030
+ expect16(users).toEqual([
2909
3031
  { id: 1, name: "Alice" },
2910
3032
  { id: 2, name: "Bob" }
2911
3033
  ]);
2912
3034
  const userResponse = await actor2.fetch("/users/1");
2913
- expect15(userResponse.ok).toBe(true);
3035
+ expect16(userResponse.ok).toBe(true);
2914
3036
  const user = await userResponse.json();
2915
- expect15(user).toEqual({ id: 1, name: "Alice" });
3037
+ expect16(user).toEqual({ id: 1, name: "Alice" });
2916
3038
  const newUser = { name: "Charlie" };
2917
3039
  const createResponse = await actor2.fetch("/users", {
2918
3040
  method: "POST",
2919
3041
  headers: { "Content-Type": "application/json" },
2920
3042
  body: JSON.stringify(newUser)
2921
3043
  });
2922
- expect15(createResponse.ok).toBe(true);
2923
- expect15(createResponse.status).toBe(201);
3044
+ expect16(createResponse.ok).toBe(true);
3045
+ expect16(createResponse.status).toBe(201);
2924
3046
  const createdUser = await createResponse.json();
2925
- expect15(createdUser).toEqual({ id: 3, name: "Charlie" });
3047
+ expect16(createdUser).toEqual({ id: 3, name: "Charlie" });
2926
3048
  const updateData = { name: "Alice Updated" };
2927
3049
  const updateResponse = await actor2.fetch("/users/1", {
2928
3050
  method: "PUT",
2929
3051
  headers: { "Content-Type": "application/json" },
2930
3052
  body: JSON.stringify(updateData)
2931
3053
  });
2932
- expect15(updateResponse.ok).toBe(true);
3054
+ expect16(updateResponse.ok).toBe(true);
2933
3055
  const updatedUser = await updateResponse.json();
2934
- expect15(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
3056
+ expect16(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
2935
3057
  const deleteResponse = await actor2.fetch("/users/2", {
2936
3058
  method: "DELETE"
2937
3059
  });
2938
- expect15(deleteResponse.ok).toBe(true);
3060
+ expect16(deleteResponse.ok).toBe(true);
2939
3061
  const deleteResult = await deleteResponse.json();
2940
- expect15(deleteResult).toEqual({ message: "User 2 deleted" });
3062
+ expect16(deleteResult).toEqual({ message: "User 2 deleted" });
2941
3063
  const notFoundResponse = await actor2.fetch("/api/unknown");
2942
- expect15(notFoundResponse.ok).toBe(false);
2943
- expect15(notFoundResponse.status).toBe(404);
3064
+ expect16(notFoundResponse.ok).toBe(false);
3065
+ expect16(notFoundResponse.status).toBe(404);
2944
3066
  });
2945
- test15("should handle paths with and without leading slashes", async (c) => {
3067
+ test16("should handle paths with and without leading slashes", async (c) => {
2946
3068
  const { client } = await setupDriverTest(c, driverTestConfig);
2947
3069
  const actor2 = client.rawHttpActor.getOrCreate(["path-test"]);
2948
3070
  const responseWithoutSlash = await actor2.fetch("api/hello");
2949
- expect15(responseWithoutSlash.ok).toBe(true);
3071
+ expect16(responseWithoutSlash.ok).toBe(true);
2950
3072
  const dataWithoutSlash = await responseWithoutSlash.json();
2951
- expect15(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
3073
+ expect16(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
2952
3074
  const responseWithSlash = await actor2.fetch("/api/hello");
2953
- expect15(responseWithSlash.ok).toBe(true);
3075
+ expect16(responseWithSlash.ok).toBe(true);
2954
3076
  const dataWithSlash = await responseWithSlash.json();
2955
- expect15(dataWithSlash).toEqual({ message: "Hello from actor!" });
3077
+ expect16(dataWithSlash).toEqual({ message: "Hello from actor!" });
2956
3078
  });
2957
- test15("should not create double slashes in request URLs", async (c) => {
3079
+ test16("should not create double slashes in request URLs", async (c) => {
2958
3080
  const { client } = await setupDriverTest(c, driverTestConfig);
2959
3081
  const actor2 = client.rawHttpHonoActor.getOrCreate(["url-test"]);
2960
3082
  const response = await actor2.fetch("/users");
2961
- expect15(response.ok).toBe(true);
3083
+ expect16(response.ok).toBe(true);
2962
3084
  const data = await response.json();
2963
- expect15(data).toEqual([
3085
+ expect16(data).toEqual([
2964
3086
  { id: 1, name: "Alice" },
2965
3087
  { id: 2, name: "Bob" }
2966
3088
  ]);
2967
3089
  });
2968
- test15("should handle forwarded requests correctly without double slashes", async (c) => {
3090
+ test16("should handle forwarded requests correctly without double slashes", async (c) => {
2969
3091
  const { client } = await setupDriverTest(c, driverTestConfig);
2970
3092
  const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-test"]);
2971
3093
  const truncatedPath = "/users";
@@ -2974,14 +3096,14 @@ function runRawHttpTests(driverTestConfig) {
2974
3096
  method: "GET"
2975
3097
  });
2976
3098
  const response = await actor2.fetch(truncatedPath, newRequest);
2977
- expect15(response.ok).toBe(true);
3099
+ expect16(response.ok).toBe(true);
2978
3100
  const users = await response.json();
2979
- expect15(users).toEqual([
3101
+ expect16(users).toEqual([
2980
3102
  { id: 1, name: "Alice" },
2981
3103
  { id: 2, name: "Bob" }
2982
3104
  ]);
2983
3105
  });
2984
- test15("example fix: should properly forward requests using just Request object", async (c) => {
3106
+ test16("example fix: should properly forward requests using just Request object", async (c) => {
2985
3107
  const { client } = await setupDriverTest(c, driverTestConfig);
2986
3108
  const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-fix"]);
2987
3109
  const truncatedPath = "/users/1";
@@ -2990,11 +3112,11 @@ function runRawHttpTests(driverTestConfig) {
2990
3112
  method: "GET"
2991
3113
  });
2992
3114
  const response = await actor2.fetch(newRequest);
2993
- expect15(response.ok).toBe(true);
3115
+ expect16(response.ok).toBe(true);
2994
3116
  const user = await response.json();
2995
- expect15(user).toEqual({ id: 1, name: "Alice" });
3117
+ expect16(user).toEqual({ id: 1, name: "Alice" });
2996
3118
  });
2997
- test15("should support standard fetch API with URL and Request objects", async (c) => {
3119
+ test16("should support standard fetch API with URL and Request objects", async (c) => {
2998
3120
  const { client } = await setupDriverTest(c, driverTestConfig);
2999
3121
  const actor2 = client.rawHttpActor.getOrCreate(["fetch-api-test"]);
3000
3122
  const url = new URL("/api/echo", "http://example.com");
@@ -3003,18 +3125,18 @@ function runRawHttpTests(driverTestConfig) {
3003
3125
  headers: { "Content-Type": "application/json" },
3004
3126
  body: JSON.stringify({ from: "URL object" })
3005
3127
  });
3006
- expect15(urlResponse.ok).toBe(true);
3128
+ expect16(urlResponse.ok).toBe(true);
3007
3129
  const urlData = await urlResponse.json();
3008
- expect15(urlData).toEqual({ from: "URL object" });
3130
+ expect16(urlData).toEqual({ from: "URL object" });
3009
3131
  const request = new Request("http://example.com/api/echo", {
3010
3132
  method: "POST",
3011
3133
  headers: { "Content-Type": "application/json" },
3012
3134
  body: JSON.stringify({ from: "Request object" })
3013
3135
  });
3014
3136
  const requestResponse = await actor2.fetch(request);
3015
- expect15(requestResponse.ok).toBe(true);
3137
+ expect16(requestResponse.ok).toBe(true);
3016
3138
  const requestData = await requestResponse.json();
3017
- expect15(requestData).toEqual({ from: "Request object" });
3139
+ expect16(requestData).toEqual({ from: "Request object" });
3018
3140
  const request2 = new Request("http://example.com/api/headers", {
3019
3141
  method: "GET",
3020
3142
  headers: { "X-Original": "request-header" }
@@ -3022,19 +3144,19 @@ function runRawHttpTests(driverTestConfig) {
3022
3144
  const overrideResponse = await actor2.fetch(request2, {
3023
3145
  headers: { "X-Override": "init-header" }
3024
3146
  });
3025
- expect15(overrideResponse.ok).toBe(true);
3147
+ expect16(overrideResponse.ok).toBe(true);
3026
3148
  const headers = await overrideResponse.json();
3027
- expect15(headers["x-override"]).toBe("init-header");
3028
- expect15(headers["x-original"]).toBe("request-header");
3149
+ expect16(headers["x-override"]).toBe("init-header");
3150
+ expect16(headers["x-original"]).toBe("request-header");
3029
3151
  });
3030
3152
  });
3031
3153
  }
3032
3154
 
3033
3155
  // src/driver-test-suite/tests/raw-http-request-properties.ts
3034
- import { describe as describe17, expect as expect16, test as test16 } from "vitest";
3156
+ import { describe as describe18, expect as expect17, test as test17 } from "vitest";
3035
3157
  function runRawHttpRequestPropertiesTests(driverTestConfig) {
3036
- describe17("raw http request properties", () => {
3037
- test16("should pass all Request properties correctly to onFetch", async (c) => {
3158
+ describe18("raw http request properties", () => {
3159
+ test17("should pass all Request properties correctly to onFetch", async (c) => {
3038
3160
  const { client } = await setupDriverTest(c, driverTestConfig);
3039
3161
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3040
3162
  const response = await actor2.fetch("test/path?foo=bar&baz=qux", {
@@ -3046,33 +3168,33 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3046
3168
  },
3047
3169
  body: JSON.stringify({ test: "data" })
3048
3170
  });
3049
- expect16(response.ok).toBe(true);
3171
+ expect17(response.ok).toBe(true);
3050
3172
  const data = await response.json();
3051
- expect16(data.url).toContain("/test/path?foo=bar&baz=qux");
3052
- expect16(data.pathname).toBe("/test/path");
3053
- expect16(data.search).toBe("?foo=bar&baz=qux");
3054
- expect16(data.searchParams).toEqual({
3173
+ expect17(data.url).toContain("/test/path?foo=bar&baz=qux");
3174
+ expect17(data.pathname).toBe("/test/path");
3175
+ expect17(data.search).toBe("?foo=bar&baz=qux");
3176
+ expect17(data.searchParams).toEqual({
3055
3177
  foo: "bar",
3056
3178
  baz: "qux"
3057
3179
  });
3058
- expect16(data.method).toBe("POST");
3059
- expect16(data.headers["content-type"]).toBe("application/json");
3060
- expect16(data.headers["x-custom-header"]).toBe("custom-value");
3061
- expect16(data.headers["authorization"]).toBe("Bearer test-token");
3062
- expect16(data.body).toEqual({ test: "data" });
3180
+ expect17(data.method).toBe("POST");
3181
+ expect17(data.headers["content-type"]).toBe("application/json");
3182
+ expect17(data.headers["x-custom-header"]).toBe("custom-value");
3183
+ expect17(data.headers["authorization"]).toBe("Bearer test-token");
3184
+ expect17(data.body).toEqual({ test: "data" });
3063
3185
  });
3064
- test16("should handle GET requests with no body", async (c) => {
3186
+ test17("should handle GET requests with no body", async (c) => {
3065
3187
  const { client } = await setupDriverTest(c, driverTestConfig);
3066
3188
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3067
3189
  const response = await actor2.fetch("test/get", {
3068
3190
  method: "GET"
3069
3191
  });
3070
- expect16(response.ok).toBe(true);
3192
+ expect17(response.ok).toBe(true);
3071
3193
  const data = await response.json();
3072
- expect16(data.method).toBe("GET");
3073
- expect16(data.body).toBeNull();
3194
+ expect17(data.method).toBe("GET");
3195
+ expect17(data.body).toBeNull();
3074
3196
  });
3075
- test16("should handle different content types", async (c) => {
3197
+ test17("should handle different content types", async (c) => {
3076
3198
  const { client } = await setupDriverTest(c, driverTestConfig);
3077
3199
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3078
3200
  const formData = new URLSearchParams();
@@ -3085,12 +3207,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3085
3207
  },
3086
3208
  body: formData.toString()
3087
3209
  });
3088
- expect16(formResponse.ok).toBe(true);
3210
+ expect17(formResponse.ok).toBe(true);
3089
3211
  const formResult = await formResponse.json();
3090
- expect16(formResult.headers["content-type"]).toBe(
3212
+ expect17(formResult.headers["content-type"]).toBe(
3091
3213
  "application/x-www-form-urlencoded"
3092
3214
  );
3093
- expect16(formResult.bodyText).toBe("field1=value1&field2=value2");
3215
+ expect17(formResult.bodyText).toBe("field1=value1&field2=value2");
3094
3216
  const textResponse = await actor2.fetch("test/text", {
3095
3217
  method: "POST",
3096
3218
  headers: {
@@ -3098,12 +3220,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3098
3220
  },
3099
3221
  body: "Hello, World!"
3100
3222
  });
3101
- expect16(textResponse.ok).toBe(true);
3223
+ expect17(textResponse.ok).toBe(true);
3102
3224
  const textResult = await textResponse.json();
3103
- expect16(textResult.headers["content-type"]).toBe("text/plain");
3104
- expect16(textResult.bodyText).toBe("Hello, World!");
3225
+ expect17(textResult.headers["content-type"]).toBe("text/plain");
3226
+ expect17(textResult.bodyText).toBe("Hello, World!");
3105
3227
  });
3106
- test16("should preserve all header casing and values", async (c) => {
3228
+ test17("should preserve all header casing and values", async (c) => {
3107
3229
  const { client } = await setupDriverTest(c, driverTestConfig);
3108
3230
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3109
3231
  const response = await actor2.fetch("test/headers", {
@@ -3115,34 +3237,34 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3115
3237
  "X-Request-ID": "12345"
3116
3238
  }
3117
3239
  });
3118
- expect16(response.ok).toBe(true);
3240
+ expect17(response.ok).toBe(true);
3119
3241
  const data = await response.json();
3120
- expect16(data.headers["accept"]).toBe("application/json");
3121
- expect16(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
3122
- expect16(data.headers["cache-control"]).toBe("no-cache");
3123
- expect16(data.headers["user-agent"]).toBeTruthy();
3124
- expect16(data.headers["x-request-id"]).toBe("12345");
3242
+ expect17(data.headers["accept"]).toBe("application/json");
3243
+ expect17(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
3244
+ expect17(data.headers["cache-control"]).toBe("no-cache");
3245
+ expect17(data.headers["user-agent"]).toBeTruthy();
3246
+ expect17(data.headers["x-request-id"]).toBe("12345");
3125
3247
  });
3126
- test16("should handle empty and special URL paths", async (c) => {
3248
+ test17("should handle empty and special URL paths", async (c) => {
3127
3249
  const { client } = await setupDriverTest(c, driverTestConfig);
3128
3250
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3129
3251
  const rootResponse = await actor2.fetch("");
3130
- expect16(rootResponse.ok).toBe(true);
3252
+ expect17(rootResponse.ok).toBe(true);
3131
3253
  const rootData = await rootResponse.json();
3132
- expect16(rootData.pathname).toBe("/");
3254
+ expect17(rootData.pathname).toBe("/");
3133
3255
  const specialResponse = await actor2.fetch(
3134
3256
  "test/path%20with%20spaces/and%2Fslashes"
3135
3257
  );
3136
- expect16(specialResponse.ok).toBe(true);
3258
+ expect17(specialResponse.ok).toBe(true);
3137
3259
  const specialData = await specialResponse.json();
3138
- expect16(specialData.pathname).toMatch(/path.*with.*spaces.*and.*slashes/);
3260
+ expect17(specialData.pathname).toMatch(/path.*with.*spaces.*and.*slashes/);
3139
3261
  const fragmentResponse = await actor2.fetch("test/path#fragment");
3140
- expect16(fragmentResponse.ok).toBe(true);
3262
+ expect17(fragmentResponse.ok).toBe(true);
3141
3263
  const fragmentData = await fragmentResponse.json();
3142
- expect16(fragmentData.pathname).toBe("/test/path");
3143
- expect16(fragmentData.hash).toBe("");
3264
+ expect17(fragmentData.pathname).toBe("/test/path");
3265
+ expect17(fragmentData.hash).toBe("");
3144
3266
  });
3145
- test16("should handle request properties for all HTTP methods", async (c) => {
3267
+ test17("should handle request properties for all HTTP methods", async (c) => {
3146
3268
  const { client } = await setupDriverTest(c, driverTestConfig);
3147
3269
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3148
3270
  const methods = [
@@ -3161,33 +3283,33 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3161
3283
  body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
3162
3284
  });
3163
3285
  if (method === "HEAD") {
3164
- expect16(response.status).toBe(200);
3286
+ expect17(response.status).toBe(200);
3165
3287
  const text = await response.text();
3166
- expect16(text).toBe("");
3288
+ expect17(text).toBe("");
3167
3289
  } else if (method === "OPTIONS") {
3168
- expect16(response.status).toBe(204);
3290
+ expect17(response.status).toBe(204);
3169
3291
  const text = await response.text();
3170
- expect16(text).toBe("");
3292
+ expect17(text).toBe("");
3171
3293
  } else {
3172
- expect16(response.ok).toBe(true);
3294
+ expect17(response.ok).toBe(true);
3173
3295
  const data = await response.json();
3174
- expect16(data.method).toBe(method);
3296
+ expect17(data.method).toBe(method);
3175
3297
  }
3176
3298
  }
3177
3299
  });
3178
- test16("should handle complex query parameters", async (c) => {
3300
+ test17("should handle complex query parameters", async (c) => {
3179
3301
  const { client } = await setupDriverTest(c, driverTestConfig);
3180
3302
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3181
3303
  const response = await actor2.fetch(
3182
3304
  "test?key=value1&key=value2&array[]=1&array[]=2&nested[prop]=val"
3183
3305
  );
3184
- expect16(response.ok).toBe(true);
3306
+ expect17(response.ok).toBe(true);
3185
3307
  const data = await response.json();
3186
- expect16(data.searchParams.key).toBe("value2");
3187
- expect16(data.searchParams["array[]"]).toBe("2");
3188
- expect16(data.searchParams["nested[prop]"]).toBe("val");
3308
+ expect17(data.searchParams.key).toBe("value2");
3309
+ expect17(data.searchParams["array[]"]).toBe("2");
3310
+ expect17(data.searchParams["nested[prop]"]).toBe("val");
3189
3311
  });
3190
- test16("should handle multipart form data", async (c) => {
3312
+ test17("should handle multipart form data", async (c) => {
3191
3313
  const { client } = await setupDriverTest(c, driverTestConfig);
3192
3314
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3193
3315
  const boundary = "----RivetKitBoundary";
@@ -3209,23 +3331,23 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3209
3331
  },
3210
3332
  body
3211
3333
  });
3212
- expect16(response.ok).toBe(true);
3334
+ expect17(response.ok).toBe(true);
3213
3335
  const data = await response.json();
3214
- expect16(data.headers["content-type"]).toContain("multipart/form-data");
3215
- expect16(data.bodyText).toContain("field1");
3216
- expect16(data.bodyText).toContain("value1");
3336
+ expect17(data.headers["content-type"]).toContain("multipart/form-data");
3337
+ expect17(data.bodyText).toContain("field1");
3338
+ expect17(data.bodyText).toContain("value1");
3217
3339
  });
3218
- test16("should handle very long URLs", async (c) => {
3340
+ test17("should handle very long URLs", async (c) => {
3219
3341
  const { client } = await setupDriverTest(c, driverTestConfig);
3220
3342
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3221
3343
  const longValue = "x".repeat(1e3);
3222
3344
  const response = await actor2.fetch(`test/long?param=${longValue}`);
3223
- expect16(response.ok).toBe(true);
3345
+ expect17(response.ok).toBe(true);
3224
3346
  const data = await response.json();
3225
- expect16(data.searchParams.param).toBe(longValue);
3226
- expect16(data.search.length).toBeGreaterThan(1e3);
3347
+ expect17(data.searchParams.param).toBe(longValue);
3348
+ expect17(data.search.length).toBeGreaterThan(1e3);
3227
3349
  });
3228
- test16("should handle large request bodies", async (c) => {
3350
+ test17("should handle large request bodies", async (c) => {
3229
3351
  const { client } = await setupDriverTest(c, driverTestConfig);
3230
3352
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3231
3353
  const largeArray = new Array(1e4).fill({
@@ -3240,22 +3362,22 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3240
3362
  },
3241
3363
  body: JSON.stringify(largeArray)
3242
3364
  });
3243
- expect16(response.ok).toBe(true);
3365
+ expect17(response.ok).toBe(true);
3244
3366
  const data = await response.json();
3245
- expect16(data.body).toHaveLength(1e4);
3367
+ expect17(data.body).toHaveLength(1e4);
3246
3368
  });
3247
- test16("should handle missing content-type header", async (c) => {
3369
+ test17("should handle missing content-type header", async (c) => {
3248
3370
  const { client } = await setupDriverTest(c, driverTestConfig);
3249
3371
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3250
3372
  const response = await actor2.fetch("test/no-content-type", {
3251
3373
  method: "POST",
3252
3374
  body: "plain text without content-type"
3253
3375
  });
3254
- expect16(response.ok).toBe(true);
3376
+ expect17(response.ok).toBe(true);
3255
3377
  const data = await response.json();
3256
- expect16(data.bodyText).toBe("plain text without content-type");
3378
+ expect17(data.bodyText).toBe("plain text without content-type");
3257
3379
  });
3258
- test16("should handle empty request body", async (c) => {
3380
+ test17("should handle empty request body", async (c) => {
3259
3381
  const { client } = await setupDriverTest(c, driverTestConfig);
3260
3382
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3261
3383
  const response = await actor2.fetch("test/empty", {
@@ -3265,12 +3387,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3265
3387
  },
3266
3388
  body: ""
3267
3389
  });
3268
- expect16(response.ok).toBe(true);
3390
+ expect17(response.ok).toBe(true);
3269
3391
  const data = await response.json();
3270
- expect16(data.body).toBeNull();
3271
- expect16(data.bodyText).toBe("");
3392
+ expect17(data.body).toBeNull();
3393
+ expect17(data.bodyText).toBe("");
3272
3394
  });
3273
- test16("should handle custom HTTP methods", async (c) => {
3395
+ test17("should handle custom HTTP methods", async (c) => {
3274
3396
  const { client } = await setupDriverTest(c, driverTestConfig);
3275
3397
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3276
3398
  try {
@@ -3279,12 +3401,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3279
3401
  });
3280
3402
  if (response.ok) {
3281
3403
  const data = await response.json();
3282
- expect16(data.method).toBe("CUSTOM");
3404
+ expect17(data.method).toBe("CUSTOM");
3283
3405
  }
3284
3406
  } catch (error) {
3285
3407
  }
3286
3408
  });
3287
- test16("should handle cookies in headers", async (c) => {
3409
+ test17("should handle cookies in headers", async (c) => {
3288
3410
  const { client } = await setupDriverTest(c, driverTestConfig);
3289
3411
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3290
3412
  const response = await actor2.fetch("test/cookies", {
@@ -3292,25 +3414,25 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3292
3414
  Cookie: "session=abc123; user=test; preferences=dark_mode"
3293
3415
  }
3294
3416
  });
3295
- expect16(response.ok).toBe(true);
3417
+ expect17(response.ok).toBe(true);
3296
3418
  const data = await response.json();
3297
- expect16(data.headers.cookie).toBe(
3419
+ expect17(data.headers.cookie).toBe(
3298
3420
  "session=abc123; user=test; preferences=dark_mode"
3299
3421
  );
3300
3422
  });
3301
- test16("should handle URL encoding properly", async (c) => {
3423
+ test17("should handle URL encoding properly", async (c) => {
3302
3424
  const { client } = await setupDriverTest(c, driverTestConfig);
3303
3425
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3304
3426
  const response = await actor2.fetch(
3305
3427
  "test/encoded?special=%20%21%40%23%24%25%5E%26&unicode=%E2%9C%93&email=test%40example.com"
3306
3428
  );
3307
- expect16(response.ok).toBe(true);
3429
+ expect17(response.ok).toBe(true);
3308
3430
  const data = await response.json();
3309
- expect16(data.searchParams.special).toBe(" !@#$%^&");
3310
- expect16(data.searchParams.unicode).toBe("\u2713");
3311
- expect16(data.searchParams.email).toBe("test@example.com");
3431
+ expect17(data.searchParams.special).toBe(" !@#$%^&");
3432
+ expect17(data.searchParams.unicode).toBe("\u2713");
3433
+ expect17(data.searchParams.email).toBe("test@example.com");
3312
3434
  });
3313
- test16("should handle concurrent requests maintaining separate contexts", async (c) => {
3435
+ test17("should handle concurrent requests maintaining separate contexts", async (c) => {
3314
3436
  const { client } = await setupDriverTest(c, driverTestConfig);
3315
3437
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3316
3438
  const requests = [
@@ -3332,24 +3454,24 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3332
3454
  const results = await Promise.all(
3333
3455
  responses.map((r) => r.json())
3334
3456
  );
3335
- expect16(results[0].searchParams.id).toBe("1");
3336
- expect16(results[0].method).toBe("POST");
3337
- expect16(results[0].body).toEqual({ request: 1 });
3338
- expect16(results[1].searchParams.id).toBe("2");
3339
- expect16(results[1].method).toBe("PUT");
3340
- expect16(results[1].body).toEqual({ request: 2 });
3341
- expect16(results[2].searchParams.id).toBe("3");
3342
- expect16(results[2].method).toBe("DELETE");
3343
- expect16(results[2].body).toBeNull();
3457
+ expect17(results[0].searchParams.id).toBe("1");
3458
+ expect17(results[0].method).toBe("POST");
3459
+ expect17(results[0].body).toEqual({ request: 1 });
3460
+ expect17(results[1].searchParams.id).toBe("2");
3461
+ expect17(results[1].method).toBe("PUT");
3462
+ expect17(results[1].body).toEqual({ request: 2 });
3463
+ expect17(results[2].searchParams.id).toBe("3");
3464
+ expect17(results[2].method).toBe("DELETE");
3465
+ expect17(results[2].body).toBeNull();
3344
3466
  });
3345
3467
  });
3346
3468
  }
3347
3469
 
3348
3470
  // src/driver-test-suite/tests/raw-websocket.ts
3349
- import { describe as describe18, expect as expect17, test as test17 } from "vitest";
3471
+ import { describe as describe19, expect as expect18, test as test18 } from "vitest";
3350
3472
  function runRawWebSocketTests(driverTestConfig) {
3351
- describe18("raw websocket", () => {
3352
- test17("should establish raw WebSocket connection", async (c) => {
3473
+ describe19("raw websocket", () => {
3474
+ test18("should establish raw WebSocket connection", async (c) => {
3353
3475
  const { client } = await setupDriverTest(c, driverTestConfig);
3354
3476
  const actor2 = client.rawWebSocketActor.getOrCreate(["basic"]);
3355
3477
  const ws = await actor2.websocket();
@@ -3376,11 +3498,11 @@ function runRawWebSocketTests(driverTestConfig) {
3376
3498
  );
3377
3499
  ws.addEventListener("close", reject);
3378
3500
  });
3379
- expect17(welcomeMessage.type).toBe("welcome");
3380
- expect17(welcomeMessage.connectionCount).toBe(1);
3501
+ expect18(welcomeMessage.type).toBe("welcome");
3502
+ expect18(welcomeMessage.connectionCount).toBe(1);
3381
3503
  ws.close();
3382
3504
  });
3383
- test17("should echo messages", async (c) => {
3505
+ test18("should echo messages", async (c) => {
3384
3506
  const { client } = await setupDriverTest(c, driverTestConfig);
3385
3507
  const actor2 = client.rawWebSocketActor.getOrCreate(["echo"]);
3386
3508
  const ws = await actor2.websocket();
@@ -3406,10 +3528,10 @@ function runRawWebSocketTests(driverTestConfig) {
3406
3528
  );
3407
3529
  ws.addEventListener("close", reject);
3408
3530
  });
3409
- expect17(echoMessage).toEqual(testMessage);
3531
+ expect18(echoMessage).toEqual(testMessage);
3410
3532
  ws.close();
3411
3533
  });
3412
- test17("should handle ping/pong protocol", async (c) => {
3534
+ test18("should handle ping/pong protocol", async (c) => {
3413
3535
  const { client } = await setupDriverTest(c, driverTestConfig);
3414
3536
  const actor2 = client.rawWebSocketActor.getOrCreate(["ping"]);
3415
3537
  const ws = await actor2.websocket();
@@ -3433,11 +3555,11 @@ function runRawWebSocketTests(driverTestConfig) {
3433
3555
  });
3434
3556
  ws.addEventListener("close", reject);
3435
3557
  });
3436
- expect17(pongMessage.type).toBe("pong");
3437
- expect17(pongMessage.timestamp).toBeDefined();
3558
+ expect18(pongMessage.type).toBe("pong");
3559
+ expect18(pongMessage.timestamp).toBeDefined();
3438
3560
  ws.close();
3439
3561
  });
3440
- test17("should track stats across connections", async (c) => {
3562
+ test18("should track stats across connections", async (c) => {
3441
3563
  const { client } = await setupDriverTest(c, driverTestConfig);
3442
3564
  const actor1 = client.rawWebSocketActor.getOrCreate(["stats"]);
3443
3565
  const ws1 = await actor1.websocket();
@@ -3477,15 +3599,15 @@ function runRawWebSocketTests(driverTestConfig) {
3477
3599
  });
3478
3600
  ws1.send(JSON.stringify({ type: "getStats" }));
3479
3601
  const stats = await statsPromise;
3480
- expect17(stats.connectionCount).toBe(2);
3481
- expect17(stats.messageCount).toBe(4);
3602
+ expect18(stats.connectionCount).toBe(2);
3603
+ expect18(stats.messageCount).toBe(4);
3482
3604
  const actionStats = await actor1.getStats();
3483
- expect17(actionStats.connectionCount).toBe(2);
3484
- expect17(actionStats.messageCount).toBe(4);
3605
+ expect18(actionStats.connectionCount).toBe(2);
3606
+ expect18(actionStats.messageCount).toBe(4);
3485
3607
  ws1.close();
3486
3608
  ws2.close();
3487
3609
  });
3488
- test17("should handle binary data", async (c) => {
3610
+ test18("should handle binary data", async (c) => {
3489
3611
  const { client } = await setupDriverTest(c, driverTestConfig);
3490
3612
  const actor2 = client.rawWebSocketBinaryActor.getOrCreate(["binary"]);
3491
3613
  const ws = await actor2.websocket();
@@ -3514,7 +3636,7 @@ function runRawWebSocketTests(driverTestConfig) {
3514
3636
  const smallData = new Uint8Array([1, 2, 3, 4, 5]);
3515
3637
  ws.send(smallData);
3516
3638
  const smallReversed = await receiveBinaryMessage();
3517
- expect17(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
3639
+ expect18(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
3518
3640
  const largeData = new Uint8Array(1024);
3519
3641
  for (let i = 0; i < largeData.length; i++) {
3520
3642
  largeData[i] = i % 256;
@@ -3522,11 +3644,11 @@ function runRawWebSocketTests(driverTestConfig) {
3522
3644
  ws.send(largeData);
3523
3645
  const largeReversed = await receiveBinaryMessage();
3524
3646
  for (let i = 0; i < largeData.length; i++) {
3525
- expect17(largeReversed[i]).toBe(largeData[largeData.length - 1 - i]);
3647
+ expect18(largeReversed[i]).toBe(largeData[largeData.length - 1 - i]);
3526
3648
  }
3527
3649
  ws.close();
3528
3650
  });
3529
- test17("should work with custom paths", async (c) => {
3651
+ test18("should work with custom paths", async (c) => {
3530
3652
  const { client } = await setupDriverTest(c, driverTestConfig);
3531
3653
  const actor2 = client.rawWebSocketActor.getOrCreate(["paths"]);
3532
3654
  const ws = await actor2.websocket("custom/path");
@@ -3546,33 +3668,10 @@ function runRawWebSocketTests(driverTestConfig) {
3546
3668
  { once: true }
3547
3669
  );
3548
3670
  });
3549
- expect17(welcomeMessage.type).toBe("welcome");
3550
- ws.close();
3551
- });
3552
- test17("should pass connection parameters through subprotocols", async (c) => {
3553
- const { client } = await setupDriverTest(c, driverTestConfig);
3554
- const testParams = { userId: "test123", role: "admin" };
3555
- const actor2 = client.rawWebSocketActor.getOrCreate(["params"], {
3556
- params: testParams
3557
- });
3558
- const ws = await actor2.websocket();
3559
- await new Promise((resolve) => {
3560
- ws.addEventListener("open", () => resolve(), { once: true });
3561
- });
3562
- ws.send(JSON.stringify({ type: "getAuthData" }));
3563
- const response = await new Promise((resolve, reject) => {
3564
- ws.addEventListener("message", (event) => {
3565
- const data = JSON.parse(event.data);
3566
- if (data.type === "authData") {
3567
- resolve(data);
3568
- }
3569
- });
3570
- ws.addEventListener("close", reject);
3571
- });
3572
- expect17(response).toBeDefined();
3671
+ expect18(welcomeMessage.type).toBe("welcome");
3573
3672
  ws.close();
3574
3673
  });
3575
- test17("should handle connection close properly", async (c) => {
3674
+ test18("should handle connection close properly", async (c) => {
3576
3675
  const { client } = await setupDriverTest(c, driverTestConfig);
3577
3676
  const actor2 = client.rawWebSocketActor.getOrCreate(["close-test"]);
3578
3677
  const ws = await actor2.websocket();
@@ -3583,7 +3682,7 @@ function runRawWebSocketTests(driverTestConfig) {
3583
3682
  });
3584
3683
  }
3585
3684
  const initialStats = await actor2.getStats();
3586
- expect17(initialStats.connectionCount).toBe(1);
3685
+ expect18(initialStats.connectionCount).toBe(1);
3587
3686
  const closePromise = new Promise((resolve) => {
3588
3687
  ws.addEventListener("close", () => resolve(), { once: true });
3589
3688
  });
@@ -3597,9 +3696,9 @@ function runRawWebSocketTests(driverTestConfig) {
3597
3696
  }
3598
3697
  await new Promise((resolve) => setTimeout(resolve, 50));
3599
3698
  }
3600
- expect17(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3699
+ expect18(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3601
3700
  });
3602
- test17("should properly handle onWebSocket open and close events", async (c) => {
3701
+ test18("should properly handle onWebSocket open and close events", async (c) => {
3603
3702
  const { client } = await setupDriverTest(c, driverTestConfig);
3604
3703
  const actor2 = client.rawWebSocketActor.getOrCreate(["open-close-test"]);
3605
3704
  const ws1 = await actor2.websocket();
@@ -3617,8 +3716,8 @@ function runRawWebSocketTests(driverTestConfig) {
3617
3716
  );
3618
3717
  ws1.addEventListener("close", reject);
3619
3718
  });
3620
- expect17(welcome1.type).toBe("welcome");
3621
- expect17(welcome1.connectionCount).toBe(1);
3719
+ expect18(welcome1.type).toBe("welcome");
3720
+ expect18(welcome1.connectionCount).toBe(1);
3622
3721
  const ws2 = await actor2.websocket();
3623
3722
  await new Promise((resolve, reject) => {
3624
3723
  ws2.addEventListener("open", () => resolve(), { once: true });
@@ -3634,10 +3733,10 @@ function runRawWebSocketTests(driverTestConfig) {
3634
3733
  );
3635
3734
  ws2.addEventListener("close", reject);
3636
3735
  });
3637
- expect17(welcome2.type).toBe("welcome");
3638
- expect17(welcome2.connectionCount).toBe(2);
3736
+ expect18(welcome2.type).toBe("welcome");
3737
+ expect18(welcome2.connectionCount).toBe(2);
3639
3738
  const midStats = await actor2.getStats();
3640
- expect17(midStats.connectionCount).toBe(2);
3739
+ expect18(midStats.connectionCount).toBe(2);
3641
3740
  ws1.close();
3642
3741
  await new Promise((resolve) => {
3643
3742
  ws1.addEventListener("close", () => resolve(), { once: true });
@@ -3650,7 +3749,7 @@ function runRawWebSocketTests(driverTestConfig) {
3650
3749
  }
3651
3750
  await new Promise((resolve) => setTimeout(resolve, 50));
3652
3751
  }
3653
- expect17(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
3752
+ expect18(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
3654
3753
  ws2.close();
3655
3754
  await new Promise((resolve) => {
3656
3755
  ws2.addEventListener("close", () => resolve(), { once: true });
@@ -3663,9 +3762,9 @@ function runRawWebSocketTests(driverTestConfig) {
3663
3762
  }
3664
3763
  await new Promise((resolve) => setTimeout(resolve, 50));
3665
3764
  }
3666
- expect17(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3765
+ expect18(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3667
3766
  });
3668
- test17("should handle query parameters in websocket paths", async (c) => {
3767
+ test18("should handle query parameters in websocket paths", async (c) => {
3669
3768
  const { client } = await setupDriverTest(c, driverTestConfig);
3670
3769
  const actor2 = client.rawWebSocketActor.getOrCreate(["query-params"]);
3671
3770
  const ws = await actor2.websocket("api/v1/stream?token=abc123&user=test");
@@ -3684,19 +3783,19 @@ function runRawWebSocketTests(driverTestConfig) {
3684
3783
  });
3685
3784
  ws.send(JSON.stringify({ type: "getRequestInfo" }));
3686
3785
  const requestInfo = await requestInfoPromise;
3687
- expect17(requestInfo.url).toContain("api/v1/stream");
3688
- expect17(requestInfo.url).toContain("token=abc123");
3689
- expect17(requestInfo.url).toContain("user=test");
3786
+ expect18(requestInfo.url).toContain("api/v1/stream");
3787
+ expect18(requestInfo.url).toContain("token=abc123");
3788
+ expect18(requestInfo.url).toContain("user=test");
3690
3789
  ws.close();
3691
3790
  });
3692
3791
  });
3693
3792
  }
3694
3793
 
3695
3794
  // src/driver-test-suite/tests/request-access.ts
3696
- import { describe as describe19, expect as expect18, test as test18 } from "vitest";
3795
+ import { describe as describe20, expect as expect19, test as test19 } from "vitest";
3697
3796
  function runRequestAccessTests(driverTestConfig) {
3698
- describe19("Request Access in Lifecycle Hooks", () => {
3699
- test18("should have access to request object in onBeforeConnect and createConnState", async (c) => {
3797
+ describe20("Request Access in Lifecycle Hooks", () => {
3798
+ test19("should have access to request object in onBeforeConnect and createConnState", async (c) => {
3700
3799
  const { client } = await setupDriverTest(c, driverTestConfig);
3701
3800
  const handle = client.requestAccessActor.getOrCreate(["test-request"], {
3702
3801
  params: { trackRequest: true }
@@ -3704,19 +3803,19 @@ function runRequestAccessTests(driverTestConfig) {
3704
3803
  const connection = handle.connect();
3705
3804
  const requestInfo = await connection.getRequestInfo();
3706
3805
  if (driverTestConfig.clientType === "http") {
3707
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3708
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
3709
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
3710
- expect18(requestInfo.onBeforeConnect.requestHeaders).toBeDefined();
3711
- expect18(requestInfo.createConnState.hasRequest).toBe(true);
3712
- expect18(requestInfo.createConnState.requestUrl).toBeDefined();
3713
- expect18(requestInfo.createConnState.requestMethod).toBeDefined();
3714
- expect18(requestInfo.createConnState.requestHeaders).toBeDefined();
3806
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3807
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
3808
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
3809
+ expect19(requestInfo.onBeforeConnect.requestHeaders).toBeDefined();
3810
+ expect19(requestInfo.createConnState.hasRequest).toBe(true);
3811
+ expect19(requestInfo.createConnState.requestUrl).toBeDefined();
3812
+ expect19(requestInfo.createConnState.requestMethod).toBeDefined();
3813
+ expect19(requestInfo.createConnState.requestHeaders).toBeDefined();
3715
3814
  } else {
3716
3815
  }
3717
3816
  await connection.dispose();
3718
3817
  });
3719
- test18("should not have request when trackRequest is false", async (c) => {
3818
+ test19("should not have request when trackRequest is false", async (c) => {
3720
3819
  const { client } = await setupDriverTest(c, driverTestConfig);
3721
3820
  const handle = client.requestAccessActor.getOrCreate(
3722
3821
  ["test-no-request"],
@@ -3726,21 +3825,21 @@ function runRequestAccessTests(driverTestConfig) {
3726
3825
  );
3727
3826
  const connection = handle.connect();
3728
3827
  const requestInfo = await connection.getRequestInfo();
3729
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(false);
3730
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeNull();
3731
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeNull();
3732
- expect18(
3828
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(false);
3829
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeNull();
3830
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeNull();
3831
+ expect19(
3733
3832
  Object.keys(requestInfo.onBeforeConnect.requestHeaders)
3734
3833
  ).toHaveLength(0);
3735
- expect18(requestInfo.createConnState.hasRequest).toBe(false);
3736
- expect18(requestInfo.createConnState.requestUrl).toBeNull();
3737
- expect18(requestInfo.createConnState.requestMethod).toBeNull();
3738
- expect18(
3834
+ expect19(requestInfo.createConnState.hasRequest).toBe(false);
3835
+ expect19(requestInfo.createConnState.requestUrl).toBeNull();
3836
+ expect19(requestInfo.createConnState.requestMethod).toBeNull();
3837
+ expect19(
3739
3838
  Object.keys(requestInfo.createConnState.requestHeaders)
3740
3839
  ).toHaveLength(0);
3741
3840
  await connection.dispose();
3742
3841
  });
3743
- test18("should capture request headers and method", async (c) => {
3842
+ test19("should capture request headers and method", async (c) => {
3744
3843
  const { client } = await setupDriverTest(c, driverTestConfig);
3745
3844
  const handle = client.requestAccessActor.getOrCreate(["test-headers"], {
3746
3845
  params: { trackRequest: true }
@@ -3748,18 +3847,18 @@ function runRequestAccessTests(driverTestConfig) {
3748
3847
  const connection = handle.connect();
3749
3848
  const requestInfo = await connection.getRequestInfo();
3750
3849
  if (driverTestConfig.clientType === "http") {
3751
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3752
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
3753
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
3754
- expect18(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
3755
- expect18(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
3850
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3851
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
3852
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
3853
+ expect19(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
3854
+ expect19(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
3756
3855
  "object"
3757
3856
  );
3758
- expect18(requestInfo.createConnState.hasRequest).toBe(true);
3759
- expect18(requestInfo.createConnState.requestMethod).toBeTruthy();
3760
- expect18(requestInfo.createConnState.requestUrl).toBeTruthy();
3761
- expect18(requestInfo.createConnState.requestHeaders).toBeTruthy();
3762
- expect18(typeof requestInfo.createConnState.requestHeaders).toBe(
3857
+ expect19(requestInfo.createConnState.hasRequest).toBe(true);
3858
+ expect19(requestInfo.createConnState.requestMethod).toBeTruthy();
3859
+ expect19(requestInfo.createConnState.requestUrl).toBeTruthy();
3860
+ expect19(requestInfo.createConnState.requestHeaders).toBeTruthy();
3861
+ expect19(typeof requestInfo.createConnState.requestHeaders).toBe(
3763
3862
  "object"
3764
3863
  );
3765
3864
  } else {
@@ -3776,16 +3875,19 @@ function runDriverTests(driverTestConfigPartial) {
3776
3875
  ...driverTestConfigPartial,
3777
3876
  clientType
3778
3877
  };
3779
- describe20(`client type (${clientType})`, () => {
3878
+ describe21(`client type (${clientType})`, () => {
3879
+ var _a;
3780
3880
  runActorDriverTests(driverTestConfig);
3781
3881
  runManagerDriverTests(driverTestConfig);
3782
- for (const transport of ["websocket", "sse"]) {
3783
- describe20(`transport (${transport})`, () => {
3882
+ const transports = ((_a = driverTestConfig.skip) == null ? void 0 : _a.sse) ? ["websocket"] : ["websocket", "sse"];
3883
+ for (const transport of transports) {
3884
+ describe21(`transport (${transport})`, () => {
3784
3885
  runActorConnTests({
3785
3886
  ...driverTestConfig,
3786
3887
  transport
3787
3888
  });
3788
3889
  runActorConnStateTests({ ...driverTestConfig, transport });
3890
+ runActorReconnectTests({ ...driverTestConfig, transport });
3789
3891
  runRequestAccessTests({ ...driverTestConfig, transport });
3790
3892
  runActorDriverTestsWithTransport({ ...driverTestConfig, transport });
3791
3893
  });
@@ -3837,11 +3939,12 @@ async function createTestRuntime(registryPath, driverFactory) {
3837
3939
  }
3838
3940
  });
3839
3941
  const managerDriver = driver.manager(registry.config, config);
3942
+ configureInspectorAccessToken(config, managerDriver);
3840
3943
  const { router } = createManagerRouter(
3841
3944
  registry.config,
3842
3945
  config,
3843
3946
  managerDriver,
3844
- false
3947
+ void 0
3845
3948
  );
3846
3949
  const nodeWebSocket = createNodeWebSocket({ app: router });
3847
3950
  upgradeWebSocket = nodeWebSocket.upgradeWebSocket;