rivetkit 3.0.1 → 3.0.2
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/browser/client.d.ts +69 -7
- package/dist/browser/client.js +1 -1
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-LXSYHJ7E.cjs → chunk-3C5KLO4V.cjs} +4 -4
- package/dist/tsup/{chunk-LXSYHJ7E.cjs.map → chunk-3C5KLO4V.cjs.map} +1 -1
- package/dist/tsup/{chunk-B3MXZSPO.cjs → chunk-3KVVYC5I.cjs} +144 -144
- package/dist/tsup/{chunk-B3MXZSPO.cjs.map → chunk-3KVVYC5I.cjs.map} +1 -1
- package/dist/tsup/{chunk-B5WDVY32.js → chunk-3RE23GTB.js} +2 -2
- package/dist/tsup/{chunk-B5WDVY32.js.map → chunk-3RE23GTB.js.map} +1 -1
- package/dist/tsup/{chunk-2JSFY7XD.js → chunk-47W6FHPJ.js} +2 -2
- package/dist/tsup/{chunk-57I7SSSV.js → chunk-4ASLJWUQ.js} +4 -4
- package/dist/tsup/{chunk-JOCSSMLU.js → chunk-ANP7UCAM.js} +6 -6
- package/dist/tsup/{chunk-NSQWB4QD.cjs → chunk-BBEH6RML.cjs} +3 -3
- package/dist/tsup/{chunk-NSQWB4QD.cjs.map → chunk-BBEH6RML.cjs.map} +1 -1
- package/dist/tsup/{chunk-HQ5JCCK6.cjs → chunk-DVXMOEFT.cjs} +7 -7
- package/dist/tsup/{chunk-HQ5JCCK6.cjs.map → chunk-DVXMOEFT.cjs.map} +1 -1
- package/dist/tsup/{chunk-N7V3BQUB.cjs → chunk-FR5QOAYE.cjs} +10 -10
- package/dist/tsup/{chunk-N7V3BQUB.cjs.map → chunk-FR5QOAYE.cjs.map} +1 -1
- package/dist/tsup/{chunk-BOVQ3JQK.js → chunk-HJWK46Z5.js} +3 -3
- package/dist/tsup/{chunk-QX7DWU46.js → chunk-J7T52LN6.js} +2 -2
- package/dist/tsup/{chunk-3PFAODLE.cjs → chunk-KF7ETIFK.cjs} +3 -3
- package/dist/tsup/{chunk-3PFAODLE.cjs.map → chunk-KF7ETIFK.cjs.map} +1 -1
- package/dist/tsup/{chunk-QI7E2UH5.cjs → chunk-M3H37DUQ.cjs} +2 -2
- package/dist/tsup/{chunk-QI7E2UH5.cjs.map → chunk-M3H37DUQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-4VEJIK7O.cjs → chunk-M7KPJSGO.cjs} +3 -3
- package/dist/tsup/{chunk-4VEJIK7O.cjs.map → chunk-M7KPJSGO.cjs.map} +1 -1
- package/dist/tsup/{chunk-7K6MC544.js → chunk-OF63EVJQ.js} +2 -2
- package/dist/tsup/{chunk-PLZVADML.js → chunk-ZAZAKYNQ.js} +2 -2
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-XfKwGYxx.d.ts → config-BtUHYdoj.d.ts} +21 -1
- package/dist/tsup/{config-B2wlj9wx.d.ts → config-CBTr4IhE.d.cts} +50 -8
- package/dist/tsup/{config-B2wlj9wx.d.cts → config-CBTr4IhE.d.ts} +50 -8
- package/dist/tsup/{config-K9uOKlok.d.cts → config-H6pJy_J1.d.cts} +21 -1
- package/dist/tsup/{context-Bm7mA4E3.d.ts → context-DrDoMXSD.d.ts} +2 -2
- package/dist/tsup/{context-CPCM-xn6.d.cts → context-TWrKZjqf.d.cts} +2 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/mod.cjs +212 -87
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +131 -6
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +7 -7
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +9 -9
- package/src/common/database/config.ts +50 -7
- package/src/db/mod.ts +1 -0
- package/src/registry/index.ts +142 -1
- package/src/registry/napi-runtime.ts +15 -0
- package/src/registry/runtime.ts +6 -0
- /package/dist/tsup/{chunk-2JSFY7XD.js.map → chunk-47W6FHPJ.js.map} +0 -0
- /package/dist/tsup/{chunk-57I7SSSV.js.map → chunk-4ASLJWUQ.js.map} +0 -0
- /package/dist/tsup/{chunk-JOCSSMLU.js.map → chunk-ANP7UCAM.js.map} +0 -0
- /package/dist/tsup/{chunk-BOVQ3JQK.js.map → chunk-HJWK46Z5.js.map} +0 -0
- /package/dist/tsup/{chunk-QX7DWU46.js.map → chunk-J7T52LN6.js.map} +0 -0
- /package/dist/tsup/{chunk-7K6MC544.js.map → chunk-OF63EVJQ.js.map} +0 -0
- /package/dist/tsup/{chunk-PLZVADML.js.map → chunk-ZAZAKYNQ.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk3C5KLO4Vcjs = require('./chunk-3C5KLO4V.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -35,18 +35,18 @@ var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunk3KVVYC5Icjs = require('./chunk-3KVVYC5I.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
var _chunkRTWH3AX3cjs = require('./chunk-RTWH3AX3.cjs');
|
|
43
|
+
require('./chunk-M7KPJSGO.cjs');
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
var
|
|
48
|
+
var _chunkKF7ETIFKcjs = require('./chunk-KF7ETIFK.cjs');
|
|
48
49
|
require('./chunk-KVFIONKQ.cjs');
|
|
49
|
-
require('./chunk-4VEJIK7O.cjs');
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
@@ -80,7 +80,7 @@ require('./chunk-4VEJIK7O.cjs');
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkM3H37DUQcjs = require('./chunk-M3H37DUQ.cjs');
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
|
|
@@ -98,7 +98,7 @@ var _chunkMGI2VVF6cjs = require('./chunk-MGI2VVF6.cjs');
|
|
|
98
98
|
|
|
99
99
|
// src/actor/log.ts
|
|
100
100
|
function loggerWithoutContext() {
|
|
101
|
-
return
|
|
101
|
+
return _chunkM3H37DUQcjs.getLogger.call(void 0, "actor-runtime");
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// src/actor/definition.ts
|
|
@@ -240,7 +240,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
240
240
|
var _virtualwebsocket = require('@rivetkit/virtual-websocket');
|
|
241
241
|
var _ws = require('hono/ws');
|
|
242
242
|
function logger() {
|
|
243
|
-
return
|
|
243
|
+
return _chunkM3H37DUQcjs.getLogger.call(void 0, "inline-websocket-adapter");
|
|
244
244
|
}
|
|
245
245
|
var InlineWebSocketAdapter = class {
|
|
246
246
|
#handler;
|
|
@@ -392,7 +392,7 @@ var InlineWebSocketAdapter = class {
|
|
|
392
392
|
|
|
393
393
|
// src/registry/log.ts
|
|
394
394
|
function logger2() {
|
|
395
|
-
return
|
|
395
|
+
return _chunkM3H37DUQcjs.getLogger.call(void 0, "registry");
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
// src/serverless/configure.ts
|
|
@@ -438,8 +438,8 @@ async function configureServerlessPool(config) {
|
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
440
|
const customConfig = config.configurePool;
|
|
441
|
-
const clientConfig =
|
|
442
|
-
const dcsRes = await
|
|
441
|
+
const clientConfig = _chunk3KVVYC5Icjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
442
|
+
const dcsRes = await _chunk3KVVYC5Icjs.getDatacenters.call(void 0, clientConfig);
|
|
443
443
|
const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
|
|
444
444
|
const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
|
|
445
445
|
const headers = {
|
|
@@ -461,7 +461,7 @@ async function configureServerlessPool(config) {
|
|
|
461
461
|
metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
|
|
462
462
|
drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
|
|
463
463
|
};
|
|
464
|
-
await
|
|
464
|
+
await _chunk3KVVYC5Icjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
|
|
465
465
|
datacenters: Object.fromEntries(
|
|
466
466
|
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
467
467
|
)
|
|
@@ -478,7 +478,7 @@ async function configureServerlessPool(config) {
|
|
|
478
478
|
logger2().warn({
|
|
479
479
|
msg: "serverless pool configuration attempt failed",
|
|
480
480
|
attempts,
|
|
481
|
-
error:
|
|
481
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
482
482
|
});
|
|
483
483
|
await sleep(CONFIGURE_RETRY_DELAY_MS);
|
|
484
484
|
}
|
|
@@ -486,7 +486,7 @@ async function configureServerlessPool(config) {
|
|
|
486
486
|
logger2().error({
|
|
487
487
|
msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
|
|
488
488
|
attempts,
|
|
489
|
-
error:
|
|
489
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, lastError)
|
|
490
490
|
});
|
|
491
491
|
throw lastError;
|
|
492
492
|
}
|
|
@@ -497,10 +497,10 @@ var _zod = require('zod');
|
|
|
497
497
|
// src/registry/config/envoy.ts
|
|
498
498
|
var _v4 = require('zod/v4');
|
|
499
499
|
var EnvoyConfigSchema = _v4.z.object({
|
|
500
|
-
poolName: _v4.z.string().default(() => _nullishCoalesce(
|
|
501
|
-
version: _v4.z.number().default(() => _nullishCoalesce(
|
|
500
|
+
poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
501
|
+
version: _v4.z.number().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
|
|
502
502
|
// Deprecated.
|
|
503
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
503
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
|
|
504
504
|
nodeKey: _v4.z.string().optional()
|
|
505
505
|
});
|
|
506
506
|
|
|
@@ -538,7 +538,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
538
538
|
*
|
|
539
539
|
* Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
|
|
540
540
|
*/
|
|
541
|
-
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
541
|
+
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetPublicEndpoint.call(void 0, )))),
|
|
542
542
|
/**
|
|
543
543
|
* Token that clients should use when connecting via the public endpoint.
|
|
544
544
|
*
|
|
@@ -546,7 +546,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
546
546
|
*
|
|
547
547
|
* Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
|
|
548
548
|
*/
|
|
549
|
-
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
549
|
+
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetPublicToken.call(void 0, ))))
|
|
550
550
|
// There is no publicNamespace config option because the frontend and backend
|
|
551
551
|
// cannot use different namespaces. The namespace is extracted from the
|
|
552
552
|
// publicEndpoint URL auth syntax if provided.
|
|
@@ -600,7 +600,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
600
600
|
* Runtime binding to use for RivetKit core.
|
|
601
601
|
* */
|
|
602
602
|
runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
|
|
603
|
-
const rawRuntime = _nullishCoalesce(val, () => (
|
|
603
|
+
const rawRuntime = _nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetkitRuntime.call(void 0, )));
|
|
604
604
|
if (rawRuntime === void 0) {
|
|
605
605
|
return "auto";
|
|
606
606
|
}
|
|
@@ -637,7 +637,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
637
637
|
* */
|
|
638
638
|
logging: _zod.z.object({
|
|
639
639
|
baseLogger: _zod.z.custom().optional(),
|
|
640
|
-
level:
|
|
640
|
+
level: _chunkM3H37DUQcjs.LogLevelSchema.optional()
|
|
641
641
|
}).optional().default(() => ({})),
|
|
642
642
|
// MARK: Routing
|
|
643
643
|
// // This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
@@ -655,9 +655,9 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
655
655
|
*
|
|
656
656
|
* Can also be set via RIVET_ENDPOINT environment variables.
|
|
657
657
|
*/
|
|
658
|
-
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
659
|
-
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
660
|
-
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
658
|
+
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetEngine.call(void 0, ))), () => ( _chunkM3H37DUQcjs.getRivetEndpoint.call(void 0, )))),
|
|
659
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetToken.call(void 0, )))),
|
|
660
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM3H37DUQcjs.getRivetNamespace.call(void 0, )))),
|
|
661
661
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
|
|
662
662
|
// MARK: Client
|
|
663
663
|
// TODO:
|
|
@@ -697,21 +697,21 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
697
697
|
*
|
|
698
698
|
* Starts the full Rust engine process locally.
|
|
699
699
|
*/
|
|
700
|
-
startEngine: _zod.z.boolean().default(() =>
|
|
700
|
+
startEngine: _zod.z.boolean().default(() => _chunkM3H37DUQcjs.getRivetRunEngine.call(void 0, )),
|
|
701
701
|
/**
|
|
702
702
|
* @experimental
|
|
703
703
|
*
|
|
704
704
|
* Host to bind the spawned local engine process to.
|
|
705
705
|
*/
|
|
706
|
-
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
706
|
+
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunk3KVVYC5Icjs.ENGINE_HOST))),
|
|
707
707
|
/**
|
|
708
708
|
* @experimental
|
|
709
709
|
*
|
|
710
710
|
* Port to bind the spawned local engine process to.
|
|
711
711
|
*/
|
|
712
|
-
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(
|
|
712
|
+
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunk3KVVYC5Icjs.ENGINE_PORT))),
|
|
713
713
|
/** @experimental */
|
|
714
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
714
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkM3H37DUQcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkM3H37DUQcjs.VERSION))),
|
|
715
715
|
/**
|
|
716
716
|
* Starts the first-party Services actor host when RivetKit manages
|
|
717
717
|
* a local engine. Enabled by default for a managed local Engine. Set
|
|
@@ -768,7 +768,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
768
768
|
}))
|
|
769
769
|
}).transform((config, ctx) => {
|
|
770
770
|
var _a, _b, _c;
|
|
771
|
-
const isDevEnv =
|
|
771
|
+
const isDevEnv = _chunkM3H37DUQcjs.isDev.call(void 0, );
|
|
772
772
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
773
773
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
774
774
|
ctx.addIssue({
|
|
@@ -778,7 +778,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
778
778
|
});
|
|
779
779
|
}
|
|
780
780
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
781
|
-
const parsedEndpoint = config.endpoint ?
|
|
781
|
+
const parsedEndpoint = config.endpoint ? _chunk3KVVYC5Icjs.tryParseEndpoint.call(void 0, ctx, {
|
|
782
782
|
endpoint: config.endpoint,
|
|
783
783
|
path: ["endpoint"],
|
|
784
784
|
namespace: config.namespace,
|
|
@@ -797,19 +797,19 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
797
797
|
path: ["configurePool"]
|
|
798
798
|
});
|
|
799
799
|
}
|
|
800
|
-
const localEngineEndpoint =
|
|
800
|
+
const localEngineEndpoint = _chunk3KVVYC5Icjs.buildEngineEndpoint.call(void 0,
|
|
801
801
|
config.engineHost,
|
|
802
802
|
config.enginePort
|
|
803
803
|
);
|
|
804
804
|
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
|
|
805
805
|
const engineSpawn = !parsedEndpoint && Boolean(endpoint);
|
|
806
|
-
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => (
|
|
806
|
+
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkM3H37DUQcjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
|
|
807
807
|
const validateServerlessEndpoint = Boolean(
|
|
808
808
|
config.startEngine || parsedEndpoint
|
|
809
809
|
);
|
|
810
810
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
811
|
-
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint &&
|
|
812
|
-
const parsedPublicEndpoint = config.serverless.publicEndpoint ?
|
|
811
|
+
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunk3KVVYC5Icjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
|
|
812
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunk3KVVYC5Icjs.tryParseEndpoint.call(void 0, ctx, {
|
|
813
813
|
endpoint: config.serverless.publicEndpoint,
|
|
814
814
|
path: ["serverless", "publicEndpoint"]
|
|
815
815
|
}) : void 0;
|
|
@@ -914,7 +914,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
914
914
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
915
915
|
sqlite: DocSqliteConfigSchema,
|
|
916
916
|
logging: _zod.z.object({
|
|
917
|
-
level:
|
|
917
|
+
level: _chunkM3H37DUQcjs.LogLevelSchema.optional().describe(
|
|
918
918
|
"Log level for RivetKit. Default: 'warn'"
|
|
919
919
|
)
|
|
920
920
|
}).optional().describe("Logging configuration."),
|
|
@@ -1554,7 +1554,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1554
1554
|
if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
|
|
1555
1555
|
return ownerCtx;
|
|
1556
1556
|
}
|
|
1557
|
-
const applicationSpan =
|
|
1557
|
+
const applicationSpan = _chunk3KVVYC5Icjs.readActiveTraceHeaders.call(void 0, );
|
|
1558
1558
|
if (!applicationSpan) {
|
|
1559
1559
|
return active;
|
|
1560
1560
|
}
|
|
@@ -1599,6 +1599,15 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1599
1599
|
async registryActorStopThresholdMs(registry) {
|
|
1600
1600
|
return await _asyncNullishCoalesce(await asNativeRegistry(registry).actorStopThresholdMs(), async () => ( void 0));
|
|
1601
1601
|
}
|
|
1602
|
+
registryActiveActorCount(registry) {
|
|
1603
|
+
return asNativeRegistry(registry).activeActorCount();
|
|
1604
|
+
}
|
|
1605
|
+
onRegistryActiveActorCountChange(registry, callback, cancelToken) {
|
|
1606
|
+
asNativeRegistry(registry).onActiveActorCountChange(
|
|
1607
|
+
callback,
|
|
1608
|
+
asNativeCancellationToken(cancelToken)
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1602
1611
|
async registryHealth(registry) {
|
|
1603
1612
|
const response = await asNativeRegistry(registry).health();
|
|
1604
1613
|
return {
|
|
@@ -1758,7 +1767,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1758
1767
|
const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
|
|
1759
1768
|
return this.#invocationContext.run(
|
|
1760
1769
|
nativeCtx,
|
|
1761
|
-
() =>
|
|
1770
|
+
() => _chunk3KVVYC5Icjs.runWithActorInvocationSpan.call(void 0, span, run)
|
|
1762
1771
|
);
|
|
1763
1772
|
}
|
|
1764
1773
|
actorInvocationTraceContext(ctx) {
|
|
@@ -2133,8 +2142,8 @@ function runtimeBytesToArrayBuffer(value) {
|
|
|
2133
2142
|
function buildNativeHttpRequest(init) {
|
|
2134
2143
|
var _a;
|
|
2135
2144
|
const headers = new Headers(init.headers);
|
|
2136
|
-
const originalUrl = headers.get(
|
|
2137
|
-
headers.delete(
|
|
2145
|
+
const originalUrl = headers.get(_chunk3KVVYC5Icjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2146
|
+
headers.delete(_chunk3KVVYC5Icjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2138
2147
|
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2139
2148
|
const method2 = init.method.toUpperCase();
|
|
2140
2149
|
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
@@ -2213,7 +2222,7 @@ async function pumpResponseBody(reader, stream) {
|
|
|
2213
2222
|
}
|
|
2214
2223
|
} catch (error) {
|
|
2215
2224
|
try {
|
|
2216
|
-
await stream.error(
|
|
2225
|
+
await stream.error(_chunkM3H37DUQcjs.stringifyError.call(void 0, error));
|
|
2217
2226
|
} catch (streamError) {
|
|
2218
2227
|
logger2().debug({
|
|
2219
2228
|
msg: "failed to report native http response stream error",
|
|
@@ -3452,7 +3461,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3452
3461
|
nativeError = error;
|
|
3453
3462
|
logger2().warn({
|
|
3454
3463
|
msg: "native runtime failed to load; falling back to wasm",
|
|
3455
|
-
error:
|
|
3464
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
3456
3465
|
});
|
|
3457
3466
|
}
|
|
3458
3467
|
try {
|
|
@@ -3461,7 +3470,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3461
3470
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3462
3471
|
"config",
|
|
3463
3472
|
"runtime_unavailable",
|
|
3464
|
-
`RivetKit could not load a core runtime. Native runtime: ${
|
|
3473
|
+
`RivetKit could not load a core runtime. Native runtime: ${_chunkM3H37DUQcjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunkM3H37DUQcjs.stringifyError.call(void 0, wasmError)}`,
|
|
3465
3474
|
{
|
|
3466
3475
|
public: true,
|
|
3467
3476
|
statusCode: 500
|
|
@@ -3669,7 +3678,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
3669
3678
|
}).catch((error) => {
|
|
3670
3679
|
logger2().warn({
|
|
3671
3680
|
msg: "deferred native sleep cleanup failed",
|
|
3672
|
-
error:
|
|
3681
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
3673
3682
|
});
|
|
3674
3683
|
});
|
|
3675
3684
|
return;
|
|
@@ -3841,10 +3850,10 @@ function decodeValue(value) {
|
|
|
3841
3850
|
if (!value || value.length === 0) {
|
|
3842
3851
|
return void 0;
|
|
3843
3852
|
}
|
|
3844
|
-
return
|
|
3853
|
+
return _chunkM3H37DUQcjs.decodeCborCompat.call(void 0, value);
|
|
3845
3854
|
}
|
|
3846
3855
|
function encodeValue(value) {
|
|
3847
|
-
return
|
|
3856
|
+
return _chunkM3H37DUQcjs.encodeCborCompat.call(void 0, value);
|
|
3848
3857
|
}
|
|
3849
3858
|
function normalizeArgs(value) {
|
|
3850
3859
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3880,7 +3889,7 @@ function isStructuredBridgeError(error) {
|
|
|
3880
3889
|
return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3881
3890
|
}
|
|
3882
3891
|
function encodeNativeCallbackError(error) {
|
|
3883
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
3892
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkM3H37DUQcjs.deconstructError.call(void 0, error, true);
|
|
3884
3893
|
const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
|
|
3885
3894
|
if (droppedMetadataCause !== void 0) {
|
|
3886
3895
|
logger2().warn(
|
|
@@ -3942,7 +3951,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3942
3951
|
return null;
|
|
3943
3952
|
}
|
|
3944
3953
|
try {
|
|
3945
|
-
return
|
|
3954
|
+
return _chunkM3H37DUQcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3946
3955
|
} catch (e3) {
|
|
3947
3956
|
return null;
|
|
3948
3957
|
}
|
|
@@ -4055,7 +4064,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
4055
4064
|
if (data === null) {
|
|
4056
4065
|
return null;
|
|
4057
4066
|
}
|
|
4058
|
-
const history =
|
|
4067
|
+
const history = _chunk3C5KLO4Vcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
4059
4068
|
return jsonSafe({
|
|
4060
4069
|
nameRegistry: [...history.nameRegistry],
|
|
4061
4070
|
entries: history.entries.map((entry) => ({
|
|
@@ -4201,7 +4210,7 @@ var NativeConnAdapter = class {
|
|
|
4201
4210
|
},
|
|
4202
4211
|
(newValue) => {
|
|
4203
4212
|
assertCurrentState();
|
|
4204
|
-
|
|
4213
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4205
4214
|
}
|
|
4206
4215
|
);
|
|
4207
4216
|
}
|
|
@@ -4209,7 +4218,7 @@ var NativeConnAdapter = class {
|
|
|
4209
4218
|
var _a;
|
|
4210
4219
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
4211
4220
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4212
|
-
|
|
4221
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4213
4222
|
this.#writeState(nextValue, { writeNative: true });
|
|
4214
4223
|
}
|
|
4215
4224
|
initializeState(value) {
|
|
@@ -5288,7 +5297,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5288
5297
|
},
|
|
5289
5298
|
(newValue) => {
|
|
5290
5299
|
assertCurrentState();
|
|
5291
|
-
|
|
5300
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
5292
5301
|
}
|
|
5293
5302
|
);
|
|
5294
5303
|
}
|
|
@@ -5300,7 +5309,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5300
5309
|
}
|
|
5301
5310
|
this.#assertCanMutateState();
|
|
5302
5311
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
5303
|
-
|
|
5312
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
5304
5313
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
5305
5314
|
}
|
|
5306
5315
|
initializeState(value) {
|
|
@@ -5514,7 +5523,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5514
5523
|
log: {
|
|
5515
5524
|
debug: (obj) => logger2().debug(obj)
|
|
5516
5525
|
},
|
|
5517
|
-
nativeDatabaseProvider:
|
|
5526
|
+
nativeDatabaseProvider: _chunkKF7ETIFKcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5518
5527
|
{
|
|
5519
5528
|
open: async (requestedActorId) => {
|
|
5520
5529
|
void requestedActorId;
|
|
@@ -5537,7 +5546,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5537
5546
|
return this.#db;
|
|
5538
5547
|
}
|
|
5539
5548
|
#bindDatabaseClient(client) {
|
|
5540
|
-
return
|
|
5549
|
+
return _chunkKF7ETIFKcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5541
5550
|
enter: async () => await this.#enterStateTransaction(),
|
|
5542
5551
|
exit: (scope) => this.#exitStateTransaction(
|
|
5543
5552
|
scope
|
|
@@ -5741,7 +5750,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5741
5750
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5742
5751
|
logger2().warn({
|
|
5743
5752
|
msg: "keepAwake promise rejected",
|
|
5744
|
-
error:
|
|
5753
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
5745
5754
|
});
|
|
5746
5755
|
}).then(() => null);
|
|
5747
5756
|
try {
|
|
@@ -6239,7 +6248,7 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
6239
6248
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
6240
6249
|
var _a;
|
|
6241
6250
|
const config = definition.config;
|
|
6242
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
6251
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkKF7ETIFKcjs.db.call(void 0, )));
|
|
6243
6252
|
const actionHandlers = _chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
|
|
6244
6253
|
const schemaConfig = {
|
|
6245
6254
|
actionInputSchemas: _chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0,
|
|
@@ -6250,9 +6259,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6250
6259
|
events: config.events,
|
|
6251
6260
|
queues: config.queues
|
|
6252
6261
|
};
|
|
6253
|
-
const createClient = (ctx) =>
|
|
6254
|
-
new (0,
|
|
6255
|
-
|
|
6262
|
+
const createClient = (ctx) => _chunk3KVVYC5Icjs.createClientWithDriver.call(void 0,
|
|
6263
|
+
new (0, _chunk3KVVYC5Icjs.RemoteEngineControlClient)(
|
|
6264
|
+
_chunk3KVVYC5Icjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
6256
6265
|
),
|
|
6257
6266
|
{
|
|
6258
6267
|
encoding: "bare",
|
|
@@ -6444,7 +6453,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6444
6453
|
400
|
|
6445
6454
|
);
|
|
6446
6455
|
}
|
|
6447
|
-
const cbor =
|
|
6456
|
+
const cbor = _chunkM3H37DUQcjs.encodeCborCompat.call(void 0,
|
|
6448
6457
|
_nullishCoalesce(body.body, () => ( null))
|
|
6449
6458
|
);
|
|
6450
6459
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -7041,7 +7050,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7041
7050
|
...request,
|
|
7042
7051
|
abortController: requestAbortController
|
|
7043
7052
|
});
|
|
7044
|
-
const rawConnParams = handlerRequest.headers.get(
|
|
7053
|
+
const rawConnParams = handlerRequest.headers.get(_chunk3KVVYC5Icjs.HEADER_CONN_PARAMS);
|
|
7045
7054
|
let requestCtx;
|
|
7046
7055
|
let conn;
|
|
7047
7056
|
let removeRequestAbortListener;
|
|
@@ -7098,7 +7107,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7098
7107
|
requestCtx,
|
|
7099
7108
|
handlerRequest
|
|
7100
7109
|
);
|
|
7101
|
-
if (!
|
|
7110
|
+
if (!_chunk3KVVYC5Icjs.isResponseLike.call(void 0, response)) {
|
|
7102
7111
|
throw new Error(
|
|
7103
7112
|
"onRequest handler must return a Response"
|
|
7104
7113
|
);
|
|
@@ -7193,7 +7202,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7193
7202
|
var _a2;
|
|
7194
7203
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
7195
7204
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
7196
|
-
return history == null ? void 0 :
|
|
7205
|
+
return history == null ? void 0 : _chunkM3H37DUQcjs.toUint8Array.call(void 0, history);
|
|
7197
7206
|
}
|
|
7198
7207
|
) : void 0,
|
|
7199
7208
|
replayWorkflow: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
@@ -7207,7 +7216,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7207
7216
|
return void 0;
|
|
7208
7217
|
}
|
|
7209
7218
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
7210
|
-
return history == null ? void 0 :
|
|
7219
|
+
return history == null ? void 0 : _chunkM3H37DUQcjs.toUint8Array.call(void 0, history);
|
|
7211
7220
|
}
|
|
7212
7221
|
) : void 0,
|
|
7213
7222
|
actions: Object.fromEntries(
|
|
@@ -7349,7 +7358,7 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7349
7358
|
startServices: resolveNativeBinaries && config.startServices,
|
|
7350
7359
|
handleInspectorHttpInRuntime: true,
|
|
7351
7360
|
serverlessBasePath: config.serverless.basePath,
|
|
7352
|
-
serverlessPackageVersion:
|
|
7361
|
+
serverlessPackageVersion: _chunkM3H37DUQcjs.VERSION,
|
|
7353
7362
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
7354
7363
|
serverlessClientNamespace: config.publicNamespace,
|
|
7355
7364
|
serverlessClientToken: config.publicToken,
|
|
@@ -7363,12 +7372,12 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7363
7372
|
} catch (error) {
|
|
7364
7373
|
logger2().warn({
|
|
7365
7374
|
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable \u2014 set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
|
|
7366
|
-
error:
|
|
7375
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
7367
7376
|
});
|
|
7368
7377
|
}
|
|
7369
7378
|
}
|
|
7370
7379
|
if (resolveNativeBinaries && config.startServices) {
|
|
7371
|
-
const servicesBinary =
|
|
7380
|
+
const servicesBinary = _chunkM3H37DUQcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
|
|
7372
7381
|
if (servicesBinary) {
|
|
7373
7382
|
serveConfig.servicesBinaryPath = servicesBinary;
|
|
7374
7383
|
} else {
|
|
@@ -7383,13 +7392,13 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
|
7383
7392
|
serveConfig.engineHost = config.engineHost;
|
|
7384
7393
|
serveConfig.enginePort = config.enginePort;
|
|
7385
7394
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
7386
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7395
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkM3H37DUQcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
7387
7396
|
}
|
|
7388
7397
|
return serveConfig;
|
|
7389
7398
|
}
|
|
7390
7399
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
7391
7400
|
var _a;
|
|
7392
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
7401
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkM3H37DUQcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
7393
7402
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
7394
7403
|
}
|
|
7395
7404
|
if (runtime.kind === "napi") {
|
|
@@ -7421,6 +7430,7 @@ async function buildConfiguredRegistry(config) {
|
|
|
7421
7430
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7422
7431
|
var LOCAL_ENGINE_READY_TIMEOUT_MS = 6e4;
|
|
7423
7432
|
var LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4e3;
|
|
7433
|
+
var DEFAULT_ACTOR_STOP_THRESHOLD_MS = 3e4;
|
|
7424
7434
|
function rejectServerless() {
|
|
7425
7435
|
throw new Error("serverless is disabled in this version");
|
|
7426
7436
|
}
|
|
@@ -7461,7 +7471,7 @@ function createApplicationFetch(application, runtime) {
|
|
|
7461
7471
|
signal: abortController.signal
|
|
7462
7472
|
})
|
|
7463
7473
|
);
|
|
7464
|
-
if (!
|
|
7474
|
+
if (!_chunk3KVVYC5Icjs.isResponseLike.call(void 0, response)) {
|
|
7465
7475
|
throw new TypeError(
|
|
7466
7476
|
"registry.listen() application fetch must return a Response"
|
|
7467
7477
|
);
|
|
@@ -7507,11 +7517,16 @@ var Registry = class {
|
|
|
7507
7517
|
#shutdownInstalled = false;
|
|
7508
7518
|
#shutdownInFlight = null;
|
|
7509
7519
|
#signalHandlers = {};
|
|
7520
|
+
#envoyConfiguredRegistry;
|
|
7521
|
+
#activeActorCountListeners = /* @__PURE__ */ new Set();
|
|
7522
|
+
#activeActorCountToken;
|
|
7523
|
+
#lastActiveActorCount;
|
|
7524
|
+
#activeActorCountSupported;
|
|
7510
7525
|
constructor(config, deps) {
|
|
7511
7526
|
var _a;
|
|
7512
7527
|
this.#config = config;
|
|
7513
7528
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
7514
|
-
|
|
7529
|
+
_chunkM3H37DUQcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7515
7530
|
}
|
|
7516
7531
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7517
7532
|
this.routes = {
|
|
@@ -7743,10 +7758,10 @@ var Registry = class {
|
|
|
7743
7758
|
if (!opts.application) {
|
|
7744
7759
|
rejectServerless();
|
|
7745
7760
|
}
|
|
7746
|
-
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => (
|
|
7747
|
-
const publicDir = _nullishCoalesce(opts.publicDir, () => (
|
|
7761
|
+
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkM3H37DUQcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
|
|
7762
|
+
const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkM3H37DUQcjs.getRivetkitPublicDir.call(void 0, )));
|
|
7748
7763
|
const config = this.parseConfig();
|
|
7749
|
-
if (opts.application &&
|
|
7764
|
+
if (opts.application && _chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7750
7765
|
if (config.runtime === "wasm") {
|
|
7751
7766
|
throw new Error(
|
|
7752
7767
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7822,7 +7837,7 @@ var Registry = class {
|
|
|
7822
7837
|
return jsonRouteResponse(503, {
|
|
7823
7838
|
status: "not_started",
|
|
7824
7839
|
runtime: "rivetkit",
|
|
7825
|
-
version:
|
|
7840
|
+
version: _chunkM3H37DUQcjs.VERSION
|
|
7826
7841
|
});
|
|
7827
7842
|
}
|
|
7828
7843
|
const { runtime, registry } = configured;
|
|
@@ -7830,7 +7845,7 @@ var Registry = class {
|
|
|
7830
7845
|
return jsonRouteResponse(501, {
|
|
7831
7846
|
status: "unsupported",
|
|
7832
7847
|
runtime: "rivetkit",
|
|
7833
|
-
version:
|
|
7848
|
+
version: _chunkM3H37DUQcjs.VERSION
|
|
7834
7849
|
});
|
|
7835
7850
|
}
|
|
7836
7851
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7905,14 +7920,14 @@ var Registry = class {
|
|
|
7905
7920
|
var _a;
|
|
7906
7921
|
if (!this.#runtimeServePromise) {
|
|
7907
7922
|
const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
|
|
7908
|
-
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" :
|
|
7923
|
+
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkM3H37DUQcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
|
|
7909
7924
|
logger2().info({
|
|
7910
7925
|
msg: "starting rivetkit envoy",
|
|
7911
|
-
rivetkitVersion:
|
|
7926
|
+
rivetkitVersion: _chunkM3H37DUQcjs.VERSION,
|
|
7912
7927
|
envoyVersion: config.node.version,
|
|
7913
7928
|
envoyVersionSource
|
|
7914
7929
|
});
|
|
7915
|
-
if (envoyVersionSource === "default" &&
|
|
7930
|
+
if (envoyVersionSource === "default" && _chunkM3H37DUQcjs.getNodeEnv.call(void 0, ) === "production") {
|
|
7916
7931
|
logger2().error({
|
|
7917
7932
|
msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
|
|
7918
7933
|
envoyVersion: config.node.version,
|
|
@@ -7921,6 +7936,21 @@ var Registry = class {
|
|
|
7921
7936
|
}
|
|
7922
7937
|
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
7923
7938
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
7939
|
+
configuredRegistryPromise.then(
|
|
7940
|
+
(configured) => {
|
|
7941
|
+
this.#envoyConfiguredRegistry = configured;
|
|
7942
|
+
try {
|
|
7943
|
+
this.#syncActiveActorCountSubscription();
|
|
7944
|
+
} catch (error) {
|
|
7945
|
+
logger2().error(
|
|
7946
|
+
{ error },
|
|
7947
|
+
"failed to subscribe to the active actor count"
|
|
7948
|
+
);
|
|
7949
|
+
}
|
|
7950
|
+
},
|
|
7951
|
+
// The serve lifecycle below reports build failures.
|
|
7952
|
+
() => void 0
|
|
7953
|
+
);
|
|
7924
7954
|
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
7925
7955
|
async ({ runtime, registry, serveConfig }) => {
|
|
7926
7956
|
await runtime.serveRegistry(registry, serveConfig);
|
|
@@ -8001,12 +8031,12 @@ var Registry = class {
|
|
|
8001
8031
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
8002
8032
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
8003
8033
|
const runtimes = /* @__PURE__ */ new Set();
|
|
8004
|
-
const localDevSignal = signalDriven &&
|
|
8034
|
+
const localDevSignal = signalDriven && _chunkM3H37DUQcjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunk3KVVYC5Icjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
|
|
8005
8035
|
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
8006
8036
|
if (gracePeriodMs === void 0) {
|
|
8007
8037
|
gracePeriodMs = localDevSignal ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
|
|
8008
8038
|
_nullishCoalesce(modeAPromise, () => ( modeBPromise))
|
|
8009
|
-
), async () => (
|
|
8039
|
+
), async () => ( DEFAULT_ACTOR_STOP_THRESHOLD_MS));
|
|
8010
8040
|
}
|
|
8011
8041
|
const drain = async () => {
|
|
8012
8042
|
const registries = [];
|
|
@@ -8113,7 +8143,7 @@ var Registry = class {
|
|
|
8113
8143
|
}
|
|
8114
8144
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8115
8145
|
try {
|
|
8116
|
-
if (
|
|
8146
|
+
if (_chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8117
8147
|
return Promise.reject(
|
|
8118
8148
|
new Error(
|
|
8119
8149
|
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
@@ -8137,7 +8167,7 @@ var Registry = class {
|
|
|
8137
8167
|
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
8138
8168
|
throw new Error("registry envoy startup did not initialize");
|
|
8139
8169
|
}
|
|
8140
|
-
const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 &&
|
|
8170
|
+
const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 && _chunk3KVVYC5Icjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? LOCAL_ENGINE_READY_TIMEOUT_MS : REGISTRY_READY_TIMEOUT_MS;
|
|
8141
8171
|
let timeout;
|
|
8142
8172
|
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
8143
8173
|
var _a;
|
|
@@ -8187,8 +8217,8 @@ var Registry = class {
|
|
|
8187
8217
|
* ```
|
|
8188
8218
|
*/
|
|
8189
8219
|
start() {
|
|
8190
|
-
if (
|
|
8191
|
-
const publicDir = _nullishCoalesce(
|
|
8220
|
+
if (_chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8221
|
+
const publicDir = _nullishCoalesce(_chunkM3H37DUQcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
8192
8222
|
this.listen({ publicDir }).catch((error) => {
|
|
8193
8223
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
8194
8224
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -8200,6 +8230,101 @@ var Registry = class {
|
|
|
8200
8230
|
const config = this.parseConfig();
|
|
8201
8231
|
this.#startEnvoy(config, true);
|
|
8202
8232
|
}
|
|
8233
|
+
/**
|
|
8234
|
+
* Returns the number of actors hosted by this process's envoy, which is zero
|
|
8235
|
+
* while it is not serving. Requires the native runtime.
|
|
8236
|
+
*/
|
|
8237
|
+
activeActorCount() {
|
|
8238
|
+
this.#assertActiveActorCountSupported("activeActorCount");
|
|
8239
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
8240
|
+
if (!configured) return 0;
|
|
8241
|
+
const { runtime, registry } = configured;
|
|
8242
|
+
if (!runtime.registryActiveActorCount) {
|
|
8243
|
+
throw new Error(
|
|
8244
|
+
"registry.activeActorCount() is not supported by this runtime"
|
|
8245
|
+
);
|
|
8246
|
+
}
|
|
8247
|
+
return runtime.registryActiveActorCount(registry);
|
|
8248
|
+
}
|
|
8249
|
+
/**
|
|
8250
|
+
* Calls `callback` with the number of actors hosted by this process's envoy
|
|
8251
|
+
* and again whenever it changes. Rapid changes may coalesce.
|
|
8252
|
+
* Returns a function that unsubscribes. Requires the native runtime.
|
|
8253
|
+
*
|
|
8254
|
+
* @example
|
|
8255
|
+
* ```ts
|
|
8256
|
+
* const unsubscribe = registry.onActiveActorCountChange((count) => {
|
|
8257
|
+
* setTaskProtection(count > 0);
|
|
8258
|
+
* });
|
|
8259
|
+
* ```
|
|
8260
|
+
*/
|
|
8261
|
+
onActiveActorCountChange(callback) {
|
|
8262
|
+
this.#assertActiveActorCountSupported("onActiveActorCountChange");
|
|
8263
|
+
const listener = (count) => callback(count);
|
|
8264
|
+
this.#activeActorCountListeners.add(listener);
|
|
8265
|
+
this.#syncActiveActorCountSubscription();
|
|
8266
|
+
const lastCount = this.#lastActiveActorCount;
|
|
8267
|
+
if (lastCount !== void 0) {
|
|
8268
|
+
queueMicrotask(() => {
|
|
8269
|
+
if (this.#activeActorCountListeners.has(listener)) {
|
|
8270
|
+
this.#deliverActiveActorCount(listener, lastCount);
|
|
8271
|
+
}
|
|
8272
|
+
});
|
|
8273
|
+
}
|
|
8274
|
+
return () => {
|
|
8275
|
+
this.#activeActorCountListeners.delete(listener);
|
|
8276
|
+
this.#syncActiveActorCountSubscription();
|
|
8277
|
+
};
|
|
8278
|
+
}
|
|
8279
|
+
#assertActiveActorCountSupported(method2) {
|
|
8280
|
+
this.#activeActorCountSupported ??= this.parseConfig().runtime !== "wasm";
|
|
8281
|
+
if (!this.#activeActorCountSupported) {
|
|
8282
|
+
throw new Error(
|
|
8283
|
+
`registry.${method2}() requires the native runtime; WebAssembly registries do not host an envoy`
|
|
8284
|
+
);
|
|
8285
|
+
}
|
|
8286
|
+
}
|
|
8287
|
+
/** Holds one native subscription while any listener is registered. */
|
|
8288
|
+
#syncActiveActorCountSubscription() {
|
|
8289
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
8290
|
+
if (!configured) return;
|
|
8291
|
+
const { runtime, registry } = configured;
|
|
8292
|
+
const token = this.#activeActorCountToken;
|
|
8293
|
+
if (this.#activeActorCountListeners.size === 0) {
|
|
8294
|
+
if (token !== void 0) {
|
|
8295
|
+
this.#activeActorCountToken = void 0;
|
|
8296
|
+
this.#lastActiveActorCount = void 0;
|
|
8297
|
+
runtime.cancelCancellationToken(token);
|
|
8298
|
+
}
|
|
8299
|
+
return;
|
|
8300
|
+
}
|
|
8301
|
+
if (token !== void 0) return;
|
|
8302
|
+
if (!runtime.onRegistryActiveActorCountChange) {
|
|
8303
|
+
throw new Error(
|
|
8304
|
+
"active actor count subscriptions are not supported by this runtime"
|
|
8305
|
+
);
|
|
8306
|
+
}
|
|
8307
|
+
const nextToken = runtime.createCancellationToken();
|
|
8308
|
+
this.#activeActorCountToken = nextToken;
|
|
8309
|
+
runtime.onRegistryActiveActorCountChange(
|
|
8310
|
+
registry,
|
|
8311
|
+
(count) => {
|
|
8312
|
+
if (this.#activeActorCountToken !== nextToken) return;
|
|
8313
|
+
this.#lastActiveActorCount = count;
|
|
8314
|
+
for (const listener of [...this.#activeActorCountListeners]) {
|
|
8315
|
+
this.#deliverActiveActorCount(listener, count);
|
|
8316
|
+
}
|
|
8317
|
+
},
|
|
8318
|
+
nextToken
|
|
8319
|
+
);
|
|
8320
|
+
}
|
|
8321
|
+
#deliverActiveActorCount(listener, count) {
|
|
8322
|
+
try {
|
|
8323
|
+
listener(count);
|
|
8324
|
+
} catch (error) {
|
|
8325
|
+
logger2().error({ error }, "active actor count listener threw");
|
|
8326
|
+
}
|
|
8327
|
+
}
|
|
8203
8328
|
#printWelcome(config, kind, listener) {
|
|
8204
8329
|
if (config.noWelcome || this.#welcomePrinted) return;
|
|
8205
8330
|
this.#welcomePrinted = true;
|
|
@@ -8209,13 +8334,13 @@ var Registry = class {
|
|
|
8209
8334
|
};
|
|
8210
8335
|
console.log();
|
|
8211
8336
|
console.log(
|
|
8212
|
-
` RivetKit ${
|
|
8337
|
+
` RivetKit ${_chunkM3H37DUQcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
8213
8338
|
);
|
|
8214
8339
|
if (config.namespace !== "default") {
|
|
8215
8340
|
logLine("Namespace", config.namespace);
|
|
8216
8341
|
}
|
|
8217
8342
|
if (config.endpoint) {
|
|
8218
|
-
const endpointType = config.startEngine ||
|
|
8343
|
+
const endpointType = config.startEngine || _chunk3KVVYC5Icjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
|
|
8219
8344
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
8220
8345
|
}
|
|
8221
8346
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -8285,5 +8410,5 @@ function setup(input) {
|
|
|
8285
8410
|
|
|
8286
8411
|
|
|
8287
8412
|
|
|
8288
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
8413
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunk3KVVYC5Icjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkMGI2VVF6cjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkMGI2VVF6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkMGI2VVF6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunk3KVVYC5Icjs.createClientWithDriver; exports.defineRunHandler = _chunkSSF2XC33cjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkM3H37DUQcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkM3H37DUQcjs.toUint8Array;
|
|
8289
8414
|
//# sourceMappingURL=mod.cjs.map
|