@rivetkit/supabase 2.3.30 → 2.3.32
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 +2288 -2290
- package/dist/mod.mjs +2290 -2292
- package/package.json +3 -3
package/dist/mod.mjs
CHANGED
|
@@ -297,215 +297,6 @@ var require_retry2 = __commonJS({
|
|
|
297
297
|
// src/mod.ts
|
|
298
298
|
import * as wasmBindings from "@rivetkit/rivetkit-wasm";
|
|
299
299
|
|
|
300
|
-
// ../rivetkit/dist/tsup/chunk-ZOVJDAOW.js
|
|
301
|
-
var INTERNAL_ERROR_CODE = "internal_error";
|
|
302
|
-
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
303
|
-
var USER_ERROR_CODE = "user_error";
|
|
304
|
-
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
305
|
-
function looksLikeRivetErrorOptions(value) {
|
|
306
|
-
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
307
|
-
}
|
|
308
|
-
function isTypedErrorTag(value) {
|
|
309
|
-
return value === "ActorError" || value === "RivetError";
|
|
310
|
-
}
|
|
311
|
-
function errorMessage(error46, fallback = String(error46)) {
|
|
312
|
-
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
313
|
-
return error46.message;
|
|
314
|
-
}
|
|
315
|
-
return fallback;
|
|
316
|
-
}
|
|
317
|
-
function isRivetErrorLike(error46) {
|
|
318
|
-
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));
|
|
319
|
-
}
|
|
320
|
-
function isActorAbortedError(error46) {
|
|
321
|
-
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
322
|
-
}
|
|
323
|
-
function isActorSpecifier(value) {
|
|
324
|
-
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");
|
|
325
|
-
}
|
|
326
|
-
var RivetError = class extends Error {
|
|
327
|
-
__type = "RivetError";
|
|
328
|
-
public;
|
|
329
|
-
metadata;
|
|
330
|
-
rayId;
|
|
331
|
-
statusCode;
|
|
332
|
-
actor;
|
|
333
|
-
group;
|
|
334
|
-
code;
|
|
335
|
-
static isRivetError(error46) {
|
|
336
|
-
return isRivetErrorLike(error46);
|
|
337
|
-
}
|
|
338
|
-
static isActorError(error46) {
|
|
339
|
-
return isRivetErrorLike(error46);
|
|
340
|
-
}
|
|
341
|
-
constructor(group, code, message, options) {
|
|
342
|
-
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
343
|
-
super(message, { cause: normalized.cause });
|
|
344
|
-
this.name = "RivetError";
|
|
345
|
-
this.group = group;
|
|
346
|
-
this.code = code;
|
|
347
|
-
this.public = normalized.public ?? false;
|
|
348
|
-
this.metadata = normalized.metadata;
|
|
349
|
-
this.rayId = normalized.rayId ?? void 0;
|
|
350
|
-
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
351
|
-
this.actor = normalized.actor;
|
|
352
|
-
}
|
|
353
|
-
toString() {
|
|
354
|
-
return this.message;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
var UserError = class extends RivetError {
|
|
358
|
-
constructor(message, options) {
|
|
359
|
-
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
360
|
-
public: true,
|
|
361
|
-
metadata: options == null ? void 0 : options.metadata,
|
|
362
|
-
cause: options == null ? void 0 : options.cause
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
function toRivetError(error46, fallback) {
|
|
367
|
-
if (typeof error46 === "string") {
|
|
368
|
-
const bridged = decodeBridgeRivetError(error46);
|
|
369
|
-
if (bridged) {
|
|
370
|
-
return bridged;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
if (error46 instanceof Error) {
|
|
374
|
-
const bridged = decodeBridgeRivetError(error46.message);
|
|
375
|
-
if (bridged) {
|
|
376
|
-
return bridged;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
if (isRivetErrorLike(error46)) {
|
|
380
|
-
return new RivetError(error46.group, error46.code, error46.message, {
|
|
381
|
-
public: error46.public,
|
|
382
|
-
statusCode: error46.statusCode,
|
|
383
|
-
metadata: error46.metadata,
|
|
384
|
-
rayId: error46.rayId,
|
|
385
|
-
actor: error46.actor,
|
|
386
|
-
cause: error46 instanceof Error ? error46.cause : void 0
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
return new RivetError(
|
|
390
|
-
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
391
|
-
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
392
|
-
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
393
|
-
{
|
|
394
|
-
public: fallback == null ? void 0 : fallback.public,
|
|
395
|
-
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
396
|
-
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
397
|
-
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
398
|
-
actor: fallback == null ? void 0 : fallback.actor,
|
|
399
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
}
|
|
403
|
-
function encodeBridgeRivetError(error46) {
|
|
404
|
-
const payload = {
|
|
405
|
-
group: error46.group,
|
|
406
|
-
code: error46.code,
|
|
407
|
-
message: error46.message,
|
|
408
|
-
metadata: error46.metadata,
|
|
409
|
-
rayId: error46.rayId,
|
|
410
|
-
public: error46.public,
|
|
411
|
-
statusCode: error46.statusCode,
|
|
412
|
-
actor: error46.actor
|
|
413
|
-
};
|
|
414
|
-
try {
|
|
415
|
-
return {
|
|
416
|
-
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify(payload)}`
|
|
417
|
-
};
|
|
418
|
-
} catch (cause) {
|
|
419
|
-
return {
|
|
420
|
-
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({ ...payload, metadata: void 0 })}`,
|
|
421
|
-
droppedMetadataCause: cause
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function encodeErrorForBridge(error46) {
|
|
426
|
-
if (isCanonicalStructuredRivetError(error46)) {
|
|
427
|
-
return encodeBridgeRivetError(error46).encoded;
|
|
428
|
-
}
|
|
429
|
-
return String(error46);
|
|
430
|
-
}
|
|
431
|
-
function isCanonicalStructuredRivetError(error46) {
|
|
432
|
-
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";
|
|
433
|
-
}
|
|
434
|
-
function decodeBridgeRivetErrorPayload(value) {
|
|
435
|
-
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
436
|
-
return void 0;
|
|
437
|
-
}
|
|
438
|
-
try {
|
|
439
|
-
const raw = JSON.parse(
|
|
440
|
-
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
441
|
-
);
|
|
442
|
-
const payload = {
|
|
443
|
-
...raw,
|
|
444
|
-
rayId: raw.rayId ?? void 0
|
|
445
|
-
};
|
|
446
|
-
if (!isRivetErrorLike(payload)) {
|
|
447
|
-
return void 0;
|
|
448
|
-
}
|
|
449
|
-
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
450
|
-
return void 0;
|
|
451
|
-
}
|
|
452
|
-
return payload;
|
|
453
|
-
} catch {
|
|
454
|
-
return void 0;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function decodeBridgeRivetError(value) {
|
|
458
|
-
const payload = decodeBridgeRivetErrorPayload(value);
|
|
459
|
-
if (!payload) {
|
|
460
|
-
return void 0;
|
|
461
|
-
}
|
|
462
|
-
return new RivetError(payload.group, payload.code, payload.message, {
|
|
463
|
-
metadata: payload.metadata,
|
|
464
|
-
rayId: payload.rayId,
|
|
465
|
-
public: payload.public,
|
|
466
|
-
statusCode: payload.statusCode,
|
|
467
|
-
actor: payload.actor ?? void 0
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
function invalidRequest(error46) {
|
|
471
|
-
return new RivetError(
|
|
472
|
-
"request",
|
|
473
|
-
"invalid",
|
|
474
|
-
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
475
|
-
{
|
|
476
|
-
public: true,
|
|
477
|
-
cause: error46 instanceof Error ? error46 : void 0
|
|
478
|
-
}
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
function actorNotFound(identifier) {
|
|
482
|
-
return new RivetError(
|
|
483
|
-
"actor",
|
|
484
|
-
"not_found",
|
|
485
|
-
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
486
|
-
{ public: true }
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
function forbiddenError() {
|
|
490
|
-
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
491
|
-
public: true,
|
|
492
|
-
statusCode: 403
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
function unsupportedFeature(feature) {
|
|
496
|
-
return new RivetError(
|
|
497
|
-
"feature",
|
|
498
|
-
"unsupported",
|
|
499
|
-
`Unsupported feature: ${feature}`
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// ../rivetkit/dist/tsup/chunk-CORYIKDC.js
|
|
504
|
-
import {
|
|
505
|
-
pino,
|
|
506
|
-
stdTimeFunctions
|
|
507
|
-
} from "pino";
|
|
508
|
-
|
|
509
300
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
510
301
|
var external_exports = {};
|
|
511
302
|
__export(external_exports, {
|
|
@@ -13176,2273 +12967,2480 @@ var classic_default = external_exports;
|
|
|
13176
12967
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13177
12968
|
var v4_default = classic_default;
|
|
13178
12969
|
|
|
13179
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13185
|
-
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13186
|
-
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13187
|
-
var getRivetTotalSlots = () => {
|
|
13188
|
-
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13189
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13190
|
-
};
|
|
13191
|
-
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13192
|
-
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13193
|
-
var getRivetRunEnginePort = () => {
|
|
13194
|
-
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13195
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13196
|
-
};
|
|
13197
|
-
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13198
|
-
var getRivetRunServices = () => {
|
|
13199
|
-
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13200
|
-
return value === void 0 ? void 0 : value === "1";
|
|
13201
|
-
};
|
|
13202
|
-
var getRivetEnvoyVersion = () => {
|
|
13203
|
-
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13204
|
-
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13205
|
-
};
|
|
13206
|
-
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13207
|
-
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13208
|
-
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13209
|
-
var getRivetkitRuntimeMode = () => {
|
|
13210
|
-
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13211
|
-
if (value === void 0) return "envoy";
|
|
13212
|
-
if (value === "envoy" || value === "serverless") return value;
|
|
13213
|
-
throw new Error(
|
|
13214
|
-
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13215
|
-
);
|
|
13216
|
-
};
|
|
13217
|
-
var getRivetkitPublicDir = () => {
|
|
13218
|
-
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13219
|
-
return value === void 0 || value === "" ? void 0 : value;
|
|
13220
|
-
};
|
|
13221
|
-
function parsePortEnv(raw) {
|
|
13222
|
-
if (raw === void 0 || raw === "") return void 0;
|
|
13223
|
-
const parsed = Number.parseInt(raw, 10);
|
|
13224
|
-
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13225
|
-
throw new Error(
|
|
13226
|
-
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13227
|
-
);
|
|
12970
|
+
// ../rivetkit/dist/tsup/chunk-6FEYCVZC.js
|
|
12971
|
+
function flattenActionHandlers(actions) {
|
|
12972
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
12973
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
12974
|
+
flattened[name] = handler;
|
|
13228
12975
|
}
|
|
13229
|
-
return
|
|
13230
|
-
}
|
|
13231
|
-
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13232
|
-
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13233
|
-
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13234
|
-
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13235
|
-
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13236
|
-
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13237
|
-
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13238
|
-
var isDev = () => getNodeEnv() !== "production";
|
|
13239
|
-
function assertUnreachable(x) {
|
|
13240
|
-
throw new Error(`Unreachable case: ${x}`);
|
|
12976
|
+
return flattened;
|
|
13241
12977
|
}
|
|
13242
|
-
function
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
code = error46.code;
|
|
13256
|
-
message = error46.message;
|
|
13257
|
-
metadata = error46.metadata;
|
|
13258
|
-
rayId = error46.rayId;
|
|
13259
|
-
actor2 = error46.actor;
|
|
13260
|
-
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13261
|
-
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13262
|
-
public_ = true;
|
|
13263
|
-
group = error46.group;
|
|
13264
|
-
code = error46.code;
|
|
13265
|
-
message = getErrorMessage(error46);
|
|
13266
|
-
metadata = error46.metadata;
|
|
13267
|
-
rayId = error46.rayId;
|
|
13268
|
-
actor2 = error46.actor;
|
|
13269
|
-
} else if (exposeInternalError) {
|
|
13270
|
-
if (RivetError.isActorError(error46)) {
|
|
13271
|
-
statusCode = 500;
|
|
13272
|
-
public_ = false;
|
|
13273
|
-
group = error46.group;
|
|
13274
|
-
code = error46.code;
|
|
13275
|
-
message = getErrorMessage(error46);
|
|
13276
|
-
metadata = error46.metadata;
|
|
13277
|
-
rayId = error46.rayId;
|
|
13278
|
-
actor2 = error46.actor;
|
|
13279
|
-
} else {
|
|
13280
|
-
statusCode = 500;
|
|
13281
|
-
public_ = false;
|
|
13282
|
-
group = "rivetkit";
|
|
13283
|
-
code = INTERNAL_ERROR_CODE;
|
|
13284
|
-
message = getErrorMessage(error46);
|
|
12978
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
12979
|
+
if (schemas === void 0) return void 0;
|
|
12980
|
+
if (!isRecord(schemas)) {
|
|
12981
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
12982
|
+
}
|
|
12983
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
12984
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
12985
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
12986
|
+
const flatSchema = schemas[name];
|
|
12987
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
12988
|
+
throw new TypeError(
|
|
12989
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
12990
|
+
);
|
|
13285
12991
|
}
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
group = "rivetkit";
|
|
13290
|
-
code = INTERNAL_ERROR_CODE;
|
|
13291
|
-
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13292
|
-
if (RivetError.isActorError(error46)) {
|
|
13293
|
-
actor2 = error46.actor;
|
|
12992
|
+
const schema = nestedSchema ?? flatSchema;
|
|
12993
|
+
if (schema !== void 0) {
|
|
12994
|
+
flattened[name] = schema;
|
|
13294
12995
|
}
|
|
13295
|
-
metadata = {
|
|
13296
|
-
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13297
|
-
};
|
|
13298
12996
|
}
|
|
13299
|
-
return
|
|
13300
|
-
__type: "ActorError",
|
|
13301
|
-
statusCode,
|
|
13302
|
-
public: public_,
|
|
13303
|
-
group,
|
|
13304
|
-
code,
|
|
13305
|
-
message,
|
|
13306
|
-
metadata,
|
|
13307
|
-
rayId,
|
|
13308
|
-
actor: actor2
|
|
13309
|
-
};
|
|
12997
|
+
return flattened;
|
|
13310
12998
|
}
|
|
13311
|
-
function
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
12999
|
+
function flattenActionTraceSamplers(actions, rates = {}) {
|
|
13000
|
+
const handlers = flattenActionHandlers(actions);
|
|
13001
|
+
const flattened = Object.fromEntries(flattenSampleRates(rates, []));
|
|
13002
|
+
for (const name of Object.keys(flattened)) {
|
|
13003
|
+
if (!Object.hasOwn(handlers, name)) {
|
|
13004
|
+
throw new TypeError(
|
|
13005
|
+
`tracing.actions.${name} does not name an action`
|
|
13006
|
+
);
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
return flattened;
|
|
13010
|
+
}
|
|
13011
|
+
function flattenSampleRates(rates, path2) {
|
|
13012
|
+
return Object.entries(rates).flatMap(
|
|
13013
|
+
([segment, rate]) => {
|
|
13014
|
+
const childPath = [...path2, segment];
|
|
13015
|
+
return typeof rate === "number" ? [[childPath.join("."), rate]] : flattenSampleRates(rate, childPath);
|
|
13016
|
+
}
|
|
13017
|
+
);
|
|
13018
|
+
}
|
|
13019
|
+
function collectActionEntries(actions) {
|
|
13020
|
+
const entries = [];
|
|
13021
|
+
const names = /* @__PURE__ */ new Set();
|
|
13022
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
13023
|
+
return entries;
|
|
13024
|
+
}
|
|
13025
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
13026
|
+
if (!isRecord(value)) {
|
|
13027
|
+
throw new TypeError(
|
|
13028
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
13029
|
+
);
|
|
13030
|
+
}
|
|
13031
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
13032
|
+
const childPath = [...path2, segment];
|
|
13033
|
+
if (typeof child === "function") {
|
|
13034
|
+
const name = childPath.join(".");
|
|
13035
|
+
if (names.has(name)) {
|
|
13036
|
+
throw new TypeError(
|
|
13037
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
13038
|
+
);
|
|
13319
13039
|
}
|
|
13320
|
-
|
|
13321
|
-
|
|
13040
|
+
names.add(name);
|
|
13041
|
+
entries.push({
|
|
13042
|
+
name,
|
|
13043
|
+
path: childPath,
|
|
13044
|
+
handler: child
|
|
13045
|
+
});
|
|
13322
13046
|
} else {
|
|
13323
|
-
|
|
13047
|
+
visitActionGroup(child, childPath, entries, names);
|
|
13324
13048
|
}
|
|
13325
|
-
}
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
return
|
|
13049
|
+
}
|
|
13050
|
+
}
|
|
13051
|
+
function lookupNestedSchema(schemas, path2) {
|
|
13052
|
+
let value = schemas;
|
|
13053
|
+
for (const segment of path2) {
|
|
13054
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
13055
|
+
return void 0;
|
|
13332
13056
|
}
|
|
13333
|
-
|
|
13334
|
-
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13057
|
+
value = value[segment];
|
|
13335
13058
|
}
|
|
13059
|
+
return value;
|
|
13336
13060
|
}
|
|
13337
|
-
function
|
|
13338
|
-
if (
|
|
13339
|
-
return
|
|
13340
|
-
} else {
|
|
13341
|
-
return String(err);
|
|
13061
|
+
function isRecord(value) {
|
|
13062
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13063
|
+
return false;
|
|
13342
13064
|
}
|
|
13065
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13066
|
+
return prototype === Object.prototype || prototype === null;
|
|
13343
13067
|
}
|
|
13344
|
-
function
|
|
13345
|
-
return
|
|
13346
|
-
};
|
|
13068
|
+
function formatActionPath(path2) {
|
|
13069
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
13347
13070
|
}
|
|
13348
|
-
var
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
default: "./dist/tsup/db/drizzle.cjs"
|
|
13420
|
-
}
|
|
13421
|
-
},
|
|
13422
|
-
"./unstable/migrations": {
|
|
13423
|
-
import: {
|
|
13424
|
-
types: "./dist/tsup/unstable/migrations.d.ts",
|
|
13425
|
-
default: "./dist/tsup/unstable/migrations.js"
|
|
13426
|
-
},
|
|
13427
|
-
require: {
|
|
13428
|
-
types: "./dist/tsup/unstable/migrations.d.cts",
|
|
13429
|
-
default: "./dist/tsup/unstable/migrations.cjs"
|
|
13430
|
-
}
|
|
13431
|
-
},
|
|
13432
|
-
"./dynamic": {
|
|
13433
|
-
import: {
|
|
13434
|
-
types: "./dist/tsup/dynamic/mod.d.ts",
|
|
13435
|
-
default: "./dist/tsup/dynamic/mod.js"
|
|
13436
|
-
},
|
|
13437
|
-
require: {
|
|
13438
|
-
types: "./dist/tsup/dynamic/mod.d.cts",
|
|
13439
|
-
default: "./dist/tsup/dynamic/mod.cjs"
|
|
13440
|
-
}
|
|
13441
|
-
},
|
|
13442
|
-
"./client": {
|
|
13443
|
-
import: {
|
|
13444
|
-
browser: {
|
|
13445
|
-
types: "./dist/browser/client.d.ts",
|
|
13446
|
-
default: "./dist/browser/client.js"
|
|
13447
|
-
},
|
|
13448
|
-
types: "./dist/tsup/client/mod.d.ts",
|
|
13449
|
-
default: "./dist/tsup/client/mod.js"
|
|
13450
|
-
},
|
|
13451
|
-
require: {
|
|
13452
|
-
types: "./dist/tsup/client/mod.d.cts",
|
|
13453
|
-
default: "./dist/tsup/client/mod.cjs"
|
|
13454
|
-
}
|
|
13455
|
-
},
|
|
13456
|
-
"./log": {
|
|
13457
|
-
import: {
|
|
13458
|
-
types: "./dist/tsup/common/log.d.ts",
|
|
13459
|
-
default: "./dist/tsup/common/log.js"
|
|
13460
|
-
},
|
|
13461
|
-
require: {
|
|
13462
|
-
types: "./dist/tsup/common/log.d.cts",
|
|
13463
|
-
default: "./dist/tsup/common/log.cjs"
|
|
13464
|
-
}
|
|
13465
|
-
},
|
|
13466
|
-
"./errors": {
|
|
13467
|
-
import: {
|
|
13468
|
-
types: "./dist/tsup/actor/errors.d.ts",
|
|
13469
|
-
default: "./dist/tsup/actor/errors.js"
|
|
13470
|
-
},
|
|
13471
|
-
require: {
|
|
13472
|
-
types: "./dist/tsup/actor/errors.d.cts",
|
|
13473
|
-
default: "./dist/tsup/actor/errors.cjs"
|
|
13474
|
-
}
|
|
13475
|
-
},
|
|
13476
|
-
"./inspector": {
|
|
13477
|
-
import: {
|
|
13478
|
-
types: "./dist/tsup/inspector/mod.d.ts",
|
|
13479
|
-
default: "./dist/tsup/inspector/mod.js"
|
|
13480
|
-
},
|
|
13481
|
-
require: {
|
|
13482
|
-
types: "./dist/tsup/inspector/mod.d.cts",
|
|
13483
|
-
default: "./dist/tsup/inspector/mod.cjs"
|
|
13484
|
-
}
|
|
13485
|
-
},
|
|
13486
|
-
"./experimental/inspector/workflow": {
|
|
13487
|
-
import: {
|
|
13488
|
-
types: "./dist/tsup/inspector/workflow.d.ts",
|
|
13489
|
-
default: "./dist/tsup/inspector/workflow.js"
|
|
13490
|
-
},
|
|
13491
|
-
require: {
|
|
13492
|
-
types: "./dist/tsup/inspector/workflow.d.cts",
|
|
13493
|
-
default: "./dist/tsup/inspector/workflow.cjs"
|
|
13494
|
-
}
|
|
13495
|
-
},
|
|
13496
|
-
"./inspector-tab": {
|
|
13497
|
-
import: {
|
|
13498
|
-
types: "./dist/tsup/inspector-tab/mod.d.ts",
|
|
13499
|
-
default: "./dist/tsup/inspector-tab/mod.js"
|
|
13500
|
-
},
|
|
13501
|
-
require: {
|
|
13502
|
-
types: "./dist/tsup/inspector-tab/mod.d.cts",
|
|
13503
|
-
default: "./dist/tsup/inspector-tab/mod.cjs"
|
|
13504
|
-
}
|
|
13505
|
-
},
|
|
13506
|
-
"./inspector/client": {
|
|
13507
|
-
import: {
|
|
13508
|
-
types: "./dist/browser/inspector/client.d.ts",
|
|
13509
|
-
default: "./dist/browser/inspector/client.js"
|
|
13510
|
-
}
|
|
13511
|
-
},
|
|
13512
|
-
"./utils": {
|
|
13513
|
-
import: {
|
|
13514
|
-
types: "./dist/tsup/utils.d.ts",
|
|
13515
|
-
default: "./dist/tsup/utils.js"
|
|
13516
|
-
},
|
|
13517
|
-
require: {
|
|
13518
|
-
types: "./dist/tsup/utils.d.cts",
|
|
13519
|
-
default: "./dist/tsup/utils.cjs"
|
|
13520
|
-
}
|
|
13521
|
-
},
|
|
13522
|
-
"./agent-os": {
|
|
13523
|
-
import: {
|
|
13524
|
-
types: "./dist/tsup/agent-os/index.d.ts",
|
|
13525
|
-
default: "./dist/tsup/agent-os/index.js"
|
|
13526
|
-
},
|
|
13527
|
-
require: {
|
|
13528
|
-
types: "./dist/tsup/agent-os/index.d.cts",
|
|
13529
|
-
default: "./dist/tsup/agent-os/index.cjs"
|
|
13530
|
-
}
|
|
13531
|
-
}
|
|
13532
|
-
},
|
|
13533
|
-
engines: {
|
|
13534
|
-
node: ">=22.0.0"
|
|
13535
|
-
},
|
|
13536
|
-
sideEffects: [
|
|
13537
|
-
"./dist/tsup/chunk-*.js",
|
|
13538
|
-
"./dist/tsup/chunk-*.cjs"
|
|
13539
|
-
],
|
|
13540
|
-
scripts: {
|
|
13541
|
-
build: "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/utils.ts src/workflow/mod.ts src/test/mod.ts src/inspector/mod.ts src/inspector/workflow.ts src/inspector-tab/mod.ts src/db/mod.ts src/db/drizzle.ts src/dynamic/mod.ts src/unstable/migrations.ts && tsup src/agent-os/index.ts --no-clean --out-dir dist/tsup/agent-os && node scripts/check-built-commonjs.mjs",
|
|
13542
|
-
"build:browser": "tsup --config tsup.browser.config.ts",
|
|
13543
|
-
"check-types": "tsc --noEmit",
|
|
13544
|
-
lint: "biome check . && pnpm run check:test-skips && pnpm run check:wait-for-comments",
|
|
13545
|
-
"lint:fix": "biome check --write .",
|
|
13546
|
-
"check:test-skips": "tsx scripts/check-annotated-skips.ts",
|
|
13547
|
-
"check:wait-for-comments": "tsx scripts/check-wait-for-comments.ts",
|
|
13548
|
-
format: "biome format .",
|
|
13549
|
-
"format:write": "biome format --write .",
|
|
13550
|
-
test: "vitest run",
|
|
13551
|
-
"test:platforms": "pnpm run build && RIVETKIT_INCLUDE_PLATFORM_TESTS=1 vitest run tests/platforms --passWithNoTests",
|
|
13552
|
-
"test:watch": "vitest",
|
|
13553
|
-
"dump-asyncapi": "tsx scripts/dump-asyncapi.ts",
|
|
13554
|
-
"registry-config-schema-gen": "tsx scripts/registry-config-schema-gen.ts",
|
|
13555
|
-
"actor-config-schema-gen": "tsx scripts/actor-config-schema-gen.ts"
|
|
13556
|
-
},
|
|
13557
|
-
dependencies: {
|
|
13558
|
-
"@hono/zod-openapi": "^1.1.5",
|
|
13559
|
-
"@opentelemetry/api": "^1.1.0",
|
|
13560
|
-
"@rivet-dev/services": "^0.2.3",
|
|
13561
|
-
"@rivetkit/bare-ts": "^0.6.2",
|
|
13562
|
-
"@rivetkit/engine-api-full": "workspace:*",
|
|
13563
|
-
"@rivetkit/engine-cli": "workspace:*",
|
|
13564
|
-
"@rivetkit/engine-envoy-protocol": "workspace:*",
|
|
13565
|
-
"@rivetkit/on-change": "6.0.1",
|
|
13566
|
-
"@rivetkit/rivetkit-napi": "workspace:*",
|
|
13567
|
-
"@rivetkit/rivetkit-wasm": "workspace:*",
|
|
13568
|
-
"@rivetkit/traces": "workspace:*",
|
|
13569
|
-
"@rivetkit/virtual-websocket": "workspace:*",
|
|
13570
|
-
"@rivetkit/workflow-engine": "workspace:*",
|
|
13571
|
-
"cbor-x": "^1.6.0",
|
|
13572
|
-
"drizzle-orm": "catalog:",
|
|
13573
|
-
hono: "^4.7.0",
|
|
13574
|
-
invariant: "^2.2.4",
|
|
13575
|
-
"p-retry": "^6.2.1",
|
|
13576
|
-
pino: "^9.5.0",
|
|
13577
|
-
uuid: "^12.0.0",
|
|
13578
|
-
vbare: "^0.0.4",
|
|
13579
|
-
zod: "^4.1.0"
|
|
13580
|
-
},
|
|
13581
|
-
devDependencies: {
|
|
13582
|
-
"@biomejs/biome": "^2.3",
|
|
13583
|
-
"@copilotkit/llmock": "^1.6.0",
|
|
13584
|
-
"@hono/node-server": "^1.18.2",
|
|
13585
|
-
"@hono/node-ws": "^1.1.1",
|
|
13586
|
-
"@opentelemetry/sdk-trace-node": "2.11.0",
|
|
13587
|
-
"@standard-schema/spec": "^1.0.0",
|
|
13588
|
-
"@types/invariant": "^2",
|
|
13589
|
-
"@types/node": "^22.13.1",
|
|
13590
|
-
eventsource: "^4.0.0",
|
|
13591
|
-
"get-port": "^7.1.0",
|
|
13592
|
-
tsup: "^8.4.0",
|
|
13593
|
-
tsx: "^4.19.4",
|
|
13594
|
-
typescript: "^5.7.3",
|
|
13595
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
13596
|
-
vitest: "^3.1.1",
|
|
13597
|
-
ws: "^8.18.1"
|
|
13071
|
+
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
13072
|
+
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
13073
|
+
"rivetkit.actor_context_internal"
|
|
13074
|
+
);
|
|
13075
|
+
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
13076
|
+
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
13077
|
+
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
13078
|
+
var zActionTree = external_exports.custom((value) => {
|
|
13079
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
13080
|
+
return false;
|
|
13081
|
+
}
|
|
13082
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13083
|
+
return prototype === Object.prototype || prototype === null;
|
|
13084
|
+
}).superRefine((actions, ctx) => {
|
|
13085
|
+
try {
|
|
13086
|
+
flattenActionHandlers(actions);
|
|
13087
|
+
} catch (error46) {
|
|
13088
|
+
ctx.addIssue({
|
|
13089
|
+
code: "custom",
|
|
13090
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
13091
|
+
});
|
|
13092
|
+
}
|
|
13093
|
+
});
|
|
13094
|
+
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
13095
|
+
getHistory: zFunction(),
|
|
13096
|
+
getState: zFunction().optional(),
|
|
13097
|
+
onHistoryUpdated: zFunction().optional(),
|
|
13098
|
+
replayFromStep: zFunction().optional()
|
|
13099
|
+
});
|
|
13100
|
+
var RunInspectorConfigSchema = external_exports.object({
|
|
13101
|
+
workflow: WorkflowInspectorConfigSchema.optional()
|
|
13102
|
+
}).optional();
|
|
13103
|
+
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
13104
|
+
"workflow",
|
|
13105
|
+
"database",
|
|
13106
|
+
"state",
|
|
13107
|
+
"queue",
|
|
13108
|
+
"schedules",
|
|
13109
|
+
"connections",
|
|
13110
|
+
"console"
|
|
13111
|
+
];
|
|
13112
|
+
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13113
|
+
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
13114
|
+
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
13115
|
+
id: external_exports.string().regex(
|
|
13116
|
+
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
13117
|
+
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
13118
|
+
),
|
|
13119
|
+
label: external_exports.string().min(1),
|
|
13120
|
+
source: external_exports.string().min(1),
|
|
13121
|
+
/**
|
|
13122
|
+
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
13123
|
+
* icon registry); unknown ids fall back to a generic icon.
|
|
13124
|
+
*/
|
|
13125
|
+
icon: external_exports.string().min(1).optional(),
|
|
13126
|
+
hidden: external_exports.literal(false).optional()
|
|
13127
|
+
}).strict();
|
|
13128
|
+
var HideInspectorTabEntrySchema = external_exports.object({
|
|
13129
|
+
id: BuiltinInspectorTabIdSchema,
|
|
13130
|
+
hidden: external_exports.literal(true)
|
|
13131
|
+
}).strict();
|
|
13132
|
+
var InspectorTabEntrySchema = external_exports.union([
|
|
13133
|
+
CustomInspectorTabEntrySchema,
|
|
13134
|
+
HideInspectorTabEntrySchema
|
|
13135
|
+
]);
|
|
13136
|
+
var ActorInspectorConfigSchema = external_exports.object({
|
|
13137
|
+
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
13138
|
+
}).strict().refine(
|
|
13139
|
+
(data) => {
|
|
13140
|
+
const ids = data.tabs.map((t) => t.id);
|
|
13141
|
+
return new Set(ids).size === ids.length;
|
|
13598
13142
|
},
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13143
|
+
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
13144
|
+
).refine(
|
|
13145
|
+
(data) => {
|
|
13146
|
+
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
13147
|
+
return data.tabs.every(
|
|
13148
|
+
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
13149
|
+
);
|
|
13603
13150
|
},
|
|
13604
|
-
|
|
13605
|
-
"
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13151
|
+
{
|
|
13152
|
+
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
13153
|
+
path: ["tabs"]
|
|
13154
|
+
}
|
|
13155
|
+
);
|
|
13156
|
+
var RunConfigSchema = external_exports.object({
|
|
13157
|
+
/** Display name for the actor in the Inspector UI. */
|
|
13158
|
+
name: external_exports.string().optional(),
|
|
13159
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13160
|
+
icon: external_exports.string().optional(),
|
|
13161
|
+
/** The run handler function. */
|
|
13162
|
+
run: zFunction(),
|
|
13163
|
+
/** Inspector integration for long-running run handlers. */
|
|
13164
|
+
inspector: RunInspectorConfigSchema.optional()
|
|
13165
|
+
});
|
|
13166
|
+
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
13167
|
+
function defineRunHandler(run, options) {
|
|
13168
|
+
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
13169
|
+
throw new TypeError(
|
|
13170
|
+
"defineRunHandler requires inspectorKind and createInspector together"
|
|
13171
|
+
);
|
|
13172
|
+
}
|
|
13173
|
+
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
13174
|
+
configurable: false,
|
|
13175
|
+
enumerable: false,
|
|
13176
|
+
writable: false,
|
|
13177
|
+
value: {
|
|
13178
|
+
name: options.name,
|
|
13179
|
+
icon: options.icon,
|
|
13180
|
+
inspectorKind: options.inspectorKind,
|
|
13181
|
+
createInspector: options.createInspector
|
|
13613
13182
|
}
|
|
13614
|
-
}
|
|
13615
|
-
|
|
13616
|
-
}
|
|
13617
|
-
|
|
13618
|
-
var
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
"
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
if (
|
|
13631
|
-
|
|
13183
|
+
});
|
|
13184
|
+
return run;
|
|
13185
|
+
}
|
|
13186
|
+
function getRunInspectorKind(run) {
|
|
13187
|
+
var _a2;
|
|
13188
|
+
if (!run || typeof run !== "function") return void 0;
|
|
13189
|
+
return (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.inspectorKind;
|
|
13190
|
+
}
|
|
13191
|
+
function createRunInspector(run, context2) {
|
|
13192
|
+
var _a2, _b;
|
|
13193
|
+
if (!run || typeof run !== "function") return void 0;
|
|
13194
|
+
return (_b = (_a2 = run[RUN_FUNCTION_CONFIG_SYMBOL]) == null ? void 0 : _a2.createInspector) == null ? void 0 : _b.call(_a2, context2);
|
|
13195
|
+
}
|
|
13196
|
+
var zRunHandler = external_exports.union([zFunction(), RunConfigSchema]).optional();
|
|
13197
|
+
function getRunFunction(run) {
|
|
13198
|
+
if (!run) return void 0;
|
|
13199
|
+
if (typeof run === "function") return run;
|
|
13200
|
+
return run.run;
|
|
13201
|
+
}
|
|
13202
|
+
function getRunMetadata(run) {
|
|
13203
|
+
if (!run) return {};
|
|
13204
|
+
if (typeof run === "function") {
|
|
13205
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13206
|
+
if (!config3) return {};
|
|
13207
|
+
return { name: config3.name, icon: config3.icon };
|
|
13208
|
+
}
|
|
13209
|
+
return { name: run.name, icon: run.icon };
|
|
13210
|
+
}
|
|
13211
|
+
function getRunInspectorConfig(run, actor2) {
|
|
13212
|
+
if (!run) return void 0;
|
|
13213
|
+
if (typeof run === "function") {
|
|
13214
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13215
|
+
return (config3 == null ? void 0 : config3.inspectorFactory) ? config3.inspectorFactory(actor2) : config3 == null ? void 0 : config3.inspector;
|
|
13216
|
+
}
|
|
13217
|
+
return run.inspector;
|
|
13218
|
+
}
|
|
13219
|
+
function hasRunInspectorConfig(run) {
|
|
13220
|
+
if (!run) return false;
|
|
13221
|
+
if (typeof run !== "function") return run.inspector !== void 0;
|
|
13222
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13223
|
+
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;
|
|
13224
|
+
}
|
|
13225
|
+
function disposeRunInspector(run, actorId) {
|
|
13226
|
+
var _a2;
|
|
13227
|
+
if (!run || typeof run !== "function") {
|
|
13228
|
+
return;
|
|
13229
|
+
}
|
|
13230
|
+
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
13231
|
+
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
13232
|
+
}
|
|
13233
|
+
var GlobalActorOptionsBaseSchema = external_exports.object({
|
|
13234
|
+
/** Display name for the actor in the Inspector UI. */
|
|
13235
|
+
name: external_exports.string().optional(),
|
|
13236
|
+
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
13237
|
+
icon: external_exports.string().optional(),
|
|
13238
|
+
/** Enables the experimental Actor Runtime Socket for this actor. */
|
|
13239
|
+
enableActorRuntimeSocket: external_exports.boolean().default(false),
|
|
13240
|
+
/**
|
|
13241
|
+
* Can hibernate WebSockets, both client connections for actions and
|
|
13242
|
+
* events and WebSockets for onWebSocket. A WebSocket that does not
|
|
13243
|
+
* hibernate closes when the actor sleeps, and the client reconnects.
|
|
13244
|
+
*
|
|
13245
|
+
* @experimental
|
|
13246
|
+
**/
|
|
13247
|
+
canHibernateWebSocket: external_exports.union([external_exports.boolean(), zFunction()]).default(false)
|
|
13248
|
+
}).strict();
|
|
13249
|
+
var GlobalActorOptionsSchema = GlobalActorOptionsBaseSchema.prefault(
|
|
13250
|
+
() => ({})
|
|
13251
|
+
);
|
|
13252
|
+
var InstanceActorOptionsBaseSchema = external_exports.object({
|
|
13253
|
+
createVarsTimeout: external_exports.number().positive().default(5e3),
|
|
13254
|
+
createConnStateTimeout: external_exports.number().positive().default(5e3),
|
|
13255
|
+
onBeforeConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13256
|
+
onConnectTimeout: external_exports.number().positive().default(5e3),
|
|
13257
|
+
onMigrateTimeout: external_exports.number().positive().default(3e4),
|
|
13258
|
+
sleepGracePeriod: external_exports.number().positive().default(DEFAULT_SLEEP_GRACE_PERIOD),
|
|
13259
|
+
/** @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. */
|
|
13260
|
+
onDestroyTimeout: external_exports.number().positive().optional(),
|
|
13261
|
+
/** @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. */
|
|
13262
|
+
waitUntilTimeout: external_exports.number().positive().optional(),
|
|
13263
|
+
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
13264
|
+
actionTimeout: external_exports.number().positive().default(6e4),
|
|
13265
|
+
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
13266
|
+
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
13267
|
+
/** @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. */
|
|
13268
|
+
noSleep: external_exports.boolean().default(false),
|
|
13269
|
+
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
13270
|
+
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
13271
|
+
/** Maximum pending one-shot and recurring schedules. */
|
|
13272
|
+
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
13273
|
+
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
13274
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13275
|
+
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
13276
|
+
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
13277
|
+
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
13278
|
+
}).strict();
|
|
13279
|
+
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
13280
|
+
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
13281
|
+
InstanceActorOptionsBaseSchema.shape
|
|
13282
|
+
).strict().prefault(() => ({}));
|
|
13283
|
+
var zSampleRate = external_exports.number().min(0).max(1);
|
|
13284
|
+
var zActionSampleRates = external_exports.lazy(
|
|
13285
|
+
() => external_exports.record(external_exports.string(), external_exports.union([zSampleRate, zActionSampleRates]))
|
|
13286
|
+
);
|
|
13287
|
+
var ActorConfigSchema = external_exports.object({
|
|
13288
|
+
onCreate: zFunction().optional(),
|
|
13289
|
+
onDestroy: zFunction().optional(),
|
|
13290
|
+
onMigrate: zFunction().optional(),
|
|
13291
|
+
onWake: zFunction().optional(),
|
|
13292
|
+
onSleep: zFunction().optional(),
|
|
13293
|
+
run: zRunHandler,
|
|
13294
|
+
onStateChange: zFunction().optional(),
|
|
13295
|
+
onBeforeConnect: zFunction().optional(),
|
|
13296
|
+
onConnect: zFunction().optional(),
|
|
13297
|
+
onDisconnect: zFunction().optional(),
|
|
13298
|
+
onBeforeActionResponse: zFunction().optional(),
|
|
13299
|
+
onRequest: zFunction().optional(),
|
|
13300
|
+
onWebSocket: zFunction().optional(),
|
|
13301
|
+
actions: zActionTree.default(() => ({})),
|
|
13302
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13303
|
+
tracing: external_exports.object({
|
|
13304
|
+
sampler: zSampleRate.optional(),
|
|
13305
|
+
actions: zActionSampleRates.optional()
|
|
13306
|
+
}).strict().optional(),
|
|
13307
|
+
connParamsSchema: external_exports.any().optional(),
|
|
13308
|
+
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13309
|
+
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
13310
|
+
state: external_exports.any().optional(),
|
|
13311
|
+
createState: zFunction().optional(),
|
|
13312
|
+
connState: external_exports.any().optional(),
|
|
13313
|
+
createConnState: zFunction().optional(),
|
|
13314
|
+
vars: external_exports.any().optional(),
|
|
13315
|
+
db: external_exports.any().optional(),
|
|
13316
|
+
createVars: zFunction().optional(),
|
|
13317
|
+
options: ActorOptionsSchema,
|
|
13318
|
+
inspector: ActorInspectorConfigSchema.optional()
|
|
13319
|
+
}).strict().refine(
|
|
13320
|
+
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
13321
|
+
{
|
|
13322
|
+
message: "Cannot define both 'state' and 'createState'",
|
|
13323
|
+
path: ["state"]
|
|
13324
|
+
}
|
|
13325
|
+
).refine(
|
|
13326
|
+
(data) => !(data.connState !== void 0 && data.createConnState !== void 0),
|
|
13327
|
+
{
|
|
13328
|
+
message: "Cannot define both 'connState' and 'createConnState'",
|
|
13329
|
+
path: ["connState"]
|
|
13632
13330
|
}
|
|
13633
|
-
|
|
13634
|
-
|
|
13331
|
+
).refine(
|
|
13332
|
+
(data) => !(data.vars !== void 0 && data.createVars !== void 0),
|
|
13333
|
+
{
|
|
13334
|
+
message: "Cannot define both 'vars' and 'createVars'",
|
|
13335
|
+
path: ["vars"]
|
|
13635
13336
|
}
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13337
|
+
);
|
|
13338
|
+
var DocActorOptionsSchema = external_exports.object({
|
|
13339
|
+
name: external_exports.string().optional().describe("Display name for the actor in the Inspector UI."),
|
|
13340
|
+
icon: external_exports.string().optional().describe(
|
|
13341
|
+
"Icon for the actor in the Inspector UI. Can be an emoji (e.g., '\u{1F680}') or FontAwesome icon name (e.g., 'rocket')."
|
|
13342
|
+
),
|
|
13343
|
+
enableActorRuntimeSocket: external_exports.boolean().optional().describe(
|
|
13344
|
+
"Enables the experimental Actor Runtime Socket for this actor. Default: false"
|
|
13345
|
+
),
|
|
13346
|
+
createVarsTimeout: external_exports.number().optional().describe("Timeout in ms for createVars handler. Default: 5000"),
|
|
13347
|
+
createConnStateTimeout: external_exports.number().optional().describe(
|
|
13348
|
+
"Timeout in ms for createConnState handler. Default: 5000"
|
|
13349
|
+
),
|
|
13350
|
+
onMigrateTimeout: external_exports.number().optional().describe("Timeout in ms for onMigrate handler. Default: 30000"),
|
|
13351
|
+
onBeforeConnectTimeout: external_exports.number().optional().describe(
|
|
13352
|
+
"Timeout in ms for onBeforeConnect handler. Default: 5000"
|
|
13353
|
+
),
|
|
13354
|
+
onConnectTimeout: external_exports.number().optional().describe("Timeout in ms for onConnect handler. Default: 5000"),
|
|
13355
|
+
sleepGracePeriod: external_exports.number().optional().describe(
|
|
13356
|
+
`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}.`
|
|
13357
|
+
),
|
|
13358
|
+
onDestroyTimeout: external_exports.number().optional().describe(
|
|
13359
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13360
|
+
),
|
|
13361
|
+
waitUntilTimeout: external_exports.number().optional().describe(
|
|
13362
|
+
"Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0."
|
|
13363
|
+
),
|
|
13364
|
+
stateSaveInterval: external_exports.number().optional().describe(
|
|
13365
|
+
"Interval in ms between automatic state saves. Default: 1000"
|
|
13366
|
+
),
|
|
13367
|
+
actionTimeout: external_exports.number().optional().describe("Timeout in ms for action handlers. Default: 60000"),
|
|
13368
|
+
connectionLivenessTimeout: external_exports.number().optional().describe(
|
|
13369
|
+
"Timeout in ms for connection liveness checks. Default: 2500"
|
|
13370
|
+
),
|
|
13371
|
+
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
13372
|
+
"Interval in ms between connection liveness checks. Default: 5000"
|
|
13373
|
+
),
|
|
13374
|
+
noSleep: external_exports.boolean().optional().describe(
|
|
13375
|
+
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
13376
|
+
),
|
|
13377
|
+
sleepTimeout: external_exports.number().optional().describe(
|
|
13378
|
+
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
13379
|
+
),
|
|
13380
|
+
maxQueueSize: external_exports.number().optional().describe(
|
|
13381
|
+
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
13382
|
+
),
|
|
13383
|
+
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
13384
|
+
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
13385
|
+
),
|
|
13386
|
+
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
13387
|
+
"Maximum size of each queue message in bytes. Default: 65536"
|
|
13388
|
+
),
|
|
13389
|
+
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
13390
|
+
"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"
|
|
13391
|
+
)
|
|
13392
|
+
}).describe("Actor options for timeouts and behavior configuration.");
|
|
13393
|
+
var DocActorConfigSchema = external_exports.object({
|
|
13394
|
+
state: external_exports.unknown().optional().describe(
|
|
13395
|
+
"Initial state value for the actor. Cannot be used with createState."
|
|
13396
|
+
),
|
|
13397
|
+
createState: external_exports.unknown().optional().describe(
|
|
13398
|
+
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
13399
|
+
),
|
|
13400
|
+
connState: external_exports.unknown().optional().describe(
|
|
13401
|
+
"Initial connection state value. Cannot be used with createConnState."
|
|
13402
|
+
),
|
|
13403
|
+
createConnState: external_exports.unknown().optional().describe(
|
|
13404
|
+
"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."
|
|
13405
|
+
),
|
|
13406
|
+
vars: external_exports.unknown().optional().describe(
|
|
13407
|
+
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
13408
|
+
),
|
|
13409
|
+
createVars: external_exports.unknown().optional().describe(
|
|
13410
|
+
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
13411
|
+
),
|
|
13412
|
+
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
13413
|
+
onCreate: external_exports.unknown().optional().describe(
|
|
13414
|
+
"Called when the actor is first initialized. Use to initialize state."
|
|
13415
|
+
),
|
|
13416
|
+
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
13417
|
+
onMigrate: external_exports.unknown().optional().describe(
|
|
13418
|
+
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
13419
|
+
),
|
|
13420
|
+
onWake: external_exports.unknown().optional().describe(
|
|
13421
|
+
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
13422
|
+
),
|
|
13423
|
+
onSleep: external_exports.unknown().optional().describe(
|
|
13424
|
+
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
13425
|
+
),
|
|
13426
|
+
run: external_exports.unknown().optional().describe(
|
|
13427
|
+
"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."
|
|
13428
|
+
),
|
|
13429
|
+
onStateChange: external_exports.unknown().optional().describe(
|
|
13430
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
13431
|
+
),
|
|
13432
|
+
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
13433
|
+
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
13434
|
+
),
|
|
13435
|
+
onConnect: external_exports.unknown().optional().describe(
|
|
13436
|
+
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
13437
|
+
),
|
|
13438
|
+
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
13439
|
+
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
13440
|
+
"Called before sending an action response. Use to transform output."
|
|
13441
|
+
),
|
|
13442
|
+
onRequest: external_exports.unknown().optional().describe(
|
|
13443
|
+
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
13444
|
+
),
|
|
13445
|
+
onWebSocket: external_exports.unknown().optional().describe(
|
|
13446
|
+
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
13447
|
+
),
|
|
13448
|
+
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13449
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
13450
|
+
),
|
|
13451
|
+
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
13452
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
13453
|
+
),
|
|
13454
|
+
tracing: external_exports.unknown().optional().describe(
|
|
13455
|
+
"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."
|
|
13456
|
+
),
|
|
13457
|
+
connParamsSchema: external_exports.unknown().optional().describe(
|
|
13458
|
+
"Optional schema for validating connection params in native runtimes."
|
|
13459
|
+
),
|
|
13460
|
+
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
13461
|
+
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
13462
|
+
options: DocActorOptionsSchema.optional()
|
|
13463
|
+
}).describe("Actor configuration passed to the actor() function.");
|
|
13464
|
+
|
|
13465
|
+
// ../rivetkit/dist/tsup/chunk-ZOVJDAOW.js
|
|
13466
|
+
var INTERNAL_ERROR_CODE = "internal_error";
|
|
13467
|
+
var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
|
|
13468
|
+
var USER_ERROR_CODE = "user_error";
|
|
13469
|
+
var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
|
|
13470
|
+
function looksLikeRivetErrorOptions(value) {
|
|
13471
|
+
return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
|
|
13472
|
+
}
|
|
13473
|
+
function isTypedErrorTag(value) {
|
|
13474
|
+
return value === "ActorError" || value === "RivetError";
|
|
13475
|
+
}
|
|
13476
|
+
function errorMessage(error46, fallback = String(error46)) {
|
|
13477
|
+
if (error46 && typeof error46 === "object" && "message" in error46 && typeof error46.message === "string") {
|
|
13478
|
+
return error46.message;
|
|
13640
13479
|
}
|
|
13641
|
-
return
|
|
13480
|
+
return fallback;
|
|
13642
13481
|
}
|
|
13643
|
-
function
|
|
13644
|
-
return
|
|
13482
|
+
function isRivetErrorLike(error46) {
|
|
13483
|
+
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));
|
|
13645
13484
|
}
|
|
13646
|
-
function
|
|
13647
|
-
|
|
13648
|
-
loggerCache.clear();
|
|
13485
|
+
function isActorAbortedError(error46) {
|
|
13486
|
+
return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
|
|
13649
13487
|
}
|
|
13650
|
-
function
|
|
13651
|
-
return
|
|
13488
|
+
function isActorSpecifier(value) {
|
|
13489
|
+
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");
|
|
13490
|
+
}
|
|
13491
|
+
var RivetError = class extends Error {
|
|
13492
|
+
__type = "RivetError";
|
|
13493
|
+
public;
|
|
13494
|
+
metadata;
|
|
13495
|
+
rayId;
|
|
13496
|
+
statusCode;
|
|
13497
|
+
actor;
|
|
13498
|
+
group;
|
|
13499
|
+
code;
|
|
13500
|
+
static isRivetError(error46) {
|
|
13501
|
+
return isRivetErrorLike(error46);
|
|
13502
|
+
}
|
|
13503
|
+
static isActorError(error46) {
|
|
13504
|
+
return isRivetErrorLike(error46);
|
|
13505
|
+
}
|
|
13506
|
+
constructor(group, code, message, options) {
|
|
13507
|
+
const normalized = looksLikeRivetErrorOptions(options) ? options : { metadata: options };
|
|
13508
|
+
super(message, { cause: normalized.cause });
|
|
13509
|
+
this.name = "RivetError";
|
|
13510
|
+
this.group = group;
|
|
13511
|
+
this.code = code;
|
|
13512
|
+
this.public = normalized.public ?? false;
|
|
13513
|
+
this.metadata = normalized.metadata;
|
|
13514
|
+
this.rayId = normalized.rayId ?? void 0;
|
|
13515
|
+
this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
|
|
13516
|
+
this.actor = normalized.actor;
|
|
13517
|
+
}
|
|
13518
|
+
toString() {
|
|
13519
|
+
return this.message;
|
|
13520
|
+
}
|
|
13521
|
+
};
|
|
13522
|
+
var UserError = class extends RivetError {
|
|
13523
|
+
constructor(message, options) {
|
|
13524
|
+
super("user", (options == null ? void 0 : options.code) ?? USER_ERROR_CODE, message, {
|
|
13525
|
+
public: true,
|
|
13526
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
13527
|
+
cause: options == null ? void 0 : options.cause
|
|
13528
|
+
});
|
|
13529
|
+
}
|
|
13530
|
+
};
|
|
13531
|
+
function toRivetError(error46, fallback) {
|
|
13532
|
+
if (typeof error46 === "string") {
|
|
13533
|
+
const bridged = decodeBridgeRivetError(error46);
|
|
13534
|
+
if (bridged) {
|
|
13535
|
+
return bridged;
|
|
13536
|
+
}
|
|
13537
|
+
}
|
|
13538
|
+
if (error46 instanceof Error) {
|
|
13539
|
+
const bridged = decodeBridgeRivetError(error46.message);
|
|
13540
|
+
if (bridged) {
|
|
13541
|
+
return bridged;
|
|
13542
|
+
}
|
|
13543
|
+
}
|
|
13544
|
+
if (isRivetErrorLike(error46)) {
|
|
13545
|
+
return new RivetError(error46.group, error46.code, error46.message, {
|
|
13546
|
+
public: error46.public,
|
|
13547
|
+
statusCode: error46.statusCode,
|
|
13548
|
+
metadata: error46.metadata,
|
|
13549
|
+
rayId: error46.rayId,
|
|
13550
|
+
actor: error46.actor,
|
|
13551
|
+
cause: error46 instanceof Error ? error46.cause : void 0
|
|
13552
|
+
});
|
|
13553
|
+
}
|
|
13554
|
+
return new RivetError(
|
|
13555
|
+
(fallback == null ? void 0 : fallback.group) ?? "actor",
|
|
13556
|
+
(fallback == null ? void 0 : fallback.code) ?? INTERNAL_ERROR_CODE,
|
|
13557
|
+
errorMessage(error46, (fallback == null ? void 0 : fallback.message) ?? "Unknown error"),
|
|
13652
13558
|
{
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
level(_label, number4) {
|
|
13661
|
-
return { level: number4 };
|
|
13662
|
-
}
|
|
13663
|
-
},
|
|
13664
|
-
timestamp: getLogTimestamp() ? stdTimeFunctions.epochTime : false
|
|
13665
|
-
},
|
|
13666
|
-
createLogfmtDestination()
|
|
13559
|
+
public: fallback == null ? void 0 : fallback.public,
|
|
13560
|
+
statusCode: fallback == null ? void 0 : fallback.statusCode,
|
|
13561
|
+
metadata: fallback == null ? void 0 : fallback.metadata,
|
|
13562
|
+
rayId: fallback == null ? void 0 : fallback.rayId,
|
|
13563
|
+
actor: fallback == null ? void 0 : fallback.actor,
|
|
13564
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
13565
|
+
}
|
|
13667
13566
|
);
|
|
13668
13567
|
}
|
|
13669
|
-
function
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13568
|
+
function encodeBridgeRivetError(error46) {
|
|
13569
|
+
const payload = {
|
|
13570
|
+
group: error46.group,
|
|
13571
|
+
code: error46.code,
|
|
13572
|
+
message: error46.message,
|
|
13573
|
+
metadata: error46.metadata,
|
|
13574
|
+
rayId: error46.rayId,
|
|
13575
|
+
public: error46.public,
|
|
13576
|
+
statusCode: error46.statusCode,
|
|
13577
|
+
actor: error46.actor
|
|
13578
|
+
};
|
|
13579
|
+
try {
|
|
13580
|
+
return {
|
|
13581
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify(payload)}`
|
|
13582
|
+
};
|
|
13583
|
+
} catch (cause) {
|
|
13584
|
+
return {
|
|
13585
|
+
encoded: `${BRIDGE_RIVET_ERROR_PREFIX}${JSON.stringify({ ...payload, metadata: void 0 })}`,
|
|
13586
|
+
droppedMetadataCause: cause
|
|
13587
|
+
};
|
|
13679
13588
|
}
|
|
13680
|
-
return baseLogger;
|
|
13681
13589
|
}
|
|
13682
|
-
function
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
return cached2;
|
|
13590
|
+
function encodeErrorForBridge(error46) {
|
|
13591
|
+
if (isCanonicalStructuredRivetError(error46)) {
|
|
13592
|
+
return encodeBridgeRivetError(error46).encoded;
|
|
13686
13593
|
}
|
|
13687
|
-
|
|
13688
|
-
const child = getIncludeTarget() ? base.child({ target: name }) : base;
|
|
13689
|
-
loggerCache.set(name, child);
|
|
13690
|
-
return child;
|
|
13594
|
+
return String(error46);
|
|
13691
13595
|
}
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
20: "debug",
|
|
13695
|
-
30: "info",
|
|
13696
|
-
40: "warn",
|
|
13697
|
-
50: "error",
|
|
13698
|
-
60: "fatal"
|
|
13699
|
-
};
|
|
13700
|
-
function createLogfmtDestination() {
|
|
13701
|
-
return {
|
|
13702
|
-
write(msg) {
|
|
13703
|
-
var _a2;
|
|
13704
|
-
const line = formatLogfmtLine(msg);
|
|
13705
|
-
if (typeof process !== "undefined" && ((_a2 = process.stdout) == null ? void 0 : _a2.write)) {
|
|
13706
|
-
process.stdout.write(`${line}
|
|
13707
|
-
`);
|
|
13708
|
-
} else {
|
|
13709
|
-
console.log(line);
|
|
13710
|
-
}
|
|
13711
|
-
}
|
|
13712
|
-
};
|
|
13596
|
+
function isCanonicalStructuredRivetError(error46) {
|
|
13597
|
+
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";
|
|
13713
13598
|
}
|
|
13714
|
-
function
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
data = JSON.parse(raw);
|
|
13718
|
-
} catch {
|
|
13719
|
-
return raw.trimEnd();
|
|
13720
|
-
}
|
|
13721
|
-
const parts = [];
|
|
13722
|
-
appendLogfmtEntry(parts, "level", formatPinoLevel(data.level));
|
|
13723
|
-
if (data.time !== void 0) {
|
|
13724
|
-
appendLogfmtEntry(parts, "ts", data.time);
|
|
13599
|
+
function decodeBridgeRivetErrorPayload(value) {
|
|
13600
|
+
if (!value.startsWith(BRIDGE_RIVET_ERROR_PREFIX)) {
|
|
13601
|
+
return void 0;
|
|
13725
13602
|
}
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13603
|
+
try {
|
|
13604
|
+
const raw = JSON.parse(
|
|
13605
|
+
value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
|
|
13606
|
+
);
|
|
13607
|
+
const payload = {
|
|
13608
|
+
...raw,
|
|
13609
|
+
rayId: raw.rayId ?? void 0
|
|
13610
|
+
};
|
|
13611
|
+
if (!isRivetErrorLike(payload)) {
|
|
13612
|
+
return void 0;
|
|
13729
13613
|
}
|
|
13730
|
-
|
|
13614
|
+
if (payload.actor !== void 0 && payload.actor !== null && !isActorSpecifier(payload.actor)) {
|
|
13615
|
+
return void 0;
|
|
13616
|
+
}
|
|
13617
|
+
return payload;
|
|
13618
|
+
} catch {
|
|
13619
|
+
return void 0;
|
|
13731
13620
|
}
|
|
13732
|
-
return parts.join(" ");
|
|
13733
13621
|
}
|
|
13734
|
-
function
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
if (typeof level === "string") {
|
|
13739
|
-
return level.toLowerCase();
|
|
13622
|
+
function decodeBridgeRivetError(value) {
|
|
13623
|
+
const payload = decodeBridgeRivetErrorPayload(value);
|
|
13624
|
+
if (!payload) {
|
|
13625
|
+
return void 0;
|
|
13740
13626
|
}
|
|
13741
|
-
return
|
|
13627
|
+
return new RivetError(payload.group, payload.code, payload.message, {
|
|
13628
|
+
metadata: payload.metadata,
|
|
13629
|
+
rayId: payload.rayId,
|
|
13630
|
+
public: payload.public,
|
|
13631
|
+
statusCode: payload.statusCode,
|
|
13632
|
+
actor: payload.actor ?? void 0
|
|
13633
|
+
});
|
|
13742
13634
|
}
|
|
13743
|
-
function
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13635
|
+
function invalidRequest(error46) {
|
|
13636
|
+
return new RivetError(
|
|
13637
|
+
"request",
|
|
13638
|
+
"invalid",
|
|
13639
|
+
`Invalid request: ${errorMessage(error46, String(error46))}`,
|
|
13640
|
+
{
|
|
13641
|
+
public: true,
|
|
13642
|
+
cause: error46 instanceof Error ? error46 : void 0
|
|
13643
|
+
}
|
|
13644
|
+
);
|
|
13749
13645
|
}
|
|
13750
|
-
function
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
if (typeof value === "string") {
|
|
13758
|
-
return quoteLogfmtString(value);
|
|
13759
|
-
}
|
|
13760
|
-
return quoteLogfmtString(JSON.stringify(value));
|
|
13646
|
+
function actorNotFound(identifier) {
|
|
13647
|
+
return new RivetError(
|
|
13648
|
+
"actor",
|
|
13649
|
+
"not_found",
|
|
13650
|
+
identifier ? `Actor not found: ${identifier} (https://www.rivet.dev/docs/clients/javascript)` : "Actor not found (https://www.rivet.dev/docs/clients/javascript)",
|
|
13651
|
+
{ public: true }
|
|
13652
|
+
);
|
|
13761
13653
|
}
|
|
13762
|
-
function
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13654
|
+
function forbiddenError() {
|
|
13655
|
+
return new RivetError("auth", "forbidden", "Forbidden", {
|
|
13656
|
+
public: true,
|
|
13657
|
+
statusCode: 403
|
|
13658
|
+
});
|
|
13767
13659
|
}
|
|
13768
|
-
function
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
for (let i = 0; i < len; i++) {
|
|
13775
|
-
binary += String.fromCharCode(uint8Array[i]);
|
|
13776
|
-
}
|
|
13777
|
-
return btoa(binary);
|
|
13660
|
+
function unsupportedFeature(feature) {
|
|
13661
|
+
return new RivetError(
|
|
13662
|
+
"feature",
|
|
13663
|
+
"unsupported",
|
|
13664
|
+
`Unsupported feature: ${feature}`
|
|
13665
|
+
);
|
|
13778
13666
|
}
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13667
|
+
|
|
13668
|
+
// ../rivetkit/dist/tsup/chunk-3LLGBENU.js
|
|
13669
|
+
import {
|
|
13670
|
+
pino,
|
|
13671
|
+
stdTimeFunctions
|
|
13672
|
+
} from "pino";
|
|
13673
|
+
var import_invariant = __toESM(require_invariant(), 1);
|
|
13674
|
+
import * as cbor from "cbor-x";
|
|
13675
|
+
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
13676
|
+
var getRivetEndpoint = () => getEnvUniversal("RIVET_ENDPOINT");
|
|
13677
|
+
var getRivetToken = () => getEnvUniversal("RIVET_TOKEN");
|
|
13678
|
+
var getRivetNamespace = () => getEnvUniversal("RIVET_NAMESPACE");
|
|
13679
|
+
var getRivetPool = () => getEnvUniversal("RIVET_POOL");
|
|
13680
|
+
var getRivetTotalSlots = () => {
|
|
13681
|
+
const value = getEnvUniversal("RIVET_TOTAL_SLOTS");
|
|
13682
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13683
|
+
};
|
|
13684
|
+
var getRivetRunEngine = () => getEnvUniversal("RIVET_RUN_ENGINE") === "1";
|
|
13685
|
+
var getRivetRunEngineHost = () => getEnvUniversal("RIVET_RUN_ENGINE_HOST");
|
|
13686
|
+
var getRivetRunEnginePort = () => {
|
|
13687
|
+
const value = getEnvUniversal("RIVET_RUN_ENGINE_PORT");
|
|
13688
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13689
|
+
};
|
|
13690
|
+
var getRivetRunEngineVersion = () => getEnvUniversal("RIVET_RUN_ENGINE_VERSION");
|
|
13691
|
+
var getRivetRunServices = () => {
|
|
13692
|
+
const value = getEnvUniversal("RIVET_RUN_SERVICES");
|
|
13693
|
+
return value === void 0 ? void 0 : value === "1";
|
|
13694
|
+
};
|
|
13695
|
+
var getRivetEnvoyVersion = () => {
|
|
13696
|
+
const value = getEnvUniversal("RIVET_ENVOY_VERSION");
|
|
13697
|
+
return value !== void 0 ? parseInt(value, 10) : void 0;
|
|
13698
|
+
};
|
|
13699
|
+
var getRivetPublicEndpoint = () => getEnvUniversal("RIVET_PUBLIC_ENDPOINT");
|
|
13700
|
+
var getRivetPublicToken = () => getEnvUniversal("RIVET_PUBLIC_TOKEN");
|
|
13701
|
+
var getRivetkitRuntime = () => getEnvUniversal("RIVETKIT_RUNTIME");
|
|
13702
|
+
var getRivetkitRuntimeMode = () => {
|
|
13703
|
+
const value = getEnvUniversal("RIVETKIT_RUNTIME_MODE");
|
|
13704
|
+
if (value === void 0) return "envoy";
|
|
13705
|
+
if (value === "envoy" || value === "serverless") return value;
|
|
13706
|
+
throw new Error(
|
|
13707
|
+
`RIVETKIT_RUNTIME_MODE env var must be "envoy" or "serverless"; got "${value}"`
|
|
13708
|
+
);
|
|
13709
|
+
};
|
|
13710
|
+
var getRivetkitPublicDir = () => {
|
|
13711
|
+
const value = getEnvUniversal("RIVETKIT_PUBLIC_DIR");
|
|
13712
|
+
return value === void 0 || value === "" ? void 0 : value;
|
|
13713
|
+
};
|
|
13714
|
+
function parsePortEnv(raw) {
|
|
13715
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
13716
|
+
const parsed = Number.parseInt(raw, 10);
|
|
13717
|
+
if (!Number.isFinite(parsed) || parsed < 1 || parsed > 65535 || String(parsed) !== raw.trim()) {
|
|
13718
|
+
throw new Error(
|
|
13719
|
+
`RIVET_PORT env var must be an integer between 1 and 65535; got "${raw}"`
|
|
13720
|
+
);
|
|
13786
13721
|
}
|
|
13722
|
+
return parsed;
|
|
13787
13723
|
}
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13724
|
+
var getLogLevel = () => getEnvUniversal("RIVET_LOG_LEVEL") ?? getEnvUniversal("LOG_LEVEL");
|
|
13725
|
+
var getLogTarget = () => getEnvUniversal("RIVET_LOG_TARGET") === "1";
|
|
13726
|
+
var getLogTimestamp = () => getEnvUniversal("RIVET_LOG_TIMESTAMP") === "1";
|
|
13727
|
+
var getLogMessage = () => getEnvUniversal("RIVET_LOG_MESSAGE") === "1";
|
|
13728
|
+
var getLogErrorStack = () => getEnvUniversal("RIVET_LOG_ERROR_STACK") === "1";
|
|
13729
|
+
var getNodeEnv = () => getEnvUniversal("NODE_ENV");
|
|
13730
|
+
var getNextPhase = () => getEnvUniversal("NEXT_PHASE");
|
|
13731
|
+
var isDev = () => getNodeEnv() !== "production";
|
|
13732
|
+
function assertUnreachable(x) {
|
|
13733
|
+
throw new Error(`Unreachable case: ${x}`);
|
|
13793
13734
|
}
|
|
13794
|
-
function
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13735
|
+
function deconstructError(error46, exposeInternalError = false) {
|
|
13736
|
+
let statusCode;
|
|
13737
|
+
let public_;
|
|
13738
|
+
let group;
|
|
13739
|
+
let code;
|
|
13740
|
+
let message;
|
|
13741
|
+
let metadata;
|
|
13742
|
+
let rayId;
|
|
13743
|
+
let actor2;
|
|
13744
|
+
if (isCanonicalStructuredRivetError(error46)) {
|
|
13745
|
+
statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
|
|
13746
|
+
public_ = error46.public ?? false;
|
|
13747
|
+
group = error46.group;
|
|
13748
|
+
code = error46.code;
|
|
13749
|
+
message = error46.message;
|
|
13750
|
+
metadata = error46.metadata;
|
|
13751
|
+
rayId = error46.rayId;
|
|
13752
|
+
actor2 = error46.actor;
|
|
13753
|
+
} else if (RivetError.isActorError(error46) && error46.public) {
|
|
13754
|
+
statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
|
|
13755
|
+
public_ = true;
|
|
13756
|
+
group = error46.group;
|
|
13757
|
+
code = error46.code;
|
|
13758
|
+
message = getErrorMessage(error46);
|
|
13759
|
+
metadata = error46.metadata;
|
|
13760
|
+
rayId = error46.rayId;
|
|
13761
|
+
actor2 = error46.actor;
|
|
13762
|
+
} else if (exposeInternalError) {
|
|
13763
|
+
if (RivetError.isActorError(error46)) {
|
|
13764
|
+
statusCode = 500;
|
|
13765
|
+
public_ = false;
|
|
13766
|
+
group = error46.group;
|
|
13767
|
+
code = error46.code;
|
|
13768
|
+
message = getErrorMessage(error46);
|
|
13769
|
+
metadata = error46.metadata;
|
|
13770
|
+
rayId = error46.rayId;
|
|
13771
|
+
actor2 = error46.actor;
|
|
13772
|
+
} else {
|
|
13773
|
+
statusCode = 500;
|
|
13774
|
+
public_ = false;
|
|
13775
|
+
group = "rivetkit";
|
|
13776
|
+
code = INTERNAL_ERROR_CODE;
|
|
13777
|
+
message = getErrorMessage(error46);
|
|
13811
13778
|
}
|
|
13812
|
-
const bareValue = toBare(value);
|
|
13813
|
-
return versionedDataHandler.serializeWithEmbeddedVersion(
|
|
13814
|
-
bareValue,
|
|
13815
|
-
version2
|
|
13816
|
-
);
|
|
13817
13779
|
} else {
|
|
13818
|
-
|
|
13780
|
+
statusCode = 500;
|
|
13781
|
+
public_ = false;
|
|
13782
|
+
group = "rivetkit";
|
|
13783
|
+
code = INTERNAL_ERROR_CODE;
|
|
13784
|
+
message = INTERNAL_ERROR_DESCRIPTION;
|
|
13785
|
+
if (RivetError.isActorError(error46)) {
|
|
13786
|
+
actor2 = error46.actor;
|
|
13787
|
+
}
|
|
13788
|
+
metadata = {
|
|
13789
|
+
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
13790
|
+
};
|
|
13819
13791
|
}
|
|
13792
|
+
return {
|
|
13793
|
+
__type: "ActorError",
|
|
13794
|
+
statusCode,
|
|
13795
|
+
public: public_,
|
|
13796
|
+
group,
|
|
13797
|
+
code,
|
|
13798
|
+
message,
|
|
13799
|
+
metadata,
|
|
13800
|
+
rayId,
|
|
13801
|
+
actor: actor2
|
|
13802
|
+
};
|
|
13820
13803
|
}
|
|
13821
|
-
function
|
|
13822
|
-
if (
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13804
|
+
function stringifyError(error46) {
|
|
13805
|
+
if (error46 instanceof Error) {
|
|
13806
|
+
if (typeof process !== "undefined" && getLogErrorStack()) {
|
|
13807
|
+
let stack;
|
|
13808
|
+
try {
|
|
13809
|
+
stack = error46.stack;
|
|
13810
|
+
} catch {
|
|
13811
|
+
stack = void 0;
|
|
13812
|
+
}
|
|
13813
|
+
return `${error46.name}: ${error46.message}${stack ? `
|
|
13814
|
+
${stack}` : ""}`;
|
|
13826
13815
|
} else {
|
|
13827
|
-
|
|
13828
|
-
const jsonString = decoder.decode(buffer);
|
|
13829
|
-
parsed = jsonParseCompat(jsonString);
|
|
13816
|
+
return `${error46.name}: ${error46.message}`;
|
|
13830
13817
|
}
|
|
13831
|
-
|
|
13832
|
-
return
|
|
13833
|
-
} else if (
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
const decoded = decodeCborCompat(buffer);
|
|
13839
|
-
const validated = zodSchema.parse(decoded);
|
|
13840
|
-
return fromJson(validated);
|
|
13841
|
-
} else if (encoding === "bare") {
|
|
13842
|
-
(0, import_invariant.default)(
|
|
13843
|
-
typeof buffer !== "string",
|
|
13844
|
-
"buffer cannot be string for bare encoding"
|
|
13845
|
-
);
|
|
13846
|
-
if (!versionedDataHandler) {
|
|
13847
|
-
throw new Error(
|
|
13848
|
-
"VersionedDataHandler is required for 'bare' encoding"
|
|
13849
|
-
);
|
|
13818
|
+
} else if (typeof error46 === "string") {
|
|
13819
|
+
return error46;
|
|
13820
|
+
} else if (typeof error46 === "object" && error46 !== null) {
|
|
13821
|
+
try {
|
|
13822
|
+
return `${JSON.stringify(error46)}`;
|
|
13823
|
+
} catch {
|
|
13824
|
+
return "[cannot stringify error]";
|
|
13850
13825
|
}
|
|
13851
|
-
const bareValue = versionedDataHandler.deserializeWithEmbeddedVersion(buffer);
|
|
13852
|
-
return fromBare(bareValue);
|
|
13853
13826
|
} else {
|
|
13854
|
-
|
|
13827
|
+
return `Unknown error: ${getErrorMessage(error46)}`;
|
|
13855
13828
|
}
|
|
13856
13829
|
}
|
|
13857
|
-
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
|
|
13861
|
-
|
|
13862
|
-
function isTypedArray(value) {
|
|
13863
|
-
return value instanceof Uint8ClampedArray || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof BigUint64Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array || value instanceof BigInt64Array || value instanceof Float32Array || value instanceof Float64Array;
|
|
13864
|
-
}
|
|
13865
|
-
function assertJsonCompatValue(value, path2 = "") {
|
|
13866
|
-
var _a2;
|
|
13867
|
-
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
13868
|
-
return;
|
|
13869
|
-
}
|
|
13870
|
-
if (typeof value === "function") {
|
|
13871
|
-
throw new TypeError(
|
|
13872
|
-
`Value at ${path2 || "root"} is a function and is not CBOR serializable`
|
|
13873
|
-
);
|
|
13874
|
-
}
|
|
13875
|
-
if (typeof value === "symbol") {
|
|
13876
|
-
throw new TypeError(
|
|
13877
|
-
`Value at ${path2 || "root"} is a symbol and is not CBOR serializable`
|
|
13878
|
-
);
|
|
13879
|
-
}
|
|
13880
|
-
if (value instanceof Date || value instanceof RegExp || value instanceof Error || value instanceof ArrayBuffer || value instanceof Uint8Array || isTypedArray(value)) {
|
|
13881
|
-
return;
|
|
13882
|
-
}
|
|
13883
|
-
if (value instanceof WeakMap) {
|
|
13884
|
-
throw new TypeError(
|
|
13885
|
-
`Value at ${path2 || "root"} is a WeakMap and is not CBOR serializable`
|
|
13886
|
-
);
|
|
13887
|
-
}
|
|
13888
|
-
if (value instanceof WeakSet) {
|
|
13889
|
-
throw new TypeError(
|
|
13890
|
-
`Value at ${path2 || "root"} is a WeakSet and is not CBOR serializable`
|
|
13891
|
-
);
|
|
13892
|
-
}
|
|
13893
|
-
if (value instanceof WeakRef) {
|
|
13894
|
-
throw new TypeError(
|
|
13895
|
-
`Value at ${path2 || "root"} is a WeakRef and is not CBOR serializable`
|
|
13896
|
-
);
|
|
13897
|
-
}
|
|
13898
|
-
if (value instanceof Promise) {
|
|
13899
|
-
throw new TypeError(
|
|
13900
|
-
`Value at ${path2 || "root"} is a Promise and is not CBOR serializable`
|
|
13901
|
-
);
|
|
13902
|
-
}
|
|
13903
|
-
if (value instanceof Map) {
|
|
13904
|
-
for (const [k, v] of value.entries()) {
|
|
13905
|
-
assertJsonCompatValue(k, `${path2 || "root"}.key(${String(k)})`);
|
|
13906
|
-
assertJsonCompatValue(v, `${path2 || "root"}.value(${String(k)})`);
|
|
13907
|
-
}
|
|
13908
|
-
return;
|
|
13909
|
-
}
|
|
13910
|
-
if (value instanceof Set) {
|
|
13911
|
-
let index = 0;
|
|
13912
|
-
for (const item of value.values()) {
|
|
13913
|
-
assertJsonCompatValue(item, `${path2 || "root"}.set[${index}]`);
|
|
13914
|
-
index++;
|
|
13915
|
-
}
|
|
13916
|
-
return;
|
|
13830
|
+
function getErrorMessage(err) {
|
|
13831
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string") {
|
|
13832
|
+
return err.message;
|
|
13833
|
+
} else {
|
|
13834
|
+
return String(err);
|
|
13917
13835
|
}
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13836
|
+
}
|
|
13837
|
+
function noopNext() {
|
|
13838
|
+
return async () => {
|
|
13839
|
+
};
|
|
13840
|
+
}
|
|
13841
|
+
var package_default = {
|
|
13842
|
+
name: "rivetkit",
|
|
13843
|
+
version: "2.3.32",
|
|
13844
|
+
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13845
|
+
license: "Apache-2.0",
|
|
13846
|
+
keywords: [
|
|
13847
|
+
"rivetkit",
|
|
13848
|
+
"stateful",
|
|
13849
|
+
"serverless",
|
|
13850
|
+
"actors",
|
|
13851
|
+
"agents",
|
|
13852
|
+
"realtime",
|
|
13853
|
+
"websocket",
|
|
13854
|
+
"actors",
|
|
13855
|
+
"framework"
|
|
13856
|
+
],
|
|
13857
|
+
files: [
|
|
13858
|
+
"dist",
|
|
13859
|
+
"schemas",
|
|
13860
|
+
"src",
|
|
13861
|
+
"package.json"
|
|
13862
|
+
],
|
|
13863
|
+
type: "module",
|
|
13864
|
+
exports: {
|
|
13865
|
+
".": {
|
|
13866
|
+
import: {
|
|
13867
|
+
types: "./dist/tsup/mod.d.ts",
|
|
13868
|
+
default: "./dist/tsup/mod.js"
|
|
13869
|
+
},
|
|
13870
|
+
require: {
|
|
13871
|
+
types: "./dist/tsup/mod.d.cts",
|
|
13872
|
+
default: "./dist/tsup/mod.cjs"
|
|
13873
|
+
}
|
|
13874
|
+
},
|
|
13875
|
+
"./workflow": {
|
|
13876
|
+
import: {
|
|
13877
|
+
types: "./dist/tsup/workflow/mod.d.ts",
|
|
13878
|
+
default: "./dist/tsup/workflow/mod.js"
|
|
13879
|
+
},
|
|
13880
|
+
require: {
|
|
13881
|
+
types: "./dist/tsup/workflow/mod.d.cts",
|
|
13882
|
+
default: "./dist/tsup/workflow/mod.cjs"
|
|
13883
|
+
}
|
|
13884
|
+
},
|
|
13885
|
+
"./test": {
|
|
13886
|
+
import: {
|
|
13887
|
+
types: "./dist/tsup/test/mod.d.ts",
|
|
13888
|
+
default: "./dist/tsup/test/mod.js"
|
|
13889
|
+
},
|
|
13890
|
+
require: {
|
|
13891
|
+
types: "./dist/tsup/test/mod.d.cts",
|
|
13892
|
+
default: "./dist/tsup/test/mod.cjs"
|
|
13893
|
+
}
|
|
13894
|
+
},
|
|
13895
|
+
"./db": {
|
|
13896
|
+
import: {
|
|
13897
|
+
types: "./dist/tsup/db/mod.d.ts",
|
|
13898
|
+
default: "./dist/tsup/db/mod.js"
|
|
13899
|
+
},
|
|
13900
|
+
require: {
|
|
13901
|
+
types: "./dist/tsup/db/mod.d.cts",
|
|
13902
|
+
default: "./dist/tsup/db/mod.cjs"
|
|
13903
|
+
}
|
|
13904
|
+
},
|
|
13905
|
+
"./db/drizzle": {
|
|
13906
|
+
import: {
|
|
13907
|
+
types: "./dist/tsup/db/drizzle.d.ts",
|
|
13908
|
+
default: "./dist/tsup/db/drizzle.js"
|
|
13909
|
+
},
|
|
13910
|
+
require: {
|
|
13911
|
+
types: "./dist/tsup/db/drizzle.d.cts",
|
|
13912
|
+
default: "./dist/tsup/db/drizzle.cjs"
|
|
13913
|
+
}
|
|
13914
|
+
},
|
|
13915
|
+
"./unstable/migrations": {
|
|
13916
|
+
import: {
|
|
13917
|
+
types: "./dist/tsup/unstable/migrations.d.ts",
|
|
13918
|
+
default: "./dist/tsup/unstable/migrations.js"
|
|
13919
|
+
},
|
|
13920
|
+
require: {
|
|
13921
|
+
types: "./dist/tsup/unstable/migrations.d.cts",
|
|
13922
|
+
default: "./dist/tsup/unstable/migrations.cjs"
|
|
13923
|
+
}
|
|
13924
|
+
},
|
|
13925
|
+
"./dynamic": {
|
|
13926
|
+
import: {
|
|
13927
|
+
types: "./dist/tsup/dynamic/mod.d.ts",
|
|
13928
|
+
default: "./dist/tsup/dynamic/mod.js"
|
|
13929
|
+
},
|
|
13930
|
+
require: {
|
|
13931
|
+
types: "./dist/tsup/dynamic/mod.d.cts",
|
|
13932
|
+
default: "./dist/tsup/dynamic/mod.cjs"
|
|
13933
|
+
}
|
|
13934
|
+
},
|
|
13935
|
+
"./client": {
|
|
13936
|
+
import: {
|
|
13937
|
+
browser: {
|
|
13938
|
+
types: "./dist/browser/client.d.ts",
|
|
13939
|
+
default: "./dist/browser/client.js"
|
|
13940
|
+
},
|
|
13941
|
+
types: "./dist/tsup/client/mod.d.ts",
|
|
13942
|
+
default: "./dist/tsup/client/mod.js"
|
|
13943
|
+
},
|
|
13944
|
+
require: {
|
|
13945
|
+
types: "./dist/tsup/client/mod.d.cts",
|
|
13946
|
+
default: "./dist/tsup/client/mod.cjs"
|
|
13947
|
+
}
|
|
13948
|
+
},
|
|
13949
|
+
"./log": {
|
|
13950
|
+
import: {
|
|
13951
|
+
types: "./dist/tsup/common/log.d.ts",
|
|
13952
|
+
default: "./dist/tsup/common/log.js"
|
|
13953
|
+
},
|
|
13954
|
+
require: {
|
|
13955
|
+
types: "./dist/tsup/common/log.d.cts",
|
|
13956
|
+
default: "./dist/tsup/common/log.cjs"
|
|
13957
|
+
}
|
|
13958
|
+
},
|
|
13959
|
+
"./errors": {
|
|
13960
|
+
import: {
|
|
13961
|
+
types: "./dist/tsup/actor/errors.d.ts",
|
|
13962
|
+
default: "./dist/tsup/actor/errors.js"
|
|
13963
|
+
},
|
|
13964
|
+
require: {
|
|
13965
|
+
types: "./dist/tsup/actor/errors.d.cts",
|
|
13966
|
+
default: "./dist/tsup/actor/errors.cjs"
|
|
13967
|
+
}
|
|
13968
|
+
},
|
|
13969
|
+
"./inspector": {
|
|
13970
|
+
import: {
|
|
13971
|
+
types: "./dist/tsup/inspector/mod.d.ts",
|
|
13972
|
+
default: "./dist/tsup/inspector/mod.js"
|
|
13973
|
+
},
|
|
13974
|
+
require: {
|
|
13975
|
+
types: "./dist/tsup/inspector/mod.d.cts",
|
|
13976
|
+
default: "./dist/tsup/inspector/mod.cjs"
|
|
13977
|
+
}
|
|
13978
|
+
},
|
|
13979
|
+
"./experimental/inspector/workflow": {
|
|
13980
|
+
import: {
|
|
13981
|
+
types: "./dist/tsup/inspector/workflow.d.ts",
|
|
13982
|
+
default: "./dist/tsup/inspector/workflow.js"
|
|
13983
|
+
},
|
|
13984
|
+
require: {
|
|
13985
|
+
types: "./dist/tsup/inspector/workflow.d.cts",
|
|
13986
|
+
default: "./dist/tsup/inspector/workflow.cjs"
|
|
13987
|
+
}
|
|
13988
|
+
},
|
|
13989
|
+
"./inspector-tab": {
|
|
13990
|
+
import: {
|
|
13991
|
+
types: "./dist/tsup/inspector-tab/mod.d.ts",
|
|
13992
|
+
default: "./dist/tsup/inspector-tab/mod.js"
|
|
13993
|
+
},
|
|
13994
|
+
require: {
|
|
13995
|
+
types: "./dist/tsup/inspector-tab/mod.d.cts",
|
|
13996
|
+
default: "./dist/tsup/inspector-tab/mod.cjs"
|
|
13997
|
+
}
|
|
13998
|
+
},
|
|
13999
|
+
"./inspector/client": {
|
|
14000
|
+
import: {
|
|
14001
|
+
types: "./dist/browser/inspector/client.d.ts",
|
|
14002
|
+
default: "./dist/browser/inspector/client.js"
|
|
14003
|
+
}
|
|
14004
|
+
},
|
|
14005
|
+
"./utils": {
|
|
14006
|
+
import: {
|
|
14007
|
+
types: "./dist/tsup/utils.d.ts",
|
|
14008
|
+
default: "./dist/tsup/utils.js"
|
|
14009
|
+
},
|
|
14010
|
+
require: {
|
|
14011
|
+
types: "./dist/tsup/utils.d.cts",
|
|
14012
|
+
default: "./dist/tsup/utils.cjs"
|
|
14013
|
+
}
|
|
14014
|
+
},
|
|
14015
|
+
"./agent-os": {
|
|
14016
|
+
import: {
|
|
14017
|
+
types: "./dist/tsup/agent-os/index.d.ts",
|
|
14018
|
+
default: "./dist/tsup/agent-os/index.js"
|
|
14019
|
+
},
|
|
14020
|
+
require: {
|
|
14021
|
+
types: "./dist/tsup/agent-os/index.d.cts",
|
|
14022
|
+
default: "./dist/tsup/agent-os/index.cjs"
|
|
14023
|
+
}
|
|
13921
14024
|
}
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
14025
|
+
},
|
|
14026
|
+
engines: {
|
|
14027
|
+
node: ">=22.0.0"
|
|
14028
|
+
},
|
|
14029
|
+
sideEffects: [
|
|
14030
|
+
"./dist/tsup/chunk-*.js",
|
|
14031
|
+
"./dist/tsup/chunk-*.cjs"
|
|
14032
|
+
],
|
|
14033
|
+
scripts: {
|
|
14034
|
+
build: "tsup src/mod.ts src/client/mod.ts src/common/log.ts src/common/websocket.ts src/actor/errors.ts src/utils.ts src/workflow/mod.ts src/test/mod.ts src/inspector/mod.ts src/inspector/workflow.ts src/inspector-tab/mod.ts src/db/mod.ts src/db/drizzle.ts src/dynamic/mod.ts src/unstable/migrations.ts && tsup src/agent-os/index.ts --no-clean --out-dir dist/tsup/agent-os && node scripts/check-built-commonjs.mjs",
|
|
14035
|
+
"build:browser": "tsup --config tsup.browser.config.ts",
|
|
14036
|
+
"check-types": "tsc --noEmit",
|
|
14037
|
+
lint: "biome check . && pnpm run check:test-skips && pnpm run check:wait-for-comments",
|
|
14038
|
+
"lint:fix": "biome check --write .",
|
|
14039
|
+
"check:test-skips": "tsx scripts/check-annotated-skips.ts",
|
|
14040
|
+
"check:wait-for-comments": "tsx scripts/check-wait-for-comments.ts",
|
|
14041
|
+
format: "biome format .",
|
|
14042
|
+
"format:write": "biome format --write .",
|
|
14043
|
+
test: "vitest run",
|
|
14044
|
+
"test:platforms": "pnpm run build && RIVETKIT_INCLUDE_PLATFORM_TESTS=1 vitest run tests/platforms --passWithNoTests",
|
|
14045
|
+
"test:watch": "vitest",
|
|
14046
|
+
"dump-asyncapi": "tsx scripts/dump-asyncapi.ts",
|
|
14047
|
+
"registry-config-schema-gen": "tsx scripts/registry-config-schema-gen.ts",
|
|
14048
|
+
"actor-config-schema-gen": "tsx scripts/actor-config-schema-gen.ts"
|
|
14049
|
+
},
|
|
14050
|
+
dependencies: {
|
|
14051
|
+
"@hono/zod-openapi": "^1.1.5",
|
|
14052
|
+
"@opentelemetry/api": "^1.1.0",
|
|
14053
|
+
"@rivet-dev/services": "^0.2.3",
|
|
14054
|
+
"@rivetkit/bare-ts": "^0.6.2",
|
|
14055
|
+
"@rivetkit/engine-api-full": "workspace:*",
|
|
14056
|
+
"@rivetkit/engine-cli": "workspace:*",
|
|
14057
|
+
"@rivetkit/engine-envoy-protocol": "workspace:*",
|
|
14058
|
+
"@rivetkit/on-change": "6.0.1",
|
|
14059
|
+
"@rivetkit/rivetkit-napi": "workspace:*",
|
|
14060
|
+
"@rivetkit/rivetkit-wasm": "workspace:*",
|
|
14061
|
+
"@rivetkit/traces": "workspace:*",
|
|
14062
|
+
"@rivetkit/virtual-websocket": "workspace:*",
|
|
14063
|
+
"@rivetkit/workflow-engine": "workspace:*",
|
|
14064
|
+
"cbor-x": "^1.6.0",
|
|
14065
|
+
"drizzle-orm": "catalog:",
|
|
14066
|
+
hono: "^4.7.0",
|
|
14067
|
+
invariant: "^2.2.4",
|
|
14068
|
+
"p-retry": "^6.2.1",
|
|
14069
|
+
pino: "^9.5.0",
|
|
14070
|
+
uuid: "^12.0.0",
|
|
14071
|
+
vbare: "^0.0.4",
|
|
14072
|
+
zod: "^4.1.0"
|
|
14073
|
+
},
|
|
14074
|
+
devDependencies: {
|
|
14075
|
+
"@biomejs/biome": "^2.3",
|
|
14076
|
+
"@copilotkit/llmock": "^1.6.0",
|
|
14077
|
+
"@hono/node-server": "^1.18.2",
|
|
14078
|
+
"@hono/node-ws": "^1.1.1",
|
|
14079
|
+
"@opentelemetry/sdk-trace-node": "2.11.0",
|
|
14080
|
+
"@standard-schema/spec": "^1.0.0",
|
|
14081
|
+
"@types/invariant": "^2",
|
|
14082
|
+
"@types/node": "^22.13.1",
|
|
14083
|
+
eventsource: "^4.0.0",
|
|
14084
|
+
"get-port": "^7.1.0",
|
|
14085
|
+
tsup: "^8.4.0",
|
|
14086
|
+
tsx: "^4.19.4",
|
|
14087
|
+
typescript: "^5.7.3",
|
|
14088
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
14089
|
+
vitest: "^3.1.1",
|
|
14090
|
+
ws: "^8.18.1"
|
|
14091
|
+
},
|
|
14092
|
+
peerDependencies: {
|
|
14093
|
+
"drizzle-kit": "^0.31.2",
|
|
14094
|
+
eventsource: "^4.0.0",
|
|
14095
|
+
ws: "^8.0.0"
|
|
14096
|
+
},
|
|
14097
|
+
peerDependenciesMeta: {
|
|
14098
|
+
"drizzle-kit": {
|
|
14099
|
+
optional: true
|
|
14100
|
+
},
|
|
14101
|
+
eventsource: {
|
|
14102
|
+
optional: true
|
|
14103
|
+
},
|
|
14104
|
+
ws: {
|
|
14105
|
+
optional: true
|
|
13930
14106
|
}
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
14107
|
+
},
|
|
14108
|
+
stableVersion: "0.8.0"
|
|
14109
|
+
};
|
|
14110
|
+
var baseLogger;
|
|
14111
|
+
var configuredLogLevel;
|
|
14112
|
+
var loggerCache = /* @__PURE__ */ new Map();
|
|
14113
|
+
var LogLevelSchema = external_exports.enum([
|
|
14114
|
+
"trace",
|
|
14115
|
+
"debug",
|
|
14116
|
+
"info",
|
|
14117
|
+
"warn",
|
|
14118
|
+
"error",
|
|
14119
|
+
"fatal",
|
|
14120
|
+
"silent"
|
|
14121
|
+
]);
|
|
14122
|
+
function getPinoLevel(logLevel) {
|
|
14123
|
+
if (logLevel) {
|
|
14124
|
+
return logLevel;
|
|
13945
14125
|
}
|
|
13946
|
-
if (
|
|
13947
|
-
return
|
|
14126
|
+
if (configuredLogLevel) {
|
|
14127
|
+
return configuredLogLevel;
|
|
13948
14128
|
}
|
|
13949
|
-
|
|
13950
|
-
|
|
14129
|
+
const raw = (getLogLevel() || "warn").toString().toLowerCase();
|
|
14130
|
+
const parsed = LogLevelSchema.safeParse(raw);
|
|
14131
|
+
if (parsed.success) {
|
|
14132
|
+
return parsed.data;
|
|
13951
14133
|
}
|
|
13952
|
-
|
|
14134
|
+
return "info";
|
|
13953
14135
|
}
|
|
13954
|
-
function
|
|
13955
|
-
|
|
13956
|
-
for (const value of uint8Array) {
|
|
13957
|
-
binary += String.fromCharCode(value);
|
|
13958
|
-
}
|
|
13959
|
-
return btoa(binary);
|
|
14136
|
+
function getIncludeTarget() {
|
|
14137
|
+
return getLogTarget();
|
|
13960
14138
|
}
|
|
13961
|
-
function
|
|
13962
|
-
|
|
14139
|
+
function configureBaseLogger(logger23) {
|
|
14140
|
+
baseLogger = logger23;
|
|
14141
|
+
loggerCache.clear();
|
|
13963
14142
|
}
|
|
13964
|
-
function
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
|
|
14143
|
+
function makeDefaultLogger(logLevel) {
|
|
14144
|
+
return pino(
|
|
14145
|
+
{
|
|
14146
|
+
level: getPinoLevel(logLevel),
|
|
14147
|
+
messageKey: "msg",
|
|
14148
|
+
// Do not include pid/hostname in output
|
|
14149
|
+
base: {},
|
|
14150
|
+
errorKey: "error",
|
|
14151
|
+
// Keep the numeric level so the logfmt sink can match Pino's levels.
|
|
14152
|
+
formatters: {
|
|
14153
|
+
level(_label, number4) {
|
|
14154
|
+
return { level: number4 };
|
|
14155
|
+
}
|
|
14156
|
+
},
|
|
14157
|
+
timestamp: getLogTimestamp() ? stdTimeFunctions.epochTime : false
|
|
14158
|
+
},
|
|
14159
|
+
createLogfmtDestination()
|
|
14160
|
+
);
|
|
13970
14161
|
}
|
|
13971
|
-
function
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
return input;
|
|
13975
|
-
}
|
|
13976
|
-
if (input === void 0) {
|
|
13977
|
-
return [JSON_COMPAT_UNDEFINED, 0];
|
|
13978
|
-
}
|
|
13979
|
-
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
|
13980
|
-
return input;
|
|
13981
|
-
}
|
|
13982
|
-
if (typeof input === "bigint") {
|
|
13983
|
-
return [JSON_COMPAT_BIGINT, input.toString()];
|
|
13984
|
-
}
|
|
13985
|
-
if (input instanceof ArrayBuffer) {
|
|
13986
|
-
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];
|
|
13987
|
-
}
|
|
13988
|
-
if (input instanceof Uint8Array) {
|
|
13989
|
-
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];
|
|
13990
|
-
}
|
|
13991
|
-
if (isTypedArray(input)) {
|
|
13992
|
-
return input;
|
|
13993
|
-
}
|
|
13994
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Error) {
|
|
13995
|
-
return input;
|
|
13996
|
-
}
|
|
13997
|
-
if (input instanceof Set) {
|
|
13998
|
-
const encoded = [...input.values()].map(
|
|
13999
|
-
(v) => encodeJsonCompatValue(v)
|
|
14000
|
-
);
|
|
14001
|
-
return [JSON_COMPAT_SET, encoded];
|
|
14002
|
-
}
|
|
14003
|
-
if (input instanceof Map) {
|
|
14004
|
-
const encoded = /* @__PURE__ */ new Map();
|
|
14005
|
-
for (const [k, v] of input.entries()) {
|
|
14006
|
-
encoded.set(
|
|
14007
|
-
encodeJsonCompatValue(k),
|
|
14008
|
-
encodeJsonCompatValue(v)
|
|
14009
|
-
);
|
|
14010
|
-
}
|
|
14011
|
-
return encoded;
|
|
14012
|
-
}
|
|
14013
|
-
if (Array.isArray(input)) {
|
|
14014
|
-
const encoded = input.map(
|
|
14015
|
-
(value) => encodeJsonCompatValue(value)
|
|
14016
|
-
);
|
|
14017
|
-
if (encoded.length === 2 && typeof encoded[0] === "string" && encoded[0].startsWith("$")) {
|
|
14018
|
-
return [`$${encoded[0]}`, encoded[1]];
|
|
14019
|
-
}
|
|
14020
|
-
return encoded;
|
|
14021
|
-
}
|
|
14022
|
-
if (isPlainObject2(input)) {
|
|
14023
|
-
const encoded = {};
|
|
14024
|
-
for (const [key, value] of Object.entries(input)) {
|
|
14025
|
-
encoded[key] = encodeJsonCompatValue(value);
|
|
14026
|
-
}
|
|
14027
|
-
return encoded;
|
|
14162
|
+
function configureDefaultLogger(logLevel) {
|
|
14163
|
+
if (logLevel) {
|
|
14164
|
+
configuredLogLevel = logLevel;
|
|
14028
14165
|
}
|
|
14029
|
-
|
|
14030
|
-
|
|
14166
|
+
baseLogger = makeDefaultLogger(logLevel);
|
|
14167
|
+
loggerCache.clear();
|
|
14031
14168
|
}
|
|
14032
|
-
function
|
|
14033
|
-
if (
|
|
14034
|
-
|
|
14035
|
-
return Number(input);
|
|
14036
|
-
}
|
|
14037
|
-
return input;
|
|
14169
|
+
function getBaseLogger() {
|
|
14170
|
+
if (!baseLogger) {
|
|
14171
|
+
configureDefaultLogger();
|
|
14038
14172
|
}
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
);
|
|
14046
|
-
}
|
|
14047
|
-
return revived;
|
|
14173
|
+
return baseLogger;
|
|
14174
|
+
}
|
|
14175
|
+
function getLogger(name = "default") {
|
|
14176
|
+
const cached2 = loggerCache.get(name);
|
|
14177
|
+
if (cached2) {
|
|
14178
|
+
return cached2;
|
|
14048
14179
|
}
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
reviveJsonCompatValue(input[1], options)
|
|
14073
|
-
];
|
|
14180
|
+
const base = getBaseLogger();
|
|
14181
|
+
const child = getIncludeTarget() ? base.child({ target: name }) : base;
|
|
14182
|
+
loggerCache.set(name, child);
|
|
14183
|
+
return child;
|
|
14184
|
+
}
|
|
14185
|
+
var PINO_LEVEL_LABELS = {
|
|
14186
|
+
10: "trace",
|
|
14187
|
+
20: "debug",
|
|
14188
|
+
30: "info",
|
|
14189
|
+
40: "warn",
|
|
14190
|
+
50: "error",
|
|
14191
|
+
60: "fatal"
|
|
14192
|
+
};
|
|
14193
|
+
function createLogfmtDestination() {
|
|
14194
|
+
return {
|
|
14195
|
+
write(msg) {
|
|
14196
|
+
var _a2;
|
|
14197
|
+
const line = formatLogfmtLine(msg);
|
|
14198
|
+
if (typeof process !== "undefined" && ((_a2 = process.stdout) == null ? void 0 : _a2.write)) {
|
|
14199
|
+
process.stdout.write(`${line}
|
|
14200
|
+
`);
|
|
14201
|
+
} else {
|
|
14202
|
+
console.log(line);
|
|
14074
14203
|
}
|
|
14075
|
-
throw new Error(
|
|
14076
|
-
`Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`
|
|
14077
|
-
);
|
|
14078
14204
|
}
|
|
14079
|
-
|
|
14205
|
+
};
|
|
14206
|
+
}
|
|
14207
|
+
function formatLogfmtLine(raw) {
|
|
14208
|
+
let data;
|
|
14209
|
+
try {
|
|
14210
|
+
data = JSON.parse(raw);
|
|
14211
|
+
} catch {
|
|
14212
|
+
return raw.trimEnd();
|
|
14080
14213
|
}
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14214
|
+
const parts = [];
|
|
14215
|
+
appendLogfmtEntry(parts, "level", formatPinoLevel(data.level));
|
|
14216
|
+
if (data.time !== void 0) {
|
|
14217
|
+
appendLogfmtEntry(parts, "ts", data.time);
|
|
14218
|
+
}
|
|
14219
|
+
for (const [key, value] of Object.entries(data)) {
|
|
14220
|
+
if (key === "level" || key === "time") {
|
|
14221
|
+
continue;
|
|
14085
14222
|
}
|
|
14086
|
-
|
|
14223
|
+
appendLogfmtEntry(parts, key, value);
|
|
14087
14224
|
}
|
|
14088
|
-
return
|
|
14225
|
+
return parts.join(" ");
|
|
14089
14226
|
}
|
|
14090
|
-
function
|
|
14091
|
-
if (typeof
|
|
14092
|
-
return
|
|
14227
|
+
function formatPinoLevel(level) {
|
|
14228
|
+
if (typeof level === "number") {
|
|
14229
|
+
return PINO_LEVEL_LABELS[level] ?? level.toString();
|
|
14093
14230
|
}
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
for (let i = 0; i < binary.length; i++) {
|
|
14097
|
-
bytes[i] = binary.charCodeAt(i);
|
|
14231
|
+
if (typeof level === "string") {
|
|
14232
|
+
return level.toLowerCase();
|
|
14098
14233
|
}
|
|
14099
|
-
return
|
|
14100
|
-
}
|
|
14101
|
-
function base64DecodeToArrayBuffer(base643) {
|
|
14102
|
-
return base64DecodeToUint8Array(base643).buffer;
|
|
14103
|
-
}
|
|
14104
|
-
function jsonStringifyCompat(input, space) {
|
|
14105
|
-
return JSON.stringify(
|
|
14106
|
-
input,
|
|
14107
|
-
(_key, value) => {
|
|
14108
|
-
if (typeof value === "bigint") {
|
|
14109
|
-
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14110
|
-
}
|
|
14111
|
-
if (value instanceof ArrayBuffer) {
|
|
14112
|
-
return [
|
|
14113
|
-
JSON_COMPAT_ARRAY_BUFFER,
|
|
14114
|
-
base64EncodeArrayBuffer(value)
|
|
14115
|
-
];
|
|
14116
|
-
}
|
|
14117
|
-
if (value instanceof Uint8Array) {
|
|
14118
|
-
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
14119
|
-
}
|
|
14120
|
-
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0].startsWith("$")) {
|
|
14121
|
-
return [`$${value[0]}`, value[1]];
|
|
14122
|
-
}
|
|
14123
|
-
return value;
|
|
14124
|
-
},
|
|
14125
|
-
space
|
|
14126
|
-
);
|
|
14234
|
+
return "info";
|
|
14127
14235
|
}
|
|
14128
|
-
function
|
|
14129
|
-
|
|
14236
|
+
function appendLogfmtEntry(parts, key, value) {
|
|
14237
|
+
const safeKey = key.replace(/[\s="]/g, "");
|
|
14238
|
+
if (safeKey.length === 0) {
|
|
14239
|
+
return;
|
|
14240
|
+
}
|
|
14241
|
+
parts.push(`${safeKey}=${formatLogfmtValue(value)}`);
|
|
14130
14242
|
}
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
if (_userAgent !== void 0) {
|
|
14135
|
-
return _userAgent;
|
|
14243
|
+
function formatLogfmtValue(value) {
|
|
14244
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
14245
|
+
return String(value);
|
|
14136
14246
|
}
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14247
|
+
if (value === null || value === void 0) {
|
|
14248
|
+
return "null";
|
|
14249
|
+
}
|
|
14250
|
+
if (typeof value === "string") {
|
|
14251
|
+
return quoteLogfmtString(value);
|
|
14252
|
+
}
|
|
14253
|
+
return quoteLogfmtString(JSON.stringify(value));
|
|
14142
14254
|
}
|
|
14143
|
-
function
|
|
14144
|
-
if (
|
|
14145
|
-
return
|
|
14146
|
-
} else if (typeof process !== "undefined") {
|
|
14147
|
-
return process.env[key];
|
|
14255
|
+
function quoteLogfmtString(value) {
|
|
14256
|
+
if (!/[\s="]/.test(value)) {
|
|
14257
|
+
return value;
|
|
14148
14258
|
}
|
|
14259
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`;
|
|
14149
14260
|
}
|
|
14150
|
-
function
|
|
14151
|
-
if (
|
|
14152
|
-
return
|
|
14153
|
-
}
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14261
|
+
function uint8ArrayToBase642(uint8Array) {
|
|
14262
|
+
if (typeof Buffer !== "undefined") {
|
|
14263
|
+
return Buffer.from(uint8Array).toString("base64");
|
|
14264
|
+
}
|
|
14265
|
+
let binary = "";
|
|
14266
|
+
const len = uint8Array.byteLength;
|
|
14267
|
+
for (let i = 0; i < len; i++) {
|
|
14268
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
14269
|
+
}
|
|
14270
|
+
return btoa(binary);
|
|
14271
|
+
}
|
|
14272
|
+
function contentTypeForEncoding(encoding) {
|
|
14273
|
+
if (encoding === "json") {
|
|
14274
|
+
return "application/json";
|
|
14275
|
+
} else if (encoding === "cbor" || encoding === "bare") {
|
|
14276
|
+
return "application/octet-stream";
|
|
14162
14277
|
} else {
|
|
14163
|
-
|
|
14278
|
+
assertUnreachable(encoding);
|
|
14164
14279
|
}
|
|
14165
14280
|
}
|
|
14166
|
-
function
|
|
14167
|
-
|
|
14168
|
-
let reject;
|
|
14169
|
-
const promise2 = new Promise((res, rej) => {
|
|
14170
|
-
resolve = res;
|
|
14171
|
-
reject = rej;
|
|
14172
|
-
});
|
|
14173
|
-
promise2.catch(onReject);
|
|
14174
|
-
return { promise: promise2, resolve, reject };
|
|
14281
|
+
function encodeCborCompat(value) {
|
|
14282
|
+
return cbor.encode(encodeJsonCompatValue(value));
|
|
14175
14283
|
}
|
|
14176
|
-
function
|
|
14177
|
-
return
|
|
14178
|
-
buf.byteOffset,
|
|
14179
|
-
buf.byteOffset + buf.byteLength
|
|
14180
|
-
);
|
|
14284
|
+
function decodeCborCompat(buffer) {
|
|
14285
|
+
return reviveJsonCompatValue(cbor.decode(buffer));
|
|
14181
14286
|
}
|
|
14182
|
-
function
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
if (
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
if (value !== void 0) {
|
|
14197
|
-
queryParts.push(
|
|
14198
|
-
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
14199
|
-
);
|
|
14200
|
-
}
|
|
14287
|
+
function serializeWithEncoding(encoding, value, versionedDataHandler, version2, zodSchema, toJson, toBare) {
|
|
14288
|
+
if (encoding === "json") {
|
|
14289
|
+
const jsonValue = toJson(value);
|
|
14290
|
+
const validated = zodSchema.parse(jsonValue);
|
|
14291
|
+
return jsonStringifyCompat(validated);
|
|
14292
|
+
} else if (encoding === "cbor") {
|
|
14293
|
+
const jsonValue = toJson(value);
|
|
14294
|
+
const validated = zodSchema.parse(jsonValue);
|
|
14295
|
+
return cbor.encode(validated);
|
|
14296
|
+
} else if (encoding === "bare") {
|
|
14297
|
+
if (!versionedDataHandler) {
|
|
14298
|
+
throw new Error(
|
|
14299
|
+
"VersionedDataHandler is required for 'bare' encoding"
|
|
14300
|
+
);
|
|
14201
14301
|
}
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
function assert2(test, message = "") {
|
|
14213
|
-
if (!test) {
|
|
14214
|
-
const e = new AssertionError(message);
|
|
14215
|
-
V8Error.captureStackTrace?.(e, assert2);
|
|
14216
|
-
throw e;
|
|
14302
|
+
if (version2 === void 0) {
|
|
14303
|
+
throw new Error("version is required for 'bare' encoding");
|
|
14304
|
+
}
|
|
14305
|
+
const bareValue = toBare(value);
|
|
14306
|
+
return versionedDataHandler.serializeWithEmbeddedVersion(
|
|
14307
|
+
bareValue,
|
|
14308
|
+
version2
|
|
14309
|
+
);
|
|
14310
|
+
} else {
|
|
14311
|
+
assertUnreachable(encoding);
|
|
14217
14312
|
}
|
|
14218
14313
|
}
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14314
|
+
function deserializeWithEncoding(encoding, buffer, versionedDataHandler, zodSchema, fromJson, fromBare) {
|
|
14315
|
+
if (encoding === "json") {
|
|
14316
|
+
let parsed;
|
|
14317
|
+
if (typeof buffer === "string") {
|
|
14318
|
+
parsed = jsonParseCompat(buffer);
|
|
14319
|
+
} else {
|
|
14320
|
+
const decoder = new TextDecoder("utf-8");
|
|
14321
|
+
const jsonString = decoder.decode(buffer);
|
|
14322
|
+
parsed = jsonParseCompat(jsonString);
|
|
14323
|
+
}
|
|
14324
|
+
const validated = zodSchema.parse(parsed);
|
|
14325
|
+
return fromJson(validated);
|
|
14326
|
+
} else if (encoding === "cbor") {
|
|
14327
|
+
(0, import_invariant.default)(
|
|
14328
|
+
typeof buffer !== "string",
|
|
14329
|
+
"buffer cannot be string for cbor encoding"
|
|
14330
|
+
);
|
|
14331
|
+
const decoded = decodeCborCompat(buffer);
|
|
14332
|
+
const validated = zodSchema.parse(decoded);
|
|
14333
|
+
return fromJson(validated);
|
|
14334
|
+
} else if (encoding === "bare") {
|
|
14335
|
+
(0, import_invariant.default)(
|
|
14336
|
+
typeof buffer !== "string",
|
|
14337
|
+
"buffer cannot be string for bare encoding"
|
|
14338
|
+
);
|
|
14339
|
+
if (!versionedDataHandler) {
|
|
14340
|
+
throw new Error(
|
|
14341
|
+
"VersionedDataHandler is required for 'bare' encoding"
|
|
14342
|
+
);
|
|
14343
|
+
}
|
|
14344
|
+
const bareValue = versionedDataHandler.deserializeWithEmbeddedVersion(buffer);
|
|
14345
|
+
return fromBare(bareValue);
|
|
14346
|
+
} else {
|
|
14347
|
+
assertUnreachable(encoding);
|
|
14223
14348
|
}
|
|
14224
|
-
};
|
|
14225
|
-
|
|
14226
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/validator.js
|
|
14227
|
-
function isU8(val) {
|
|
14228
|
-
return val === (val & 255);
|
|
14229
|
-
}
|
|
14230
|
-
function isU32(val) {
|
|
14231
|
-
return val === val >>> 0;
|
|
14232
14349
|
}
|
|
14233
|
-
|
|
14234
|
-
|
|
14350
|
+
var JSON_COMPAT_BIGINT = "$BigInt";
|
|
14351
|
+
var JSON_COMPAT_ARRAY_BUFFER = "$ArrayBuffer";
|
|
14352
|
+
var JSON_COMPAT_UINT8_ARRAY = "$Uint8Array";
|
|
14353
|
+
var JSON_COMPAT_UNDEFINED = "$Undefined";
|
|
14354
|
+
var JSON_COMPAT_SET = "$Set";
|
|
14355
|
+
function isTypedArray(value) {
|
|
14356
|
+
return value instanceof Uint8ClampedArray || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof BigUint64Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array || value instanceof BigInt64Array || value instanceof Float32Array || value instanceof Float64Array;
|
|
14235
14357
|
}
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14358
|
+
function assertJsonCompatValue(value, path2 = "") {
|
|
14359
|
+
var _a2;
|
|
14360
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
14361
|
+
return;
|
|
14362
|
+
}
|
|
14363
|
+
if (typeof value === "function") {
|
|
14364
|
+
throw new TypeError(
|
|
14365
|
+
`Value at ${path2 || "root"} is a function and is not CBOR serializable`
|
|
14366
|
+
);
|
|
14367
|
+
}
|
|
14368
|
+
if (typeof value === "symbol") {
|
|
14369
|
+
throw new TypeError(
|
|
14370
|
+
`Value at ${path2 || "root"} is a symbol and is not CBOR serializable`
|
|
14371
|
+
);
|
|
14372
|
+
}
|
|
14373
|
+
if (value instanceof Date || value instanceof RegExp || value instanceof Error || value instanceof ArrayBuffer || value instanceof Uint8Array || isTypedArray(value)) {
|
|
14374
|
+
return;
|
|
14375
|
+
}
|
|
14376
|
+
if (value instanceof WeakMap) {
|
|
14377
|
+
throw new TypeError(
|
|
14378
|
+
`Value at ${path2 || "root"} is a WeakMap and is not CBOR serializable`
|
|
14379
|
+
);
|
|
14380
|
+
}
|
|
14381
|
+
if (value instanceof WeakSet) {
|
|
14382
|
+
throw new TypeError(
|
|
14383
|
+
`Value at ${path2 || "root"} is a WeakSet and is not CBOR serializable`
|
|
14384
|
+
);
|
|
14385
|
+
}
|
|
14386
|
+
if (value instanceof WeakRef) {
|
|
14387
|
+
throw new TypeError(
|
|
14388
|
+
`Value at ${path2 || "root"} is a WeakRef and is not CBOR serializable`
|
|
14389
|
+
);
|
|
14390
|
+
}
|
|
14391
|
+
if (value instanceof Promise) {
|
|
14392
|
+
throw new TypeError(
|
|
14393
|
+
`Value at ${path2 || "root"} is a Promise and is not CBOR serializable`
|
|
14394
|
+
);
|
|
14395
|
+
}
|
|
14396
|
+
if (value instanceof Map) {
|
|
14397
|
+
for (const [k, v] of value.entries()) {
|
|
14398
|
+
assertJsonCompatValue(k, `${path2 || "root"}.key(${String(k)})`);
|
|
14399
|
+
assertJsonCompatValue(v, `${path2 || "root"}.value(${String(k)})`);
|
|
14400
|
+
}
|
|
14401
|
+
return;
|
|
14256
14402
|
}
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
* @throws {BareError} Buffer exceeds `config.maxBufferLength`
|
|
14263
|
-
*/
|
|
14264
|
-
constructor(bytes, config3) {
|
|
14265
|
-
this.offset = 0;
|
|
14266
|
-
if (bytes.length > config3.maxBufferLength) {
|
|
14267
|
-
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14403
|
+
if (value instanceof Set) {
|
|
14404
|
+
let index = 0;
|
|
14405
|
+
for (const item of value.values()) {
|
|
14406
|
+
assertJsonCompatValue(item, `${path2 || "root"}.set[${index}]`);
|
|
14407
|
+
index++;
|
|
14268
14408
|
}
|
|
14269
|
-
|
|
14270
|
-
this.config = config3;
|
|
14271
|
-
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
14409
|
+
return;
|
|
14272
14410
|
}
|
|
14273
|
-
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14411
|
+
if (Array.isArray(value)) {
|
|
14412
|
+
for (let i = 0; i < value.length; i++) {
|
|
14413
|
+
assertJsonCompatValue(value[i], `${path2 || "root"}[${i}]`);
|
|
14414
|
+
}
|
|
14415
|
+
return;
|
|
14277
14416
|
}
|
|
14278
|
-
if (
|
|
14279
|
-
|
|
14417
|
+
if (isPlainObject2(value)) {
|
|
14418
|
+
for (const key in value) {
|
|
14419
|
+
assertJsonCompatValue(
|
|
14420
|
+
value[key],
|
|
14421
|
+
path2 ? `${path2}.${key}` : key
|
|
14422
|
+
);
|
|
14423
|
+
}
|
|
14424
|
+
return;
|
|
14280
14425
|
}
|
|
14426
|
+
const typeName = typeof value === "object" && value !== null ? ((_a2 = value.constructor) == null ? void 0 : _a2.name) ?? typeof value : typeof value;
|
|
14427
|
+
throw new TypeError(
|
|
14428
|
+
`Value at ${path2 || "root"} of type "${typeName}" is not CBOR serializable`
|
|
14429
|
+
);
|
|
14281
14430
|
}
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14431
|
+
var EncodingSchema = external_exports.enum(["json", "cbor", "bare"]);
|
|
14432
|
+
async function inputDataToBuffer(data) {
|
|
14433
|
+
if (typeof data === "string") {
|
|
14434
|
+
return data;
|
|
14285
14435
|
}
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
grow(bc, minLen);
|
|
14436
|
+
if (data instanceof Blob) {
|
|
14437
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
14289
14438
|
}
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
if (minLen > bc.config.maxBufferLength) {
|
|
14293
|
-
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14439
|
+
if (data instanceof Uint8Array) {
|
|
14440
|
+
return data;
|
|
14294
14441
|
}
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
if (isEs2024ArrayBufferLike(buffer) && // Make sure that the view covers the end of the buffer.
|
|
14298
|
-
// If it is not the case, this indicates that the user don't want
|
|
14299
|
-
// to override the trailing bytes.
|
|
14300
|
-
bc.bytes.byteOffset + bc.bytes.byteLength === buffer.byteLength && bc.bytes.byteLength + minLen <= buffer.maxByteLength) {
|
|
14301
|
-
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength, buffer.maxByteLength);
|
|
14302
|
-
if (buffer instanceof ArrayBuffer) {
|
|
14303
|
-
buffer.resize(newLen);
|
|
14304
|
-
} else {
|
|
14305
|
-
buffer.grow(newLen);
|
|
14306
|
-
}
|
|
14307
|
-
newBytes = new Uint8Array(buffer, bc.bytes.byteOffset, newLen);
|
|
14308
|
-
} else {
|
|
14309
|
-
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength);
|
|
14310
|
-
newBytes = new Uint8Array(newLen);
|
|
14311
|
-
newBytes.set(bc.bytes);
|
|
14442
|
+
if (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) {
|
|
14443
|
+
return new Uint8Array(data);
|
|
14312
14444
|
}
|
|
14313
|
-
|
|
14314
|
-
bc.view = new DataView(newBytes.buffer);
|
|
14315
|
-
}
|
|
14316
|
-
function isEs2024ArrayBufferLike(buffer) {
|
|
14317
|
-
return "maxByteLength" in buffer;
|
|
14445
|
+
throw new Error("Malformed message");
|
|
14318
14446
|
}
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
if (val > 1) {
|
|
14324
|
-
bc.offset--;
|
|
14325
|
-
throw new BareError(bc.offset, "a bool must be equal to 0 or 1");
|
|
14447
|
+
function base64EncodeUint8Array(uint8Array) {
|
|
14448
|
+
let binary = "";
|
|
14449
|
+
for (const value of uint8Array) {
|
|
14450
|
+
binary += String.fromCharCode(value);
|
|
14326
14451
|
}
|
|
14327
|
-
return
|
|
14328
|
-
}
|
|
14329
|
-
function writeBool(bc, x) {
|
|
14330
|
-
writeU8(bc, x ? 1 : 0);
|
|
14452
|
+
return btoa(binary);
|
|
14331
14453
|
}
|
|
14332
|
-
function
|
|
14333
|
-
|
|
14334
|
-
return bc.bytes[bc.offset++];
|
|
14454
|
+
function base64EncodeArrayBuffer(arrayBuffer) {
|
|
14455
|
+
return base64EncodeUint8Array(new Uint8Array(arrayBuffer));
|
|
14335
14456
|
}
|
|
14336
|
-
function
|
|
14337
|
-
if (
|
|
14338
|
-
|
|
14457
|
+
function isPlainObject2(value) {
|
|
14458
|
+
if (value === null || typeof value !== "object") {
|
|
14459
|
+
return false;
|
|
14339
14460
|
}
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
}
|
|
14343
|
-
function readU32(bc) {
|
|
14344
|
-
check2(bc, 4);
|
|
14345
|
-
const result = bc.view.getUint32(bc.offset, true);
|
|
14346
|
-
bc.offset += 4;
|
|
14347
|
-
return result;
|
|
14348
|
-
}
|
|
14349
|
-
function readU64(bc) {
|
|
14350
|
-
check2(bc, 8);
|
|
14351
|
-
const result = bc.view.getBigUint64(bc.offset, true);
|
|
14352
|
-
bc.offset += 8;
|
|
14353
|
-
return result;
|
|
14461
|
+
const proto = Object.getPrototypeOf(value);
|
|
14462
|
+
return proto === Object.prototype || proto === null;
|
|
14354
14463
|
}
|
|
14355
|
-
function
|
|
14356
|
-
|
|
14357
|
-
|
|
14464
|
+
function encodeJsonCompatValue(input) {
|
|
14465
|
+
var _a2;
|
|
14466
|
+
if (input === null) {
|
|
14467
|
+
return input;
|
|
14358
14468
|
}
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
bc.offset += 8;
|
|
14362
|
-
}
|
|
14363
|
-
|
|
14364
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/uint.js
|
|
14365
|
-
function readUint(bc) {
|
|
14366
|
-
let low = readU8(bc);
|
|
14367
|
-
if (low >= 128) {
|
|
14368
|
-
low &= 127;
|
|
14369
|
-
let shiftMul = 128;
|
|
14370
|
-
let byteCount = 1;
|
|
14371
|
-
let byte;
|
|
14372
|
-
do {
|
|
14373
|
-
byte = readU8(bc);
|
|
14374
|
-
low += (byte & 127) * shiftMul;
|
|
14375
|
-
shiftMul *= /* 2**7 */
|
|
14376
|
-
128;
|
|
14377
|
-
byteCount++;
|
|
14378
|
-
} while (byte >= 128 && byteCount < 7);
|
|
14379
|
-
let height = 0;
|
|
14380
|
-
shiftMul = 1;
|
|
14381
|
-
while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
|
|
14382
|
-
byte = readU8(bc);
|
|
14383
|
-
height += (byte & 127) * shiftMul;
|
|
14384
|
-
shiftMul *= /* 2**7 */
|
|
14385
|
-
128;
|
|
14386
|
-
byteCount++;
|
|
14387
|
-
}
|
|
14388
|
-
if (byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
|
|
14389
|
-
bc.offset -= byteCount;
|
|
14390
|
-
throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
|
|
14391
|
-
}
|
|
14392
|
-
return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
|
|
14469
|
+
if (input === void 0) {
|
|
14470
|
+
return [JSON_COMPAT_UNDEFINED, 0];
|
|
14393
14471
|
}
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
function writeUint(bc, x) {
|
|
14397
|
-
const truncated = BigInt.asUintN(64, x);
|
|
14398
|
-
if (DEV) {
|
|
14399
|
-
assert2(truncated === x, TOO_LARGE_NUMBER);
|
|
14472
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
|
14473
|
+
return input;
|
|
14400
14474
|
}
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
function writeUintTruncated(bc, x) {
|
|
14404
|
-
let tmp = Number(BigInt.asUintN(7 * 7, x));
|
|
14405
|
-
let rest = Number(x >> BigInt(7 * 7));
|
|
14406
|
-
let byteCount = 0;
|
|
14407
|
-
while (tmp >= 128 || rest > 0) {
|
|
14408
|
-
writeU8(bc, 128 | tmp & 127);
|
|
14409
|
-
tmp = Math.floor(tmp / /* 2**7 */
|
|
14410
|
-
128);
|
|
14411
|
-
byteCount++;
|
|
14412
|
-
if (byteCount === 7) {
|
|
14413
|
-
tmp = rest;
|
|
14414
|
-
rest = 0;
|
|
14415
|
-
}
|
|
14475
|
+
if (typeof input === "bigint") {
|
|
14476
|
+
return [JSON_COMPAT_BIGINT, input.toString()];
|
|
14416
14477
|
}
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
14478
|
+
if (input instanceof ArrayBuffer) {
|
|
14479
|
+
return [JSON_COMPAT_ARRAY_BUFFER, base64EncodeArrayBuffer(input)];
|
|
14480
|
+
}
|
|
14481
|
+
if (input instanceof Uint8Array) {
|
|
14482
|
+
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(input)];
|
|
14483
|
+
}
|
|
14484
|
+
if (isTypedArray(input)) {
|
|
14485
|
+
return input;
|
|
14486
|
+
}
|
|
14487
|
+
if (input instanceof Date || input instanceof RegExp || input instanceof Error) {
|
|
14488
|
+
return input;
|
|
14489
|
+
}
|
|
14490
|
+
if (input instanceof Set) {
|
|
14491
|
+
const encoded = [...input.values()].map(
|
|
14492
|
+
(v) => encodeJsonCompatValue(v)
|
|
14493
|
+
);
|
|
14494
|
+
return [JSON_COMPAT_SET, encoded];
|
|
14495
|
+
}
|
|
14496
|
+
if (input instanceof Map) {
|
|
14497
|
+
const encoded = /* @__PURE__ */ new Map();
|
|
14498
|
+
for (const [k, v] of input.entries()) {
|
|
14499
|
+
encoded.set(
|
|
14500
|
+
encodeJsonCompatValue(k),
|
|
14501
|
+
encodeJsonCompatValue(v)
|
|
14502
|
+
);
|
|
14435
14503
|
}
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14504
|
+
return encoded;
|
|
14505
|
+
}
|
|
14506
|
+
if (Array.isArray(input)) {
|
|
14507
|
+
const encoded = input.map(
|
|
14508
|
+
(value) => encodeJsonCompatValue(value)
|
|
14509
|
+
);
|
|
14510
|
+
if (encoded.length === 2 && typeof encoded[0] === "string" && encoded[0].startsWith("$")) {
|
|
14511
|
+
return [`$${encoded[0]}`, encoded[1]];
|
|
14439
14512
|
}
|
|
14513
|
+
return encoded;
|
|
14440
14514
|
}
|
|
14441
|
-
|
|
14515
|
+
if (isPlainObject2(input)) {
|
|
14516
|
+
const encoded = {};
|
|
14517
|
+
for (const [key, value] of Object.entries(input)) {
|
|
14518
|
+
encoded[key] = encodeJsonCompatValue(value);
|
|
14519
|
+
}
|
|
14520
|
+
return encoded;
|
|
14521
|
+
}
|
|
14522
|
+
const typeName = typeof input === "object" && input !== null ? ((_a2 = input.constructor) == null ? void 0 : _a2.name) ?? typeof input : typeof input;
|
|
14523
|
+
throw new TypeError(`Value of type "${typeName}" is not CBOR serializable`);
|
|
14442
14524
|
}
|
|
14443
|
-
function
|
|
14444
|
-
if (
|
|
14445
|
-
|
|
14525
|
+
function reviveJsonCompatValue(input, options = {}) {
|
|
14526
|
+
if (typeof input === "bigint") {
|
|
14527
|
+
if (options.coerceSafeIntegerBigInts && input >= BigInt(Number.MIN_SAFE_INTEGER) && input <= BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
14528
|
+
return Number(input);
|
|
14529
|
+
}
|
|
14530
|
+
return input;
|
|
14446
14531
|
}
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14532
|
+
if (input instanceof Map) {
|
|
14533
|
+
const revived = /* @__PURE__ */ new Map();
|
|
14534
|
+
for (const [k, v] of input.entries()) {
|
|
14535
|
+
revived.set(
|
|
14536
|
+
reviveJsonCompatValue(k, options),
|
|
14537
|
+
reviveJsonCompatValue(v, options)
|
|
14538
|
+
);
|
|
14539
|
+
}
|
|
14540
|
+
return revived;
|
|
14451
14541
|
}
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14542
|
+
if (Array.isArray(input)) {
|
|
14543
|
+
if (input.length === 2 && typeof input[0] === "string" && input[0].startsWith("$")) {
|
|
14544
|
+
if (input[0] === JSON_COMPAT_BIGINT) {
|
|
14545
|
+
return BigInt(input[1]);
|
|
14546
|
+
}
|
|
14547
|
+
if (input[0] === JSON_COMPAT_ARRAY_BUFFER) {
|
|
14548
|
+
return base64DecodeToArrayBuffer(input[1]);
|
|
14549
|
+
}
|
|
14550
|
+
if (input[0] === JSON_COMPAT_UINT8_ARRAY) {
|
|
14551
|
+
return base64DecodeToUint8Array(input[1]);
|
|
14552
|
+
}
|
|
14553
|
+
if (input[0] === JSON_COMPAT_UNDEFINED) {
|
|
14554
|
+
return void 0;
|
|
14555
|
+
}
|
|
14556
|
+
if (input[0] === JSON_COMPAT_SET) {
|
|
14557
|
+
const items = input[1].map(
|
|
14558
|
+
(v) => reviveJsonCompatValue(v, options)
|
|
14559
|
+
);
|
|
14560
|
+
return new Set(items);
|
|
14561
|
+
}
|
|
14562
|
+
if (input[0].startsWith("$$")) {
|
|
14563
|
+
return [
|
|
14564
|
+
input[0].substring(1),
|
|
14565
|
+
reviveJsonCompatValue(input[1], options)
|
|
14566
|
+
];
|
|
14567
|
+
}
|
|
14568
|
+
throw new Error(
|
|
14569
|
+
`Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`
|
|
14570
|
+
);
|
|
14474
14571
|
}
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14572
|
+
return input.map((value) => reviveJsonCompatValue(value, options));
|
|
14573
|
+
}
|
|
14574
|
+
if (isPlainObject2(input)) {
|
|
14575
|
+
const decoded = {};
|
|
14576
|
+
for (const [key, value] of Object.entries(input)) {
|
|
14577
|
+
decoded[key] = reviveJsonCompatValue(value, options);
|
|
14478
14578
|
}
|
|
14579
|
+
return decoded;
|
|
14479
14580
|
}
|
|
14480
|
-
return
|
|
14481
|
-
}
|
|
14482
|
-
|
|
14483
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/u8-array.js
|
|
14484
|
-
function readU8Array(bc) {
|
|
14485
|
-
return readU8FixedArray(bc, readUintSafe32(bc));
|
|
14486
|
-
}
|
|
14487
|
-
function writeU8Array(bc, x) {
|
|
14488
|
-
writeUintSafe32(bc, x.length);
|
|
14489
|
-
writeU8FixedArray(bc, x);
|
|
14490
|
-
}
|
|
14491
|
-
function readU8FixedArray(bc, len) {
|
|
14492
|
-
return readUnsafeU8FixedArray(bc, len).slice();
|
|
14581
|
+
return input;
|
|
14493
14582
|
}
|
|
14494
|
-
function
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
reserve(bc, len);
|
|
14498
|
-
bc.bytes.set(x, bc.offset);
|
|
14499
|
-
bc.offset += len;
|
|
14583
|
+
function base64DecodeToUint8Array(base643) {
|
|
14584
|
+
if (typeof Buffer !== "undefined") {
|
|
14585
|
+
return new Uint8Array(Buffer.from(base643, "base64"));
|
|
14500
14586
|
}
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14587
|
+
const binary = atob(base643);
|
|
14588
|
+
const bytes = new Uint8Array(binary.length);
|
|
14589
|
+
for (let i = 0; i < binary.length; i++) {
|
|
14590
|
+
bytes[i] = binary.charCodeAt(i);
|
|
14505
14591
|
}
|
|
14506
|
-
|
|
14507
|
-
const offset = bc.offset;
|
|
14508
|
-
bc.offset += len;
|
|
14509
|
-
return bc.bytes.subarray(offset, offset + len);
|
|
14592
|
+
return bytes;
|
|
14510
14593
|
}
|
|
14511
|
-
|
|
14512
|
-
|
|
14513
|
-
function readData(bc) {
|
|
14514
|
-
return readU8Array(bc).buffer;
|
|
14594
|
+
function base64DecodeToArrayBuffer(base643) {
|
|
14595
|
+
return base64DecodeToUint8Array(base643).buffer;
|
|
14515
14596
|
}
|
|
14516
|
-
function
|
|
14517
|
-
|
|
14597
|
+
function jsonStringifyCompat(input, space) {
|
|
14598
|
+
return JSON.stringify(
|
|
14599
|
+
input,
|
|
14600
|
+
(_key, value) => {
|
|
14601
|
+
if (typeof value === "bigint") {
|
|
14602
|
+
return [JSON_COMPAT_BIGINT, value.toString()];
|
|
14603
|
+
}
|
|
14604
|
+
if (value instanceof ArrayBuffer) {
|
|
14605
|
+
return [
|
|
14606
|
+
JSON_COMPAT_ARRAY_BUFFER,
|
|
14607
|
+
base64EncodeArrayBuffer(value)
|
|
14608
|
+
];
|
|
14609
|
+
}
|
|
14610
|
+
if (value instanceof Uint8Array) {
|
|
14611
|
+
return [JSON_COMPAT_UINT8_ARRAY, base64EncodeUint8Array(value)];
|
|
14612
|
+
}
|
|
14613
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && value[0].startsWith("$")) {
|
|
14614
|
+
return [`$${value[0]}`, value[1]];
|
|
14615
|
+
}
|
|
14616
|
+
return value;
|
|
14617
|
+
},
|
|
14618
|
+
space
|
|
14619
|
+
);
|
|
14518
14620
|
}
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
function readString(bc) {
|
|
14522
|
-
return readFixedString(bc, readUintSafe32(bc));
|
|
14621
|
+
function jsonParseCompat(input) {
|
|
14622
|
+
return reviveJsonCompatValue(JSON.parse(input));
|
|
14523
14623
|
}
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
writeUtf8Js(bc, x);
|
|
14530
|
-
} else {
|
|
14531
|
-
const strBytes = UTF8_ENCODER.encode(x);
|
|
14532
|
-
writeUintSafe32(bc, strBytes.length);
|
|
14533
|
-
writeU8FixedArray(bc, strBytes);
|
|
14624
|
+
var VERSION = package_default.version;
|
|
14625
|
+
var _userAgent;
|
|
14626
|
+
function httpUserAgent() {
|
|
14627
|
+
if (_userAgent !== void 0) {
|
|
14628
|
+
return _userAgent;
|
|
14534
14629
|
}
|
|
14630
|
+
let userAgent = `RivetKit/${VERSION}`;
|
|
14631
|
+
const navigatorObj = typeof navigator !== "undefined" ? navigator : void 0;
|
|
14632
|
+
if (navigatorObj == null ? void 0 : navigatorObj.userAgent) userAgent += ` ${navigatorObj.userAgent}`;
|
|
14633
|
+
_userAgent = userAgent;
|
|
14634
|
+
return userAgent;
|
|
14535
14635
|
}
|
|
14536
|
-
function
|
|
14537
|
-
if (
|
|
14538
|
-
|
|
14539
|
-
}
|
|
14540
|
-
|
|
14541
|
-
return readUtf8Js(bc, byteLen);
|
|
14542
|
-
}
|
|
14543
|
-
try {
|
|
14544
|
-
return UTF8_DECODER.decode(readUnsafeU8FixedArray(bc, byteLen));
|
|
14545
|
-
} catch (_cause) {
|
|
14546
|
-
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14636
|
+
function getEnvUniversal(key) {
|
|
14637
|
+
if (typeof Deno !== "undefined") {
|
|
14638
|
+
return Deno.env.get(key);
|
|
14639
|
+
} else if (typeof process !== "undefined") {
|
|
14640
|
+
return process.env[key];
|
|
14547
14641
|
}
|
|
14548
14642
|
}
|
|
14549
|
-
function
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
malformed = codePoint >> 7 === 0 || // non-canonical char
|
|
14564
|
-
byte1 >> 5 !== 6 || // invalid tag
|
|
14565
|
-
byte2 >> 6 !== 2;
|
|
14566
|
-
} else if (offset + 1 < upperOffset && codePoint < 240) {
|
|
14567
|
-
const byte2 = bytes[offset++];
|
|
14568
|
-
const byte3 = bytes[offset++];
|
|
14569
|
-
codePoint = (byte1 & 15) << 12 | (byte2 & 63) << 6 | byte3 & 63;
|
|
14570
|
-
malformed = codePoint >> 11 === 0 || // non-canonical char or missing data
|
|
14571
|
-
codePoint >> 11 === 27 || // surrogate char (0xD800 <= codePoint <= 0xDFFF)
|
|
14572
|
-
byte1 >> 4 !== 14 || // invalid tag
|
|
14573
|
-
byte2 >> 6 !== 2 || // invalid tag
|
|
14574
|
-
byte3 >> 6 !== 2;
|
|
14575
|
-
} else if (offset + 2 < upperOffset) {
|
|
14576
|
-
const byte2 = bytes[offset++];
|
|
14577
|
-
const byte3 = bytes[offset++];
|
|
14578
|
-
const byte4 = bytes[offset++];
|
|
14579
|
-
codePoint = (byte1 & 7) << 18 | (byte2 & 63) << 12 | (byte3 & 63) << 6 | byte4 & 63;
|
|
14580
|
-
malformed = codePoint >> 16 === 0 || // non-canonical char or missing data
|
|
14581
|
-
codePoint > 1114111 || // too large code point
|
|
14582
|
-
byte1 >> 3 !== 30 || // invalid tag
|
|
14583
|
-
byte2 >> 6 !== 2 || // invalid tag
|
|
14584
|
-
byte3 >> 6 !== 2 || // invalid tag
|
|
14585
|
-
byte4 >> 6 !== 2;
|
|
14586
|
-
}
|
|
14587
|
-
if (malformed) {
|
|
14588
|
-
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14589
|
-
}
|
|
14590
|
-
}
|
|
14591
|
-
result += String.fromCodePoint(codePoint);
|
|
14643
|
+
function toUint8Array(data) {
|
|
14644
|
+
if (data instanceof Uint8Array) {
|
|
14645
|
+
return data;
|
|
14646
|
+
} else if (data instanceof ArrayBuffer) {
|
|
14647
|
+
return new Uint8Array(data);
|
|
14648
|
+
} else if (ArrayBuffer.isView(data)) {
|
|
14649
|
+
return new Uint8Array(
|
|
14650
|
+
data.buffer.slice(
|
|
14651
|
+
data.byteOffset,
|
|
14652
|
+
data.byteOffset + data.byteLength
|
|
14653
|
+
)
|
|
14654
|
+
);
|
|
14655
|
+
} else {
|
|
14656
|
+
throw new TypeError("Input must be ArrayBuffer or ArrayBufferView");
|
|
14592
14657
|
}
|
|
14593
|
-
bc.offset = offset;
|
|
14594
|
-
return result;
|
|
14595
14658
|
}
|
|
14596
|
-
function
|
|
14597
|
-
|
|
14598
|
-
let
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
if (codePoint < 2048) {
|
|
14606
|
-
bytes[offset++] = 192 | codePoint >> 6;
|
|
14607
|
-
} else {
|
|
14608
|
-
if (codePoint < 65536) {
|
|
14609
|
-
bytes[offset++] = 224 | codePoint >> 12;
|
|
14610
|
-
} else {
|
|
14611
|
-
bytes[offset++] = 240 | codePoint >> 18;
|
|
14612
|
-
bytes[offset++] = 128 | codePoint >> 12 & 63;
|
|
14613
|
-
i++;
|
|
14614
|
-
}
|
|
14615
|
-
bytes[offset++] = 128 | codePoint >> 6 & 63;
|
|
14616
|
-
}
|
|
14617
|
-
bytes[offset++] = 128 | codePoint & 63;
|
|
14618
|
-
}
|
|
14619
|
-
}
|
|
14620
|
-
bc.offset = offset;
|
|
14659
|
+
function promiseWithResolvers(onReject) {
|
|
14660
|
+
let resolve;
|
|
14661
|
+
let reject;
|
|
14662
|
+
const promise2 = new Promise((res, rej) => {
|
|
14663
|
+
resolve = res;
|
|
14664
|
+
reject = rej;
|
|
14665
|
+
});
|
|
14666
|
+
promise2.catch(onReject);
|
|
14667
|
+
return { promise: promise2, resolve, reject };
|
|
14621
14668
|
}
|
|
14622
|
-
function
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14669
|
+
function bufferToArrayBuffer(buf) {
|
|
14670
|
+
return buf.buffer.slice(
|
|
14671
|
+
buf.byteOffset,
|
|
14672
|
+
buf.byteOffset + buf.byteLength
|
|
14673
|
+
);
|
|
14674
|
+
}
|
|
14675
|
+
function combineUrlPath(endpoint, path2, queryParams) {
|
|
14676
|
+
const baseUrl = new URL(endpoint);
|
|
14677
|
+
const pathParts = path2.split("?");
|
|
14678
|
+
const pathOnly = pathParts[0];
|
|
14679
|
+
const existingQuery = pathParts[1] || "";
|
|
14680
|
+
const basePath = baseUrl.pathname.replace(/\/$/, "");
|
|
14681
|
+
const cleanPath = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
|
|
14682
|
+
const fullPath = (basePath + cleanPath).replace(/\/\//g, "/");
|
|
14683
|
+
const queryParts = [];
|
|
14684
|
+
if (existingQuery) {
|
|
14685
|
+
queryParts.push(existingQuery);
|
|
14686
|
+
}
|
|
14687
|
+
if (queryParams) {
|
|
14688
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
14689
|
+
if (value !== void 0) {
|
|
14690
|
+
queryParts.push(
|
|
14691
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
|
|
14692
|
+
);
|
|
14633
14693
|
}
|
|
14634
14694
|
}
|
|
14635
14695
|
}
|
|
14636
|
-
|
|
14696
|
+
const fullQuery = queryParts.length > 0 ? `?${queryParts.join("&")}` : "";
|
|
14697
|
+
return `${baseUrl.protocol}//${baseUrl.host}${fullPath}${fullQuery}`;
|
|
14637
14698
|
}
|
|
14638
|
-
var UTF8_DECODER = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
|
|
14639
|
-
var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
|
|
14640
14699
|
|
|
14641
|
-
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14700
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/imports/dev.node.js
|
|
14701
|
+
var DEV = process.env.NODE_ENV === "development";
|
|
14702
|
+
|
|
14703
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/assert.js
|
|
14704
|
+
var V8Error = Error;
|
|
14705
|
+
function assert2(test, message = "") {
|
|
14706
|
+
if (!test) {
|
|
14707
|
+
const e = new AssertionError(message);
|
|
14708
|
+
V8Error.captureStackTrace?.(e, assert2);
|
|
14709
|
+
throw e;
|
|
14647
14710
|
}
|
|
14648
|
-
return {
|
|
14649
|
-
initialBufferLength,
|
|
14650
|
-
maxBufferLength
|
|
14651
|
-
};
|
|
14652
14711
|
}
|
|
14712
|
+
var AssertionError = class extends Error {
|
|
14713
|
+
constructor() {
|
|
14714
|
+
super(...arguments);
|
|
14715
|
+
this.name = "AssertionError";
|
|
14716
|
+
}
|
|
14717
|
+
};
|
|
14653
14718
|
|
|
14654
|
-
//
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
return readData(bc);
|
|
14719
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/validator.js
|
|
14720
|
+
function isU8(val) {
|
|
14721
|
+
return val === (val & 255);
|
|
14658
14722
|
}
|
|
14659
|
-
function
|
|
14660
|
-
return
|
|
14723
|
+
function isU32(val) {
|
|
14724
|
+
return val === val >>> 0;
|
|
14661
14725
|
}
|
|
14662
|
-
function
|
|
14663
|
-
return
|
|
14664
|
-
loop: readWorkflowNameIndex(bc),
|
|
14665
|
-
iteration: readU32(bc)
|
|
14666
|
-
};
|
|
14726
|
+
function isU64(val) {
|
|
14727
|
+
return val === BigInt.asUintN(64, val);
|
|
14667
14728
|
}
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
|
|
14680
|
-
|
|
14681
|
-
|
|
14729
|
+
|
|
14730
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/util/constants.js
|
|
14731
|
+
var TEXT_DECODER_THRESHOLD = 256;
|
|
14732
|
+
var TEXT_ENCODER_THRESHOLD = 256;
|
|
14733
|
+
var INT_SAFE_MAX_BYTE_COUNT = 8;
|
|
14734
|
+
var UINT_MAX_BYTE_COUNT = 10;
|
|
14735
|
+
var UINT_SAFE32_MAX_BYTE_COUNT = 5;
|
|
14736
|
+
var INVALID_UTF8_STRING = "invalid UTF-8 string";
|
|
14737
|
+
var NON_CANONICAL_REPRESENTATION = "must be canonical";
|
|
14738
|
+
var TOO_LARGE_BUFFER = "too large buffer";
|
|
14739
|
+
var TOO_LARGE_NUMBER = "too large number";
|
|
14740
|
+
|
|
14741
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/bare-error.js
|
|
14742
|
+
var BareError = class extends Error {
|
|
14743
|
+
constructor(offset, issue2, opts) {
|
|
14744
|
+
super(`(byte:${offset}) ${issue2}`);
|
|
14745
|
+
this.name = "BareError";
|
|
14746
|
+
this.issue = issue2;
|
|
14747
|
+
this.offset = offset;
|
|
14748
|
+
this.cause = opts?.cause;
|
|
14749
|
+
}
|
|
14750
|
+
};
|
|
14751
|
+
|
|
14752
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/byte-cursor.js
|
|
14753
|
+
var ByteCursor = class {
|
|
14754
|
+
/**
|
|
14755
|
+
* @throws {BareError} Buffer exceeds `config.maxBufferLength`
|
|
14756
|
+
*/
|
|
14757
|
+
constructor(bytes, config3) {
|
|
14758
|
+
this.offset = 0;
|
|
14759
|
+
if (bytes.length > config3.maxBufferLength) {
|
|
14760
|
+
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14682
14761
|
}
|
|
14762
|
+
this.bytes = bytes;
|
|
14763
|
+
this.config = config3;
|
|
14764
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
14683
14765
|
}
|
|
14684
|
-
}
|
|
14685
|
-
function
|
|
14686
|
-
|
|
14687
|
-
|
|
14688
|
-
return [];
|
|
14766
|
+
};
|
|
14767
|
+
function check2(bc, min) {
|
|
14768
|
+
if (DEV) {
|
|
14769
|
+
assert2(isU32(min));
|
|
14689
14770
|
}
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
result[i] = readWorkflowPathSegment(bc);
|
|
14771
|
+
if (bc.offset + min > bc.bytes.length) {
|
|
14772
|
+
throw new BareError(bc.offset, "missing bytes");
|
|
14693
14773
|
}
|
|
14694
|
-
return result;
|
|
14695
14774
|
}
|
|
14696
|
-
function
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
switch (tag) {
|
|
14700
|
-
case 0:
|
|
14701
|
-
return "PENDING";
|
|
14702
|
-
case 1:
|
|
14703
|
-
return "RUNNING";
|
|
14704
|
-
case 2:
|
|
14705
|
-
return "COMPLETED";
|
|
14706
|
-
case 3:
|
|
14707
|
-
return "FAILED";
|
|
14708
|
-
case 4:
|
|
14709
|
-
return "EXHAUSTED";
|
|
14710
|
-
default: {
|
|
14711
|
-
bc.offset = offset;
|
|
14712
|
-
throw new BareError(offset, "invalid tag");
|
|
14713
|
-
}
|
|
14775
|
+
function reserve(bc, min) {
|
|
14776
|
+
if (DEV) {
|
|
14777
|
+
assert2(isU32(min));
|
|
14714
14778
|
}
|
|
14715
|
-
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
const tag = readU8(bc);
|
|
14719
|
-
switch (tag) {
|
|
14720
|
-
case 0:
|
|
14721
|
-
return "PENDING";
|
|
14722
|
-
case 1:
|
|
14723
|
-
return "COMPLETED";
|
|
14724
|
-
case 2:
|
|
14725
|
-
return "INTERRUPTED";
|
|
14726
|
-
default: {
|
|
14727
|
-
bc.offset = offset;
|
|
14728
|
-
throw new BareError(offset, "invalid tag");
|
|
14729
|
-
}
|
|
14779
|
+
const minLen = bc.offset + min | 0;
|
|
14780
|
+
if (minLen > bc.bytes.length) {
|
|
14781
|
+
grow(bc, minLen);
|
|
14730
14782
|
}
|
|
14731
14783
|
}
|
|
14732
|
-
function
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
bc.offset = offset;
|
|
14748
|
-
throw new BareError(offset, "invalid tag");
|
|
14784
|
+
function grow(bc, minLen) {
|
|
14785
|
+
if (minLen > bc.config.maxBufferLength) {
|
|
14786
|
+
throw new BareError(0, TOO_LARGE_BUFFER);
|
|
14787
|
+
}
|
|
14788
|
+
const buffer = bc.bytes.buffer;
|
|
14789
|
+
let newBytes;
|
|
14790
|
+
if (isEs2024ArrayBufferLike(buffer) && // Make sure that the view covers the end of the buffer.
|
|
14791
|
+
// If it is not the case, this indicates that the user don't want
|
|
14792
|
+
// to override the trailing bytes.
|
|
14793
|
+
bc.bytes.byteOffset + bc.bytes.byteLength === buffer.byteLength && bc.bytes.byteLength + minLen <= buffer.maxByteLength) {
|
|
14794
|
+
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength, buffer.maxByteLength);
|
|
14795
|
+
if (buffer instanceof ArrayBuffer) {
|
|
14796
|
+
buffer.resize(newLen);
|
|
14797
|
+
} else {
|
|
14798
|
+
buffer.grow(newLen);
|
|
14749
14799
|
}
|
|
14800
|
+
newBytes = new Uint8Array(buffer, bc.bytes.byteOffset, newLen);
|
|
14801
|
+
} else {
|
|
14802
|
+
const newLen = Math.min(minLen << 1, bc.config.maxBufferLength);
|
|
14803
|
+
newBytes = new Uint8Array(newLen);
|
|
14804
|
+
newBytes.set(bc.bytes);
|
|
14750
14805
|
}
|
|
14806
|
+
bc.bytes = newBytes;
|
|
14807
|
+
bc.view = new DataView(newBytes.buffer);
|
|
14751
14808
|
}
|
|
14752
|
-
function
|
|
14753
|
-
return
|
|
14809
|
+
function isEs2024ArrayBufferLike(buffer) {
|
|
14810
|
+
return "maxByteLength" in buffer;
|
|
14754
14811
|
}
|
|
14755
|
-
|
|
14756
|
-
|
|
14812
|
+
|
|
14813
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/fixed-primitive.js
|
|
14814
|
+
function readBool(bc) {
|
|
14815
|
+
const val = readU8(bc);
|
|
14816
|
+
if (val > 1) {
|
|
14817
|
+
bc.offset--;
|
|
14818
|
+
throw new BareError(bc.offset, "a bool must be equal to 0 or 1");
|
|
14819
|
+
}
|
|
14820
|
+
return val > 0;
|
|
14757
14821
|
}
|
|
14758
|
-
function
|
|
14759
|
-
|
|
14760
|
-
output: read0(bc),
|
|
14761
|
-
error: read1(bc)
|
|
14762
|
-
};
|
|
14822
|
+
function writeBool(bc, x) {
|
|
14823
|
+
writeU8(bc, x ? 1 : 0);
|
|
14763
14824
|
}
|
|
14764
|
-
function
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
iteration: readU32(bc),
|
|
14768
|
-
output: read0(bc)
|
|
14769
|
-
};
|
|
14825
|
+
function readU8(bc) {
|
|
14826
|
+
check2(bc, 1);
|
|
14827
|
+
return bc.bytes[bc.offset++];
|
|
14770
14828
|
}
|
|
14771
|
-
function
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14829
|
+
function writeU8(bc, x) {
|
|
14830
|
+
if (DEV) {
|
|
14831
|
+
assert2(isU8(x), TOO_LARGE_NUMBER);
|
|
14832
|
+
}
|
|
14833
|
+
reserve(bc, 1);
|
|
14834
|
+
bc.bytes[bc.offset++] = x;
|
|
14776
14835
|
}
|
|
14777
|
-
function
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14836
|
+
function readU32(bc) {
|
|
14837
|
+
check2(bc, 4);
|
|
14838
|
+
const result = bc.view.getUint32(bc.offset, true);
|
|
14839
|
+
bc.offset += 4;
|
|
14840
|
+
return result;
|
|
14782
14841
|
}
|
|
14783
|
-
function
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14842
|
+
function readU64(bc) {
|
|
14843
|
+
check2(bc, 8);
|
|
14844
|
+
const result = bc.view.getBigUint64(bc.offset, true);
|
|
14845
|
+
bc.offset += 8;
|
|
14846
|
+
return result;
|
|
14787
14847
|
}
|
|
14788
|
-
function
|
|
14789
|
-
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
14793
|
-
|
|
14848
|
+
function writeU64(bc, x) {
|
|
14849
|
+
if (DEV) {
|
|
14850
|
+
assert2(isU64(x), TOO_LARGE_NUMBER);
|
|
14851
|
+
}
|
|
14852
|
+
reserve(bc, 8);
|
|
14853
|
+
bc.view.setBigUint64(bc.offset, x, true);
|
|
14854
|
+
bc.offset += 8;
|
|
14794
14855
|
}
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14856
|
+
|
|
14857
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/uint.js
|
|
14858
|
+
function readUint(bc) {
|
|
14859
|
+
let low = readU8(bc);
|
|
14860
|
+
if (low >= 128) {
|
|
14861
|
+
low &= 127;
|
|
14862
|
+
let shiftMul = 128;
|
|
14863
|
+
let byteCount = 1;
|
|
14864
|
+
let byte;
|
|
14865
|
+
do {
|
|
14866
|
+
byte = readU8(bc);
|
|
14867
|
+
low += (byte & 127) * shiftMul;
|
|
14868
|
+
shiftMul *= /* 2**7 */
|
|
14869
|
+
128;
|
|
14870
|
+
byteCount++;
|
|
14871
|
+
} while (byte >= 128 && byteCount < 7);
|
|
14872
|
+
let height = 0;
|
|
14873
|
+
shiftMul = 1;
|
|
14874
|
+
while (byte >= 128 && byteCount < UINT_MAX_BYTE_COUNT) {
|
|
14875
|
+
byte = readU8(bc);
|
|
14876
|
+
height += (byte & 127) * shiftMul;
|
|
14877
|
+
shiftMul *= /* 2**7 */
|
|
14878
|
+
128;
|
|
14879
|
+
byteCount++;
|
|
14804
14880
|
}
|
|
14805
|
-
|
|
14881
|
+
if (byte === 0 || byteCount === UINT_MAX_BYTE_COUNT && byte > 1) {
|
|
14882
|
+
bc.offset -= byteCount;
|
|
14883
|
+
throw new BareError(bc.offset, NON_CANONICAL_REPRESENTATION);
|
|
14884
|
+
}
|
|
14885
|
+
return BigInt(low) + (BigInt(height) << BigInt(7 * 7));
|
|
14806
14886
|
}
|
|
14807
|
-
return
|
|
14887
|
+
return BigInt(low);
|
|
14808
14888
|
}
|
|
14809
|
-
function
|
|
14810
|
-
|
|
14811
|
-
|
|
14812
|
-
|
|
14889
|
+
function writeUint(bc, x) {
|
|
14890
|
+
const truncated = BigInt.asUintN(64, x);
|
|
14891
|
+
if (DEV) {
|
|
14892
|
+
assert2(truncated === x, TOO_LARGE_NUMBER);
|
|
14893
|
+
}
|
|
14894
|
+
writeUintTruncated(bc, truncated);
|
|
14813
14895
|
}
|
|
14814
|
-
function
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14896
|
+
function writeUintTruncated(bc, x) {
|
|
14897
|
+
let tmp = Number(BigInt.asUintN(7 * 7, x));
|
|
14898
|
+
let rest = Number(x >> BigInt(7 * 7));
|
|
14899
|
+
let byteCount = 0;
|
|
14900
|
+
while (tmp >= 128 || rest > 0) {
|
|
14901
|
+
writeU8(bc, 128 | tmp & 127);
|
|
14902
|
+
tmp = Math.floor(tmp / /* 2**7 */
|
|
14903
|
+
128);
|
|
14904
|
+
byteCount++;
|
|
14905
|
+
if (byteCount === 7) {
|
|
14906
|
+
tmp = rest;
|
|
14907
|
+
rest = 0;
|
|
14908
|
+
}
|
|
14909
|
+
}
|
|
14910
|
+
writeU8(bc, tmp);
|
|
14819
14911
|
}
|
|
14820
|
-
function
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14912
|
+
function readUintSafe32(bc) {
|
|
14913
|
+
let result = readU8(bc);
|
|
14914
|
+
if (result >= 128) {
|
|
14915
|
+
result &= 127;
|
|
14916
|
+
let shift = 7;
|
|
14917
|
+
let byteCount = 1;
|
|
14918
|
+
let byte;
|
|
14919
|
+
do {
|
|
14920
|
+
byte = readU8(bc);
|
|
14921
|
+
result += (byte & 127) << shift >>> 0;
|
|
14922
|
+
shift += 7;
|
|
14923
|
+
byteCount++;
|
|
14924
|
+
} while (byte >= 128 && byteCount < UINT_SAFE32_MAX_BYTE_COUNT);
|
|
14925
|
+
if (byte === 0) {
|
|
14926
|
+
bc.offset -= byteCount - 1;
|
|
14927
|
+
throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
|
|
14928
|
+
}
|
|
14929
|
+
if (byteCount === UINT_SAFE32_MAX_BYTE_COUNT && byte > 15) {
|
|
14930
|
+
bc.offset -= byteCount - 1;
|
|
14931
|
+
throw new BareError(bc.offset, TOO_LARGE_NUMBER);
|
|
14932
|
+
}
|
|
14933
|
+
}
|
|
14934
|
+
return result;
|
|
14825
14935
|
}
|
|
14826
|
-
function
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
|
|
14830
|
-
|
|
14936
|
+
function writeUintSafe32(bc, x) {
|
|
14937
|
+
if (DEV) {
|
|
14938
|
+
assert2(isU32(x), TOO_LARGE_NUMBER);
|
|
14939
|
+
}
|
|
14940
|
+
let zigZag = x >>> 0;
|
|
14941
|
+
while (zigZag >= 128) {
|
|
14942
|
+
writeU8(bc, 128 | zigZag & 127);
|
|
14943
|
+
zigZag >>>= 7;
|
|
14944
|
+
}
|
|
14945
|
+
writeU8(bc, zigZag);
|
|
14831
14946
|
}
|
|
14832
|
-
function
|
|
14833
|
-
|
|
14834
|
-
|
|
14835
|
-
|
|
14836
|
-
|
|
14837
|
-
|
|
14838
|
-
|
|
14839
|
-
|
|
14840
|
-
|
|
14841
|
-
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
14857
|
-
case 6:
|
|
14858
|
-
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
14859
|
-
case 7:
|
|
14860
|
-
return {
|
|
14861
|
-
tag: "WorkflowRemovedEntry",
|
|
14862
|
-
val: readWorkflowRemovedEntry(bc)
|
|
14863
|
-
};
|
|
14864
|
-
case 8:
|
|
14865
|
-
return {
|
|
14866
|
-
tag: "WorkflowVersionCheckEntry",
|
|
14867
|
-
val: readWorkflowVersionCheckEntry(bc)
|
|
14868
|
-
};
|
|
14869
|
-
default: {
|
|
14870
|
-
bc.offset = offset;
|
|
14871
|
-
throw new BareError(offset, "invalid tag");
|
|
14947
|
+
function readUintSafe(bc) {
|
|
14948
|
+
let result = readU8(bc);
|
|
14949
|
+
if (result >= 128) {
|
|
14950
|
+
result &= 127;
|
|
14951
|
+
let shiftMul = (
|
|
14952
|
+
/* 2**7 */
|
|
14953
|
+
128
|
|
14954
|
+
);
|
|
14955
|
+
let byteCount = 1;
|
|
14956
|
+
let byte;
|
|
14957
|
+
do {
|
|
14958
|
+
byte = readU8(bc);
|
|
14959
|
+
result += (byte & 127) * shiftMul;
|
|
14960
|
+
shiftMul *= /* 2**7 */
|
|
14961
|
+
128;
|
|
14962
|
+
byteCount++;
|
|
14963
|
+
} while (byte >= 128 && byteCount < INT_SAFE_MAX_BYTE_COUNT);
|
|
14964
|
+
if (byte === 0) {
|
|
14965
|
+
bc.offset -= byteCount - 1;
|
|
14966
|
+
throw new BareError(bc.offset - byteCount + 1, NON_CANONICAL_REPRESENTATION);
|
|
14967
|
+
}
|
|
14968
|
+
if (byteCount === INT_SAFE_MAX_BYTE_COUNT && byte > 15) {
|
|
14969
|
+
bc.offset -= byteCount - 1;
|
|
14970
|
+
throw new BareError(bc.offset, TOO_LARGE_NUMBER);
|
|
14872
14971
|
}
|
|
14873
14972
|
}
|
|
14973
|
+
return result;
|
|
14874
14974
|
}
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
kind: readWorkflowEntryKind(bc)
|
|
14880
|
-
};
|
|
14975
|
+
|
|
14976
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/u8-array.js
|
|
14977
|
+
function readU8Array(bc) {
|
|
14978
|
+
return readU8FixedArray(bc, readUintSafe32(bc));
|
|
14881
14979
|
}
|
|
14882
|
-
function
|
|
14883
|
-
|
|
14980
|
+
function writeU8Array(bc, x) {
|
|
14981
|
+
writeUintSafe32(bc, x.length);
|
|
14982
|
+
writeU8FixedArray(bc, x);
|
|
14884
14983
|
}
|
|
14885
|
-
function
|
|
14886
|
-
return
|
|
14887
|
-
status: readWorkflowEntryStatus(bc),
|
|
14888
|
-
error: read1(bc),
|
|
14889
|
-
attempts: readU32(bc),
|
|
14890
|
-
lastAttemptAt: readU64(bc),
|
|
14891
|
-
createdAt: readU64(bc),
|
|
14892
|
-
completedAt: read3(bc),
|
|
14893
|
-
rollbackCompletedAt: read3(bc),
|
|
14894
|
-
rollbackError: read1(bc)
|
|
14895
|
-
};
|
|
14984
|
+
function readU8FixedArray(bc, len) {
|
|
14985
|
+
return readUnsafeU8FixedArray(bc, len).slice();
|
|
14896
14986
|
}
|
|
14897
|
-
function
|
|
14898
|
-
const len =
|
|
14899
|
-
if (len
|
|
14900
|
-
|
|
14987
|
+
function writeU8FixedArray(bc, x) {
|
|
14988
|
+
const len = x.length;
|
|
14989
|
+
if (len > 0) {
|
|
14990
|
+
reserve(bc, len);
|
|
14991
|
+
bc.bytes.set(x, bc.offset);
|
|
14992
|
+
bc.offset += len;
|
|
14901
14993
|
}
|
|
14902
|
-
|
|
14903
|
-
|
|
14904
|
-
|
|
14994
|
+
}
|
|
14995
|
+
function readUnsafeU8FixedArray(bc, len) {
|
|
14996
|
+
if (DEV) {
|
|
14997
|
+
assert2(isU32(len));
|
|
14905
14998
|
}
|
|
14906
|
-
|
|
14999
|
+
check2(bc, len);
|
|
15000
|
+
const offset = bc.offset;
|
|
15001
|
+
bc.offset += len;
|
|
15002
|
+
return bc.bytes.subarray(offset, offset + len);
|
|
14907
15003
|
}
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
15004
|
+
|
|
15005
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/data.js
|
|
15006
|
+
function readData(bc) {
|
|
15007
|
+
return readU8Array(bc).buffer;
|
|
15008
|
+
}
|
|
15009
|
+
function writeData(bc, x) {
|
|
15010
|
+
writeU8Array(bc, new Uint8Array(x));
|
|
15011
|
+
}
|
|
15012
|
+
|
|
15013
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/codec/string.js
|
|
15014
|
+
function readString(bc) {
|
|
15015
|
+
return readFixedString(bc, readUintSafe32(bc));
|
|
15016
|
+
}
|
|
15017
|
+
function writeString(bc, x) {
|
|
15018
|
+
if (x.length < TEXT_ENCODER_THRESHOLD) {
|
|
15019
|
+
const byteLen = utf8ByteLength(x);
|
|
15020
|
+
writeUintSafe32(bc, byteLen);
|
|
15021
|
+
reserve(bc, byteLen);
|
|
15022
|
+
writeUtf8Js(bc, x);
|
|
15023
|
+
} else {
|
|
15024
|
+
const strBytes = UTF8_ENCODER.encode(x);
|
|
15025
|
+
writeUintSafe32(bc, strBytes.length);
|
|
15026
|
+
writeU8FixedArray(bc, strBytes);
|
|
14912
15027
|
}
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
15028
|
+
}
|
|
15029
|
+
function readFixedString(bc, byteLen) {
|
|
15030
|
+
if (DEV) {
|
|
15031
|
+
assert2(isU32(byteLen));
|
|
15032
|
+
}
|
|
15033
|
+
if (byteLen < TEXT_DECODER_THRESHOLD) {
|
|
15034
|
+
return readUtf8Js(bc, byteLen);
|
|
15035
|
+
}
|
|
15036
|
+
try {
|
|
15037
|
+
return UTF8_DECODER.decode(readUnsafeU8FixedArray(bc, byteLen));
|
|
15038
|
+
} catch (_cause) {
|
|
15039
|
+
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
14916
15040
|
}
|
|
14917
|
-
return result;
|
|
14918
15041
|
}
|
|
14919
|
-
function
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
15042
|
+
function readUtf8Js(bc, byteLen) {
|
|
15043
|
+
check2(bc, byteLen);
|
|
15044
|
+
let result = "";
|
|
15045
|
+
const bytes = bc.bytes;
|
|
15046
|
+
let offset = bc.offset;
|
|
15047
|
+
const upperOffset = offset + byteLen;
|
|
15048
|
+
while (offset < upperOffset) {
|
|
15049
|
+
let codePoint = bytes[offset++];
|
|
15050
|
+
if (codePoint > 127) {
|
|
15051
|
+
let malformed = true;
|
|
15052
|
+
const byte1 = codePoint;
|
|
15053
|
+
if (offset < upperOffset && codePoint < 224) {
|
|
15054
|
+
const byte2 = bytes[offset++];
|
|
15055
|
+
codePoint = (byte1 & 31) << 6 | byte2 & 63;
|
|
15056
|
+
malformed = codePoint >> 7 === 0 || // non-canonical char
|
|
15057
|
+
byte1 >> 5 !== 6 || // invalid tag
|
|
15058
|
+
byte2 >> 6 !== 2;
|
|
15059
|
+
} else if (offset + 1 < upperOffset && codePoint < 240) {
|
|
15060
|
+
const byte2 = bytes[offset++];
|
|
15061
|
+
const byte3 = bytes[offset++];
|
|
15062
|
+
codePoint = (byte1 & 15) << 12 | (byte2 & 63) << 6 | byte3 & 63;
|
|
15063
|
+
malformed = codePoint >> 11 === 0 || // non-canonical char or missing data
|
|
15064
|
+
codePoint >> 11 === 27 || // surrogate char (0xD800 <= codePoint <= 0xDFFF)
|
|
15065
|
+
byte1 >> 4 !== 14 || // invalid tag
|
|
15066
|
+
byte2 >> 6 !== 2 || // invalid tag
|
|
15067
|
+
byte3 >> 6 !== 2;
|
|
15068
|
+
} else if (offset + 2 < upperOffset) {
|
|
15069
|
+
const byte2 = bytes[offset++];
|
|
15070
|
+
const byte3 = bytes[offset++];
|
|
15071
|
+
const byte4 = bytes[offset++];
|
|
15072
|
+
codePoint = (byte1 & 7) << 18 | (byte2 & 63) << 12 | (byte3 & 63) << 6 | byte4 & 63;
|
|
15073
|
+
malformed = codePoint >> 16 === 0 || // non-canonical char or missing data
|
|
15074
|
+
codePoint > 1114111 || // too large code point
|
|
15075
|
+
byte1 >> 3 !== 30 || // invalid tag
|
|
15076
|
+
byte2 >> 6 !== 2 || // invalid tag
|
|
15077
|
+
byte3 >> 6 !== 2 || // invalid tag
|
|
15078
|
+
byte4 >> 6 !== 2;
|
|
15079
|
+
}
|
|
15080
|
+
if (malformed) {
|
|
15081
|
+
throw new BareError(bc.offset, INVALID_UTF8_STRING);
|
|
15082
|
+
}
|
|
14928
15083
|
}
|
|
14929
|
-
result.
|
|
15084
|
+
result += String.fromCodePoint(codePoint);
|
|
14930
15085
|
}
|
|
15086
|
+
bc.offset = offset;
|
|
14931
15087
|
return result;
|
|
14932
15088
|
}
|
|
14933
|
-
function
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
15089
|
+
function writeUtf8Js(bc, s) {
|
|
15090
|
+
const bytes = bc.bytes;
|
|
15091
|
+
let offset = bc.offset;
|
|
15092
|
+
let i = 0;
|
|
15093
|
+
while (i < s.length) {
|
|
15094
|
+
const codePoint = s.codePointAt(i++);
|
|
15095
|
+
if (codePoint < 128) {
|
|
15096
|
+
bytes[offset++] = codePoint;
|
|
15097
|
+
} else {
|
|
15098
|
+
if (codePoint < 2048) {
|
|
15099
|
+
bytes[offset++] = 192 | codePoint >> 6;
|
|
15100
|
+
} else {
|
|
15101
|
+
if (codePoint < 65536) {
|
|
15102
|
+
bytes[offset++] = 224 | codePoint >> 12;
|
|
15103
|
+
} else {
|
|
15104
|
+
bytes[offset++] = 240 | codePoint >> 18;
|
|
15105
|
+
bytes[offset++] = 128 | codePoint >> 12 & 63;
|
|
15106
|
+
i++;
|
|
15107
|
+
}
|
|
15108
|
+
bytes[offset++] = 128 | codePoint >> 6 & 63;
|
|
15109
|
+
}
|
|
15110
|
+
bytes[offset++] = 128 | codePoint & 63;
|
|
15111
|
+
}
|
|
15112
|
+
}
|
|
15113
|
+
bc.offset = offset;
|
|
14939
15114
|
}
|
|
14940
|
-
function
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
15115
|
+
function utf8ByteLength(s) {
|
|
15116
|
+
let result = s.length;
|
|
15117
|
+
for (let i = 0; i < s.length; i++) {
|
|
15118
|
+
const codePoint = s.codePointAt(i);
|
|
15119
|
+
if (codePoint > 127) {
|
|
15120
|
+
result++;
|
|
15121
|
+
if (codePoint > 2047) {
|
|
15122
|
+
result++;
|
|
15123
|
+
if (codePoint > 65535) {
|
|
15124
|
+
i++;
|
|
15125
|
+
}
|
|
15126
|
+
}
|
|
15127
|
+
}
|
|
14945
15128
|
}
|
|
14946
15129
|
return result;
|
|
14947
15130
|
}
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
}
|
|
15131
|
+
var UTF8_DECODER = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
|
|
15132
|
+
var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
|
|
14951
15133
|
|
|
14952
|
-
//
|
|
14953
|
-
function
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
15134
|
+
// ../../../node_modules/.pnpm/@rivetkit+bare-ts@0.6.2/node_modules/@rivetkit/bare-ts/dist/core/config.js
|
|
15135
|
+
function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32 }) {
|
|
15136
|
+
if (DEV) {
|
|
15137
|
+
assert2(isU32(initialBufferLength), TOO_LARGE_NUMBER);
|
|
15138
|
+
assert2(isU32(maxBufferLength), TOO_LARGE_NUMBER);
|
|
15139
|
+
assert2(initialBufferLength <= maxBufferLength, "initialBufferLength must be lower than or equal to maxBufferLength");
|
|
14957
15140
|
}
|
|
14958
|
-
return
|
|
15141
|
+
return {
|
|
15142
|
+
initialBufferLength,
|
|
15143
|
+
maxBufferLength
|
|
15144
|
+
};
|
|
14959
15145
|
}
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
15146
|
+
|
|
15147
|
+
// ../rivetkit/dist/tsup/chunk-IVX7KBSQ.js
|
|
15148
|
+
var config2 = /* @__PURE__ */ Config({});
|
|
15149
|
+
function readWorkflowCbor(bc) {
|
|
15150
|
+
return readData(bc);
|
|
15151
|
+
}
|
|
15152
|
+
function readWorkflowNameIndex(bc) {
|
|
15153
|
+
return readU32(bc);
|
|
15154
|
+
}
|
|
15155
|
+
function readWorkflowLoopIterationMarker(bc) {
|
|
15156
|
+
return {
|
|
15157
|
+
loop: readWorkflowNameIndex(bc),
|
|
15158
|
+
iteration: readU32(bc)
|
|
15159
|
+
};
|
|
15160
|
+
}
|
|
15161
|
+
function readWorkflowPathSegment(bc) {
|
|
15162
|
+
const offset = bc.offset;
|
|
15163
|
+
const tag = readU8(bc);
|
|
15164
|
+
switch (tag) {
|
|
15165
|
+
case 0:
|
|
15166
|
+
return { tag: "WorkflowNameIndex", val: readWorkflowNameIndex(bc) };
|
|
15167
|
+
case 1:
|
|
15168
|
+
return {
|
|
15169
|
+
tag: "WorkflowLoopIterationMarker",
|
|
15170
|
+
val: readWorkflowLoopIterationMarker(bc)
|
|
15171
|
+
};
|
|
15172
|
+
default: {
|
|
15173
|
+
bc.offset = offset;
|
|
15174
|
+
throw new BareError(offset, "invalid tag");
|
|
14977
15175
|
}
|
|
14978
15176
|
}
|
|
14979
|
-
return flattened;
|
|
14980
15177
|
}
|
|
14981
|
-
function
|
|
14982
|
-
const
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
if (!Object.hasOwn(handlers, name)) {
|
|
14986
|
-
throw new TypeError(
|
|
14987
|
-
`tracing.actions.${name} does not name an action`
|
|
14988
|
-
);
|
|
14989
|
-
}
|
|
15178
|
+
function readWorkflowLocation(bc) {
|
|
15179
|
+
const len = readUintSafe(bc);
|
|
15180
|
+
if (len === 0) {
|
|
15181
|
+
return [];
|
|
14990
15182
|
}
|
|
14991
|
-
|
|
15183
|
+
const result = [readWorkflowPathSegment(bc)];
|
|
15184
|
+
for (let i = 1; i < len; i++) {
|
|
15185
|
+
result[i] = readWorkflowPathSegment(bc);
|
|
15186
|
+
}
|
|
15187
|
+
return result;
|
|
14992
15188
|
}
|
|
14993
|
-
function
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
15189
|
+
function readWorkflowEntryStatus(bc) {
|
|
15190
|
+
const offset = bc.offset;
|
|
15191
|
+
const tag = readU8(bc);
|
|
15192
|
+
switch (tag) {
|
|
15193
|
+
case 0:
|
|
15194
|
+
return "PENDING";
|
|
15195
|
+
case 1:
|
|
15196
|
+
return "RUNNING";
|
|
15197
|
+
case 2:
|
|
15198
|
+
return "COMPLETED";
|
|
15199
|
+
case 3:
|
|
15200
|
+
return "FAILED";
|
|
15201
|
+
case 4:
|
|
15202
|
+
return "EXHAUSTED";
|
|
15203
|
+
default: {
|
|
15204
|
+
bc.offset = offset;
|
|
15205
|
+
throw new BareError(offset, "invalid tag");
|
|
14998
15206
|
}
|
|
14999
|
-
);
|
|
15000
|
-
}
|
|
15001
|
-
function collectActionEntries(actions) {
|
|
15002
|
-
const entries = [];
|
|
15003
|
-
const names = /* @__PURE__ */ new Set();
|
|
15004
|
-
visitActionGroup(actions ?? {}, [], entries, names);
|
|
15005
|
-
return entries;
|
|
15006
|
-
}
|
|
15007
|
-
function visitActionGroup(value, path2, entries, names) {
|
|
15008
|
-
if (!isRecord(value)) {
|
|
15009
|
-
throw new TypeError(
|
|
15010
|
-
`${formatActionPath(path2)} must be an action handler or group`
|
|
15011
|
-
);
|
|
15012
15207
|
}
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
});
|
|
15028
|
-
} else {
|
|
15029
|
-
visitActionGroup(child, childPath, entries, names);
|
|
15208
|
+
}
|
|
15209
|
+
function readWorkflowSleepState(bc) {
|
|
15210
|
+
const offset = bc.offset;
|
|
15211
|
+
const tag = readU8(bc);
|
|
15212
|
+
switch (tag) {
|
|
15213
|
+
case 0:
|
|
15214
|
+
return "PENDING";
|
|
15215
|
+
case 1:
|
|
15216
|
+
return "COMPLETED";
|
|
15217
|
+
case 2:
|
|
15218
|
+
return "INTERRUPTED";
|
|
15219
|
+
default: {
|
|
15220
|
+
bc.offset = offset;
|
|
15221
|
+
throw new BareError(offset, "invalid tag");
|
|
15030
15222
|
}
|
|
15031
15223
|
}
|
|
15032
15224
|
}
|
|
15033
|
-
function
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15225
|
+
function readWorkflowBranchStatusType(bc) {
|
|
15226
|
+
const offset = bc.offset;
|
|
15227
|
+
const tag = readU8(bc);
|
|
15228
|
+
switch (tag) {
|
|
15229
|
+
case 0:
|
|
15230
|
+
return "PENDING";
|
|
15231
|
+
case 1:
|
|
15232
|
+
return "RUNNING";
|
|
15233
|
+
case 2:
|
|
15234
|
+
return "COMPLETED";
|
|
15235
|
+
case 3:
|
|
15236
|
+
return "FAILED";
|
|
15237
|
+
case 4:
|
|
15238
|
+
return "CANCELLED";
|
|
15239
|
+
default: {
|
|
15240
|
+
bc.offset = offset;
|
|
15241
|
+
throw new BareError(offset, "invalid tag");
|
|
15038
15242
|
}
|
|
15039
|
-
value = value[segment];
|
|
15040
15243
|
}
|
|
15041
|
-
return value;
|
|
15042
15244
|
}
|
|
15043
|
-
function
|
|
15044
|
-
|
|
15045
|
-
return false;
|
|
15046
|
-
}
|
|
15047
|
-
const prototype = Object.getPrototypeOf(value);
|
|
15048
|
-
return prototype === Object.prototype || prototype === null;
|
|
15245
|
+
function read0(bc) {
|
|
15246
|
+
return readBool(bc) ? readWorkflowCbor(bc) : null;
|
|
15049
15247
|
}
|
|
15050
|
-
function
|
|
15051
|
-
return
|
|
15248
|
+
function read1(bc) {
|
|
15249
|
+
return readBool(bc) ? readString(bc) : null;
|
|
15052
15250
|
}
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
)
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
return prototype === Object.prototype || prototype === null;
|
|
15066
|
-
}).superRefine((actions, ctx) => {
|
|
15067
|
-
try {
|
|
15068
|
-
flattenActionHandlers(actions);
|
|
15069
|
-
} catch (error46) {
|
|
15070
|
-
ctx.addIssue({
|
|
15071
|
-
code: "custom",
|
|
15072
|
-
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15073
|
-
});
|
|
15074
|
-
}
|
|
15075
|
-
});
|
|
15076
|
-
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
15077
|
-
getHistory: zFunction(),
|
|
15078
|
-
getState: zFunction().optional(),
|
|
15079
|
-
onHistoryUpdated: zFunction().optional(),
|
|
15080
|
-
replayFromStep: zFunction().optional()
|
|
15081
|
-
});
|
|
15082
|
-
var RunInspectorConfigSchema = external_exports.object({
|
|
15083
|
-
workflow: WorkflowInspectorConfigSchema.optional()
|
|
15084
|
-
}).optional();
|
|
15085
|
-
var BUILTIN_INSPECTOR_TAB_IDS = [
|
|
15086
|
-
"workflow",
|
|
15087
|
-
"database",
|
|
15088
|
-
"state",
|
|
15089
|
-
"queue",
|
|
15090
|
-
"schedules",
|
|
15091
|
-
"connections",
|
|
15092
|
-
"console"
|
|
15093
|
-
];
|
|
15094
|
-
var BuiltinInspectorTabIdSchema = external_exports.enum(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15095
|
-
var CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
15096
|
-
var CustomInspectorTabEntrySchema = external_exports.object({
|
|
15097
|
-
id: external_exports.string().regex(
|
|
15098
|
-
CUSTOM_INSPECTOR_TAB_ID_RE,
|
|
15099
|
-
"inspector.tabs[].id must contain only letters, digits, underscore, or dash"
|
|
15100
|
-
),
|
|
15101
|
-
label: external_exports.string().min(1),
|
|
15102
|
-
source: external_exports.string().min(1),
|
|
15103
|
-
/**
|
|
15104
|
-
* Optional icon id. The dashboard maps strings to glyphs (see its
|
|
15105
|
-
* icon registry); unknown ids fall back to a generic icon.
|
|
15106
|
-
*/
|
|
15107
|
-
icon: external_exports.string().min(1).optional(),
|
|
15108
|
-
hidden: external_exports.literal(false).optional()
|
|
15109
|
-
}).strict();
|
|
15110
|
-
var HideInspectorTabEntrySchema = external_exports.object({
|
|
15111
|
-
id: BuiltinInspectorTabIdSchema,
|
|
15112
|
-
hidden: external_exports.literal(true)
|
|
15113
|
-
}).strict();
|
|
15114
|
-
var InspectorTabEntrySchema = external_exports.union([
|
|
15115
|
-
CustomInspectorTabEntrySchema,
|
|
15116
|
-
HideInspectorTabEntrySchema
|
|
15117
|
-
]);
|
|
15118
|
-
var ActorInspectorConfigSchema = external_exports.object({
|
|
15119
|
-
tabs: external_exports.array(InspectorTabEntrySchema).default(() => [])
|
|
15120
|
-
}).strict().refine(
|
|
15121
|
-
(data) => {
|
|
15122
|
-
const ids = data.tabs.map((t) => t.id);
|
|
15123
|
-
return new Set(ids).size === ids.length;
|
|
15124
|
-
},
|
|
15125
|
-
{ message: "Duplicate id in inspector.tabs", path: ["tabs"] }
|
|
15126
|
-
).refine(
|
|
15127
|
-
(data) => {
|
|
15128
|
-
const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
|
|
15129
|
-
return data.tabs.every(
|
|
15130
|
-
(t) => t.hidden === true || !builtinSet.has(t.id)
|
|
15131
|
-
);
|
|
15132
|
-
},
|
|
15133
|
-
{
|
|
15134
|
-
message: "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
|
|
15135
|
-
path: ["tabs"]
|
|
15136
|
-
}
|
|
15137
|
-
);
|
|
15138
|
-
var RunConfigSchema = external_exports.object({
|
|
15139
|
-
/** Display name for the actor in the Inspector UI. */
|
|
15140
|
-
name: external_exports.string().optional(),
|
|
15141
|
-
/** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
|
|
15142
|
-
icon: external_exports.string().optional(),
|
|
15143
|
-
/** The run handler function. */
|
|
15144
|
-
run: zFunction(),
|
|
15145
|
-
/** Inspector integration for long-running run handlers. */
|
|
15146
|
-
inspector: RunInspectorConfigSchema.optional()
|
|
15147
|
-
});
|
|
15148
|
-
var RUN_FUNCTION_CONFIG_SYMBOL = /* @__PURE__ */ Symbol.for("rivetkit.run_function_config");
|
|
15149
|
-
function defineRunHandler(run, options) {
|
|
15150
|
-
if (options.inspectorKind === void 0 !== (options.createInspector === void 0)) {
|
|
15151
|
-
throw new TypeError(
|
|
15152
|
-
"defineRunHandler requires inspectorKind and createInspector together"
|
|
15153
|
-
);
|
|
15154
|
-
}
|
|
15155
|
-
Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
|
|
15156
|
-
configurable: false,
|
|
15157
|
-
enumerable: false,
|
|
15158
|
-
writable: false,
|
|
15159
|
-
value: {
|
|
15160
|
-
name: options.name,
|
|
15161
|
-
icon: options.icon,
|
|
15162
|
-
inspectorKind: options.inspectorKind,
|
|
15163
|
-
createInspector: options.createInspector
|
|
15164
|
-
}
|
|
15165
|
-
});
|
|
15166
|
-
return run;
|
|
15251
|
+
function readWorkflowStepEntry(bc) {
|
|
15252
|
+
return {
|
|
15253
|
+
output: read0(bc),
|
|
15254
|
+
error: read1(bc)
|
|
15255
|
+
};
|
|
15256
|
+
}
|
|
15257
|
+
function readWorkflowLoopEntry(bc) {
|
|
15258
|
+
return {
|
|
15259
|
+
state: readWorkflowCbor(bc),
|
|
15260
|
+
iteration: readU32(bc),
|
|
15261
|
+
output: read0(bc)
|
|
15262
|
+
};
|
|
15167
15263
|
}
|
|
15168
|
-
function
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15264
|
+
function readWorkflowSleepEntry(bc) {
|
|
15265
|
+
return {
|
|
15266
|
+
deadline: readU64(bc),
|
|
15267
|
+
state: readWorkflowSleepState(bc)
|
|
15268
|
+
};
|
|
15172
15269
|
}
|
|
15173
|
-
function
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15270
|
+
function readWorkflowMessageEntry(bc) {
|
|
15271
|
+
return {
|
|
15272
|
+
name: readString(bc),
|
|
15273
|
+
messageData: readWorkflowCbor(bc)
|
|
15274
|
+
};
|
|
15177
15275
|
}
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15182
|
-
return run.run;
|
|
15276
|
+
function readWorkflowRollbackCheckpointEntry(bc) {
|
|
15277
|
+
return {
|
|
15278
|
+
name: readString(bc)
|
|
15279
|
+
};
|
|
15183
15280
|
}
|
|
15184
|
-
function
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
}
|
|
15191
|
-
return { name: run.name, icon: run.icon };
|
|
15281
|
+
function readWorkflowBranchStatus(bc) {
|
|
15282
|
+
return {
|
|
15283
|
+
status: readWorkflowBranchStatusType(bc),
|
|
15284
|
+
output: read0(bc),
|
|
15285
|
+
error: read1(bc)
|
|
15286
|
+
};
|
|
15192
15287
|
}
|
|
15193
|
-
function
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15288
|
+
function read2(bc) {
|
|
15289
|
+
const len = readUintSafe(bc);
|
|
15290
|
+
const result = /* @__PURE__ */ new Map();
|
|
15291
|
+
for (let i = 0; i < len; i++) {
|
|
15292
|
+
const offset = bc.offset;
|
|
15293
|
+
const key = readString(bc);
|
|
15294
|
+
if (result.has(key)) {
|
|
15295
|
+
bc.offset = offset;
|
|
15296
|
+
throw new BareError(offset, "duplicated key");
|
|
15297
|
+
}
|
|
15298
|
+
result.set(key, readWorkflowBranchStatus(bc));
|
|
15198
15299
|
}
|
|
15199
|
-
return
|
|
15300
|
+
return result;
|
|
15200
15301
|
}
|
|
15201
|
-
function
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
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;
|
|
15302
|
+
function readWorkflowJoinEntry(bc) {
|
|
15303
|
+
return {
|
|
15304
|
+
branches: read2(bc)
|
|
15305
|
+
};
|
|
15206
15306
|
}
|
|
15207
|
-
function
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15307
|
+
function readWorkflowRaceEntry(bc) {
|
|
15308
|
+
return {
|
|
15309
|
+
winner: read1(bc),
|
|
15310
|
+
branches: read2(bc)
|
|
15311
|
+
};
|
|
15312
|
+
}
|
|
15313
|
+
function readWorkflowRemovedEntry(bc) {
|
|
15314
|
+
return {
|
|
15315
|
+
originalType: readString(bc),
|
|
15316
|
+
originalName: read1(bc)
|
|
15317
|
+
};
|
|
15318
|
+
}
|
|
15319
|
+
function readWorkflowVersionCheckEntry(bc) {
|
|
15320
|
+
return {
|
|
15321
|
+
resolved: readU32(bc),
|
|
15322
|
+
latest: readU32(bc)
|
|
15323
|
+
};
|
|
15324
|
+
}
|
|
15325
|
+
function readWorkflowEntryKind(bc) {
|
|
15326
|
+
const offset = bc.offset;
|
|
15327
|
+
const tag = readU8(bc);
|
|
15328
|
+
switch (tag) {
|
|
15329
|
+
case 0:
|
|
15330
|
+
return { tag: "WorkflowStepEntry", val: readWorkflowStepEntry(bc) };
|
|
15331
|
+
case 1:
|
|
15332
|
+
return { tag: "WorkflowLoopEntry", val: readWorkflowLoopEntry(bc) };
|
|
15333
|
+
case 2:
|
|
15334
|
+
return {
|
|
15335
|
+
tag: "WorkflowSleepEntry",
|
|
15336
|
+
val: readWorkflowSleepEntry(bc)
|
|
15337
|
+
};
|
|
15338
|
+
case 3:
|
|
15339
|
+
return {
|
|
15340
|
+
tag: "WorkflowMessageEntry",
|
|
15341
|
+
val: readWorkflowMessageEntry(bc)
|
|
15342
|
+
};
|
|
15343
|
+
case 4:
|
|
15344
|
+
return {
|
|
15345
|
+
tag: "WorkflowRollbackCheckpointEntry",
|
|
15346
|
+
val: readWorkflowRollbackCheckpointEntry(bc)
|
|
15347
|
+
};
|
|
15348
|
+
case 5:
|
|
15349
|
+
return { tag: "WorkflowJoinEntry", val: readWorkflowJoinEntry(bc) };
|
|
15350
|
+
case 6:
|
|
15351
|
+
return { tag: "WorkflowRaceEntry", val: readWorkflowRaceEntry(bc) };
|
|
15352
|
+
case 7:
|
|
15353
|
+
return {
|
|
15354
|
+
tag: "WorkflowRemovedEntry",
|
|
15355
|
+
val: readWorkflowRemovedEntry(bc)
|
|
15356
|
+
};
|
|
15357
|
+
case 8:
|
|
15358
|
+
return {
|
|
15359
|
+
tag: "WorkflowVersionCheckEntry",
|
|
15360
|
+
val: readWorkflowVersionCheckEntry(bc)
|
|
15361
|
+
};
|
|
15362
|
+
default: {
|
|
15363
|
+
bc.offset = offset;
|
|
15364
|
+
throw new BareError(offset, "invalid tag");
|
|
15365
|
+
}
|
|
15211
15366
|
}
|
|
15212
|
-
const config3 = run[RUN_FUNCTION_CONFIG_SYMBOL];
|
|
15213
|
-
(_a2 = config3 == null ? void 0 : config3.disposeInspector) == null ? void 0 : _a2.call(config3, actorId);
|
|
15214
15367
|
}
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
)
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
stateSaveInterval: external_exports.number().positive().default(1e3),
|
|
15246
|
-
actionTimeout: external_exports.number().positive().default(6e4),
|
|
15247
|
-
connectionLivenessTimeout: external_exports.number().positive().default(2500),
|
|
15248
|
-
connectionLivenessInterval: external_exports.number().positive().default(5e3),
|
|
15249
|
-
/** @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. */
|
|
15250
|
-
noSleep: external_exports.boolean().default(false),
|
|
15251
|
-
sleepTimeout: external_exports.number().positive().default(3e4),
|
|
15252
|
-
maxQueueSize: external_exports.number().positive().default(1e3),
|
|
15253
|
-
/** Maximum pending one-shot and recurring schedules. */
|
|
15254
|
-
maxSchedules: external_exports.number().int().nonnegative().default(1e3),
|
|
15255
|
-
maxQueueMessageSize: external_exports.number().positive().default(64 * 1024),
|
|
15256
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15257
|
-
preloadMaxWorkflowBytes: external_exports.number().nonnegative().optional(),
|
|
15258
|
-
/** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 2.2.0. */
|
|
15259
|
-
preloadMaxConnectionsBytes: external_exports.number().nonnegative().optional()
|
|
15260
|
-
}).strict();
|
|
15261
|
-
var InstanceActorOptionsSchema = InstanceActorOptionsBaseSchema.prefault(() => ({}));
|
|
15262
|
-
var ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
|
|
15263
|
-
InstanceActorOptionsBaseSchema.shape
|
|
15264
|
-
).strict().prefault(() => ({}));
|
|
15265
|
-
var zSampleRate = external_exports.number().min(0).max(1);
|
|
15266
|
-
var zActionSampleRates = external_exports.lazy(
|
|
15267
|
-
() => external_exports.record(external_exports.string(), external_exports.union([zSampleRate, zActionSampleRates]))
|
|
15268
|
-
);
|
|
15269
|
-
var ActorConfigSchema = external_exports.object({
|
|
15270
|
-
onCreate: zFunction().optional(),
|
|
15271
|
-
onDestroy: zFunction().optional(),
|
|
15272
|
-
onMigrate: zFunction().optional(),
|
|
15273
|
-
onWake: zFunction().optional(),
|
|
15274
|
-
onSleep: zFunction().optional(),
|
|
15275
|
-
run: zRunHandler,
|
|
15276
|
-
onStateChange: zFunction().optional(),
|
|
15277
|
-
onBeforeConnect: zFunction().optional(),
|
|
15278
|
-
onConnect: zFunction().optional(),
|
|
15279
|
-
onDisconnect: zFunction().optional(),
|
|
15280
|
-
onBeforeActionResponse: zFunction().optional(),
|
|
15281
|
-
onRequest: zFunction().optional(),
|
|
15282
|
-
onWebSocket: zFunction().optional(),
|
|
15283
|
-
actions: zActionTree.default(() => ({})),
|
|
15284
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15285
|
-
tracing: external_exports.object({
|
|
15286
|
-
sampler: zSampleRate.optional(),
|
|
15287
|
-
actions: zActionSampleRates.optional()
|
|
15288
|
-
}).strict().optional(),
|
|
15289
|
-
connParamsSchema: external_exports.any().optional(),
|
|
15290
|
-
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15291
|
-
queues: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15292
|
-
state: external_exports.any().optional(),
|
|
15293
|
-
createState: zFunction().optional(),
|
|
15294
|
-
connState: external_exports.any().optional(),
|
|
15295
|
-
createConnState: zFunction().optional(),
|
|
15296
|
-
vars: external_exports.any().optional(),
|
|
15297
|
-
db: external_exports.any().optional(),
|
|
15298
|
-
createVars: zFunction().optional(),
|
|
15299
|
-
options: ActorOptionsSchema,
|
|
15300
|
-
inspector: ActorInspectorConfigSchema.optional()
|
|
15301
|
-
}).strict().refine(
|
|
15302
|
-
(data) => !(data.state !== void 0 && data.createState !== void 0),
|
|
15303
|
-
{
|
|
15304
|
-
message: "Cannot define both 'state' and 'createState'",
|
|
15305
|
-
path: ["state"]
|
|
15368
|
+
function readWorkflowEntry(bc) {
|
|
15369
|
+
return {
|
|
15370
|
+
id: readString(bc),
|
|
15371
|
+
location: readWorkflowLocation(bc),
|
|
15372
|
+
kind: readWorkflowEntryKind(bc)
|
|
15373
|
+
};
|
|
15374
|
+
}
|
|
15375
|
+
function read3(bc) {
|
|
15376
|
+
return readBool(bc) ? readU64(bc) : null;
|
|
15377
|
+
}
|
|
15378
|
+
function readWorkflowEntryMetadata(bc) {
|
|
15379
|
+
return {
|
|
15380
|
+
status: readWorkflowEntryStatus(bc),
|
|
15381
|
+
error: read1(bc),
|
|
15382
|
+
attempts: readU32(bc),
|
|
15383
|
+
lastAttemptAt: readU64(bc),
|
|
15384
|
+
createdAt: readU64(bc),
|
|
15385
|
+
completedAt: read3(bc),
|
|
15386
|
+
rollbackCompletedAt: read3(bc),
|
|
15387
|
+
rollbackError: read1(bc)
|
|
15388
|
+
};
|
|
15389
|
+
}
|
|
15390
|
+
function read4(bc) {
|
|
15391
|
+
const len = readUintSafe(bc);
|
|
15392
|
+
if (len === 0) {
|
|
15393
|
+
return [];
|
|
15394
|
+
}
|
|
15395
|
+
const result = [readString(bc)];
|
|
15396
|
+
for (let i = 1; i < len; i++) {
|
|
15397
|
+
result[i] = readString(bc);
|
|
15306
15398
|
}
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15399
|
+
return result;
|
|
15400
|
+
}
|
|
15401
|
+
function read5(bc) {
|
|
15402
|
+
const len = readUintSafe(bc);
|
|
15403
|
+
if (len === 0) {
|
|
15404
|
+
return [];
|
|
15312
15405
|
}
|
|
15313
|
-
)
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
message: "Cannot define both 'vars' and 'createVars'",
|
|
15317
|
-
path: ["vars"]
|
|
15406
|
+
const result = [readWorkflowEntry(bc)];
|
|
15407
|
+
for (let i = 1; i < len; i++) {
|
|
15408
|
+
result[i] = readWorkflowEntry(bc);
|
|
15318
15409
|
}
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
)
|
|
15325
|
-
|
|
15326
|
-
|
|
15327
|
-
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
|
|
15338
|
-
|
|
15339
|
-
|
|
15340
|
-
|
|
15341
|
-
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
15345
|
-
)
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
|
|
15353
|
-
connectionLivenessInterval: external_exports.number().optional().describe(
|
|
15354
|
-
"Interval in ms between connection liveness checks. Default: 5000"
|
|
15355
|
-
),
|
|
15356
|
-
noSleep: external_exports.boolean().optional().describe(
|
|
15357
|
-
"Deprecated. If true, the actor will never sleep. Use c.keepAwake(promise) to scope keep-awake to a specific operation instead. Default: false"
|
|
15358
|
-
),
|
|
15359
|
-
sleepTimeout: external_exports.number().optional().describe(
|
|
15360
|
-
"Time in ms of inactivity before the actor sleeps. Default: 30000"
|
|
15361
|
-
),
|
|
15362
|
-
maxQueueSize: external_exports.number().optional().describe(
|
|
15363
|
-
"Maximum number of queue messages before rejecting new messages. Default: 1000"
|
|
15364
|
-
),
|
|
15365
|
-
maxSchedules: external_exports.number().int().nonnegative().optional().describe(
|
|
15366
|
-
"Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000"
|
|
15367
|
-
),
|
|
15368
|
-
maxQueueMessageSize: external_exports.number().optional().describe(
|
|
15369
|
-
"Maximum size of each queue message in bytes. Default: 65536"
|
|
15370
|
-
),
|
|
15371
|
-
canHibernateWebSocket: external_exports.boolean().optional().describe(
|
|
15372
|
-
"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"
|
|
15373
|
-
)
|
|
15374
|
-
}).describe("Actor options for timeouts and behavior configuration.");
|
|
15375
|
-
var DocActorConfigSchema = external_exports.object({
|
|
15376
|
-
state: external_exports.unknown().optional().describe(
|
|
15377
|
-
"Initial state value for the actor. Cannot be used with createState."
|
|
15378
|
-
),
|
|
15379
|
-
createState: external_exports.unknown().optional().describe(
|
|
15380
|
-
"Function to create initial state. Receives context and input. Cannot be used with state."
|
|
15381
|
-
),
|
|
15382
|
-
connState: external_exports.unknown().optional().describe(
|
|
15383
|
-
"Initial connection state value. Cannot be used with createConnState."
|
|
15384
|
-
),
|
|
15385
|
-
createConnState: external_exports.unknown().optional().describe(
|
|
15386
|
-
"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."
|
|
15387
|
-
),
|
|
15388
|
-
vars: external_exports.unknown().optional().describe(
|
|
15389
|
-
"Initial ephemeral variables value. Cannot be used with createVars."
|
|
15390
|
-
),
|
|
15391
|
-
createVars: external_exports.unknown().optional().describe(
|
|
15392
|
-
"Function to create ephemeral variables. Receives context and driver context. Cannot be used with vars."
|
|
15393
|
-
),
|
|
15394
|
-
db: external_exports.unknown().optional().describe("Database provider instance for the actor."),
|
|
15395
|
-
onCreate: external_exports.unknown().optional().describe(
|
|
15396
|
-
"Called when the actor is first initialized. Use to initialize state."
|
|
15397
|
-
),
|
|
15398
|
-
onDestroy: external_exports.unknown().optional().describe("Called when the actor is destroyed."),
|
|
15399
|
-
onMigrate: external_exports.unknown().optional().describe(
|
|
15400
|
-
"Called on every actor start after persisted state loads and before onWake. Use for repeatable schema migrations."
|
|
15401
|
-
),
|
|
15402
|
-
onWake: external_exports.unknown().optional().describe(
|
|
15403
|
-
"Called when the actor wakes up and is ready to receive connections and actions."
|
|
15404
|
-
),
|
|
15405
|
-
onSleep: external_exports.unknown().optional().describe(
|
|
15406
|
-
"Called when the actor is stopping or sleeping. Use to clean up resources."
|
|
15407
|
-
),
|
|
15408
|
-
run: external_exports.unknown().optional().describe(
|
|
15409
|
-
"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."
|
|
15410
|
-
),
|
|
15411
|
-
onStateChange: external_exports.unknown().optional().describe(
|
|
15412
|
-
"Called when the actor's state changes. State changes within this hook won't trigger recursion."
|
|
15413
|
-
),
|
|
15414
|
-
onBeforeConnect: external_exports.unknown().optional().describe(
|
|
15415
|
-
"Called before a client connects. Throw an error to reject the connection. The pending connection is not visible in c.conns while this runs."
|
|
15416
|
-
),
|
|
15417
|
-
onConnect: external_exports.unknown().optional().describe(
|
|
15418
|
-
"Called when a client successfully connects. The connection is visible in c.conns before this runs."
|
|
15419
|
-
),
|
|
15420
|
-
onDisconnect: external_exports.unknown().optional().describe("Called when a client disconnects."),
|
|
15421
|
-
onBeforeActionResponse: external_exports.unknown().optional().describe(
|
|
15422
|
-
"Called before sending an action response. Use to transform output."
|
|
15423
|
-
),
|
|
15424
|
-
onRequest: external_exports.unknown().optional().describe(
|
|
15425
|
-
"Called for raw HTTP requests to /actors/{name}/http/* endpoints."
|
|
15426
|
-
),
|
|
15427
|
-
onWebSocket: external_exports.unknown().optional().describe(
|
|
15428
|
-
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15429
|
-
),
|
|
15430
|
-
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15431
|
-
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15432
|
-
),
|
|
15433
|
-
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15434
|
-
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15435
|
-
),
|
|
15436
|
-
tracing: external_exports.unknown().optional().describe(
|
|
15437
|
-
"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."
|
|
15438
|
-
),
|
|
15439
|
-
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15440
|
-
"Optional schema for validating connection params in native runtimes."
|
|
15441
|
-
),
|
|
15442
|
-
events: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of event names to schemas."),
|
|
15443
|
-
queues: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Map of queue names to schemas."),
|
|
15444
|
-
options: DocActorOptionsSchema.optional()
|
|
15445
|
-
}).describe("Actor configuration passed to the actor() function.");
|
|
15410
|
+
return result;
|
|
15411
|
+
}
|
|
15412
|
+
function read6(bc) {
|
|
15413
|
+
const len = readUintSafe(bc);
|
|
15414
|
+
const result = /* @__PURE__ */ new Map();
|
|
15415
|
+
for (let i = 0; i < len; i++) {
|
|
15416
|
+
const offset = bc.offset;
|
|
15417
|
+
const key = readString(bc);
|
|
15418
|
+
if (result.has(key)) {
|
|
15419
|
+
bc.offset = offset;
|
|
15420
|
+
throw new BareError(offset, "duplicated key");
|
|
15421
|
+
}
|
|
15422
|
+
result.set(key, readWorkflowEntryMetadata(bc));
|
|
15423
|
+
}
|
|
15424
|
+
return result;
|
|
15425
|
+
}
|
|
15426
|
+
function readWorkflowHistory(bc) {
|
|
15427
|
+
return {
|
|
15428
|
+
nameRegistry: read4(bc),
|
|
15429
|
+
entries: read5(bc),
|
|
15430
|
+
entryMetadata: read6(bc)
|
|
15431
|
+
};
|
|
15432
|
+
}
|
|
15433
|
+
function decodeWorkflowHistory(bytes) {
|
|
15434
|
+
const bc = new ByteCursor(bytes, config2);
|
|
15435
|
+
const result = readWorkflowHistory(bc);
|
|
15436
|
+
if (bc.offset < bc.view.byteLength) {
|
|
15437
|
+
throw new BareError(bc.offset, "remaining bytes");
|
|
15438
|
+
}
|
|
15439
|
+
return result;
|
|
15440
|
+
}
|
|
15441
|
+
function decodeWorkflowHistoryTransport(data) {
|
|
15442
|
+
return decodeWorkflowHistory(toUint8Array(data));
|
|
15443
|
+
}
|
|
15446
15444
|
|
|
15447
15445
|
// ../rivetkit/dist/tsup/chunk-JI6GZ2C2.js
|
|
15448
15446
|
var EMPTY_KEY = "/";
|
|
@@ -15561,6 +15559,44 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15561
15559
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15562
15560
|
}
|
|
15563
15561
|
|
|
15562
|
+
// ../rivetkit/dist/tsup/chunk-EOYS5GVX.js
|
|
15563
|
+
function logger() {
|
|
15564
|
+
return getLogger("actor-client");
|
|
15565
|
+
}
|
|
15566
|
+
var webSocketPromise = null;
|
|
15567
|
+
async function importWebSocket() {
|
|
15568
|
+
if (webSocketPromise !== null) {
|
|
15569
|
+
return webSocketPromise;
|
|
15570
|
+
}
|
|
15571
|
+
webSocketPromise = (async () => {
|
|
15572
|
+
let _WebSocket;
|
|
15573
|
+
if (typeof WebSocket !== "undefined") {
|
|
15574
|
+
_WebSocket = WebSocket;
|
|
15575
|
+
} else {
|
|
15576
|
+
try {
|
|
15577
|
+
const moduleName = "ws";
|
|
15578
|
+
const ws = await import(
|
|
15579
|
+
/* webpackIgnore: true */
|
|
15580
|
+
moduleName
|
|
15581
|
+
);
|
|
15582
|
+
_WebSocket = ws.default;
|
|
15583
|
+
logger().debug("using websocket from npm");
|
|
15584
|
+
} catch {
|
|
15585
|
+
_WebSocket = class MockWebSocket {
|
|
15586
|
+
constructor() {
|
|
15587
|
+
throw new Error(
|
|
15588
|
+
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15589
|
+
);
|
|
15590
|
+
}
|
|
15591
|
+
};
|
|
15592
|
+
logger().debug("using mock websocket");
|
|
15593
|
+
}
|
|
15594
|
+
}
|
|
15595
|
+
return _WebSocket;
|
|
15596
|
+
})();
|
|
15597
|
+
return webSocketPromise;
|
|
15598
|
+
}
|
|
15599
|
+
|
|
15564
15600
|
// ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
|
|
15565
15601
|
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15566
15602
|
function isManualTransactionControl(query) {
|
|
@@ -15644,45 +15680,7 @@ var AsyncMutex = class {
|
|
|
15644
15680
|
}
|
|
15645
15681
|
};
|
|
15646
15682
|
|
|
15647
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15648
|
-
function logger() {
|
|
15649
|
-
return getLogger("actor-client");
|
|
15650
|
-
}
|
|
15651
|
-
var webSocketPromise = null;
|
|
15652
|
-
async function importWebSocket() {
|
|
15653
|
-
if (webSocketPromise !== null) {
|
|
15654
|
-
return webSocketPromise;
|
|
15655
|
-
}
|
|
15656
|
-
webSocketPromise = (async () => {
|
|
15657
|
-
let _WebSocket;
|
|
15658
|
-
if (typeof WebSocket !== "undefined") {
|
|
15659
|
-
_WebSocket = WebSocket;
|
|
15660
|
-
} else {
|
|
15661
|
-
try {
|
|
15662
|
-
const moduleName = "ws";
|
|
15663
|
-
const ws = await import(
|
|
15664
|
-
/* webpackIgnore: true */
|
|
15665
|
-
moduleName
|
|
15666
|
-
);
|
|
15667
|
-
_WebSocket = ws.default;
|
|
15668
|
-
logger().debug("using websocket from npm");
|
|
15669
|
-
} catch {
|
|
15670
|
-
_WebSocket = class MockWebSocket {
|
|
15671
|
-
constructor() {
|
|
15672
|
-
throw new Error(
|
|
15673
|
-
'WebSocket support requires installing the "ws" peer dependency.'
|
|
15674
|
-
);
|
|
15675
|
-
}
|
|
15676
|
-
};
|
|
15677
|
-
logger().debug("using mock websocket");
|
|
15678
|
-
}
|
|
15679
|
-
}
|
|
15680
|
-
return _WebSocket;
|
|
15681
|
-
})();
|
|
15682
|
-
return webSocketPromise;
|
|
15683
|
-
}
|
|
15684
|
-
|
|
15685
|
-
// ../rivetkit/dist/tsup/chunk-I472KTIC.js
|
|
15683
|
+
// ../rivetkit/dist/tsup/chunk-7VIY7WIH.js
|
|
15686
15684
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15687
15685
|
|
|
15688
15686
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -16897,7 +16895,7 @@ var TraceAPI = (
|
|
|
16897
16895
|
// ../../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
|
|
16898
16896
|
var trace = TraceAPI.getInstance();
|
|
16899
16897
|
|
|
16900
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
16898
|
+
// ../rivetkit/dist/tsup/chunk-7VIY7WIH.js
|
|
16901
16899
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
16902
16900
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
16903
16901
|
var PATH_CONNECT = "/connect";
|
|
@@ -23093,7 +23091,7 @@ function apiActorToOutput(actor2) {
|
|
|
23093
23091
|
};
|
|
23094
23092
|
}
|
|
23095
23093
|
|
|
23096
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
23094
|
+
// ../rivetkit/dist/tsup/chunk-XWEGENG4.js
|
|
23097
23095
|
var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
|
|
23098
23096
|
var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
|
|
23099
23097
|
function registerNativeStateTransactionOpener(provider, opener) {
|