rivetkit 0.0.0-sqlite-sync-3-0-1-final.5663d2f → 0.0.0-sqlite-sync-3-0-6-final.cf8679c

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 (118) hide show
  1. package/dist/browser/client.d.ts +103 -27
  2. package/dist/browser/client.js +2 -2
  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/{chunk-DGU2H5IJ.cjs → chunk-275ZGRSG.cjs} +3 -3
  7. package/dist/tsup/{chunk-DGU2H5IJ.cjs.map → chunk-275ZGRSG.cjs.map} +1 -1
  8. package/dist/tsup/{chunk-X567WA3N.cjs → chunk-E54YPM4V.cjs} +10 -10
  9. package/dist/tsup/{chunk-X567WA3N.cjs.map → chunk-E54YPM4V.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-6UDO6UYM.cjs → chunk-I26AW6BG.cjs} +2 -2
  11. package/dist/tsup/{chunk-6UDO6UYM.cjs.map → chunk-I26AW6BG.cjs.map} +1 -1
  12. package/dist/tsup/{chunk-C2NON6V4.cjs → chunk-JHHUCWBC.cjs} +7 -7
  13. package/dist/tsup/{chunk-C2NON6V4.cjs.map → chunk-JHHUCWBC.cjs.map} +1 -1
  14. package/dist/tsup/{chunk-XLD6TRSE.cjs → chunk-LYXPQB6H.cjs} +3 -3
  15. package/dist/tsup/{chunk-XLD6TRSE.cjs.map → chunk-LYXPQB6H.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-DU7V4SDK.js → chunk-M72ZKQ7R.js} +2 -2
  17. package/dist/tsup/{chunk-DU7V4SDK.js.map → chunk-M72ZKQ7R.js.map} +1 -1
  18. package/dist/tsup/{chunk-3ZKCK6NL.js → chunk-ME74LHJM.js} +7 -7
  19. package/dist/tsup/chunk-ME74LHJM.js.map +1 -0
  20. package/dist/tsup/{chunk-UXDASKP6.js → chunk-PBIQPYE5.js} +12 -13
  21. package/dist/tsup/chunk-PBIQPYE5.js.map +1 -0
  22. package/dist/tsup/{chunk-TTMWSZZA.js → chunk-R4QCQBB4.js} +2 -2
  23. package/dist/tsup/{chunk-GAFMEUAL.js → chunk-RJ7WDGOJ.js} +3 -3
  24. package/dist/tsup/{chunk-YJ2X5STT.cjs → chunk-SJJWJU26.cjs} +145 -145
  25. package/dist/tsup/chunk-SJJWJU26.cjs.map +1 -0
  26. package/dist/tsup/{chunk-SEKTNJU6.js → chunk-SSMFNH4N.js} +4 -4
  27. package/dist/tsup/{chunk-EKERHPCE.cjs → chunk-TKCX6KNZ.cjs} +4 -4
  28. package/dist/tsup/{chunk-EKERHPCE.cjs.map → chunk-TKCX6KNZ.cjs.map} +1 -1
  29. package/dist/tsup/{chunk-G26OT2Q6.cjs → chunk-TVBQQXQE.cjs} +3 -3
  30. package/dist/tsup/{chunk-G26OT2Q6.cjs.map → chunk-TVBQQXQE.cjs.map} +1 -1
  31. package/dist/tsup/{chunk-YNAEH775.js → chunk-VXVJHTW6.js} +2 -2
  32. package/dist/tsup/{chunk-MT4SROQM.js → chunk-XATHAIZX.js} +2 -2
  33. package/dist/tsup/{chunk-T7DJZSPH.js → chunk-Y5TV6V5Z.js} +2 -2
  34. package/dist/tsup/{chunk-SSF2XC33.cjs → chunk-YWWDUC6D.cjs} +12 -13
  35. package/dist/tsup/chunk-YWWDUC6D.cjs.map +1 -0
  36. package/dist/tsup/client/mod.cjs +5 -5
  37. package/dist/tsup/client/mod.d.cts +3 -3
  38. package/dist/tsup/client/mod.d.ts +3 -3
  39. package/dist/tsup/client/mod.js +4 -4
  40. package/dist/tsup/common/log.cjs +2 -2
  41. package/dist/tsup/common/log.js +1 -1
  42. package/dist/tsup/common/websocket.cjs +3 -3
  43. package/dist/tsup/common/websocket.js +2 -2
  44. package/dist/tsup/{config-RMLak20L.d.cts → config-5K0rzjv1.d.cts} +57 -25
  45. package/dist/tsup/{config-BfG1qpYz.d.ts → config-Df5jOcde.d.cts} +50 -8
  46. package/dist/tsup/{config-BfG1qpYz.d.cts → config-Df5jOcde.d.ts} +50 -8
  47. package/dist/tsup/{config-CASGH-5t.d.ts → config-DsAjIyfZ.d.ts} +57 -25
  48. package/dist/tsup/{context-C1tMYvV-.d.ts → context-B19Rx5Zg.d.cts} +5 -2
  49. package/dist/tsup/{context-CxNE2KvK.d.cts → context-BEh8x4jn.d.ts} +5 -2
  50. package/dist/tsup/db/drizzle.cjs +2 -2
  51. package/dist/tsup/db/drizzle.d.cts +1 -1
  52. package/dist/tsup/db/drizzle.d.ts +1 -1
  53. package/dist/tsup/db/drizzle.js +1 -1
  54. package/dist/tsup/db/mod.cjs +3 -3
  55. package/dist/tsup/db/mod.d.cts +2 -2
  56. package/dist/tsup/db/mod.d.ts +2 -2
  57. package/dist/tsup/db/mod.js +2 -2
  58. package/dist/tsup/dynamic/mod.cjs +2 -2
  59. package/dist/tsup/dynamic/mod.d.cts +2 -2
  60. package/dist/tsup/dynamic/mod.d.ts +2 -2
  61. package/dist/tsup/dynamic/mod.js +1 -1
  62. package/dist/tsup/inspector/mod.cjs +5 -5
  63. package/dist/tsup/inspector/mod.js +4 -4
  64. package/dist/tsup/inspector/workflow.cjs +4 -4
  65. package/dist/tsup/inspector/workflow.js +3 -3
  66. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  67. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  68. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  69. package/dist/tsup/inspector-tab/mod.js +1 -1
  70. package/dist/tsup/mod.cjs +255 -135
  71. package/dist/tsup/mod.cjs.map +1 -1
  72. package/dist/tsup/mod.d.cts +6 -4
  73. package/dist/tsup/mod.d.ts +6 -4
  74. package/dist/tsup/mod.js +152 -32
  75. package/dist/tsup/mod.js.map +1 -1
  76. package/dist/tsup/test/mod.cjs +6 -6
  77. package/dist/tsup/test/mod.d.cts +2 -2
  78. package/dist/tsup/test/mod.d.ts +2 -2
  79. package/dist/tsup/test/mod.js +4 -4
  80. package/dist/tsup/unstable/migrations.d.cts +1 -1
  81. package/dist/tsup/unstable/migrations.d.ts +1 -1
  82. package/dist/tsup/utils.cjs +2 -2
  83. package/dist/tsup/utils.js +1 -1
  84. package/dist/tsup/workflow/mod.cjs +13 -10
  85. package/dist/tsup/workflow/mod.cjs.map +1 -1
  86. package/dist/tsup/workflow/mod.d.cts +4 -4
  87. package/dist/tsup/workflow/mod.d.ts +4 -4
  88. package/dist/tsup/workflow/mod.js +8 -5
  89. package/dist/tsup/workflow/mod.js.map +1 -1
  90. package/package.json +9 -9
  91. package/src/actor/config.ts +41 -29
  92. package/src/actor/contexts/index.ts +2 -0
  93. package/src/actor/definition.ts +33 -1
  94. package/src/actor/schema.ts +4 -0
  95. package/src/client/actor-common.ts +4 -0
  96. package/src/client/actor-conn.ts +2 -0
  97. package/src/client/actor-handle.ts +2 -0
  98. package/src/client/config.ts +1 -1
  99. package/src/client/queue.ts +2 -0
  100. package/src/common/database/config.ts +50 -7
  101. package/src/db/mod.ts +1 -0
  102. package/src/registry/index.ts +142 -1
  103. package/src/registry/napi-runtime.ts +15 -4
  104. package/src/registry/native.ts +4 -11
  105. package/src/registry/runtime.ts +6 -8
  106. package/src/registry/wasm-runtime.ts +0 -14
  107. package/src/workflow/context.ts +3 -0
  108. package/dist/tsup/chunk-3ZKCK6NL.js.map +0 -1
  109. package/dist/tsup/chunk-SSF2XC33.cjs.map +0 -1
  110. package/dist/tsup/chunk-UXDASKP6.js.map +0 -1
  111. package/dist/tsup/chunk-YJ2X5STT.cjs.map +0 -1
  112. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +0 -848
  113. /package/dist/tsup/{chunk-TTMWSZZA.js.map → chunk-R4QCQBB4.js.map} +0 -0
  114. /package/dist/tsup/{chunk-GAFMEUAL.js.map → chunk-RJ7WDGOJ.js.map} +0 -0
  115. /package/dist/tsup/{chunk-SEKTNJU6.js.map → chunk-SSMFNH4N.js.map} +0 -0
  116. /package/dist/tsup/{chunk-YNAEH775.js.map → chunk-VXVJHTW6.js.map} +0 -0
  117. /package/dist/tsup/{chunk-MT4SROQM.js.map → chunk-XATHAIZX.js.map} +0 -0
  118. /package/dist/tsup/{chunk-T7DJZSPH.js.map → chunk-Y5TV6V5Z.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 _chunkEKERHPCEcjs = require('./chunk-EKERHPCE.cjs');
3
+ var _chunkTKCX6KNZcjs = require('./chunk-TKCX6KNZ.cjs');
4
4
 
5
5
 
6
6
 
@@ -17,7 +17,7 @@ var _chunkEKERHPCEcjs = require('./chunk-EKERHPCE.cjs');
17
17
 
18
18
 
19
19
 
20
- var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
20
+ var _chunkYWWDUC6Dcjs = require('./chunk-YWWDUC6D.cjs');
21
21
 
22
22
 
23
23
 
@@ -35,18 +35,18 @@ var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
35
35
 
36
36
 
37
37
 
38
- var _chunkYJ2X5STTcjs = require('./chunk-YJ2X5STT.cjs');
38
+ var _chunkSJJWJU26cjs = require('./chunk-SJJWJU26.cjs');
39
39
 
40
40
 
41
41
 
42
42
  var _chunkRTWH3AX3cjs = require('./chunk-RTWH3AX3.cjs');
43
- require('./chunk-G26OT2Q6.cjs');
44
43
 
45
44
 
46
45
 
47
46
 
48
- var _chunkXLD6TRSEcjs = require('./chunk-XLD6TRSE.cjs');
47
+ var _chunkLYXPQB6Hcjs = require('./chunk-LYXPQB6H.cjs');
49
48
  require('./chunk-KVFIONKQ.cjs');
49
+ require('./chunk-TVBQQXQE.cjs');
50
50
 
51
51
 
52
52
 
@@ -80,7 +80,7 @@ require('./chunk-KVFIONKQ.cjs');
80
80
 
81
81
 
82
82
 
83
- var _chunk6UDO6UYMcjs = require('./chunk-6UDO6UYM.cjs');
83
+ var _chunkI26AW6BGcjs = require('./chunk-I26AW6BG.cjs');
84
84
 
85
85
 
86
86
 
@@ -98,7 +98,7 @@ var _chunkMGI2VVF6cjs = require('./chunk-MGI2VVF6.cjs');
98
98
 
99
99
  // src/actor/log.ts
100
100
  function loggerWithoutContext() {
101
- return _chunk6UDO6UYMcjs.getLogger.call(void 0, "actor-runtime");
101
+ return _chunkI26AW6BGcjs.getLogger.call(void 0, "actor-runtime");
102
102
  }
103
103
 
104
104
  // src/actor/definition.ts
@@ -116,11 +116,25 @@ function warnDeprecatedOptionKeys(options) {
116
116
  if (opts[key] !== void 0 && !warnedDeprecatedOptionKeys.has(key)) {
117
117
  warnedDeprecatedOptionKeys.add(key);
118
118
  loggerWithoutContext().warn({
119
- msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 2.2.0.`
119
+ msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 3.2.0.`
120
120
  });
121
121
  }
122
122
  }
123
123
  }
124
+ var warnedDeprecatedRun = false;
125
+ function warnDeprecatedRun(input) {
126
+ if (warnedDeprecatedRun || !input || typeof input !== "object") return;
127
+ const run = input.run;
128
+ if (run === void 0) return;
129
+ const runFunction = typeof run === "object" && run !== null ? run.run : run;
130
+ if (typeof runFunction === "function" && _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, runFunction) === "workflow") {
131
+ return;
132
+ }
133
+ warnedDeprecatedRun = true;
134
+ loggerWithoutContext().warn({
135
+ msg: "actor option `run` with a plain function was deprecated in 3.0 and will be removed in a future version. Start background work from `onWake` with `c.keepAwake` and track it in `c.vars`. `run: workflow(...)` is not deprecated. See https://rivet.dev/actors/docs/deprecated/run"
136
+ });
137
+ }
124
138
  var ActorDefinition = class {
125
139
  #config;
126
140
  constructor(config) {
@@ -138,10 +152,11 @@ function actor(input) {
138
152
  warnDeprecatedOptionKeys(
139
153
  input == null ? void 0 : input.options
140
154
  );
141
- const config = _chunkSSF2XC33cjs.ActorConfigSchema.parse(input);
142
- _chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
143
- _chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
144
- _chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
155
+ warnDeprecatedRun(input);
156
+ const config = _chunkYWWDUC6Dcjs.ActorConfigSchema.parse(input);
157
+ _chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions);
158
+ _chunkYWWDUC6Dcjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
159
+ _chunkYWWDUC6Dcjs.flattenActionTraceSamplers.call(void 0, config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
145
160
  return new ActorDefinition(config);
146
161
  }
147
162
  function isStaticActorDefinition(definition) {
@@ -240,7 +255,7 @@ function validateSchemaSync(schemas, key, data) {
240
255
  var _virtualwebsocket = require('@rivetkit/virtual-websocket');
241
256
  var _ws = require('hono/ws');
242
257
  function logger() {
243
- return _chunk6UDO6UYMcjs.getLogger.call(void 0, "inline-websocket-adapter");
258
+ return _chunkI26AW6BGcjs.getLogger.call(void 0, "inline-websocket-adapter");
244
259
  }
245
260
  var InlineWebSocketAdapter = class {
246
261
  #handler;
@@ -392,7 +407,7 @@ var InlineWebSocketAdapter = class {
392
407
 
393
408
  // src/registry/log.ts
394
409
  function logger2() {
395
- return _chunk6UDO6UYMcjs.getLogger.call(void 0, "registry");
410
+ return _chunkI26AW6BGcjs.getLogger.call(void 0, "registry");
396
411
  }
397
412
 
398
413
  // src/serverless/configure.ts
@@ -438,8 +453,8 @@ async function configureServerlessPool(config) {
438
453
  );
439
454
  }
440
455
  const customConfig = config.configurePool;
441
- const clientConfig = _chunkYJ2X5STTcjs.convertRegistryConfigToClientConfig.call(void 0, config);
442
- const dcsRes = await _chunkYJ2X5STTcjs.getDatacenters.call(void 0, clientConfig);
456
+ const clientConfig = _chunkSJJWJU26cjs.convertRegistryConfigToClientConfig.call(void 0, config);
457
+ const dcsRes = await _chunkSJJWJU26cjs.getDatacenters.call(void 0, clientConfig);
443
458
  const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
444
459
  const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
445
460
  const headers = {
@@ -461,7 +476,7 @@ async function configureServerlessPool(config) {
461
476
  metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
462
477
  drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
463
478
  };
464
- await _chunkYJ2X5STTcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
479
+ await _chunkSJJWJU26cjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
465
480
  datacenters: Object.fromEntries(
466
481
  dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
467
482
  )
@@ -478,7 +493,7 @@ async function configureServerlessPool(config) {
478
493
  logger2().warn({
479
494
  msg: "serverless pool configuration attempt failed",
480
495
  attempts,
481
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, error)
496
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
482
497
  });
483
498
  await sleep(CONFIGURE_RETRY_DELAY_MS);
484
499
  }
@@ -486,7 +501,7 @@ async function configureServerlessPool(config) {
486
501
  logger2().error({
487
502
  msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
488
503
  attempts,
489
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, lastError)
504
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, lastError)
490
505
  });
491
506
  throw lastError;
492
507
  }
@@ -497,10 +512,10 @@ var _zod = require('zod');
497
512
  // src/registry/config/envoy.ts
498
513
  var _v4 = require('zod/v4');
499
514
  var EnvoyConfigSchema = _v4.z.object({
500
- poolName: _v4.z.string().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetPool.call(void 0, ), () => ( "default"))),
501
- version: _v4.z.number().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
515
+ poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetPool.call(void 0, ), () => ( "default"))),
516
+ version: _v4.z.number().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
502
517
  // Deprecated.
503
- totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
518
+ totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
504
519
  nodeKey: _v4.z.string().optional()
505
520
  });
506
521
 
@@ -538,7 +553,7 @@ var ServerlessConfigSchema = _v4.z.object({
538
553
  *
539
554
  * Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
540
555
  */
541
- publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetPublicEndpoint.call(void 0, )))),
556
+ publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetPublicEndpoint.call(void 0, )))),
542
557
  /**
543
558
  * Token that clients should use when connecting via the public endpoint.
544
559
  *
@@ -546,7 +561,7 @@ var ServerlessConfigSchema = _v4.z.object({
546
561
  *
547
562
  * Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
548
563
  */
549
- publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetPublicToken.call(void 0, ))))
564
+ publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetPublicToken.call(void 0, ))))
550
565
  // There is no publicNamespace config option because the frontend and backend
551
566
  // cannot use different namespaces. The namespace is extracted from the
552
567
  // publicEndpoint URL auth syntax if provided.
@@ -600,7 +615,7 @@ var RegistryConfigSchema = _zod.z.object({
600
615
  * Runtime binding to use for RivetKit core.
601
616
  * */
602
617
  runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
603
- const rawRuntime = _nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetkitRuntime.call(void 0, )));
618
+ const rawRuntime = _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetkitRuntime.call(void 0, )));
604
619
  if (rawRuntime === void 0) {
605
620
  return "auto";
606
621
  }
@@ -637,7 +652,7 @@ var RegistryConfigSchema = _zod.z.object({
637
652
  * */
638
653
  logging: _zod.z.object({
639
654
  baseLogger: _zod.z.custom().optional(),
640
- level: _chunk6UDO6UYMcjs.LogLevelSchema.optional()
655
+ level: _chunkI26AW6BGcjs.LogLevelSchema.optional()
641
656
  }).optional().default(() => ({})),
642
657
  // MARK: Routing
643
658
  // // This is a function to allow for lazy configuration of upgradeWebSocket on the
@@ -655,9 +670,9 @@ var RegistryConfigSchema = _zod.z.object({
655
670
  *
656
671
  * Can also be set via RIVET_ENDPOINT environment variables.
657
672
  */
658
- endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetEngine.call(void 0, ))), () => ( _chunk6UDO6UYMcjs.getRivetEndpoint.call(void 0, )))),
659
- token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetToken.call(void 0, )))),
660
- namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunk6UDO6UYMcjs.getRivetNamespace.call(void 0, )))),
673
+ endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetEngine.call(void 0, ))), () => ( _chunkI26AW6BGcjs.getRivetEndpoint.call(void 0, )))),
674
+ token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetToken.call(void 0, )))),
675
+ namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkI26AW6BGcjs.getRivetNamespace.call(void 0, )))),
661
676
  headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
662
677
  // MARK: Client
663
678
  // TODO:
@@ -697,21 +712,21 @@ var RegistryConfigSchema = _zod.z.object({
697
712
  *
698
713
  * Starts the full Rust engine process locally.
699
714
  */
700
- startEngine: _zod.z.boolean().default(() => _chunk6UDO6UYMcjs.getRivetRunEngine.call(void 0, )),
715
+ startEngine: _zod.z.boolean().default(() => _chunkI26AW6BGcjs.getRivetRunEngine.call(void 0, )),
701
716
  /**
702
717
  * @experimental
703
718
  *
704
719
  * Host to bind the spawned local engine process to.
705
720
  */
706
- engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunkYJ2X5STTcjs.ENGINE_HOST))),
721
+ engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunkSJJWJU26cjs.ENGINE_HOST))),
707
722
  /**
708
723
  * @experimental
709
724
  *
710
725
  * Port to bind the spawned local engine process to.
711
726
  */
712
- enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunkYJ2X5STTcjs.ENGINE_PORT))),
727
+ enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunkSJJWJU26cjs.ENGINE_PORT))),
713
728
  /** @experimental */
714
- engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunk6UDO6UYMcjs.VERSION))),
729
+ engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkI26AW6BGcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkI26AW6BGcjs.VERSION))),
715
730
  /**
716
731
  * Starts the first-party Services actor host when RivetKit manages
717
732
  * a local engine. Enabled by default for a managed local Engine. Set
@@ -768,7 +783,7 @@ var RegistryConfigSchema = _zod.z.object({
768
783
  }))
769
784
  }).transform((config, ctx) => {
770
785
  var _a, _b, _c;
771
- const isDevEnv = _chunk6UDO6UYMcjs.isDev.call(void 0, );
786
+ const isDevEnv = _chunkI26AW6BGcjs.isDev.call(void 0, );
772
787
  const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
773
788
  if (config.runtime === "wasm" && sqliteBackend === "local") {
774
789
  ctx.addIssue({
@@ -778,7 +793,7 @@ var RegistryConfigSchema = _zod.z.object({
778
793
  });
779
794
  }
780
795
  const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
781
- const parsedEndpoint = config.endpoint ? _chunkYJ2X5STTcjs.tryParseEndpoint.call(void 0, ctx, {
796
+ const parsedEndpoint = config.endpoint ? _chunkSJJWJU26cjs.tryParseEndpoint.call(void 0, ctx, {
782
797
  endpoint: config.endpoint,
783
798
  path: ["endpoint"],
784
799
  namespace: config.namespace,
@@ -797,19 +812,19 @@ var RegistryConfigSchema = _zod.z.object({
797
812
  path: ["configurePool"]
798
813
  });
799
814
  }
800
- const localEngineEndpoint = _chunkYJ2X5STTcjs.buildEngineEndpoint.call(void 0,
815
+ const localEngineEndpoint = _chunkSJJWJU26cjs.buildEngineEndpoint.call(void 0,
801
816
  config.engineHost,
802
817
  config.enginePort
803
818
  );
804
819
  const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
805
820
  const engineSpawn = !parsedEndpoint && Boolean(endpoint);
806
- const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunk6UDO6UYMcjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
821
+ const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkI26AW6BGcjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
807
822
  const validateServerlessEndpoint = Boolean(
808
823
  config.startEngine || parsedEndpoint
809
824
  );
810
825
  const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
811
- const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunkYJ2X5STTcjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
812
- const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkYJ2X5STTcjs.tryParseEndpoint.call(void 0, ctx, {
826
+ const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
827
+ const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkSJJWJU26cjs.tryParseEndpoint.call(void 0, ctx, {
813
828
  endpoint: config.serverless.publicEndpoint,
814
829
  path: ["serverless", "publicEndpoint"]
815
830
  }) : void 0;
@@ -846,7 +861,7 @@ function buildActorNames(config) {
846
861
  Object.keys(config.use).map((actorName) => {
847
862
  const definition = config.use[actorName];
848
863
  const options = _nullishCoalesce(definition.config.options, () => ( {}));
849
- const runMeta = _chunkSSF2XC33cjs.getRunMetadata.call(void 0, definition.config.run);
864
+ const runMeta = _chunkYWWDUC6Dcjs.getRunMetadata.call(void 0, definition.config.run);
850
865
  const metadata = {};
851
866
  metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
852
867
  metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
@@ -914,7 +929,7 @@ var DocRegistryConfigSchema = _zod.z.object({
914
929
  noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
915
930
  sqlite: DocSqliteConfigSchema,
916
931
  logging: _zod.z.object({
917
- level: _chunk6UDO6UYMcjs.LogLevelSchema.optional().describe(
932
+ level: _chunkI26AW6BGcjs.LogLevelSchema.optional().describe(
918
933
  "Log level for RivetKit. Default: 'warn'"
919
934
  )
920
935
  }).optional().describe("Logging configuration."),
@@ -1695,7 +1710,7 @@ var NapiCoreRuntime = (_class = class {
1695
1710
  if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
1696
1711
  return ownerCtx;
1697
1712
  }
1698
- const applicationSpan = _chunkYJ2X5STTcjs.readActiveTraceHeaders.call(void 0, );
1713
+ const applicationSpan = _chunkSJJWJU26cjs.readActiveTraceHeaders.call(void 0, );
1699
1714
  if (!applicationSpan) {
1700
1715
  return active;
1701
1716
  }
@@ -1740,6 +1755,15 @@ var NapiCoreRuntime = (_class = class {
1740
1755
  async registryActorStopThresholdMs(registry) {
1741
1756
  return await _asyncNullishCoalesce(await asNativeRegistry(registry).actorStopThresholdMs(), async () => ( void 0));
1742
1757
  }
1758
+ registryActiveActorCount(registry) {
1759
+ return asNativeRegistry(registry).activeActorCount();
1760
+ }
1761
+ onRegistryActiveActorCountChange(registry, callback, cancelToken) {
1762
+ asNativeRegistry(registry).onActiveActorCountChange(
1763
+ callback,
1764
+ asNativeCancellationToken(cancelToken)
1765
+ );
1766
+ }
1743
1767
  async registryHealth(registry) {
1744
1768
  const response = await asNativeRegistry(registry).health();
1745
1769
  return {
@@ -1899,7 +1923,7 @@ var NapiCoreRuntime = (_class = class {
1899
1923
  const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
1900
1924
  return this.#invocationContext.run(
1901
1925
  nativeCtx,
1902
- () => _chunkYJ2X5STTcjs.runWithActorInvocationSpan.call(void 0, span, run)
1926
+ () => _chunkSJJWJU26cjs.runWithActorInvocationSpan.call(void 0, span, run)
1903
1927
  );
1904
1928
  }
1905
1929
  actorInvocationTraceContext(ctx) {
@@ -2161,9 +2185,6 @@ var NapiCoreRuntime = (_class = class {
2161
2185
  }
2162
2186
  await nativeCtx.sql().close();
2163
2187
  }
2164
- async actorRuntimeSocketProvision(ctx) {
2165
- return await asNativeActorContext(ctx).provisionActorRuntimeSocket();
2166
- }
2167
2188
  async actorQueueSend(ctx, name, body) {
2168
2189
  return toNapiQueueMessage(
2169
2190
  await this.#actorContextForOperation(ctx).queue().send(name, toNapiBuffer(body))
@@ -2318,8 +2339,8 @@ function runtimeBytesToArrayBuffer(value) {
2318
2339
  function buildNativeHttpRequest(init) {
2319
2340
  var _a;
2320
2341
  const headers = new Headers(init.headers);
2321
- const originalUrl = headers.get(_chunkYJ2X5STTcjs.HEADER_ORIGINAL_REQUEST_URL);
2322
- headers.delete(_chunkYJ2X5STTcjs.HEADER_ORIGINAL_REQUEST_URL);
2342
+ const originalUrl = headers.get(_chunkSJJWJU26cjs.HEADER_ORIGINAL_REQUEST_URL);
2343
+ headers.delete(_chunkSJJWJU26cjs.HEADER_ORIGINAL_REQUEST_URL);
2323
2344
  const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
2324
2345
  const method2 = init.method.toUpperCase();
2325
2346
  const bodyForbidden = method2 === "GET" || method2 === "HEAD";
@@ -2398,7 +2419,7 @@ async function pumpResponseBody(reader, stream) {
2398
2419
  }
2399
2420
  } catch (error) {
2400
2421
  try {
2401
- await stream.error(_chunk6UDO6UYMcjs.stringifyError.call(void 0, error));
2422
+ await stream.error(_chunkI26AW6BGcjs.stringifyError.call(void 0, error));
2402
2423
  } catch (streamError) {
2403
2424
  logger2().debug({
2404
2425
  msg: "failed to report native http response stream error",
@@ -2566,7 +2587,7 @@ var RunHandlerCoordinator = class {
2566
2587
  this.#run = run;
2567
2588
  }
2568
2589
  get inspectorKind() {
2569
- return _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, this.#run);
2590
+ return _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, this.#run);
2570
2591
  }
2571
2592
  async run(actorId, restart, callback) {
2572
2593
  const state = this.#getOrCreate(actorId);
@@ -2674,7 +2695,7 @@ var RunHandlerCoordinator = class {
2674
2695
  }
2675
2696
  #initializeInspector(actorId, state) {
2676
2697
  if (state.inspectorInitialized) return;
2677
- const inspector = _chunkSSF2XC33cjs.createRunInspector.call(void 0, this.#run, {
2698
+ const inspector = _chunkYWWDUC6Dcjs.createRunInspector.call(void 0, this.#run, {
2678
2699
  actorId,
2679
2700
  control: this.#control(actorId, state)
2680
2701
  });
@@ -3297,17 +3318,6 @@ var WasmCoreRuntime = (_class2 = class {
3297
3318
  this.#sql.delete(wasmCtx);
3298
3319
  await callWasm(() => database.close());
3299
3320
  }
3300
- async actorRuntimeSocketProvision(_ctx) {
3301
- throw new (0, _chunkMGI2VVF6cjs.RivetError)(
3302
- "actor_runtime_socket",
3303
- "unsupported",
3304
- "Actor Runtime Socket is only available on Unix native runtimes.",
3305
- {
3306
- public: true,
3307
- metadata: { runtime: "wasm" }
3308
- }
3309
- );
3310
- }
3311
3321
  async actorQueueSend(ctx, name, body) {
3312
3322
  const queue2 = childHandle(asWasmActorContext(ctx), "queue");
3313
3323
  return normalizeQueueMessage(
@@ -3688,7 +3698,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
3688
3698
  nativeError = error;
3689
3699
  logger2().warn({
3690
3700
  msg: "native runtime failed to load; falling back to wasm",
3691
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, error)
3701
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
3692
3702
  });
3693
3703
  }
3694
3704
  try {
@@ -3697,7 +3707,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
3697
3707
  throw new (0, _chunkMGI2VVF6cjs.RivetError)(
3698
3708
  "config",
3699
3709
  "runtime_unavailable",
3700
- `RivetKit could not load a core runtime. Native runtime: ${_chunk6UDO6UYMcjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunk6UDO6UYMcjs.stringifyError.call(void 0, wasmError)}`,
3710
+ `RivetKit could not load a core runtime. Native runtime: ${_chunkI26AW6BGcjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunkI26AW6BGcjs.stringifyError.call(void 0, wasmError)}`,
3701
3711
  {
3702
3712
  public: true,
3703
3713
  statusCode: 500
@@ -3905,7 +3915,7 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
3905
3915
  }).catch((error) => {
3906
3916
  logger2().warn({
3907
3917
  msg: "deferred native sleep cleanup failed",
3908
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, error)
3918
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
3909
3919
  });
3910
3920
  });
3911
3921
  return;
@@ -4095,10 +4105,10 @@ function decodeValue(value) {
4095
4105
  if (!value || value.length === 0) {
4096
4106
  return void 0;
4097
4107
  }
4098
- return _chunk6UDO6UYMcjs.decodeCborCompat.call(void 0, value);
4108
+ return _chunkI26AW6BGcjs.decodeCborCompat.call(void 0, value);
4099
4109
  }
4100
4110
  function encodeValue(value) {
4101
- return _chunk6UDO6UYMcjs.encodeCborCompat.call(void 0, value);
4111
+ return _chunkI26AW6BGcjs.encodeCborCompat.call(void 0, value);
4102
4112
  }
4103
4113
  function normalizeArgs(value) {
4104
4114
  return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
@@ -4134,7 +4144,7 @@ function isStructuredBridgeError(error) {
4134
4144
  return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
4135
4145
  }
4136
4146
  function encodeNativeCallbackError(error) {
4137
- const structuredError = isStructuredBridgeError(error) ? error : _chunk6UDO6UYMcjs.deconstructError.call(void 0, error, true);
4147
+ const structuredError = isStructuredBridgeError(error) ? error : _chunkI26AW6BGcjs.deconstructError.call(void 0, error, true);
4138
4148
  const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
4139
4149
  if (droppedMetadataCause !== void 0) {
4140
4150
  logger2().warn(
@@ -4196,7 +4206,7 @@ function decodeWorkflowCbor(data) {
4196
4206
  return null;
4197
4207
  }
4198
4208
  try {
4199
- return _chunk6UDO6UYMcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
4209
+ return _chunkI26AW6BGcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
4200
4210
  } catch (e3) {
4201
4211
  return null;
4202
4212
  }
@@ -4309,7 +4319,7 @@ function serializeWorkflowHistoryForJson(data) {
4309
4319
  if (data === null) {
4310
4320
  return null;
4311
4321
  }
4312
- const history = _chunkEKERHPCEcjs.decodeWorkflowHistoryTransport.call(void 0, data);
4322
+ const history = _chunkTKCX6KNZcjs.decodeWorkflowHistoryTransport.call(void 0, data);
4313
4323
  return jsonSafe({
4314
4324
  nameRegistry: [...history.nameRegistry],
4315
4325
  entries: history.entries.map((entry) => ({
@@ -4408,7 +4418,7 @@ var NativeConnAdapter = class {
4408
4418
  this.#ctx = ctx;
4409
4419
  this.#queueHibernationRemoval = queueHibernationRemoval;
4410
4420
  this.#assertCanMutateState = assertCanMutateState;
4411
- this[_chunkSSF2XC33cjs.CONN_STATE_MANAGER_SYMBOL] = {
4421
+ this[_chunkYWWDUC6Dcjs.CONN_STATE_MANAGER_SYMBOL] = {
4412
4422
  stateEnabled: true,
4413
4423
  get state() {
4414
4424
  return thisConn.state;
@@ -4425,7 +4435,7 @@ var NativeConnAdapter = class {
4425
4435
  decodeValue(this.#runtime.connParams(this.#conn))
4426
4436
  );
4427
4437
  }
4428
- [_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
4438
+ [_chunkYWWDUC6Dcjs.RAW_STATE_SYMBOL]() {
4429
4439
  return this.#readState();
4430
4440
  }
4431
4441
  get state() {
@@ -4455,7 +4465,7 @@ var NativeConnAdapter = class {
4455
4465
  },
4456
4466
  (newValue) => {
4457
4467
  assertCurrentState();
4458
- _chunk6UDO6UYMcjs.assertJsonCompatValue.call(void 0, newValue);
4468
+ _chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, newValue);
4459
4469
  }
4460
4470
  );
4461
4471
  }
@@ -4463,7 +4473,7 @@ var NativeConnAdapter = class {
4463
4473
  var _a;
4464
4474
  (_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
4465
4475
  const nextValue = unwrapWriteThroughProxy(value);
4466
- _chunk6UDO6UYMcjs.assertJsonCompatValue.call(void 0, nextValue);
4476
+ _chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, nextValue);
4467
4477
  this.#writeState(nextValue, { writeNative: true });
4468
4478
  }
4469
4479
  initializeState(value) {
@@ -5482,7 +5492,7 @@ var ActorContextHandleAdapter = class {
5482
5492
  this.#databaseProvider = databaseProvider;
5483
5493
  }
5484
5494
  this.#request = request;
5485
- this[_chunkSSF2XC33cjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
5495
+ this[_chunkYWWDUC6Dcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
5486
5496
  this,
5487
5497
  () => this.#logByInvocationScope.delete(
5488
5498
  _nullishCoalesce(this.#runtime.currentInvocationScope(), () => ( NO_INVOCATION_SCOPE))
@@ -5495,11 +5505,6 @@ var ActorContextHandleAdapter = class {
5495
5505
  }
5496
5506
  return this.#kv;
5497
5507
  }
5498
- async actorRuntimeSocket() {
5499
- return await callNative(
5500
- () => this.#runtime.actorRuntimeSocketProvision(this.#ctx)
5501
- );
5502
- }
5503
5508
  get db() {
5504
5509
  if (!this.#databaseProvider) {
5505
5510
  throw databaseNotConfiguredError();
@@ -5515,7 +5520,7 @@ var ActorContextHandleAdapter = class {
5515
5520
  }
5516
5521
  throw databaseClientNotReadyError();
5517
5522
  }
5518
- [_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
5523
+ [_chunkYWWDUC6Dcjs.RAW_STATE_SYMBOL]() {
5519
5524
  if (!this.#stateEnabled) {
5520
5525
  throw stateNotEnabledError();
5521
5526
  }
@@ -5542,7 +5547,7 @@ var ActorContextHandleAdapter = class {
5542
5547
  },
5543
5548
  (newValue) => {
5544
5549
  assertCurrentState();
5545
- _chunk6UDO6UYMcjs.assertJsonCompatValue.call(void 0, newValue);
5550
+ _chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, newValue);
5546
5551
  }
5547
5552
  );
5548
5553
  }
@@ -5554,7 +5559,7 @@ var ActorContextHandleAdapter = class {
5554
5559
  }
5555
5560
  this.#assertCanMutateState();
5556
5561
  const nextValue = unwrapWriteThroughProxy(value);
5557
- _chunk6UDO6UYMcjs.assertJsonCompatValue.call(void 0, nextValue);
5562
+ _chunkI26AW6BGcjs.assertJsonCompatValue.call(void 0, nextValue);
5558
5563
  this.#writeState(nextValue, { scheduleSave: true });
5559
5564
  }
5560
5565
  initializeState(value) {
@@ -5768,7 +5773,7 @@ var ActorContextHandleAdapter = class {
5768
5773
  log: {
5769
5774
  debug: (obj) => logger2().debug(obj)
5770
5775
  },
5771
- nativeDatabaseProvider: _chunkXLD6TRSEcjs.registerNativeStateTransactionOpener.call(void 0,
5776
+ nativeDatabaseProvider: _chunkLYXPQB6Hcjs.registerNativeStateTransactionOpener.call(void 0,
5772
5777
  {
5773
5778
  open: async (requestedActorId) => {
5774
5779
  void requestedActorId;
@@ -5793,7 +5798,7 @@ var ActorContextHandleAdapter = class {
5793
5798
  return this.#db;
5794
5799
  }
5795
5800
  #bindDatabaseClient(client) {
5796
- return _chunkXLD6TRSEcjs.bindNativeStateTransactionContext.call(void 0, client, {
5801
+ return _chunkLYXPQB6Hcjs.bindNativeStateTransactionContext.call(void 0, client, {
5797
5802
  enter: async () => await this.#enterStateTransaction(),
5798
5803
  exit: (scope) => this.#exitStateTransaction(
5799
5804
  scope
@@ -5997,7 +6002,7 @@ var ActorContextHandleAdapter = class {
5997
6002
  const trackedPromise = Promise.resolve(promise).catch((error) => {
5998
6003
  logger2().warn({
5999
6004
  msg: "keepAwake promise rejected",
6000
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, error)
6005
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
6001
6006
  });
6002
6007
  }).then(() => null);
6003
6008
  try {
@@ -6058,16 +6063,16 @@ var ActorContextHandleAdapter = class {
6058
6063
  // need to keep an actor awake should use `keepAwake(promise)` or
6059
6064
  // `waitUntil(promise)` so the native counter machinery in rivetkit-core
6060
6065
  // owns the lifecycle.
6061
- /** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)` instead. */
6066
+ /** @deprecated `setPreventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
6062
6067
  setPreventSleep(_preventSleep) {
6063
6068
  logger2().warn({
6064
- msg: "setPreventSleep is deprecated and is a no-op; use keepAwake(promise) or waitUntil(promise) instead"
6069
+ msg: "setPreventSleep was deprecated in 3.0 and will be removed in a future version. It is a no-op; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep"
6065
6070
  });
6066
6071
  }
6067
- /** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)` instead. */
6072
+ /** @deprecated `preventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op that always returns `false`. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
6068
6073
  get preventSleep() {
6069
6074
  logger2().warn({
6070
- msg: "preventSleep is deprecated and always returns false; use keepAwake(promise) or waitUntil(promise) instead"
6075
+ msg: "preventSleep was deprecated in 3.0 and will be removed in a future version. It always returns false; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep"
6071
6076
  });
6072
6077
  return false;
6073
6078
  }
@@ -6377,7 +6382,7 @@ function buildActorTracingConfig(actions, tracing) {
6377
6382
  if (tracing === void 0) return void 0;
6378
6383
  return {
6379
6384
  sampler: tracing.sampler,
6380
- actions: _chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, actions, tracing.actions)
6385
+ actions: _chunkYWWDUC6Dcjs.flattenActionTraceSamplers.call(void 0, actions, tracing.actions)
6381
6386
  };
6382
6387
  }
6383
6388
  var SQLITE_DEFERRED_COMMITS = /* @__PURE__ */ Symbol.for("rivetkit.sqlite.deferredCommits");
@@ -6400,7 +6405,6 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
6400
6405
  definition.config.actions,
6401
6406
  definition.config.tracing
6402
6407
  ),
6403
- enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
6404
6408
  hasState: config.state !== void 0 || typeof config.createState === "function",
6405
6409
  canHibernateWebsocket: typeof canHibernate === "boolean" ? canHibernate : void 0,
6406
6410
  stateSaveIntervalMs: options.stateSaveInterval,
@@ -6422,7 +6426,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
6422
6426
  maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
6423
6427
  preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
6424
6428
  preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
6425
- actions: Object.keys(_chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
6429
+ actions: Object.keys(_chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
6426
6430
  inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
6427
6431
  };
6428
6432
  }
@@ -6498,10 +6502,10 @@ function validateInspectorTabSource(tabId, resolved) {
6498
6502
  function buildNativeFactory(runtime, registryConfig, definition) {
6499
6503
  var _a;
6500
6504
  const config = definition.config;
6501
- const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkXLD6TRSEcjs.db.call(void 0, )));
6502
- const actionHandlers = _chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
6505
+ const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkLYXPQB6Hcjs.db.call(void 0, )));
6506
+ const actionHandlers = _chunkYWWDUC6Dcjs.flattenActionHandlers.call(void 0, config.actions);
6503
6507
  const schemaConfig = {
6504
- actionInputSchemas: _chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0,
6508
+ actionInputSchemas: _chunkYWWDUC6Dcjs.flattenActionInputSchemas.call(void 0,
6505
6509
  config.actions,
6506
6510
  config.actionInputSchemas
6507
6511
  ),
@@ -6509,9 +6513,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6509
6513
  events: config.events,
6510
6514
  queues: config.queues
6511
6515
  };
6512
- const createClient = (ctx) => _chunkYJ2X5STTcjs.createClientWithDriver.call(void 0,
6513
- new (0, _chunkYJ2X5STTcjs.RemoteEngineControlClient)(
6514
- _chunkYJ2X5STTcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
6516
+ const createClient = (ctx) => _chunkSJJWJU26cjs.createClientWithDriver.call(void 0,
6517
+ new (0, _chunkSJJWJU26cjs.RemoteEngineControlClient)(
6518
+ _chunkSJJWJU26cjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
6515
6519
  ),
6516
6520
  {
6517
6521
  encoding: "bare",
@@ -6523,13 +6527,13 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6523
6527
  )
6524
6528
  }
6525
6529
  );
6526
- const run = _chunkSSF2XC33cjs.getRunFunction.call(void 0, config.run);
6527
- const runHandlerCoordinator = _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
6530
+ const run = _chunkYWWDUC6Dcjs.getRunFunction.call(void 0, config.run);
6531
+ const runHandlerCoordinator = _chunkYWWDUC6Dcjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
6528
6532
  const getNativeWorkflowInspector = (ctx) => {
6529
6533
  var _a2, _b;
6530
6534
  const actorId = callNativeSync(() => runtime.actorId(ctx));
6531
6535
  const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
6532
- return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunkSSF2XC33cjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
6536
+ return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunkYWWDUC6Dcjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
6533
6537
  };
6534
6538
  const onStateChange = typeof config.onStateChange === "function" ? (actorCtx, nextState) => {
6535
6539
  config.onStateChange(actorCtx, nextState);
@@ -6703,7 +6707,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6703
6707
  400
6704
6708
  );
6705
6709
  }
6706
- const cbor = _chunk6UDO6UYMcjs.encodeCborCompat.call(void 0,
6710
+ const cbor = _chunkI26AW6BGcjs.encodeCborCompat.call(void 0,
6707
6711
  _nullishCoalesce(body.body, () => ( null))
6708
6712
  );
6709
6713
  const message = await runtime.actorQueueSend(ctx, name, cbor);
@@ -7071,7 +7075,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7071
7075
  );
7072
7076
  } finally {
7073
7077
  runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
7074
- _chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
7078
+ _chunkYWWDUC6Dcjs.disposeRunInspector.call(void 0, config.run, actorId);
7075
7079
  await actorCtx.dispose();
7076
7080
  }
7077
7081
  }
@@ -7083,7 +7087,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7083
7087
  const actorCtx = makeActorCtx(ctx);
7084
7088
  const actorId = callNativeSync(() => runtime.actorId(ctx));
7085
7089
  runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
7086
- _chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
7090
+ _chunkYWWDUC6Dcjs.disposeRunInspector.call(void 0, config.run, actorId);
7087
7091
  try {
7088
7092
  if (typeof config.onDestroy === "function") {
7089
7093
  await config.onDestroy(actorCtx);
@@ -7300,7 +7304,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7300
7304
  ...request,
7301
7305
  abortController: requestAbortController
7302
7306
  });
7303
- const rawConnParams = handlerRequest.headers.get(_chunkYJ2X5STTcjs.HEADER_CONN_PARAMS);
7307
+ const rawConnParams = handlerRequest.headers.get(_chunkSJJWJU26cjs.HEADER_CONN_PARAMS);
7304
7308
  let requestCtx;
7305
7309
  let conn;
7306
7310
  let removeRequestAbortListener;
@@ -7357,7 +7361,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7357
7361
  requestCtx,
7358
7362
  handlerRequest
7359
7363
  );
7360
- if (!_chunkYJ2X5STTcjs.isResponseLike.call(void 0, response)) {
7364
+ if (!_chunkSJJWJU26cjs.isResponseLike.call(void 0, response)) {
7361
7365
  throw new Error(
7362
7366
  "onRequest handler must return a Response"
7363
7367
  );
@@ -7447,15 +7451,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7447
7451
  }
7448
7452
  );
7449
7453
  })(),
7450
- getWorkflowHistory: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
7454
+ getWorkflowHistory: _chunkYWWDUC6Dcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
7451
7455
  async (error, payload) => {
7452
7456
  var _a2;
7453
7457
  const { ctx } = unwrapTsfnPayload(error, payload);
7454
7458
  const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
7455
- return history == null ? void 0 : _chunk6UDO6UYMcjs.toUint8Array.call(void 0, history);
7459
+ return history == null ? void 0 : _chunkI26AW6BGcjs.toUint8Array.call(void 0, history);
7456
7460
  }
7457
7461
  ) : void 0,
7458
- replayWorkflow: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
7462
+ replayWorkflow: _chunkYWWDUC6Dcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
7459
7463
  async (error, payload) => {
7460
7464
  const { ctx, entryId } = unwrapTsfnPayload(
7461
7465
  error,
@@ -7466,7 +7470,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7466
7470
  return void 0;
7467
7471
  }
7468
7472
  const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
7469
- return history == null ? void 0 : _chunk6UDO6UYMcjs.toUint8Array.call(void 0, history);
7473
+ return history == null ? void 0 : _chunkI26AW6BGcjs.toUint8Array.call(void 0, history);
7470
7474
  }
7471
7475
  ) : void 0,
7472
7476
  actions: Object.fromEntries(
@@ -7608,7 +7612,7 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
7608
7612
  startServices: resolveNativeBinaries && config.startServices,
7609
7613
  handleInspectorHttpInRuntime: true,
7610
7614
  serverlessBasePath: config.serverless.basePath,
7611
- serverlessPackageVersion: _chunk6UDO6UYMcjs.VERSION,
7615
+ serverlessPackageVersion: _chunkI26AW6BGcjs.VERSION,
7612
7616
  serverlessClientEndpoint: config.publicEndpoint,
7613
7617
  serverlessClientNamespace: config.publicNamespace,
7614
7618
  serverlessClientToken: config.publicToken,
@@ -7622,12 +7626,12 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
7622
7626
  } catch (error) {
7623
7627
  logger2().warn({
7624
7628
  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",
7625
- error: _chunk6UDO6UYMcjs.stringifyError.call(void 0, error)
7629
+ error: _chunkI26AW6BGcjs.stringifyError.call(void 0, error)
7626
7630
  });
7627
7631
  }
7628
7632
  }
7629
7633
  if (resolveNativeBinaries && config.startServices) {
7630
- const servicesBinary = _chunk6UDO6UYMcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
7634
+ const servicesBinary = _chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
7631
7635
  if (servicesBinary) {
7632
7636
  serveConfig.servicesBinaryPath = servicesBinary;
7633
7637
  } else {
@@ -7642,13 +7646,13 @@ async function buildServeConfig(config, resolveNativeBinaries = true) {
7642
7646
  serveConfig.engineHost = config.engineHost;
7643
7647
  serveConfig.enginePort = config.enginePort;
7644
7648
  if ((_a = config.test) == null ? void 0 : _a.enabled) {
7645
- serveConfig.inspectorTestToken = _nullishCoalesce(_chunk6UDO6UYMcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
7649
+ serveConfig.inspectorTestToken = _nullishCoalesce(_chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
7646
7650
  }
7647
7651
  return serveConfig;
7648
7652
  }
7649
7653
  async function buildRegistryWithRuntime(config, runtime) {
7650
7654
  var _a;
7651
- if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunk6UDO6UYMcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
7655
+ if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkI26AW6BGcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
7652
7656
  trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
7653
7657
  }
7654
7658
  if (runtime.kind === "napi") {
@@ -7680,6 +7684,7 @@ async function buildConfiguredRegistry(config) {
7680
7684
  var REGISTRY_READY_TIMEOUT_MS = 3e4;
7681
7685
  var LOCAL_ENGINE_READY_TIMEOUT_MS = 6e4;
7682
7686
  var LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4e3;
7687
+ var DEFAULT_ACTOR_STOP_THRESHOLD_MS = 3e4;
7683
7688
  function rejectServerless() {
7684
7689
  throw new Error("serverless is disabled in this version");
7685
7690
  }
@@ -7720,7 +7725,7 @@ function createApplicationFetch(application, runtime) {
7720
7725
  signal: abortController.signal
7721
7726
  })
7722
7727
  );
7723
- if (!_chunkYJ2X5STTcjs.isResponseLike.call(void 0, response)) {
7728
+ if (!_chunkSJJWJU26cjs.isResponseLike.call(void 0, response)) {
7724
7729
  throw new TypeError(
7725
7730
  "registry.listen() application fetch must return a Response"
7726
7731
  );
@@ -7766,11 +7771,16 @@ var Registry = class {
7766
7771
  #shutdownInstalled = false;
7767
7772
  #shutdownInFlight = null;
7768
7773
  #signalHandlers = {};
7774
+ #envoyConfiguredRegistry;
7775
+ #activeActorCountListeners = /* @__PURE__ */ new Set();
7776
+ #activeActorCountToken;
7777
+ #lastActiveActorCount;
7778
+ #activeActorCountSupported;
7769
7779
  constructor(config, deps) {
7770
7780
  var _a;
7771
7781
  this.#config = config;
7772
7782
  if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
7773
- _chunk6UDO6UYMcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
7783
+ _chunkI26AW6BGcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
7774
7784
  }
7775
7785
  this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
7776
7786
  this.routes = {
@@ -8002,10 +8012,10 @@ var Registry = class {
8002
8012
  if (!opts.application) {
8003
8013
  rejectServerless();
8004
8014
  }
8005
- const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunk6UDO6UYMcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
8006
- const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunk6UDO6UYMcjs.getRivetkitPublicDir.call(void 0, )));
8015
+ const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkI26AW6BGcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
8016
+ const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkI26AW6BGcjs.getRivetkitPublicDir.call(void 0, )));
8007
8017
  const config = this.parseConfig();
8008
- if (opts.application && _chunk6UDO6UYMcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
8018
+ if (opts.application && _chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
8009
8019
  if (config.runtime === "wasm") {
8010
8020
  throw new Error(
8011
8021
  "registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
@@ -8081,7 +8091,7 @@ var Registry = class {
8081
8091
  return jsonRouteResponse(503, {
8082
8092
  status: "not_started",
8083
8093
  runtime: "rivetkit",
8084
- version: _chunk6UDO6UYMcjs.VERSION
8094
+ version: _chunkI26AW6BGcjs.VERSION
8085
8095
  });
8086
8096
  }
8087
8097
  const { runtime, registry } = configured;
@@ -8089,7 +8099,7 @@ var Registry = class {
8089
8099
  return jsonRouteResponse(501, {
8090
8100
  status: "unsupported",
8091
8101
  runtime: "rivetkit",
8092
- version: _chunk6UDO6UYMcjs.VERSION
8102
+ version: _chunkI26AW6BGcjs.VERSION
8093
8103
  });
8094
8104
  }
8095
8105
  const response = await runtime.registryHealth(registry);
@@ -8164,14 +8174,14 @@ var Registry = class {
8164
8174
  var _a;
8165
8175
  if (!this.#runtimeServePromise) {
8166
8176
  const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
8167
- const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunk6UDO6UYMcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
8177
+ const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkI26AW6BGcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
8168
8178
  logger2().info({
8169
8179
  msg: "starting rivetkit envoy",
8170
- rivetkitVersion: _chunk6UDO6UYMcjs.VERSION,
8180
+ rivetkitVersion: _chunkI26AW6BGcjs.VERSION,
8171
8181
  envoyVersion: config.node.version,
8172
8182
  envoyVersionSource
8173
8183
  });
8174
- if (envoyVersionSource === "default" && _chunk6UDO6UYMcjs.getNodeEnv.call(void 0, ) === "production") {
8184
+ if (envoyVersionSource === "default" && _chunkI26AW6BGcjs.getNodeEnv.call(void 0, ) === "production") {
8175
8185
  logger2().error({
8176
8186
  msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
8177
8187
  envoyVersion: config.node.version,
@@ -8180,6 +8190,21 @@ var Registry = class {
8180
8190
  }
8181
8191
  const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
8182
8192
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
8193
+ configuredRegistryPromise.then(
8194
+ (configured) => {
8195
+ this.#envoyConfiguredRegistry = configured;
8196
+ try {
8197
+ this.#syncActiveActorCountSubscription();
8198
+ } catch (error) {
8199
+ logger2().error(
8200
+ { error },
8201
+ "failed to subscribe to the active actor count"
8202
+ );
8203
+ }
8204
+ },
8205
+ // The serve lifecycle below reports build failures.
8206
+ () => void 0
8207
+ );
8183
8208
  this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
8184
8209
  async ({ runtime, registry, serveConfig }) => {
8185
8210
  await runtime.serveRegistry(registry, serveConfig);
@@ -8260,12 +8285,12 @@ var Registry = class {
8260
8285
  const modeAPromise = this.#runtimeServeConfiguredPromise;
8261
8286
  const modeBPromise = this.#runtimeServerlessPromise;
8262
8287
  const runtimes = /* @__PURE__ */ new Set();
8263
- const localDevSignal = signalDriven && _chunk6UDO6UYMcjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunkYJ2X5STTcjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
8288
+ const localDevSignal = signalDriven && _chunkI26AW6BGcjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
8264
8289
  let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
8265
8290
  if (gracePeriodMs === void 0) {
8266
8291
  gracePeriodMs = localDevSignal ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
8267
8292
  _nullishCoalesce(modeAPromise, () => ( modeBPromise))
8268
- ), async () => ( 30 * 60 * 1e3));
8293
+ ), async () => ( DEFAULT_ACTOR_STOP_THRESHOLD_MS));
8269
8294
  }
8270
8295
  const drain = async () => {
8271
8296
  const registries = [];
@@ -8372,7 +8397,7 @@ var Registry = class {
8372
8397
  }
8373
8398
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
8374
8399
  try {
8375
- if (_chunk6UDO6UYMcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
8400
+ if (_chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
8376
8401
  return Promise.reject(
8377
8402
  new Error(
8378
8403
  "registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
@@ -8396,7 +8421,7 @@ var Registry = class {
8396
8421
  if (!configuredRegistryPromise || !serveLifecyclePromise) {
8397
8422
  throw new Error("registry envoy startup did not initialize");
8398
8423
  }
8399
- const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 && _chunkYJ2X5STTcjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? LOCAL_ENGINE_READY_TIMEOUT_MS : REGISTRY_READY_TIMEOUT_MS;
8424
+ const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 && _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? LOCAL_ENGINE_READY_TIMEOUT_MS : REGISTRY_READY_TIMEOUT_MS;
8400
8425
  let timeout;
8401
8426
  const timeoutPromise = new Promise((_resolve, reject) => {
8402
8427
  var _a;
@@ -8446,8 +8471,8 @@ var Registry = class {
8446
8471
  * ```
8447
8472
  */
8448
8473
  start() {
8449
- if (_chunk6UDO6UYMcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
8450
- const publicDir = _nullishCoalesce(_chunk6UDO6UYMcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
8474
+ if (_chunkI26AW6BGcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
8475
+ const publicDir = _nullishCoalesce(_chunkI26AW6BGcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
8451
8476
  this.listen({ publicDir }).catch((error) => {
8452
8477
  logger2().error({ error }, "auto-listen failed; exiting");
8453
8478
  if (typeof process !== "undefined" && typeof process.exit === "function") {
@@ -8459,6 +8484,101 @@ var Registry = class {
8459
8484
  const config = this.parseConfig();
8460
8485
  this.#startEnvoy(config, true);
8461
8486
  }
8487
+ /**
8488
+ * Returns the number of actors hosted by this process's envoy, which is zero
8489
+ * while it is not serving. Requires the native runtime.
8490
+ */
8491
+ activeActorCount() {
8492
+ this.#assertActiveActorCountSupported("activeActorCount");
8493
+ const configured = this.#envoyConfiguredRegistry;
8494
+ if (!configured) return 0;
8495
+ const { runtime, registry } = configured;
8496
+ if (!runtime.registryActiveActorCount) {
8497
+ throw new Error(
8498
+ "registry.activeActorCount() is not supported by this runtime"
8499
+ );
8500
+ }
8501
+ return runtime.registryActiveActorCount(registry);
8502
+ }
8503
+ /**
8504
+ * Calls `callback` with the number of actors hosted by this process's envoy
8505
+ * and again whenever it changes. Rapid changes may coalesce.
8506
+ * Returns a function that unsubscribes. Requires the native runtime.
8507
+ *
8508
+ * @example
8509
+ * ```ts
8510
+ * const unsubscribe = registry.onActiveActorCountChange((count) => {
8511
+ * setTaskProtection(count > 0);
8512
+ * });
8513
+ * ```
8514
+ */
8515
+ onActiveActorCountChange(callback) {
8516
+ this.#assertActiveActorCountSupported("onActiveActorCountChange");
8517
+ const listener = (count) => callback(count);
8518
+ this.#activeActorCountListeners.add(listener);
8519
+ this.#syncActiveActorCountSubscription();
8520
+ const lastCount = this.#lastActiveActorCount;
8521
+ if (lastCount !== void 0) {
8522
+ queueMicrotask(() => {
8523
+ if (this.#activeActorCountListeners.has(listener)) {
8524
+ this.#deliverActiveActorCount(listener, lastCount);
8525
+ }
8526
+ });
8527
+ }
8528
+ return () => {
8529
+ this.#activeActorCountListeners.delete(listener);
8530
+ this.#syncActiveActorCountSubscription();
8531
+ };
8532
+ }
8533
+ #assertActiveActorCountSupported(method2) {
8534
+ this.#activeActorCountSupported ??= this.parseConfig().runtime !== "wasm";
8535
+ if (!this.#activeActorCountSupported) {
8536
+ throw new Error(
8537
+ `registry.${method2}() requires the native runtime; WebAssembly registries do not host an envoy`
8538
+ );
8539
+ }
8540
+ }
8541
+ /** Holds one native subscription while any listener is registered. */
8542
+ #syncActiveActorCountSubscription() {
8543
+ const configured = this.#envoyConfiguredRegistry;
8544
+ if (!configured) return;
8545
+ const { runtime, registry } = configured;
8546
+ const token = this.#activeActorCountToken;
8547
+ if (this.#activeActorCountListeners.size === 0) {
8548
+ if (token !== void 0) {
8549
+ this.#activeActorCountToken = void 0;
8550
+ this.#lastActiveActorCount = void 0;
8551
+ runtime.cancelCancellationToken(token);
8552
+ }
8553
+ return;
8554
+ }
8555
+ if (token !== void 0) return;
8556
+ if (!runtime.onRegistryActiveActorCountChange) {
8557
+ throw new Error(
8558
+ "active actor count subscriptions are not supported by this runtime"
8559
+ );
8560
+ }
8561
+ const nextToken = runtime.createCancellationToken();
8562
+ this.#activeActorCountToken = nextToken;
8563
+ runtime.onRegistryActiveActorCountChange(
8564
+ registry,
8565
+ (count) => {
8566
+ if (this.#activeActorCountToken !== nextToken) return;
8567
+ this.#lastActiveActorCount = count;
8568
+ for (const listener of [...this.#activeActorCountListeners]) {
8569
+ this.#deliverActiveActorCount(listener, count);
8570
+ }
8571
+ },
8572
+ nextToken
8573
+ );
8574
+ }
8575
+ #deliverActiveActorCount(listener, count) {
8576
+ try {
8577
+ listener(count);
8578
+ } catch (error) {
8579
+ logger2().error({ error }, "active actor count listener threw");
8580
+ }
8581
+ }
8462
8582
  #printWelcome(config, kind, listener) {
8463
8583
  if (config.noWelcome || this.#welcomePrinted) return;
8464
8584
  this.#welcomePrinted = true;
@@ -8468,13 +8588,13 @@ var Registry = class {
8468
8588
  };
8469
8589
  console.log();
8470
8590
  console.log(
8471
- ` RivetKit ${_chunk6UDO6UYMcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
8591
+ ` RivetKit ${_chunkI26AW6BGcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
8472
8592
  );
8473
8593
  if (config.namespace !== "default") {
8474
8594
  logLine("Namespace", config.namespace);
8475
8595
  }
8476
8596
  if (config.endpoint) {
8477
- const endpointType = config.startEngine || _chunkYJ2X5STTcjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
8597
+ const endpointType = config.startEngine || _chunkSJJWJU26cjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
8478
8598
  logLine("Endpoint", `${config.endpoint} (${endpointType})`);
8479
8599
  }
8480
8600
  if (kind === "serverless" && config.publicEndpoint) {
@@ -8544,5 +8664,5 @@ function setup(input) {
8544
8664
 
8545
8665
 
8546
8666
 
8547
- exports.ALLOWED_PUBLIC_HEADERS = _chunkYJ2X5STTcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkMGI2VVF6cjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkMGI2VVF6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkMGI2VVF6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkYJ2X5STTcjs.createClientWithDriver; exports.defineRunHandler = _chunkSSF2XC33cjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunk6UDO6UYMcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunk6UDO6UYMcjs.toUint8Array;
8667
+ exports.ALLOWED_PUBLIC_HEADERS = _chunkSJJWJU26cjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkMGI2VVF6cjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkMGI2VVF6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkMGI2VVF6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkSJJWJU26cjs.createClientWithDriver; exports.defineRunHandler = _chunkYWWDUC6Dcjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkI26AW6BGcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkI26AW6BGcjs.toUint8Array;
8548
8668
  //# sourceMappingURL=mod.cjs.map