@rivetkit/supabase 0.0.0-stack-chore-sync-engine-changes-from-enterprise-mszropyy.677d526 → 0.0.0-wmain-rc.7ab5f18
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 +754 -744
- package/dist/mod.mjs +754 -744
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -335,193 +335,6 @@ __export(mod_exports, {
|
|
|
335
335
|
module.exports = __toCommonJS(mod_exports);
|
|
336
336
|
var wasmBindings = __toESM(require("@rivetkit/rivetkit-wasm"));
|
|
337
337
|
|
|
338
|
-
// ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
|
|
339
|
-
var INTERNAL_ERROR_CODE = "internal_error";
|
|
340
|
-
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
341
|
-
var USER_ERROR_CODE = "user_error";
|
|
342
|
-
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
343
|
-
function looksLikeRivetErrorOptions(value) {
|
|
344
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
345
|
-
}
|
|
346
|
-
function isTypedErrorTag(value) {
|
|
347
|
-
return value === "ActorError" || value === "RivetError";
|
|
348
|
-
}
|
|
349
|
-
function errorMessage(error46, fallback = String(error46)) {
|
|
350
|
-
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
351
|
-
return error46.message;
|
|
352
|
-
}
|
|
353
|
-
return fallback;
|
|
354
|
-
}
|
|
355
|
-
function isRivetErrorLike(error46) {
|
|
356
|
-
return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
357
|
-
}
|
|
358
|
-
function isActorAbortedError(error46) {
|
|
359
|
-
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
360
|
-
}
|
|
361
|
-
function isActorSpecifier(value) {
|
|
362
|
-
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
363
|
-
}
|
|
364
|
-
var RivetError = class extends Error {
|
|
365
|
-
__type = "RivetError";
|
|
366
|
-
public;
|
|
367
|
-
metadata;
|
|
368
|
-
rayId;
|
|
369
|
-
statusCode;
|
|
370
|
-
actor;
|
|
371
|
-
group;
|
|
372
|
-
code;
|
|
373
|
-
static isRivetError(error46) {
|
|
374
|
-
return isRivetErrorLike(error46);
|
|
375
|
-
}
|
|
376
|
-
static isActorError(error46) {
|
|
377
|
-
return isRivetErrorLike(error46);
|
|
378
|
-
}
|
|
379
|
-
constructor(group, code, message, options) {
|
|
380
|
-
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
381
|
-
super(message, { cause: normalized.cause });
|
|
382
|
-
this.name = "RivetError";
|
|
383
|
-
this.group = group;
|
|
384
|
-
this.code = code;
|
|
385
|
-
this.public = normalized.public ?? false;
|
|
386
|
-
this.metadata = normalized.metadata;
|
|
387
|
-
this.rayId = normalized.rayId ?? void 0;
|
|
388
|
-
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
389
|
-
this.actor = normalized.actor;
|
|
390
|
-
}
|
|
391
|
-
toString() {
|
|
392
|
-
return this.message;
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
var UserError = class extends RivetError {
|
|
396
|
-
constructor(message, options) {
|
|
397
|
-
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
398
|
-
public: true,
|
|
399
|
-
metadata: options == null ? void 0 : options.metadata,
|
|
400
|
-
cause: options == null ? void 0 : options.cause
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
function toRivetError(error46, fallback) {
|
|
405
|
-
if (typeof error46 === "string") {
|
|
406
|
-
const bridged = decodeBridgeRivetError(error46);
|
|
407
|
-
if (bridged) {
|
|
408
|
-
return bridged;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (error46 instanceof Error) {
|
|
412
|
-
const bridged = decodeBridgeRivetError(error46.message);
|
|
413
|
-
if (bridged) {
|
|
414
|
-
return bridged;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
if (isRivetErrorLike(error46)) {
|
|
418
|
-
return new RivetError(error46.group, error46.code, error46.message, {
|
|
419
|
-
public: error46.public,
|
|
420
|
-
statusCode: error46.statusCode,
|
|
421
|
-
metadata: error46.metadata,
|
|
422
|
-
rayId: error46.rayId,
|
|
423
|
-
actor: error46.actor,
|
|
424
|
-
cause: error46 instanceof Error ? error46.cause : void 0
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
return new RivetError(
|
|
428
|
-
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
429
|
-
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
430
|
-
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
431
|
-
{
|
|
432
|
-
public: fallback == null ? void 0 : fallback.public,
|
|
433
|
-
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
434
|
-
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
435
|
-
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
436
|
-
actor: fallback == null ? void 0 : fallback.actor,
|
|
437
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
438
|
-
}
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
function encodeBridgeRivetError(error46) {
|
|
442
|
-
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
443
|
-
group: error46.group,
|
|
444
|
-
code: error46.code,
|
|
445
|
-
message: error46.message,
|
|
446
|
-
metadata: error46.metadata,
|
|
447
|
-
rayId: error46.rayId,
|
|
448
|
-
public: error46.public,
|
|
449
|
-
statusCode: error46.statusCode,
|
|
450
|
-
actor: error46.actor
|
|
451
|
-
})}`;
|
|
452
|
-
}
|
|
453
|
-
function decodeBridgeRivetErrorPayload(value) {
|
|
454
|
-
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
455
|
-
return void 0;
|
|
456
|
-
}
|
|
457
|
-
try {
|
|
458
|
-
const raw = JSON.parse(
|
|
459
|
-
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
460
|
-
);
|
|
461
|
-
const payload = {
|
|
462
|
-
...raw,
|
|
463
|
-
rayId: raw.rayId ?? void 0
|
|
464
|
-
};
|
|
465
|
-
if (!isRivetErrorLike(payload)) {
|
|
466
|
-
return void 0;
|
|
467
|
-
}
|
|
468
|
-
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
469
|
-
return void 0;
|
|
470
|
-
}
|
|
471
|
-
return payload;
|
|
472
|
-
} catch {
|
|
473
|
-
return void 0;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
function decodeBridgeRivetError(value) {
|
|
477
|
-
const payload = decodeBridgeRivetErrorPayload(value);
|
|
478
|
-
if (!payload) {
|
|
479
|
-
return void 0;
|
|
480
|
-
}
|
|
481
|
-
return new RivetError(payload.group, payload.code, payload.message, {
|
|
482
|
-
metadata: payload.metadata,
|
|
483
|
-
rayId: payload.rayId,
|
|
484
|
-
public: payload.public,
|
|
485
|
-
statusCode: payload.statusCode,
|
|
486
|
-
actor: payload.actor ?? void 0
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
function invalidRequest(error46) {
|
|
490
|
-
return new RivetError(
|
|
491
|
-
"request",
|
|
492
|
-
"invalid",
|
|
493
|
-
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
494
|
-
{
|
|
495
|
-
public: true,
|
|
496
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
497
|
-
}
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
function actorNotFound(identifier) {
|
|
501
|
-
return new RivetError(
|
|
502
|
-
"actor",
|
|
503
|
-
"not_found",
|
|
504
|
-
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
505
|
-
{ public: true }
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
function forbiddenError() {
|
|
509
|
-
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
510
|
-
public: true,
|
|
511
|
-
statusCode: 403
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
function unsupportedFeature(feature) {
|
|
515
|
-
return new RivetError(
|
|
516
|
-
"feature",
|
|
517
|
-
"unsupported",
|
|
518
|
-
`Unsupported feature: ${feature}`
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// ../rivetkit/dist/tsup/chunk-GPD77M3M.js
|
|
523
|
-
var import_pino = require("pino");
|
|
524
|
-
|
|
525
338
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
526
339
|
var external_exports = {};
|
|
527
340
|
__export(external_exports, {
|
|
@@ -13192,73 +13005,722 @@ var classic_default = external_exports;
|
|
|
13192
13005
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13193
13006
|
var v4_default = classic_default;
|
|
13194
13007
|
|
|
13195
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13201
|
-
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13202
|
-
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13203
|
-
var getRivetTotalSlots = () => {
|
|
13204
|
-
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13205
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13206
|
-
};
|
|
13207
|
-
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13208
|
-
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13209
|
-
var getRivetRunEnginePort = () => {
|
|
13210
|
-
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13211
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13212
|
-
};
|
|
13213
|
-
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13214
|
-
var getRivetRunServices = () => {
|
|
13215
|
-
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13216
|
-
return value === void 0 ? void 0 : value === "1";
|
|
13217
|
-
};
|
|
13218
|
-
var getRivetEnvoyVersion = () => {
|
|
13219
|
-
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13220
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13221
|
-
};
|
|
13222
|
-
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13223
|
-
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13224
|
-
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13225
|
-
var getRivetkitRuntimeMode = () => {
|
|
13226
|
-
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13227
|
-
if (value === void 0) return "envoy";
|
|
13228
|
-
if (value === "envoy" || value === "serverless") return value;
|
|
13229
|
-
throw new Error(
|
|
13230
|
-
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13231
|
-
);
|
|
13232
|
-
};
|
|
13233
|
-
var getRivetkitPublicDir = () => {
|
|
13234
|
-
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13235
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
13236
|
-
};
|
|
13237
|
-
function parsePortEnv(raw) {
|
|
13238
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
13239
|
-
const parsed = Number.parseInt(raw, 10);
|
|
13240
|
-
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13241
|
-
throw new Error(
|
|
13242
|
-
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13243
|
-
);
|
|
13008
|
+
// ../rivetkit/dist/tsup/chunk-6W5VGLFT.js
|
|
13009
|
+
function flattenActionHandlers(actions) {
|
|
13010
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
13011
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
13012
|
+
flattened[name] = handler;
|
|
13244
13013
|
}
|
|
13245
|
-
return
|
|
13246
|
-
}
|
|
13247
|
-
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13248
|
-
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13249
|
-
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13250
|
-
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13251
|
-
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13252
|
-
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13253
|
-
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13254
|
-
var isDev = () => getNodeEnv() !== "production";
|
|
13255
|
-
function assertUnreachable(x) {
|
|
13256
|
-
throw new Error(`Unreachable case: ${x}`);
|
|
13257
|
-
}
|
|
13258
|
-
function isCanonicalStructuredRivetError(error46) {
|
|
13259
|
-
return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
|
|
13014
|
+
return flattened;
|
|
13260
13015
|
}
|
|
13261
|
-
function
|
|
13016
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
13017
|
+
if (schemas === void 0) return void 0;
|
|
13018
|
+
if (!isRecord(schemas)) {
|
|
13019
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
13020
|
+
}
|
|
13021
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
13022
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
13023
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
13024
|
+
const flatSchema = schemas[name];
|
|
13025
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
13026
|
+
throw new TypeError(
|
|
13027
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
13028
|
+
);
|
|
13029
|
+
}
|
|
13030
|
+
const schema = nestedSchema ?? flatSchema;
|
|
13031
|
+
if (schema !== void 0) {
|
|
13032
|
+
flattened[name] = schema;
|
|
13033
|
+
}
|
|
13034
|
+
}
|
|
13035
|
+
return flattened;
|
|
13036
|
+
}
|
|
13037
|
+
function collectActionEntries(actions) {
|
|
13038
|
+
const entries = [];
|
|
13039
|
+
const names = /* @__PURE__ */ new Set();
|
|
13040
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
13041
|
+
return entries;
|
|
13042
|
+
}
|
|
13043
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
13044
|
+
if (!isRecord(value)) {
|
|
13045
|
+
throw new TypeError(
|
|
13046
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
13047
|
+
);
|
|
13048
|
+
}
|
|
13049
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
13050
|
+
const childPath = [...path2, segment];
|
|
13051
|
+
if (typeof child === "function") {
|
|
13052
|
+
const name = childPath.join(".");
|
|
13053
|
+
if (names.has(name)) {
|
|
13054
|
+
throw new TypeError(
|
|
13055
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
13056
|
+
);
|
|
13057
|
+
}
|
|
13058
|
+
names.add(name);
|
|
13059
|
+
entries.push({
|
|
13060
|
+
name,
|
|
13061
|
+
path: childPath,
|
|
13062
|
+
handler: child
|
|
13063
|
+
});
|
|
13064
|
+
} else {
|
|
13065
|
+
visitActionGroup(child, childPath, entries, names);
|
|
13066
|
+
}
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
function lookupNestedSchema(schemas, path2) {
|
|
13070
|
+
let value = schemas;
|
|
13071
|
+
for (const segment of path2) {
|
|
13072
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
13073
|
+
return void 0;
|
|
13074
|
+
}
|
|
13075
|
+
value = value[segment];
|
|
13076
|
+
}
|
|
13077
|
+
return value;
|
|
13078
|
+
}
|
|
13079
|
+
function isRecord(value) {
|
|
13080
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13081
|
+
return false;
|
|
13082
|
+
}
|
|
13083
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13084
|
+
return prototype === Object.prototype || prototype === null;
|
|
13085
|
+
}
|
|
13086
|
+
function formatActionPath(path2) {
|
|
13087
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
13088
|
+
}
|
|
13089
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
13090
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
13091
|
+
"rivetkit.actor_context_internal"
|
|
13092
|
+
);
|
|
13093
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
13094
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
13095
|
+
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
13096
|
+
var zActionTree = external_exports.custom((value) => {
|
|
13097
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13098
|
+
return false;
|
|
13099
|
+
}
|
|
13100
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13101
|
+
return prototype === Object.prototype || prototype === null;
|
|
13102
|
+
}).superRefine((actions, ctx) => {
|
|
13103
|
+
try {
|
|
13104
|
+
flattenActionHandlers(actions);
|
|
13105
|
+
} catch (error46) {
|
|
13106
|
+
ctx.addIssue({
|
|
13107
|
+
code: "custom",
|
|
13108
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
13109
|
+
});
|
|
13110
|
+
}
|
|
13111
|
+
});
|
|
13112
|
+
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
13113
|
+
getHistory: zFunction(),
|
|
13114
|
+
getState: zFunction().optional(),
|
|
13115
|
+
onHistoryUpdated: zFunction().optional(),
|
|
13116
|
+
replayFromStep: zFunction().optional()
|
|
13117
|
+
});
|
|
13118
|
+
var RunInspectorConfigSchema = external_exports.object({
|
|
13119
|
+
workflow: WorkflowInspectorConfigSchema.optional()
|
|
13120
|
+
}).optional();
|
|
13121
|
+
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
13122
|
+
"workflow",
|
|
13123
|
+
"database",
|
|
13124
|
+
"state",
|
|
13125
|
+
"queue",
|
|
13126
|
+
"schedules",
|
|
13127
|
+
"connections",
|
|
13128
|
+
"console"
|
|
13129
|
+
];
|
|
13130
|
+
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13131
|
+
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
13132
|
+
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
13133
|
+
id: external_exports.string().regex(
|
|
13134
|
+
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
13135
|
+
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
13136
|
+
),
|
|
13137
|
+
label: external_exports.string().min(1),
|
|
13138
|
+
source: external_exports.string().min(1),
|
|
13139
|
+
/**
|
|
13140
|
+
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
13141
|
+
* icon registry); unknown ids fall back to a generic icon.
|
|
13142
|
+
*/
|
|
13143
|
+
icon: external_exports.string().min(1).optional(),
|
|
13144
|
+
hidden: external_exports.literal(false).optional()
|
|
13145
|
+
}).strict();
|
|
13146
|
+
var HideInspectorTabEntrySchema = external_exports.object({
|
|
13147
|
+
id: BuiltinInspectorTabIdSchema,
|
|
13148
|
+
hidden: external_exports.literal(true)
|
|
13149
|
+
}).strict();
|
|
13150
|
+
var InspectorTabEntrySchema = external_exports.union([
|
|
13151
|
+
CustomInspectorTabEntrySchema,
|
|
13152
|
+
HideInspectorTabEntrySchema
|
|
13153
|
+
]);
|
|
13154
|
+
var ActorInspectorConfigSchema = external_exports.object({
|
|
13155
|
+
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
13156
|
+
}).strict().refine(
|
|
13157
|
+
(data) => {
|
|
13158
|
+
const ids = data.tabs.map((t) => t.id);
|
|
13159
|
+
return new Set(ids).size === ids.length;
|
|
13160
|
+
},
|
|
13161
|
+
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
13162
|
+
).refine(
|
|
13163
|
+
(data) => {
|
|
13164
|
+
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13165
|
+
return data.tabs.every(
|
|
13166
|
+
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
13167
|
+
);
|
|
13168
|
+
},
|
|
13169
|
+
{
|
|
13170
|
+
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
13171
|
+
path: ["tabs"]
|
|
13172
|
+
}
|
|
13173
|
+
);
|
|
13174
|
+
var RunConfigSchema = external_exports.object({
|
|
13175
|
+
/** Display name for the actor in the Inspector UI. */
|
|
13176
|
+
name: external_exports.string().optional(),
|
|
13177
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13178
|
+
icon: external_exports.string().optional(),
|
|
13179
|
+
/** The run handler function. */
|
|
13180
|
+
run: zFunction(),
|
|
13181
|
+
/** Inspector integration for long-running run handlers. */
|
|
13182
|
+
inspector: RunInspectorConfigSchema.optional()
|
|
13183
|
+
});
|
|
13184
|
+
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
13185
|
+
function defineRunHandler(run, options) {
|
|
13186
|
+
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
13187
|
+
throw new TypeError(
|
|
13188
|
+
"defineRunHandler requires inspectorKind and createInspector together"
|
|
13189
|
+
);
|
|
13190
|
+
}
|
|
13191
|
+
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
13192
|
+
configurable: false,
|
|
13193
|
+
enumerable: false,
|
|
13194
|
+
writable: false,
|
|
13195
|
+
value: {
|
|
13196
|
+
name: options.name,
|
|
13197
|
+
icon: options.icon,
|
|
13198
|
+
inspectorKind: options.inspectorKind,
|
|
13199
|
+
createInspector: options.createInspector
|
|
13200
|
+
}
|
|
13201
|
+
});
|
|
13202
|
+
return run;
|
|
13203
|
+
}
|
|
13204
|
+
function getRunInspectorKind(run) {
|
|
13205
|
+
var _a2;
|
|
13206
|
+
if (!run || typeof run !== "function") return void 0;
|
|
13207
|
+
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
13208
|
+
}
|
|
13209
|
+
function createRunInspector(run, context) {
|
|
13210
|
+
var _a2, _b;
|
|
13211
|
+
if (!run || typeof run !== "function") return void 0;
|
|
13212
|
+
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
|
|
13213
|
+
}
|
|
13214
|
+
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
13215
|
+
function getRunFunction(run) {
|
|
13216
|
+
if (!run) return void 0;
|
|
13217
|
+
if (typeof run === "function") return run;
|
|
13218
|
+
return run.run;
|
|
13219
|
+
}
|
|
13220
|
+
function getRunMetadata(run) {
|
|
13221
|
+
if (!run) return {};
|
|
13222
|
+
if (typeof run === "function") {
|
|
13223
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13224
|
+
if (!config3) return {};
|
|
13225
|
+
return { name: config3.name, icon: config3.icon };
|
|
13226
|
+
}
|
|
13227
|
+
return { name: run.name, icon: run.icon };
|
|
13228
|
+
}
|
|
13229
|
+
function getRunInspectorConfig(run, actor2) {
|
|
13230
|
+
if (!run) return void 0;
|
|
13231
|
+
if (typeof run === "function") {
|
|
13232
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13233
|
+
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
13234
|
+
}
|
|
13235
|
+
return run.inspector;
|
|
13236
|
+
}
|
|
13237
|
+
function hasRunInspectorConfig(run) {
|
|
13238
|
+
if (!run) return false;
|
|
13239
|
+
if (typeof run !== "function") return run.inspector !== void 0;
|
|
13240
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13241
|
+
return (config3 == null ? void 0 : config3.inspectorKind) !== void 0 || (config3 == null ? void 0 : config3.createInspector) !== void 0 || (config3 == null ? void 0 : config3.inspector) !== void 0 || (config3 == null ? void 0 : config3.inspectorFactory) !== void 0;
|
|
13242
|
+
}
|
|
13243
|
+
function disposeRunInspector(run, actorId) {
|
|
13244
|
+
var _a2;
|
|
13245
|
+
if (!run || typeof run !== "function") {
|
|
13246
|
+
return;
|
|
13247
|
+
}
|
|
13248
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13249
|
+
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
13250
|
+
}
|
|
13251
|
+
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
13252
|
+
/** Display name for the actor in the Inspector UI. */
|
|
13253
|
+
name: external_exports.string().optional(),
|
|
13254
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13255
|
+
icon: external_exports.string().optional(),
|
|
13256
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
13257
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
13258
|
+
/**
|
|
13259
|
+
* Can hibernate WebSockets for onWebSocket.
|
|
13260
|
+
*
|
|
13261
|
+
* WebSockets using actions/events are hibernatable by default.
|
|
13262
|
+
*
|
|
13263
|
+
* @experimental
|
|
13264
|
+
**/
|
|
13265
|
+
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
13266
|
+
}).strict();
|
|
13267
|
+
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
13268
|
+
() => ({})
|
|
13269
|
+
);
|
|
13270
|
+
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
13271
|
+
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
13272
|
+
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
13273
|
+
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13274
|
+
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13275
|
+
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
13276
|
+
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
13277
|
+
/** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
13278
|
+
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
13279
|
+
/** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
13280
|
+
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
13281
|
+
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
13282
|
+
actionTimeout: external_exports.number().positive().default(6e4),
|
|
13283
|
+
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
13284
|
+
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
13285
|
+
/** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
|
|
13286
|
+
noSleep: external_exports.boolean().default(false),
|
|
13287
|
+
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
13288
|
+
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
13289
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
13290
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
13291
|
+
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
13292
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13293
|
+
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
13294
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13295
|
+
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
13296
|
+
}).strict();
|
|
13297
|
+
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
13298
|
+
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
13299
|
+
InstanceActorOptionsBaseSchema.shape
|
|
13300
|
+
).strict().prefault(() => ({}));
|
|
13301
|
+
var ActorConfigSchema = external_exports.object({
|
|
13302
|
+
onCreate: zFunction().optional(),
|
|
13303
|
+
onDestroy: zFunction().optional(),
|
|
13304
|
+
onMigrate: zFunction().optional(),
|
|
13305
|
+
onWake: zFunction().optional(),
|
|
13306
|
+
onSleep: zFunction().optional(),
|
|
13307
|
+
run: zRunHandler,
|
|
13308
|
+
onStateChange: zFunction().optional(),
|
|
13309
|
+
onBeforeConnect: zFunction().optional(),
|
|
13310
|
+
onConnect: zFunction().optional(),
|
|
13311
|
+
onDisconnect: zFunction().optional(),
|
|
13312
|
+
onBeforeActionResponse: zFunction().optional(),
|
|
13313
|
+
onRequest: zFunction().optional(),
|
|
13314
|
+
onWebSocket: zFunction().optional(),
|
|
13315
|
+
actions: zActionTree.default(() => ({})),
|
|
13316
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13317
|
+
connParamsSchema: external_exports.any().optional(),
|
|
13318
|
+
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13319
|
+
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13320
|
+
state: external_exports.any().optional(),
|
|
13321
|
+
createState: zFunction().optional(),
|
|
13322
|
+
connState: external_exports.any().optional(),
|
|
13323
|
+
createConnState: zFunction().optional(),
|
|
13324
|
+
vars: external_exports.any().optional(),
|
|
13325
|
+
db: external_exports.any().optional(),
|
|
13326
|
+
createVars: zFunction().optional(),
|
|
13327
|
+
options: ActorOptionsSchema,
|
|
13328
|
+
inspector: ActorInspectorConfigSchema.optional()
|
|
13329
|
+
}).strict().refine(
|
|
13330
|
+
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
13331
|
+
{
|
|
13332
|
+
message: "Cannot define both 'state' and 'createState'",
|
|
13333
|
+
path: ["state"]
|
|
13334
|
+
}
|
|
13335
|
+
).refine(
|
|
13336
|
+
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
13337
|
+
{
|
|
13338
|
+
message: "Cannot define both 'connState' and 'createConnState'",
|
|
13339
|
+
path: ["connState"]
|
|
13340
|
+
}
|
|
13341
|
+
).refine(
|
|
13342
|
+
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
13343
|
+
{
|
|
13344
|
+
message: "Cannot define both 'vars' and 'createVars'",
|
|
13345
|
+
path: ["vars"]
|
|
13346
|
+
}
|
|
13347
|
+
);
|
|
13348
|
+
var DocActorOptionsSchema = external_exports.object({
|
|
13349
|
+
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
13350
|
+
icon: external_exports.string().optional().describe(
|
|
13351
|
+
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
13352
|
+
),
|
|
13353
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
13354
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
13355
|
+
),
|
|
13356
|
+
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
13357
|
+
createConnStateTimeout: external_exports.number().optional().describe(
|
|
13358
|
+
"Timeout in ms for createConnState handler. Default: 5000"
|
|
13359
|
+
),
|
|
13360
|
+
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
13361
|
+
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
13362
|
+
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
13363
|
+
),
|
|
13364
|
+
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
13365
|
+
sleepGracePeriod: external_exports.number().optional().describe(
|
|
13366
|
+
`Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
|
|
13367
|
+
),
|
|
13368
|
+
onDestroyTimeout: external_exports.number().optional().describe(
|
|
13369
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13370
|
+
),
|
|
13371
|
+
waitUntilTimeout: external_exports.number().optional().describe(
|
|
13372
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13373
|
+
),
|
|
13374
|
+
stateSaveInterval: external_exports.number().optional().describe(
|
|
13375
|
+
"Interval in ms between automatic state saves. Default: 1000"
|
|
13376
|
+
),
|
|
13377
|
+
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
13378
|
+
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
13379
|
+
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
13380
|
+
),
|
|
13381
|
+
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
13382
|
+
"Interval in ms between connection liveness checks. Default: 5000"
|
|
13383
|
+
),
|
|
13384
|
+
noSleep: external_exports.boolean().optional().describe(
|
|
13385
|
+
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
13386
|
+
),
|
|
13387
|
+
sleepTimeout: external_exports.number().optional().describe(
|
|
13388
|
+
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
13389
|
+
),
|
|
13390
|
+
maxQueueSize: external_exports.number().optional().describe(
|
|
13391
|
+
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
13392
|
+
),
|
|
13393
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
13394
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
13395
|
+
),
|
|
13396
|
+
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
13397
|
+
"Maximum size of each queue message in bytes. Default: 65536"
|
|
13398
|
+
),
|
|
13399
|
+
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
13400
|
+
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
13401
|
+
)
|
|
13402
|
+
}).describe("Actor options for timeouts and behavior configuration.");
|
|
13403
|
+
var DocActorConfigSchema = external_exports.object({
|
|
13404
|
+
state: external_exports.unknown().optional().describe(
|
|
13405
|
+
"Initial state value for the actor. Cannot be used with createState."
|
|
13406
|
+
),
|
|
13407
|
+
createState: external_exports.unknown().optional().describe(
|
|
13408
|
+
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
13409
|
+
),
|
|
13410
|
+
connState: external_exports.unknown().optional().describe(
|
|
13411
|
+
"Initial connection state value. Cannot be used with createConnState."
|
|
13412
|
+
),
|
|
13413
|
+
createConnState: external_exports.unknown().optional().describe(
|
|
13414
|
+
"Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
|
|
13415
|
+
),
|
|
13416
|
+
vars: external_exports.unknown().optional().describe(
|
|
13417
|
+
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
13418
|
+
),
|
|
13419
|
+
createVars: external_exports.unknown().optional().describe(
|
|
13420
|
+
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
13421
|
+
),
|
|
13422
|
+
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
13423
|
+
onCreate: external_exports.unknown().optional().describe(
|
|
13424
|
+
"Called when the actor is first initialized. Use to initialize state."
|
|
13425
|
+
),
|
|
13426
|
+
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
13427
|
+
onMigrate: external_exports.unknown().optional().describe(
|
|
13428
|
+
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
13429
|
+
),
|
|
13430
|
+
onWake: external_exports.unknown().optional().describe(
|
|
13431
|
+
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
13432
|
+
),
|
|
13433
|
+
onSleep: external_exports.unknown().optional().describe(
|
|
13434
|
+
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
13435
|
+
),
|
|
13436
|
+
run: external_exports.unknown().optional().describe(
|
|
13437
|
+
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
|
|
13438
|
+
),
|
|
13439
|
+
onStateChange: external_exports.unknown().optional().describe(
|
|
13440
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
13441
|
+
),
|
|
13442
|
+
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
13443
|
+
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
13444
|
+
),
|
|
13445
|
+
onConnect: external_exports.unknown().optional().describe(
|
|
13446
|
+
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
13447
|
+
),
|
|
13448
|
+
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
13449
|
+
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
13450
|
+
"Called before sending an action response. Use to transform output."
|
|
13451
|
+
),
|
|
13452
|
+
onRequest: external_exports.unknown().optional().describe(
|
|
13453
|
+
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
13454
|
+
),
|
|
13455
|
+
onWebSocket: external_exports.unknown().optional().describe(
|
|
13456
|
+
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
13457
|
+
),
|
|
13458
|
+
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13459
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
13460
|
+
),
|
|
13461
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13462
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
13463
|
+
),
|
|
13464
|
+
connParamsSchema: external_exports.unknown().optional().describe(
|
|
13465
|
+
"Optional schema for validating connection params in native runtimes."
|
|
13466
|
+
),
|
|
13467
|
+
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
13468
|
+
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
13469
|
+
options: DocActorOptionsSchema.optional()
|
|
13470
|
+
}).describe("Actor configuration passed to the actor() function.");
|
|
13471
|
+
|
|
13472
|
+
// ../rivetkit/dist/tsup/chunk-OUQUIBVW.js
|
|
13473
|
+
var INTERNAL_ERROR_CODE = "internal_error";
|
|
13474
|
+
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
13475
|
+
var USER_ERROR_CODE = "user_error";
|
|
13476
|
+
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
13477
|
+
function looksLikeRivetErrorOptions(value) {
|
|
13478
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
13479
|
+
}
|
|
13480
|
+
function isTypedErrorTag(value) {
|
|
13481
|
+
return value === "ActorError" || value === "RivetError";
|
|
13482
|
+
}
|
|
13483
|
+
function errorMessage(error46, fallback = String(error46)) {
|
|
13484
|
+
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
13485
|
+
return error46.message;
|
|
13486
|
+
}
|
|
13487
|
+
return fallback;
|
|
13488
|
+
}
|
|
13489
|
+
function isRivetErrorLike(error46) {
|
|
13490
|
+
return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
|
|
13491
|
+
}
|
|
13492
|
+
function isActorAbortedError(error46) {
|
|
13493
|
+
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
13494
|
+
}
|
|
13495
|
+
function isActorSpecifier(value) {
|
|
13496
|
+
return typeof value === "object" && value !== null && "actorId" in value && typeof value.actorId === "string" && "generation" in value && typeof value.generation === "number" && (!("key" in value) || value.key === void 0 || typeof value.key === "string");
|
|
13497
|
+
}
|
|
13498
|
+
var RivetError = class extends Error {
|
|
13499
|
+
__type = "RivetError";
|
|
13500
|
+
public;
|
|
13501
|
+
metadata;
|
|
13502
|
+
rayId;
|
|
13503
|
+
statusCode;
|
|
13504
|
+
actor;
|
|
13505
|
+
group;
|
|
13506
|
+
code;
|
|
13507
|
+
static isRivetError(error46) {
|
|
13508
|
+
return isRivetErrorLike(error46);
|
|
13509
|
+
}
|
|
13510
|
+
static isActorError(error46) {
|
|
13511
|
+
return isRivetErrorLike(error46);
|
|
13512
|
+
}
|
|
13513
|
+
constructor(group, code, message, options) {
|
|
13514
|
+
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
13515
|
+
super(message, { cause: normalized.cause });
|
|
13516
|
+
this.name = "RivetError";
|
|
13517
|
+
this.group = group;
|
|
13518
|
+
this.code = code;
|
|
13519
|
+
this.public = normalized.public ?? false;
|
|
13520
|
+
this.metadata = normalized.metadata;
|
|
13521
|
+
this.rayId = normalized.rayId ?? void 0;
|
|
13522
|
+
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
13523
|
+
this.actor = normalized.actor;
|
|
13524
|
+
}
|
|
13525
|
+
toString() {
|
|
13526
|
+
return this.message;
|
|
13527
|
+
}
|
|
13528
|
+
};
|
|
13529
|
+
var UserError = class extends RivetError {
|
|
13530
|
+
constructor(message, options) {
|
|
13531
|
+
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
13532
|
+
public: true,
|
|
13533
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
13534
|
+
cause: options == null ? void 0 : options.cause
|
|
13535
|
+
});
|
|
13536
|
+
}
|
|
13537
|
+
};
|
|
13538
|
+
function toRivetError(error46, fallback) {
|
|
13539
|
+
if (typeof error46 === "string") {
|
|
13540
|
+
const bridged = decodeBridgeRivetError(error46);
|
|
13541
|
+
if (bridged) {
|
|
13542
|
+
return bridged;
|
|
13543
|
+
}
|
|
13544
|
+
}
|
|
13545
|
+
if (error46 instanceof Error) {
|
|
13546
|
+
const bridged = decodeBridgeRivetError(error46.message);
|
|
13547
|
+
if (bridged) {
|
|
13548
|
+
return bridged;
|
|
13549
|
+
}
|
|
13550
|
+
}
|
|
13551
|
+
if (isRivetErrorLike(error46)) {
|
|
13552
|
+
return new RivetError(error46.group, error46.code, error46.message, {
|
|
13553
|
+
public: error46.public,
|
|
13554
|
+
statusCode: error46.statusCode,
|
|
13555
|
+
metadata: error46.metadata,
|
|
13556
|
+
rayId: error46.rayId,
|
|
13557
|
+
actor: error46.actor,
|
|
13558
|
+
cause: error46 instanceof Error ? error46.cause : void 0
|
|
13559
|
+
});
|
|
13560
|
+
}
|
|
13561
|
+
return new RivetError(
|
|
13562
|
+
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
13563
|
+
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
13564
|
+
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
13565
|
+
{
|
|
13566
|
+
public: fallback == null ? void 0 : fallback.public,
|
|
13567
|
+
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
13568
|
+
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
13569
|
+
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
13570
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
13571
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
13572
|
+
}
|
|
13573
|
+
);
|
|
13574
|
+
}
|
|
13575
|
+
function encodeBridgeRivetError(error46) {
|
|
13576
|
+
return `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({
|
|
13577
|
+
group: error46.group,
|
|
13578
|
+
code: error46.code,
|
|
13579
|
+
message: error46.message,
|
|
13580
|
+
metadata: error46.metadata,
|
|
13581
|
+
rayId: error46.rayId,
|
|
13582
|
+
public: error46.public,
|
|
13583
|
+
statusCode: error46.statusCode,
|
|
13584
|
+
actor: error46.actor
|
|
13585
|
+
})}`;
|
|
13586
|
+
}
|
|
13587
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
13588
|
+
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
13589
|
+
return void 0;
|
|
13590
|
+
}
|
|
13591
|
+
try {
|
|
13592
|
+
const raw = JSON.parse(
|
|
13593
|
+
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
13594
|
+
);
|
|
13595
|
+
const payload = {
|
|
13596
|
+
...raw,
|
|
13597
|
+
rayId: raw.rayId ?? void 0
|
|
13598
|
+
};
|
|
13599
|
+
if (!isRivetErrorLike(payload)) {
|
|
13600
|
+
return void 0;
|
|
13601
|
+
}
|
|
13602
|
+
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
13603
|
+
return void 0;
|
|
13604
|
+
}
|
|
13605
|
+
return payload;
|
|
13606
|
+
} catch {
|
|
13607
|
+
return void 0;
|
|
13608
|
+
}
|
|
13609
|
+
}
|
|
13610
|
+
function decodeBridgeRivetError(value) {
|
|
13611
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
13612
|
+
if (!payload) {
|
|
13613
|
+
return void 0;
|
|
13614
|
+
}
|
|
13615
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
13616
|
+
metadata: payload.metadata,
|
|
13617
|
+
rayId: payload.rayId,
|
|
13618
|
+
public: payload.public,
|
|
13619
|
+
statusCode: payload.statusCode,
|
|
13620
|
+
actor: payload.actor ?? void 0
|
|
13621
|
+
});
|
|
13622
|
+
}
|
|
13623
|
+
function invalidRequest(error46) {
|
|
13624
|
+
return new RivetError(
|
|
13625
|
+
"request",
|
|
13626
|
+
"invalid",
|
|
13627
|
+
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
13628
|
+
{
|
|
13629
|
+
public: true,
|
|
13630
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
13631
|
+
}
|
|
13632
|
+
);
|
|
13633
|
+
}
|
|
13634
|
+
function actorNotFound(identifier) {
|
|
13635
|
+
return new RivetError(
|
|
13636
|
+
"actor",
|
|
13637
|
+
"not_found",
|
|
13638
|
+
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
13639
|
+
{ public: true }
|
|
13640
|
+
);
|
|
13641
|
+
}
|
|
13642
|
+
function forbiddenError() {
|
|
13643
|
+
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
13644
|
+
public: true,
|
|
13645
|
+
statusCode: 403
|
|
13646
|
+
});
|
|
13647
|
+
}
|
|
13648
|
+
function unsupportedFeature(feature) {
|
|
13649
|
+
return new RivetError(
|
|
13650
|
+
"feature",
|
|
13651
|
+
"unsupported",
|
|
13652
|
+
`Unsupported feature: ${feature}`
|
|
13653
|
+
);
|
|
13654
|
+
}
|
|
13655
|
+
|
|
13656
|
+
// ../rivetkit/dist/tsup/chunk-DUYYVOYL.js
|
|
13657
|
+
var import_pino = require("pino");
|
|
13658
|
+
var cbor = __toESM(require("cbor-x"), 1);
|
|
13659
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13660
|
+
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13661
|
+
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13662
|
+
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13663
|
+
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13664
|
+
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13665
|
+
var getRivetTotalSlots = () => {
|
|
13666
|
+
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13667
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13668
|
+
};
|
|
13669
|
+
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13670
|
+
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13671
|
+
var getRivetRunEnginePort = () => {
|
|
13672
|
+
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13673
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13674
|
+
};
|
|
13675
|
+
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13676
|
+
var getRivetRunServices = () => {
|
|
13677
|
+
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13678
|
+
return value === void 0 ? void 0 : value === "1";
|
|
13679
|
+
};
|
|
13680
|
+
var getRivetEnvoyVersion = () => {
|
|
13681
|
+
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13682
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13683
|
+
};
|
|
13684
|
+
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13685
|
+
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13686
|
+
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13687
|
+
var getRivetkitRuntimeMode = () => {
|
|
13688
|
+
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13689
|
+
if (value === void 0) return "envoy";
|
|
13690
|
+
if (value === "envoy" || value === "serverless") return value;
|
|
13691
|
+
throw new Error(
|
|
13692
|
+
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13693
|
+
);
|
|
13694
|
+
};
|
|
13695
|
+
var getRivetkitPublicDir = () => {
|
|
13696
|
+
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13697
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
13698
|
+
};
|
|
13699
|
+
function parsePortEnv(raw) {
|
|
13700
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
13701
|
+
const parsed = Number.parseInt(raw, 10);
|
|
13702
|
+
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13703
|
+
throw new Error(
|
|
13704
|
+
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13705
|
+
);
|
|
13706
|
+
}
|
|
13707
|
+
return parsed;
|
|
13708
|
+
}
|
|
13709
|
+
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13710
|
+
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13711
|
+
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13712
|
+
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13713
|
+
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13714
|
+
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13715
|
+
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13716
|
+
var isDev = () => getNodeEnv() !== "production";
|
|
13717
|
+
function assertUnreachable(x) {
|
|
13718
|
+
throw new Error(`Unreachable case: ${x}`);
|
|
13719
|
+
}
|
|
13720
|
+
function isCanonicalStructuredRivetError(error46) {
|
|
13721
|
+
return error46 instanceof RivetError || typeof error46 === "object" && error46 !== null && "__type" in error46 && error46.__type === "RivetError" && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string";
|
|
13722
|
+
}
|
|
13723
|
+
function deconstructError(error46, exposeInternalError = false) {
|
|
13262
13724
|
let statusCode;
|
|
13263
13725
|
let public_;
|
|
13264
13726
|
let group;
|
|
@@ -13366,7 +13828,7 @@ function noopNext() {
|
|
|
13366
13828
|
}
|
|
13367
13829
|
var package_default = {
|
|
13368
13830
|
name: "rivetkit",
|
|
13369
|
-
version: "0.0.0-
|
|
13831
|
+
version: "0.0.0-wmain-rc.7ab5f18",
|
|
13370
13832
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13371
13833
|
license: "Apache-2.0",
|
|
13372
13834
|
keywords: [
|
|
@@ -14670,7 +15132,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14670
15132
|
};
|
|
14671
15133
|
}
|
|
14672
15134
|
|
|
14673
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15135
|
+
// ../rivetkit/dist/tsup/chunk-Z2OV6OX7.js
|
|
14674
15136
|
var config2 = /* @__PURE__ */ Config({});
|
|
14675
15137
|
function readWorkflowCbor(bc) {
|
|
14676
15138
|
return readData(bc);
|
|
@@ -14944,493 +15406,29 @@ function read6(bc) {
|
|
|
14944
15406
|
if (result.has(key)) {
|
|
14945
15407
|
bc.offset = offset;
|
|
14946
15408
|
throw new BareError(offset, "duplicated key");
|
|
14947
|
-
}
|
|
14948
|
-
result.set(key, readWorkflowEntryMetadata(bc));
|
|
14949
|
-
}
|
|
14950
|
-
return result;
|
|
14951
|
-
}
|
|
14952
|
-
function readWorkflowHistory(bc) {
|
|
14953
|
-
return {
|
|
14954
|
-
nameRegistry: read4(bc),
|
|
14955
|
-
entries: read5(bc),
|
|
14956
|
-
entryMetadata: read6(bc)
|
|
14957
|
-
};
|
|
14958
|
-
}
|
|
14959
|
-
function decodeWorkflowHistory(bytes) {
|
|
14960
|
-
const bc = new ByteCursor(bytes, config2);
|
|
14961
|
-
const result = readWorkflowHistory(bc);
|
|
14962
|
-
if (bc.offset < bc.view.byteLength) {
|
|
14963
|
-
throw new BareError(bc.offset, "remaining bytes");
|
|
14964
|
-
}
|
|
14965
|
-
return result;
|
|
14966
|
-
}
|
|
14967
|
-
function decodeWorkflowHistoryTransport(data) {
|
|
14968
|
-
return decodeWorkflowHistory(toUint8Array(data));
|
|
14969
|
-
}
|
|
14970
|
-
|
|
14971
|
-
// ../rivetkit/dist/tsup/chunk-6W5VGLFT.js
|
|
14972
|
-
function flattenActionHandlers(actions) {
|
|
14973
|
-
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14974
|
-
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14975
|
-
flattened[name] = handler;
|
|
14976
|
-
}
|
|
14977
|
-
return flattened;
|
|
14978
|
-
}
|
|
14979
|
-
function flattenActionInputSchemas(actions, schemas) {
|
|
14980
|
-
if (schemas === void 0) return void 0;
|
|
14981
|
-
if (!isRecord(schemas)) {
|
|
14982
|
-
throw new TypeError("actionInputSchemas must be an object");
|
|
14983
|
-
}
|
|
14984
|
-
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14985
|
-
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
14986
|
-
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
14987
|
-
const flatSchema = schemas[name];
|
|
14988
|
-
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
14989
|
-
throw new TypeError(
|
|
14990
|
-
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
14991
|
-
);
|
|
14992
|
-
}
|
|
14993
|
-
const schema = nestedSchema ?? flatSchema;
|
|
14994
|
-
if (schema !== void 0) {
|
|
14995
|
-
flattened[name] = schema;
|
|
14996
|
-
}
|
|
14997
|
-
}
|
|
14998
|
-
return flattened;
|
|
14999
|
-
}
|
|
15000
|
-
function collectActionEntries(actions) {
|
|
15001
|
-
const entries = [];
|
|
15002
|
-
const names = /* @__PURE__ */ new Set();
|
|
15003
|
-
visitActionGroup(actions ?? {}, [], entries, names);
|
|
15004
|
-
return entries;
|
|
15005
|
-
}
|
|
15006
|
-
function visitActionGroup(value, path2, entries, names) {
|
|
15007
|
-
if (!isRecord(value)) {
|
|
15008
|
-
throw new TypeError(
|
|
15009
|
-
`${formatActionPath(path2)} must be an action handler or group`
|
|
15010
|
-
);
|
|
15011
|
-
}
|
|
15012
|
-
for (const [segment, child] of Object.entries(value)) {
|
|
15013
|
-
const childPath = [...path2, segment];
|
|
15014
|
-
if (typeof child === "function") {
|
|
15015
|
-
const name = childPath.join(".");
|
|
15016
|
-
if (names.has(name)) {
|
|
15017
|
-
throw new TypeError(
|
|
15018
|
-
`Multiple action definitions flatten to \`${name}\``
|
|
15019
|
-
);
|
|
15020
|
-
}
|
|
15021
|
-
names.add(name);
|
|
15022
|
-
entries.push({
|
|
15023
|
-
name,
|
|
15024
|
-
path: childPath,
|
|
15025
|
-
handler: child
|
|
15026
|
-
});
|
|
15027
|
-
} else {
|
|
15028
|
-
visitActionGroup(child, childPath, entries, names);
|
|
15029
|
-
}
|
|
15030
|
-
}
|
|
15031
|
-
}
|
|
15032
|
-
function lookupNestedSchema(schemas, path2) {
|
|
15033
|
-
let value = schemas;
|
|
15034
|
-
for (const segment of path2) {
|
|
15035
|
-
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
15036
|
-
return void 0;
|
|
15037
|
-
}
|
|
15038
|
-
value = value[segment];
|
|
15039
|
-
}
|
|
15040
|
-
return value;
|
|
15041
|
-
}
|
|
15042
|
-
function isRecord(value) {
|
|
15043
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15044
|
-
return false;
|
|
15045
|
-
}
|
|
15046
|
-
const prototype = Object.getPrototypeOf(value);
|
|
15047
|
-
return prototype === Object.prototype || prototype === null;
|
|
15048
|
-
}
|
|
15049
|
-
function formatActionPath(path2) {
|
|
15050
|
-
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
15051
|
-
}
|
|
15052
|
-
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
15053
|
-
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
15054
|
-
"rivetkit.actor_context_internal"
|
|
15055
|
-
);
|
|
15056
|
-
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
15057
|
-
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
15058
|
-
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
15059
|
-
var zActionTree = external_exports.custom((value) => {
|
|
15060
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15061
|
-
return false;
|
|
15062
|
-
}
|
|
15063
|
-
const prototype = Object.getPrototypeOf(value);
|
|
15064
|
-
return prototype === Object.prototype || prototype === null;
|
|
15065
|
-
}).superRefine((actions, ctx) => {
|
|
15066
|
-
try {
|
|
15067
|
-
flattenActionHandlers(actions);
|
|
15068
|
-
} catch (error46) {
|
|
15069
|
-
ctx.addIssue({
|
|
15070
|
-
code: "custom",
|
|
15071
|
-
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15072
|
-
});
|
|
15073
|
-
}
|
|
15074
|
-
});
|
|
15075
|
-
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
15076
|
-
getHistory: zFunction(),
|
|
15077
|
-
getState: zFunction().optional(),
|
|
15078
|
-
onHistoryUpdated: zFunction().optional(),
|
|
15079
|
-
replayFromStep: zFunction().optional()
|
|
15080
|
-
});
|
|
15081
|
-
var RunInspectorConfigSchema = external_exports.object({
|
|
15082
|
-
workflow: WorkflowInspectorConfigSchema.optional()
|
|
15083
|
-
}).optional();
|
|
15084
|
-
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
15085
|
-
"workflow",
|
|
15086
|
-
"database",
|
|
15087
|
-
"state",
|
|
15088
|
-
"queue",
|
|
15089
|
-
"schedules",
|
|
15090
|
-
"connections",
|
|
15091
|
-
"console"
|
|
15092
|
-
];
|
|
15093
|
-
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15094
|
-
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
15095
|
-
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
15096
|
-
id: external_exports.string().regex(
|
|
15097
|
-
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
15098
|
-
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
15099
|
-
),
|
|
15100
|
-
label: external_exports.string().min(1),
|
|
15101
|
-
source: external_exports.string().min(1),
|
|
15102
|
-
/**
|
|
15103
|
-
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
15104
|
-
* icon registry); unknown ids fall back to a generic icon.
|
|
15105
|
-
*/
|
|
15106
|
-
icon: external_exports.string().min(1).optional(),
|
|
15107
|
-
hidden: external_exports.literal(false).optional()
|
|
15108
|
-
}).strict();
|
|
15109
|
-
var HideInspectorTabEntrySchema = external_exports.object({
|
|
15110
|
-
id: BuiltinInspectorTabIdSchema,
|
|
15111
|
-
hidden: external_exports.literal(true)
|
|
15112
|
-
}).strict();
|
|
15113
|
-
var InspectorTabEntrySchema = external_exports.union([
|
|
15114
|
-
CustomInspectorTabEntrySchema,
|
|
15115
|
-
HideInspectorTabEntrySchema
|
|
15116
|
-
]);
|
|
15117
|
-
var ActorInspectorConfigSchema = external_exports.object({
|
|
15118
|
-
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
15119
|
-
}).strict().refine(
|
|
15120
|
-
(data) => {
|
|
15121
|
-
const ids = data.tabs.map((t) => t.id);
|
|
15122
|
-
return new Set(ids).size === ids.length;
|
|
15123
|
-
},
|
|
15124
|
-
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
15125
|
-
).refine(
|
|
15126
|
-
(data) => {
|
|
15127
|
-
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15128
|
-
return data.tabs.every(
|
|
15129
|
-
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
15130
|
-
);
|
|
15131
|
-
},
|
|
15132
|
-
{
|
|
15133
|
-
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
15134
|
-
path: ["tabs"]
|
|
15135
|
-
}
|
|
15136
|
-
);
|
|
15137
|
-
var RunConfigSchema = external_exports.object({
|
|
15138
|
-
/** Display name for the actor in the Inspector UI. */
|
|
15139
|
-
name: external_exports.string().optional(),
|
|
15140
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15141
|
-
icon: external_exports.string().optional(),
|
|
15142
|
-
/** The run handler function. */
|
|
15143
|
-
run: zFunction(),
|
|
15144
|
-
/** Inspector integration for long-running run handlers. */
|
|
15145
|
-
inspector: RunInspectorConfigSchema.optional()
|
|
15146
|
-
});
|
|
15147
|
-
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
15148
|
-
function defineRunHandler(run, options) {
|
|
15149
|
-
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
15150
|
-
throw new TypeError(
|
|
15151
|
-
"defineRunHandler requires inspectorKind and createInspector together"
|
|
15152
|
-
);
|
|
15153
|
-
}
|
|
15154
|
-
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
15155
|
-
configurable: false,
|
|
15156
|
-
enumerable: false,
|
|
15157
|
-
writable: false,
|
|
15158
|
-
value: {
|
|
15159
|
-
name: options.name,
|
|
15160
|
-
icon: options.icon,
|
|
15161
|
-
inspectorKind: options.inspectorKind,
|
|
15162
|
-
createInspector: options.createInspector
|
|
15163
|
-
}
|
|
15164
|
-
});
|
|
15165
|
-
return run;
|
|
15166
|
-
}
|
|
15167
|
-
function getRunInspectorKind(run) {
|
|
15168
|
-
var _a2;
|
|
15169
|
-
if (!run || typeof run !== "function") return void 0;
|
|
15170
|
-
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
15171
|
-
}
|
|
15172
|
-
function createRunInspector(run, context) {
|
|
15173
|
-
var _a2, _b;
|
|
15174
|
-
if (!run || typeof run !== "function") return void 0;
|
|
15175
|
-
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context);
|
|
15176
|
-
}
|
|
15177
|
-
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
15178
|
-
function getRunFunction(run) {
|
|
15179
|
-
if (!run) return void 0;
|
|
15180
|
-
if (typeof run === "function") return run;
|
|
15181
|
-
return run.run;
|
|
15182
|
-
}
|
|
15183
|
-
function getRunMetadata(run) {
|
|
15184
|
-
if (!run) return {};
|
|
15185
|
-
if (typeof run === "function") {
|
|
15186
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15187
|
-
if (!config3) return {};
|
|
15188
|
-
return { name: config3.name, icon: config3.icon };
|
|
15189
|
-
}
|
|
15190
|
-
return { name: run.name, icon: run.icon };
|
|
15191
|
-
}
|
|
15192
|
-
function getRunInspectorConfig(run, actor2) {
|
|
15193
|
-
if (!run) return void 0;
|
|
15194
|
-
if (typeof run === "function") {
|
|
15195
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15196
|
-
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
15409
|
+
}
|
|
15410
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
15197
15411
|
}
|
|
15198
|
-
return
|
|
15412
|
+
return result;
|
|
15199
15413
|
}
|
|
15200
|
-
function
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15414
|
+
function readWorkflowHistory(bc) {
|
|
15415
|
+
return {
|
|
15416
|
+
nameRegistry: read4(bc),
|
|
15417
|
+
entries: read5(bc),
|
|
15418
|
+
entryMetadata: read6(bc)
|
|
15419
|
+
};
|
|
15205
15420
|
}
|
|
15206
|
-
function
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15421
|
+
function decodeWorkflowHistory(bytes) {
|
|
15422
|
+
const bc = new ByteCursor(bytes, config2);
|
|
15423
|
+
const result = readWorkflowHistory(bc);
|
|
15424
|
+
if (bc.offset < bc.view.byteLength) {
|
|
15425
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
15210
15426
|
}
|
|
15211
|
-
|
|
15212
|
-
|
|
15427
|
+
return result;
|
|
15428
|
+
}
|
|
15429
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
15430
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
15213
15431
|
}
|
|
15214
|
-
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
15215
|
-
/** Display name for the actor in the Inspector UI. */
|
|
15216
|
-
name: external_exports.string().optional(),
|
|
15217
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15218
|
-
icon: external_exports.string().optional(),
|
|
15219
|
-
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
15220
|
-
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
15221
|
-
/**
|
|
15222
|
-
* Can hibernate WebSockets for onWebSocket.
|
|
15223
|
-
*
|
|
15224
|
-
* WebSockets using actions/events are hibernatable by default.
|
|
15225
|
-
*
|
|
15226
|
-
* @experimental
|
|
15227
|
-
**/
|
|
15228
|
-
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
15229
|
-
}).strict();
|
|
15230
|
-
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
15231
|
-
() => ({})
|
|
15232
|
-
);
|
|
15233
|
-
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
15234
|
-
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
15235
|
-
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
15236
|
-
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15237
|
-
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
15238
|
-
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
15239
|
-
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
15240
|
-
/** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
15241
|
-
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
15242
|
-
/** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
|
|
15243
|
-
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
15244
|
-
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
15245
|
-
actionTimeout: external_exports.number().positive().default(6e4),
|
|
15246
|
-
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
15247
|
-
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
15248
|
-
/** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
|
|
15249
|
-
noSleep: external_exports.boolean().default(false),
|
|
15250
|
-
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
15251
|
-
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15252
|
-
/** Maximum pending one-shot and recurring schedules. */
|
|
15253
|
-
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
15254
|
-
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
15255
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15256
|
-
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
15257
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15258
|
-
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
15259
|
-
}).strict();
|
|
15260
|
-
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
15261
|
-
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
15262
|
-
InstanceActorOptionsBaseSchema.shape
|
|
15263
|
-
).strict().prefault(() => ({}));
|
|
15264
|
-
var ActorConfigSchema = external_exports.object({
|
|
15265
|
-
onCreate: zFunction().optional(),
|
|
15266
|
-
onDestroy: zFunction().optional(),
|
|
15267
|
-
onMigrate: zFunction().optional(),
|
|
15268
|
-
onWake: zFunction().optional(),
|
|
15269
|
-
onSleep: zFunction().optional(),
|
|
15270
|
-
run: zRunHandler,
|
|
15271
|
-
onStateChange: zFunction().optional(),
|
|
15272
|
-
onBeforeConnect: zFunction().optional(),
|
|
15273
|
-
onConnect: zFunction().optional(),
|
|
15274
|
-
onDisconnect: zFunction().optional(),
|
|
15275
|
-
onBeforeActionResponse: zFunction().optional(),
|
|
15276
|
-
onRequest: zFunction().optional(),
|
|
15277
|
-
onWebSocket: zFunction().optional(),
|
|
15278
|
-
actions: zActionTree.default(() => ({})),
|
|
15279
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15280
|
-
connParamsSchema: external_exports.any().optional(),
|
|
15281
|
-
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15282
|
-
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15283
|
-
state: external_exports.any().optional(),
|
|
15284
|
-
createState: zFunction().optional(),
|
|
15285
|
-
connState: external_exports.any().optional(),
|
|
15286
|
-
createConnState: zFunction().optional(),
|
|
15287
|
-
vars: external_exports.any().optional(),
|
|
15288
|
-
db: external_exports.any().optional(),
|
|
15289
|
-
createVars: zFunction().optional(),
|
|
15290
|
-
options: ActorOptionsSchema,
|
|
15291
|
-
inspector: ActorInspectorConfigSchema.optional()
|
|
15292
|
-
}).strict().refine(
|
|
15293
|
-
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
15294
|
-
{
|
|
15295
|
-
message: "Cannot define both 'state' and 'createState'",
|
|
15296
|
-
path: ["state"]
|
|
15297
|
-
}
|
|
15298
|
-
).refine(
|
|
15299
|
-
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
15300
|
-
{
|
|
15301
|
-
message: "Cannot define both 'connState' and 'createConnState'",
|
|
15302
|
-
path: ["connState"]
|
|
15303
|
-
}
|
|
15304
|
-
).refine(
|
|
15305
|
-
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
15306
|
-
{
|
|
15307
|
-
message: "Cannot define both 'vars' and 'createVars'",
|
|
15308
|
-
path: ["vars"]
|
|
15309
|
-
}
|
|
15310
|
-
);
|
|
15311
|
-
var DocActorOptionsSchema = external_exports.object({
|
|
15312
|
-
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
15313
|
-
icon: external_exports.string().optional().describe(
|
|
15314
|
-
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
15315
|
-
),
|
|
15316
|
-
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
15317
|
-
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
15318
|
-
),
|
|
15319
|
-
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
15320
|
-
createConnStateTimeout: external_exports.number().optional().describe(
|
|
15321
|
-
"Timeout in ms for createConnState handler. Default: 5000"
|
|
15322
|
-
),
|
|
15323
|
-
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
15324
|
-
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
15325
|
-
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
15326
|
-
),
|
|
15327
|
-
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
15328
|
-
sleepGracePeriod: external_exports.number().optional().describe(
|
|
15329
|
-
`Max time in ms for the graceful shutdown window. Covers lifecycle hooks (onSleep, onDestroy), the run handler wait, async raw WebSocket handlers, disconnect callbacks, and final state serialization. Default: ${DEFAULT_SLEEP_GRACE_PERIOD}.`
|
|
15330
|
-
),
|
|
15331
|
-
onDestroyTimeout: external_exports.number().optional().describe(
|
|
15332
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15333
|
-
),
|
|
15334
|
-
waitUntilTimeout: external_exports.number().optional().describe(
|
|
15335
|
-
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
15336
|
-
),
|
|
15337
|
-
stateSaveInterval: external_exports.number().optional().describe(
|
|
15338
|
-
"Interval in ms between automatic state saves. Default: 1000"
|
|
15339
|
-
),
|
|
15340
|
-
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
15341
|
-
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
15342
|
-
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
15343
|
-
),
|
|
15344
|
-
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
15345
|
-
"Interval in ms between connection liveness checks. Default: 5000"
|
|
15346
|
-
),
|
|
15347
|
-
noSleep: external_exports.boolean().optional().describe(
|
|
15348
|
-
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
15349
|
-
),
|
|
15350
|
-
sleepTimeout: external_exports.number().optional().describe(
|
|
15351
|
-
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
15352
|
-
),
|
|
15353
|
-
maxQueueSize: external_exports.number().optional().describe(
|
|
15354
|
-
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
15355
|
-
),
|
|
15356
|
-
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15357
|
-
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15358
|
-
),
|
|
15359
|
-
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
15360
|
-
"Maximum size of each queue message in bytes. Default: 65536"
|
|
15361
|
-
),
|
|
15362
|
-
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
15363
|
-
"Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false"
|
|
15364
|
-
)
|
|
15365
|
-
}).describe("Actor options for timeouts and behavior configuration.");
|
|
15366
|
-
var DocActorConfigSchema = external_exports.object({
|
|
15367
|
-
state: external_exports.unknown().optional().describe(
|
|
15368
|
-
"Initial state value for the actor. Cannot be used with createState."
|
|
15369
|
-
),
|
|
15370
|
-
createState: external_exports.unknown().optional().describe(
|
|
15371
|
-
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
15372
|
-
),
|
|
15373
|
-
connState: external_exports.unknown().optional().describe(
|
|
15374
|
-
"Initial connection state value. Cannot be used with createConnState."
|
|
15375
|
-
),
|
|
15376
|
-
createConnState: external_exports.unknown().optional().describe(
|
|
15377
|
-
"Function to create connection state. Receives context and connection params. The pending connection is not visible in c.conns until this succeeds. Cannot be used with connState."
|
|
15378
|
-
),
|
|
15379
|
-
vars: external_exports.unknown().optional().describe(
|
|
15380
|
-
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
15381
|
-
),
|
|
15382
|
-
createVars: external_exports.unknown().optional().describe(
|
|
15383
|
-
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
15384
|
-
),
|
|
15385
|
-
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
15386
|
-
onCreate: external_exports.unknown().optional().describe(
|
|
15387
|
-
"Called when the actor is first initialized. Use to initialize state."
|
|
15388
|
-
),
|
|
15389
|
-
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
15390
|
-
onMigrate: external_exports.unknown().optional().describe(
|
|
15391
|
-
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
15392
|
-
),
|
|
15393
|
-
onWake: external_exports.unknown().optional().describe(
|
|
15394
|
-
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
15395
|
-
),
|
|
15396
|
-
onSleep: external_exports.unknown().optional().describe(
|
|
15397
|
-
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
15398
|
-
),
|
|
15399
|
-
run: external_exports.unknown().optional().describe(
|
|
15400
|
-
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle."
|
|
15401
|
-
),
|
|
15402
|
-
onStateChange: external_exports.unknown().optional().describe(
|
|
15403
|
-
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
15404
|
-
),
|
|
15405
|
-
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
15406
|
-
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
15407
|
-
),
|
|
15408
|
-
onConnect: external_exports.unknown().optional().describe(
|
|
15409
|
-
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
15410
|
-
),
|
|
15411
|
-
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
15412
|
-
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
15413
|
-
"Called before sending an action response. Use to transform output."
|
|
15414
|
-
),
|
|
15415
|
-
onRequest: external_exports.unknown().optional().describe(
|
|
15416
|
-
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
15417
|
-
),
|
|
15418
|
-
onWebSocket: external_exports.unknown().optional().describe(
|
|
15419
|
-
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15420
|
-
),
|
|
15421
|
-
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15422
|
-
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15423
|
-
),
|
|
15424
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15425
|
-
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15426
|
-
),
|
|
15427
|
-
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15428
|
-
"Optional schema for validating connection params in native runtimes."
|
|
15429
|
-
),
|
|
15430
|
-
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
15431
|
-
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
15432
|
-
options: DocActorOptionsSchema.optional()
|
|
15433
|
-
}).describe("Actor configuration passed to the actor() function.");
|
|
15434
15432
|
|
|
15435
15433
|
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
15436
15434
|
var EMPTY_KEY = "/";
|
|
@@ -15549,7 +15547,7 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15549
15547
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15550
15548
|
}
|
|
15551
15549
|
|
|
15552
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15550
|
+
// ../rivetkit/dist/tsup/chunk-OXLW5J6X.js
|
|
15553
15551
|
function logger() {
|
|
15554
15552
|
return getLogger("actor-client");
|
|
15555
15553
|
}
|
|
@@ -15670,7 +15668,7 @@ var AsyncMutex = class {
|
|
|
15670
15668
|
}
|
|
15671
15669
|
};
|
|
15672
15670
|
|
|
15673
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15671
|
+
// ../rivetkit/dist/tsup/chunk-TH2I5PMK.js
|
|
15674
15672
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15675
15673
|
|
|
15676
15674
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15848,7 +15846,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15848
15846
|
return new VersionedDataHandler(config3);
|
|
15849
15847
|
}
|
|
15850
15848
|
|
|
15851
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15849
|
+
// ../rivetkit/dist/tsup/chunk-TH2I5PMK.js
|
|
15852
15850
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15853
15851
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15854
15852
|
var PATH_CONNECT = "/connect";
|
|
@@ -18353,6 +18351,15 @@ function createQueueSender(senderOptions) {
|
|
|
18353
18351
|
send
|
|
18354
18352
|
};
|
|
18355
18353
|
}
|
|
18354
|
+
async function prepareRetryableInit(init) {
|
|
18355
|
+
if (init.body instanceof ReadableStream) {
|
|
18356
|
+
return {
|
|
18357
|
+
...init,
|
|
18358
|
+
body: new Uint8Array(await new Response(init.body).arrayBuffer())
|
|
18359
|
+
};
|
|
18360
|
+
}
|
|
18361
|
+
return init;
|
|
18362
|
+
}
|
|
18356
18363
|
async function rawHttpFetch(driver, target, params, input, init, options = {}) {
|
|
18357
18364
|
let path2;
|
|
18358
18365
|
let originalUrl;
|
|
@@ -18887,9 +18894,10 @@ var ActorHandleRaw = class {
|
|
|
18887
18894
|
return this.#fetchWithResolvedActor(input, init);
|
|
18888
18895
|
}
|
|
18889
18896
|
async #fetchWithResolvedActor(input, init) {
|
|
18890
|
-
const { skipReadyWait, ...
|
|
18891
|
-
const
|
|
18892
|
-
const
|
|
18897
|
+
const { skipReadyWait, ...restInit } = init ?? {};
|
|
18898
|
+
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
18899
|
+
const requestInit = maxAttempts > 1 ? await prepareRetryableInit(restInit) : restInit;
|
|
18900
|
+
const clonesInputBody = requestInit.body === void 0 && isRequestLike(input) && input.body !== null;
|
|
18893
18901
|
let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
|
|
18894
18902
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
18895
18903
|
this.#gatewayOptions,
|
|
@@ -18909,7 +18917,9 @@ var ActorHandleRaw = class {
|
|
|
18909
18917
|
this.#driver,
|
|
18910
18918
|
target,
|
|
18911
18919
|
this.#params,
|
|
18912
|
-
|
|
18920
|
+
// Clone a body-bearing Request so retries don't reuse a consumed stream.
|
|
18921
|
+
// NOTE: This holds the body in memory until GC (unavoidable).
|
|
18922
|
+
clonesInputBody ? input.clone() : input,
|
|
18913
18923
|
requestInit,
|
|
18914
18924
|
gatewayOptions
|
|
18915
18925
|
);
|
|
@@ -21620,7 +21630,7 @@ function apiActorToOutput(actor2) {
|
|
|
21620
21630
|
};
|
|
21621
21631
|
}
|
|
21622
21632
|
|
|
21623
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
21633
|
+
// ../rivetkit/dist/tsup/chunk-E62MUZEA.js
|
|
21624
21634
|
var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
|
|
21625
21635
|
var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
|
|
21626
21636
|
function registerNativeStateTransactionOpener(provider, opener) {
|