@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.mjs
CHANGED
|
@@ -471,7 +471,7 @@ function unsupportedFeature(feature) {
|
|
|
471
471
|
);
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
474
|
+
// ../rivetkit/dist/tsup/chunk-RDTFPGU2.js
|
|
475
475
|
import {
|
|
476
476
|
pino,
|
|
477
477
|
stdTimeFunctions
|
|
@@ -13147,7 +13147,7 @@ var classic_default = external_exports;
|
|
|
13147
13147
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
|
|
13148
13148
|
var v4_default = classic_default;
|
|
13149
13149
|
|
|
13150
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
13150
|
+
// ../rivetkit/dist/tsup/chunk-RDTFPGU2.js
|
|
13151
13151
|
var import_invariant = __toESM(require_invariant(), 1);
|
|
13152
13152
|
import * as cbor from "cbor-x";
|
|
13153
13153
|
var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
|
|
@@ -13312,7 +13312,7 @@ function noopNext() {
|
|
|
13312
13312
|
}
|
|
13313
13313
|
var package_default = {
|
|
13314
13314
|
name: "rivetkit",
|
|
13315
|
-
version: "2.3.
|
|
13315
|
+
version: "2.3.6",
|
|
13316
13316
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
13317
13317
|
license: "Apache-2.0",
|
|
13318
13318
|
keywords: [
|
|
@@ -13384,6 +13384,16 @@ var package_default = {
|
|
|
13384
13384
|
default: "./dist/tsup/db/drizzle.cjs"
|
|
13385
13385
|
}
|
|
13386
13386
|
},
|
|
13387
|
+
"./unstable/migrations": {
|
|
13388
|
+
import: {
|
|
13389
|
+
types: "./dist/tsup/unstable/migrations.d.ts",
|
|
13390
|
+
default: "./dist/tsup/unstable/migrations.js"
|
|
13391
|
+
},
|
|
13392
|
+
require: {
|
|
13393
|
+
types: "./dist/tsup/unstable/migrations.d.cts",
|
|
13394
|
+
default: "./dist/tsup/unstable/migrations.cjs"
|
|
13395
|
+
}
|
|
13396
|
+
},
|
|
13387
13397
|
"./dynamic": {
|
|
13388
13398
|
import: {
|
|
13389
13399
|
types: "./dist/tsup/dynamic/mod.d.ts",
|
|
@@ -13483,7 +13493,7 @@ var package_default = {
|
|
|
13483
13493
|
"./dist/tsup/chunk-*.cjs"
|
|
13484
13494
|
],
|
|
13485
13495
|
scripts: {
|
|
13486
|
-
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",
|
|
13496
|
+
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",
|
|
13487
13497
|
"build:browser": "tsup --config tsup.browser.config.ts",
|
|
13488
13498
|
"check-types": "tsc --noEmit",
|
|
13489
13499
|
lint: "biome check . && pnpm run check:test-skips && pnpm run check:wait-for-comments",
|
|
@@ -14592,7 +14602,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
|
|
|
14592
14602
|
};
|
|
14593
14603
|
}
|
|
14594
14604
|
|
|
14595
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14605
|
+
// ../rivetkit/dist/tsup/chunk-PLLHHJWR.js
|
|
14596
14606
|
var config2 = /* @__PURE__ */ Config({});
|
|
14597
14607
|
function readWorkflowCbor(bc) {
|
|
14598
14608
|
return readData(bc);
|
|
@@ -14890,7 +14900,87 @@ function decodeWorkflowHistoryTransport(data) {
|
|
|
14890
14900
|
return decodeWorkflowHistory(toUint8Array(data));
|
|
14891
14901
|
}
|
|
14892
14902
|
|
|
14893
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
14903
|
+
// ../rivetkit/dist/tsup/chunk-QWLJCP3X.js
|
|
14904
|
+
function flattenActionHandlers(actions) {
|
|
14905
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14906
|
+
for (const { name, handler } of collectActionEntries(actions)) {
|
|
14907
|
+
flattened[name] = handler;
|
|
14908
|
+
}
|
|
14909
|
+
return flattened;
|
|
14910
|
+
}
|
|
14911
|
+
function flattenActionInputSchemas(actions, schemas) {
|
|
14912
|
+
if (schemas === void 0) return void 0;
|
|
14913
|
+
if (!isRecord(schemas)) {
|
|
14914
|
+
throw new TypeError("actionInputSchemas must be an object");
|
|
14915
|
+
}
|
|
14916
|
+
const flattened = /* @__PURE__ */ Object.create(null);
|
|
14917
|
+
for (const { name, path: path2 } of collectActionEntries(actions)) {
|
|
14918
|
+
const nestedSchema = lookupNestedSchema(schemas, path2);
|
|
14919
|
+
const flatSchema = schemas[name];
|
|
14920
|
+
if (nestedSchema !== void 0 && flatSchema !== void 0 && nestedSchema !== flatSchema) {
|
|
14921
|
+
throw new TypeError(
|
|
14922
|
+
`Action input schema \`${name}\` is defined by both a nested path and a dotted key`
|
|
14923
|
+
);
|
|
14924
|
+
}
|
|
14925
|
+
const schema = nestedSchema ?? flatSchema;
|
|
14926
|
+
if (schema !== void 0) {
|
|
14927
|
+
flattened[name] = schema;
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
return flattened;
|
|
14931
|
+
}
|
|
14932
|
+
function collectActionEntries(actions) {
|
|
14933
|
+
const entries = [];
|
|
14934
|
+
const names = /* @__PURE__ */ new Set();
|
|
14935
|
+
visitActionGroup(actions ?? {}, [], entries, names);
|
|
14936
|
+
return entries;
|
|
14937
|
+
}
|
|
14938
|
+
function visitActionGroup(value, path2, entries, names) {
|
|
14939
|
+
if (!isRecord(value)) {
|
|
14940
|
+
throw new TypeError(
|
|
14941
|
+
`${formatActionPath(path2)} must be an action handler or group`
|
|
14942
|
+
);
|
|
14943
|
+
}
|
|
14944
|
+
for (const [segment, child] of Object.entries(value)) {
|
|
14945
|
+
const childPath = [...path2, segment];
|
|
14946
|
+
if (typeof child === "function") {
|
|
14947
|
+
const name = childPath.join(".");
|
|
14948
|
+
if (names.has(name)) {
|
|
14949
|
+
throw new TypeError(
|
|
14950
|
+
`Multiple action definitions flatten to \`${name}\``
|
|
14951
|
+
);
|
|
14952
|
+
}
|
|
14953
|
+
names.add(name);
|
|
14954
|
+
entries.push({
|
|
14955
|
+
name,
|
|
14956
|
+
path: childPath,
|
|
14957
|
+
handler: child
|
|
14958
|
+
});
|
|
14959
|
+
} else {
|
|
14960
|
+
visitActionGroup(child, childPath, entries, names);
|
|
14961
|
+
}
|
|
14962
|
+
}
|
|
14963
|
+
}
|
|
14964
|
+
function lookupNestedSchema(schemas, path2) {
|
|
14965
|
+
let value = schemas;
|
|
14966
|
+
for (const segment of path2) {
|
|
14967
|
+
if (!isRecord(value) || !Object.hasOwn(value, segment)) {
|
|
14968
|
+
return void 0;
|
|
14969
|
+
}
|
|
14970
|
+
value = value[segment];
|
|
14971
|
+
}
|
|
14972
|
+
return value;
|
|
14973
|
+
}
|
|
14974
|
+
function isRecord(value) {
|
|
14975
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
14976
|
+
return false;
|
|
14977
|
+
}
|
|
14978
|
+
const prototype = Object.getPrototypeOf(value);
|
|
14979
|
+
return prototype === Object.prototype || prototype === null;
|
|
14980
|
+
}
|
|
14981
|
+
function formatActionPath(path2) {
|
|
14982
|
+
return path2.length === 0 ? "actions" : `Action \`${path2.join(".")}\``;
|
|
14983
|
+
}
|
|
14894
14984
|
var DEFAULT_SLEEP_GRACE_PERIOD = 15e3;
|
|
14895
14985
|
var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
14896
14986
|
"rivetkit.actor_context_internal"
|
|
@@ -14898,6 +14988,22 @@ var ACTOR_CONTEXT_INTERNAL_SYMBOL = /* @__PURE__ */ Symbol(
|
|
|
14898
14988
|
var RAW_STATE_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.raw_state");
|
|
14899
14989
|
var CONN_STATE_MANAGER_SYMBOL = /* @__PURE__ */ Symbol("rivetkit.conn_state_manager");
|
|
14900
14990
|
var zFunction = () => external_exports.custom((val) => typeof val === "function");
|
|
14991
|
+
var zActionTree = external_exports.custom((value) => {
|
|
14992
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
14993
|
+
return false;
|
|
14994
|
+
}
|
|
14995
|
+
const prototype = Object.getPrototypeOf(value);
|
|
14996
|
+
return prototype === Object.prototype || prototype === null;
|
|
14997
|
+
}).superRefine((actions, ctx) => {
|
|
14998
|
+
try {
|
|
14999
|
+
flattenActionHandlers(actions);
|
|
15000
|
+
} catch (error46) {
|
|
15001
|
+
ctx.addIssue({
|
|
15002
|
+
code: "custom",
|
|
15003
|
+
message: error46 instanceof Error ? error46.message : "Invalid action definition"
|
|
15004
|
+
});
|
|
15005
|
+
}
|
|
15006
|
+
});
|
|
14901
15007
|
var WorkflowInspectorConfigSchema = external_exports.object({
|
|
14902
15008
|
getHistory: zFunction(),
|
|
14903
15009
|
onHistoryUpdated: zFunction().optional(),
|
|
@@ -15067,7 +15173,7 @@ var ActorConfigSchema = external_exports.object({
|
|
|
15067
15173
|
onBeforeActionResponse: zFunction().optional(),
|
|
15068
15174
|
onRequest: zFunction().optional(),
|
|
15069
15175
|
onWebSocket: zFunction().optional(),
|
|
15070
|
-
actions:
|
|
15176
|
+
actions: zActionTree.default(() => ({})),
|
|
15071
15177
|
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15072
15178
|
connParamsSchema: external_exports.any().optional(),
|
|
15073
15179
|
events: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
@@ -15211,10 +15317,10 @@ var DocActorConfigSchema = external_exports.object({
|
|
|
15211
15317
|
"Called for raw WebSocket connections to /actors/{name}/websocket/* endpoints."
|
|
15212
15318
|
),
|
|
15213
15319
|
actions: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15214
|
-
"
|
|
15320
|
+
"Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object."
|
|
15215
15321
|
),
|
|
15216
15322
|
actionInputSchemas: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
|
|
15217
|
-
"Optional
|
|
15323
|
+
"Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names."
|
|
15218
15324
|
),
|
|
15219
15325
|
connParamsSchema: external_exports.unknown().optional().describe(
|
|
15220
15326
|
"Optional schema for validating connection params in native runtimes."
|
|
@@ -15341,35 +15447,7 @@ function removePrefixFromKey(prefixedKey) {
|
|
|
15341
15447
|
return prefixedKey.slice(KEYS.KV.length);
|
|
15342
15448
|
}
|
|
15343
15449
|
|
|
15344
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15345
|
-
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15346
|
-
var AsyncMutex = class {
|
|
15347
|
-
#locked = false;
|
|
15348
|
-
#waiting = [];
|
|
15349
|
-
async acquire() {
|
|
15350
|
-
while (this.#locked) {
|
|
15351
|
-
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15352
|
-
}
|
|
15353
|
-
this.#locked = true;
|
|
15354
|
-
}
|
|
15355
|
-
release() {
|
|
15356
|
-
this.#locked = false;
|
|
15357
|
-
const next = this.#waiting.shift();
|
|
15358
|
-
if (next) {
|
|
15359
|
-
next();
|
|
15360
|
-
}
|
|
15361
|
-
}
|
|
15362
|
-
async run(fn) {
|
|
15363
|
-
await this.acquire();
|
|
15364
|
-
try {
|
|
15365
|
-
return await fn();
|
|
15366
|
-
} finally {
|
|
15367
|
-
this.release();
|
|
15368
|
-
}
|
|
15369
|
-
}
|
|
15370
|
-
};
|
|
15371
|
-
|
|
15372
|
-
// ../rivetkit/dist/tsup/chunk-PAG6G46L.js
|
|
15450
|
+
// ../rivetkit/dist/tsup/chunk-OH6CBWUD.js
|
|
15373
15451
|
function logger() {
|
|
15374
15452
|
return getLogger("actor-client");
|
|
15375
15453
|
}
|
|
@@ -15407,7 +15485,35 @@ async function importWebSocket() {
|
|
|
15407
15485
|
return webSocketPromise;
|
|
15408
15486
|
}
|
|
15409
15487
|
|
|
15410
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15488
|
+
// ../rivetkit/dist/tsup/chunk-7AFZMFPQ.js
|
|
15489
|
+
var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
|
|
15490
|
+
var AsyncMutex = class {
|
|
15491
|
+
#locked = false;
|
|
15492
|
+
#waiting = [];
|
|
15493
|
+
async acquire() {
|
|
15494
|
+
while (this.#locked) {
|
|
15495
|
+
await new Promise((resolve) => this.#waiting.push(resolve));
|
|
15496
|
+
}
|
|
15497
|
+
this.#locked = true;
|
|
15498
|
+
}
|
|
15499
|
+
release() {
|
|
15500
|
+
this.#locked = false;
|
|
15501
|
+
const next = this.#waiting.shift();
|
|
15502
|
+
if (next) {
|
|
15503
|
+
next();
|
|
15504
|
+
}
|
|
15505
|
+
}
|
|
15506
|
+
async run(fn) {
|
|
15507
|
+
await this.acquire();
|
|
15508
|
+
try {
|
|
15509
|
+
return await fn();
|
|
15510
|
+
} finally {
|
|
15511
|
+
this.release();
|
|
15512
|
+
}
|
|
15513
|
+
}
|
|
15514
|
+
};
|
|
15515
|
+
|
|
15516
|
+
// ../rivetkit/dist/tsup/chunk-F6ZW7JZQ.js
|
|
15411
15517
|
var import_invariant2 = __toESM(require_invariant(), 1);
|
|
15412
15518
|
|
|
15413
15519
|
// ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
@@ -15585,7 +15691,7 @@ function createVersionedDataHandler(config3) {
|
|
|
15585
15691
|
return new VersionedDataHandler(config3);
|
|
15586
15692
|
}
|
|
15587
15693
|
|
|
15588
|
-
// ../rivetkit/dist/tsup/chunk-
|
|
15694
|
+
// ../rivetkit/dist/tsup/chunk-F6ZW7JZQ.js
|
|
15589
15695
|
var import_invariant3 = __toESM(require_invariant(), 1);
|
|
15590
15696
|
var import_invariant4 = __toESM(require_invariant(), 1);
|
|
15591
15697
|
var PATH_CONNECT = "/connect";
|
|
@@ -19032,6 +19138,23 @@ function createClientWithDriver(driver, config3 = {}) {
|
|
|
19032
19138
|
}
|
|
19033
19139
|
function createActorProxy(handle) {
|
|
19034
19140
|
const methodCache = /* @__PURE__ */ new Map();
|
|
19141
|
+
const actionPath = (name) => {
|
|
19142
|
+
let method2 = methodCache.get(name);
|
|
19143
|
+
if (method2) return method2;
|
|
19144
|
+
method2 = new Proxy(
|
|
19145
|
+
(...args) => handle.action({ name, args }),
|
|
19146
|
+
{
|
|
19147
|
+
get(target, prop) {
|
|
19148
|
+
if (typeof prop === "symbol")
|
|
19149
|
+
return Reflect.get(target, prop);
|
|
19150
|
+
if (prop === "then") return void 0;
|
|
19151
|
+
return actionPath(`${name}.${prop}`);
|
|
19152
|
+
}
|
|
19153
|
+
}
|
|
19154
|
+
);
|
|
19155
|
+
methodCache.set(name, method2);
|
|
19156
|
+
return method2;
|
|
19157
|
+
};
|
|
19035
19158
|
return new Proxy(handle, {
|
|
19036
19159
|
get(target, prop, receiver) {
|
|
19037
19160
|
if (typeof prop === "symbol") {
|
|
@@ -19046,12 +19169,7 @@ function createActorProxy(handle) {
|
|
|
19046
19169
|
}
|
|
19047
19170
|
if (typeof prop === "string") {
|
|
19048
19171
|
if (prop === "then") return void 0;
|
|
19049
|
-
|
|
19050
|
-
if (!method2) {
|
|
19051
|
-
method2 = (...args) => target.action({ name: prop, args });
|
|
19052
|
-
methodCache.set(prop, method2);
|
|
19053
|
-
}
|
|
19054
|
-
return method2;
|
|
19172
|
+
return actionPath(prop);
|
|
19055
19173
|
}
|
|
19056
19174
|
},
|
|
19057
19175
|
// Support for 'in' operator
|
|
@@ -19069,6 +19187,7 @@ function createActorProxy(handle) {
|
|
|
19069
19187
|
},
|
|
19070
19188
|
// Support proper property descriptors
|
|
19071
19189
|
getOwnPropertyDescriptor(target, prop) {
|
|
19190
|
+
if (prop === "then") return void 0;
|
|
19072
19191
|
const targetDescriptor = Reflect.getOwnPropertyDescriptor(
|
|
19073
19192
|
target,
|
|
19074
19193
|
prop
|
|
@@ -19081,7 +19200,7 @@ function createActorProxy(handle) {
|
|
|
19081
19200
|
configurable: true,
|
|
19082
19201
|
enumerable: false,
|
|
19083
19202
|
writable: false,
|
|
19084
|
-
value: (
|
|
19203
|
+
value: actionPath(prop)
|
|
19085
19204
|
};
|
|
19086
19205
|
}
|
|
19087
19206
|
return void 0;
|
|
@@ -20317,103 +20436,6 @@ function convertRegistryConfigToClientConfig(config3) {
|
|
|
20317
20436
|
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")
|
|
20318
20437
|
};
|
|
20319
20438
|
}
|
|
20320
|
-
function logger2() {
|
|
20321
|
-
return getLogger("engine-client");
|
|
20322
|
-
}
|
|
20323
|
-
function getEndpoint(config3) {
|
|
20324
|
-
return config3.endpoint ?? "http://127.0.0.1:6420";
|
|
20325
|
-
}
|
|
20326
|
-
async function apiCall(config3, method2, path2, body) {
|
|
20327
|
-
const endpoint = getEndpoint(config3);
|
|
20328
|
-
const url2 = combineUrlPath(endpoint, path2, {
|
|
20329
|
-
namespace: config3.namespace
|
|
20330
|
-
});
|
|
20331
|
-
logger2().debug({ msg: "making api call", method: method2, url: url2 });
|
|
20332
|
-
const headers = {
|
|
20333
|
-
...config3.headers
|
|
20334
|
-
};
|
|
20335
|
-
if (config3.token) {
|
|
20336
|
-
headers.Authorization = `Bearer ${config3.token}`;
|
|
20337
|
-
}
|
|
20338
|
-
return await sendHttpRequest({
|
|
20339
|
-
method: method2,
|
|
20340
|
-
url: url2,
|
|
20341
|
-
headers,
|
|
20342
|
-
body,
|
|
20343
|
-
encoding: "json",
|
|
20344
|
-
skipParseResponse: false,
|
|
20345
|
-
requestVersionedDataHandler: void 0,
|
|
20346
|
-
requestVersion: void 0,
|
|
20347
|
-
responseVersionedDataHandler: void 0,
|
|
20348
|
-
responseVersion: void 0,
|
|
20349
|
-
requestZodSchema: external_exports.any(),
|
|
20350
|
-
responseZodSchema: external_exports.any(),
|
|
20351
|
-
// Identity conversions (passthrough for generic API calls)
|
|
20352
|
-
requestToJson: (value) => value,
|
|
20353
|
-
requestToBare: (value) => value,
|
|
20354
|
-
responseFromJson: (value) => value,
|
|
20355
|
-
responseFromBare: (value) => value
|
|
20356
|
-
});
|
|
20357
|
-
}
|
|
20358
|
-
async function getActor(config3, _, actorId) {
|
|
20359
|
-
return apiCall(
|
|
20360
|
-
config3,
|
|
20361
|
-
"GET",
|
|
20362
|
-
`/actors?actor_ids=${encodeURIComponent(actorId)}`
|
|
20363
|
-
);
|
|
20364
|
-
}
|
|
20365
|
-
async function getActorByKey(config3, name, key) {
|
|
20366
|
-
const serializedKey = serializeActorKey(key);
|
|
20367
|
-
return apiCall(
|
|
20368
|
-
config3,
|
|
20369
|
-
"GET",
|
|
20370
|
-
`/actors?name=${encodeURIComponent(name)}&key=${encodeURIComponent(serializedKey)}`
|
|
20371
|
-
);
|
|
20372
|
-
}
|
|
20373
|
-
async function listActorsByName(config3, name) {
|
|
20374
|
-
return apiCall(
|
|
20375
|
-
config3,
|
|
20376
|
-
"GET",
|
|
20377
|
-
`/actors?name=${encodeURIComponent(name)}`
|
|
20378
|
-
);
|
|
20379
|
-
}
|
|
20380
|
-
async function getOrCreateActor(config3, request) {
|
|
20381
|
-
return apiCall(
|
|
20382
|
-
config3,
|
|
20383
|
-
"PUT",
|
|
20384
|
-
`/actors`,
|
|
20385
|
-
request
|
|
20386
|
-
);
|
|
20387
|
-
}
|
|
20388
|
-
async function createActor(config3, request) {
|
|
20389
|
-
return apiCall(
|
|
20390
|
-
config3,
|
|
20391
|
-
"POST",
|
|
20392
|
-
`/actors`,
|
|
20393
|
-
request
|
|
20394
|
-
);
|
|
20395
|
-
}
|
|
20396
|
-
async function destroyActor(config3, actorId) {
|
|
20397
|
-
return apiCall(
|
|
20398
|
-
config3,
|
|
20399
|
-
"DELETE",
|
|
20400
|
-
`/actors/${encodeURIComponent(actorId)}`
|
|
20401
|
-
);
|
|
20402
|
-
}
|
|
20403
|
-
async function getMetadata(config3) {
|
|
20404
|
-
return apiCall(config3, "GET", `/metadata`);
|
|
20405
|
-
}
|
|
20406
|
-
async function getDatacenters(config3) {
|
|
20407
|
-
return apiCall(config3, "GET", `/datacenters`);
|
|
20408
|
-
}
|
|
20409
|
-
async function updateRunnerConfig(config3, runnerName, request) {
|
|
20410
|
-
return apiCall(
|
|
20411
|
-
config3,
|
|
20412
|
-
"PUT",
|
|
20413
|
-
`/runner-configs/${runnerName}`,
|
|
20414
|
-
request
|
|
20415
|
-
);
|
|
20416
|
-
}
|
|
20417
20439
|
function shouldSkipReadyWait(options = {}) {
|
|
20418
20440
|
return options.skipReadyWait === true;
|
|
20419
20441
|
}
|
|
@@ -20501,6 +20523,9 @@ function setRemoteHibernatableWebSocketAckTestHooks(websocket, token, enabled) {
|
|
|
20501
20523
|
enabled
|
|
20502
20524
|
);
|
|
20503
20525
|
}
|
|
20526
|
+
function logger2() {
|
|
20527
|
+
return getLogger("engine-client");
|
|
20528
|
+
}
|
|
20504
20529
|
var BufferedRemoteWebSocket = class {
|
|
20505
20530
|
CONNECTING = 0;
|
|
20506
20531
|
OPEN = 1;
|
|
@@ -20778,6 +20803,100 @@ function buildWebSocketProtocols(runConfig, encoding, params, ackHookToken, targ
|
|
|
20778
20803
|
}
|
|
20779
20804
|
return protocols;
|
|
20780
20805
|
}
|
|
20806
|
+
function getEndpoint(config3) {
|
|
20807
|
+
return config3.endpoint ?? "http://127.0.0.1:6420";
|
|
20808
|
+
}
|
|
20809
|
+
async function apiCall(config3, method2, path2, body) {
|
|
20810
|
+
const endpoint = getEndpoint(config3);
|
|
20811
|
+
const url2 = combineUrlPath(endpoint, path2, {
|
|
20812
|
+
namespace: config3.namespace
|
|
20813
|
+
});
|
|
20814
|
+
logger2().debug({ msg: "making api call", method: method2, url: url2 });
|
|
20815
|
+
const headers = {
|
|
20816
|
+
...config3.headers
|
|
20817
|
+
};
|
|
20818
|
+
if (config3.token) {
|
|
20819
|
+
headers.Authorization = `Bearer ${config3.token}`;
|
|
20820
|
+
}
|
|
20821
|
+
return await sendHttpRequest({
|
|
20822
|
+
method: method2,
|
|
20823
|
+
url: url2,
|
|
20824
|
+
headers,
|
|
20825
|
+
body,
|
|
20826
|
+
encoding: "json",
|
|
20827
|
+
skipParseResponse: false,
|
|
20828
|
+
requestVersionedDataHandler: void 0,
|
|
20829
|
+
requestVersion: void 0,
|
|
20830
|
+
responseVersionedDataHandler: void 0,
|
|
20831
|
+
responseVersion: void 0,
|
|
20832
|
+
requestZodSchema: external_exports.any(),
|
|
20833
|
+
responseZodSchema: external_exports.any(),
|
|
20834
|
+
// Identity conversions (passthrough for generic API calls)
|
|
20835
|
+
requestToJson: (value) => value,
|
|
20836
|
+
requestToBare: (value) => value,
|
|
20837
|
+
responseFromJson: (value) => value,
|
|
20838
|
+
responseFromBare: (value) => value
|
|
20839
|
+
});
|
|
20840
|
+
}
|
|
20841
|
+
async function getActor(config3, _, actorId) {
|
|
20842
|
+
return apiCall(
|
|
20843
|
+
config3,
|
|
20844
|
+
"GET",
|
|
20845
|
+
`/actors?actor_ids=${encodeURIComponent(actorId)}`
|
|
20846
|
+
);
|
|
20847
|
+
}
|
|
20848
|
+
async function getActorByKey(config3, name, key) {
|
|
20849
|
+
const serializedKey = serializeActorKey(key);
|
|
20850
|
+
return apiCall(
|
|
20851
|
+
config3,
|
|
20852
|
+
"GET",
|
|
20853
|
+
`/actors?name=${encodeURIComponent(name)}&key=${encodeURIComponent(serializedKey)}`
|
|
20854
|
+
);
|
|
20855
|
+
}
|
|
20856
|
+
async function listActorsByName(config3, name) {
|
|
20857
|
+
return apiCall(
|
|
20858
|
+
config3,
|
|
20859
|
+
"GET",
|
|
20860
|
+
`/actors?name=${encodeURIComponent(name)}`
|
|
20861
|
+
);
|
|
20862
|
+
}
|
|
20863
|
+
async function getOrCreateActor(config3, request) {
|
|
20864
|
+
return apiCall(
|
|
20865
|
+
config3,
|
|
20866
|
+
"PUT",
|
|
20867
|
+
`/actors`,
|
|
20868
|
+
request
|
|
20869
|
+
);
|
|
20870
|
+
}
|
|
20871
|
+
async function createActor(config3, request) {
|
|
20872
|
+
return apiCall(
|
|
20873
|
+
config3,
|
|
20874
|
+
"POST",
|
|
20875
|
+
`/actors`,
|
|
20876
|
+
request
|
|
20877
|
+
);
|
|
20878
|
+
}
|
|
20879
|
+
async function destroyActor(config3, actorId) {
|
|
20880
|
+
return apiCall(
|
|
20881
|
+
config3,
|
|
20882
|
+
"DELETE",
|
|
20883
|
+
`/actors/${encodeURIComponent(actorId)}`
|
|
20884
|
+
);
|
|
20885
|
+
}
|
|
20886
|
+
async function getMetadata(config3) {
|
|
20887
|
+
return apiCall(config3, "GET", `/metadata`);
|
|
20888
|
+
}
|
|
20889
|
+
async function getDatacenters(config3) {
|
|
20890
|
+
return apiCall(config3, "GET", `/datacenters`);
|
|
20891
|
+
}
|
|
20892
|
+
async function updateRunnerConfig(config3, runnerName, request) {
|
|
20893
|
+
return apiCall(
|
|
20894
|
+
config3,
|
|
20895
|
+
"PUT",
|
|
20896
|
+
`/runner-configs/${runnerName}`,
|
|
20897
|
+
request
|
|
20898
|
+
);
|
|
20899
|
+
}
|
|
20781
20900
|
var metadataLookupCache = /* @__PURE__ */ new Map();
|
|
20782
20901
|
async function lookupMetadataCached(config3) {
|
|
20783
20902
|
const endpoint = getEndpoint(config3);
|
|
@@ -22536,6 +22655,8 @@ function actor(input) {
|
|
|
22536
22655
|
input == null ? void 0 : input.options
|
|
22537
22656
|
);
|
|
22538
22657
|
const config3 = ActorConfigSchema.parse(input);
|
|
22658
|
+
flattenActionHandlers(config3.actions);
|
|
22659
|
+
flattenActionInputSchemas(config3.actions, config3.actionInputSchemas);
|
|
22539
22660
|
return new ActorDefinition(config3);
|
|
22540
22661
|
}
|
|
22541
22662
|
function isStaticActorDefinition(definition) {
|
|
@@ -23192,7 +23313,7 @@ var RegistryConfigSchema = external_exports.object({
|
|
|
23192
23313
|
config3.engineHost,
|
|
23193
23314
|
config3.enginePort
|
|
23194
23315
|
);
|
|
23195
|
-
const endpoint = config3.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ?
|
|
23316
|
+
const endpoint = config3.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ? localEngineEndpoint : void 0);
|
|
23196
23317
|
const validateServerlessEndpoint = Boolean(
|
|
23197
23318
|
config3.startEngine || parsedEndpoint
|
|
23198
23319
|
);
|
|
@@ -23209,7 +23330,7 @@ var RegistryConfigSchema = external_exports.object({
|
|
|
23209
23330
|
path: ["serverless", "publicEndpoint"]
|
|
23210
23331
|
});
|
|
23211
23332
|
}
|
|
23212
|
-
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv &&
|
|
23333
|
+
const publicEndpoint = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint) ?? (isDevEnv && !parsedEndpoint ? endpoint : void 0);
|
|
23213
23334
|
const publicNamespace = parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.namespace;
|
|
23214
23335
|
const publicToken = (parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.token) ?? config3.serverless.publicToken;
|
|
23215
23336
|
return {
|
|
@@ -23879,6 +24000,9 @@ var NapiCoreRuntime = class {
|
|
|
23879
24000
|
async serveRegistry(registry2, config3) {
|
|
23880
24001
|
await asNativeRegistry(registry2).serve(config3);
|
|
23881
24002
|
}
|
|
24003
|
+
async waitRegistryReady(registry2) {
|
|
24004
|
+
await asNativeRegistry(registry2).waitReady();
|
|
24005
|
+
}
|
|
23882
24006
|
async shutdownRegistry(registry2) {
|
|
23883
24007
|
await asNativeRegistry(registry2).shutdown();
|
|
23884
24008
|
}
|
|
@@ -24543,6 +24667,11 @@ var WasmCoreRuntime = class {
|
|
|
24543
24667
|
async serveRegistry(registry2, config3) {
|
|
24544
24668
|
await callWasm(() => asWasmRegistry(registry2).serve(config3));
|
|
24545
24669
|
}
|
|
24670
|
+
async waitRegistryReady() {
|
|
24671
|
+
throw new Error(
|
|
24672
|
+
"registry.startAndWait() is not supported by the WASM runtime"
|
|
24673
|
+
);
|
|
24674
|
+
}
|
|
24546
24675
|
async shutdownRegistry(registry2) {
|
|
24547
24676
|
await callWasm(() => asWasmRegistry(registry2).shutdown());
|
|
24548
24677
|
}
|
|
@@ -27532,7 +27661,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
27532
27661
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
27533
27662
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
27534
27663
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
27535
|
-
actions: Object.keys(config3.actions
|
|
27664
|
+
actions: Object.keys(flattenActionHandlers(config3.actions)).sort().map((name) => ({ name })),
|
|
27536
27665
|
inspectorTabs: buildInspectorTabs(config3.inspector, runtimeKind)
|
|
27537
27666
|
};
|
|
27538
27667
|
}
|
|
@@ -27609,15 +27738,16 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
27609
27738
|
var _a2;
|
|
27610
27739
|
const config3 = definition.config;
|
|
27611
27740
|
const databaseProvider = config3.db;
|
|
27741
|
+
const actionHandlers = flattenActionHandlers(config3.actions);
|
|
27612
27742
|
const schemaConfig = {
|
|
27613
|
-
actionInputSchemas:
|
|
27743
|
+
actionInputSchemas: flattenActionInputSchemas(
|
|
27744
|
+
config3.actions,
|
|
27745
|
+
config3.actionInputSchemas
|
|
27746
|
+
),
|
|
27614
27747
|
connParamsSchema: config3.connParamsSchema,
|
|
27615
27748
|
events: config3.events,
|
|
27616
27749
|
queues: config3.queues
|
|
27617
27750
|
};
|
|
27618
|
-
const actionHandlers = Object.fromEntries(
|
|
27619
|
-
Object.entries(config3.actions ?? {}).map(([name, handler]) => [name, handler])
|
|
27620
|
-
);
|
|
27621
27751
|
const createClient = () => createClientWithDriver(
|
|
27622
27752
|
new RemoteEngineControlClient(
|
|
27623
27753
|
convertRegistryConfigToClientConfig(registryConfig)
|
|
@@ -28665,6 +28795,7 @@ async function buildConfiguredRegistry(config3) {
|
|
|
28665
28795
|
runtime
|
|
28666
28796
|
);
|
|
28667
28797
|
}
|
|
28798
|
+
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
28668
28799
|
function signalExitCode(signal) {
|
|
28669
28800
|
switch (signal) {
|
|
28670
28801
|
case "SIGINT":
|
|
@@ -28690,6 +28821,8 @@ var Registry = class {
|
|
|
28690
28821
|
return RegistryConfigSchema.parse(this.#config);
|
|
28691
28822
|
}
|
|
28692
28823
|
#runtimeServePromise;
|
|
28824
|
+
#runtimeServeLifecyclePromise;
|
|
28825
|
+
#runtimeReadyPromise;
|
|
28693
28826
|
#runtimeServeConfiguredPromise;
|
|
28694
28827
|
#runtimeServerlessPromise;
|
|
28695
28828
|
#configureServerlessPoolPromise;
|
|
@@ -29036,11 +29169,16 @@ var Registry = class {
|
|
|
29036
29169
|
if (!this.#runtimeServePromise) {
|
|
29037
29170
|
const configuredRegistryPromise = this.#buildConfiguredRegistry(config3);
|
|
29038
29171
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
29039
|
-
this.#
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29172
|
+
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
29173
|
+
async ({ runtime, registry: registry2, serveConfig }) => {
|
|
29174
|
+
await runtime.serveRegistry(registry2, serveConfig);
|
|
29175
|
+
}
|
|
29176
|
+
);
|
|
29177
|
+
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch(
|
|
29178
|
+
(error46) => {
|
|
29179
|
+
logger22().warn({ error: error46 }, "runtime registry serve errored");
|
|
29180
|
+
}
|
|
29181
|
+
);
|
|
29044
29182
|
this.#installSignalHandlers(config3);
|
|
29045
29183
|
}
|
|
29046
29184
|
if (printWelcome) {
|
|
@@ -29186,6 +29324,75 @@ var Registry = class {
|
|
|
29186
29324
|
startEnvoy() {
|
|
29187
29325
|
this.#startEnvoy(this.parseConfig(), true);
|
|
29188
29326
|
}
|
|
29327
|
+
/**
|
|
29328
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
29329
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
29330
|
+
* startup lifecycle and readiness promise.
|
|
29331
|
+
*
|
|
29332
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
29333
|
+
* merely because an HTTP health endpoint is listening.
|
|
29334
|
+
*/
|
|
29335
|
+
startAndWait() {
|
|
29336
|
+
if (this.#shutdownInFlight !== null) {
|
|
29337
|
+
return Promise.reject(
|
|
29338
|
+
new Error("registry.startAndWait() cannot run after shutdown has begun")
|
|
29339
|
+
);
|
|
29340
|
+
}
|
|
29341
|
+
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
29342
|
+
if (getRivetkitRuntimeMode() === "serverless") {
|
|
29343
|
+
return Promise.reject(
|
|
29344
|
+
new Error(
|
|
29345
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
29346
|
+
)
|
|
29347
|
+
);
|
|
29348
|
+
}
|
|
29349
|
+
const config3 = this.parseConfig();
|
|
29350
|
+
if (config3.runtime === "wasm") {
|
|
29351
|
+
return Promise.reject(
|
|
29352
|
+
new Error(
|
|
29353
|
+
"registry.startAndWait() requires the native runtime; WebAssembly registries do not host an envoy"
|
|
29354
|
+
)
|
|
29355
|
+
);
|
|
29356
|
+
}
|
|
29357
|
+
this.#startEnvoy(config3, true);
|
|
29358
|
+
const configuredRegistryPromise = this.#runtimeServeConfiguredPromise;
|
|
29359
|
+
const serveLifecyclePromise = this.#runtimeServeLifecyclePromise;
|
|
29360
|
+
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
29361
|
+
throw new Error("registry envoy startup did not initialize");
|
|
29362
|
+
}
|
|
29363
|
+
let timeout;
|
|
29364
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
29365
|
+
var _a2;
|
|
29366
|
+
timeout = setTimeout(
|
|
29367
|
+
() => reject(
|
|
29368
|
+
new Error(
|
|
29369
|
+
`RivetKit registry did not register with the Engine within ${REGISTRY_READY_TIMEOUT_MS}ms`
|
|
29370
|
+
)
|
|
29371
|
+
),
|
|
29372
|
+
REGISTRY_READY_TIMEOUT_MS
|
|
29373
|
+
);
|
|
29374
|
+
(_a2 = timeout.unref) == null ? void 0 : _a2.call(timeout);
|
|
29375
|
+
});
|
|
29376
|
+
const readinessPromise = (async () => {
|
|
29377
|
+
const { runtime, registry: registry2 } = await configuredRegistryPromise;
|
|
29378
|
+
const stoppedBeforeReady = serveLifecyclePromise.then(() => {
|
|
29379
|
+
throw new Error("RivetKit registry stopped before becoming ready");
|
|
29380
|
+
});
|
|
29381
|
+
await Promise.race([
|
|
29382
|
+
runtime.waitRegistryReady(registry2),
|
|
29383
|
+
stoppedBeforeReady
|
|
29384
|
+
]);
|
|
29385
|
+
})();
|
|
29386
|
+
this.#runtimeReadyPromise = Promise.race([
|
|
29387
|
+
readinessPromise,
|
|
29388
|
+
timeoutPromise
|
|
29389
|
+
]).finally(() => {
|
|
29390
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
29391
|
+
});
|
|
29392
|
+
this.#runtimeReadyPromise.catch(() => {
|
|
29393
|
+
});
|
|
29394
|
+
return this.#runtimeReadyPromise;
|
|
29395
|
+
}
|
|
29189
29396
|
/**
|
|
29190
29397
|
* Starts the actor envoy for standalone server deployments.
|
|
29191
29398
|
*
|