rivetkit 2.0.24-rc.1 → 2.0.25-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.
- package/dist/schemas/actor-persist/v1.ts +6 -0
- package/dist/schemas/actor-persist/v2.ts +9 -3
- package/dist/schemas/actor-persist/v3.ts +280 -0
- package/dist/schemas/client-protocol/v1.ts +6 -0
- package/dist/schemas/client-protocol/v2.ts +438 -0
- package/dist/schemas/file-system-driver/v1.ts +6 -0
- package/dist/schemas/file-system-driver/v2.ts +142 -0
- package/dist/tsup/actor/errors.cjs +2 -4
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +7 -10
- package/dist/tsup/actor/errors.d.ts +7 -10
- package/dist/tsup/actor/errors.js +9 -11
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.cts → actor-router-consts-DzI2szci.d.cts} +5 -9
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.ts → actor-router-consts-DzI2szci.d.ts} +5 -9
- package/dist/tsup/{chunk-ZTH3KYFH.cjs → chunk-3FG5OJ3G.cjs} +3 -3
- package/dist/tsup/{chunk-ZTH3KYFH.cjs.map → chunk-3FG5OJ3G.cjs.map} +1 -1
- package/dist/tsup/{chunk-BLK27ES3.js → chunk-6JN6W6G3.js} +44 -56
- package/dist/tsup/chunk-6JN6W6G3.js.map +1 -0
- package/dist/tsup/chunk-7IBNNGQ2.js +514 -0
- package/dist/tsup/chunk-7IBNNGQ2.js.map +1 -0
- package/dist/tsup/{chunk-36JJ4IQB.cjs → chunk-AZATXPR4.cjs} +4 -8
- package/dist/tsup/chunk-AZATXPR4.cjs.map +1 -0
- package/dist/tsup/chunk-B7MENRD5.cjs +5694 -0
- package/dist/tsup/chunk-B7MENRD5.cjs.map +1 -0
- package/dist/tsup/{chunk-BOMZS2TJ.js → chunk-BBVFDEYD.js} +9 -9
- package/dist/tsup/chunk-BBVFDEYD.js.map +1 -0
- package/dist/tsup/{chunk-KSRXX3Z4.cjs → chunk-D6762AOA.cjs} +20 -25
- package/dist/tsup/chunk-D6762AOA.cjs.map +1 -0
- package/dist/tsup/{chunk-2JYPS5YM.cjs → chunk-E63WZNMR.cjs} +6 -6
- package/dist/tsup/chunk-E63WZNMR.cjs.map +1 -0
- package/dist/tsup/{chunk-YBG6R7LX.js → chunk-EDGN4OC7.js} +3 -7
- package/dist/tsup/chunk-EDGN4OC7.js.map +1 -0
- package/dist/tsup/{chunk-BYMKMOBS.js → chunk-FLOQ3UWM.js} +1844 -1681
- package/dist/tsup/chunk-FLOQ3UWM.js.map +1 -0
- package/dist/tsup/{chunk-7L65NNWP.cjs → chunk-H7GV5DIW.cjs} +187 -185
- package/dist/tsup/chunk-H7GV5DIW.cjs.map +1 -0
- package/dist/tsup/{chunk-227FEWMB.js → chunk-HZYZ7JSF.js} +3322 -2251
- package/dist/tsup/chunk-HZYZ7JSF.js.map +1 -0
- package/dist/tsup/{chunk-FX7TWFQR.js → chunk-IDJK7ILQ.js} +2 -6
- package/dist/tsup/chunk-IDJK7ILQ.js.map +1 -0
- package/dist/tsup/{chunk-VHGY7PU5.cjs → chunk-ILFXA4AL.cjs} +1900 -1737
- package/dist/tsup/chunk-ILFXA4AL.cjs.map +1 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs +514 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs.map +1 -0
- package/dist/tsup/{chunk-PLUN2NQT.js → chunk-NWBKMCWC.js} +189 -187
- package/dist/tsup/chunk-NWBKMCWC.js.map +1 -0
- package/dist/tsup/{chunk-CD33GT6Z.js → chunk-QIHBDXTO.js} +2 -2
- package/dist/tsup/{chunk-G64QUEDJ.js → chunk-W6RDS6NW.js} +23 -28
- package/dist/tsup/chunk-W6RDS6NW.js.map +1 -0
- package/dist/tsup/{chunk-INNFK746.cjs → chunk-WQU4M4ZC.cjs} +10 -14
- package/dist/tsup/chunk-WQU4M4ZC.cjs.map +1 -0
- package/dist/tsup/{chunk-SHVX2QUR.cjs → chunk-XKZA47XS.cjs} +17 -17
- package/dist/tsup/chunk-XKZA47XS.cjs.map +1 -0
- package/dist/tsup/{chunk-HHFKKVLR.cjs → chunk-YHWIOWVA.cjs} +45 -57
- package/dist/tsup/chunk-YHWIOWVA.cjs.map +1 -0
- package/dist/tsup/{chunk-YBHYXIP6.js → chunk-YVL6IRUM.js} +3 -3
- package/dist/tsup/chunk-YVL6IRUM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -7
- package/dist/tsup/client/mod.d.ts +5 -7
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{conn-B3Vhbgnd.d.ts → config-BRDYDraU.d.cts} +1119 -1047
- package/dist/tsup/{conn-DJWL3nGx.d.cts → config-Bo-blHpJ.d.ts} +1119 -1047
- package/dist/tsup/driver-helpers/mod.cjs +5 -13
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +11 -9
- package/dist/tsup/driver-helpers/mod.d.ts +11 -9
- package/dist/tsup/driver-helpers/mod.js +14 -22
- package/dist/tsup/driver-test-suite/mod.cjs +474 -303
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +6 -9
- package/dist/tsup/driver-test-suite/mod.d.ts +6 -9
- package/dist/tsup/driver-test-suite/mod.js +1085 -914
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.d.cts +5 -7
- package/dist/tsup/inspector/mod.d.ts +5 -7
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -16
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +23 -25
- package/dist/tsup/mod.d.ts +23 -25
- package/dist/tsup/mod.js +17 -23
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.d.cts +4 -6
- package/dist/tsup/test/mod.d.ts +4 -6
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +3 -5
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +1 -2
- package/dist/tsup/utils.d.ts +1 -2
- package/dist/tsup/utils.js +2 -4
- package/package.json +13 -6
- package/src/actor/config.ts +56 -44
- package/src/actor/conn/driver.ts +61 -0
- package/src/actor/conn/drivers/http.ts +17 -0
- package/src/actor/conn/drivers/raw-request.ts +24 -0
- package/src/actor/conn/drivers/raw-websocket.ts +65 -0
- package/src/actor/conn/drivers/websocket.ts +129 -0
- package/src/actor/conn/mod.ts +232 -0
- package/src/actor/conn/persisted.ts +81 -0
- package/src/actor/conn/state-manager.ts +196 -0
- package/src/actor/contexts/action.ts +23 -0
- package/src/actor/{context.ts → contexts/actor.ts} +19 -8
- package/src/actor/contexts/conn-init.ts +31 -0
- package/src/actor/contexts/conn.ts +48 -0
- package/src/actor/contexts/create-conn-state.ts +13 -0
- package/src/actor/contexts/on-before-connect.ts +13 -0
- package/src/actor/contexts/on-connect.ts +22 -0
- package/src/actor/contexts/request.ts +48 -0
- package/src/actor/contexts/websocket.ts +48 -0
- package/src/actor/definition.ts +3 -3
- package/src/actor/driver.ts +36 -5
- package/src/actor/errors.ts +19 -24
- package/src/actor/instance/connection-manager.ts +465 -0
- package/src/actor/instance/event-manager.ts +292 -0
- package/src/actor/instance/kv.ts +15 -0
- package/src/actor/instance/mod.ts +1107 -0
- package/src/actor/instance/persisted.ts +67 -0
- package/src/actor/instance/schedule-manager.ts +349 -0
- package/src/actor/instance/state-manager.ts +502 -0
- package/src/actor/mod.ts +13 -16
- package/src/actor/protocol/old.ts +131 -43
- package/src/actor/protocol/serde.ts +19 -4
- package/src/actor/router-endpoints.ts +61 -586
- package/src/actor/router-websocket-endpoints.ts +408 -0
- package/src/actor/router.ts +63 -197
- package/src/actor/schedule.ts +1 -1
- package/src/client/actor-conn.ts +183 -249
- package/src/client/actor-handle.ts +29 -6
- package/src/client/client.ts +0 -4
- package/src/client/config.ts +1 -4
- package/src/client/mod.ts +0 -1
- package/src/client/raw-utils.ts +3 -3
- package/src/client/utils.ts +85 -39
- package/src/common/actor-router-consts.ts +5 -12
- package/src/common/{inline-websocket-adapter2.ts → inline-websocket-adapter.ts} +26 -48
- package/src/common/log.ts +1 -1
- package/src/common/router.ts +28 -17
- package/src/common/utils.ts +2 -0
- package/src/driver-helpers/mod.ts +7 -10
- package/src/driver-helpers/utils.ts +18 -9
- package/src/driver-test-suite/mod.ts +26 -50
- package/src/driver-test-suite/test-inline-client-driver.ts +27 -51
- package/src/driver-test-suite/tests/actor-conn-hibernation.ts +150 -0
- package/src/driver-test-suite/tests/actor-conn-state.ts +1 -4
- package/src/driver-test-suite/tests/actor-conn.ts +5 -9
- package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
- package/src/driver-test-suite/tests/actor-driver.ts +0 -7
- package/src/driver-test-suite/tests/actor-handle.ts +12 -12
- package/src/driver-test-suite/tests/actor-metadata.ts +1 -1
- package/src/driver-test-suite/tests/manager-driver.ts +1 -1
- package/src/driver-test-suite/tests/raw-http-direct-registry.ts +8 -8
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +6 -5
- package/src/driver-test-suite/tests/raw-http.ts +5 -5
- package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +7 -7
- package/src/driver-test-suite/tests/request-access.ts +4 -4
- package/src/driver-test-suite/utils.ts +6 -10
- package/src/drivers/engine/actor-driver.ts +614 -424
- package/src/drivers/engine/mod.ts +0 -1
- package/src/drivers/file-system/actor.ts +24 -12
- package/src/drivers/file-system/global-state.ts +427 -37
- package/src/drivers/file-system/manager.ts +71 -83
- package/src/drivers/file-system/mod.ts +3 -0
- package/src/drivers/file-system/utils.ts +18 -8
- package/src/engine-process/mod.ts +38 -38
- package/src/inspector/utils.ts +7 -5
- package/src/manager/driver.ts +11 -4
- package/src/manager/gateway.ts +4 -29
- package/src/manager/protocol/mod.ts +0 -2
- package/src/manager/protocol/query.ts +0 -4
- package/src/manager/router.ts +67 -64
- package/src/manager-api/actors.ts +13 -0
- package/src/mod.ts +1 -3
- package/src/registry/mod.ts +20 -20
- package/src/registry/serve.ts +9 -14
- package/src/remote-manager-driver/actor-websocket-client.ts +1 -16
- package/src/remote-manager-driver/api-endpoints.ts +13 -1
- package/src/remote-manager-driver/api-utils.ts +8 -0
- package/src/remote-manager-driver/metadata.ts +58 -0
- package/src/remote-manager-driver/mod.ts +47 -62
- package/src/remote-manager-driver/ws-proxy.ts +1 -1
- package/src/schemas/actor-persist/mod.ts +1 -1
- package/src/schemas/actor-persist/versioned.ts +56 -31
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +41 -21
- package/src/schemas/client-protocol-zod/mod.ts +103 -0
- package/src/schemas/file-system-driver/mod.ts +1 -1
- package/src/schemas/file-system-driver/versioned.ts +42 -19
- package/src/serde.ts +33 -11
- package/src/test/mod.ts +7 -3
- package/src/utils/node.ts +173 -0
- package/src/utils.ts +0 -4
- package/dist/tsup/chunk-227FEWMB.js.map +0 -1
- package/dist/tsup/chunk-2JYPS5YM.cjs.map +0 -1
- package/dist/tsup/chunk-36JJ4IQB.cjs.map +0 -1
- package/dist/tsup/chunk-7L65NNWP.cjs.map +0 -1
- package/dist/tsup/chunk-BLK27ES3.js.map +0 -1
- package/dist/tsup/chunk-BOMZS2TJ.js.map +0 -1
- package/dist/tsup/chunk-BYMKMOBS.js.map +0 -1
- package/dist/tsup/chunk-FX7TWFQR.js.map +0 -1
- package/dist/tsup/chunk-G64QUEDJ.js.map +0 -1
- package/dist/tsup/chunk-HHFKKVLR.cjs.map +0 -1
- package/dist/tsup/chunk-INNFK746.cjs.map +0 -1
- package/dist/tsup/chunk-KSRXX3Z4.cjs.map +0 -1
- package/dist/tsup/chunk-O44LFKSB.cjs +0 -4623
- package/dist/tsup/chunk-O44LFKSB.cjs.map +0 -1
- package/dist/tsup/chunk-PLUN2NQT.js.map +0 -1
- package/dist/tsup/chunk-S4UJG7ZE.js +0 -1119
- package/dist/tsup/chunk-S4UJG7ZE.js.map +0 -1
- package/dist/tsup/chunk-SHVX2QUR.cjs.map +0 -1
- package/dist/tsup/chunk-VFB23BYZ.cjs +0 -1119
- package/dist/tsup/chunk-VFB23BYZ.cjs.map +0 -1
- package/dist/tsup/chunk-VHGY7PU5.cjs.map +0 -1
- package/dist/tsup/chunk-YBG6R7LX.js.map +0 -1
- package/dist/tsup/chunk-YBHYXIP6.js.map +0 -1
- package/src/actor/action.ts +0 -178
- package/src/actor/conn-drivers.ts +0 -216
- package/src/actor/conn-socket.ts +0 -8
- package/src/actor/conn.ts +0 -272
- package/src/actor/instance.ts +0 -2336
- package/src/actor/persisted.ts +0 -49
- package/src/actor/unstable-react.ts +0 -110
- package/src/driver-test-suite/tests/actor-reconnect.ts +0 -170
- package/src/drivers/engine/kv.ts +0 -3
- package/src/manager/hono-websocket-adapter.ts +0 -393
- /package/dist/tsup/{chunk-CD33GT6Z.js.map → chunk-QIHBDXTO.js.map} +0 -0
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { Context as HonoContext } from "hono";
|
|
2
2
|
import invariant from "invariant";
|
|
3
|
-
import {
|
|
3
|
+
import { ActorStopping } from "@/actor/errors";
|
|
4
4
|
import { type ActorRouter, createActorRouter } from "@/actor/router";
|
|
5
|
-
import {
|
|
6
|
-
handleRawWebSocketHandler,
|
|
7
|
-
handleWebSocketConnect,
|
|
8
|
-
} from "@/actor/router-endpoints";
|
|
5
|
+
import { routeWebSocket } from "@/actor/router-websocket-endpoints";
|
|
9
6
|
import { createClientWithDriver } from "@/client/client";
|
|
10
7
|
import { ClientConfigSchema } from "@/client/config";
|
|
11
|
-
import {
|
|
8
|
+
import { InlineWebSocketAdapter } from "@/common/inline-websocket-adapter";
|
|
12
9
|
import { noopNext } from "@/common/utils";
|
|
13
10
|
import type {
|
|
14
11
|
ActorDriver,
|
|
@@ -17,19 +14,18 @@ import type {
|
|
|
17
14
|
GetForIdInput,
|
|
18
15
|
GetOrCreateWithKeyInput,
|
|
19
16
|
GetWithKeyInput,
|
|
17
|
+
ListActorsInput,
|
|
20
18
|
ManagerDriver,
|
|
21
19
|
} from "@/driver-helpers/mod";
|
|
22
20
|
import { ManagerInspector } from "@/inspector/manager";
|
|
23
21
|
import { type Actor, ActorFeature, type ActorId } from "@/inspector/mod";
|
|
24
22
|
import type { ManagerDisplayInformation } from "@/manager/driver";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type RunConfig,
|
|
32
|
-
type UniversalWebSocket,
|
|
23
|
+
import type {
|
|
24
|
+
DriverConfig,
|
|
25
|
+
Encoding,
|
|
26
|
+
RegistryConfig,
|
|
27
|
+
RunConfig,
|
|
28
|
+
UniversalWebSocket,
|
|
33
29
|
} from "@/mod";
|
|
34
30
|
import type * as schema from "@/schemas/file-system-driver/mod";
|
|
35
31
|
import type { FileSystemGlobalState } from "./global-state";
|
|
@@ -157,46 +153,28 @@ export class FileSystemManagerDriver implements ManagerDriver {
|
|
|
157
153
|
actorId: string,
|
|
158
154
|
encoding: Encoding,
|
|
159
155
|
params: unknown,
|
|
160
|
-
connId?: string,
|
|
161
|
-
connToken?: string,
|
|
162
156
|
): Promise<UniversalWebSocket> {
|
|
163
157
|
// Handle raw WebSocket paths
|
|
164
158
|
const pathOnly = path.split("?")[0];
|
|
165
159
|
const normalizedPath = pathOnly.startsWith("/")
|
|
166
160
|
? pathOnly
|
|
167
161
|
: `/${pathOnly}`;
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
normalizedPath.startsWith(PATH_RAW_WEBSOCKET_PREFIX) ||
|
|
185
|
-
normalizedPath === "/raw/websocket"
|
|
186
|
-
) {
|
|
187
|
-
// Handle websocket proxy
|
|
188
|
-
// Use the full path with query parameters
|
|
189
|
-
const wsHandler = await handleRawWebSocketHandler(
|
|
190
|
-
undefined,
|
|
191
|
-
path,
|
|
192
|
-
this.#actorDriver,
|
|
193
|
-
actorId,
|
|
194
|
-
undefined,
|
|
195
|
-
);
|
|
196
|
-
return new InlineWebSocketAdapter2(wsHandler);
|
|
197
|
-
} else {
|
|
198
|
-
throw new Error(`Unreachable path: ${path}`);
|
|
199
|
-
}
|
|
162
|
+
const wsHandler = await routeWebSocket(
|
|
163
|
+
// TODO: Create fake request
|
|
164
|
+
undefined,
|
|
165
|
+
normalizedPath,
|
|
166
|
+
{},
|
|
167
|
+
this.#runConfig,
|
|
168
|
+
this.#actorDriver,
|
|
169
|
+
actorId,
|
|
170
|
+
encoding,
|
|
171
|
+
params,
|
|
172
|
+
undefined,
|
|
173
|
+
undefined,
|
|
174
|
+
false,
|
|
175
|
+
false,
|
|
176
|
+
);
|
|
177
|
+
return new InlineWebSocketAdapter(wsHandler);
|
|
200
178
|
}
|
|
201
179
|
|
|
202
180
|
async proxyRequest(
|
|
@@ -214,9 +192,7 @@ export class FileSystemManagerDriver implements ManagerDriver {
|
|
|
214
192
|
path: string,
|
|
215
193
|
actorId: string,
|
|
216
194
|
encoding: Encoding,
|
|
217
|
-
|
|
218
|
-
connId?: string,
|
|
219
|
-
connToken?: string,
|
|
195
|
+
params: unknown,
|
|
220
196
|
): Promise<Response> {
|
|
221
197
|
const upgradeWebSocket = this.#runConfig.getUpgradeWebSocket?.();
|
|
222
198
|
invariant(upgradeWebSocket, "missing getUpgradeWebSocket");
|
|
@@ -226,38 +202,22 @@ export class FileSystemManagerDriver implements ManagerDriver {
|
|
|
226
202
|
const normalizedPath = pathOnly.startsWith("/")
|
|
227
203
|
? pathOnly
|
|
228
204
|
: `/${pathOnly}`;
|
|
229
|
-
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
normalizedPath.startsWith(PATH_RAW_WEBSOCKET_PREFIX) ||
|
|
246
|
-
normalizedPath === "/raw/websocket"
|
|
247
|
-
) {
|
|
248
|
-
// Handle websocket proxy
|
|
249
|
-
// Use the full path with query parameters
|
|
250
|
-
const wsHandler = await handleRawWebSocketHandler(
|
|
251
|
-
c.req.raw,
|
|
252
|
-
path,
|
|
253
|
-
this.#actorDriver,
|
|
254
|
-
actorId,
|
|
255
|
-
undefined,
|
|
256
|
-
);
|
|
257
|
-
return upgradeWebSocket(() => wsHandler)(c, noopNext());
|
|
258
|
-
} else {
|
|
259
|
-
throw new Error(`Unreachable path: ${path}`);
|
|
260
|
-
}
|
|
205
|
+
const wsHandler = await routeWebSocket(
|
|
206
|
+
// TODO: Create new request with new path
|
|
207
|
+
c.req.raw,
|
|
208
|
+
normalizedPath,
|
|
209
|
+
c.req.header(),
|
|
210
|
+
this.#runConfig,
|
|
211
|
+
this.#actorDriver,
|
|
212
|
+
actorId,
|
|
213
|
+
encoding,
|
|
214
|
+
params,
|
|
215
|
+
undefined,
|
|
216
|
+
undefined,
|
|
217
|
+
false,
|
|
218
|
+
false,
|
|
219
|
+
);
|
|
220
|
+
return upgradeWebSocket(() => wsHandler)(c, noopNext());
|
|
261
221
|
}
|
|
262
222
|
|
|
263
223
|
async getForId({
|
|
@@ -268,6 +228,9 @@ export class FileSystemManagerDriver implements ManagerDriver {
|
|
|
268
228
|
if (!actor.state) {
|
|
269
229
|
return undefined;
|
|
270
230
|
}
|
|
231
|
+
if (this.#state.isActorStopping(actorId)) {
|
|
232
|
+
throw new ActorStopping(actorId);
|
|
233
|
+
}
|
|
271
234
|
|
|
272
235
|
try {
|
|
273
236
|
// Load actor state
|
|
@@ -341,6 +304,31 @@ export class FileSystemManagerDriver implements ManagerDriver {
|
|
|
341
304
|
};
|
|
342
305
|
}
|
|
343
306
|
|
|
307
|
+
async listActors({ name }: ListActorsInput): Promise<ActorOutput[]> {
|
|
308
|
+
const actors: ActorOutput[] = [];
|
|
309
|
+
const itr = this.#state.getActorsIterator({});
|
|
310
|
+
|
|
311
|
+
for await (const actor of itr) {
|
|
312
|
+
if (actor.name === name) {
|
|
313
|
+
actors.push({
|
|
314
|
+
actorId: actor.actorId,
|
|
315
|
+
name: actor.name,
|
|
316
|
+
key: actor.key as string[],
|
|
317
|
+
createTs: Number(actor.createdAt),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Sort by create ts desc (most recent first)
|
|
323
|
+
actors.sort((a, b) => {
|
|
324
|
+
const aTs = a.createTs ?? 0;
|
|
325
|
+
const bTs = b.createTs ?? 0;
|
|
326
|
+
return bTs - aTs;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
return actors;
|
|
330
|
+
}
|
|
331
|
+
|
|
344
332
|
displayInformation(): ManagerDisplayInformation {
|
|
345
333
|
return {
|
|
346
334
|
name: this.#state.persist ? "File System" : "Memory",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DriverConfig } from "@/registry/run-config";
|
|
2
|
+
import { importNodeDependencies } from "@/utils/node";
|
|
2
3
|
import { FileSystemActorDriver } from "./actor";
|
|
3
4
|
import { FileSystemGlobalState } from "./global-state";
|
|
4
5
|
import { FileSystemManagerDriver } from "./manager";
|
|
@@ -12,6 +13,8 @@ export function createFileSystemOrMemoryDriver(
|
|
|
12
13
|
persist: boolean = true,
|
|
13
14
|
customPath?: string,
|
|
14
15
|
): DriverConfig {
|
|
16
|
+
importNodeDependencies();
|
|
17
|
+
|
|
15
18
|
const state = new FileSystemGlobalState(persist, customPath);
|
|
16
19
|
const driverConfig: DriverConfig = {
|
|
17
20
|
name: persist ? "file-system" : "memory",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import * as crypto from "node:crypto";
|
|
2
|
-
import * as fsSync from "node:fs";
|
|
3
|
-
import * as fs from "node:fs/promises";
|
|
4
|
-
import * as os from "node:os";
|
|
5
|
-
import * as path from "node:path";
|
|
6
1
|
import type { ActorKey } from "@/actor/mod";
|
|
2
|
+
import {
|
|
3
|
+
getNodeCrypto,
|
|
4
|
+
getNodeFs,
|
|
5
|
+
getNodeFsSync,
|
|
6
|
+
getNodeOs,
|
|
7
|
+
getNodePath,
|
|
8
|
+
} from "@/utils/node";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Generate a deterministic actor ID from name and key
|
|
@@ -13,6 +15,7 @@ export function generateActorId(name: string, key: ActorKey): string {
|
|
|
13
15
|
const jsonString = JSON.stringify([name, key]);
|
|
14
16
|
|
|
15
17
|
// Hash to ensure safe file system names
|
|
18
|
+
const crypto = getNodeCrypto();
|
|
16
19
|
const hash = crypto
|
|
17
20
|
.createHash("sha256")
|
|
18
21
|
.update(jsonString)
|
|
@@ -26,6 +29,7 @@ export function generateActorId(name: string, key: ActorKey): string {
|
|
|
26
29
|
* Create a hash for a path, normalizing it first
|
|
27
30
|
*/
|
|
28
31
|
function createHashForPath(dirPath: string): string {
|
|
32
|
+
const path = getNodePath();
|
|
29
33
|
// Normalize the path first
|
|
30
34
|
const normalizedPath = path.normalize(dirPath);
|
|
31
35
|
|
|
@@ -33,6 +37,7 @@ function createHashForPath(dirPath: string): string {
|
|
|
33
37
|
const lastComponent = path.basename(normalizedPath);
|
|
34
38
|
|
|
35
39
|
// Create SHA-256 hash
|
|
40
|
+
const crypto = getNodeCrypto();
|
|
36
41
|
const hash = crypto
|
|
37
42
|
.createHash("sha256")
|
|
38
43
|
.update(normalizedPath)
|
|
@@ -45,10 +50,10 @@ function createHashForPath(dirPath: string): string {
|
|
|
45
50
|
/**
|
|
46
51
|
* Get the storage path for the current working directory or a specified path
|
|
47
52
|
*/
|
|
48
|
-
export function getStoragePath(
|
|
53
|
+
export function getStoragePath(): string {
|
|
49
54
|
const dataPath = getDataPath("rivetkit");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
55
|
+
const dirHash = createHashForPath(process.cwd());
|
|
56
|
+
const path = getNodePath();
|
|
52
57
|
return path.join(dataPath, dirHash);
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -57,6 +62,7 @@ export function getStoragePath(customPath?: string): string {
|
|
|
57
62
|
*/
|
|
58
63
|
export async function pathExists(path: string): Promise<boolean> {
|
|
59
64
|
try {
|
|
65
|
+
const fs = getNodeFs();
|
|
60
66
|
await fs.access(path);
|
|
61
67
|
return true;
|
|
62
68
|
} catch {
|
|
@@ -71,6 +77,7 @@ export async function ensureDirectoryExists(
|
|
|
71
77
|
directoryPath: string,
|
|
72
78
|
): Promise<void> {
|
|
73
79
|
if (!(await pathExists(directoryPath))) {
|
|
80
|
+
const fs = getNodeFs();
|
|
74
81
|
await fs.mkdir(directoryPath, { recursive: true });
|
|
75
82
|
}
|
|
76
83
|
}
|
|
@@ -80,6 +87,7 @@ export async function ensureDirectoryExists(
|
|
|
80
87
|
* All other operations use the async version
|
|
81
88
|
*/
|
|
82
89
|
export function ensureDirectoryExistsSync(directoryPath: string): void {
|
|
90
|
+
const fsSync = getNodeFsSync();
|
|
83
91
|
if (!fsSync.existsSync(directoryPath)) {
|
|
84
92
|
fsSync.mkdirSync(directoryPath, { recursive: true });
|
|
85
93
|
}
|
|
@@ -90,7 +98,9 @@ export function ensureDirectoryExistsSync(directoryPath: string): void {
|
|
|
90
98
|
*/
|
|
91
99
|
function getDataPath(appName: string): string {
|
|
92
100
|
const platform = process.platform;
|
|
101
|
+
const os = getNodeOs();
|
|
93
102
|
const homeDir = os.homedir();
|
|
103
|
+
const path = getNodePath();
|
|
94
104
|
|
|
95
105
|
switch (platform) {
|
|
96
106
|
case "win32":
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { createWriteStream } from "node:fs";
|
|
4
|
-
import * as fs from "node:fs/promises";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { pipeline } from "node:stream/promises";
|
|
7
1
|
import {
|
|
8
2
|
ensureDirectoryExists,
|
|
9
3
|
getStoragePath,
|
|
10
4
|
} from "@/drivers/file-system/utils";
|
|
11
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getNodeChildProcess,
|
|
7
|
+
getNodeCrypto,
|
|
8
|
+
getNodeFs,
|
|
9
|
+
getNodeFsSync,
|
|
10
|
+
getNodePath,
|
|
11
|
+
getNodeStream,
|
|
12
|
+
importNodeDependencies,
|
|
13
|
+
} from "@/utils/node";
|
|
12
14
|
import { logger } from "./log";
|
|
13
15
|
|
|
14
16
|
export const ENGINE_PORT = 6420;
|
|
@@ -24,10 +26,14 @@ interface EnsureEngineProcessOptions {
|
|
|
24
26
|
export async function ensureEngineProcess(
|
|
25
27
|
options: EnsureEngineProcessOptions,
|
|
26
28
|
): Promise<void> {
|
|
29
|
+
importNodeDependencies();
|
|
30
|
+
|
|
27
31
|
logger().debug({
|
|
28
32
|
msg: "ensuring engine process",
|
|
29
33
|
version: options.version,
|
|
30
34
|
});
|
|
35
|
+
|
|
36
|
+
const path = getNodePath();
|
|
31
37
|
const storageRoot = getStoragePath();
|
|
32
38
|
const binDir = path.join(storageRoot, "bin");
|
|
33
39
|
const varDir = path.join(storageRoot, "var");
|
|
@@ -62,7 +68,6 @@ export async function ensureEngineProcess(
|
|
|
62
68
|
);
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
|
-
|
|
66
71
|
// Create log file streams with timestamp in the filename
|
|
67
72
|
const timestamp = new Date()
|
|
68
73
|
.toISOString()
|
|
@@ -71,8 +76,13 @@ export async function ensureEngineProcess(
|
|
|
71
76
|
const stdoutLogPath = path.join(logsDir, `engine-${timestamp}-stdout.log`);
|
|
72
77
|
const stderrLogPath = path.join(logsDir, `engine-${timestamp}-stderr.log`);
|
|
73
78
|
|
|
74
|
-
const
|
|
75
|
-
const
|
|
79
|
+
const fsSync = getNodeFsSync();
|
|
80
|
+
const stdoutStream = fsSync.createWriteStream(stdoutLogPath, {
|
|
81
|
+
flags: "a",
|
|
82
|
+
});
|
|
83
|
+
const stderrStream = fsSync.createWriteStream(stderrLogPath, {
|
|
84
|
+
flags: "a",
|
|
85
|
+
});
|
|
76
86
|
|
|
77
87
|
logger().debug({
|
|
78
88
|
msg: "creating engine log files",
|
|
@@ -80,30 +90,12 @@ export async function ensureEngineProcess(
|
|
|
80
90
|
stderr: stderrLogPath,
|
|
81
91
|
});
|
|
82
92
|
|
|
83
|
-
const
|
|
93
|
+
const childProcess = getNodeChildProcess();
|
|
94
|
+
const child = childProcess.spawn(binaryPath, ["start"], {
|
|
84
95
|
cwd: path.dirname(binaryPath),
|
|
85
96
|
stdio: ["inherit", "pipe", "pipe"],
|
|
86
97
|
env: {
|
|
87
98
|
...process.env,
|
|
88
|
-
// In development, runners can be terminated without a graceful
|
|
89
|
-
// shutdown (i.e. SIGKILL instead of SIGTERM). This is treated as a
|
|
90
|
-
// crash by Rivet Engine in production and implements a backoff for
|
|
91
|
-
// rescheduling actors in case of a crash loop.
|
|
92
|
-
//
|
|
93
|
-
// This is problematic in development since this will cause actors
|
|
94
|
-
// to become unresponsive if frequently killing your dev server.
|
|
95
|
-
//
|
|
96
|
-
// We reduce the timeouts for resetting a runner as healthy in
|
|
97
|
-
// order to account for this.
|
|
98
|
-
RIVET__PEGBOARD__RETRY_RESET_DURATION: "100",
|
|
99
|
-
RIVET__PEGBOARD__BASE_RETRY_TIMEOUT: "100",
|
|
100
|
-
// Set max exponent to 1 to have a maximum of base_retry_timeout
|
|
101
|
-
RIVET__PEGBOARD__RESCHEDULE_BACKOFF_MAX_EXPONENT: "1",
|
|
102
|
-
// Reduce thresholds for faster development iteration
|
|
103
|
-
//
|
|
104
|
-
// Default ping interval is 3s, this gives a 2s & 4s grace
|
|
105
|
-
RIVET__PEGBOARD__RUNNER_ELIGIBLE_THRESHOLD: "5000",
|
|
106
|
-
RIVET__PEGBOARD__RUNNER_LOST_THRESHOLD: "7000",
|
|
107
99
|
},
|
|
108
100
|
});
|
|
109
101
|
|
|
@@ -118,7 +110,6 @@ export async function ensureEngineProcess(
|
|
|
118
110
|
if (child.stderr) {
|
|
119
111
|
child.stderr.pipe(stderrStream);
|
|
120
112
|
}
|
|
121
|
-
|
|
122
113
|
logger().debug({
|
|
123
114
|
msg: "spawned engine process",
|
|
124
115
|
pid: child.pid,
|
|
@@ -130,7 +121,8 @@ export async function ensureEngineProcess(
|
|
|
130
121
|
msg: "engine process exited, please report this error",
|
|
131
122
|
code,
|
|
132
123
|
signal,
|
|
133
|
-
|
|
124
|
+
issues: "https://github.com/rivet-dev/rivetkit/issues",
|
|
125
|
+
support: "https://rivet.dev/discord",
|
|
134
126
|
});
|
|
135
127
|
// Clean up log streams
|
|
136
128
|
stdoutStream.end();
|
|
@@ -194,7 +186,8 @@ async function downloadEngineBinaryIfNeeded(
|
|
|
194
186
|
}
|
|
195
187
|
|
|
196
188
|
// Generate unique temp file name to prevent parallel download conflicts
|
|
197
|
-
const
|
|
189
|
+
const crypto = getNodeCrypto();
|
|
190
|
+
const tempPath = `${binaryPath}.${crypto.randomUUID()}.tmp`;
|
|
198
191
|
const startTime = Date.now();
|
|
199
192
|
|
|
200
193
|
logger().debug({
|
|
@@ -212,12 +205,18 @@ async function downloadEngineBinaryIfNeeded(
|
|
|
212
205
|
}, 5000);
|
|
213
206
|
|
|
214
207
|
try {
|
|
215
|
-
|
|
208
|
+
const stream = getNodeStream();
|
|
209
|
+
const fsSync = getNodeFsSync();
|
|
210
|
+
await stream.pipeline(
|
|
211
|
+
response.body,
|
|
212
|
+
fsSync.createWriteStream(tempPath),
|
|
213
|
+
);
|
|
216
214
|
|
|
217
215
|
// Clear the slow download warning
|
|
218
216
|
clearTimeout(slowDownloadWarning);
|
|
219
217
|
|
|
220
218
|
// Get file size to verify download
|
|
219
|
+
const fs = getNodeFs();
|
|
221
220
|
const stats = await fs.stat(tempPath);
|
|
222
221
|
const downloadDuration = Date.now() - startTime;
|
|
223
222
|
|
|
@@ -247,9 +246,11 @@ async function downloadEngineBinaryIfNeeded(
|
|
|
247
246
|
msg: "engine download failed, please report this error",
|
|
248
247
|
tempPath,
|
|
249
248
|
error,
|
|
250
|
-
|
|
249
|
+
issues: "https://github.com/rivet-dev/rivetkit/issues",
|
|
250
|
+
support: "https://rivet.dev/discord",
|
|
251
251
|
});
|
|
252
252
|
try {
|
|
253
|
+
const fs = getNodeFs();
|
|
253
254
|
await fs.unlink(tempPath);
|
|
254
255
|
} catch (unlinkError) {
|
|
255
256
|
// Ignore errors when cleaning up (file may not exist)
|
|
@@ -257,7 +258,7 @@ async function downloadEngineBinaryIfNeeded(
|
|
|
257
258
|
throw error;
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
+
//
|
|
261
262
|
function resolveTargetTriplet(): { targetTriplet: string; extension: string } {
|
|
262
263
|
return resolveTargetTripletFor(process.platform, process.arch);
|
|
263
264
|
}
|
|
@@ -297,7 +298,6 @@ export function resolveTargetTripletFor(
|
|
|
297
298
|
`unsupported platform for rivet engine binary: ${platform}/${arch}`,
|
|
298
299
|
);
|
|
299
300
|
}
|
|
300
|
-
|
|
301
301
|
async function isEngineRunning(): Promise<boolean> {
|
|
302
302
|
// Check if the engine is running on the port
|
|
303
303
|
return await checkIfEngineAlreadyRunningOnPort(ENGINE_PORT);
|
|
@@ -346,9 +346,9 @@ async function checkIfEngineAlreadyRunningOnPort(
|
|
|
346
346
|
// Port responded but not with OK status
|
|
347
347
|
return false;
|
|
348
348
|
}
|
|
349
|
-
|
|
350
349
|
async function fileExists(filePath: string): Promise<boolean> {
|
|
351
350
|
try {
|
|
351
|
+
const fs = getNodeFs();
|
|
352
352
|
await fs.access(filePath);
|
|
353
353
|
return true;
|
|
354
354
|
} catch {
|
package/src/inspector/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
1
|
+
// import crypto from "node:crypto";
|
|
2
2
|
import { createMiddleware } from "hono/factory";
|
|
3
3
|
import type { ManagerDriver } from "@/driver-helpers/mod";
|
|
4
4
|
import type { RunConfig } from "@/mod";
|
|
@@ -20,10 +20,11 @@ export function compareSecrets(providedSecret: string, validSecret: string) {
|
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
// TODO:
|
|
24
|
+
// // Perform timing-safe comparison
|
|
25
|
+
// if (!crypto.timingSafeEqual(a, b)) {
|
|
26
|
+
// return false;
|
|
27
|
+
// }
|
|
27
28
|
return true;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -77,6 +78,7 @@ export function getInspectorUrl(runConfig: RunnerConfigInput | undefined) {
|
|
|
77
78
|
|
|
78
79
|
export const isInspectorEnabled = (
|
|
79
80
|
runConfig: RunConfig,
|
|
81
|
+
// TODO(kacper): Remove context in favor of using the gateway, so only context is the actor
|
|
80
82
|
context: "actor" | "manager",
|
|
81
83
|
) => {
|
|
82
84
|
if (typeof runConfig.inspector?.enabled === "boolean") {
|
package/src/manager/driver.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface ManagerDriver {
|
|
|
14
14
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
15
15
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
16
16
|
createActor(input: CreateInput): Promise<ActorOutput>;
|
|
17
|
+
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
17
18
|
|
|
18
19
|
sendRequest(actorId: string, actorRequest: Request): Promise<Response>;
|
|
19
20
|
openWebSocket(
|
|
@@ -21,8 +22,6 @@ export interface ManagerDriver {
|
|
|
21
22
|
actorId: string,
|
|
22
23
|
encoding: Encoding,
|
|
23
24
|
params: unknown,
|
|
24
|
-
connId?: string,
|
|
25
|
-
connToken?: string,
|
|
26
25
|
): Promise<UniversalWebSocket>;
|
|
27
26
|
proxyRequest(
|
|
28
27
|
c: HonoContext,
|
|
@@ -35,8 +34,6 @@ export interface ManagerDriver {
|
|
|
35
34
|
actorId: string,
|
|
36
35
|
encoding: Encoding,
|
|
37
36
|
params: unknown,
|
|
38
|
-
connId?: string,
|
|
39
|
-
connToken?: string,
|
|
40
37
|
): Promise<Response>;
|
|
41
38
|
|
|
42
39
|
displayInformation(): ManagerDisplayInformation;
|
|
@@ -48,11 +45,13 @@ export interface ManagerDriver {
|
|
|
48
45
|
router: Hono,
|
|
49
46
|
) => void;
|
|
50
47
|
|
|
48
|
+
// TODO(kacper): Remove this in favor of standard manager API
|
|
51
49
|
/**
|
|
52
50
|
* @internal
|
|
53
51
|
*/
|
|
54
52
|
readonly inspector?: ManagerInspector;
|
|
55
53
|
|
|
54
|
+
// TODO(kacper): Remove this in favor of ActorDriver.getinspectorToken
|
|
56
55
|
/**
|
|
57
56
|
* Get or create the inspector access token.
|
|
58
57
|
* @experimental
|
|
@@ -94,8 +93,16 @@ export interface CreateInput<E extends Env = any> {
|
|
|
94
93
|
region?: string;
|
|
95
94
|
}
|
|
96
95
|
|
|
96
|
+
export interface ListActorsInput<E extends Env = any> {
|
|
97
|
+
c?: HonoContext | undefined;
|
|
98
|
+
name: string;
|
|
99
|
+
key?: string;
|
|
100
|
+
includeDestroyed?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
export interface ActorOutput {
|
|
98
104
|
actorId: string;
|
|
99
105
|
name: string;
|
|
100
106
|
key: ActorKey;
|
|
107
|
+
createTs?: number;
|
|
101
108
|
}
|
package/src/manager/gateway.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import type { Context as HonoContext, Next } from "hono";
|
|
2
2
|
import type { WSContext } from "hono/ws";
|
|
3
3
|
import { MissingActorHeader, WebSocketsNotEnabled } from "@/actor/errors";
|
|
4
|
-
import type {
|
|
4
|
+
import type { UpgradeWebSocketArgs } from "@/actor/router-websocket-endpoints";
|
|
5
5
|
import {
|
|
6
6
|
HEADER_RIVET_ACTOR,
|
|
7
|
-
HEADER_RIVET_NAMESPACE,
|
|
8
7
|
HEADER_RIVET_TARGET,
|
|
9
8
|
WS_PROTOCOL_ACTOR,
|
|
10
|
-
WS_PROTOCOL_CONN_ID,
|
|
11
9
|
WS_PROTOCOL_CONN_PARAMS,
|
|
12
|
-
WS_PROTOCOL_CONN_TOKEN,
|
|
13
10
|
WS_PROTOCOL_ENCODING,
|
|
14
11
|
WS_PROTOCOL_TARGET,
|
|
15
|
-
WS_PROTOCOL_TOKEN,
|
|
16
12
|
} from "@/common/actor-router-consts";
|
|
17
|
-
import {
|
|
18
|
-
import type { UniversalWebSocket, UpgradeWebSocketArgs } from "@/mod";
|
|
13
|
+
import type { UniversalWebSocket } from "@/mod";
|
|
19
14
|
import type { RunnerConfig } from "@/registry/run-config";
|
|
20
|
-
import { promiseWithResolvers
|
|
15
|
+
import { promiseWithResolvers } from "@/utils";
|
|
21
16
|
import type { ManagerDriver } from "./driver";
|
|
22
17
|
import { logger } from "./log";
|
|
23
18
|
|
|
@@ -47,8 +42,6 @@ async function handleWebSocketGatewayPathBased(
|
|
|
47
42
|
const protocols = c.req.header("sec-websocket-protocol");
|
|
48
43
|
let encodingRaw: string | undefined;
|
|
49
44
|
let connParamsRaw: string | undefined;
|
|
50
|
-
let connIdRaw: string | undefined;
|
|
51
|
-
let connTokenRaw: string | undefined;
|
|
52
45
|
|
|
53
46
|
if (protocols) {
|
|
54
47
|
const protocolList = protocols.split(",").map((p) => p.trim());
|
|
@@ -59,12 +52,6 @@ async function handleWebSocketGatewayPathBased(
|
|
|
59
52
|
connParamsRaw = decodeURIComponent(
|
|
60
53
|
protocol.substring(WS_PROTOCOL_CONN_PARAMS.length),
|
|
61
54
|
);
|
|
62
|
-
} else if (protocol.startsWith(WS_PROTOCOL_CONN_ID)) {
|
|
63
|
-
connIdRaw = protocol.substring(WS_PROTOCOL_CONN_ID.length);
|
|
64
|
-
} else if (protocol.startsWith(WS_PROTOCOL_CONN_TOKEN)) {
|
|
65
|
-
connTokenRaw = protocol.substring(
|
|
66
|
-
WS_PROTOCOL_CONN_TOKEN.length,
|
|
67
|
-
);
|
|
68
55
|
}
|
|
69
56
|
}
|
|
70
57
|
}
|
|
@@ -85,8 +72,6 @@ async function handleWebSocketGatewayPathBased(
|
|
|
85
72
|
actorPathInfo.actorId,
|
|
86
73
|
encoding as any, // Will be validated by driver
|
|
87
74
|
connParams,
|
|
88
|
-
connIdRaw,
|
|
89
|
-
connTokenRaw,
|
|
90
75
|
);
|
|
91
76
|
}
|
|
92
77
|
|
|
@@ -230,8 +215,6 @@ async function handleWebSocketGateway(
|
|
|
230
215
|
let actorId: string | undefined;
|
|
231
216
|
let encodingRaw: string | undefined;
|
|
232
217
|
let connParamsRaw: string | undefined;
|
|
233
|
-
let connIdRaw: string | undefined;
|
|
234
|
-
let connTokenRaw: string | undefined;
|
|
235
218
|
|
|
236
219
|
if (protocols) {
|
|
237
220
|
const protocolList = protocols.split(",").map((p) => p.trim());
|
|
@@ -239,19 +222,13 @@ async function handleWebSocketGateway(
|
|
|
239
222
|
if (protocol.startsWith(WS_PROTOCOL_TARGET)) {
|
|
240
223
|
target = protocol.substring(WS_PROTOCOL_TARGET.length);
|
|
241
224
|
} else if (protocol.startsWith(WS_PROTOCOL_ACTOR)) {
|
|
242
|
-
actorId = protocol.substring(WS_PROTOCOL_ACTOR.length);
|
|
225
|
+
actorId = decodeURIComponent(protocol.substring(WS_PROTOCOL_ACTOR.length));
|
|
243
226
|
} else if (protocol.startsWith(WS_PROTOCOL_ENCODING)) {
|
|
244
227
|
encodingRaw = protocol.substring(WS_PROTOCOL_ENCODING.length);
|
|
245
228
|
} else if (protocol.startsWith(WS_PROTOCOL_CONN_PARAMS)) {
|
|
246
229
|
connParamsRaw = decodeURIComponent(
|
|
247
230
|
protocol.substring(WS_PROTOCOL_CONN_PARAMS.length),
|
|
248
231
|
);
|
|
249
|
-
} else if (protocol.startsWith(WS_PROTOCOL_CONN_ID)) {
|
|
250
|
-
connIdRaw = protocol.substring(WS_PROTOCOL_CONN_ID.length);
|
|
251
|
-
} else if (protocol.startsWith(WS_PROTOCOL_CONN_TOKEN)) {
|
|
252
|
-
connTokenRaw = protocol.substring(
|
|
253
|
-
WS_PROTOCOL_CONN_TOKEN.length,
|
|
254
|
-
);
|
|
255
232
|
}
|
|
256
233
|
}
|
|
257
234
|
}
|
|
@@ -285,8 +262,6 @@ async function handleWebSocketGateway(
|
|
|
285
262
|
actorId,
|
|
286
263
|
encoding as any, // Will be validated by driver
|
|
287
264
|
connParams,
|
|
288
|
-
connIdRaw,
|
|
289
|
-
connTokenRaw,
|
|
290
265
|
);
|
|
291
266
|
}
|
|
292
267
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { TransportSchema } from "@/actor/protocol/old";
|
|
3
2
|
import { ActorQuerySchema } from "./query";
|
|
4
3
|
|
|
5
4
|
export * from "./query";
|
|
@@ -10,7 +9,6 @@ export const ActorsRequestSchema = z.object({
|
|
|
10
9
|
|
|
11
10
|
export const ActorsResponseSchema = z.object({
|
|
12
11
|
actorId: z.string(),
|
|
13
|
-
supportedTransports: z.array(TransportSchema),
|
|
14
12
|
});
|
|
15
13
|
|
|
16
14
|
//export const RivetConfigResponseSchema = z.object({
|