rivetkit 3.0.1-preview.2 → 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 +78 -7
- package/dist/browser/client.js +67 -7
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +4 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-4QJQH4T4.cjs → chunk-3C5KLO4V.cjs} +4 -4
- package/dist/tsup/{chunk-4QJQH4T4.cjs.map → chunk-3C5KLO4V.cjs.map} +1 -1
- package/dist/tsup/{chunk-BSGU45BD.cjs → chunk-3KVVYC5I.cjs} +202 -145
- package/dist/tsup/chunk-3KVVYC5I.cjs.map +1 -0
- package/dist/tsup/{chunk-JRLVFBMY.js → chunk-3RE23GTB.js} +9 -3
- package/dist/tsup/chunk-3RE23GTB.js.map +1 -0
- package/dist/tsup/{chunk-SD3PQA7R.js → chunk-47W6FHPJ.js} +2 -2
- package/dist/tsup/{chunk-JKTXQQEE.js → chunk-4ASLJWUQ.js} +4 -4
- package/dist/tsup/{chunk-G5VHMGDB.js → chunk-ANP7UCAM.js} +66 -9
- package/dist/tsup/chunk-ANP7UCAM.js.map +1 -0
- package/dist/tsup/{chunk-LNYYP2PY.cjs → chunk-BBEH6RML.cjs} +3 -3
- package/dist/tsup/{chunk-LNYYP2PY.cjs.map → chunk-BBEH6RML.cjs.map} +1 -1
- package/dist/tsup/{chunk-AGQUQEZM.cjs → chunk-DVXMOEFT.cjs} +7 -7
- package/dist/tsup/{chunk-AGQUQEZM.cjs.map → chunk-DVXMOEFT.cjs.map} +1 -1
- package/dist/tsup/{chunk-N7UDXIJN.cjs → chunk-FR5QOAYE.cjs} +10 -10
- package/dist/tsup/{chunk-N7UDXIJN.cjs.map → chunk-FR5QOAYE.cjs.map} +1 -1
- package/dist/tsup/{chunk-OOHHMLQX.js → chunk-HJWK46Z5.js} +3 -3
- package/dist/tsup/{chunk-CEUOGGOM.js → chunk-J7T52LN6.js} +2 -2
- package/dist/tsup/{chunk-4E76XTEX.cjs → chunk-KF7ETIFK.cjs} +3 -3
- package/dist/tsup/{chunk-4E76XTEX.cjs.map → chunk-KF7ETIFK.cjs.map} +1 -1
- package/dist/tsup/{chunk-FUSYDRMB.cjs → chunk-M3H37DUQ.cjs} +9 -3
- package/dist/tsup/chunk-M3H37DUQ.cjs.map +1 -0
- package/dist/tsup/{chunk-BT4SSKF6.cjs → chunk-M7KPJSGO.cjs} +3 -3
- package/dist/tsup/{chunk-BT4SSKF6.cjs.map → chunk-M7KPJSGO.cjs.map} +1 -1
- package/dist/tsup/{chunk-GPKL6OTF.js → chunk-OF63EVJQ.js} +2 -2
- package/dist/tsup/{chunk-HDVZ6YZG.cjs → chunk-SSF2XC33.cjs} +1 -1
- package/dist/tsup/chunk-SSF2XC33.cjs.map +1 -0
- package/dist/tsup/{chunk-6FEYCVZC.js → chunk-UXDASKP6.js} +1 -1
- package/dist/tsup/chunk-UXDASKP6.js.map +1 -0
- package/dist/tsup/{chunk-O3HSYSUU.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-DJ3KW-fe.d.ts → config-BtUHYdoj.d.ts} +23 -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-8NgsxIcT.d.cts → config-H6pJy_J1.d.cts} +23 -1
- package/dist/tsup/{context-BL8kUGjq.d.ts → context-DrDoMXSD.d.ts} +2 -2
- package/dist/tsup/{context-_RoE_YHL.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.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- 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.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +258 -125
- 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 +159 -26
- 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 +10 -10
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +12 -9
- package/src/actor/config.ts +2 -0
- package/src/client/actor-handle.ts +43 -7
- package/src/client/raw-utils.ts +17 -3
- package/src/client/utils.ts +4 -0
- package/src/common/database/config.ts +50 -7
- package/src/db/mod.ts +1 -0
- package/src/registry/config/index.ts +7 -5
- package/src/registry/index.ts +142 -1
- package/src/registry/napi-runtime.ts +15 -0
- package/src/registry/native.ts +24 -17
- package/src/registry/runtime.ts +7 -1
- package/src/utils/env-vars.ts +4 -2
- package/dist/tsup/chunk-6FEYCVZC.js.map +0 -1
- package/dist/tsup/chunk-BSGU45BD.cjs.map +0 -1
- package/dist/tsup/chunk-FUSYDRMB.cjs.map +0 -1
- package/dist/tsup/chunk-G5VHMGDB.js.map +0 -1
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +0 -1
- package/dist/tsup/chunk-JRLVFBMY.js.map +0 -1
- /package/dist/tsup/{chunk-SD3PQA7R.js.map → chunk-47W6FHPJ.js.map} +0 -0
- /package/dist/tsup/{chunk-JKTXQQEE.js.map → chunk-4ASLJWUQ.js.map} +0 -0
- /package/dist/tsup/{chunk-OOHHMLQX.js.map → chunk-HJWK46Z5.js.map} +0 -0
- /package/dist/tsup/{chunk-CEUOGGOM.js.map → chunk-J7T52LN6.js.map} +0 -0
- /package/dist/tsup/{chunk-GPKL6OTF.js.map → chunk-OF63EVJQ.js.map} +0 -0
- /package/dist/tsup/{chunk-O3HSYSUU.js.map → chunk-ZAZAKYNQ.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,5 +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 _chunk3C5KLO4Vcjs = require('./chunk-3C5KLO4V.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,10 +15,9 @@
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
var _chunkHDVZ6YZGcjs = require('./chunk-HDVZ6YZG.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -35,17 +35,17 @@ var _chunk4QJQH4T4cjs = require('./chunk-4QJQH4T4.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-
|
|
43
|
+
require('./chunk-M7KPJSGO.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _chunkKF7ETIFKcjs = require('./chunk-KF7ETIFK.cjs');
|
|
49
49
|
require('./chunk-KVFIONKQ.cjs');
|
|
50
50
|
|
|
51
51
|
|
|
@@ -80,7 +80,7 @@ require('./chunk-KVFIONKQ.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
|
|
@@ -138,10 +138,10 @@ function actor(input) {
|
|
|
138
138
|
warnDeprecatedOptionKeys(
|
|
139
139
|
input == null ? void 0 : input.options
|
|
140
140
|
);
|
|
141
|
-
const config =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
const config = _chunkSSF2XC33cjs.ActorConfigSchema.parse(input);
|
|
142
|
+
_chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
|
|
143
|
+
_chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
|
|
144
|
+
_chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
|
|
145
145
|
return new ActorDefinition(config);
|
|
146
146
|
}
|
|
147
147
|
function isStaticActorDefinition(definition) {
|
|
@@ -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,25 +697,25 @@ 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
|
-
* a local engine.
|
|
718
|
-
* or startServices:
|
|
717
|
+
* a local engine. Enabled by default for a managed local Engine. Set
|
|
718
|
+
* RIVET_RUN_SERVICES=0 or startServices: false to disable it.
|
|
719
719
|
*/
|
|
720
720
|
startServices: _zod.z.boolean().optional(),
|
|
721
721
|
/**
|
|
@@ -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,18 +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
|
-
const
|
|
805
|
+
const engineSpawn = !parsedEndpoint && Boolean(endpoint);
|
|
806
|
+
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkM3H37DUQcjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
|
|
806
807
|
const validateServerlessEndpoint = Boolean(
|
|
807
808
|
config.startEngine || parsedEndpoint
|
|
808
809
|
);
|
|
809
810
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
810
|
-
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint &&
|
|
811
|
-
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, {
|
|
812
813
|
endpoint: config.serverless.publicEndpoint,
|
|
813
814
|
path: ["serverless", "publicEndpoint"]
|
|
814
815
|
}) : void 0;
|
|
@@ -826,7 +827,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
826
827
|
...config,
|
|
827
828
|
sqlite,
|
|
828
829
|
endpoint,
|
|
829
|
-
engineSpawn
|
|
830
|
+
engineSpawn,
|
|
830
831
|
startServices,
|
|
831
832
|
namespace,
|
|
832
833
|
token,
|
|
@@ -845,7 +846,7 @@ function buildActorNames(config) {
|
|
|
845
846
|
Object.keys(config.use).map((actorName) => {
|
|
846
847
|
const definition = config.use[actorName];
|
|
847
848
|
const options = _nullishCoalesce(definition.config.options, () => ( {}));
|
|
848
|
-
const runMeta =
|
|
849
|
+
const runMeta = _chunkSSF2XC33cjs.getRunMetadata.call(void 0, definition.config.run);
|
|
849
850
|
const metadata = {};
|
|
850
851
|
metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
|
|
851
852
|
metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
|
|
@@ -913,7 +914,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
913
914
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
914
915
|
sqlite: DocSqliteConfigSchema,
|
|
915
916
|
logging: _zod.z.object({
|
|
916
|
-
level:
|
|
917
|
+
level: _chunkM3H37DUQcjs.LogLevelSchema.optional().describe(
|
|
917
918
|
"Log level for RivetKit. Default: 'warn'"
|
|
918
919
|
)
|
|
919
920
|
}).optional().describe("Logging configuration."),
|
|
@@ -942,7 +943,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
942
943
|
"Version of the local engine package to use. Defaults to the current RivetKit version."
|
|
943
944
|
),
|
|
944
945
|
startServices: _zod.z.boolean().optional().describe(
|
|
945
|
-
"Starts Services when RivetKit manages a local Engine.
|
|
946
|
+
"Starts Services when RivetKit manages a local Engine. Enabled by default for a managed local Engine. Set RIVET_RUN_SERVICES=0 or startServices: false to disable."
|
|
946
947
|
),
|
|
947
948
|
configurePool: DocConfigurePoolSchema.describe(
|
|
948
949
|
"Automatically configure serverless nodes in the engine."
|
|
@@ -1404,7 +1405,7 @@ function normalizeRuntimeSqlExecuteResult(result) {
|
|
|
1404
1405
|
}
|
|
1405
1406
|
function servicesBinaryUnavailable(cause) {
|
|
1406
1407
|
return new Error(
|
|
1407
|
-
"services.binary_unavailable: Install @rivet-dev/services
|
|
1408
|
+
"services.binary_unavailable: Install @rivet-dev/services to run local Services, set RIVET_SERVICES_BINARY to its executable path, or set RIVET_RUN_SERVICES=0 to disable Services.",
|
|
1408
1409
|
{ cause }
|
|
1409
1410
|
);
|
|
1410
1411
|
}
|
|
@@ -1553,7 +1554,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1553
1554
|
if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
|
|
1554
1555
|
return ownerCtx;
|
|
1555
1556
|
}
|
|
1556
|
-
const applicationSpan =
|
|
1557
|
+
const applicationSpan = _chunk3KVVYC5Icjs.readActiveTraceHeaders.call(void 0, );
|
|
1557
1558
|
if (!applicationSpan) {
|
|
1558
1559
|
return active;
|
|
1559
1560
|
}
|
|
@@ -1598,6 +1599,15 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1598
1599
|
async registryActorStopThresholdMs(registry) {
|
|
1599
1600
|
return await _asyncNullishCoalesce(await asNativeRegistry(registry).actorStopThresholdMs(), async () => ( void 0));
|
|
1600
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
|
+
}
|
|
1601
1611
|
async registryHealth(registry) {
|
|
1602
1612
|
const response = await asNativeRegistry(registry).health();
|
|
1603
1613
|
return {
|
|
@@ -1757,7 +1767,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1757
1767
|
const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
|
|
1758
1768
|
return this.#invocationContext.run(
|
|
1759
1769
|
nativeCtx,
|
|
1760
|
-
() =>
|
|
1770
|
+
() => _chunk3KVVYC5Icjs.runWithActorInvocationSpan.call(void 0, span, run)
|
|
1761
1771
|
);
|
|
1762
1772
|
}
|
|
1763
1773
|
actorInvocationTraceContext(ctx) {
|
|
@@ -2132,8 +2142,8 @@ function runtimeBytesToArrayBuffer(value) {
|
|
|
2132
2142
|
function buildNativeHttpRequest(init) {
|
|
2133
2143
|
var _a;
|
|
2134
2144
|
const headers = new Headers(init.headers);
|
|
2135
|
-
const originalUrl = headers.get(
|
|
2136
|
-
headers.delete(
|
|
2145
|
+
const originalUrl = headers.get(_chunk3KVVYC5Icjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2146
|
+
headers.delete(_chunk3KVVYC5Icjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2137
2147
|
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2138
2148
|
const method2 = init.method.toUpperCase();
|
|
2139
2149
|
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
@@ -2212,7 +2222,7 @@ async function pumpResponseBody(reader, stream) {
|
|
|
2212
2222
|
}
|
|
2213
2223
|
} catch (error) {
|
|
2214
2224
|
try {
|
|
2215
|
-
await stream.error(
|
|
2225
|
+
await stream.error(_chunkM3H37DUQcjs.stringifyError.call(void 0, error));
|
|
2216
2226
|
} catch (streamError) {
|
|
2217
2227
|
logger2().debug({
|
|
2218
2228
|
msg: "failed to report native http response stream error",
|
|
@@ -2380,7 +2390,7 @@ var RunHandlerCoordinator = class {
|
|
|
2380
2390
|
this.#run = run;
|
|
2381
2391
|
}
|
|
2382
2392
|
get inspectorKind() {
|
|
2383
|
-
return
|
|
2393
|
+
return _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, this.#run);
|
|
2384
2394
|
}
|
|
2385
2395
|
async run(actorId, restart, callback) {
|
|
2386
2396
|
const state = this.#getOrCreate(actorId);
|
|
@@ -2488,7 +2498,7 @@ var RunHandlerCoordinator = class {
|
|
|
2488
2498
|
}
|
|
2489
2499
|
#initializeInspector(actorId, state) {
|
|
2490
2500
|
if (state.inspectorInitialized) return;
|
|
2491
|
-
const inspector =
|
|
2501
|
+
const inspector = _chunkSSF2XC33cjs.createRunInspector.call(void 0, this.#run, {
|
|
2492
2502
|
actorId,
|
|
2493
2503
|
control: this.#control(actorId, state)
|
|
2494
2504
|
});
|
|
@@ -3451,7 +3461,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3451
3461
|
nativeError = error;
|
|
3452
3462
|
logger2().warn({
|
|
3453
3463
|
msg: "native runtime failed to load; falling back to wasm",
|
|
3454
|
-
error:
|
|
3464
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
3455
3465
|
});
|
|
3456
3466
|
}
|
|
3457
3467
|
try {
|
|
@@ -3460,7 +3470,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3460
3470
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3461
3471
|
"config",
|
|
3462
3472
|
"runtime_unavailable",
|
|
3463
|
-
`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)}`,
|
|
3464
3474
|
{
|
|
3465
3475
|
public: true,
|
|
3466
3476
|
statusCode: 500
|
|
@@ -3668,7 +3678,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
3668
3678
|
}).catch((error) => {
|
|
3669
3679
|
logger2().warn({
|
|
3670
3680
|
msg: "deferred native sleep cleanup failed",
|
|
3671
|
-
error:
|
|
3681
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
3672
3682
|
});
|
|
3673
3683
|
});
|
|
3674
3684
|
return;
|
|
@@ -3840,10 +3850,10 @@ function decodeValue(value) {
|
|
|
3840
3850
|
if (!value || value.length === 0) {
|
|
3841
3851
|
return void 0;
|
|
3842
3852
|
}
|
|
3843
|
-
return
|
|
3853
|
+
return _chunkM3H37DUQcjs.decodeCborCompat.call(void 0, value);
|
|
3844
3854
|
}
|
|
3845
3855
|
function encodeValue(value) {
|
|
3846
|
-
return
|
|
3856
|
+
return _chunkM3H37DUQcjs.encodeCborCompat.call(void 0, value);
|
|
3847
3857
|
}
|
|
3848
3858
|
function normalizeArgs(value) {
|
|
3849
3859
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3879,7 +3889,7 @@ function isStructuredBridgeError(error) {
|
|
|
3879
3889
|
return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3880
3890
|
}
|
|
3881
3891
|
function encodeNativeCallbackError(error) {
|
|
3882
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
3892
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkM3H37DUQcjs.deconstructError.call(void 0, error, true);
|
|
3883
3893
|
const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
|
|
3884
3894
|
if (droppedMetadataCause !== void 0) {
|
|
3885
3895
|
logger2().warn(
|
|
@@ -3941,7 +3951,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3941
3951
|
return null;
|
|
3942
3952
|
}
|
|
3943
3953
|
try {
|
|
3944
|
-
return
|
|
3954
|
+
return _chunkM3H37DUQcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3945
3955
|
} catch (e3) {
|
|
3946
3956
|
return null;
|
|
3947
3957
|
}
|
|
@@ -4054,7 +4064,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
4054
4064
|
if (data === null) {
|
|
4055
4065
|
return null;
|
|
4056
4066
|
}
|
|
4057
|
-
const history =
|
|
4067
|
+
const history = _chunk3C5KLO4Vcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
4058
4068
|
return jsonSafe({
|
|
4059
4069
|
nameRegistry: [...history.nameRegistry],
|
|
4060
4070
|
entries: history.entries.map((entry) => ({
|
|
@@ -4153,7 +4163,7 @@ var NativeConnAdapter = class {
|
|
|
4153
4163
|
this.#ctx = ctx;
|
|
4154
4164
|
this.#queueHibernationRemoval = queueHibernationRemoval;
|
|
4155
4165
|
this.#assertCanMutateState = assertCanMutateState;
|
|
4156
|
-
this[
|
|
4166
|
+
this[_chunkSSF2XC33cjs.CONN_STATE_MANAGER_SYMBOL] = {
|
|
4157
4167
|
stateEnabled: true,
|
|
4158
4168
|
get state() {
|
|
4159
4169
|
return thisConn.state;
|
|
@@ -4170,7 +4180,7 @@ var NativeConnAdapter = class {
|
|
|
4170
4180
|
decodeValue(this.#runtime.connParams(this.#conn))
|
|
4171
4181
|
);
|
|
4172
4182
|
}
|
|
4173
|
-
[
|
|
4183
|
+
[_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
|
|
4174
4184
|
return this.#readState();
|
|
4175
4185
|
}
|
|
4176
4186
|
get state() {
|
|
@@ -4200,7 +4210,7 @@ var NativeConnAdapter = class {
|
|
|
4200
4210
|
},
|
|
4201
4211
|
(newValue) => {
|
|
4202
4212
|
assertCurrentState();
|
|
4203
|
-
|
|
4213
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4204
4214
|
}
|
|
4205
4215
|
);
|
|
4206
4216
|
}
|
|
@@ -4208,7 +4218,7 @@ var NativeConnAdapter = class {
|
|
|
4208
4218
|
var _a;
|
|
4209
4219
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
4210
4220
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4211
|
-
|
|
4221
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4212
4222
|
this.#writeState(nextValue, { writeNative: true });
|
|
4213
4223
|
}
|
|
4214
4224
|
initializeState(value) {
|
|
@@ -5227,7 +5237,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5227
5237
|
this.#databaseProvider = databaseProvider;
|
|
5228
5238
|
}
|
|
5229
5239
|
this.#request = request;
|
|
5230
|
-
this[
|
|
5240
|
+
this[_chunkSSF2XC33cjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
|
|
5231
5241
|
this,
|
|
5232
5242
|
() => this.#logByInvocationScope.delete(
|
|
5233
5243
|
_nullishCoalesce(this.#runtime.currentInvocationScope(), () => ( NO_INVOCATION_SCOPE))
|
|
@@ -5260,7 +5270,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5260
5270
|
}
|
|
5261
5271
|
throw databaseClientNotReadyError();
|
|
5262
5272
|
}
|
|
5263
|
-
[
|
|
5273
|
+
[_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
|
|
5264
5274
|
if (!this.#stateEnabled) {
|
|
5265
5275
|
throw stateNotEnabledError();
|
|
5266
5276
|
}
|
|
@@ -5287,7 +5297,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5287
5297
|
},
|
|
5288
5298
|
(newValue) => {
|
|
5289
5299
|
assertCurrentState();
|
|
5290
|
-
|
|
5300
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
5291
5301
|
}
|
|
5292
5302
|
);
|
|
5293
5303
|
}
|
|
@@ -5299,7 +5309,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5299
5309
|
}
|
|
5300
5310
|
this.#assertCanMutateState();
|
|
5301
5311
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
5302
|
-
|
|
5312
|
+
_chunkM3H37DUQcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
5303
5313
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
5304
5314
|
}
|
|
5305
5315
|
initializeState(value) {
|
|
@@ -5513,7 +5523,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5513
5523
|
log: {
|
|
5514
5524
|
debug: (obj) => logger2().debug(obj)
|
|
5515
5525
|
},
|
|
5516
|
-
nativeDatabaseProvider:
|
|
5526
|
+
nativeDatabaseProvider: _chunkKF7ETIFKcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5517
5527
|
{
|
|
5518
5528
|
open: async (requestedActorId) => {
|
|
5519
5529
|
void requestedActorId;
|
|
@@ -5536,7 +5546,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5536
5546
|
return this.#db;
|
|
5537
5547
|
}
|
|
5538
5548
|
#bindDatabaseClient(client) {
|
|
5539
|
-
return
|
|
5549
|
+
return _chunkKF7ETIFKcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5540
5550
|
enter: async () => await this.#enterStateTransaction(),
|
|
5541
5551
|
exit: (scope) => this.#exitStateTransaction(
|
|
5542
5552
|
scope
|
|
@@ -5740,7 +5750,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5740
5750
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5741
5751
|
logger2().warn({
|
|
5742
5752
|
msg: "keepAwake promise rejected",
|
|
5743
|
-
error:
|
|
5753
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
5744
5754
|
});
|
|
5745
5755
|
}).then(() => null);
|
|
5746
5756
|
try {
|
|
@@ -6120,7 +6130,7 @@ function buildActorTracingConfig(actions, tracing) {
|
|
|
6120
6130
|
if (tracing === void 0) return void 0;
|
|
6121
6131
|
return {
|
|
6122
6132
|
sampler: tracing.sampler,
|
|
6123
|
-
actions:
|
|
6133
|
+
actions: _chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, actions, tracing.actions)
|
|
6124
6134
|
};
|
|
6125
6135
|
}
|
|
6126
6136
|
function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
@@ -6162,7 +6172,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
6162
6172
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
6163
6173
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
6164
6174
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
6165
|
-
actions: Object.keys(
|
|
6175
|
+
actions: Object.keys(_chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
|
|
6166
6176
|
inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
|
|
6167
6177
|
};
|
|
6168
6178
|
}
|
|
@@ -6238,10 +6248,10 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
6238
6248
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
6239
6249
|
var _a;
|
|
6240
6250
|
const config = definition.config;
|
|
6241
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
6242
|
-
const actionHandlers =
|
|
6251
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkKF7ETIFKcjs.db.call(void 0, )));
|
|
6252
|
+
const actionHandlers = _chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
|
|
6243
6253
|
const schemaConfig = {
|
|
6244
|
-
actionInputSchemas:
|
|
6254
|
+
actionInputSchemas: _chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0,
|
|
6245
6255
|
config.actions,
|
|
6246
6256
|
config.actionInputSchemas
|
|
6247
6257
|
),
|
|
@@ -6249,9 +6259,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6249
6259
|
events: config.events,
|
|
6250
6260
|
queues: config.queues
|
|
6251
6261
|
};
|
|
6252
|
-
const createClient = (ctx) =>
|
|
6253
|
-
new (0,
|
|
6254
|
-
|
|
6262
|
+
const createClient = (ctx) => _chunk3KVVYC5Icjs.createClientWithDriver.call(void 0,
|
|
6263
|
+
new (0, _chunk3KVVYC5Icjs.RemoteEngineControlClient)(
|
|
6264
|
+
_chunk3KVVYC5Icjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
6255
6265
|
),
|
|
6256
6266
|
{
|
|
6257
6267
|
encoding: "bare",
|
|
@@ -6263,13 +6273,13 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6263
6273
|
)
|
|
6264
6274
|
}
|
|
6265
6275
|
);
|
|
6266
|
-
const run =
|
|
6267
|
-
const runHandlerCoordinator =
|
|
6276
|
+
const run = _chunkSSF2XC33cjs.getRunFunction.call(void 0, config.run);
|
|
6277
|
+
const runHandlerCoordinator = _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
|
|
6268
6278
|
const getNativeWorkflowInspector = (ctx) => {
|
|
6269
6279
|
var _a2, _b;
|
|
6270
6280
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6271
6281
|
const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
|
|
6272
|
-
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b =
|
|
6282
|
+
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunkSSF2XC33cjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
|
|
6273
6283
|
};
|
|
6274
6284
|
const onStateChange = typeof config.onStateChange === "function" ? (actorCtx, nextState) => {
|
|
6275
6285
|
config.onStateChange(actorCtx, nextState);
|
|
@@ -6443,7 +6453,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6443
6453
|
400
|
|
6444
6454
|
);
|
|
6445
6455
|
}
|
|
6446
|
-
const cbor =
|
|
6456
|
+
const cbor = _chunkM3H37DUQcjs.encodeCborCompat.call(void 0,
|
|
6447
6457
|
_nullishCoalesce(body.body, () => ( null))
|
|
6448
6458
|
);
|
|
6449
6459
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -6811,7 +6821,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6811
6821
|
);
|
|
6812
6822
|
} finally {
|
|
6813
6823
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6814
|
-
|
|
6824
|
+
_chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6815
6825
|
await actorCtx.dispose();
|
|
6816
6826
|
}
|
|
6817
6827
|
}
|
|
@@ -6823,7 +6833,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6823
6833
|
const actorCtx = makeActorCtx(ctx);
|
|
6824
6834
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6825
6835
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6826
|
-
|
|
6836
|
+
_chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6827
6837
|
try {
|
|
6828
6838
|
if (typeof config.onDestroy === "function") {
|
|
6829
6839
|
await config.onDestroy(actorCtx);
|
|
@@ -7040,7 +7050,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7040
7050
|
...request,
|
|
7041
7051
|
abortController: requestAbortController
|
|
7042
7052
|
});
|
|
7043
|
-
const rawConnParams = handlerRequest.headers.get(
|
|
7053
|
+
const rawConnParams = handlerRequest.headers.get(_chunk3KVVYC5Icjs.HEADER_CONN_PARAMS);
|
|
7044
7054
|
let requestCtx;
|
|
7045
7055
|
let conn;
|
|
7046
7056
|
let removeRequestAbortListener;
|
|
@@ -7097,7 +7107,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7097
7107
|
requestCtx,
|
|
7098
7108
|
handlerRequest
|
|
7099
7109
|
);
|
|
7100
|
-
if (!
|
|
7110
|
+
if (!_chunk3KVVYC5Icjs.isResponseLike.call(void 0, response)) {
|
|
7101
7111
|
throw new Error(
|
|
7102
7112
|
"onRequest handler must return a Response"
|
|
7103
7113
|
);
|
|
@@ -7187,15 +7197,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7187
7197
|
}
|
|
7188
7198
|
);
|
|
7189
7199
|
})(),
|
|
7190
|
-
getWorkflowHistory:
|
|
7200
|
+
getWorkflowHistory: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7191
7201
|
async (error, payload) => {
|
|
7192
7202
|
var _a2;
|
|
7193
7203
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
7194
7204
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
7195
|
-
return history == null ? void 0 :
|
|
7205
|
+
return history == null ? void 0 : _chunkM3H37DUQcjs.toUint8Array.call(void 0, history);
|
|
7196
7206
|
}
|
|
7197
7207
|
) : void 0,
|
|
7198
|
-
replayWorkflow:
|
|
7208
|
+
replayWorkflow: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7199
7209
|
async (error, payload) => {
|
|
7200
7210
|
const { ctx, entryId } = unwrapTsfnPayload(
|
|
7201
7211
|
error,
|
|
@@ -7206,7 +7216,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7206
7216
|
return void 0;
|
|
7207
7217
|
}
|
|
7208
7218
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
7209
|
-
return history == null ? void 0 :
|
|
7219
|
+
return history == null ? void 0 : _chunkM3H37DUQcjs.toUint8Array.call(void 0, history);
|
|
7210
7220
|
}
|
|
7211
7221
|
) : void 0,
|
|
7212
7222
|
actions: Object.fromEntries(
|
|
@@ -7216,6 +7226,11 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7216
7226
|
async (error, payload) => {
|
|
7217
7227
|
const { ctx, conn, args, scheduledFire, cancelToken } = unwrapTsfnPayload(error, payload);
|
|
7218
7228
|
const actorCtx = conn != null ? makeConnCtx(ctx, conn, void 0, cancelToken) : makeActorCtx(ctx, void 0, cancelToken);
|
|
7229
|
+
if (scheduledFire) {
|
|
7230
|
+
Object.defineProperty(actorCtx, "scheduledFire", {
|
|
7231
|
+
value: scheduledFire
|
|
7232
|
+
});
|
|
7233
|
+
}
|
|
7219
7234
|
const runAction = async () => {
|
|
7220
7235
|
try {
|
|
7221
7236
|
return encodeValue(
|
|
@@ -7328,7 +7343,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7328
7343
|
buildActorConfig(definition, registryConfig, runtime.kind)
|
|
7329
7344
|
);
|
|
7330
7345
|
}
|
|
7331
|
-
async function buildServeConfig(config,
|
|
7346
|
+
async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
7332
7347
|
var _a;
|
|
7333
7348
|
if (!config.endpoint) {
|
|
7334
7349
|
throw nativeEndpointNotConfiguredError();
|
|
@@ -7340,27 +7355,29 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7340
7355
|
token: config.token,
|
|
7341
7356
|
namespace: config.namespace,
|
|
7342
7357
|
poolName: config.node.poolName,
|
|
7343
|
-
startServices:
|
|
7358
|
+
startServices: resolveNativeBinaries && config.startServices,
|
|
7344
7359
|
handleInspectorHttpInRuntime: true,
|
|
7345
7360
|
serverlessBasePath: config.serverless.basePath,
|
|
7346
|
-
serverlessPackageVersion:
|
|
7361
|
+
serverlessPackageVersion: _chunkM3H37DUQcjs.VERSION,
|
|
7347
7362
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
7348
7363
|
serverlessClientNamespace: config.publicNamespace,
|
|
7349
7364
|
serverlessClientToken: config.publicToken,
|
|
7350
7365
|
serverlessValidateEndpoint: config.validateServerlessEndpoint,
|
|
7351
7366
|
serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes
|
|
7352
7367
|
};
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7368
|
+
if (resolveNativeBinaries) {
|
|
7369
|
+
try {
|
|
7370
|
+
const { getEnginePath } = await loadEngineCli();
|
|
7371
|
+
serveConfig.engineBinaryPath = getEnginePath();
|
|
7372
|
+
} catch (error) {
|
|
7373
|
+
logger2().warn({
|
|
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",
|
|
7375
|
+
error: _chunkM3H37DUQcjs.stringifyError.call(void 0, error)
|
|
7376
|
+
});
|
|
7377
|
+
}
|
|
7361
7378
|
}
|
|
7362
|
-
if (
|
|
7363
|
-
const servicesBinary =
|
|
7379
|
+
if (resolveNativeBinaries && config.startServices) {
|
|
7380
|
+
const servicesBinary = _chunkM3H37DUQcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
|
|
7364
7381
|
if (servicesBinary) {
|
|
7365
7382
|
serveConfig.servicesBinaryPath = servicesBinary;
|
|
7366
7383
|
} else {
|
|
@@ -7375,13 +7392,13 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7375
7392
|
serveConfig.engineHost = config.engineHost;
|
|
7376
7393
|
serveConfig.enginePort = config.enginePort;
|
|
7377
7394
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
7378
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7395
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkM3H37DUQcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
7379
7396
|
}
|
|
7380
7397
|
return serveConfig;
|
|
7381
7398
|
}
|
|
7382
7399
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
7383
7400
|
var _a;
|
|
7384
|
-
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) {
|
|
7385
7402
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
7386
7403
|
}
|
|
7387
7404
|
if (runtime.kind === "napi") {
|
|
@@ -7413,6 +7430,7 @@ async function buildConfiguredRegistry(config) {
|
|
|
7413
7430
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7414
7431
|
var LOCAL_ENGINE_READY_TIMEOUT_MS = 6e4;
|
|
7415
7432
|
var LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4e3;
|
|
7433
|
+
var DEFAULT_ACTOR_STOP_THRESHOLD_MS = 3e4;
|
|
7416
7434
|
function rejectServerless() {
|
|
7417
7435
|
throw new Error("serverless is disabled in this version");
|
|
7418
7436
|
}
|
|
@@ -7453,7 +7471,7 @@ function createApplicationFetch(application, runtime) {
|
|
|
7453
7471
|
signal: abortController.signal
|
|
7454
7472
|
})
|
|
7455
7473
|
);
|
|
7456
|
-
if (!
|
|
7474
|
+
if (!_chunk3KVVYC5Icjs.isResponseLike.call(void 0, response)) {
|
|
7457
7475
|
throw new TypeError(
|
|
7458
7476
|
"registry.listen() application fetch must return a Response"
|
|
7459
7477
|
);
|
|
@@ -7499,11 +7517,16 @@ var Registry = class {
|
|
|
7499
7517
|
#shutdownInstalled = false;
|
|
7500
7518
|
#shutdownInFlight = null;
|
|
7501
7519
|
#signalHandlers = {};
|
|
7520
|
+
#envoyConfiguredRegistry;
|
|
7521
|
+
#activeActorCountListeners = /* @__PURE__ */ new Set();
|
|
7522
|
+
#activeActorCountToken;
|
|
7523
|
+
#lastActiveActorCount;
|
|
7524
|
+
#activeActorCountSupported;
|
|
7502
7525
|
constructor(config, deps) {
|
|
7503
7526
|
var _a;
|
|
7504
7527
|
this.#config = config;
|
|
7505
7528
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
7506
|
-
|
|
7529
|
+
_chunkM3H37DUQcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7507
7530
|
}
|
|
7508
7531
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7509
7532
|
this.routes = {
|
|
@@ -7735,10 +7758,10 @@ var Registry = class {
|
|
|
7735
7758
|
if (!opts.application) {
|
|
7736
7759
|
rejectServerless();
|
|
7737
7760
|
}
|
|
7738
|
-
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => (
|
|
7739
|
-
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, )));
|
|
7740
7763
|
const config = this.parseConfig();
|
|
7741
|
-
if (opts.application &&
|
|
7764
|
+
if (opts.application && _chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7742
7765
|
if (config.runtime === "wasm") {
|
|
7743
7766
|
throw new Error(
|
|
7744
7767
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7814,7 +7837,7 @@ var Registry = class {
|
|
|
7814
7837
|
return jsonRouteResponse(503, {
|
|
7815
7838
|
status: "not_started",
|
|
7816
7839
|
runtime: "rivetkit",
|
|
7817
|
-
version:
|
|
7840
|
+
version: _chunkM3H37DUQcjs.VERSION
|
|
7818
7841
|
});
|
|
7819
7842
|
}
|
|
7820
7843
|
const { runtime, registry } = configured;
|
|
@@ -7822,7 +7845,7 @@ var Registry = class {
|
|
|
7822
7845
|
return jsonRouteResponse(501, {
|
|
7823
7846
|
status: "unsupported",
|
|
7824
7847
|
runtime: "rivetkit",
|
|
7825
|
-
version:
|
|
7848
|
+
version: _chunkM3H37DUQcjs.VERSION
|
|
7826
7849
|
});
|
|
7827
7850
|
}
|
|
7828
7851
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7897,14 +7920,14 @@ var Registry = class {
|
|
|
7897
7920
|
var _a;
|
|
7898
7921
|
if (!this.#runtimeServePromise) {
|
|
7899
7922
|
const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
|
|
7900
|
-
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" :
|
|
7923
|
+
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkM3H37DUQcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
|
|
7901
7924
|
logger2().info({
|
|
7902
7925
|
msg: "starting rivetkit envoy",
|
|
7903
|
-
rivetkitVersion:
|
|
7926
|
+
rivetkitVersion: _chunkM3H37DUQcjs.VERSION,
|
|
7904
7927
|
envoyVersion: config.node.version,
|
|
7905
7928
|
envoyVersionSource
|
|
7906
7929
|
});
|
|
7907
|
-
if (envoyVersionSource === "default" &&
|
|
7930
|
+
if (envoyVersionSource === "default" && _chunkM3H37DUQcjs.getNodeEnv.call(void 0, ) === "production") {
|
|
7908
7931
|
logger2().error({
|
|
7909
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",
|
|
7910
7933
|
envoyVersion: config.node.version,
|
|
@@ -7913,6 +7936,21 @@ var Registry = class {
|
|
|
7913
7936
|
}
|
|
7914
7937
|
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
7915
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
|
+
);
|
|
7916
7954
|
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
7917
7955
|
async ({ runtime, registry, serveConfig }) => {
|
|
7918
7956
|
await runtime.serveRegistry(registry, serveConfig);
|
|
@@ -7993,12 +8031,12 @@ var Registry = class {
|
|
|
7993
8031
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
7994
8032
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
7995
8033
|
const runtimes = /* @__PURE__ */ new Set();
|
|
7996
|
-
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);
|
|
7997
8035
|
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
7998
8036
|
if (gracePeriodMs === void 0) {
|
|
7999
8037
|
gracePeriodMs = localDevSignal ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
|
|
8000
8038
|
_nullishCoalesce(modeAPromise, () => ( modeBPromise))
|
|
8001
|
-
), async () => (
|
|
8039
|
+
), async () => ( DEFAULT_ACTOR_STOP_THRESHOLD_MS));
|
|
8002
8040
|
}
|
|
8003
8041
|
const drain = async () => {
|
|
8004
8042
|
const registries = [];
|
|
@@ -8105,7 +8143,7 @@ var Registry = class {
|
|
|
8105
8143
|
}
|
|
8106
8144
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8107
8145
|
try {
|
|
8108
|
-
if (
|
|
8146
|
+
if (_chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8109
8147
|
return Promise.reject(
|
|
8110
8148
|
new Error(
|
|
8111
8149
|
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
@@ -8129,7 +8167,7 @@ var Registry = class {
|
|
|
8129
8167
|
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
8130
8168
|
throw new Error("registry envoy startup did not initialize");
|
|
8131
8169
|
}
|
|
8132
|
-
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;
|
|
8133
8171
|
let timeout;
|
|
8134
8172
|
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
8135
8173
|
var _a;
|
|
@@ -8179,8 +8217,8 @@ var Registry = class {
|
|
|
8179
8217
|
* ```
|
|
8180
8218
|
*/
|
|
8181
8219
|
start() {
|
|
8182
|
-
if (
|
|
8183
|
-
const publicDir = _nullishCoalesce(
|
|
8220
|
+
if (_chunkM3H37DUQcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8221
|
+
const publicDir = _nullishCoalesce(_chunkM3H37DUQcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
8184
8222
|
this.listen({ publicDir }).catch((error) => {
|
|
8185
8223
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
8186
8224
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -8192,6 +8230,101 @@ var Registry = class {
|
|
|
8192
8230
|
const config = this.parseConfig();
|
|
8193
8231
|
this.#startEnvoy(config, true);
|
|
8194
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
|
+
}
|
|
8195
8328
|
#printWelcome(config, kind, listener) {
|
|
8196
8329
|
if (config.noWelcome || this.#welcomePrinted) return;
|
|
8197
8330
|
this.#welcomePrinted = true;
|
|
@@ -8201,13 +8334,13 @@ var Registry = class {
|
|
|
8201
8334
|
};
|
|
8202
8335
|
console.log();
|
|
8203
8336
|
console.log(
|
|
8204
|
-
` RivetKit ${
|
|
8337
|
+
` RivetKit ${_chunkM3H37DUQcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
8205
8338
|
);
|
|
8206
8339
|
if (config.namespace !== "default") {
|
|
8207
8340
|
logLine("Namespace", config.namespace);
|
|
8208
8341
|
}
|
|
8209
8342
|
if (config.endpoint) {
|
|
8210
|
-
const endpointType = config.startEngine ||
|
|
8343
|
+
const endpointType = config.startEngine || _chunk3KVVYC5Icjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
|
|
8211
8344
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
8212
8345
|
}
|
|
8213
8346
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -8277,5 +8410,5 @@ function setup(input) {
|
|
|
8277
8410
|
|
|
8278
8411
|
|
|
8279
8412
|
|
|
8280
|
-
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;
|
|
8281
8414
|
//# sourceMappingURL=mod.cjs.map
|