@rivetkit/supabase 2.3.5-rc.1 → 2.3.6
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 +363 -156
- package/dist/mod.mjs +363 -156
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -508,7 +508,7 @@ function unsupportedFeature(feature) {
|
|
|
508
508
|
);
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
511
|
+
// ../rivetkit/dist/tsup/chunk-RDTFPGU2.js
|
|
512
512
|
var import_pino = require("pino");
|
|
513
513
|
|
|
514
514
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
@@ -13181,7 +13181,7 @@ var classic_default = external_exports;
|
|
|
13181
13181
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13182
13182
|
var v4_default = classic_default;
|
|
13183
13183
|
|
|
13184
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13184
|
+
// ../rivetkit/dist/tsup/chunk-RDTFPGU2.js
|
|
13185
13185
|
var cbor = __toESM(require("cbor-x"), 1);
|
|
13186
13186
|
var import_invariant = __toESM(require_invariant(), 1);
|
|
13187
13187
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
@@ -13346,7 +13346,7 @@ function noopNext() {
|
|
|
13346
13346
|
}
|
|
13347
13347
|
var package_default = {
|
|
13348
13348
|
name: "rivetkit",
|
|
13349
|
-
version: "2.3.
|
|
13349
|
+
version: "2.3.6",
|
|
13350
13350
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13351
13351
|
license: "Apache-2.0",
|
|
13352
13352
|
keywords: [
|
|
@@ -13418,6 +13418,16 @@ var package_default = {
|
|
|
13418
13418
|
default: "./dist/tsup/db/drizzle.cjs"
|
|
13419
13419
|
}
|
|
13420
13420
|
},
|
|
13421
|
+
"./unstable/migrations": {
|
|
13422
|
+
import: {
|
|
13423
|
+
types: "./dist/tsup/unstable/migrations.d.ts",
|
|
13424
|
+
default: "./dist/tsup/unstable/migrations.js"
|
|
13425
|
+
},
|
|
13426
|
+
require: {
|
|
13427
|
+
types: "./dist/tsup/unstable/migrations.d.cts",
|
|
13428
|
+
default: "./dist/tsup/unstable/migrations.cjs"
|
|
13429
|
+
}
|
|
13430
|
+
},
|
|
13421
13431
|
"./dynamic": {
|
|
13422
13432
|
import: {
|
|
13423
13433
|
types: "./dist/tsup/dynamic/mod.d.ts",
|
|
@@ -13517,7 +13527,7 @@ var package_default = {
|
|
|
13517
13527
|
"./dist/tsup/chunk-*.cjs"
|
|
13518
13528
|
],
|
|
13519
13529
|
scripts: {
|
|
13520
|
-
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-tab/mod.ts src/db/mod.ts src/db/drizzle.ts src/dynamic/mod.ts && tsup src/agent-os/index.ts --no-clean --out-dir dist/tsup/agent-os",
|
|
13530
|
+
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-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",
|
|
13521
13531
|
"build:browser": "tsup --config tsup.browser.config.ts",
|
|
13522
13532
|
"check-types": "tsc --noEmit",
|
|
13523
13533
|
lint: "biome check . && pnpm run check:test-skips && pnpm run check:wait-for-comments",
|
|
@@ -14626,7 +14636,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14626
14636
|
};
|
|
14627
14637
|
}
|
|
14628
14638
|
|
|
14629
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14639
|
+
// ../rivetkit/dist/tsup/chunk-PLLHHJWR.js
|
|
14630
14640
|
var config2 = /* @__PURE__ */ Config({});
|
|
14631
14641
|
function readWorkflowCbor(bc) {
|
|
14632
14642
|
return readData(bc);
|
|
@@ -14924,7 +14934,87 @@ function decodeWorkflowHistoryTransport(data) {
|
|
|
14924
14934
|
return decodeWorkflowHistory(toUint8Array(data));
|
|
14925
14935
|
}
|
|
14926
14936
|
|
|
14927
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14937
|
+
// ../rivetkit/dist/tsup/chunk-QWLJCP3X.js
|
|
14938
|
+
function flattenActionHandlers(actions) {
|
|
14939
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14940
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14941
|
+
flattened[name] = handler;
|
|
14942
|
+
}
|
|
14943
|
+
return flattened;
|
|
14944
|
+
}
|
|
14945
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
14946
|
+
if (schemas === void 0) return void 0;
|
|
14947
|
+
if (!isRecord(schemas)) {
|
|
14948
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
14949
|
+
}
|
|
14950
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14951
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
14952
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
14953
|
+
const flatSchema = schemas[name];
|
|
14954
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
14955
|
+
throw new TypeError(
|
|
14956
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
14957
|
+
);
|
|
14958
|
+
}
|
|
14959
|
+
const schema = nestedSchema ?? flatSchema;
|
|
14960
|
+
if (schema !== void 0) {
|
|
14961
|
+
flattened[name] = schema;
|
|
14962
|
+
}
|
|
14963
|
+
}
|
|
14964
|
+
return flattened;
|
|
14965
|
+
}
|
|
14966
|
+
function collectActionEntries(actions) {
|
|
14967
|
+
const entries = [];
|
|
14968
|
+
const names = /* @__PURE__ */ new Set();
|
|
14969
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
14970
|
+
return entries;
|
|
14971
|
+
}
|
|
14972
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
14973
|
+
if (!isRecord(value)) {
|
|
14974
|
+
throw new TypeError(
|
|
14975
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
14976
|
+
);
|
|
14977
|
+
}
|
|
14978
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
14979
|
+
const childPath = [...path2, segment];
|
|
14980
|
+
if (typeof child === "function") {
|
|
14981
|
+
const name = childPath.join(".");
|
|
14982
|
+
if (names.has(name)) {
|
|
14983
|
+
throw new TypeError(
|
|
14984
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
14985
|
+
);
|
|
14986
|
+
}
|
|
14987
|
+
names.add(name);
|
|
14988
|
+
entries.push({
|
|
14989
|
+
name,
|
|
14990
|
+
path: childPath,
|
|
14991
|
+
handler: child
|
|
14992
|
+
});
|
|
14993
|
+
} else {
|
|
14994
|
+
visitActionGroup(child, childPath, entries, names);
|
|
14995
|
+
}
|
|
14996
|
+
}
|
|
14997
|
+
}
|
|
14998
|
+
function lookupNestedSchema(schemas, path2) {
|
|
14999
|
+
let value = schemas;
|
|
15000
|
+
for (const segment of path2) {
|
|
15001
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
15002
|
+
return void 0;
|
|
15003
|
+
}
|
|
15004
|
+
value = value[segment];
|
|
15005
|
+
}
|
|
15006
|
+
return value;
|
|
15007
|
+
}
|
|
15008
|
+
function isRecord(value) {
|
|
15009
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15010
|
+
return false;
|
|
15011
|
+
}
|
|
15012
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15013
|
+
return prototype === Object.prototype || prototype === null;
|
|
15014
|
+
}
|
|
15015
|
+
function formatActionPath(path2) {
|
|
15016
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
15017
|
+
}
|
|
14928
15018
|
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
14929
15019
|
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
14930
15020
|
"rivetkit.actor_context_internal"
|
|
@@ -14932,6 +15022,22 @@ var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
|
14932
15022
|
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
14933
15023
|
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
14934
15024
|
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
15025
|
+
var zActionTree = external_exports.custom((value) => {
|
|
15026
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
15027
|
+
return false;
|
|
15028
|
+
}
|
|
15029
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15030
|
+
return prototype === Object.prototype || prototype === null;
|
|
15031
|
+
}).superRefine((actions, ctx) => {
|
|
15032
|
+
try {
|
|
15033
|
+
flattenActionHandlers(actions);
|
|
15034
|
+
} catch (error46) {
|
|
15035
|
+
ctx.addIssue({
|
|
15036
|
+
code: "custom",
|
|
15037
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15038
|
+
});
|
|
15039
|
+
}
|
|
15040
|
+
});
|
|
14935
15041
|
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
14936
15042
|
getHistory: zFunction(),
|
|
14937
15043
|
onHistoryUpdated: zFunction().optional(),
|
|
@@ -15101,7 +15207,7 @@ var ActorConfigSchema = external_exports.object({
|
|
|
15101
15207
|
onBeforeActionResponse: zFunction().optional(),
|
|
15102
15208
|
onRequest: zFunction().optional(),
|
|
15103
15209
|
onWebSocket: zFunction().optional(),
|
|
15104
|
-
actions:
|
|
15210
|
+
actions: zActionTree.default(() => ({})),
|
|
15105
15211
|
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15106
15212
|
connParamsSchema: external_exports.any().optional(),
|
|
15107
15213
|
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
@@ -15245,10 +15351,10 @@ var DocActorConfigSchema = external_exports.object({
|
|
|
15245
15351
|
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15246
15352
|
),
|
|
15247
15353
|
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15248
|
-
"
|
|
15354
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15249
15355
|
),
|
|
15250
15356
|
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15251
|
-
"Optional
|
|
15357
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15252
15358
|
),
|
|
15253
15359
|
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15254
15360
|
"Optional schema for validating connection params in native runtimes."
|
|
@@ -15375,35 +15481,7 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15375
15481
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15376
15482
|
}
|
|
15377
15483
|
|
|
15378
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15379
|
-
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15380
|
-
var AsyncMutex = class {
|
|
15381
|
-
#locked = false;
|
|
15382
|
-
#waiting = [];
|
|
15383
|
-
async acquire() {
|
|
15384
|
-
while (this.#locked) {
|
|
15385
|
-
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15386
|
-
}
|
|
15387
|
-
this.#locked = true;
|
|
15388
|
-
}
|
|
15389
|
-
release() {
|
|
15390
|
-
this.#locked = false;
|
|
15391
|
-
const next = this.#waiting.shift();
|
|
15392
|
-
if (next) {
|
|
15393
|
-
next();
|
|
15394
|
-
}
|
|
15395
|
-
}
|
|
15396
|
-
async run(fn) {
|
|
15397
|
-
await this.acquire();
|
|
15398
|
-
try {
|
|
15399
|
-
return await fn();
|
|
15400
|
-
} finally {
|
|
15401
|
-
this.release();
|
|
15402
|
-
}
|
|
15403
|
-
}
|
|
15404
|
-
};
|
|
15405
|
-
|
|
15406
|
-
// ../rivetkit/dist/tsup/chunk-PAG6G46L.js
|
|
15484
|
+
// ../rivetkit/dist/tsup/chunk-OH6CBWUD.js
|
|
15407
15485
|
function logger() {
|
|
15408
15486
|
return getLogger("actor-client");
|
|
15409
15487
|
}
|
|
@@ -15441,7 +15519,35 @@ async function importWebSocket() {
|
|
|
15441
15519
|
return webSocketPromise;
|
|
15442
15520
|
}
|
|
15443
15521
|
|
|
15444
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15522
|
+
// ../rivetkit/dist/tsup/chunk-7AFZMFPQ.js
|
|
15523
|
+
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15524
|
+
var AsyncMutex = class {
|
|
15525
|
+
#locked = false;
|
|
15526
|
+
#waiting = [];
|
|
15527
|
+
async acquire() {
|
|
15528
|
+
while (this.#locked) {
|
|
15529
|
+
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15530
|
+
}
|
|
15531
|
+
this.#locked = true;
|
|
15532
|
+
}
|
|
15533
|
+
release() {
|
|
15534
|
+
this.#locked = false;
|
|
15535
|
+
const next = this.#waiting.shift();
|
|
15536
|
+
if (next) {
|
|
15537
|
+
next();
|
|
15538
|
+
}
|
|
15539
|
+
}
|
|
15540
|
+
async run(fn) {
|
|
15541
|
+
await this.acquire();
|
|
15542
|
+
try {
|
|
15543
|
+
return await fn();
|
|
15544
|
+
} finally {
|
|
15545
|
+
this.release();
|
|
15546
|
+
}
|
|
15547
|
+
}
|
|
15548
|
+
};
|
|
15549
|
+
|
|
15550
|
+
// ../rivetkit/dist/tsup/chunk-F6ZW7JZQ.js
|
|
15445
15551
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15446
15552
|
|
|
15447
15553
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15619,7 +15725,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15619
15725
|
return new VersionedDataHandler(config3);
|
|
15620
15726
|
}
|
|
15621
15727
|
|
|
15622
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15728
|
+
// ../rivetkit/dist/tsup/chunk-F6ZW7JZQ.js
|
|
15623
15729
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15624
15730
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15625
15731
|
var PATH_CONNECT = "/connect";
|
|
@@ -19066,6 +19172,23 @@ function createClientWithDriver(driver, config3 = {}) {
|
|
|
19066
19172
|
}
|
|
19067
19173
|
function createActorProxy(handle) {
|
|
19068
19174
|
const methodCache = /* @__PURE__ */ new Map();
|
|
19175
|
+
const actionPath = (name) => {
|
|
19176
|
+
let method2 = methodCache.get(name);
|
|
19177
|
+
if (method2) return method2;
|
|
19178
|
+
method2 = new Proxy(
|
|
19179
|
+
(...args) => handle.action({ name, args }),
|
|
19180
|
+
{
|
|
19181
|
+
get(target, prop) {
|
|
19182
|
+
if (typeof prop === "symbol")
|
|
19183
|
+
return Reflect.get(target, prop);
|
|
19184
|
+
if (prop === "then") return void 0;
|
|
19185
|
+
return actionPath(`${name}.${prop}`);
|
|
19186
|
+
}
|
|
19187
|
+
}
|
|
19188
|
+
);
|
|
19189
|
+
methodCache.set(name, method2);
|
|
19190
|
+
return method2;
|
|
19191
|
+
};
|
|
19069
19192
|
return new Proxy(handle, {
|
|
19070
19193
|
get(target, prop, receiver) {
|
|
19071
19194
|
if (typeof prop === "symbol") {
|
|
@@ -19080,12 +19203,7 @@ function createActorProxy(handle) {
|
|
|
19080
19203
|
}
|
|
19081
19204
|
if (typeof prop === "string") {
|
|
19082
19205
|
if (prop === "then") return void 0;
|
|
19083
|
-
|
|
19084
|
-
if (!method2) {
|
|
19085
|
-
method2 = (...args) => target.action({ name: prop, args });
|
|
19086
|
-
methodCache.set(prop, method2);
|
|
19087
|
-
}
|
|
19088
|
-
return method2;
|
|
19206
|
+
return actionPath(prop);
|
|
19089
19207
|
}
|
|
19090
19208
|
},
|
|
19091
19209
|
// Support for 'in' operator
|
|
@@ -19103,6 +19221,7 @@ function createActorProxy(handle) {
|
|
|
19103
19221
|
},
|
|
19104
19222
|
// Support proper property descriptors
|
|
19105
19223
|
getOwnPropertyDescriptor(target, prop) {
|
|
19224
|
+
if (prop === "then") return void 0;
|
|
19106
19225
|
const targetDescriptor = Reflect.getOwnPropertyDescriptor(
|
|
19107
19226
|
target,
|
|
19108
19227
|
prop
|
|
@@ -19115,7 +19234,7 @@ function createActorProxy(handle) {
|
|
|
19115
19234
|
configurable: true,
|
|
19116
19235
|
enumerable: false,
|
|
19117
19236
|
writable: false,
|
|
19118
|
-
value: (
|
|
19237
|
+
value: actionPath(prop)
|
|
19119
19238
|
};
|
|
19120
19239
|
}
|
|
19121
19240
|
return void 0;
|
|
@@ -20351,103 +20470,6 @@ function convertRegistryConfigToClientConfig(config3) {
|
|
|
20351
20470
|
devtools: typeof window !== "undefined" && (((_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname) === "127.0.0.1" || ((_b = window == null ? void 0 : window.location) == null ? void 0 : _b.hostname) === "localhost")
|
|
20352
20471
|
};
|
|
20353
20472
|
}
|
|
20354
|
-
function logger2() {
|
|
20355
|
-
return getLogger("engine-client");
|
|
20356
|
-
}
|
|
20357
|
-
function getEndpoint(config3) {
|
|
20358
|
-
return config3.endpoint ?? "http://127.0.0.1:6420";
|
|
20359
|
-
}
|
|
20360
|
-
async function apiCall(config3, method2, path2, body) {
|
|
20361
|
-
const endpoint = getEndpoint(config3);
|
|
20362
|
-
const url2 = combineUrlPath(endpoint, path2, {
|
|
20363
|
-
namespace: config3.namespace
|
|
20364
|
-
});
|
|
20365
|
-
logger2().debug({ msg: "making api call", method: method2, url: url2 });
|
|
20366
|
-
const headers = {
|
|
20367
|
-
...config3.headers
|
|
20368
|
-
};
|
|
20369
|
-
if (config3.token) {
|
|
20370
|
-
headers.Authorization = `Bearer ${config3.token}`;
|
|
20371
|
-
}
|
|
20372
|
-
return await sendHttpRequest({
|
|
20373
|
-
method: method2,
|
|
20374
|
-
url: url2,
|
|
20375
|
-
headers,
|
|
20376
|
-
body,
|
|
20377
|
-
encoding: "json",
|
|
20378
|
-
skipParseResponse: false,
|
|
20379
|
-
requestVersionedDataHandler: void 0,
|
|
20380
|
-
requestVersion: void 0,
|
|
20381
|
-
responseVersionedDataHandler: void 0,
|
|
20382
|
-
responseVersion: void 0,
|
|
20383
|
-
requestZodSchema: external_exports.any(),
|
|
20384
|
-
responseZodSchema: external_exports.any(),
|
|
20385
|
-
// Identity conversions (passthrough for generic API calls)
|
|
20386
|
-
requestToJson: (value) => value,
|
|
20387
|
-
requestToBare: (value) => value,
|
|
20388
|
-
responseFromJson: (value) => value,
|
|
20389
|
-
responseFromBare: (value) => value
|
|
20390
|
-
});
|
|
20391
|
-
}
|
|
20392
|
-
async function getActor(config3, _, actorId) {
|
|
20393
|
-
return apiCall(
|
|
20394
|
-
config3,
|
|
20395
|
-
"GET",
|
|
20396
|
-
`/actors?actor_ids=${encodeURIComponent(actorId)}`
|
|
20397
|
-
);
|
|
20398
|
-
}
|
|
20399
|
-
async function getActorByKey(config3, name, key) {
|
|
20400
|
-
const serializedKey = serializeActorKey(key);
|
|
20401
|
-
return apiCall(
|
|
20402
|
-
config3,
|
|
20403
|
-
"GET",
|
|
20404
|
-
`/actors?name=${encodeURIComponent(name)}&key=${encodeURIComponent(serializedKey)}`
|
|
20405
|
-
);
|
|
20406
|
-
}
|
|
20407
|
-
async function listActorsByName(config3, name) {
|
|
20408
|
-
return apiCall(
|
|
20409
|
-
config3,
|
|
20410
|
-
"GET",
|
|
20411
|
-
`/actors?name=${encodeURIComponent(name)}`
|
|
20412
|
-
);
|
|
20413
|
-
}
|
|
20414
|
-
async function getOrCreateActor(config3, request) {
|
|
20415
|
-
return apiCall(
|
|
20416
|
-
config3,
|
|
20417
|
-
"PUT",
|
|
20418
|
-
`/actors`,
|
|
20419
|
-
request
|
|
20420
|
-
);
|
|
20421
|
-
}
|
|
20422
|
-
async function createActor(config3, request) {
|
|
20423
|
-
return apiCall(
|
|
20424
|
-
config3,
|
|
20425
|
-
"POST",
|
|
20426
|
-
`/actors`,
|
|
20427
|
-
request
|
|
20428
|
-
);
|
|
20429
|
-
}
|
|
20430
|
-
async function destroyActor(config3, actorId) {
|
|
20431
|
-
return apiCall(
|
|
20432
|
-
config3,
|
|
20433
|
-
"DELETE",
|
|
20434
|
-
`/actors/${encodeURIComponent(actorId)}`
|
|
20435
|
-
);
|
|
20436
|
-
}
|
|
20437
|
-
async function getMetadata(config3) {
|
|
20438
|
-
return apiCall(config3, "GET", `/metadata`);
|
|
20439
|
-
}
|
|
20440
|
-
async function getDatacenters(config3) {
|
|
20441
|
-
return apiCall(config3, "GET", `/datacenters`);
|
|
20442
|
-
}
|
|
20443
|
-
async function updateRunnerConfig(config3, runnerName, request) {
|
|
20444
|
-
return apiCall(
|
|
20445
|
-
config3,
|
|
20446
|
-
"PUT",
|
|
20447
|
-
`/runner-configs/${runnerName}`,
|
|
20448
|
-
request
|
|
20449
|
-
);
|
|
20450
|
-
}
|
|
20451
20473
|
function shouldSkipReadyWait(options = {}) {
|
|
20452
20474
|
return options.skipReadyWait === true;
|
|
20453
20475
|
}
|
|
@@ -20535,6 +20557,9 @@ function setRemoteHibernatableWebSocketAckTestHooks(websocket, token, enabled) {
|
|
|
20535
20557
|
enabled
|
|
20536
20558
|
);
|
|
20537
20559
|
}
|
|
20560
|
+
function logger2() {
|
|
20561
|
+
return getLogger("engine-client");
|
|
20562
|
+
}
|
|
20538
20563
|
var BufferedRemoteWebSocket = class {
|
|
20539
20564
|
CONNECTING = 0;
|
|
20540
20565
|
OPEN = 1;
|
|
@@ -20812,6 +20837,100 @@ function buildWebSocketProtocols(runConfig, encoding, params, ackHookToken, targ
|
|
|
20812
20837
|
}
|
|
20813
20838
|
return protocols;
|
|
20814
20839
|
}
|
|
20840
|
+
function getEndpoint(config3) {
|
|
20841
|
+
return config3.endpoint ?? "http://127.0.0.1:6420";
|
|
20842
|
+
}
|
|
20843
|
+
async function apiCall(config3, method2, path2, body) {
|
|
20844
|
+
const endpoint = getEndpoint(config3);
|
|
20845
|
+
const url2 = combineUrlPath(endpoint, path2, {
|
|
20846
|
+
namespace: config3.namespace
|
|
20847
|
+
});
|
|
20848
|
+
logger2().debug({ msg: "making api call", method: method2, url: url2 });
|
|
20849
|
+
const headers = {
|
|
20850
|
+
...config3.headers
|
|
20851
|
+
};
|
|
20852
|
+
if (config3.token) {
|
|
20853
|
+
headers.Authorization = `Bearer ${config3.token}`;
|
|
20854
|
+
}
|
|
20855
|
+
return await sendHttpRequest({
|
|
20856
|
+
method: method2,
|
|
20857
|
+
url: url2,
|
|
20858
|
+
headers,
|
|
20859
|
+
body,
|
|
20860
|
+
encoding: "json",
|
|
20861
|
+
skipParseResponse: false,
|
|
20862
|
+
requestVersionedDataHandler: void 0,
|
|
20863
|
+
requestVersion: void 0,
|
|
20864
|
+
responseVersionedDataHandler: void 0,
|
|
20865
|
+
responseVersion: void 0,
|
|
20866
|
+
requestZodSchema: external_exports.any(),
|
|
20867
|
+
responseZodSchema: external_exports.any(),
|
|
20868
|
+
// Identity conversions (passthrough for generic API calls)
|
|
20869
|
+
requestToJson: (value) => value,
|
|
20870
|
+
requestToBare: (value) => value,
|
|
20871
|
+
responseFromJson: (value) => value,
|
|
20872
|
+
responseFromBare: (value) => value
|
|
20873
|
+
});
|
|
20874
|
+
}
|
|
20875
|
+
async function getActor(config3, _, actorId) {
|
|
20876
|
+
return apiCall(
|
|
20877
|
+
config3,
|
|
20878
|
+
"GET",
|
|
20879
|
+
`/actors?actor_ids=${encodeURIComponent(actorId)}`
|
|
20880
|
+
);
|
|
20881
|
+
}
|
|
20882
|
+
async function getActorByKey(config3, name, key) {
|
|
20883
|
+
const serializedKey = serializeActorKey(key);
|
|
20884
|
+
return apiCall(
|
|
20885
|
+
config3,
|
|
20886
|
+
"GET",
|
|
20887
|
+
`/actors?name=${encodeURIComponent(name)}&key=${encodeURIComponent(serializedKey)}`
|
|
20888
|
+
);
|
|
20889
|
+
}
|
|
20890
|
+
async function listActorsByName(config3, name) {
|
|
20891
|
+
return apiCall(
|
|
20892
|
+
config3,
|
|
20893
|
+
"GET",
|
|
20894
|
+
`/actors?name=${encodeURIComponent(name)}`
|
|
20895
|
+
);
|
|
20896
|
+
}
|
|
20897
|
+
async function getOrCreateActor(config3, request) {
|
|
20898
|
+
return apiCall(
|
|
20899
|
+
config3,
|
|
20900
|
+
"PUT",
|
|
20901
|
+
`/actors`,
|
|
20902
|
+
request
|
|
20903
|
+
);
|
|
20904
|
+
}
|
|
20905
|
+
async function createActor(config3, request) {
|
|
20906
|
+
return apiCall(
|
|
20907
|
+
config3,
|
|
20908
|
+
"POST",
|
|
20909
|
+
`/actors`,
|
|
20910
|
+
request
|
|
20911
|
+
);
|
|
20912
|
+
}
|
|
20913
|
+
async function destroyActor(config3, actorId) {
|
|
20914
|
+
return apiCall(
|
|
20915
|
+
config3,
|
|
20916
|
+
"DELETE",
|
|
20917
|
+
`/actors/${encodeURIComponent(actorId)}`
|
|
20918
|
+
);
|
|
20919
|
+
}
|
|
20920
|
+
async function getMetadata(config3) {
|
|
20921
|
+
return apiCall(config3, "GET", `/metadata`);
|
|
20922
|
+
}
|
|
20923
|
+
async function getDatacenters(config3) {
|
|
20924
|
+
return apiCall(config3, "GET", `/datacenters`);
|
|
20925
|
+
}
|
|
20926
|
+
async function updateRunnerConfig(config3, runnerName, request) {
|
|
20927
|
+
return apiCall(
|
|
20928
|
+
config3,
|
|
20929
|
+
"PUT",
|
|
20930
|
+
`/runner-configs/${runnerName}`,
|
|
20931
|
+
request
|
|
20932
|
+
);
|
|
20933
|
+
}
|
|
20815
20934
|
var metadataLookupCache = /* @__PURE__ */ new Map();
|
|
20816
20935
|
async function lookupMetadataCached(config3) {
|
|
20817
20936
|
const endpoint = getEndpoint(config3);
|
|
@@ -22571,6 +22690,8 @@ function actor(input) {
|
|
|
22571
22690
|
input == null ? void 0 : input.options
|
|
22572
22691
|
);
|
|
22573
22692
|
const config3 = ActorConfigSchema.parse(input);
|
|
22693
|
+
flattenActionHandlers(config3.actions);
|
|
22694
|
+
flattenActionInputSchemas(config3.actions, config3.actionInputSchemas);
|
|
22574
22695
|
return new ActorDefinition(config3);
|
|
22575
22696
|
}
|
|
22576
22697
|
function isStaticActorDefinition(definition) {
|
|
@@ -23227,7 +23348,7 @@ var RegistryConfigSchema = external_exports.object({
|
|
|
23227
23348
|
config3.engineHost,
|
|
23228
23349
|
config3.enginePort
|
|
23229
23350
|
);
|
|
23230
|
-
const endpoint = config3.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ?
|
|
23351
|
+
const endpoint = config3.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ? localEngineEndpoint : void 0);
|
|
23231
23352
|
const validateServerlessEndpoint = Boolean(
|
|
23232
23353
|
config3.startEngine || parsedEndpoint
|
|
23233
23354
|
);
|
|
@@ -23244,7 +23365,7 @@ var RegistryConfigSchema = external_exports.object({
|
|
|
23244
23365
|
path: ["serverless", "publicEndpoint"]
|
|
23245
23366
|
});
|
|
23246
23367
|
}
|
|
23247
|
-
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv &&
|
|
23368
|
+
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv && !parsedEndpoint ? endpoint : void 0);
|
|
23248
23369
|
const publicNamespace = parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.namespace;
|
|
23249
23370
|
const publicToken = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.token) ?? config3.serverless.publicToken;
|
|
23250
23371
|
return {
|
|
@@ -23914,6 +24035,9 @@ var NapiCoreRuntime = class {
|
|
|
23914
24035
|
async serveRegistry(registry2, config3) {
|
|
23915
24036
|
await asNativeRegistry(registry2).serve(config3);
|
|
23916
24037
|
}
|
|
24038
|
+
async waitRegistryReady(registry2) {
|
|
24039
|
+
await asNativeRegistry(registry2).waitReady();
|
|
24040
|
+
}
|
|
23917
24041
|
async shutdownRegistry(registry2) {
|
|
23918
24042
|
await asNativeRegistry(registry2).shutdown();
|
|
23919
24043
|
}
|
|
@@ -24578,6 +24702,11 @@ var WasmCoreRuntime = class {
|
|
|
24578
24702
|
async serveRegistry(registry2, config3) {
|
|
24579
24703
|
await callWasm(() => asWasmRegistry(registry2).serve(config3));
|
|
24580
24704
|
}
|
|
24705
|
+
async waitRegistryReady() {
|
|
24706
|
+
throw new Error(
|
|
24707
|
+
"registry.startAndWait() is not supported by the WASM runtime"
|
|
24708
|
+
);
|
|
24709
|
+
}
|
|
24581
24710
|
async shutdownRegistry(registry2) {
|
|
24582
24711
|
await callWasm(() => asWasmRegistry(registry2).shutdown());
|
|
24583
24712
|
}
|
|
@@ -27567,7 +27696,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
27567
27696
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
27568
27697
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
27569
27698
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
27570
|
-
actions: Object.keys(config3.actions
|
|
27699
|
+
actions: Object.keys(flattenActionHandlers(config3.actions)).sort().map((name) => ({ name })),
|
|
27571
27700
|
inspectorTabs: buildInspectorTabs(config3.inspector, runtimeKind)
|
|
27572
27701
|
};
|
|
27573
27702
|
}
|
|
@@ -27644,15 +27773,16 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
27644
27773
|
var _a2;
|
|
27645
27774
|
const config3 = definition.config;
|
|
27646
27775
|
const databaseProvider = config3.db;
|
|
27776
|
+
const actionHandlers = flattenActionHandlers(config3.actions);
|
|
27647
27777
|
const schemaConfig = {
|
|
27648
|
-
actionInputSchemas:
|
|
27778
|
+
actionInputSchemas: flattenActionInputSchemas(
|
|
27779
|
+
config3.actions,
|
|
27780
|
+
config3.actionInputSchemas
|
|
27781
|
+
),
|
|
27649
27782
|
connParamsSchema: config3.connParamsSchema,
|
|
27650
27783
|
events: config3.events,
|
|
27651
27784
|
queues: config3.queues
|
|
27652
27785
|
};
|
|
27653
|
-
const actionHandlers = Object.fromEntries(
|
|
27654
|
-
Object.entries(config3.actions ?? {}).map(([name, handler]) => [name, handler])
|
|
27655
|
-
);
|
|
27656
27786
|
const createClient = () => createClientWithDriver(
|
|
27657
27787
|
new RemoteEngineControlClient(
|
|
27658
27788
|
convertRegistryConfigToClientConfig(registryConfig)
|
|
@@ -28700,6 +28830,7 @@ async function buildConfiguredRegistry(config3) {
|
|
|
28700
28830
|
runtime
|
|
28701
28831
|
);
|
|
28702
28832
|
}
|
|
28833
|
+
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
28703
28834
|
function signalExitCode(signal) {
|
|
28704
28835
|
switch (signal) {
|
|
28705
28836
|
case "SIGINT":
|
|
@@ -28725,6 +28856,8 @@ var Registry = class {
|
|
|
28725
28856
|
return RegistryConfigSchema.parse(this.#config);
|
|
28726
28857
|
}
|
|
28727
28858
|
#runtimeServePromise;
|
|
28859
|
+
#runtimeServeLifecyclePromise;
|
|
28860
|
+
#runtimeReadyPromise;
|
|
28728
28861
|
#runtimeServeConfiguredPromise;
|
|
28729
28862
|
#runtimeServerlessPromise;
|
|
28730
28863
|
#configureServerlessPoolPromise;
|
|
@@ -29071,11 +29204,16 @@ var Registry = class {
|
|
|
29071
29204
|
if (!this.#runtimeServePromise) {
|
|
29072
29205
|
const configuredRegistryPromise = this.#buildConfiguredRegistry(config3);
|
|
29073
29206
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
29074
|
-
this.#
|
|
29075
|
-
|
|
29076
|
-
|
|
29077
|
-
|
|
29078
|
-
|
|
29207
|
+
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
29208
|
+
async ({ runtime, registry: registry2, serveConfig }) => {
|
|
29209
|
+
await runtime.serveRegistry(registry2, serveConfig);
|
|
29210
|
+
}
|
|
29211
|
+
);
|
|
29212
|
+
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29213
|
+
(error46) => {
|
|
29214
|
+
logger22().warn({ error: error46 }, "runtime registry serve errored");
|
|
29215
|
+
}
|
|
29216
|
+
);
|
|
29079
29217
|
this.#installSignalHandlers(config3);
|
|
29080
29218
|
}
|
|
29081
29219
|
if (printWelcome) {
|
|
@@ -29221,6 +29359,75 @@ var Registry = class {
|
|
|
29221
29359
|
startEnvoy() {
|
|
29222
29360
|
this.#startEnvoy(this.parseConfig(), true);
|
|
29223
29361
|
}
|
|
29362
|
+
/**
|
|
29363
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
29364
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
29365
|
+
* startup lifecycle and readiness promise.
|
|
29366
|
+
*
|
|
29367
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
29368
|
+
* merely because an HTTP health endpoint is listening.
|
|
29369
|
+
*/
|
|
29370
|
+
startAndWait() {
|
|
29371
|
+
if (this.#shutdownInFlight !== null) {
|
|
29372
|
+
return Promise.reject(
|
|
29373
|
+
new Error("registry.startAndWait() cannot run after shutdown has begun")
|
|
29374
|
+
);
|
|
29375
|
+
}
|
|
29376
|
+
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
29377
|
+
if (getRivetkitRuntimeMode() === "serverless") {
|
|
29378
|
+
return Promise.reject(
|
|
29379
|
+
new Error(
|
|
29380
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
29381
|
+
)
|
|
29382
|
+
);
|
|
29383
|
+
}
|
|
29384
|
+
const config3 = this.parseConfig();
|
|
29385
|
+
if (config3.runtime === "wasm") {
|
|
29386
|
+
return Promise.reject(
|
|
29387
|
+
new Error(
|
|
29388
|
+
"registry.startAndWait() requires the native runtime; WebAssembly registries do not host an envoy"
|
|
29389
|
+
)
|
|
29390
|
+
);
|
|
29391
|
+
}
|
|
29392
|
+
this.#startEnvoy(config3, true);
|
|
29393
|
+
const configuredRegistryPromise = this.#runtimeServeConfiguredPromise;
|
|
29394
|
+
const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
|
|
29395
|
+
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
29396
|
+
throw new Error("registry envoy startup did not initialize");
|
|
29397
|
+
}
|
|
29398
|
+
let timeout;
|
|
29399
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
29400
|
+
var _a2;
|
|
29401
|
+
timeout = setTimeout(
|
|
29402
|
+
() => reject(
|
|
29403
|
+
new Error(
|
|
29404
|
+
`RivetKit registry did not register with the Engine within ${REGISTRY_READY_TIMEOUT_MS}ms`
|
|
29405
|
+
)
|
|
29406
|
+
),
|
|
29407
|
+
REGISTRY_READY_TIMEOUT_MS
|
|
29408
|
+
);
|
|
29409
|
+
(_a2 = timeout.unref) == null ? void 0 : _a2.call(timeout);
|
|
29410
|
+
});
|
|
29411
|
+
const readinessPromise = (async () => {
|
|
29412
|
+
const { runtime, registry: registry2 } = await configuredRegistryPromise;
|
|
29413
|
+
const stoppedBeforeReady = serveLifecyclePromise.then(() => {
|
|
29414
|
+
throw new Error("RivetKit registry stopped before becoming ready");
|
|
29415
|
+
});
|
|
29416
|
+
await Promise.race([
|
|
29417
|
+
runtime.waitRegistryReady(registry2),
|
|
29418
|
+
stoppedBeforeReady
|
|
29419
|
+
]);
|
|
29420
|
+
})();
|
|
29421
|
+
this.#runtimeReadyPromise = Promise.race([
|
|
29422
|
+
readinessPromise,
|
|
29423
|
+
timeoutPromise
|
|
29424
|
+
]).finally(() => {
|
|
29425
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
29426
|
+
});
|
|
29427
|
+
this.#runtimeReadyPromise.catch(() => {
|
|
29428
|
+
});
|
|
29429
|
+
return this.#runtimeReadyPromise;
|
|
29430
|
+
}
|
|
29224
29431
|
/**
|
|
29225
29432
|
* Starts the actor envoy for standalone server deployments.
|
|
29226
29433
|
*
|