@rivetkit/supabase 2.3.18-rc.2 → 2.3.18-rc.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.
Files changed (3) hide show
  1. package/dist/mod.js +1021 -1019
  2. package/dist/mod.mjs +1023 -1021
  3. package/package.json +3 -3
package/dist/mod.js CHANGED
@@ -335,6 +335,193 @@ __export(mod_exports, {
335
335
  module.exports = __toCommonJS(mod_exports);
336
336
  var wasmBindings = __toESM(require("@rivetkit/rivetkit-wasm"));
337
337
 
338
+ // ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
339
+ var INTERNAL_ERROR_CODE = "internal_error";
340
+ var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
341
+ var USER_ERROR_CODE = "user_error";
342
+ var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
343
+ function looksLikeRivetErrorOptions(value) {
344
+ return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
345
+ }
346
+ function isTypedErrorTag(value) {
347
+ return value === "ActorError" || value === "RivetError";
348
+ }
349
+ function errorMessage(error46, fallback = String(error46)) {
350
+ if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
351
+ return error46.message;
352
+ }
353
+ return fallback;
354
+ }
355
+ function isRivetErrorLike(error46) {
356
+ return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
357
+ }
358
+ function isActorAbortedError(error46) {
359
+ return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
360
+ }
361
+ function isActorSpecifier(value) {
362
+ return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
363
+ }
364
+ var RivetError = class extends Error {
365
+ __type = "RivetError";
366
+ public;
367
+ metadata;
368
+ rayId;
369
+ statusCode;
370
+ actor;
371
+ group;
372
+ code;
373
+ static isRivetError(error46) {
374
+ return isRivetErrorLike(error46);
375
+ }
376
+ static isActorError(error46) {
377
+ return isRivetErrorLike(error46);
378
+ }
379
+ constructor(group, code, message, options) {
380
+ const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
381
+ super(message, { cause: normalized.cause });
382
+ this.name = "RivetError";
383
+ this.group = group;
384
+ this.code = code;
385
+ this.public = normalized.public ?? false;
386
+ this.metadata = normalized.metadata;
387
+ this.rayId = normalized.rayId ?? void 0;
388
+ this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
389
+ this.actor = normalized.actor;
390
+ }
391
+ toString() {
392
+ return this.message;
393
+ }
394
+ };
395
+ var UserError = class extends RivetError {
396
+ constructor(message, options) {
397
+ super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
398
+ public: true,
399
+ metadata: options == null ? void 0 : options.metadata,
400
+ cause: options == null ? void 0 : options.cause
401
+ });
402
+ }
403
+ };
404
+ function toRivetError(error46, fallback) {
405
+ if (typeof error46 === "string") {
406
+ const bridged = decodeBridgeRivetError(error46);
407
+ if (bridged) {
408
+ return bridged;
409
+ }
410
+ }
411
+ if (error46 instanceof Error) {
412
+ const bridged = decodeBridgeRivetError(error46.message);
413
+ if (bridged) {
414
+ return bridged;
415
+ }
416
+ }
417
+ if (isRivetErrorLike(error46)) {
418
+ return new RivetError(error46.group, error46.code, error46.message, {
419
+ public: error46.public,
420
+ statusCode: error46.statusCode,
421
+ metadata: error46.metadata,
422
+ rayId: error46.rayId,
423
+ actor: error46.actor,
424
+ cause: error46 instanceof Error ? error46.cause : void 0
425
+ });
426
+ }
427
+ return new RivetError(
428
+ (fallback == null ? void 0 : fallback.group) ?? "actor",
429
+ (fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
430
+ errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
431
+ {
432
+ public: fallback == null ? void 0 : fallback.public,
433
+ statusCode: fallback == null ? void 0 : fallback.statusCode,
434
+ metadata: fallback == null ? void 0 : fallback.metadata,
435
+ rayId: fallback == null ? void 0 : fallback.rayId,
436
+ actor: fallback == null ? void 0 : fallback.actor,
437
+ cause: error46 instanceof Error ? error46 : void 0
438
+ }
439
+ );
440
+ }
441
+ function encodeBridgeRivetError(error46) {
442
+ return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
443
+ group: error46.group,
444
+ code: error46.code,
445
+ message: error46.message,
446
+ metadata: error46.metadata,
447
+ rayId: error46.rayId,
448
+ public: error46.public,
449
+ statusCode: error46.statusCode,
450
+ actor: error46.actor
451
+ })}`;
452
+ }
453
+ function decodeBridgeRivetErrorPayload(value) {
454
+ if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
455
+ return void 0;
456
+ }
457
+ try {
458
+ const raw = JSON.parse(
459
+ value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
460
+ );
461
+ const payload = {
462
+ ...raw,
463
+ rayId: raw.rayId ?? void 0
464
+ };
465
+ if (!isRivetErrorLike(payload)) {
466
+ return void 0;
467
+ }
468
+ if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
469
+ return void 0;
470
+ }
471
+ return payload;
472
+ } catch {
473
+ return void 0;
474
+ }
475
+ }
476
+ function decodeBridgeRivetError(value) {
477
+ const payload = decodeBridgeRivetErrorPayload(value);
478
+ if (!payload) {
479
+ return void 0;
480
+ }
481
+ return new RivetError(payload.group, payload.code, payload.message, {
482
+ metadata: payload.metadata,
483
+ rayId: payload.rayId,
484
+ public: payload.public,
485
+ statusCode: payload.statusCode,
486
+ actor: payload.actor ?? void 0
487
+ });
488
+ }
489
+ function invalidRequest(error46) {
490
+ return new RivetError(
491
+ "request",
492
+ "invalid",
493
+ `Invalid request: ${errorMessage(error46, String(error46))}`,
494
+ {
495
+ public: true,
496
+ cause: error46 instanceof Error ? error46 : void 0
497
+ }
498
+ );
499
+ }
500
+ function actorNotFound(identifier) {
501
+ return new RivetError(
502
+ "actor",
503
+ "not_found",
504
+ identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
505
+ { public: true }
506
+ );
507
+ }
508
+ function forbiddenError() {
509
+ return new RivetError("auth", "forbidden", "Forbidden", {
510
+ public: true,
511
+ statusCode: 403
512
+ });
513
+ }
514
+ function unsupportedFeature(feature) {
515
+ return new RivetError(
516
+ "feature",
517
+ "unsupported",
518
+ `Unsupported feature: ${feature}`
519
+ );
520
+ }
521
+
522
+ // ../rivetkit/dist/tsup/chunk-KGARR4E2.js
523
+ var import_pino = require("pino");
524
+
338
525
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
339
526
  var external_exports = {};
340
527
  __export(external_exports, {
@@ -13005,830 +13192,181 @@ var classic_default = external_exports;
13005
13192
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13006
13193
  var v4_default = classic_default;
13007
13194
 
13008
- // ../rivetkit/dist/tsup/chunk-6W5VGLFT.js
13009
- function flattenActionHandlers(actions) {
13010
- const flattened = /* @__PURE__ */ Object.create(null);
13011
- for (const { name, handler } of collectActionEntries(actions)) {
13012
- flattened[name] = handler;
13195
+ // ../rivetkit/dist/tsup/chunk-KGARR4E2.js
13196
+ var cbor = __toESM(require("cbor-x"), 1);
13197
+ var import_invariant = __toESM(require_invariant(), 1);
13198
+ var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
13199
+ var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
13200
+ var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
13201
+ var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
13202
+ var getRivetPool = () => getEnvUniversal("RIVET_POOL");
13203
+ var getRivetTotalSlots = () => {
13204
+ const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
13205
+ return value !== void 0 ? parseInt(value, 10) : void 0;
13206
+ };
13207
+ var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
13208
+ var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
13209
+ var getRivetRunEnginePort = () => {
13210
+ const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
13211
+ return value !== void 0 ? parseInt(value, 10) : void 0;
13212
+ };
13213
+ var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
13214
+ var getRivetRunServices = () => {
13215
+ const value = getEnvUniversal("RIVET_RUN_SERVICES");
13216
+ return value === void 0 ? void 0 : value === "1";
13217
+ };
13218
+ var getRivetEnvoyVersion = () => {
13219
+ const value = getEnvUniversal("RIVET_ENVOY_VERSION");
13220
+ return value !== void 0 ? parseInt(value, 10) : void 0;
13221
+ };
13222
+ var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
13223
+ var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
13224
+ var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
13225
+ var getRivetkitRuntimeMode = () => {
13226
+ const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
13227
+ if (value === void 0) return "envoy";
13228
+ if (value === "envoy" || value === "serverless") return value;
13229
+ throw new Error(
13230
+ `RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
13231
+ );
13232
+ };
13233
+ var getRivetkitPublicDir = () => {
13234
+ const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
13235
+ return value === void 0 || value === "" ? void 0 : value;
13236
+ };
13237
+ function parsePortEnv(raw) {
13238
+ if (raw === void 0 || raw === "") return void 0;
13239
+ const parsed = Number.parseInt(raw, 10);
13240
+ if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
13241
+ throw new Error(
13242
+ `RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
13243
+ );
13013
13244
  }
13014
- return flattened;
13245
+ return parsed;
13015
13246
  }
13016
- function flattenActionInputSchemas(actions, schemas) {
13017
- if (schemas === void 0) return void 0;
13018
- if (!isRecord(schemas)) {
13019
- throw new TypeError("actionInputSchemas must be an object");
13020
- }
13021
- const flattened = /* @__PURE__ */ Object.create(null);
13022
- for (const { name, path: path2 } of collectActionEntries(actions)) {
13023
- const nestedSchema = lookupNestedSchema(schemas, path2);
13024
- const flatSchema = schemas[name];
13025
- if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
13026
- throw new TypeError(
13027
- `Action input schema \`${name}\` is defined by both a nested path and a dotted key`
13028
- );
13029
- }
13030
- const schema = nestedSchema ?? flatSchema;
13031
- if (schema !== void 0) {
13032
- flattened[name] = schema;
13033
- }
13034
- }
13035
- return flattened;
13247
+ var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
13248
+ var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
13249
+ var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
13250
+ var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
13251
+ var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
13252
+ var getNodeEnv = () => getEnvUniversal("NODE_ENV");
13253
+ var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
13254
+ var isDev = () => getNodeEnv() !== "production";
13255
+ function assertUnreachable(x) {
13256
+ throw new Error(`Unreachable case: ${x}`);
13036
13257
  }
13037
- function collectActionEntries(actions) {
13038
- const entries = [];
13039
- const names = /* @__PURE__ */ new Set();
13040
- visitActionGroup(actions ?? {}, [], entries, names);
13041
- return entries;
13258
+ function isCanonicalStructuredRivetError(error46) {
13259
+ return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
13042
13260
  }
13043
- function visitActionGroup(value, path2, entries, names) {
13044
- if (!isRecord(value)) {
13045
- throw new TypeError(
13046
- `${formatActionPath(path2)} must be an action handler or group`
13047
- );
13048
- }
13049
- for (const [segment, child] of Object.entries(value)) {
13050
- const childPath = [...path2, segment];
13051
- if (typeof child === "function") {
13052
- const name = childPath.join(".");
13053
- if (names.has(name)) {
13054
- throw new TypeError(
13055
- `Multiple action definitions flatten to \`${name}\``
13056
- );
13057
- }
13058
- names.add(name);
13059
- entries.push({
13060
- name,
13061
- path: childPath,
13062
- handler: child
13063
- });
13261
+ function deconstructError(error46, exposeInternalError = false) {
13262
+ let statusCode;
13263
+ let public_;
13264
+ let group;
13265
+ let code;
13266
+ let message;
13267
+ let metadata;
13268
+ let rayId;
13269
+ let actor2;
13270
+ if (isCanonicalStructuredRivetError(error46)) {
13271
+ statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
13272
+ public_ = error46.public ?? false;
13273
+ group = error46.group;
13274
+ code = error46.code;
13275
+ message = error46.message;
13276
+ metadata = error46.metadata;
13277
+ rayId = error46.rayId;
13278
+ actor2 = error46.actor;
13279
+ } else if (RivetError.isActorError(error46) && error46.public) {
13280
+ statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
13281
+ public_ = true;
13282
+ group = error46.group;
13283
+ code = error46.code;
13284
+ message = getErrorMessage(error46);
13285
+ metadata = error46.metadata;
13286
+ rayId = error46.rayId;
13287
+ actor2 = error46.actor;
13288
+ } else if (exposeInternalError) {
13289
+ if (RivetError.isActorError(error46)) {
13290
+ statusCode = 500;
13291
+ public_ = false;
13292
+ group = error46.group;
13293
+ code = error46.code;
13294
+ message = getErrorMessage(error46);
13295
+ metadata = error46.metadata;
13296
+ rayId = error46.rayId;
13297
+ actor2 = error46.actor;
13064
13298
  } else {
13065
- visitActionGroup(child, childPath, entries, names);
13299
+ statusCode = 500;
13300
+ public_ = false;
13301
+ group = "rivetkit";
13302
+ code = INTERNAL_ERROR_CODE;
13303
+ message = getErrorMessage(error46);
13304
+ }
13305
+ } else {
13306
+ statusCode = 500;
13307
+ public_ = false;
13308
+ group = "rivetkit";
13309
+ code = INTERNAL_ERROR_CODE;
13310
+ message = INTERNAL_ERROR_DESCRIPTION;
13311
+ if (RivetError.isActorError(error46)) {
13312
+ actor2 = error46.actor;
13066
13313
  }
13314
+ metadata = {
13315
+ //url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
13316
+ };
13067
13317
  }
13318
+ return {
13319
+ __type: "ActorError",
13320
+ statusCode,
13321
+ public: public_,
13322
+ group,
13323
+ code,
13324
+ message,
13325
+ metadata,
13326
+ rayId,
13327
+ actor: actor2
13328
+ };
13068
13329
  }
13069
- function lookupNestedSchema(schemas, path2) {
13070
- let value = schemas;
13071
- for (const segment of path2) {
13072
- if (!isRecord(value) || !Object.hasOwn(value, segment)) {
13073
- return void 0;
13330
+ function stringifyError(error46) {
13331
+ if (error46 instanceof Error) {
13332
+ if (typeof process !== "undefined" && getLogErrorStack()) {
13333
+ let stack;
13334
+ try {
13335
+ stack = error46.stack;
13336
+ } catch {
13337
+ stack = void 0;
13338
+ }
13339
+ return `${error46.name}: ${error46.message}${stack ? `
13340
+ ${stack}` : ""}`;
13341
+ } else {
13342
+ return `${error46.name}: ${error46.message}`;
13074
13343
  }
13075
- value = value[segment];
13344
+ } else if (typeof error46 === "string") {
13345
+ return error46;
13346
+ } else if (typeof error46 === "object" && error46 !== null) {
13347
+ try {
13348
+ return `${JSON.stringify(error46)}`;
13349
+ } catch {
13350
+ return "[cannot stringify error]";
13351
+ }
13352
+ } else {
13353
+ return `Unknown error: ${getErrorMessage(error46)}`;
13076
13354
  }
13077
- return value;
13078
13355
  }
13079
- function isRecord(value) {
13080
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
13081
- return false;
13356
+ function getErrorMessage(err) {
13357
+ if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
13358
+ return err.message;
13359
+ } else {
13360
+ return String(err);
13082
13361
  }
13083
- const prototype = Object.getPrototypeOf(value);
13084
- return prototype === Object.prototype || prototype === null;
13085
13362
  }
13086
- function formatActionPath(path2) {
13087
- return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
13088
- }
13089
- var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
13090
- var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
13091
- "rivetkit.actor_context_internal"
13092
- );
13093
- var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
13094
- var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
13095
- var zFunction = () => external_exports.custom((val) => typeof val === "function");
13096
- var zActionTree = external_exports.custom((value) => {
13097
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
13098
- return false;
13099
- }
13100
- const prototype = Object.getPrototypeOf(value);
13101
- return prototype === Object.prototype || prototype === null;
13102
- }).superRefine((actions, ctx) => {
13103
- try {
13104
- flattenActionHandlers(actions);
13105
- } catch (error46) {
13106
- ctx.addIssue({
13107
- code: "custom",
13108
- message: error46 instanceof Error ? error46.message : "Invalid action definition"
13109
- });
13110
- }
13111
- });
13112
- var WorkflowInspectorConfigSchema = external_exports.object({
13113
- getHistory: zFunction(),
13114
- getState: zFunction().optional(),
13115
- onHistoryUpdated: zFunction().optional(),
13116
- replayFromStep: zFunction().optional()
13117
- });
13118
- var RunInspectorConfigSchema = external_exports.object({
13119
- workflow: WorkflowInspectorConfigSchema.optional()
13120
- }).optional();
13121
- var BUILTIN_INSPECTOR_TAB_IDS = [
13122
- "workflow",
13123
- "database",
13124
- "state",
13125
- "queue",
13126
- "schedules",
13127
- "connections",
13128
- "console"
13129
- ];
13130
- var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
13131
- var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
13132
- var CustomInspectorTabEntrySchema = external_exports.object({
13133
- id: external_exports.string().regex(
13134
- CUSTOM_INSPECTOR_TAB_ID_RE,
13135
- "inspector.tabs[].id must contain only letters, digits, underscore, or dash"
13136
- ),
13137
- label: external_exports.string().min(1),
13138
- source: external_exports.string().min(1),
13139
- /**
13140
- * Optional icon id. The dashboard maps strings to glyphs (see its
13141
- * icon registry); unknown ids fall back to a generic icon.
13142
- */
13143
- icon: external_exports.string().min(1).optional(),
13144
- hidden: external_exports.literal(false).optional()
13145
- }).strict();
13146
- var HideInspectorTabEntrySchema = external_exports.object({
13147
- id: BuiltinInspectorTabIdSchema,
13148
- hidden: external_exports.literal(true)
13149
- }).strict();
13150
- var InspectorTabEntrySchema = external_exports.union([
13151
- CustomInspectorTabEntrySchema,
13152
- HideInspectorTabEntrySchema
13153
- ]);
13154
- var ActorInspectorConfigSchema = external_exports.object({
13155
- tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
13156
- }).strict().refine(
13157
- (data) => {
13158
- const ids = data.tabs.map((t) => t.id);
13159
- return new Set(ids).size === ids.length;
13160
- },
13161
- { message: "Duplicate id in inspector.tabs", path: ["tabs"] }
13162
- ).refine(
13163
- (data) => {
13164
- const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
13165
- return data.tabs.every(
13166
- (t) => t.hidden === true || !builtinSet.has(t.id)
13167
- );
13168
- },
13169
- {
13170
- message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
13171
- path: ["tabs"]
13172
- }
13173
- );
13174
- var RunConfigSchema = external_exports.object({
13175
- /** Display name for the actor in the Inspector UI. */
13176
- name: external_exports.string().optional(),
13177
- /** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
13178
- icon: external_exports.string().optional(),
13179
- /** The run handler function. */
13180
- run: zFunction(),
13181
- /** Inspector integration for long-running run handlers. */
13182
- inspector: RunInspectorConfigSchema.optional()
13183
- });
13184
- var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
13185
- function defineRunHandler(run, options) {
13186
- if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
13187
- throw new TypeError(
13188
- "defineRunHandler requires inspectorKind and createInspector together"
13189
- );
13190
- }
13191
- Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
13192
- configurable: false,
13193
- enumerable: false,
13194
- writable: false,
13195
- value: {
13196
- name: options.name,
13197
- icon: options.icon,
13198
- inspectorKind: options.inspectorKind,
13199
- createInspector: options.createInspector
13200
- }
13201
- });
13202
- return run;
13203
- }
13204
- function getRunInspectorKind(run) {
13205
- var _a2;
13206
- if (!run || typeof run !== "function") return void 0;
13207
- return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
13208
- }
13209
- function createRunInspector(run, context) {
13210
- var _a2, _b;
13211
- if (!run || typeof run !== "function") return void 0;
13212
- return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
13213
- }
13214
- var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
13215
- function getRunFunction(run) {
13216
- if (!run) return void 0;
13217
- if (typeof run === "function") return run;
13218
- return run.run;
13219
- }
13220
- function getRunMetadata(run) {
13221
- if (!run) return {};
13222
- if (typeof run === "function") {
13223
- const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
13224
- if (!config3) return {};
13225
- return { name: config3.name, icon: config3.icon };
13226
- }
13227
- return { name: run.name, icon: run.icon };
13228
- }
13229
- function getRunInspectorConfig(run, actor2) {
13230
- if (!run) return void 0;
13231
- if (typeof run === "function") {
13232
- const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
13233
- return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
13234
- }
13235
- return run.inspector;
13236
- }
13237
- function hasRunInspectorConfig(run) {
13238
- if (!run) return false;
13239
- if (typeof run !== "function") return run.inspector !== void 0;
13240
- const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
13241
- return (config3 == null ? void 0 : config3.inspectorKind) !== void 0 || (config3 == null ? void 0 : config3.createInspector) !== void 0 || (config3 == null ? void 0 : config3.inspector) !== void 0 || (config3 == null ? void 0 : config3.inspectorFactory) !== void 0;
13242
- }
13243
- function disposeRunInspector(run, actorId) {
13244
- var _a2;
13245
- if (!run || typeof run !== "function") {
13246
- return;
13247
- }
13248
- const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
13249
- (_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
13250
- }
13251
- var GlobalActorOptionsBaseSchema = external_exports.object({
13252
- /** Display name for the actor in the Inspector UI. */
13253
- name: external_exports.string().optional(),
13254
- /** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
13255
- icon: external_exports.string().optional(),
13256
- /** Enables the experimental Actor Runtime Socket for this actor. */
13257
- enableActorRuntimeSocket: external_exports.boolean().default(false),
13258
- /**
13259
- * Can hibernate WebSockets for onWebSocket.
13260
- *
13261
- * WebSockets using actions/events are hibernatable by default.
13262
- *
13263
- * @experimental
13264
- **/
13265
- canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
13266
- }).strict();
13267
- var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
13268
- () => ({})
13269
- );
13270
- var InstanceActorOptionsBaseSchema = external_exports.object({
13271
- createVarsTimeout: external_exports.number().positive().default(5e3),
13272
- createConnStateTimeout: external_exports.number().positive().default(5e3),
13273
- onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
13274
- onConnectTimeout: external_exports.number().positive().default(5e3),
13275
- onMigrateTimeout: external_exports.number().positive().default(3e4),
13276
- sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
13277
- /** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
13278
- onDestroyTimeout: external_exports.number().positive().optional(),
13279
- /** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
13280
- waitUntilTimeout: external_exports.number().positive().optional(),
13281
- stateSaveInterval: external_exports.number().positive().default(1e3),
13282
- actionTimeout: external_exports.number().positive().default(6e4),
13283
- connectionLivenessTimeout: external_exports.number().positive().default(2500),
13284
- connectionLivenessInterval: external_exports.number().positive().default(5e3),
13285
- /** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
13286
- noSleep: external_exports.boolean().default(false),
13287
- sleepTimeout: external_exports.number().positive().default(3e4),
13288
- maxQueueSize: external_exports.number().positive().default(1e3),
13289
- /** Maximum pending one-shot and recurring schedules. */
13290
- maxSchedules: external_exports.number().int().nonnegative().default(1e3),
13291
- maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
13292
- /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
13293
- preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
13294
- /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
13295
- preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
13296
- }).strict();
13297
- var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
13298
- var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
13299
- InstanceActorOptionsBaseSchema.shape
13300
- ).strict().prefault(() => ({}));
13301
- var ActorConfigSchema = external_exports.object({
13302
- onCreate: zFunction().optional(),
13303
- onDestroy: zFunction().optional(),
13304
- onMigrate: zFunction().optional(),
13305
- onWake: zFunction().optional(),
13306
- onSleep: zFunction().optional(),
13307
- run: zRunHandler,
13308
- onStateChange: zFunction().optional(),
13309
- onBeforeConnect: zFunction().optional(),
13310
- onConnect: zFunction().optional(),
13311
- onDisconnect: zFunction().optional(),
13312
- onBeforeActionResponse: zFunction().optional(),
13313
- onRequest: zFunction().optional(),
13314
- onWebSocket: zFunction().optional(),
13315
- actions: zActionTree.default(() => ({})),
13316
- actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
13317
- connParamsSchema: external_exports.any().optional(),
13318
- events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
13319
- queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
13320
- state: external_exports.any().optional(),
13321
- createState: zFunction().optional(),
13322
- connState: external_exports.any().optional(),
13323
- createConnState: zFunction().optional(),
13324
- vars: external_exports.any().optional(),
13325
- db: external_exports.any().optional(),
13326
- createVars: zFunction().optional(),
13327
- options: ActorOptionsSchema,
13328
- inspector: ActorInspectorConfigSchema.optional()
13329
- }).strict().refine(
13330
- (data) => !(data.state !== void 0 && data.createState !== void 0),
13331
- {
13332
- message: "Cannot define both 'state' and 'createState'",
13333
- path: ["state"]
13334
- }
13335
- ).refine(
13336
- (data) => !(data.connState !== void 0 && data.createConnState !== void 0),
13337
- {
13338
- message: "Cannot define both 'connState' and 'createConnState'",
13339
- path: ["connState"]
13340
- }
13341
- ).refine(
13342
- (data) => !(data.vars !== void 0 && data.createVars !== void 0),
13343
- {
13344
- message: "Cannot define both 'vars' and 'createVars'",
13345
- path: ["vars"]
13346
- }
13347
- );
13348
- var DocActorOptionsSchema = external_exports.object({
13349
- name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
13350
- icon: external_exports.string().optional().describe(
13351
- "Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
13352
- ),
13353
- enableActorRuntimeSocket: external_exports.boolean().optional().describe(
13354
- "Enables the experimental Actor Runtime Socket for this actor. Default: false"
13355
- ),
13356
- createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
13357
- createConnStateTimeout: external_exports.number().optional().describe(
13358
- "Timeout in ms for createConnState handler. Default: 5000"
13359
- ),
13360
- onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
13361
- onBeforeConnectTimeout: external_exports.number().optional().describe(
13362
- "Timeout in ms for onBeforeConnect handler. Default: 5000"
13363
- ),
13364
- onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
13365
- sleepGracePeriod: external_exports.number().optional().describe(
13366
- `Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
13367
- ),
13368
- onDestroyTimeout: external_exports.number().optional().describe(
13369
- "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
13370
- ),
13371
- waitUntilTimeout: external_exports.number().optional().describe(
13372
- "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
13373
- ),
13374
- stateSaveInterval: external_exports.number().optional().describe(
13375
- "Interval in ms between automatic state saves. Default: 1000"
13376
- ),
13377
- actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
13378
- connectionLivenessTimeout: external_exports.number().optional().describe(
13379
- "Timeout in ms for connection liveness checks. Default: 2500"
13380
- ),
13381
- connectionLivenessInterval: external_exports.number().optional().describe(
13382
- "Interval in ms between connection liveness checks. Default: 5000"
13383
- ),
13384
- noSleep: external_exports.boolean().optional().describe(
13385
- "Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
13386
- ),
13387
- sleepTimeout: external_exports.number().optional().describe(
13388
- "Time in ms of inactivity before the actor sleeps. Default: 30000"
13389
- ),
13390
- maxQueueSize: external_exports.number().optional().describe(
13391
- "Maximum number of queue messages before rejecting new messages. Default: 1000"
13392
- ),
13393
- maxSchedules: external_exports.number().int().nonnegative().optional().describe(
13394
- "Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
13395
- ),
13396
- maxQueueMessageSize: external_exports.number().optional().describe(
13397
- "Maximum size of each queue message in bytes. Default: 65536"
13398
- ),
13399
- canHibernateWebSocket: external_exports.boolean().optional().describe(
13400
- "Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
13401
- )
13402
- }).describe("Actor options for timeouts and behavior configuration.");
13403
- var DocActorConfigSchema = external_exports.object({
13404
- state: external_exports.unknown().optional().describe(
13405
- "Initial state value for the actor. Cannot be used with createState."
13406
- ),
13407
- createState: external_exports.unknown().optional().describe(
13408
- "Function to create initial state. Receives context and input. Cannot be used with state."
13409
- ),
13410
- connState: external_exports.unknown().optional().describe(
13411
- "Initial connection state value. Cannot be used with createConnState."
13412
- ),
13413
- createConnState: external_exports.unknown().optional().describe(
13414
- "Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
13415
- ),
13416
- vars: external_exports.unknown().optional().describe(
13417
- "Initial ephemeral variables value. Cannot be used with createVars."
13418
- ),
13419
- createVars: external_exports.unknown().optional().describe(
13420
- "Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
13421
- ),
13422
- db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
13423
- onCreate: external_exports.unknown().optional().describe(
13424
- "Called when the actor is first initialized. Use to initialize state."
13425
- ),
13426
- onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
13427
- onMigrate: external_exports.unknown().optional().describe(
13428
- "Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
13429
- ),
13430
- onWake: external_exports.unknown().optional().describe(
13431
- "Called when the actor wakes up and is ready to receive connections and actions."
13432
- ),
13433
- onSleep: external_exports.unknown().optional().describe(
13434
- "Called when the actor is stopping or sleeping. Use to clean up resources."
13435
- ),
13436
- run: external_exports.unknown().optional().describe(
13437
- "Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
13438
- ),
13439
- onStateChange: external_exports.unknown().optional().describe(
13440
- "Called when the actor's state changes. State changes within this hook won't trigger recursion."
13441
- ),
13442
- onBeforeConnect: external_exports.unknown().optional().describe(
13443
- "Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
13444
- ),
13445
- onConnect: external_exports.unknown().optional().describe(
13446
- "Called when a client successfully connects. The connection is visible in c.conns before this runs."
13447
- ),
13448
- onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
13449
- onBeforeActionResponse: external_exports.unknown().optional().describe(
13450
- "Called before sending an action response. Use to transform output."
13451
- ),
13452
- onRequest: external_exports.unknown().optional().describe(
13453
- "Called for raw HTTP requests to /actors/{name}/http/* endpoints."
13454
- ),
13455
- onWebSocket: external_exports.unknown().optional().describe(
13456
- "Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
13457
- ),
13458
- actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
13459
- "Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
13460
- ),
13461
- actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
13462
- "Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
13463
- ),
13464
- connParamsSchema: external_exports.unknown().optional().describe(
13465
- "Optional schema for validating connection params in native runtimes."
13466
- ),
13467
- events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
13468
- queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
13469
- options: DocActorOptionsSchema.optional()
13470
- }).describe("Actor configuration passed to the actor() function.");
13471
-
13472
- // ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
13473
- var INTERNAL_ERROR_CODE = "internal_error";
13474
- var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
13475
- var USER_ERROR_CODE = "user_error";
13476
- var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
13477
- function looksLikeRivetErrorOptions(value) {
13478
- return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
13479
- }
13480
- function isTypedErrorTag(value) {
13481
- return value === "ActorError" || value === "RivetError";
13482
- }
13483
- function errorMessage(error46, fallback = String(error46)) {
13484
- if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
13485
- return error46.message;
13486
- }
13487
- return fallback;
13488
- }
13489
- function isRivetErrorLike(error46) {
13490
- return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
13491
- }
13492
- function isActorAbortedError(error46) {
13493
- return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
13494
- }
13495
- function isActorSpecifier(value) {
13496
- return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
13497
- }
13498
- var RivetError = class extends Error {
13499
- __type = "RivetError";
13500
- public;
13501
- metadata;
13502
- rayId;
13503
- statusCode;
13504
- actor;
13505
- group;
13506
- code;
13507
- static isRivetError(error46) {
13508
- return isRivetErrorLike(error46);
13509
- }
13510
- static isActorError(error46) {
13511
- return isRivetErrorLike(error46);
13512
- }
13513
- constructor(group, code, message, options) {
13514
- const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
13515
- super(message, { cause: normalized.cause });
13516
- this.name = "RivetError";
13517
- this.group = group;
13518
- this.code = code;
13519
- this.public = normalized.public ?? false;
13520
- this.metadata = normalized.metadata;
13521
- this.rayId = normalized.rayId ?? void 0;
13522
- this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
13523
- this.actor = normalized.actor;
13524
- }
13525
- toString() {
13526
- return this.message;
13527
- }
13528
- };
13529
- var UserError = class extends RivetError {
13530
- constructor(message, options) {
13531
- super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
13532
- public: true,
13533
- metadata: options == null ? void 0 : options.metadata,
13534
- cause: options == null ? void 0 : options.cause
13535
- });
13536
- }
13537
- };
13538
- function toRivetError(error46, fallback) {
13539
- if (typeof error46 === "string") {
13540
- const bridged = decodeBridgeRivetError(error46);
13541
- if (bridged) {
13542
- return bridged;
13543
- }
13544
- }
13545
- if (error46 instanceof Error) {
13546
- const bridged = decodeBridgeRivetError(error46.message);
13547
- if (bridged) {
13548
- return bridged;
13549
- }
13550
- }
13551
- if (isRivetErrorLike(error46)) {
13552
- return new RivetError(error46.group, error46.code, error46.message, {
13553
- public: error46.public,
13554
- statusCode: error46.statusCode,
13555
- metadata: error46.metadata,
13556
- rayId: error46.rayId,
13557
- actor: error46.actor,
13558
- cause: error46 instanceof Error ? error46.cause : void 0
13559
- });
13560
- }
13561
- return new RivetError(
13562
- (fallback == null ? void 0 : fallback.group) ?? "actor",
13563
- (fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
13564
- errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
13565
- {
13566
- public: fallback == null ? void 0 : fallback.public,
13567
- statusCode: fallback == null ? void 0 : fallback.statusCode,
13568
- metadata: fallback == null ? void 0 : fallback.metadata,
13569
- rayId: fallback == null ? void 0 : fallback.rayId,
13570
- actor: fallback == null ? void 0 : fallback.actor,
13571
- cause: error46 instanceof Error ? error46 : void 0
13572
- }
13573
- );
13574
- }
13575
- function encodeBridgeRivetError(error46) {
13576
- return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
13577
- group: error46.group,
13578
- code: error46.code,
13579
- message: error46.message,
13580
- metadata: error46.metadata,
13581
- rayId: error46.rayId,
13582
- public: error46.public,
13583
- statusCode: error46.statusCode,
13584
- actor: error46.actor
13585
- })}`;
13586
- }
13587
- function decodeBridgeRivetErrorPayload(value) {
13588
- if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
13589
- return void 0;
13590
- }
13591
- try {
13592
- const raw = JSON.parse(
13593
- value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
13594
- );
13595
- const payload = {
13596
- ...raw,
13597
- rayId: raw.rayId ?? void 0
13598
- };
13599
- if (!isRivetErrorLike(payload)) {
13600
- return void 0;
13601
- }
13602
- if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
13603
- return void 0;
13604
- }
13605
- return payload;
13606
- } catch {
13607
- return void 0;
13608
- }
13609
- }
13610
- function decodeBridgeRivetError(value) {
13611
- const payload = decodeBridgeRivetErrorPayload(value);
13612
- if (!payload) {
13613
- return void 0;
13614
- }
13615
- return new RivetError(payload.group, payload.code, payload.message, {
13616
- metadata: payload.metadata,
13617
- rayId: payload.rayId,
13618
- public: payload.public,
13619
- statusCode: payload.statusCode,
13620
- actor: payload.actor ?? void 0
13621
- });
13622
- }
13623
- function invalidRequest(error46) {
13624
- return new RivetError(
13625
- "request",
13626
- "invalid",
13627
- `Invalid request: ${errorMessage(error46, String(error46))}`,
13628
- {
13629
- public: true,
13630
- cause: error46 instanceof Error ? error46 : void 0
13631
- }
13632
- );
13633
- }
13634
- function actorNotFound(identifier) {
13635
- return new RivetError(
13636
- "actor",
13637
- "not_found",
13638
- identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
13639
- { public: true }
13640
- );
13641
- }
13642
- function forbiddenError() {
13643
- return new RivetError("auth", "forbidden", "Forbidden", {
13644
- public: true,
13645
- statusCode: 403
13646
- });
13647
- }
13648
- function unsupportedFeature(feature) {
13649
- return new RivetError(
13650
- "feature",
13651
- "unsupported",
13652
- `Unsupported feature: ${feature}`
13653
- );
13654
- }
13655
-
13656
- // ../rivetkit/dist/tsup/chunk-AQYDUW63.js
13657
- var import_pino = require("pino");
13658
- var cbor = __toESM(require("cbor-x"), 1);
13659
- var import_invariant = __toESM(require_invariant(), 1);
13660
- var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
13661
- var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
13662
- var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
13663
- var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
13664
- var getRivetPool = () => getEnvUniversal("RIVET_POOL");
13665
- var getRivetTotalSlots = () => {
13666
- const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
13667
- return value !== void 0 ? parseInt(value, 10) : void 0;
13668
- };
13669
- var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
13670
- var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
13671
- var getRivetRunEnginePort = () => {
13672
- const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
13673
- return value !== void 0 ? parseInt(value, 10) : void 0;
13674
- };
13675
- var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
13676
- var getRivetRunServices = () => {
13677
- const value = getEnvUniversal("RIVET_RUN_SERVICES");
13678
- return value === void 0 ? void 0 : value === "1";
13679
- };
13680
- var getRivetEnvoyVersion = () => {
13681
- const value = getEnvUniversal("RIVET_ENVOY_VERSION");
13682
- return value !== void 0 ? parseInt(value, 10) : void 0;
13683
- };
13684
- var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
13685
- var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
13686
- var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
13687
- var getRivetkitRuntimeMode = () => {
13688
- const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
13689
- if (value === void 0) return "envoy";
13690
- if (value === "envoy" || value === "serverless") return value;
13691
- throw new Error(
13692
- `RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
13693
- );
13694
- };
13695
- var getRivetkitPublicDir = () => {
13696
- const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
13697
- return value === void 0 || value === "" ? void 0 : value;
13698
- };
13699
- function parsePortEnv(raw) {
13700
- if (raw === void 0 || raw === "") return void 0;
13701
- const parsed = Number.parseInt(raw, 10);
13702
- if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
13703
- throw new Error(
13704
- `RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
13705
- );
13706
- }
13707
- return parsed;
13708
- }
13709
- var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
13710
- var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
13711
- var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
13712
- var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
13713
- var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
13714
- var getNodeEnv = () => getEnvUniversal("NODE_ENV");
13715
- var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
13716
- var isDev = () => getNodeEnv() !== "production";
13717
- function assertUnreachable(x) {
13718
- throw new Error(`Unreachable case: ${x}`);
13719
- }
13720
- function isCanonicalStructuredRivetError(error46) {
13721
- return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
13722
- }
13723
- function deconstructError(error46, exposeInternalError = false) {
13724
- let statusCode;
13725
- let public_;
13726
- let group;
13727
- let code;
13728
- let message;
13729
- let metadata;
13730
- let rayId;
13731
- let actor2;
13732
- if (isCanonicalStructuredRivetError(error46)) {
13733
- statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
13734
- public_ = error46.public ?? false;
13735
- group = error46.group;
13736
- code = error46.code;
13737
- message = error46.message;
13738
- metadata = error46.metadata;
13739
- rayId = error46.rayId;
13740
- actor2 = error46.actor;
13741
- } else if (RivetError.isActorError(error46) && error46.public) {
13742
- statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
13743
- public_ = true;
13744
- group = error46.group;
13745
- code = error46.code;
13746
- message = getErrorMessage(error46);
13747
- metadata = error46.metadata;
13748
- rayId = error46.rayId;
13749
- actor2 = error46.actor;
13750
- } else if (exposeInternalError) {
13751
- if (RivetError.isActorError(error46)) {
13752
- statusCode = 500;
13753
- public_ = false;
13754
- group = error46.group;
13755
- code = error46.code;
13756
- message = getErrorMessage(error46);
13757
- metadata = error46.metadata;
13758
- rayId = error46.rayId;
13759
- actor2 = error46.actor;
13760
- } else {
13761
- statusCode = 500;
13762
- public_ = false;
13763
- group = "rivetkit";
13764
- code = INTERNAL_ERROR_CODE;
13765
- message = getErrorMessage(error46);
13766
- }
13767
- } else {
13768
- statusCode = 500;
13769
- public_ = false;
13770
- group = "rivetkit";
13771
- code = INTERNAL_ERROR_CODE;
13772
- message = INTERNAL_ERROR_DESCRIPTION;
13773
- if (RivetError.isActorError(error46)) {
13774
- actor2 = error46.actor;
13775
- }
13776
- metadata = {
13777
- //url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
13778
- };
13779
- }
13780
- return {
13781
- __type: "ActorError",
13782
- statusCode,
13783
- public: public_,
13784
- group,
13785
- code,
13786
- message,
13787
- metadata,
13788
- rayId,
13789
- actor: actor2
13790
- };
13791
- }
13792
- function stringifyError(error46) {
13793
- if (error46 instanceof Error) {
13794
- if (typeof process !== "undefined" && getLogErrorStack()) {
13795
- let stack;
13796
- try {
13797
- stack = error46.stack;
13798
- } catch {
13799
- stack = void 0;
13800
- }
13801
- return `${error46.name}: ${error46.message}${stack ? `
13802
- ${stack}` : ""}`;
13803
- } else {
13804
- return `${error46.name}: ${error46.message}`;
13805
- }
13806
- } else if (typeof error46 === "string") {
13807
- return error46;
13808
- } else if (typeof error46 === "object" && error46 !== null) {
13809
- try {
13810
- return `${JSON.stringify(error46)}`;
13811
- } catch {
13812
- return "[cannot stringify error]";
13813
- }
13814
- } else {
13815
- return `Unknown error: ${getErrorMessage(error46)}`;
13816
- }
13817
- }
13818
- function getErrorMessage(err) {
13819
- if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
13820
- return err.message;
13821
- } else {
13822
- return String(err);
13823
- }
13824
- }
13825
- function noopNext() {
13826
- return async () => {
13827
- };
13363
+ function noopNext() {
13364
+ return async () => {
13365
+ };
13828
13366
  }
13829
13367
  var package_default = {
13830
13368
  name: "rivetkit",
13831
- version: "2.3.18-rc.2",
13369
+ version: "2.3.18-rc.3",
13832
13370
  description: "Lightweight libraries for building stateful actors on edge platforms",
13833
13371
  license: "Apache-2.0",
13834
13372
  keywords: [
@@ -15132,7 +14670,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
15132
14670
  };
15133
14671
  }
15134
14672
 
15135
- // ../rivetkit/dist/tsup/chunk-7IN6PYYD.js
14673
+ // ../rivetkit/dist/tsup/chunk-LWGP653X.js
15136
14674
  var config2 = /* @__PURE__ */ Config({});
15137
14675
  function readWorkflowCbor(bc) {
15138
14676
  return readData(bc);
@@ -15223,57 +14761,181 @@ function readWorkflowBranchStatusType(bc) {
15223
14761
  case 3:
15224
14762
  return "FAILED";
15225
14763
  case 4:
15226
- return "CANCELLED";
14764
+ return "CANCELLED";
14765
+ default: {
14766
+ bc.offset = offset;
14767
+ throw new BareError(offset, "invalid tag");
14768
+ }
14769
+ }
14770
+ }
14771
+ function read0(bc) {
14772
+ return readBool(bc) ? readWorkflowCbor(bc) : null;
14773
+ }
14774
+ function read1(bc) {
14775
+ return readBool(bc) ? readString(bc) : null;
14776
+ }
14777
+ function readWorkflowStepEntry(bc) {
14778
+ return {
14779
+ output: read0(bc),
14780
+ error: read1(bc)
14781
+ };
14782
+ }
14783
+ function readWorkflowLoopEntry(bc) {
14784
+ return {
14785
+ state: readWorkflowCbor(bc),
14786
+ iteration: readU32(bc),
14787
+ output: read0(bc)
14788
+ };
14789
+ }
14790
+ function readWorkflowSleepEntry(bc) {
14791
+ return {
14792
+ deadline: readU64(bc),
14793
+ state: readWorkflowSleepState(bc)
14794
+ };
14795
+ }
14796
+ function readWorkflowMessageEntry(bc) {
14797
+ return {
14798
+ name: readString(bc),
14799
+ messageData: readWorkflowCbor(bc)
14800
+ };
14801
+ }
14802
+ function readWorkflowRollbackCheckpointEntry(bc) {
14803
+ return {
14804
+ name: readString(bc)
14805
+ };
14806
+ }
14807
+ function readWorkflowBranchStatus(bc) {
14808
+ return {
14809
+ status: readWorkflowBranchStatusType(bc),
14810
+ output: read0(bc),
14811
+ error: read1(bc)
14812
+ };
14813
+ }
14814
+ function read2(bc) {
14815
+ const len = readUintSafe(bc);
14816
+ const result = /* @__PURE__ */ new Map();
14817
+ for (let i = 0; i < len; i++) {
14818
+ const offset = bc.offset;
14819
+ const key = readString(bc);
14820
+ if (result.has(key)) {
14821
+ bc.offset = offset;
14822
+ throw new BareError(offset, "duplicated key");
14823
+ }
14824
+ result.set(key, readWorkflowBranchStatus(bc));
14825
+ }
14826
+ return result;
14827
+ }
14828
+ function readWorkflowJoinEntry(bc) {
14829
+ return {
14830
+ branches: read2(bc)
14831
+ };
14832
+ }
14833
+ function readWorkflowRaceEntry(bc) {
14834
+ return {
14835
+ winner: read1(bc),
14836
+ branches: read2(bc)
14837
+ };
14838
+ }
14839
+ function readWorkflowRemovedEntry(bc) {
14840
+ return {
14841
+ originalType: readString(bc),
14842
+ originalName: read1(bc)
14843
+ };
14844
+ }
14845
+ function readWorkflowVersionCheckEntry(bc) {
14846
+ return {
14847
+ resolved: readU32(bc),
14848
+ latest: readU32(bc)
14849
+ };
14850
+ }
14851
+ function readWorkflowEntryKind(bc) {
14852
+ const offset = bc.offset;
14853
+ const tag = readU8(bc);
14854
+ switch (tag) {
14855
+ case 0:
14856
+ return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
14857
+ case 1:
14858
+ return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
14859
+ case 2:
14860
+ return {
14861
+ tag: "WorkflowSleepEntry",
14862
+ val: readWorkflowSleepEntry(bc)
14863
+ };
14864
+ case 3:
14865
+ return {
14866
+ tag: "WorkflowMessageEntry",
14867
+ val: readWorkflowMessageEntry(bc)
14868
+ };
14869
+ case 4:
14870
+ return {
14871
+ tag: "WorkflowRollbackCheckpointEntry",
14872
+ val: readWorkflowRollbackCheckpointEntry(bc)
14873
+ };
14874
+ case 5:
14875
+ return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
14876
+ case 6:
14877
+ return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
14878
+ case 7:
14879
+ return {
14880
+ tag: "WorkflowRemovedEntry",
14881
+ val: readWorkflowRemovedEntry(bc)
14882
+ };
14883
+ case 8:
14884
+ return {
14885
+ tag: "WorkflowVersionCheckEntry",
14886
+ val: readWorkflowVersionCheckEntry(bc)
14887
+ };
15227
14888
  default: {
15228
14889
  bc.offset = offset;
15229
14890
  throw new BareError(offset, "invalid tag");
15230
14891
  }
15231
14892
  }
15232
14893
  }
15233
- function read0(bc) {
15234
- return readBool(bc) ? readWorkflowCbor(bc) : null;
15235
- }
15236
- function read1(bc) {
15237
- return readBool(bc) ? readString(bc) : null;
15238
- }
15239
- function readWorkflowStepEntry(bc) {
15240
- return {
15241
- output: read0(bc),
15242
- error: read1(bc)
15243
- };
15244
- }
15245
- function readWorkflowLoopEntry(bc) {
14894
+ function readWorkflowEntry(bc) {
15246
14895
  return {
15247
- state: readWorkflowCbor(bc),
15248
- iteration: readU32(bc),
15249
- output: read0(bc)
14896
+ id: readString(bc),
14897
+ location: readWorkflowLocation(bc),
14898
+ kind: readWorkflowEntryKind(bc)
15250
14899
  };
15251
14900
  }
15252
- function readWorkflowSleepEntry(bc) {
15253
- return {
15254
- deadline: readU64(bc),
15255
- state: readWorkflowSleepState(bc)
15256
- };
14901
+ function read3(bc) {
14902
+ return readBool(bc) ? readU64(bc) : null;
15257
14903
  }
15258
- function readWorkflowMessageEntry(bc) {
14904
+ function readWorkflowEntryMetadata(bc) {
15259
14905
  return {
15260
- name: readString(bc),
15261
- messageData: readWorkflowCbor(bc)
14906
+ status: readWorkflowEntryStatus(bc),
14907
+ error: read1(bc),
14908
+ attempts: readU32(bc),
14909
+ lastAttemptAt: readU64(bc),
14910
+ createdAt: readU64(bc),
14911
+ completedAt: read3(bc),
14912
+ rollbackCompletedAt: read3(bc),
14913
+ rollbackError: read1(bc)
15262
14914
  };
15263
14915
  }
15264
- function readWorkflowRollbackCheckpointEntry(bc) {
15265
- return {
15266
- name: readString(bc)
15267
- };
14916
+ function read4(bc) {
14917
+ const len = readUintSafe(bc);
14918
+ if (len === 0) {
14919
+ return [];
14920
+ }
14921
+ const result = [readString(bc)];
14922
+ for (let i = 1; i < len; i++) {
14923
+ result[i] = readString(bc);
14924
+ }
14925
+ return result;
15268
14926
  }
15269
- function readWorkflowBranchStatus(bc) {
15270
- return {
15271
- status: readWorkflowBranchStatusType(bc),
15272
- output: read0(bc),
15273
- error: read1(bc)
15274
- };
14927
+ function read5(bc) {
14928
+ const len = readUintSafe(bc);
14929
+ if (len === 0) {
14930
+ return [];
14931
+ }
14932
+ const result = [readWorkflowEntry(bc)];
14933
+ for (let i = 1; i < len; i++) {
14934
+ result[i] = readWorkflowEntry(bc);
14935
+ }
14936
+ return result;
15275
14937
  }
15276
- function read2(bc) {
14938
+ function read6(bc) {
15277
14939
  const len = readUintSafe(bc);
15278
14940
  const result = /* @__PURE__ */ new Map();
15279
14941
  for (let i = 0; i < len; i++) {
@@ -15283,152 +14945,492 @@ function read2(bc) {
15283
14945
  bc.offset = offset;
15284
14946
  throw new BareError(offset, "duplicated key");
15285
14947
  }
15286
- result.set(key, readWorkflowBranchStatus(bc));
14948
+ result.set(key, readWorkflowEntryMetadata(bc));
14949
+ }
14950
+ return result;
14951
+ }
14952
+ function readWorkflowHistory(bc) {
14953
+ return {
14954
+ nameRegistry: read4(bc),
14955
+ entries: read5(bc),
14956
+ entryMetadata: read6(bc)
14957
+ };
14958
+ }
14959
+ function decodeWorkflowHistory(bytes) {
14960
+ const bc = new ByteCursor(bytes, config2);
14961
+ const result = readWorkflowHistory(bc);
14962
+ if (bc.offset < bc.view.byteLength) {
14963
+ throw new BareError(bc.offset, "remaining bytes");
14964
+ }
14965
+ return result;
14966
+ }
14967
+ function decodeWorkflowHistoryTransport(data) {
14968
+ return decodeWorkflowHistory(toUint8Array(data));
14969
+ }
14970
+
14971
+ // ../rivetkit/dist/tsup/chunk-6W5VGLFT.js
14972
+ function flattenActionHandlers(actions) {
14973
+ const flattened = /* @__PURE__ */ Object.create(null);
14974
+ for (const { name, handler } of collectActionEntries(actions)) {
14975
+ flattened[name] = handler;
14976
+ }
14977
+ return flattened;
14978
+ }
14979
+ function flattenActionInputSchemas(actions, schemas) {
14980
+ if (schemas === void 0) return void 0;
14981
+ if (!isRecord(schemas)) {
14982
+ throw new TypeError("actionInputSchemas must be an object");
14983
+ }
14984
+ const flattened = /* @__PURE__ */ Object.create(null);
14985
+ for (const { name, path: path2 } of collectActionEntries(actions)) {
14986
+ const nestedSchema = lookupNestedSchema(schemas, path2);
14987
+ const flatSchema = schemas[name];
14988
+ if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
14989
+ throw new TypeError(
14990
+ `Action input schema \`${name}\` is defined by both a nested path and a dotted key`
14991
+ );
14992
+ }
14993
+ const schema = nestedSchema ?? flatSchema;
14994
+ if (schema !== void 0) {
14995
+ flattened[name] = schema;
14996
+ }
14997
+ }
14998
+ return flattened;
14999
+ }
15000
+ function collectActionEntries(actions) {
15001
+ const entries = [];
15002
+ const names = /* @__PURE__ */ new Set();
15003
+ visitActionGroup(actions ?? {}, [], entries, names);
15004
+ return entries;
15005
+ }
15006
+ function visitActionGroup(value, path2, entries, names) {
15007
+ if (!isRecord(value)) {
15008
+ throw new TypeError(
15009
+ `${formatActionPath(path2)} must be an action handler or group`
15010
+ );
15011
+ }
15012
+ for (const [segment, child] of Object.entries(value)) {
15013
+ const childPath = [...path2, segment];
15014
+ if (typeof child === "function") {
15015
+ const name = childPath.join(".");
15016
+ if (names.has(name)) {
15017
+ throw new TypeError(
15018
+ `Multiple action definitions flatten to \`${name}\``
15019
+ );
15020
+ }
15021
+ names.add(name);
15022
+ entries.push({
15023
+ name,
15024
+ path: childPath,
15025
+ handler: child
15026
+ });
15027
+ } else {
15028
+ visitActionGroup(child, childPath, entries, names);
15029
+ }
15030
+ }
15031
+ }
15032
+ function lookupNestedSchema(schemas, path2) {
15033
+ let value = schemas;
15034
+ for (const segment of path2) {
15035
+ if (!isRecord(value) || !Object.hasOwn(value, segment)) {
15036
+ return void 0;
15037
+ }
15038
+ value = value[segment];
15039
+ }
15040
+ return value;
15041
+ }
15042
+ function isRecord(value) {
15043
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
15044
+ return false;
15045
+ }
15046
+ const prototype = Object.getPrototypeOf(value);
15047
+ return prototype === Object.prototype || prototype === null;
15048
+ }
15049
+ function formatActionPath(path2) {
15050
+ return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
15051
+ }
15052
+ var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
15053
+ var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
15054
+ "rivetkit.actor_context_internal"
15055
+ );
15056
+ var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
15057
+ var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
15058
+ var zFunction = () => external_exports.custom((val) => typeof val === "function");
15059
+ var zActionTree = external_exports.custom((value) => {
15060
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
15061
+ return false;
15062
+ }
15063
+ const prototype = Object.getPrototypeOf(value);
15064
+ return prototype === Object.prototype || prototype === null;
15065
+ }).superRefine((actions, ctx) => {
15066
+ try {
15067
+ flattenActionHandlers(actions);
15068
+ } catch (error46) {
15069
+ ctx.addIssue({
15070
+ code: "custom",
15071
+ message: error46 instanceof Error ? error46.message : "Invalid action definition"
15072
+ });
15073
+ }
15074
+ });
15075
+ var WorkflowInspectorConfigSchema = external_exports.object({
15076
+ getHistory: zFunction(),
15077
+ getState: zFunction().optional(),
15078
+ onHistoryUpdated: zFunction().optional(),
15079
+ replayFromStep: zFunction().optional()
15080
+ });
15081
+ var RunInspectorConfigSchema = external_exports.object({
15082
+ workflow: WorkflowInspectorConfigSchema.optional()
15083
+ }).optional();
15084
+ var BUILTIN_INSPECTOR_TAB_IDS = [
15085
+ "workflow",
15086
+ "database",
15087
+ "state",
15088
+ "queue",
15089
+ "schedules",
15090
+ "connections",
15091
+ "console"
15092
+ ];
15093
+ var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
15094
+ var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
15095
+ var CustomInspectorTabEntrySchema = external_exports.object({
15096
+ id: external_exports.string().regex(
15097
+ CUSTOM_INSPECTOR_TAB_ID_RE,
15098
+ "inspector.tabs[].id must contain only letters, digits, underscore, or dash"
15099
+ ),
15100
+ label: external_exports.string().min(1),
15101
+ source: external_exports.string().min(1),
15102
+ /**
15103
+ * Optional icon id. The dashboard maps strings to glyphs (see its
15104
+ * icon registry); unknown ids fall back to a generic icon.
15105
+ */
15106
+ icon: external_exports.string().min(1).optional(),
15107
+ hidden: external_exports.literal(false).optional()
15108
+ }).strict();
15109
+ var HideInspectorTabEntrySchema = external_exports.object({
15110
+ id: BuiltinInspectorTabIdSchema,
15111
+ hidden: external_exports.literal(true)
15112
+ }).strict();
15113
+ var InspectorTabEntrySchema = external_exports.union([
15114
+ CustomInspectorTabEntrySchema,
15115
+ HideInspectorTabEntrySchema
15116
+ ]);
15117
+ var ActorInspectorConfigSchema = external_exports.object({
15118
+ tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
15119
+ }).strict().refine(
15120
+ (data) => {
15121
+ const ids = data.tabs.map((t) => t.id);
15122
+ return new Set(ids).size === ids.length;
15123
+ },
15124
+ { message: "Duplicate id in inspector.tabs", path: ["tabs"] }
15125
+ ).refine(
15126
+ (data) => {
15127
+ const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
15128
+ return data.tabs.every(
15129
+ (t) => t.hidden === true || !builtinSet.has(t.id)
15130
+ );
15131
+ },
15132
+ {
15133
+ message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
15134
+ path: ["tabs"]
15287
15135
  }
15288
- return result;
15289
- }
15290
- function readWorkflowJoinEntry(bc) {
15291
- return {
15292
- branches: read2(bc)
15293
- };
15136
+ );
15137
+ var RunConfigSchema = external_exports.object({
15138
+ /** Display name for the actor in the Inspector UI. */
15139
+ name: external_exports.string().optional(),
15140
+ /** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
15141
+ icon: external_exports.string().optional(),
15142
+ /** The run handler function. */
15143
+ run: zFunction(),
15144
+ /** Inspector integration for long-running run handlers. */
15145
+ inspector: RunInspectorConfigSchema.optional()
15146
+ });
15147
+ var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
15148
+ function defineRunHandler(run, options) {
15149
+ if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
15150
+ throw new TypeError(
15151
+ "defineRunHandler requires inspectorKind and createInspector together"
15152
+ );
15153
+ }
15154
+ Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
15155
+ configurable: false,
15156
+ enumerable: false,
15157
+ writable: false,
15158
+ value: {
15159
+ name: options.name,
15160
+ icon: options.icon,
15161
+ inspectorKind: options.inspectorKind,
15162
+ createInspector: options.createInspector
15163
+ }
15164
+ });
15165
+ return run;
15294
15166
  }
15295
- function readWorkflowRaceEntry(bc) {
15296
- return {
15297
- winner: read1(bc),
15298
- branches: read2(bc)
15299
- };
15167
+ function getRunInspectorKind(run) {
15168
+ var _a2;
15169
+ if (!run || typeof run !== "function") return void 0;
15170
+ return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
15300
15171
  }
15301
- function readWorkflowRemovedEntry(bc) {
15302
- return {
15303
- originalType: readString(bc),
15304
- originalName: read1(bc)
15305
- };
15172
+ function createRunInspector(run, context) {
15173
+ var _a2, _b;
15174
+ if (!run || typeof run !== "function") return void 0;
15175
+ return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
15306
15176
  }
15307
- function readWorkflowVersionCheckEntry(bc) {
15308
- return {
15309
- resolved: readU32(bc),
15310
- latest: readU32(bc)
15311
- };
15177
+ var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
15178
+ function getRunFunction(run) {
15179
+ if (!run) return void 0;
15180
+ if (typeof run === "function") return run;
15181
+ return run.run;
15312
15182
  }
15313
- function readWorkflowEntryKind(bc) {
15314
- const offset = bc.offset;
15315
- const tag = readU8(bc);
15316
- switch (tag) {
15317
- case 0:
15318
- return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
15319
- case 1:
15320
- return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
15321
- case 2:
15322
- return {
15323
- tag: "WorkflowSleepEntry",
15324
- val: readWorkflowSleepEntry(bc)
15325
- };
15326
- case 3:
15327
- return {
15328
- tag: "WorkflowMessageEntry",
15329
- val: readWorkflowMessageEntry(bc)
15330
- };
15331
- case 4:
15332
- return {
15333
- tag: "WorkflowRollbackCheckpointEntry",
15334
- val: readWorkflowRollbackCheckpointEntry(bc)
15335
- };
15336
- case 5:
15337
- return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
15338
- case 6:
15339
- return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
15340
- case 7:
15341
- return {
15342
- tag: "WorkflowRemovedEntry",
15343
- val: readWorkflowRemovedEntry(bc)
15344
- };
15345
- case 8:
15346
- return {
15347
- tag: "WorkflowVersionCheckEntry",
15348
- val: readWorkflowVersionCheckEntry(bc)
15349
- };
15350
- default: {
15351
- bc.offset = offset;
15352
- throw new BareError(offset, "invalid tag");
15353
- }
15183
+ function getRunMetadata(run) {
15184
+ if (!run) return {};
15185
+ if (typeof run === "function") {
15186
+ const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
15187
+ if (!config3) return {};
15188
+ return { name: config3.name, icon: config3.icon };
15354
15189
  }
15190
+ return { name: run.name, icon: run.icon };
15355
15191
  }
15356
- function readWorkflowEntry(bc) {
15357
- return {
15358
- id: readString(bc),
15359
- location: readWorkflowLocation(bc),
15360
- kind: readWorkflowEntryKind(bc)
15361
- };
15362
- }
15363
- function read3(bc) {
15364
- return readBool(bc) ? readU64(bc) : null;
15192
+ function getRunInspectorConfig(run, actor2) {
15193
+ if (!run) return void 0;
15194
+ if (typeof run === "function") {
15195
+ const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
15196
+ return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
15197
+ }
15198
+ return run.inspector;
15365
15199
  }
15366
- function readWorkflowEntryMetadata(bc) {
15367
- return {
15368
- status: readWorkflowEntryStatus(bc),
15369
- error: read1(bc),
15370
- attempts: readU32(bc),
15371
- lastAttemptAt: readU64(bc),
15372
- createdAt: readU64(bc),
15373
- completedAt: read3(bc),
15374
- rollbackCompletedAt: read3(bc),
15375
- rollbackError: read1(bc)
15376
- };
15200
+ function hasRunInspectorConfig(run) {
15201
+ if (!run) return false;
15202
+ if (typeof run !== "function") return run.inspector !== void 0;
15203
+ const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
15204
+ return (config3 == null ? void 0 : config3.inspectorKind) !== void 0 || (config3 == null ? void 0 : config3.createInspector) !== void 0 || (config3 == null ? void 0 : config3.inspector) !== void 0 || (config3 == null ? void 0 : config3.inspectorFactory) !== void 0;
15377
15205
  }
15378
- function read4(bc) {
15379
- const len = readUintSafe(bc);
15380
- if (len === 0) {
15381
- return [];
15382
- }
15383
- const result = [readString(bc)];
15384
- for (let i = 1; i < len; i++) {
15385
- result[i] = readString(bc);
15206
+ function disposeRunInspector(run, actorId) {
15207
+ var _a2;
15208
+ if (!run || typeof run !== "function") {
15209
+ return;
15386
15210
  }
15387
- return result;
15211
+ const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
15212
+ (_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
15388
15213
  }
15389
- function read5(bc) {
15390
- const len = readUintSafe(bc);
15391
- if (len === 0) {
15392
- return [];
15393
- }
15394
- const result = [readWorkflowEntry(bc)];
15395
- for (let i = 1; i < len; i++) {
15396
- result[i] = readWorkflowEntry(bc);
15214
+ var GlobalActorOptionsBaseSchema = external_exports.object({
15215
+ /** Display name for the actor in the Inspector UI. */
15216
+ name: external_exports.string().optional(),
15217
+ /** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
15218
+ icon: external_exports.string().optional(),
15219
+ /** Enables the experimental Actor Runtime Socket for this actor. */
15220
+ enableActorRuntimeSocket: external_exports.boolean().default(false),
15221
+ /**
15222
+ * Can hibernate WebSockets for onWebSocket.
15223
+ *
15224
+ * WebSockets using actions/events are hibernatable by default.
15225
+ *
15226
+ * @experimental
15227
+ **/
15228
+ canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
15229
+ }).strict();
15230
+ var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
15231
+ () => ({})
15232
+ );
15233
+ var InstanceActorOptionsBaseSchema = external_exports.object({
15234
+ createVarsTimeout: external_exports.number().positive().default(5e3),
15235
+ createConnStateTimeout: external_exports.number().positive().default(5e3),
15236
+ onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
15237
+ onConnectTimeout: external_exports.number().positive().default(5e3),
15238
+ onMigrateTimeout: external_exports.number().positive().default(3e4),
15239
+ sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
15240
+ /** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
15241
+ onDestroyTimeout: external_exports.number().positive().optional(),
15242
+ /** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
15243
+ waitUntilTimeout: external_exports.number().positive().optional(),
15244
+ stateSaveInterval: external_exports.number().positive().default(1e3),
15245
+ actionTimeout: external_exports.number().positive().default(6e4),
15246
+ connectionLivenessTimeout: external_exports.number().positive().default(2500),
15247
+ connectionLivenessInterval: external_exports.number().positive().default(5e3),
15248
+ /** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
15249
+ noSleep: external_exports.boolean().default(false),
15250
+ sleepTimeout: external_exports.number().positive().default(3e4),
15251
+ maxQueueSize: external_exports.number().positive().default(1e3),
15252
+ /** Maximum pending one-shot and recurring schedules. */
15253
+ maxSchedules: external_exports.number().int().nonnegative().default(1e3),
15254
+ maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
15255
+ /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
15256
+ preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
15257
+ /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
15258
+ preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
15259
+ }).strict();
15260
+ var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
15261
+ var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
15262
+ InstanceActorOptionsBaseSchema.shape
15263
+ ).strict().prefault(() => ({}));
15264
+ var ActorConfigSchema = external_exports.object({
15265
+ onCreate: zFunction().optional(),
15266
+ onDestroy: zFunction().optional(),
15267
+ onMigrate: zFunction().optional(),
15268
+ onWake: zFunction().optional(),
15269
+ onSleep: zFunction().optional(),
15270
+ run: zRunHandler,
15271
+ onStateChange: zFunction().optional(),
15272
+ onBeforeConnect: zFunction().optional(),
15273
+ onConnect: zFunction().optional(),
15274
+ onDisconnect: zFunction().optional(),
15275
+ onBeforeActionResponse: zFunction().optional(),
15276
+ onRequest: zFunction().optional(),
15277
+ onWebSocket: zFunction().optional(),
15278
+ actions: zActionTree.default(() => ({})),
15279
+ actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
15280
+ connParamsSchema: external_exports.any().optional(),
15281
+ events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
15282
+ queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
15283
+ state: external_exports.any().optional(),
15284
+ createState: zFunction().optional(),
15285
+ connState: external_exports.any().optional(),
15286
+ createConnState: zFunction().optional(),
15287
+ vars: external_exports.any().optional(),
15288
+ db: external_exports.any().optional(),
15289
+ createVars: zFunction().optional(),
15290
+ options: ActorOptionsSchema,
15291
+ inspector: ActorInspectorConfigSchema.optional()
15292
+ }).strict().refine(
15293
+ (data) => !(data.state !== void 0 && data.createState !== void 0),
15294
+ {
15295
+ message: "Cannot define both 'state' and 'createState'",
15296
+ path: ["state"]
15397
15297
  }
15398
- return result;
15399
- }
15400
- function read6(bc) {
15401
- const len = readUintSafe(bc);
15402
- const result = /* @__PURE__ */ new Map();
15403
- for (let i = 0; i < len; i++) {
15404
- const offset = bc.offset;
15405
- const key = readString(bc);
15406
- if (result.has(key)) {
15407
- bc.offset = offset;
15408
- throw new BareError(offset, "duplicated key");
15409
- }
15410
- result.set(key, readWorkflowEntryMetadata(bc));
15298
+ ).refine(
15299
+ (data) => !(data.connState !== void 0 && data.createConnState !== void 0),
15300
+ {
15301
+ message: "Cannot define both 'connState' and 'createConnState'",
15302
+ path: ["connState"]
15411
15303
  }
15412
- return result;
15413
- }
15414
- function readWorkflowHistory(bc) {
15415
- return {
15416
- nameRegistry: read4(bc),
15417
- entries: read5(bc),
15418
- entryMetadata: read6(bc)
15419
- };
15420
- }
15421
- function decodeWorkflowHistory(bytes) {
15422
- const bc = new ByteCursor(bytes, config2);
15423
- const result = readWorkflowHistory(bc);
15424
- if (bc.offset < bc.view.byteLength) {
15425
- throw new BareError(bc.offset, "remaining bytes");
15304
+ ).refine(
15305
+ (data) => !(data.vars !== void 0 && data.createVars !== void 0),
15306
+ {
15307
+ message: "Cannot define both 'vars' and 'createVars'",
15308
+ path: ["vars"]
15426
15309
  }
15427
- return result;
15428
- }
15429
- function decodeWorkflowHistoryTransport(data) {
15430
- return decodeWorkflowHistory(toUint8Array(data));
15431
- }
15310
+ );
15311
+ var DocActorOptionsSchema = external_exports.object({
15312
+ name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
15313
+ icon: external_exports.string().optional().describe(
15314
+ "Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
15315
+ ),
15316
+ enableActorRuntimeSocket: external_exports.boolean().optional().describe(
15317
+ "Enables the experimental Actor Runtime Socket for this actor. Default: false"
15318
+ ),
15319
+ createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
15320
+ createConnStateTimeout: external_exports.number().optional().describe(
15321
+ "Timeout in ms for createConnState handler. Default: 5000"
15322
+ ),
15323
+ onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
15324
+ onBeforeConnectTimeout: external_exports.number().optional().describe(
15325
+ "Timeout in ms for onBeforeConnect handler. Default: 5000"
15326
+ ),
15327
+ onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
15328
+ sleepGracePeriod: external_exports.number().optional().describe(
15329
+ `Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
15330
+ ),
15331
+ onDestroyTimeout: external_exports.number().optional().describe(
15332
+ "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
15333
+ ),
15334
+ waitUntilTimeout: external_exports.number().optional().describe(
15335
+ "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
15336
+ ),
15337
+ stateSaveInterval: external_exports.number().optional().describe(
15338
+ "Interval in ms between automatic state saves. Default: 1000"
15339
+ ),
15340
+ actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
15341
+ connectionLivenessTimeout: external_exports.number().optional().describe(
15342
+ "Timeout in ms for connection liveness checks. Default: 2500"
15343
+ ),
15344
+ connectionLivenessInterval: external_exports.number().optional().describe(
15345
+ "Interval in ms between connection liveness checks. Default: 5000"
15346
+ ),
15347
+ noSleep: external_exports.boolean().optional().describe(
15348
+ "Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
15349
+ ),
15350
+ sleepTimeout: external_exports.number().optional().describe(
15351
+ "Time in ms of inactivity before the actor sleeps. Default: 30000"
15352
+ ),
15353
+ maxQueueSize: external_exports.number().optional().describe(
15354
+ "Maximum number of queue messages before rejecting new messages. Default: 1000"
15355
+ ),
15356
+ maxSchedules: external_exports.number().int().nonnegative().optional().describe(
15357
+ "Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
15358
+ ),
15359
+ maxQueueMessageSize: external_exports.number().optional().describe(
15360
+ "Maximum size of each queue message in bytes. Default: 65536"
15361
+ ),
15362
+ canHibernateWebSocket: external_exports.boolean().optional().describe(
15363
+ "Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
15364
+ )
15365
+ }).describe("Actor options for timeouts and behavior configuration.");
15366
+ var DocActorConfigSchema = external_exports.object({
15367
+ state: external_exports.unknown().optional().describe(
15368
+ "Initial state value for the actor. Cannot be used with createState."
15369
+ ),
15370
+ createState: external_exports.unknown().optional().describe(
15371
+ "Function to create initial state. Receives context and input. Cannot be used with state."
15372
+ ),
15373
+ connState: external_exports.unknown().optional().describe(
15374
+ "Initial connection state value. Cannot be used with createConnState."
15375
+ ),
15376
+ createConnState: external_exports.unknown().optional().describe(
15377
+ "Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
15378
+ ),
15379
+ vars: external_exports.unknown().optional().describe(
15380
+ "Initial ephemeral variables value. Cannot be used with createVars."
15381
+ ),
15382
+ createVars: external_exports.unknown().optional().describe(
15383
+ "Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
15384
+ ),
15385
+ db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
15386
+ onCreate: external_exports.unknown().optional().describe(
15387
+ "Called when the actor is first initialized. Use to initialize state."
15388
+ ),
15389
+ onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
15390
+ onMigrate: external_exports.unknown().optional().describe(
15391
+ "Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
15392
+ ),
15393
+ onWake: external_exports.unknown().optional().describe(
15394
+ "Called when the actor wakes up and is ready to receive connections and actions."
15395
+ ),
15396
+ onSleep: external_exports.unknown().optional().describe(
15397
+ "Called when the actor is stopping or sleeping. Use to clean up resources."
15398
+ ),
15399
+ run: external_exports.unknown().optional().describe(
15400
+ "Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
15401
+ ),
15402
+ onStateChange: external_exports.unknown().optional().describe(
15403
+ "Called when the actor's state changes. State changes within this hook won't trigger recursion."
15404
+ ),
15405
+ onBeforeConnect: external_exports.unknown().optional().describe(
15406
+ "Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
15407
+ ),
15408
+ onConnect: external_exports.unknown().optional().describe(
15409
+ "Called when a client successfully connects. The connection is visible in c.conns before this runs."
15410
+ ),
15411
+ onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
15412
+ onBeforeActionResponse: external_exports.unknown().optional().describe(
15413
+ "Called before sending an action response. Use to transform output."
15414
+ ),
15415
+ onRequest: external_exports.unknown().optional().describe(
15416
+ "Called for raw HTTP requests to /actors/{name}/http/* endpoints."
15417
+ ),
15418
+ onWebSocket: external_exports.unknown().optional().describe(
15419
+ "Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
15420
+ ),
15421
+ actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
15422
+ "Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
15423
+ ),
15424
+ actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
15425
+ "Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
15426
+ ),
15427
+ connParamsSchema: external_exports.unknown().optional().describe(
15428
+ "Optional schema for validating connection params in native runtimes."
15429
+ ),
15430
+ events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
15431
+ queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
15432
+ options: DocActorOptionsSchema.optional()
15433
+ }).describe("Actor configuration passed to the actor() function.");
15432
15434
 
15433
15435
  // ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
15434
15436
  var EMPTY_KEY = "/";
@@ -15547,44 +15549,6 @@ function removePrefixFromKey(prefixedKey) {
15547
15549
  return prefixedKey.slice(KEYS.KV.length);
15548
15550
  }
15549
15551
 
15550
- // ../rivetkit/dist/tsup/chunk-ZY3ZUXAJ.js
15551
- function logger() {
15552
- return getLogger("actor-client");
15553
- }
15554
- var webSocketPromise = null;
15555
- async function importWebSocket() {
15556
- if (webSocketPromise !== null) {
15557
- return webSocketPromise;
15558
- }
15559
- webSocketPromise = (async () => {
15560
- let _WebSocket;
15561
- if (typeof WebSocket !== "undefined") {
15562
- _WebSocket = WebSocket;
15563
- } else {
15564
- try {
15565
- const moduleName = "ws";
15566
- const ws = await import(
15567
- /* webpackIgnore: true */
15568
- moduleName
15569
- );
15570
- _WebSocket = ws.default;
15571
- logger().debug("using websocket from npm");
15572
- } catch {
15573
- _WebSocket = class MockWebSocket {
15574
- constructor() {
15575
- throw new Error(
15576
- 'WebSocket support requires installing the "ws" peer dependency.'
15577
- );
15578
- }
15579
- };
15580
- logger().debug("using mock websocket");
15581
- }
15582
- }
15583
- return _WebSocket;
15584
- })();
15585
- return webSocketPromise;
15586
- }
15587
-
15588
15552
  // ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
15589
15553
  var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
15590
15554
  function isManualTransactionControl(query) {
@@ -15668,7 +15632,45 @@ var AsyncMutex = class {
15668
15632
  }
15669
15633
  };
15670
15634
 
15671
- // ../rivetkit/dist/tsup/chunk-GPJ76U2B.js
15635
+ // ../rivetkit/dist/tsup/chunk-ABQUEXF4.js
15636
+ function logger() {
15637
+ return getLogger("actor-client");
15638
+ }
15639
+ var webSocketPromise = null;
15640
+ async function importWebSocket() {
15641
+ if (webSocketPromise !== null) {
15642
+ return webSocketPromise;
15643
+ }
15644
+ webSocketPromise = (async () => {
15645
+ let _WebSocket;
15646
+ if (typeof WebSocket !== "undefined") {
15647
+ _WebSocket = WebSocket;
15648
+ } else {
15649
+ try {
15650
+ const moduleName = "ws";
15651
+ const ws = await import(
15652
+ /* webpackIgnore: true */
15653
+ moduleName
15654
+ );
15655
+ _WebSocket = ws.default;
15656
+ logger().debug("using websocket from npm");
15657
+ } catch {
15658
+ _WebSocket = class MockWebSocket {
15659
+ constructor() {
15660
+ throw new Error(
15661
+ 'WebSocket support requires installing the "ws" peer dependency.'
15662
+ );
15663
+ }
15664
+ };
15665
+ logger().debug("using mock websocket");
15666
+ }
15667
+ }
15668
+ return _WebSocket;
15669
+ })();
15670
+ return webSocketPromise;
15671
+ }
15672
+
15673
+ // ../rivetkit/dist/tsup/chunk-W4HOK4YC.js
15672
15674
  var import_invariant2 = __toESM(require_invariant(), 1);
15673
15675
 
15674
15676
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15846,7 +15848,7 @@ function createVersionedDataHandler(config3) {
15846
15848
  return new VersionedDataHandler(config3);
15847
15849
  }
15848
15850
 
15849
- // ../rivetkit/dist/tsup/chunk-GPJ76U2B.js
15851
+ // ../rivetkit/dist/tsup/chunk-W4HOK4YC.js
15850
15852
  var import_invariant3 = __toESM(require_invariant(), 1);
15851
15853
  var import_invariant4 = __toESM(require_invariant(), 1);
15852
15854
  var PATH_CONNECT = "/connect";
@@ -21639,7 +21641,7 @@ function apiActorToOutput(actor2) {
21639
21641
  };
21640
21642
  }
21641
21643
 
21642
- // ../rivetkit/dist/tsup/chunk-ZW4F5U6Z.js
21644
+ // ../rivetkit/dist/tsup/chunk-EVYJ3P3V.js
21643
21645
  var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
21644
21646
  var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
21645
21647
  function registerNativeStateTransactionOpener(provider, opener) {
@@ -23806,7 +23808,7 @@ var RegistryConfigSchema = external_exports.object({
23806
23808
  config3.startEngine || parsedEndpoint
23807
23809
  );
23808
23810
  const namespace = (parsedEndpoint == null ? void 0 : parsedEndpoint.namespace) ?? config3.namespace ?? "default";
23809
- const token = (parsedEndpoint == null ? void 0 : parsedEndpoint.token) ?? config3.token;
23811
+ const token = (parsedEndpoint == null ? void 0 : parsedEndpoint.token) ?? config3.token ?? "dev";
23810
23812
  const parsedPublicEndpoint = config3.serverless.publicEndpoint ? tryParseEndpoint(ctx, {
23811
23813
  endpoint: config3.serverless.publicEndpoint,
23812
23814
  path: ["serverless", "publicEndpoint"]