@rivetkit/supabase 2.3.32 → 2.3.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mod.js +1056 -1054
- package/dist/mod.mjs +1059 -1057
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -335,6 +335,212 @@ __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-ZOVJDAOW.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
|
+
const payload = {
|
|
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
|
+
try {
|
|
453
|
+
return {
|
|
454
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify(payload)}`
|
|
455
|
+
};
|
|
456
|
+
} catch (cause) {
|
|
457
|
+
return {
|
|
458
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({ ...payload, metadata: void 0 })}`,
|
|
459
|
+
droppedMetadataCause: cause
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
function encodeErrorForBridge(error46) {
|
|
464
|
+
if (isCanonicalStructuredRivetError(error46)) {
|
|
465
|
+
return encodeBridgeRivetError(error46).encoded;
|
|
466
|
+
}
|
|
467
|
+
return String(error46);
|
|
468
|
+
}
|
|
469
|
+
function isCanonicalStructuredRivetError(error46) {
|
|
470
|
+
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";
|
|
471
|
+
}
|
|
472
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
473
|
+
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
const raw = JSON.parse(
|
|
478
|
+
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
479
|
+
);
|
|
480
|
+
const payload = {
|
|
481
|
+
...raw,
|
|
482
|
+
rayId: raw.rayId ?? void 0
|
|
483
|
+
};
|
|
484
|
+
if (!isRivetErrorLike(payload)) {
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
488
|
+
return void 0;
|
|
489
|
+
}
|
|
490
|
+
return payload;
|
|
491
|
+
} catch {
|
|
492
|
+
return void 0;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function decodeBridgeRivetError(value) {
|
|
496
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
497
|
+
if (!payload) {
|
|
498
|
+
return void 0;
|
|
499
|
+
}
|
|
500
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
501
|
+
metadata: payload.metadata,
|
|
502
|
+
rayId: payload.rayId,
|
|
503
|
+
public: payload.public,
|
|
504
|
+
statusCode: payload.statusCode,
|
|
505
|
+
actor: payload.actor ?? void 0
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function invalidRequest(error46) {
|
|
509
|
+
return new RivetError(
|
|
510
|
+
"request",
|
|
511
|
+
"invalid",
|
|
512
|
+
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
513
|
+
{
|
|
514
|
+
public: true,
|
|
515
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
function actorNotFound(identifier) {
|
|
520
|
+
return new RivetError(
|
|
521
|
+
"actor",
|
|
522
|
+
"not_found",
|
|
523
|
+
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
524
|
+
{ public: true }
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
function forbiddenError() {
|
|
528
|
+
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
529
|
+
public: true,
|
|
530
|
+
statusCode: 403
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
function unsupportedFeature(feature) {
|
|
534
|
+
return new RivetError(
|
|
535
|
+
"feature",
|
|
536
|
+
"unsupported",
|
|
537
|
+
`Unsupported feature: ${feature}`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// ../rivetkit/dist/tsup/chunk-F4M5TRJZ.js
|
|
542
|
+
var import_pino = require("pino");
|
|
543
|
+
|
|
338
544
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
339
545
|
var external_exports = {};
|
|
340
546
|
__export(external_exports, {
|
|
@@ -13005,877 +13211,178 @@ var classic_default = external_exports;
|
|
|
13005
13211
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13006
13212
|
var v4_default = classic_default;
|
|
13007
13213
|
|
|
13008
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
const
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
}
|
|
13057
|
-
function collectActionEntries(actions) {
|
|
13058
|
-
const entries = [];
|
|
13059
|
-
const names = /* @__PURE__ */ new Set();
|
|
13060
|
-
visitActionGroup(actions ?? {}, [], entries, names);
|
|
13061
|
-
return entries;
|
|
13062
|
-
}
|
|
13063
|
-
function visitActionGroup(value, path2, entries, names) {
|
|
13064
|
-
if (!isRecord(value)) {
|
|
13065
|
-
throw new TypeError(
|
|
13066
|
-
`${formatActionPath(path2)} must be an action handler or group`
|
|
13214
|
+
// ../rivetkit/dist/tsup/chunk-F4M5TRJZ.js
|
|
13215
|
+
var cbor = __toESM(require("cbor-x"), 1);
|
|
13216
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13217
|
+
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13218
|
+
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13219
|
+
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13220
|
+
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13221
|
+
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13222
|
+
var getRivetTotalSlots = () => {
|
|
13223
|
+
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13224
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13225
|
+
};
|
|
13226
|
+
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13227
|
+
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13228
|
+
var getRivetRunEnginePort = () => {
|
|
13229
|
+
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13230
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13231
|
+
};
|
|
13232
|
+
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13233
|
+
var getRivetRunServices = () => {
|
|
13234
|
+
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13235
|
+
return value === void 0 ? void 0 : value === "1";
|
|
13236
|
+
};
|
|
13237
|
+
var getRivetEnvoyVersion = () => {
|
|
13238
|
+
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13239
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13240
|
+
};
|
|
13241
|
+
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13242
|
+
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13243
|
+
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13244
|
+
var getRivetkitRuntimeMode = () => {
|
|
13245
|
+
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13246
|
+
if (value === void 0) return "envoy";
|
|
13247
|
+
if (value === "envoy" || value === "serverless") return value;
|
|
13248
|
+
throw new Error(
|
|
13249
|
+
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13250
|
+
);
|
|
13251
|
+
};
|
|
13252
|
+
var getRivetkitPublicDir = () => {
|
|
13253
|
+
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13254
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
13255
|
+
};
|
|
13256
|
+
function parsePortEnv(raw) {
|
|
13257
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
13258
|
+
const parsed = Number.parseInt(raw, 10);
|
|
13259
|
+
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13260
|
+
throw new Error(
|
|
13261
|
+
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13067
13262
|
);
|
|
13068
13263
|
}
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13264
|
+
return parsed;
|
|
13265
|
+
}
|
|
13266
|
+
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13267
|
+
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13268
|
+
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13269
|
+
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13270
|
+
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13271
|
+
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13272
|
+
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13273
|
+
var isDev = () => getNodeEnv() !== "production";
|
|
13274
|
+
function assertUnreachable(x) {
|
|
13275
|
+
throw new Error(`Unreachable case: ${x}`);
|
|
13276
|
+
}
|
|
13277
|
+
function deconstructError(error46, exposeInternalError = false) {
|
|
13278
|
+
let statusCode;
|
|
13279
|
+
let public_;
|
|
13280
|
+
let group;
|
|
13281
|
+
let code;
|
|
13282
|
+
let message;
|
|
13283
|
+
let metadata;
|
|
13284
|
+
let rayId;
|
|
13285
|
+
let actor2;
|
|
13286
|
+
if (isCanonicalStructuredRivetError(error46)) {
|
|
13287
|
+
statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
|
|
13288
|
+
public_ = error46.public ?? false;
|
|
13289
|
+
group = error46.group;
|
|
13290
|
+
code = error46.code;
|
|
13291
|
+
message = error46.message;
|
|
13292
|
+
metadata = error46.metadata;
|
|
13293
|
+
rayId = error46.rayId;
|
|
13294
|
+
actor2 = error46.actor;
|
|
13295
|
+
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13296
|
+
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13297
|
+
public_ = true;
|
|
13298
|
+
group = error46.group;
|
|
13299
|
+
code = error46.code;
|
|
13300
|
+
message = getErrorMessage(error46);
|
|
13301
|
+
metadata = error46.metadata;
|
|
13302
|
+
rayId = error46.rayId;
|
|
13303
|
+
actor2 = error46.actor;
|
|
13304
|
+
} else if (exposeInternalError) {
|
|
13305
|
+
if (RivetError.isActorError(error46)) {
|
|
13306
|
+
statusCode = 500;
|
|
13307
|
+
public_ = false;
|
|
13308
|
+
group = error46.group;
|
|
13309
|
+
code = error46.code;
|
|
13310
|
+
message = getErrorMessage(error46);
|
|
13311
|
+
metadata = error46.metadata;
|
|
13312
|
+
rayId = error46.rayId;
|
|
13313
|
+
actor2 = error46.actor;
|
|
13084
13314
|
} else {
|
|
13085
|
-
|
|
13315
|
+
statusCode = 500;
|
|
13316
|
+
public_ = false;
|
|
13317
|
+
group = "rivetkit";
|
|
13318
|
+
code = INTERNAL_ERROR_CODE;
|
|
13319
|
+
message = getErrorMessage(error46);
|
|
13320
|
+
}
|
|
13321
|
+
} else {
|
|
13322
|
+
statusCode = 500;
|
|
13323
|
+
public_ = false;
|
|
13324
|
+
group = "rivetkit";
|
|
13325
|
+
code = INTERNAL_ERROR_CODE;
|
|
13326
|
+
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13327
|
+
if (RivetError.isActorError(error46)) {
|
|
13328
|
+
actor2 = error46.actor;
|
|
13086
13329
|
}
|
|
13330
|
+
metadata = {
|
|
13331
|
+
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13332
|
+
};
|
|
13087
13333
|
}
|
|
13334
|
+
return {
|
|
13335
|
+
__type: "ActorError",
|
|
13336
|
+
statusCode,
|
|
13337
|
+
public: public_,
|
|
13338
|
+
group,
|
|
13339
|
+
code,
|
|
13340
|
+
message,
|
|
13341
|
+
metadata,
|
|
13342
|
+
rayId,
|
|
13343
|
+
actor: actor2
|
|
13344
|
+
};
|
|
13088
13345
|
}
|
|
13089
|
-
function
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13346
|
+
function stringifyError(error46) {
|
|
13347
|
+
if (error46 instanceof Error) {
|
|
13348
|
+
if (typeof process !== "undefined" && getLogErrorStack()) {
|
|
13349
|
+
let stack;
|
|
13350
|
+
try {
|
|
13351
|
+
stack = error46.stack;
|
|
13352
|
+
} catch {
|
|
13353
|
+
stack = void 0;
|
|
13354
|
+
}
|
|
13355
|
+
return `${error46.name}: ${error46.message}${stack ? `
|
|
13356
|
+
${stack}` : ""}`;
|
|
13357
|
+
} else {
|
|
13358
|
+
return `${error46.name}: ${error46.message}`;
|
|
13094
13359
|
}
|
|
13095
|
-
|
|
13360
|
+
} else if (typeof error46 === "string") {
|
|
13361
|
+
return error46;
|
|
13362
|
+
} else if (typeof error46 === "object" && error46 !== null) {
|
|
13363
|
+
try {
|
|
13364
|
+
return `${JSON.stringify(error46)}`;
|
|
13365
|
+
} catch {
|
|
13366
|
+
return "[cannot stringify error]";
|
|
13367
|
+
}
|
|
13368
|
+
} else {
|
|
13369
|
+
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13096
13370
|
}
|
|
13097
|
-
return value;
|
|
13098
13371
|
}
|
|
13099
|
-
function
|
|
13100
|
-
if (typeof
|
|
13101
|
-
return
|
|
13372
|
+
function getErrorMessage(err) {
|
|
13373
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
13374
|
+
return err.message;
|
|
13375
|
+
} else {
|
|
13376
|
+
return String(err);
|
|
13102
13377
|
}
|
|
13103
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13104
|
-
return prototype === Object.prototype || prototype === null;
|
|
13105
13378
|
}
|
|
13106
|
-
function
|
|
13107
|
-
return
|
|
13108
|
-
}
|
|
13109
|
-
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
13110
|
-
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
13111
|
-
"rivetkit.actor_context_internal"
|
|
13112
|
-
);
|
|
13113
|
-
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
13114
|
-
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
13115
|
-
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
13116
|
-
var zActionTree = external_exports.custom((value) => {
|
|
13117
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13118
|
-
return false;
|
|
13119
|
-
}
|
|
13120
|
-
const prototype = Object.getPrototypeOf(value);
|
|
13121
|
-
return prototype === Object.prototype || prototype === null;
|
|
13122
|
-
}).superRefine((actions, ctx) => {
|
|
13123
|
-
try {
|
|
13124
|
-
flattenActionHandlers(actions);
|
|
13125
|
-
} catch (error46) {
|
|
13126
|
-
ctx.addIssue({
|
|
13127
|
-
code: "custom",
|
|
13128
|
-
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
13129
|
-
});
|
|
13130
|
-
}
|
|
13131
|
-
});
|
|
13132
|
-
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
13133
|
-
getHistory: zFunction(),
|
|
13134
|
-
getState: zFunction().optional(),
|
|
13135
|
-
onHistoryUpdated: zFunction().optional(),
|
|
13136
|
-
replayFromStep: zFunction().optional()
|
|
13137
|
-
});
|
|
13138
|
-
var RunInspectorConfigSchema = external_exports.object({
|
|
13139
|
-
workflow: WorkflowInspectorConfigSchema.optional()
|
|
13140
|
-
}).optional();
|
|
13141
|
-
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
13142
|
-
"workflow",
|
|
13143
|
-
"database",
|
|
13144
|
-
"state",
|
|
13145
|
-
"queue",
|
|
13146
|
-
"schedules",
|
|
13147
|
-
"connections",
|
|
13148
|
-
"console"
|
|
13149
|
-
];
|
|
13150
|
-
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13151
|
-
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
13152
|
-
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
13153
|
-
id: external_exports.string().regex(
|
|
13154
|
-
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
13155
|
-
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
13156
|
-
),
|
|
13157
|
-
label: external_exports.string().min(1),
|
|
13158
|
-
source: external_exports.string().min(1),
|
|
13159
|
-
/**
|
|
13160
|
-
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
13161
|
-
* icon registry); unknown ids fall back to a generic icon.
|
|
13162
|
-
*/
|
|
13163
|
-
icon: external_exports.string().min(1).optional(),
|
|
13164
|
-
hidden: external_exports.literal(false).optional()
|
|
13165
|
-
}).strict();
|
|
13166
|
-
var HideInspectorTabEntrySchema = external_exports.object({
|
|
13167
|
-
id: BuiltinInspectorTabIdSchema,
|
|
13168
|
-
hidden: external_exports.literal(true)
|
|
13169
|
-
}).strict();
|
|
13170
|
-
var InspectorTabEntrySchema = external_exports.union([
|
|
13171
|
-
CustomInspectorTabEntrySchema,
|
|
13172
|
-
HideInspectorTabEntrySchema
|
|
13173
|
-
]);
|
|
13174
|
-
var ActorInspectorConfigSchema = external_exports.object({
|
|
13175
|
-
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
13176
|
-
}).strict().refine(
|
|
13177
|
-
(data) => {
|
|
13178
|
-
const ids = data.tabs.map((t) => t.id);
|
|
13179
|
-
return new Set(ids).size === ids.length;
|
|
13180
|
-
},
|
|
13181
|
-
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
13182
|
-
).refine(
|
|
13183
|
-
(data) => {
|
|
13184
|
-
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13185
|
-
return data.tabs.every(
|
|
13186
|
-
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
13187
|
-
);
|
|
13188
|
-
},
|
|
13189
|
-
{
|
|
13190
|
-
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
13191
|
-
path: ["tabs"]
|
|
13192
|
-
}
|
|
13193
|
-
);
|
|
13194
|
-
var RunConfigSchema = external_exports.object({
|
|
13195
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13196
|
-
name: external_exports.string().optional(),
|
|
13197
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13198
|
-
icon: external_exports.string().optional(),
|
|
13199
|
-
/** The run handler function. */
|
|
13200
|
-
run: zFunction(),
|
|
13201
|
-
/** Inspector integration for long-running run handlers. */
|
|
13202
|
-
inspector: RunInspectorConfigSchema.optional()
|
|
13203
|
-
});
|
|
13204
|
-
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
13205
|
-
function defineRunHandler(run, options) {
|
|
13206
|
-
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
13207
|
-
throw new TypeError(
|
|
13208
|
-
"defineRunHandler requires inspectorKind and createInspector together"
|
|
13209
|
-
);
|
|
13210
|
-
}
|
|
13211
|
-
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
13212
|
-
configurable: false,
|
|
13213
|
-
enumerable: false,
|
|
13214
|
-
writable: false,
|
|
13215
|
-
value: {
|
|
13216
|
-
name: options.name,
|
|
13217
|
-
icon: options.icon,
|
|
13218
|
-
inspectorKind: options.inspectorKind,
|
|
13219
|
-
createInspector: options.createInspector
|
|
13220
|
-
}
|
|
13221
|
-
});
|
|
13222
|
-
return run;
|
|
13223
|
-
}
|
|
13224
|
-
function getRunInspectorKind(run) {
|
|
13225
|
-
var _a2;
|
|
13226
|
-
if (!run || typeof run !== "function") return void 0;
|
|
13227
|
-
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
13228
|
-
}
|
|
13229
|
-
function createRunInspector(run, context2) {
|
|
13230
|
-
var _a2, _b;
|
|
13231
|
-
if (!run || typeof run !== "function") return void 0;
|
|
13232
|
-
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context2);
|
|
13233
|
-
}
|
|
13234
|
-
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
13235
|
-
function getRunFunction(run) {
|
|
13236
|
-
if (!run) return void 0;
|
|
13237
|
-
if (typeof run === "function") return run;
|
|
13238
|
-
return run.run;
|
|
13239
|
-
}
|
|
13240
|
-
function getRunMetadata(run) {
|
|
13241
|
-
if (!run) return {};
|
|
13242
|
-
if (typeof run === "function") {
|
|
13243
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13244
|
-
if (!config3) return {};
|
|
13245
|
-
return { name: config3.name, icon: config3.icon };
|
|
13246
|
-
}
|
|
13247
|
-
return { name: run.name, icon: run.icon };
|
|
13248
|
-
}
|
|
13249
|
-
function getRunInspectorConfig(run, actor2) {
|
|
13250
|
-
if (!run) return void 0;
|
|
13251
|
-
if (typeof run === "function") {
|
|
13252
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13253
|
-
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
13254
|
-
}
|
|
13255
|
-
return run.inspector;
|
|
13256
|
-
}
|
|
13257
|
-
function hasRunInspectorConfig(run) {
|
|
13258
|
-
if (!run) return false;
|
|
13259
|
-
if (typeof run !== "function") return run.inspector !== void 0;
|
|
13260
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13261
|
-
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;
|
|
13262
|
-
}
|
|
13263
|
-
function disposeRunInspector(run, actorId) {
|
|
13264
|
-
var _a2;
|
|
13265
|
-
if (!run || typeof run !== "function") {
|
|
13266
|
-
return;
|
|
13267
|
-
}
|
|
13268
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13269
|
-
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
13270
|
-
}
|
|
13271
|
-
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
13272
|
-
/** Display name for the actor in the Inspector UI. */
|
|
13273
|
-
name: external_exports.string().optional(),
|
|
13274
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13275
|
-
icon: external_exports.string().optional(),
|
|
13276
|
-
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
13277
|
-
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
13278
|
-
/**
|
|
13279
|
-
* Can hibernate WebSockets, both client connections for actions and
|
|
13280
|
-
* events and WebSockets for onWebSocket. A WebSocket that does not
|
|
13281
|
-
* hibernate closes when the actor sleeps, and the client reconnects.
|
|
13282
|
-
*
|
|
13283
|
-
* @experimental
|
|
13284
|
-
**/
|
|
13285
|
-
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
13286
|
-
}).strict();
|
|
13287
|
-
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
13288
|
-
() => ({})
|
|
13289
|
-
);
|
|
13290
|
-
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
13291
|
-
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
13292
|
-
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
13293
|
-
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13294
|
-
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13295
|
-
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
13296
|
-
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
13297
|
-
/** @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. */
|
|
13298
|
-
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
13299
|
-
/** @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. */
|
|
13300
|
-
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
13301
|
-
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
13302
|
-
actionTimeout: external_exports.number().positive().default(6e4),
|
|
13303
|
-
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
13304
|
-
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
13305
|
-
/** @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. */
|
|
13306
|
-
noSleep: external_exports.boolean().default(false),
|
|
13307
|
-
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
13308
|
-
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
13309
|
-
/** Maximum pending one-shot and recurring schedules. */
|
|
13310
|
-
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
13311
|
-
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
13312
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13313
|
-
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
13314
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13315
|
-
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
13316
|
-
}).strict();
|
|
13317
|
-
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
13318
|
-
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
13319
|
-
InstanceActorOptionsBaseSchema.shape
|
|
13320
|
-
).strict().prefault(() => ({}));
|
|
13321
|
-
var zSampleRate = external_exports.number().min(0).max(1);
|
|
13322
|
-
var zActionSampleRates = external_exports.lazy(
|
|
13323
|
-
() => external_exports.record(external_exports.string(), external_exports.union([zSampleRate, zActionSampleRates]))
|
|
13324
|
-
);
|
|
13325
|
-
var ActorConfigSchema = external_exports.object({
|
|
13326
|
-
onCreate: zFunction().optional(),
|
|
13327
|
-
onDestroy: zFunction().optional(),
|
|
13328
|
-
onMigrate: zFunction().optional(),
|
|
13329
|
-
onWake: zFunction().optional(),
|
|
13330
|
-
onSleep: zFunction().optional(),
|
|
13331
|
-
run: zRunHandler,
|
|
13332
|
-
onStateChange: zFunction().optional(),
|
|
13333
|
-
onBeforeConnect: zFunction().optional(),
|
|
13334
|
-
onConnect: zFunction().optional(),
|
|
13335
|
-
onDisconnect: zFunction().optional(),
|
|
13336
|
-
onBeforeActionResponse: zFunction().optional(),
|
|
13337
|
-
onRequest: zFunction().optional(),
|
|
13338
|
-
onWebSocket: zFunction().optional(),
|
|
13339
|
-
actions: zActionTree.default(() => ({})),
|
|
13340
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13341
|
-
tracing: external_exports.object({
|
|
13342
|
-
sampler: zSampleRate.optional(),
|
|
13343
|
-
actions: zActionSampleRates.optional()
|
|
13344
|
-
}).strict().optional(),
|
|
13345
|
-
connParamsSchema: external_exports.any().optional(),
|
|
13346
|
-
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13347
|
-
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13348
|
-
state: external_exports.any().optional(),
|
|
13349
|
-
createState: zFunction().optional(),
|
|
13350
|
-
connState: external_exports.any().optional(),
|
|
13351
|
-
createConnState: zFunction().optional(),
|
|
13352
|
-
vars: external_exports.any().optional(),
|
|
13353
|
-
db: external_exports.any().optional(),
|
|
13354
|
-
createVars: zFunction().optional(),
|
|
13355
|
-
options: ActorOptionsSchema,
|
|
13356
|
-
inspector: ActorInspectorConfigSchema.optional()
|
|
13357
|
-
}).strict().refine(
|
|
13358
|
-
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
13359
|
-
{
|
|
13360
|
-
message: "Cannot define both 'state' and 'createState'",
|
|
13361
|
-
path: ["state"]
|
|
13362
|
-
}
|
|
13363
|
-
).refine(
|
|
13364
|
-
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
13365
|
-
{
|
|
13366
|
-
message: "Cannot define both 'connState' and 'createConnState'",
|
|
13367
|
-
path: ["connState"]
|
|
13368
|
-
}
|
|
13369
|
-
).refine(
|
|
13370
|
-
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
13371
|
-
{
|
|
13372
|
-
message: "Cannot define both 'vars' and 'createVars'",
|
|
13373
|
-
path: ["vars"]
|
|
13374
|
-
}
|
|
13375
|
-
);
|
|
13376
|
-
var DocActorOptionsSchema = external_exports.object({
|
|
13377
|
-
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
13378
|
-
icon: external_exports.string().optional().describe(
|
|
13379
|
-
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
13380
|
-
),
|
|
13381
|
-
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
13382
|
-
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
13383
|
-
),
|
|
13384
|
-
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
13385
|
-
createConnStateTimeout: external_exports.number().optional().describe(
|
|
13386
|
-
"Timeout in ms for createConnState handler. Default: 5000"
|
|
13387
|
-
),
|
|
13388
|
-
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
13389
|
-
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
13390
|
-
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
13391
|
-
),
|
|
13392
|
-
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
13393
|
-
sleepGracePeriod: external_exports.number().optional().describe(
|
|
13394
|
-
`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}.`
|
|
13395
|
-
),
|
|
13396
|
-
onDestroyTimeout: external_exports.number().optional().describe(
|
|
13397
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13398
|
-
),
|
|
13399
|
-
waitUntilTimeout: external_exports.number().optional().describe(
|
|
13400
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13401
|
-
),
|
|
13402
|
-
stateSaveInterval: external_exports.number().optional().describe(
|
|
13403
|
-
"Interval in ms between automatic state saves. Default: 1000"
|
|
13404
|
-
),
|
|
13405
|
-
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
13406
|
-
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
13407
|
-
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
13408
|
-
),
|
|
13409
|
-
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
13410
|
-
"Interval in ms between connection liveness checks. Default: 5000"
|
|
13411
|
-
),
|
|
13412
|
-
noSleep: external_exports.boolean().optional().describe(
|
|
13413
|
-
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
13414
|
-
),
|
|
13415
|
-
sleepTimeout: external_exports.number().optional().describe(
|
|
13416
|
-
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
13417
|
-
),
|
|
13418
|
-
maxQueueSize: external_exports.number().optional().describe(
|
|
13419
|
-
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
13420
|
-
),
|
|
13421
|
-
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
13422
|
-
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
13423
|
-
),
|
|
13424
|
-
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
13425
|
-
"Maximum size of each queue message in bytes. Default: 65536"
|
|
13426
|
-
),
|
|
13427
|
-
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
13428
|
-
"Whether WebSockets can be hibernated, both client connections for actions and events and WebSockets using onWebSocket. A WebSocket that does not hibernate closes when the actor sleeps. Default: false"
|
|
13429
|
-
)
|
|
13430
|
-
}).describe("Actor options for timeouts and behavior configuration.");
|
|
13431
|
-
var DocActorConfigSchema = external_exports.object({
|
|
13432
|
-
state: external_exports.unknown().optional().describe(
|
|
13433
|
-
"Initial state value for the actor. Cannot be used with createState."
|
|
13434
|
-
),
|
|
13435
|
-
createState: external_exports.unknown().optional().describe(
|
|
13436
|
-
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
13437
|
-
),
|
|
13438
|
-
connState: external_exports.unknown().optional().describe(
|
|
13439
|
-
"Initial connection state value. Cannot be used with createConnState."
|
|
13440
|
-
),
|
|
13441
|
-
createConnState: external_exports.unknown().optional().describe(
|
|
13442
|
-
"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."
|
|
13443
|
-
),
|
|
13444
|
-
vars: external_exports.unknown().optional().describe(
|
|
13445
|
-
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
13446
|
-
),
|
|
13447
|
-
createVars: external_exports.unknown().optional().describe(
|
|
13448
|
-
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
13449
|
-
),
|
|
13450
|
-
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
13451
|
-
onCreate: external_exports.unknown().optional().describe(
|
|
13452
|
-
"Called when the actor is first initialized. Use to initialize state."
|
|
13453
|
-
),
|
|
13454
|
-
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
13455
|
-
onMigrate: external_exports.unknown().optional().describe(
|
|
13456
|
-
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
13457
|
-
),
|
|
13458
|
-
onWake: external_exports.unknown().optional().describe(
|
|
13459
|
-
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
13460
|
-
),
|
|
13461
|
-
onSleep: external_exports.unknown().optional().describe(
|
|
13462
|
-
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
13463
|
-
),
|
|
13464
|
-
run: external_exports.unknown().optional().describe(
|
|
13465
|
-
"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."
|
|
13466
|
-
),
|
|
13467
|
-
onStateChange: external_exports.unknown().optional().describe(
|
|
13468
|
-
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
13469
|
-
),
|
|
13470
|
-
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
13471
|
-
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
13472
|
-
),
|
|
13473
|
-
onConnect: external_exports.unknown().optional().describe(
|
|
13474
|
-
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
13475
|
-
),
|
|
13476
|
-
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
13477
|
-
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
13478
|
-
"Called before sending an action response. Use to transform output."
|
|
13479
|
-
),
|
|
13480
|
-
onRequest: external_exports.unknown().optional().describe(
|
|
13481
|
-
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
13482
|
-
),
|
|
13483
|
-
onWebSocket: external_exports.unknown().optional().describe(
|
|
13484
|
-
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
13485
|
-
),
|
|
13486
|
-
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13487
|
-
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
13488
|
-
),
|
|
13489
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13490
|
-
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
13491
|
-
),
|
|
13492
|
-
tracing: external_exports.unknown().optional().describe(
|
|
13493
|
-
"Trace sampling for this actor: `sampler` is the share of its invocations that are recorded, from 0 to 1, with optional per-action rates under `actions`. A rate lowers what is recorded and never raises it. Defaults to the process sampler from OTEL_TRACES_SAMPLER."
|
|
13494
|
-
),
|
|
13495
|
-
connParamsSchema: external_exports.unknown().optional().describe(
|
|
13496
|
-
"Optional schema for validating connection params in native runtimes."
|
|
13497
|
-
),
|
|
13498
|
-
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
13499
|
-
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
13500
|
-
options: DocActorOptionsSchema.optional()
|
|
13501
|
-
}).describe("Actor configuration passed to the actor() function.");
|
|
13502
|
-
|
|
13503
|
-
// ../rivetkit/dist/tsup/chunk-ZOVJDAOW.js
|
|
13504
|
-
var INTERNAL_ERROR_CODE = "internal_error";
|
|
13505
|
-
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
13506
|
-
var USER_ERROR_CODE = "user_error";
|
|
13507
|
-
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
13508
|
-
function looksLikeRivetErrorOptions(value) {
|
|
13509
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
13510
|
-
}
|
|
13511
|
-
function isTypedErrorTag(value) {
|
|
13512
|
-
return value === "ActorError" || value === "RivetError";
|
|
13513
|
-
}
|
|
13514
|
-
function errorMessage(error46, fallback = String(error46)) {
|
|
13515
|
-
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
13516
|
-
return error46.message;
|
|
13517
|
-
}
|
|
13518
|
-
return fallback;
|
|
13519
|
-
}
|
|
13520
|
-
function isRivetErrorLike(error46) {
|
|
13521
|
-
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));
|
|
13522
|
-
}
|
|
13523
|
-
function isActorAbortedError(error46) {
|
|
13524
|
-
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
13525
|
-
}
|
|
13526
|
-
function isActorSpecifier(value) {
|
|
13527
|
-
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");
|
|
13528
|
-
}
|
|
13529
|
-
var RivetError = class extends Error {
|
|
13530
|
-
__type = "RivetError";
|
|
13531
|
-
public;
|
|
13532
|
-
metadata;
|
|
13533
|
-
rayId;
|
|
13534
|
-
statusCode;
|
|
13535
|
-
actor;
|
|
13536
|
-
group;
|
|
13537
|
-
code;
|
|
13538
|
-
static isRivetError(error46) {
|
|
13539
|
-
return isRivetErrorLike(error46);
|
|
13540
|
-
}
|
|
13541
|
-
static isActorError(error46) {
|
|
13542
|
-
return isRivetErrorLike(error46);
|
|
13543
|
-
}
|
|
13544
|
-
constructor(group, code, message, options) {
|
|
13545
|
-
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
13546
|
-
super(message, { cause: normalized.cause });
|
|
13547
|
-
this.name = "RivetError";
|
|
13548
|
-
this.group = group;
|
|
13549
|
-
this.code = code;
|
|
13550
|
-
this.public = normalized.public ?? false;
|
|
13551
|
-
this.metadata = normalized.metadata;
|
|
13552
|
-
this.rayId = normalized.rayId ?? void 0;
|
|
13553
|
-
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
13554
|
-
this.actor = normalized.actor;
|
|
13555
|
-
}
|
|
13556
|
-
toString() {
|
|
13557
|
-
return this.message;
|
|
13558
|
-
}
|
|
13559
|
-
};
|
|
13560
|
-
var UserError = class extends RivetError {
|
|
13561
|
-
constructor(message, options) {
|
|
13562
|
-
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
13563
|
-
public: true,
|
|
13564
|
-
metadata: options == null ? void 0 : options.metadata,
|
|
13565
|
-
cause: options == null ? void 0 : options.cause
|
|
13566
|
-
});
|
|
13567
|
-
}
|
|
13568
|
-
};
|
|
13569
|
-
function toRivetError(error46, fallback) {
|
|
13570
|
-
if (typeof error46 === "string") {
|
|
13571
|
-
const bridged = decodeBridgeRivetError(error46);
|
|
13572
|
-
if (bridged) {
|
|
13573
|
-
return bridged;
|
|
13574
|
-
}
|
|
13575
|
-
}
|
|
13576
|
-
if (error46 instanceof Error) {
|
|
13577
|
-
const bridged = decodeBridgeRivetError(error46.message);
|
|
13578
|
-
if (bridged) {
|
|
13579
|
-
return bridged;
|
|
13580
|
-
}
|
|
13581
|
-
}
|
|
13582
|
-
if (isRivetErrorLike(error46)) {
|
|
13583
|
-
return new RivetError(error46.group, error46.code, error46.message, {
|
|
13584
|
-
public: error46.public,
|
|
13585
|
-
statusCode: error46.statusCode,
|
|
13586
|
-
metadata: error46.metadata,
|
|
13587
|
-
rayId: error46.rayId,
|
|
13588
|
-
actor: error46.actor,
|
|
13589
|
-
cause: error46 instanceof Error ? error46.cause : void 0
|
|
13590
|
-
});
|
|
13591
|
-
}
|
|
13592
|
-
return new RivetError(
|
|
13593
|
-
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
13594
|
-
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
13595
|
-
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
13596
|
-
{
|
|
13597
|
-
public: fallback == null ? void 0 : fallback.public,
|
|
13598
|
-
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
13599
|
-
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
13600
|
-
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
13601
|
-
actor: fallback == null ? void 0 : fallback.actor,
|
|
13602
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13603
|
-
}
|
|
13604
|
-
);
|
|
13605
|
-
}
|
|
13606
|
-
function encodeBridgeRivetError(error46) {
|
|
13607
|
-
const payload = {
|
|
13608
|
-
group: error46.group,
|
|
13609
|
-
code: error46.code,
|
|
13610
|
-
message: error46.message,
|
|
13611
|
-
metadata: error46.metadata,
|
|
13612
|
-
rayId: error46.rayId,
|
|
13613
|
-
public: error46.public,
|
|
13614
|
-
statusCode: error46.statusCode,
|
|
13615
|
-
actor: error46.actor
|
|
13616
|
-
};
|
|
13617
|
-
try {
|
|
13618
|
-
return {
|
|
13619
|
-
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify(payload)}`
|
|
13620
|
-
};
|
|
13621
|
-
} catch (cause) {
|
|
13622
|
-
return {
|
|
13623
|
-
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({ ...payload, metadata: void 0 })}`,
|
|
13624
|
-
droppedMetadataCause: cause
|
|
13625
|
-
};
|
|
13626
|
-
}
|
|
13627
|
-
}
|
|
13628
|
-
function encodeErrorForBridge(error46) {
|
|
13629
|
-
if (isCanonicalStructuredRivetError(error46)) {
|
|
13630
|
-
return encodeBridgeRivetError(error46).encoded;
|
|
13631
|
-
}
|
|
13632
|
-
return String(error46);
|
|
13633
|
-
}
|
|
13634
|
-
function isCanonicalStructuredRivetError(error46) {
|
|
13635
|
-
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";
|
|
13636
|
-
}
|
|
13637
|
-
function decodeBridgeRivetErrorPayload(value) {
|
|
13638
|
-
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
13639
|
-
return void 0;
|
|
13640
|
-
}
|
|
13641
|
-
try {
|
|
13642
|
-
const raw = JSON.parse(
|
|
13643
|
-
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
13644
|
-
);
|
|
13645
|
-
const payload = {
|
|
13646
|
-
...raw,
|
|
13647
|
-
rayId: raw.rayId ?? void 0
|
|
13648
|
-
};
|
|
13649
|
-
if (!isRivetErrorLike(payload)) {
|
|
13650
|
-
return void 0;
|
|
13651
|
-
}
|
|
13652
|
-
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
13653
|
-
return void 0;
|
|
13654
|
-
}
|
|
13655
|
-
return payload;
|
|
13656
|
-
} catch {
|
|
13657
|
-
return void 0;
|
|
13658
|
-
}
|
|
13659
|
-
}
|
|
13660
|
-
function decodeBridgeRivetError(value) {
|
|
13661
|
-
const payload = decodeBridgeRivetErrorPayload(value);
|
|
13662
|
-
if (!payload) {
|
|
13663
|
-
return void 0;
|
|
13664
|
-
}
|
|
13665
|
-
return new RivetError(payload.group, payload.code, payload.message, {
|
|
13666
|
-
metadata: payload.metadata,
|
|
13667
|
-
rayId: payload.rayId,
|
|
13668
|
-
public: payload.public,
|
|
13669
|
-
statusCode: payload.statusCode,
|
|
13670
|
-
actor: payload.actor ?? void 0
|
|
13671
|
-
});
|
|
13672
|
-
}
|
|
13673
|
-
function invalidRequest(error46) {
|
|
13674
|
-
return new RivetError(
|
|
13675
|
-
"request",
|
|
13676
|
-
"invalid",
|
|
13677
|
-
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
13678
|
-
{
|
|
13679
|
-
public: true,
|
|
13680
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
13681
|
-
}
|
|
13682
|
-
);
|
|
13683
|
-
}
|
|
13684
|
-
function actorNotFound(identifier) {
|
|
13685
|
-
return new RivetError(
|
|
13686
|
-
"actor",
|
|
13687
|
-
"not_found",
|
|
13688
|
-
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
13689
|
-
{ public: true }
|
|
13690
|
-
);
|
|
13691
|
-
}
|
|
13692
|
-
function forbiddenError() {
|
|
13693
|
-
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
13694
|
-
public: true,
|
|
13695
|
-
statusCode: 403
|
|
13696
|
-
});
|
|
13697
|
-
}
|
|
13698
|
-
function unsupportedFeature(feature) {
|
|
13699
|
-
return new RivetError(
|
|
13700
|
-
"feature",
|
|
13701
|
-
"unsupported",
|
|
13702
|
-
`Unsupported feature: ${feature}`
|
|
13703
|
-
);
|
|
13704
|
-
}
|
|
13705
|
-
|
|
13706
|
-
// ../rivetkit/dist/tsup/chunk-3LLGBENU.js
|
|
13707
|
-
var import_pino = require("pino");
|
|
13708
|
-
var cbor = __toESM(require("cbor-x"), 1);
|
|
13709
|
-
var import_invariant = __toESM(require_invariant(), 1);
|
|
13710
|
-
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13711
|
-
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13712
|
-
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13713
|
-
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13714
|
-
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13715
|
-
var getRivetTotalSlots = () => {
|
|
13716
|
-
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13717
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13718
|
-
};
|
|
13719
|
-
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13720
|
-
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13721
|
-
var getRivetRunEnginePort = () => {
|
|
13722
|
-
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13723
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13724
|
-
};
|
|
13725
|
-
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13726
|
-
var getRivetRunServices = () => {
|
|
13727
|
-
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13728
|
-
return value === void 0 ? void 0 : value === "1";
|
|
13729
|
-
};
|
|
13730
|
-
var getRivetEnvoyVersion = () => {
|
|
13731
|
-
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13732
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13733
|
-
};
|
|
13734
|
-
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13735
|
-
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13736
|
-
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13737
|
-
var getRivetkitRuntimeMode = () => {
|
|
13738
|
-
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13739
|
-
if (value === void 0) return "envoy";
|
|
13740
|
-
if (value === "envoy" || value === "serverless") return value;
|
|
13741
|
-
throw new Error(
|
|
13742
|
-
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13743
|
-
);
|
|
13744
|
-
};
|
|
13745
|
-
var getRivetkitPublicDir = () => {
|
|
13746
|
-
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13747
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
13748
|
-
};
|
|
13749
|
-
function parsePortEnv(raw) {
|
|
13750
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
13751
|
-
const parsed = Number.parseInt(raw, 10);
|
|
13752
|
-
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13753
|
-
throw new Error(
|
|
13754
|
-
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13755
|
-
);
|
|
13756
|
-
}
|
|
13757
|
-
return parsed;
|
|
13758
|
-
}
|
|
13759
|
-
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13760
|
-
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13761
|
-
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13762
|
-
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13763
|
-
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13764
|
-
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13765
|
-
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13766
|
-
var isDev = () => getNodeEnv() !== "production";
|
|
13767
|
-
function assertUnreachable(x) {
|
|
13768
|
-
throw new Error(`Unreachable case: ${x}`);
|
|
13769
|
-
}
|
|
13770
|
-
function deconstructError(error46, exposeInternalError = false) {
|
|
13771
|
-
let statusCode;
|
|
13772
|
-
let public_;
|
|
13773
|
-
let group;
|
|
13774
|
-
let code;
|
|
13775
|
-
let message;
|
|
13776
|
-
let metadata;
|
|
13777
|
-
let rayId;
|
|
13778
|
-
let actor2;
|
|
13779
|
-
if (isCanonicalStructuredRivetError(error46)) {
|
|
13780
|
-
statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
|
|
13781
|
-
public_ = error46.public ?? false;
|
|
13782
|
-
group = error46.group;
|
|
13783
|
-
code = error46.code;
|
|
13784
|
-
message = error46.message;
|
|
13785
|
-
metadata = error46.metadata;
|
|
13786
|
-
rayId = error46.rayId;
|
|
13787
|
-
actor2 = error46.actor;
|
|
13788
|
-
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13789
|
-
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13790
|
-
public_ = true;
|
|
13791
|
-
group = error46.group;
|
|
13792
|
-
code = error46.code;
|
|
13793
|
-
message = getErrorMessage(error46);
|
|
13794
|
-
metadata = error46.metadata;
|
|
13795
|
-
rayId = error46.rayId;
|
|
13796
|
-
actor2 = error46.actor;
|
|
13797
|
-
} else if (exposeInternalError) {
|
|
13798
|
-
if (RivetError.isActorError(error46)) {
|
|
13799
|
-
statusCode = 500;
|
|
13800
|
-
public_ = false;
|
|
13801
|
-
group = error46.group;
|
|
13802
|
-
code = error46.code;
|
|
13803
|
-
message = getErrorMessage(error46);
|
|
13804
|
-
metadata = error46.metadata;
|
|
13805
|
-
rayId = error46.rayId;
|
|
13806
|
-
actor2 = error46.actor;
|
|
13807
|
-
} else {
|
|
13808
|
-
statusCode = 500;
|
|
13809
|
-
public_ = false;
|
|
13810
|
-
group = "rivetkit";
|
|
13811
|
-
code = INTERNAL_ERROR_CODE;
|
|
13812
|
-
message = getErrorMessage(error46);
|
|
13813
|
-
}
|
|
13814
|
-
} else {
|
|
13815
|
-
statusCode = 500;
|
|
13816
|
-
public_ = false;
|
|
13817
|
-
group = "rivetkit";
|
|
13818
|
-
code = INTERNAL_ERROR_CODE;
|
|
13819
|
-
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13820
|
-
if (RivetError.isActorError(error46)) {
|
|
13821
|
-
actor2 = error46.actor;
|
|
13822
|
-
}
|
|
13823
|
-
metadata = {
|
|
13824
|
-
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13825
|
-
};
|
|
13826
|
-
}
|
|
13827
|
-
return {
|
|
13828
|
-
__type: "ActorError",
|
|
13829
|
-
statusCode,
|
|
13830
|
-
public: public_,
|
|
13831
|
-
group,
|
|
13832
|
-
code,
|
|
13833
|
-
message,
|
|
13834
|
-
metadata,
|
|
13835
|
-
rayId,
|
|
13836
|
-
actor: actor2
|
|
13837
|
-
};
|
|
13838
|
-
}
|
|
13839
|
-
function stringifyError(error46) {
|
|
13840
|
-
if (error46 instanceof Error) {
|
|
13841
|
-
if (typeof process !== "undefined" && getLogErrorStack()) {
|
|
13842
|
-
let stack;
|
|
13843
|
-
try {
|
|
13844
|
-
stack = error46.stack;
|
|
13845
|
-
} catch {
|
|
13846
|
-
stack = void 0;
|
|
13847
|
-
}
|
|
13848
|
-
return `${error46.name}: ${error46.message}${stack ? `
|
|
13849
|
-
${stack}` : ""}`;
|
|
13850
|
-
} else {
|
|
13851
|
-
return `${error46.name}: ${error46.message}`;
|
|
13852
|
-
}
|
|
13853
|
-
} else if (typeof error46 === "string") {
|
|
13854
|
-
return error46;
|
|
13855
|
-
} else if (typeof error46 === "object" && error46 !== null) {
|
|
13856
|
-
try {
|
|
13857
|
-
return `${JSON.stringify(error46)}`;
|
|
13858
|
-
} catch {
|
|
13859
|
-
return "[cannot stringify error]";
|
|
13860
|
-
}
|
|
13861
|
-
} else {
|
|
13862
|
-
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13863
|
-
}
|
|
13864
|
-
}
|
|
13865
|
-
function getErrorMessage(err) {
|
|
13866
|
-
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
13867
|
-
return err.message;
|
|
13868
|
-
} else {
|
|
13869
|
-
return String(err);
|
|
13870
|
-
}
|
|
13871
|
-
}
|
|
13872
|
-
function noopNext() {
|
|
13873
|
-
return async () => {
|
|
13874
|
-
};
|
|
13379
|
+
function noopNext() {
|
|
13380
|
+
return async () => {
|
|
13381
|
+
};
|
|
13875
13382
|
}
|
|
13876
13383
|
var package_default = {
|
|
13877
13384
|
name: "rivetkit",
|
|
13878
|
-
version: "2.3.
|
|
13385
|
+
version: "2.3.33",
|
|
13879
13386
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13880
13387
|
license: "Apache-2.0",
|
|
13881
13388
|
keywords: [
|
|
@@ -15179,7 +14686,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
15179
14686
|
};
|
|
15180
14687
|
}
|
|
15181
14688
|
|
|
15182
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14689
|
+
// ../rivetkit/dist/tsup/chunk-TYDG7WEH.js
|
|
15183
14690
|
var config2 = /* @__PURE__ */ Config({});
|
|
15184
14691
|
function readWorkflowCbor(bc) {
|
|
15185
14692
|
return readData(bc);
|
|
@@ -15289,38 +14796,162 @@ function readWorkflowStepEntry(bc) {
|
|
|
15289
14796
|
error: read1(bc)
|
|
15290
14797
|
};
|
|
15291
14798
|
}
|
|
15292
|
-
function readWorkflowLoopEntry(bc) {
|
|
14799
|
+
function readWorkflowLoopEntry(bc) {
|
|
14800
|
+
return {
|
|
14801
|
+
state: readWorkflowCbor(bc),
|
|
14802
|
+
iteration: readU32(bc),
|
|
14803
|
+
output: read0(bc)
|
|
14804
|
+
};
|
|
14805
|
+
}
|
|
14806
|
+
function readWorkflowSleepEntry(bc) {
|
|
14807
|
+
return {
|
|
14808
|
+
deadline: readU64(bc),
|
|
14809
|
+
state: readWorkflowSleepState(bc)
|
|
14810
|
+
};
|
|
14811
|
+
}
|
|
14812
|
+
function readWorkflowMessageEntry(bc) {
|
|
14813
|
+
return {
|
|
14814
|
+
name: readString(bc),
|
|
14815
|
+
messageData: readWorkflowCbor(bc)
|
|
14816
|
+
};
|
|
14817
|
+
}
|
|
14818
|
+
function readWorkflowRollbackCheckpointEntry(bc) {
|
|
14819
|
+
return {
|
|
14820
|
+
name: readString(bc)
|
|
14821
|
+
};
|
|
14822
|
+
}
|
|
14823
|
+
function readWorkflowBranchStatus(bc) {
|
|
14824
|
+
return {
|
|
14825
|
+
status: readWorkflowBranchStatusType(bc),
|
|
14826
|
+
output: read0(bc),
|
|
14827
|
+
error: read1(bc)
|
|
14828
|
+
};
|
|
14829
|
+
}
|
|
14830
|
+
function read2(bc) {
|
|
14831
|
+
const len = readUintSafe(bc);
|
|
14832
|
+
const result = /* @__PURE__ */ new Map();
|
|
14833
|
+
for (let i = 0; i < len; i++) {
|
|
14834
|
+
const offset = bc.offset;
|
|
14835
|
+
const key = readString(bc);
|
|
14836
|
+
if (result.has(key)) {
|
|
14837
|
+
bc.offset = offset;
|
|
14838
|
+
throw new BareError(offset, "duplicated key");
|
|
14839
|
+
}
|
|
14840
|
+
result.set(key, readWorkflowBranchStatus(bc));
|
|
14841
|
+
}
|
|
14842
|
+
return result;
|
|
14843
|
+
}
|
|
14844
|
+
function readWorkflowJoinEntry(bc) {
|
|
14845
|
+
return {
|
|
14846
|
+
branches: read2(bc)
|
|
14847
|
+
};
|
|
14848
|
+
}
|
|
14849
|
+
function readWorkflowRaceEntry(bc) {
|
|
14850
|
+
return {
|
|
14851
|
+
winner: read1(bc),
|
|
14852
|
+
branches: read2(bc)
|
|
14853
|
+
};
|
|
14854
|
+
}
|
|
14855
|
+
function readWorkflowRemovedEntry(bc) {
|
|
14856
|
+
return {
|
|
14857
|
+
originalType: readString(bc),
|
|
14858
|
+
originalName: read1(bc)
|
|
14859
|
+
};
|
|
14860
|
+
}
|
|
14861
|
+
function readWorkflowVersionCheckEntry(bc) {
|
|
14862
|
+
return {
|
|
14863
|
+
resolved: readU32(bc),
|
|
14864
|
+
latest: readU32(bc)
|
|
14865
|
+
};
|
|
14866
|
+
}
|
|
14867
|
+
function readWorkflowEntryKind(bc) {
|
|
14868
|
+
const offset = bc.offset;
|
|
14869
|
+
const tag = readU8(bc);
|
|
14870
|
+
switch (tag) {
|
|
14871
|
+
case 0:
|
|
14872
|
+
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
14873
|
+
case 1:
|
|
14874
|
+
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
14875
|
+
case 2:
|
|
14876
|
+
return {
|
|
14877
|
+
tag: "WorkflowSleepEntry",
|
|
14878
|
+
val: readWorkflowSleepEntry(bc)
|
|
14879
|
+
};
|
|
14880
|
+
case 3:
|
|
14881
|
+
return {
|
|
14882
|
+
tag: "WorkflowMessageEntry",
|
|
14883
|
+
val: readWorkflowMessageEntry(bc)
|
|
14884
|
+
};
|
|
14885
|
+
case 4:
|
|
14886
|
+
return {
|
|
14887
|
+
tag: "WorkflowRollbackCheckpointEntry",
|
|
14888
|
+
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
14889
|
+
};
|
|
14890
|
+
case 5:
|
|
14891
|
+
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14892
|
+
case 6:
|
|
14893
|
+
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14894
|
+
case 7:
|
|
14895
|
+
return {
|
|
14896
|
+
tag: "WorkflowRemovedEntry",
|
|
14897
|
+
val: readWorkflowRemovedEntry(bc)
|
|
14898
|
+
};
|
|
14899
|
+
case 8:
|
|
14900
|
+
return {
|
|
14901
|
+
tag: "WorkflowVersionCheckEntry",
|
|
14902
|
+
val: readWorkflowVersionCheckEntry(bc)
|
|
14903
|
+
};
|
|
14904
|
+
default: {
|
|
14905
|
+
bc.offset = offset;
|
|
14906
|
+
throw new BareError(offset, "invalid tag");
|
|
14907
|
+
}
|
|
14908
|
+
}
|
|
14909
|
+
}
|
|
14910
|
+
function readWorkflowEntry(bc) {
|
|
15293
14911
|
return {
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
14912
|
+
id: readString(bc),
|
|
14913
|
+
location: readWorkflowLocation(bc),
|
|
14914
|
+
kind: readWorkflowEntryKind(bc)
|
|
15297
14915
|
};
|
|
15298
14916
|
}
|
|
15299
|
-
function
|
|
15300
|
-
return
|
|
15301
|
-
deadline: readU64(bc),
|
|
15302
|
-
state: readWorkflowSleepState(bc)
|
|
15303
|
-
};
|
|
14917
|
+
function read3(bc) {
|
|
14918
|
+
return readBool(bc) ? readU64(bc) : null;
|
|
15304
14919
|
}
|
|
15305
|
-
function
|
|
14920
|
+
function readWorkflowEntryMetadata(bc) {
|
|
15306
14921
|
return {
|
|
15307
|
-
|
|
15308
|
-
|
|
14922
|
+
status: readWorkflowEntryStatus(bc),
|
|
14923
|
+
error: read1(bc),
|
|
14924
|
+
attempts: readU32(bc),
|
|
14925
|
+
lastAttemptAt: readU64(bc),
|
|
14926
|
+
createdAt: readU64(bc),
|
|
14927
|
+
completedAt: read3(bc),
|
|
14928
|
+
rollbackCompletedAt: read3(bc),
|
|
14929
|
+
rollbackError: read1(bc)
|
|
15309
14930
|
};
|
|
15310
14931
|
}
|
|
15311
|
-
function
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
14932
|
+
function read4(bc) {
|
|
14933
|
+
const len = readUintSafe(bc);
|
|
14934
|
+
if (len === 0) {
|
|
14935
|
+
return [];
|
|
14936
|
+
}
|
|
14937
|
+
const result = [readString(bc)];
|
|
14938
|
+
for (let i = 1; i < len; i++) {
|
|
14939
|
+
result[i] = readString(bc);
|
|
14940
|
+
}
|
|
14941
|
+
return result;
|
|
15315
14942
|
}
|
|
15316
|
-
function
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
14943
|
+
function read5(bc) {
|
|
14944
|
+
const len = readUintSafe(bc);
|
|
14945
|
+
if (len === 0) {
|
|
14946
|
+
return [];
|
|
14947
|
+
}
|
|
14948
|
+
const result = [readWorkflowEntry(bc)];
|
|
14949
|
+
for (let i = 1; i < len; i++) {
|
|
14950
|
+
result[i] = readWorkflowEntry(bc);
|
|
14951
|
+
}
|
|
14952
|
+
return result;
|
|
15322
14953
|
}
|
|
15323
|
-
function
|
|
14954
|
+
function read6(bc) {
|
|
15324
14955
|
const len = readUintSafe(bc);
|
|
15325
14956
|
const result = /* @__PURE__ */ new Map();
|
|
15326
14957
|
for (let i = 0; i < len; i++) {
|
|
@@ -15330,152 +14961,523 @@ function read2(bc) {
|
|
|
15330
14961
|
bc.offset = offset;
|
|
15331
14962
|
throw new BareError(offset, "duplicated key");
|
|
15332
14963
|
}
|
|
15333
|
-
result.set(key,
|
|
14964
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14965
|
+
}
|
|
14966
|
+
return result;
|
|
14967
|
+
}
|
|
14968
|
+
function readWorkflowHistory(bc) {
|
|
14969
|
+
return {
|
|
14970
|
+
nameRegistry: read4(bc),
|
|
14971
|
+
entries: read5(bc),
|
|
14972
|
+
entryMetadata: read6(bc)
|
|
14973
|
+
};
|
|
14974
|
+
}
|
|
14975
|
+
function decodeWorkflowHistory(bytes) {
|
|
14976
|
+
const bc = new ByteCursor(bytes, config2);
|
|
14977
|
+
const result = readWorkflowHistory(bc);
|
|
14978
|
+
if (bc.offset < bc.view.byteLength) {
|
|
14979
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
14980
|
+
}
|
|
14981
|
+
return result;
|
|
14982
|
+
}
|
|
14983
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
14984
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
14985
|
+
}
|
|
14986
|
+
|
|
14987
|
+
// ../rivetkit/dist/tsup/chunk-6FEYCVZC.js
|
|
14988
|
+
function flattenActionHandlers(actions) {
|
|
14989
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14990
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14991
|
+
flattened[name] = handler;
|
|
14992
|
+
}
|
|
14993
|
+
return flattened;
|
|
14994
|
+
}
|
|
14995
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
14996
|
+
if (schemas === void 0) return void 0;
|
|
14997
|
+
if (!isRecord(schemas)) {
|
|
14998
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
14999
|
+
}
|
|
15000
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
15001
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
15002
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
15003
|
+
const flatSchema = schemas[name];
|
|
15004
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
15005
|
+
throw new TypeError(
|
|
15006
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
15007
|
+
);
|
|
15008
|
+
}
|
|
15009
|
+
const schema = nestedSchema ?? flatSchema;
|
|
15010
|
+
if (schema !== void 0) {
|
|
15011
|
+
flattened[name] = schema;
|
|
15012
|
+
}
|
|
15013
|
+
}
|
|
15014
|
+
return flattened;
|
|
15015
|
+
}
|
|
15016
|
+
function flattenActionTraceSamplers(actions, rates = {}) {
|
|
15017
|
+
const handlers = flattenActionHandlers(actions);
|
|
15018
|
+
const flattened = Object.fromEntries(flattenSampleRates(rates, []));
|
|
15019
|
+
for (const name of Object.keys(flattened)) {
|
|
15020
|
+
if (!Object.hasOwn(handlers, name)) {
|
|
15021
|
+
throw new TypeError(
|
|
15022
|
+
`tracing.actions.${name} does not name an action`
|
|
15023
|
+
);
|
|
15024
|
+
}
|
|
15025
|
+
}
|
|
15026
|
+
return flattened;
|
|
15027
|
+
}
|
|
15028
|
+
function flattenSampleRates(rates, path2) {
|
|
15029
|
+
return Object.entries(rates).flatMap(
|
|
15030
|
+
([segment, rate]) => {
|
|
15031
|
+
const childPath = [...path2, segment];
|
|
15032
|
+
return typeof rate === "number" ? [[childPath.join("."), rate]] : flattenSampleRates(rate, childPath);
|
|
15033
|
+
}
|
|
15034
|
+
);
|
|
15035
|
+
}
|
|
15036
|
+
function collectActionEntries(actions) {
|
|
15037
|
+
const entries = [];
|
|
15038
|
+
const names = /* @__PURE__ */ new Set();
|
|
15039
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
15040
|
+
return entries;
|
|
15041
|
+
}
|
|
15042
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
15043
|
+
if (!isRecord(value)) {
|
|
15044
|
+
throw new TypeError(
|
|
15045
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
15046
|
+
);
|
|
15047
|
+
}
|
|
15048
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
15049
|
+
const childPath = [...path2, segment];
|
|
15050
|
+
if (typeof child === "function") {
|
|
15051
|
+
const name = childPath.join(".");
|
|
15052
|
+
if (names.has(name)) {
|
|
15053
|
+
throw new TypeError(
|
|
15054
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
15055
|
+
);
|
|
15056
|
+
}
|
|
15057
|
+
names.add(name);
|
|
15058
|
+
entries.push({
|
|
15059
|
+
name,
|
|
15060
|
+
path: childPath,
|
|
15061
|
+
handler: child
|
|
15062
|
+
});
|
|
15063
|
+
} else {
|
|
15064
|
+
visitActionGroup(child, childPath, entries, names);
|
|
15065
|
+
}
|
|
15066
|
+
}
|
|
15067
|
+
}
|
|
15068
|
+
function lookupNestedSchema(schemas, path2) {
|
|
15069
|
+
let value = schemas;
|
|
15070
|
+
for (const segment of path2) {
|
|
15071
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
15072
|
+
return void 0;
|
|
15073
|
+
}
|
|
15074
|
+
value = value[segment];
|
|
15075
|
+
}
|
|
15076
|
+
return value;
|
|
15077
|
+
}
|
|
15078
|
+
function isRecord(value) {
|
|
15079
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15080
|
+
return false;
|
|
15081
|
+
}
|
|
15082
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15083
|
+
return prototype === Object.prototype || prototype === null;
|
|
15084
|
+
}
|
|
15085
|
+
function formatActionPath(path2) {
|
|
15086
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
15087
|
+
}
|
|
15088
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
15089
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
15090
|
+
"rivetkit.actor_context_internal"
|
|
15091
|
+
);
|
|
15092
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
15093
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
15094
|
+
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
15095
|
+
var zActionTree = external_exports.custom((value) => {
|
|
15096
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15097
|
+
return false;
|
|
15098
|
+
}
|
|
15099
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15100
|
+
return prototype === Object.prototype || prototype === null;
|
|
15101
|
+
}).superRefine((actions, ctx) => {
|
|
15102
|
+
try {
|
|
15103
|
+
flattenActionHandlers(actions);
|
|
15104
|
+
} catch (error46) {
|
|
15105
|
+
ctx.addIssue({
|
|
15106
|
+
code: "custom",
|
|
15107
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15108
|
+
});
|
|
15109
|
+
}
|
|
15110
|
+
});
|
|
15111
|
+
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
15112
|
+
getHistory: zFunction(),
|
|
15113
|
+
getState: zFunction().optional(),
|
|
15114
|
+
onHistoryUpdated: zFunction().optional(),
|
|
15115
|
+
replayFromStep: zFunction().optional()
|
|
15116
|
+
});
|
|
15117
|
+
var RunInspectorConfigSchema = external_exports.object({
|
|
15118
|
+
workflow: WorkflowInspectorConfigSchema.optional()
|
|
15119
|
+
}).optional();
|
|
15120
|
+
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
15121
|
+
"workflow",
|
|
15122
|
+
"database",
|
|
15123
|
+
"state",
|
|
15124
|
+
"queue",
|
|
15125
|
+
"schedules",
|
|
15126
|
+
"connections",
|
|
15127
|
+
"console"
|
|
15128
|
+
];
|
|
15129
|
+
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15130
|
+
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
15131
|
+
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
15132
|
+
id: external_exports.string().regex(
|
|
15133
|
+
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
15134
|
+
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
15135
|
+
),
|
|
15136
|
+
label: external_exports.string().min(1),
|
|
15137
|
+
source: external_exports.string().min(1),
|
|
15138
|
+
/**
|
|
15139
|
+
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
15140
|
+
* icon registry); unknown ids fall back to a generic icon.
|
|
15141
|
+
*/
|
|
15142
|
+
icon: external_exports.string().min(1).optional(),
|
|
15143
|
+
hidden: external_exports.literal(false).optional()
|
|
15144
|
+
}).strict();
|
|
15145
|
+
var HideInspectorTabEntrySchema = external_exports.object({
|
|
15146
|
+
id: BuiltinInspectorTabIdSchema,
|
|
15147
|
+
hidden: external_exports.literal(true)
|
|
15148
|
+
}).strict();
|
|
15149
|
+
var InspectorTabEntrySchema = external_exports.union([
|
|
15150
|
+
CustomInspectorTabEntrySchema,
|
|
15151
|
+
HideInspectorTabEntrySchema
|
|
15152
|
+
]);
|
|
15153
|
+
var ActorInspectorConfigSchema = external_exports.object({
|
|
15154
|
+
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
15155
|
+
}).strict().refine(
|
|
15156
|
+
(data) => {
|
|
15157
|
+
const ids = data.tabs.map((t) => t.id);
|
|
15158
|
+
return new Set(ids).size === ids.length;
|
|
15159
|
+
},
|
|
15160
|
+
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
15161
|
+
).refine(
|
|
15162
|
+
(data) => {
|
|
15163
|
+
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15164
|
+
return data.tabs.every(
|
|
15165
|
+
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
15166
|
+
);
|
|
15167
|
+
},
|
|
15168
|
+
{
|
|
15169
|
+
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
15170
|
+
path: ["tabs"]
|
|
15334
15171
|
}
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15172
|
+
);
|
|
15173
|
+
var RunConfigSchema = external_exports.object({
|
|
15174
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15175
|
+
name: external_exports.string().optional(),
|
|
15176
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15177
|
+
icon: external_exports.string().optional(),
|
|
15178
|
+
/** The run handler function. */
|
|
15179
|
+
run: zFunction(),
|
|
15180
|
+
/** Inspector integration for long-running run handlers. */
|
|
15181
|
+
inspector: RunInspectorConfigSchema.optional()
|
|
15182
|
+
});
|
|
15183
|
+
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
15184
|
+
function defineRunHandler(run, options) {
|
|
15185
|
+
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
15186
|
+
throw new TypeError(
|
|
15187
|
+
"defineRunHandler requires inspectorKind and createInspector together"
|
|
15188
|
+
);
|
|
15189
|
+
}
|
|
15190
|
+
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
15191
|
+
configurable: false,
|
|
15192
|
+
enumerable: false,
|
|
15193
|
+
writable: false,
|
|
15194
|
+
value: {
|
|
15195
|
+
name: options.name,
|
|
15196
|
+
icon: options.icon,
|
|
15197
|
+
inspectorKind: options.inspectorKind,
|
|
15198
|
+
createInspector: options.createInspector
|
|
15199
|
+
}
|
|
15200
|
+
});
|
|
15201
|
+
return run;
|
|
15341
15202
|
}
|
|
15342
|
-
function
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
|
|
15346
|
-
};
|
|
15203
|
+
function getRunInspectorKind(run) {
|
|
15204
|
+
var _a2;
|
|
15205
|
+
if (!run || typeof run !== "function") return void 0;
|
|
15206
|
+
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
15347
15207
|
}
|
|
15348
|
-
function
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
};
|
|
15208
|
+
function createRunInspector(run, context2) {
|
|
15209
|
+
var _a2, _b;
|
|
15210
|
+
if (!run || typeof run !== "function") return void 0;
|
|
15211
|
+
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context2);
|
|
15353
15212
|
}
|
|
15354
|
-
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
|
|
15358
|
-
|
|
15213
|
+
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
15214
|
+
function getRunFunction(run) {
|
|
15215
|
+
if (!run) return void 0;
|
|
15216
|
+
if (typeof run === "function") return run;
|
|
15217
|
+
return run.run;
|
|
15359
15218
|
}
|
|
15360
|
-
function
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
case 1:
|
|
15367
|
-
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
15368
|
-
case 2:
|
|
15369
|
-
return {
|
|
15370
|
-
tag: "WorkflowSleepEntry",
|
|
15371
|
-
val: readWorkflowSleepEntry(bc)
|
|
15372
|
-
};
|
|
15373
|
-
case 3:
|
|
15374
|
-
return {
|
|
15375
|
-
tag: "WorkflowMessageEntry",
|
|
15376
|
-
val: readWorkflowMessageEntry(bc)
|
|
15377
|
-
};
|
|
15378
|
-
case 4:
|
|
15379
|
-
return {
|
|
15380
|
-
tag: "WorkflowRollbackCheckpointEntry",
|
|
15381
|
-
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
15382
|
-
};
|
|
15383
|
-
case 5:
|
|
15384
|
-
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
15385
|
-
case 6:
|
|
15386
|
-
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
15387
|
-
case 7:
|
|
15388
|
-
return {
|
|
15389
|
-
tag: "WorkflowRemovedEntry",
|
|
15390
|
-
val: readWorkflowRemovedEntry(bc)
|
|
15391
|
-
};
|
|
15392
|
-
case 8:
|
|
15393
|
-
return {
|
|
15394
|
-
tag: "WorkflowVersionCheckEntry",
|
|
15395
|
-
val: readWorkflowVersionCheckEntry(bc)
|
|
15396
|
-
};
|
|
15397
|
-
default: {
|
|
15398
|
-
bc.offset = offset;
|
|
15399
|
-
throw new BareError(offset, "invalid tag");
|
|
15400
|
-
}
|
|
15219
|
+
function getRunMetadata(run) {
|
|
15220
|
+
if (!run) return {};
|
|
15221
|
+
if (typeof run === "function") {
|
|
15222
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15223
|
+
if (!config3) return {};
|
|
15224
|
+
return { name: config3.name, icon: config3.icon };
|
|
15401
15225
|
}
|
|
15226
|
+
return { name: run.name, icon: run.icon };
|
|
15402
15227
|
}
|
|
15403
|
-
function
|
|
15404
|
-
return
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15408
|
-
}
|
|
15409
|
-
|
|
15410
|
-
function read3(bc) {
|
|
15411
|
-
return readBool(bc) ? readU64(bc) : null;
|
|
15228
|
+
function getRunInspectorConfig(run, actor2) {
|
|
15229
|
+
if (!run) return void 0;
|
|
15230
|
+
if (typeof run === "function") {
|
|
15231
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15232
|
+
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
15233
|
+
}
|
|
15234
|
+
return run.inspector;
|
|
15412
15235
|
}
|
|
15413
|
-
function
|
|
15414
|
-
return
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
lastAttemptAt: readU64(bc),
|
|
15419
|
-
createdAt: readU64(bc),
|
|
15420
|
-
completedAt: read3(bc),
|
|
15421
|
-
rollbackCompletedAt: read3(bc),
|
|
15422
|
-
rollbackError: read1(bc)
|
|
15423
|
-
};
|
|
15236
|
+
function hasRunInspectorConfig(run) {
|
|
15237
|
+
if (!run) return false;
|
|
15238
|
+
if (typeof run !== "function") return run.inspector !== void 0;
|
|
15239
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15240
|
+
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;
|
|
15424
15241
|
}
|
|
15425
|
-
function
|
|
15426
|
-
|
|
15427
|
-
if (
|
|
15428
|
-
return
|
|
15429
|
-
}
|
|
15430
|
-
const result = [readString(bc)];
|
|
15431
|
-
for (let i = 1; i < len; i++) {
|
|
15432
|
-
result[i] = readString(bc);
|
|
15242
|
+
function disposeRunInspector(run, actorId) {
|
|
15243
|
+
var _a2;
|
|
15244
|
+
if (!run || typeof run !== "function") {
|
|
15245
|
+
return;
|
|
15433
15246
|
}
|
|
15434
|
-
|
|
15247
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15248
|
+
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
15435
15249
|
}
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15250
|
+
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
15251
|
+
/** Display name for the actor in the Inspector UI. */
|
|
15252
|
+
name: external_exports.string().optional(),
|
|
15253
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15254
|
+
icon: external_exports.string().optional(),
|
|
15255
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
15256
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
15257
|
+
/**
|
|
15258
|
+
* Can hibernate WebSockets, both client connections for actions and
|
|
15259
|
+
* events and WebSockets for onWebSocket. A WebSocket that does not
|
|
15260
|
+
* hibernate closes when the actor sleeps, and the client reconnects.
|
|
15261
|
+
*
|
|
15262
|
+
* @experimental
|
|
15263
|
+
**/
|
|
15264
|
+
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
15265
|
+
}).strict();
|
|
15266
|
+
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
15267
|
+
() => ({})
|
|
15268
|
+
);
|
|
15269
|
+
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
15270
|
+
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
15271
|
+
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
15272
|
+
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15273
|
+
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15274
|
+
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
15275
|
+
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
15276
|
+
/** @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. */
|
|
15277
|
+
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
15278
|
+
/** @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. */
|
|
15279
|
+
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
15280
|
+
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
15281
|
+
actionTimeout: external_exports.number().positive().default(6e4),
|
|
15282
|
+
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
15283
|
+
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
15284
|
+
/** @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. */
|
|
15285
|
+
noSleep: external_exports.boolean().default(false),
|
|
15286
|
+
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
15287
|
+
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15288
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
15289
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
15290
|
+
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
15291
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15292
|
+
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
15293
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15294
|
+
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
15295
|
+
}).strict();
|
|
15296
|
+
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
15297
|
+
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
15298
|
+
InstanceActorOptionsBaseSchema.shape
|
|
15299
|
+
).strict().prefault(() => ({}));
|
|
15300
|
+
var zSampleRate = external_exports.number().min(0).max(1);
|
|
15301
|
+
var zActionSampleRates = external_exports.lazy(
|
|
15302
|
+
() => external_exports.record(external_exports.string(), external_exports.union([zSampleRate, zActionSampleRates]))
|
|
15303
|
+
);
|
|
15304
|
+
var ActorConfigSchema = external_exports.object({
|
|
15305
|
+
onCreate: zFunction().optional(),
|
|
15306
|
+
onDestroy: zFunction().optional(),
|
|
15307
|
+
onMigrate: zFunction().optional(),
|
|
15308
|
+
onWake: zFunction().optional(),
|
|
15309
|
+
onSleep: zFunction().optional(),
|
|
15310
|
+
run: zRunHandler,
|
|
15311
|
+
onStateChange: zFunction().optional(),
|
|
15312
|
+
onBeforeConnect: zFunction().optional(),
|
|
15313
|
+
onConnect: zFunction().optional(),
|
|
15314
|
+
onDisconnect: zFunction().optional(),
|
|
15315
|
+
onBeforeActionResponse: zFunction().optional(),
|
|
15316
|
+
onRequest: zFunction().optional(),
|
|
15317
|
+
onWebSocket: zFunction().optional(),
|
|
15318
|
+
actions: zActionTree.default(() => ({})),
|
|
15319
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15320
|
+
tracing: external_exports.object({
|
|
15321
|
+
sampler: zSampleRate.optional(),
|
|
15322
|
+
actions: zActionSampleRates.optional()
|
|
15323
|
+
}).strict().optional(),
|
|
15324
|
+
connParamsSchema: external_exports.any().optional(),
|
|
15325
|
+
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15326
|
+
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15327
|
+
state: external_exports.any().optional(),
|
|
15328
|
+
createState: zFunction().optional(),
|
|
15329
|
+
connState: external_exports.any().optional(),
|
|
15330
|
+
createConnState: zFunction().optional(),
|
|
15331
|
+
vars: external_exports.any().optional(),
|
|
15332
|
+
db: external_exports.any().optional(),
|
|
15333
|
+
createVars: zFunction().optional(),
|
|
15334
|
+
options: ActorOptionsSchema,
|
|
15335
|
+
inspector: ActorInspectorConfigSchema.optional()
|
|
15336
|
+
}).strict().refine(
|
|
15337
|
+
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
15338
|
+
{
|
|
15339
|
+
message: "Cannot define both 'state' and 'createState'",
|
|
15340
|
+
path: ["state"]
|
|
15444
15341
|
}
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
for (let i = 0; i < len; i++) {
|
|
15451
|
-
const offset = bc.offset;
|
|
15452
|
-
const key = readString(bc);
|
|
15453
|
-
if (result.has(key)) {
|
|
15454
|
-
bc.offset = offset;
|
|
15455
|
-
throw new BareError(offset, "duplicated key");
|
|
15456
|
-
}
|
|
15457
|
-
result.set(key, readWorkflowEntryMetadata(bc));
|
|
15342
|
+
).refine(
|
|
15343
|
+
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
15344
|
+
{
|
|
15345
|
+
message: "Cannot define both 'connState' and 'createConnState'",
|
|
15346
|
+
path: ["connState"]
|
|
15458
15347
|
}
|
|
15459
|
-
|
|
15460
|
-
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
entries: read5(bc),
|
|
15465
|
-
entryMetadata: read6(bc)
|
|
15466
|
-
};
|
|
15467
|
-
}
|
|
15468
|
-
function decodeWorkflowHistory(bytes) {
|
|
15469
|
-
const bc = new ByteCursor(bytes, config2);
|
|
15470
|
-
const result = readWorkflowHistory(bc);
|
|
15471
|
-
if (bc.offset < bc.view.byteLength) {
|
|
15472
|
-
throw new BareError(bc.offset, "remaining bytes");
|
|
15348
|
+
).refine(
|
|
15349
|
+
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
15350
|
+
{
|
|
15351
|
+
message: "Cannot define both 'vars' and 'createVars'",
|
|
15352
|
+
path: ["vars"]
|
|
15473
15353
|
}
|
|
15474
|
-
|
|
15475
|
-
|
|
15476
|
-
|
|
15477
|
-
|
|
15478
|
-
}
|
|
15354
|
+
);
|
|
15355
|
+
var DocActorOptionsSchema = external_exports.object({
|
|
15356
|
+
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
15357
|
+
icon: external_exports.string().optional().describe(
|
|
15358
|
+
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
15359
|
+
),
|
|
15360
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
15361
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
15362
|
+
),
|
|
15363
|
+
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
15364
|
+
createConnStateTimeout: external_exports.number().optional().describe(
|
|
15365
|
+
"Timeout in ms for createConnState handler. Default: 5000"
|
|
15366
|
+
),
|
|
15367
|
+
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
15368
|
+
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
15369
|
+
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
15370
|
+
),
|
|
15371
|
+
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
15372
|
+
sleepGracePeriod: external_exports.number().optional().describe(
|
|
15373
|
+
`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}.`
|
|
15374
|
+
),
|
|
15375
|
+
onDestroyTimeout: external_exports.number().optional().describe(
|
|
15376
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15377
|
+
),
|
|
15378
|
+
waitUntilTimeout: external_exports.number().optional().describe(
|
|
15379
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15380
|
+
),
|
|
15381
|
+
stateSaveInterval: external_exports.number().optional().describe(
|
|
15382
|
+
"Interval in ms between automatic state saves. Default: 1000"
|
|
15383
|
+
),
|
|
15384
|
+
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
15385
|
+
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
15386
|
+
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
15387
|
+
),
|
|
15388
|
+
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
15389
|
+
"Interval in ms between connection liveness checks. Default: 5000"
|
|
15390
|
+
),
|
|
15391
|
+
noSleep: external_exports.boolean().optional().describe(
|
|
15392
|
+
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
15393
|
+
),
|
|
15394
|
+
sleepTimeout: external_exports.number().optional().describe(
|
|
15395
|
+
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
15396
|
+
),
|
|
15397
|
+
maxQueueSize: external_exports.number().optional().describe(
|
|
15398
|
+
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
15399
|
+
),
|
|
15400
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15401
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15402
|
+
),
|
|
15403
|
+
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
15404
|
+
"Maximum size of each queue message in bytes. Default: 65536"
|
|
15405
|
+
),
|
|
15406
|
+
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
15407
|
+
"Whether WebSockets can be hibernated, both client connections for actions and events and WebSockets using onWebSocket. A WebSocket that does not hibernate closes when the actor sleeps. Default: false"
|
|
15408
|
+
)
|
|
15409
|
+
}).describe("Actor options for timeouts and behavior configuration.");
|
|
15410
|
+
var DocActorConfigSchema = external_exports.object({
|
|
15411
|
+
state: external_exports.unknown().optional().describe(
|
|
15412
|
+
"Initial state value for the actor. Cannot be used with createState."
|
|
15413
|
+
),
|
|
15414
|
+
createState: external_exports.unknown().optional().describe(
|
|
15415
|
+
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
15416
|
+
),
|
|
15417
|
+
connState: external_exports.unknown().optional().describe(
|
|
15418
|
+
"Initial connection state value. Cannot be used with createConnState."
|
|
15419
|
+
),
|
|
15420
|
+
createConnState: external_exports.unknown().optional().describe(
|
|
15421
|
+
"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."
|
|
15422
|
+
),
|
|
15423
|
+
vars: external_exports.unknown().optional().describe(
|
|
15424
|
+
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
15425
|
+
),
|
|
15426
|
+
createVars: external_exports.unknown().optional().describe(
|
|
15427
|
+
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
15428
|
+
),
|
|
15429
|
+
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
15430
|
+
onCreate: external_exports.unknown().optional().describe(
|
|
15431
|
+
"Called when the actor is first initialized. Use to initialize state."
|
|
15432
|
+
),
|
|
15433
|
+
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
15434
|
+
onMigrate: external_exports.unknown().optional().describe(
|
|
15435
|
+
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
15436
|
+
),
|
|
15437
|
+
onWake: external_exports.unknown().optional().describe(
|
|
15438
|
+
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
15439
|
+
),
|
|
15440
|
+
onSleep: external_exports.unknown().optional().describe(
|
|
15441
|
+
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
15442
|
+
),
|
|
15443
|
+
run: external_exports.unknown().optional().describe(
|
|
15444
|
+
"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."
|
|
15445
|
+
),
|
|
15446
|
+
onStateChange: external_exports.unknown().optional().describe(
|
|
15447
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
15448
|
+
),
|
|
15449
|
+
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
15450
|
+
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
15451
|
+
),
|
|
15452
|
+
onConnect: external_exports.unknown().optional().describe(
|
|
15453
|
+
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
15454
|
+
),
|
|
15455
|
+
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
15456
|
+
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
15457
|
+
"Called before sending an action response. Use to transform output."
|
|
15458
|
+
),
|
|
15459
|
+
onRequest: external_exports.unknown().optional().describe(
|
|
15460
|
+
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
15461
|
+
),
|
|
15462
|
+
onWebSocket: external_exports.unknown().optional().describe(
|
|
15463
|
+
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15464
|
+
),
|
|
15465
|
+
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15466
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15467
|
+
),
|
|
15468
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15469
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15470
|
+
),
|
|
15471
|
+
tracing: external_exports.unknown().optional().describe(
|
|
15472
|
+
"Trace sampling for this actor: `sampler` is the share of its invocations that are recorded, from 0 to 1, with optional per-action rates under `actions`. A rate lowers what is recorded and never raises it. Defaults to the process sampler from OTEL_TRACES_SAMPLER."
|
|
15473
|
+
),
|
|
15474
|
+
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15475
|
+
"Optional schema for validating connection params in native runtimes."
|
|
15476
|
+
),
|
|
15477
|
+
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
15478
|
+
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
15479
|
+
options: DocActorOptionsSchema.optional()
|
|
15480
|
+
}).describe("Actor configuration passed to the actor() function.");
|
|
15479
15481
|
|
|
15480
15482
|
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
15481
15483
|
var EMPTY_KEY = "/";
|
|
@@ -15594,44 +15596,6 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15594
15596
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15595
15597
|
}
|
|
15596
15598
|
|
|
15597
|
-
// ../rivetkit/dist/tsup/chunk-EOYS5GVX.js
|
|
15598
|
-
function logger() {
|
|
15599
|
-
return getLogger("actor-client");
|
|
15600
|
-
}
|
|
15601
|
-
var webSocketPromise = null;
|
|
15602
|
-
async function importWebSocket() {
|
|
15603
|
-
if (webSocketPromise !== null) {
|
|
15604
|
-
return webSocketPromise;
|
|
15605
|
-
}
|
|
15606
|
-
webSocketPromise = (async () => {
|
|
15607
|
-
let _WebSocket;
|
|
15608
|
-
if (typeof WebSocket !== "undefined") {
|
|
15609
|
-
_WebSocket = WebSocket;
|
|
15610
|
-
} else {
|
|
15611
|
-
try {
|
|
15612
|
-
const moduleName = "ws";
|
|
15613
|
-
const ws = await import(
|
|
15614
|
-
/* webpackIgnore: true */
|
|
15615
|
-
moduleName
|
|
15616
|
-
);
|
|
15617
|
-
_WebSocket = ws.default;
|
|
15618
|
-
logger().debug("using websocket from npm");
|
|
15619
|
-
} catch {
|
|
15620
|
-
_WebSocket = class MockWebSocket {
|
|
15621
|
-
constructor() {
|
|
15622
|
-
throw new Error(
|
|
15623
|
-
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15624
|
-
);
|
|
15625
|
-
}
|
|
15626
|
-
};
|
|
15627
|
-
logger().debug("using mock websocket");
|
|
15628
|
-
}
|
|
15629
|
-
}
|
|
15630
|
-
return _WebSocket;
|
|
15631
|
-
})();
|
|
15632
|
-
return webSocketPromise;
|
|
15633
|
-
}
|
|
15634
|
-
|
|
15635
15599
|
// ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
|
|
15636
15600
|
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15637
15601
|
function isManualTransactionControl(query) {
|
|
@@ -15715,7 +15679,45 @@ var AsyncMutex = class {
|
|
|
15715
15679
|
}
|
|
15716
15680
|
};
|
|
15717
15681
|
|
|
15718
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15682
|
+
// ../rivetkit/dist/tsup/chunk-5IL4VLV6.js
|
|
15683
|
+
function logger() {
|
|
15684
|
+
return getLogger("actor-client");
|
|
15685
|
+
}
|
|
15686
|
+
var webSocketPromise = null;
|
|
15687
|
+
async function importWebSocket() {
|
|
15688
|
+
if (webSocketPromise !== null) {
|
|
15689
|
+
return webSocketPromise;
|
|
15690
|
+
}
|
|
15691
|
+
webSocketPromise = (async () => {
|
|
15692
|
+
let _WebSocket;
|
|
15693
|
+
if (typeof WebSocket !== "undefined") {
|
|
15694
|
+
_WebSocket = WebSocket;
|
|
15695
|
+
} else {
|
|
15696
|
+
try {
|
|
15697
|
+
const moduleName = "ws";
|
|
15698
|
+
const ws = await import(
|
|
15699
|
+
/* webpackIgnore: true */
|
|
15700
|
+
moduleName
|
|
15701
|
+
);
|
|
15702
|
+
_WebSocket = ws.default;
|
|
15703
|
+
logger().debug("using websocket from npm");
|
|
15704
|
+
} catch {
|
|
15705
|
+
_WebSocket = class MockWebSocket {
|
|
15706
|
+
constructor() {
|
|
15707
|
+
throw new Error(
|
|
15708
|
+
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15709
|
+
);
|
|
15710
|
+
}
|
|
15711
|
+
};
|
|
15712
|
+
logger().debug("using mock websocket");
|
|
15713
|
+
}
|
|
15714
|
+
}
|
|
15715
|
+
return _WebSocket;
|
|
15716
|
+
})();
|
|
15717
|
+
return webSocketPromise;
|
|
15718
|
+
}
|
|
15719
|
+
|
|
15720
|
+
// ../rivetkit/dist/tsup/chunk-JV6I42CB.js
|
|
15719
15721
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15720
15722
|
|
|
15721
15723
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -16930,7 +16932,7 @@ var TraceAPI = (
|
|
|
16930
16932
|
// ../../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
|
|
16931
16933
|
var trace = TraceAPI.getInstance();
|
|
16932
16934
|
|
|
16933
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
16935
|
+
// ../rivetkit/dist/tsup/chunk-JV6I42CB.js
|
|
16934
16936
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
16935
16937
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
16936
16938
|
var PATH_CONNECT = "/connect";
|
|
@@ -23126,7 +23128,7 @@ function apiActorToOutput(actor2) {
|
|
|
23126
23128
|
};
|
|
23127
23129
|
}
|
|
23128
23130
|
|
|
23129
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
23131
|
+
// ../rivetkit/dist/tsup/chunk-XUN7GJJN.js
|
|
23130
23132
|
var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
|
|
23131
23133
|
var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
|
|
23132
23134
|
function registerNativeStateTransactionOpener(provider, opener) {
|