rivetkit 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsup/actor-router-consts-BK6arfy8.d.cts +17 -0
- package/dist/tsup/actor-router-consts-BK6arfy8.d.ts +17 -0
- package/dist/tsup/chunk-2K3JMDAN.js +232 -0
- package/dist/tsup/chunk-2K3JMDAN.js.map +1 -0
- package/dist/tsup/chunk-42I3OZ3Q.js +15 -0
- package/dist/tsup/chunk-42I3OZ3Q.js.map +1 -0
- package/dist/tsup/{chunk-L7QRXNWP.js → chunk-4CKHQRXG.js} +1642 -4408
- package/dist/tsup/chunk-4CKHQRXG.js.map +1 -0
- package/dist/tsup/{chunk-WADSS5X4.cjs → chunk-5JBFVV4C.cjs} +2 -2
- package/dist/tsup/{chunk-WADSS5X4.cjs.map → chunk-5JBFVV4C.cjs.map} +1 -1
- package/dist/tsup/{chunk-FGFT4FVX.cjs → chunk-6P6RA47N.cjs} +9 -9
- package/dist/tsup/{chunk-FGFT4FVX.cjs.map → chunk-6P6RA47N.cjs.map} +1 -1
- package/dist/tsup/chunk-7OUKNSTU.js +1043 -0
- package/dist/tsup/chunk-7OUKNSTU.js.map +1 -0
- package/dist/tsup/{chunk-LZIBTLEY.cjs → chunk-DIAYNQTE.cjs} +13 -25
- package/dist/tsup/chunk-DIAYNQTE.cjs.map +1 -0
- package/dist/tsup/{chunk-YW6Y6VNE.js → chunk-G75SVQON.js} +4 -4
- package/dist/tsup/{chunk-PHSQJ6QI.cjs → chunk-KG3C7MKR.cjs} +3 -3
- package/dist/tsup/{chunk-PHSQJ6QI.cjs.map → chunk-KG3C7MKR.cjs.map} +1 -1
- package/dist/tsup/chunk-KUPQZYUQ.cjs +15 -0
- package/dist/tsup/chunk-KUPQZYUQ.cjs.map +1 -0
- package/dist/tsup/{chunk-5YTI25C3.cjs → chunk-MRRT2CZD.cjs} +7 -7
- package/dist/tsup/{chunk-5YTI25C3.cjs.map → chunk-MRRT2CZD.cjs.map} +1 -1
- package/dist/tsup/chunk-NTCUGYSD.cjs +1043 -0
- package/dist/tsup/chunk-NTCUGYSD.cjs.map +1 -0
- package/dist/tsup/{chunk-CFFKMUYH.js → chunk-RGQR2J7S.js} +2 -2
- package/dist/tsup/{chunk-CFFKMUYH.js.map → chunk-RGQR2J7S.js.map} +1 -1
- package/dist/tsup/chunk-TCUI5JFE.cjs +232 -0
- package/dist/tsup/chunk-TCUI5JFE.cjs.map +1 -0
- package/dist/tsup/chunk-TWGATZ3X.cjs +3676 -0
- package/dist/tsup/chunk-TWGATZ3X.cjs.map +1 -0
- package/dist/tsup/chunk-UFWAK3X2.cjs +3796 -0
- package/dist/tsup/chunk-UFWAK3X2.cjs.map +1 -0
- package/dist/tsup/{chunk-D7NWUCRK.cjs → chunk-UTI5NCES.cjs} +6 -6
- package/dist/tsup/{chunk-D7NWUCRK.cjs.map → chunk-UTI5NCES.cjs.map} +1 -1
- package/dist/tsup/{chunk-PG3K2LI7.js → chunk-VCEHU56K.js} +2 -2
- package/dist/tsup/{chunk-I5VTWPHW.js → chunk-VPV4MWXR.js} +3 -3
- package/dist/tsup/chunk-W6LN7AF5.js +3676 -0
- package/dist/tsup/chunk-W6LN7AF5.js.map +1 -0
- package/dist/tsup/{chunk-WNGOBAA7.js → chunk-WC2PSJWN.js} +2 -2
- package/dist/tsup/{chunk-CKA54YQN.js → chunk-ZYLTS2EM.js} +3 -15
- package/dist/tsup/chunk-ZYLTS2EM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- 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/{connection-BvE-Oq7t.d.ts → connection-BLemxi4f.d.ts} +1 -1
- package/dist/tsup/{connection-DTzmWwU5.d.cts → connection-CpDIydXf.d.cts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +5 -5
- package/dist/tsup/driver-helpers/mod.d.cts +2 -2
- package/dist/tsup/driver-helpers/mod.d.ts +2 -2
- package/dist/tsup/driver-helpers/mod.js +4 -4
- package/dist/tsup/driver-test-suite/mod.cjs +66 -58
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +1 -1
- package/dist/tsup/driver-test-suite/mod.d.ts +1 -1
- package/dist/tsup/driver-test-suite/mod.js +24 -16
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +7 -5
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.js +9 -7
- package/dist/tsup/mod.cjs +11 -8
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +52 -7
- package/dist/tsup/mod.d.ts +52 -7
- package/dist/tsup/mod.js +17 -14
- package/dist/tsup/test/mod.cjs +11 -9
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +10 -8
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/package.json +1 -1
- package/src/actor/mod.ts +5 -3
- package/src/actor/router-endpoints.ts +5 -32
- package/src/actor/router.ts +9 -8
- package/src/client/actor-conn.ts +9 -8
- package/src/client/actor-handle.ts +0 -1
- package/src/client/client.ts +1 -1
- package/src/client/raw-utils.ts +1 -1
- package/src/client/utils.ts +1 -1
- package/src/common/actor-router-consts.ts +38 -0
- package/src/driver-helpers/mod.ts +1 -1
- package/src/driver-test-suite/test-inline-client-driver.ts +4 -4
- package/src/driver-test-suite/utils.ts +7 -2
- package/src/drivers/engine/actor-driver.ts +18 -17
- package/src/manager/driver.ts +1 -1
- package/src/manager/protocol/query.ts +1 -1
- package/src/registry/mod.ts +7 -2
- package/src/registry/serve.ts +8 -3
- package/src/remote-manager-driver/actor-websocket-client.ts +2 -2
- package/src/remote-manager-driver/mod.ts +2 -5
- package/dist/tsup/chunk-2MD57QF4.js +0 -1794
- package/dist/tsup/chunk-2MD57QF4.js.map +0 -1
- package/dist/tsup/chunk-B2QGJGZQ.js +0 -338
- package/dist/tsup/chunk-B2QGJGZQ.js.map +0 -1
- package/dist/tsup/chunk-CKA54YQN.js.map +0 -1
- package/dist/tsup/chunk-IRMBWX36.cjs +0 -1794
- package/dist/tsup/chunk-IRMBWX36.cjs.map +0 -1
- package/dist/tsup/chunk-L7QRXNWP.js.map +0 -1
- package/dist/tsup/chunk-LZIBTLEY.cjs.map +0 -1
- package/dist/tsup/chunk-MRZS2J4X.cjs +0 -6562
- package/dist/tsup/chunk-MRZS2J4X.cjs.map +0 -1
- package/dist/tsup/chunk-RM2SVURR.cjs +0 -338
- package/dist/tsup/chunk-RM2SVURR.cjs.map +0 -1
- package/dist/tsup/router-endpoints-CctffZNL.d.cts +0 -65
- package/dist/tsup/router-endpoints-DFm1BglJ.d.ts +0 -65
- /package/dist/tsup/{chunk-YW6Y6VNE.js.map → chunk-G75SVQON.js.map} +0 -0
- /package/dist/tsup/{chunk-PG3K2LI7.js.map → chunk-VCEHU56K.js.map} +0 -0
- /package/dist/tsup/{chunk-I5VTWPHW.js.map → chunk-VPV4MWXR.js.map} +0 -0
- /package/dist/tsup/{chunk-WNGOBAA7.js.map → chunk-WC2PSJWN.js.map} +0 -0
package/src/client/raw-utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
|
-
import { PATH_RAW_WEBSOCKET_PREFIX } from "@/actor
|
|
2
|
+
import { PATH_RAW_WEBSOCKET_PREFIX } from "@/common/actor-router-consts";
|
|
3
3
|
import { deconstructError } from "@/common/utils";
|
|
4
4
|
import { HEADER_CONN_PARAMS, type ManagerDriver } from "@/driver-helpers/mod";
|
|
5
5
|
import type { ActorQuery } from "@/manager/protocol/query";
|
package/src/client/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as cbor from "cbor-x";
|
|
2
2
|
import invariant from "invariant";
|
|
3
|
+
import type { Encoding } from "@/actor/protocol/serde";
|
|
3
4
|
import { assertUnreachable } from "@/common/utils";
|
|
4
5
|
import type { VersionedDataHandler } from "@/common/versioned-data";
|
|
5
|
-
import type { Encoding } from "@/mod";
|
|
6
6
|
import type { HttpResponseError } from "@/schemas/client-protocol/mod";
|
|
7
7
|
import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/schemas/client-protocol/versioned";
|
|
8
8
|
import {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// NOTE: This is in a separate file from the router since it needs to be shared between the client & the server. If this was in the router file, the client would end up importing the *entire* actor router and tree shaking would not work.
|
|
2
|
+
|
|
3
|
+
// MARK: Paths
|
|
4
|
+
export const PATH_CONNECT_WEBSOCKET = "/connect/websocket";
|
|
5
|
+
export const PATH_RAW_WEBSOCKET_PREFIX = "/raw/websocket/";
|
|
6
|
+
|
|
7
|
+
// MARK: Headers
|
|
8
|
+
export const HEADER_ACTOR_QUERY = "X-RivetKit-Query";
|
|
9
|
+
|
|
10
|
+
export const HEADER_ENCODING = "X-RivetKit-Encoding";
|
|
11
|
+
|
|
12
|
+
// IMPORTANT: Params must be in headers or in an E2EE part of the request (i.e. NOT the URL or query string) in order to ensure that tokens can be securely passed in params.
|
|
13
|
+
export const HEADER_CONN_PARAMS = "X-RivetKit-Conn-Params";
|
|
14
|
+
|
|
15
|
+
// Internal header
|
|
16
|
+
export const HEADER_AUTH_DATA = "X-RivetKit-Auth-Data";
|
|
17
|
+
|
|
18
|
+
export const HEADER_ACTOR_ID = "X-RivetKit-Actor";
|
|
19
|
+
|
|
20
|
+
export const HEADER_CONN_ID = "X-RivetKit-Conn";
|
|
21
|
+
|
|
22
|
+
export const HEADER_CONN_TOKEN = "X-RivetKit-Conn-Token";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Headers that publics can send from public clients.
|
|
26
|
+
*
|
|
27
|
+
* Used for CORS.
|
|
28
|
+
**/
|
|
29
|
+
export const ALLOWED_PUBLIC_HEADERS = [
|
|
30
|
+
"Content-Type",
|
|
31
|
+
"User-Agent",
|
|
32
|
+
HEADER_ACTOR_QUERY,
|
|
33
|
+
HEADER_ENCODING,
|
|
34
|
+
HEADER_CONN_PARAMS,
|
|
35
|
+
HEADER_ACTOR_ID,
|
|
36
|
+
HEADER_CONN_ID,
|
|
37
|
+
HEADER_CONN_TOKEN,
|
|
38
|
+
];
|
|
@@ -3,14 +3,14 @@ import type { Context as HonoContext } from "hono";
|
|
|
3
3
|
import invariant from "invariant";
|
|
4
4
|
import type { WebSocket } from "ws";
|
|
5
5
|
import type { Encoding } from "@/actor/protocol/serde";
|
|
6
|
+
import { assertUnreachable } from "@/actor/utils";
|
|
7
|
+
import { ActorError as ClientActorError } from "@/client/errors";
|
|
8
|
+
import type { Transport } from "@/client/mod";
|
|
6
9
|
import {
|
|
7
10
|
HEADER_ACTOR_QUERY,
|
|
8
11
|
HEADER_CONN_PARAMS,
|
|
9
12
|
HEADER_ENCODING,
|
|
10
|
-
} from "@/actor
|
|
11
|
-
import { assertUnreachable } from "@/actor/utils";
|
|
12
|
-
import { ActorError as ClientActorError } from "@/client/errors";
|
|
13
|
-
import type { Transport } from "@/client/mod";
|
|
13
|
+
} from "@/common/actor-router-consts";
|
|
14
14
|
import type { UniversalEventSource } from "@/common/eventsource-interface";
|
|
15
15
|
import type { DeconstructedError } from "@/common/utils";
|
|
16
16
|
import { importWebSocket } from "@/common/websocket";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import invariant from "invariant";
|
|
2
2
|
import { type TestContext, vi } from "vitest";
|
|
3
3
|
import { assertUnreachable } from "@/actor/utils";
|
|
4
4
|
import { type Client, createClient } from "@/client/mod";
|
|
5
|
+
import { RunConfigSchema } from "@/driver-helpers/mod";
|
|
5
6
|
import { createClientWithDriver } from "@/mod";
|
|
6
7
|
import type { registry } from "../../fixtures/driver-test-suite/registry";
|
|
7
8
|
import type { DriverTestConfig } from "./mod";
|
|
@@ -43,7 +44,11 @@ export async function setupDriverTest(
|
|
|
43
44
|
"bare",
|
|
44
45
|
driverTestConfig.transport ?? "websocket",
|
|
45
46
|
);
|
|
46
|
-
|
|
47
|
+
invariant(driverTestConfig.transport, "missing transport");
|
|
48
|
+
const runConfig = RunConfigSchema.parse({
|
|
49
|
+
transport: driverTestConfig.transport,
|
|
50
|
+
});
|
|
51
|
+
client = createClientWithDriver(managerDriver, runConfig);
|
|
47
52
|
} else {
|
|
48
53
|
assertUnreachable(driverTestConfig.clientType);
|
|
49
54
|
}
|
|
@@ -6,10 +6,26 @@ import { Runner } from "@rivetkit/engine-runner";
|
|
|
6
6
|
import * as cbor from "cbor-x";
|
|
7
7
|
import { WSContext } from "hono/ws";
|
|
8
8
|
import invariant from "invariant";
|
|
9
|
+
import { lookupInRegistry } from "@/actor/definition";
|
|
10
|
+
import {
|
|
11
|
+
createGenericConnDrivers,
|
|
12
|
+
GenericConnGlobalState,
|
|
13
|
+
} from "@/actor/generic-conn-driver";
|
|
9
14
|
import { deserializeActorKey } from "@/actor/keys";
|
|
10
15
|
import { EncodingSchema } from "@/actor/protocol/serde";
|
|
16
|
+
import { type ActorRouter, createActorRouter } from "@/actor/router";
|
|
17
|
+
import {
|
|
18
|
+
handleRawWebSocketHandler,
|
|
19
|
+
handleWebSocketConnect,
|
|
20
|
+
} from "@/actor/router-endpoints";
|
|
11
21
|
import type { Client } from "@/client/client";
|
|
22
|
+
import {
|
|
23
|
+
PATH_CONNECT_WEBSOCKET,
|
|
24
|
+
PATH_RAW_WEBSOCKET_PREFIX,
|
|
25
|
+
} from "@/common/actor-router-consts";
|
|
26
|
+
import type { UpgradeWebSocketArgs } from "@/common/inline-websocket-adapter2";
|
|
12
27
|
import { getLogger } from "@/common/log";
|
|
28
|
+
import type { UniversalWebSocket } from "@/common/websocket-interface";
|
|
13
29
|
import {
|
|
14
30
|
type ActorDriver,
|
|
15
31
|
type AnyActorInstance,
|
|
@@ -19,23 +35,8 @@ import {
|
|
|
19
35
|
type ManagerDriver,
|
|
20
36
|
serializeEmptyPersistData,
|
|
21
37
|
} from "@/driver-helpers/mod";
|
|
22
|
-
import type {
|
|
23
|
-
|
|
24
|
-
RegistryConfig,
|
|
25
|
-
RunConfig,
|
|
26
|
-
UniversalWebSocket,
|
|
27
|
-
UpgradeWebSocketArgs,
|
|
28
|
-
} from "@/mod";
|
|
29
|
-
import {
|
|
30
|
-
createActorRouter,
|
|
31
|
-
createGenericConnDrivers,
|
|
32
|
-
GenericConnGlobalState,
|
|
33
|
-
handleRawWebSocketHandler,
|
|
34
|
-
handleWebSocketConnect,
|
|
35
|
-
lookupInRegistry,
|
|
36
|
-
PATH_CONNECT_WEBSOCKET,
|
|
37
|
-
PATH_RAW_WEBSOCKET_PREFIX,
|
|
38
|
-
} from "@/mod";
|
|
38
|
+
import type { RegistryConfig } from "@/registry/config";
|
|
39
|
+
import type { RunConfig } from "@/registry/run-config";
|
|
39
40
|
import type { Config } from "./config";
|
|
40
41
|
import { KEYS } from "./kv";
|
|
41
42
|
import { logger } from "./log";
|
package/src/manager/driver.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Env, Hono, Context as HonoContext } from "hono";
|
|
2
2
|
import type { ActorKey, Encoding, UniversalWebSocket } from "@/actor/mod";
|
|
3
3
|
import type { ManagerInspector } from "@/inspector/manager";
|
|
4
|
-
import type { RunConfig } from "@/mod";
|
|
5
4
|
import type { RegistryConfig } from "@/registry/config";
|
|
5
|
+
import type { RunConfig } from "@/registry/run-config";
|
|
6
6
|
|
|
7
7
|
export type ManagerDriverBuilder = (
|
|
8
8
|
registryConfig: RegistryConfig,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
HEADER_CONN_PARAMS,
|
|
8
8
|
HEADER_CONN_TOKEN,
|
|
9
9
|
HEADER_ENCODING,
|
|
10
|
-
} from "@/actor
|
|
10
|
+
} from "@/common/actor-router-consts";
|
|
11
11
|
|
|
12
12
|
// Maximum size of a key component in bytes
|
|
13
13
|
// Set to 128 bytes to allow for separators and escape characters in the full key
|
package/src/registry/mod.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Hono } from "hono";
|
|
2
1
|
import { type Client, createClientWithDriver } from "@/client/client";
|
|
3
2
|
import { configureBaseLogger, configureDefaultLogger } from "@/common/log";
|
|
4
3
|
import { chooseDefaultDriver } from "@/drivers/default";
|
|
@@ -149,5 +148,11 @@ export function setup<A extends RegistryActors>(
|
|
|
149
148
|
return new Registry(config);
|
|
150
149
|
}
|
|
151
150
|
|
|
152
|
-
export type {
|
|
151
|
+
export type {
|
|
152
|
+
RegistryConfig,
|
|
153
|
+
RegistryActors,
|
|
154
|
+
RunConfig,
|
|
155
|
+
RunConfigInput,
|
|
156
|
+
DriverConfig,
|
|
157
|
+
};
|
|
153
158
|
export { RegistryConfigSchema };
|
package/src/registry/serve.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import { getEnvUniversal } from "@/utils";
|
|
3
2
|
import { logger } from "./log";
|
|
4
3
|
|
|
5
4
|
export async function crossPlatformServe(
|
|
@@ -11,7 +10,10 @@ export async function crossPlatformServe(
|
|
|
11
10
|
// Import @hono/node-server
|
|
12
11
|
let serve: any;
|
|
13
12
|
try {
|
|
14
|
-
const dep = await import(
|
|
13
|
+
const dep = await import(
|
|
14
|
+
/* webpackIgnore: true */
|
|
15
|
+
"@hono/node-server"
|
|
16
|
+
);
|
|
15
17
|
serve = dep.serve;
|
|
16
18
|
} catch (err) {
|
|
17
19
|
logger().error(
|
|
@@ -27,7 +29,10 @@ export async function crossPlatformServe(
|
|
|
27
29
|
// Import @hono/node-ws
|
|
28
30
|
let createNodeWebSocket: any;
|
|
29
31
|
try {
|
|
30
|
-
const dep = await import(
|
|
32
|
+
const dep = await import(
|
|
33
|
+
/* webpackIgnore: true */
|
|
34
|
+
"@hono/node-ws"
|
|
35
|
+
);
|
|
31
36
|
createNodeWebSocket = dep.createNodeWebSocket;
|
|
32
37
|
} catch (err) {
|
|
33
38
|
logger().error(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { ClientConfig } from "@/client/config";
|
|
1
2
|
import {
|
|
2
3
|
HEADER_AUTH_DATA,
|
|
3
4
|
HEADER_CONN_PARAMS,
|
|
4
5
|
HEADER_ENCODING,
|
|
5
|
-
} from "@/actor
|
|
6
|
-
import type { ClientConfig } from "@/client/config";
|
|
6
|
+
} from "@/common/actor-router-consts";
|
|
7
7
|
import { importWebSocket } from "@/common/websocket";
|
|
8
8
|
import type { Encoding, UniversalWebSocket } from "@/mod";
|
|
9
9
|
import { combineUrlPath } from "@/utils";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as cbor from "cbor-x";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Context as HonoContext } from "hono";
|
|
3
3
|
import invariant from "invariant";
|
|
4
|
-
import { ActorAlreadyExists } from "@/actor/errors";
|
|
5
4
|
import { deserializeActorKey, serializeActorKey } from "@/actor/keys";
|
|
6
5
|
import type { ClientConfig } from "@/client/client";
|
|
7
6
|
import { noopNext } from "@/common/utils";
|
|
@@ -14,9 +13,7 @@ import type {
|
|
|
14
13
|
ManagerDisplayInformation,
|
|
15
14
|
ManagerDriver,
|
|
16
15
|
} from "@/driver-helpers/mod";
|
|
17
|
-
import type {
|
|
18
|
-
import type { Encoding, RegistryConfig, UniversalWebSocket } from "@/mod";
|
|
19
|
-
import type { RunConfig } from "@/registry/run-config";
|
|
16
|
+
import type { Encoding, UniversalWebSocket } from "@/mod";
|
|
20
17
|
import { combineUrlPath } from "@/utils";
|
|
21
18
|
import { sendHttpRequestToActor } from "./actor-http-client";
|
|
22
19
|
import {
|