rivetkit 2.0.15 → 2.0.17
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-TD5RNAZU.js → chunk-2RN5RI6B.js} +2 -2
- package/dist/tsup/{chunk-NRYLXYDB.cjs → chunk-3IPDYE3Z.cjs} +6 -6
- package/dist/tsup/{chunk-NRYLXYDB.cjs.map → chunk-3IPDYE3Z.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZT77CQXR.js → chunk-4JQCKZV4.js} +6 -6
- package/dist/tsup/{chunk-WMEMX7ND.cjs → chunk-6WNRLSTJ.cjs} +7 -7
- package/dist/tsup/{chunk-WMEMX7ND.cjs.map → chunk-6WNRLSTJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-RQRDBVMA.cjs → chunk-AA74JNFV.cjs} +3 -3
- package/dist/tsup/{chunk-RQRDBVMA.cjs.map → chunk-AA74JNFV.cjs.map} +1 -1
- package/dist/tsup/{chunk-PBAZ6FDY.cjs → chunk-AWOVDKZM.cjs} +3 -3
- package/dist/tsup/{chunk-PBAZ6FDY.cjs.map → chunk-AWOVDKZM.cjs.map} +1 -1
- package/dist/tsup/{chunk-CJJW2HVJ.cjs → chunk-BYQ67SON.cjs} +12 -12
- package/dist/tsup/{chunk-CJJW2HVJ.cjs.map → chunk-BYQ67SON.cjs.map} +1 -1
- package/dist/tsup/{chunk-AMLE3HUH.js → chunk-DMC745I6.js} +2 -2
- package/dist/tsup/{chunk-7MDKUHE4.js → chunk-E73XVU6Z.js} +12 -10
- package/dist/tsup/chunk-E73XVU6Z.js.map +1 -0
- package/dist/tsup/{chunk-T7MZMA5D.cjs → chunk-FB752WM4.cjs} +14 -14
- package/dist/tsup/{chunk-T7MZMA5D.cjs.map → chunk-FB752WM4.cjs.map} +1 -1
- package/dist/tsup/{chunk-UBBJE54L.js → chunk-FBCB4BRK.js} +3 -3
- package/dist/tsup/{chunk-UBBJE54L.js.map → chunk-FBCB4BRK.js.map} +1 -1
- package/dist/tsup/{chunk-IESTGXF3.js → chunk-HEAZ6K5B.js} +3 -3
- package/dist/tsup/{chunk-XR6ZIZEK.cjs → chunk-JYALFDJ7.cjs} +26 -26
- package/dist/tsup/{chunk-XR6ZIZEK.cjs.map → chunk-JYALFDJ7.cjs.map} +1 -1
- package/dist/tsup/{chunk-HMGH3AWC.js → chunk-LM7MHACC.js} +5 -5
- package/dist/tsup/{chunk-HMGH3AWC.js.map → chunk-LM7MHACC.js.map} +1 -1
- package/dist/tsup/{chunk-YAUIBXG3.js → chunk-PKBAWJIC.js} +3 -3
- package/dist/tsup/{chunk-U7ZDMHVJ.js → chunk-PSWOD5F4.js} +7 -7
- package/dist/tsup/{chunk-BTEDNZSI.js → chunk-TR672K46.js} +2 -2
- package/dist/tsup/{chunk-C66P3AU6.cjs → chunk-TZ3ITYDP.cjs} +8 -8
- package/dist/tsup/{chunk-C66P3AU6.cjs.map → chunk-TZ3ITYDP.cjs.map} +1 -1
- package/dist/tsup/{chunk-FUF4YPTZ.js → chunk-V7T3WTZW.js} +2 -2
- package/dist/tsup/{chunk-QLIJ6I3M.cjs → chunk-X2X4UPYC.cjs} +3 -3
- package/dist/tsup/{chunk-QLIJ6I3M.cjs.map → chunk-X2X4UPYC.cjs.map} +1 -1
- package/dist/tsup/{chunk-BPQTS4VW.cjs → chunk-ZEDMEV6P.cjs} +175 -173
- package/dist/tsup/chunk-ZEDMEV6P.cjs.map +1 -0
- package/dist/tsup/{chunk-UWGWDHYS.cjs → chunk-ZFJPNOIG.cjs} +208 -208
- package/dist/tsup/{chunk-UWGWDHYS.cjs.map → chunk-ZFJPNOIG.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +9 -9
- 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/driver-helpers/mod.cjs +5 -5
- package/dist/tsup/driver-helpers/mod.js +4 -4
- package/dist/tsup/driver-test-suite/mod.cjs +71 -71
- package/dist/tsup/driver-test-suite/mod.js +11 -11
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -10
- package/dist/tsup/mod.js +9 -9
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/package.json +2 -2
- package/src/common/router.ts +4 -1
- package/src/registry/mod.ts +1 -3
- package/src/registry/run-config.ts +1 -1
- package/dist/tsup/chunk-7MDKUHE4.js.map +0 -1
- package/dist/tsup/chunk-BPQTS4VW.cjs.map +0 -1
- /package/dist/tsup/{chunk-TD5RNAZU.js.map → chunk-2RN5RI6B.js.map} +0 -0
- /package/dist/tsup/{chunk-ZT77CQXR.js.map → chunk-4JQCKZV4.js.map} +0 -0
- /package/dist/tsup/{chunk-AMLE3HUH.js.map → chunk-DMC745I6.js.map} +0 -0
- /package/dist/tsup/{chunk-IESTGXF3.js.map → chunk-HEAZ6K5B.js.map} +0 -0
- /package/dist/tsup/{chunk-YAUIBXG3.js.map → chunk-PKBAWJIC.js.map} +0 -0
- /package/dist/tsup/{chunk-U7ZDMHVJ.js.map → chunk-PSWOD5F4.js.map} +0 -0
- /package/dist/tsup/{chunk-BTEDNZSI.js.map → chunk-TR672K46.js.map} +0 -0
- /package/dist/tsup/{chunk-FUF4YPTZ.js.map → chunk-V7T3WTZW.js.map} +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkZEDMEV6Pcjs = require('./chunk-ZEDMEV6P.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkX2X4UPYCcjs = require('./chunk-X2X4UPYC.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkZFJPNOIGcjs = require('./chunk-ZFJPNOIG.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkJYALFDJ7cjs = require('./chunk-JYALFDJ7.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunk6WNRLSTJcjs = require('./chunk-6WNRLSTJ.cjs');
|
|
18
18
|
|
|
19
19
|
// src/test/mod.ts
|
|
20
20
|
var _net = require('net');
|
|
@@ -24,14 +24,14 @@ var _vitest = require('vitest');
|
|
|
24
24
|
|
|
25
25
|
// src/test/config.ts
|
|
26
26
|
var _zod = require('zod');
|
|
27
|
-
var ConfigSchema =
|
|
27
|
+
var ConfigSchema = _chunkJYALFDJ7cjs.RunnerConfigSchema.removeDefault().extend({
|
|
28
28
|
hostname: _zod.z.string().optional().default(_nullishCoalesce(process.env.HOSTNAME, () => ( "127.0.0.1"))),
|
|
29
29
|
port: _zod.z.number().optional().default(Number.parseInt(_nullishCoalesce(process.env.PORT, () => ( "8080"))))
|
|
30
30
|
}).default({});
|
|
31
31
|
|
|
32
32
|
// src/test/log.ts
|
|
33
33
|
function logger() {
|
|
34
|
-
return
|
|
34
|
+
return _chunk6WNRLSTJcjs.getLogger.call(void 0, "test");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// src/test/mod.ts
|
|
@@ -42,15 +42,15 @@ function serve(registry, inputConfig) {
|
|
|
42
42
|
if (!config.getUpgradeWebSocket) {
|
|
43
43
|
config.getUpgradeWebSocket = () => upgradeWebSocket;
|
|
44
44
|
}
|
|
45
|
-
const runConfig =
|
|
46
|
-
const driver = _nullishCoalesce(inputConfig.driver, () => (
|
|
45
|
+
const runConfig = _chunkJYALFDJ7cjs.RunnerConfigSchema.parse(inputConfig);
|
|
46
|
+
const driver = _nullishCoalesce(inputConfig.driver, () => ( _chunkZEDMEV6Pcjs.createFileSystemOrMemoryDriver.call(void 0, false)));
|
|
47
47
|
const managerDriver = driver.manager(registry.config, config);
|
|
48
|
-
const client =
|
|
48
|
+
const client = _chunkZFJPNOIGcjs.createClientWithDriver.call(void 0,
|
|
49
49
|
managerDriver,
|
|
50
|
-
|
|
50
|
+
_chunkJYALFDJ7cjs.ClientConfigSchema.parse({})
|
|
51
51
|
);
|
|
52
|
-
|
|
53
|
-
const { router } =
|
|
52
|
+
_chunkX2X4UPYCcjs.configureInspectorAccessToken.call(void 0, config, managerDriver);
|
|
53
|
+
const { router } = _chunkZEDMEV6Pcjs.createManagerRouter.call(void 0,
|
|
54
54
|
registry.config,
|
|
55
55
|
runConfig,
|
|
56
56
|
managerDriver,
|
|
@@ -127,4 +127,4 @@ async function getPort() {
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
exports.setupTest = setupTest; exports.getPort = getPort;
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-FB752WM4.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-FB752WM4.cjs","../../src/test/mod.ts","../../src/test/config.ts","../../src/test/log.ts"],"names":["server"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;AClBA,0BAA6B;AAC7B,+CAAoD;AACpD,uCAAoC;AACpC,gCAAqC;ADoBrC;AACA;AExBA,0BAAkB;AAGX,IAAM,aAAA,EAAe,oCAAA,CAAmB,aAAA,CAAc,CAAA,CAC3D,M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AAO,MAAA,CAAO,IAAI,CAAA;AAAA,MACnB,CAAC,CAAA;AAGD,MAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAA,GAAY;AACpC,QAAA,MAAA,CAAO,KAAA,CAAM,CAAA,EAAA,GAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,MAC7B,CAAC,CAAA;AAED,MAAA,OAAO,IAAA;AAAA,IACR,EAAA,MAAA,CAAS,GAAA,EAAK;AAEb,MAAA,WAAA,EAAA;AACA,MAAA,GAAA,CAAI,YAAA,GAAe,CAAA,EAAG;AACrB,QAAA,KAAA;AAAA,MACD;AACA,MAAA,KAAA,EAAO,aAAA,CAAc,CAAA;AAAA,IACtB;AAAA,EACD;AAEA,EAAA,MAAM,IAAI,KAAA,CAAM,0DAA0D,CAAA;AAC3E;ADxCA;AACA;AACE;AACA;AACF,yDAAC","file":"/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-FB752WM4.cjs","sourcesContent":[null,"import { createServer } from \"node:net\";\nimport { serve as honoServe, type ServerType } from \"@hono/node-server\";\nimport { createNodeWebSocket } from \"@hono/node-ws\";\nimport { type TestContext, vi } from \"vitest\";\nimport { ClientConfigSchema } from \"@/client/config\";\nimport { type Client, createClient } from \"@/client/mod\";\nimport { chooseDefaultDriver } from \"@/drivers/default\";\nimport { createFileSystemOrMemoryDriver } from \"@/drivers/file-system/mod\";\nimport {\n\tconfigureInspectorAccessToken,\n\tgetInspectorUrl,\n} from \"@/inspector/utils\";\nimport { createManagerRouter } from \"@/manager/router\";\nimport { createClientWithDriver } from \"@/mod\";\nimport type { Registry } from \"@/registry/mod\";\nimport { RunnerConfigSchema } from \"@/registry/run-config\";\nimport { ConfigSchema, type InputConfig } from \"./config\";\nimport { logger } from \"./log\";\n\nfunction serve(registry: Registry<any>, inputConfig?: InputConfig): ServerType {\n\t// Configure default configuration\n\tinputConfig ??= {};\n\n\tconst config = ConfigSchema.parse(inputConfig);\n\n\tlet upgradeWebSocket: any;\n\tif (!config.getUpgradeWebSocket) {\n\t\tconfig.getUpgradeWebSocket = () => upgradeWebSocket!;\n\t}\n\n\t// Create router\n\tconst runConfig = RunnerConfigSchema.parse(inputConfig);\n\tconst driver = inputConfig.driver ?? createFileSystemOrMemoryDriver(false);\n\tconst managerDriver = driver.manager(registry.config, config);\n\tconst client = createClientWithDriver(\n\t\tmanagerDriver,\n\t\tClientConfigSchema.parse({}),\n\t);\n\tconfigureInspectorAccessToken(config, managerDriver);\n\tconst { router } = createManagerRouter(\n\t\tregistry.config,\n\t\trunConfig,\n\t\tmanagerDriver,\n\t\tdriver,\n\t\tclient,\n\t);\n\n\t// Inject WebSocket\n\tconst nodeWebSocket = createNodeWebSocket({ app: router });\n\tupgradeWebSocket = nodeWebSocket.upgradeWebSocket;\n\n\tconst server = honoServe({\n\t\tfetch: router.fetch,\n\t\thostname: config.hostname,\n\t\tport: config.port,\n\t});\n\tnodeWebSocket.injectWebSocket(server);\n\n\tlogger().info({\n\t\tmsg: \"rivetkit started\",\n\t\thostname: config.hostname,\n\t\tport: config.port,\n\t\tdefinitions: Object.keys(registry.config.use).length,\n\t});\n\n\treturn server;\n}\n\nexport interface SetupTestResult<A extends Registry<any>> {\n\tclient: Client<A>;\n\tmockDriver: {\n\t\tactorDriver: {\n\t\t\tsetCreateVarsContext: (ctx: any) => void;\n\t\t};\n\t};\n}\n\n// Must use `TestContext` since global hooks do not work when running concurrently\nexport async function setupTest<A extends Registry<any>>(\n\tc: TestContext,\n\tregistry: A,\n): Promise<SetupTestResult<A>> {\n\tvi.useFakeTimers();\n\n\t// Set up mock driver for testing createVars context\n\tconst mockDriverContext: any = {};\n\tconst setDriverContextFn = (ctx: any) => {\n\t\tmockDriverContext.current = ctx;\n\t};\n\n\t// We don't need to modify the driver context anymore since we're testing with the actual context\n\n\t// Start server with a random port\n\tconst port = await getPort();\n\tconst server = serve(registry, { port });\n\tc.onTestFinished(\n\t\tasync () => await new Promise((resolve) => server.close(() => resolve())),\n\t);\n\n\tthrow \"TODO: Fix engine port\";\n\n\t// // TODO: Figure out how to make this the correct endpoint\n\t// // Create client\n\t// const client = createClient<A>(`http://127.0.0.1:${port}`);\n\t// c.onTestFinished(async () => await client.dispose());\n\t//\n\t// return {\n\t// \tclient,\n\t// \tmockDriver: {\n\t// \t\tactorDriver: {\n\t// \t\t\tsetCreateVarsContext: setDriverContextFn,\n\t// \t\t},\n\t// \t},\n\t// };\n}\n\nexport async function getPort(): Promise<number> {\n\t// Pick random port between 10000 and 65535 (avoiding well-known and registered ports)\n\tconst MIN_PORT = 10000;\n\tconst MAX_PORT = 65535;\n\tconst getRandomPort = () =>\n\t\tMath.floor(Math.random() * (MAX_PORT - MIN_PORT + 1)) + MIN_PORT;\n\n\tlet port = getRandomPort();\n\tlet maxAttempts = 10;\n\n\twhile (maxAttempts > 0) {\n\t\ttry {\n\t\t\t// Try to create a server on the port to check if it's available\n\t\t\tconst server = await new Promise<any>((resolve, reject) => {\n\t\t\t\tconst server = createServer();\n\n\t\t\t\tserver.once(\"error\", (err: Error & { code?: string }) => {\n\t\t\t\t\tif (err.code === \"EADDRINUSE\") {\n\t\t\t\t\t\treject(new Error(`Port ${port} is in use`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tserver.once(\"listening\", () => {\n\t\t\t\t\tresolve(server);\n\t\t\t\t});\n\n\t\t\t\tserver.listen(port);\n\t\t\t});\n\n\t\t\t// Close the server since we're just checking availability\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tserver.close(() => resolve());\n\t\t\t});\n\n\t\t\treturn port;\n\t\t} catch (err) {\n\t\t\t// If port is in use, try a different one\n\t\t\tmaxAttempts--;\n\t\t\tif (maxAttempts <= 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tport = getRandomPort();\n\t\t}\n\t}\n\n\tthrow new Error(\"Could not find an available port after multiple attempts\");\n}\n","import { z } from \"zod\";\nimport { RunnerConfigSchema } from \"@/registry/run-config\";\n\nexport const ConfigSchema = RunnerConfigSchema.removeDefault()\n\t.extend({\n\t\thostname: z\n\t\t\t.string()\n\t\t\t.optional()\n\t\t\t.default(process.env.HOSTNAME ?? \"127.0.0.1\"),\n\t\tport: z\n\t\t\t.number()\n\t\t\t.optional()\n\t\t\t.default(Number.parseInt(process.env.PORT ?? \"8080\")),\n\t})\n\t.default({});\nexport type InputConfig = z.input<typeof ConfigSchema>;\n","import { getLogger } from \"@/common/log\";\n\nexport function logger() {\n\treturn getLogger(\"test\");\n}\n"]}
|
|
@@ -208,7 +208,7 @@ function noopNext() {
|
|
|
208
208
|
// package.json
|
|
209
209
|
var package_default = {
|
|
210
210
|
name: "rivetkit",
|
|
211
|
-
version: "2.0.
|
|
211
|
+
version: "2.0.17",
|
|
212
212
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
213
213
|
license: "Apache-2.0",
|
|
214
214
|
keywords: [
|
|
@@ -371,7 +371,7 @@ var package_default = {
|
|
|
371
371
|
"@bare-ts/lib": "~0.3.0",
|
|
372
372
|
"@hono/standard-validator": "^0.1.3",
|
|
373
373
|
"@hono/zod-openapi": "^0.19.10",
|
|
374
|
-
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@
|
|
374
|
+
"@rivetkit/engine-runner": "https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@6659217",
|
|
375
375
|
"@rivetkit/fast-json-patch": "^3.1.2",
|
|
376
376
|
"cbor-x": "^1.6.0",
|
|
377
377
|
hono: "^4.7.0",
|
|
@@ -574,4 +574,4 @@ export {
|
|
|
574
574
|
bufferToArrayBuffer,
|
|
575
575
|
combineUrlPath
|
|
576
576
|
};
|
|
577
|
-
//# sourceMappingURL=chunk-
|
|
577
|
+
//# sourceMappingURL=chunk-FBCB4BRK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/common/utils.ts","../../package.json","../../src/utils.ts"],"sourcesContent":["import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { getEnvUniversal } from \"@/utils\";\nimport type { Logger } from \"./log\";\n\nexport function assertUnreachable(x: never): never {\n\tthrow new Error(`Unreachable case: ${x}`);\n}\n\n/**\n * Safely stringifies an object, ensuring that the stringified object is under a certain size.\n * @param obj any object to stringify\n * @param maxSize maximum size of the stringified object in bytes\n * @returns stringified object\n */\nexport function safeStringify(obj: unknown, maxSize: number) {\n\tlet size = 0;\n\n\tfunction replacer(key: string, value: unknown) {\n\t\tif (value === null || value === undefined) return value;\n\t\tconst valueSize =\n\t\t\ttypeof value === \"string\" ? value.length : JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(`JSON object exceeds size limit of ${maxSize} bytes.`);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\treturn JSON.stringify(obj, replacer);\n}\n\n// TODO: Instead of doing this, use a temp var for state and attempt to write\n// it. Roll back state if fails to serialize.\n\n/**\n * Check if a value is CBOR serializable.\n * Optionally pass an onInvalid callback to receive the path to invalid values.\n *\n * For a complete list of supported CBOR tags, see:\n * https://github.com/kriszyp/cbor-x/blob/cc1cf9df8ba72288c7842af1dd374d73e34cdbc1/README.md#list-of-supported-tags-for-decoding\n */\nexport function isCborSerializable(\n\tvalue: unknown,\n\tonInvalid?: (path: string) => void,\n\tcurrentPath = \"\",\n): boolean {\n\t// Handle primitive types directly\n\tif (value === null || value === undefined) {\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tonInvalid?.(currentPath);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"boolean\" || typeof value === \"string\") {\n\t\treturn true;\n\t}\n\n\t// Handle BigInt (CBOR tags 2 and 3)\n\tif (typeof value === \"bigint\") {\n\t\treturn true;\n\t}\n\n\t// Handle Date objects (CBOR tags 0 and 1)\n\tif (value instanceof Date) {\n\t\treturn true;\n\t}\n\n\t// Handle typed arrays (CBOR tags 64-82)\n\tif (\n\t\tvalue instanceof Uint8Array ||\n\t\tvalue instanceof Uint8ClampedArray ||\n\t\tvalue instanceof Uint16Array ||\n\t\tvalue instanceof Uint32Array ||\n\t\tvalue instanceof BigUint64Array ||\n\t\tvalue instanceof Int8Array ||\n\t\tvalue instanceof Int16Array ||\n\t\tvalue instanceof Int32Array ||\n\t\tvalue instanceof BigInt64Array ||\n\t\tvalue instanceof Float32Array ||\n\t\tvalue instanceof Float64Array\n\t) {\n\t\treturn true;\n\t}\n\n\t// Handle Map (CBOR tag 259)\n\tif (value instanceof Map) {\n\t\tfor (const [key, val] of value.entries()) {\n\t\t\tconst keyPath = currentPath\n\t\t\t\t? `${currentPath}.key(${String(key)})`\n\t\t\t\t: `key(${String(key)})`;\n\t\t\tconst valPath = currentPath\n\t\t\t\t? `${currentPath}.value(${String(key)})`\n\t\t\t\t: `value(${String(key)})`;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(key, onInvalid, keyPath) ||\n\t\t\t\t!isCborSerializable(val, onInvalid, valPath)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle Set (CBOR tag 258)\n\tif (value instanceof Set) {\n\t\tlet index = 0;\n\t\tfor (const item of value.values()) {\n\t\t\tconst itemPath = currentPath\n\t\t\t\t? `${currentPath}.set[${index}]`\n\t\t\t\t: `set[${index}]`;\n\t\t\tif (!isCborSerializable(item, onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle RegExp (CBOR tag 27)\n\tif (value instanceof RegExp) {\n\t\treturn true;\n\t}\n\n\t// Handle Error objects (CBOR tag 27)\n\tif (value instanceof Error) {\n\t\treturn true;\n\t}\n\n\t// Handle arrays\n\tif (Array.isArray(value)) {\n\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\tconst itemPath = currentPath ? `${currentPath}[${i}]` : `[${i}]`;\n\t\t\tif (!isCborSerializable(value[i], onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle plain objects and records (CBOR tags 105, 51, 57344-57599)\n\tif (typeof value === \"object\") {\n\t\t// Allow plain objects and objects with prototypes (for records and named objects)\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\tif (proto !== null && proto !== Object.prototype) {\n\t\t\t// Check if it's a known serializable object type\n\t\t\tconst protoConstructor = value.constructor;\n\t\t\tif (protoConstructor && typeof protoConstructor.name === \"string\") {\n\t\t\t\t// Allow objects with named constructors (records, named objects)\n\t\t\t\t// This includes user-defined classes and built-in objects\n\t\t\t\t// that CBOR can serialize with tag 27 or record tags\n\t\t\t}\n\t\t}\n\n\t\t// Check all properties recursively\n\t\tfor (const key in value) {\n\t\t\tconst propPath = currentPath ? `${currentPath}.${key}` : key;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(\n\t\t\t\t\tvalue[key as keyof typeof value],\n\t\t\t\t\tonInvalid,\n\t\t\t\t\tpropPath,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Not serializable\n\tonInvalid?.(currentPath);\n\treturn false;\n}\n\nexport interface DeconstructedError {\n\t__type: \"ActorError\";\n\tstatusCode: ContentfulStatusCode;\n\tpublic: boolean;\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n}\n\n/** Deconstructs error in to components that are used to build responses. */\nexport function deconstructError(\n\terror: unknown,\n\tlogger: Logger,\n\textraLog: Record<string, unknown>,\n\texposeInternalError = false,\n): DeconstructedError {\n\t// Build response error information. Only return errors if flagged as public in order to prevent leaking internal behavior.\n\t//\n\t// We log the error here instead of after generating the code & message because we need to log the original error, not the masked internal error.\n\tlet statusCode: ContentfulStatusCode;\n\tlet public_: boolean;\n\tlet group: string;\n\tlet code: string;\n\tlet message: string;\n\tlet metadata: unknown;\n\tif (errors.ActorError.isActorError(error) && error.public) {\n\t\t// Check if error has statusCode (could be ActorError instance or DeconstructedError)\n\t\tstatusCode = (\n\t\t\t\"statusCode\" in error && error.statusCode ? error.statusCode : 400\n\t\t) as ContentfulStatusCode;\n\t\tpublic_ = true;\n\t\tgroup = error.group;\n\t\tcode = error.code;\n\t\tmessage = getErrorMessage(error);\n\t\tmetadata = error.metadata;\n\n\t\tlogger.info({\n\t\t\tmsg: \"public error\",\n\t\t\tgroup,\n\t\t\tcode,\n\t\t\tmessage,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t} else if (exposeInternalError) {\n\t\tif (errors.ActorError.isActorError(error)) {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = error.group;\n\t\t\tcode = error.code;\n\t\t\tmessage = getErrorMessage(error);\n\t\t\tmetadata = error.metadata;\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t} else {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = \"internal\";\n\t\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\t\tmessage = getErrorMessage(error);\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tstatusCode = 500;\n\t\tpublic_ = false;\n\t\tgroup = \"internal\";\n\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\tmessage = errors.INTERNAL_ERROR_DESCRIPTION;\n\t\tmetadata = {\n\t\t\t//url: `https://hub.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,\n\t\t} satisfies errors.InternalErrorMetadata;\n\n\t\tlogger.warn({\n\t\t\tmsg: \"internal error\",\n\t\t\terror: getErrorMessage(error),\n\t\t\tstack: (error as Error)?.stack,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t}\n\n\treturn {\n\t\t__type: \"ActorError\",\n\t\tstatusCode,\n\t\tpublic: public_,\n\t\tgroup,\n\t\tcode,\n\t\tmessage,\n\t\tmetadata,\n\t};\n}\n\nexport function stringifyError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tgetEnvUniversal(\"_RIVETKIT_ERROR_STACK\") === \"1\"\n\t\t) {\n\t\t\treturn `${error.name}: ${error.message}${error.stack ? `\\n${error.stack}` : \"\"}`;\n\t\t} else {\n\t\t\treturn `${error.name}: ${error.message}`;\n\t\t}\n\t} else if (typeof error === \"string\") {\n\t\treturn error;\n\t} else if (typeof error === \"object\" && error !== null) {\n\t\ttry {\n\t\t\treturn `${JSON.stringify(error)}`;\n\t\t} catch {\n\t\t\treturn \"[cannot stringify error]\";\n\t\t}\n\t} else {\n\t\treturn `Unknown error: ${getErrorMessage(error)}`;\n\t}\n}\n\nfunction getErrorMessage(err: unknown): string {\n\tif (\n\t\terr &&\n\t\ttypeof err === \"object\" &&\n\t\t\"message\" in err &&\n\t\ttypeof err.message === \"string\"\n\t) {\n\t\treturn err.message;\n\t} else {\n\t\treturn String(err);\n\t}\n}\n\n/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */\nexport function noopNext(): Next {\n\treturn async () => {};\n}\n","{\n \"name\": \"rivetkit\",\n \"version\": \"2.0.15\",\n \"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n \"license\": \"Apache-2.0\",\n \"keywords\": [\n \"rivetkit\",\n \"stateful\",\n \"serverless\",\n \"actors\",\n \"agents\",\n \"realtime\",\n \"websocket\",\n \"actors\",\n \"framework\"\n ],\n \"files\": [\n \"dist\",\n \"src\",\n \"deno.json\",\n \"bun.json\",\n \"package.json\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/tsup/mod.d.ts\",\n \"default\": \"./dist/tsup/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/mod.d.cts\",\n \"default\": \"./dist/tsup/mod.cjs\"\n }\n },\n \"./client\": {\n \"import\": {\n \"types\": \"./dist/tsup/client/mod.d.ts\",\n \"default\": \"./dist/tsup/client/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/client/mod.d.cts\",\n \"default\": \"./dist/tsup/client/mod.cjs\"\n }\n },\n \"./log\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/log.d.ts\",\n \"default\": \"./dist/tsup/common/log.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/log.d.cts\",\n \"default\": \"./dist/tsup/common/log.cjs\"\n }\n },\n \"./errors\": {\n \"import\": {\n \"types\": \"./dist/tsup/actor/errors.d.ts\",\n \"default\": \"./dist/tsup/actor/errors.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/actor/errors.d.cts\",\n \"default\": \"./dist/tsup/actor/errors.cjs\"\n }\n },\n \"./utils\": {\n \"import\": {\n \"types\": \"./dist/tsup/utils.d.ts\",\n \"default\": \"./dist/tsup/utils.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/utils.d.cts\",\n \"default\": \"./dist/tsup/utils.cjs\"\n }\n },\n \"./driver-helpers\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n }\n },\n \"./driver-helpers/websocket\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/websocket.d.ts\",\n \"default\": \"./dist/tsup/common/websocket.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/websocket.d.cts\",\n \"default\": \"./dist/tsup/common/websocket.cjs\"\n }\n },\n \"./driver-test-suite\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n }\n },\n \"./topologies/coordinate\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n }\n },\n \"./topologies/partition\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n }\n },\n \"./test\": {\n \"import\": {\n \"types\": \"./dist/tsup/test/mod.d.ts\",\n \"default\": \"./dist/tsup/test/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/test/mod.d.cts\",\n \"default\": \"./dist/tsup/test/mod.cjs\"\n }\n },\n \"./inspector\": {\n \"import\": {\n \"types\": \"./dist/tsup/inspector/mod.d.ts\",\n \"default\": \"./dist/tsup/inspector/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/inspector/mod.d.cts\",\n \"default\": \"./dist/tsup/inspector/mod.cjs\"\n }\n }\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"sideEffects\": [\n \"./dist/tsup/chunk-*.js\",\n \"./dist/tsup/chunk-*.cjs\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts\",\n \"build:schema\": \"./scripts/compile-bare.ts compile schemas/client-protocol/v1.bare -o dist/schemas/client-protocol/v1.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v1.bare -o dist/schemas/file-system-driver/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts\",\n \"check-types\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"dump-openapi\": \"tsx scripts/dump-openapi.ts\"\n },\n \"dependencies\": {\n \"@bare-ts/lib\": \"~0.3.0\",\n \"@hono/standard-validator\": \"^0.1.3\",\n \"@hono/zod-openapi\": \"^0.19.10\",\n \"@rivetkit/engine-runner\": \"https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@bdfca35\",\n \"@rivetkit/fast-json-patch\": \"^3.1.2\",\n \"cbor-x\": \"^1.6.0\",\n \"hono\": \"^4.7.0\",\n \"invariant\": \"^2.2.4\",\n \"nanoevents\": \"^9.1.0\",\n \"on-change\": \"^5.0.1\",\n \"p-retry\": \"^6.2.1\",\n \"pino\": \"^9.5.0\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@bare-ts/tools\": \"^0.13.0\",\n \"@hono/node-server\": \"^1.18.2\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"@types/invariant\": \"^2\",\n \"@types/node\": \"^22.13.1\",\n \"@types/ws\": \"^8\",\n \"@vitest/ui\": \"3.1.1\",\n \"bundle-require\": \"^5.1.0\",\n \"eventsource\": \"^4.0.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.1.1\",\n \"ws\": \"^8.18.1\"\n },\n \"peerDependencies\": {\n \"@hono/node-server\": \"^1.14.0\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"eventsource\": \"^4.0.0\",\n \"ws\": \"^8.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"@hono/node-server\": {\n \"optional\": true\n },\n \"@hono/node-ws\": {\n \"optional\": true\n },\n \"eventsource\": {\n \"optional\": true\n },\n \"ws\": {\n \"optional\": true\n }\n },\n \"stableVersion\": \"0.8.0\"\n}\n","export { stringifyError } from \"@/common/utils\";\nexport { assertUnreachable } from \"./common/utils\";\n\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\n\nimport pkgJson from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nexport function httpUserAgent(): string {\n\t// Return cached value if already initialized\n\tif (_userAgent !== undefined) {\n\t\treturn _userAgent;\n\t}\n\n\t// Library\n\tlet userAgent = `RivetKit/${VERSION}`;\n\n\t// Navigator\n\tconst navigatorObj = typeof navigator !== \"undefined\" ? navigator : undefined;\n\tif (navigatorObj?.userAgent) userAgent += ` ${navigatorObj.userAgent}`;\n\n\t_userAgent = userAgent;\n\n\treturn userAgent;\n}\n\nexport type UpgradeWebSocket = (\n\tcreateEvents: (c: HonoContext) => any,\n) => HonoHandler;\n\nexport type GetUpgradeWebSocket = () => UpgradeWebSocket;\n\nexport function getEnvUniversal(key: string): string | undefined {\n\tif (typeof Deno !== \"undefined\") {\n\t\treturn Deno.env.get(key);\n\t} else if (typeof process !== \"undefined\") {\n\t\t// Do this after Deno since `process` is sometimes polyfilled\n\t\treturn process.env[key];\n\t}\n}\n\nexport function dbg<T>(x: T): T {\n\tconsole.trace(`=== DEBUG ===\\n${x}`);\n\treturn x;\n}\n\n/**\n * Converts various ArrayBuffer-like types to Uint8Array.\n * Handles ArrayBuffer, ArrayBufferView (including typed arrays), and passes through existing Uint8Array.\n *\n * @param data - The ArrayBuffer or ArrayBufferView to convert\n * @returns A Uint8Array view of the data\n */\nexport function toUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t} else if (data instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t} else if (ArrayBuffer.isView(data)) {\n\t\t// Handle other ArrayBufferView types (Int8Array, Uint16Array, DataView, etc.)\n\t\treturn new Uint8Array(\n\t\t\tdata.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),\n\t\t);\n\t} else {\n\t\tthrow new TypeError(\"Input must be ArrayBuffer or ArrayBufferView\");\n\t}\n}\n\n// Long timeouts\n//\n// JavaScript timers use a signed 32-bit integer for delays, so values above 2^31-1 (~24.8 days)\n// are not reliable and may fire immediately or overflow.\n//\n// https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value\nconst TIMEOUT_MAX = 2147483647; // 2^31-1\n\nexport type LongTimeoutHandle = { abort: () => void };\n\n/**\n * Polyfill for Promise.withResolvers().\n *\n * This is specifically for Cloudflare Workers. Their implementation of Promise.withResolvers does not work correctly.\n */\nexport function promiseWithResolvers<T>(): {\n\tpromise: Promise<T>;\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: any) => void;\n} {\n\tlet resolve!: (value: T | PromiseLike<T>) => void;\n\tlet reject!: (reason?: any) => void;\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\treturn { promise, resolve, reject };\n}\n\nexport function setLongTimeout(\n\tlistener: () => void,\n\tafter: number,\n): LongTimeoutHandle {\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tfunction start(remaining: number) {\n\t\tif (remaining <= TIMEOUT_MAX) {\n\t\t\ttimeout = setTimeout(listener, remaining);\n\t\t} else {\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tstart(remaining - TIMEOUT_MAX);\n\t\t\t}, TIMEOUT_MAX);\n\t\t}\n\t}\n\n\tstart(after);\n\n\treturn {\n\t\tabort: () => {\n\t\t\tif (timeout !== undefined) clearTimeout(timeout);\n\t\t},\n\t};\n}\n\n/**\n * A tiny utility that coalesces/enqueues async operations so only the latest\n * queued task runs per cycle, while callers receive a promise that resolves\n * when the task for the cycle they joined has completed.\n */\nexport class SinglePromiseQueue {\n\t/** Next operation to execute in the queue. If attempting to enqueue another op, it will override the existing op. */\n\t#queuedOp?: () => Promise<void>;\n\n\t/** The currently running promise of #drainLoop. Do not await this, instead await `pending` to await the current cycle. */\n\trunningDrainLoop?: Promise<void>;\n\n\t/** Pending resolver fro the currently queued entry. */\n\t#pending?: ReturnType<typeof promiseWithResolvers<void>>;\n\n\t/** Queue the next operation and return a promise that resolves when it flushes. */\n\tenqueue(op: () => Promise<void>): Promise<void> {\n\t\t// Replace any previously queued operation with the latest one\n\t\tthis.#queuedOp = op;\n\n\t\t// Ensure a shared resolver exists for all callers in this cycle\n\t\tif (!this.#pending) {\n\t\t\tthis.#pending = promiseWithResolvers<void>();\n\t\t}\n\n\t\tconst waitForThisCycle = this.#pending.promise;\n\n\t\t// Start runner if not already running\n\t\tif (!this.runningDrainLoop) {\n\t\t\tthis.runningDrainLoop = this.#drainLoop();\n\t\t}\n\n\t\treturn waitForThisCycle;\n\t}\n\n\t/** Drain queued operations sequentially until there is nothing left. */\n\tasync #drainLoop(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#queuedOp) {\n\t\t\t\t// Capture current cycle resolver then reset for the next cycle\n\t\t\t\tconst resolver = this.#pending;\n\t\t\t\tthis.#pending = undefined;\n\n\t\t\t\t// Capture and clear the currently queued operation\n\t\t\t\tconst op = this.#queuedOp;\n\t\t\t\tthis.#queuedOp = undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tawait op();\n\t\t\t\t} catch {\n\t\t\t\t\t// Swallow errors: callers only await cycle completion, not success\n\t\t\t\t}\n\n\t\t\t\t// Notify all waiters for this cycle\n\t\t\t\tresolver?.resolve();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\nexport function bufferToArrayBuffer(buf: Buffer | Uint8Array): ArrayBuffer {\n\treturn buf.buffer.slice(\n\t\tbuf.byteOffset,\n\t\tbuf.byteOffset + buf.byteLength,\n\t) as ArrayBuffer;\n}\n\n/**\n * Properly combines a base URL endpoint with a path, preserving any base path in the endpoint.\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors/action\")\n * // Returns: \"http://localhost:8787/rivet/actors/action\"\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors?type=foo\", { namespace: \"test\" })\n * // Returns: \"http://localhost:8787/rivet/actors?type=foo&namespace=test\"\n *\n * @param endpoint The base URL endpoint that may contain a path component\n * @param path The path to append to the endpoint (may include query parameters)\n * @param queryParams Optional additional query parameters to append\n * @returns The properly combined URL string\n */\nexport function combineUrlPath(\n\tendpoint: string,\n\tpath: string,\n\tqueryParams?: Record<string, string | undefined>,\n): string {\n\tconst baseUrl = new URL(endpoint);\n\n\t// Extract path and query from the provided path\n\tconst pathParts = path.split(\"?\");\n\tconst pathOnly = pathParts[0];\n\tconst existingQuery = pathParts[1] || \"\";\n\n\t// Remove trailing slash from base path and ensure path starts with /\n\tconst basePath = baseUrl.pathname.replace(/\\/$/, \"\");\n\tconst cleanPath = pathOnly.startsWith(\"/\") ? pathOnly : `/${pathOnly}`;\n\t// Combine paths and remove any double slashes\n\tconst fullPath = (basePath + cleanPath).replace(/\\/\\//g, \"/\");\n\n\t// Build query string\n\tconst queryParts: string[] = [];\n\tif (existingQuery) {\n\t\tqueryParts.push(existingQuery);\n\t}\n\tif (queryParams) {\n\t\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tqueryParts.push(\n\t\t\t\t\t`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst fullQuery = queryParts.length > 0 ? `?${queryParts.join(\"&\")}` : \"\";\n\treturn `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;\n}\n"],"mappings":";;;;;;;AAMO,SAAS,kBAAkB,GAAiB;AAClD,QAAM,IAAI,MAAM,qBAAqB,CAAC,EAAE;AACzC;AAqCO,SAAS,mBACf,OACA,WACA,cAAc,IACJ;AAEV,MAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,6CAAY;AACZ,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC5D,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,MAAM;AAC1B,WAAO;AAAA,EACR;AAGA,MACC,iBAAiB,cACjB,iBAAiB,qBACjB,iBAAiB,eACjB,iBAAiB,eACjB,iBAAiB,kBACjB,iBAAiB,aACjB,iBAAiB,cACjB,iBAAiB,cACjB,iBAAiB,iBACjB,iBAAiB,gBACjB,iBAAiB,cAChB;AACD,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,KAAK;AACzB,eAAW,CAAC,KAAK,GAAG,KAAK,MAAM,QAAQ,GAAG;AACzC,YAAM,UAAU,cACb,GAAG,WAAW,QAAQ,OAAO,GAAG,CAAC,MACjC,OAAO,OAAO,GAAG,CAAC;AACrB,YAAM,UAAU,cACb,GAAG,WAAW,U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M,KAAK,KAAK;AAChB,aAAK,YAAY;AAEjB,YAAI;AACH,gBAAM,GAAG;AAAA,QACV,QAAQ;AAAA,QAER;AAGA,6CAAU;AAAA,MACX;AAAA,IACD,UAAE;AACD,WAAK,mBAAmB;AAAA,IACzB;AAAA,EACD;AACD;AAEO,SAAS,oBAAoB,KAAuC;AAC1E,SAAO,IAAI,OAAO;AAAA,IACjB,IAAI;AAAA,IACJ,IAAI,aAAa,IAAI;AAAA,EACtB;AACD;AAkBO,SAAS,eACf,UACA,MACA,aACS;AACT,QAAM,UAAU,IAAI,IAAI,QAAQ;AAGhC,QAAM,YAAY,KAAK,MAAM,GAAG;AAChC,QAAM,WAAW,UAAU,CAAC;AAC5B,QAAM,gBAAgB,UAAU,CAAC,KAAK;AAGtC,QAAM,WAAW,QAAQ,SAAS,QAAQ,OAAO,EAAE;AACnD,QAAM,YAAY,SAAS,WAAW,GAAG,IAAI,WAAW,IAAI,QAAQ;AAEpE,QAAM,YAAY,WAAW,WAAW,QAAQ,SAAS,GAAG;AAG5D,QAAM,aAAuB,CAAC;AAC9B,MAAI,eAAe;AAClB,eAAW,KAAK,aAAa;AAAA,EAC9B;AACA,MAAI,aAAa;AAChB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACvD,UAAI,UAAU,QAAW;AACxB,mBAAW;AAAA,UACV,GAAG,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,KAAK,CAAC;AAAA,QACxD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,YAAY,WAAW,SAAS,IAAI,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK;AACvE,SAAO,GAAG,QAAQ,QAAQ,KAAK,QAAQ,IAAI,GAAG,QAAQ,GAAG,SAAS;AACnE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/common/utils.ts","../../package.json","../../src/utils.ts"],"sourcesContent":["import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { getEnvUniversal } from \"@/utils\";\nimport type { Logger } from \"./log\";\n\nexport function assertUnreachable(x: never): never {\n\tthrow new Error(`Unreachable case: ${x}`);\n}\n\n/**\n * Safely stringifies an object, ensuring that the stringified object is under a certain size.\n * @param obj any object to stringify\n * @param maxSize maximum size of the stringified object in bytes\n * @returns stringified object\n */\nexport function safeStringify(obj: unknown, maxSize: number) {\n\tlet size = 0;\n\n\tfunction replacer(key: string, value: unknown) {\n\t\tif (value === null || value === undefined) return value;\n\t\tconst valueSize =\n\t\t\ttypeof value === \"string\" ? value.length : JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(`JSON object exceeds size limit of ${maxSize} bytes.`);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\treturn JSON.stringify(obj, replacer);\n}\n\n// TODO: Instead of doing this, use a temp var for state and attempt to write\n// it. Roll back state if fails to serialize.\n\n/**\n * Check if a value is CBOR serializable.\n * Optionally pass an onInvalid callback to receive the path to invalid values.\n *\n * For a complete list of supported CBOR tags, see:\n * https://github.com/kriszyp/cbor-x/blob/cc1cf9df8ba72288c7842af1dd374d73e34cdbc1/README.md#list-of-supported-tags-for-decoding\n */\nexport function isCborSerializable(\n\tvalue: unknown,\n\tonInvalid?: (path: string) => void,\n\tcurrentPath = \"\",\n): boolean {\n\t// Handle primitive types directly\n\tif (value === null || value === undefined) {\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tonInvalid?.(currentPath);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"boolean\" || typeof value === \"string\") {\n\t\treturn true;\n\t}\n\n\t// Handle BigInt (CBOR tags 2 and 3)\n\tif (typeof value === \"bigint\") {\n\t\treturn true;\n\t}\n\n\t// Handle Date objects (CBOR tags 0 and 1)\n\tif (value instanceof Date) {\n\t\treturn true;\n\t}\n\n\t// Handle typed arrays (CBOR tags 64-82)\n\tif (\n\t\tvalue instanceof Uint8Array ||\n\t\tvalue instanceof Uint8ClampedArray ||\n\t\tvalue instanceof Uint16Array ||\n\t\tvalue instanceof Uint32Array ||\n\t\tvalue instanceof BigUint64Array ||\n\t\tvalue instanceof Int8Array ||\n\t\tvalue instanceof Int16Array ||\n\t\tvalue instanceof Int32Array ||\n\t\tvalue instanceof BigInt64Array ||\n\t\tvalue instanceof Float32Array ||\n\t\tvalue instanceof Float64Array\n\t) {\n\t\treturn true;\n\t}\n\n\t// Handle Map (CBOR tag 259)\n\tif (value instanceof Map) {\n\t\tfor (const [key, val] of value.entries()) {\n\t\t\tconst keyPath = currentPath\n\t\t\t\t? `${currentPath}.key(${String(key)})`\n\t\t\t\t: `key(${String(key)})`;\n\t\t\tconst valPath = currentPath\n\t\t\t\t? `${currentPath}.value(${String(key)})`\n\t\t\t\t: `value(${String(key)})`;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(key, onInvalid, keyPath) ||\n\t\t\t\t!isCborSerializable(val, onInvalid, valPath)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle Set (CBOR tag 258)\n\tif (value instanceof Set) {\n\t\tlet index = 0;\n\t\tfor (const item of value.values()) {\n\t\t\tconst itemPath = currentPath\n\t\t\t\t? `${currentPath}.set[${index}]`\n\t\t\t\t: `set[${index}]`;\n\t\t\tif (!isCborSerializable(item, onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle RegExp (CBOR tag 27)\n\tif (value instanceof RegExp) {\n\t\treturn true;\n\t}\n\n\t// Handle Error objects (CBOR tag 27)\n\tif (value instanceof Error) {\n\t\treturn true;\n\t}\n\n\t// Handle arrays\n\tif (Array.isArray(value)) {\n\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\tconst itemPath = currentPath ? `${currentPath}[${i}]` : `[${i}]`;\n\t\t\tif (!isCborSerializable(value[i], onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle plain objects and records (CBOR tags 105, 51, 57344-57599)\n\tif (typeof value === \"object\") {\n\t\t// Allow plain objects and objects with prototypes (for records and named objects)\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\tif (proto !== null && proto !== Object.prototype) {\n\t\t\t// Check if it's a known serializable object type\n\t\t\tconst protoConstructor = value.constructor;\n\t\t\tif (protoConstructor && typeof protoConstructor.name === \"string\") {\n\t\t\t\t// Allow objects with named constructors (records, named objects)\n\t\t\t\t// This includes user-defined classes and built-in objects\n\t\t\t\t// that CBOR can serialize with tag 27 or record tags\n\t\t\t}\n\t\t}\n\n\t\t// Check all properties recursively\n\t\tfor (const key in value) {\n\t\t\tconst propPath = currentPath ? `${currentPath}.${key}` : key;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(\n\t\t\t\t\tvalue[key as keyof typeof value],\n\t\t\t\t\tonInvalid,\n\t\t\t\t\tpropPath,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Not serializable\n\tonInvalid?.(currentPath);\n\treturn false;\n}\n\nexport interface DeconstructedError {\n\t__type: \"ActorError\";\n\tstatusCode: ContentfulStatusCode;\n\tpublic: boolean;\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n}\n\n/** Deconstructs error in to components that are used to build responses. */\nexport function deconstructError(\n\terror: unknown,\n\tlogger: Logger,\n\textraLog: Record<string, unknown>,\n\texposeInternalError = false,\n): DeconstructedError {\n\t// Build response error information. Only return errors if flagged as public in order to prevent leaking internal behavior.\n\t//\n\t// We log the error here instead of after generating the code & message because we need to log the original error, not the masked internal error.\n\tlet statusCode: ContentfulStatusCode;\n\tlet public_: boolean;\n\tlet group: string;\n\tlet code: string;\n\tlet message: string;\n\tlet metadata: unknown;\n\tif (errors.ActorError.isActorError(error) && error.public) {\n\t\t// Check if error has statusCode (could be ActorError instance or DeconstructedError)\n\t\tstatusCode = (\n\t\t\t\"statusCode\" in error && error.statusCode ? error.statusCode : 400\n\t\t) as ContentfulStatusCode;\n\t\tpublic_ = true;\n\t\tgroup = error.group;\n\t\tcode = error.code;\n\t\tmessage = getErrorMessage(error);\n\t\tmetadata = error.metadata;\n\n\t\tlogger.info({\n\t\t\tmsg: \"public error\",\n\t\t\tgroup,\n\t\t\tcode,\n\t\t\tmessage,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t} else if (exposeInternalError) {\n\t\tif (errors.ActorError.isActorError(error)) {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = error.group;\n\t\t\tcode = error.code;\n\t\t\tmessage = getErrorMessage(error);\n\t\t\tmetadata = error.metadata;\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t} else {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = \"internal\";\n\t\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\t\tmessage = getErrorMessage(error);\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tstatusCode = 500;\n\t\tpublic_ = false;\n\t\tgroup = \"internal\";\n\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\tmessage = errors.INTERNAL_ERROR_DESCRIPTION;\n\t\tmetadata = {\n\t\t\t//url: `https://hub.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,\n\t\t} satisfies errors.InternalErrorMetadata;\n\n\t\tlogger.warn({\n\t\t\tmsg: \"internal error\",\n\t\t\terror: getErrorMessage(error),\n\t\t\tstack: (error as Error)?.stack,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t}\n\n\treturn {\n\t\t__type: \"ActorError\",\n\t\tstatusCode,\n\t\tpublic: public_,\n\t\tgroup,\n\t\tcode,\n\t\tmessage,\n\t\tmetadata,\n\t};\n}\n\nexport function stringifyError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tgetEnvUniversal(\"_RIVETKIT_ERROR_STACK\") === \"1\"\n\t\t) {\n\t\t\treturn `${error.name}: ${error.message}${error.stack ? `\\n${error.stack}` : \"\"}`;\n\t\t} else {\n\t\t\treturn `${error.name}: ${error.message}`;\n\t\t}\n\t} else if (typeof error === \"string\") {\n\t\treturn error;\n\t} else if (typeof error === \"object\" && error !== null) {\n\t\ttry {\n\t\t\treturn `${JSON.stringify(error)}`;\n\t\t} catch {\n\t\t\treturn \"[cannot stringify error]\";\n\t\t}\n\t} else {\n\t\treturn `Unknown error: ${getErrorMessage(error)}`;\n\t}\n}\n\nfunction getErrorMessage(err: unknown): string {\n\tif (\n\t\terr &&\n\t\ttypeof err === \"object\" &&\n\t\t\"message\" in err &&\n\t\ttypeof err.message === \"string\"\n\t) {\n\t\treturn err.message;\n\t} else {\n\t\treturn String(err);\n\t}\n}\n\n/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */\nexport function noopNext(): Next {\n\treturn async () => {};\n}\n","{\n \"name\": \"rivetkit\",\n \"version\": \"2.0.17\",\n \"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n \"license\": \"Apache-2.0\",\n \"keywords\": [\n \"rivetkit\",\n \"stateful\",\n \"serverless\",\n \"actors\",\n \"agents\",\n \"realtime\",\n \"websocket\",\n \"actors\",\n \"framework\"\n ],\n \"files\": [\n \"dist\",\n \"src\",\n \"deno.json\",\n \"bun.json\",\n \"package.json\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/tsup/mod.d.ts\",\n \"default\": \"./dist/tsup/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/mod.d.cts\",\n \"default\": \"./dist/tsup/mod.cjs\"\n }\n },\n \"./client\": {\n \"import\": {\n \"types\": \"./dist/tsup/client/mod.d.ts\",\n \"default\": \"./dist/tsup/client/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/client/mod.d.cts\",\n \"default\": \"./dist/tsup/client/mod.cjs\"\n }\n },\n \"./log\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/log.d.ts\",\n \"default\": \"./dist/tsup/common/log.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/log.d.cts\",\n \"default\": \"./dist/tsup/common/log.cjs\"\n }\n },\n \"./errors\": {\n \"import\": {\n \"types\": \"./dist/tsup/actor/errors.d.ts\",\n \"default\": \"./dist/tsup/actor/errors.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/actor/errors.d.cts\",\n \"default\": \"./dist/tsup/actor/errors.cjs\"\n }\n },\n \"./utils\": {\n \"import\": {\n \"types\": \"./dist/tsup/utils.d.ts\",\n \"default\": \"./dist/tsup/utils.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/utils.d.cts\",\n \"default\": \"./dist/tsup/utils.cjs\"\n }\n },\n \"./driver-helpers\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n }\n },\n \"./driver-helpers/websocket\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/websocket.d.ts\",\n \"default\": \"./dist/tsup/common/websocket.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/websocket.d.cts\",\n \"default\": \"./dist/tsup/common/websocket.cjs\"\n }\n },\n \"./driver-test-suite\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n }\n },\n \"./topologies/coordinate\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n }\n },\n \"./topologies/partition\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n }\n },\n \"./test\": {\n \"import\": {\n \"types\": \"./dist/tsup/test/mod.d.ts\",\n \"default\": \"./dist/tsup/test/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/test/mod.d.cts\",\n \"default\": \"./dist/tsup/test/mod.cjs\"\n }\n },\n \"./inspector\": {\n \"import\": {\n \"types\": \"./dist/tsup/inspector/mod.d.ts\",\n \"default\": \"./dist/tsup/inspector/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/inspector/mod.d.cts\",\n \"default\": \"./dist/tsup/inspector/mod.cjs\"\n }\n }\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"sideEffects\": [\n \"./dist/tsup/chunk-*.js\",\n \"./dist/tsup/chunk-*.cjs\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts\",\n \"build:schema\": \"./scripts/compile-bare.ts compile schemas/client-protocol/v1.bare -o dist/schemas/client-protocol/v1.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v1.bare -o dist/schemas/file-system-driver/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts\",\n \"check-types\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"dump-openapi\": \"tsx scripts/dump-openapi.ts\"\n },\n \"dependencies\": {\n \"@bare-ts/lib\": \"~0.3.0\",\n \"@hono/standard-validator\": \"^0.1.3\",\n \"@hono/zod-openapi\": \"^0.19.10\",\n \"@rivetkit/engine-runner\": \"https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@6659217\",\n \"@rivetkit/fast-json-patch\": \"^3.1.2\",\n \"cbor-x\": \"^1.6.0\",\n \"hono\": \"^4.7.0\",\n \"invariant\": \"^2.2.4\",\n \"nanoevents\": \"^9.1.0\",\n \"on-change\": \"^5.0.1\",\n \"p-retry\": \"^6.2.1\",\n \"pino\": \"^9.5.0\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@bare-ts/tools\": \"^0.13.0\",\n \"@hono/node-server\": \"^1.18.2\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"@types/invariant\": \"^2\",\n \"@types/node\": \"^22.13.1\",\n \"@types/ws\": \"^8\",\n \"@vitest/ui\": \"3.1.1\",\n \"bundle-require\": \"^5.1.0\",\n \"eventsource\": \"^4.0.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.1.1\",\n \"ws\": \"^8.18.1\"\n },\n \"peerDependencies\": {\n \"@hono/node-server\": \"^1.14.0\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"eventsource\": \"^4.0.0\",\n \"ws\": \"^8.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"@hono/node-server\": {\n \"optional\": true\n },\n \"@hono/node-ws\": {\n \"optional\": true\n },\n \"eventsource\": {\n \"optional\": true\n },\n \"ws\": {\n \"optional\": true\n }\n },\n \"stableVersion\": \"0.8.0\"\n}\n","export { stringifyError } from \"@/common/utils\";\nexport { assertUnreachable } from \"./common/utils\";\n\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\n\nimport pkgJson from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nexport function httpUserAgent(): string {\n\t// Return cached value if already initialized\n\tif (_userAgent !== undefined) {\n\t\treturn _userAgent;\n\t}\n\n\t// Library\n\tlet userAgent = `RivetKit/${VERSION}`;\n\n\t// Navigator\n\tconst navigatorObj = typeof navigator !== \"undefined\" ? navigator : undefined;\n\tif (navigatorObj?.userAgent) userAgent += ` ${navigatorObj.userAgent}`;\n\n\t_userAgent = userAgent;\n\n\treturn userAgent;\n}\n\nexport type UpgradeWebSocket = (\n\tcreateEvents: (c: HonoContext) => any,\n) => HonoHandler;\n\nexport type GetUpgradeWebSocket = () => UpgradeWebSocket;\n\nexport function getEnvUniversal(key: string): string | undefined {\n\tif (typeof Deno !== \"undefined\") {\n\t\treturn Deno.env.get(key);\n\t} else if (typeof process !== \"undefined\") {\n\t\t// Do this after Deno since `process` is sometimes polyfilled\n\t\treturn process.env[key];\n\t}\n}\n\nexport function dbg<T>(x: T): T {\n\tconsole.trace(`=== DEBUG ===\\n${x}`);\n\treturn x;\n}\n\n/**\n * Converts various ArrayBuffer-like types to Uint8Array.\n * Handles ArrayBuffer, ArrayBufferView (including typed arrays), and passes through existing Uint8Array.\n *\n * @param data - The ArrayBuffer or ArrayBufferView to convert\n * @returns A Uint8Array view of the data\n */\nexport function toUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t} else if (data instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t} else if (ArrayBuffer.isView(data)) {\n\t\t// Handle other ArrayBufferView types (Int8Array, Uint16Array, DataView, etc.)\n\t\treturn new Uint8Array(\n\t\t\tdata.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),\n\t\t);\n\t} else {\n\t\tthrow new TypeError(\"Input must be ArrayBuffer or ArrayBufferView\");\n\t}\n}\n\n// Long timeouts\n//\n// JavaScript timers use a signed 32-bit integer for delays, so values above 2^31-1 (~24.8 days)\n// are not reliable and may fire immediately or overflow.\n//\n// https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value\nconst TIMEOUT_MAX = 2147483647; // 2^31-1\n\nexport type LongTimeoutHandle = { abort: () => void };\n\n/**\n * Polyfill for Promise.withResolvers().\n *\n * This is specifically for Cloudflare Workers. Their implementation of Promise.withResolvers does not work correctly.\n */\nexport function promiseWithResolvers<T>(): {\n\tpromise: Promise<T>;\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: any) => void;\n} {\n\tlet resolve!: (value: T | PromiseLike<T>) => void;\n\tlet reject!: (reason?: any) => void;\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\treturn { promise, resolve, reject };\n}\n\nexport function setLongTimeout(\n\tlistener: () => void,\n\tafter: number,\n): LongTimeoutHandle {\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tfunction start(remaining: number) {\n\t\tif (remaining <= TIMEOUT_MAX) {\n\t\t\ttimeout = setTimeout(listener, remaining);\n\t\t} else {\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tstart(remaining - TIMEOUT_MAX);\n\t\t\t}, TIMEOUT_MAX);\n\t\t}\n\t}\n\n\tstart(after);\n\n\treturn {\n\t\tabort: () => {\n\t\t\tif (timeout !== undefined) clearTimeout(timeout);\n\t\t},\n\t};\n}\n\n/**\n * A tiny utility that coalesces/enqueues async operations so only the latest\n * queued task runs per cycle, while callers receive a promise that resolves\n * when the task for the cycle they joined has completed.\n */\nexport class SinglePromiseQueue {\n\t/** Next operation to execute in the queue. If attempting to enqueue another op, it will override the existing op. */\n\t#queuedOp?: () => Promise<void>;\n\n\t/** The currently running promise of #drainLoop. Do not await this, instead await `pending` to await the current cycle. */\n\trunningDrainLoop?: Promise<void>;\n\n\t/** Pending resolver fro the currently queued entry. */\n\t#pending?: ReturnType<typeof promiseWithResolvers<void>>;\n\n\t/** Queue the next operation and return a promise that resolves when it flushes. */\n\tenqueue(op: () => Promise<void>): Promise<void> {\n\t\t// Replace any previously queued operation with the latest one\n\t\tthis.#queuedOp = op;\n\n\t\t// Ensure a shared resolver exists for all callers in this cycle\n\t\tif (!this.#pending) {\n\t\t\tthis.#pending = promiseWithResolvers<void>();\n\t\t}\n\n\t\tconst waitForThisCycle = this.#pending.promise;\n\n\t\t// Start runner if not already running\n\t\tif (!this.runningDrainLoop) {\n\t\t\tthis.runningDrainLoop = this.#drainLoop();\n\t\t}\n\n\t\treturn waitForThisCycle;\n\t}\n\n\t/** Drain queued operations sequentially until there is nothing left. */\n\tasync #drainLoop(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#queuedOp) {\n\t\t\t\t// Capture current cycle resolver then reset for the next cycle\n\t\t\t\tconst resolver = this.#pending;\n\t\t\t\tthis.#pending = undefined;\n\n\t\t\t\t// Capture and clear the currently queued operation\n\t\t\t\tconst op = this.#queuedOp;\n\t\t\t\tthis.#queuedOp = undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tawait op();\n\t\t\t\t} catch {\n\t\t\t\t\t// Swallow errors: callers only await cycle completion, not success\n\t\t\t\t}\n\n\t\t\t\t// Notify all waiters for this cycle\n\t\t\t\tresolver?.resolve();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\nexport function bufferToArrayBuffer(buf: Buffer | Uint8Array): ArrayBuffer {\n\treturn buf.buffer.slice(\n\t\tbuf.byteOffset,\n\t\tbuf.byteOffset + buf.byteLength,\n\t) as ArrayBuffer;\n}\n\n/**\n * Properly combines a base URL endpoint with a path, preserving any base path in the endpoint.\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors/action\")\n * // Returns: \"http://localhost:8787/rivet/actors/action\"\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors?type=foo\", { namespace: \"test\" })\n * // Returns: \"http://localhost:8787/rivet/actors?type=foo&namespace=test\"\n *\n * @param endpoint The base URL endpoint that may contain a path component\n * @param path The path to append to the endpoint (may include query parameters)\n * @param queryParams Optional additional query parameters to append\n * @returns The properly combined URL string\n */\nexport function combineUrlPath(\n\tendpoint: string,\n\tpath: string,\n\tqueryParams?: Record<string, string | undefined>,\n): string {\n\tconst baseUrl = new URL(endpoint);\n\n\t// Extract path and query from the provided path\n\tconst pathParts = path.split(\"?\");\n\tconst pathOnly = pathParts[0];\n\tconst existingQuery = pathParts[1] || \"\";\n\n\t// Remove trailing slash from base path and ensure path starts with /\n\tconst basePath = baseUrl.pathname.replace(/\\/$/, \"\");\n\tconst cleanPath = pathOnly.startsWith(\"/\") ? pathOnly : `/${pathOnly}`;\n\t// Combine paths and remove any double slashes\n\tconst fullPath = (basePath + cleanPath).replace(/\\/\\//g, \"/\");\n\n\t// Build query string\n\tconst queryParts: string[] = [];\n\tif (existingQuery) {\n\t\tqueryParts.push(existingQuery);\n\t}\n\tif (queryParams) {\n\t\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tqueryParts.push(\n\t\t\t\t\t`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst fullQuery = queryParts.length > 0 ? `?${queryParts.join(\"&\")}` : \"\";\n\treturn `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;\n}\n"],"mappings":";;;;;;;AAMO,SAAS,kBAAkB,GAAiB;AAClD,QAAM,IAAI,MAAM,qBAAqB,CAAC,EAAE;AACzC;AAqCO,SAAS,mBACf,OACA,WACA,cAAc,IACJ;AAEV,MAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,6CAAY;AACZ,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC5D,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,MAAM;AAC1B,WAAO;AAAA,EACR;AAGA,MACC,iBAAiB,cACjB,iBAAiB,qBACjB,iBAAiB,eACjB,iBAAiB,eACjB,iBAAiB,kBACjB,iBAAiB,aACjB,iBAAiB,cACjB,iBAAiB,cACjB,iBAAiB,iBACjB,iBAAiB,gBACjB,iBAAiB,cAChB;AACD,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,KAAK;AACzB,eAAW,CAAC,KAAK,GAAG,KAAK,MAAM,QAAQ,GAAG;AACzC,YAAM,UAAU,cACb,GAAG,WAAW,QAAQ,OAAO,GAAG,CAAC,MACjC,OAAO,OAAO,GAAG,CAAC;AACrB,YAAM,UAAU,cACb,GAAG,WAAW,UAAU,OAAO,GAAG,CAAC,MACnC,SAAS,OAAO,GAAG,CAAC;AACvB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ConfigSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LM7MHACC.js";
|
|
8
8
|
|
|
9
9
|
// src/client/mod.ts
|
|
10
10
|
function createClient(endpointOrConfig) {
|
|
@@ -17,4 +17,4 @@ function createClient(endpointOrConfig) {
|
|
|
17
17
|
export {
|
|
18
18
|
createClient
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-HEAZ6K5B.js.map
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkTZ3ITYDPcjs = require('./chunk-TZ3ITYDP.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk6WNRLSTJcjs = require('./chunk-6WNRLSTJ.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkAA74JNFVcjs = require('./chunk-AA74JNFV.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -580,7 +580,7 @@ function getValueLength(value) {
|
|
|
580
580
|
} else if (value instanceof ArrayBuffer || value instanceof SharedArrayBuffer || value instanceof Uint8Array) {
|
|
581
581
|
return value.byteLength;
|
|
582
582
|
} else {
|
|
583
|
-
|
|
583
|
+
_chunkAA74JNFVcjs.assertUnreachable.call(void 0, value);
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
async function inputDataToBuffer(data) {
|
|
@@ -606,7 +606,7 @@ async function parseMessage(value, opts) {
|
|
|
606
606
|
if (buffer instanceof Buffer) {
|
|
607
607
|
buffer = new Uint8Array(buffer);
|
|
608
608
|
}
|
|
609
|
-
return
|
|
609
|
+
return _chunkTZ3ITYDPcjs.deserializeWithEncoding.call(void 0, opts.encoding, buffer, TO_SERVER_VERSIONED);
|
|
610
610
|
}
|
|
611
611
|
async function processMessage(message, actor, conn, handler) {
|
|
612
612
|
let actionId;
|
|
@@ -638,13 +638,13 @@ async function processMessage(message, actor, conn, handler) {
|
|
|
638
638
|
isPromise: output instanceof Promise
|
|
639
639
|
});
|
|
640
640
|
conn._sendMessage(
|
|
641
|
-
new (0,
|
|
641
|
+
new (0, _chunkTZ3ITYDPcjs.CachedSerializer)(
|
|
642
642
|
{
|
|
643
643
|
body: {
|
|
644
644
|
tag: "ActionResponse",
|
|
645
645
|
val: {
|
|
646
646
|
id,
|
|
647
|
-
output:
|
|
647
|
+
output: _chunkAA74JNFVcjs.bufferToArrayBuffer.call(void 0, cbor.encode(output))
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
},
|
|
@@ -673,10 +673,10 @@ async function processMessage(message, actor, conn, handler) {
|
|
|
673
673
|
subscribe
|
|
674
674
|
});
|
|
675
675
|
} else {
|
|
676
|
-
|
|
676
|
+
_chunkAA74JNFVcjs.assertUnreachable.call(void 0, message.body);
|
|
677
677
|
}
|
|
678
678
|
} catch (error) {
|
|
679
|
-
const { group, code, message: message2, metadata } =
|
|
679
|
+
const { group, code, message: message2, metadata } = _chunkAA74JNFVcjs.deconstructError.call(void 0,
|
|
680
680
|
error,
|
|
681
681
|
actor.rLog,
|
|
682
682
|
{
|
|
@@ -693,7 +693,7 @@ async function processMessage(message, actor, conn, handler) {
|
|
|
693
693
|
message: message2
|
|
694
694
|
});
|
|
695
695
|
conn._sendMessage(
|
|
696
|
-
new (0,
|
|
696
|
+
new (0, _chunkTZ3ITYDPcjs.CachedSerializer)(
|
|
697
697
|
{
|
|
698
698
|
body: {
|
|
699
699
|
tag: "Error",
|
|
@@ -701,7 +701,7 @@ async function processMessage(message, actor, conn, handler) {
|
|
|
701
701
|
group,
|
|
702
702
|
code,
|
|
703
703
|
message: message2,
|
|
704
|
-
metadata:
|
|
704
|
+
metadata: _chunkAA74JNFVcjs.bufferToArrayBuffer.call(void 0, cbor.encode(metadata)),
|
|
705
705
|
actionId: _nullishCoalesce(actionId, () => ( null))
|
|
706
706
|
}
|
|
707
707
|
}
|
|
@@ -717,15 +717,15 @@ async function processMessage(message, actor, conn, handler) {
|
|
|
717
717
|
var ClientConfigSchema = _zod2.default.object({
|
|
718
718
|
/** Endpoint to connect to for Rivet Engine or RivetKit manager API. */
|
|
719
719
|
endpoint: _zod2.default.string().optional().transform(
|
|
720
|
-
(x) => _nullishCoalesce(_nullishCoalesce(x, () => (
|
|
720
|
+
(x) => _nullishCoalesce(_nullishCoalesce(x, () => ( _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_ENGINE"))), () => ( _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_ENDPOINT")))
|
|
721
721
|
),
|
|
722
722
|
/** Token to use to authenticate with the API. */
|
|
723
|
-
token: _zod2.default.string().optional().transform((x) => _nullishCoalesce(x, () => (
|
|
723
|
+
token: _zod2.default.string().optional().transform((x) => _nullishCoalesce(x, () => ( _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_TOKEN")))),
|
|
724
724
|
/** Namespace to connect to. */
|
|
725
|
-
namespace: _zod2.default.string().default(() => _nullishCoalesce(
|
|
725
|
+
namespace: _zod2.default.string().default(() => _nullishCoalesce(_chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_NAMESPACE"), () => ( "default"))),
|
|
726
726
|
/** Name of the runner. This is used to group together runners in to different pools. */
|
|
727
|
-
runnerName: _zod2.default.string().default(() => _nullishCoalesce(
|
|
728
|
-
encoding:
|
|
727
|
+
runnerName: _zod2.default.string().default(() => _nullishCoalesce(_chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_RUNNER"), () => ( "default"))),
|
|
728
|
+
encoding: _chunkTZ3ITYDPcjs.EncodingSchema.default("bare"),
|
|
729
729
|
transport: TransportSchema.default("websocket"),
|
|
730
730
|
headers: _zod2.default.record(_zod2.default.string()).optional().default({}),
|
|
731
731
|
// See RunConfig.getUpgradeWebSocket
|
|
@@ -738,7 +738,7 @@ var ClientConfigSchema = _zod2.default.object({
|
|
|
738
738
|
var EngingConfigSchema = _zod.z.object({
|
|
739
739
|
/** Unique key for this runner. Runners connecting a given key will replace any other runner connected with the same key. */
|
|
740
740
|
runnerKey: _zod.z.string().default(
|
|
741
|
-
() => _nullishCoalesce(
|
|
741
|
+
() => _nullishCoalesce(_chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_RUNNER_KEY"), () => ( crypto.randomUUID()))
|
|
742
742
|
),
|
|
743
743
|
/** How many actors this runner can run. */
|
|
744
744
|
totalSlots: _zod.z.number().default(1e5)
|
|
@@ -747,14 +747,14 @@ var EngingConfigSchema = _zod.z.object({
|
|
|
747
747
|
// src/inspector/config.ts
|
|
748
748
|
|
|
749
749
|
var defaultTokenFn = () => {
|
|
750
|
-
const envToken =
|
|
750
|
+
const envToken = _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVETKIT_INSPECTOR_TOKEN");
|
|
751
751
|
if (envToken) {
|
|
752
752
|
return envToken;
|
|
753
753
|
}
|
|
754
754
|
return "";
|
|
755
755
|
};
|
|
756
756
|
var defaultEnabled = () => {
|
|
757
|
-
return
|
|
757
|
+
return _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "NODE_ENV") !== "production" || !_chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVETKIT_INSPECTOR_DISABLE");
|
|
758
758
|
};
|
|
759
759
|
var defaultInspectorOrigins = [
|
|
760
760
|
"http://localhost:43708",
|
|
@@ -830,9 +830,9 @@ var RunnerConfigSchema = _zod.z.object({
|
|
|
830
830
|
/** @experimental */
|
|
831
831
|
defaultServerPort: _zod.z.number().default(6420),
|
|
832
832
|
/** @experimental */
|
|
833
|
-
runEngine: _zod.z.boolean().optional().default(() =>
|
|
833
|
+
runEngine: _zod.z.boolean().optional().default(() => _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_RUN_ENGINE") === "1"),
|
|
834
834
|
/** @experimental */
|
|
835
|
-
runEngineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
835
|
+
runEngineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_RUN_ENGINE_VERSION"), () => ( "25.8.0"))),
|
|
836
836
|
/** @experimental */
|
|
837
837
|
overrideServerAddress: _zod.z.string().optional(),
|
|
838
838
|
/** @experimental */
|
|
@@ -844,7 +844,7 @@ var RunnerConfigSchema = _zod.z.object({
|
|
|
844
844
|
* serverlessly (by the Rivet Engine for example).
|
|
845
845
|
*/
|
|
846
846
|
runnerKind: _zod.z.enum(["serverless", "normal"]).optional().default(
|
|
847
|
-
() =>
|
|
847
|
+
() => _chunkAA74JNFVcjs.getEnvUniversal.call(void 0, "RIVET_RUNNER_KIND") === "serverless" ? "serverless" : "normal"
|
|
848
848
|
),
|
|
849
849
|
totalSlots: _zod.z.number().optional(),
|
|
850
850
|
/**
|
|
@@ -866,7 +866,7 @@ var RunnerConfigSchema = _zod.z.object({
|
|
|
866
866
|
* */
|
|
867
867
|
logging: _zod.z.object({
|
|
868
868
|
baseLogger: _zod.z.custom().optional(),
|
|
869
|
-
level:
|
|
869
|
+
level: _chunk6WNRLSTJcjs.LogLevelSchema.optional()
|
|
870
870
|
}).optional().default({}),
|
|
871
871
|
/**
|
|
872
872
|
* @experimental
|
|
@@ -1075,9 +1075,9 @@ var PERSISTED_ACTOR_VERSIONED = createVersionedDataHandler({
|
|
|
1075
1075
|
// src/driver-helpers/utils.ts
|
|
1076
1076
|
function serializeEmptyPersistData(input) {
|
|
1077
1077
|
const persistData = {
|
|
1078
|
-
input: input !== void 0 ?
|
|
1078
|
+
input: input !== void 0 ? _chunkAA74JNFVcjs.bufferToArrayBuffer.call(void 0, cbor2.encode(input)) : null,
|
|
1079
1079
|
hasInitialized: false,
|
|
1080
|
-
state:
|
|
1080
|
+
state: _chunkAA74JNFVcjs.bufferToArrayBuffer.call(void 0, cbor2.encode(void 0)),
|
|
1081
1081
|
connections: [],
|
|
1082
1082
|
scheduledEvents: []
|
|
1083
1083
|
};
|
|
@@ -1101,4 +1101,4 @@ function serializeEmptyPersistData(input) {
|
|
|
1101
1101
|
|
|
1102
1102
|
|
|
1103
1103
|
exports.createVersionedDataHandler = createVersionedDataHandler; exports.TO_SERVER_VERSIONED = TO_SERVER_VERSIONED; exports.TO_CLIENT_VERSIONED = TO_CLIENT_VERSIONED; exports.HTTP_ACTION_REQUEST_VERSIONED = HTTP_ACTION_REQUEST_VERSIONED; exports.HTTP_ACTION_RESPONSE_VERSIONED = HTTP_ACTION_RESPONSE_VERSIONED; exports.HTTP_RESPONSE_ERROR_VERSIONED = HTTP_RESPONSE_ERROR_VERSIONED; exports.PERSISTED_ACTOR_VERSIONED = PERSISTED_ACTOR_VERSIONED; exports.ActionContext = ActionContext; exports.inputDataToBuffer = inputDataToBuffer; exports.parseMessage = parseMessage; exports.processMessage = processMessage; exports.ClientConfigSchema = ClientConfigSchema; exports.DriverConfigSchema = DriverConfigSchema; exports.RunnerConfigSchema = RunnerConfigSchema; exports.serializeEmptyPersistData = serializeEmptyPersistData;
|
|
1104
|
-
//# sourceMappingURL=chunk-
|
|
1104
|
+
//# sourceMappingURL=chunk-JYALFDJ7.cjs.map
|