rivetkit 2.3.0-rc.11 → 2.3.0-rc.13
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 +407 -20
- package/dist/browser/client.js +101 -86
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +12 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/agent-os/index.cjs +66 -3
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +404 -17
- package/dist/tsup/agent-os/index.d.ts +404 -17
- package/dist/tsup/agent-os/index.js +66 -3
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-WXYWDLJY.js → chunk-33YE6XCI.js} +4 -4
- package/dist/tsup/{chunk-2NXFKPRB.cjs → chunk-7OR3CHD5.cjs} +10 -10
- package/dist/tsup/{chunk-2NXFKPRB.cjs.map → chunk-7OR3CHD5.cjs.map} +1 -1
- package/dist/tsup/{chunk-LW5HNCWD.cjs → chunk-7XQCARVY.cjs} +3 -3
- package/dist/tsup/{chunk-LW5HNCWD.cjs.map → chunk-7XQCARVY.cjs.map} +1 -1
- package/dist/tsup/{chunk-GX6W4MW3.cjs → chunk-BSPS6NSN.cjs} +5 -5
- package/dist/tsup/{chunk-GX6W4MW3.cjs.map → chunk-BSPS6NSN.cjs.map} +1 -1
- package/dist/tsup/{chunk-T3VCJ4PV.js → chunk-DPIMKYNB.js} +61 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-XG25CGSW.cjs → chunk-E5CLYAUZ.cjs} +146 -143
- package/dist/tsup/chunk-E5CLYAUZ.cjs.map +1 -0
- package/dist/tsup/{chunk-RDBGKI66.cjs → chunk-EBWOJRCC.cjs} +22 -5
- package/dist/tsup/chunk-EBWOJRCC.cjs.map +1 -0
- package/dist/tsup/{chunk-YRQ4F5CD.js → chunk-HHNYEQD3.js} +6 -6
- package/dist/tsup/chunk-HHNYEQD3.js.map +1 -0
- package/dist/tsup/{chunk-4FP4FFB5.js → chunk-IOUSQVXI.js} +21 -4
- package/dist/tsup/chunk-IOUSQVXI.js.map +1 -0
- package/dist/tsup/{chunk-LNP7Q6I6.cjs → chunk-ISDKSSYR.cjs} +4 -4
- package/dist/tsup/{chunk-LNP7Q6I6.cjs.map → chunk-ISDKSSYR.cjs.map} +1 -1
- package/dist/tsup/{chunk-TTLUIDVH.js → chunk-J72WHUBC.js} +12 -9
- package/dist/tsup/chunk-J72WHUBC.js.map +1 -0
- package/dist/tsup/{chunk-Y3JBOFBG.cjs → chunk-KWABEUUA.cjs} +10 -10
- package/dist/tsup/chunk-KWABEUUA.cjs.map +1 -0
- package/dist/tsup/{chunk-XCDCURZ4.cjs → chunk-NIY3RSPX.cjs} +62 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-3P2JUHWJ.js → chunk-T44AVAGW.js} +2 -2
- package/dist/tsup/{chunk-GRFBV2U7.js → chunk-TCXEM6PA.js} +2 -2
- package/dist/tsup/{chunk-KRC4L3YB.js → chunk-ZI5CNA2Z.js} +2 -2
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +6 -6
- 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-De5UVu0V.d.ts → config-BxWAw3iH.d.ts} +476 -20
- package/dist/tsup/{config-CTwe3WwC.d.cts → config-CZQQ-mso.d.cts} +476 -20
- package/dist/tsup/{context-Dmj477Uh.d.cts → context-Bw7xq8w3.d.cts} +1 -1
- package/dist/tsup/{context-DPHISlUi.d.ts → context-D8QA76sV.d.ts} +1 -1
- 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-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +341 -138
- 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 +277 -74
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +11 -11
- 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 +19 -9
- package/src/actor/config.ts +111 -10
- package/src/actor/definition.ts +6 -5
- package/src/actor/instance/mod.ts +4 -4
- package/src/actor/mod.ts +2 -0
- package/src/client/actor-common.ts +24 -27
- package/src/client/actor-handle.ts +2 -1
- package/src/common/engine.ts +28 -1
- package/src/common/utils.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +16 -5
- package/src/engine-client/actor-http-client.ts +2 -2
- package/src/engine-client/api-endpoints.ts +5 -1
- package/src/engine-client/ws-proxy.ts +5 -0
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +143 -62
- package/src/registry/napi-runtime.ts +6 -0
- package/src/registry/native.ts +170 -27
- package/src/registry/process-metrics.ts +16 -4
- package/src/registry/runtime.ts +26 -0
- package/src/registry/wasm-runtime.ts +16 -1
- package/src/utils/env-vars.ts +6 -0
- package/dist/tsup/chunk-4FP4FFB5.js.map +0 -1
- package/dist/tsup/chunk-RDBGKI66.cjs.map +0 -1
- package/dist/tsup/chunk-T3VCJ4PV.js.map +0 -1
- package/dist/tsup/chunk-TTLUIDVH.js.map +0 -1
- package/dist/tsup/chunk-XCDCURZ4.cjs.map +0 -1
- package/dist/tsup/chunk-XG25CGSW.cjs.map +0 -1
- package/dist/tsup/chunk-Y3JBOFBG.cjs.map +0 -1
- package/dist/tsup/chunk-YRQ4F5CD.js.map +0 -1
- /package/dist/tsup/{chunk-WXYWDLJY.js.map → chunk-33YE6XCI.js.map} +0 -0
- /package/dist/tsup/{chunk-3P2JUHWJ.js.map → chunk-T44AVAGW.js.map} +0 -0
- /package/dist/tsup/{chunk-GRFBV2U7.js.map → chunk-TCXEM6PA.js.map} +0 -0
- /package/dist/tsup/{chunk-KRC4L3YB.js.map → chunk-ZI5CNA2Z.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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 _chunkISDKSSYRcjs = require('./chunk-ISDKSSYR.cjs');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
var _chunkXCDCURZ4cjs = require('./chunk-XCDCURZ4.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkNIY3RSPXcjs = require('./chunk-NIY3RSPX.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ var _chunkLNP7Q6I6cjs = require('./chunk-LNP7Q6I6.cjs');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkE5CLYAUZcjs = require('./chunk-E5CLYAUZ.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -32,9 +32,10 @@ var _chunkVE2X4KMGcjs = require('./chunk-VE2X4KMG.cjs');
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
36
|
-
require('./chunk-
|
|
37
|
-
|
|
35
|
+
var _chunkBSPS6NSNcjs = require('./chunk-BSPS6NSN.cjs');
|
|
36
|
+
require('./chunk-7XQCARVY.cjs');
|
|
37
|
+
|
|
38
|
+
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
|
|
@@ -59,7 +60,7 @@ require('./chunk-LW5HNCWD.cjs');
|
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
|
|
62
|
-
var
|
|
63
|
+
var _chunkEBWOJRCCcjs = require('./chunk-EBWOJRCC.cjs');
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
|
|
@@ -71,10 +72,11 @@ var _chunkRDBGKI66cjs = require('./chunk-RDBGKI66.cjs');
|
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
var _chunkKORQB2IRcjs = require('./chunk-KORQB2IR.cjs');
|
|
75
|
+
require('./chunk-ZA7FLHKH.cjs');
|
|
74
76
|
|
|
75
77
|
// src/actor/log.ts
|
|
76
78
|
function loggerWithoutContext() {
|
|
77
|
-
return
|
|
79
|
+
return _chunkEBWOJRCCcjs.getLogger.call(void 0, "actor-runtime");
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
// src/actor/definition.ts
|
|
@@ -107,7 +109,7 @@ function actor(input) {
|
|
|
107
109
|
warnDeprecatedShutdownTimeoutKeys(
|
|
108
110
|
input == null ? void 0 : input.options
|
|
109
111
|
);
|
|
110
|
-
const config =
|
|
112
|
+
const config = _chunkNIY3RSPXcjs.ActorConfigSchema.parse(input);
|
|
111
113
|
return new ActorDefinition(config);
|
|
112
114
|
}
|
|
113
115
|
function isStaticActorDefinition(definition) {
|
|
@@ -206,7 +208,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
206
208
|
var _virtualwebsocket = require('@rivetkit/virtual-websocket');
|
|
207
209
|
var _ws = require('hono/ws');
|
|
208
210
|
function logger() {
|
|
209
|
-
return
|
|
211
|
+
return _chunkEBWOJRCCcjs.getLogger.call(void 0, "inline-websocket-adapter");
|
|
210
212
|
}
|
|
211
213
|
var InlineWebSocketAdapter = class {
|
|
212
214
|
#handler;
|
|
@@ -360,12 +362,27 @@ var InlineWebSocketAdapter = class {
|
|
|
360
362
|
var _hono = require('hono');
|
|
361
363
|
|
|
362
364
|
// src/common/engine.ts
|
|
365
|
+
var ENGINE_HOST = "127.0.0.1";
|
|
363
366
|
var ENGINE_PORT = 6420;
|
|
364
|
-
var ENGINE_ENDPOINT =
|
|
367
|
+
var ENGINE_ENDPOINT = buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT);
|
|
368
|
+
function buildEngineEndpoint(host, port) {
|
|
369
|
+
const urlHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
370
|
+
return `http://${urlHost}:${port}`;
|
|
371
|
+
}
|
|
372
|
+
function isLocalEngineEndpoint(endpoint) {
|
|
373
|
+
let url;
|
|
374
|
+
try {
|
|
375
|
+
url = new URL(endpoint);
|
|
376
|
+
} catch (e) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
const hostname = url.hostname.toLowerCase();
|
|
380
|
+
return hostname === "localhost" || hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]" || hostname === "::1" || hostname === "[::1]" || /^127(?:\.\d{1,3}){0,3}$/.test(hostname);
|
|
381
|
+
}
|
|
365
382
|
|
|
366
383
|
// src/registry/log.ts
|
|
367
384
|
function logger2() {
|
|
368
|
-
return
|
|
385
|
+
return _chunkEBWOJRCCcjs.getLogger.call(void 0, "registry");
|
|
369
386
|
}
|
|
370
387
|
|
|
371
388
|
// src/serverless/configure.ts
|
|
@@ -411,8 +428,8 @@ async function configureServerlessPool(config) {
|
|
|
411
428
|
);
|
|
412
429
|
}
|
|
413
430
|
const customConfig = config.configurePool;
|
|
414
|
-
const clientConfig =
|
|
415
|
-
const dcsRes = await
|
|
431
|
+
const clientConfig = _chunkE5CLYAUZcjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
432
|
+
const dcsRes = await _chunkE5CLYAUZcjs.getDatacenters.call(void 0, clientConfig);
|
|
416
433
|
const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
|
|
417
434
|
const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
|
|
418
435
|
const headers = {
|
|
@@ -434,7 +451,7 @@ async function configureServerlessPool(config) {
|
|
|
434
451
|
metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
|
|
435
452
|
drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
|
|
436
453
|
};
|
|
437
|
-
await
|
|
454
|
+
await _chunkE5CLYAUZcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
|
|
438
455
|
datacenters: Object.fromEntries(
|
|
439
456
|
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
440
457
|
)
|
|
@@ -451,7 +468,7 @@ async function configureServerlessPool(config) {
|
|
|
451
468
|
logger2().warn({
|
|
452
469
|
msg: "serverless pool configuration attempt failed",
|
|
453
470
|
attempts,
|
|
454
|
-
error:
|
|
471
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, error)
|
|
455
472
|
});
|
|
456
473
|
await sleep(CONFIGURE_RETRY_DELAY_MS);
|
|
457
474
|
}
|
|
@@ -459,7 +476,7 @@ async function configureServerlessPool(config) {
|
|
|
459
476
|
logger2().error({
|
|
460
477
|
msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
|
|
461
478
|
attempts,
|
|
462
|
-
error:
|
|
479
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, lastError)
|
|
463
480
|
});
|
|
464
481
|
throw lastError;
|
|
465
482
|
}
|
|
@@ -467,7 +484,7 @@ async function configureServerlessPool(config) {
|
|
|
467
484
|
// src/utils/serve.ts
|
|
468
485
|
var _getport = require('get-port'); var _getport2 = _interopRequireDefault(_getport);
|
|
469
486
|
var serveStaticLoaderPromises = {};
|
|
470
|
-
async function crossPlatformServe(config, httpPort, app, runtime =
|
|
487
|
+
async function crossPlatformServe(config, httpPort, app, runtime = _chunkEBWOJRCCcjs.detectRuntime.call(void 0, )) {
|
|
471
488
|
logger2().debug({ msg: "detected runtime for serve", runtime });
|
|
472
489
|
switch (runtime) {
|
|
473
490
|
case "deno":
|
|
@@ -518,7 +535,7 @@ async function serveNode(config, httpPort, app) {
|
|
|
518
535
|
} catch (err) {
|
|
519
536
|
logger2().error({
|
|
520
537
|
msg: "failed to import @hono/node-server. please run 'npm install @hono/node-server @hono/node-ws'",
|
|
521
|
-
error:
|
|
538
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, err)
|
|
522
539
|
});
|
|
523
540
|
process.exit(1);
|
|
524
541
|
}
|
|
@@ -533,7 +550,7 @@ async function serveNode(config, httpPort, app) {
|
|
|
533
550
|
} catch (err) {
|
|
534
551
|
logger2().error({
|
|
535
552
|
msg: "failed to import @hono/node-ws. please run 'npm install @hono/node-server @hono/node-ws'",
|
|
536
|
-
error:
|
|
553
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, err)
|
|
537
554
|
});
|
|
538
555
|
process.exit(1);
|
|
539
556
|
}
|
|
@@ -564,7 +581,7 @@ async function serveDeno(config, httpPort, app) {
|
|
|
564
581
|
} catch (err) {
|
|
565
582
|
logger2().error({
|
|
566
583
|
msg: "failed to import hono/deno",
|
|
567
|
-
error:
|
|
584
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, err)
|
|
568
585
|
});
|
|
569
586
|
process.exit(1);
|
|
570
587
|
}
|
|
@@ -586,7 +603,7 @@ async function serveBun(config, httpPort, app) {
|
|
|
586
603
|
} catch (err) {
|
|
587
604
|
logger2().error({
|
|
588
605
|
msg: "failed to import hono/bun",
|
|
589
|
-
error:
|
|
606
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, err)
|
|
590
607
|
});
|
|
591
608
|
process.exit(1);
|
|
592
609
|
}
|
|
@@ -610,20 +627,20 @@ var _zod = require('zod');
|
|
|
610
627
|
var _v4 = require('zod/v4');
|
|
611
628
|
var warnedMissingVersion = false;
|
|
612
629
|
var EnvoyConfigSchema = _v4.z.object({
|
|
613
|
-
poolName: _v4.z.string().default(() => _nullishCoalesce(
|
|
630
|
+
poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkEBWOJRCCcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
614
631
|
version: _v4.z.number().default(() => {
|
|
615
|
-
const version =
|
|
632
|
+
const version = _chunkEBWOJRCCcjs.getRivetEnvoyVersion.call(void 0, );
|
|
616
633
|
if (version !== void 0) return version;
|
|
617
|
-
if (
|
|
634
|
+
if (_chunkEBWOJRCCcjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
|
|
618
635
|
warnedMissingVersion = true;
|
|
619
|
-
|
|
636
|
+
_chunkEBWOJRCCcjs.getLogger.call(void 0, "rivetkit").error(
|
|
620
637
|
"RIVET_ENVOY_VERSION is not set. Actors will not be versioned, which means they won't be drained on deploy. This is only needed when self-hosting or using a custom envoy (not needed for Rivet Compute). Set this as a build arg in your Dockerfile. See https://rivet.dev/docs/actors/versions"
|
|
621
638
|
);
|
|
622
639
|
}
|
|
623
640
|
return 1;
|
|
624
641
|
}),
|
|
625
642
|
// Deprecated.
|
|
626
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
643
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkEBWOJRCCcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
|
|
627
644
|
envoyKey: _v4.z.string().optional()
|
|
628
645
|
});
|
|
629
646
|
|
|
@@ -661,7 +678,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
661
678
|
*
|
|
662
679
|
* Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
|
|
663
680
|
*/
|
|
664
|
-
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
681
|
+
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetPublicEndpoint.call(void 0, )))),
|
|
665
682
|
/**
|
|
666
683
|
* Token that clients should use when connecting via the public endpoint.
|
|
667
684
|
*
|
|
@@ -669,7 +686,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
669
686
|
*
|
|
670
687
|
* Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
|
|
671
688
|
*/
|
|
672
|
-
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
689
|
+
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetPublicToken.call(void 0, ))))
|
|
673
690
|
// There is no publicNamespace config option because the frontend and backend
|
|
674
691
|
// cannot use different namespaces. The namespace is extracted from the
|
|
675
692
|
// publicEndpoint URL auth syntax if provided.
|
|
@@ -723,7 +740,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
723
740
|
* Runtime binding to use for RivetKit core.
|
|
724
741
|
* */
|
|
725
742
|
runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
|
|
726
|
-
const rawRuntime = _nullishCoalesce(val, () => (
|
|
743
|
+
const rawRuntime = _nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetkitRuntime.call(void 0, )));
|
|
727
744
|
if (rawRuntime === void 0) {
|
|
728
745
|
return "auto";
|
|
729
746
|
}
|
|
@@ -760,7 +777,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
760
777
|
* */
|
|
761
778
|
logging: _zod.z.object({
|
|
762
779
|
baseLogger: _zod.z.custom().optional(),
|
|
763
|
-
level:
|
|
780
|
+
level: _chunkEBWOJRCCcjs.LogLevelSchema.optional()
|
|
764
781
|
}).optional().default(() => ({})),
|
|
765
782
|
// MARK: Routing
|
|
766
783
|
// // This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
@@ -778,9 +795,9 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
778
795
|
*
|
|
779
796
|
* Can also be set via RIVET_ENDPOINT environment variables.
|
|
780
797
|
*/
|
|
781
|
-
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
782
|
-
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
783
|
-
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
798
|
+
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetEngine.call(void 0, ))), () => ( _chunkEBWOJRCCcjs.getRivetEndpoint.call(void 0, )))),
|
|
799
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetToken.call(void 0, )))),
|
|
800
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkEBWOJRCCcjs.getRivetNamespace.call(void 0, )))),
|
|
784
801
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
|
|
785
802
|
// MARK: Client
|
|
786
803
|
// TODO:
|
|
@@ -820,9 +837,21 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
820
837
|
*
|
|
821
838
|
* Starts the full Rust engine process locally.
|
|
822
839
|
*/
|
|
823
|
-
startEngine: _zod.z.boolean().default(() =>
|
|
840
|
+
startEngine: _zod.z.boolean().default(() => _chunkEBWOJRCCcjs.getRivetRunEngine.call(void 0, )),
|
|
841
|
+
/**
|
|
842
|
+
* @experimental
|
|
843
|
+
*
|
|
844
|
+
* Host to bind the spawned local engine process to.
|
|
845
|
+
*/
|
|
846
|
+
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkEBWOJRCCcjs.getRivetRunEngineHost.call(void 0, ), () => ( ENGINE_HOST))),
|
|
847
|
+
/**
|
|
848
|
+
* @experimental
|
|
849
|
+
*
|
|
850
|
+
* Port to bind the spawned local engine process to.
|
|
851
|
+
*/
|
|
852
|
+
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkEBWOJRCCcjs.getRivetRunEnginePort.call(void 0, ), () => ( ENGINE_PORT))),
|
|
824
853
|
/** @experimental */
|
|
825
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
854
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkEBWOJRCCcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkEBWOJRCCcjs.VERSION))),
|
|
826
855
|
/**
|
|
827
856
|
* @experimental
|
|
828
857
|
*
|
|
@@ -853,12 +882,12 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
853
882
|
shutdown: _zod.z.object({
|
|
854
883
|
/**
|
|
855
884
|
* Wait this many milliseconds for the serve promise to resolve
|
|
856
|
-
* after calling `CoreRegistry::shutdown()`. Defaults to
|
|
857
|
-
*
|
|
885
|
+
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
886
|
+
* engine-provided actor stop threshold once the envoy connects.
|
|
858
887
|
*
|
|
859
888
|
* Must be long enough for rivetkit-core to drain the envoy.
|
|
860
889
|
*/
|
|
861
|
-
gracePeriodMs: _zod.z.number().int().min(1e3).optional()
|
|
890
|
+
gracePeriodMs: _zod.z.number().int().min(1e3).optional(),
|
|
862
891
|
/**
|
|
863
892
|
* If true, rivetkit will not install SIGINT/SIGTERM handlers.
|
|
864
893
|
* Use when the host application owns signal policy and will
|
|
@@ -866,12 +895,11 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
866
895
|
*/
|
|
867
896
|
disableSignalHandlers: _zod.z.boolean().optional().default(false)
|
|
868
897
|
}).optional().default(() => ({
|
|
869
|
-
gracePeriodMs: 3e4,
|
|
870
898
|
disableSignalHandlers: false
|
|
871
899
|
}))
|
|
872
900
|
}).transform((config, ctx) => {
|
|
873
901
|
var _a, _b, _c;
|
|
874
|
-
const isDevEnv =
|
|
902
|
+
const isDevEnv = _chunkEBWOJRCCcjs.isDev.call(void 0, );
|
|
875
903
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
876
904
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
877
905
|
ctx.addIssue({
|
|
@@ -881,7 +909,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
881
909
|
});
|
|
882
910
|
}
|
|
883
911
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
884
|
-
const parsedEndpoint = config.endpoint ?
|
|
912
|
+
const parsedEndpoint = config.endpoint ? _chunkE5CLYAUZcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
885
913
|
endpoint: config.endpoint,
|
|
886
914
|
path: ["endpoint"],
|
|
887
915
|
namespace: config.namespace,
|
|
@@ -899,13 +927,17 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
899
927
|
message: "configurePool requires either endpoint or startEngine"
|
|
900
928
|
});
|
|
901
929
|
}
|
|
902
|
-
const
|
|
930
|
+
const localEngineEndpoint = buildEngineEndpoint(
|
|
931
|
+
config.engineHost,
|
|
932
|
+
config.enginePort
|
|
933
|
+
);
|
|
934
|
+
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT) : void 0)));
|
|
903
935
|
const validateServerlessEndpoint = Boolean(
|
|
904
936
|
config.startEngine || parsedEndpoint
|
|
905
937
|
);
|
|
906
938
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
907
939
|
const token = _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token));
|
|
908
|
-
const parsedPublicEndpoint = config.serverless.publicEndpoint ?
|
|
940
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkE5CLYAUZcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
909
941
|
endpoint: config.serverless.publicEndpoint,
|
|
910
942
|
path: ["serverless", "publicEndpoint"]
|
|
911
943
|
}) : void 0;
|
|
@@ -916,7 +948,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
916
948
|
path: ["serverless", "publicEndpoint"]
|
|
917
949
|
});
|
|
918
950
|
}
|
|
919
|
-
const publicEndpoint = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint), () => ( (isDevEnv && config.startEngine ?
|
|
951
|
+
const publicEndpoint = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint), () => ( (isDevEnv && config.startEngine ? endpoint : void 0)));
|
|
920
952
|
const publicNamespace = parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.namespace;
|
|
921
953
|
const publicToken = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.token), () => ( config.serverless.publicToken));
|
|
922
954
|
return {
|
|
@@ -940,7 +972,7 @@ function buildActorNames(config) {
|
|
|
940
972
|
Object.keys(config.use).map((actorName) => {
|
|
941
973
|
const definition = config.use[actorName];
|
|
942
974
|
const options = _nullishCoalesce(definition.config.options, () => ( {}));
|
|
943
|
-
const runMeta =
|
|
975
|
+
const runMeta = _chunkNIY3RSPXcjs.getRunMetadata.call(void 0, definition.config.run);
|
|
944
976
|
const metadata = {};
|
|
945
977
|
metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
|
|
946
978
|
metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
|
|
@@ -1033,7 +1065,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
1033
1065
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
1034
1066
|
sqlite: DocSqliteConfigSchema,
|
|
1035
1067
|
logging: _zod.z.object({
|
|
1036
|
-
level:
|
|
1068
|
+
level: _chunkEBWOJRCCcjs.LogLevelSchema.optional().describe(
|
|
1037
1069
|
"Log level for RivetKit. Default: 'warn'"
|
|
1038
1070
|
)
|
|
1039
1071
|
}).optional().describe("Logging configuration."),
|
|
@@ -1578,6 +1610,9 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1578
1610
|
async actorWaitForTrackedShutdownWork(ctx) {
|
|
1579
1611
|
return await asNativeActorContext(ctx).waitForTrackedShutdownWork();
|
|
1580
1612
|
}
|
|
1613
|
+
async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
|
|
1614
|
+
await asNativeActorContext(ctx).waitForTrackedShutdownWorkUnbounded();
|
|
1615
|
+
}
|
|
1581
1616
|
actorKeepAwake(ctx, promise) {
|
|
1582
1617
|
asNativeActorContext(ctx).keepAwake(promise);
|
|
1583
1618
|
}
|
|
@@ -2163,6 +2198,12 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2163
2198
|
"waitForTrackedShutdownWork"
|
|
2164
2199
|
);
|
|
2165
2200
|
}
|
|
2201
|
+
async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
|
|
2202
|
+
await callHandle(
|
|
2203
|
+
asWasmActorContext(ctx),
|
|
2204
|
+
"waitForTrackedShutdownWorkUnbounded"
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2166
2207
|
actorKeepAwake(ctx, promise) {
|
|
2167
2208
|
const wasmCtx = asWasmActorContext(ctx);
|
|
2168
2209
|
const regionId = callHandle(wasmCtx, "beginKeepAwake");
|
|
@@ -2312,7 +2353,13 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2312
2353
|
}
|
|
2313
2354
|
async actorQueueWaitForNamesAvailable(ctx, names, options, signal) {
|
|
2314
2355
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
2315
|
-
await callHandleAsync(
|
|
2356
|
+
await callHandleAsync(
|
|
2357
|
+
queue2,
|
|
2358
|
+
"waitForNamesAvailable",
|
|
2359
|
+
names,
|
|
2360
|
+
options,
|
|
2361
|
+
signal
|
|
2362
|
+
);
|
|
2316
2363
|
}
|
|
2317
2364
|
async actorQueueEnqueueAndWait(ctx, name, body, options, signal) {
|
|
2318
2365
|
const queue2 = childHandle(asWasmActorContext(ctx), "queue");
|
|
@@ -2404,6 +2451,10 @@ async function loadWasmRuntime(config) {
|
|
|
2404
2451
|
};
|
|
2405
2452
|
}
|
|
2406
2453
|
|
|
2454
|
+
// src/registry/native.ts
|
|
2455
|
+
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
2456
|
+
var _path2 = require('path'); var _path3 = _interopRequireDefault(_path2);
|
|
2457
|
+
|
|
2407
2458
|
// src/registry/write-through-proxy.ts
|
|
2408
2459
|
var _onchange = require('@rivetkit/on-change'); var _onchange2 = _interopRequireDefault(_onchange);
|
|
2409
2460
|
function createWriteThroughProxy(value, commit, beforeChange) {
|
|
@@ -2439,7 +2490,7 @@ function trySetProcessEnv(key, value) {
|
|
|
2439
2490
|
if (typeof process === "undefined") return;
|
|
2440
2491
|
try {
|
|
2441
2492
|
process.env[key] = value;
|
|
2442
|
-
} catch (
|
|
2493
|
+
} catch (e2) {
|
|
2443
2494
|
}
|
|
2444
2495
|
}
|
|
2445
2496
|
function detectRuntimeHost() {
|
|
@@ -2476,7 +2527,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
2476
2527
|
}
|
|
2477
2528
|
try {
|
|
2478
2529
|
return (await loaders.loadNative()).runtime;
|
|
2479
|
-
} catch (
|
|
2530
|
+
} catch (e3) {
|
|
2480
2531
|
return (await loaders.loadWasm(config.wasm)).runtime;
|
|
2481
2532
|
}
|
|
2482
2533
|
}
|
|
@@ -2639,8 +2690,23 @@ function resolveNativeDestroy(runtime, ctx) {
|
|
|
2639
2690
|
function clearNativeRuntimeState(runtime, ctx) {
|
|
2640
2691
|
callNativeSync(() => runtime.actorClearRuntimeState(ctx));
|
|
2641
2692
|
}
|
|
2642
|
-
async function cleanupNativeSleepRuntimeState(runtime, ctx) {
|
|
2643
|
-
await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
2693
|
+
async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
|
|
2694
|
+
const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
2695
|
+
if (!drained) {
|
|
2696
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
2697
|
+
await closeNativeSqlDatabase(runtime, ctx);
|
|
2698
|
+
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
2699
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
2700
|
+
clearNativeRuntimeState(runtime, ctx);
|
|
2701
|
+
}).catch((error) => {
|
|
2702
|
+
logger2().warn({
|
|
2703
|
+
msg: "deferred native sleep cleanup failed",
|
|
2704
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, error)
|
|
2705
|
+
});
|
|
2706
|
+
});
|
|
2707
|
+
return;
|
|
2708
|
+
}
|
|
2709
|
+
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
2644
2710
|
await closeNativeDatabaseClient(runtime, ctx);
|
|
2645
2711
|
await closeNativeSqlDatabase(runtime, ctx);
|
|
2646
2712
|
clearNativeRuntimeState(runtime, ctx);
|
|
@@ -2745,10 +2811,13 @@ function decodeValue(value) {
|
|
|
2745
2811
|
if (!value || value.length === 0) {
|
|
2746
2812
|
return void 0;
|
|
2747
2813
|
}
|
|
2748
|
-
return
|
|
2814
|
+
return _chunkBSPS6NSNcjs.decodeCborCompat.call(void 0, value);
|
|
2749
2815
|
}
|
|
2750
2816
|
function encodeValue(value) {
|
|
2751
|
-
return
|
|
2817
|
+
return _chunkBSPS6NSNcjs.encodeCborCompat.call(void 0, value);
|
|
2818
|
+
}
|
|
2819
|
+
function normalizeArgs(value) {
|
|
2820
|
+
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
2752
2821
|
}
|
|
2753
2822
|
function unwrapTsfnPayload(error, payload) {
|
|
2754
2823
|
if (error !== null && error !== void 0) {
|
|
@@ -2781,7 +2850,7 @@ function isStructuredBridgeError(error) {
|
|
|
2781
2850
|
return _chunkKORQB2IRcjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
2782
2851
|
}
|
|
2783
2852
|
function encodeNativeCallbackError(error) {
|
|
2784
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
2853
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkEBWOJRCCcjs.deconstructError.call(void 0, error, true);
|
|
2785
2854
|
const bridgeError = new Error(_chunkKORQB2IRcjs.encodeBridgeRivetError.call(void 0, structuredError), {
|
|
2786
2855
|
cause: error instanceof Error ? error : void 0
|
|
2787
2856
|
});
|
|
@@ -2831,8 +2900,8 @@ function decodeWorkflowCbor(data) {
|
|
|
2831
2900
|
return null;
|
|
2832
2901
|
}
|
|
2833
2902
|
try {
|
|
2834
|
-
return
|
|
2835
|
-
} catch (
|
|
2903
|
+
return _chunkBSPS6NSNcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
2904
|
+
} catch (e4) {
|
|
2836
2905
|
return null;
|
|
2837
2906
|
}
|
|
2838
2907
|
}
|
|
@@ -2936,7 +3005,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
2936
3005
|
if (data === null) {
|
|
2937
3006
|
return null;
|
|
2938
3007
|
}
|
|
2939
|
-
const history =
|
|
3008
|
+
const history = _chunkISDKSSYRcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
2940
3009
|
return jsonSafe({
|
|
2941
3010
|
nameRegistry: [...history.nameRegistry],
|
|
2942
3011
|
entries: history.entries.map((entry) => ({
|
|
@@ -3012,7 +3081,7 @@ function wrapNativeCallback(callback) {
|
|
|
3012
3081
|
}
|
|
3013
3082
|
function decodeArgs(value) {
|
|
3014
3083
|
const decoded = decodeValue(value);
|
|
3015
|
-
return
|
|
3084
|
+
return normalizeArgs(decoded);
|
|
3016
3085
|
}
|
|
3017
3086
|
function buildRequest(init) {
|
|
3018
3087
|
const url = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
|
|
@@ -3049,7 +3118,7 @@ var NativeConnAdapter = class {
|
|
|
3049
3118
|
this.#schemas = schemas;
|
|
3050
3119
|
this.#ctx = ctx;
|
|
3051
3120
|
this.#queueHibernationRemoval = queueHibernationRemoval;
|
|
3052
|
-
this[
|
|
3121
|
+
this[_chunkNIY3RSPXcjs.CONN_STATE_MANAGER_SYMBOL] = {
|
|
3053
3122
|
stateEnabled: true,
|
|
3054
3123
|
get state() {
|
|
3055
3124
|
return thisConn.state;
|
|
@@ -3066,7 +3135,7 @@ var NativeConnAdapter = class {
|
|
|
3066
3135
|
decodeValue(this.#runtime.connParams(this.#conn))
|
|
3067
3136
|
);
|
|
3068
3137
|
}
|
|
3069
|
-
[
|
|
3138
|
+
[_chunkNIY3RSPXcjs.RAW_STATE_SYMBOL]() {
|
|
3070
3139
|
return this.#readState();
|
|
3071
3140
|
}
|
|
3072
3141
|
get state() {
|
|
@@ -3077,12 +3146,12 @@ var NativeConnAdapter = class {
|
|
|
3077
3146
|
this.#writeState(nextValue, { writeNative: true });
|
|
3078
3147
|
},
|
|
3079
3148
|
(newValue) => {
|
|
3080
|
-
|
|
3149
|
+
_chunkBSPS6NSNcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
3081
3150
|
}
|
|
3082
3151
|
);
|
|
3083
3152
|
}
|
|
3084
3153
|
set state(value) {
|
|
3085
|
-
|
|
3154
|
+
_chunkBSPS6NSNcjs.assertJsonCompatValue.call(void 0, value);
|
|
3086
3155
|
this.#writeState(value, { writeNative: true });
|
|
3087
3156
|
}
|
|
3088
3157
|
initializeState(value) {
|
|
@@ -3980,7 +4049,7 @@ var ActorContextHandleAdapter = class {
|
|
|
3980
4049
|
this.#databaseProvider = databaseProvider;
|
|
3981
4050
|
}
|
|
3982
4051
|
this.#request = request;
|
|
3983
|
-
this[
|
|
4052
|
+
this[_chunkNIY3RSPXcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
|
|
3984
4053
|
this
|
|
3985
4054
|
);
|
|
3986
4055
|
}
|
|
@@ -4011,7 +4080,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4011
4080
|
}
|
|
4012
4081
|
throw databaseClientNotReadyError();
|
|
4013
4082
|
}
|
|
4014
|
-
[
|
|
4083
|
+
[_chunkNIY3RSPXcjs.RAW_STATE_SYMBOL]() {
|
|
4015
4084
|
if (!this.#stateEnabled) {
|
|
4016
4085
|
throw stateNotEnabledError();
|
|
4017
4086
|
}
|
|
@@ -4032,7 +4101,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4032
4101
|
},
|
|
4033
4102
|
(newValue) => {
|
|
4034
4103
|
this.#assertCanMutateState();
|
|
4035
|
-
|
|
4104
|
+
_chunkBSPS6NSNcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4036
4105
|
}
|
|
4037
4106
|
);
|
|
4038
4107
|
}
|
|
@@ -4043,7 +4112,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4043
4112
|
throw stateNotEnabledError();
|
|
4044
4113
|
}
|
|
4045
4114
|
this.#assertCanMutateState();
|
|
4046
|
-
|
|
4115
|
+
_chunkBSPS6NSNcjs.assertJsonCompatValue.call(void 0, value);
|
|
4047
4116
|
this.#writeState(value, { scheduleSave: true });
|
|
4048
4117
|
}
|
|
4049
4118
|
initializeState(value) {
|
|
@@ -4308,7 +4377,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4308
4377
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
4309
4378
|
logger2().warn({
|
|
4310
4379
|
msg: "keepAwake promise rejected",
|
|
4311
|
-
error:
|
|
4380
|
+
error: _chunkEBWOJRCCcjs.stringifyError.call(void 0, error)
|
|
4312
4381
|
});
|
|
4313
4382
|
}).then(() => null);
|
|
4314
4383
|
try {
|
|
@@ -4384,6 +4453,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4384
4453
|
return false;
|
|
4385
4454
|
}
|
|
4386
4455
|
sleep() {
|
|
4456
|
+
this.#flushStateChange();
|
|
4387
4457
|
callNativeSync(() => this.#runtime.actorSleep(this.#ctx));
|
|
4388
4458
|
}
|
|
4389
4459
|
destroy() {
|
|
@@ -4673,9 +4743,62 @@ function buildActorConfig(definition, registryConfig) {
|
|
|
4673
4743
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
4674
4744
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
4675
4745
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
4676
|
-
actions: Object.keys(_nullishCoalesce(config.actions, () => ( {}))).sort().map((name) => ({ name }))
|
|
4746
|
+
actions: Object.keys(_nullishCoalesce(config.actions, () => ( {}))).sort().map((name) => ({ name })),
|
|
4747
|
+
inspectorTabs: buildInspectorTabs(config.inspector)
|
|
4677
4748
|
};
|
|
4678
4749
|
}
|
|
4750
|
+
function buildInspectorTabs(inspector) {
|
|
4751
|
+
if (!inspector || typeof inspector !== "object") return void 0;
|
|
4752
|
+
const tabs = inspector.tabs;
|
|
4753
|
+
if (!Array.isArray(tabs) || tabs.length === 0) return void 0;
|
|
4754
|
+
return tabs.map((raw) => {
|
|
4755
|
+
const entry = raw;
|
|
4756
|
+
if (entry.hidden === true) {
|
|
4757
|
+
return { id: entry.id, hidden: true };
|
|
4758
|
+
}
|
|
4759
|
+
const resolved = entry.source !== void 0 ? _path3.default.resolve(entry.source) : void 0;
|
|
4760
|
+
if (resolved !== void 0) {
|
|
4761
|
+
validateInspectorTabSource(entry.id, resolved);
|
|
4762
|
+
}
|
|
4763
|
+
return {
|
|
4764
|
+
id: entry.id,
|
|
4765
|
+
label: entry.label,
|
|
4766
|
+
icon: entry.icon,
|
|
4767
|
+
source: resolved
|
|
4768
|
+
};
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
function validateInspectorTabSource(tabId, resolved) {
|
|
4772
|
+
if (resolved === _path3.default.parse(resolved).root) {
|
|
4773
|
+
throw new Error(
|
|
4774
|
+
`inspector.tabs[id="${tabId}"].source resolves to the filesystem root (${resolved}). Point it at the tab's own static-asset directory instead.`
|
|
4775
|
+
);
|
|
4776
|
+
}
|
|
4777
|
+
let stat;
|
|
4778
|
+
try {
|
|
4779
|
+
stat = _fs2.default.statSync(resolved);
|
|
4780
|
+
} catch (err) {
|
|
4781
|
+
const code = err == null ? void 0 : err.code;
|
|
4782
|
+
if (code === "ENOENT") {
|
|
4783
|
+
throw new Error(
|
|
4784
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) does not exist.`
|
|
4785
|
+
);
|
|
4786
|
+
}
|
|
4787
|
+
if (code === "EACCES") {
|
|
4788
|
+
throw new Error(
|
|
4789
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) is not readable (EACCES).`
|
|
4790
|
+
);
|
|
4791
|
+
}
|
|
4792
|
+
throw new Error(
|
|
4793
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) could not be stat'd: ${_nullishCoalesce((err == null ? void 0 : err.message), () => ( err))}`
|
|
4794
|
+
);
|
|
4795
|
+
}
|
|
4796
|
+
if (!stat.isDirectory()) {
|
|
4797
|
+
throw new Error(
|
|
4798
|
+
`inspector.tabs[id="${tabId}"].source (${resolved}) must be a directory, got ${stat.isFile() ? "file" : "non-directory"}.`
|
|
4799
|
+
);
|
|
4800
|
+
}
|
|
4801
|
+
}
|
|
4679
4802
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
4680
4803
|
var _a;
|
|
4681
4804
|
const config = definition.config;
|
|
@@ -4689,9 +4812,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
4689
4812
|
const actionHandlers = Object.fromEntries(
|
|
4690
4813
|
Object.entries(_nullishCoalesce(config.actions, () => ( {}))).map(([name, handler]) => [name, handler])
|
|
4691
4814
|
);
|
|
4692
|
-
const createClient = () =>
|
|
4693
|
-
new (0,
|
|
4694
|
-
|
|
4815
|
+
const createClient = () => _chunkE5CLYAUZcjs.createClientWithDriver.call(void 0,
|
|
4816
|
+
new (0, _chunkE5CLYAUZcjs.RemoteEngineControlClient)(
|
|
4817
|
+
_chunkE5CLYAUZcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
4695
4818
|
),
|
|
4696
4819
|
{ encoding: "bare" }
|
|
4697
4820
|
);
|
|
@@ -4701,7 +4824,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
4701
4824
|
), () => ( false));
|
|
4702
4825
|
const getNativeWorkflowInspector = (ctx) => {
|
|
4703
4826
|
var _a2;
|
|
4704
|
-
return (_a2 =
|
|
4827
|
+
return (_a2 = _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0,
|
|
4705
4828
|
config.run,
|
|
4706
4829
|
callNativeSync(() => runtime.actorId(ctx))
|
|
4707
4830
|
)) == null ? void 0 : _a2.workflow;
|
|
@@ -5008,13 +5131,26 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5008
5131
|
);
|
|
5009
5132
|
}
|
|
5010
5133
|
const body = await jsRequest.json();
|
|
5134
|
+
if (body.args !== void 0 && body.properties !== void 0) {
|
|
5135
|
+
return jsonResponse(
|
|
5136
|
+
{ error: "use either args or properties, not both" },
|
|
5137
|
+
{ status: 400 }
|
|
5138
|
+
);
|
|
5139
|
+
}
|
|
5140
|
+
if (body.properties !== void 0 && (body.properties === null || typeof body.properties !== "object" || Array.isArray(body.properties))) {
|
|
5141
|
+
return jsonResponse(
|
|
5142
|
+
{ error: "properties must be an object" },
|
|
5143
|
+
{ status: 400 }
|
|
5144
|
+
);
|
|
5145
|
+
}
|
|
5146
|
+
const args = body.properties !== void 0 ? [body.properties] : normalizeArgs(body.args);
|
|
5011
5147
|
try {
|
|
5012
5148
|
const output = await action(
|
|
5013
5149
|
actorCtx,
|
|
5014
5150
|
...validateActionArgs(
|
|
5015
5151
|
schemaConfig.actionInputSchemas,
|
|
5016
5152
|
actionName,
|
|
5017
|
-
|
|
5153
|
+
args
|
|
5018
5154
|
)
|
|
5019
5155
|
);
|
|
5020
5156
|
return jsonResponse({ output });
|
|
@@ -5162,24 +5298,30 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5162
5298
|
async (error, payload) => {
|
|
5163
5299
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
5164
5300
|
const actorCtx = makeActorCtx(ctx);
|
|
5301
|
+
const saveActorState = async () => {
|
|
5302
|
+
if (runtime.kind === "wasm") {
|
|
5303
|
+
await runtime.actorSaveState(
|
|
5304
|
+
ctx,
|
|
5305
|
+
actorCtx.serializeForTick("save")
|
|
5306
|
+
);
|
|
5307
|
+
} else {
|
|
5308
|
+
await actorCtx.saveState({
|
|
5309
|
+
immediate: true
|
|
5310
|
+
});
|
|
5311
|
+
}
|
|
5312
|
+
};
|
|
5165
5313
|
try {
|
|
5166
5314
|
if (onSleep) {
|
|
5167
|
-
|
|
5168
|
-
await onSleep(actorCtx);
|
|
5169
|
-
} finally {
|
|
5170
|
-
if (runtime.kind === "wasm") {
|
|
5171
|
-
await runtime.actorSaveState(
|
|
5172
|
-
ctx,
|
|
5173
|
-
actorCtx.serializeForTick("save")
|
|
5174
|
-
);
|
|
5175
|
-
} else {
|
|
5176
|
-
await actorCtx.saveState({ immediate: true });
|
|
5177
|
-
}
|
|
5178
|
-
}
|
|
5315
|
+
await onSleep(actorCtx);
|
|
5179
5316
|
}
|
|
5317
|
+
await saveActorState();
|
|
5180
5318
|
} finally {
|
|
5181
5319
|
try {
|
|
5182
|
-
await cleanupNativeSleepRuntimeState(
|
|
5320
|
+
await cleanupNativeSleepRuntimeState(
|
|
5321
|
+
runtime,
|
|
5322
|
+
ctx,
|
|
5323
|
+
saveActorState
|
|
5324
|
+
);
|
|
5183
5325
|
} finally {
|
|
5184
5326
|
await actorCtx.dispose();
|
|
5185
5327
|
}
|
|
@@ -5390,7 +5532,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5390
5532
|
new Response(null, { status: 404 })
|
|
5391
5533
|
);
|
|
5392
5534
|
}
|
|
5393
|
-
const rawConnParams = jsRequest.headers.get(
|
|
5535
|
+
const rawConnParams = jsRequest.headers.get(_chunkE5CLYAUZcjs.HEADER_CONN_PARAMS);
|
|
5394
5536
|
let requestCtx;
|
|
5395
5537
|
let conn;
|
|
5396
5538
|
try {
|
|
@@ -5455,7 +5597,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5455
5597
|
}
|
|
5456
5598
|
) : void 0,
|
|
5457
5599
|
run: (() => {
|
|
5458
|
-
const run =
|
|
5600
|
+
const run = _chunkNIY3RSPXcjs.getRunFunction.call(void 0, config.run);
|
|
5459
5601
|
if (!run) {
|
|
5460
5602
|
return void 0;
|
|
5461
5603
|
}
|
|
@@ -5474,7 +5616,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5474
5616
|
}
|
|
5475
5617
|
);
|
|
5476
5618
|
})(),
|
|
5477
|
-
getWorkflowHistory:
|
|
5619
|
+
getWorkflowHistory: _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
|
|
5478
5620
|
async (error, payload) => {
|
|
5479
5621
|
var _a2;
|
|
5480
5622
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
@@ -5482,7 +5624,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5482
5624
|
return history == null ? void 0 : encodeValue(history);
|
|
5483
5625
|
}
|
|
5484
5626
|
) : void 0,
|
|
5485
|
-
replayWorkflow:
|
|
5627
|
+
replayWorkflow: _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
|
|
5486
5628
|
async (error, payload) => {
|
|
5487
5629
|
const { ctx, entryId } = unwrapTsfnPayload(
|
|
5488
5630
|
error,
|
|
@@ -5617,7 +5759,7 @@ async function buildServeConfig(config) {
|
|
|
5617
5759
|
poolName: config.envoy.poolName,
|
|
5618
5760
|
handleInspectorHttpInRuntime: true,
|
|
5619
5761
|
serverlessBasePath: config.serverless.basePath,
|
|
5620
|
-
serverlessPackageVersion:
|
|
5762
|
+
serverlessPackageVersion: _chunkEBWOJRCCcjs.VERSION,
|
|
5621
5763
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
5622
5764
|
serverlessClientNamespace: config.publicNamespace,
|
|
5623
5765
|
serverlessClientToken: config.publicToken,
|
|
@@ -5627,15 +5769,17 @@ async function buildServeConfig(config) {
|
|
|
5627
5769
|
if (config.startEngine) {
|
|
5628
5770
|
const { getEnginePath } = await loadEngineCli();
|
|
5629
5771
|
serveConfig.engineBinaryPath = getEnginePath();
|
|
5772
|
+
serveConfig.engineHost = config.engineHost;
|
|
5773
|
+
serveConfig.enginePort = config.enginePort;
|
|
5630
5774
|
}
|
|
5631
5775
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
5632
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
5776
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkEBWOJRCCcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
5633
5777
|
}
|
|
5634
5778
|
return serveConfig;
|
|
5635
5779
|
}
|
|
5636
5780
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
5637
5781
|
var _a;
|
|
5638
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
5782
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkEBWOJRCCcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
5639
5783
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
5640
5784
|
}
|
|
5641
5785
|
const registry = runtime.createRegistry();
|
|
@@ -5661,8 +5805,23 @@ async function buildConfiguredRegistry(config) {
|
|
|
5661
5805
|
}
|
|
5662
5806
|
|
|
5663
5807
|
// src/registry/index.ts
|
|
5808
|
+
function signalExitCode(signal) {
|
|
5809
|
+
switch (signal) {
|
|
5810
|
+
case "SIGINT":
|
|
5811
|
+
return 130;
|
|
5812
|
+
case "SIGTERM":
|
|
5813
|
+
return 143;
|
|
5814
|
+
}
|
|
5815
|
+
}
|
|
5816
|
+
function finishShutdownSignal(signal) {
|
|
5817
|
+
if (process.pid === 1) {
|
|
5818
|
+
process.exit(signalExitCode(signal));
|
|
5819
|
+
}
|
|
5820
|
+
process.kill(process.pid, signal);
|
|
5821
|
+
}
|
|
5664
5822
|
var Registry = class {
|
|
5665
5823
|
#config;
|
|
5824
|
+
#buildConfiguredRegistry;
|
|
5666
5825
|
|
|
5667
5826
|
get config() {
|
|
5668
5827
|
return this.#config;
|
|
@@ -5678,8 +5837,9 @@ var Registry = class {
|
|
|
5678
5837
|
#shutdownInstalled = false;
|
|
5679
5838
|
#shutdownInFlight = null;
|
|
5680
5839
|
#signalHandlers = {};
|
|
5681
|
-
constructor(config) {
|
|
5840
|
+
constructor(config, deps) {
|
|
5682
5841
|
this.#config = config;
|
|
5842
|
+
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
5683
5843
|
this.routes = {
|
|
5684
5844
|
health: () => this.#healthRoute(),
|
|
5685
5845
|
metadata: () => this.#metadataRoute(),
|
|
@@ -5715,7 +5875,7 @@ var Registry = class {
|
|
|
5715
5875
|
const config = this.parseConfig();
|
|
5716
5876
|
this.#printWelcome(config, "serverless");
|
|
5717
5877
|
if (!this.#runtimeServerlessPromise) {
|
|
5718
|
-
this.#runtimeServerlessPromise = buildConfiguredRegistry(config);
|
|
5878
|
+
this.#runtimeServerlessPromise = this.#buildConfiguredRegistry(config);
|
|
5719
5879
|
}
|
|
5720
5880
|
const { runtime, registry, serveConfig } = await this.#runtimeServerlessPromise;
|
|
5721
5881
|
const isStartRequest = isServerlessStartRequest(
|
|
@@ -5895,7 +6055,7 @@ var Registry = class {
|
|
|
5895
6055
|
async listen(opts = {}) {
|
|
5896
6056
|
const port = _nullishCoalesce(opts.port, () => ( 3e3));
|
|
5897
6057
|
const config = this.parseConfig();
|
|
5898
|
-
const runtime =
|
|
6058
|
+
const runtime = _chunkEBWOJRCCcjs.detectRuntime.call(void 0, );
|
|
5899
6059
|
const app = new (0, _hono.Hono)();
|
|
5900
6060
|
if (opts.publicDir) {
|
|
5901
6061
|
const serveStatic = await loadRuntimeServeStatic(runtime);
|
|
@@ -5913,7 +6073,7 @@ var Registry = class {
|
|
|
5913
6073
|
return jsonRouteResponse(503, {
|
|
5914
6074
|
status: "not_started",
|
|
5915
6075
|
runtime: "rivetkit",
|
|
5916
|
-
version:
|
|
6076
|
+
version: _chunkEBWOJRCCcjs.VERSION
|
|
5917
6077
|
});
|
|
5918
6078
|
}
|
|
5919
6079
|
const { runtime, registry } = configured;
|
|
@@ -5921,7 +6081,7 @@ var Registry = class {
|
|
|
5921
6081
|
return jsonRouteResponse(501, {
|
|
5922
6082
|
status: "unsupported",
|
|
5923
6083
|
runtime: "rivetkit",
|
|
5924
|
-
version:
|
|
6084
|
+
version: _chunkEBWOJRCCcjs.VERSION
|
|
5925
6085
|
});
|
|
5926
6086
|
}
|
|
5927
6087
|
const response = await runtime.registryHealth(registry);
|
|
@@ -5993,20 +6153,20 @@ var Registry = class {
|
|
|
5993
6153
|
*/
|
|
5994
6154
|
#startEnvoy(config, printWelcome) {
|
|
5995
6155
|
if (!this.#runtimeServePromise) {
|
|
5996
|
-
const configuredRegistryPromise = buildConfiguredRegistry(config);
|
|
6156
|
+
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
5997
6157
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
5998
6158
|
this.#runtimeServePromise = configuredRegistryPromise.then(async ({ runtime, registry, serveConfig }) => {
|
|
5999
6159
|
await runtime.serveRegistry(registry, serveConfig);
|
|
6000
6160
|
}).catch((error) => {
|
|
6001
6161
|
logger2().warn({ error }, "runtime registry serve errored");
|
|
6002
6162
|
});
|
|
6003
|
-
this.#installSignalHandlers(config
|
|
6163
|
+
this.#installSignalHandlers(config);
|
|
6004
6164
|
}
|
|
6005
6165
|
if (printWelcome) {
|
|
6006
6166
|
this.#printWelcome(config, "serverful");
|
|
6007
6167
|
}
|
|
6008
6168
|
}
|
|
6009
|
-
#installSignalHandlers(config
|
|
6169
|
+
#installSignalHandlers(config) {
|
|
6010
6170
|
var _a;
|
|
6011
6171
|
if (this.#shutdownInstalled) return;
|
|
6012
6172
|
if ((_a = config.shutdown) == null ? void 0 : _a.disableSignalHandlers) return;
|
|
@@ -6015,54 +6175,82 @@ var Registry = class {
|
|
|
6015
6175
|
}
|
|
6016
6176
|
this.#shutdownInstalled = true;
|
|
6017
6177
|
const install = (signal) => {
|
|
6018
|
-
const handler = () => this.#onShutdownSignal(
|
|
6019
|
-
signal,
|
|
6020
|
-
config,
|
|
6021
|
-
configuredRegistryPromise
|
|
6022
|
-
);
|
|
6178
|
+
const handler = () => this.#onShutdownSignal(signal, config);
|
|
6023
6179
|
this.#signalHandlers[signal] = handler;
|
|
6024
6180
|
process.on(signal, handler);
|
|
6025
6181
|
};
|
|
6026
6182
|
install("SIGINT");
|
|
6027
6183
|
install("SIGTERM");
|
|
6028
6184
|
}
|
|
6029
|
-
#onShutdownSignal(signal, config
|
|
6185
|
+
#onShutdownSignal(signal, config) {
|
|
6030
6186
|
if (this.#shutdownInFlight !== null) {
|
|
6031
6187
|
this.#removeSignalHandlers();
|
|
6032
|
-
|
|
6188
|
+
finishShutdownSignal(signal);
|
|
6033
6189
|
return;
|
|
6034
6190
|
}
|
|
6035
|
-
this.#shutdownInFlight = this.#
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
logger2().warn({ error }, "shutdown error");
|
|
6191
|
+
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
6192
|
+
logger2().warn({ err }, "shutdown error");
|
|
6193
|
+
}).then(() => {
|
|
6194
|
+
this.#removeSignalHandlers();
|
|
6195
|
+
finishShutdownSignal(signal);
|
|
6041
6196
|
});
|
|
6042
6197
|
}
|
|
6043
|
-
|
|
6198
|
+
/**
|
|
6199
|
+
* Gracefully drains all live registries.
|
|
6200
|
+
*
|
|
6201
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
6202
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
6203
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
6204
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
6205
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
6206
|
+
*
|
|
6207
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
6208
|
+
* call even if nothing has been started.
|
|
6209
|
+
*
|
|
6210
|
+
* @example
|
|
6211
|
+
* ```ts
|
|
6212
|
+
* const registry = setup({ use: { counter } });
|
|
6213
|
+
* registry.start();
|
|
6214
|
+
* // ...later, on your own shutdown trigger:
|
|
6215
|
+
* await registry.shutdown();
|
|
6216
|
+
* ```
|
|
6217
|
+
*/
|
|
6218
|
+
async shutdown() {
|
|
6219
|
+
if (this.#shutdownInFlight !== null) return this.#shutdownInFlight;
|
|
6220
|
+
const config = this.parseConfig();
|
|
6221
|
+
this.#removeSignalHandlers();
|
|
6222
|
+
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
6223
|
+
logger2().warn({ err }, "shutdown error");
|
|
6224
|
+
});
|
|
6225
|
+
return this.#shutdownInFlight;
|
|
6226
|
+
}
|
|
6227
|
+
async #drain(config) {
|
|
6044
6228
|
var _a;
|
|
6045
|
-
const
|
|
6229
|
+
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
6230
|
+
const modeBPromise = this.#runtimeServerlessPromise;
|
|
6231
|
+
const gracePeriodMs = await _asyncNullishCoalesce(await _asyncNullishCoalesce(((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs), async () => ( await this.#actorStopThresholdMs(_nullishCoalesce(modeAPromise, () => ( modeBPromise))))), async () => ( 30 * 60 * 1e3));
|
|
6046
6232
|
const drain = async () => {
|
|
6047
|
-
const registries = [
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6233
|
+
const registries = [];
|
|
6234
|
+
if (modeAPromise !== void 0) {
|
|
6235
|
+
registries.push(
|
|
6236
|
+
(async () => {
|
|
6237
|
+
try {
|
|
6238
|
+
const { runtime, registry } = await modeAPromise;
|
|
6239
|
+
await runtime.shutdownRegistry(registry);
|
|
6240
|
+
} catch (err) {
|
|
6241
|
+
logger2().warn(
|
|
6242
|
+
{ err },
|
|
6243
|
+
"runtime registry shutdown errored (mode A)"
|
|
6244
|
+
);
|
|
6245
|
+
}
|
|
6246
|
+
})()
|
|
6247
|
+
);
|
|
6248
|
+
}
|
|
6249
|
+
if (modeBPromise !== void 0) {
|
|
6062
6250
|
registries.push(
|
|
6063
6251
|
(async () => {
|
|
6064
6252
|
try {
|
|
6065
|
-
const { runtime, registry } = await
|
|
6253
|
+
const { runtime, registry } = await modeBPromise;
|
|
6066
6254
|
await runtime.shutdownRegistry(registry);
|
|
6067
6255
|
} catch (err) {
|
|
6068
6256
|
logger2().warn(
|
|
@@ -6088,8 +6276,23 @@ var Registry = class {
|
|
|
6088
6276
|
}
|
|
6089
6277
|
)
|
|
6090
6278
|
]);
|
|
6091
|
-
|
|
6092
|
-
|
|
6279
|
+
}
|
|
6280
|
+
async #actorStopThresholdMs(configuredRegistryPromise) {
|
|
6281
|
+
var _a;
|
|
6282
|
+
if (configuredRegistryPromise === void 0) return void 0;
|
|
6283
|
+
try {
|
|
6284
|
+
const { runtime, registry } = await configuredRegistryPromise;
|
|
6285
|
+
const thresholdMs = await ((_a = runtime.registryActorStopThresholdMs) == null ? void 0 : _a.call(runtime, registry));
|
|
6286
|
+
if (thresholdMs !== void 0 && Number.isFinite(thresholdMs) && thresholdMs > 0) {
|
|
6287
|
+
return thresholdMs;
|
|
6288
|
+
}
|
|
6289
|
+
} catch (err) {
|
|
6290
|
+
logger2().warn(
|
|
6291
|
+
{ err },
|
|
6292
|
+
"failed to read actor stop threshold for shutdown grace"
|
|
6293
|
+
);
|
|
6294
|
+
}
|
|
6295
|
+
return void 0;
|
|
6093
6296
|
}
|
|
6094
6297
|
#removeSignalHandlers() {
|
|
6095
6298
|
for (const [signal, handler] of Object.entries(
|
|
@@ -6124,13 +6327,13 @@ var Registry = class {
|
|
|
6124
6327
|
};
|
|
6125
6328
|
console.log();
|
|
6126
6329
|
console.log(
|
|
6127
|
-
` RivetKit ${
|
|
6330
|
+
` RivetKit ${_chunkEBWOJRCCcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
6128
6331
|
);
|
|
6129
6332
|
if (config.namespace !== "default") {
|
|
6130
6333
|
logLine("Namespace", config.namespace);
|
|
6131
6334
|
}
|
|
6132
6335
|
if (config.endpoint) {
|
|
6133
|
-
const endpointType = config.
|
|
6336
|
+
const endpointType = config.startEngine || isLocalEngineEndpoint(config.endpoint) ? "local native" : "remote";
|
|
6134
6337
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
6135
6338
|
}
|
|
6136
6339
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -6192,5 +6395,5 @@ function setup(input) {
|
|
|
6192
6395
|
|
|
6193
6396
|
|
|
6194
6397
|
|
|
6195
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
6398
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunkE5CLYAUZcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkKORQB2IRcjs.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 = _chunkKORQB2IRcjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkKORQB2IRcjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkE5CLYAUZcjs.createClientWithDriver; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkEBWOJRCCcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkEBWOJRCCcjs.toUint8Array;
|
|
6196
6399
|
//# sourceMappingURL=mod.cjs.map
|