rivetkit 2.0.13 → 2.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +0 -8
- package/dist/tsup/actor/errors.d.ts +0 -8
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/{chunk-2ALBSAT7.cjs → chunk-3HCSWRUA.cjs} +10 -10
- package/dist/tsup/{chunk-2ALBSAT7.cjs.map → chunk-3HCSWRUA.cjs.map} +1 -1
- package/dist/tsup/{chunk-WFADCZPK.js → chunk-3LGDBNZG.js} +2 -2
- package/dist/tsup/{chunk-E7CPGIQE.js → chunk-43PTNF7W.js} +3 -3
- package/dist/tsup/{chunk-SDB3B7ZO.js → chunk-5C3MRFAU.js} +2 -2
- package/dist/tsup/{chunk-PL46WM3W.cjs → chunk-ATMZDEVA.cjs} +3 -3
- package/dist/tsup/{chunk-PL46WM3W.cjs.map → chunk-ATMZDEVA.cjs.map} +1 -1
- package/dist/tsup/{chunk-HASQHAZF.cjs → chunk-DJDDJDWR.cjs} +12 -12
- package/dist/tsup/{chunk-HASQHAZF.cjs.map → chunk-DJDDJDWR.cjs.map} +1 -1
- package/dist/tsup/{chunk-IZKFTUF7.js → chunk-EY5EMNAB.js} +3 -3
- package/dist/tsup/{chunk-IZKFTUF7.js.map → chunk-EY5EMNAB.js.map} +1 -1
- package/dist/tsup/{chunk-V4GFUBOJ.cjs → chunk-FNCNYJFG.cjs} +3 -3
- package/dist/tsup/{chunk-V4GFUBOJ.cjs.map → chunk-FNCNYJFG.cjs.map} +1 -1
- package/dist/tsup/{chunk-XW5IS7NH.js → chunk-FNQGHSFJ.js} +2 -2
- package/dist/tsup/{chunk-W5AMA5MD.js → chunk-G3R2O5VL.js} +67 -75
- package/dist/tsup/chunk-G3R2O5VL.js.map +1 -0
- package/dist/tsup/{chunk-YPZFLUO6.js → chunk-G64QUEDJ.js} +1 -11
- package/dist/tsup/chunk-G64QUEDJ.js.map +1 -0
- package/dist/tsup/{chunk-QBDLQRFN.cjs → chunk-HNC6Y6JC.cjs} +321 -234
- package/dist/tsup/{chunk-W76ULFDH.js.map → chunk-HNC6Y6JC.cjs.map} +1 -1
- package/dist/tsup/{chunk-YCQL4TJR.js → chunk-HY3MZSKX.js} +4 -4
- package/dist/tsup/{chunk-PKH3YCMG.cjs → chunk-INNBRUPH.cjs} +17 -13
- package/dist/tsup/chunk-INNBRUPH.cjs.map +1 -0
- package/dist/tsup/{chunk-5QGQK44L.cjs → chunk-KSRXX3Z4.cjs} +1 -11
- package/dist/tsup/chunk-KSRXX3Z4.cjs.map +1 -0
- package/dist/tsup/{chunk-4LAWCEKE.cjs → chunk-MF76IOZD.cjs} +7 -7
- package/dist/tsup/{chunk-4LAWCEKE.cjs.map → chunk-MF76IOZD.cjs.map} +1 -1
- package/dist/tsup/{chunk-HBRZOISM.cjs → chunk-OWPBIHFM.cjs} +8 -8
- package/dist/tsup/{chunk-HBRZOISM.cjs.map → chunk-OWPBIHFM.cjs.map} +1 -1
- package/dist/tsup/{chunk-QLCMNNEA.js → chunk-PO352AW7.js} +2 -2
- package/dist/tsup/{chunk-T33JFOMB.cjs → chunk-Q6ESJU7P.cjs} +34 -32
- package/dist/tsup/chunk-Q6ESJU7P.cjs.map +1 -0
- package/dist/tsup/{chunk-5VER7GR2.cjs → chunk-QZWHQAOF.cjs} +6 -6
- package/dist/tsup/{chunk-5VER7GR2.cjs.map → chunk-QZWHQAOF.cjs.map} +1 -1
- package/dist/tsup/{chunk-CL67HHVB.js → chunk-SQPFZW4U.js} +11 -7
- package/dist/tsup/chunk-SQPFZW4U.js.map +1 -0
- package/dist/tsup/{chunk-QVMIMEYZ.cjs → chunk-SXEHZODB.cjs} +236 -244
- package/dist/tsup/chunk-SXEHZODB.cjs.map +1 -0
- package/dist/tsup/{chunk-Y5JPI3EV.js → chunk-XQR2BHQP.js} +8 -6
- package/dist/tsup/chunk-XQR2BHQP.js.map +1 -0
- package/dist/tsup/{chunk-W76ULFDH.js → chunk-ZD5CZSSF.js} +104 -17
- package/dist/tsup/chunk-ZD5CZSSF.js.map +1 -0
- package/dist/tsup/client/mod.cjs +10 -10
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +9 -9
- package/dist/tsup/common/log.cjs +4 -4
- package/dist/tsup/common/log.js +3 -3
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -4
- package/dist/tsup/{conn-Cc9WHuN4.d.cts → conn-CxCsTz2s.d.cts} +27 -24
- package/dist/tsup/{conn-DfPG71FA.d.ts → conn-DhdZYlSX.d.ts} +27 -24
- package/dist/tsup/driver-helpers/mod.cjs +6 -6
- package/dist/tsup/driver-helpers/mod.d.cts +1 -1
- package/dist/tsup/driver-helpers/mod.d.ts +1 -1
- package/dist/tsup/driver-helpers/mod.js +5 -5
- package/dist/tsup/driver-test-suite/mod.cjs +77 -73
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +1 -1
- package/dist/tsup/driver-test-suite/mod.d.ts +1 -1
- package/dist/tsup/driver-test-suite/mod.js +17 -13
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +7 -7
- package/dist/tsup/inspector/mod.d.cts +2 -2
- package/dist/tsup/inspector/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.js +6 -6
- package/dist/tsup/mod.cjs +11 -11
- package/dist/tsup/mod.d.cts +2 -2
- package/dist/tsup/mod.d.ts +2 -2
- package/dist/tsup/mod.js +10 -10
- package/dist/tsup/test/mod.cjs +12 -12
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +11 -11
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.js +2 -2
- package/package.json +1 -1
- package/src/actor/errors.ts +0 -11
- package/src/client/client.ts +4 -8
- package/src/client/config.ts +3 -0
- package/src/client/utils.ts +8 -3
- package/src/common/router.ts +50 -1
- package/src/driver-test-suite/mod.ts +5 -1
- package/src/drivers/default.ts +0 -6
- package/src/drivers/engine/actor-driver.ts +16 -10
- package/src/drivers/file-system/manager.ts +5 -1
- package/src/manager/router.ts +9 -15
- package/src/registry/mod.ts +30 -47
- package/src/remote-manager-driver/api-endpoints.ts +50 -0
- package/src/remote-manager-driver/mod.ts +104 -1
- package/src/test/mod.ts +5 -1
- package/dist/tsup/chunk-5QGQK44L.cjs.map +0 -1
- package/dist/tsup/chunk-CL67HHVB.js.map +0 -1
- package/dist/tsup/chunk-PKH3YCMG.cjs.map +0 -1
- package/dist/tsup/chunk-QBDLQRFN.cjs.map +0 -1
- package/dist/tsup/chunk-QVMIMEYZ.cjs.map +0 -1
- package/dist/tsup/chunk-T33JFOMB.cjs.map +0 -1
- package/dist/tsup/chunk-W5AMA5MD.js.map +0 -1
- package/dist/tsup/chunk-Y5JPI3EV.js.map +0 -1
- package/dist/tsup/chunk-YPZFLUO6.js.map +0 -1
- /package/dist/tsup/{chunk-WFADCZPK.js.map → chunk-3LGDBNZG.js.map} +0 -0
- /package/dist/tsup/{chunk-E7CPGIQE.js.map → chunk-43PTNF7W.js.map} +0 -0
- /package/dist/tsup/{chunk-SDB3B7ZO.js.map → chunk-5C3MRFAU.js.map} +0 -0
- /package/dist/tsup/{chunk-XW5IS7NH.js.map → chunk-FNQGHSFJ.js.map} +0 -0
- /package/dist/tsup/{chunk-YCQL4TJR.js.map → chunk-HY3MZSKX.js.map} +0 -0
- /package/dist/tsup/{chunk-QLCMNNEA.js.map → chunk-PO352AW7.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/common/utils.ts","../../package.json","../../src/utils.ts"],"sourcesContent":["import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { getEnvUniversal } from \"@/utils\";\nimport type { Logger } from \"./log\";\n\nexport function assertUnreachable(x: never): never {\n\tthrow new Error(`Unreachable case: ${x}`);\n}\n\n/**\n * Safely stringifies an object, ensuring that the stringified object is under a certain size.\n * @param obj any object to stringify\n * @param maxSize maximum size of the stringified object in bytes\n * @returns stringified object\n */\nexport function safeStringify(obj: unknown, maxSize: number) {\n\tlet size = 0;\n\n\tfunction replacer(key: string, value: unknown) {\n\t\tif (value === null || value === undefined) return value;\n\t\tconst valueSize =\n\t\t\ttypeof value === \"string\" ? value.length : JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(`JSON object exceeds size limit of ${maxSize} bytes.`);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\treturn JSON.stringify(obj, replacer);\n}\n\n// TODO: Instead of doing this, use a temp var for state and attempt to write\n// it. Roll back state if fails to serialize.\n\n/**\n * Check if a value is CBOR serializable.\n * Optionally pass an onInvalid callback to receive the path to invalid values.\n *\n * For a complete list of supported CBOR tags, see:\n * https://github.com/kriszyp/cbor-x/blob/cc1cf9df8ba72288c7842af1dd374d73e34cdbc1/README.md#list-of-supported-tags-for-decoding\n */\nexport function isCborSerializable(\n\tvalue: unknown,\n\tonInvalid?: (path: string) => void,\n\tcurrentPath = \"\",\n): boolean {\n\t// Handle primitive types directly\n\tif (value === null || value === undefined) {\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tonInvalid?.(currentPath);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"boolean\" || typeof value === \"string\") {\n\t\treturn true;\n\t}\n\n\t// Handle BigInt (CBOR tags 2 and 3)\n\tif (typeof value === \"bigint\") {\n\t\treturn true;\n\t}\n\n\t// Handle Date objects (CBOR tags 0 and 1)\n\tif (value instanceof Date) {\n\t\treturn true;\n\t}\n\n\t// Handle typed arrays (CBOR tags 64-82)\n\tif (\n\t\tvalue instanceof Uint8Array ||\n\t\tvalue instanceof Uint8ClampedArray ||\n\t\tvalue instanceof Uint16Array ||\n\t\tvalue instanceof Uint32Array ||\n\t\tvalue instanceof BigUint64Array ||\n\t\tvalue instanceof Int8Array ||\n\t\tvalue instanceof Int16Array ||\n\t\tvalue instanceof Int32Array ||\n\t\tvalue instanceof BigInt64Array ||\n\t\tvalue instanceof Float32Array ||\n\t\tvalue instanceof Float64Array\n\t) {\n\t\treturn true;\n\t}\n\n\t// Handle Map (CBOR tag 259)\n\tif (value instanceof Map) {\n\t\tfor (const [key, val] of value.entries()) {\n\t\t\tconst keyPath = currentPath\n\t\t\t\t? `${currentPath}.key(${String(key)})`\n\t\t\t\t: `key(${String(key)})`;\n\t\t\tconst valPath = currentPath\n\t\t\t\t? `${currentPath}.value(${String(key)})`\n\t\t\t\t: `value(${String(key)})`;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(key, onInvalid, keyPath) ||\n\t\t\t\t!isCborSerializable(val, onInvalid, valPath)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle Set (CBOR tag 258)\n\tif (value instanceof Set) {\n\t\tlet index = 0;\n\t\tfor (const item of value.values()) {\n\t\t\tconst itemPath = currentPath\n\t\t\t\t? `${currentPath}.set[${index}]`\n\t\t\t\t: `set[${index}]`;\n\t\t\tif (!isCborSerializable(item, onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle RegExp (CBOR tag 27)\n\tif (value instanceof RegExp) {\n\t\treturn true;\n\t}\n\n\t// Handle Error objects (CBOR tag 27)\n\tif (value instanceof Error) {\n\t\treturn true;\n\t}\n\n\t// Handle arrays\n\tif (Array.isArray(value)) {\n\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\tconst itemPath = currentPath ? `${currentPath}[${i}]` : `[${i}]`;\n\t\t\tif (!isCborSerializable(value[i], onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle plain objects and records (CBOR tags 105, 51, 57344-57599)\n\tif (typeof value === \"object\") {\n\t\t// Allow plain objects and objects with prototypes (for records and named objects)\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\tif (proto !== null && proto !== Object.prototype) {\n\t\t\t// Check if it's a known serializable object type\n\t\t\tconst protoConstructor = value.constructor;\n\t\t\tif (protoConstructor && typeof protoConstructor.name === \"string\") {\n\t\t\t\t// Allow objects with named constructors (records, named objects)\n\t\t\t\t// This includes user-defined classes and built-in objects\n\t\t\t\t// that CBOR can serialize with tag 27 or record tags\n\t\t\t}\n\t\t}\n\n\t\t// Check all properties recursively\n\t\tfor (const key in value) {\n\t\t\tconst propPath = currentPath ? `${currentPath}.${key}` : key;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(\n\t\t\t\t\tvalue[key as keyof typeof value],\n\t\t\t\t\tonInvalid,\n\t\t\t\t\tpropPath,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Not serializable\n\tonInvalid?.(currentPath);\n\treturn false;\n}\n\nexport interface DeconstructedError {\n\t__type: \"ActorError\";\n\tstatusCode: ContentfulStatusCode;\n\tpublic: boolean;\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n}\n\n/** Deconstructs error in to components that are used to build responses. */\nexport function deconstructError(\n\terror: unknown,\n\tlogger: Logger,\n\textraLog: Record<string, unknown>,\n\texposeInternalError = false,\n): DeconstructedError {\n\t// Build response error information. Only return errors if flagged as public in order to prevent leaking internal behavior.\n\t//\n\t// We log the error here instead of after generating the code & message because we need to log the original error, not the masked internal error.\n\tlet statusCode: ContentfulStatusCode;\n\tlet public_: boolean;\n\tlet group: string;\n\tlet code: string;\n\tlet message: string;\n\tlet metadata: unknown;\n\tif (errors.ActorError.isActorError(error) && error.public) {\n\t\t// Check if error has statusCode (could be ActorError instance or DeconstructedError)\n\t\tstatusCode = (\n\t\t\t\"statusCode\" in error && error.statusCode ? error.statusCode : 400\n\t\t) as ContentfulStatusCode;\n\t\tpublic_ = true;\n\t\tgroup = error.group;\n\t\tcode = error.code;\n\t\tmessage = getErrorMessage(error);\n\t\tmetadata = error.metadata;\n\n\t\tlogger.info({\n\t\t\tmsg: \"public error\",\n\t\t\tgroup,\n\t\t\tcode,\n\t\t\tmessage,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t} else if (exposeInternalError) {\n\t\tif (errors.ActorError.isActorError(error)) {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = error.group;\n\t\t\tcode = error.code;\n\t\t\tmessage = getErrorMessage(error);\n\t\t\tmetadata = error.metadata;\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t} else {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = \"internal\";\n\t\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\t\tmessage = getErrorMessage(error);\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tstatusCode = 500;\n\t\tpublic_ = false;\n\t\tgroup = \"internal\";\n\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\tmessage = errors.INTERNAL_ERROR_DESCRIPTION;\n\t\tmetadata = {\n\t\t\t//url: `https://hub.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,\n\t\t} satisfies errors.InternalErrorMetadata;\n\n\t\tlogger.warn({\n\t\t\tmsg: \"internal error\",\n\t\t\terror: getErrorMessage(error),\n\t\t\tstack: (error as Error)?.stack,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t}\n\n\treturn {\n\t\t__type: \"ActorError\",\n\t\tstatusCode,\n\t\tpublic: public_,\n\t\tgroup,\n\t\tcode,\n\t\tmessage,\n\t\tmetadata,\n\t};\n}\n\nexport function stringifyError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tgetEnvUniversal(\"_RIVETKIT_ERROR_STACK\") === \"1\"\n\t\t) {\n\t\t\treturn `${error.name}: ${error.message}${error.stack ? `\\n${error.stack}` : \"\"}`;\n\t\t} else {\n\t\t\treturn `${error.name}: ${error.message}`;\n\t\t}\n\t} else if (typeof error === \"string\") {\n\t\treturn error;\n\t} else if (typeof error === \"object\" && error !== null) {\n\t\ttry {\n\t\t\treturn `${JSON.stringify(error)}`;\n\t\t} catch {\n\t\t\treturn \"[cannot stringify error]\";\n\t\t}\n\t} else {\n\t\treturn `Unknown error: ${getErrorMessage(error)}`;\n\t}\n}\n\nfunction getErrorMessage(err: unknown): string {\n\tif (\n\t\terr &&\n\t\ttypeof err === \"object\" &&\n\t\t\"message\" in err &&\n\t\ttypeof err.message === \"string\"\n\t) {\n\t\treturn err.message;\n\t} else {\n\t\treturn String(err);\n\t}\n}\n\n/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */\nexport function noopNext(): Next {\n\treturn async () => {};\n}\n","{\n \"name\": \"rivetkit\",\n \"version\": \"2.0.13\",\n \"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n \"license\": \"Apache-2.0\",\n \"keywords\": [\n \"rivetkit\",\n \"stateful\",\n \"serverless\",\n \"actors\",\n \"agents\",\n \"realtime\",\n \"websocket\",\n \"actors\",\n \"framework\"\n ],\n \"files\": [\n \"dist\",\n \"src\",\n \"deno.json\",\n \"bun.json\",\n \"package.json\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/tsup/mod.d.ts\",\n \"default\": \"./dist/tsup/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/mod.d.cts\",\n \"default\": \"./dist/tsup/mod.cjs\"\n }\n },\n \"./client\": {\n \"import\": {\n \"types\": \"./dist/tsup/client/mod.d.ts\",\n \"default\": \"./dist/tsup/client/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/client/mod.d.cts\",\n \"default\": \"./dist/tsup/client/mod.cjs\"\n }\n },\n \"./log\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/log.d.ts\",\n \"default\": \"./dist/tsup/common/log.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/log.d.cts\",\n \"default\": \"./dist/tsup/common/log.cjs\"\n }\n },\n \"./errors\": {\n \"import\": {\n \"types\": \"./dist/tsup/actor/errors.d.ts\",\n \"default\": \"./dist/tsup/actor/errors.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/actor/errors.d.cts\",\n \"default\": \"./dist/tsup/actor/errors.cjs\"\n }\n },\n \"./utils\": {\n \"import\": {\n \"types\": \"./dist/tsup/utils.d.ts\",\n \"default\": \"./dist/tsup/utils.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/utils.d.cts\",\n \"default\": \"./dist/tsup/utils.cjs\"\n }\n },\n \"./driver-helpers\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n }\n },\n \"./driver-helpers/websocket\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/websocket.d.ts\",\n \"default\": \"./dist/tsup/common/websocket.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/websocket.d.cts\",\n \"default\": \"./dist/tsup/common/websocket.cjs\"\n }\n },\n \"./driver-test-suite\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n }\n },\n \"./topologies/coordinate\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n }\n },\n \"./topologies/partition\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n }\n },\n \"./test\": {\n \"import\": {\n \"types\": \"./dist/tsup/test/mod.d.ts\",\n \"default\": \"./dist/tsup/test/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/test/mod.d.cts\",\n \"default\": \"./dist/tsup/test/mod.cjs\"\n }\n },\n \"./inspector\": {\n \"import\": {\n \"types\": \"./dist/tsup/inspector/mod.d.ts\",\n \"default\": \"./dist/tsup/inspector/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/inspector/mod.d.cts\",\n \"default\": \"./dist/tsup/inspector/mod.cjs\"\n }\n }\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"sideEffects\": [\n \"./dist/tsup/chunk-*.js\",\n \"./dist/tsup/chunk-*.cjs\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts\",\n \"build:schema\": \"./scripts/compile-bare.ts compile schemas/client-protocol/v1.bare -o dist/schemas/client-protocol/v1.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v1.bare -o dist/schemas/file-system-driver/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts\",\n \"check-types\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"dump-openapi\": \"tsx scripts/dump-openapi.ts\"\n },\n \"dependencies\": {\n \"@bare-ts/lib\": \"~0.3.0\",\n \"@hono/standard-validator\": \"^0.1.3\",\n \"@hono/zod-openapi\": \"^0.19.10\",\n \"@rivetkit/engine-runner\": \"https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@bdfca35\",\n \"@rivetkit/fast-json-patch\": \"^3.1.2\",\n \"cbor-x\": \"^1.6.0\",\n \"hono\": \"^4.7.0\",\n \"invariant\": \"^2.2.4\",\n \"nanoevents\": \"^9.1.0\",\n \"on-change\": \"^5.0.1\",\n \"p-retry\": \"^6.2.1\",\n \"pino\": \"^9.5.0\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@bare-ts/tools\": \"^0.13.0\",\n \"@hono/node-server\": \"^1.18.2\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"@types/invariant\": \"^2\",\n \"@types/node\": \"^22.13.1\",\n \"@types/ws\": \"^8\",\n \"@vitest/ui\": \"3.1.1\",\n \"bundle-require\": \"^5.1.0\",\n \"eventsource\": \"^4.0.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.1.1\",\n \"ws\": \"^8.18.1\"\n },\n \"peerDependencies\": {\n \"@hono/node-server\": \"^1.14.0\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"eventsource\": \"^4.0.0\",\n \"ws\": \"^8.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"@hono/node-server\": {\n \"optional\": true\n },\n \"@hono/node-ws\": {\n \"optional\": true\n },\n \"eventsource\": {\n \"optional\": true\n },\n \"ws\": {\n \"optional\": true\n }\n },\n \"stableVersion\": \"0.8.0\"\n}\n","export { stringifyError } from \"@/common/utils\";\nexport { assertUnreachable } from \"./common/utils\";\n\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\n\nimport pkgJson from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nexport function httpUserAgent(): string {\n\t// Return cached value if already initialized\n\tif (_userAgent !== undefined) {\n\t\treturn _userAgent;\n\t}\n\n\t// Library\n\tlet userAgent = `RivetKit/${VERSION}`;\n\n\t// Navigator\n\tconst navigatorObj = typeof navigator !== \"undefined\" ? navigator : undefined;\n\tif (navigatorObj?.userAgent) userAgent += ` ${navigatorObj.userAgent}`;\n\n\t_userAgent = userAgent;\n\n\treturn userAgent;\n}\n\nexport type UpgradeWebSocket = (\n\tcreateEvents: (c: HonoContext) => any,\n) => HonoHandler;\n\nexport type GetUpgradeWebSocket = () => UpgradeWebSocket;\n\nexport function getEnvUniversal(key: string): string | undefined {\n\tif (typeof Deno !== \"undefined\") {\n\t\treturn Deno.env.get(key);\n\t} else if (typeof process !== \"undefined\") {\n\t\t// Do this after Deno since `process` is sometimes polyfilled\n\t\treturn process.env[key];\n\t}\n}\n\nexport function dbg<T>(x: T): T {\n\tconsole.trace(`=== DEBUG ===\\n${x}`);\n\treturn x;\n}\n\n/**\n * Converts various ArrayBuffer-like types to Uint8Array.\n * Handles ArrayBuffer, ArrayBufferView (including typed arrays), and passes through existing Uint8Array.\n *\n * @param data - The ArrayBuffer or ArrayBufferView to convert\n * @returns A Uint8Array view of the data\n */\nexport function toUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t} else if (data instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t} else if (ArrayBuffer.isView(data)) {\n\t\t// Handle other ArrayBufferView types (Int8Array, Uint16Array, DataView, etc.)\n\t\treturn new Uint8Array(\n\t\t\tdata.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),\n\t\t);\n\t} else {\n\t\tthrow new TypeError(\"Input must be ArrayBuffer or ArrayBufferView\");\n\t}\n}\n\n// Long timeouts\n//\n// JavaScript timers use a signed 32-bit integer for delays, so values above 2^31-1 (~24.8 days)\n// are not reliable and may fire immediately or overflow.\n//\n// https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value\nconst TIMEOUT_MAX = 2147483647; // 2^31-1\n\nexport type LongTimeoutHandle = { abort: () => void };\n\n/**\n * Polyfill for Promise.withResolvers().\n *\n * This is specifically for Cloudflare Workers. Their implementation of Promise.withResolvers does not work correctly.\n */\nexport function promiseWithResolvers<T>(): {\n\tpromise: Promise<T>;\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: any) => void;\n} {\n\tlet resolve!: (value: T | PromiseLike<T>) => void;\n\tlet reject!: (reason?: any) => void;\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\treturn { promise, resolve, reject };\n}\n\nexport function setLongTimeout(\n\tlistener: () => void,\n\tafter: number,\n): LongTimeoutHandle {\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tfunction start(remaining: number) {\n\t\tif (remaining <= TIMEOUT_MAX) {\n\t\t\ttimeout = setTimeout(listener, remaining);\n\t\t} else {\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tstart(remaining - TIMEOUT_MAX);\n\t\t\t}, TIMEOUT_MAX);\n\t\t}\n\t}\n\n\tstart(after);\n\n\treturn {\n\t\tabort: () => {\n\t\t\tif (timeout !== undefined) clearTimeout(timeout);\n\t\t},\n\t};\n}\n\n/**\n * A tiny utility that coalesces/enqueues async operations so only the latest\n * queued task runs per cycle, while callers receive a promise that resolves\n * when the task for the cycle they joined has completed.\n */\nexport class SinglePromiseQueue {\n\t/** Next operation to execute in the queue. If attempting to enqueue another op, it will override the existing op. */\n\t#queuedOp?: () => Promise<void>;\n\n\t/** The currently running promise of #drainLoop. Do not await this, instead await `pending` to await the current cycle. */\n\trunningDrainLoop?: Promise<void>;\n\n\t/** Pending resolver fro the currently queued entry. */\n\t#pending?: ReturnType<typeof promiseWithResolvers<void>>;\n\n\t/** Queue the next operation and return a promise that resolves when it flushes. */\n\tenqueue(op: () => Promise<void>): Promise<void> {\n\t\t// Replace any previously queued operation with the latest one\n\t\tthis.#queuedOp = op;\n\n\t\t// Ensure a shared resolver exists for all callers in this cycle\n\t\tif (!this.#pending) {\n\t\t\tthis.#pending = promiseWithResolvers<void>();\n\t\t}\n\n\t\tconst waitForThisCycle = this.#pending.promise;\n\n\t\t// Start runner if not already running\n\t\tif (!this.runningDrainLoop) {\n\t\t\tthis.runningDrainLoop = this.#drainLoop();\n\t\t}\n\n\t\treturn waitForThisCycle;\n\t}\n\n\t/** Drain queued operations sequentially until there is nothing left. */\n\tasync #drainLoop(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#queuedOp) {\n\t\t\t\t// Capture current cycle resolver then reset for the next cycle\n\t\t\t\tconst resolver = this.#pending;\n\t\t\t\tthis.#pending = undefined;\n\n\t\t\t\t// Capture and clear the currently queued operation\n\t\t\t\tconst op = this.#queuedOp;\n\t\t\t\tthis.#queuedOp = undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tawait op();\n\t\t\t\t} catch {\n\t\t\t\t\t// Swallow errors: callers only await cycle completion, not success\n\t\t\t\t}\n\n\t\t\t\t// Notify all waiters for this cycle\n\t\t\t\tresolver?.resolve();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\nexport function bufferToArrayBuffer(buf: Buffer | Uint8Array): ArrayBuffer {\n\treturn buf.buffer.slice(\n\t\tbuf.byteOffset,\n\t\tbuf.byteOffset + buf.byteLength,\n\t) as ArrayBuffer;\n}\n\n/**\n * Properly combines a base URL endpoint with a path, preserving any base path in the endpoint.\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors/action\")\n * // Returns: \"http://localhost:8787/rivet/actors/action\"\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors?type=foo\", { namespace: \"test\" })\n * // Returns: \"http://localhost:8787/rivet/actors?type=foo&namespace=test\"\n *\n * @param endpoint The base URL endpoint that may contain a path component\n * @param path The path to append to the endpoint (may include query parameters)\n * @param queryParams Optional additional query parameters to append\n * @returns The properly combined URL string\n */\nexport function combineUrlPath(\n\tendpoint: string,\n\tpath: string,\n\tqueryParams?: Record<string, string | undefined>,\n): string {\n\tconst baseUrl = new URL(endpoint);\n\n\t// Extract path and query from the provided path\n\tconst pathParts = path.split(\"?\");\n\tconst pathOnly = pathParts[0];\n\tconst existingQuery = pathParts[1] || \"\";\n\n\t// Remove trailing slash from base path and ensure path starts with /\n\tconst basePath = baseUrl.pathname.replace(/\\/$/, \"\");\n\tconst cleanPath = pathOnly.startsWith(\"/\") ? pathOnly : `/${pathOnly}`;\n\t// Combine paths and remove any double slashes\n\tconst fullPath = (basePath + cleanPath).replace(/\\/\\//g, \"/\");\n\n\t// Build query string\n\tconst queryParts: string[] = [];\n\tif (existingQuery) {\n\t\tqueryParts.push(existingQuery);\n\t}\n\tif (queryParams) {\n\t\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tqueryParts.push(\n\t\t\t\t\t`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst fullQuery = queryParts.length > 0 ? `?${queryParts.join(\"&\")}` : \"\";\n\treturn `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;\n}\n"],"mappings":";;;;;;;AAMO,SAAS,kBAAkB,GAAiB;AAClD,QAAM,IAAI,MAAM,qBAAqB,CAAC,EAAE;AACzC;AAqCO,SAAS,mBACf,OACA,WACA,cAAc,IACJ;AAEV,MAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,6CAAY;AACZ,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC5D,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,MAAM;AAC1B,WAAO;AAAA,EACR;AAGA,MACC,iBAAiB,cACjB,iBAAiB,qBACjB,iBAAiB,eACjB,iBAAiB,eACjB,iBAAiB,kBACjB,iBAAiB,aACjB,iBAAiB,cACjB,iBAAiB,cACjB,iBAAiB,iBACjB,iBAAiB,gBACjB,iBAAiB,cAChB;AACD,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,KAAK;AACzB,eAAW,CAAC,KAAK,GAAG,KAAK,MAAM,QAAQ,GAAG;AACzC,YAAM,UAAU,cACb,GAAG,WAAW,QAAQ,OAAO,GAAG,CAAC,MACjC,OAAO,OAAO,GAAG,CAAC;AACrB,YAAM,UAAU,cACb,GAAG,WAAW,UAAU,OAAO,GAAG,CAAC,MACnC,SAAS,OAAO,GAAG,CAAC;AACvB,UACC,CA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AA,QACV,QAAQ;AAAA,QAER;AAGA,6CAAU;AAAA,MACX;AAAA,IACD,UAAE;AACD,WAAK,mBAAmB;AAAA,IACzB;AAAA,EACD;AACD;AAEO,SAAS,oBAAoB,KAAuC;AAC1E,SAAO,IAAI,OAAO;AAAA,IACjB,IAAI;AAAA,IACJ,IAAI,aAAa,IAAI;AAAA,EACtB;AACD;AAkBO,SAAS,eACf,UACA,MACA,aACS;AACT,QAAM,UAAU,IAAI,IAAI,QAAQ;AAGhC,QAAM,YAAY,KAAK,MAAM,GAAG;AAChC,QAAM,WAAW,UAAU,CAAC;AAC5B,QAAM,gBAAgB,UAAU,CAAC,KAAK;AAGtC,QAAM,WAAW,QAAQ,SAAS,QAAQ,OAAO,EAAE;AACnD,QAAM,YAAY,SAAS,WAAW,GAAG,IAAI,WAAW,IAAI,QAAQ;AAEpE,QAAM,YAAY,WAAW,WAAW,QAAQ,SAAS,GAAG;AAG5D,QAAM,aAAuB,CAAC;AAC9B,MAAI,eAAe;AAClB,eAAW,KAAK,aAAa;AAAA,EAC9B;AACA,MAAI,aAAa;AAChB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACvD,UAAI,UAAU,QAAW;AACxB,mBAAW;AAAA,UACV,GAAG,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,KAAK,CAAC;AAAA,QACxD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,YAAY,WAAW,SAAS,IAAI,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK;AACvE,SAAO,GAAG,QAAQ,QAAQ,KAAK,QAAQ,IAAI,GAAG,QAAQ,GAAG,SAAS;AACnE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/common/utils.ts","../../package.json","../../src/utils.ts"],"sourcesContent":["import type { Next } from \"hono\";\nimport type { ContentfulStatusCode } from \"hono/utils/http-status\";\nimport * as errors from \"@/actor/errors\";\nimport { getEnvUniversal } from \"@/utils\";\nimport type { Logger } from \"./log\";\n\nexport function assertUnreachable(x: never): never {\n\tthrow new Error(`Unreachable case: ${x}`);\n}\n\n/**\n * Safely stringifies an object, ensuring that the stringified object is under a certain size.\n * @param obj any object to stringify\n * @param maxSize maximum size of the stringified object in bytes\n * @returns stringified object\n */\nexport function safeStringify(obj: unknown, maxSize: number) {\n\tlet size = 0;\n\n\tfunction replacer(key: string, value: unknown) {\n\t\tif (value === null || value === undefined) return value;\n\t\tconst valueSize =\n\t\t\ttypeof value === \"string\" ? value.length : JSON.stringify(value).length;\n\t\tsize += key.length + valueSize;\n\n\t\tif (size > maxSize) {\n\t\t\tthrow new Error(`JSON object exceeds size limit of ${maxSize} bytes.`);\n\t\t}\n\n\t\treturn value;\n\t}\n\n\treturn JSON.stringify(obj, replacer);\n}\n\n// TODO: Instead of doing this, use a temp var for state and attempt to write\n// it. Roll back state if fails to serialize.\n\n/**\n * Check if a value is CBOR serializable.\n * Optionally pass an onInvalid callback to receive the path to invalid values.\n *\n * For a complete list of supported CBOR tags, see:\n * https://github.com/kriszyp/cbor-x/blob/cc1cf9df8ba72288c7842af1dd374d73e34cdbc1/README.md#list-of-supported-tags-for-decoding\n */\nexport function isCborSerializable(\n\tvalue: unknown,\n\tonInvalid?: (path: string) => void,\n\tcurrentPath = \"\",\n): boolean {\n\t// Handle primitive types directly\n\tif (value === null || value === undefined) {\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) {\n\t\t\tonInvalid?.(currentPath);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\tif (typeof value === \"boolean\" || typeof value === \"string\") {\n\t\treturn true;\n\t}\n\n\t// Handle BigInt (CBOR tags 2 and 3)\n\tif (typeof value === \"bigint\") {\n\t\treturn true;\n\t}\n\n\t// Handle Date objects (CBOR tags 0 and 1)\n\tif (value instanceof Date) {\n\t\treturn true;\n\t}\n\n\t// Handle typed arrays (CBOR tags 64-82)\n\tif (\n\t\tvalue instanceof Uint8Array ||\n\t\tvalue instanceof Uint8ClampedArray ||\n\t\tvalue instanceof Uint16Array ||\n\t\tvalue instanceof Uint32Array ||\n\t\tvalue instanceof BigUint64Array ||\n\t\tvalue instanceof Int8Array ||\n\t\tvalue instanceof Int16Array ||\n\t\tvalue instanceof Int32Array ||\n\t\tvalue instanceof BigInt64Array ||\n\t\tvalue instanceof Float32Array ||\n\t\tvalue instanceof Float64Array\n\t) {\n\t\treturn true;\n\t}\n\n\t// Handle Map (CBOR tag 259)\n\tif (value instanceof Map) {\n\t\tfor (const [key, val] of value.entries()) {\n\t\t\tconst keyPath = currentPath\n\t\t\t\t? `${currentPath}.key(${String(key)})`\n\t\t\t\t: `key(${String(key)})`;\n\t\t\tconst valPath = currentPath\n\t\t\t\t? `${currentPath}.value(${String(key)})`\n\t\t\t\t: `value(${String(key)})`;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(key, onInvalid, keyPath) ||\n\t\t\t\t!isCborSerializable(val, onInvalid, valPath)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle Set (CBOR tag 258)\n\tif (value instanceof Set) {\n\t\tlet index = 0;\n\t\tfor (const item of value.values()) {\n\t\t\tconst itemPath = currentPath\n\t\t\t\t? `${currentPath}.set[${index}]`\n\t\t\t\t: `set[${index}]`;\n\t\t\tif (!isCborSerializable(item, onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle RegExp (CBOR tag 27)\n\tif (value instanceof RegExp) {\n\t\treturn true;\n\t}\n\n\t// Handle Error objects (CBOR tag 27)\n\tif (value instanceof Error) {\n\t\treturn true;\n\t}\n\n\t// Handle arrays\n\tif (Array.isArray(value)) {\n\t\tfor (let i = 0; i < value.length; i++) {\n\t\t\tconst itemPath = currentPath ? `${currentPath}[${i}]` : `[${i}]`;\n\t\t\tif (!isCborSerializable(value[i], onInvalid, itemPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Handle plain objects and records (CBOR tags 105, 51, 57344-57599)\n\tif (typeof value === \"object\") {\n\t\t// Allow plain objects and objects with prototypes (for records and named objects)\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\tif (proto !== null && proto !== Object.prototype) {\n\t\t\t// Check if it's a known serializable object type\n\t\t\tconst protoConstructor = value.constructor;\n\t\t\tif (protoConstructor && typeof protoConstructor.name === \"string\") {\n\t\t\t\t// Allow objects with named constructors (records, named objects)\n\t\t\t\t// This includes user-defined classes and built-in objects\n\t\t\t\t// that CBOR can serialize with tag 27 or record tags\n\t\t\t}\n\t\t}\n\n\t\t// Check all properties recursively\n\t\tfor (const key in value) {\n\t\t\tconst propPath = currentPath ? `${currentPath}.${key}` : key;\n\t\t\tif (\n\t\t\t\t!isCborSerializable(\n\t\t\t\t\tvalue[key as keyof typeof value],\n\t\t\t\t\tonInvalid,\n\t\t\t\t\tpropPath,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Not serializable\n\tonInvalid?.(currentPath);\n\treturn false;\n}\n\nexport interface DeconstructedError {\n\t__type: \"ActorError\";\n\tstatusCode: ContentfulStatusCode;\n\tpublic: boolean;\n\tgroup: string;\n\tcode: string;\n\tmessage: string;\n\tmetadata?: unknown;\n}\n\n/** Deconstructs error in to components that are used to build responses. */\nexport function deconstructError(\n\terror: unknown,\n\tlogger: Logger,\n\textraLog: Record<string, unknown>,\n\texposeInternalError = false,\n): DeconstructedError {\n\t// Build response error information. Only return errors if flagged as public in order to prevent leaking internal behavior.\n\t//\n\t// We log the error here instead of after generating the code & message because we need to log the original error, not the masked internal error.\n\tlet statusCode: ContentfulStatusCode;\n\tlet public_: boolean;\n\tlet group: string;\n\tlet code: string;\n\tlet message: string;\n\tlet metadata: unknown;\n\tif (errors.ActorError.isActorError(error) && error.public) {\n\t\t// Check if error has statusCode (could be ActorError instance or DeconstructedError)\n\t\tstatusCode = (\n\t\t\t\"statusCode\" in error && error.statusCode ? error.statusCode : 400\n\t\t) as ContentfulStatusCode;\n\t\tpublic_ = true;\n\t\tgroup = error.group;\n\t\tcode = error.code;\n\t\tmessage = getErrorMessage(error);\n\t\tmetadata = error.metadata;\n\n\t\tlogger.info({\n\t\t\tmsg: \"public error\",\n\t\t\tgroup,\n\t\t\tcode,\n\t\t\tmessage,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t} else if (exposeInternalError) {\n\t\tif (errors.ActorError.isActorError(error)) {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = error.group;\n\t\t\tcode = error.code;\n\t\t\tmessage = getErrorMessage(error);\n\t\t\tmetadata = error.metadata;\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t} else {\n\t\t\tstatusCode = 500;\n\t\t\tpublic_ = false;\n\t\t\tgroup = \"internal\";\n\t\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\t\tmessage = getErrorMessage(error);\n\n\t\t\tlogger.info({\n\t\t\t\tmsg: \"internal error\",\n\t\t\t\tgroup,\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t\t...extraLog,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tstatusCode = 500;\n\t\tpublic_ = false;\n\t\tgroup = \"internal\";\n\t\tcode = errors.INTERNAL_ERROR_CODE;\n\t\tmessage = errors.INTERNAL_ERROR_DESCRIPTION;\n\t\tmetadata = {\n\t\t\t//url: `https://hub.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,\n\t\t} satisfies errors.InternalErrorMetadata;\n\n\t\tlogger.warn({\n\t\t\tmsg: \"internal error\",\n\t\t\terror: getErrorMessage(error),\n\t\t\tstack: (error as Error)?.stack,\n\t\t\tissues: \"https://github.com/rivet-dev/rivetkit/issues\",\n\t\t\tsupport: \"https://rivet.dev/discord\",\n\t\t\t...extraLog,\n\t\t});\n\t}\n\n\treturn {\n\t\t__type: \"ActorError\",\n\t\tstatusCode,\n\t\tpublic: public_,\n\t\tgroup,\n\t\tcode,\n\t\tmessage,\n\t\tmetadata,\n\t};\n}\n\nexport function stringifyError(error: unknown): string {\n\tif (error instanceof Error) {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tgetEnvUniversal(\"_RIVETKIT_ERROR_STACK\") === \"1\"\n\t\t) {\n\t\t\treturn `${error.name}: ${error.message}${error.stack ? `\\n${error.stack}` : \"\"}`;\n\t\t} else {\n\t\t\treturn `${error.name}: ${error.message}`;\n\t\t}\n\t} else if (typeof error === \"string\") {\n\t\treturn error;\n\t} else if (typeof error === \"object\" && error !== null) {\n\t\ttry {\n\t\t\treturn `${JSON.stringify(error)}`;\n\t\t} catch {\n\t\t\treturn \"[cannot stringify error]\";\n\t\t}\n\t} else {\n\t\treturn `Unknown error: ${getErrorMessage(error)}`;\n\t}\n}\n\nfunction getErrorMessage(err: unknown): string {\n\tif (\n\t\terr &&\n\t\ttypeof err === \"object\" &&\n\t\t\"message\" in err &&\n\t\ttypeof err.message === \"string\"\n\t) {\n\t\treturn err.message;\n\t} else {\n\t\treturn String(err);\n\t}\n}\n\n/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */\nexport function noopNext(): Next {\n\treturn async () => {};\n}\n","{\n \"name\": \"rivetkit\",\n \"version\": \"2.0.14\",\n \"description\": \"Lightweight libraries for building stateful actors on edge platforms\",\n \"license\": \"Apache-2.0\",\n \"keywords\": [\n \"rivetkit\",\n \"stateful\",\n \"serverless\",\n \"actors\",\n \"agents\",\n \"realtime\",\n \"websocket\",\n \"actors\",\n \"framework\"\n ],\n \"files\": [\n \"dist\",\n \"src\",\n \"deno.json\",\n \"bun.json\",\n \"package.json\"\n ],\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/tsup/mod.d.ts\",\n \"default\": \"./dist/tsup/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/mod.d.cts\",\n \"default\": \"./dist/tsup/mod.cjs\"\n }\n },\n \"./client\": {\n \"import\": {\n \"types\": \"./dist/tsup/client/mod.d.ts\",\n \"default\": \"./dist/tsup/client/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/client/mod.d.cts\",\n \"default\": \"./dist/tsup/client/mod.cjs\"\n }\n },\n \"./log\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/log.d.ts\",\n \"default\": \"./dist/tsup/common/log.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/log.d.cts\",\n \"default\": \"./dist/tsup/common/log.cjs\"\n }\n },\n \"./errors\": {\n \"import\": {\n \"types\": \"./dist/tsup/actor/errors.d.ts\",\n \"default\": \"./dist/tsup/actor/errors.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/actor/errors.d.cts\",\n \"default\": \"./dist/tsup/actor/errors.cjs\"\n }\n },\n \"./utils\": {\n \"import\": {\n \"types\": \"./dist/tsup/utils.d.ts\",\n \"default\": \"./dist/tsup/utils.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/utils.d.cts\",\n \"default\": \"./dist/tsup/utils.cjs\"\n }\n },\n \"./driver-helpers\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-helpers/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-helpers/mod.cjs\"\n }\n },\n \"./driver-helpers/websocket\": {\n \"import\": {\n \"types\": \"./dist/tsup/common/websocket.d.ts\",\n \"default\": \"./dist/tsup/common/websocket.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/common/websocket.d.cts\",\n \"default\": \"./dist/tsup/common/websocket.cjs\"\n }\n },\n \"./driver-test-suite\": {\n \"import\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.ts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/driver-test-suite/mod.d.cts\",\n \"default\": \"./dist/tsup/driver-test-suite/mod.cjs\"\n }\n },\n \"./topologies/coordinate\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/coordinate/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/coordinate/mod.cjs\"\n }\n },\n \"./topologies/partition\": {\n \"import\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.ts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/topologies/partition/mod.d.cts\",\n \"default\": \"./dist/tsup/topologies/partition/mod.cjs\"\n }\n },\n \"./test\": {\n \"import\": {\n \"types\": \"./dist/tsup/test/mod.d.ts\",\n \"default\": \"./dist/tsup/test/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/test/mod.d.cts\",\n \"default\": \"./dist/tsup/test/mod.cjs\"\n }\n },\n \"./inspector\": {\n \"import\": {\n \"types\": \"./dist/tsup/inspector/mod.d.ts\",\n \"default\": \"./dist/tsup/inspector/mod.js\"\n },\n \"require\": {\n \"types\": \"./dist/tsup/inspector/mod.d.cts\",\n \"default\": \"./dist/tsup/inspector/mod.cjs\"\n }\n }\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"sideEffects\": [\n \"./dist/tsup/chunk-*.js\",\n \"./dist/tsup/chunk-*.cjs\"\n ],\n \"scripts\": {\n \"build\": \"tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/topologies/coordinate/mod.ts src/topologies/partition/mod.ts src/utils.ts src/driver-helpers/mod.ts src/driver-test-suite/mod.ts src/test/mod.ts src/inspector/mod.ts\",\n \"build:schema\": \"./scripts/compile-bare.ts compile schemas/client-protocol/v1.bare -o dist/schemas/client-protocol/v1.ts && ./scripts/compile-bare.ts compile schemas/file-system-driver/v1.bare -o dist/schemas/file-system-driver/v1.ts && ./scripts/compile-bare.ts compile schemas/actor-persist/v1.bare -o dist/schemas/actor-persist/v1.ts\",\n \"check-types\": \"tsc --noEmit\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"dump-openapi\": \"tsx scripts/dump-openapi.ts\"\n },\n \"dependencies\": {\n \"@bare-ts/lib\": \"~0.3.0\",\n \"@hono/standard-validator\": \"^0.1.3\",\n \"@hono/zod-openapi\": \"^0.19.10\",\n \"@rivetkit/engine-runner\": \"https://pkg.pr.new/rivet-dev/engine/@rivetkit/engine-runner@bdfca35\",\n \"@rivetkit/fast-json-patch\": \"^3.1.2\",\n \"cbor-x\": \"^1.6.0\",\n \"hono\": \"^4.7.0\",\n \"invariant\": \"^2.2.4\",\n \"nanoevents\": \"^9.1.0\",\n \"on-change\": \"^5.0.1\",\n \"p-retry\": \"^6.2.1\",\n \"pino\": \"^9.5.0\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@bare-ts/tools\": \"^0.13.0\",\n \"@hono/node-server\": \"^1.18.2\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"@types/invariant\": \"^2\",\n \"@types/node\": \"^22.13.1\",\n \"@types/ws\": \"^8\",\n \"@vitest/ui\": \"3.1.1\",\n \"bundle-require\": \"^5.1.0\",\n \"eventsource\": \"^4.0.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.1.1\",\n \"ws\": \"^8.18.1\"\n },\n \"peerDependencies\": {\n \"@hono/node-server\": \"^1.14.0\",\n \"@hono/node-ws\": \"^1.1.1\",\n \"eventsource\": \"^4.0.0\",\n \"ws\": \"^8.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"@hono/node-server\": {\n \"optional\": true\n },\n \"@hono/node-ws\": {\n \"optional\": true\n },\n \"eventsource\": {\n \"optional\": true\n },\n \"ws\": {\n \"optional\": true\n }\n },\n \"stableVersion\": \"0.8.0\"\n}\n","export { stringifyError } from \"@/common/utils\";\nexport { assertUnreachable } from \"./common/utils\";\n\nimport type { Context as HonoContext, Handler as HonoHandler } from \"hono\";\n\nimport pkgJson from \"../package.json\" with { type: \"json\" };\n\nexport const VERSION = pkgJson.version;\n\nlet _userAgent: string | undefined;\n\nexport function httpUserAgent(): string {\n\t// Return cached value if already initialized\n\tif (_userAgent !== undefined) {\n\t\treturn _userAgent;\n\t}\n\n\t// Library\n\tlet userAgent = `RivetKit/${VERSION}`;\n\n\t// Navigator\n\tconst navigatorObj = typeof navigator !== \"undefined\" ? navigator : undefined;\n\tif (navigatorObj?.userAgent) userAgent += ` ${navigatorObj.userAgent}`;\n\n\t_userAgent = userAgent;\n\n\treturn userAgent;\n}\n\nexport type UpgradeWebSocket = (\n\tcreateEvents: (c: HonoContext) => any,\n) => HonoHandler;\n\nexport type GetUpgradeWebSocket = () => UpgradeWebSocket;\n\nexport function getEnvUniversal(key: string): string | undefined {\n\tif (typeof Deno !== \"undefined\") {\n\t\treturn Deno.env.get(key);\n\t} else if (typeof process !== \"undefined\") {\n\t\t// Do this after Deno since `process` is sometimes polyfilled\n\t\treturn process.env[key];\n\t}\n}\n\nexport function dbg<T>(x: T): T {\n\tconsole.trace(`=== DEBUG ===\\n${x}`);\n\treturn x;\n}\n\n/**\n * Converts various ArrayBuffer-like types to Uint8Array.\n * Handles ArrayBuffer, ArrayBufferView (including typed arrays), and passes through existing Uint8Array.\n *\n * @param data - The ArrayBuffer or ArrayBufferView to convert\n * @returns A Uint8Array view of the data\n */\nexport function toUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n\tif (data instanceof Uint8Array) {\n\t\treturn data;\n\t} else if (data instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(data);\n\t} else if (ArrayBuffer.isView(data)) {\n\t\t// Handle other ArrayBufferView types (Int8Array, Uint16Array, DataView, etc.)\n\t\treturn new Uint8Array(\n\t\t\tdata.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength),\n\t\t);\n\t} else {\n\t\tthrow new TypeError(\"Input must be ArrayBuffer or ArrayBufferView\");\n\t}\n}\n\n// Long timeouts\n//\n// JavaScript timers use a signed 32-bit integer for delays, so values above 2^31-1 (~24.8 days)\n// are not reliable and may fire immediately or overflow.\n//\n// https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value\nconst TIMEOUT_MAX = 2147483647; // 2^31-1\n\nexport type LongTimeoutHandle = { abort: () => void };\n\n/**\n * Polyfill for Promise.withResolvers().\n *\n * This is specifically for Cloudflare Workers. Their implementation of Promise.withResolvers does not work correctly.\n */\nexport function promiseWithResolvers<T>(): {\n\tpromise: Promise<T>;\n\tresolve: (value: T | PromiseLike<T>) => void;\n\treject: (reason?: any) => void;\n} {\n\tlet resolve!: (value: T | PromiseLike<T>) => void;\n\tlet reject!: (reason?: any) => void;\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\treturn { promise, resolve, reject };\n}\n\nexport function setLongTimeout(\n\tlistener: () => void,\n\tafter: number,\n): LongTimeoutHandle {\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\n\tfunction start(remaining: number) {\n\t\tif (remaining <= TIMEOUT_MAX) {\n\t\t\ttimeout = setTimeout(listener, remaining);\n\t\t} else {\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tstart(remaining - TIMEOUT_MAX);\n\t\t\t}, TIMEOUT_MAX);\n\t\t}\n\t}\n\n\tstart(after);\n\n\treturn {\n\t\tabort: () => {\n\t\t\tif (timeout !== undefined) clearTimeout(timeout);\n\t\t},\n\t};\n}\n\n/**\n * A tiny utility that coalesces/enqueues async operations so only the latest\n * queued task runs per cycle, while callers receive a promise that resolves\n * when the task for the cycle they joined has completed.\n */\nexport class SinglePromiseQueue {\n\t/** Next operation to execute in the queue. If attempting to enqueue another op, it will override the existing op. */\n\t#queuedOp?: () => Promise<void>;\n\n\t/** The currently running promise of #drainLoop. Do not await this, instead await `pending` to await the current cycle. */\n\trunningDrainLoop?: Promise<void>;\n\n\t/** Pending resolver fro the currently queued entry. */\n\t#pending?: ReturnType<typeof promiseWithResolvers<void>>;\n\n\t/** Queue the next operation and return a promise that resolves when it flushes. */\n\tenqueue(op: () => Promise<void>): Promise<void> {\n\t\t// Replace any previously queued operation with the latest one\n\t\tthis.#queuedOp = op;\n\n\t\t// Ensure a shared resolver exists for all callers in this cycle\n\t\tif (!this.#pending) {\n\t\t\tthis.#pending = promiseWithResolvers<void>();\n\t\t}\n\n\t\tconst waitForThisCycle = this.#pending.promise;\n\n\t\t// Start runner if not already running\n\t\tif (!this.runningDrainLoop) {\n\t\t\tthis.runningDrainLoop = this.#drainLoop();\n\t\t}\n\n\t\treturn waitForThisCycle;\n\t}\n\n\t/** Drain queued operations sequentially until there is nothing left. */\n\tasync #drainLoop(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#queuedOp) {\n\t\t\t\t// Capture current cycle resolver then reset for the next cycle\n\t\t\t\tconst resolver = this.#pending;\n\t\t\t\tthis.#pending = undefined;\n\n\t\t\t\t// Capture and clear the currently queued operation\n\t\t\t\tconst op = this.#queuedOp;\n\t\t\t\tthis.#queuedOp = undefined;\n\n\t\t\t\ttry {\n\t\t\t\t\tawait op();\n\t\t\t\t} catch {\n\t\t\t\t\t// Swallow errors: callers only await cycle completion, not success\n\t\t\t\t}\n\n\t\t\t\t// Notify all waiters for this cycle\n\t\t\t\tresolver?.resolve();\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.runningDrainLoop = undefined;\n\t\t}\n\t}\n}\n\nexport function bufferToArrayBuffer(buf: Buffer | Uint8Array): ArrayBuffer {\n\treturn buf.buffer.slice(\n\t\tbuf.byteOffset,\n\t\tbuf.byteOffset + buf.byteLength,\n\t) as ArrayBuffer;\n}\n\n/**\n * Properly combines a base URL endpoint with a path, preserving any base path in the endpoint.\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors/action\")\n * // Returns: \"http://localhost:8787/rivet/actors/action\"\n *\n * @example\n * combineUrlPath(\"http://localhost:8787/rivet\", \"/actors?type=foo\", { namespace: \"test\" })\n * // Returns: \"http://localhost:8787/rivet/actors?type=foo&namespace=test\"\n *\n * @param endpoint The base URL endpoint that may contain a path component\n * @param path The path to append to the endpoint (may include query parameters)\n * @param queryParams Optional additional query parameters to append\n * @returns The properly combined URL string\n */\nexport function combineUrlPath(\n\tendpoint: string,\n\tpath: string,\n\tqueryParams?: Record<string, string | undefined>,\n): string {\n\tconst baseUrl = new URL(endpoint);\n\n\t// Extract path and query from the provided path\n\tconst pathParts = path.split(\"?\");\n\tconst pathOnly = pathParts[0];\n\tconst existingQuery = pathParts[1] || \"\";\n\n\t// Remove trailing slash from base path and ensure path starts with /\n\tconst basePath = baseUrl.pathname.replace(/\\/$/, \"\");\n\tconst cleanPath = pathOnly.startsWith(\"/\") ? pathOnly : `/${pathOnly}`;\n\t// Combine paths and remove any double slashes\n\tconst fullPath = (basePath + cleanPath).replace(/\\/\\//g, \"/\");\n\n\t// Build query string\n\tconst queryParts: string[] = [];\n\tif (existingQuery) {\n\t\tqueryParts.push(existingQuery);\n\t}\n\tif (queryParams) {\n\t\tfor (const [key, value] of Object.entries(queryParams)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tqueryParts.push(\n\t\t\t\t\t`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst fullQuery = queryParts.length > 0 ? `?${queryParts.join(\"&\")}` : \"\";\n\treturn `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;\n}\n"],"mappings":";;;;;;;AAMO,SAAS,kBAAkB,GAAiB;AAClD,QAAM,IAAI,MAAM,qBAAqB,CAAC,EAAE;AACzC;AAqCO,SAAS,mBACf,OACA,WACA,cAAc,IACJ;AAEV,MAAI,UAAU,QAAQ,UAAU,QAAW;AAC1C,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC5B,6CAAY;AACZ,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC5D,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,MAAM;AAC1B,WAAO;AAAA,EACR;AAGA,MACC,iBAAiB,cACjB,iBAAiB,qBACjB,iBAAiB,eACjB,iBAAiB,eACjB,iBAAiB,kBACjB,iBAAiB,aACjB,iBAAiB,cACjB,iBAAiB,cACjB,iBAAiB,iBACjB,iBAAiB,gBACjB,iBAAiB,cAChB;AACD,WAAO;AAAA,EACR;AAGA,MAAI,iBAAiB,KAAK;AACzB,eAAW,CAAC,KAAK,GAAG,KAAK,MAAM,QAAQ,GAAG;AACzC,YAAM,UAAU,cACb,GAAG,WAAW,QAAQ,OAAO,GAAG,CAAC,MACjC,OAAO,OAAO,GAAG,CAAC;AACrB,YAAM,UAAU,cACb,GAAG,WAAW,UAAU,OAAO,GAAG,CAAC,MACnC,SAAS,OAAO,GAAG,CAAC;AACvB,UACC,CAAC,mBAAmB,KAAK,WAAW,OAAO,KAC3C,CAAC,mBAAmB,KAA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,IACD,UAAE;AACD,WAAK,mBAAmB;AAAA,IACzB;AAAA,EACD;AACD;AAEO,SAAS,oBAAoB,KAAuC;AAC1E,SAAO,IAAI,OAAO;AAAA,IACjB,IAAI;AAAA,IACJ,IAAI,aAAa,IAAI;AAAA,EACtB;AACD;AAkBO,SAAS,eACf,UACA,MACA,aACS;AACT,QAAM,UAAU,IAAI,IAAI,QAAQ;AAGhC,QAAM,YAAY,KAAK,MAAM,GAAG;AAChC,QAAM,WAAW,UAAU,CAAC;AAC5B,QAAM,gBAAgB,UAAU,CAAC,KAAK;AAGtC,QAAM,WAAW,QAAQ,SAAS,QAAQ,OAAO,EAAE;AACnD,QAAM,YAAY,SAAS,WAAW,GAAG,IAAI,WAAW,IAAI,QAAQ;AAEpE,QAAM,YAAY,WAAW,WAAW,QAAQ,SAAS,GAAG;AAG5D,QAAM,aAAuB,CAAC;AAC9B,MAAI,eAAe;AAClB,eAAW,KAAK,aAAa;AAAA,EAC9B;AACA,MAAI,aAAa;AAChB,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACvD,UAAI,UAAU,QAAW;AACxB,mBAAW;AAAA,UACV,GAAG,mBAAmB,GAAG,CAAC,IAAI,mBAAmB,KAAK,CAAC;AAAA,QACxD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,YAAY,WAAW,SAAS,IAAI,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK;AACvE,SAAO,GAAG,QAAQ,QAAQ,KAAK,QAAQ,IAAI,GAAG,QAAQ,GAAG,SAAS;AACnE;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMF76IOZDcjs = require('./chunk-MF76IOZD.cjs');
|
|
4
4
|
|
|
5
5
|
// src/inspector/protocol/actor.ts
|
|
6
6
|
var _client = require('hono/client');
|
|
@@ -18,7 +18,7 @@ var _factory = require('hono/factory');
|
|
|
18
18
|
|
|
19
19
|
// src/inspector/log.ts
|
|
20
20
|
function inspectorLogger() {
|
|
21
|
-
return
|
|
21
|
+
return _chunkMF76IOZDcjs.getLogger.call(void 0, "inspector");
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// src/inspector/utils.ts
|
|
@@ -100,4 +100,4 @@ var configureInspectorAccessToken = (runConfig, managerDriver) => {
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
exports.inspectorLogger = inspectorLogger; exports.compareSecrets = compareSecrets; exports.secureInspector = secureInspector; exports.getInspectorUrl = getInspectorUrl; exports.isInspectorEnabled = isInspectorEnabled; exports.configureInspectorAccessToken = configureInspectorAccessToken; exports.createActorInspectorClient = createActorInspectorClient; exports.createManagerInspectorClient = createManagerInspectorClient;
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-FNCNYJFG.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-
|
|
1
|
+
{"version":3,"sources":["/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-FNCNYJFG.cjs","../../src/inspector/protocol/actor.ts","../../src/inspector/protocol/manager.ts","../../src/inspector/utils.ts","../../src/inspector/log.ts"],"names":["client","hc"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,qCAAmB;AAInB,IAAM,OAAA,EAAS,wBAAA,EAA2B,CAAA;AAGnC,IAAM,2BAAA,EAA6B,CAAA,GACtC,IAAA,EAAA,GACuB,wBAAA,GAA4B,IAAI,CAAA;ADD3D;AACA;AETA;AAIA,IAAMA,QAAAA,EAASC,wBAAAA,EAA6B,CAAA;AAGrC,IAAM,6BAAA,EAA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CAC5C,SAAA,EACA,aAAA,EAAA,GACI;AA3FL,EAAA,IAAA,EAAA;AA4FC,EAAA,GAAA,CAAI,CAAA,CAAA,CAAC,GAAA,EAAA,SAAA,CAAU,SAAA,EAAA,GAAV,KAAA,EAAA,KAAA,EAAA,EAAA,EAAA,CAAqB,KAAA,CAAA,CAAA,CAAA,EAAS;AAClC,IAAA,MAAM,MAAA,EAAQ,aAAA,CAAc,+BAAA,CAAgC,CAAA;AAC5D,IAAA,SAAA,CAAU,SAAA,CAAU,MAAA,EAAQ,CAAA,EAAA,GAAM,KAAA;AAAA,EACnC;AACD,CAAA;AHLA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,uaAAC","file":"/Users/nathan/rivetkit/packages/rivetkit/dist/tsup/chunk-FNCNYJFG.cjs","sourcesContent":[null,"import { hc } from \"hono/client\";\nimport type { createActorInspectorRouter } from \"../actor\";\n\ntype ActorInspectorRouter = ReturnType<typeof createActorInspectorRouter>;\nconst client = hc<ActorInspectorRouter>(\"\");\nexport type ActorInspectorClient = typeof client;\n\nexport const createActorInspectorClient = (\n\t...args: Parameters<typeof hc>\n): ActorInspectorClient => hc<ActorInspectorRouter>(...args);\n","import { hc } from \"hono/client\";\nimport type { createManagerInspectorRouter } from \"../manager\";\n\ntype ManagerInspectorRouter = ReturnType<typeof createManagerInspectorRouter>;\nconst client = hc<ManagerInspectorRouter>(\"\");\nexport type ManagerInspectorClient = typeof client;\n\nexport const createManagerInspectorClient = (\n\t...args: Parameters<typeof hc>\n): ManagerInspectorClient => hc<ManagerInspectorRouter>(...args);\n","import crypto from \"node:crypto\";\nimport { createMiddleware } from \"hono/factory\";\nimport type { ManagerDriver } from \"@/driver-helpers/mod\";\nimport type { RunConfig } from \"@/mod\";\nimport type { RunnerConfigInput } from \"@/registry/run-config\";\nimport { inspectorLogger } from \"./log\";\n\nexport function compareSecrets(providedSecret: string, validSecret: string) {\n\t// Early length check to avoid unnecessary processing\n\tif (providedSecret.length !== validSecret.length) {\n\t\treturn false;\n\t}\n\n\tconst encoder = new TextEncoder();\n\n\tconst a = encoder.encode(providedSecret);\n\tconst b = encoder.encode(validSecret);\n\n\tif (a.byteLength !== b.byteLength) {\n\t\treturn false;\n\t}\n\n\t// Perform timing-safe comparison\n\tif (!crypto.timingSafeEqual(a, b)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport const secureInspector = (runConfig: RunConfig) =>\n\tcreateMiddleware(async (c, next) => {\n\t\tconst userToken = c.req.header(\"Authorization\")?.replace(\"Bearer \", \"\");\n\t\tif (!userToken) {\n\t\t\treturn c.text(\"Unauthorized\", 401);\n\t\t}\n\n\t\tconst inspectorToken = runConfig.inspector.token?.();\n\t\tif (!inspectorToken) {\n\t\t\treturn c.text(\"Unauthorized\", 401);\n\t\t}\n\n\t\tconst isValid = compareSecrets(userToken, inspectorToken);\n\n\t\tif (!isValid) {\n\t\t\treturn c.text(\"Unauthorized\", 401);\n\t\t}\n\t\tawait next();\n\t});\n\nexport function getInspectorUrl(runConfig: RunnerConfigInput | undefined) {\n\tif (!runConfig?.inspector?.enabled) {\n\t\treturn \"disabled\";\n\t}\n\n\tconst accessToken = runConfig?.inspector?.token?.();\n\n\tif (!accessToken) {\n\t\tinspectorLogger().warn(\n\t\t\t\"Inspector Token is not set, but Inspector is enabled. Please set it in the run configuration `inspector.token` or via `RIVETKIT_INSPECTOR_TOKEN` environment variable. Inspector will not be accessible.\",\n\t\t);\n\t\treturn \"disabled\";\n\t}\n\n\tconst url = new URL(\"https://inspect.rivet.dev\");\n\n\turl.searchParams.set(\"t\", accessToken);\n\n\tconst overrideDefaultEndpoint =\n\t\trunConfig?.inspector?.defaultEndpoint ?? runConfig.overrideServerAddress;\n\tif (overrideDefaultEndpoint) {\n\t\turl.searchParams.set(\"u\", overrideDefaultEndpoint);\n\t}\n\n\treturn url.href;\n}\n\nexport const isInspectorEnabled = (\n\trunConfig: RunConfig,\n\tcontext: \"actor\" | \"manager\",\n) => {\n\tif (typeof runConfig.inspector?.enabled === \"boolean\") {\n\t\treturn runConfig.inspector.enabled;\n\t} else if (typeof runConfig.inspector?.enabled === \"object\") {\n\t\treturn runConfig.inspector.enabled[context];\n\t}\n\treturn false;\n};\n\nexport const configureInspectorAccessToken = (\n\trunConfig: RunConfig,\n\tmanagerDriver: ManagerDriver,\n) => {\n\tif (!runConfig.inspector?.token()) {\n\t\tconst token = managerDriver.getOrCreateInspectorAccessToken();\n\t\trunConfig.inspector.token = () => token;\n\t}\n};\n","import { getLogger } from \"@/common/log\";\n\nexport function inspectorLogger() {\n\treturn getLogger(\"inspector\");\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLogger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PO352AW7.js";
|
|
4
4
|
|
|
5
5
|
// src/client/log.ts
|
|
6
6
|
function logger() {
|
|
@@ -42,4 +42,4 @@ export {
|
|
|
42
42
|
logger,
|
|
43
43
|
importWebSocket
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-FNQGHSFJ.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
inspectorLogger,
|
|
5
5
|
isInspectorEnabled,
|
|
6
6
|
secureInspector
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5C3MRFAU.js";
|
|
8
8
|
import {
|
|
9
9
|
ActorDefinition,
|
|
10
10
|
RemoteManagerDriver,
|
|
@@ -12,15 +12,18 @@ import {
|
|
|
12
12
|
createClientWithDriver,
|
|
13
13
|
deserializeActorKey,
|
|
14
14
|
generateConnSocketId,
|
|
15
|
+
getDatacenters,
|
|
15
16
|
getEndpoint,
|
|
16
17
|
lookupInRegistry,
|
|
17
|
-
serializeActorKey
|
|
18
|
-
|
|
18
|
+
serializeActorKey,
|
|
19
|
+
updateRunnerConfig
|
|
20
|
+
} from "./chunk-ZD5CZSSF.js";
|
|
19
21
|
import {
|
|
20
22
|
CreateActorSchema
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-3LGDBNZG.js";
|
|
22
24
|
import {
|
|
23
25
|
ActionContext,
|
|
26
|
+
ClientConfigSchema,
|
|
24
27
|
HTTP_ACTION_REQUEST_VERSIONED,
|
|
25
28
|
HTTP_ACTION_RESPONSE_VERSIONED,
|
|
26
29
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
@@ -29,7 +32,7 @@ import {
|
|
|
29
32
|
createVersionedDataHandler,
|
|
30
33
|
parseMessage,
|
|
31
34
|
serializeEmptyPersistData
|
|
32
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XQR2BHQP.js";
|
|
33
36
|
import {
|
|
34
37
|
EncodingSchema,
|
|
35
38
|
HEADER_ACTOR_ID,
|
|
@@ -55,12 +58,12 @@ import {
|
|
|
55
58
|
generateRandomString,
|
|
56
59
|
loggerWithoutContext,
|
|
57
60
|
serializeWithEncoding
|
|
58
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-HY3MZSKX.js";
|
|
59
62
|
import {
|
|
60
63
|
configureBaseLogger,
|
|
61
64
|
configureDefaultLogger,
|
|
62
65
|
getLogger
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-PO352AW7.js";
|
|
64
67
|
import {
|
|
65
68
|
VERSION,
|
|
66
69
|
assertUnreachable,
|
|
@@ -71,7 +74,7 @@ import {
|
|
|
71
74
|
promiseWithResolvers,
|
|
72
75
|
setLongTimeout,
|
|
73
76
|
stringifyError
|
|
74
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-EY5EMNAB.js";
|
|
75
78
|
import {
|
|
76
79
|
ActorAlreadyExists,
|
|
77
80
|
ConnNotFound,
|
|
@@ -84,7 +87,7 @@ import {
|
|
|
84
87
|
Unsupported,
|
|
85
88
|
UserError,
|
|
86
89
|
WebSocketsNotEnabled
|
|
87
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-G64QUEDJ.js";
|
|
88
91
|
|
|
89
92
|
// src/actor/config.ts
|
|
90
93
|
import { z } from "zod";
|
|
@@ -883,6 +886,24 @@ function handleRouteError(error, c) {
|
|
|
883
886
|
);
|
|
884
887
|
return c.body(output, { status: statusCode });
|
|
885
888
|
}
|
|
889
|
+
function handleMetadataRequest(c, runConfig) {
|
|
890
|
+
const response = {
|
|
891
|
+
runtime: "rivetkit",
|
|
892
|
+
version: VERSION,
|
|
893
|
+
runner: {
|
|
894
|
+
kind: runConfig.runnerKind === "serverless" ? { serverless: {} } : { normal: {} }
|
|
895
|
+
},
|
|
896
|
+
clientEndpoint: getEndpoint(runConfig)
|
|
897
|
+
};
|
|
898
|
+
return c.json(response);
|
|
899
|
+
}
|
|
900
|
+
function handleHealthRequest(c) {
|
|
901
|
+
return c.json({
|
|
902
|
+
status: "ok",
|
|
903
|
+
runtime: "rivetkit",
|
|
904
|
+
version: VERSION
|
|
905
|
+
});
|
|
906
|
+
}
|
|
886
907
|
|
|
887
908
|
// src/actor/router.ts
|
|
888
909
|
function createActorRouter(runConfig, actorDriver, isTest) {
|
|
@@ -1537,14 +1558,7 @@ var EngineActorDriver = class {
|
|
|
1537
1558
|
async readPersistedData(actorId) {
|
|
1538
1559
|
const handler = this.#actors.get(actorId);
|
|
1539
1560
|
if (!handler) throw new Error(`Actor ${actorId} not loaded`);
|
|
1540
|
-
|
|
1541
|
-
const [value] = await this.#runner.kvGet(actorId, [KEYS.PERSIST_DATA]);
|
|
1542
|
-
if (value !== null) {
|
|
1543
|
-
handler.persistedData = value;
|
|
1544
|
-
return value;
|
|
1545
|
-
} else {
|
|
1546
|
-
return void 0;
|
|
1547
|
-
}
|
|
1561
|
+
return handler.persistedData;
|
|
1548
1562
|
}
|
|
1549
1563
|
async writePersistedData(actorId, data) {
|
|
1550
1564
|
const handler = this.#actors.get(actorId);
|
|
@@ -1585,9 +1599,13 @@ var EngineActorDriver = class {
|
|
|
1585
1599
|
if (!handler) {
|
|
1586
1600
|
handler = {
|
|
1587
1601
|
actorStartPromise: promiseWithResolvers(),
|
|
1588
|
-
persistedData:
|
|
1602
|
+
persistedData: void 0
|
|
1589
1603
|
};
|
|
1590
1604
|
this.#actors.set(actorId, handler);
|
|
1605
|
+
const [persistedValue] = await this.#runner.kvGet(actorId, [
|
|
1606
|
+
KEYS.PERSIST_DATA
|
|
1607
|
+
]);
|
|
1608
|
+
handler.persistedData = persistedValue !== null ? persistedValue : serializeEmptyPersistData(input);
|
|
1591
1609
|
}
|
|
1592
1610
|
const name = runConfig.name;
|
|
1593
1611
|
invariant3(runConfig.key, "actor should have a key");
|
|
@@ -2547,7 +2565,10 @@ var FileSystemManagerDriver = class {
|
|
|
2547
2565
|
};
|
|
2548
2566
|
});
|
|
2549
2567
|
}
|
|
2550
|
-
const inlineClient = createClientWithDriver(
|
|
2568
|
+
const inlineClient = createClientWithDriver(
|
|
2569
|
+
this,
|
|
2570
|
+
ClientConfigSchema.parse({})
|
|
2571
|
+
);
|
|
2551
2572
|
this.#actorDriver = this.#driverConfig.actor(
|
|
2552
2573
|
registryConfig,
|
|
2553
2574
|
runConfig,
|
|
@@ -2744,11 +2765,6 @@ function chooseDefaultDriver(runConfig) {
|
|
|
2744
2765
|
"Cannot specify both 'endpoint' and 'driver' in configuration"
|
|
2745
2766
|
);
|
|
2746
2767
|
}
|
|
2747
|
-
if (runConfig.runnerKind === "serverless" && !runConfig.endpoint) {
|
|
2748
|
-
throw new UserError(
|
|
2749
|
-
"Cannot use 'serverless' runnerKind without the 'endpoint' config set."
|
|
2750
|
-
);
|
|
2751
|
-
}
|
|
2752
2768
|
if (runConfig.driver) {
|
|
2753
2769
|
return runConfig.driver;
|
|
2754
2770
|
}
|
|
@@ -3468,13 +3484,8 @@ function addServerlessRoutes(driverConfig, registryConfig, runConfig, managerDri
|
|
|
3468
3484
|
);
|
|
3469
3485
|
return await actorDriver.serverlessHandleStart(c);
|
|
3470
3486
|
});
|
|
3471
|
-
router.get("/health", (c) =>
|
|
3472
|
-
|
|
3473
|
-
status: "ok",
|
|
3474
|
-
runtime: "rivetkit",
|
|
3475
|
-
version: VERSION
|
|
3476
|
-
});
|
|
3477
|
-
});
|
|
3487
|
+
router.get("/health", (c) => handleHealthRequest(c));
|
|
3488
|
+
router.get("/metadata", (c) => handleMetadataRequest(c, runConfig));
|
|
3478
3489
|
}
|
|
3479
3490
|
function addManagerRoutes(registryConfig, runConfig, managerDriver, router) {
|
|
3480
3491
|
var _a;
|
|
@@ -3790,14 +3801,8 @@ function addManagerRoutes(registryConfig, runConfig, managerDriver, router) {
|
|
|
3790
3801
|
}
|
|
3791
3802
|
});
|
|
3792
3803
|
}
|
|
3793
|
-
router.get("/health", (c) =>
|
|
3794
|
-
|
|
3795
|
-
status: "ok",
|
|
3796
|
-
rivetkit: {
|
|
3797
|
-
version: VERSION
|
|
3798
|
-
}
|
|
3799
|
-
});
|
|
3800
|
-
});
|
|
3804
|
+
router.get("/health", (c) => handleHealthRequest(c));
|
|
3805
|
+
router.get("/metadata", (c) => handleMetadataRequest(c, runConfig));
|
|
3801
3806
|
(_a = managerDriver.modifyManagerRouter) == null ? void 0 : _a.call(
|
|
3802
3807
|
managerDriver,
|
|
3803
3808
|
registryConfig,
|
|
@@ -4027,23 +4032,28 @@ async function configureServerlessRunner(config2) {
|
|
|
4027
4032
|
throw new Error("endpoint is required for serverless configuration");
|
|
4028
4033
|
}
|
|
4029
4034
|
const customConfig = typeof config2.autoConfigureServerless === "object" ? config2.autoConfigureServerless : {};
|
|
4030
|
-
const
|
|
4035
|
+
const clientConfig = {
|
|
4036
|
+
endpoint: config2.endpoint,
|
|
4037
|
+
token: config2.token,
|
|
4038
|
+
namespace: config2.namespace,
|
|
4039
|
+
runnerName: config2.runnerName,
|
|
4040
|
+
encoding: config2.encoding,
|
|
4041
|
+
transport: config2.transport,
|
|
4042
|
+
headers: config2.headers,
|
|
4043
|
+
getUpgradeWebSocket: config2.getUpgradeWebSocket,
|
|
4044
|
+
disableHealthCheck: true
|
|
4045
|
+
// We don't need health check for this operation
|
|
4046
|
+
};
|
|
4031
4047
|
logger7().debug({
|
|
4032
4048
|
msg: "fetching datacenters",
|
|
4033
|
-
|
|
4049
|
+
endpoint: config2.endpoint
|
|
4034
4050
|
});
|
|
4035
|
-
const
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4051
|
+
const dcsRes = await getDatacenters(clientConfig);
|
|
4052
|
+
logger7().debug({
|
|
4053
|
+
msg: "configuring serverless runner",
|
|
4054
|
+
runnerName: config2.runnerName,
|
|
4055
|
+
namespace: config2.namespace
|
|
4039
4056
|
});
|
|
4040
|
-
if (!dcsResponse.ok) {
|
|
4041
|
-
const errorText = await dcsResponse.text();
|
|
4042
|
-
throw new Error(
|
|
4043
|
-
`failed to configure serverless runner: ${dcsResponse.status} ${dcsResponse.statusText} - ${errorText}`
|
|
4044
|
-
);
|
|
4045
|
-
}
|
|
4046
|
-
const dcsRes = await dcsResponse.json();
|
|
4047
4057
|
const serverlessConfig = {
|
|
4048
4058
|
serverless: {
|
|
4049
4059
|
url: customConfig.url || `http://localhost:${config2.defaultServerPort}/start`,
|
|
@@ -4055,29 +4065,11 @@ async function configureServerlessRunner(config2) {
|
|
|
4055
4065
|
slots_per_runner: customConfig.slotsPerRunner ?? config2.totalSlots ?? 1e3
|
|
4056
4066
|
}
|
|
4057
4067
|
};
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
logger7().debug({
|
|
4063
|
-
msg: "configuring serverless runner",
|
|
4064
|
-
url: configUrl,
|
|
4065
|
-
config: serverlessConfig.serverless
|
|
4068
|
+
await updateRunnerConfig(clientConfig, config2.runnerName, {
|
|
4069
|
+
datacenters: Object.fromEntries(
|
|
4070
|
+
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
4071
|
+
)
|
|
4066
4072
|
});
|
|
4067
|
-
const response = await fetch(configUrl, {
|
|
4068
|
-
method: "PUT",
|
|
4069
|
-
headers: {
|
|
4070
|
-
"Content-Type": "application/json",
|
|
4071
|
-
...config2.token ? { Authorization: `Bearer ${config2.token}` } : {}
|
|
4072
|
-
},
|
|
4073
|
-
body: JSON.stringify(requestBody)
|
|
4074
|
-
});
|
|
4075
|
-
if (!response.ok) {
|
|
4076
|
-
const errorText = await response.text();
|
|
4077
|
-
throw new Error(
|
|
4078
|
-
`failed to configure serverless runner: ${response.status} ${response.statusText} - ${errorText}`
|
|
4079
|
-
);
|
|
4080
|
-
}
|
|
4081
4073
|
logger7().info({
|
|
4082
4074
|
msg: "serverless runner configured successfully",
|
|
4083
4075
|
runnerName: config2.runnerName,
|
|
@@ -4112,4 +4104,4 @@ export {
|
|
|
4112
4104
|
setup
|
|
4113
4105
|
};
|
|
4114
4106
|
//! These configs configs hold anything that's not platform-specific about running actors.
|
|
4115
|
-
//# sourceMappingURL=chunk-
|
|
4107
|
+
//# sourceMappingURL=chunk-G3R2O5VL.js.map
|