rivetkit 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsup/{chunk-APHV6WXU.js → chunk-346X2XU4.js} +2 -2
- package/dist/tsup/{chunk-DLPIL3VC.js → chunk-7E5K3375.js} +2 -2
- package/dist/tsup/{chunk-SOC4HWCG.cjs → chunk-CA3X5M6H.cjs} +92 -39
- package/dist/tsup/{chunk-VVCL5DXN.js.map → chunk-CA3X5M6H.cjs.map} +1 -1
- package/dist/tsup/{chunk-2MJYYF2Q.cjs → chunk-DVPXSB4B.cjs} +12 -12
- package/dist/tsup/{chunk-2MJYYF2Q.cjs.map → chunk-DVPXSB4B.cjs.map} +1 -1
- package/dist/tsup/{chunk-U2IXX6DY.cjs → chunk-GIFHYL7A.cjs} +5 -6
- package/dist/tsup/chunk-GIFHYL7A.cjs.map +1 -0
- package/dist/tsup/{chunk-KHZ2QSQ4.js → chunk-H7E2UU23.js} +32 -10
- package/dist/tsup/chunk-H7E2UU23.js.map +1 -0
- package/dist/tsup/{chunk-E63WU5PL.js → chunk-HI55LHM3.js} +5 -6
- package/dist/tsup/chunk-HI55LHM3.js.map +1 -0
- package/dist/tsup/{chunk-SDXTJDDR.cjs → chunk-I3FB346I.cjs} +58 -14
- package/dist/tsup/chunk-I3FB346I.cjs.map +1 -0
- package/dist/tsup/{chunk-WBSPHV5V.js → chunk-KGDZYQYE.js} +2 -2
- package/dist/tsup/{chunk-A44TWAS5.cjs → chunk-KH5WFDUK.cjs} +6 -6
- package/dist/tsup/{chunk-A44TWAS5.cjs.map → chunk-KH5WFDUK.cjs.map} +1 -1
- package/dist/tsup/{chunk-YR2VY4XS.js → chunk-KL4V2ULR.js} +5 -4
- package/dist/tsup/chunk-KL4V2ULR.js.map +1 -0
- package/dist/tsup/{chunk-R7OP5N25.js → chunk-MLQIYKAZ.js} +53 -9
- package/dist/tsup/chunk-MLQIYKAZ.js.map +1 -0
- package/dist/tsup/{chunk-F2YZNUPU.js → chunk-N3A5GYJU.js} +3 -3
- package/dist/tsup/{chunk-4YV6RDZL.cjs → chunk-PDFL7FBL.cjs} +698 -358
- package/dist/tsup/chunk-PDFL7FBL.cjs.map +1 -0
- package/dist/tsup/{chunk-DZZQG7VH.cjs → chunk-PPLR53PP.cjs} +3 -3
- package/dist/tsup/{chunk-DZZQG7VH.cjs.map → chunk-PPLR53PP.cjs.map} +1 -1
- package/dist/tsup/{chunk-7OMMIAWP.cjs → chunk-PSCDCEXM.cjs} +17 -12
- package/dist/tsup/chunk-PSCDCEXM.cjs.map +1 -0
- package/dist/tsup/{chunk-VVCL5DXN.js → chunk-QRFXXTLG.js} +96 -43
- package/dist/tsup/chunk-QRFXXTLG.js.map +1 -0
- package/dist/tsup/{chunk-WRSWUDFA.js → chunk-R2S45MO6.js} +14 -9
- package/dist/tsup/chunk-R2S45MO6.js.map +1 -0
- package/dist/tsup/{chunk-QGRYH6TU.cjs → chunk-SIWYIRXP.cjs} +7 -6
- package/dist/tsup/chunk-SIWYIRXP.cjs.map +1 -0
- package/dist/tsup/{chunk-FZP2IBIX.js → chunk-VJRXZPTT.js} +579 -239
- package/dist/tsup/chunk-VJRXZPTT.js.map +1 -0
- package/dist/tsup/{chunk-4PSLOAXR.cjs → chunk-VZMXAZKC.cjs} +226 -204
- package/dist/tsup/chunk-VZMXAZKC.cjs.map +1 -0
- package/dist/tsup/{chunk-DL7TPF63.cjs → chunk-YKVTF7MP.cjs} +7 -7
- package/dist/tsup/{chunk-DL7TPF63.cjs.map → chunk-YKVTF7MP.cjs.map} +1 -1
- 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/{conn-CEh3WKbA.d.cts → conn-Cc9WHuN4.d.cts} +196 -191
- package/dist/tsup/{conn-Bt8rkUzm.d.ts → conn-DfPG71FA.d.ts} +196 -191
- package/dist/tsup/driver-helpers/mod.cjs +5 -5
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +1 -1
- package/dist/tsup/driver-helpers/mod.d.ts +1 -1
- package/dist/tsup/driver-helpers/mod.js +6 -6
- package/dist/tsup/driver-test-suite/mod.cjs +116 -102
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +3 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +3 -2
- package/dist/tsup/driver-test-suite/mod.js +61 -47
- 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 +6 -6
- package/dist/tsup/inspector/mod.d.ts +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -10
- package/dist/tsup/mod.d.cts +8 -39
- package/dist/tsup/mod.d.ts +8 -39
- package/dist/tsup/mod.js +9 -9
- package/dist/tsup/test/mod.cjs +11 -11
- 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 -10
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.d.cts +2 -1
- package/dist/tsup/utils.d.ts +2 -1
- package/dist/tsup/utils.js +1 -1
- package/package.json +4 -5
- package/src/actor/driver.ts +2 -2
- package/src/actor/protocol/serde.ts +75 -3
- package/src/actor/router-endpoints.ts +6 -6
- package/src/actor/router.ts +2 -2
- package/src/client/actor-conn.ts +24 -3
- package/src/client/config.ts +18 -25
- package/src/driver-helpers/mod.ts +4 -1
- package/src/driver-test-suite/mod.ts +65 -43
- package/src/driver-test-suite/utils.ts +4 -1
- package/src/drivers/default.ts +11 -9
- package/src/drivers/engine/actor-driver.ts +40 -39
- package/src/drivers/engine/config.ts +9 -22
- package/src/drivers/engine/mod.ts +9 -8
- package/src/drivers/file-system/global-state.ts +4 -4
- package/src/engine-process/log.ts +5 -0
- package/src/engine-process/mod.ts +316 -0
- package/src/inspector/utils.ts +6 -4
- package/src/manager/driver.ts +2 -2
- package/src/manager/gateway.ts +29 -11
- package/src/manager/router-schema.ts +20 -0
- package/src/manager/router.ts +105 -23
- package/src/registry/mod.ts +145 -119
- package/src/registry/run-config.ts +116 -47
- package/src/registry/serve.ts +3 -1
- package/src/serde.ts +3 -3
- package/src/test/config.ts +2 -2
- package/src/test/mod.ts +6 -3
- package/src/utils.ts +2 -0
- package/dist/tsup/chunk-4PSLOAXR.cjs.map +0 -1
- package/dist/tsup/chunk-4YV6RDZL.cjs.map +0 -1
- package/dist/tsup/chunk-7OMMIAWP.cjs.map +0 -1
- package/dist/tsup/chunk-E63WU5PL.js.map +0 -1
- package/dist/tsup/chunk-FZP2IBIX.js.map +0 -1
- package/dist/tsup/chunk-KHZ2QSQ4.js.map +0 -1
- package/dist/tsup/chunk-QGRYH6TU.cjs.map +0 -1
- package/dist/tsup/chunk-R7OP5N25.js.map +0 -1
- package/dist/tsup/chunk-SDXTJDDR.cjs.map +0 -1
- package/dist/tsup/chunk-SOC4HWCG.cjs.map +0 -1
- package/dist/tsup/chunk-U2IXX6DY.cjs.map +0 -1
- package/dist/tsup/chunk-WRSWUDFA.js.map +0 -1
- package/dist/tsup/chunk-YR2VY4XS.js.map +0 -1
- /package/dist/tsup/{chunk-APHV6WXU.js.map → chunk-346X2XU4.js.map} +0 -0
- /package/dist/tsup/{chunk-DLPIL3VC.js.map → chunk-7E5K3375.js.map} +0 -0
- /package/dist/tsup/{chunk-WBSPHV5V.js.map → chunk-KGDZYQYE.js.map} +0 -0
- /package/dist/tsup/{chunk-F2YZNUPU.js.map → chunk-N3A5GYJU.js.map} +0 -0
|
@@ -2,10 +2,12 @@ import type { cors } from "hono/cors";
|
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import type { ActorDriverBuilder } from "@/actor/driver";
|
|
5
|
-
import { ClientConfigSchema } from "@/client/config";
|
|
6
5
|
import { LogLevelSchema } from "@/common/log";
|
|
6
|
+
import { EngingConfigSchema as EngineConfigSchema } from "@/drivers/engine/config";
|
|
7
7
|
import { InspectorConfigSchema } from "@/inspector/config";
|
|
8
8
|
import type { ManagerDriverBuilder } from "@/manager/driver";
|
|
9
|
+
import type { GetUpgradeWebSocket } from "@/utils";
|
|
10
|
+
import { getEnvUniversal } from "@/utils";
|
|
9
11
|
|
|
10
12
|
type CorsOptions = NonNullable<Parameters<typeof cors>[0]>;
|
|
11
13
|
|
|
@@ -19,49 +21,116 @@ export const DriverConfigSchema = z.object({
|
|
|
19
21
|
export type DriverConfig = z.infer<typeof DriverConfigSchema>;
|
|
20
22
|
|
|
21
23
|
/** Base config used for the actor config across all platforms. */
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
24
|
+
export const RunnerConfigSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
driver: DriverConfigSchema.optional(),
|
|
27
|
+
|
|
28
|
+
/** CORS configuration for the router. Uses Hono's CORS middleware options. */
|
|
29
|
+
cors: z.custom<CorsOptions>().optional(),
|
|
30
|
+
|
|
31
|
+
/** @experimental */
|
|
32
|
+
maxIncomingMessageSize: z.number().optional().default(65_536),
|
|
33
|
+
|
|
34
|
+
/** @experimental */
|
|
35
|
+
inspector: InspectorConfigSchema,
|
|
36
|
+
|
|
37
|
+
/** @experimental */
|
|
38
|
+
disableDefaultServer: z.boolean().optional().default(false),
|
|
39
|
+
|
|
40
|
+
/** @experimental */
|
|
41
|
+
defaultServerPort: z.number().default(6420),
|
|
42
|
+
|
|
43
|
+
/** @experimental */
|
|
44
|
+
runEngine: z
|
|
45
|
+
.boolean()
|
|
46
|
+
.optional()
|
|
47
|
+
.default(() => getEnvUniversal("RIVET_RUN_ENGINE") === "1"),
|
|
48
|
+
|
|
49
|
+
/** @experimental */
|
|
50
|
+
runEngineVersion: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.default(() => getEnvUniversal("RIVET_RUN_ENGINE_VERSION") ?? "25.7.3"),
|
|
54
|
+
|
|
55
|
+
/** @experimental */
|
|
56
|
+
overrideServerAddress: z.string().optional(),
|
|
57
|
+
|
|
58
|
+
/** @experimental */
|
|
59
|
+
disableActorDriver: z.boolean().optional().default(false),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @experimental
|
|
63
|
+
*
|
|
64
|
+
* Whether to run runners normally or have them managed
|
|
65
|
+
* serverlessly (by the Rivet Engine for example).
|
|
66
|
+
*/
|
|
67
|
+
runnerKind: z
|
|
68
|
+
.enum(["serverless", "normal"])
|
|
69
|
+
.optional()
|
|
70
|
+
.default(() =>
|
|
71
|
+
getEnvUniversal("RIVET_RUNNER_KIND") === "serverless"
|
|
72
|
+
? "serverless"
|
|
73
|
+
: "normal",
|
|
74
|
+
),
|
|
75
|
+
totalSlots: z.number().optional(),
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @experimental
|
|
79
|
+
*
|
|
80
|
+
* Base path for the router. This is used to prefix all routes.
|
|
81
|
+
* For example, if the base path is `/api`, then the route `/actors` will be
|
|
82
|
+
* available at `/api/actors`.
|
|
83
|
+
*/
|
|
84
|
+
basePath: z.string().optional().default("/"),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @experimental
|
|
88
|
+
*
|
|
89
|
+
* Disable welcome message.
|
|
90
|
+
* */
|
|
91
|
+
noWelcome: z.boolean().optional().default(false),
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @experimental
|
|
95
|
+
* */
|
|
96
|
+
logging: z
|
|
97
|
+
.object({
|
|
98
|
+
baseLogger: z.custom<Logger>().optional(),
|
|
99
|
+
level: LogLevelSchema.optional(),
|
|
100
|
+
})
|
|
101
|
+
.optional()
|
|
102
|
+
.default({}),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @experimental
|
|
106
|
+
*
|
|
107
|
+
* Automatically configure serverless runners in the engine.
|
|
108
|
+
* Can only be used when runnerKind is "serverless".
|
|
109
|
+
* If true, uses default configuration. Can also provide custom configuration.
|
|
110
|
+
*/
|
|
111
|
+
autoConfigureServerless: z
|
|
112
|
+
.union([
|
|
113
|
+
z.boolean(),
|
|
114
|
+
z.object({
|
|
115
|
+
url: z.string().optional(),
|
|
116
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
117
|
+
maxRunners: z.number().optional(),
|
|
118
|
+
minRunners: z.number().optional(),
|
|
119
|
+
requestLifespan: z.number().optional(),
|
|
120
|
+
runnersMargin: z.number().optional(),
|
|
121
|
+
slotsPerRunner: z.number().optional(),
|
|
122
|
+
}),
|
|
123
|
+
])
|
|
124
|
+
.optional(),
|
|
125
|
+
|
|
126
|
+
// This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
127
|
+
// fly. This is required since the dependencies that upgradeWebSocket
|
|
128
|
+
// (specifically Node.js) can sometimes only be specified after the router is
|
|
129
|
+
// created or must be imported async using `await import(...)`
|
|
130
|
+
getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
|
|
131
|
+
})
|
|
132
|
+
.merge(EngineConfigSchema.removeDefault())
|
|
133
|
+
.default({});
|
|
134
|
+
|
|
135
|
+
export type RunnerConfig = z.infer<typeof RunnerConfigSchema>;
|
|
136
|
+
export type RunnerConfigInput = z.input<typeof RunnerConfigSchema>;
|
package/src/registry/serve.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { logger } from "./log";
|
|
3
|
+
import type { RunnerConfig } from "./run-config";
|
|
3
4
|
|
|
4
5
|
export async function crossPlatformServe(
|
|
6
|
+
runConfig: RunnerConfig,
|
|
5
7
|
rivetKitRouter: Hono<any>,
|
|
6
8
|
userRouter: Hono | undefined,
|
|
7
9
|
) {
|
|
@@ -47,7 +49,7 @@ export async function crossPlatformServe(
|
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
// Start server
|
|
50
|
-
const port =
|
|
52
|
+
const port = runConfig.defaultServerPort;
|
|
51
53
|
const server = serve({ fetch: app.fetch, port }, () =>
|
|
52
54
|
logger().info({ msg: "server listening", port }),
|
|
53
55
|
);
|
package/src/serde.ts
CHANGED
|
@@ -3,7 +3,7 @@ import invariant from "invariant";
|
|
|
3
3
|
import { assertUnreachable } from "@/common/utils";
|
|
4
4
|
import type { VersionedDataHandler } from "@/common/versioned-data";
|
|
5
5
|
import type { Encoding } from "@/mod";
|
|
6
|
-
import { jsonStringifyCompat } from "./actor/protocol/serde";
|
|
6
|
+
import { jsonParseCompat, jsonStringifyCompat } from "./actor/protocol/serde";
|
|
7
7
|
|
|
8
8
|
export function uint8ArrayToBase64(uint8Array: Uint8Array): string {
|
|
9
9
|
// Check if Buffer is available (Node.js)
|
|
@@ -78,11 +78,11 @@ export function deserializeWithEncoding<T>(
|
|
|
78
78
|
): T {
|
|
79
79
|
if (encoding === "json") {
|
|
80
80
|
if (typeof buffer === "string") {
|
|
81
|
-
return
|
|
81
|
+
return jsonParseCompat(buffer);
|
|
82
82
|
} else {
|
|
83
83
|
const decoder = new TextDecoder("utf-8");
|
|
84
84
|
const jsonString = decoder.decode(buffer);
|
|
85
|
-
return
|
|
85
|
+
return jsonParseCompat(jsonString);
|
|
86
86
|
}
|
|
87
87
|
} else if (encoding === "cbor") {
|
|
88
88
|
invariant(
|
package/src/test/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { RunnerConfigSchema } from "@/registry/run-config";
|
|
3
3
|
|
|
4
|
-
export const ConfigSchema =
|
|
4
|
+
export const ConfigSchema = RunnerConfigSchema.removeDefault()
|
|
5
5
|
.extend({
|
|
6
6
|
hostname: z
|
|
7
7
|
.string()
|
package/src/test/mod.ts
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
getInspectorUrl,
|
|
11
11
|
} from "@/inspector/utils";
|
|
12
12
|
import { createManagerRouter } from "@/manager/router";
|
|
13
|
+
import { createClientWithDriver } from "@/mod";
|
|
13
14
|
import type { Registry } from "@/registry/mod";
|
|
14
|
-
import {
|
|
15
|
+
import { RunnerConfigSchema } from "@/registry/run-config";
|
|
15
16
|
import { ConfigSchema, type InputConfig } from "./config";
|
|
16
17
|
import { logger } from "./log";
|
|
17
18
|
|
|
@@ -27,15 +28,17 @@ function serve(registry: Registry<any>, inputConfig?: InputConfig): ServerType {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Create router
|
|
30
|
-
const runConfig =
|
|
31
|
+
const runConfig = RunnerConfigSchema.parse(inputConfig);
|
|
31
32
|
const driver = inputConfig.driver ?? createFileSystemOrMemoryDriver(false);
|
|
32
33
|
const managerDriver = driver.manager(registry.config, config);
|
|
34
|
+
const client = createClientWithDriver(managerDriver);
|
|
33
35
|
configureInspectorAccessToken(config, managerDriver);
|
|
34
36
|
const { router } = createManagerRouter(
|
|
35
37
|
registry.config,
|
|
36
38
|
runConfig,
|
|
37
39
|
managerDriver,
|
|
38
|
-
|
|
40
|
+
driver,
|
|
41
|
+
client,
|
|
39
42
|
);
|
|
40
43
|
|
|
41
44
|
// Inject WebSocket
|
package/src/utils.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type UpgradeWebSocket = (
|
|
|
31
31
|
createEvents: (c: HonoContext) => any,
|
|
32
32
|
) => HonoHandler;
|
|
33
33
|
|
|
34
|
+
export type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
35
|
+
|
|
34
36
|
export function getEnvUniversal(key: string): string | undefined {
|
|
35
37
|
if (typeof Deno !== "undefined") {
|
|
36
38
|
return Deno.env.get(key);
|