rivetkit 2.3.12-rc.4 → 2.3.12
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 +17 -4
- package/dist/browser/client.js +32 -24
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +2 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +3 -19
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +17 -4
- package/dist/tsup/agent-os/index.d.ts +17 -4
- package/dist/tsup/agent-os/index.js +3 -19
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-SPJORZMM.cjs → chunk-2JSYYH6P.cjs} +1 -1
- package/dist/tsup/chunk-2JSYYH6P.cjs.map +1 -0
- package/dist/tsup/{chunk-IAH47VDZ.cjs → chunk-4KGXFC6M.cjs} +2 -19
- package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
- package/dist/tsup/{chunk-DLQSZ6Q7.js → chunk-6W5VGLFT.js} +2 -19
- package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
- package/dist/tsup/{chunk-JIOLC5I2.cjs → chunk-AN7WO7BM.cjs} +3 -3
- package/dist/tsup/{chunk-JIOLC5I2.cjs.map → chunk-AN7WO7BM.cjs.map} +1 -1
- package/dist/tsup/{chunk-AF2VKCFA.js → chunk-EBXARMGI.js} +2 -2
- package/dist/tsup/{chunk-4LRWLBTR.cjs → chunk-FGQABMXZ.cjs} +3 -3
- package/dist/tsup/{chunk-4LRWLBTR.cjs.map → chunk-FGQABMXZ.cjs.map} +1 -1
- package/dist/tsup/{chunk-BQ7YJ3PG.js → chunk-GEN4NHXM.js} +2 -2
- package/dist/tsup/{chunk-NVMHEG5J.js → chunk-JYTXOMM7.js} +2 -2
- package/dist/tsup/{chunk-NKLM6C5A.cjs → chunk-MEF7RVQ7.cjs} +10 -10
- package/dist/tsup/{chunk-NKLM6C5A.cjs.map → chunk-MEF7RVQ7.cjs.map} +1 -1
- package/dist/tsup/{chunk-64DT44V2.js → chunk-MF42PRF2.js} +9 -3
- package/dist/tsup/chunk-MF42PRF2.js.map +1 -0
- package/dist/tsup/{chunk-IXBD7BXC.js → chunk-OUQUIBVW.js} +1 -1
- package/dist/tsup/chunk-OUQUIBVW.js.map +1 -0
- package/dist/tsup/{chunk-S3GXVCIM.cjs → chunk-PW2VSGUR.cjs} +4 -4
- package/dist/tsup/{chunk-S3GXVCIM.cjs.map → chunk-PW2VSGUR.cjs.map} +1 -1
- package/dist/tsup/{chunk-GMBCKV6C.js → chunk-RBXJWAJB.js} +3 -3
- package/dist/tsup/{chunk-XDYECGCT.cjs → chunk-SSPTEGTX.cjs} +7 -7
- package/dist/tsup/{chunk-XDYECGCT.cjs.map → chunk-SSPTEGTX.cjs.map} +1 -1
- package/dist/tsup/{chunk-ARFTQ5HY.cjs → chunk-TAG6UEL5.cjs} +17 -11
- package/dist/tsup/chunk-TAG6UEL5.cjs.map +1 -0
- package/dist/tsup/{chunk-OCXHNHGQ.cjs → chunk-TXUHVBKH.cjs} +3 -3
- package/dist/tsup/{chunk-OCXHNHGQ.cjs.map → chunk-TXUHVBKH.cjs.map} +1 -1
- package/dist/tsup/{chunk-F7G5WHOD.cjs → chunk-TZPNSOG2.cjs} +203 -195
- package/dist/tsup/chunk-TZPNSOG2.cjs.map +1 -0
- package/dist/tsup/{chunk-O74736N5.js → chunk-VOYNLY57.js} +41 -33
- package/dist/tsup/chunk-VOYNLY57.js.map +1 -0
- package/dist/tsup/{chunk-3CBQIP37.js → chunk-XUODFCRJ.js} +4 -4
- package/dist/tsup/{chunk-P5JJG4KY.js → chunk-ZIPXAVKR.js} +2 -2
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-DzaddF-j.d.ts → config-BGTanB_3.d.ts} +19 -10
- package/dist/tsup/{config-VxDc6yMu.d.cts → config-NHz6oMb9.d.cts} +19 -10
- package/dist/tsup/{context-Cn8CIrOR.d.cts → context-DB8zG_Ib.d.cts} +1 -1
- package/dist/tsup/{context-B6HYokje.d.ts → context-SHomdVV8.d.ts} +1 -1
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.js +2 -2
- package/dist/tsup/db/mod.cjs +4 -4
- package/dist/tsup/db/mod.js +3 -3
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector/workflow.cjs +5 -5
- package/dist/tsup/inspector/workflow.js +4 -4
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +444 -199
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +323 -78
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +14 -14
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +6 -6
- package/package.json +9 -8
- package/src/actor/config.test.ts +0 -8
- package/src/actor/config.ts +1 -24
- package/src/actor/errors.ts +2 -1
- package/src/client/actor-handle.ts +10 -3
- package/src/client/raw-utils.ts +8 -0
- package/src/common/actor-router-consts.ts +2 -0
- package/src/engine-client/actor-http-client.ts +6 -22
- package/src/engine-client/mod.ts +1 -1
- package/src/registry/config/index.ts +27 -1
- package/src/registry/index.ts +48 -14
- package/src/registry/napi-runtime.ts +32 -5
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native.ts +130 -65
- package/src/registry/runtime.ts +30 -3
- package/src/utils/env-vars.ts +4 -0
- package/dist/tsup/chunk-64DT44V2.js.map +0 -1
- package/dist/tsup/chunk-ARFTQ5HY.cjs.map +0 -1
- package/dist/tsup/chunk-DLQSZ6Q7.js.map +0 -1
- package/dist/tsup/chunk-F7G5WHOD.cjs.map +0 -1
- package/dist/tsup/chunk-IAH47VDZ.cjs.map +0 -1
- package/dist/tsup/chunk-IXBD7BXC.js.map +0 -1
- package/dist/tsup/chunk-O74736N5.js.map +0 -1
- package/dist/tsup/chunk-SPJORZMM.cjs.map +0 -1
- /package/dist/tsup/{chunk-AF2VKCFA.js.map → chunk-EBXARMGI.js.map} +0 -0
- /package/dist/tsup/{chunk-BQ7YJ3PG.js.map → chunk-GEN4NHXM.js.map} +0 -0
- /package/dist/tsup/{chunk-NVMHEG5J.js.map → chunk-JYTXOMM7.js.map} +0 -0
- /package/dist/tsup/{chunk-GMBCKV6C.js.map → chunk-RBXJWAJB.js.map} +0 -0
- /package/dist/tsup/{chunk-3CBQIP37.js.map → chunk-XUODFCRJ.js.map} +0 -0
- /package/dist/tsup/{chunk-P5JJG4KY.js.map → chunk-ZIPXAVKR.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkPW2VSGURcjs = require('./chunk-PW2VSGUR.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ var _chunkS3GXVCIMcjs = require('./chunk-S3GXVCIM.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk4KGXFC6Mcjs = require('./chunk-4KGXFC6M.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -27,18 +27,19 @@ var _chunkIAH47VDZcjs = require('./chunk-IAH47VDZ.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
var _chunkTZPNSOG2cjs = require('./chunk-TZPNSOG2.cjs');
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
var _chunkMYWZCDMLcjs = require('./chunk-MYWZCDML.cjs');
|
|
36
|
+
require('./chunk-TXUHVBKH.cjs');
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
|
|
39
|
-
var
|
|
41
|
+
var _chunkFGQABMXZcjs = require('./chunk-FGQABMXZ.cjs');
|
|
40
42
|
require('./chunk-KVFIONKQ.cjs');
|
|
41
|
-
require('./chunk-OCXHNHGQ.cjs');
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
|
|
@@ -71,7 +72,8 @@ require('./chunk-OCXHNHGQ.cjs');
|
|
|
71
72
|
|
|
72
73
|
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
|
|
76
|
+
var _chunkTAG6UEL5cjs = require('./chunk-TAG6UEL5.cjs');
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
|
|
@@ -83,11 +85,11 @@ var _chunkARFTQ5HYcjs = require('./chunk-ARFTQ5HY.cjs');
|
|
|
83
85
|
|
|
84
86
|
|
|
85
87
|
|
|
86
|
-
var
|
|
88
|
+
var _chunk2JSYYH6Pcjs = require('./chunk-2JSYYH6P.cjs');
|
|
87
89
|
|
|
88
90
|
// src/actor/log.ts
|
|
89
91
|
function loggerWithoutContext() {
|
|
90
|
-
return
|
|
92
|
+
return _chunkTAG6UEL5cjs.getLogger.call(void 0, "actor-runtime");
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
// src/actor/definition.ts
|
|
@@ -126,9 +128,9 @@ function actor(input) {
|
|
|
126
128
|
warnDeprecatedOptionKeys(
|
|
127
129
|
input == null ? void 0 : input.options
|
|
128
130
|
);
|
|
129
|
-
const config =
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
const config = _chunk4KGXFC6Mcjs.ActorConfigSchema.parse(input);
|
|
132
|
+
_chunk4KGXFC6Mcjs.flattenActionHandlers.call(void 0, config.actions);
|
|
133
|
+
_chunk4KGXFC6Mcjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
|
|
132
134
|
return new ActorDefinition(config);
|
|
133
135
|
}
|
|
134
136
|
function isStaticActorDefinition(definition) {
|
|
@@ -210,7 +212,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
210
212
|
if (isStandardSchema(schema)) {
|
|
211
213
|
const result = schema["~standard"].validate(data);
|
|
212
214
|
if (isPromiseLike(result)) {
|
|
213
|
-
throw
|
|
215
|
+
throw _chunk2JSYYH6Pcjs.unsupportedFeature.call(void 0, "async schema validation");
|
|
214
216
|
}
|
|
215
217
|
if (result.issues) {
|
|
216
218
|
return { success: false, issues: [...result.issues] };
|
|
@@ -227,7 +229,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
227
229
|
var _virtualwebsocket = require('@rivetkit/virtual-websocket');
|
|
228
230
|
var _ws = require('hono/ws');
|
|
229
231
|
function logger() {
|
|
230
|
-
return
|
|
232
|
+
return _chunkTAG6UEL5cjs.getLogger.call(void 0, "inline-websocket-adapter");
|
|
231
233
|
}
|
|
232
234
|
var InlineWebSocketAdapter = class {
|
|
233
235
|
#handler;
|
|
@@ -398,7 +400,7 @@ function isLocalEngineEndpoint(endpoint) {
|
|
|
398
400
|
|
|
399
401
|
// src/registry/log.ts
|
|
400
402
|
function logger2() {
|
|
401
|
-
return
|
|
403
|
+
return _chunkTAG6UEL5cjs.getLogger.call(void 0, "registry");
|
|
402
404
|
}
|
|
403
405
|
|
|
404
406
|
// src/serverless/configure.ts
|
|
@@ -444,8 +446,8 @@ async function configureServerlessPool(config) {
|
|
|
444
446
|
);
|
|
445
447
|
}
|
|
446
448
|
const customConfig = config.configurePool;
|
|
447
|
-
const clientConfig =
|
|
448
|
-
const dcsRes = await
|
|
449
|
+
const clientConfig = _chunkTZPNSOG2cjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
450
|
+
const dcsRes = await _chunkTZPNSOG2cjs.getDatacenters.call(void 0, clientConfig);
|
|
449
451
|
const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
|
|
450
452
|
const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
|
|
451
453
|
const headers = {
|
|
@@ -467,7 +469,7 @@ async function configureServerlessPool(config) {
|
|
|
467
469
|
metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
|
|
468
470
|
drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
|
|
469
471
|
};
|
|
470
|
-
await
|
|
472
|
+
await _chunkTZPNSOG2cjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
|
|
471
473
|
datacenters: Object.fromEntries(
|
|
472
474
|
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
473
475
|
)
|
|
@@ -484,7 +486,7 @@ async function configureServerlessPool(config) {
|
|
|
484
486
|
logger2().warn({
|
|
485
487
|
msg: "serverless pool configuration attempt failed",
|
|
486
488
|
attempts,
|
|
487
|
-
error:
|
|
489
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, error)
|
|
488
490
|
});
|
|
489
491
|
await sleep(CONFIGURE_RETRY_DELAY_MS);
|
|
490
492
|
}
|
|
@@ -492,7 +494,7 @@ async function configureServerlessPool(config) {
|
|
|
492
494
|
logger2().error({
|
|
493
495
|
msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
|
|
494
496
|
attempts,
|
|
495
|
-
error:
|
|
497
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, lastError)
|
|
496
498
|
});
|
|
497
499
|
throw lastError;
|
|
498
500
|
}
|
|
@@ -504,20 +506,20 @@ var _zod = require('zod');
|
|
|
504
506
|
var _v4 = require('zod/v4');
|
|
505
507
|
var warnedMissingVersion = false;
|
|
506
508
|
var EnvoyConfigSchema = _v4.z.object({
|
|
507
|
-
poolName: _v4.z.string().default(() => _nullishCoalesce(
|
|
509
|
+
poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
508
510
|
version: _v4.z.number().default(() => {
|
|
509
|
-
const version =
|
|
511
|
+
const version = _chunkTAG6UEL5cjs.getRivetEnvoyVersion.call(void 0, );
|
|
510
512
|
if (version !== void 0) return version;
|
|
511
|
-
if (
|
|
513
|
+
if (_chunkTAG6UEL5cjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
|
|
512
514
|
warnedMissingVersion = true;
|
|
513
|
-
|
|
515
|
+
_chunkTAG6UEL5cjs.getLogger.call(void 0, "rivetkit").error(
|
|
514
516
|
"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"
|
|
515
517
|
);
|
|
516
518
|
}
|
|
517
519
|
return 1;
|
|
518
520
|
}),
|
|
519
521
|
// Deprecated.
|
|
520
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
522
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
|
|
521
523
|
envoyKey: _v4.z.string().optional()
|
|
522
524
|
});
|
|
523
525
|
|
|
@@ -555,7 +557,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
555
557
|
*
|
|
556
558
|
* Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
|
|
557
559
|
*/
|
|
558
|
-
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
560
|
+
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetPublicEndpoint.call(void 0, )))),
|
|
559
561
|
/**
|
|
560
562
|
* Token that clients should use when connecting via the public endpoint.
|
|
561
563
|
*
|
|
@@ -563,7 +565,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
563
565
|
*
|
|
564
566
|
* Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
|
|
565
567
|
*/
|
|
566
|
-
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
568
|
+
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetPublicToken.call(void 0, ))))
|
|
567
569
|
// There is no publicNamespace config option because the frontend and backend
|
|
568
570
|
// cannot use different namespaces. The namespace is extracted from the
|
|
569
571
|
// publicEndpoint URL auth syntax if provided.
|
|
@@ -617,7 +619,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
617
619
|
* Runtime binding to use for RivetKit core.
|
|
618
620
|
* */
|
|
619
621
|
runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
|
|
620
|
-
const rawRuntime = _nullishCoalesce(val, () => (
|
|
622
|
+
const rawRuntime = _nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetkitRuntime.call(void 0, )));
|
|
621
623
|
if (rawRuntime === void 0) {
|
|
622
624
|
return "auto";
|
|
623
625
|
}
|
|
@@ -654,7 +656,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
654
656
|
* */
|
|
655
657
|
logging: _zod.z.object({
|
|
656
658
|
baseLogger: _zod.z.custom().optional(),
|
|
657
|
-
level:
|
|
659
|
+
level: _chunkTAG6UEL5cjs.LogLevelSchema.optional()
|
|
658
660
|
}).optional().default(() => ({})),
|
|
659
661
|
// MARK: Routing
|
|
660
662
|
// // This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
@@ -672,9 +674,9 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
672
674
|
*
|
|
673
675
|
* Can also be set via RIVET_ENDPOINT environment variables.
|
|
674
676
|
*/
|
|
675
|
-
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
676
|
-
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
677
|
-
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
677
|
+
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetEngine.call(void 0, ))), () => ( _chunkTAG6UEL5cjs.getRivetEndpoint.call(void 0, )))),
|
|
678
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetToken.call(void 0, )))),
|
|
679
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTAG6UEL5cjs.getRivetNamespace.call(void 0, )))),
|
|
678
680
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
|
|
679
681
|
// MARK: Client
|
|
680
682
|
// TODO:
|
|
@@ -714,21 +716,27 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
714
716
|
*
|
|
715
717
|
* Starts the full Rust engine process locally.
|
|
716
718
|
*/
|
|
717
|
-
startEngine: _zod.z.boolean().default(() =>
|
|
719
|
+
startEngine: _zod.z.boolean().default(() => _chunkTAG6UEL5cjs.getRivetRunEngine.call(void 0, )),
|
|
718
720
|
/**
|
|
719
721
|
* @experimental
|
|
720
722
|
*
|
|
721
723
|
* Host to bind the spawned local engine process to.
|
|
722
724
|
*/
|
|
723
|
-
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
725
|
+
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetRunEngineHost.call(void 0, ), () => ( ENGINE_HOST))),
|
|
724
726
|
/**
|
|
725
727
|
* @experimental
|
|
726
728
|
*
|
|
727
729
|
* Port to bind the spawned local engine process to.
|
|
728
730
|
*/
|
|
729
|
-
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(
|
|
731
|
+
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetRunEnginePort.call(void 0, ), () => ( ENGINE_PORT))),
|
|
730
732
|
/** @experimental */
|
|
731
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
733
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkTAG6UEL5cjs.VERSION))),
|
|
734
|
+
/**
|
|
735
|
+
* Starts the first-party Services actor host when RivetKit manages
|
|
736
|
+
* a local engine. Defaults to the local-engine decision. Set
|
|
737
|
+
* RIVET_RUN_SERVICES=0 or 1 to override it.
|
|
738
|
+
*/
|
|
739
|
+
startServices: _zod.z.boolean().optional(),
|
|
732
740
|
/**
|
|
733
741
|
* @experimental
|
|
734
742
|
*
|
|
@@ -776,7 +784,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
776
784
|
}))
|
|
777
785
|
}).transform((config, ctx) => {
|
|
778
786
|
var _a, _b, _c;
|
|
779
|
-
const isDevEnv =
|
|
787
|
+
const isDevEnv = _chunkTAG6UEL5cjs.isDev.call(void 0, );
|
|
780
788
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
781
789
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
782
790
|
ctx.addIssue({
|
|
@@ -786,7 +794,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
786
794
|
});
|
|
787
795
|
}
|
|
788
796
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
789
|
-
const parsedEndpoint = config.endpoint ?
|
|
797
|
+
const parsedEndpoint = config.endpoint ? _chunkTZPNSOG2cjs.tryParseEndpoint.call(void 0, ctx, {
|
|
790
798
|
endpoint: config.endpoint,
|
|
791
799
|
path: ["endpoint"],
|
|
792
800
|
namespace: config.namespace,
|
|
@@ -809,12 +817,13 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
809
817
|
config.enginePort
|
|
810
818
|
);
|
|
811
819
|
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
|
|
820
|
+
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkTAG6UEL5cjs.getRivetRunServices.call(void 0, ))), () => ( Boolean(endpoint && isLocalEngineEndpoint(endpoint))));
|
|
812
821
|
const validateServerlessEndpoint = Boolean(
|
|
813
822
|
config.startEngine || parsedEndpoint
|
|
814
823
|
);
|
|
815
824
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
816
825
|
const token = _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token));
|
|
817
|
-
const parsedPublicEndpoint = config.serverless.publicEndpoint ?
|
|
826
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkTZPNSOG2cjs.tryParseEndpoint.call(void 0, ctx, {
|
|
818
827
|
endpoint: config.serverless.publicEndpoint,
|
|
819
828
|
path: ["serverless", "publicEndpoint"]
|
|
820
829
|
}) : void 0;
|
|
@@ -832,6 +841,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
832
841
|
...config,
|
|
833
842
|
sqlite,
|
|
834
843
|
endpoint,
|
|
844
|
+
startServices,
|
|
835
845
|
namespace,
|
|
836
846
|
token,
|
|
837
847
|
publicEndpoint,
|
|
@@ -849,7 +859,7 @@ function buildActorNames(config) {
|
|
|
849
859
|
Object.keys(config.use).map((actorName) => {
|
|
850
860
|
const definition = config.use[actorName];
|
|
851
861
|
const options = _nullishCoalesce(definition.config.options, () => ( {}));
|
|
852
|
-
const runMeta =
|
|
862
|
+
const runMeta = _chunk4KGXFC6Mcjs.getRunMetadata.call(void 0, definition.config.run);
|
|
853
863
|
const metadata = {};
|
|
854
864
|
metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
|
|
855
865
|
metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
|
|
@@ -917,7 +927,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
917
927
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
918
928
|
sqlite: DocSqliteConfigSchema,
|
|
919
929
|
logging: _zod.z.object({
|
|
920
|
-
level:
|
|
930
|
+
level: _chunkTAG6UEL5cjs.LogLevelSchema.optional().describe(
|
|
921
931
|
"Log level for RivetKit. Default: 'warn'"
|
|
922
932
|
)
|
|
923
933
|
}).optional().describe("Logging configuration."),
|
|
@@ -945,6 +955,9 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
945
955
|
engineVersion: _zod.z.string().optional().describe(
|
|
946
956
|
"Version of the local engine package to use. Defaults to the current RivetKit version."
|
|
947
957
|
),
|
|
958
|
+
startServices: _zod.z.boolean().optional().describe(
|
|
959
|
+
"Starts Services when RivetKit manages a local Engine. Defaults to the local-Engine decision. Set RIVET_RUN_SERVICES=0 or 1 to override."
|
|
960
|
+
),
|
|
948
961
|
configurePool: DocConfigurePoolSchema.describe(
|
|
949
962
|
"Automatically configure serverless runners in the engine."
|
|
950
963
|
),
|
|
@@ -962,7 +975,7 @@ function shouldAttachNativeKvError(message) {
|
|
|
962
975
|
function enrichNativeDatabaseError(database, error) {
|
|
963
976
|
var _a;
|
|
964
977
|
const bridgeReason = typeof error === "string" ? error : error instanceof Error ? error.message : void 0;
|
|
965
|
-
const bridged = bridgeReason === void 0 ? void 0 :
|
|
978
|
+
const bridged = bridgeReason === void 0 ? void 0 : _chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, bridgeReason);
|
|
966
979
|
if (bridged) {
|
|
967
980
|
throw bridged;
|
|
968
981
|
}
|
|
@@ -1466,16 +1479,30 @@ function toNapiApplication(application) {
|
|
|
1466
1479
|
if (!request) {
|
|
1467
1480
|
throw new Error("application fetch callback received no request");
|
|
1468
1481
|
}
|
|
1469
|
-
const response = await application(
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1482
|
+
const response = await application(
|
|
1483
|
+
{
|
|
1484
|
+
...request,
|
|
1485
|
+
body: new Uint8Array(request.body),
|
|
1486
|
+
cancelToken: request.cancelToken
|
|
1487
|
+
},
|
|
1488
|
+
request.responseBodyStream ? fromNapiHttpResponseBodyStream(
|
|
1489
|
+
request.responseBodyStream
|
|
1490
|
+
) : void 0
|
|
1491
|
+
);
|
|
1473
1492
|
return {
|
|
1474
1493
|
...response,
|
|
1475
|
-
body: toNapiBuffer(response.body)
|
|
1494
|
+
body: response.body === void 0 ? void 0 : toNapiBuffer(response.body)
|
|
1476
1495
|
};
|
|
1477
1496
|
};
|
|
1478
1497
|
}
|
|
1498
|
+
function fromNapiHttpResponseBodyStream(stream) {
|
|
1499
|
+
return {
|
|
1500
|
+
cancelled: () => stream.cancelled(),
|
|
1501
|
+
write: (chunk) => stream.write(Buffer.from(chunk)),
|
|
1502
|
+
end: () => stream.end(),
|
|
1503
|
+
error: (message) => stream.error(message)
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1479
1506
|
function toNapiHttpRequest(request) {
|
|
1480
1507
|
if (!request) {
|
|
1481
1508
|
return request;
|
|
@@ -2019,6 +2046,149 @@ async function loadNapiRuntime() {
|
|
|
2019
2046
|
};
|
|
2020
2047
|
}
|
|
2021
2048
|
|
|
2049
|
+
// src/registry/native-http.ts
|
|
2050
|
+
var HTTP_BODY_CHUNK_SIZE = 64 * 1024;
|
|
2051
|
+
function runtimeBytesToArrayBuffer(value) {
|
|
2052
|
+
return value.buffer.slice(
|
|
2053
|
+
value.byteOffset,
|
|
2054
|
+
value.byteOffset + value.byteLength
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
function buildNativeHttpRequest(init) {
|
|
2058
|
+
var _a;
|
|
2059
|
+
const headers = new Headers(init.headers);
|
|
2060
|
+
const originalUrl = headers.get(_chunkTZPNSOG2cjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2061
|
+
headers.delete(_chunkTZPNSOG2cjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2062
|
+
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2063
|
+
const method2 = init.method.toUpperCase();
|
|
2064
|
+
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
2065
|
+
const body = bodyForbidden ? void 0 : init.bodyStream ? new ReadableStream({
|
|
2066
|
+
async pull(controller) {
|
|
2067
|
+
var _a2, _b;
|
|
2068
|
+
try {
|
|
2069
|
+
if (init.body && init.body.length > 0) {
|
|
2070
|
+
controller.enqueue(new Uint8Array(init.body));
|
|
2071
|
+
init.body = void 0;
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
const chunk = await ((_a2 = init.bodyStream) == null ? void 0 : _a2.read());
|
|
2075
|
+
if (!chunk) {
|
|
2076
|
+
controller.close();
|
|
2077
|
+
} else {
|
|
2078
|
+
controller.enqueue(new Uint8Array(chunk));
|
|
2079
|
+
}
|
|
2080
|
+
} catch (error) {
|
|
2081
|
+
(_b = init.abortController) == null ? void 0 : _b.abort(error);
|
|
2082
|
+
controller.error(error);
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
async cancel() {
|
|
2086
|
+
var _a2;
|
|
2087
|
+
await ((_a2 = init.bodyStream) == null ? void 0 : _a2.cancel());
|
|
2088
|
+
}
|
|
2089
|
+
}) : init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
|
|
2090
|
+
const streamInit = init.bodyStream && !bodyForbidden ? { duplex: "half" } : {};
|
|
2091
|
+
return new Request(url, {
|
|
2092
|
+
method: method2,
|
|
2093
|
+
headers,
|
|
2094
|
+
body,
|
|
2095
|
+
signal: _nullishCoalesce(((_a = init.abortController) == null ? void 0 : _a.signal), () => ( init.signal)),
|
|
2096
|
+
...streamInit
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
async function cancelNativeHttpRequestBody(bodyStream) {
|
|
2100
|
+
await (bodyStream == null ? void 0 : bodyStream.cancel());
|
|
2101
|
+
}
|
|
2102
|
+
async function writeResponseChunk(stream, chunk) {
|
|
2103
|
+
for (let offset = 0; offset < chunk.byteLength; offset += HTTP_BODY_CHUNK_SIZE) {
|
|
2104
|
+
await stream.write(
|
|
2105
|
+
chunk.subarray(offset, offset + HTTP_BODY_CHUNK_SIZE)
|
|
2106
|
+
);
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
async function pumpResponseBody(reader, stream) {
|
|
2110
|
+
var _a;
|
|
2111
|
+
const cancelled = stream.cancelled().then(() => ({ cancelled: true }));
|
|
2112
|
+
try {
|
|
2113
|
+
for (; ; ) {
|
|
2114
|
+
const read = reader.read().then((next2) => ({ cancelled: false, next: next2 }));
|
|
2115
|
+
const result = await Promise.race([read, cancelled]);
|
|
2116
|
+
if (result.cancelled) {
|
|
2117
|
+
void reader.cancel(
|
|
2118
|
+
new Error(
|
|
2119
|
+
"native http response stream receiver dropped"
|
|
2120
|
+
)
|
|
2121
|
+
).catch((error) => {
|
|
2122
|
+
logger2().debug({
|
|
2123
|
+
msg: "failed to cancel native http response reader",
|
|
2124
|
+
error
|
|
2125
|
+
});
|
|
2126
|
+
});
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
const { next } = result;
|
|
2130
|
+
if (next.done) {
|
|
2131
|
+
await stream.end();
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
if ((_a = next.value) == null ? void 0 : _a.byteLength) {
|
|
2135
|
+
await writeResponseChunk(stream, next.value);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
} catch (error) {
|
|
2139
|
+
try {
|
|
2140
|
+
await stream.error(_chunkTAG6UEL5cjs.stringifyError.call(void 0, error));
|
|
2141
|
+
} catch (streamError) {
|
|
2142
|
+
logger2().debug({
|
|
2143
|
+
msg: "failed to report native http response stream error",
|
|
2144
|
+
error: streamError
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
void reader.cancel(error).catch(() => {
|
|
2148
|
+
});
|
|
2149
|
+
} finally {
|
|
2150
|
+
try {
|
|
2151
|
+
reader.releaseLock();
|
|
2152
|
+
} catch (error) {
|
|
2153
|
+
logger2().debug({
|
|
2154
|
+
msg: "failed to release native http response reader lock",
|
|
2155
|
+
error
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
async function convertNativeHttpResponse(response, responseBodyStream) {
|
|
2161
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
2162
|
+
if (!response.body) {
|
|
2163
|
+
return {
|
|
2164
|
+
response: {
|
|
2165
|
+
status: response.status,
|
|
2166
|
+
headers,
|
|
2167
|
+
body: new Uint8Array()
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
if (responseBodyStream) {
|
|
2172
|
+
const reader = response.body.getReader();
|
|
2173
|
+
const bodyCompletion = pumpResponseBody(reader, responseBodyStream);
|
|
2174
|
+
return {
|
|
2175
|
+
response: {
|
|
2176
|
+
status: response.status,
|
|
2177
|
+
headers,
|
|
2178
|
+
stream: true
|
|
2179
|
+
},
|
|
2180
|
+
bodyCompletion
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
return {
|
|
2184
|
+
response: {
|
|
2185
|
+
status: response.status,
|
|
2186
|
+
headers,
|
|
2187
|
+
body: new Uint8Array(await response.arrayBuffer())
|
|
2188
|
+
}
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2022
2192
|
// src/registry/native-validation.ts
|
|
2023
2193
|
var CONN_PARAMS_KEY = "__conn_params__";
|
|
2024
2194
|
function validateActionArgs(schemas, name, args) {
|
|
@@ -2097,7 +2267,7 @@ function validateQueueComplete(schemas, name, response) {
|
|
|
2097
2267
|
return result.data;
|
|
2098
2268
|
}
|
|
2099
2269
|
function validationError(target, issues) {
|
|
2100
|
-
return new (0,
|
|
2270
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)("actor", "validation_error", `Invalid ${target}`, {
|
|
2101
2271
|
public: true,
|
|
2102
2272
|
metadata: { issues }
|
|
2103
2273
|
});
|
|
@@ -2105,7 +2275,7 @@ function validationError(target, issues) {
|
|
|
2105
2275
|
|
|
2106
2276
|
// src/registry/run-handler-coordinator.ts
|
|
2107
2277
|
function runUnavailable(actorId, reason) {
|
|
2108
|
-
return new (0,
|
|
2278
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
2109
2279
|
"actor",
|
|
2110
2280
|
"run_handler_unavailable",
|
|
2111
2281
|
`Run handler control is unavailable for actor ${actorId}: ${reason}.`,
|
|
@@ -2135,7 +2305,7 @@ var RunHandlerCoordinator = class {
|
|
|
2135
2305
|
this.#run = run;
|
|
2136
2306
|
}
|
|
2137
2307
|
get inspectorKind() {
|
|
2138
|
-
return
|
|
2308
|
+
return _chunk4KGXFC6Mcjs.getRunInspectorKind.call(void 0, this.#run);
|
|
2139
2309
|
}
|
|
2140
2310
|
async run(actorId, restart, callback) {
|
|
2141
2311
|
const state = this.#getOrCreate(actorId);
|
|
@@ -2243,7 +2413,7 @@ var RunHandlerCoordinator = class {
|
|
|
2243
2413
|
}
|
|
2244
2414
|
#initializeInspector(actorId, state) {
|
|
2245
2415
|
if (state.inspectorInitialized) return;
|
|
2246
|
-
const inspector =
|
|
2416
|
+
const inspector = _chunk4KGXFC6Mcjs.createRunInspector.call(void 0, this.#run, {
|
|
2247
2417
|
actorId,
|
|
2248
2418
|
control: this.#control(actorId, state)
|
|
2249
2419
|
});
|
|
@@ -2326,16 +2496,16 @@ function normalizeQueueMessage(message) {
|
|
|
2326
2496
|
}
|
|
2327
2497
|
function normalizeWasmBridgeError(error) {
|
|
2328
2498
|
if (typeof error === "string") {
|
|
2329
|
-
return _nullishCoalesce(
|
|
2499
|
+
return _nullishCoalesce(_chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
|
|
2330
2500
|
}
|
|
2331
2501
|
if (error instanceof Error) {
|
|
2332
|
-
const bridged =
|
|
2502
|
+
const bridged = _chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error.message);
|
|
2333
2503
|
if (bridged) {
|
|
2334
2504
|
return bridged;
|
|
2335
2505
|
}
|
|
2336
2506
|
}
|
|
2337
2507
|
if (typeof error === "object" && error !== null && "reason" in error && typeof error.reason === "string") {
|
|
2338
|
-
const bridged =
|
|
2508
|
+
const bridged = _chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error.reason);
|
|
2339
2509
|
if (bridged) {
|
|
2340
2510
|
return bridged;
|
|
2341
2511
|
}
|
|
@@ -2357,7 +2527,7 @@ function callWasmSync(invoke) {
|
|
|
2357
2527
|
}
|
|
2358
2528
|
}
|
|
2359
2529
|
function unsupportedWasmMethod(method2) {
|
|
2360
|
-
throw new (0,
|
|
2530
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
2361
2531
|
"runtime",
|
|
2362
2532
|
"unsupported",
|
|
2363
2533
|
`Unsupported wasm runtime method: ${method2}`,
|
|
@@ -2792,7 +2962,7 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2792
2962
|
await callWasm(() => database.close());
|
|
2793
2963
|
}
|
|
2794
2964
|
async actorRuntimeSocketProvision(_ctx) {
|
|
2795
|
-
throw new (0,
|
|
2965
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
2796
2966
|
"actor_runtime_socket",
|
|
2797
2967
|
"unsupported",
|
|
2798
2968
|
"Actor Runtime Socket is only available on Unix native runtimes.",
|
|
@@ -3161,7 +3331,7 @@ function loadedRuntimeKind(runtime) {
|
|
|
3161
3331
|
case "wasm":
|
|
3162
3332
|
return "wasm";
|
|
3163
3333
|
}
|
|
3164
|
-
throw new (0,
|
|
3334
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3165
3335
|
"config",
|
|
3166
3336
|
"unknown_runtime",
|
|
3167
3337
|
"RivetKit runtime must be NAPI or wasm.",
|
|
@@ -3201,7 +3371,7 @@ function normalizeRuntimeConfigForKind(config, runtimeKind) {
|
|
|
3201
3371
|
return config;
|
|
3202
3372
|
}
|
|
3203
3373
|
if (sqliteBackendForConfig(config) === "local") {
|
|
3204
|
-
throw new (0,
|
|
3374
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3205
3375
|
"config",
|
|
3206
3376
|
"wasm_local_sqlite",
|
|
3207
3377
|
"WebAssembly runtime cannot use local SQLite. Use remote SQLite instead.",
|
|
@@ -3267,14 +3437,14 @@ function getNativeConnPersistState(runtime, ctx, conn) {
|
|
|
3267
3437
|
return connState;
|
|
3268
3438
|
}
|
|
3269
3439
|
function stateMutationReentrantError() {
|
|
3270
|
-
return new (0,
|
|
3440
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3271
3441
|
"actor",
|
|
3272
3442
|
"state_mutation_reentrant",
|
|
3273
3443
|
"State mutations are not allowed inside onStateChange."
|
|
3274
3444
|
);
|
|
3275
3445
|
}
|
|
3276
3446
|
function stateTransactionConflictError() {
|
|
3277
|
-
return new (0,
|
|
3447
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3278
3448
|
"actor",
|
|
3279
3449
|
"state_transaction_conflict",
|
|
3280
3450
|
"State cannot be mutated by another action while an experimental state-aware database transaction is active.",
|
|
@@ -3282,7 +3452,7 @@ function stateTransactionConflictError() {
|
|
|
3282
3452
|
);
|
|
3283
3453
|
}
|
|
3284
3454
|
function databaseNotConfiguredError() {
|
|
3285
|
-
return new (0,
|
|
3455
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3286
3456
|
"actor",
|
|
3287
3457
|
"database_not_configured",
|
|
3288
3458
|
"database is not configured for this actor",
|
|
@@ -3290,7 +3460,7 @@ function databaseNotConfiguredError() {
|
|
|
3290
3460
|
);
|
|
3291
3461
|
}
|
|
3292
3462
|
function databaseClientNotReadyError() {
|
|
3293
|
-
return new (0,
|
|
3463
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3294
3464
|
"actor",
|
|
3295
3465
|
"database_client_not_ready",
|
|
3296
3466
|
"actor database client was not initialized before user code ran. this is an internal lifecycle error; the migration callback should have pre-warmed the client. file an issue if you can reproduce.",
|
|
@@ -3298,7 +3468,7 @@ function databaseClientNotReadyError() {
|
|
|
3298
3468
|
);
|
|
3299
3469
|
}
|
|
3300
3470
|
function runHandlerNotConfiguredError() {
|
|
3301
|
-
return new (0,
|
|
3471
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3302
3472
|
"actor",
|
|
3303
3473
|
"run_handler_unavailable",
|
|
3304
3474
|
"Cannot schedule a run wake because this actor does not define a run handler.",
|
|
@@ -3306,7 +3476,7 @@ function runHandlerNotConfiguredError() {
|
|
|
3306
3476
|
);
|
|
3307
3477
|
}
|
|
3308
3478
|
function stateNotEnabledError() {
|
|
3309
|
-
return new (0,
|
|
3479
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3310
3480
|
"actor",
|
|
3311
3481
|
"state_not_enabled",
|
|
3312
3482
|
"State not enabled. Must implement `createState` or `state` to use state. (https://www.rivet.dev/docs/actors/state/#initializing-state)",
|
|
@@ -3314,7 +3484,7 @@ function stateNotEnabledError() {
|
|
|
3314
3484
|
);
|
|
3315
3485
|
}
|
|
3316
3486
|
function nativeClientNotConfiguredError() {
|
|
3317
|
-
return new (0,
|
|
3487
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3318
3488
|
"native",
|
|
3319
3489
|
"client_not_configured",
|
|
3320
3490
|
"native actor client is not configured",
|
|
@@ -3322,7 +3492,7 @@ function nativeClientNotConfiguredError() {
|
|
|
3322
3492
|
);
|
|
3323
3493
|
}
|
|
3324
3494
|
function nativeEndpointNotConfiguredError() {
|
|
3325
|
-
return new (0,
|
|
3495
|
+
return new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
3326
3496
|
"native",
|
|
3327
3497
|
"endpoint_not_configured",
|
|
3328
3498
|
"registry endpoint is required for native envoy startup",
|
|
@@ -3367,7 +3537,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
3367
3537
|
}).catch((error) => {
|
|
3368
3538
|
logger2().warn({
|
|
3369
3539
|
msg: "deferred native sleep cleanup failed",
|
|
3370
|
-
error:
|
|
3540
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, error)
|
|
3371
3541
|
});
|
|
3372
3542
|
});
|
|
3373
3543
|
return;
|
|
@@ -3477,7 +3647,7 @@ function toRuntimeBytes(value) {
|
|
|
3477
3647
|
function arrayBufferViewToRuntimeBytes(value) {
|
|
3478
3648
|
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
3479
3649
|
}
|
|
3480
|
-
function
|
|
3650
|
+
function runtimeBytesToArrayBuffer2(value) {
|
|
3481
3651
|
return value.buffer.slice(
|
|
3482
3652
|
value.byteOffset,
|
|
3483
3653
|
value.byteOffset + value.byteLength
|
|
@@ -3523,14 +3693,17 @@ function decodeNativeKvValue(value, options) {
|
|
|
3523
3693
|
async function loadEngineCli() {
|
|
3524
3694
|
return Promise.resolve().then(() => _interopRequireWildcard(require(["@rivetkit", "engine-cli"].join("/"))));
|
|
3525
3695
|
}
|
|
3696
|
+
async function loadServices() {
|
|
3697
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require(["@rivet-dev", "services"].join("/"))));
|
|
3698
|
+
}
|
|
3526
3699
|
function decodeValue(value) {
|
|
3527
3700
|
if (!value || value.length === 0) {
|
|
3528
3701
|
return void 0;
|
|
3529
3702
|
}
|
|
3530
|
-
return
|
|
3703
|
+
return _chunkTAG6UEL5cjs.decodeCborCompat.call(void 0, value);
|
|
3531
3704
|
}
|
|
3532
3705
|
function encodeValue(value) {
|
|
3533
|
-
return
|
|
3706
|
+
return _chunkTAG6UEL5cjs.encodeCborCompat.call(void 0, value);
|
|
3534
3707
|
}
|
|
3535
3708
|
function normalizeArgs(value) {
|
|
3536
3709
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3543,16 +3716,16 @@ function unwrapTsfnPayload(error, payload) {
|
|
|
3543
3716
|
}
|
|
3544
3717
|
function normalizeNativeBridgeError(error) {
|
|
3545
3718
|
if (typeof error === "string") {
|
|
3546
|
-
return _nullishCoalesce(
|
|
3719
|
+
return _nullishCoalesce(_chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
|
|
3547
3720
|
}
|
|
3548
3721
|
if (error instanceof Error) {
|
|
3549
|
-
const bridged =
|
|
3722
|
+
const bridged = _chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error.message);
|
|
3550
3723
|
if (bridged) {
|
|
3551
3724
|
return bridged;
|
|
3552
3725
|
}
|
|
3553
3726
|
}
|
|
3554
3727
|
if (typeof error === "object" && error !== null && "reason" in error && typeof error.reason === "string") {
|
|
3555
|
-
const bridged =
|
|
3728
|
+
const bridged = _chunk2JSYYH6Pcjs.decodeBridgeRivetError.call(void 0, error.reason);
|
|
3556
3729
|
if (bridged) {
|
|
3557
3730
|
return bridged;
|
|
3558
3731
|
}
|
|
@@ -3560,14 +3733,14 @@ function normalizeNativeBridgeError(error) {
|
|
|
3560
3733
|
return error;
|
|
3561
3734
|
}
|
|
3562
3735
|
function isStructuredBridgeError(error) {
|
|
3563
|
-
if (error instanceof
|
|
3736
|
+
if (error instanceof _chunk2JSYYH6Pcjs.RivetError) {
|
|
3564
3737
|
return true;
|
|
3565
3738
|
}
|
|
3566
|
-
return
|
|
3739
|
+
return _chunk2JSYYH6Pcjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3567
3740
|
}
|
|
3568
3741
|
function encodeNativeCallbackError(error) {
|
|
3569
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
3570
|
-
const bridgeError = new Error(
|
|
3742
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkTAG6UEL5cjs.deconstructError.call(void 0, error, true);
|
|
3743
|
+
const bridgeError = new Error(_chunk2JSYYH6Pcjs.encodeBridgeRivetError.call(void 0, structuredError), {
|
|
3571
3744
|
cause: error instanceof Error ? error : void 0
|
|
3572
3745
|
});
|
|
3573
3746
|
return Object.assign(bridgeError, {
|
|
@@ -3592,9 +3765,9 @@ function callNativeSync(invoke) {
|
|
|
3592
3765
|
}
|
|
3593
3766
|
}
|
|
3594
3767
|
function isClosedTaskRegistrationError(error) {
|
|
3595
|
-
const metadata = error instanceof
|
|
3768
|
+
const metadata = error instanceof _chunk2JSYYH6Pcjs.RivetError ? error.metadata : void 0;
|
|
3596
3769
|
const metadataError = metadata && typeof metadata === "object" && "error" in metadata ? metadata.error : void 0;
|
|
3597
|
-
return error instanceof
|
|
3770
|
+
return error instanceof _chunk2JSYYH6Pcjs.RivetError && error.group === "core" && error.code === _chunk2JSYYH6Pcjs.INTERNAL_ERROR_CODE && typeof metadataError === "string" && /actor task registration is (closed|not configured)/.test(metadataError);
|
|
3598
3771
|
}
|
|
3599
3772
|
async function createCancellationTokenHandle(runtime, signal) {
|
|
3600
3773
|
if (!signal) {
|
|
@@ -3617,7 +3790,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3617
3790
|
return null;
|
|
3618
3791
|
}
|
|
3619
3792
|
try {
|
|
3620
|
-
return
|
|
3793
|
+
return _chunkTAG6UEL5cjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3621
3794
|
} catch (e5) {
|
|
3622
3795
|
return null;
|
|
3623
3796
|
}
|
|
@@ -3730,7 +3903,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
3730
3903
|
if (data === null) {
|
|
3731
3904
|
return null;
|
|
3732
3905
|
}
|
|
3733
|
-
const history =
|
|
3906
|
+
const history = _chunkPW2VSGURcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
3734
3907
|
return jsonSafe({
|
|
3735
3908
|
nameRegistry: [...history.nameRegistry],
|
|
3736
3909
|
entries: history.entries.map((entry) => ({
|
|
@@ -3808,24 +3981,6 @@ function decodeArgs(value) {
|
|
|
3808
3981
|
const decoded = decodeValue(value);
|
|
3809
3982
|
return normalizeArgs(decoded);
|
|
3810
3983
|
}
|
|
3811
|
-
function buildRequest(init) {
|
|
3812
|
-
const url = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
|
|
3813
|
-
const body = init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
|
|
3814
|
-
return new Request(url, {
|
|
3815
|
-
method: init.method,
|
|
3816
|
-
headers: init.headers,
|
|
3817
|
-
body
|
|
3818
|
-
});
|
|
3819
|
-
}
|
|
3820
|
-
async function toRuntimeHttpResponse(response) {
|
|
3821
|
-
const headers = Object.fromEntries(response.headers.entries());
|
|
3822
|
-
const body = new Uint8Array(await response.arrayBuffer());
|
|
3823
|
-
return {
|
|
3824
|
-
status: response.status,
|
|
3825
|
-
headers,
|
|
3826
|
-
body
|
|
3827
|
-
};
|
|
3828
|
-
}
|
|
3829
3984
|
function toActorKey(segments) {
|
|
3830
3985
|
return segments.map(
|
|
3831
3986
|
(segment) => segment.kind === "number" ? String(_nullishCoalesce(segment.numberValue, () => ( 0))) : _nullishCoalesce(segment.stringValue, () => ( ""))
|
|
@@ -3847,7 +4002,7 @@ var NativeConnAdapter = class {
|
|
|
3847
4002
|
this.#ctx = ctx;
|
|
3848
4003
|
this.#queueHibernationRemoval = queueHibernationRemoval;
|
|
3849
4004
|
this.#assertCanMutateState = assertCanMutateState;
|
|
3850
|
-
this[
|
|
4005
|
+
this[_chunk4KGXFC6Mcjs.CONN_STATE_MANAGER_SYMBOL] = {
|
|
3851
4006
|
stateEnabled: true,
|
|
3852
4007
|
get state() {
|
|
3853
4008
|
return thisConn.state;
|
|
@@ -3864,7 +4019,7 @@ var NativeConnAdapter = class {
|
|
|
3864
4019
|
decodeValue(this.#runtime.connParams(this.#conn))
|
|
3865
4020
|
);
|
|
3866
4021
|
}
|
|
3867
|
-
[
|
|
4022
|
+
[_chunk4KGXFC6Mcjs.RAW_STATE_SYMBOL]() {
|
|
3868
4023
|
return this.#readState();
|
|
3869
4024
|
}
|
|
3870
4025
|
get state() {
|
|
@@ -3894,7 +4049,7 @@ var NativeConnAdapter = class {
|
|
|
3894
4049
|
},
|
|
3895
4050
|
(newValue) => {
|
|
3896
4051
|
assertCurrentState();
|
|
3897
|
-
|
|
4052
|
+
_chunkTAG6UEL5cjs.assertJsonCompatValue.call(void 0, newValue);
|
|
3898
4053
|
}
|
|
3899
4054
|
);
|
|
3900
4055
|
}
|
|
@@ -3902,7 +4057,7 @@ var NativeConnAdapter = class {
|
|
|
3902
4057
|
var _a;
|
|
3903
4058
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
3904
4059
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
3905
|
-
|
|
4060
|
+
_chunkTAG6UEL5cjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
3906
4061
|
this.#writeState(nextValue, { writeNative: true });
|
|
3907
4062
|
}
|
|
3908
4063
|
initializeState(value) {
|
|
@@ -4285,7 +4440,7 @@ var NativeQueueAdapter = class {
|
|
|
4285
4440
|
async nextBatch(options) {
|
|
4286
4441
|
const completable = (options == null ? void 0 : options.completable) === true;
|
|
4287
4442
|
if (this.#pendingCompletableMessageIds.size > 0) {
|
|
4288
|
-
throw new (0,
|
|
4443
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
4289
4444
|
"queue",
|
|
4290
4445
|
"previous_message_not_completed",
|
|
4291
4446
|
"Previous completable queue message is not completed. Call `message.complete(...)` before receiving the next message.",
|
|
@@ -4452,7 +4607,7 @@ var NativeQueueAdapter = class {
|
|
|
4452
4607
|
}
|
|
4453
4608
|
yield message;
|
|
4454
4609
|
} catch (error) {
|
|
4455
|
-
if (
|
|
4610
|
+
if (_chunk2JSYYH6Pcjs.isActorAbortedError.call(void 0, error)) {
|
|
4456
4611
|
return;
|
|
4457
4612
|
}
|
|
4458
4613
|
throw error;
|
|
@@ -4473,7 +4628,7 @@ var NativeQueueAdapter = class {
|
|
|
4473
4628
|
...message,
|
|
4474
4629
|
complete: async (response) => {
|
|
4475
4630
|
if (typeof message.complete !== "function") {
|
|
4476
|
-
throw new (0,
|
|
4631
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
4477
4632
|
"queue",
|
|
4478
4633
|
"complete_not_configured",
|
|
4479
4634
|
`Queue '${message.name}' does not support completion responses.`,
|
|
@@ -4485,7 +4640,7 @@ var NativeQueueAdapter = class {
|
|
|
4485
4640
|
);
|
|
4486
4641
|
}
|
|
4487
4642
|
if (completed) {
|
|
4488
|
-
throw new (0,
|
|
4643
|
+
throw new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
4489
4644
|
"queue",
|
|
4490
4645
|
"already_completed",
|
|
4491
4646
|
"Queue message was already completed.",
|
|
@@ -4538,7 +4693,7 @@ var NativeWebSocketAdapter = class {
|
|
|
4538
4693
|
this.#runtime.webSocketSetEventCallback(this.#ws, (event2) => {
|
|
4539
4694
|
if (event2.kind === "message") {
|
|
4540
4695
|
this.#virtual.triggerMessage(
|
|
4541
|
-
event2.binary ?
|
|
4696
|
+
event2.binary ? runtimeBytesToArrayBuffer2(event2.data) : event2.data,
|
|
4542
4697
|
event2.messageIndex
|
|
4543
4698
|
);
|
|
4544
4699
|
return;
|
|
@@ -4919,7 +5074,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4919
5074
|
this.#databaseProvider = databaseProvider;
|
|
4920
5075
|
}
|
|
4921
5076
|
this.#request = request;
|
|
4922
|
-
this[
|
|
5077
|
+
this[_chunk4KGXFC6Mcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
|
|
4923
5078
|
this
|
|
4924
5079
|
);
|
|
4925
5080
|
}
|
|
@@ -4949,7 +5104,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4949
5104
|
}
|
|
4950
5105
|
throw databaseClientNotReadyError();
|
|
4951
5106
|
}
|
|
4952
|
-
[
|
|
5107
|
+
[_chunk4KGXFC6Mcjs.RAW_STATE_SYMBOL]() {
|
|
4953
5108
|
if (!this.#stateEnabled) {
|
|
4954
5109
|
throw stateNotEnabledError();
|
|
4955
5110
|
}
|
|
@@ -4976,7 +5131,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4976
5131
|
},
|
|
4977
5132
|
(newValue) => {
|
|
4978
5133
|
assertCurrentState();
|
|
4979
|
-
|
|
5134
|
+
_chunkTAG6UEL5cjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4980
5135
|
}
|
|
4981
5136
|
);
|
|
4982
5137
|
}
|
|
@@ -4988,7 +5143,7 @@ var ActorContextHandleAdapter = class {
|
|
|
4988
5143
|
}
|
|
4989
5144
|
this.#assertCanMutateState();
|
|
4990
5145
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4991
|
-
|
|
5146
|
+
_chunkTAG6UEL5cjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4992
5147
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
4993
5148
|
}
|
|
4994
5149
|
initializeState(value) {
|
|
@@ -5172,7 +5327,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5172
5327
|
log: {
|
|
5173
5328
|
debug: (obj) => logger2().debug(obj)
|
|
5174
5329
|
},
|
|
5175
|
-
nativeDatabaseProvider:
|
|
5330
|
+
nativeDatabaseProvider: _chunkFGQABMXZcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5176
5331
|
{
|
|
5177
5332
|
open: async (requestedActorId) => {
|
|
5178
5333
|
void requestedActorId;
|
|
@@ -5195,7 +5350,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5195
5350
|
return this.#db;
|
|
5196
5351
|
}
|
|
5197
5352
|
#bindDatabaseClient(client) {
|
|
5198
|
-
return
|
|
5353
|
+
return _chunkFGQABMXZcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5199
5354
|
enter: async () => await this.#enterStateTransaction(),
|
|
5200
5355
|
exit: (scope) => this.#exitStateTransaction(
|
|
5201
5356
|
scope
|
|
@@ -5399,7 +5554,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5399
5554
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5400
5555
|
logger2().warn({
|
|
5401
5556
|
msg: "keepAwake promise rejected",
|
|
5402
|
-
error:
|
|
5557
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, error)
|
|
5403
5558
|
});
|
|
5404
5559
|
}).then(() => null);
|
|
5405
5560
|
try {
|
|
@@ -5760,7 +5915,6 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
5760
5915
|
return {
|
|
5761
5916
|
name: options.name,
|
|
5762
5917
|
icon: options.icon,
|
|
5763
|
-
maxActions: options.maxActions,
|
|
5764
5918
|
hasDatabase: true,
|
|
5765
5919
|
remoteSqlite: usesRemoteSqlite,
|
|
5766
5920
|
sqliteProfiling,
|
|
@@ -5786,7 +5940,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
5786
5940
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
5787
5941
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
5788
5942
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
5789
|
-
actions: Object.keys(
|
|
5943
|
+
actions: Object.keys(_chunk4KGXFC6Mcjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
|
|
5790
5944
|
inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
|
|
5791
5945
|
};
|
|
5792
5946
|
}
|
|
@@ -5862,10 +6016,10 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
5862
6016
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
5863
6017
|
var _a;
|
|
5864
6018
|
const config = definition.config;
|
|
5865
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
5866
|
-
const actionHandlers =
|
|
6019
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkFGQABMXZcjs.db.call(void 0, )));
|
|
6020
|
+
const actionHandlers = _chunk4KGXFC6Mcjs.flattenActionHandlers.call(void 0, config.actions);
|
|
5867
6021
|
const schemaConfig = {
|
|
5868
|
-
actionInputSchemas:
|
|
6022
|
+
actionInputSchemas: _chunk4KGXFC6Mcjs.flattenActionInputSchemas.call(void 0,
|
|
5869
6023
|
config.actions,
|
|
5870
6024
|
config.actionInputSchemas
|
|
5871
6025
|
),
|
|
@@ -5873,19 +6027,19 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5873
6027
|
events: config.events,
|
|
5874
6028
|
queues: config.queues
|
|
5875
6029
|
};
|
|
5876
|
-
const createClient = () =>
|
|
5877
|
-
new (0,
|
|
5878
|
-
|
|
6030
|
+
const createClient = () => _chunkTZPNSOG2cjs.createClientWithDriver.call(void 0,
|
|
6031
|
+
new (0, _chunkTZPNSOG2cjs.RemoteEngineControlClient)(
|
|
6032
|
+
_chunkTZPNSOG2cjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
5879
6033
|
),
|
|
5880
6034
|
{ encoding: "bare" }
|
|
5881
6035
|
);
|
|
5882
|
-
const run =
|
|
5883
|
-
const runHandlerCoordinator =
|
|
6036
|
+
const run = _chunk4KGXFC6Mcjs.getRunFunction.call(void 0, config.run);
|
|
6037
|
+
const runHandlerCoordinator = _chunk4KGXFC6Mcjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
|
|
5884
6038
|
const getNativeWorkflowInspector = (ctx) => {
|
|
5885
6039
|
var _a2, _b;
|
|
5886
6040
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
5887
6041
|
const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
|
|
5888
|
-
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b =
|
|
6042
|
+
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunk4KGXFC6Mcjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
|
|
5889
6043
|
};
|
|
5890
6044
|
const onStateChange = typeof config.onStateChange === "function" ? (actorCtx, nextState) => {
|
|
5891
6045
|
config.onStateChange(actorCtx, nextState);
|
|
@@ -5922,12 +6076,14 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5922
6076
|
cancelToken,
|
|
5923
6077
|
run !== void 0
|
|
5924
6078
|
);
|
|
5925
|
-
const maybeHandleNativeInspectorRequest = async (ctx,
|
|
6079
|
+
const maybeHandleNativeInspectorRequest = async (ctx, rawRequest) => {
|
|
5926
6080
|
var _a2, _b, _c, _d;
|
|
5927
|
-
const
|
|
6081
|
+
const rawUrl = rawRequest.uri.startsWith("http") ? rawRequest.uri : new URL(rawRequest.uri, "http://127.0.0.1").toString();
|
|
6082
|
+
const url = new URL(rawUrl);
|
|
5928
6083
|
if (!url.pathname.startsWith("/inspector/")) {
|
|
5929
6084
|
return void 0;
|
|
5930
6085
|
}
|
|
6086
|
+
const jsRequest = buildNativeHttpRequest(rawRequest);
|
|
5931
6087
|
const jsonResponse = (body, init) => new Response(JSON.stringify(body), {
|
|
5932
6088
|
status: _nullishCoalesce((init == null ? void 0 : init.status), () => ( 200)),
|
|
5933
6089
|
headers: {
|
|
@@ -5936,7 +6092,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
5936
6092
|
}
|
|
5937
6093
|
});
|
|
5938
6094
|
const errorResponse = (error, status) => {
|
|
5939
|
-
const rivetError =
|
|
6095
|
+
const rivetError = _chunk2JSYYH6Pcjs.toRivetError.call(void 0, error);
|
|
5940
6096
|
return jsonResponse(
|
|
5941
6097
|
{
|
|
5942
6098
|
group: rivetError.group,
|
|
@@ -6036,7 +6192,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6036
6192
|
body = await jsRequest.json();
|
|
6037
6193
|
} catch (e6) {
|
|
6038
6194
|
return errorResponse(
|
|
6039
|
-
new (0,
|
|
6195
|
+
new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
6040
6196
|
"actor",
|
|
6041
6197
|
"invalid_request",
|
|
6042
6198
|
"Invalid inspector JSON body",
|
|
@@ -6048,7 +6204,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6048
6204
|
const name = _nullishCoalesce(body.name, () => ( ""));
|
|
6049
6205
|
if (name === "") {
|
|
6050
6206
|
return errorResponse(
|
|
6051
|
-
new (0,
|
|
6207
|
+
new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
6052
6208
|
"actor",
|
|
6053
6209
|
"invalid_request",
|
|
6054
6210
|
"Queue message name must not be empty",
|
|
@@ -6057,7 +6213,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6057
6213
|
400
|
|
6058
6214
|
);
|
|
6059
6215
|
}
|
|
6060
|
-
const cbor =
|
|
6216
|
+
const cbor = _chunkTAG6UEL5cjs.encodeCborCompat.call(void 0,
|
|
6061
6217
|
_nullishCoalesce(body.body, () => ( null))
|
|
6062
6218
|
);
|
|
6063
6219
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -6222,7 +6378,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6222
6378
|
const action = actionHandlers[actionName];
|
|
6223
6379
|
if (!action) {
|
|
6224
6380
|
return errorResponse(
|
|
6225
|
-
new (0,
|
|
6381
|
+
new (0, _chunk2JSYYH6Pcjs.RivetError)(
|
|
6226
6382
|
"action",
|
|
6227
6383
|
"action_not_found",
|
|
6228
6384
|
`Action ${actionName} not found`
|
|
@@ -6425,7 +6581,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6425
6581
|
);
|
|
6426
6582
|
} finally {
|
|
6427
6583
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6428
|
-
|
|
6584
|
+
_chunk4KGXFC6Mcjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6429
6585
|
await actorCtx.dispose();
|
|
6430
6586
|
}
|
|
6431
6587
|
}
|
|
@@ -6437,7 +6593,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6437
6593
|
const actorCtx = makeActorCtx(ctx);
|
|
6438
6594
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6439
6595
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6440
|
-
|
|
6596
|
+
_chunk4KGXFC6Mcjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6441
6597
|
try {
|
|
6442
6598
|
if (typeof config.onDestroy === "function") {
|
|
6443
6599
|
await config.onDestroy(actorCtx);
|
|
@@ -6458,7 +6614,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6458
6614
|
);
|
|
6459
6615
|
const actorCtx = makeActorCtx(
|
|
6460
6616
|
ctx,
|
|
6461
|
-
request ?
|
|
6617
|
+
request ? buildNativeHttpRequest(request) : void 0
|
|
6462
6618
|
);
|
|
6463
6619
|
try {
|
|
6464
6620
|
await config.onBeforeConnect(
|
|
@@ -6478,7 +6634,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6478
6634
|
const { ctx, conn, params, request } = unwrapTsfnPayload(error, payload);
|
|
6479
6635
|
const actorCtx = makeActorCtx(
|
|
6480
6636
|
ctx,
|
|
6481
|
-
request ?
|
|
6637
|
+
request ? buildNativeHttpRequest(request) : void 0
|
|
6482
6638
|
);
|
|
6483
6639
|
const connAdapter = new NativeConnAdapter(
|
|
6484
6640
|
runtime,
|
|
@@ -6516,7 +6672,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6516
6672
|
);
|
|
6517
6673
|
const actorCtx = makeActorCtx(
|
|
6518
6674
|
ctx,
|
|
6519
|
-
request ?
|
|
6675
|
+
request ? buildNativeHttpRequest(request) : void 0
|
|
6520
6676
|
);
|
|
6521
6677
|
const connAdapter = new NativeConnAdapter(
|
|
6522
6678
|
runtime,
|
|
@@ -6595,7 +6751,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6595
6751
|
);
|
|
6596
6752
|
}
|
|
6597
6753
|
if (!result) {
|
|
6598
|
-
throw
|
|
6754
|
+
throw _chunk2JSYYH6Pcjs.forbiddenError.call(void 0, );
|
|
6599
6755
|
}
|
|
6600
6756
|
} finally {
|
|
6601
6757
|
await actorCtx.dispose();
|
|
@@ -6623,27 +6779,45 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6623
6779
|
onRequest: wrapNativeCallback(
|
|
6624
6780
|
async (error, payload) => {
|
|
6625
6781
|
try {
|
|
6626
|
-
const { ctx, request, cancelToken } = unwrapTsfnPayload(
|
|
6627
|
-
|
|
6628
|
-
payload
|
|
6629
|
-
);
|
|
6630
|
-
const jsRequest = buildRequest(request);
|
|
6631
|
-
const inspectorResponse = await maybeHandleNativeInspectorRequest(
|
|
6632
|
-
ctx,
|
|
6633
|
-
request,
|
|
6634
|
-
jsRequest
|
|
6635
|
-
);
|
|
6782
|
+
const { ctx, request, cancelToken, responseBodyStream } = unwrapTsfnPayload(error, payload);
|
|
6783
|
+
const inspectorResponse = await maybeHandleNativeInspectorRequest(ctx, request);
|
|
6636
6784
|
if (inspectorResponse) {
|
|
6637
|
-
|
|
6785
|
+
await cancelNativeHttpRequestBody(request.bodyStream);
|
|
6786
|
+
return (await convertNativeHttpResponse(
|
|
6787
|
+
inspectorResponse,
|
|
6788
|
+
responseBodyStream
|
|
6789
|
+
)).response;
|
|
6638
6790
|
}
|
|
6639
6791
|
if (typeof config.onRequest !== "function") {
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6792
|
+
await cancelNativeHttpRequestBody(request.bodyStream);
|
|
6793
|
+
return (await convertNativeHttpResponse(
|
|
6794
|
+
new Response(null, { status: 404 }),
|
|
6795
|
+
responseBodyStream
|
|
6796
|
+
)).response;
|
|
6643
6797
|
}
|
|
6644
|
-
const
|
|
6798
|
+
const requestAbortController = new AbortController();
|
|
6799
|
+
const handlerRequest = buildNativeHttpRequest({
|
|
6800
|
+
...request,
|
|
6801
|
+
abortController: requestAbortController
|
|
6802
|
+
});
|
|
6803
|
+
const rawConnParams = handlerRequest.headers.get(_chunkTZPNSOG2cjs.HEADER_CONN_PARAMS);
|
|
6645
6804
|
let requestCtx;
|
|
6646
6805
|
let conn;
|
|
6806
|
+
let removeRequestAbortListener;
|
|
6807
|
+
let cleanupDeferredToBody = false;
|
|
6808
|
+
let cleanedUp = false;
|
|
6809
|
+
const cleanupRequest = async () => {
|
|
6810
|
+
if (cleanedUp) return;
|
|
6811
|
+
cleanedUp = true;
|
|
6812
|
+
removeRequestAbortListener == null ? void 0 : removeRequestAbortListener();
|
|
6813
|
+
try {
|
|
6814
|
+
await (requestCtx == null ? void 0 : requestCtx.dispose());
|
|
6815
|
+
} finally {
|
|
6816
|
+
if (conn) {
|
|
6817
|
+
await runtime.connDisconnect(conn);
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6820
|
+
};
|
|
6647
6821
|
try {
|
|
6648
6822
|
const connParams = validateConnParams(
|
|
6649
6823
|
schemaConfig.connParamsSchema,
|
|
@@ -6659,23 +6833,56 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6659
6833
|
requestCtx = makeConnCtx(
|
|
6660
6834
|
ctx,
|
|
6661
6835
|
conn,
|
|
6662
|
-
|
|
6836
|
+
handlerRequest,
|
|
6663
6837
|
cancelToken
|
|
6664
6838
|
);
|
|
6839
|
+
const ctxAbortSignal = requestCtx.abortSignal;
|
|
6840
|
+
const abortRequest = () => requestAbortController.abort(ctxAbortSignal.reason);
|
|
6841
|
+
if (ctxAbortSignal.aborted) {
|
|
6842
|
+
abortRequest();
|
|
6843
|
+
} else {
|
|
6844
|
+
ctxAbortSignal.addEventListener(
|
|
6845
|
+
"abort",
|
|
6846
|
+
abortRequest,
|
|
6847
|
+
{ once: true }
|
|
6848
|
+
);
|
|
6849
|
+
removeRequestAbortListener = () => ctxAbortSignal.removeEventListener(
|
|
6850
|
+
"abort",
|
|
6851
|
+
abortRequest
|
|
6852
|
+
);
|
|
6853
|
+
}
|
|
6665
6854
|
const response = await config.onRequest(
|
|
6666
6855
|
requestCtx,
|
|
6667
|
-
|
|
6856
|
+
handlerRequest
|
|
6668
6857
|
);
|
|
6669
|
-
if (!
|
|
6858
|
+
if (!_chunkTZPNSOG2cjs.isResponseLike.call(void 0, response)) {
|
|
6670
6859
|
throw new Error(
|
|
6671
6860
|
"onRequest handler must return a Response"
|
|
6672
6861
|
);
|
|
6673
6862
|
}
|
|
6674
|
-
|
|
6863
|
+
const conversion = await convertNativeHttpResponse(
|
|
6864
|
+
response,
|
|
6865
|
+
responseBodyStream
|
|
6866
|
+
);
|
|
6867
|
+
if (conversion.bodyCompletion) {
|
|
6868
|
+
cleanupDeferredToBody = true;
|
|
6869
|
+
void conversion.bodyCompletion.then(cleanupRequest).catch((cleanupError) => {
|
|
6870
|
+
logger2().error({
|
|
6871
|
+
msg: "failed to clean up native streaming http request",
|
|
6872
|
+
error: cleanupError
|
|
6873
|
+
});
|
|
6874
|
+
});
|
|
6875
|
+
}
|
|
6876
|
+
return conversion.response;
|
|
6675
6877
|
} finally {
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6878
|
+
try {
|
|
6879
|
+
await cancelNativeHttpRequestBody(
|
|
6880
|
+
request.bodyStream
|
|
6881
|
+
);
|
|
6882
|
+
} finally {
|
|
6883
|
+
if (!cleanupDeferredToBody) {
|
|
6884
|
+
await cleanupRequest();
|
|
6885
|
+
}
|
|
6679
6886
|
}
|
|
6680
6887
|
}
|
|
6681
6888
|
} catch (error2) {
|
|
@@ -6690,7 +6897,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6690
6897
|
onWebSocket: typeof config.onWebSocket === "function" ? wrapNativeCallback(
|
|
6691
6898
|
async (error, payload) => {
|
|
6692
6899
|
const { ctx, conn, ws, request } = unwrapTsfnPayload(error, payload);
|
|
6693
|
-
const jsRequest = request ?
|
|
6900
|
+
const jsRequest = request ? buildNativeHttpRequest(request) : void 0;
|
|
6694
6901
|
const actorCtx = makeConnCtx(ctx, conn, jsRequest);
|
|
6695
6902
|
try {
|
|
6696
6903
|
await config.onWebSocket(
|
|
@@ -6736,15 +6943,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6736
6943
|
}
|
|
6737
6944
|
);
|
|
6738
6945
|
})(),
|
|
6739
|
-
getWorkflowHistory:
|
|
6946
|
+
getWorkflowHistory: _chunk4KGXFC6Mcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
6740
6947
|
async (error, payload) => {
|
|
6741
6948
|
var _a2;
|
|
6742
6949
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
6743
6950
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
6744
|
-
return history == null ? void 0 :
|
|
6951
|
+
return history == null ? void 0 : _chunkTAG6UEL5cjs.toUint8Array.call(void 0, history);
|
|
6745
6952
|
}
|
|
6746
6953
|
) : void 0,
|
|
6747
|
-
replayWorkflow:
|
|
6954
|
+
replayWorkflow: _chunk4KGXFC6Mcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
6748
6955
|
async (error, payload) => {
|
|
6749
6956
|
const { ctx, entryId } = unwrapTsfnPayload(
|
|
6750
6957
|
error,
|
|
@@ -6755,7 +6962,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6755
6962
|
return void 0;
|
|
6756
6963
|
}
|
|
6757
6964
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
6758
|
-
return history == null ? void 0 :
|
|
6965
|
+
return history == null ? void 0 : _chunkTAG6UEL5cjs.toUint8Array.call(void 0, history);
|
|
6759
6966
|
}
|
|
6760
6967
|
) : void 0,
|
|
6761
6968
|
actions: Object.fromEntries(
|
|
@@ -6796,7 +7003,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6796
7003
|
timeoutMs,
|
|
6797
7004
|
cancelToken
|
|
6798
7005
|
} = unwrapTsfnPayload(error, payload);
|
|
6799
|
-
const jsRequest =
|
|
7006
|
+
const jsRequest = buildNativeHttpRequest(request);
|
|
6800
7007
|
const actorCtx = withConnContext(
|
|
6801
7008
|
runtime,
|
|
6802
7009
|
ctx,
|
|
@@ -6819,7 +7026,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6819
7026
|
name
|
|
6820
7027
|
);
|
|
6821
7028
|
if (canPublish && !await canPublish(actorCtx)) {
|
|
6822
|
-
throw
|
|
7029
|
+
throw _chunk2JSYYH6Pcjs.forbiddenError.call(void 0, );
|
|
6823
7030
|
}
|
|
6824
7031
|
const decodedBody = decodeValue(body);
|
|
6825
7032
|
if (wait) {
|
|
@@ -6866,7 +7073,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6866
7073
|
buildActorConfig(definition, registryConfig, runtime.kind)
|
|
6867
7074
|
);
|
|
6868
7075
|
}
|
|
6869
|
-
async function buildServeConfig(config) {
|
|
7076
|
+
async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
6870
7077
|
var _a;
|
|
6871
7078
|
if (!config.endpoint) {
|
|
6872
7079
|
throw nativeEndpointNotConfiguredError();
|
|
@@ -6877,9 +7084,10 @@ async function buildServeConfig(config) {
|
|
|
6877
7084
|
token: config.token,
|
|
6878
7085
|
namespace: config.namespace,
|
|
6879
7086
|
poolName: config.envoy.poolName,
|
|
7087
|
+
startServices: resolveServicesBinary && config.startServices,
|
|
6880
7088
|
handleInspectorHttpInRuntime: true,
|
|
6881
7089
|
serverlessBasePath: config.serverless.basePath,
|
|
6882
|
-
serverlessPackageVersion:
|
|
7090
|
+
serverlessPackageVersion: _chunkTAG6UEL5cjs.VERSION,
|
|
6883
7091
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
6884
7092
|
serverlessClientNamespace: config.publicNamespace,
|
|
6885
7093
|
serverlessClientToken: config.publicToken,
|
|
@@ -6892,19 +7100,30 @@ async function buildServeConfig(config) {
|
|
|
6892
7100
|
} catch (error) {
|
|
6893
7101
|
logger2().warn({
|
|
6894
7102
|
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",
|
|
6895
|
-
error:
|
|
7103
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, error)
|
|
6896
7104
|
});
|
|
6897
7105
|
}
|
|
7106
|
+
if (resolveServicesBinary && config.startServices) {
|
|
7107
|
+
try {
|
|
7108
|
+
const { getServicesPath } = await loadServices();
|
|
7109
|
+
serveConfig.servicesBinaryPath = getServicesPath();
|
|
7110
|
+
} catch (error) {
|
|
7111
|
+
logger2().warn({
|
|
7112
|
+
msg: "could not resolve the Services binary; a local engine will fail with services.binary_unavailable \u2014 set RIVET_RUN_SERVICES=0 to disable Services or RIVET_SERVICES_BINARY to a local rivet-services binary",
|
|
7113
|
+
error: _chunkTAG6UEL5cjs.stringifyError.call(void 0, error)
|
|
7114
|
+
});
|
|
7115
|
+
}
|
|
7116
|
+
}
|
|
6898
7117
|
serveConfig.engineHost = config.engineHost;
|
|
6899
7118
|
serveConfig.enginePort = config.enginePort;
|
|
6900
7119
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
6901
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7120
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkTAG6UEL5cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
6902
7121
|
}
|
|
6903
7122
|
return serveConfig;
|
|
6904
7123
|
}
|
|
6905
7124
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
6906
7125
|
var _a;
|
|
6907
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
7126
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkTAG6UEL5cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
6908
7127
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
6909
7128
|
}
|
|
6910
7129
|
if (runtime.kind === "napi") {
|
|
@@ -6921,7 +7140,7 @@ async function buildRegistryWithRuntime(config, runtime) {
|
|
|
6921
7140
|
return {
|
|
6922
7141
|
runtime,
|
|
6923
7142
|
registry,
|
|
6924
|
-
serveConfig: await buildServeConfig(config)
|
|
7143
|
+
serveConfig: await buildServeConfig(config, runtime.kind === "napi")
|
|
6925
7144
|
};
|
|
6926
7145
|
}
|
|
6927
7146
|
async function buildConfiguredRegistry(config) {
|
|
@@ -6948,26 +7167,51 @@ function finishShutdownSignal(signal) {
|
|
|
6948
7167
|
}
|
|
6949
7168
|
process.kill(process.pid, signal);
|
|
6950
7169
|
}
|
|
6951
|
-
function createApplicationFetch(application) {
|
|
6952
|
-
return async (request) => {
|
|
7170
|
+
function createApplicationFetch(application, runtime) {
|
|
7171
|
+
return async (request, responseBodyStream) => {
|
|
6953
7172
|
const method2 = request.method.toUpperCase();
|
|
6954
7173
|
const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
|
|
7174
|
+
const abortController = new AbortController();
|
|
7175
|
+
if (request.cancelToken) {
|
|
7176
|
+
if (runtime.cancellationTokenAborted(request.cancelToken)) {
|
|
7177
|
+
abortController.abort();
|
|
7178
|
+
} else {
|
|
7179
|
+
runtime.onCancellationTokenCancelled(
|
|
7180
|
+
request.cancelToken,
|
|
7181
|
+
() => abortController.abort()
|
|
7182
|
+
);
|
|
7183
|
+
}
|
|
7184
|
+
}
|
|
6955
7185
|
const response = await application.fetch(
|
|
6956
7186
|
new Request(request.url, {
|
|
6957
7187
|
method: method2,
|
|
6958
7188
|
headers: request.headers,
|
|
6959
|
-
body
|
|
7189
|
+
body,
|
|
7190
|
+
signal: abortController.signal
|
|
6960
7191
|
})
|
|
6961
7192
|
);
|
|
6962
|
-
if (!
|
|
7193
|
+
if (!_chunkTZPNSOG2cjs.isResponseLike.call(void 0, response)) {
|
|
6963
7194
|
throw new TypeError(
|
|
6964
7195
|
"registry.listen() application fetch must return a Response"
|
|
6965
7196
|
);
|
|
6966
7197
|
}
|
|
7198
|
+
const conversion = await convertNativeHttpResponse(
|
|
7199
|
+
response,
|
|
7200
|
+
responseBodyStream
|
|
7201
|
+
);
|
|
7202
|
+
if (conversion.bodyCompletion) {
|
|
7203
|
+
void conversion.bodyCompletion.catch((error) => {
|
|
7204
|
+
logger2().error({
|
|
7205
|
+
msg: "application response stream failed",
|
|
7206
|
+
error
|
|
7207
|
+
});
|
|
7208
|
+
});
|
|
7209
|
+
}
|
|
6967
7210
|
return {
|
|
6968
|
-
status: response.status,
|
|
6969
|
-
headers: Object.fromEntries(response.headers.entries()),
|
|
6970
|
-
body:
|
|
7211
|
+
status: _nullishCoalesce(conversion.response.status, () => ( response.status)),
|
|
7212
|
+
headers: _nullishCoalesce(conversion.response.headers, () => ( Object.fromEntries(response.headers.entries()))),
|
|
7213
|
+
body: conversion.response.body,
|
|
7214
|
+
stream: conversion.response.stream
|
|
6971
7215
|
};
|
|
6972
7216
|
};
|
|
6973
7217
|
}
|
|
@@ -6996,7 +7240,7 @@ var Registry = class {
|
|
|
6996
7240
|
var _a;
|
|
6997
7241
|
this.#config = config;
|
|
6998
7242
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
6999
|
-
|
|
7243
|
+
_chunkTAG6UEL5cjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7000
7244
|
}
|
|
7001
7245
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7002
7246
|
this.routes = {
|
|
@@ -7222,11 +7466,10 @@ var Registry = class {
|
|
|
7222
7466
|
* ```
|
|
7223
7467
|
*/
|
|
7224
7468
|
async listen(opts = {}) {
|
|
7225
|
-
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => (
|
|
7226
|
-
const publicDir = _nullishCoalesce(opts.publicDir, () => (
|
|
7469
|
+
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkTAG6UEL5cjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
|
|
7470
|
+
const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkTAG6UEL5cjs.getRivetkitPublicDir.call(void 0, )));
|
|
7227
7471
|
const config = this.parseConfig();
|
|
7228
|
-
|
|
7229
|
-
if (application && _chunkARFTQ5HYcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7472
|
+
if (opts.application && _chunkTAG6UEL5cjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7230
7473
|
if (config.runtime === "wasm") {
|
|
7231
7474
|
throw new Error(
|
|
7232
7475
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7245,13 +7488,18 @@ var Registry = class {
|
|
|
7245
7488
|
throw new Error("registry envoy startup did not initialize");
|
|
7246
7489
|
}
|
|
7247
7490
|
const { runtime: runtime2, registry: registry2, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
|
|
7491
|
+
const application2 = createApplicationFetch(
|
|
7492
|
+
opts.application,
|
|
7493
|
+
runtime2
|
|
7494
|
+
);
|
|
7495
|
+
await readyPromise;
|
|
7248
7496
|
const listenerPromise = runtime2.serveApplicationListener(
|
|
7249
7497
|
registry2,
|
|
7250
7498
|
{
|
|
7251
7499
|
port,
|
|
7252
7500
|
host: opts.host,
|
|
7253
7501
|
publicDir,
|
|
7254
|
-
application
|
|
7502
|
+
application: application2
|
|
7255
7503
|
},
|
|
7256
7504
|
serveConfig2
|
|
7257
7505
|
);
|
|
@@ -7262,14 +7510,10 @@ var Registry = class {
|
|
|
7262
7510
|
"registry envoy serve lifecycle did not initialize"
|
|
7263
7511
|
);
|
|
7264
7512
|
}
|
|
7265
|
-
await Promise.all([
|
|
7266
|
-
readyPromise,
|
|
7267
|
-
listenerPromise,
|
|
7268
|
-
serveLifecyclePromise
|
|
7269
|
-
]);
|
|
7513
|
+
await Promise.all([listenerPromise, serveLifecyclePromise]);
|
|
7270
7514
|
return;
|
|
7271
7515
|
}
|
|
7272
|
-
const configuredRegistryPromise = buildConfiguredRegistry(config);
|
|
7516
|
+
const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
|
|
7273
7517
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
7274
7518
|
this.#runtimeServerlessPromise = configuredRegistryPromise;
|
|
7275
7519
|
this.#installSignalHandlers(config);
|
|
@@ -7280,6 +7524,7 @@ var Registry = class {
|
|
|
7280
7524
|
});
|
|
7281
7525
|
this.#ensureServerlessPoolConfigured(config);
|
|
7282
7526
|
const { runtime, registry, serveConfig } = await configuredRegistryPromise;
|
|
7527
|
+
const application = opts.application ? createApplicationFetch(opts.application, runtime) : void 0;
|
|
7283
7528
|
await runtime.serveListener(
|
|
7284
7529
|
registry,
|
|
7285
7530
|
{
|
|
@@ -7300,7 +7545,7 @@ var Registry = class {
|
|
|
7300
7545
|
return jsonRouteResponse(503, {
|
|
7301
7546
|
status: "not_started",
|
|
7302
7547
|
runtime: "rivetkit",
|
|
7303
|
-
version:
|
|
7548
|
+
version: _chunkTAG6UEL5cjs.VERSION
|
|
7304
7549
|
});
|
|
7305
7550
|
}
|
|
7306
7551
|
const { runtime, registry } = configured;
|
|
@@ -7308,7 +7553,7 @@ var Registry = class {
|
|
|
7308
7553
|
return jsonRouteResponse(501, {
|
|
7309
7554
|
status: "unsupported",
|
|
7310
7555
|
runtime: "rivetkit",
|
|
7311
|
-
version:
|
|
7556
|
+
version: _chunkTAG6UEL5cjs.VERSION
|
|
7312
7557
|
});
|
|
7313
7558
|
}
|
|
7314
7559
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7555,7 +7800,7 @@ var Registry = class {
|
|
|
7555
7800
|
);
|
|
7556
7801
|
}
|
|
7557
7802
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
7558
|
-
if (
|
|
7803
|
+
if (_chunkTAG6UEL5cjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
7559
7804
|
return Promise.reject(
|
|
7560
7805
|
new Error(
|
|
7561
7806
|
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
@@ -7625,8 +7870,8 @@ var Registry = class {
|
|
|
7625
7870
|
* ```
|
|
7626
7871
|
*/
|
|
7627
7872
|
start() {
|
|
7628
|
-
if (
|
|
7629
|
-
const publicDir = _nullishCoalesce(
|
|
7873
|
+
if (_chunkTAG6UEL5cjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
7874
|
+
const publicDir = _nullishCoalesce(_chunkTAG6UEL5cjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
7630
7875
|
this.listen({ publicDir }).catch((error) => {
|
|
7631
7876
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
7632
7877
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -7647,7 +7892,7 @@ var Registry = class {
|
|
|
7647
7892
|
};
|
|
7648
7893
|
console.log();
|
|
7649
7894
|
console.log(
|
|
7650
|
-
` RivetKit ${
|
|
7895
|
+
` RivetKit ${_chunkTAG6UEL5cjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
7651
7896
|
);
|
|
7652
7897
|
if (config.namespace !== "default") {
|
|
7653
7898
|
logLine("Namespace", config.namespace);
|
|
@@ -7723,5 +7968,5 @@ function setup(input) {
|
|
|
7723
7968
|
|
|
7724
7969
|
|
|
7725
7970
|
|
|
7726
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
7971
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunkTZPNSOG2cjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunk2JSYYH6Pcjs.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 = _chunk2JSYYH6Pcjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunk2JSYYH6Pcjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkTZPNSOG2cjs.createClientWithDriver; exports.defineRunHandler = _chunk4KGXFC6Mcjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkTAG6UEL5cjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkTAG6UEL5cjs.toUint8Array;
|
|
7727
7972
|
//# sourceMappingURL=mod.cjs.map
|