rivetkit 2.1.2 → 2.1.3
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/browser/client.js +1 -1
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/inspector.tar.gz +0 -0
- package/dist/tsup/{chunk-NXEHFUDB.cjs → chunk-5AZ6UPEF.cjs} +24 -21
- package/dist/tsup/chunk-5AZ6UPEF.cjs.map +1 -0
- package/dist/tsup/{chunk-YQ5P6KMN.js → chunk-6LHZQSWJ.js} +8 -5
- package/dist/tsup/{chunk-YQ5P6KMN.js.map → chunk-6LHZQSWJ.js.map} +1 -1
- package/dist/tsup/{chunk-BFI4LYS2.js → chunk-6T3WSP5M.js} +4 -4
- package/dist/tsup/{chunk-772NPMTY.cjs → chunk-BMNB6YRQ.cjs} +160 -103
- package/dist/tsup/chunk-BMNB6YRQ.cjs.map +1 -0
- package/dist/tsup/{chunk-GVQAVU7R.cjs → chunk-DADGS67O.cjs} +4 -4
- package/dist/tsup/{chunk-GVQAVU7R.cjs.map → chunk-DADGS67O.cjs.map} +1 -1
- package/dist/tsup/{chunk-RHUII57M.js → chunk-GNGRMP5E.js} +10 -6
- package/dist/tsup/chunk-GNGRMP5E.js.map +1 -0
- package/dist/tsup/{chunk-PZAV6PP2.cjs → chunk-HPAX7L72.cjs} +152 -152
- package/dist/tsup/{chunk-PZAV6PP2.cjs.map → chunk-HPAX7L72.cjs.map} +1 -1
- package/dist/tsup/{chunk-UZV7NXC6.cjs → chunk-IJAGZS57.cjs} +30 -30
- package/dist/tsup/{chunk-UZV7NXC6.cjs.map → chunk-IJAGZS57.cjs.map} +1 -1
- package/dist/tsup/{chunk-HFWRHT5T.cjs → chunk-KSZZRTOD.cjs} +3 -3
- package/dist/tsup/{chunk-HFWRHT5T.cjs.map → chunk-KSZZRTOD.cjs.map} +1 -1
- package/dist/tsup/{chunk-PSUVV4HM.js → chunk-MAXIXG56.js} +2 -2
- package/dist/tsup/{chunk-HB4RGGMC.js → chunk-N7ASEZ2Y.js} +5 -5
- package/dist/tsup/{chunk-PW3YONDJ.js → chunk-OAOF23ZY.js} +2 -2
- package/dist/tsup/{chunk-TDFDR7AO.js → chunk-POUBQA6Z.js} +2 -2
- package/dist/tsup/{chunk-VMX4I4MP.js → chunk-QUDLEWGD.js} +3 -3
- package/dist/tsup/{chunk-MNS5LY6M.cjs → chunk-R64EFI6F.cjs} +74 -74
- package/dist/tsup/{chunk-MNS5LY6M.cjs.map → chunk-R64EFI6F.cjs.map} +1 -1
- package/dist/tsup/{chunk-QABDKI3W.cjs → chunk-T6MM5RTW.cjs} +248 -244
- package/dist/tsup/chunk-T6MM5RTW.cjs.map +1 -0
- package/dist/tsup/{chunk-ZHQDRRMY.cjs → chunk-U6VWVHVW.cjs} +3 -3
- package/dist/tsup/{chunk-ZHQDRRMY.cjs.map → chunk-U6VWVHVW.cjs.map} +1 -1
- package/dist/tsup/{chunk-WUXR722E.js → chunk-YET3IZD6.js} +2 -2
- package/dist/tsup/{chunk-WUXR722E.js.map → chunk-YET3IZD6.js.map} +1 -1
- package/dist/tsup/{chunk-BSIJG3LG.js → chunk-YLDDENCZ.js} +69 -12
- package/dist/tsup/chunk-YLDDENCZ.js.map +1 -0
- package/dist/tsup/{chunk-RMJJE43B.cjs → chunk-ZSJ2OTY4.cjs} +2 -2
- package/dist/tsup/{chunk-RMJJE43B.cjs.map → chunk-ZSJ2OTY4.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/driver-helpers/mod.cjs +4 -4
- package/dist/tsup/driver-helpers/mod.js +3 -3
- package/dist/tsup/driver-test-suite/mod.cjs +425 -338
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.js +376 -289
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +3 -3
- package/dist/tsup/inspector/mod.js +2 -2
- package/dist/tsup/mod.cjs +8 -8
- package/dist/tsup/mod.js +7 -7
- package/dist/tsup/serve-test-suite/mod.cjs +111 -99
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +22 -10
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +5 -5
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +5 -5
- package/src/actor/instance/mod.ts +13 -2
- package/src/driver-test-suite/tests/actor-db.ts +299 -216
- package/src/driver-test-suite/tests/actor-queue.ts +10 -9
- package/src/driver-test-suite/tests/actor-workflow.ts +12 -2
- package/src/driver-test-suite/utils.ts +8 -8
- package/src/drivers/engine/actor-driver.ts +77 -7
- package/src/workflow/driver.ts +4 -1
- package/dist/tsup/chunk-772NPMTY.cjs.map +0 -1
- package/dist/tsup/chunk-BSIJG3LG.js.map +0 -1
- package/dist/tsup/chunk-NXEHFUDB.cjs.map +0 -1
- package/dist/tsup/chunk-QABDKI3W.cjs.map +0 -1
- package/dist/tsup/chunk-RHUII57M.js.map +0 -1
- /package/dist/tsup/{chunk-BFI4LYS2.js.map → chunk-6T3WSP5M.js.map} +0 -0
- /package/dist/tsup/{chunk-PSUVV4HM.js.map → chunk-MAXIXG56.js.map} +0 -0
- /package/dist/tsup/{chunk-HB4RGGMC.js.map → chunk-N7ASEZ2Y.js.map} +0 -0
- /package/dist/tsup/{chunk-PW3YONDJ.js.map → chunk-OAOF23ZY.js.map} +0 -0
- /package/dist/tsup/{chunk-TDFDR7AO.js.map → chunk-POUBQA6Z.js.map} +0 -0
- /package/dist/tsup/{chunk-VMX4I4MP.js.map → chunk-QUDLEWGD.js.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZSJ2OTY4cjs = require('./chunk-ZSJ2OTY4.cjs');
|
|
4
4
|
|
|
5
5
|
// src/client/log.ts
|
|
6
6
|
function logger() {
|
|
7
|
-
return
|
|
7
|
+
return _chunkZSJ2OTY4cjs.getLogger.call(void 0, "actor-client");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// src/common/websocket.ts
|
|
@@ -46,4 +46,4 @@ async function importWebSocket() {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
exports.logger = logger; exports.importWebSocket = importWebSocket;
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-U6VWVHVW.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-U6VWVHVW.cjs","../../src/client/log.ts","../../src/common/websocket.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACFO,SAAS,MAAA,CAAA,EAAS;AACxB,EAAA,OAAO,yCAAA,cAAwB,CAAA;AAChC;ADIA;AACA;AENA,IAAI,iBAAA,EAAqD,IAAA;AAEzD,MAAA,SAAsB,eAAA,CAAA,EAA6C;AAElE,EAAA,GAAA,CAAI,iBAAA,IAAqB,IAAA,EAAM;AAC9B,IAAA,OAAO,gBAAA;AAAA,EACR;AAGA,EAAA,iBAAA,EAAA,CAAoB,MAAA,CAAA,EAAA,GAAY;AAC/B,IAAA,IAAI,UAAA;AAEJ,IAAA,GAAA,CAAI,OAAO,UAAA,IAAc,WAAA,EAAa;AAErC,MAAA,WAAA,EAAa,SAAA;AAAA,IACd,EAAA,KAAO;AAEN,MAAA,IAAI;AACH,QAAA,MAAM,WAAA,EAAa,IAAA;AACnB,QAAA,MAAM,GAAA,EAAK,MAAM,4DAAA;AAAA;AAAA,UAAiC;AAAA,QAAA,GAAA;AAClD,QAAA,WAAA,EAAa,EAAA,CAAG,OAAA;AAChB,QAAA,MAAA,CAAO,CAAA,CAAE,KAAA,CAAM,0BAA0B,CAAA;AAAA,MAC1C,EAAA,UAAQ;AAEP,QAAA,WAAA,EAAa,MAAM,cAAc;AAAA,UAChC,WAAA,CAAA,EAAc;AACb,YAAA,MAAM,IAAI,KAAA;AAAA,cACT;AAAA,YACD,CAAA;AAAA,UACD;AAAA,QACD,CAAA;AACA,QAAA,MAAA,CAAO,CAAA,CAAE,KAAA,CAAM,sBAAsB,CAAA;AAAA,MACtC;AAAA,IACD;AAEA,IAAA,OAAO,UAAA;AAAA,EACR,CAAA,CAAA,CAAG,CAAA;AAEH,EAAA,OAAO,gBAAA;AACR;AFCA;AACA;AACE;AACA;AACF,mEAAC","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/chunk-U6VWVHVW.cjs","sourcesContent":[null,"import { getLogger } from \"@/common/log\";\n\nexport function logger() {\n\treturn getLogger(\"actor-client\");\n}\n","import { logger } from \"@/client/log\";\n\n// Global singleton promise that will be reused for subsequent calls\nlet webSocketPromise: Promise<typeof WebSocket> | null = null;\n\nexport async function importWebSocket(): Promise<typeof WebSocket> {\n\t// Return existing promise if we already started loading\n\tif (webSocketPromise !== null) {\n\t\treturn webSocketPromise;\n\t}\n\n\t// Create and store the promise\n\twebSocketPromise = (async () => {\n\t\tlet _WebSocket: typeof WebSocket;\n\n\t\tif (typeof WebSocket !== \"undefined\") {\n\t\t\t// Browser environment\n\t\t\t_WebSocket = WebSocket as unknown as typeof WebSocket;\n\t\t} else {\n\t\t\t// Node.js environment\n\t\t\ttry {\n\t\t\t\tconst moduleName = \"ws\";\n\t\t\t\tconst ws = await import(/* webpackIgnore: true */ moduleName);\n\t\t\t\t_WebSocket = ws.default as unknown as typeof WebSocket;\n\t\t\t\tlogger().debug(\"using websocket from npm\");\n\t\t\t} catch {\n\t\t\t\t// WS not available\n\t\t\t\t_WebSocket = class MockWebSocket {\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t'WebSocket support requires installing the \"ws\" peer dependency.',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} as unknown as typeof WebSocket;\n\t\t\t\tlogger().debug(\"using mock websocket\");\n\t\t\t}\n\t\t}\n\n\t\treturn _WebSocket;\n\t})();\n\n\treturn webSocketPromise;\n}\n"]}
|
|
@@ -240,7 +240,7 @@ function noopNext() {
|
|
|
240
240
|
// package.json
|
|
241
241
|
var package_default = {
|
|
242
242
|
name: "rivetkit",
|
|
243
|
-
version: "2.1.
|
|
243
|
+
version: "2.1.3",
|
|
244
244
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
245
245
|
license: "Apache-2.0",
|
|
246
246
|
keywords: [
|
|
@@ -1057,4 +1057,4 @@ export {
|
|
|
1057
1057
|
getBaseLogger,
|
|
1058
1058
|
getLogger
|
|
1059
1059
|
};
|
|
1060
|
-
//# sourceMappingURL=chunk-
|
|
1060
|
+
//# sourceMappingURL=chunk-YET3IZD6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/env-vars.ts","../../src/common/utils.ts","../../package.json","../../src/common/log.ts","../../src/common/log-levels.ts","../../src/common/logfmt.ts","../../src/utils.ts"],"sourcesContent":["// This file consolidates all environment variables that affect RivetKit's behavior.\n//\n// IMPORTANT: When adding or modifying environment variables here, also update the\n// documentation at: website/src/content/docs/general/environment-variables.mdx\n\nimport { getEnvUniversal } from \"@/utils\";\n\n// Rivet configuration\nexport const getRivetEngine = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_ENGINE\");\nexport const getRivetEndpoint = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_ENDPOINT\");\nexport const getRivetToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_TOKEN\");\nexport const getRivetNamespace = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_NAMESPACE\");\nexport const getRivetRunner = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER\");\nexport const getRivetTotalSlots = (): number | undefined => {\n\tconst value = getEnvUniversal(\"RIVET_TOTAL_SLOTS\");\n\treturn value !== undefined ? parseInt(value, 10) : undefined;\n};\nexport const getRivetRunnerKey = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER_KEY\");\nexport const getRivetRunEngine = (): boolean =>\n\tgetEnvUniversal(\"RIVET_RUN_ENGINE\") === \"1\";\nexport const getRivetRunEngineVersion = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUN_ENGINE_VERSION\");\nexport const getRivetRunnerKind = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER_KIND\");\nexport const getRivetRunnerVersion = (): number | undefined => {\n\tconst value = getEnvUniversal(\"RIVET_RUNNER_VERSION\");\n\treturn value !== undefined ? parseInt(value, 10) : undefined;\n};\nexport const getRivetPublicEndpoint = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_PUBLIC_ENDPOINT\");\nexport const getRivetPublicToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_PUBLIC_TOKEN\");\n// There is no RIVET_PUBLIC_NAMESPACE because the frontend and backend cannot\n// use different namespaces\n\n// RivetKit configuration\nexport const getRivetkitInspectorToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_INSPECTOR_TOKEN\");\nexport const getRivetkitInspectorDisable = (): boolean =>\n\tgetEnvUniversal(\"RIVET_INSPECTOR_DISABLE\") === \"1\";\nexport const getRivetkitStoragePath = (): string | undefined =>\n\tgetEnvUniversal(\"RIVETKIT_STORAGE_PATH\");\n\n// Logging configuration\n// DEPRECATED: LOG_LEVEL will be removed in a future version\nexport const getLogLevel = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_LOG_LEVEL\") ?? getEnvUniversal(\"LOG_LEVEL\");\nexport const getLogTarget = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_TARGET\") === \"1\";\nexport const getLogTimestamp = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_TIMESTAMP\") === \"1\";\nexport const getLogMessage = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_MESSAGE\") === \"1\";\nexport const getLogErrorStack = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_ERROR_STACK\") === \"1\";\nexport const getLogHeaders = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_HEADERS\") === \"1\";\n\n// Environment configuration\nexport const getNodeEnv = (): string | undefined => getEnvUniversal(\"NODE_ENV\");\nexport const getNextPhase = (): string | undefined =>\n\tgetEnvUniversal(\"NEXT_PHASE\");\nexport const isDev = (): boolean => getNodeEnv() !== \"production\";\n\n// Experimental\n/**\n * Enables experimental OTel tracing for Rivet Actors.\n *\n * When disabled, actors use an in-memory no-op traces implementation.\n */\nexport const getRivetExperimentalOtel = (): boolean =>\n\tgetEnvUniversal(\"RIVET_EXPERIMENTAL_OTEL\") === \"1\";\n","import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { EXTRA_ERROR_LOG, VERSION } from \"@/utils\";\nimport { getLogErrorStack } from \"@/utils/env-vars\";\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\"\n\t\t\t\t? value.length\n\t\t\t\t: JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(\n\t\t\t\t`JSON object exceeds size limit of ${maxSize} bytes.`,\n\t\t\t);\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\t...EXTRA_ERROR_LOG,\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\tstack: (error as Error)?.stack,\n\t\t\t\t...EXTRA_ERROR_LOG,\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 = \"rivetkit\";\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\tstack: (error as Error)?.stack,\n\t\t\t\t...EXTRA_ERROR_LOG,\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 = \"rivetkit\";\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\t...EXTRA_ERROR_LOG,\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\tgetLogErrorStack()\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\t\"name\": \"rivetkit\",\n\t\"version\": \"2.1.2\",\n\t\"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n\t\"license\": \"Apache-2.0\",\n\t\"keywords\": [\n\t\t\"rivetkit\",\n\t\t\"stateful\",\n\t\t\"serverless\",\n\t\t\"actors\",\n\t\t\"agents\",\n\t\t\"realtime\",\n\t\t\"websocket\",\n\t\t\"actors\",\n\t\t\"framework\"\n\t],\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\",\n\t\t\"deno.json\",\n\t\t\"bun.json\",\n\t\t\"package.json\"\n\t],\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./workflow\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/workflow/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/workflow/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/workflow/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/workflow/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./client\": {\n\t\t\t\"import\": {\n\t\t\t\t\"browser\": {\n\t\t\t\t\t\"types\": \"./dist/browser/client.d.ts\",\n\t\t\t\t\t\"default\": \"./dist/browser/client.js\"\n\t\t\t\t},\n\t\t\t\t\"types\": \"./dist/tsup/client/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/client/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/client/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/client/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./log\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/log.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/log.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/log.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/log.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./errors\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/actor/errors.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/actor/errors.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/actor/errors.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/actor/errors.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./utils\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/utils.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/utils.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/utils.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/utils.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-helpers\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-helpers/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-helpers/websocket\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/websocket.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/websocket.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/websocket.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/websocket.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-test-suite\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./serve-test-suite\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/serve-test-suite/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/serve-test-suite/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/serve-test-suite/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/serve-test-suite/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./topologies/coordinate\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./topologies/partition\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/partition/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./test\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/test/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/test/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/test/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/test/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./inspector\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/inspector/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/inspector/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/inspector/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/inspector/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./inspector/client\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/browser/inspector/client.d.ts\",\n\t\t\t\t\"default\": \"./dist/browser/inspector/client.js\"\n\t\t\t}\n\t\t},\n\t\t\"./db\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./db/drizzle\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/drizzle/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/drizzle/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/drizzle/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/drizzle/mod.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=22.0.0\"\n\t},\n\t\"sideEffects\": [\n\t\t\"./dist/tsup/chunk-*.js\",\n\t\t\"./dist/tsup/chunk-*.cjs\"\n\t],\n\t\"scripts\": {\n \t\t\"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/serve-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts src/workflow/mod.ts src/db/mod.ts src/db/drizzle/mod.ts\",\n\t\t\"build:browser\": \"tsup --config tsup.browser.config.ts\",\n\t\t\"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/client-protocol/v2.bare -o dist/schemas/client-protocol/v2.ts && ./scripts/compile-bare.ts compile schemas/client-protocol/v3.bare -o dist/schemas/client-protocol/v3.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/file-system-driver/v2.bare -o dist/schemas/file-system-driver/v2.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v3.bare -o dist/schemas/file-system-driver/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v2.bare -o dist/schemas/actor-persist/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v3.bare -o dist/schemas/actor-persist/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v4.bare -o dist/schemas/actor-persist/v4.ts && ./scripts/compile-bare.ts compile schemas/persist/v1.bare -o dist/schemas/persist/v1.ts && ./scripts/compile-bare.ts compile schemas/transport/v1.bare -o dist/schemas/transport/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v1.bare -o dist/schemas/actor-inspector/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v2.bare -o dist/schemas/actor-inspector/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v3.bare -o dist/schemas/actor-inspector/v3.ts\",\n\t\t\"check-types\": \"tsc --noEmit\",\n\t\t\"lint\": \"biome check .\",\n\t\t\"lint:fix\": \"biome check --write .\",\n\t\t\"format\": \"biome format .\",\n\t\t\"format:write\": \"biome format --write .\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"manager-openapi-gen\": \"tsx scripts/manager-openapi-gen.ts\",\n\t\t\"dump-asyncapi\": \"tsx scripts/dump-asyncapi.ts\",\n\t\t\"registry-config-schema-gen\": \"tsx scripts/registry-config-schema-gen.ts\",\n\t\t\"actor-config-schema-gen\": \"tsx scripts/actor-config-schema-gen.ts\",\n\t\t\"build:pack-inspector\": \"tsx scripts/pack-inspector.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"@hono/standard-validator\": \"^0.1.3\",\n\t\t\"@hono/zod-openapi\": \"^1.1.5\",\n\t\t\"@rivetkit/bare-ts\": \"^0.6.2\",\n\t\t\"@rivetkit/engine-runner\": \"workspace:*\",\n\t\t\"@rivetkit/fast-json-patch\": \"^3.1.2\",\n\t\t\"@rivetkit/on-change\": \"^6.0.2-rc.1\",\n\t\t\"@rivetkit/sqlite-vfs\": \"workspace:*\",\n\t\t\"@rivetkit/traces\": \"workspace:*\",\n\t\t\"@rivetkit/virtual-websocket\": \"workspace:*\",\n\t\t\"@rivetkit/workflow-engine\": \"workspace:*\",\n\t\t\"cbor-x\": \"^1.6.0\",\n\t\t\"get-port\": \"^7.1.0\",\n\t\t\"hono\": \"^4.7.0\",\n\t\t\"invariant\": \"^2.2.4\",\n\t\t\"nanoevents\": \"^9.1.0\",\n\t\t\"p-retry\": \"^6.2.1\",\n\t\t\"pino\": \"^9.5.0\",\n\t\t\"tar\": \"^7.5.0\",\n\t\t\"uuid\": \"^12.0.0\",\n\t\t\"vbare\": \"^0.0.4\",\n\t\t\"@rivetkit/sqlite\": \"^0.1.1\",\n\t\t\"zod\": \"^4.1.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@bare-ts/tools\": \"^0.13.0\",\n\t\t\"@biomejs/biome\": \"^2.3\",\n\t\t\"@hono/node-server\": \"^1.18.2\",\n\t\t\"@hono/node-ws\": \"^1.1.1\",\n\t\t\"@standard-schema/spec\": \"^1.0.0\",\n\t\t\"@types/invariant\": \"^2\",\n\t\t\"@types/node\": \"^22.13.1\",\n\t\t\"@types/ws\": \"^8\",\n\t\t\"@vitest/ui\": \"3.1.1\",\n\t\t\"cli-table3\": \"^0.6.5\",\n\t\t\"commander\": \"^12.1.0\",\n\t\t\"eventsource\": \"^4.0.0\",\n\t\t\"local-pkg\": \"^0.5.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"tsx\": \"^4.19.4\",\n\t\t\"typescript\": \"^5.7.3\",\n\t\t\"vite-tsconfig-paths\": \"^5.1.4\",\n\t\t\"vitest\": \"^3.1.1\",\n\t\t\"ws\": \"^8.18.1\",\n\t\t\"zod-to-json-schema\": \"^3.25.0\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@hono/node-server\": \"^1.14.0\",\n\t\t\"@hono/node-ws\": \"^1.1.1\",\n\t\t\"drizzle-kit\": \"^0.31.2\",\n\t\t\"drizzle-orm\": \"^0.44.2\",\n\t\t\"eventsource\": \"^4.0.0\",\n\t\t\"ws\": \"^8.0.0\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"@hono/node-server\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"@hono/node-ws\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"drizzle-kit\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"drizzle-orm\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"eventsource\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"ws\": {\n\t\t\t\"optional\": true\n\t\t}\n\t},\n\t\"stableVersion\": \"0.8.0\"\n}\n","import {\n\ttype LevelWithSilent,\n\ttype Logger,\n\tpino,\n\tstdTimeFunctions,\n} from \"pino\";\nimport { z } from \"zod/v4\";\nimport { getLogLevel, getLogTarget, getLogTimestamp } from \"@/utils/env-vars\";\nimport {\n\tcastToLogValue,\n\tformatTimestamp,\n\tLOGGER_CONFIG,\n\tstringify,\n} from \"./logfmt\";\n\nexport type { Logger } from \"pino\";\n\nlet baseLogger: Logger | undefined;\nlet configuredLogLevel: LogLevel | undefined;\n\n/** Cache of child loggers by logger name. */\nconst loggerCache = new Map<string, Logger>();\n\nexport const LogLevelSchema = z.enum([\n\t\"trace\",\n\t\"debug\",\n\t\"info\",\n\t\"warn\",\n\t\"error\",\n\t\"fatal\",\n\t\"silent\",\n]);\n\nexport type LogLevel = z.infer<typeof LogLevelSchema>;\n\nexport function getPinoLevel(logLevel?: LogLevel): LevelWithSilent {\n\t// Priority: provided > configured > env > default\n\tif (logLevel) {\n\t\treturn logLevel;\n\t}\n\n\tif (configuredLogLevel) {\n\t\treturn configuredLogLevel;\n\t}\n\n\tconst raw = (getLogLevel() || \"warn\").toString().toLowerCase();\n\n\tconst parsed = LogLevelSchema.safeParse(raw);\n\tif (parsed.success) {\n\t\treturn parsed.data;\n\t}\n\n\t// Default to info if invalid\n\treturn \"info\";\n}\n\nexport function getIncludeTarget(): boolean {\n\treturn getLogTarget();\n}\n\n/**\n * Configure a custom base logger.\n */\nexport function configureBaseLogger(logger: Logger): void {\n\tbaseLogger = logger;\n\tloggerCache.clear();\n}\n\n// TODO: This can be simplified in logfmt.ts\nfunction customWrite(level: string, o: any) {\n\tconst entries: any = {};\n\n\t// Add timestamp if enabled\n\tif (getLogTimestamp() && o.time) {\n\t\tconst date = typeof o.time === \"number\" ? new Date(o.time) : new Date();\n\t\tentries.ts = formatTimestamp(date);\n\t}\n\n\t// Add level\n\tentries.level = level.toUpperCase();\n\n\t// Add target if present\n\tif (o.target) {\n\t\tentries.target = o.target;\n\t}\n\n\t// Add message\n\tif (o.msg) {\n\t\tentries.msg = o.msg;\n\t}\n\n\t// Add other properties\n\tfor (const [key, value] of Object.entries(o)) {\n\t\tif (\n\t\t\tkey !== \"time\" &&\n\t\t\tkey !== \"level\" &&\n\t\t\tkey !== \"target\" &&\n\t\t\tkey !== \"msg\" &&\n\t\t\tkey !== \"pid\" &&\n\t\t\tkey !== \"hostname\"\n\t\t) {\n\t\t\tentries[key] = castToLogValue(value);\n\t\t}\n\t}\n\n\tconst output = stringify(entries);\n\tconsole.log(output);\n}\n\n/**\n * Configure the default logger with optional log level.\n */\nexport function configureDefaultLogger(logLevel?: LogLevel) {\n\t// Store the configured log level\n\tif (logLevel) {\n\t\tconfiguredLogLevel = logLevel;\n\t}\n\n\tbaseLogger = pino({\n\t\tlevel: getPinoLevel(logLevel),\n\t\tmessageKey: \"msg\",\n\t\t// Do not include pid/hostname in output\n\t\tbase: {},\n\t\t// Keep a string level in the output\n\t\tformatters: {\n\t\t\tlevel(_label: string, number: number) {\n\t\t\t\treturn { level: number };\n\t\t\t},\n\t\t},\n\t\ttimestamp: getLogTimestamp() ? stdTimeFunctions.epochTime : false,\n\t\tbrowser: {\n\t\t\twrite: {\n\t\t\t\tfatal: customWrite.bind(null, \"fatal\"),\n\t\t\t\terror: customWrite.bind(null, \"error\"),\n\t\t\t\twarn: customWrite.bind(null, \"warn\"),\n\t\t\t\tinfo: customWrite.bind(null, \"info\"),\n\t\t\t\tdebug: customWrite.bind(null, \"debug\"),\n\t\t\t\ttrace: customWrite.bind(null, \"trace\"),\n\t\t\t},\n\t\t},\n\t\thooks: {\n\t\t\tlogMethod(inputArgs, method, level) {\n\t\t\t\t// TODO: This is a hack to not implement our own Pino transport target. We can get better perf if we have our own transport target.\n\n\t\t\t\tconst levelMap: Record<number, string> = {\n\t\t\t\t\t10: \"trace\",\n\t\t\t\t\t20: \"debug\",\n\t\t\t\t\t30: \"info\",\n\t\t\t\t\t40: \"warn\",\n\t\t\t\t\t50: \"error\",\n\t\t\t\t\t60: \"fatal\",\n\t\t\t\t};\n\t\t\t\tconst levelName = levelMap[level] || \"info\";\n\t\t\t\tconst time = getLogTimestamp() ? Date.now() : undefined;\n\n\t\t\t\t// Get bindings from the logger instance (child logger fields)\n\t\t\t\tconst bindings = (this as any).bindings?.() || {};\n\n\t\t\t\t// TODO: This can be simplified in logfmt.ts\n\t\t\t\tif (inputArgs.length >= 2) {\n\t\t\t\t\tconst [objOrMsg, msg] = inputArgs;\n\t\t\t\t\tif (typeof objOrMsg === \"object\" && objOrMsg !== null) {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\t...objOrMsg,\n\t\t\t\t\t\t\tmsg,\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\tmsg: String(objOrMsg),\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (inputArgs.length === 1) {\n\t\t\t\t\tconst [objOrMsg] = inputArgs;\n\t\t\t\t\tif (typeof objOrMsg === \"object\" && objOrMsg !== null) {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\t...objOrMsg,\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\tmsg: String(objOrMsg),\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t});\n\n\tloggerCache.clear();\n}\n\n/**\n * Get or initialize the base logger.\n */\nexport function getBaseLogger(): Logger {\n\tif (!baseLogger) {\n\t\tconfigureDefaultLogger();\n\t}\n\treturn baseLogger!;\n}\n\n/**\n * Returns a child logger with `target` bound for the given name.\n */\nexport function getLogger(name = \"default\"): Logger {\n\t// Check cache first\n\tconst cached = loggerCache.get(name);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\t// Create\n\tconst base = getBaseLogger();\n\n\t// Add target to log if enabled\n\tconst child = getIncludeTarget() ? base.child({ target: name }) : base;\n\n\t// Cache the logger\n\tloggerCache.set(name, child);\n\n\treturn child;\n}\n","export type LogLevel =\n\t| \"TRACE\"\n\t| \"DEBUG\"\n\t| \"INFO\"\n\t| \"WARN\"\n\t| \"ERROR\"\n\t| \"CRITICAL\";\n\nexport const LogLevels: Record<LogLevel, LevelIndex> = {\n\tTRACE: 0,\n\tDEBUG: 1,\n\tINFO: 2,\n\tWARN: 3,\n\tERROR: 4,\n\tCRITICAL: 5,\n} as const;\n\nexport const LevelNameMap: Record<number, LogLevel> = {\n\t0: \"TRACE\",\n\t1: \"DEBUG\",\n\t2: \"INFO\",\n\t3: \"WARN\",\n\t4: \"ERROR\",\n\t5: \"CRITICAL\",\n};\n\nexport type LevelIndex = number;\n","import { type LogLevel, LogLevels } from \"./log-levels\";\n\nconst LOG_LEVEL_COLORS: Record<number, string> = {\n\t[LogLevels.CRITICAL]: \"\\x1b[31m\", // Red\n\t[LogLevels.ERROR]: \"\\x1b[31m\", // Red\n\t[LogLevels.WARN]: \"\\x1b[33m\", // Yellow\n\t[LogLevels.INFO]: \"\\x1b[32m\", // Green\n\t[LogLevels.DEBUG]: \"\\x1b[36m\", // Cyan\n\t[LogLevels.TRACE]: \"\\x1b[36m\", // Cyan\n};\n\nconst RESET_COLOR = \"\\x1b[0m\";\n\n/**\n * Serializes logfmt line from an object.\n *\n * ## Styling Methodology\n *\n * The three things you need to know for every log line is the level, the\n * message, and who called it. These properties are highlighted in different colros\n * and sorted in th eorder that you usually read them.\n *\n * Once you've found a log line you care about, then you want to find the\n * property you need to see. The property names are bolded and the default color\n * while the rest of the data is dim. This lets you scan to find the property\n * name quickly then look closer to read the data associated with the\n * property.\n */\nexport function stringify(data: any) {\n\tlet line = \"\";\n\tconst entries = Object.entries(data);\n\n\tfor (let i = 0; i < entries.length; i++) {\n\t\tconst [key, valueRaw] = entries[i];\n\n\t\tlet isNull = false;\n\t\tlet valueString: string;\n\t\tif (valueRaw == null) {\n\t\t\tisNull = true;\n\t\t\tvalueString = \"\";\n\t\t} else {\n\t\t\tvalueString = valueRaw.toString();\n\t\t}\n\n\t\t// Clip value unless specifically the error message\n\t\tif (valueString.length > 512 && key !== \"msg\" && key !== \"error\")\n\t\t\tvalueString = `${valueString.slice(0, 512)}...`;\n\n\t\tconst needsQuoting =\n\t\t\tvalueString.indexOf(\" \") > -1 || valueString.indexOf(\"=\") > -1;\n\t\tconst needsEscaping =\n\t\t\tvalueString.indexOf('\"') > -1 || valueString.indexOf(\"\\\\\") > -1;\n\n\t\tvalueString = valueString.replace(/\\n/g, \"\\\\n\");\n\t\tif (needsEscaping) valueString = valueString.replace(/[\"\\\\]/g, \"\\\\$&\");\n\t\tif (needsQuoting || needsEscaping) valueString = `\"${valueString}\"`;\n\t\tif (valueString === \"\" && !isNull) valueString = '\"\"';\n\n\t\tif (LOGGER_CONFIG.enableColor) {\n\t\t\t// With color\n\n\t\t\t// Special message colors\n\t\t\tlet color = \"\\x1b[2m\";\n\t\t\tif (key === \"level\") {\n\t\t\t\tconst level = LogLevels[valueString as LogLevel];\n\t\t\t\tconst levelColor = LOG_LEVEL_COLORS[level];\n\t\t\t\tif (levelColor) {\n\t\t\t\t\tcolor = levelColor;\n\t\t\t\t}\n\t\t\t} else if (key === \"msg\") {\n\t\t\t\tcolor = \"\\x1b[32m\";\n\t\t\t} else if (key === \"trace\") {\n\t\t\t\tcolor = \"\\x1b[34m\";\n\t\t\t}\n\n\t\t\t// Format line\n\t\t\tline += `\\x1b[0m\\x1b[1m${key}\\x1b[0m\\x1b[2m=\\x1b[0m${color}${valueString}${RESET_COLOR}`;\n\t\t} else {\n\t\t\t// No color\n\t\t\tline += `${key}=${valueString}`;\n\t\t}\n\n\t\tif (i !== entries.length - 1) {\n\t\t\tline += \" \";\n\t\t}\n\t}\n\n\treturn line;\n}\n\nexport function formatTimestamp(date: Date): string {\n\tconst year = date.getUTCFullYear();\n\tconst month = String(date.getUTCMonth() + 1).padStart(2, \"0\");\n\tconst day = String(date.getUTCDate()).padStart(2, \"0\");\n\tconst hours = String(date.getUTCHours()).padStart(2, \"0\");\n\tconst minutes = String(date.getUTCMinutes()).padStart(2, \"0\");\n\tconst seconds = String(date.getUTCSeconds()).padStart(2, \"0\");\n\tconst milliseconds = String(date.getUTCMilliseconds()).padStart(3, \"0\");\n\n\treturn `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}Z`;\n}\n\nexport function castToLogValue(v: unknown): any {\n\tif (\n\t\ttypeof v === \"string\" ||\n\t\ttypeof v === \"number\" ||\n\t\ttypeof v === \"bigint\" ||\n\t\ttypeof v === \"boolean\" ||\n\t\tv === null ||\n\t\tv === undefined\n\t) {\n\t\treturn v;\n\t}\n\tif (v instanceof Error) {\n\t\t//args.push(...errorToLogEntries(k, v));\n\t\treturn String(v);\n\t}\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch {\n\t\treturn \"[cannot stringify]\";\n\t}\n}\n\n// MARK: Config\ninterface GlobalLoggerConfig {\n\tenableColor: boolean;\n\tenableSpreadObject: boolean;\n\tenableErrorStack: boolean;\n}\n\nexport const LOGGER_CONFIG: GlobalLoggerConfig = {\n\tenableColor: false,\n\tenableSpreadObject: false,\n\tenableErrorStack: false,\n};\n\n// MARK: Utils\n/**\n * Converts an object in to an easier to read KV of entries.\n */\nexport function spreadObjectToLogEntries(base: string, data: unknown): any {\n\tif (\n\t\tLOGGER_CONFIG.enableSpreadObject &&\n\t\ttypeof data === \"object\" &&\n\t\t!Array.isArray(data) &&\n\t\tdata !== null &&\n\t\tObject.keys(data).length !== 0 &&\n\t\tObject.keys(data).length < 16\n\t) {\n\t\tconst logData: any = {};\n\t\tfor (const key in data) {\n\t\t\tObject.assign(\n\t\t\t\tlogData,\n\t\t\t\tspreadObjectToLogEntries(\n\t\t\t\t\t`${base}.${key}`,\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: FIXME\n\t\t\t\t\t(data as any)[key],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn logData;\n\t}\n\n\treturn { [base]: JSON.stringify(data) };\n}\n\nexport function errorToLogEntries(base: string, error: unknown): any {\n\tif (error instanceof Error) {\n\t\treturn {\n\t\t\t[`${base}.message`]: error.message,\n\t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n\t\t\t\t? { [`${base}.stack`]: formatStackTrace(error.stack) }\n\t\t\t\t: {}),\n\t\t\t...(error.cause\n\t\t\t\t? errorToLogEntries(`${base}.cause`, error.cause)\n\t\t\t\t: {}),\n\t\t};\n\t}\n\treturn { [base]: `${error}` };\n}\n\n// export function errorToLogEntries(base: string, error: unknown): LogEntry[] {\n// \tif (error instanceof RuntimeError) {\n// \t\treturn [\n// \t\t\t[`${base}.code`, error.code],\n// \t\t\t[`${base}.description`, error.errorConfig?.description],\n// \t\t\t[`${base}.module`, error.moduleName],\n// \t\t\t...(error.trace ? [[`${base}.trace`, stringifyTrace(error.trace)] as LogEntry] : []),\n// \t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n// \t\t\t\t? [[`${base}.stack`, formatStackTrace(error.stack)] as LogEntry]\n// \t\t\t\t: []),\n// \t\t\t...(error.meta ? [[`${base}.meta`, JSON.stringify(error.meta)] as LogEntry] : []),\n// \t\t\t...(error.cause ? errorToLogEntries(`${base}.cause`, error.cause) : []),\n// \t\t];\n// \t} else if (error instanceof Error) {\n// \t\treturn [\n// \t\t\t[`${base}.name`, error.name],\n// \t\t\t[`${base}.message`, error.message],\n// \t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n// \t\t\t\t? [[`${base}.stack`, formatStackTrace(error.stack)] as LogEntry]\n// \t\t\t\t: []),\n// \t\t\t...(error.cause ? errorToLogEntries(`${base}.cause`, error.cause) : []),\n// \t\t];\n// \t} else {\n// \t\treturn [\n// \t\t\t[base, `${error}`],\n// \t\t];\n// \t}\n// }\n\n/**\n * Formats a JS stack trace in to a legible one-liner.\n */\nfunction formatStackTrace(stackTrace: string): string {\n\tconst regex = /at (.+?)$/gm;\n\tconst matches = [...stackTrace.matchAll(regex)];\n\t// Reverse array since the stack goes from top level -> bottom level\n\tmatches.reverse();\n\treturn matches.map((match) => match[1].trim()).join(\" > \");\n}\n","import { stringifyError } from \"@/common/utils\";\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\nimport { stringify as uuidstringify } from \"uuid\";\nimport pkgJson from \"../package.json\" with { type: \"json\" };\nimport { getLogger } from \"./common/log\";\nimport { assertUnreachable } from \"./common/utils\";\n\n/** @experimental */\nexport { stringifyError };\n\n/** @experimental */\nexport { assertUnreachable };\n\n/**\n * Joins multiple abort signals into one.\n *\n * The returned signal aborts when the first input signal aborts.\n * Uses `AbortSignal.any(...)` when available, with a runtime fallback.\n *\n * @experimental\n */\nexport function joinSignals(\n\t...signals: Array<AbortSignal | undefined | null>\n): AbortSignal {\n\tconst validSignals = signals.filter(\n\t\t(signal): signal is AbortSignal => signal != null,\n\t);\n\n\tif (validSignals.length === 0) {\n\t\treturn new AbortController().signal;\n\t}\n\n\tif (validSignals.length === 1) {\n\t\treturn validSignals[0];\n\t}\n\n\tconst signalAny = (\n\t\tAbortSignal as typeof AbortSignal & {\n\t\t\tany?: (signals: AbortSignal[]) => AbortSignal;\n\t\t}\n\t).any;\n\tif (typeof signalAny === \"function\") {\n\t\treturn signalAny(validSignals);\n\t}\n\n\tconst controller = new AbortController();\n\tconst cleanups: Array<() => void> = [];\n\n\tconst abortWithSignal = (signal: AbortSignal) => {\n\t\tif (controller.signal.aborted) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const cleanup of cleanups) {\n\t\t\tcleanup();\n\t\t}\n\n\t\tconst reason = (signal as AbortSignal & { reason?: unknown }).reason;\n\t\tcontroller.abort(reason);\n\t};\n\n\tfor (const signal of validSignals) {\n\t\tif (signal.aborted) {\n\t\t\tabortWithSignal(signal);\n\t\t\tbreak;\n\t\t}\n\n\t\tconst onAbort = () => abortWithSignal(signal);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tcleanups.push(() => signal.removeEventListener(\"abort\", onAbort));\n\t}\n\n\treturn controller.signal;\n}\n\n/**\n * Returns a promise that resolves after the given number of milliseconds.\n *\n * @experimental\n */\nexport function sleep(ms: number): Promise<void> {\n\treturn new Promise<void>((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Creates a fixed-rate interval tick function that can be awaited in a loop.\n *\n * @example\n * const tick = interval(100);\n * while (!c.aborted) {\n * await tick();\n * if (c.aborted) break;\n * // ... game logic\n * }\n *\n * @experimental\n */\nexport function interval(ms: number): () => Promise<void> {\n\treturn () => sleep(ms);\n}\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nfunction logger() {\n\treturn getLogger(\"utils\");\n}\n\n/**\n * Builds the HTTP user agent used by this library.\n *\n * @experimental\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 =\n\t\ttypeof 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\n/**\n * Reads an environment variable from Deno or Node runtimes.\n *\n * @experimental\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\n/**\n * Traces a debug value and returns it.\n *\n * @experimental\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 *\n * @experimental\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(\n\t\t\t\tdata.byteOffset,\n\t\t\t\tdata.byteOffset + data.byteLength,\n\t\t\t),\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 *\n * @experimental\n */\nexport function promiseWithResolvers<T>(onReject: (reason?: any) => void): {\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\tpromise.catch(onReject);\n\treturn { promise, resolve, reject };\n}\n\n/**\n * Sets a timeout that supports delays larger than the JavaScript timer limit.\n *\n * @experimental\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>((reason) => logger().warn({ msg: \"unhandled single promise queue rejection\", reason }));\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\t// Notify all waiters for this cycle\n\t\t\t\t\tresolver?.resolve();\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogger().error({\n\t\t\t\t\t\tmsg: \"error in SinglePromiseQueue drain loop\",\n\t\t\t\t\t\terror: stringifyError(err),\n\t\t\t\t\t});\n\t\t\t\t\t// Reject all waiters for this cycle\n\t\t\t\t\tresolver?.reject(err);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Converts a Buffer or Uint8Array into an ArrayBuffer view.\n *\n * @experimental\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 *\n * @experimental\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\n/**\n * Compares two ArrayBuffer values by byte content.\n *\n * @experimental\n */\nexport function arrayBuffersEqual(\n\tbuf1: ArrayBuffer,\n\tbuf2: ArrayBuffer,\n): boolean {\n\tif (buf1.byteLength !== buf2.byteLength) return false;\n\n\tconst view1 = new Uint8Array(buf1);\n\tconst view2 = new Uint8Array(buf2);\n\n\tfor (let i = 0; i < view1.length; i++) {\n\t\tif (view1[i] !== view2[i]) return false;\n\t}\n\treturn true;\n}\n\nexport const EXTRA_ERROR_LOG = {\n\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\tsupport: \"https://rivet.dev/discord\",\n\tversion: VERSION,\n};\n\nexport type Runtime = \"deno\" | \"bun\" | \"node\";\n\n/**\n * Detects the current JavaScript runtime from the user agent.\n *\n * @experimental\n */\nexport function detectRuntime(): Runtime {\n\tconst userAgent =\n\t\ttypeof navigator !== \"undefined\" ? navigator.userAgent : \"\";\n\tif (userAgent.includes(\"Deno\")) {\n\t\treturn \"deno\";\n\t}\n\tif (userAgent.includes(\"Bun\")) {\n\t\treturn \"bun\";\n\t}\n\treturn \"node\";\n}\n\nexport type DeepReadonly<T> = {\n\treadonly [K in keyof T]: T[K] extends object ? De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O;AAAA,EACnC;AACA,SAAO;AACR;AAEO,IAAM,kBAAkB;AAAA,EAC9B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAASA;AACV;AASO,SAAS,gBAAyB;AACxC,QAAM,YACL,OAAO,cAAc,cAAc,UAAU,YAAY;AAC1D,MAAI,UAAU,SAAS,MAAM,GAAG;AAC/B,WAAO;AAAA,EACR;AACA,MAAI,UAAU,SAAS,KAAK,GAAG;AAC9B,WAAO;AAAA,EACR;AACA,SAAO;AACR;","names":["logger","logger","VERSION"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/env-vars.ts","../../src/common/utils.ts","../../package.json","../../src/common/log.ts","../../src/common/log-levels.ts","../../src/common/logfmt.ts","../../src/utils.ts"],"sourcesContent":["// This file consolidates all environment variables that affect RivetKit's behavior.\n//\n// IMPORTANT: When adding or modifying environment variables here, also update the\n// documentation at: website/src/content/docs/general/environment-variables.mdx\n\nimport { getEnvUniversal } from \"@/utils\";\n\n// Rivet configuration\nexport const getRivetEngine = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_ENGINE\");\nexport const getRivetEndpoint = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_ENDPOINT\");\nexport const getRivetToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_TOKEN\");\nexport const getRivetNamespace = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_NAMESPACE\");\nexport const getRivetRunner = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER\");\nexport const getRivetTotalSlots = (): number | undefined => {\n\tconst value = getEnvUniversal(\"RIVET_TOTAL_SLOTS\");\n\treturn value !== undefined ? parseInt(value, 10) : undefined;\n};\nexport const getRivetRunnerKey = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER_KEY\");\nexport const getRivetRunEngine = (): boolean =>\n\tgetEnvUniversal(\"RIVET_RUN_ENGINE\") === \"1\";\nexport const getRivetRunEngineVersion = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUN_ENGINE_VERSION\");\nexport const getRivetRunnerKind = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_RUNNER_KIND\");\nexport const getRivetRunnerVersion = (): number | undefined => {\n\tconst value = getEnvUniversal(\"RIVET_RUNNER_VERSION\");\n\treturn value !== undefined ? parseInt(value, 10) : undefined;\n};\nexport const getRivetPublicEndpoint = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_PUBLIC_ENDPOINT\");\nexport const getRivetPublicToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_PUBLIC_TOKEN\");\n// There is no RIVET_PUBLIC_NAMESPACE because the frontend and backend cannot\n// use different namespaces\n\n// RivetKit configuration\nexport const getRivetkitInspectorToken = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_INSPECTOR_TOKEN\");\nexport const getRivetkitInspectorDisable = (): boolean =>\n\tgetEnvUniversal(\"RIVET_INSPECTOR_DISABLE\") === \"1\";\nexport const getRivetkitStoragePath = (): string | undefined =>\n\tgetEnvUniversal(\"RIVETKIT_STORAGE_PATH\");\n\n// Logging configuration\n// DEPRECATED: LOG_LEVEL will be removed in a future version\nexport const getLogLevel = (): string | undefined =>\n\tgetEnvUniversal(\"RIVET_LOG_LEVEL\") ?? getEnvUniversal(\"LOG_LEVEL\");\nexport const getLogTarget = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_TARGET\") === \"1\";\nexport const getLogTimestamp = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_TIMESTAMP\") === \"1\";\nexport const getLogMessage = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_MESSAGE\") === \"1\";\nexport const getLogErrorStack = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_ERROR_STACK\") === \"1\";\nexport const getLogHeaders = (): boolean =>\n\tgetEnvUniversal(\"RIVET_LOG_HEADERS\") === \"1\";\n\n// Environment configuration\nexport const getNodeEnv = (): string | undefined => getEnvUniversal(\"NODE_ENV\");\nexport const getNextPhase = (): string | undefined =>\n\tgetEnvUniversal(\"NEXT_PHASE\");\nexport const isDev = (): boolean => getNodeEnv() !== \"production\";\n\n// Experimental\n/**\n * Enables experimental OTel tracing for Rivet Actors.\n *\n * When disabled, actors use an in-memory no-op traces implementation.\n */\nexport const getRivetExperimentalOtel = (): boolean =>\n\tgetEnvUniversal(\"RIVET_EXPERIMENTAL_OTEL\") === \"1\";\n","import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { EXTRA_ERROR_LOG, VERSION } from \"@/utils\";\nimport { getLogErrorStack } from \"@/utils/env-vars\";\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\"\n\t\t\t\t? value.length\n\t\t\t\t: JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(\n\t\t\t\t`JSON object exceeds size limit of ${maxSize} bytes.`,\n\t\t\t);\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\t...EXTRA_ERROR_LOG,\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\tstack: (error as Error)?.stack,\n\t\t\t\t...EXTRA_ERROR_LOG,\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 = \"rivetkit\";\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\tstack: (error as Error)?.stack,\n\t\t\t\t...EXTRA_ERROR_LOG,\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 = \"rivetkit\";\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\t...EXTRA_ERROR_LOG,\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\tgetLogErrorStack()\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\t\"name\": \"rivetkit\",\n\t\"version\": \"2.1.3\",\n\t\"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n\t\"license\": \"Apache-2.0\",\n\t\"keywords\": [\n\t\t\"rivetkit\",\n\t\t\"stateful\",\n\t\t\"serverless\",\n\t\t\"actors\",\n\t\t\"agents\",\n\t\t\"realtime\",\n\t\t\"websocket\",\n\t\t\"actors\",\n\t\t\"framework\"\n\t],\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\",\n\t\t\"deno.json\",\n\t\t\"bun.json\",\n\t\t\"package.json\"\n\t],\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./workflow\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/workflow/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/workflow/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/workflow/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/workflow/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./client\": {\n\t\t\t\"import\": {\n\t\t\t\t\"browser\": {\n\t\t\t\t\t\"types\": \"./dist/browser/client.d.ts\",\n\t\t\t\t\t\"default\": \"./dist/browser/client.js\"\n\t\t\t\t},\n\t\t\t\t\"types\": \"./dist/tsup/client/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/client/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/client/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/client/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./log\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/log.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/log.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/log.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/log.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./errors\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/actor/errors.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/actor/errors.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/actor/errors.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/actor/errors.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./utils\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/utils.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/utils.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/utils.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/utils.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-helpers\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-helpers/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-helpers/websocket\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/websocket.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/websocket.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/common/websocket.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/common/websocket.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./driver-test-suite\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./serve-test-suite\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/serve-test-suite/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/serve-test-suite/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/serve-test-suite/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/serve-test-suite/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./topologies/coordinate\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./topologies/partition\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/partition/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./test\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/test/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/test/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/test/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/test/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./inspector\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/inspector/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/inspector/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/inspector/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/inspector/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./inspector/client\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/browser/inspector/client.d.ts\",\n\t\t\t\t\"default\": \"./dist/browser/inspector/client.js\"\n\t\t\t}\n\t\t},\n\t\t\"./db\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/mod.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./db/drizzle\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/drizzle/mod.d.ts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/drizzle/mod.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/tsup/db/drizzle/mod.d.cts\",\n\t\t\t\t\"default\": \"./dist/tsup/db/drizzle/mod.cjs\"\n\t\t\t}\n\t\t}\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=22.0.0\"\n\t},\n\t\"sideEffects\": [\n\t\t\"./dist/tsup/chunk-*.js\",\n\t\t\"./dist/tsup/chunk-*.cjs\"\n\t],\n\t\"scripts\": {\n \t\t\"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/serve-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts src/workflow/mod.ts src/db/mod.ts src/db/drizzle/mod.ts\",\n\t\t\"build:browser\": \"tsup --config tsup.browser.config.ts\",\n\t\t\"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/client-protocol/v2.bare -o dist/schemas/client-protocol/v2.ts && ./scripts/compile-bare.ts compile schemas/client-protocol/v3.bare -o dist/schemas/client-protocol/v3.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/file-system-driver/v2.bare -o dist/schemas/file-system-driver/v2.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v3.bare -o dist/schemas/file-system-driver/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v2.bare -o dist/schemas/actor-persist/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v3.bare -o dist/schemas/actor-persist/v3.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v4.bare -o dist/schemas/actor-persist/v4.ts && ./scripts/compile-bare.ts compile schemas/persist/v1.bare -o dist/schemas/persist/v1.ts && ./scripts/compile-bare.ts compile schemas/transport/v1.bare -o dist/schemas/transport/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v1.bare -o dist/schemas/actor-inspector/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v2.bare -o dist/schemas/actor-inspector/v2.ts && ./scripts/compile-bare.ts compile schemas/actor-inspector/v3.bare -o dist/schemas/actor-inspector/v3.ts\",\n\t\t\"check-types\": \"tsc --noEmit\",\n\t\t\"lint\": \"biome check .\",\n\t\t\"lint:fix\": \"biome check --write .\",\n\t\t\"format\": \"biome format .\",\n\t\t\"format:write\": \"biome format --write .\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"manager-openapi-gen\": \"tsx scripts/manager-openapi-gen.ts\",\n\t\t\"dump-asyncapi\": \"tsx scripts/dump-asyncapi.ts\",\n\t\t\"registry-config-schema-gen\": \"tsx scripts/registry-config-schema-gen.ts\",\n\t\t\"actor-config-schema-gen\": \"tsx scripts/actor-config-schema-gen.ts\",\n\t\t\"build:pack-inspector\": \"tsx scripts/pack-inspector.ts\"\n\t},\n\t\"dependencies\": {\n\t\t\"@hono/standard-validator\": \"^0.1.3\",\n\t\t\"@hono/zod-openapi\": \"^1.1.5\",\n\t\t\"@rivetkit/bare-ts\": \"^0.6.2\",\n\t\t\"@rivetkit/engine-runner\": \"workspace:*\",\n\t\t\"@rivetkit/fast-json-patch\": \"^3.1.2\",\n\t\t\"@rivetkit/on-change\": \"^6.0.2-rc.1\",\n\t\t\"@rivetkit/sqlite-vfs\": \"workspace:*\",\n\t\t\"@rivetkit/traces\": \"workspace:*\",\n\t\t\"@rivetkit/virtual-websocket\": \"workspace:*\",\n\t\t\"@rivetkit/workflow-engine\": \"workspace:*\",\n\t\t\"cbor-x\": \"^1.6.0\",\n\t\t\"get-port\": \"^7.1.0\",\n\t\t\"hono\": \"^4.7.0\",\n\t\t\"invariant\": \"^2.2.4\",\n\t\t\"nanoevents\": \"^9.1.0\",\n\t\t\"p-retry\": \"^6.2.1\",\n\t\t\"pino\": \"^9.5.0\",\n\t\t\"tar\": \"^7.5.0\",\n\t\t\"uuid\": \"^12.0.0\",\n\t\t\"vbare\": \"^0.0.4\",\n\t\t\"@rivetkit/sqlite\": \"^0.1.1\",\n\t\t\"zod\": \"^4.1.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@bare-ts/tools\": \"^0.13.0\",\n\t\t\"@biomejs/biome\": \"^2.3\",\n\t\t\"@hono/node-server\": \"^1.18.2\",\n\t\t\"@hono/node-ws\": \"^1.1.1\",\n\t\t\"@standard-schema/spec\": \"^1.0.0\",\n\t\t\"@types/invariant\": \"^2\",\n\t\t\"@types/node\": \"^22.13.1\",\n\t\t\"@types/ws\": \"^8\",\n\t\t\"@vitest/ui\": \"3.1.1\",\n\t\t\"cli-table3\": \"^0.6.5\",\n\t\t\"commander\": \"^12.1.0\",\n\t\t\"eventsource\": \"^4.0.0\",\n\t\t\"local-pkg\": \"^0.5.1\",\n\t\t\"tsup\": \"^8.4.0\",\n\t\t\"tsx\": \"^4.19.4\",\n\t\t\"typescript\": \"^5.7.3\",\n\t\t\"vite-tsconfig-paths\": \"^5.1.4\",\n\t\t\"vitest\": \"^3.1.1\",\n\t\t\"ws\": \"^8.18.1\",\n\t\t\"zod-to-json-schema\": \"^3.25.0\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"@hono/node-server\": \"^1.14.0\",\n\t\t\"@hono/node-ws\": \"^1.1.1\",\n\t\t\"drizzle-kit\": \"^0.31.2\",\n\t\t\"drizzle-orm\": \"^0.44.2\",\n\t\t\"eventsource\": \"^4.0.0\",\n\t\t\"ws\": \"^8.0.0\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"@hono/node-server\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"@hono/node-ws\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"drizzle-kit\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"drizzle-orm\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"eventsource\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"ws\": {\n\t\t\t\"optional\": true\n\t\t}\n\t},\n\t\"stableVersion\": \"0.8.0\"\n}\n","import {\n\ttype LevelWithSilent,\n\ttype Logger,\n\tpino,\n\tstdTimeFunctions,\n} from \"pino\";\nimport { z } from \"zod/v4\";\nimport { getLogLevel, getLogTarget, getLogTimestamp } from \"@/utils/env-vars\";\nimport {\n\tcastToLogValue,\n\tformatTimestamp,\n\tLOGGER_CONFIG,\n\tstringify,\n} from \"./logfmt\";\n\nexport type { Logger } from \"pino\";\n\nlet baseLogger: Logger | undefined;\nlet configuredLogLevel: LogLevel | undefined;\n\n/** Cache of child loggers by logger name. */\nconst loggerCache = new Map<string, Logger>();\n\nexport const LogLevelSchema = z.enum([\n\t\"trace\",\n\t\"debug\",\n\t\"info\",\n\t\"warn\",\n\t\"error\",\n\t\"fatal\",\n\t\"silent\",\n]);\n\nexport type LogLevel = z.infer<typeof LogLevelSchema>;\n\nexport function getPinoLevel(logLevel?: LogLevel): LevelWithSilent {\n\t// Priority: provided > configured > env > default\n\tif (logLevel) {\n\t\treturn logLevel;\n\t}\n\n\tif (configuredLogLevel) {\n\t\treturn configuredLogLevel;\n\t}\n\n\tconst raw = (getLogLevel() || \"warn\").toString().toLowerCase();\n\n\tconst parsed = LogLevelSchema.safeParse(raw);\n\tif (parsed.success) {\n\t\treturn parsed.data;\n\t}\n\n\t// Default to info if invalid\n\treturn \"info\";\n}\n\nexport function getIncludeTarget(): boolean {\n\treturn getLogTarget();\n}\n\n/**\n * Configure a custom base logger.\n */\nexport function configureBaseLogger(logger: Logger): void {\n\tbaseLogger = logger;\n\tloggerCache.clear();\n}\n\n// TODO: This can be simplified in logfmt.ts\nfunction customWrite(level: string, o: any) {\n\tconst entries: any = {};\n\n\t// Add timestamp if enabled\n\tif (getLogTimestamp() && o.time) {\n\t\tconst date = typeof o.time === \"number\" ? new Date(o.time) : new Date();\n\t\tentries.ts = formatTimestamp(date);\n\t}\n\n\t// Add level\n\tentries.level = level.toUpperCase();\n\n\t// Add target if present\n\tif (o.target) {\n\t\tentries.target = o.target;\n\t}\n\n\t// Add message\n\tif (o.msg) {\n\t\tentries.msg = o.msg;\n\t}\n\n\t// Add other properties\n\tfor (const [key, value] of Object.entries(o)) {\n\t\tif (\n\t\t\tkey !== \"time\" &&\n\t\t\tkey !== \"level\" &&\n\t\t\tkey !== \"target\" &&\n\t\t\tkey !== \"msg\" &&\n\t\t\tkey !== \"pid\" &&\n\t\t\tkey !== \"hostname\"\n\t\t) {\n\t\t\tentries[key] = castToLogValue(value);\n\t\t}\n\t}\n\n\tconst output = stringify(entries);\n\tconsole.log(output);\n}\n\n/**\n * Configure the default logger with optional log level.\n */\nexport function configureDefaultLogger(logLevel?: LogLevel) {\n\t// Store the configured log level\n\tif (logLevel) {\n\t\tconfiguredLogLevel = logLevel;\n\t}\n\n\tbaseLogger = pino({\n\t\tlevel: getPinoLevel(logLevel),\n\t\tmessageKey: \"msg\",\n\t\t// Do not include pid/hostname in output\n\t\tbase: {},\n\t\t// Keep a string level in the output\n\t\tformatters: {\n\t\t\tlevel(_label: string, number: number) {\n\t\t\t\treturn { level: number };\n\t\t\t},\n\t\t},\n\t\ttimestamp: getLogTimestamp() ? stdTimeFunctions.epochTime : false,\n\t\tbrowser: {\n\t\t\twrite: {\n\t\t\t\tfatal: customWrite.bind(null, \"fatal\"),\n\t\t\t\terror: customWrite.bind(null, \"error\"),\n\t\t\t\twarn: customWrite.bind(null, \"warn\"),\n\t\t\t\tinfo: customWrite.bind(null, \"info\"),\n\t\t\t\tdebug: customWrite.bind(null, \"debug\"),\n\t\t\t\ttrace: customWrite.bind(null, \"trace\"),\n\t\t\t},\n\t\t},\n\t\thooks: {\n\t\t\tlogMethod(inputArgs, method, level) {\n\t\t\t\t// TODO: This is a hack to not implement our own Pino transport target. We can get better perf if we have our own transport target.\n\n\t\t\t\tconst levelMap: Record<number, string> = {\n\t\t\t\t\t10: \"trace\",\n\t\t\t\t\t20: \"debug\",\n\t\t\t\t\t30: \"info\",\n\t\t\t\t\t40: \"warn\",\n\t\t\t\t\t50: \"error\",\n\t\t\t\t\t60: \"fatal\",\n\t\t\t\t};\n\t\t\t\tconst levelName = levelMap[level] || \"info\";\n\t\t\t\tconst time = getLogTimestamp() ? Date.now() : undefined;\n\n\t\t\t\t// Get bindings from the logger instance (child logger fields)\n\t\t\t\tconst bindings = (this as any).bindings?.() || {};\n\n\t\t\t\t// TODO: This can be simplified in logfmt.ts\n\t\t\t\tif (inputArgs.length >= 2) {\n\t\t\t\t\tconst [objOrMsg, msg] = inputArgs;\n\t\t\t\t\tif (typeof objOrMsg === \"object\" && objOrMsg !== null) {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\t...objOrMsg,\n\t\t\t\t\t\t\tmsg,\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\tmsg: String(objOrMsg),\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else if (inputArgs.length === 1) {\n\t\t\t\t\tconst [objOrMsg] = inputArgs;\n\t\t\t\t\tif (typeof objOrMsg === \"object\" && objOrMsg !== null) {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\t...objOrMsg,\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcustomWrite(levelName, {\n\t\t\t\t\t\t\t...bindings,\n\t\t\t\t\t\t\tmsg: String(objOrMsg),\n\t\t\t\t\t\t\ttime,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t});\n\n\tloggerCache.clear();\n}\n\n/**\n * Get or initialize the base logger.\n */\nexport function getBaseLogger(): Logger {\n\tif (!baseLogger) {\n\t\tconfigureDefaultLogger();\n\t}\n\treturn baseLogger!;\n}\n\n/**\n * Returns a child logger with `target` bound for the given name.\n */\nexport function getLogger(name = \"default\"): Logger {\n\t// Check cache first\n\tconst cached = loggerCache.get(name);\n\tif (cached) {\n\t\treturn cached;\n\t}\n\n\t// Create\n\tconst base = getBaseLogger();\n\n\t// Add target to log if enabled\n\tconst child = getIncludeTarget() ? base.child({ target: name }) : base;\n\n\t// Cache the logger\n\tloggerCache.set(name, child);\n\n\treturn child;\n}\n","export type LogLevel =\n\t| \"TRACE\"\n\t| \"DEBUG\"\n\t| \"INFO\"\n\t| \"WARN\"\n\t| \"ERROR\"\n\t| \"CRITICAL\";\n\nexport const LogLevels: Record<LogLevel, LevelIndex> = {\n\tTRACE: 0,\n\tDEBUG: 1,\n\tINFO: 2,\n\tWARN: 3,\n\tERROR: 4,\n\tCRITICAL: 5,\n} as const;\n\nexport const LevelNameMap: Record<number, LogLevel> = {\n\t0: \"TRACE\",\n\t1: \"DEBUG\",\n\t2: \"INFO\",\n\t3: \"WARN\",\n\t4: \"ERROR\",\n\t5: \"CRITICAL\",\n};\n\nexport type LevelIndex = number;\n","import { type LogLevel, LogLevels } from \"./log-levels\";\n\nconst LOG_LEVEL_COLORS: Record<number, string> = {\n\t[LogLevels.CRITICAL]: \"\\x1b[31m\", // Red\n\t[LogLevels.ERROR]: \"\\x1b[31m\", // Red\n\t[LogLevels.WARN]: \"\\x1b[33m\", // Yellow\n\t[LogLevels.INFO]: \"\\x1b[32m\", // Green\n\t[LogLevels.DEBUG]: \"\\x1b[36m\", // Cyan\n\t[LogLevels.TRACE]: \"\\x1b[36m\", // Cyan\n};\n\nconst RESET_COLOR = \"\\x1b[0m\";\n\n/**\n * Serializes logfmt line from an object.\n *\n * ## Styling Methodology\n *\n * The three things you need to know for every log line is the level, the\n * message, and who called it. These properties are highlighted in different colros\n * and sorted in th eorder that you usually read them.\n *\n * Once you've found a log line you care about, then you want to find the\n * property you need to see. The property names are bolded and the default color\n * while the rest of the data is dim. This lets you scan to find the property\n * name quickly then look closer to read the data associated with the\n * property.\n */\nexport function stringify(data: any) {\n\tlet line = \"\";\n\tconst entries = Object.entries(data);\n\n\tfor (let i = 0; i < entries.length; i++) {\n\t\tconst [key, valueRaw] = entries[i];\n\n\t\tlet isNull = false;\n\t\tlet valueString: string;\n\t\tif (valueRaw == null) {\n\t\t\tisNull = true;\n\t\t\tvalueString = \"\";\n\t\t} else {\n\t\t\tvalueString = valueRaw.toString();\n\t\t}\n\n\t\t// Clip value unless specifically the error message\n\t\tif (valueString.length > 512 && key !== \"msg\" && key !== \"error\")\n\t\t\tvalueString = `${valueString.slice(0, 512)}...`;\n\n\t\tconst needsQuoting =\n\t\t\tvalueString.indexOf(\" \") > -1 || valueString.indexOf(\"=\") > -1;\n\t\tconst needsEscaping =\n\t\t\tvalueString.indexOf('\"') > -1 || valueString.indexOf(\"\\\\\") > -1;\n\n\t\tvalueString = valueString.replace(/\\n/g, \"\\\\n\");\n\t\tif (needsEscaping) valueString = valueString.replace(/[\"\\\\]/g, \"\\\\$&\");\n\t\tif (needsQuoting || needsEscaping) valueString = `\"${valueString}\"`;\n\t\tif (valueString === \"\" && !isNull) valueString = '\"\"';\n\n\t\tif (LOGGER_CONFIG.enableColor) {\n\t\t\t// With color\n\n\t\t\t// Special message colors\n\t\t\tlet color = \"\\x1b[2m\";\n\t\t\tif (key === \"level\") {\n\t\t\t\tconst level = LogLevels[valueString as LogLevel];\n\t\t\t\tconst levelColor = LOG_LEVEL_COLORS[level];\n\t\t\t\tif (levelColor) {\n\t\t\t\t\tcolor = levelColor;\n\t\t\t\t}\n\t\t\t} else if (key === \"msg\") {\n\t\t\t\tcolor = \"\\x1b[32m\";\n\t\t\t} else if (key === \"trace\") {\n\t\t\t\tcolor = \"\\x1b[34m\";\n\t\t\t}\n\n\t\t\t// Format line\n\t\t\tline += `\\x1b[0m\\x1b[1m${key}\\x1b[0m\\x1b[2m=\\x1b[0m${color}${valueString}${RESET_COLOR}`;\n\t\t} else {\n\t\t\t// No color\n\t\t\tline += `${key}=${valueString}`;\n\t\t}\n\n\t\tif (i !== entries.length - 1) {\n\t\t\tline += \" \";\n\t\t}\n\t}\n\n\treturn line;\n}\n\nexport function formatTimestamp(date: Date): string {\n\tconst year = date.getUTCFullYear();\n\tconst month = String(date.getUTCMonth() + 1).padStart(2, \"0\");\n\tconst day = String(date.getUTCDate()).padStart(2, \"0\");\n\tconst hours = String(date.getUTCHours()).padStart(2, \"0\");\n\tconst minutes = String(date.getUTCMinutes()).padStart(2, \"0\");\n\tconst seconds = String(date.getUTCSeconds()).padStart(2, \"0\");\n\tconst milliseconds = String(date.getUTCMilliseconds()).padStart(3, \"0\");\n\n\treturn `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}Z`;\n}\n\nexport function castToLogValue(v: unknown): any {\n\tif (\n\t\ttypeof v === \"string\" ||\n\t\ttypeof v === \"number\" ||\n\t\ttypeof v === \"bigint\" ||\n\t\ttypeof v === \"boolean\" ||\n\t\tv === null ||\n\t\tv === undefined\n\t) {\n\t\treturn v;\n\t}\n\tif (v instanceof Error) {\n\t\t//args.push(...errorToLogEntries(k, v));\n\t\treturn String(v);\n\t}\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch {\n\t\treturn \"[cannot stringify]\";\n\t}\n}\n\n// MARK: Config\ninterface GlobalLoggerConfig {\n\tenableColor: boolean;\n\tenableSpreadObject: boolean;\n\tenableErrorStack: boolean;\n}\n\nexport const LOGGER_CONFIG: GlobalLoggerConfig = {\n\tenableColor: false,\n\tenableSpreadObject: false,\n\tenableErrorStack: false,\n};\n\n// MARK: Utils\n/**\n * Converts an object in to an easier to read KV of entries.\n */\nexport function spreadObjectToLogEntries(base: string, data: unknown): any {\n\tif (\n\t\tLOGGER_CONFIG.enableSpreadObject &&\n\t\ttypeof data === \"object\" &&\n\t\t!Array.isArray(data) &&\n\t\tdata !== null &&\n\t\tObject.keys(data).length !== 0 &&\n\t\tObject.keys(data).length < 16\n\t) {\n\t\tconst logData: any = {};\n\t\tfor (const key in data) {\n\t\t\tObject.assign(\n\t\t\t\tlogData,\n\t\t\t\tspreadObjectToLogEntries(\n\t\t\t\t\t`${base}.${key}`,\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: FIXME\n\t\t\t\t\t(data as any)[key],\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn logData;\n\t}\n\n\treturn { [base]: JSON.stringify(data) };\n}\n\nexport function errorToLogEntries(base: string, error: unknown): any {\n\tif (error instanceof Error) {\n\t\treturn {\n\t\t\t[`${base}.message`]: error.message,\n\t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n\t\t\t\t? { [`${base}.stack`]: formatStackTrace(error.stack) }\n\t\t\t\t: {}),\n\t\t\t...(error.cause\n\t\t\t\t? errorToLogEntries(`${base}.cause`, error.cause)\n\t\t\t\t: {}),\n\t\t};\n\t}\n\treturn { [base]: `${error}` };\n}\n\n// export function errorToLogEntries(base: string, error: unknown): LogEntry[] {\n// \tif (error instanceof RuntimeError) {\n// \t\treturn [\n// \t\t\t[`${base}.code`, error.code],\n// \t\t\t[`${base}.description`, error.errorConfig?.description],\n// \t\t\t[`${base}.module`, error.moduleName],\n// \t\t\t...(error.trace ? [[`${base}.trace`, stringifyTrace(error.trace)] as LogEntry] : []),\n// \t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n// \t\t\t\t? [[`${base}.stack`, formatStackTrace(error.stack)] as LogEntry]\n// \t\t\t\t: []),\n// \t\t\t...(error.meta ? [[`${base}.meta`, JSON.stringify(error.meta)] as LogEntry] : []),\n// \t\t\t...(error.cause ? errorToLogEntries(`${base}.cause`, error.cause) : []),\n// \t\t];\n// \t} else if (error instanceof Error) {\n// \t\treturn [\n// \t\t\t[`${base}.name`, error.name],\n// \t\t\t[`${base}.message`, error.message],\n// \t\t\t...(LOGGER_CONFIG.enableErrorStack && error.stack\n// \t\t\t\t? [[`${base}.stack`, formatStackTrace(error.stack)] as LogEntry]\n// \t\t\t\t: []),\n// \t\t\t...(error.cause ? errorToLogEntries(`${base}.cause`, error.cause) : []),\n// \t\t];\n// \t} else {\n// \t\treturn [\n// \t\t\t[base, `${error}`],\n// \t\t];\n// \t}\n// }\n\n/**\n * Formats a JS stack trace in to a legible one-liner.\n */\nfunction formatStackTrace(stackTrace: string): string {\n\tconst regex = /at (.+?)$/gm;\n\tconst matches = [...stackTrace.matchAll(regex)];\n\t// Reverse array since the stack goes from top level -> bottom level\n\tmatches.reverse();\n\treturn matches.map((match) => match[1].trim()).join(\" > \");\n}\n","import { stringifyError } from \"@/common/utils\";\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\nimport { stringify as uuidstringify } from \"uuid\";\nimport pkgJson from \"../package.json\" with { type: \"json\" };\nimport { getLogger } from \"./common/log\";\nimport { assertUnreachable } from \"./common/utils\";\n\n/** @experimental */\nexport { stringifyError };\n\n/** @experimental */\nexport { assertUnreachable };\n\n/**\n * Joins multiple abort signals into one.\n *\n * The returned signal aborts when the first input signal aborts.\n * Uses `AbortSignal.any(...)` when available, with a runtime fallback.\n *\n * @experimental\n */\nexport function joinSignals(\n\t...signals: Array<AbortSignal | undefined | null>\n): AbortSignal {\n\tconst validSignals = signals.filter(\n\t\t(signal): signal is AbortSignal => signal != null,\n\t);\n\n\tif (validSignals.length === 0) {\n\t\treturn new AbortController().signal;\n\t}\n\n\tif (validSignals.length === 1) {\n\t\treturn validSignals[0];\n\t}\n\n\tconst signalAny = (\n\t\tAbortSignal as typeof AbortSignal & {\n\t\t\tany?: (signals: AbortSignal[]) => AbortSignal;\n\t\t}\n\t).any;\n\tif (typeof signalAny === \"function\") {\n\t\treturn signalAny(validSignals);\n\t}\n\n\tconst controller = new AbortController();\n\tconst cleanups: Array<() => void> = [];\n\n\tconst abortWithSignal = (signal: AbortSignal) => {\n\t\tif (controller.signal.aborted) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const cleanup of cleanups) {\n\t\t\tcleanup();\n\t\t}\n\n\t\tconst reason = (signal as AbortSignal & { reason?: unknown }).reason;\n\t\tcontroller.abort(reason);\n\t};\n\n\tfor (const signal of validSignals) {\n\t\tif (signal.aborted) {\n\t\t\tabortWithSignal(signal);\n\t\t\tbreak;\n\t\t}\n\n\t\tconst onAbort = () => abortWithSignal(signal);\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tcleanups.push(() => signal.removeEventListener(\"abort\", onAbort));\n\t}\n\n\treturn controller.signal;\n}\n\n/**\n * Returns a promise that resolves after the given number of milliseconds.\n *\n * @experimental\n */\nexport function sleep(ms: number): Promise<void> {\n\treturn new Promise<void>((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Creates a fixed-rate interval tick function that can be awaited in a loop.\n *\n * @example\n * const tick = interval(100);\n * while (!c.aborted) {\n * await tick();\n * if (c.aborted) break;\n * // ... game logic\n * }\n *\n * @experimental\n */\nexport function interval(ms: number): () => Promise<void> {\n\treturn () => sleep(ms);\n}\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nfunction logger() {\n\treturn getLogger(\"utils\");\n}\n\n/**\n * Builds the HTTP user agent used by this library.\n *\n * @experimental\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 =\n\t\ttypeof 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\n/**\n * Reads an environment variable from Deno or Node runtimes.\n *\n * @experimental\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\n/**\n * Traces a debug value and returns it.\n *\n * @experimental\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 *\n * @experimental\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(\n\t\t\t\tdata.byteOffset,\n\t\t\t\tdata.byteOffset + data.byteLength,\n\t\t\t),\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 *\n * @experimental\n */\nexport function promiseWithResolvers<T>(onReject: (reason?: any) => void): {\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\tpromise.catch(onReject);\n\treturn { promise, resolve, reject };\n}\n\n/**\n * Sets a timeout that supports delays larger than the JavaScript timer limit.\n *\n * @experimental\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>((reason) => logger().warn({ msg: \"unhandled single promise queue rejection\", reason }));\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\t// Notify all waiters for this cycle\n\t\t\t\t\tresolver?.resolve();\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogger().error({\n\t\t\t\t\t\tmsg: \"error in SinglePromiseQueue drain loop\",\n\t\t\t\t\t\terror: stringifyError(err),\n\t\t\t\t\t});\n\t\t\t\t\t// Reject all waiters for this cycle\n\t\t\t\t\tresolver?.reject(err);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Converts a Buffer or Uint8Array into an ArrayBuffer view.\n *\n * @experimental\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 *\n * @experimental\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\n/**\n * Compares two ArrayBuffer values by byte content.\n *\n * @experimental\n */\nexport function arrayBuffersEqual(\n\tbuf1: ArrayBuffer,\n\tbuf2: ArrayBuffer,\n): boolean {\n\tif (buf1.byteLength !== buf2.byteLength) return false;\n\n\tconst view1 = new Uint8Array(buf1);\n\tconst view2 = new Uint8Array(buf2);\n\n\tfor (let i = 0; i < view1.length; i++) {\n\t\tif (view1[i] !== view2[i]) return false;\n\t}\n\treturn true;\n}\n\nexport const EXTRA_ERROR_LOG = {\n\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\tsupport: \"https://rivet.dev/discord\",\n\tversion: VERSION,\n};\n\nexport type Runtime = \"deno\" | \"bun\" | \"node\";\n\n/**\n * Detects the current JavaScript runtime from the user agent.\n *\n * @experimental\n */\nexport function detectRuntime(): Runtime {\n\tconst userAgent =\n\t\ttypeof navigator !== \"undefined\" ? navigator.userAgent : \"\";\n\tif (userAgent.includes(\"Deno\")) {\n\t\treturn \"deno\";\n\t}\n\tif (userAgent.includes(\"Bun\")) {\n\t\treturn \"bun\";\n\t}\n\treturn \"node\";\n}\n\nexport type DeepReadonly<T> = {\n\treadonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];\n};\n\nexport type DeepMutable<T> = {\n\t-readonly [K in keyof T]: T[K] extends object ? DeepMutable<T[K]> : T[K];\n};\n"],"mappings":";;;;;;;AAQO,IAAM,iBAAiB,MAC7B,gBAAgB,cAAc;AACxB,IAAM,mBAAmB,MAC/B,gBAAgB,gBAAgB;AAC1B,IAAM,gBAAgB,MAC5B,gBAAgB,aAAa;AACvB,IAAM,oBAAoB,MAChC,gBAAgB,iBAAiB;AAC3B,IAAM,iBAAiB,MAC7B,gBAAgB,cAAc;AACxB,IAAM,qBAAqB,MAA0B;AAC3D,QAAM,QAAQ,gBAAgB,mBAAmB;AACjD,SAAO,UAAU,SAAY,SAAS,OAAO,EAAE,IAAI;AACpD;AACO,IAAM,oBAAoB,MAChC,gBAAgB,kBAAkB;AAC5B,IAAM,oBAAoB,MAChC,gBAAgB,kBAAkB,MAAM;AAClC,IAAM,2BAA2B,MACvC,gBAAgB,0BAA0B;AACpC,IAAM,qBAAqB,MACjC,gBAAgB,mBAAmB;AAC7B,IAAM,wBAAwB,MAA0B;AAC9D,QAAM,QAAQ,gBAAgB,sBAAsB;AACpD,SAAO,UAAU,SAAY,SAAS,OAAO,EAAE,IAAI;A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AG,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;AAOO,SAAS,kBACf,MACA,MACU;AACV,MAAI,KAAK,eAAe,KAAK,WAAY,QAAO;AAEhD,QAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,QAAM,QAAQ,IAAI,WAAW,IAAI;AAEjC,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,EAAG,QAAO;AAAA,EACnC;AACA,SAAO;AACR;AAEO,IAAM,kBAAkB;AAAA,EAC9B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAASA;AACV;AASO,SAAS,gBAAyB;AACxC,QAAM,YACL,OAAO,cAAc,cAAc,UAAU,YAAY;AAC1D,MAAI,UAAU,SAAS,MAAM,GAAG;AAC/B,WAAO;AAAA,EACR;AACA,MAAI,UAAU,SAAS,KAAK,GAAG;AAC9B,WAAO;AAAA,EACR;AACA,SAAO;AACR;","names":["logger","logger","VERSION"]}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ensureDirectoryExists,
|
|
6
6
|
getStoragePath,
|
|
7
7
|
lookupInRegistry
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GNGRMP5E.js";
|
|
9
9
|
import {
|
|
10
10
|
ClientConfigSchemaBase,
|
|
11
11
|
RemoteManagerDriver,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
getEndpoint,
|
|
17
17
|
transformClientConfig,
|
|
18
18
|
updateRunnerConfig
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-N7ASEZ2Y.js";
|
|
20
20
|
import {
|
|
21
21
|
CONN_STATE_MANAGER_SYMBOL,
|
|
22
22
|
ENGINE_ENDPOINT,
|
|
@@ -45,14 +45,14 @@ import {
|
|
|
45
45
|
parseWebSocketProtocols,
|
|
46
46
|
routeWebSocket,
|
|
47
47
|
truncateRawWebSocketPathPrefix
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-QUDLEWGD.js";
|
|
49
49
|
import {
|
|
50
50
|
ActorConfigSchema,
|
|
51
51
|
KEYS,
|
|
52
52
|
event,
|
|
53
53
|
loggerWithoutContext,
|
|
54
54
|
queue
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-MAXIXG56.js";
|
|
56
56
|
import {
|
|
57
57
|
LogLevelSchema,
|
|
58
58
|
VERSION,
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
promiseWithResolvers,
|
|
72
72
|
setLongTimeout,
|
|
73
73
|
stringifyError
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-YET3IZD6.js";
|
|
75
75
|
import {
|
|
76
76
|
EndpointMismatch,
|
|
77
77
|
InvalidRequest,
|
|
@@ -101,6 +101,7 @@ function logger() {
|
|
|
101
101
|
|
|
102
102
|
// src/drivers/engine/actor-driver.ts
|
|
103
103
|
var RUNNER_SSE_PING_INTERVAL = 1e3;
|
|
104
|
+
var RUNNER_STOP_WAIT_MS = 15e3;
|
|
104
105
|
var CONN_MESSAGE_ACK_DEADLINE = 5e3;
|
|
105
106
|
var CONN_BUFFERED_MESSAGE_SIZE_THRESHOLD = 5e5;
|
|
106
107
|
var EngineActorDriver = class {
|
|
@@ -188,6 +189,7 @@ var EngineActorDriver = class {
|
|
|
188
189
|
if (!handler)
|
|
189
190
|
throw new Error(`Actor handler does not exist ${actorId}`);
|
|
190
191
|
if (handler.actorStartPromise) await handler.actorStartPromise.promise;
|
|
192
|
+
if (handler.actorStartError) throw handler.actorStartError;
|
|
191
193
|
if (!handler.actor) throw new Error("Actor should be loaded");
|
|
192
194
|
return handler;
|
|
193
195
|
}
|
|
@@ -249,6 +251,12 @@ var EngineActorDriver = class {
|
|
|
249
251
|
});
|
|
250
252
|
return result;
|
|
251
253
|
}
|
|
254
|
+
/** Creates a SQLite VFS instance for creating KV-backed databases */
|
|
255
|
+
async createSqliteVfs() {
|
|
256
|
+
const specifier = "@rivetkit/sqlite-vfs";
|
|
257
|
+
const { SqliteVfs } = await import(specifier);
|
|
258
|
+
return new SqliteVfs();
|
|
259
|
+
}
|
|
252
260
|
// MARK: - Actor Lifecycle
|
|
253
261
|
async loadActor(actorId) {
|
|
254
262
|
const handler = await this.#loadActorHandler(actorId);
|
|
@@ -285,7 +293,31 @@ var EngineActorDriver = class {
|
|
|
285
293
|
}
|
|
286
294
|
await Promise.all(stopPromises);
|
|
287
295
|
logger().debug({ msg: "all actors stopped" });
|
|
288
|
-
|
|
296
|
+
try {
|
|
297
|
+
await this.#runner.shutdown(immediate);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
300
|
+
if (message.includes("WebSocket connection closed during shutdown")) {
|
|
301
|
+
logger().debug({
|
|
302
|
+
msg: "ignoring shutdown websocket close race",
|
|
303
|
+
error: message
|
|
304
|
+
});
|
|
305
|
+
} else {
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const stopped = await Promise.race([
|
|
310
|
+
this.#runnerStopped.promise.then(() => true),
|
|
311
|
+
new Promise(
|
|
312
|
+
(resolve) => setTimeout(() => resolve(false), RUNNER_STOP_WAIT_MS)
|
|
313
|
+
)
|
|
314
|
+
]);
|
|
315
|
+
if (!stopped) {
|
|
316
|
+
logger().warn({
|
|
317
|
+
msg: "timed out waiting for runner shutdown",
|
|
318
|
+
waitMs: RUNNER_STOP_WAIT_MS
|
|
319
|
+
});
|
|
320
|
+
}
|
|
289
321
|
}
|
|
290
322
|
async serverlessHandleStart(c) {
|
|
291
323
|
return streamSSE(c, async (stream) => {
|
|
@@ -340,6 +372,7 @@ var EngineActorDriver = class {
|
|
|
340
372
|
};
|
|
341
373
|
this.#actors.set(actorId, handler);
|
|
342
374
|
}
|
|
375
|
+
handler.actorStartError = void 0;
|
|
343
376
|
const name = actorConfig.name;
|
|
344
377
|
invariant(actorConfig.key, "actor should have a key");
|
|
345
378
|
const key = deserializeActorKey(actorConfig.key);
|
|
@@ -374,13 +407,30 @@ var EngineActorDriver = class {
|
|
|
374
407
|
);
|
|
375
408
|
logger().debug({ msg: "runner actor started", actorId, name, key });
|
|
376
409
|
} catch (innerError) {
|
|
377
|
-
const error = new Error(
|
|
378
|
-
`Failed to start actor ${actorId}: ${innerError}`,
|
|
410
|
+
const error = innerError instanceof Error ? new Error(
|
|
411
|
+
`Failed to start actor ${actorId}: ${innerError.message}`,
|
|
379
412
|
{ cause: innerError }
|
|
380
|
-
);
|
|
413
|
+
) : new Error(`Failed to start actor ${actorId}: ${String(innerError)}`);
|
|
414
|
+
handler.actor = void 0;
|
|
415
|
+
handler.actorStartError = error;
|
|
381
416
|
(_a = handler.actorStartPromise) == null ? void 0 : _a.reject(error);
|
|
382
417
|
handler.actorStartPromise = void 0;
|
|
383
|
-
|
|
418
|
+
logger().error({
|
|
419
|
+
msg: "runner actor failed to start",
|
|
420
|
+
actorId,
|
|
421
|
+
name,
|
|
422
|
+
key,
|
|
423
|
+
err: stringifyError(error)
|
|
424
|
+
});
|
|
425
|
+
try {
|
|
426
|
+
this.#runner.stopActor(actorId);
|
|
427
|
+
} catch (stopError) {
|
|
428
|
+
logger().debug({
|
|
429
|
+
msg: "failed to stop actor after start failure",
|
|
430
|
+
actorId,
|
|
431
|
+
err: stringifyError(stopError)
|
|
432
|
+
});
|
|
433
|
+
}
|
|
384
434
|
}
|
|
385
435
|
}
|
|
386
436
|
async #runnerOnActorStop(actorId, generation) {
|
|
@@ -388,6 +438,12 @@ var EngineActorDriver = class {
|
|
|
388
438
|
const reason = this.#actorStopIntent.get(actorId) ?? "sleep";
|
|
389
439
|
this.#actorStopIntent.delete(actorId);
|
|
390
440
|
const handler = this.#actors.get(actorId);
|
|
441
|
+
if (handler == null ? void 0 : handler.actorStartPromise) {
|
|
442
|
+
const startError = handler.actorStartError ?? new Error(`Actor ${actorId} stopped before start completed`);
|
|
443
|
+
handler.actorStartError = startError;
|
|
444
|
+
handler.actorStartPromise.reject(startError);
|
|
445
|
+
handler.actorStartPromise = void 0;
|
|
446
|
+
}
|
|
391
447
|
if (handler == null ? void 0 : handler.actor) {
|
|
392
448
|
try {
|
|
393
449
|
await handler.actor.onStop(reason);
|
|
@@ -397,8 +453,8 @@ var EngineActorDriver = class {
|
|
|
397
453
|
err: stringifyError(err)
|
|
398
454
|
});
|
|
399
455
|
}
|
|
400
|
-
this.#actors.delete(actorId);
|
|
401
456
|
}
|
|
457
|
+
if (handler) this.#actors.delete(actorId);
|
|
402
458
|
logger().debug({ msg: "runner actor stopped", actorId, reason });
|
|
403
459
|
}
|
|
404
460
|
// MARK: - Runner Networking
|
|
@@ -645,6 +701,7 @@ var EngineActorDriver = class {
|
|
|
645
701
|
var _a;
|
|
646
702
|
const handler = this.#actors.get(actor2.id);
|
|
647
703
|
invariant(handler, "missing actor handler in onBeforeActorReady");
|
|
704
|
+
handler.actorStartError = void 0;
|
|
648
705
|
(_a = handler.actorStartPromise) == null ? void 0 : _a.resolve();
|
|
649
706
|
handler.actorStartPromise = void 0;
|
|
650
707
|
const metaEntries = await this.#hwsLoadAll(actor2.id);
|
|
@@ -1868,4 +1925,4 @@ export {
|
|
|
1868
1925
|
Registry,
|
|
1869
1926
|
setup
|
|
1870
1927
|
};
|
|
1871
|
-
//# sourceMappingURL=chunk-
|
|
1928
|
+
//# sourceMappingURL=chunk-YLDDENCZ.js.map
|