rivetkit 2.3.9 → 2.3.11-rc.1

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.
Files changed (87) hide show
  1. package/dist/browser/client.d.ts +2 -12
  2. package/dist/browser/client.js +22 -27
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/agent-os/index.cjs +1 -1
  7. package/dist/tsup/agent-os/index.cjs.map +1 -1
  8. package/dist/tsup/agent-os/index.d.cts +2 -12
  9. package/dist/tsup/agent-os/index.d.ts +2 -12
  10. package/dist/tsup/agent-os/index.js +1 -1
  11. package/dist/tsup/agent-os/index.js.map +1 -1
  12. package/dist/tsup/{chunk-S57DMBTM.cjs → chunk-57ZE43T5.cjs} +3 -3
  13. package/dist/tsup/{chunk-S57DMBTM.cjs.map → chunk-57ZE43T5.cjs.map} +1 -1
  14. package/dist/tsup/{chunk-X25YYVFL.js → chunk-5FVMFSBH.js} +2 -2
  15. package/dist/tsup/{chunk-BQU4XTKM.js → chunk-5ZS22TOP.js} +3 -3
  16. package/dist/tsup/{chunk-CQ23UFQ4.js → chunk-6ZPMYIZ6.js} +2 -2
  17. package/dist/tsup/{chunk-UBYPRYJR.js → chunk-ET2F6BXK.js} +2 -2
  18. package/dist/tsup/chunk-ET2F6BXK.js.map +1 -0
  19. package/dist/tsup/{chunk-AVUMOGUE.cjs → chunk-JAQHV6LB.cjs} +7 -7
  20. package/dist/tsup/{chunk-AVUMOGUE.cjs.map → chunk-JAQHV6LB.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-GZ5DYSIR.cjs → chunk-K4DNAIWT.cjs} +4 -4
  22. package/dist/tsup/{chunk-GZ5DYSIR.cjs.map → chunk-K4DNAIWT.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-KVKWTOW7.js → chunk-L4DYLD7P.js} +3 -3
  24. package/dist/tsup/{chunk-MQDQ3A72.js → chunk-MMPE77KO.js} +27 -33
  25. package/dist/tsup/chunk-MMPE77KO.js.map +1 -0
  26. package/dist/tsup/{chunk-M4R2O5NJ.cjs → chunk-TWNMQDZK.cjs} +2 -2
  27. package/dist/tsup/chunk-TWNMQDZK.cjs.map +1 -0
  28. package/dist/tsup/{chunk-3IDKUXQT.cjs → chunk-W2YEXCCJ.cjs} +163 -169
  29. package/dist/tsup/chunk-W2YEXCCJ.cjs.map +1 -0
  30. package/dist/tsup/{chunk-KPP2YRS5.cjs → chunk-XEOPXHN2.cjs} +9 -9
  31. package/dist/tsup/{chunk-KPP2YRS5.cjs.map → chunk-XEOPXHN2.cjs.map} +1 -1
  32. package/dist/tsup/client/mod.cjs +5 -5
  33. package/dist/tsup/client/mod.d.cts +2 -2
  34. package/dist/tsup/client/mod.d.ts +2 -2
  35. package/dist/tsup/client/mod.js +4 -4
  36. package/dist/tsup/common/log.cjs +2 -2
  37. package/dist/tsup/common/log.js +1 -1
  38. package/dist/tsup/common/websocket.cjs +3 -3
  39. package/dist/tsup/common/websocket.js +2 -2
  40. package/dist/tsup/{config-CUymbyM6.d.ts → config-BKAMOHez.d.ts} +2 -12
  41. package/dist/tsup/{config-CpB-e4I9.d.cts → config-Caocy3Z9.d.cts} +2 -12
  42. package/dist/tsup/{context-YBUBTwTS.d.ts → context-AfCExwbr.d.ts} +1 -1
  43. package/dist/tsup/{context-c-6G4mjk.d.cts → context-D1_m5x1D.d.cts} +1 -1
  44. package/dist/tsup/db/drizzle.cjs +2 -2
  45. package/dist/tsup/db/drizzle.js +1 -1
  46. package/dist/tsup/db/mod.cjs +2 -2
  47. package/dist/tsup/db/mod.js +1 -1
  48. package/dist/tsup/dynamic/mod.d.cts +1 -1
  49. package/dist/tsup/dynamic/mod.d.ts +1 -1
  50. package/dist/tsup/inspector/mod.cjs +4 -4
  51. package/dist/tsup/inspector/mod.js +3 -3
  52. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  53. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  54. package/dist/tsup/mod.cjs +131 -341
  55. package/dist/tsup/mod.cjs.map +1 -1
  56. package/dist/tsup/mod.d.cts +3 -3
  57. package/dist/tsup/mod.d.ts +3 -3
  58. package/dist/tsup/mod.js +68 -278
  59. package/dist/tsup/mod.js.map +1 -1
  60. package/dist/tsup/test/mod.cjs +6 -6
  61. package/dist/tsup/test/mod.d.cts +1 -1
  62. package/dist/tsup/test/mod.d.ts +1 -1
  63. package/dist/tsup/test/mod.js +4 -4
  64. package/dist/tsup/utils.cjs +2 -2
  65. package/dist/tsup/utils.js +1 -1
  66. package/dist/tsup/workflow/mod.cjs +6 -6
  67. package/dist/tsup/workflow/mod.d.cts +3 -3
  68. package/dist/tsup/workflow/mod.d.ts +3 -3
  69. package/dist/tsup/workflow/mod.js +3 -3
  70. package/package.json +8 -8
  71. package/src/client/actor-handle.ts +1 -3
  72. package/src/client/raw-utils.ts +0 -8
  73. package/src/common/actor-router-consts.ts +0 -1
  74. package/src/engine-client/actor-http-client.ts +22 -6
  75. package/src/registry/index.ts +11 -51
  76. package/src/registry/napi-runtime.ts +5 -32
  77. package/src/registry/native.ts +63 -110
  78. package/src/registry/runtime.ts +2 -16
  79. package/dist/tsup/chunk-3IDKUXQT.cjs.map +0 -1
  80. package/dist/tsup/chunk-M4R2O5NJ.cjs.map +0 -1
  81. package/dist/tsup/chunk-MQDQ3A72.js.map +0 -1
  82. package/dist/tsup/chunk-UBYPRYJR.js.map +0 -1
  83. package/src/registry/native-http.ts +0 -208
  84. /package/dist/tsup/{chunk-X25YYVFL.js.map → chunk-5FVMFSBH.js.map} +0 -0
  85. /package/dist/tsup/{chunk-BQU4XTKM.js.map → chunk-5ZS22TOP.js.map} +0 -0
  86. /package/dist/tsup/{chunk-CQ23UFQ4.js.map → chunk-6ZPMYIZ6.js.map} +0 -0
  87. /package/dist/tsup/{chunk-KVKWTOW7.js.map → chunk-L4DYLD7P.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 _chunkGZ5DYSIRcjs = require('./chunk-GZ5DYSIR.cjs');
3
+ var _chunkK4DNAIWTcjs = require('./chunk-K4DNAIWT.cjs');
4
4
 
5
5
 
6
6
 
@@ -23,14 +23,13 @@ var _chunkHNHLBM3Ycjs = require('./chunk-HNHLBM3Y.cjs');
23
23
 
24
24
 
25
25
 
26
-
27
- var _chunk3IDKUXQTcjs = require('./chunk-3IDKUXQT.cjs');
26
+ var _chunkW2YEXCCJcjs = require('./chunk-W2YEXCCJ.cjs');
28
27
 
29
28
 
30
29
 
31
30
  var _chunkMYWZCDMLcjs = require('./chunk-MYWZCDML.cjs');
32
31
  require('./chunk-UEULFXUI.cjs');
33
- require('./chunk-S57DMBTM.cjs');
32
+ require('./chunk-57ZE43T5.cjs');
34
33
 
35
34
 
36
35
 
@@ -63,7 +62,7 @@ require('./chunk-S57DMBTM.cjs');
63
62
 
64
63
 
65
64
 
66
- var _chunkM4R2O5NJcjs = require('./chunk-M4R2O5NJ.cjs');
65
+ var _chunkTWNMQDZKcjs = require('./chunk-TWNMQDZK.cjs');
67
66
 
68
67
 
69
68
 
@@ -79,7 +78,7 @@ var _chunk4FC7TVS6cjs = require('./chunk-4FC7TVS6.cjs');
79
78
 
80
79
  // src/actor/log.ts
81
80
  function loggerWithoutContext() {
82
- return _chunkM4R2O5NJcjs.getLogger.call(void 0, "actor-runtime");
81
+ return _chunkTWNMQDZKcjs.getLogger.call(void 0, "actor-runtime");
83
82
  }
84
83
 
85
84
  // src/actor/definition.ts
@@ -219,7 +218,7 @@ function validateSchemaSync(schemas, key, data) {
219
218
  var _virtualwebsocket = require('@rivetkit/virtual-websocket');
220
219
  var _ws = require('hono/ws');
221
220
  function logger() {
222
- return _chunkM4R2O5NJcjs.getLogger.call(void 0, "inline-websocket-adapter");
221
+ return _chunkTWNMQDZKcjs.getLogger.call(void 0, "inline-websocket-adapter");
223
222
  }
224
223
  var InlineWebSocketAdapter = class {
225
224
  #handler;
@@ -390,7 +389,7 @@ function isLocalEngineEndpoint(endpoint) {
390
389
 
391
390
  // src/registry/log.ts
392
391
  function logger2() {
393
- return _chunkM4R2O5NJcjs.getLogger.call(void 0, "registry");
392
+ return _chunkTWNMQDZKcjs.getLogger.call(void 0, "registry");
394
393
  }
395
394
 
396
395
  // src/serverless/configure.ts
@@ -436,8 +435,8 @@ async function configureServerlessPool(config) {
436
435
  );
437
436
  }
438
437
  const customConfig = config.configurePool;
439
- const clientConfig = _chunk3IDKUXQTcjs.convertRegistryConfigToClientConfig.call(void 0, config);
440
- const dcsRes = await _chunk3IDKUXQTcjs.getDatacenters.call(void 0, clientConfig);
438
+ const clientConfig = _chunkW2YEXCCJcjs.convertRegistryConfigToClientConfig.call(void 0, config);
439
+ const dcsRes = await _chunkW2YEXCCJcjs.getDatacenters.call(void 0, clientConfig);
441
440
  const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
442
441
  const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
443
442
  const headers = {
@@ -459,7 +458,7 @@ async function configureServerlessPool(config) {
459
458
  metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
460
459
  drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
461
460
  };
462
- await _chunk3IDKUXQTcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
461
+ await _chunkW2YEXCCJcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
463
462
  datacenters: Object.fromEntries(
464
463
  dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
465
464
  )
@@ -476,7 +475,7 @@ async function configureServerlessPool(config) {
476
475
  logger2().warn({
477
476
  msg: "serverless pool configuration attempt failed",
478
477
  attempts,
479
- error: _chunkM4R2O5NJcjs.stringifyError.call(void 0, error)
478
+ error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
480
479
  });
481
480
  await sleep(CONFIGURE_RETRY_DELAY_MS);
482
481
  }
@@ -484,7 +483,7 @@ async function configureServerlessPool(config) {
484
483
  logger2().error({
485
484
  msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
486
485
  attempts,
487
- error: _chunkM4R2O5NJcjs.stringifyError.call(void 0, lastError)
486
+ error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, lastError)
488
487
  });
489
488
  throw lastError;
490
489
  }
@@ -496,20 +495,20 @@ var _zod = require('zod');
496
495
  var _v4 = require('zod/v4');
497
496
  var warnedMissingVersion = false;
498
497
  var EnvoyConfigSchema = _v4.z.object({
499
- poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetPool.call(void 0, ), () => ( "default"))),
498
+ poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetPool.call(void 0, ), () => ( "default"))),
500
499
  version: _v4.z.number().default(() => {
501
- const version = _chunkM4R2O5NJcjs.getRivetEnvoyVersion.call(void 0, );
500
+ const version = _chunkTWNMQDZKcjs.getRivetEnvoyVersion.call(void 0, );
502
501
  if (version !== void 0) return version;
503
- if (_chunkM4R2O5NJcjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
502
+ if (_chunkTWNMQDZKcjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
504
503
  warnedMissingVersion = true;
505
- _chunkM4R2O5NJcjs.getLogger.call(void 0, "rivetkit").error(
504
+ _chunkTWNMQDZKcjs.getLogger.call(void 0, "rivetkit").error(
506
505
  "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"
507
506
  );
508
507
  }
509
508
  return 1;
510
509
  }),
511
510
  // Deprecated.
512
- totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
511
+ totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
513
512
  envoyKey: _v4.z.string().optional()
514
513
  });
515
514
 
@@ -547,7 +546,7 @@ var ServerlessConfigSchema = _v4.z.object({
547
546
  *
548
547
  * Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
549
548
  */
550
- publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetPublicEndpoint.call(void 0, )))),
549
+ publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetPublicEndpoint.call(void 0, )))),
551
550
  /**
552
551
  * Token that clients should use when connecting via the public endpoint.
553
552
  *
@@ -555,7 +554,7 @@ var ServerlessConfigSchema = _v4.z.object({
555
554
  *
556
555
  * Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
557
556
  */
558
- publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetPublicToken.call(void 0, ))))
557
+ publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetPublicToken.call(void 0, ))))
559
558
  // There is no publicNamespace config option because the frontend and backend
560
559
  // cannot use different namespaces. The namespace is extracted from the
561
560
  // publicEndpoint URL auth syntax if provided.
@@ -609,7 +608,7 @@ var RegistryConfigSchema = _zod.z.object({
609
608
  * Runtime binding to use for RivetKit core.
610
609
  * */
611
610
  runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
612
- const rawRuntime = _nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetkitRuntime.call(void 0, )));
611
+ const rawRuntime = _nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetkitRuntime.call(void 0, )));
613
612
  if (rawRuntime === void 0) {
614
613
  return "auto";
615
614
  }
@@ -646,7 +645,7 @@ var RegistryConfigSchema = _zod.z.object({
646
645
  * */
647
646
  logging: _zod.z.object({
648
647
  baseLogger: _zod.z.custom().optional(),
649
- level: _chunkM4R2O5NJcjs.LogLevelSchema.optional()
648
+ level: _chunkTWNMQDZKcjs.LogLevelSchema.optional()
650
649
  }).optional().default(() => ({})),
651
650
  // MARK: Routing
652
651
  // // This is a function to allow for lazy configuration of upgradeWebSocket on the
@@ -664,9 +663,9 @@ var RegistryConfigSchema = _zod.z.object({
664
663
  *
665
664
  * Can also be set via RIVET_ENDPOINT environment variables.
666
665
  */
667
- endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetEngine.call(void 0, ))), () => ( _chunkM4R2O5NJcjs.getRivetEndpoint.call(void 0, )))),
668
- token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetToken.call(void 0, )))),
669
- namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkM4R2O5NJcjs.getRivetNamespace.call(void 0, )))),
666
+ endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetEngine.call(void 0, ))), () => ( _chunkTWNMQDZKcjs.getRivetEndpoint.call(void 0, )))),
667
+ token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetToken.call(void 0, )))),
668
+ namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkTWNMQDZKcjs.getRivetNamespace.call(void 0, )))),
670
669
  headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
671
670
  // MARK: Client
672
671
  // TODO:
@@ -706,21 +705,21 @@ var RegistryConfigSchema = _zod.z.object({
706
705
  *
707
706
  * Starts the full Rust engine process locally.
708
707
  */
709
- startEngine: _zod.z.boolean().default(() => _chunkM4R2O5NJcjs.getRivetRunEngine.call(void 0, )),
708
+ startEngine: _zod.z.boolean().default(() => _chunkTWNMQDZKcjs.getRivetRunEngine.call(void 0, )),
710
709
  /**
711
710
  * @experimental
712
711
  *
713
712
  * Host to bind the spawned local engine process to.
714
713
  */
715
- engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetRunEngineHost.call(void 0, ), () => ( ENGINE_HOST))),
714
+ engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetRunEngineHost.call(void 0, ), () => ( ENGINE_HOST))),
716
715
  /**
717
716
  * @experimental
718
717
  *
719
718
  * Port to bind the spawned local engine process to.
720
719
  */
721
- enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetRunEnginePort.call(void 0, ), () => ( ENGINE_PORT))),
720
+ enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetRunEnginePort.call(void 0, ), () => ( ENGINE_PORT))),
722
721
  /** @experimental */
723
- engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkM4R2O5NJcjs.VERSION))),
722
+ engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkTWNMQDZKcjs.VERSION))),
724
723
  /**
725
724
  * @experimental
726
725
  *
@@ -768,7 +767,7 @@ var RegistryConfigSchema = _zod.z.object({
768
767
  }))
769
768
  }).transform((config, ctx) => {
770
769
  var _a, _b, _c;
771
- const isDevEnv = _chunkM4R2O5NJcjs.isDev.call(void 0, );
770
+ const isDevEnv = _chunkTWNMQDZKcjs.isDev.call(void 0, );
772
771
  const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
773
772
  if (config.runtime === "wasm" && sqliteBackend === "local") {
774
773
  ctx.addIssue({
@@ -778,7 +777,7 @@ var RegistryConfigSchema = _zod.z.object({
778
777
  });
779
778
  }
780
779
  const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
781
- const parsedEndpoint = config.endpoint ? _chunk3IDKUXQTcjs.tryParseEndpoint.call(void 0, ctx, {
780
+ const parsedEndpoint = config.endpoint ? _chunkW2YEXCCJcjs.tryParseEndpoint.call(void 0, ctx, {
782
781
  endpoint: config.endpoint,
783
782
  path: ["endpoint"],
784
783
  namespace: config.namespace,
@@ -806,7 +805,7 @@ var RegistryConfigSchema = _zod.z.object({
806
805
  );
807
806
  const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
808
807
  const token = _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token));
809
- const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunk3IDKUXQTcjs.tryParseEndpoint.call(void 0, ctx, {
808
+ const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkW2YEXCCJcjs.tryParseEndpoint.call(void 0, ctx, {
810
809
  endpoint: config.serverless.publicEndpoint,
811
810
  path: ["serverless", "publicEndpoint"]
812
811
  }) : void 0;
@@ -909,7 +908,7 @@ var DocRegistryConfigSchema = _zod.z.object({
909
908
  noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
910
909
  sqlite: DocSqliteConfigSchema,
911
910
  logging: _zod.z.object({
912
- level: _chunkM4R2O5NJcjs.LogLevelSchema.optional().describe(
911
+ level: _chunkTWNMQDZKcjs.LogLevelSchema.optional().describe(
913
912
  "Log level for RivetKit. Default: 'warn'"
914
913
  )
915
914
  }).optional().describe("Logging configuration."),
@@ -1441,30 +1440,16 @@ function toNapiApplication(application) {
1441
1440
  if (!request) {
1442
1441
  throw new Error("application fetch callback received no request");
1443
1442
  }
1444
- const response = await application(
1445
- {
1446
- ...request,
1447
- body: new Uint8Array(request.body),
1448
- cancelToken: request.cancelToken
1449
- },
1450
- request.responseBodyStream ? fromNapiHttpResponseBodyStream(
1451
- request.responseBodyStream
1452
- ) : void 0
1453
- );
1443
+ const response = await application({
1444
+ ...request,
1445
+ body: new Uint8Array(request.body)
1446
+ });
1454
1447
  return {
1455
1448
  ...response,
1456
- body: response.body === void 0 ? void 0 : toNapiBuffer(response.body)
1449
+ body: toNapiBuffer(response.body)
1457
1450
  };
1458
1451
  };
1459
1452
  }
1460
- function fromNapiHttpResponseBodyStream(stream) {
1461
- return {
1462
- cancelled: () => stream.cancelled(),
1463
- write: (chunk) => stream.write(Buffer.from(chunk)),
1464
- end: () => stream.end(),
1465
- error: (message) => stream.error(message)
1466
- };
1467
- }
1468
1453
  function toNapiHttpRequest(request) {
1469
1454
  if (!request) {
1470
1455
  return request;
@@ -1977,137 +1962,6 @@ async function loadNapiRuntime() {
1977
1962
  };
1978
1963
  }
1979
1964
 
1980
- // src/registry/native-http.ts
1981
- var HTTP_BODY_CHUNK_SIZE = 64 * 1024;
1982
- function runtimeBytesToArrayBuffer(value) {
1983
- return value.buffer.slice(
1984
- value.byteOffset,
1985
- value.byteOffset + value.byteLength
1986
- );
1987
- }
1988
- function buildNativeHttpRequest(init) {
1989
- var _a;
1990
- const headers = new Headers(init.headers);
1991
- const originalUrl = headers.get(_chunk3IDKUXQTcjs.HEADER_ORIGINAL_REQUEST_URL);
1992
- headers.delete(_chunk3IDKUXQTcjs.HEADER_ORIGINAL_REQUEST_URL);
1993
- const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
1994
- const method2 = init.method.toUpperCase();
1995
- const bodyForbidden = method2 === "GET" || method2 === "HEAD";
1996
- const body = bodyForbidden ? void 0 : init.bodyStream ? new ReadableStream({
1997
- async pull(controller) {
1998
- var _a2, _b;
1999
- try {
2000
- if (init.body && init.body.length > 0) {
2001
- controller.enqueue(new Uint8Array(init.body));
2002
- init.body = void 0;
2003
- return;
2004
- }
2005
- const chunk = await ((_a2 = init.bodyStream) == null ? void 0 : _a2.read());
2006
- if (!chunk) {
2007
- controller.close();
2008
- } else {
2009
- controller.enqueue(new Uint8Array(chunk));
2010
- }
2011
- } catch (error) {
2012
- (_b = init.abortController) == null ? void 0 : _b.abort(error);
2013
- controller.error(error);
2014
- }
2015
- },
2016
- async cancel() {
2017
- var _a2;
2018
- await ((_a2 = init.bodyStream) == null ? void 0 : _a2.cancel());
2019
- }
2020
- }) : init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
2021
- const streamInit = init.bodyStream && !bodyForbidden ? { duplex: "half" } : {};
2022
- return new Request(url, {
2023
- method: method2,
2024
- headers,
2025
- body,
2026
- signal: _nullishCoalesce(((_a = init.abortController) == null ? void 0 : _a.signal), () => ( init.signal)),
2027
- ...streamInit
2028
- });
2029
- }
2030
- async function cancelNativeHttpRequestBody(bodyStream) {
2031
- await (bodyStream == null ? void 0 : bodyStream.cancel());
2032
- }
2033
- async function writeResponseChunk(stream, chunk) {
2034
- for (let offset = 0; offset < chunk.byteLength; offset += HTTP_BODY_CHUNK_SIZE) {
2035
- await stream.write(
2036
- chunk.subarray(offset, offset + HTTP_BODY_CHUNK_SIZE)
2037
- );
2038
- }
2039
- }
2040
- async function pumpResponseBody(reader, stream) {
2041
- var _a;
2042
- const cancelled = stream.cancelled().then(() => ({ cancelled: true }));
2043
- try {
2044
- for (; ; ) {
2045
- const read = reader.read().then((next2) => ({ cancelled: false, next: next2 }));
2046
- const result = await Promise.race([read, cancelled]);
2047
- if (result.cancelled) {
2048
- await reader.cancel(
2049
- new Error("native http response stream receiver dropped")
2050
- );
2051
- return;
2052
- }
2053
- const { next } = result;
2054
- if (next.done) {
2055
- await stream.end();
2056
- return;
2057
- }
2058
- if ((_a = next.value) == null ? void 0 : _a.byteLength) {
2059
- await writeResponseChunk(stream, next.value);
2060
- }
2061
- }
2062
- } catch (error) {
2063
- try {
2064
- await stream.error(_chunkM4R2O5NJcjs.stringifyError.call(void 0, error));
2065
- } catch (streamError) {
2066
- logger2().debug({
2067
- msg: "failed to report native http response stream error",
2068
- error: streamError
2069
- });
2070
- }
2071
- try {
2072
- await reader.cancel(error);
2073
- } catch (e3) {
2074
- }
2075
- } finally {
2076
- reader.releaseLock();
2077
- }
2078
- }
2079
- async function convertNativeHttpResponse(response, responseBodyStream) {
2080
- const headers = Object.fromEntries(response.headers.entries());
2081
- if (!response.body) {
2082
- return {
2083
- response: {
2084
- status: response.status,
2085
- headers,
2086
- body: new Uint8Array()
2087
- }
2088
- };
2089
- }
2090
- if (responseBodyStream) {
2091
- const reader = response.body.getReader();
2092
- const bodyCompletion = pumpResponseBody(reader, responseBodyStream);
2093
- return {
2094
- response: {
2095
- status: response.status,
2096
- headers,
2097
- stream: true
2098
- },
2099
- bodyCompletion
2100
- };
2101
- }
2102
- return {
2103
- response: {
2104
- status: response.status,
2105
- headers,
2106
- body: new Uint8Array(await response.arrayBuffer())
2107
- }
2108
- };
2109
- }
2110
-
2111
1965
  // src/registry/native-validation.ts
2112
1966
  var CONN_PARAMS_KEY = "__conn_params__";
2113
1967
  function validateActionArgs(schemas, name, args) {
@@ -2954,7 +2808,7 @@ function trySetProcessEnv(key, value) {
2954
2808
  if (typeof process === "undefined") return;
2955
2809
  try {
2956
2810
  process.env[key] = value;
2957
- } catch (e4) {
2811
+ } catch (e3) {
2958
2812
  }
2959
2813
  }
2960
2814
  function detectRuntimeHost() {
@@ -2991,7 +2845,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
2991
2845
  }
2992
2846
  try {
2993
2847
  return (await loaders.loadNative()).runtime;
2994
- } catch (e5) {
2848
+ } catch (e4) {
2995
2849
  return (await loaders.loadWasm(config.wasm)).runtime;
2996
2850
  }
2997
2851
  }
@@ -3165,7 +3019,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
3165
3019
  }).catch((error) => {
3166
3020
  logger2().warn({
3167
3021
  msg: "deferred native sleep cleanup failed",
3168
- error: _chunkM4R2O5NJcjs.stringifyError.call(void 0, error)
3022
+ error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
3169
3023
  });
3170
3024
  });
3171
3025
  return;
@@ -3242,7 +3096,7 @@ function toRuntimeBytes(value) {
3242
3096
  function arrayBufferViewToRuntimeBytes(value) {
3243
3097
  return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
3244
3098
  }
3245
- function runtimeBytesToArrayBuffer2(value) {
3099
+ function runtimeBytesToArrayBuffer(value) {
3246
3100
  return value.buffer.slice(
3247
3101
  value.byteOffset,
3248
3102
  value.byteOffset + value.byteLength
@@ -3292,10 +3146,10 @@ function decodeValue(value) {
3292
3146
  if (!value || value.length === 0) {
3293
3147
  return void 0;
3294
3148
  }
3295
- return _chunkM4R2O5NJcjs.decodeCborCompat.call(void 0, value);
3149
+ return _chunkTWNMQDZKcjs.decodeCborCompat.call(void 0, value);
3296
3150
  }
3297
3151
  function encodeValue(value) {
3298
- return _chunkM4R2O5NJcjs.encodeCborCompat.call(void 0, value);
3152
+ return _chunkTWNMQDZKcjs.encodeCborCompat.call(void 0, value);
3299
3153
  }
3300
3154
  function normalizeArgs(value) {
3301
3155
  return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
@@ -3331,7 +3185,7 @@ function isStructuredBridgeError(error) {
3331
3185
  return _chunk4FC7TVS6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
3332
3186
  }
3333
3187
  function encodeNativeCallbackError(error) {
3334
- const structuredError = isStructuredBridgeError(error) ? error : _chunkM4R2O5NJcjs.deconstructError.call(void 0, error, true);
3188
+ const structuredError = isStructuredBridgeError(error) ? error : _chunkTWNMQDZKcjs.deconstructError.call(void 0, error, true);
3335
3189
  const bridgeError = new Error(_chunk4FC7TVS6cjs.encodeBridgeRivetError.call(void 0, structuredError), {
3336
3190
  cause: error instanceof Error ? error : void 0
3337
3191
  });
@@ -3381,8 +3235,8 @@ function decodeWorkflowCbor(data) {
3381
3235
  return null;
3382
3236
  }
3383
3237
  try {
3384
- return _chunkM4R2O5NJcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
3385
- } catch (e6) {
3238
+ return _chunkTWNMQDZKcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
3239
+ } catch (e5) {
3386
3240
  return null;
3387
3241
  }
3388
3242
  }
@@ -3494,7 +3348,7 @@ function serializeWorkflowHistoryForJson(data) {
3494
3348
  if (data === null) {
3495
3349
  return null;
3496
3350
  }
3497
- const history = _chunkGZ5DYSIRcjs.decodeWorkflowHistoryTransport.call(void 0, data);
3351
+ const history = _chunkK4DNAIWTcjs.decodeWorkflowHistoryTransport.call(void 0, data);
3498
3352
  return jsonSafe({
3499
3353
  nameRegistry: [...history.nameRegistry],
3500
3354
  entries: history.entries.map((entry) => ({
@@ -3572,6 +3426,24 @@ function decodeArgs(value) {
3572
3426
  const decoded = decodeValue(value);
3573
3427
  return normalizeArgs(decoded);
3574
3428
  }
3429
+ function buildRequest(init) {
3430
+ const url = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
3431
+ const body = init.body && init.body.length > 0 ? runtimeBytesToArrayBuffer(init.body) : void 0;
3432
+ return new Request(url, {
3433
+ method: init.method,
3434
+ headers: init.headers,
3435
+ body
3436
+ });
3437
+ }
3438
+ async function toRuntimeHttpResponse(response) {
3439
+ const headers = Object.fromEntries(response.headers.entries());
3440
+ const body = new Uint8Array(await response.arrayBuffer());
3441
+ return {
3442
+ status: response.status,
3443
+ headers,
3444
+ body
3445
+ };
3446
+ }
3575
3447
  function toActorKey(segments) {
3576
3448
  return segments.map(
3577
3449
  (segment) => segment.kind === "number" ? String(_nullishCoalesce(segment.numberValue, () => ( 0))) : _nullishCoalesce(segment.stringValue, () => ( ""))
@@ -3617,12 +3489,12 @@ var NativeConnAdapter = class {
3617
3489
  this.#writeState(nextValue, { writeNative: true });
3618
3490
  },
3619
3491
  (newValue) => {
3620
- _chunkM4R2O5NJcjs.assertJsonCompatValue.call(void 0, newValue);
3492
+ _chunkTWNMQDZKcjs.assertJsonCompatValue.call(void 0, newValue);
3621
3493
  }
3622
3494
  );
3623
3495
  }
3624
3496
  set state(value) {
3625
- _chunkM4R2O5NJcjs.assertJsonCompatValue.call(void 0, value);
3497
+ _chunkTWNMQDZKcjs.assertJsonCompatValue.call(void 0, value);
3626
3498
  this.#writeState(value, { writeNative: true });
3627
3499
  }
3628
3500
  initializeState(value) {
@@ -4236,7 +4108,7 @@ var NativeWebSocketAdapter = class {
4236
4108
  this.#runtime.webSocketSetEventCallback(this.#ws, (event2) => {
4237
4109
  if (event2.kind === "message") {
4238
4110
  this.#virtual.triggerMessage(
4239
- event2.binary ? runtimeBytesToArrayBuffer2(event2.data) : event2.data,
4111
+ event2.binary ? runtimeBytesToArrayBuffer(event2.data) : event2.data,
4240
4112
  event2.messageIndex
4241
4113
  );
4242
4114
  return;
@@ -4668,7 +4540,7 @@ var ActorContextHandleAdapter = class {
4668
4540
  },
4669
4541
  (newValue) => {
4670
4542
  this.#assertCanMutateState();
4671
- _chunkM4R2O5NJcjs.assertJsonCompatValue.call(void 0, newValue);
4543
+ _chunkTWNMQDZKcjs.assertJsonCompatValue.call(void 0, newValue);
4672
4544
  }
4673
4545
  );
4674
4546
  }
@@ -4679,7 +4551,7 @@ var ActorContextHandleAdapter = class {
4679
4551
  throw stateNotEnabledError();
4680
4552
  }
4681
4553
  this.#assertCanMutateState();
4682
- _chunkM4R2O5NJcjs.assertJsonCompatValue.call(void 0, value);
4554
+ _chunkTWNMQDZKcjs.assertJsonCompatValue.call(void 0, value);
4683
4555
  this.#writeState(value, { scheduleSave: true });
4684
4556
  }
4685
4557
  initializeState(value) {
@@ -4955,7 +4827,7 @@ var ActorContextHandleAdapter = class {
4955
4827
  const trackedPromise = Promise.resolve(promise).catch((error) => {
4956
4828
  logger2().warn({
4957
4829
  msg: "keepAwake promise rejected",
4958
- error: _chunkM4R2O5NJcjs.stringifyError.call(void 0, error)
4830
+ error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
4959
4831
  });
4960
4832
  }).then(() => null);
4961
4833
  try {
@@ -5417,9 +5289,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5417
5289
  events: config.events,
5418
5290
  queues: config.queues
5419
5291
  };
5420
- const createClient = () => _chunk3IDKUXQTcjs.createClientWithDriver.call(void 0,
5421
- new (0, _chunk3IDKUXQTcjs.RemoteEngineControlClient)(
5422
- _chunk3IDKUXQTcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
5292
+ const createClient = () => _chunkW2YEXCCJcjs.createClientWithDriver.call(void 0,
5293
+ new (0, _chunkW2YEXCCJcjs.RemoteEngineControlClient)(
5294
+ _chunkW2YEXCCJcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
5423
5295
  ),
5424
5296
  { encoding: "bare" }
5425
5297
  );
@@ -5468,14 +5340,12 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5468
5340
  onStateChange,
5469
5341
  cancelToken
5470
5342
  );
5471
- const maybeHandleNativeInspectorRequest = async (ctx, rawRequest) => {
5343
+ const maybeHandleNativeInspectorRequest = async (ctx, _rawRequest, jsRequest) => {
5472
5344
  var _a2, _b, _c, _d;
5473
- const rawUrl = rawRequest.uri.startsWith("http") ? rawRequest.uri : new URL(rawRequest.uri, "http://127.0.0.1").toString();
5474
- const url = new URL(rawUrl);
5345
+ const url = new URL(jsRequest.url);
5475
5346
  if (!url.pathname.startsWith("/inspector/")) {
5476
5347
  return void 0;
5477
5348
  }
5478
- const jsRequest = buildNativeHttpRequest(rawRequest);
5479
5349
  const jsonResponse = (body, init) => new Response(JSON.stringify(body), {
5480
5350
  status: _nullishCoalesce((init == null ? void 0 : init.status), () => ( 200)),
5481
5351
  headers: {
@@ -5581,7 +5451,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5581
5451
  let body;
5582
5452
  try {
5583
5453
  body = await jsRequest.json();
5584
- } catch (e7) {
5454
+ } catch (e6) {
5585
5455
  return errorResponse(
5586
5456
  new (0, _chunk4FC7TVS6cjs.RivetError)(
5587
5457
  "actor",
@@ -5604,7 +5474,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5604
5474
  400
5605
5475
  );
5606
5476
  }
5607
- const cbor = _chunkM4R2O5NJcjs.encodeCborCompat.call(void 0,
5477
+ const cbor = _chunkTWNMQDZKcjs.encodeCborCompat.call(void 0,
5608
5478
  _nullishCoalesce(body.body, () => ( null))
5609
5479
  );
5610
5480
  const message = await runtime.actorQueueSend(ctx, name, cbor);
@@ -6006,7 +5876,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6006
5876
  );
6007
5877
  const actorCtx = makeActorCtx(
6008
5878
  ctx,
6009
- request ? buildNativeHttpRequest(request) : void 0
5879
+ request ? buildRequest(request) : void 0
6010
5880
  );
6011
5881
  try {
6012
5882
  await config.onBeforeConnect(
@@ -6026,7 +5896,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6026
5896
  const { ctx, conn, params, request } = unwrapTsfnPayload(error, payload);
6027
5897
  const actorCtx = makeActorCtx(
6028
5898
  ctx,
6029
- request ? buildNativeHttpRequest(request) : void 0
5899
+ request ? buildRequest(request) : void 0
6030
5900
  );
6031
5901
  const connAdapter = new NativeConnAdapter(
6032
5902
  runtime,
@@ -6063,7 +5933,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6063
5933
  );
6064
5934
  const actorCtx = makeActorCtx(
6065
5935
  ctx,
6066
- request ? buildNativeHttpRequest(request) : void 0
5936
+ request ? buildRequest(request) : void 0
6067
5937
  );
6068
5938
  const connAdapter = new NativeConnAdapter(
6069
5939
  runtime,
@@ -6168,45 +6038,27 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6168
6038
  onRequest: wrapNativeCallback(
6169
6039
  async (error, payload) => {
6170
6040
  try {
6171
- const { ctx, request, cancelToken, responseBodyStream } = unwrapTsfnPayload(error, payload);
6172
- const inspectorResponse = await maybeHandleNativeInspectorRequest(ctx, request);
6041
+ const { ctx, request, cancelToken } = unwrapTsfnPayload(
6042
+ error,
6043
+ payload
6044
+ );
6045
+ const jsRequest = buildRequest(request);
6046
+ const inspectorResponse = await maybeHandleNativeInspectorRequest(
6047
+ ctx,
6048
+ request,
6049
+ jsRequest
6050
+ );
6173
6051
  if (inspectorResponse) {
6174
- await cancelNativeHttpRequestBody(request.bodyStream);
6175
- return (await convertNativeHttpResponse(
6176
- inspectorResponse,
6177
- responseBodyStream
6178
- )).response;
6052
+ return await toRuntimeHttpResponse(inspectorResponse);
6179
6053
  }
6180
6054
  if (typeof config.onRequest !== "function") {
6181
- await cancelNativeHttpRequestBody(request.bodyStream);
6182
- return (await convertNativeHttpResponse(
6183
- new Response(null, { status: 404 }),
6184
- responseBodyStream
6185
- )).response;
6055
+ return await toRuntimeHttpResponse(
6056
+ new Response(null, { status: 404 })
6057
+ );
6186
6058
  }
6187
- const requestAbortController = new AbortController();
6188
- const handlerRequest = buildNativeHttpRequest({
6189
- ...request,
6190
- abortController: requestAbortController
6191
- });
6192
- const rawConnParams = handlerRequest.headers.get(_chunk3IDKUXQTcjs.HEADER_CONN_PARAMS);
6059
+ const rawConnParams = jsRequest.headers.get(_chunkW2YEXCCJcjs.HEADER_CONN_PARAMS);
6193
6060
  let requestCtx;
6194
6061
  let conn;
6195
- let removeRequestAbortListener;
6196
- let cleanupDeferredToBody = false;
6197
- let cleanedUp = false;
6198
- const cleanupRequest = async () => {
6199
- if (cleanedUp) return;
6200
- cleanedUp = true;
6201
- removeRequestAbortListener == null ? void 0 : removeRequestAbortListener();
6202
- try {
6203
- await (requestCtx == null ? void 0 : requestCtx.dispose());
6204
- } finally {
6205
- if (conn) {
6206
- await runtime.connDisconnect(conn);
6207
- }
6208
- }
6209
- };
6210
6062
  try {
6211
6063
  const connParams = validateConnParams(
6212
6064
  schemaConfig.connParamsSchema,
@@ -6222,56 +6074,23 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6222
6074
  requestCtx = makeConnCtx(
6223
6075
  ctx,
6224
6076
  conn,
6225
- handlerRequest,
6077
+ jsRequest,
6226
6078
  cancelToken
6227
6079
  );
6228
- const ctxAbortSignal = requestCtx.abortSignal;
6229
- const abortRequest = () => requestAbortController.abort(ctxAbortSignal.reason);
6230
- if (ctxAbortSignal.aborted) {
6231
- abortRequest();
6232
- } else {
6233
- ctxAbortSignal.addEventListener(
6234
- "abort",
6235
- abortRequest,
6236
- { once: true }
6237
- );
6238
- removeRequestAbortListener = () => ctxAbortSignal.removeEventListener(
6239
- "abort",
6240
- abortRequest
6241
- );
6242
- }
6243
6080
  const response = await config.onRequest(
6244
6081
  requestCtx,
6245
- handlerRequest
6082
+ jsRequest
6246
6083
  );
6247
- if (!_chunk3IDKUXQTcjs.isResponseLike.call(void 0, response)) {
6084
+ if (!_chunkW2YEXCCJcjs.isResponseLike.call(void 0, response)) {
6248
6085
  throw new Error(
6249
6086
  "onRequest handler must return a Response"
6250
6087
  );
6251
6088
  }
6252
- const conversion = await convertNativeHttpResponse(
6253
- response,
6254
- responseBodyStream
6255
- );
6256
- if (conversion.bodyCompletion) {
6257
- cleanupDeferredToBody = true;
6258
- void conversion.bodyCompletion.then(cleanupRequest).catch((cleanupError) => {
6259
- logger2().error({
6260
- msg: "failed to clean up native streaming http request",
6261
- error: cleanupError
6262
- });
6263
- });
6264
- }
6265
- return conversion.response;
6089
+ return await toRuntimeHttpResponse(response);
6266
6090
  } finally {
6267
- try {
6268
- await cancelNativeHttpRequestBody(
6269
- request.bodyStream
6270
- );
6271
- } finally {
6272
- if (!cleanupDeferredToBody) {
6273
- await cleanupRequest();
6274
- }
6091
+ await (requestCtx == null ? void 0 : requestCtx.dispose());
6092
+ if (conn) {
6093
+ await runtime.connDisconnect(conn);
6275
6094
  }
6276
6095
  }
6277
6096
  } catch (error2) {
@@ -6286,7 +6105,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6286
6105
  onWebSocket: typeof config.onWebSocket === "function" ? wrapNativeCallback(
6287
6106
  async (error, payload) => {
6288
6107
  const { ctx, conn, ws, request } = unwrapTsfnPayload(error, payload);
6289
- const jsRequest = request ? buildNativeHttpRequest(request) : void 0;
6108
+ const jsRequest = request ? buildRequest(request) : void 0;
6290
6109
  const actorCtx = makeConnCtx(ctx, conn, jsRequest);
6291
6110
  try {
6292
6111
  await config.onWebSocket(
@@ -6383,7 +6202,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6383
6202
  timeoutMs,
6384
6203
  cancelToken
6385
6204
  } = unwrapTsfnPayload(error, payload);
6386
- const jsRequest = buildNativeHttpRequest(request);
6205
+ const jsRequest = buildRequest(request);
6387
6206
  const actorCtx = withConnContext(
6388
6207
  runtime,
6389
6208
  ctx,
@@ -6465,7 +6284,7 @@ async function buildServeConfig(config) {
6465
6284
  poolName: config.envoy.poolName,
6466
6285
  handleInspectorHttpInRuntime: true,
6467
6286
  serverlessBasePath: config.serverless.basePath,
6468
- serverlessPackageVersion: _chunkM4R2O5NJcjs.VERSION,
6287
+ serverlessPackageVersion: _chunkTWNMQDZKcjs.VERSION,
6469
6288
  serverlessClientEndpoint: config.publicEndpoint,
6470
6289
  serverlessClientNamespace: config.publicNamespace,
6471
6290
  serverlessClientToken: config.publicToken,
@@ -6478,19 +6297,19 @@ async function buildServeConfig(config) {
6478
6297
  } catch (error) {
6479
6298
  logger2().warn({
6480
6299
  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",
6481
- error: _chunkM4R2O5NJcjs.stringifyError.call(void 0, error)
6300
+ error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
6482
6301
  });
6483
6302
  }
6484
6303
  serveConfig.engineHost = config.engineHost;
6485
6304
  serveConfig.enginePort = config.enginePort;
6486
6305
  if ((_a = config.test) == null ? void 0 : _a.enabled) {
6487
- serveConfig.inspectorTestToken = _nullishCoalesce(_chunkM4R2O5NJcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
6306
+ serveConfig.inspectorTestToken = _nullishCoalesce(_chunkTWNMQDZKcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
6488
6307
  }
6489
6308
  return serveConfig;
6490
6309
  }
6491
6310
  async function buildRegistryWithRuntime(config, runtime) {
6492
6311
  var _a;
6493
- if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkM4R2O5NJcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
6312
+ if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkTWNMQDZKcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
6494
6313
  trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
6495
6314
  }
6496
6315
  if (runtime.kind === "napi") {
@@ -6534,51 +6353,26 @@ function finishShutdownSignal(signal) {
6534
6353
  }
6535
6354
  process.kill(process.pid, signal);
6536
6355
  }
6537
- function createApplicationFetch(application, runtime) {
6538
- return async (request, responseBodyStream) => {
6356
+ function createApplicationFetch(application) {
6357
+ return async (request) => {
6539
6358
  const method2 = request.method.toUpperCase();
6540
6359
  const body = method2 === "GET" || method2 === "HEAD" || request.body.length === 0 ? void 0 : Uint8Array.from(request.body).buffer;
6541
- const abortController = new AbortController();
6542
- if (request.cancelToken) {
6543
- if (runtime.cancellationTokenAborted(request.cancelToken)) {
6544
- abortController.abort();
6545
- } else {
6546
- runtime.onCancellationTokenCancelled(
6547
- request.cancelToken,
6548
- () => abortController.abort()
6549
- );
6550
- }
6551
- }
6552
6360
  const response = await application.fetch(
6553
6361
  new Request(request.url, {
6554
6362
  method: method2,
6555
6363
  headers: request.headers,
6556
- body,
6557
- signal: abortController.signal
6364
+ body
6558
6365
  })
6559
6366
  );
6560
- if (!_chunk3IDKUXQTcjs.isResponseLike.call(void 0, response)) {
6367
+ if (!_chunkW2YEXCCJcjs.isResponseLike.call(void 0, response)) {
6561
6368
  throw new TypeError(
6562
6369
  "registry.listen() application fetch must return a Response"
6563
6370
  );
6564
6371
  }
6565
- const conversion = await convertNativeHttpResponse(
6566
- response,
6567
- responseBodyStream
6568
- );
6569
- if (conversion.bodyCompletion) {
6570
- void conversion.bodyCompletion.catch((error) => {
6571
- logger2().error({
6572
- msg: "application response stream failed",
6573
- error
6574
- });
6575
- });
6576
- }
6577
6372
  return {
6578
- status: _nullishCoalesce(conversion.response.status, () => ( response.status)),
6579
- headers: _nullishCoalesce(conversion.response.headers, () => ( Object.fromEntries(response.headers.entries()))),
6580
- body: conversion.response.body,
6581
- stream: conversion.response.stream
6373
+ status: response.status,
6374
+ headers: Object.fromEntries(response.headers.entries()),
6375
+ body: new Uint8Array(await response.arrayBuffer())
6582
6376
  };
6583
6377
  };
6584
6378
  }
@@ -6607,7 +6401,7 @@ var Registry = class {
6607
6401
  var _a;
6608
6402
  this.#config = config;
6609
6403
  if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
6610
- _chunkM4R2O5NJcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
6404
+ _chunkTWNMQDZKcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
6611
6405
  }
6612
6406
  this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
6613
6407
  this.routes = {
@@ -6833,10 +6627,11 @@ var Registry = class {
6833
6627
  * ```
6834
6628
  */
6835
6629
  async listen(opts = {}) {
6836
- const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkM4R2O5NJcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
6837
- const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkM4R2O5NJcjs.getRivetkitPublicDir.call(void 0, )));
6630
+ const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkTWNMQDZKcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
6631
+ const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkTWNMQDZKcjs.getRivetkitPublicDir.call(void 0, )));
6838
6632
  const config = this.parseConfig();
6839
- if (opts.application && _chunkM4R2O5NJcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
6633
+ const application = opts.application ? createApplicationFetch(opts.application) : void 0;
6634
+ if (application && _chunkTWNMQDZKcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
6840
6635
  if (config.runtime === "wasm") {
6841
6636
  throw new Error(
6842
6637
  "registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
@@ -6855,18 +6650,13 @@ var Registry = class {
6855
6650
  throw new Error("registry envoy startup did not initialize");
6856
6651
  }
6857
6652
  const { runtime: runtime2, registry: registry2, serveConfig: serveConfig2 } = await configuredRegistryPromise2;
6858
- const application2 = createApplicationFetch(
6859
- opts.application,
6860
- runtime2
6861
- );
6862
- await readyPromise;
6863
6653
  const listenerPromise = runtime2.serveApplicationListener(
6864
6654
  registry2,
6865
6655
  {
6866
6656
  port,
6867
6657
  host: opts.host,
6868
6658
  publicDir,
6869
- application: application2
6659
+ application
6870
6660
  },
6871
6661
  serveConfig2
6872
6662
  );
@@ -6878,12 +6668,13 @@ var Registry = class {
6878
6668
  );
6879
6669
  }
6880
6670
  await Promise.all([
6671
+ readyPromise,
6881
6672
  listenerPromise,
6882
6673
  serveLifecyclePromise
6883
6674
  ]);
6884
6675
  return;
6885
6676
  }
6886
- const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
6677
+ const configuredRegistryPromise = buildConfiguredRegistry(config);
6887
6678
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
6888
6679
  this.#runtimeServerlessPromise = configuredRegistryPromise;
6889
6680
  this.#installSignalHandlers(config);
@@ -6894,7 +6685,6 @@ var Registry = class {
6894
6685
  });
6895
6686
  this.#ensureServerlessPoolConfigured(config);
6896
6687
  const { runtime, registry, serveConfig } = await configuredRegistryPromise;
6897
- const application = opts.application ? createApplicationFetch(opts.application, runtime) : void 0;
6898
6688
  await runtime.serveListener(
6899
6689
  registry,
6900
6690
  {
@@ -6915,7 +6705,7 @@ var Registry = class {
6915
6705
  return jsonRouteResponse(503, {
6916
6706
  status: "not_started",
6917
6707
  runtime: "rivetkit",
6918
- version: _chunkM4R2O5NJcjs.VERSION
6708
+ version: _chunkTWNMQDZKcjs.VERSION
6919
6709
  });
6920
6710
  }
6921
6711
  const { runtime, registry } = configured;
@@ -6923,7 +6713,7 @@ var Registry = class {
6923
6713
  return jsonRouteResponse(501, {
6924
6714
  status: "unsupported",
6925
6715
  runtime: "rivetkit",
6926
- version: _chunkM4R2O5NJcjs.VERSION
6716
+ version: _chunkTWNMQDZKcjs.VERSION
6927
6717
  });
6928
6718
  }
6929
6719
  const response = await runtime.registryHealth(registry);
@@ -7170,7 +6960,7 @@ var Registry = class {
7170
6960
  );
7171
6961
  }
7172
6962
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
7173
- if (_chunkM4R2O5NJcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
6963
+ if (_chunkTWNMQDZKcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
7174
6964
  return Promise.reject(
7175
6965
  new Error(
7176
6966
  "registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
@@ -7240,8 +7030,8 @@ var Registry = class {
7240
7030
  * ```
7241
7031
  */
7242
7032
  start() {
7243
- if (_chunkM4R2O5NJcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
7244
- const publicDir = _nullishCoalesce(_chunkM4R2O5NJcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
7033
+ if (_chunkTWNMQDZKcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
7034
+ const publicDir = _nullishCoalesce(_chunkTWNMQDZKcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
7245
7035
  this.listen({ publicDir }).catch((error) => {
7246
7036
  logger2().error({ error }, "auto-listen failed; exiting");
7247
7037
  if (typeof process !== "undefined" && typeof process.exit === "function") {
@@ -7262,7 +7052,7 @@ var Registry = class {
7262
7052
  };
7263
7053
  console.log();
7264
7054
  console.log(
7265
- ` RivetKit ${_chunkM4R2O5NJcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
7055
+ ` RivetKit ${_chunkTWNMQDZKcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
7266
7056
  );
7267
7057
  if (config.namespace !== "default") {
7268
7058
  logLine("Namespace", config.namespace);
@@ -7337,5 +7127,5 @@ function setup(input) {
7337
7127
 
7338
7128
 
7339
7129
 
7340
- exports.ALLOWED_PUBLIC_HEADERS = _chunk3IDKUXQTcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunk4FC7TVS6cjs.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 = _chunk4FC7TVS6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunk4FC7TVS6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunk3IDKUXQTcjs.createClientWithDriver; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkM4R2O5NJcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkM4R2O5NJcjs.toUint8Array;
7130
+ exports.ALLOWED_PUBLIC_HEADERS = _chunkW2YEXCCJcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunk4FC7TVS6cjs.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 = _chunk4FC7TVS6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunk4FC7TVS6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkW2YEXCCJcjs.createClientWithDriver; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkTWNMQDZKcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkTWNMQDZKcjs.toUint8Array;
7341
7131
  //# sourceMappingURL=mod.cjs.map