rivetkit 2.3.0-rc.9 → 2.3.0

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 (222) hide show
  1. package/dist/browser/client.d.ts +498 -62
  2. package/dist/browser/client.js +227 -171
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +50 -20
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +2 -2
  7. package/dist/tsup/actor/errors.d.cts +1 -1
  8. package/dist/tsup/actor/errors.d.ts +1 -1
  9. package/dist/tsup/actor/errors.js +1 -1
  10. package/dist/tsup/agent-os/index.cjs +2163 -2087
  11. package/dist/tsup/agent-os/index.cjs.map +1 -1
  12. package/dist/tsup/agent-os/index.d.cts +496 -69
  13. package/dist/tsup/agent-os/index.d.ts +496 -69
  14. package/dist/tsup/agent-os/index.js +2163 -2087
  15. package/dist/tsup/agent-os/index.js.map +1 -1
  16. package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
  17. package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
  18. package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
  19. package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
  20. package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
  21. package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
  22. package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
  23. package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
  24. package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
  25. package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
  27. package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
  28. package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
  29. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
  30. package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
  31. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
  32. package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
  33. package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
  34. package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
  35. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
  36. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  37. package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
  38. package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
  39. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  40. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  41. package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
  42. package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
  43. package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
  44. package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
  45. package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
  46. package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
  47. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
  48. package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
  49. package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
  50. package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
  51. package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
  52. package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
  53. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
  54. package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
  55. package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
  56. package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
  57. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
  58. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
  59. package/dist/tsup/client/mod.cjs +9 -9
  60. package/dist/tsup/client/mod.d.cts +5 -5
  61. package/dist/tsup/client/mod.d.ts +5 -5
  62. package/dist/tsup/client/mod.js +8 -8
  63. package/dist/tsup/common/log.cjs +3 -3
  64. package/dist/tsup/common/log.js +2 -2
  65. package/dist/tsup/common/websocket.cjs +4 -4
  66. package/dist/tsup/common/websocket.js +3 -3
  67. package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
  68. package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
  69. package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
  70. package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
  71. package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
  72. package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
  73. package/dist/tsup/db/drizzle.cjs +3 -3
  74. package/dist/tsup/db/drizzle.d.cts +1 -1
  75. package/dist/tsup/db/drizzle.d.ts +1 -1
  76. package/dist/tsup/db/drizzle.js +1 -1
  77. package/dist/tsup/db/mod.cjs +2 -2
  78. package/dist/tsup/db/mod.d.cts +2 -2
  79. package/dist/tsup/db/mod.d.ts +2 -2
  80. package/dist/tsup/db/mod.js +1 -1
  81. package/dist/tsup/dynamic/mod.cjs +24 -0
  82. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  83. package/dist/tsup/dynamic/mod.d.cts +37 -0
  84. package/dist/tsup/dynamic/mod.d.ts +37 -0
  85. package/dist/tsup/dynamic/mod.js +24 -0
  86. package/dist/tsup/dynamic/mod.js.map +1 -0
  87. package/dist/tsup/inspector/mod.cjs +6 -6
  88. package/dist/tsup/inspector/mod.js +5 -5
  89. package/dist/tsup/inspector-tab/mod.cjs +173 -0
  90. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  91. package/dist/tsup/inspector-tab/mod.d.cts +250 -0
  92. package/dist/tsup/inspector-tab/mod.d.ts +250 -0
  93. package/dist/tsup/inspector-tab/mod.js +173 -0
  94. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  95. package/dist/tsup/mod.cjs +730 -336
  96. package/dist/tsup/mod.cjs.map +1 -1
  97. package/dist/tsup/mod.d.cts +5 -5
  98. package/dist/tsup/mod.d.ts +5 -5
  99. package/dist/tsup/mod.js +633 -239
  100. package/dist/tsup/mod.js.map +1 -1
  101. package/dist/tsup/test/mod.cjs +21 -18
  102. package/dist/tsup/test/mod.cjs.map +1 -1
  103. package/dist/tsup/test/mod.d.cts +4 -4
  104. package/dist/tsup/test/mod.d.ts +4 -4
  105. package/dist/tsup/test/mod.js +18 -15
  106. package/dist/tsup/test/mod.js.map +1 -1
  107. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
  108. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
  109. package/dist/tsup/utils.cjs +3 -3
  110. package/dist/tsup/utils.d.cts +1 -1
  111. package/dist/tsup/utils.d.ts +1 -1
  112. package/dist/tsup/utils.js +2 -2
  113. package/dist/tsup/workflow/mod.cjs +307 -282
  114. package/dist/tsup/workflow/mod.cjs.map +1 -1
  115. package/dist/tsup/workflow/mod.d.cts +6 -6
  116. package/dist/tsup/workflow/mod.d.ts +6 -6
  117. package/dist/tsup/workflow/mod.js +501 -476
  118. package/dist/tsup/workflow/mod.js.map +1 -1
  119. package/package.json +32 -11
  120. package/src/actor/config.ts +159 -51
  121. package/src/actor/contexts/index.ts +7 -2
  122. package/src/actor/definition.ts +17 -19
  123. package/src/actor/driver.ts +3 -3
  124. package/src/actor/errors.ts +9 -3
  125. package/src/actor/instance/mod.ts +26 -34
  126. package/src/actor/keys.ts +1 -1
  127. package/src/actor/mod.ts +22 -20
  128. package/src/actor/schema.ts +2 -2
  129. package/src/agent-os/actor/index.ts +38 -18
  130. package/src/agent-os/actor/preview.ts +1 -2
  131. package/src/agent-os/actor/session.ts +2 -2
  132. package/src/agent-os/config.ts +1 -1
  133. package/src/agent-os/fs/database-vfs.ts +1 -1
  134. package/src/agent-os/index.ts +16 -15
  135. package/src/client/actor-common.ts +87 -54
  136. package/src/client/actor-conn.ts +8 -36
  137. package/src/client/actor-handle.ts +69 -51
  138. package/src/client/actor-query.ts +5 -5
  139. package/src/client/errors.ts +1 -1
  140. package/src/client/lifecycle-errors.ts +2 -4
  141. package/src/client/query.ts +1 -1
  142. package/src/client/queue.ts +8 -3
  143. package/src/client/raw-utils.ts +8 -6
  144. package/src/client/resolve-gateway-target.ts +1 -1
  145. package/src/client/utils.ts +2 -7
  146. package/src/common/actor-websocket.ts +3 -1
  147. package/src/common/bare/actor-persist/v1.ts +205 -163
  148. package/src/common/bare/actor-persist/v2.ts +265 -213
  149. package/src/common/bare/actor-persist/v3.ts +176 -172
  150. package/src/common/bare/actor-persist/v4.ts +254 -253
  151. package/src/common/bare/transport/v1.ts +659 -543
  152. package/src/common/client-protocol-versioned.ts +66 -64
  153. package/src/common/database/config.ts +2 -8
  154. package/src/common/database/native-database.ts +1 -1
  155. package/src/common/database/shared.ts +1 -0
  156. package/src/common/encoding.ts +250 -16
  157. package/src/common/engine.ts +28 -1
  158. package/src/common/eventsource.ts +1 -1
  159. package/src/common/inline-websocket-adapter.ts +14 -13
  160. package/src/common/log.ts +1 -0
  161. package/src/common/router.ts +13 -17
  162. package/src/common/utils.ts +1 -150
  163. package/src/common/websocket-interface.ts +1 -1
  164. package/src/db/mod.ts +1 -1
  165. package/src/devtools-loader/index.ts +4 -7
  166. package/src/devtools-loader/serve-devtools.ts +26 -0
  167. package/src/drivers/engine/actor-driver.ts +58 -56
  168. package/src/dynamic/instance.ts +32 -0
  169. package/src/dynamic/internal.ts +50 -0
  170. package/src/dynamic/isolate-runtime.ts +66 -0
  171. package/src/dynamic/mod.ts +32 -0
  172. package/src/engine-client/actor-http-client.ts +3 -3
  173. package/src/engine-client/actor-websocket-client.ts +6 -5
  174. package/src/engine-client/api-endpoints.ts +51 -2
  175. package/src/engine-client/api-utils.ts +2 -2
  176. package/src/engine-client/driver.ts +1 -1
  177. package/src/engine-client/mod.ts +6 -3
  178. package/src/engine-client/ws-proxy.ts +9 -4
  179. package/src/inspector/client.browser.ts +5 -11
  180. package/src/inspector/mod.ts +1 -3
  181. package/src/inspector-tab/mod.ts +315 -0
  182. package/src/registry/config/envoy.ts +1 -2
  183. package/src/registry/config/index.ts +40 -16
  184. package/src/registry/index.ts +154 -74
  185. package/src/registry/napi-runtime.ts +13 -2
  186. package/src/registry/native-validation.ts +10 -12
  187. package/src/registry/native.ts +367 -181
  188. package/src/registry/process-metrics.ts +250 -0
  189. package/src/registry/runtime.ts +41 -1
  190. package/src/registry/wasm-runtime.ts +18 -2
  191. package/src/registry/write-through-proxy.ts +40 -0
  192. package/src/serde.ts +2 -2
  193. package/src/serverless/configure.ts +18 -7
  194. package/src/test/mod.ts +11 -8
  195. package/src/utils/endpoint-parser.ts +1 -1
  196. package/src/utils/env-vars.ts +6 -0
  197. package/src/utils/router.ts +1 -1
  198. package/src/utils/serve.ts +4 -5
  199. package/src/utils.ts +1 -2
  200. package/src/workflow/context.ts +61 -33
  201. package/src/workflow/driver.ts +4 -6
  202. package/src/workflow/inspector.ts +4 -3
  203. package/src/workflow/mod.ts +15 -17
  204. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  205. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  206. package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
  207. package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
  208. package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
  209. package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
  210. package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
  211. package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
  212. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  213. package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
  214. package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
  215. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  216. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  217. package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
  218. package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
  219. package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
  220. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  221. package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
  222. /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
package/dist/tsup/mod.cjs CHANGED
@@ -1,15 +1,15 @@
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 _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;
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 _chunk47HHIEXHcjs = require('./chunk-47HHIEXH.cjs');
3
4
 
4
5
 
5
6
 
6
7
 
7
8
 
8
- var _chunkWQ4HNA4Wcjs = require('./chunk-WQ4HNA4W.cjs');
9
9
 
10
10
 
11
- var _chunk4CGA6QJOcjs = require('./chunk-4CGA6QJO.cjs');
12
11
 
12
+ var _chunkNIY3RSPXcjs = require('./chunk-NIY3RSPX.cjs');
13
13
 
14
14
 
15
15
 
@@ -18,23 +18,23 @@ var _chunk4CGA6QJOcjs = require('./chunk-4CGA6QJO.cjs');
18
18
 
19
19
 
20
20
 
21
- var _chunkGVTOE34Scjs = require('./chunk-GVTOE34S.cjs');
22
21
 
22
+ var _chunk7QKCIVAYcjs = require('./chunk-7QKCIVAY.cjs');
23
23
 
24
24
 
25
25
 
26
26
 
27
27
 
28
28
 
29
- var _chunkLD5YASJUcjs = require('./chunk-LD5YASJU.cjs');
30
29
 
30
+ var _chunkVE2X4KMGcjs = require('./chunk-VE2X4KMG.cjs');
31
31
 
32
32
 
33
33
 
34
- var _chunkVJFRBJVQcjs = require('./chunk-VJFRBJVQ.cjs');
35
- require('./chunk-2NDZ7JCR.cjs');
36
- require('./chunk-MALSPBAF.cjs');
37
34
 
35
+ var _chunk3677IIOVcjs = require('./chunk-3677IIOV.cjs');
36
+ require('./chunk-ZA7FLHKH.cjs');
37
+ require('./chunk-LVTBW2RE.cjs');
38
38
 
39
39
 
40
40
 
@@ -57,22 +57,26 @@ require('./chunk-MALSPBAF.cjs');
57
57
 
58
58
 
59
59
 
60
- var _chunkY5NSCZA2cjs = require('./chunk-Y5NSCZA2.cjs');
61
60
 
62
61
 
63
62
 
64
63
 
64
+ var _chunkDXXJPH55cjs = require('./chunk-DXXJPH55.cjs');
65
65
 
66
66
 
67
67
 
68
68
 
69
69
 
70
70
 
71
- var _chunkQAZLM4WTcjs = require('./chunk-QAZLM4WT.cjs');
71
+
72
+
73
+
74
+
75
+ var _chunkKORQB2IRcjs = require('./chunk-KORQB2IR.cjs');
72
76
 
73
77
  // src/actor/log.ts
74
78
  function loggerWithoutContext() {
75
- return _chunkY5NSCZA2cjs.getLogger.call(void 0, "actor-runtime");
79
+ return _chunkDXXJPH55cjs.getLogger.call(void 0, "actor-runtime");
76
80
  }
77
81
 
78
82
  // src/actor/definition.ts
@@ -105,7 +109,7 @@ function actor(input) {
105
109
  warnDeprecatedShutdownTimeoutKeys(
106
110
  input == null ? void 0 : input.options
107
111
  );
108
- const config = _chunkWQ4HNA4Wcjs.ActorConfigSchema.parse(input);
112
+ const config = _chunkNIY3RSPXcjs.ActorConfigSchema.parse(input);
109
113
  return new ActorDefinition(config);
110
114
  }
111
115
  function isStaticActorDefinition(definition) {
@@ -140,7 +144,7 @@ function hasSchemaConfigKey(schemas, key) {
140
144
  if (!schemas) {
141
145
  return false;
142
146
  }
143
- return Object.prototype.hasOwnProperty.call(schemas, key);
147
+ return Object.hasOwn(schemas, key);
144
148
  }
145
149
  function getEventCanSubscribe(schemas, key) {
146
150
  const schema = schemas == null ? void 0 : schemas[key];
@@ -187,7 +191,7 @@ function validateSchemaSync(schemas, key, data) {
187
191
  if (isStandardSchema(schema)) {
188
192
  const result = schema["~standard"].validate(data);
189
193
  if (isPromiseLike(result)) {
190
- throw _chunkQAZLM4WTcjs.unsupportedFeature.call(void 0, "async schema validation");
194
+ throw _chunkKORQB2IRcjs.unsupportedFeature.call(void 0, "async schema validation");
191
195
  }
192
196
  if (result.issues) {
193
197
  return { success: false, issues: [...result.issues] };
@@ -201,10 +205,10 @@ function validateSchemaSync(schemas, key, data) {
201
205
  }
202
206
 
203
207
  // src/common/inline-websocket-adapter.ts
204
- var _ws = require('hono/ws');
205
208
  var _virtualwebsocket = require('@rivetkit/virtual-websocket');
209
+ var _ws = require('hono/ws');
206
210
  function logger() {
207
- return _chunkY5NSCZA2cjs.getLogger.call(void 0, "inline-websocket-adapter");
211
+ return _chunkDXXJPH55cjs.getLogger.call(void 0, "inline-websocket-adapter");
208
212
  }
209
213
  var InlineWebSocketAdapter = class {
210
214
  #handler;
@@ -314,24 +318,24 @@ var InlineWebSocketAdapter = class {
314
318
  this.#close(1011, "Internal error during initialization");
315
319
  }
316
320
  }
317
- #handleError(err) {
318
- console.error("INLINE_WEBSOCKET_ADAPTER_ERROR", err);
321
+ #handleError(error) {
322
+ console.error("INLINE_WEBSOCKET_ADAPTER_ERROR", error);
319
323
  logger().error({
320
324
  msg: "error in websocket",
321
- error: err,
322
- errorMessage: err instanceof Error ? err.message : String(err),
323
- stack: err instanceof Error ? err.stack : void 0
325
+ error,
326
+ errorMessage: error instanceof Error ? error.message : String(error),
327
+ stack: error instanceof Error ? error.stack : void 0
324
328
  });
325
329
  try {
326
- this.#handler.onError(err, this.#wsContext);
327
- } catch (handlerErr) {
330
+ this.#handler.onError(error, this.#wsContext);
331
+ } catch (error2) {
328
332
  logger().error({
329
333
  msg: "error in onError handler",
330
- error: handlerErr
334
+ error: error2
331
335
  });
332
336
  }
333
- this.#clientWs.triggerError(err);
334
- this.#actorWs.triggerError(err);
337
+ this.#clientWs.triggerError(error);
338
+ this.#actorWs.triggerError(error);
335
339
  }
336
340
  #close(code, reason) {
337
341
  if (this.#readyState === 3 || this.#readyState === 2) {
@@ -344,8 +348,8 @@ var InlineWebSocketAdapter = class {
344
348
  { code, reason, wasClean: true },
345
349
  this.#wsContext
346
350
  );
347
- } catch (err) {
348
- logger().error({ msg: "error closing websocket", error: err });
351
+ } catch (error) {
352
+ logger().error({ msg: "error closing websocket", error });
349
353
  } finally {
350
354
  this.#readyState = 3;
351
355
  this.#clientWs.triggerClose(code, reason);
@@ -354,13 +358,31 @@ var InlineWebSocketAdapter = class {
354
358
  }
355
359
  };
356
360
 
361
+ // src/registry/index.ts
362
+ var _hono = require('hono');
363
+
357
364
  // src/common/engine.ts
365
+ var ENGINE_HOST = "127.0.0.1";
358
366
  var ENGINE_PORT = 6420;
359
- var ENGINE_ENDPOINT = `http://127.0.0.1:${ENGINE_PORT}`;
367
+ var ENGINE_ENDPOINT = buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT);
368
+ function buildEngineEndpoint(host, port) {
369
+ const urlHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
370
+ return `http://${urlHost}:${port}`;
371
+ }
372
+ function isLocalEngineEndpoint(endpoint) {
373
+ let url;
374
+ try {
375
+ url = new URL(endpoint);
376
+ } catch (e) {
377
+ return false;
378
+ }
379
+ const hostname = url.hostname.toLowerCase();
380
+ return hostname === "localhost" || hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]" || hostname === "::1" || hostname === "[::1]" || /^127(?:\.\d{1,3}){0,3}$/.test(hostname);
381
+ }
360
382
 
361
383
  // src/registry/log.ts
362
384
  function logger2() {
363
- return _chunkY5NSCZA2cjs.getLogger.call(void 0, "registry");
385
+ return _chunkDXXJPH55cjs.getLogger.call(void 0, "registry");
364
386
  }
365
387
 
366
388
  // src/serverless/configure.ts
@@ -371,10 +393,13 @@ function sleep(ms) {
371
393
  }
372
394
  function configureTimeoutMs() {
373
395
  const value = process.env.RIVET_SERVERLESS_CONFIGURE_TIMEOUT_MS;
374
- if (value === void 0 || value === "") return DEFAULT_CONFIGURE_TIMEOUT_MS;
396
+ if (value === void 0 || value === "")
397
+ return DEFAULT_CONFIGURE_TIMEOUT_MS;
375
398
  const parsed = Number(value);
376
399
  if (!Number.isFinite(parsed) || parsed < 0) {
377
- throw new Error("RIVET_SERVERLESS_CONFIGURE_TIMEOUT_MS must be a finite non-negative number");
400
+ throw new Error(
401
+ "RIVET_SERVERLESS_CONFIGURE_TIMEOUT_MS must be a finite non-negative number"
402
+ );
378
403
  }
379
404
  return parsed;
380
405
  }
@@ -388,17 +413,23 @@ async function configureServerlessPool(config) {
388
413
  attempts += 1;
389
414
  try {
390
415
  if (!config.namespace) {
391
- throw new Error("namespace is required for serverless configuration");
416
+ throw new Error(
417
+ "namespace is required for serverless configuration"
418
+ );
392
419
  }
393
420
  if (!config.endpoint) {
394
- throw new Error("endpoint is required for serverless configuration");
421
+ throw new Error(
422
+ "endpoint is required for serverless configuration"
423
+ );
395
424
  }
396
425
  if (!config.configurePool) {
397
- throw new Error("configurePool is required for serverless configuration");
426
+ throw new Error(
427
+ "configurePool is required for serverless configuration"
428
+ );
398
429
  }
399
430
  const customConfig = config.configurePool;
400
- const clientConfig = _chunkGVTOE34Scjs.convertRegistryConfigToClientConfig.call(void 0, config);
401
- const dcsRes = await _chunkGVTOE34Scjs.getDatacenters.call(void 0, clientConfig);
431
+ const clientConfig = _chunk7QKCIVAYcjs.convertRegistryConfigToClientConfig.call(void 0, config);
432
+ const dcsRes = await _chunk7QKCIVAYcjs.getDatacenters.call(void 0, clientConfig);
402
433
  const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
403
434
  const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
404
435
  const headers = {
@@ -420,7 +451,7 @@ async function configureServerlessPool(config) {
420
451
  metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
421
452
  drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
422
453
  };
423
- await _chunkGVTOE34Scjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
454
+ await _chunk7QKCIVAYcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
424
455
  datacenters: Object.fromEntries(
425
456
  dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
426
457
  )
@@ -437,7 +468,7 @@ async function configureServerlessPool(config) {
437
468
  logger2().warn({
438
469
  msg: "serverless pool configuration attempt failed",
439
470
  attempts,
440
- error: _chunkY5NSCZA2cjs.stringifyError.call(void 0, error)
471
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
441
472
  });
442
473
  await sleep(CONFIGURE_RETRY_DELAY_MS);
443
474
  }
@@ -445,11 +476,150 @@ async function configureServerlessPool(config) {
445
476
  logger2().error({
446
477
  msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
447
478
  attempts,
448
- error: _chunkY5NSCZA2cjs.stringifyError.call(void 0, lastError)
479
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, lastError)
449
480
  });
450
481
  throw lastError;
451
482
  }
452
483
 
484
+ // src/utils/serve.ts
485
+ var _getport = require('get-port'); var _getport2 = _interopRequireDefault(_getport);
486
+ var serveStaticLoaderPromises = {};
487
+ async function crossPlatformServe(config, httpPort, app, runtime = _chunkDXXJPH55cjs.detectRuntime.call(void 0, )) {
488
+ logger2().debug({ msg: "detected runtime for serve", runtime });
489
+ switch (runtime) {
490
+ case "deno":
491
+ return serveDeno(config, httpPort, app);
492
+ case "bun":
493
+ return serveBun(config, httpPort, app);
494
+ case "node":
495
+ return serveNode(config, httpPort, app);
496
+ default:
497
+ return serveNode(config, httpPort, app);
498
+ }
499
+ }
500
+ async function loadRuntimeServeStatic(runtime) {
501
+ if (!serveStaticLoaderPromises[runtime]) {
502
+ if (runtime === "node") {
503
+ const nodeServeStaticModule = "@hono/node-server/serve-static";
504
+ serveStaticLoaderPromises[runtime] = Promise.resolve().then(() => _interopRequireWildcard(require(
505
+ /* webpackIgnore: true */
506
+ nodeServeStaticModule
507
+ ))).then((x) => x.serveStatic);
508
+ } else if (runtime === "bun") {
509
+ const bunModule = "hono/bun";
510
+ serveStaticLoaderPromises[runtime] = Promise.resolve().then(() => _interopRequireWildcard(require(
511
+ /* webpackIgnore: true */
512
+ bunModule
513
+ ))).then((x) => x.serveStatic);
514
+ } else if (runtime === "deno") {
515
+ const denoModule = "hono/deno";
516
+ serveStaticLoaderPromises[runtime] = Promise.resolve().then(() => _interopRequireWildcard(require(
517
+ /* webpackIgnore: true */
518
+ denoModule
519
+ ))).then((x) => x.serveStatic);
520
+ } else {
521
+ throw new Error(`unsupported runtime: ${runtime}`);
522
+ }
523
+ }
524
+ return await serveStaticLoaderPromises[runtime];
525
+ }
526
+ async function serveNode(config, httpPort, app) {
527
+ const nodeServerModule = "@hono/node-server";
528
+ let serve;
529
+ try {
530
+ const dep = await Promise.resolve().then(() => _interopRequireWildcard(require(
531
+ /* webpackIgnore: true */
532
+ nodeServerModule
533
+ )));
534
+ serve = dep.serve;
535
+ } catch (err) {
536
+ logger2().error({
537
+ msg: "failed to import @hono/node-server. please run 'npm install @hono/node-server @hono/node-ws'",
538
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, err)
539
+ });
540
+ process.exit(1);
541
+ }
542
+ const nodeWsModule = "@hono/node-ws";
543
+ let createNodeWebSocket;
544
+ try {
545
+ const dep = await Promise.resolve().then(() => _interopRequireWildcard(require(
546
+ /* webpackIgnore: true */
547
+ nodeWsModule
548
+ )));
549
+ createNodeWebSocket = dep.createNodeWebSocket;
550
+ } catch (err) {
551
+ logger2().error({
552
+ msg: "failed to import @hono/node-ws. please run 'npm install @hono/node-server @hono/node-ws'",
553
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, err)
554
+ });
555
+ process.exit(1);
556
+ }
557
+ const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({
558
+ app
559
+ });
560
+ const port = httpPort;
561
+ const hostname = config.httpHost;
562
+ const server = serve(
563
+ { fetch: app.fetch, port, hostname },
564
+ () => logger2().info({ msg: "server listening", port, hostname })
565
+ );
566
+ injectWebSocket(server);
567
+ const closeServer = () => {
568
+ server.close();
569
+ };
570
+ return { upgradeWebSocket, closeServer };
571
+ }
572
+ async function serveDeno(config, httpPort, app) {
573
+ const honoDenoModule = "hono/deno";
574
+ let upgradeWebSocket;
575
+ try {
576
+ const dep = await Promise.resolve().then(() => _interopRequireWildcard(require(
577
+ /* webpackIgnore: true */
578
+ honoDenoModule
579
+ )));
580
+ upgradeWebSocket = dep.upgradeWebSocket;
581
+ } catch (err) {
582
+ logger2().error({
583
+ msg: "failed to import hono/deno",
584
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, err)
585
+ });
586
+ process.exit(1);
587
+ }
588
+ const port = httpPort;
589
+ const hostname = config.httpHost;
590
+ Deno.serve({ port, hostname }, app.fetch);
591
+ logger2().info({ msg: "server listening", port, hostname });
592
+ return { upgradeWebSocket };
593
+ }
594
+ async function serveBun(config, httpPort, app) {
595
+ const honoBunModule = "hono/bun";
596
+ let createBunWebSocket;
597
+ try {
598
+ const dep = await Promise.resolve().then(() => _interopRequireWildcard(require(
599
+ /* webpackIgnore: true */
600
+ honoBunModule
601
+ )));
602
+ createBunWebSocket = dep.createBunWebSocket;
603
+ } catch (err) {
604
+ logger2().error({
605
+ msg: "failed to import hono/bun",
606
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, err)
607
+ });
608
+ process.exit(1);
609
+ }
610
+ const { websocket, upgradeWebSocket } = createBunWebSocket();
611
+ const port = httpPort;
612
+ const hostname = config.httpHost;
613
+ Bun.serve({
614
+ fetch: app.fetch,
615
+ port,
616
+ hostname,
617
+ websocket
618
+ });
619
+ logger2().info({ msg: "server listening", port, hostname });
620
+ return { upgradeWebSocket };
621
+ }
622
+
453
623
  // src/registry/config/index.ts
454
624
  var _zod = require('zod');
455
625
 
@@ -457,20 +627,20 @@ var _zod = require('zod');
457
627
  var _v4 = require('zod/v4');
458
628
  var warnedMissingVersion = false;
459
629
  var EnvoyConfigSchema = _v4.z.object({
460
- poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkY5NSCZA2cjs.getRivetPool.call(void 0, ), () => ( "default"))),
630
+ poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkDXXJPH55cjs.getRivetPool.call(void 0, ), () => ( "default"))),
461
631
  version: _v4.z.number().default(() => {
462
- const version = _chunkY5NSCZA2cjs.getRivetEnvoyVersion.call(void 0, );
632
+ const version = _chunkDXXJPH55cjs.getRivetEnvoyVersion.call(void 0, );
463
633
  if (version !== void 0) return version;
464
- if (_chunkY5NSCZA2cjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
634
+ if (_chunkDXXJPH55cjs.getNodeEnv.call(void 0, ) === "production" && !warnedMissingVersion) {
465
635
  warnedMissingVersion = true;
466
- _chunkY5NSCZA2cjs.getLogger.call(void 0, "rivetkit").error(
636
+ _chunkDXXJPH55cjs.getLogger.call(void 0, "rivetkit").error(
467
637
  "RIVET_ENVOY_VERSION is not set. Actors will not be versioned, which means they won't be drained on deploy. This is only needed when self-hosting or using a custom envoy (not needed for Rivet Compute). Set this as a build arg in your Dockerfile. See https://rivet.dev/docs/actors/versions"
468
638
  );
469
639
  }
470
640
  return 1;
471
641
  }),
472
642
  // Deprecated.
473
- totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkY5NSCZA2cjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
643
+ totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkDXXJPH55cjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
474
644
  envoyKey: _v4.z.string().optional()
475
645
  });
476
646
 
@@ -508,7 +678,7 @@ var ServerlessConfigSchema = _v4.z.object({
508
678
  *
509
679
  * Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
510
680
  */
511
- publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetPublicEndpoint.call(void 0, )))),
681
+ publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetPublicEndpoint.call(void 0, )))),
512
682
  /**
513
683
  * Token that clients should use when connecting via the public endpoint.
514
684
  *
@@ -516,7 +686,7 @@ var ServerlessConfigSchema = _v4.z.object({
516
686
  *
517
687
  * Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
518
688
  */
519
- publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetPublicToken.call(void 0, ))))
689
+ publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetPublicToken.call(void 0, ))))
520
690
  // There is no publicNamespace config option because the frontend and backend
521
691
  // cannot use different namespaces. The namespace is extracted from the
522
692
  // publicEndpoint URL auth syntax if provided.
@@ -570,7 +740,7 @@ var RegistryConfigSchema = _zod.z.object({
570
740
  * Runtime binding to use for RivetKit core.
571
741
  * */
572
742
  runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
573
- const rawRuntime = _nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetkitRuntime.call(void 0, )));
743
+ const rawRuntime = _nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetkitRuntime.call(void 0, )));
574
744
  if (rawRuntime === void 0) {
575
745
  return "auto";
576
746
  }
@@ -607,7 +777,7 @@ var RegistryConfigSchema = _zod.z.object({
607
777
  * */
608
778
  logging: _zod.z.object({
609
779
  baseLogger: _zod.z.custom().optional(),
610
- level: _chunkY5NSCZA2cjs.LogLevelSchema.optional()
780
+ level: _chunkDXXJPH55cjs.LogLevelSchema.optional()
611
781
  }).optional().default(() => ({})),
612
782
  // MARK: Routing
613
783
  // // This is a function to allow for lazy configuration of upgradeWebSocket on the
@@ -625,9 +795,9 @@ var RegistryConfigSchema = _zod.z.object({
625
795
  *
626
796
  * Can also be set via RIVET_ENDPOINT environment variables.
627
797
  */
628
- endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetEngine.call(void 0, ))), () => ( _chunkY5NSCZA2cjs.getRivetEndpoint.call(void 0, )))),
629
- token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetToken.call(void 0, )))),
630
- namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY5NSCZA2cjs.getRivetNamespace.call(void 0, )))),
798
+ endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetEngine.call(void 0, ))), () => ( _chunkDXXJPH55cjs.getRivetEndpoint.call(void 0, )))),
799
+ token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetToken.call(void 0, )))),
800
+ namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkDXXJPH55cjs.getRivetNamespace.call(void 0, )))),
631
801
  headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
632
802
  // MARK: Client
633
803
  // TODO:
@@ -667,9 +837,21 @@ var RegistryConfigSchema = _zod.z.object({
667
837
  *
668
838
  * Starts the full Rust engine process locally.
669
839
  */
670
- startEngine: _zod.z.boolean().default(() => _chunkY5NSCZA2cjs.getRivetRunEngine.call(void 0, )),
840
+ startEngine: _zod.z.boolean().default(() => _chunkDXXJPH55cjs.getRivetRunEngine.call(void 0, )),
841
+ /**
842
+ * @experimental
843
+ *
844
+ * Host to bind the spawned local engine process to.
845
+ */
846
+ engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkDXXJPH55cjs.getRivetRunEngineHost.call(void 0, ), () => ( ENGINE_HOST))),
847
+ /**
848
+ * @experimental
849
+ *
850
+ * Port to bind the spawned local engine process to.
851
+ */
852
+ enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkDXXJPH55cjs.getRivetRunEnginePort.call(void 0, ), () => ( ENGINE_PORT))),
671
853
  /** @experimental */
672
- engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkY5NSCZA2cjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkY5NSCZA2cjs.VERSION))),
854
+ engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkDXXJPH55cjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkDXXJPH55cjs.VERSION))),
673
855
  /**
674
856
  * @experimental
675
857
  *
@@ -703,7 +885,7 @@ var RegistryConfigSchema = _zod.z.object({
703
885
  * after calling `CoreRegistry::shutdown()`. Defaults to the
704
886
  * engine-provided actor stop threshold once the envoy connects.
705
887
  *
706
- * Must be >= rivetkit-core's drain timeout (20s) + margin.
888
+ * Must be long enough for rivetkit-core to drain the envoy.
707
889
  */
708
890
  gracePeriodMs: _zod.z.number().int().min(1e3).optional(),
709
891
  /**
@@ -717,7 +899,7 @@ var RegistryConfigSchema = _zod.z.object({
717
899
  }))
718
900
  }).transform((config, ctx) => {
719
901
  var _a, _b, _c;
720
- const isDevEnv = _chunkY5NSCZA2cjs.isDev.call(void 0, );
902
+ const isDevEnv = _chunkDXXJPH55cjs.isDev.call(void 0, );
721
903
  const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
722
904
  if (config.runtime === "wasm" && sqliteBackend === "local") {
723
905
  ctx.addIssue({
@@ -727,7 +909,7 @@ var RegistryConfigSchema = _zod.z.object({
727
909
  });
728
910
  }
729
911
  const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
730
- const parsedEndpoint = config.endpoint ? _chunkGVTOE34Scjs.tryParseEndpoint.call(void 0, ctx, {
912
+ const parsedEndpoint = config.endpoint ? _chunk7QKCIVAYcjs.tryParseEndpoint.call(void 0, ctx, {
731
913
  endpoint: config.endpoint,
732
914
  path: ["endpoint"],
733
915
  namespace: config.namespace,
@@ -745,13 +927,17 @@ var RegistryConfigSchema = _zod.z.object({
745
927
  message: "configurePool requires either endpoint or startEngine"
746
928
  });
747
929
  }
748
- const endpoint = config.startEngine ? ENGINE_ENDPOINT : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? ENGINE_ENDPOINT : void 0)));
930
+ const localEngineEndpoint = buildEngineEndpoint(
931
+ config.engineHost,
932
+ config.enginePort
933
+ );
934
+ const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT) : void 0)));
749
935
  const validateServerlessEndpoint = Boolean(
750
936
  config.startEngine || parsedEndpoint
751
937
  );
752
938
  const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
753
939
  const token = _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token));
754
- const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkGVTOE34Scjs.tryParseEndpoint.call(void 0, ctx, {
940
+ const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunk7QKCIVAYcjs.tryParseEndpoint.call(void 0, ctx, {
755
941
  endpoint: config.serverless.publicEndpoint,
756
942
  path: ["serverless", "publicEndpoint"]
757
943
  }) : void 0;
@@ -762,7 +948,7 @@ var RegistryConfigSchema = _zod.z.object({
762
948
  path: ["serverless", "publicEndpoint"]
763
949
  });
764
950
  }
765
- const publicEndpoint = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint), () => ( (isDevEnv && config.startEngine ? ENGINE_ENDPOINT : void 0)));
951
+ const publicEndpoint = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.endpoint), () => ( (isDevEnv && config.startEngine ? endpoint : void 0)));
766
952
  const publicNamespace = parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.namespace;
767
953
  const publicToken = _nullishCoalesce((parsedPublicEndpoint == null ? void 0 : parsedPublicEndpoint.token), () => ( config.serverless.publicToken));
768
954
  return {
@@ -786,30 +972,30 @@ function buildActorNames(config) {
786
972
  Object.keys(config.use).map((actorName) => {
787
973
  const definition = config.use[actorName];
788
974
  const options = _nullishCoalesce(definition.config.options, () => ( {}));
789
- const runMeta = _chunkWQ4HNA4Wcjs.getRunMetadata.call(void 0, definition.config.run);
975
+ const runMeta = _chunkNIY3RSPXcjs.getRunMetadata.call(void 0, definition.config.run);
790
976
  const metadata = {};
791
977
  metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
792
978
  metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
793
979
  metadata.preload = {
794
980
  keys: [
795
- Array.from(_chunkLD5YASJUcjs.KEYS.PERSIST_DATA),
796
- Array.from(_chunkLD5YASJUcjs.KEYS.INSPECTOR_TOKEN),
797
- Array.from(_chunkLD5YASJUcjs.queueMetadataKey.call(void 0, )),
798
- Array.from(_chunkLD5YASJUcjs.KEYS.LAST_PUSHED_ALARM)
981
+ Array.from(_chunkVE2X4KMGcjs.KEYS.PERSIST_DATA),
982
+ Array.from(_chunkVE2X4KMGcjs.KEYS.INSPECTOR_TOKEN),
983
+ Array.from(_chunkVE2X4KMGcjs.queueMetadataKey.call(void 0, )),
984
+ Array.from(_chunkVE2X4KMGcjs.KEYS.LAST_PUSHED_ALARM)
799
985
  ],
800
986
  prefixes: [
801
987
  {
802
- prefix: Array.from(_chunkLD5YASJUcjs.workflowStoragePrefix.call(void 0, )),
988
+ prefix: Array.from(_chunkVE2X4KMGcjs.workflowStoragePrefix.call(void 0, )),
803
989
  maxBytes: _nullishCoalesce(options.preloadMaxWorkflowBytes, () => ( 131072)),
804
990
  partial: false
805
991
  },
806
992
  {
807
- prefix: Array.from(_chunkLD5YASJUcjs.KEYS.CONN_PREFIX),
993
+ prefix: Array.from(_chunkVE2X4KMGcjs.KEYS.CONN_PREFIX),
808
994
  maxBytes: _nullishCoalesce(options.preloadMaxConnectionsBytes, () => ( 65536)),
809
995
  partial: false
810
996
  },
811
997
  {
812
- prefix: Array.from(_chunkLD5YASJUcjs.queueMessagesPrefix.call(void 0, )),
998
+ prefix: Array.from(_chunkVE2X4KMGcjs.queueMessagesPrefix.call(void 0, )),
813
999
  maxBytes: 65536,
814
1000
  partial: false
815
1001
  }
@@ -879,7 +1065,7 @@ var DocRegistryConfigSchema = _zod.z.object({
879
1065
  noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
880
1066
  sqlite: DocSqliteConfigSchema,
881
1067
  logging: _zod.z.object({
882
- level: _chunkY5NSCZA2cjs.LogLevelSchema.optional().describe(
1068
+ level: _chunkDXXJPH55cjs.LogLevelSchema.optional().describe(
883
1069
  "Log level for RivetKit. Default: 'warn'"
884
1070
  )
885
1071
  }).optional().describe("Logging configuration."),
@@ -924,7 +1110,7 @@ function shouldAttachNativeKvError(message) {
924
1110
  function enrichNativeDatabaseError(database, error) {
925
1111
  var _a;
926
1112
  const bridgeReason = typeof error === "string" ? error : error instanceof Error ? error.message : void 0;
927
- const bridged = bridgeReason === void 0 ? void 0 : _chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, bridgeReason);
1113
+ const bridged = bridgeReason === void 0 ? void 0 : _chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, bridgeReason);
928
1114
  if (bridged) {
929
1115
  throw bridged;
930
1116
  }
@@ -1424,6 +1610,9 @@ var NapiCoreRuntime = (_class = class {
1424
1610
  async actorWaitForTrackedShutdownWork(ctx) {
1425
1611
  return await asNativeActorContext(ctx).waitForTrackedShutdownWork();
1426
1612
  }
1613
+ async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
1614
+ await asNativeActorContext(ctx).waitForTrackedShutdownWorkUnbounded();
1615
+ }
1427
1616
  actorKeepAwake(ctx, promise) {
1428
1617
  asNativeActorContext(ctx).keepAwake(promise);
1429
1618
  }
@@ -1535,8 +1724,12 @@ var NapiCoreRuntime = (_class = class {
1535
1724
  )
1536
1725
  );
1537
1726
  }
1538
- async actorQueueWaitForNamesAvailable(ctx, names, options) {
1539
- await asNativeActorContext(ctx).queue().waitForNamesAvailable(names, options);
1727
+ async actorQueueWaitForNamesAvailable(ctx, names, options, signal) {
1728
+ await asNativeActorContext(ctx).queue().waitForNamesAvailable(
1729
+ names,
1730
+ options,
1731
+ signal ? asNativeCancellationToken(signal) : signal
1732
+ );
1540
1733
  }
1541
1734
  async actorQueueEnqueueAndWait(ctx, name, body, options, signal) {
1542
1735
  return await asNativeActorContext(ctx).queue().enqueueAndWait(
@@ -1670,20 +1863,18 @@ function validateQueueComplete(schemas, name, response) {
1670
1863
  response
1671
1864
  );
1672
1865
  if (!result.success) {
1673
- throw validationError(`queue \`${name}\` completion response`, result.issues);
1866
+ throw validationError(
1867
+ `queue \`${name}\` completion response`,
1868
+ result.issues
1869
+ );
1674
1870
  }
1675
1871
  return result.data;
1676
1872
  }
1677
1873
  function validationError(target, issues) {
1678
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
1679
- "actor",
1680
- "validation_error",
1681
- `Invalid ${target}`,
1682
- {
1683
- public: true,
1684
- metadata: { issues }
1685
- }
1686
- );
1874
+ return new (0, _chunkKORQB2IRcjs.RivetError)("actor", "validation_error", `Invalid ${target}`, {
1875
+ public: true,
1876
+ metadata: { issues }
1877
+ });
1687
1878
  }
1688
1879
 
1689
1880
  // src/registry/wasm-runtime.ts
@@ -1749,16 +1940,16 @@ function normalizeQueueMessage(message) {
1749
1940
  }
1750
1941
  function normalizeWasmBridgeError(error) {
1751
1942
  if (typeof error === "string") {
1752
- return _nullishCoalesce(_chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
1943
+ return _nullishCoalesce(_chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
1753
1944
  }
1754
1945
  if (error instanceof Error) {
1755
- const bridged = _chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error.message);
1946
+ const bridged = _chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error.message);
1756
1947
  if (bridged) {
1757
1948
  return bridged;
1758
1949
  }
1759
1950
  }
1760
1951
  if (typeof error === "object" && error !== null && "reason" in error && typeof error.reason === "string") {
1761
- const bridged = _chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error.reason);
1952
+ const bridged = _chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error.reason);
1762
1953
  if (bridged) {
1763
1954
  return bridged;
1764
1955
  }
@@ -1780,7 +1971,7 @@ function callWasmSync(invoke) {
1780
1971
  }
1781
1972
  }
1782
1973
  function unsupportedWasmMethod(method2) {
1783
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
1974
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
1784
1975
  "runtime",
1785
1976
  "unsupported",
1786
1977
  `Unsupported wasm runtime method: ${method2}`,
@@ -2007,6 +2198,12 @@ var WasmCoreRuntime = (_class2 = class {
2007
2198
  "waitForTrackedShutdownWork"
2008
2199
  );
2009
2200
  }
2201
+ async actorWaitForTrackedShutdownWorkUnbounded(ctx) {
2202
+ await callHandle(
2203
+ asWasmActorContext(ctx),
2204
+ "waitForTrackedShutdownWorkUnbounded"
2205
+ );
2206
+ }
2010
2207
  actorKeepAwake(ctx, promise) {
2011
2208
  const wasmCtx = asWasmActorContext(ctx);
2012
2209
  const regionId = callHandle(wasmCtx, "beginKeepAwake");
@@ -2154,9 +2351,15 @@ var WasmCoreRuntime = (_class2 = class {
2154
2351
  )
2155
2352
  );
2156
2353
  }
2157
- async actorQueueWaitForNamesAvailable(ctx, names, options) {
2354
+ async actorQueueWaitForNamesAvailable(ctx, names, options, signal) {
2158
2355
  const queue2 = childHandle(asWasmActorContext(ctx), "queue");
2159
- await callHandleAsync(queue2, "waitForNamesAvailable", names, options);
2356
+ await callHandleAsync(
2357
+ queue2,
2358
+ "waitForNamesAvailable",
2359
+ names,
2360
+ options,
2361
+ signal
2362
+ );
2160
2363
  }
2161
2364
  async actorQueueEnqueueAndWait(ctx, name, body, options, signal) {
2162
2365
  const queue2 = childHandle(asWasmActorContext(ctx), "queue");
@@ -2248,6 +2451,33 @@ async function loadWasmRuntime(config) {
2248
2451
  };
2249
2452
  }
2250
2453
 
2454
+ // src/registry/native.ts
2455
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
2456
+ var _path2 = require('path'); var _path3 = _interopRequireDefault(_path2);
2457
+
2458
+ // src/registry/write-through-proxy.ts
2459
+ var _onchange = require('@rivetkit/on-change'); var _onchange2 = _interopRequireDefault(_onchange);
2460
+ function createWriteThroughProxy(value, commit, beforeChange) {
2461
+ if (!value || typeof value !== "object") {
2462
+ return value;
2463
+ }
2464
+ return _onchange2.default.call(void 0,
2465
+ value,
2466
+ () => {
2467
+ commit(value);
2468
+ },
2469
+ {
2470
+ // Rejection is throw-based: beforeChange throws to prevent the
2471
+ // mutation. We always return true so on-change applies the change
2472
+ // if beforeChange did not throw.
2473
+ onValidate(_path, newValue) {
2474
+ beforeChange == null ? void 0 : beforeChange(newValue);
2475
+ return true;
2476
+ }
2477
+ }
2478
+ );
2479
+ }
2480
+
2251
2481
  // src/registry/native.ts
2252
2482
  var textEncoder = new TextEncoder();
2253
2483
  var textDecoder = new TextDecoder();
@@ -2260,7 +2490,7 @@ function trySetProcessEnv(key, value) {
2260
2490
  if (typeof process === "undefined") return;
2261
2491
  try {
2262
2492
  process.env[key] = value;
2263
- } catch (e) {
2493
+ } catch (e2) {
2264
2494
  }
2265
2495
  }
2266
2496
  function detectRuntimeHost() {
@@ -2281,7 +2511,7 @@ function loadedRuntimeKind(runtime) {
2281
2511
  case "wasm":
2282
2512
  return "wasm";
2283
2513
  }
2284
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
2514
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
2285
2515
  "config",
2286
2516
  "unknown_runtime",
2287
2517
  "RivetKit runtime must be NAPI or wasm.",
@@ -2297,7 +2527,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
2297
2527
  }
2298
2528
  try {
2299
2529
  return (await loaders.loadNative()).runtime;
2300
- } catch (e2) {
2530
+ } catch (e3) {
2301
2531
  return (await loaders.loadWasm(config.wasm)).runtime;
2302
2532
  }
2303
2533
  }
@@ -2321,7 +2551,7 @@ function normalizeRuntimeConfigForKind(config, runtimeKind) {
2321
2551
  return config;
2322
2552
  }
2323
2553
  if (sqliteBackendForConfig(config) === "local") {
2324
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
2554
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
2325
2555
  "config",
2326
2556
  "wasm_local_sqlite",
2327
2557
  "WebAssembly runtime cannot use local SQLite. Use remote SQLite instead.",
@@ -2387,22 +2617,30 @@ function getNativeConnPersistState(runtime, ctx, conn) {
2387
2617
  return connState;
2388
2618
  }
2389
2619
  function stateMutationReentrantError() {
2390
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
2620
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2391
2621
  "actor",
2392
2622
  "state_mutation_reentrant",
2393
2623
  "State mutations are not allowed inside onStateChange."
2394
2624
  );
2395
2625
  }
2396
2626
  function databaseNotConfiguredError() {
2397
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
2627
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2398
2628
  "actor",
2399
2629
  "database_not_configured",
2400
2630
  "database is not configured for this actor",
2401
2631
  { public: true }
2402
2632
  );
2403
2633
  }
2634
+ function databaseClientNotReadyError() {
2635
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2636
+ "actor",
2637
+ "database_client_not_ready",
2638
+ "actor database client was not initialized before user code ran. this is an internal lifecycle error; the migration callback should have pre-warmed the client. file an issue if you can reproduce.",
2639
+ { public: true }
2640
+ );
2641
+ }
2404
2642
  function stateNotEnabledError() {
2405
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
2643
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2406
2644
  "actor",
2407
2645
  "state_not_enabled",
2408
2646
  "State not enabled. Must implement `createState` or `state` to use state. (https://www.rivet.dev/docs/actors/state/#initializing-state)",
@@ -2410,7 +2648,7 @@ function stateNotEnabledError() {
2410
2648
  );
2411
2649
  }
2412
2650
  function nativeClientNotConfiguredError() {
2413
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
2651
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2414
2652
  "native",
2415
2653
  "client_not_configured",
2416
2654
  "native actor client is not configured",
@@ -2418,7 +2656,7 @@ function nativeClientNotConfiguredError() {
2418
2656
  );
2419
2657
  }
2420
2658
  function nativeEndpointNotConfiguredError() {
2421
- return new (0, _chunkQAZLM4WTcjs.RivetError)(
2659
+ return new (0, _chunkKORQB2IRcjs.RivetError)(
2422
2660
  "native",
2423
2661
  "endpoint_not_configured",
2424
2662
  "registry endpoint is required for native envoy startup",
@@ -2452,8 +2690,23 @@ function resolveNativeDestroy(runtime, ctx) {
2452
2690
  function clearNativeRuntimeState(runtime, ctx) {
2453
2691
  callNativeSync(() => runtime.actorClearRuntimeState(ctx));
2454
2692
  }
2455
- async function cleanupNativeSleepRuntimeState(runtime, ctx) {
2456
- await runtime.actorWaitForTrackedShutdownWork(ctx);
2693
+ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
2694
+ const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
2695
+ if (!drained) {
2696
+ await closeNativeDatabaseClient(runtime, ctx);
2697
+ await closeNativeSqlDatabase(runtime, ctx);
2698
+ void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
2699
+ await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
2700
+ clearNativeRuntimeState(runtime, ctx);
2701
+ }).catch((error) => {
2702
+ logger2().warn({
2703
+ msg: "deferred native sleep cleanup failed",
2704
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
2705
+ });
2706
+ });
2707
+ return;
2708
+ }
2709
+ await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
2457
2710
  await closeNativeDatabaseClient(runtime, ctx);
2458
2711
  await closeNativeSqlDatabase(runtime, ctx);
2459
2712
  clearNativeRuntimeState(runtime, ctx);
@@ -2558,10 +2811,13 @@ function decodeValue(value) {
2558
2811
  if (!value || value.length === 0) {
2559
2812
  return void 0;
2560
2813
  }
2561
- return _chunkVJFRBJVQcjs.decodeCborJsonCompat.call(void 0, value);
2814
+ return _chunk3677IIOVcjs.decodeCborCompat.call(void 0, value);
2562
2815
  }
2563
2816
  function encodeValue(value) {
2564
- return _chunkVJFRBJVQcjs.encodeCborCompat.call(void 0, value);
2817
+ return _chunk3677IIOVcjs.encodeCborCompat.call(void 0, value);
2818
+ }
2819
+ function normalizeArgs(value) {
2820
+ return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
2565
2821
  }
2566
2822
  function unwrapTsfnPayload(error, payload) {
2567
2823
  if (error !== null && error !== void 0) {
@@ -2571,16 +2827,16 @@ function unwrapTsfnPayload(error, payload) {
2571
2827
  }
2572
2828
  function normalizeNativeBridgeError(error) {
2573
2829
  if (typeof error === "string") {
2574
- return _nullishCoalesce(_chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
2830
+ return _nullishCoalesce(_chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error), () => ( error));
2575
2831
  }
2576
2832
  if (error instanceof Error) {
2577
- const bridged = _chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error.message);
2833
+ const bridged = _chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error.message);
2578
2834
  if (bridged) {
2579
2835
  return bridged;
2580
2836
  }
2581
2837
  }
2582
2838
  if (typeof error === "object" && error !== null && "reason" in error && typeof error.reason === "string") {
2583
- const bridged = _chunkQAZLM4WTcjs.decodeBridgeRivetError.call(void 0, error.reason);
2839
+ const bridged = _chunkKORQB2IRcjs.decodeBridgeRivetError.call(void 0, error.reason);
2584
2840
  if (bridged) {
2585
2841
  return bridged;
2586
2842
  }
@@ -2588,14 +2844,14 @@ function normalizeNativeBridgeError(error) {
2588
2844
  return error;
2589
2845
  }
2590
2846
  function isStructuredBridgeError(error) {
2591
- if (error instanceof _chunkQAZLM4WTcjs.RivetError) {
2847
+ if (error instanceof _chunkKORQB2IRcjs.RivetError) {
2592
2848
  return true;
2593
2849
  }
2594
- return _chunkQAZLM4WTcjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
2850
+ return _chunkKORQB2IRcjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
2595
2851
  }
2596
2852
  function encodeNativeCallbackError(error) {
2597
- const structuredError = isStructuredBridgeError(error) ? error : _chunkY5NSCZA2cjs.deconstructError.call(void 0, error, true);
2598
- const bridgeError = new Error(_chunkQAZLM4WTcjs.encodeBridgeRivetError.call(void 0, structuredError), {
2853
+ const structuredError = isStructuredBridgeError(error) ? error : _chunkDXXJPH55cjs.deconstructError.call(void 0, error, true);
2854
+ const bridgeError = new Error(_chunkKORQB2IRcjs.encodeBridgeRivetError.call(void 0, structuredError), {
2599
2855
  cause: error instanceof Error ? error : void 0
2600
2856
  });
2601
2857
  return Object.assign(bridgeError, {
@@ -2618,16 +2874,10 @@ function callNativeSync(invoke) {
2618
2874
  throw normalizeNativeBridgeError(error);
2619
2875
  }
2620
2876
  }
2621
- function actorAbortedError() {
2622
- return Object.assign(new Error("Actor aborted"), {
2623
- group: "actor",
2624
- code: "aborted"
2625
- });
2626
- }
2627
2877
  function isClosedTaskRegistrationError(error) {
2628
- const metadata = error instanceof _chunkQAZLM4WTcjs.RivetError ? error.metadata : void 0;
2878
+ const metadata = error instanceof _chunkKORQB2IRcjs.RivetError ? error.metadata : void 0;
2629
2879
  const metadataError = metadata && typeof metadata === "object" && "error" in metadata ? metadata.error : void 0;
2630
- return error instanceof _chunkQAZLM4WTcjs.RivetError && error.group === "core" && error.code === _chunkQAZLM4WTcjs.INTERNAL_ERROR_CODE && typeof metadataError === "string" && /actor task registration is (closed|not configured)/.test(metadataError);
2880
+ return error instanceof _chunkKORQB2IRcjs.RivetError && error.group === "core" && error.code === _chunkKORQB2IRcjs.INTERNAL_ERROR_CODE && typeof metadataError === "string" && /actor task registration is (closed|not configured)/.test(metadataError);
2631
2881
  }
2632
2882
  async function createCancellationTokenHandle(runtime, signal) {
2633
2883
  if (!signal) {
@@ -2650,8 +2900,8 @@ function decodeWorkflowCbor(data) {
2650
2900
  return null;
2651
2901
  }
2652
2902
  try {
2653
- return _chunkVJFRBJVQcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
2654
- } catch (e3) {
2903
+ return _chunk3677IIOVcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
2904
+ } catch (e4) {
2655
2905
  return null;
2656
2906
  }
2657
2907
  }
@@ -2755,8 +3005,8 @@ function serializeWorkflowHistoryForJson(data) {
2755
3005
  if (data === null) {
2756
3006
  return null;
2757
3007
  }
2758
- const history = _chunk4CGA6QJOcjs.decodeWorkflowHistoryTransport.call(void 0, data);
2759
- return {
3008
+ const history = _chunk47HHIEXHcjs.decodeWorkflowHistoryTransport.call(void 0, data);
3009
+ return jsonSafe({
2760
3010
  nameRegistry: [...history.nameRegistry],
2761
3011
  entries: history.entries.map((entry) => ({
2762
3012
  id: entry.id,
@@ -2780,7 +3030,7 @@ function serializeWorkflowHistoryForJson(data) {
2780
3030
  ]
2781
3031
  )
2782
3032
  )
2783
- };
3033
+ });
2784
3034
  }
2785
3035
  function toHttpJsonCompatible(value) {
2786
3036
  return JSON.parse(
@@ -2831,45 +3081,7 @@ function wrapNativeCallback(callback) {
2831
3081
  }
2832
3082
  function decodeArgs(value) {
2833
3083
  const decoded = decodeValue(value);
2834
- return Array.isArray(decoded) ? decoded : decoded === void 0 ? [] : [decoded];
2835
- }
2836
- function createWriteThroughProxy(value, commit, beforeChange) {
2837
- if (!value || typeof value !== "object") {
2838
- return value;
2839
- }
2840
- const proxies = /* @__PURE__ */ new WeakMap();
2841
- const wrap = (target) => {
2842
- const cached = proxies.get(target);
2843
- if (cached) {
2844
- return cached;
2845
- }
2846
- const proxy = new Proxy(target, {
2847
- get(innerTarget, property, receiver) {
2848
- const result = Reflect.get(innerTarget, property, receiver);
2849
- return result && typeof result === "object" ? wrap(result) : result;
2850
- },
2851
- set(innerTarget, property, nextValue, receiver) {
2852
- beforeChange == null ? void 0 : beforeChange();
2853
- const updated = Reflect.set(
2854
- innerTarget,
2855
- property,
2856
- nextValue,
2857
- receiver
2858
- );
2859
- commit(value);
2860
- return updated;
2861
- },
2862
- deleteProperty(innerTarget, property) {
2863
- beforeChange == null ? void 0 : beforeChange();
2864
- const updated = Reflect.deleteProperty(innerTarget, property);
2865
- commit(value);
2866
- return updated;
2867
- }
2868
- });
2869
- proxies.set(target, proxy);
2870
- return proxy;
2871
- };
2872
- return wrap(value);
3084
+ return normalizeArgs(decoded);
2873
3085
  }
2874
3086
  function buildRequest(init) {
2875
3087
  const url = init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString();
@@ -2906,7 +3118,7 @@ var NativeConnAdapter = class {
2906
3118
  this.#schemas = schemas;
2907
3119
  this.#ctx = ctx;
2908
3120
  this.#queueHibernationRemoval = queueHibernationRemoval;
2909
- this[_chunkWQ4HNA4Wcjs.CONN_STATE_MANAGER_SYMBOL] = {
3121
+ this[_chunkNIY3RSPXcjs.CONN_STATE_MANAGER_SYMBOL] = {
2910
3122
  stateEnabled: true,
2911
3123
  get state() {
2912
3124
  return thisConn.state;
@@ -2923,13 +3135,23 @@ var NativeConnAdapter = class {
2923
3135
  decodeValue(this.#runtime.connParams(this.#conn))
2924
3136
  );
2925
3137
  }
3138
+ [_chunkNIY3RSPXcjs.RAW_STATE_SYMBOL]() {
3139
+ return this.#readState();
3140
+ }
2926
3141
  get state() {
2927
3142
  const nextState = this.#readState();
2928
- return createWriteThroughProxy(nextState, (nextValue) => {
2929
- this.#writeState(nextValue, { writeNative: true });
2930
- });
3143
+ return createWriteThroughProxy(
3144
+ nextState,
3145
+ (nextValue) => {
3146
+ this.#writeState(nextValue, { writeNative: true });
3147
+ },
3148
+ (newValue) => {
3149
+ _chunk3677IIOVcjs.assertJsonCompatValue.call(void 0, newValue);
3150
+ }
3151
+ );
2931
3152
  }
2932
3153
  set state(value) {
3154
+ _chunk3677IIOVcjs.assertJsonCompatValue.call(void 0, value);
2933
3155
  this.#writeState(value, { writeNative: true });
2934
3156
  }
2935
3157
  initializeState(value) {
@@ -3034,7 +3256,7 @@ var NativeKvAdapter = class {
3034
3256
  const value = await callNative(
3035
3257
  () => this.#runtime.actorKvGet(
3036
3258
  this.#ctx,
3037
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
3259
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
3038
3260
  )
3039
3261
  );
3040
3262
  return value ? decodeNativeKvValue(new Uint8Array(value), options) : null;
@@ -3043,7 +3265,7 @@ var NativeKvAdapter = class {
3043
3265
  await callNative(
3044
3266
  () => this.#runtime.actorKvPut(
3045
3267
  this.#ctx,
3046
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key)),
3268
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key)),
3047
3269
  toRuntimeBytes(value)
3048
3270
  )
3049
3271
  );
@@ -3052,7 +3274,7 @@ var NativeKvAdapter = class {
3052
3274
  await callNative(
3053
3275
  () => this.#runtime.actorKvDelete(
3054
3276
  this.#ctx,
3055
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
3277
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
3056
3278
  )
3057
3279
  );
3058
3280
  }
@@ -3060,8 +3282,8 @@ var NativeKvAdapter = class {
3060
3282
  await callNative(
3061
3283
  () => this.#runtime.actorKvDeleteRange(
3062
3284
  this.#ctx,
3063
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(start)),
3064
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(end))
3285
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(start)),
3286
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(end))
3065
3287
  )
3066
3288
  );
3067
3289
  }
@@ -3074,7 +3296,7 @@ var NativeKvAdapter = class {
3074
3296
  const entries = await callNative(
3075
3297
  () => this.#runtime.actorKvListPrefix(
3076
3298
  this.#ctx,
3077
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0,
3299
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0,
3078
3300
  encodeNativeKvUserKey(
3079
3301
  prefix,
3080
3302
  options == null ? void 0 : options.keyType
@@ -3088,7 +3310,7 @@ var NativeKvAdapter = class {
3088
3310
  );
3089
3311
  return entries.map((entry) => [
3090
3312
  decodeNativeKvKey(
3091
- _chunkLD5YASJUcjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
3313
+ _chunkVE2X4KMGcjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
3092
3314
  options == null ? void 0 : options.keyType
3093
3315
  ),
3094
3316
  decodeNativeKvValue(new Uint8Array(entry.value), options)
@@ -3107,13 +3329,13 @@ var NativeKvAdapter = class {
3107
3329
  const entries = await callNative(
3108
3330
  () => this.#runtime.actorKvListRange(
3109
3331
  this.#ctx,
3110
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0,
3332
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0,
3111
3333
  encodeNativeKvUserKey(
3112
3334
  start,
3113
3335
  options == null ? void 0 : options.keyType
3114
3336
  )
3115
3337
  ),
3116
- _chunkLD5YASJUcjs.makePrefixedKey.call(void 0,
3338
+ _chunkVE2X4KMGcjs.makePrefixedKey.call(void 0,
3117
3339
  encodeNativeKvUserKey(
3118
3340
  end,
3119
3341
  options == null ? void 0 : options.keyType
@@ -3127,7 +3349,7 @@ var NativeKvAdapter = class {
3127
3349
  );
3128
3350
  return entries.map((entry) => [
3129
3351
  decodeNativeKvKey(
3130
- _chunkLD5YASJUcjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
3352
+ _chunkVE2X4KMGcjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
3131
3353
  options == null ? void 0 : options.keyType
3132
3354
  ),
3133
3355
  decodeNativeKvValue(new Uint8Array(entry.value), options)
@@ -3219,7 +3441,7 @@ var NativeQueueAdapter = class {
3219
3441
  async nextBatch(options) {
3220
3442
  const completable = (options == null ? void 0 : options.completable) === true;
3221
3443
  if (this.#pendingCompletableMessageIds.size > 0) {
3222
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
3444
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
3223
3445
  "queue",
3224
3446
  "previous_message_not_completed",
3225
3447
  "Previous completable queue message is not completed. Call `message.complete(...)` before receiving the next message.",
@@ -3281,44 +3503,23 @@ var NativeQueueAdapter = class {
3281
3503
  }
3282
3504
  }
3283
3505
  async waitForNamesAvailable(names, options) {
3284
- if (!(options == null ? void 0 : options.signal)) {
3506
+ const { token, cleanup } = await createCancellationTokenHandle(
3507
+ this.#runtime,
3508
+ options == null ? void 0 : options.signal
3509
+ );
3510
+ try {
3285
3511
  await callNative(
3286
3512
  () => this.#runtime.actorQueueWaitForNamesAvailable(
3287
3513
  this.#ctx,
3288
3514
  [...names],
3289
3515
  {
3290
3516
  timeoutMs: options == null ? void 0 : options.timeout
3291
- }
3517
+ },
3518
+ token
3292
3519
  )
3293
3520
  );
3294
- return;
3295
- }
3296
- const deadline = options.timeout === void 0 ? void 0 : Date.now() + options.timeout;
3297
- for (; ; ) {
3298
- if (options.signal.aborted) {
3299
- throw actorAbortedError();
3300
- }
3301
- const remainingTimeout = deadline === void 0 ? void 0 : Math.max(0, deadline - Date.now());
3302
- const sliceTimeout = remainingTimeout === void 0 ? 100 : Math.min(remainingTimeout, 100);
3303
- try {
3304
- await callNative(
3305
- () => this.#runtime.actorQueueWaitForNamesAvailable(
3306
- this.#ctx,
3307
- [...names],
3308
- {
3309
- timeoutMs: sliceTimeout
3310
- }
3311
- )
3312
- );
3313
- return;
3314
- } catch (error) {
3315
- if (error.group === "queue" && error.code === "timed_out") {
3316
- if (remainingTimeout === void 0 || remainingTimeout > 100) {
3317
- continue;
3318
- }
3319
- }
3320
- throw error;
3321
- }
3521
+ } finally {
3522
+ cleanup == null ? void 0 : cleanup();
3322
3523
  }
3323
3524
  }
3324
3525
  async enqueueAndWait(name, body, options) {
@@ -3388,7 +3589,7 @@ var NativeQueueAdapter = class {
3388
3589
  }
3389
3590
  yield message;
3390
3591
  } catch (error) {
3391
- if (_chunkQAZLM4WTcjs.isRivetErrorLike.call(void 0, error) && error.group === "actor" && error.code === "aborted") {
3592
+ if (_chunkKORQB2IRcjs.isRivetErrorLike.call(void 0, error) && error.group === "actor" && error.code === "aborted") {
3392
3593
  return;
3393
3594
  }
3394
3595
  throw error;
@@ -3409,7 +3610,7 @@ var NativeQueueAdapter = class {
3409
3610
  ...message,
3410
3611
  complete: async (response) => {
3411
3612
  if (typeof message.complete !== "function") {
3412
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
3613
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
3413
3614
  "queue",
3414
3615
  "complete_not_configured",
3415
3616
  `Queue '${message.name}' does not support completion responses.`,
@@ -3421,7 +3622,7 @@ var NativeQueueAdapter = class {
3421
3622
  );
3422
3623
  }
3423
3624
  if (completed) {
3424
- throw new (0, _chunkQAZLM4WTcjs.RivetError)(
3625
+ throw new (0, _chunkKORQB2IRcjs.RivetError)(
3425
3626
  "queue",
3426
3627
  "already_completed",
3427
3628
  "Queue message was already completed.",
@@ -3753,6 +3954,68 @@ var TrackedWebSocketHandleAdapter = class {
3753
3954
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
3754
3955
  }
3755
3956
  };
3957
+ var NativeConnectionMap = (_class3 = class {
3958
+ #runtime;
3959
+ #ctx;
3960
+ #schemas;
3961
+ constructor(runtime, ctx, schemas) {;_class3.prototype.__init3.call(this);
3962
+ this.#runtime = runtime;
3963
+ this.#ctx = ctx;
3964
+ this.#schemas = schemas;
3965
+ }
3966
+ #connToAdapter(conn) {
3967
+ return new NativeConnAdapter(
3968
+ this.#runtime,
3969
+ conn,
3970
+ this.#schemas,
3971
+ this.#ctx,
3972
+ (connId) => callNativeSync(
3973
+ () => this.#runtime.actorQueueHibernationRemoval(
3974
+ this.#ctx,
3975
+ connId
3976
+ )
3977
+ )
3978
+ );
3979
+ }
3980
+ get size() {
3981
+ return callNativeSync(() => this.#runtime.actorConns(this.#ctx)).length;
3982
+ }
3983
+ get(key) {
3984
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
3985
+ const conn = conns.find((c) => this.#runtime.connId(c) === key);
3986
+ if (!conn) return void 0;
3987
+ return this.#connToAdapter(conn);
3988
+ }
3989
+ has(key) {
3990
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
3991
+ return conns.some((c) => this.#runtime.connId(c) === key);
3992
+ }
3993
+ keys() {
3994
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
3995
+ return conns.map((c) => this.#runtime.connId(c))[Symbol.iterator]();
3996
+ }
3997
+ values() {
3998
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
3999
+ return conns.map((c) => this.#connToAdapter(c))[Symbol.iterator]();
4000
+ }
4001
+ entries() {
4002
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
4003
+ return conns.map(
4004
+ (c) => [this.#runtime.connId(c), this.#connToAdapter(c)]
4005
+ )[Symbol.iterator]();
4006
+ }
4007
+ forEach(callback, thisArg) {
4008
+ const conns = callNativeSync(() => this.#runtime.actorConns(this.#ctx));
4009
+ for (const conn of conns) {
4010
+ const id = this.#runtime.connId(conn);
4011
+ callback.call(thisArg, this.#connToAdapter(conn), id, this);
4012
+ }
4013
+ }
4014
+ [Symbol.iterator]() {
4015
+ return this.entries();
4016
+ }
4017
+ __init3() {this[Symbol.toStringTag] = "NativeConnectionMap"}
4018
+ }, _class3);
3756
4019
  var ActorContextHandleAdapter = class {
3757
4020
  #runtime;
3758
4021
  #ctx;
@@ -3761,9 +4024,9 @@ var ActorContextHandleAdapter = class {
3761
4024
  #abortSignalCleanup;
3762
4025
  #client;
3763
4026
  #clientFactory;
4027
+ #connMap;
3764
4028
  #databaseProvider;
3765
4029
  #db;
3766
- #dbProxy;
3767
4030
  #dispatchCancelToken;
3768
4031
  #kv;
3769
4032
  #queue;
@@ -3786,7 +4049,7 @@ var ActorContextHandleAdapter = class {
3786
4049
  this.#databaseProvider = databaseProvider;
3787
4050
  }
3788
4051
  this.#request = request;
3789
- this[_chunkWQ4HNA4Wcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
4052
+ this[_chunkNIY3RSPXcjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
3790
4053
  this
3791
4054
  );
3792
4055
  }
@@ -3806,30 +4069,22 @@ var ActorContextHandleAdapter = class {
3806
4069
  if (!this.#databaseProvider) {
3807
4070
  throw databaseNotConfiguredError();
3808
4071
  }
3809
- if (!this.#dbProxy) {
3810
- this.#dbProxy = new Proxy(
3811
- {},
3812
- {
3813
- get: (_target, property) => {
3814
- if (property === "then") {
3815
- return void 0;
3816
- }
3817
- return async (...args) => {
3818
- const client = await this.ensureDatabaseClient();
3819
- const value = Reflect.get(
3820
- client,
3821
- property
3822
- );
3823
- if (typeof value !== "function") {
3824
- return value;
3825
- }
3826
- return await value.apply(client, args);
3827
- };
3828
- }
3829
- }
3830
- );
4072
+ if (this.#db) {
4073
+ return this.#db;
3831
4074
  }
3832
- return this.#dbProxy;
4075
+ const runtimeState = getNativeRuntimeState(this.#runtime, this.#ctx);
4076
+ const cachedClient = runtimeState.databaseClient;
4077
+ if (cachedClient) {
4078
+ this.#db = cachedClient.client;
4079
+ return this.#db;
4080
+ }
4081
+ throw databaseClientNotReadyError();
4082
+ }
4083
+ [_chunkNIY3RSPXcjs.RAW_STATE_SYMBOL]() {
4084
+ if (!this.#stateEnabled) {
4085
+ throw stateNotEnabledError();
4086
+ }
4087
+ return this.#readState();
3833
4088
  }
3834
4089
  get state() {
3835
4090
  if (!this.#stateEnabled) {
@@ -3844,8 +4099,9 @@ var ActorContextHandleAdapter = class {
3844
4099
  (nextValue) => {
3845
4100
  this.#writeState(nextValue, { scheduleSave: true });
3846
4101
  },
3847
- () => {
4102
+ (newValue) => {
3848
4103
  this.#assertCanMutateState();
4104
+ _chunk3677IIOVcjs.assertJsonCompatValue.call(void 0, newValue);
3849
4105
  }
3850
4106
  );
3851
4107
  }
@@ -3856,6 +4112,7 @@ var ActorContextHandleAdapter = class {
3856
4112
  throw stateNotEnabledError();
3857
4113
  }
3858
4114
  this.#assertCanMutateState();
4115
+ _chunk3677IIOVcjs.assertJsonCompatValue.call(void 0, value);
3859
4116
  this.#writeState(value, { scheduleSave: true });
3860
4117
  }
3861
4118
  initializeState(value) {
@@ -3912,25 +4169,14 @@ var ActorContextHandleAdapter = class {
3912
4169
  return callNativeSync(() => this.#runtime.actorRegion(this.#ctx));
3913
4170
  }
3914
4171
  get conns() {
3915
- return new Map(
3916
- callNativeSync(() => this.#runtime.actorConns(this.#ctx)).map(
3917
- (conn) => [
3918
- this.#runtime.connId(conn),
3919
- new NativeConnAdapter(
3920
- this.#runtime,
3921
- conn,
3922
- this.#schemas,
3923
- this.#ctx,
3924
- (connId) => callNativeSync(
3925
- () => this.#runtime.actorQueueHibernationRemoval(
3926
- this.#ctx,
3927
- connId
3928
- )
3929
- )
3930
- )
3931
- ]
3932
- )
3933
- );
4172
+ if (!this.#connMap) {
4173
+ this.#connMap = new NativeConnectionMap(
4174
+ this.#runtime,
4175
+ this.#ctx,
4176
+ this.#schemas
4177
+ );
4178
+ }
4179
+ return this.#connMap;
3934
4180
  }
3935
4181
  get log() {
3936
4182
  return logger2();
@@ -4131,7 +4377,7 @@ var ActorContextHandleAdapter = class {
4131
4377
  const trackedPromise = Promise.resolve(promise).catch((error) => {
4132
4378
  logger2().warn({
4133
4379
  msg: "keepAwake promise rejected",
4134
- error: _chunkY5NSCZA2cjs.stringifyError.call(void 0, error)
4380
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
4135
4381
  });
4136
4382
  }).then(() => null);
4137
4383
  try {
@@ -4207,6 +4453,7 @@ var ActorContextHandleAdapter = class {
4207
4453
  return false;
4208
4454
  }
4209
4455
  sleep() {
4456
+ this.#flushStateChange();
4210
4457
  callNativeSync(() => this.#runtime.actorSleep(this.#ctx));
4211
4458
  }
4212
4459
  destroy() {
@@ -4496,9 +4743,62 @@ function buildActorConfig(definition, registryConfig) {
4496
4743
  maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
4497
4744
  preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
4498
4745
  preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
4499
- actions: Object.keys(_nullishCoalesce(config.actions, () => ( {}))).sort().map((name) => ({ name }))
4746
+ actions: Object.keys(_nullishCoalesce(config.actions, () => ( {}))).sort().map((name) => ({ name })),
4747
+ inspectorTabs: buildInspectorTabs(config.inspector)
4500
4748
  };
4501
4749
  }
4750
+ function buildInspectorTabs(inspector) {
4751
+ if (!inspector || typeof inspector !== "object") return void 0;
4752
+ const tabs = inspector.tabs;
4753
+ if (!Array.isArray(tabs) || tabs.length === 0) return void 0;
4754
+ return tabs.map((raw) => {
4755
+ const entry = raw;
4756
+ if (entry.hidden === true) {
4757
+ return { id: entry.id, hidden: true };
4758
+ }
4759
+ const resolved = entry.source !== void 0 ? _path3.default.resolve(entry.source) : void 0;
4760
+ if (resolved !== void 0) {
4761
+ validateInspectorTabSource(entry.id, resolved);
4762
+ }
4763
+ return {
4764
+ id: entry.id,
4765
+ label: entry.label,
4766
+ icon: entry.icon,
4767
+ source: resolved
4768
+ };
4769
+ });
4770
+ }
4771
+ function validateInspectorTabSource(tabId, resolved) {
4772
+ if (resolved === _path3.default.parse(resolved).root) {
4773
+ throw new Error(
4774
+ `inspector.tabs[id="${tabId}"].source resolves to the filesystem root (${resolved}). Point it at the tab's own static-asset directory instead.`
4775
+ );
4776
+ }
4777
+ let stat;
4778
+ try {
4779
+ stat = _fs2.default.statSync(resolved);
4780
+ } catch (err) {
4781
+ const code = err == null ? void 0 : err.code;
4782
+ if (code === "ENOENT") {
4783
+ throw new Error(
4784
+ `inspector.tabs[id="${tabId}"].source (${resolved}) does not exist.`
4785
+ );
4786
+ }
4787
+ if (code === "EACCES") {
4788
+ throw new Error(
4789
+ `inspector.tabs[id="${tabId}"].source (${resolved}) is not readable (EACCES).`
4790
+ );
4791
+ }
4792
+ throw new Error(
4793
+ `inspector.tabs[id="${tabId}"].source (${resolved}) could not be stat'd: ${_nullishCoalesce((err == null ? void 0 : err.message), () => ( err))}`
4794
+ );
4795
+ }
4796
+ if (!stat.isDirectory()) {
4797
+ throw new Error(
4798
+ `inspector.tabs[id="${tabId}"].source (${resolved}) must be a directory, got ${stat.isFile() ? "file" : "non-directory"}.`
4799
+ );
4800
+ }
4801
+ }
4502
4802
  function buildNativeFactory(runtime, registryConfig, definition) {
4503
4803
  var _a;
4504
4804
  const config = definition.config;
@@ -4512,9 +4812,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4512
4812
  const actionHandlers = Object.fromEntries(
4513
4813
  Object.entries(_nullishCoalesce(config.actions, () => ( {}))).map(([name, handler]) => [name, handler])
4514
4814
  );
4515
- const createClient = () => _chunkGVTOE34Scjs.createClientWithDriver.call(void 0,
4516
- new (0, _chunkGVTOE34Scjs.RemoteEngineControlClient)(
4517
- _chunkGVTOE34Scjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
4815
+ const createClient = () => _chunk7QKCIVAYcjs.createClientWithDriver.call(void 0,
4816
+ new (0, _chunk7QKCIVAYcjs.RemoteEngineControlClient)(
4817
+ _chunk7QKCIVAYcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
4518
4818
  ),
4519
4819
  { encoding: "bare" }
4520
4820
  );
@@ -4524,7 +4824,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4524
4824
  ), () => ( false));
4525
4825
  const getNativeWorkflowInspector = (ctx) => {
4526
4826
  var _a2;
4527
- return (_a2 = _chunkWQ4HNA4Wcjs.getRunInspectorConfig.call(void 0,
4827
+ return (_a2 = _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0,
4528
4828
  config.run,
4529
4829
  callNativeSync(() => runtime.actorId(ctx))
4530
4830
  )) == null ? void 0 : _a2.workflow;
@@ -4577,7 +4877,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4577
4877
  }
4578
4878
  });
4579
4879
  const errorResponse = (error, status) => {
4580
- const rivetError = _chunkQAZLM4WTcjs.toRivetError.call(void 0, error);
4880
+ const rivetError = _chunkKORQB2IRcjs.toRivetError.call(void 0, error);
4581
4881
  return jsonResponse(
4582
4882
  {
4583
4883
  group: rivetError.group,
@@ -4687,6 +4987,10 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4687
4987
  isWorkflowEnabled: getNativeWorkflowInspector(ctx) !== void 0
4688
4988
  });
4689
4989
  } catch (error) {
4990
+ logger2().error({
4991
+ msg: "error replaying workflow history",
4992
+ error
4993
+ });
4690
4994
  return errorResponse(error);
4691
4995
  }
4692
4996
  }
@@ -4818,7 +5122,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4818
5122
  const action = actionHandlers[actionName];
4819
5123
  if (!action) {
4820
5124
  return errorResponse(
4821
- new (0, _chunkQAZLM4WTcjs.RivetError)(
5125
+ new (0, _chunkKORQB2IRcjs.RivetError)(
4822
5126
  "action",
4823
5127
  "action_not_found",
4824
5128
  `Action ${actionName} not found`
@@ -4827,17 +5131,34 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4827
5131
  );
4828
5132
  }
4829
5133
  const body = await jsRequest.json();
5134
+ if (body.args !== void 0 && body.properties !== void 0) {
5135
+ return jsonResponse(
5136
+ { error: "use either args or properties, not both" },
5137
+ { status: 400 }
5138
+ );
5139
+ }
5140
+ if (body.properties !== void 0 && (body.properties === null || typeof body.properties !== "object" || Array.isArray(body.properties))) {
5141
+ return jsonResponse(
5142
+ { error: "properties must be an object" },
5143
+ { status: 400 }
5144
+ );
5145
+ }
5146
+ const args = body.properties !== void 0 ? [body.properties] : normalizeArgs(body.args);
4830
5147
  try {
4831
5148
  const output = await action(
4832
5149
  actorCtx,
4833
5150
  ...validateActionArgs(
4834
5151
  schemaConfig.actionInputSchemas,
4835
5152
  actionName,
4836
- _nullishCoalesce(body.args, () => ( []))
5153
+ args
4837
5154
  )
4838
5155
  );
4839
5156
  return jsonResponse({ output });
4840
5157
  } catch (error) {
5158
+ logger2().error({
5159
+ msg: "Error handling inspector action request",
5160
+ error
5161
+ });
4841
5162
  return errorResponse(error);
4842
5163
  }
4843
5164
  }
@@ -4851,6 +5172,10 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4851
5172
  { status: 404 }
4852
5173
  );
4853
5174
  } catch (error) {
5175
+ logger2().error({
5176
+ msg: "Error handling inspector request",
5177
+ error
5178
+ });
4854
5179
  return errorResponse(error);
4855
5180
  } finally {
4856
5181
  await actorCtx.dispose();
@@ -4973,24 +5298,30 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4973
5298
  async (error, payload) => {
4974
5299
  const { ctx } = unwrapTsfnPayload(error, payload);
4975
5300
  const actorCtx = makeActorCtx(ctx);
5301
+ const saveActorState = async () => {
5302
+ if (runtime.kind === "wasm") {
5303
+ await runtime.actorSaveState(
5304
+ ctx,
5305
+ actorCtx.serializeForTick("save")
5306
+ );
5307
+ } else {
5308
+ await actorCtx.saveState({
5309
+ immediate: true
5310
+ });
5311
+ }
5312
+ };
4976
5313
  try {
4977
5314
  if (onSleep) {
4978
- try {
4979
- await onSleep(actorCtx);
4980
- } finally {
4981
- if (runtime.kind === "wasm") {
4982
- await runtime.actorSaveState(
4983
- ctx,
4984
- actorCtx.serializeForTick("save")
4985
- );
4986
- } else {
4987
- await actorCtx.saveState({ immediate: true });
4988
- }
4989
- }
5315
+ await onSleep(actorCtx);
4990
5316
  }
5317
+ await saveActorState();
4991
5318
  } finally {
4992
5319
  try {
4993
- await cleanupNativeSleepRuntimeState(runtime, ctx);
5320
+ await cleanupNativeSleepRuntimeState(
5321
+ runtime,
5322
+ ctx,
5323
+ saveActorState
5324
+ );
4994
5325
  } finally {
4995
5326
  await actorCtx.dispose();
4996
5327
  }
@@ -5155,7 +5486,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5155
5486
  );
5156
5487
  }
5157
5488
  if (!result) {
5158
- throw _chunkQAZLM4WTcjs.forbiddenError.call(void 0, );
5489
+ throw _chunkKORQB2IRcjs.forbiddenError.call(void 0, );
5159
5490
  }
5160
5491
  } finally {
5161
5492
  await actorCtx.dispose();
@@ -5201,7 +5532,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5201
5532
  new Response(null, { status: 404 })
5202
5533
  );
5203
5534
  }
5204
- const rawConnParams = jsRequest.headers.get(_chunkGVTOE34Scjs.HEADER_CONN_PARAMS);
5535
+ const rawConnParams = jsRequest.headers.get(_chunk7QKCIVAYcjs.HEADER_CONN_PARAMS);
5205
5536
  let requestCtx;
5206
5537
  let conn;
5207
5538
  try {
@@ -5266,7 +5597,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5266
5597
  }
5267
5598
  ) : void 0,
5268
5599
  run: (() => {
5269
- const run = _chunkWQ4HNA4Wcjs.getRunFunction.call(void 0, config.run);
5600
+ const run = _chunkNIY3RSPXcjs.getRunFunction.call(void 0, config.run);
5270
5601
  if (!run) {
5271
5602
  return void 0;
5272
5603
  }
@@ -5285,7 +5616,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5285
5616
  }
5286
5617
  );
5287
5618
  })(),
5288
- getWorkflowHistory: _chunkWQ4HNA4Wcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
5619
+ getWorkflowHistory: _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
5289
5620
  async (error, payload) => {
5290
5621
  var _a2;
5291
5622
  const { ctx } = unwrapTsfnPayload(error, payload);
@@ -5293,7 +5624,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5293
5624
  return history == null ? void 0 : encodeValue(history);
5294
5625
  }
5295
5626
  ) : void 0,
5296
- replayWorkflow: _chunkWQ4HNA4Wcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
5627
+ replayWorkflow: _chunkNIY3RSPXcjs.getRunInspectorConfig.call(void 0, config.run) !== void 0 ? wrapNativeCallback(
5297
5628
  async (error, payload) => {
5298
5629
  const { ctx, entryId } = unwrapTsfnPayload(
5299
5630
  error,
@@ -5368,7 +5699,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5368
5699
  name
5369
5700
  );
5370
5701
  if (canPublish && !await canPublish(actorCtx)) {
5371
- throw _chunkQAZLM4WTcjs.forbiddenError.call(void 0, );
5702
+ throw _chunkKORQB2IRcjs.forbiddenError.call(void 0, );
5372
5703
  }
5373
5704
  const decodedBody = decodeValue(body);
5374
5705
  if (wait) {
@@ -5428,25 +5759,32 @@ async function buildServeConfig(config) {
5428
5759
  poolName: config.envoy.poolName,
5429
5760
  handleInspectorHttpInRuntime: true,
5430
5761
  serverlessBasePath: config.serverless.basePath,
5431
- serverlessPackageVersion: _chunkY5NSCZA2cjs.VERSION,
5762
+ serverlessPackageVersion: _chunkDXXJPH55cjs.VERSION,
5432
5763
  serverlessClientEndpoint: config.publicEndpoint,
5433
5764
  serverlessClientNamespace: config.publicNamespace,
5434
5765
  serverlessClientToken: config.publicToken,
5435
5766
  serverlessValidateEndpoint: config.validateServerlessEndpoint,
5436
5767
  serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes
5437
5768
  };
5438
- if (config.startEngine) {
5769
+ try {
5439
5770
  const { getEnginePath } = await loadEngineCli();
5440
5771
  serveConfig.engineBinaryPath = getEnginePath();
5772
+ } catch (error) {
5773
+ logger2().warn({
5774
+ 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",
5775
+ error: _chunkDXXJPH55cjs.stringifyError.call(void 0, error)
5776
+ });
5441
5777
  }
5778
+ serveConfig.engineHost = config.engineHost;
5779
+ serveConfig.enginePort = config.enginePort;
5442
5780
  if ((_a = config.test) == null ? void 0 : _a.enabled) {
5443
- serveConfig.inspectorTestToken = _nullishCoalesce(_chunkY5NSCZA2cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
5781
+ serveConfig.inspectorTestToken = _nullishCoalesce(_chunkDXXJPH55cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
5444
5782
  }
5445
5783
  return serveConfig;
5446
5784
  }
5447
5785
  async function buildRegistryWithRuntime(config, runtime) {
5448
5786
  var _a;
5449
- if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkY5NSCZA2cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
5787
+ if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkDXXJPH55cjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
5450
5788
  trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
5451
5789
  }
5452
5790
  const registry = runtime.createRegistry();
@@ -5488,6 +5826,7 @@ function finishShutdownSignal(signal) {
5488
5826
  }
5489
5827
  var Registry = class {
5490
5828
  #config;
5829
+ #buildConfiguredRegistry;
5491
5830
 
5492
5831
  get config() {
5493
5832
  return this.#config;
@@ -5503,8 +5842,9 @@ var Registry = class {
5503
5842
  #shutdownInstalled = false;
5504
5843
  #shutdownInFlight = null;
5505
5844
  #signalHandlers = {};
5506
- constructor(config) {
5845
+ constructor(config, deps) {
5507
5846
  this.#config = config;
5847
+ this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
5508
5848
  this.routes = {
5509
5849
  health: () => this.#healthRoute(),
5510
5850
  metadata: () => this.#metadataRoute(),
@@ -5514,12 +5854,12 @@ var Registry = class {
5514
5854
  #ensureServerlessPoolConfigured(config) {
5515
5855
  if (!config.configurePool) return void 0;
5516
5856
  if (!this.#configureServerlessPoolPromise) {
5517
- this.#configureServerlessPoolPromise = configureServerlessPool(config).catch(
5518
- (error) => {
5519
- this.#configureServerlessPoolPromise = void 0;
5520
- throw error;
5521
- }
5522
- );
5857
+ this.#configureServerlessPoolPromise = configureServerlessPool(
5858
+ config
5859
+ ).catch((error) => {
5860
+ this.#configureServerlessPoolPromise = void 0;
5861
+ throw error;
5862
+ });
5523
5863
  this.#configureServerlessPoolPromise.catch(() => {
5524
5864
  });
5525
5865
  }
@@ -5540,7 +5880,7 @@ var Registry = class {
5540
5880
  const config = this.parseConfig();
5541
5881
  this.#printWelcome(config, "serverless");
5542
5882
  if (!this.#runtimeServerlessPromise) {
5543
- this.#runtimeServerlessPromise = buildConfiguredRegistry(config);
5883
+ this.#runtimeServerlessPromise = this.#buildConfiguredRegistry(config);
5544
5884
  }
5545
5885
  const { runtime, registry, serveConfig } = await this.#runtimeServerlessPromise;
5546
5886
  const isStartRequest = isServerlessStartRequest(
@@ -5555,7 +5895,7 @@ var Registry = class {
5555
5895
  if (isStartRequest) {
5556
5896
  try {
5557
5897
  await this.#ensureServerlessPoolConfigured(config);
5558
- } catch (error) {
5898
+ } catch (_error) {
5559
5899
  return new Response(
5560
5900
  JSON.stringify({
5561
5901
  group: "guard",
@@ -5669,7 +6009,7 @@ var Registry = class {
5669
6009
  if (isMetadataRequest && !isEngineMetadataRequest) {
5670
6010
  try {
5671
6011
  await this.#ensureServerlessPoolConfigured(config);
5672
- } catch (error) {
6012
+ } catch (_error) {
5673
6013
  return new Response(
5674
6014
  JSON.stringify({
5675
6015
  group: "guard",
@@ -5702,6 +6042,33 @@ var Registry = class {
5702
6042
  fetch: (request) => this.handler(request)
5703
6043
  };
5704
6044
  }
6045
+ /**
6046
+ * Starts an HTTP server that dispatches every request through the
6047
+ * serverless handler. Uses `crossPlatformServe` to pick the right
6048
+ * runtime (Node, Bun, Deno).
6049
+ *
6050
+ * @param opts.port Port to listen on. Defaults to 3000.
6051
+ * @param opts.publicDir If set, serves static files from this directory
6052
+ * before falling through to the registry handler.
6053
+ *
6054
+ * @example
6055
+ * ```ts
6056
+ * await registry.listen();
6057
+ * await registry.listen({ port: 8080, publicDir: "./public" });
6058
+ * ```
6059
+ */
6060
+ async listen(opts = {}) {
6061
+ const port = _nullishCoalesce(opts.port, () => ( 3e3));
6062
+ const config = this.parseConfig();
6063
+ const runtime = _chunkDXXJPH55cjs.detectRuntime.call(void 0, );
6064
+ const app = new (0, _hono.Hono)();
6065
+ if (opts.publicDir) {
6066
+ const serveStatic = await loadRuntimeServeStatic(runtime);
6067
+ app.use("*", serveStatic({ root: opts.publicDir }));
6068
+ }
6069
+ app.all("*", (c) => this.handler(c.req.raw));
6070
+ await crossPlatformServe(config, port, app, runtime);
6071
+ }
5705
6072
  /**
5706
6073
  * Returns a health response suitable for mounting in a user-owned router.
5707
6074
  */
@@ -5711,7 +6078,7 @@ var Registry = class {
5711
6078
  return jsonRouteResponse(503, {
5712
6079
  status: "not_started",
5713
6080
  runtime: "rivetkit",
5714
- version: _chunkY5NSCZA2cjs.VERSION
6081
+ version: _chunkDXXJPH55cjs.VERSION
5715
6082
  });
5716
6083
  }
5717
6084
  const { runtime, registry } = configured;
@@ -5719,7 +6086,7 @@ var Registry = class {
5719
6086
  return jsonRouteResponse(501, {
5720
6087
  status: "unsupported",
5721
6088
  runtime: "rivetkit",
5722
- version: _chunkY5NSCZA2cjs.VERSION
6089
+ version: _chunkDXXJPH55cjs.VERSION
5723
6090
  });
5724
6091
  }
5725
6092
  const response = await runtime.registryHealth(registry);
@@ -5791,20 +6158,20 @@ var Registry = class {
5791
6158
  */
5792
6159
  #startEnvoy(config, printWelcome) {
5793
6160
  if (!this.#runtimeServePromise) {
5794
- const configuredRegistryPromise = buildConfiguredRegistry(config);
6161
+ const configuredRegistryPromise = this.#buildConfiguredRegistry(config);
5795
6162
  this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
5796
6163
  this.#runtimeServePromise = configuredRegistryPromise.then(async ({ runtime, registry, serveConfig }) => {
5797
6164
  await runtime.serveRegistry(registry, serveConfig);
5798
- }).catch((err) => {
5799
- logger2().warn({ err }, "runtime registry serve errored");
6165
+ }).catch((error) => {
6166
+ logger2().warn({ error }, "runtime registry serve errored");
5800
6167
  });
5801
- this.#installSignalHandlers(config, configuredRegistryPromise);
6168
+ this.#installSignalHandlers(config);
5802
6169
  }
5803
6170
  if (printWelcome) {
5804
6171
  this.#printWelcome(config, "serverful");
5805
6172
  }
5806
6173
  }
5807
- #installSignalHandlers(config, configuredRegistryPromise) {
6174
+ #installSignalHandlers(config) {
5808
6175
  var _a;
5809
6176
  if (this.#shutdownInstalled) return;
5810
6177
  if ((_a = config.shutdown) == null ? void 0 : _a.disableSignalHandlers) return;
@@ -5813,58 +6180,86 @@ var Registry = class {
5813
6180
  }
5814
6181
  this.#shutdownInstalled = true;
5815
6182
  const install = (signal) => {
5816
- const handler = () => this.#onShutdownSignal(
5817
- signal,
5818
- config,
5819
- configuredRegistryPromise
5820
- );
6183
+ const handler = () => this.#onShutdownSignal(signal, config);
5821
6184
  this.#signalHandlers[signal] = handler;
5822
6185
  process.on(signal, handler);
5823
6186
  };
5824
6187
  install("SIGINT");
5825
6188
  install("SIGTERM");
5826
6189
  }
5827
- #onShutdownSignal(signal, config, configuredRegistryPromise) {
6190
+ #onShutdownSignal(signal, config) {
5828
6191
  if (this.#shutdownInFlight !== null) {
5829
6192
  this.#removeSignalHandlers();
5830
6193
  finishShutdownSignal(signal);
5831
6194
  return;
5832
6195
  }
5833
- this.#shutdownInFlight = this.#runShutdown(
5834
- signal,
5835
- config,
5836
- configuredRegistryPromise
5837
- ).catch((err) => {
6196
+ this.#shutdownInFlight = this.#drain(config).catch((err) => {
6197
+ logger2().warn({ err }, "shutdown error");
6198
+ }).then(() => {
6199
+ this.#removeSignalHandlers();
6200
+ finishShutdownSignal(signal);
6201
+ });
6202
+ }
6203
+ /**
6204
+ * Gracefully drains all live registries.
6205
+ *
6206
+ * Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
6207
+ * every live `CoreRegistry` (both `start()` and `handler()` modes) and
6208
+ * waits for the serve promise to resolve, all bounded by the shutdown
6209
+ * grace period. Unlike a signal-driven shutdown, this does not re-raise a
6210
+ * signal or exit the process. The caller owns process lifetime.
6211
+ *
6212
+ * Idempotent: concurrent or repeated calls share a single drain. Safe to
6213
+ * call even if nothing has been started.
6214
+ *
6215
+ * @example
6216
+ * ```ts
6217
+ * const registry = setup({ use: { counter } });
6218
+ * registry.start();
6219
+ * // ...later, on your own shutdown trigger:
6220
+ * await registry.shutdown();
6221
+ * ```
6222
+ */
6223
+ async shutdown() {
6224
+ if (this.#shutdownInFlight !== null) return this.#shutdownInFlight;
6225
+ const config = this.parseConfig();
6226
+ this.#removeSignalHandlers();
6227
+ this.#shutdownInFlight = this.#drain(config).catch((err) => {
5838
6228
  logger2().warn({ err }, "shutdown error");
5839
6229
  });
6230
+ return this.#shutdownInFlight;
5840
6231
  }
5841
- async #runShutdown(signal, config, configuredRegistryPromise) {
6232
+ async #drain(config) {
5842
6233
  var _a;
5843
- const gracePeriodMs = await _asyncNullishCoalesce(await _asyncNullishCoalesce(((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs), async () => ( await this.#actorStopThresholdMs(configuredRegistryPromise))), async () => ( 30 * 60 * 1e3));
6234
+ const modeAPromise = this.#runtimeServeConfiguredPromise;
6235
+ const modeBPromise = this.#runtimeServerlessPromise;
6236
+ const gracePeriodMs = await _asyncNullishCoalesce(await _asyncNullishCoalesce(((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs), async () => ( await this.#actorStopThresholdMs(_nullishCoalesce(modeAPromise, () => ( modeBPromise))))), async () => ( 30 * 60 * 1e3));
5844
6237
  const drain = async () => {
5845
- const registries = [
5846
- (async () => {
5847
- try {
5848
- const { runtime, registry } = await configuredRegistryPromise;
5849
- await runtime.shutdownRegistry(registry);
5850
- } catch (err) {
5851
- logger2().warn(
5852
- { err },
5853
- "runtime registry shutdown errored (mode A)"
5854
- );
5855
- }
5856
- })()
5857
- ];
5858
- const runtimeServerlessPromise = this.#runtimeServerlessPromise;
5859
- if (runtimeServerlessPromise !== void 0) {
6238
+ const registries = [];
6239
+ if (modeAPromise !== void 0) {
5860
6240
  registries.push(
5861
6241
  (async () => {
5862
6242
  try {
5863
- const { runtime, registry } = await runtimeServerlessPromise;
6243
+ const { runtime, registry } = await modeAPromise;
5864
6244
  await runtime.shutdownRegistry(registry);
5865
6245
  } catch (err) {
5866
6246
  logger2().warn(
5867
6247
  { err },
6248
+ "runtime registry shutdown errored (mode A)"
6249
+ );
6250
+ }
6251
+ })()
6252
+ );
6253
+ }
6254
+ if (modeBPromise !== void 0) {
6255
+ registries.push(
6256
+ (async () => {
6257
+ try {
6258
+ const { runtime, registry } = await modeBPromise;
6259
+ await runtime.shutdownRegistry(registry);
6260
+ } catch (err) {
6261
+ logger2().warn(
6262
+ { error: err },
5868
6263
  "runtime registry shutdown errored (mode B)"
5869
6264
  );
5870
6265
  }
@@ -5886,11 +6281,10 @@ var Registry = class {
5886
6281
  }
5887
6282
  )
5888
6283
  ]);
5889
- this.#removeSignalHandlers();
5890
- finishShutdownSignal(signal);
5891
6284
  }
5892
6285
  async #actorStopThresholdMs(configuredRegistryPromise) {
5893
6286
  var _a;
6287
+ if (configuredRegistryPromise === void 0) return void 0;
5894
6288
  try {
5895
6289
  const { runtime, registry } = await configuredRegistryPromise;
5896
6290
  const thresholdMs = await ((_a = runtime.registryActorStopThresholdMs) == null ? void 0 : _a.call(runtime, registry));
@@ -5938,13 +6332,13 @@ var Registry = class {
5938
6332
  };
5939
6333
  console.log();
5940
6334
  console.log(
5941
- ` RivetKit ${_chunkY5NSCZA2cjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
6335
+ ` RivetKit ${_chunkDXXJPH55cjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
5942
6336
  );
5943
6337
  if (config.namespace !== "default") {
5944
6338
  logLine("Namespace", config.namespace);
5945
6339
  }
5946
6340
  if (config.endpoint) {
5947
- const endpointType = config.endpoint === ENGINE_ENDPOINT ? "local native" : "remote";
6341
+ const endpointType = config.startEngine || isLocalEngineEndpoint(config.endpoint) ? "local native" : "remote";
5948
6342
  logLine("Endpoint", `${config.endpoint} (${endpointType})`);
5949
6343
  }
5950
6344
  if (kind === "serverless" && config.publicEndpoint) {
@@ -6006,5 +6400,5 @@ function setup(input) {
6006
6400
 
6007
6401
 
6008
6402
 
6009
- exports.ALLOWED_PUBLIC_HEADERS = _chunkGVTOE34Scjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkQAZLM4WTcjs.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 = _chunkQAZLM4WTcjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkQAZLM4WTcjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkGVTOE34Scjs.createClientWithDriver; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkY5NSCZA2cjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkY5NSCZA2cjs.toUint8Array;
6403
+ exports.ALLOWED_PUBLIC_HEADERS = _chunk7QKCIVAYcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkKORQB2IRcjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkKORQB2IRcjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkKORQB2IRcjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunk7QKCIVAYcjs.createClientWithDriver; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkDXXJPH55cjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkDXXJPH55cjs.toUint8Array;
6010
6404
  //# sourceMappingURL=mod.cjs.map