rivetkit 2.3.30 → 3.0.0-preview.2

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 (135) hide show
  1. package/dist/browser/client.d.ts +58 -9
  2. package/dist/browser/client.js +193 -20
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -2
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-P2PHHJMH.cjs → chunk-25MUHNWE.cjs} +326 -166
  7. package/dist/tsup/chunk-25MUHNWE.cjs.map +1 -0
  8. package/dist/tsup/{chunk-5SN6GAYX.cjs → chunk-3SPYZMME.cjs} +3 -3
  9. package/dist/tsup/{chunk-5SN6GAYX.cjs.map → chunk-3SPYZMME.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-4SNS3PYZ.js → chunk-3URL73AV.js} +2 -2
  11. package/dist/tsup/{chunk-EKAQ7HG2.js → chunk-442XBCAF.js} +3 -3
  12. package/dist/tsup/{chunk-CORYIKDC.js → chunk-5F7FWAJI.js} +10 -11
  13. package/dist/tsup/chunk-5F7FWAJI.js.map +1 -0
  14. package/dist/tsup/{chunk-I472KTIC.js → chunk-6IGGYL2C.js} +185 -25
  15. package/dist/tsup/chunk-6IGGYL2C.js.map +1 -0
  16. package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
  17. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  18. package/dist/tsup/{chunk-OUB7SGSA.js → chunk-ANNVZW6B.js} +2 -2
  19. package/dist/tsup/{chunk-ZIIQQHC3.cjs → chunk-BCG7PTBS.cjs} +4 -4
  20. package/dist/tsup/{chunk-ZIIQQHC3.cjs.map → chunk-BCG7PTBS.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-OJFVABRH.cjs → chunk-CJ3MX5MI.cjs} +7 -7
  22. package/dist/tsup/{chunk-OJFVABRH.cjs.map → chunk-CJ3MX5MI.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-GEUBEODU.cjs → chunk-EPPV7WB2.cjs} +3 -3
  24. package/dist/tsup/{chunk-GEUBEODU.cjs.map → chunk-EPPV7WB2.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-MXV26ZBB.js → chunk-OLZ4KAFL.js} +4 -4
  26. package/dist/tsup/{chunk-5UUOECX2.cjs → chunk-QDRZMCX5.cjs} +10 -10
  27. package/dist/tsup/{chunk-5UUOECX2.cjs.map → chunk-QDRZMCX5.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
  29. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  30. package/dist/tsup/{chunk-H3SGQEHZ.js → chunk-WGKL7HMH.js} +2 -2
  31. package/dist/tsup/{chunk-6LOYTFPZ.js → chunk-WGQHG26S.js} +2 -2
  32. package/dist/tsup/{chunk-2BIRGEIU.cjs → chunk-XSOHGU4G.cjs} +10 -11
  33. package/dist/tsup/chunk-XSOHGU4G.cjs.map +1 -0
  34. package/dist/tsup/{chunk-ABPZG7QV.cjs → chunk-YZVVID47.cjs} +3 -3
  35. package/dist/tsup/{chunk-ABPZG7QV.cjs.map → chunk-YZVVID47.cjs.map} +1 -1
  36. package/dist/tsup/client/mod.cjs +6 -6
  37. package/dist/tsup/client/mod.d.cts +15 -3
  38. package/dist/tsup/client/mod.d.ts +15 -3
  39. package/dist/tsup/client/mod.js +5 -5
  40. package/dist/tsup/common/log.cjs +2 -2
  41. package/dist/tsup/common/log.js +1 -1
  42. package/dist/tsup/common/websocket.cjs +3 -3
  43. package/dist/tsup/common/websocket.js +2 -2
  44. package/dist/tsup/{config-osdJqQwX.d.cts → config-8NgsxIcT.d.cts} +43 -12
  45. package/dist/tsup/{config-ey2I2zz5.d.ts → config-B2wlj9wx.d.cts} +7 -1
  46. package/dist/tsup/{config-ey2I2zz5.d.cts → config-B2wlj9wx.d.ts} +7 -1
  47. package/dist/tsup/{config-Cv6pjCt-.d.ts → config-DJ3KW-fe.d.ts} +43 -12
  48. package/dist/tsup/{context-CoVbKBuk.d.ts → context-BL8kUGjq.d.ts} +2 -2
  49. package/dist/tsup/{context-DpjrM7n7.d.cts → context-_RoE_YHL.d.cts} +2 -2
  50. package/dist/tsup/db/drizzle.cjs +2 -2
  51. package/dist/tsup/db/drizzle.d.cts +1 -1
  52. package/dist/tsup/db/drizzle.d.ts +1 -1
  53. package/dist/tsup/db/drizzle.js +1 -1
  54. package/dist/tsup/db/mod.cjs +3 -3
  55. package/dist/tsup/db/mod.d.cts +2 -2
  56. package/dist/tsup/db/mod.d.ts +2 -2
  57. package/dist/tsup/db/mod.js +2 -2
  58. package/dist/tsup/dynamic/mod.d.cts +2 -2
  59. package/dist/tsup/dynamic/mod.d.ts +2 -2
  60. package/dist/tsup/inspector/mod.cjs +5 -5
  61. package/dist/tsup/inspector/mod.js +4 -4
  62. package/dist/tsup/inspector/workflow.cjs +4 -4
  63. package/dist/tsup/inspector/workflow.js +3 -3
  64. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  65. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  66. package/dist/tsup/mod.cjs +254 -166
  67. package/dist/tsup/mod.cjs.map +1 -1
  68. package/dist/tsup/mod.d.cts +4 -4
  69. package/dist/tsup/mod.d.ts +4 -4
  70. package/dist/tsup/mod.js +168 -80
  71. package/dist/tsup/mod.js.map +1 -1
  72. package/dist/tsup/test/mod.cjs +7 -7
  73. package/dist/tsup/test/mod.d.cts +2 -2
  74. package/dist/tsup/test/mod.d.ts +2 -2
  75. package/dist/tsup/test/mod.js +5 -5
  76. package/dist/tsup/unstable/migrations.d.cts +1 -1
  77. package/dist/tsup/unstable/migrations.d.ts +1 -1
  78. package/dist/tsup/utils.cjs +2 -2
  79. package/dist/tsup/utils.js +1 -1
  80. package/dist/tsup/workflow/mod.cjs +17 -17
  81. package/dist/tsup/workflow/mod.d.cts +4 -4
  82. package/dist/tsup/workflow/mod.d.ts +4 -4
  83. package/dist/tsup/workflow/mod.js +5 -5
  84. package/package.json +9 -10
  85. package/src/actor/keys.ts +86 -0
  86. package/src/client/actor-conn.ts +92 -6
  87. package/src/client/actor-handle.ts +21 -3
  88. package/src/client/client.ts +6 -0
  89. package/src/client/config.ts +12 -1
  90. package/src/client/lifecycle-errors.ts +16 -1
  91. package/src/client/retry-budget.ts +78 -0
  92. package/src/client/utils.ts +13 -2
  93. package/src/common/database/config.ts +7 -1
  94. package/src/common/database/native-database.ts +17 -6
  95. package/src/common/router.ts +1 -1
  96. package/src/engine-api/actors.ts +3 -3
  97. package/src/engine-client/actor-websocket-client.ts +4 -2
  98. package/src/engine-client/api-endpoints.ts +44 -14
  99. package/src/engine-client/mod.ts +2 -2
  100. package/src/registry/config/envoy.ts +1 -1
  101. package/src/registry/config/index.ts +28 -31
  102. package/src/registry/index.ts +51 -19
  103. package/src/registry/napi-runtime.ts +3 -2
  104. package/src/registry/native.ts +126 -34
  105. package/src/registry/runtime.ts +27 -10
  106. package/src/registry/wasm-runtime.ts +6 -3
  107. package/src/utils/env-vars.ts +15 -10
  108. package/dist/tsup/chunk-2BIRGEIU.cjs.map +0 -1
  109. package/dist/tsup/chunk-CORYIKDC.js.map +0 -1
  110. package/dist/tsup/chunk-I472KTIC.js.map +0 -1
  111. package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
  112. package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
  113. package/dist/tsup/chunk-P2PHHJMH.cjs.map +0 -1
  114. package/src/actor/config.test.ts +0 -78
  115. package/src/actor/keys.test.ts +0 -275
  116. package/src/actor/utils.test.ts +0 -48
  117. package/src/client/test.ts +0 -44
  118. package/src/client/token-provider.test.ts +0 -86
  119. package/src/common/database/mod.test.ts +0 -364
  120. package/src/common/database/native-database.test.ts +0 -220
  121. package/src/common/inline-websocket-adapter.test.ts +0 -51
  122. package/src/db/drizzle.test.ts +0 -164
  123. package/src/registry/config/index.test.ts +0 -25
  124. package/src/registry/run-handler-coordinator.test.ts +0 -252
  125. package/src/registry/runtime.test.ts +0 -124
  126. package/src/unstable/migrations.test.ts +0 -170
  127. package/src/utils/endpoint-parser.test.ts +0 -206
  128. package/src/utils.test.ts +0 -34
  129. package/src/workflow/driver.test.ts +0 -62
  130. /package/dist/tsup/{chunk-4SNS3PYZ.js.map → chunk-3URL73AV.js.map} +0 -0
  131. /package/dist/tsup/{chunk-EKAQ7HG2.js.map → chunk-442XBCAF.js.map} +0 -0
  132. /package/dist/tsup/{chunk-OUB7SGSA.js.map → chunk-ANNVZW6B.js.map} +0 -0
  133. /package/dist/tsup/{chunk-MXV26ZBB.js.map → chunk-OLZ4KAFL.js.map} +0 -0
  134. /package/dist/tsup/{chunk-H3SGQEHZ.js.map → chunk-WGKL7HMH.js.map} +0 -0
  135. /package/dist/tsup/{chunk-6LOYTFPZ.js.map → chunk-WGQHG26S.js.map} +0 -0
@@ -1,12 +1,12 @@
1
- import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-osdJqQwX.cjs';
2
- export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as ActionInputSchemas, m as ActionSampleRates, n as ActionTraceSamplers, o as Actions, p as ActorConfig, q as ActorConfigInput, r as ActorConfigSchema, s as ActorContext, t as ActorContextOf, u as ActorCron, v as ActorCronEveryOptions, w as ActorCronSetOptions, x as ActorDefinition, y as ActorInspectorConfig, z as ActorInspectorConfigSchema, F as ActorKey, G as ActorKv, H as ActorLogger, I as ActorOptions, J as ActorOptionsInput, K as ActorOptionsSchema, L as ActorQuery, N as ActorQueue, O as ActorRun, P as ActorSchedule, T as ActorTracingOptions, U as ActorTypes, V as ActorsSchema, X as AnyActorInstance, Y as AnyClient, Z as AnyConn, _ as AnyStaticActorDefinition, $ as AnyStaticActorInstance, a0 as AuthIntent, a1 as BUILTIN_INSPECTOR_TAB_IDS, a2 as BaseActorInstance, a3 as BuiltinInspectorTabIdSchema, a4 as CONN_DRIVER_SYMBOL, a5 as CONN_STATE_MANAGER_SYMBOL, a6 as Client, a7 as Conn, a8 as CronFire, a9 as CronJobInfo, aa as CustomInspectorTabEntrySchema, ab as DEFAULT_SLEEP_GRACE_PERIOD, ac as DefineRunHandlerOptions, ad as DocActorConfigSchema, ae as DocActorOptionsSchema, af as DocConfigurePoolSchema, ag as DocEnvoyConfigSchema, ah as DocRegistryConfigSchema, ai as DocServerlessConfigSchema, aj as DocSqliteConfigSchema, ak as FetchHandler, al as GlobalActorOptions, am as GlobalActorOptionsInput, an as GlobalActorOptionsSchema, ao as HideInspectorTabEntrySchema, ap as InferEventArgs, aq as InferSchemaMap, ar as InspectorTabEntrySchema, as as InspectorUnsubscribe, at as InstanceActorOptions, au as InstanceActorOptionsInput, av as InstanceActorOptionsSchema, aw as QueueEnqueueAndWaitOptions, ax as QueueFilterName, ay as QueueIterOptions, az as QueueMessageOf, aA as QueueName, aB as QueueNextBatchOptions, aC as QueueNextOptions, aD as QueueResultMessageForName, aE as QueueTryNextBatchOptions, aF as QueueTryNextOptions, aG as QueueWaitOptions, aH as RAW_STATE_SYMBOL, aI as Registry, aJ as RegistryActors, aK as RegistryApplication, aL as RegistryConfig, aM as RegistryConfigInput, aN as RegistryConfigSchema, aO as RegistryDeps, aP as RegistryListenOptions, aQ as RegistryRoutes, aR as RunConfig, aS as RunConfigSchema, aT as RunControl, aU as RunInspectorConfig, aV as RunInspectorFactoryContext, aW as RunInspectorFactoryResult, aX as RunInspectorKind, aY as RunWithInactiveOptions, aZ as RuntimeKind, a_ as RuntimeKindSchema, a$ as ScheduledEventInfo, b0 as ScheduledFireInfo, b1 as ServerlessHandler, b2 as SqliteBackend, b3 as SqliteBackendSchema, b4 as SqliteConfig, b5 as SqliteConfigSchema, b6 as TestConfig, b7 as TestConfigSchema, b8 as Type, b9 as WasmRuntimeBindings, ba as WasmRuntimeConfig, bb as WasmRuntimeConfigSchema, bc as WasmRuntimeInitInput, bd as WorkflowInspectorConfig, be as WorkflowOutcome, bf as WorkflowSpan, bg as WorkflowStepOutcome, bh as WorkflowStepSpan, bi as actor, bj as buildActorNames, bk as createClientWithDriver, bl as defineRunHandler, bm as disposeRunInspector, bn as event, bo as getRunFunction, bp as getRunInspectorConfig, bq as getRunMetadata, br as isStaticActorDefinition, bs as isStaticActorInstance, bt as lookupInRegistry, bu as queue, bv as setup, bw as test } from './config-osdJqQwX.cjs';
1
+ import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-8NgsxIcT.cjs';
2
+ export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as ActionInputSchemas, m as ActionSampleRates, n as ActionTraceSamplers, o as Actions, p as ActorConfig, q as ActorConfigInput, r as ActorConfigSchema, s as ActorContext, t as ActorContextOf, u as ActorCron, v as ActorCronEveryOptions, w as ActorCronSetOptions, x as ActorDefinition, y as ActorInspectorConfig, z as ActorInspectorConfigSchema, F as ActorKey, G as ActorKv, H as ActorLogger, I as ActorOptions, J as ActorOptionsInput, K as ActorOptionsSchema, L as ActorQuery, N as ActorQueue, O as ActorRun, P as ActorSchedule, T as ActorTracingOptions, U as ActorTypes, V as ActorsSchema, X as AnyActorInstance, Y as AnyClient, Z as AnyConn, _ as AnyStaticActorDefinition, $ as AnyStaticActorInstance, a0 as AuthIntent, a1 as BUILTIN_INSPECTOR_TAB_IDS, a2 as BaseActorInstance, a3 as BuiltinInspectorTabIdSchema, a4 as CONN_DRIVER_SYMBOL, a5 as CONN_STATE_MANAGER_SYMBOL, a6 as Client, a7 as Conn, a8 as CronFire, a9 as CronJobInfo, aa as CustomInspectorTabEntrySchema, ab as DEFAULT_SLEEP_GRACE_PERIOD, ac as DefineRunHandlerOptions, ad as DocActorConfigSchema, ae as DocActorOptionsSchema, af as DocConfigurePoolSchema, ag as DocEnvoyConfigSchema, ah as DocRegistryConfigSchema, ai as DocServerlessConfigSchema, aj as DocSqliteConfigSchema, ak as FetchHandler, al as GlobalActorOptions, am as GlobalActorOptionsInput, an as GlobalActorOptionsSchema, ao as HideInspectorTabEntrySchema, ap as InferEventArgs, aq as InferSchemaMap, ar as InspectorTabEntrySchema, as as InspectorUnsubscribe, at as InstanceActorOptions, au as InstanceActorOptionsInput, av as InstanceActorOptionsSchema, aw as QueueEnqueueAndWaitOptions, ax as QueueFilterName, ay as QueueIterOptions, az as QueueMessageOf, aA as QueueName, aB as QueueNextBatchOptions, aC as QueueNextOptions, aD as QueueResultMessageForName, aE as QueueTryNextBatchOptions, aF as QueueTryNextOptions, aG as QueueWaitOptions, aH as RAW_STATE_SYMBOL, aI as Registry, aJ as RegistryActors, aK as RegistryApplication, aL as RegistryConfig, aM as RegistryConfigInput, aN as RegistryConfigSchema, aO as RegistryDeps, aP as RegistryListenOptions, aQ as RegistryRoutes, aR as RunConfig, aS as RunConfigSchema, aT as RunControl, aU as RunInspectorConfig, aV as RunInspectorFactoryContext, aW as RunInspectorFactoryResult, aX as RunInspectorKind, aY as RunWithInactiveOptions, aZ as RuntimeKind, a_ as RuntimeKindSchema, a$ as ScheduledEventInfo, b0 as ScheduledFireInfo, b1 as ServerlessHandler, b2 as SqliteBackend, b3 as SqliteBackendSchema, b4 as SqliteConfig, b5 as SqliteConfigSchema, b6 as TestConfig, b7 as TestConfigSchema, b8 as Type, b9 as WasmRuntimeBindings, ba as WasmRuntimeConfig, bb as WasmRuntimeConfigSchema, bc as WasmRuntimeInitInput, bd as WorkflowInspectorConfig, be as WorkflowOutcome, bf as WorkflowSpan, bg as WorkflowStepOutcome, bh as WorkflowStepSpan, bi as actor, bj as buildActorNames, bk as createClientWithDriver, bl as defineRunHandler, bm as disposeRunInspector, bn as event, bo as getRunFunction, bp as getRunInspectorConfig, bq as getRunMetadata, br as isStaticActorDefinition, bs as isStaticActorInstance, bt as lookupInRegistry, bu as queue, bv as setup, bw as test } from './config-8NgsxIcT.cjs';
3
3
  export { E as Encoding, t as toUint8Array } from './utils-C6b0aYUM.cjs';
4
4
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
5
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
6
- import { A as AnyDatabaseProvider } from './config-ey2I2zz5.cjs';
6
+ import { A as AnyDatabaseProvider } from './config-B2wlj9wx.cjs';
7
7
  export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-3rsE0JvI.cjs';
8
8
  import { WSContext } from 'hono/ws';
9
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-DpjrM7n7.cjs';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-_RoE_YHL.cjs';
10
10
  import 'zod/v4';
11
11
  import '@rivetkit/rivetkit-wasm';
12
12
  import 'zod';
@@ -1,12 +1,12 @@
1
- import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-Cv6pjCt-.js';
2
- export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as ActionInputSchemas, m as ActionSampleRates, n as ActionTraceSamplers, o as Actions, p as ActorConfig, q as ActorConfigInput, r as ActorConfigSchema, s as ActorContext, t as ActorContextOf, u as ActorCron, v as ActorCronEveryOptions, w as ActorCronSetOptions, x as ActorDefinition, y as ActorInspectorConfig, z as ActorInspectorConfigSchema, F as ActorKey, G as ActorKv, H as ActorLogger, I as ActorOptions, J as ActorOptionsInput, K as ActorOptionsSchema, L as ActorQuery, N as ActorQueue, O as ActorRun, P as ActorSchedule, T as ActorTracingOptions, U as ActorTypes, V as ActorsSchema, X as AnyActorInstance, Y as AnyClient, Z as AnyConn, _ as AnyStaticActorDefinition, $ as AnyStaticActorInstance, a0 as AuthIntent, a1 as BUILTIN_INSPECTOR_TAB_IDS, a2 as BaseActorInstance, a3 as BuiltinInspectorTabIdSchema, a4 as CONN_DRIVER_SYMBOL, a5 as CONN_STATE_MANAGER_SYMBOL, a6 as Client, a7 as Conn, a8 as CronFire, a9 as CronJobInfo, aa as CustomInspectorTabEntrySchema, ab as DEFAULT_SLEEP_GRACE_PERIOD, ac as DefineRunHandlerOptions, ad as DocActorConfigSchema, ae as DocActorOptionsSchema, af as DocConfigurePoolSchema, ag as DocEnvoyConfigSchema, ah as DocRegistryConfigSchema, ai as DocServerlessConfigSchema, aj as DocSqliteConfigSchema, ak as FetchHandler, al as GlobalActorOptions, am as GlobalActorOptionsInput, an as GlobalActorOptionsSchema, ao as HideInspectorTabEntrySchema, ap as InferEventArgs, aq as InferSchemaMap, ar as InspectorTabEntrySchema, as as InspectorUnsubscribe, at as InstanceActorOptions, au as InstanceActorOptionsInput, av as InstanceActorOptionsSchema, aw as QueueEnqueueAndWaitOptions, ax as QueueFilterName, ay as QueueIterOptions, az as QueueMessageOf, aA as QueueName, aB as QueueNextBatchOptions, aC as QueueNextOptions, aD as QueueResultMessageForName, aE as QueueTryNextBatchOptions, aF as QueueTryNextOptions, aG as QueueWaitOptions, aH as RAW_STATE_SYMBOL, aI as Registry, aJ as RegistryActors, aK as RegistryApplication, aL as RegistryConfig, aM as RegistryConfigInput, aN as RegistryConfigSchema, aO as RegistryDeps, aP as RegistryListenOptions, aQ as RegistryRoutes, aR as RunConfig, aS as RunConfigSchema, aT as RunControl, aU as RunInspectorConfig, aV as RunInspectorFactoryContext, aW as RunInspectorFactoryResult, aX as RunInspectorKind, aY as RunWithInactiveOptions, aZ as RuntimeKind, a_ as RuntimeKindSchema, a$ as ScheduledEventInfo, b0 as ScheduledFireInfo, b1 as ServerlessHandler, b2 as SqliteBackend, b3 as SqliteBackendSchema, b4 as SqliteConfig, b5 as SqliteConfigSchema, b6 as TestConfig, b7 as TestConfigSchema, b8 as Type, b9 as WasmRuntimeBindings, ba as WasmRuntimeConfig, bb as WasmRuntimeConfigSchema, bc as WasmRuntimeInitInput, bd as WorkflowInspectorConfig, be as WorkflowOutcome, bf as WorkflowSpan, bg as WorkflowStepOutcome, bh as WorkflowStepSpan, bi as actor, bj as buildActorNames, bk as createClientWithDriver, bl as defineRunHandler, bm as disposeRunInspector, bn as event, bo as getRunFunction, bp as getRunInspectorConfig, bq as getRunMetadata, br as isStaticActorDefinition, bs as isStaticActorInstance, bt as lookupInRegistry, bu as queue, bv as setup, bw as test } from './config-Cv6pjCt-.js';
1
+ import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, a as ActionContext, b as BeforeActionResponseContext, c as BeforeConnectContext, C as ConnectContext, d as CreateConnStateContext, e as CreateContext, f as CreateVarsContext, D as DestroyContext, g as DisconnectContext, M as MigrateContext, R as RequestContext, h as RunContext, S as SleepContext, i as StateChangeContext, W as WakeContext, j as WebSocketContext } from './config-DJ3KW-fe.js';
2
+ export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as ActionInputSchemas, m as ActionSampleRates, n as ActionTraceSamplers, o as Actions, p as ActorConfig, q as ActorConfigInput, r as ActorConfigSchema, s as ActorContext, t as ActorContextOf, u as ActorCron, v as ActorCronEveryOptions, w as ActorCronSetOptions, x as ActorDefinition, y as ActorInspectorConfig, z as ActorInspectorConfigSchema, F as ActorKey, G as ActorKv, H as ActorLogger, I as ActorOptions, J as ActorOptionsInput, K as ActorOptionsSchema, L as ActorQuery, N as ActorQueue, O as ActorRun, P as ActorSchedule, T as ActorTracingOptions, U as ActorTypes, V as ActorsSchema, X as AnyActorInstance, Y as AnyClient, Z as AnyConn, _ as AnyStaticActorDefinition, $ as AnyStaticActorInstance, a0 as AuthIntent, a1 as BUILTIN_INSPECTOR_TAB_IDS, a2 as BaseActorInstance, a3 as BuiltinInspectorTabIdSchema, a4 as CONN_DRIVER_SYMBOL, a5 as CONN_STATE_MANAGER_SYMBOL, a6 as Client, a7 as Conn, a8 as CronFire, a9 as CronJobInfo, aa as CustomInspectorTabEntrySchema, ab as DEFAULT_SLEEP_GRACE_PERIOD, ac as DefineRunHandlerOptions, ad as DocActorConfigSchema, ae as DocActorOptionsSchema, af as DocConfigurePoolSchema, ag as DocEnvoyConfigSchema, ah as DocRegistryConfigSchema, ai as DocServerlessConfigSchema, aj as DocSqliteConfigSchema, ak as FetchHandler, al as GlobalActorOptions, am as GlobalActorOptionsInput, an as GlobalActorOptionsSchema, ao as HideInspectorTabEntrySchema, ap as InferEventArgs, aq as InferSchemaMap, ar as InspectorTabEntrySchema, as as InspectorUnsubscribe, at as InstanceActorOptions, au as InstanceActorOptionsInput, av as InstanceActorOptionsSchema, aw as QueueEnqueueAndWaitOptions, ax as QueueFilterName, ay as QueueIterOptions, az as QueueMessageOf, aA as QueueName, aB as QueueNextBatchOptions, aC as QueueNextOptions, aD as QueueResultMessageForName, aE as QueueTryNextBatchOptions, aF as QueueTryNextOptions, aG as QueueWaitOptions, aH as RAW_STATE_SYMBOL, aI as Registry, aJ as RegistryActors, aK as RegistryApplication, aL as RegistryConfig, aM as RegistryConfigInput, aN as RegistryConfigSchema, aO as RegistryDeps, aP as RegistryListenOptions, aQ as RegistryRoutes, aR as RunConfig, aS as RunConfigSchema, aT as RunControl, aU as RunInspectorConfig, aV as RunInspectorFactoryContext, aW as RunInspectorFactoryResult, aX as RunInspectorKind, aY as RunWithInactiveOptions, aZ as RuntimeKind, a_ as RuntimeKindSchema, a$ as ScheduledEventInfo, b0 as ScheduledFireInfo, b1 as ServerlessHandler, b2 as SqliteBackend, b3 as SqliteBackendSchema, b4 as SqliteConfig, b5 as SqliteConfigSchema, b6 as TestConfig, b7 as TestConfigSchema, b8 as Type, b9 as WasmRuntimeBindings, ba as WasmRuntimeConfig, bb as WasmRuntimeConfigSchema, bc as WasmRuntimeInitInput, bd as WorkflowInspectorConfig, be as WorkflowOutcome, bf as WorkflowSpan, bg as WorkflowStepOutcome, bh as WorkflowStepSpan, bi as actor, bj as buildActorNames, bk as createClientWithDriver, bl as defineRunHandler, bm as disposeRunInspector, bn as event, bo as getRunFunction, bp as getRunInspectorConfig, bq as getRunMetadata, br as isStaticActorDefinition, bs as isStaticActorInstance, bt as lookupInRegistry, bu as queue, bv as setup, bw as test } from './config-DJ3KW-fe.js';
3
3
  export { E as Encoding, t as toUint8Array } from './utils-C1O-SklO.js';
4
4
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
5
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
6
- import { A as AnyDatabaseProvider } from './config-ey2I2zz5.js';
6
+ import { A as AnyDatabaseProvider } from './config-B2wlj9wx.js';
7
7
  export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-3rsE0JvI.js';
8
8
  import { WSContext } from 'hono/ws';
9
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-CoVbKBuk.js';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-BL8kUGjq.js';
10
10
  import 'zod/v4';
11
11
  import '@rivetkit/rivetkit-wasm';
12
12
  import 'zod';
package/dist/tsup/mod.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  decodeWorkflowHistoryTransport
3
- } from "./chunk-4SNS3PYZ.js";
3
+ } from "./chunk-3URL73AV.js";
4
4
  import {
5
5
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
6
6
  ActorConfigSchema,
@@ -35,18 +35,18 @@ import {
35
35
  runWithActorInvocationSpan,
36
36
  tryParseEndpoint,
37
37
  updateRunnerConfig
38
- } from "./chunk-I472KTIC.js";
38
+ } from "./chunk-6IGGYL2C.js";
39
39
  import {
40
40
  makePrefixedKey,
41
41
  removePrefixFromKey
42
- } from "./chunk-JI6GZ2C2.js";
42
+ } from "./chunk-A2CF6PFH.js";
43
43
  import {
44
44
  bindNativeStateTransactionContext,
45
45
  db,
46
46
  registerNativeStateTransactionOpener
47
- } from "./chunk-OUB7SGSA.js";
47
+ } from "./chunk-ANNVZW6B.js";
48
48
  import "./chunk-JTHHCZCZ.js";
49
- import "./chunk-H3SGQEHZ.js";
49
+ import "./chunk-WGKL7HMH.js";
50
50
  import {
51
51
  LogLevelSchema,
52
52
  VERSION,
@@ -80,11 +80,12 @@ import {
80
80
  parsePortEnv,
81
81
  stringifyError,
82
82
  toUint8Array
83
- } from "./chunk-CORYIKDC.js";
83
+ } from "./chunk-5F7FWAJI.js";
84
84
  import {
85
85
  INTERNAL_ERROR_CODE,
86
86
  RivetError,
87
87
  UserError,
88
+ actorStopping,
88
89
  decodeBridgeRivetError,
89
90
  encodeBridgeRivetError,
90
91
  encodeErrorForBridge,
@@ -500,7 +501,7 @@ var EnvoyConfigSchema = z.object({
500
501
  version: z.number().default(() => getRivetEnvoyVersion() ?? 1),
501
502
  // Deprecated.
502
503
  totalSlots: z.number().default(() => getRivetTotalSlots() ?? 1e5),
503
- envoyKey: z.string().optional()
504
+ nodeKey: z.string().optional()
504
505
  });
505
506
 
506
507
  // src/registry/config/serverless.ts
@@ -644,7 +645,7 @@ var RegistryConfigSchema = z3.object({
644
645
  // // (specifically Node.js) can sometimes only be specified after the router is
645
646
  // // created or must be imported async using `await import(...)`
646
647
  // getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
647
- // MARK: Runner Configuration
648
+ // MARK: Node Configuration
648
649
  /**
649
650
  * Endpoint to connect to for Rivet Engine.
650
651
  *
@@ -713,30 +714,30 @@ var RegistryConfigSchema = z3.object({
713
714
  engineVersion: z3.string().optional().default(() => getRivetRunEngineVersion() ?? VERSION),
714
715
  /**
715
716
  * Starts the first-party Services actor host when RivetKit manages
716
- * a local engine. Defaults to the local-engine decision. Set
717
- * RIVET_RUN_SERVICES=0 or 1 to override it.
717
+ * a local engine. Disabled by default. Set RIVET_RUN_SERVICES=1
718
+ * or startServices: true to enable it.
718
719
  */
719
720
  startServices: z3.boolean().optional(),
720
721
  /**
721
722
  * @experimental
722
723
  *
723
- * Automatically configure serverless envoys in the engine.
724
+ * Automatically configure serverless nodes in the engine.
724
725
  */
725
726
  configurePool: ConfigurePoolSchema.optional(),
726
727
  // MARK: Runtime-specific
727
728
  serverless: ServerlessConfigSchema.optional().default(
728
729
  () => ServerlessConfigSchema.parse({})
729
730
  ),
730
- envoy: EnvoyConfigSchema.optional().default(
731
+ node: EnvoyConfigSchema.optional().default(
731
732
  () => EnvoyConfigSchema.parse({})
732
733
  ),
733
734
  // MARK: Shutdown
734
735
  /**
735
736
  * Graceful shutdown configuration for SIGINT/SIGTERM.
736
737
  *
737
- * When a persistent envoy is running (Mode A, started via `registry.start()`),
738
+ * When a persistent node is running (Mode A, started via `registry.start()`),
738
739
  * rivetkit installs Node SIGINT/SIGTERM handlers that call into core's
739
- * `shutdown()` and wait up to `gracePeriodMs` for the envoy to drain
740
+ * `shutdown()` and wait up to `gracePeriodMs` for the node to drain
740
741
  * before re-raising the signal to let Node exit via its default path.
741
742
  *
742
743
  * Handlers are NOT installed when `handler(request)` is used alone
@@ -748,9 +749,11 @@ var RegistryConfigSchema = z3.object({
748
749
  /**
749
750
  * Wait this many milliseconds for the serve promise to resolve
750
751
  * after calling `CoreRegistry::shutdown()`. Defaults to the
751
- * engine-provided actor stop threshold once the envoy connects.
752
+ * engine-provided actor stop threshold once the node connects. A
753
+ * signal-driven shutdown of a managed local development engine waits
754
+ * one second by default so a file watcher can restart promptly.
752
755
  *
753
- * Must be long enough for rivetkit-core to drain the envoy.
756
+ * Set a longer period when a complete graceful node drain is required.
754
757
  */
755
758
  gracePeriodMs: z3.number().int().min(1e3).optional(),
756
759
  /**
@@ -786,10 +789,11 @@ var RegistryConfigSchema = z3.object({
786
789
  message: "cannot specify both startEngine and endpoint"
787
790
  });
788
791
  }
789
- if (config.configurePool && !parsedEndpoint && !config.startEngine) {
792
+ if (config.configurePool) {
790
793
  ctx.addIssue({
791
794
  code: "custom",
792
- message: "configurePool requires either endpoint or startEngine"
795
+ message: "serverless is disabled in this version",
796
+ path: ["configurePool"]
793
797
  });
794
798
  }
795
799
  const localEngineEndpoint = buildEngineEndpoint(
@@ -797,7 +801,7 @@ var RegistryConfigSchema = z3.object({
797
801
  config.enginePort
798
802
  );
799
803
  const endpoint = config.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ? localEngineEndpoint : void 0);
800
- const startServices = config.startServices ?? getRivetRunServices() ?? Boolean(endpoint && isLocalEngineEndpoint(endpoint));
804
+ const startServices = config.startServices ?? getRivetRunServices();
801
805
  const validateServerlessEndpoint = Boolean(
802
806
  config.startEngine || parsedEndpoint
803
807
  );
@@ -821,6 +825,7 @@ var RegistryConfigSchema = z3.object({
821
825
  ...config,
822
826
  sqlite,
823
827
  endpoint,
828
+ engineSpawn: !parsedEndpoint && Boolean(endpoint),
824
829
  startServices,
825
830
  namespace,
826
831
  token,
@@ -850,8 +855,8 @@ function buildActorNames(config) {
850
855
  );
851
856
  }
852
857
  var DocConfigurePoolSchema = z3.object({
853
- name: z3.string().optional().describe("Name of the runner pool."),
854
- url: z3.string().describe("URL of the serverless platform to configure runners."),
858
+ name: z3.string().optional().describe("Name of the node pool."),
859
+ url: z3.string().describe("URL of the serverless platform to configure nodes."),
855
860
  headers: z3.record(z3.string(), z3.string()).optional().describe(
856
861
  "Headers to include in requests to the serverless platform."
857
862
  ),
@@ -866,7 +871,7 @@ var DocConfigurePoolSchema = z3.object({
866
871
  "Interval in milliseconds between metadata polls from the engine. Defaults to 10000 milliseconds (10 seconds)."
867
872
  ),
868
873
  drainOnVersionUpgrade: z3.boolean().optional().describe(
869
- "Drain runners when a new version is deployed. Defaults to true."
874
+ "Drain nodes when a new version is deployed. Defaults to true."
870
875
  )
871
876
  }).optional();
872
877
  var DocServerlessConfigSchema = z3.object({
@@ -885,10 +890,10 @@ var DocServerlessConfigSchema = z3.object({
885
890
  }).describe("Configuration for serverless deployment mode.");
886
891
  var DocEnvoyConfigSchema = z3.object({
887
892
  totalSlots: z3.number().optional().describe("Total number of actor slots available. Default: 100000"),
888
- poolName: z3.string().optional().describe("Name of this envoy pool. Default: 'default'"),
889
- envoyKey: z3.string().optional().describe("Deprecated. Authentication key for the envoy."),
890
- version: z3.number().optional().describe("Version number of this envoy. Default: 1")
891
- }).describe("Configuration for envoy mode.");
893
+ poolName: z3.string().optional().describe("Name of this node pool. Default: 'default'"),
894
+ nodeKey: z3.string().optional().describe("Deprecated. Authentication key for the node."),
895
+ version: z3.number().optional().describe("Version number of this node. Default: 1")
896
+ }).describe("Configuration for node mode.");
892
897
  var DocSqliteConfigSchema = z3.object({
893
898
  backend: SqliteBackendSchema.optional().describe(
894
899
  "SQLite backend to use. Native defaults to local. Wasm defaults to remote and cannot use local."
@@ -936,13 +941,13 @@ var DocRegistryConfigSchema = z3.object({
936
941
  "Version of the local engine package to use. Defaults to the current RivetKit version."
937
942
  ),
938
943
  startServices: z3.boolean().optional().describe(
939
- "Starts Services when RivetKit manages a local Engine. Defaults to the local-Engine decision. Set RIVET_RUN_SERVICES=0 or 1 to override."
944
+ "Starts Services when RivetKit manages a local Engine. Disabled by default. Set RIVET_RUN_SERVICES=1 or startServices: true to enable."
940
945
  ),
941
946
  configurePool: DocConfigurePoolSchema.describe(
942
- "Automatically configure serverless runners in the engine."
947
+ "Automatically configure serverless nodes in the engine."
943
948
  ),
944
949
  serverless: DocServerlessConfigSchema.optional(),
945
- envoy: DocEnvoyConfigSchema.optional()
950
+ node: DocEnvoyConfigSchema.optional()
946
951
  }).describe("RivetKit registry configuration.");
947
952
 
948
953
  // src/registry/native.ts
@@ -1105,12 +1110,12 @@ var NativeCloseGate = class {
1105
1110
  if (this.#active > 0) {
1106
1111
  await new Promise((resolve) => this.#waiters.push(resolve));
1107
1112
  }
1108
- await callback();
1113
+ await (callback == null ? void 0 : callback());
1109
1114
  }
1110
1115
  };
1111
1116
  function wrapJsNativeDatabase(database) {
1112
1117
  const gate = new NativeCloseGate();
1113
- let closePromise;
1118
+ let terminalPromise;
1114
1119
  let lastInsertRowId = null;
1115
1120
  const executeNative = async (sql, params) => {
1116
1121
  const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
@@ -1245,8 +1250,12 @@ function wrapJsNativeDatabase(database) {
1245
1250
  return normalizeNativeMetrics((_a = database.metrics) == null ? void 0 : _a.call(database));
1246
1251
  },
1247
1252
  async close() {
1248
- closePromise ??= gate.close(() => database.close());
1249
- await closePromise;
1253
+ terminalPromise ??= gate.close(() => database.close());
1254
+ await terminalPromise;
1255
+ },
1256
+ async detachForShutdown() {
1257
+ terminalPromise ??= gate.close();
1258
+ await terminalPromise;
1250
1259
  }
1251
1260
  };
1252
1261
  }
@@ -1392,6 +1401,12 @@ function getNodePath() {
1392
1401
  function normalizeRuntimeSqlExecuteResult(result) {
1393
1402
  return result;
1394
1403
  }
1404
+ function servicesBinaryUnavailable(cause) {
1405
+ return new Error(
1406
+ "services.binary_unavailable: Install @rivet-dev/services yourself to run local Services, or set RIVET_SERVICES_BINARY to its executable path.",
1407
+ { cause }
1408
+ );
1409
+ }
1395
1410
 
1396
1411
  // src/registry/napi-runtime.ts
1397
1412
  function asNativeRegistry(handle) {
@@ -1664,7 +1679,8 @@ var NapiCoreRuntime = class {
1664
1679
  asNativeCancellationToken(token).cancel();
1665
1680
  }
1666
1681
  onCancellationTokenCancelled(token, callback) {
1667
- asNativeCancellationToken(token).onCancelled(callback);
1682
+ const listener = asNativeCancellationToken(token).onCancelled(callback);
1683
+ return () => listener.release();
1668
1684
  }
1669
1685
  actorState(ctx) {
1670
1686
  return asNativeActorContext(ctx).state();
@@ -2703,9 +2719,10 @@ var WasmCoreRuntime = class {
2703
2719
  callWasmSync(() => asWasmCancellationToken(token).cancel());
2704
2720
  }
2705
2721
  onCancellationTokenCancelled(token, callback) {
2706
- callWasmSync(
2722
+ const listener = callWasmSync(
2707
2723
  () => asWasmCancellationToken(token).onCancelled(callback)
2708
2724
  );
2725
+ return () => callWasmSync(() => listener.release());
2709
2726
  }
2710
2727
  actorState(ctx) {
2711
2728
  return toBytes(
@@ -3498,9 +3515,10 @@ function normalizeRuntimeConfig(config, runtime) {
3498
3515
  return normalizeRuntimeConfigForKind(config, loadedRuntimeKind(runtime));
3499
3516
  }
3500
3517
  function getNativeRuntimeState(runtime, ctx) {
3501
- const runtimeState = callNativeSync(
3502
- () => runtime.actorRuntimeState(ctx)
3503
- );
3518
+ const runtimeState = readNativeRuntimeStateBag(runtime, ctx);
3519
+ if (runtimeState.cleared) {
3520
+ throw actorStopping(callNativeSync(() => runtime.actorId(ctx)));
3521
+ }
3504
3522
  if (!runtimeState.destroyGate) {
3505
3523
  runtimeState.destroyGate = {};
3506
3524
  }
@@ -3513,6 +3531,14 @@ function getNativeRuntimeState(runtime, ctx) {
3513
3531
  }
3514
3532
  return runtimeState;
3515
3533
  }
3534
+ function readNativeRuntimeStateBag(runtime, ctx) {
3535
+ return callNativeSync(
3536
+ () => runtime.actorRuntimeState(ctx)
3537
+ );
3538
+ }
3539
+ function isNativeRuntimeStateCleared(runtime, ctx) {
3540
+ return readNativeRuntimeStateBag(runtime, ctx).cleared === true;
3541
+ }
3516
3542
  function getNativePersistState(runtime, ctx) {
3517
3543
  const persistState = getNativeRuntimeState(runtime, ctx).persistState;
3518
3544
  if (!persistState) {
@@ -3623,13 +3649,18 @@ function resolveNativeDestroy(runtime, ctx) {
3623
3649
  gate.destroyCompletion = void 0;
3624
3650
  }
3625
3651
  function clearNativeRuntimeState(runtime, ctx) {
3652
+ var _a;
3653
+ const pendingSaveHandle = (_a = readNativeRuntimeStateBag(runtime, ctx).persistState) == null ? void 0 : _a.pendingSaveHandle;
3654
+ if (pendingSaveHandle !== void 0) {
3655
+ clearImmediate(pendingSaveHandle);
3656
+ }
3626
3657
  callNativeSync(() => runtime.actorClearRuntimeState(ctx));
3658
+ readNativeRuntimeStateBag(runtime, ctx).cleared = true;
3627
3659
  }
3628
3660
  async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
3629
3661
  const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
3630
3662
  if (!drained) {
3631
- await closeNativeDatabaseClient(runtime, ctx);
3632
- await closeNativeSqlDatabase(runtime, ctx);
3663
+ await detachNativeDatabaseForShutdown(runtime, ctx);
3633
3664
  void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
3634
3665
  await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
3635
3666
  clearNativeRuntimeState(runtime, ctx);
@@ -3642,10 +3673,19 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
3642
3673
  return;
3643
3674
  }
3644
3675
  await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
3645
- await closeNativeDatabaseClient(runtime, ctx);
3646
- await closeNativeSqlDatabase(runtime, ctx);
3676
+ await detachNativeDatabaseForShutdown(runtime, ctx);
3647
3677
  clearNativeRuntimeState(runtime, ctx);
3648
3678
  }
3679
+ async function detachNativeDatabaseForShutdown(runtime, ctx) {
3680
+ var _a;
3681
+ const runtimeState = getNativeRuntimeState(runtime, ctx);
3682
+ await ((_a = runtimeState.sql) == null ? void 0 : _a.detachForShutdown());
3683
+ try {
3684
+ await closeNativeDatabaseClient(runtime, ctx);
3685
+ } finally {
3686
+ runtimeState.sql = void 0;
3687
+ }
3688
+ }
3649
3689
  function closeNativeSqlDatabase(runtime, ctx) {
3650
3690
  const runtimeState = getNativeRuntimeState(runtime, ctx);
3651
3691
  const database = runtimeState.sql;
@@ -5386,12 +5426,14 @@ var ActorContextHandleAdapter = class {
5386
5426
  }
5387
5427
  get abortSignal() {
5388
5428
  if (!this.#abortSignal) {
5389
- const actorSignal = this.#createActorAbortSignal();
5429
+ const actorAbort = this.#actorAbort();
5430
+ const actorSignal = actorAbort.signal;
5390
5431
  if (this.#dispatchCancelToken === void 0) {
5391
5432
  this.#abortSignal = actorSignal;
5392
5433
  } else {
5393
5434
  const controller = new AbortController();
5394
5435
  let cleanedUp = false;
5436
+ let releaseDispatchListener;
5395
5437
  const onActorAbort = () => {
5396
5438
  cleanup();
5397
5439
  controller.abort();
@@ -5401,7 +5443,9 @@ var ActorContextHandleAdapter = class {
5401
5443
  return;
5402
5444
  }
5403
5445
  cleanedUp = true;
5404
- actorSignal.removeEventListener("abort", onActorAbort);
5446
+ actorAbort.listeners.delete(onActorAbort);
5447
+ releaseDispatchListener == null ? void 0 : releaseDispatchListener();
5448
+ releaseDispatchListener = void 0;
5405
5449
  this.#abortSignalCleanup = void 0;
5406
5450
  };
5407
5451
  if (actorSignal.aborted || this.#runtime.cancellationTokenAborted(
@@ -5411,10 +5455,8 @@ var ActorContextHandleAdapter = class {
5411
5455
  } else {
5412
5456
  const dispatchCancelToken = this.#dispatchCancelToken;
5413
5457
  this.#abortSignalCleanup = cleanup;
5414
- actorSignal.addEventListener("abort", onActorAbort, {
5415
- once: true
5416
- });
5417
- callNativeSync(
5458
+ actorAbort.listeners.add(onActorAbort);
5459
+ releaseDispatchListener = callNativeSync(
5418
5460
  () => this.#runtime.onCancellationTokenCancelled(
5419
5461
  dispatchCancelToken,
5420
5462
  () => {
@@ -5790,22 +5832,42 @@ var ActorContextHandleAdapter = class {
5790
5832
  }
5791
5833
  async dispose() {
5792
5834
  var _a;
5793
- this.#flushStateChange();
5835
+ if (!isNativeRuntimeStateCleared(this.#runtime, this.#ctx)) {
5836
+ this.#flushStateChange();
5837
+ }
5794
5838
  (_a = this.#abortSignalCleanup) == null ? void 0 : _a.call(this);
5795
5839
  }
5796
- #createActorAbortSignal() {
5840
+ #actorAbort() {
5841
+ const runtimeState = readNativeRuntimeStateBag(
5842
+ this.#runtime,
5843
+ this.#ctx
5844
+ );
5845
+ const cached = runtimeState.actorAbort;
5846
+ if (cached && !cached.signal.aborted) {
5847
+ return cached;
5848
+ }
5797
5849
  const nativeSignal = callNativeSync(
5798
5850
  () => this.#runtime.actorAbortSignal(this.#ctx)
5799
5851
  );
5800
5852
  const controller = new AbortController();
5801
- if (nativeSignal.aborted) {
5853
+ const actorAbort = {
5854
+ signal: controller.signal,
5855
+ listeners: /* @__PURE__ */ new Set()
5856
+ };
5857
+ const abort = () => {
5802
5858
  controller.abort();
5859
+ for (const listener of actorAbort.listeners) {
5860
+ listener();
5861
+ }
5862
+ actorAbort.listeners.clear();
5863
+ };
5864
+ if (nativeSignal.aborted) {
5865
+ abort();
5803
5866
  } else {
5804
- nativeSignal.addEventListener("abort", () => controller.abort(), {
5805
- once: true
5806
- });
5867
+ nativeSignal.addEventListener("abort", abort, { once: true });
5807
5868
  }
5808
- return controller.signal;
5869
+ runtimeState.actorAbort = actorAbort;
5870
+ return actorAbort;
5809
5871
  }
5810
5872
  #readState() {
5811
5873
  const actorState = getNativePersistState(this.#runtime, this.#ctx);
@@ -6767,7 +6829,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6767
6829
  }
6768
6830
  } finally {
6769
6831
  resolveNativeDestroy(runtime, ctx);
6770
- await actorCtx.closeDatabase();
6832
+ await detachNativeDatabaseForShutdown(runtime, ctx);
6771
6833
  clearNativeRuntimeState(runtime, ctx);
6772
6834
  await actorCtx.dispose();
6773
6835
  }
@@ -7271,11 +7333,12 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
7271
7333
  throw nativeEndpointNotConfiguredError();
7272
7334
  }
7273
7335
  const serveConfig = {
7274
- version: config.envoy.version,
7336
+ version: config.node.version,
7275
7337
  endpoint: config.endpoint,
7338
+ engineSpawn: config.engineSpawn,
7276
7339
  token: config.token,
7277
7340
  namespace: config.namespace,
7278
- poolName: config.envoy.poolName,
7341
+ poolName: config.node.poolName,
7279
7342
  startServices: resolveServicesBinary && config.startServices,
7280
7343
  handleInspectorHttpInRuntime: true,
7281
7344
  serverlessBasePath: config.serverless.basePath,
@@ -7296,14 +7359,16 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
7296
7359
  });
7297
7360
  }
7298
7361
  if (resolveServicesBinary && config.startServices) {
7299
- try {
7300
- const { getServicesPath } = await loadServices();
7301
- serveConfig.servicesBinaryPath = getServicesPath();
7302
- } catch (error) {
7303
- logger2().warn({
7304
- msg: "could not resolve the Services binary; a local engine will fail with services.binary_unavailable \u2014 set RIVET_RUN_SERVICES=0 to disable Services or RIVET_SERVICES_BINARY to a local rivet-services binary",
7305
- error: stringifyError(error)
7306
- });
7362
+ const servicesBinary = getEnvUniversal("RIVET_SERVICES_BINARY");
7363
+ if (servicesBinary) {
7364
+ serveConfig.servicesBinaryPath = servicesBinary;
7365
+ } else {
7366
+ try {
7367
+ const { getServicesPath } = await loadServices();
7368
+ serveConfig.servicesBinaryPath = getServicesPath();
7369
+ } catch (error) {
7370
+ throw servicesBinaryUnavailable(error);
7371
+ }
7307
7372
  }
7308
7373
  }
7309
7374
  serveConfig.engineHost = config.engineHost;
@@ -7345,6 +7410,9 @@ async function buildConfiguredRegistry(config) {
7345
7410
 
7346
7411
  // src/registry/index.ts
7347
7412
  var REGISTRY_READY_TIMEOUT_MS = 3e4;
7413
+ function rejectServerless() {
7414
+ throw new Error("serverless is disabled in this version");
7415
+ }
7348
7416
  function signalExitCode(signal) {
7349
7417
  switch (signal) {
7350
7418
  case "SIGINT":
@@ -7449,6 +7517,7 @@ var Registry = class {
7449
7517
  */
7450
7518
  #ensureServerlessPoolConfigured(config) {
7451
7519
  if (!config.configurePool) return void 0;
7520
+ rejectServerless();
7452
7521
  if (!this.#configureServerlessPoolPromise) {
7453
7522
  this.#configureServerlessPoolPromise = configureServerlessPool(
7454
7523
  config
@@ -7473,6 +7542,7 @@ var Registry = class {
7473
7542
  */
7474
7543
  async handler(request) {
7475
7544
  var _a;
7545
+ rejectServerless();
7476
7546
  const config = this.parseConfig();
7477
7547
  this.#printWelcome(config, "serverless");
7478
7548
  if (!this.#runtimeServerlessPromise) {
@@ -7634,6 +7704,7 @@ var Registry = class {
7634
7704
  * ```
7635
7705
  */
7636
7706
  serve() {
7707
+ rejectServerless();
7637
7708
  return {
7638
7709
  fetch: (request) => this.handler(request)
7639
7710
  };
@@ -7658,6 +7729,9 @@ var Registry = class {
7658
7729
  * ```
7659
7730
  */
7660
7731
  async listen(opts = {}) {
7732
+ if (!opts.application) {
7733
+ rejectServerless();
7734
+ }
7661
7735
  const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
7662
7736
  const publicDir = opts.publicDir ?? getRivetkitPublicDir();
7663
7737
  const config = this.parseConfig();
@@ -7758,6 +7832,7 @@ var Registry = class {
7758
7832
  * Returns serverless metadata suitable for mounting in a user-owned router.
7759
7833
  */
7760
7834
  async #metadataRoute() {
7835
+ rejectServerless();
7761
7836
  const configured = await this.#activeConfiguredRegistry();
7762
7837
  if (!configured) {
7763
7838
  return new Response("registry not started\n", {
@@ -7818,18 +7893,18 @@ var Registry = class {
7818
7893
  #startEnvoy(config, printWelcome) {
7819
7894
  var _a;
7820
7895
  if (!this.#runtimeServePromise) {
7821
- const configuredEnvoyVersion = (_a = this.#config.envoy) == null ? void 0 : _a.version;
7896
+ const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
7822
7897
  const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : getRivetEnvoyVersion() !== void 0 ? "environment" : "default";
7823
7898
  logger2().info({
7824
7899
  msg: "starting rivetkit envoy",
7825
7900
  rivetkitVersion: VERSION,
7826
- envoyVersion: config.envoy.version,
7901
+ envoyVersion: config.node.version,
7827
7902
  envoyVersionSource
7828
7903
  });
7829
7904
  if (envoyVersionSource === "default" && getNodeEnv() === "production") {
7830
7905
  logger2().error({
7831
- msg: "envoy version defaulted because neither config.envoy.version nor RIVET_ENVOY_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
7832
- envoyVersion: config.envoy.version,
7906
+ msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
7907
+ envoyVersion: config.node.version,
7833
7908
  envoyVersionSource
7834
7909
  });
7835
7910
  }
@@ -7841,7 +7916,10 @@ var Registry = class {
7841
7916
  }
7842
7917
  );
7843
7918
  this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error) => {
7844
- logger2().warn({ error }, "runtime registry serve errored");
7919
+ logger2().error({ error }, "runtime registry serve errored");
7920
+ if (typeof process !== "undefined" && typeof process.exit === "function") {
7921
+ process.exit(1);
7922
+ }
7845
7923
  });
7846
7924
  this.#installSignalHandlers(config);
7847
7925
  }
@@ -7871,7 +7949,7 @@ var Registry = class {
7871
7949
  finishShutdownSignal(signal);
7872
7950
  return;
7873
7951
  }
7874
- this.#shutdownInFlight = this.#drain(config).catch((err) => {
7952
+ this.#shutdownInFlight = this.#drain(config, true).catch((err) => {
7875
7953
  logger2().warn({ err }, "shutdown error");
7876
7954
  }).then(() => {
7877
7955
  this.#removeSignalHandlers();
@@ -7907,12 +7985,18 @@ var Registry = class {
7907
7985
  });
7908
7986
  return this.#shutdownInFlight;
7909
7987
  }
7910
- async #drain(config) {
7988
+ async #drain(config, signalDriven = false) {
7911
7989
  var _a;
7912
7990
  const modeAPromise = this.#runtimeServeConfiguredPromise;
7913
7991
  const modeBPromise = this.#runtimeServerlessPromise;
7914
7992
  const runtimes = /* @__PURE__ */ new Set();
7915
- const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? await this.#actorStopThresholdMs(modeAPromise ?? modeBPromise) ?? 30 * 60 * 1e3;
7993
+ const localDevSignal = signalDriven && getNodeEnv() !== "production" && config.engineSpawn && config.endpoint !== void 0 && isLocalEngineEndpoint(config.endpoint);
7994
+ let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
7995
+ if (gracePeriodMs === void 0) {
7996
+ gracePeriodMs = localDevSignal ? 1e3 : await this.#actorStopThresholdMs(
7997
+ modeAPromise ?? modeBPromise
7998
+ ) ?? 30 * 60 * 1e3;
7999
+ }
7916
8000
  const drain = async () => {
7917
8001
  const registries = [];
7918
8002
  if (modeAPromise !== void 0) {
@@ -8017,12 +8101,16 @@ var Registry = class {
8017
8101
  );
8018
8102
  }
8019
8103
  if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
8020
- if (getRivetkitRuntimeMode() === "serverless") {
8021
- return Promise.reject(
8022
- new Error(
8023
- "registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
8024
- )
8025
- );
8104
+ try {
8105
+ if (getRivetkitRuntimeMode() === "serverless") {
8106
+ return Promise.reject(
8107
+ new Error(
8108
+ "registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
8109
+ )
8110
+ );
8111
+ }
8112
+ } catch (error) {
8113
+ return Promise.reject(error);
8026
8114
  }
8027
8115
  const config = this.parseConfig();
8028
8116
  if (config.runtime === "wasm") {