rivetkit 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/browser/client.d.ts +19 -6
  2. package/dist/browser/client.js +4 -4
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +4 -4
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +4 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -1
  9. package/dist/tsup/actor/errors.d.ts +1 -1
  10. package/dist/tsup/actor/errors.js +3 -1
  11. package/dist/tsup/agent-os/index.cjs +4 -4
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +18 -5
  14. package/dist/tsup/agent-os/index.d.ts +18 -5
  15. package/dist/tsup/agent-os/index.js +4 -4
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-NIY3RSPX.cjs → chunk-3MHDOUD7.cjs} +11 -2
  18. package/dist/tsup/chunk-3MHDOUD7.cjs.map +1 -0
  19. package/dist/tsup/{chunk-KORQB2IR.cjs → chunk-4FC7TVS6.cjs} +6 -2
  20. package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
  21. package/dist/tsup/{chunk-47HHIEXH.cjs → chunk-4UUEB43Y.cjs} +4 -4
  22. package/dist/tsup/{chunk-47HHIEXH.cjs.map → chunk-4UUEB43Y.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-7QKCIVAY.cjs → chunk-5IWLUJ6W.cjs} +167 -167
  24. package/dist/tsup/{chunk-7QKCIVAY.cjs.map → chunk-5IWLUJ6W.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-P2GNQ4RN.js → chunk-H6VVZMWN.js} +4 -4
  26. package/dist/tsup/{chunk-MEHBWPLJ.js → chunk-I35VSLEM.js} +3 -3
  27. package/dist/tsup/{chunk-BEI24WTI.js → chunk-JBUZRPY5.js} +2 -2
  28. package/dist/tsup/{chunk-B6VUNZUD.cjs → chunk-JLJJZYCJ.cjs} +10 -10
  29. package/dist/tsup/{chunk-B6VUNZUD.cjs.map → chunk-JLJJZYCJ.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-VTTFNQQI.js → chunk-L2X3YFER.js} +31 -6
  31. package/dist/tsup/chunk-L2X3YFER.js.map +1 -0
  32. package/dist/tsup/{chunk-DXXJPH55.cjs → chunk-MNHKOS6L.cjs} +39 -14
  33. package/dist/tsup/chunk-MNHKOS6L.cjs.map +1 -0
  34. package/dist/tsup/{chunk-UMZVD6DQ.js → chunk-NERUIBOT.js} +2 -2
  35. package/dist/tsup/{chunk-I4LN3FNT.cjs → chunk-OST76LRW.cjs} +7 -7
  36. package/dist/tsup/{chunk-I4LN3FNT.cjs.map → chunk-OST76LRW.cjs.map} +1 -1
  37. package/dist/tsup/{chunk-LVTBW2RE.cjs → chunk-OZBCXBVP.cjs} +3 -3
  38. package/dist/tsup/{chunk-LVTBW2RE.cjs.map → chunk-OZBCXBVP.cjs.map} +1 -1
  39. package/dist/tsup/{chunk-4JDSFJS5.js → chunk-PT6OIW5E.js} +5 -5
  40. package/dist/tsup/{chunk-2OTRTA3J.js → chunk-R6KPN5EW.js} +2 -2
  41. package/dist/tsup/{chunk-3677IIOV.cjs → chunk-V5KMAMX3.cjs} +5 -5
  42. package/dist/tsup/{chunk-3677IIOV.cjs.map → chunk-V5KMAMX3.cjs.map} +1 -1
  43. package/dist/tsup/{chunk-DPIMKYNB.js → chunk-XIX5DOZN.js} +10 -1
  44. package/dist/tsup/chunk-XIX5DOZN.js.map +1 -0
  45. package/dist/tsup/{chunk-BRP62GZC.js → chunk-ZZ3WBRPD.js} +5 -1
  46. package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
  47. package/dist/tsup/client/mod.cjs +7 -7
  48. package/dist/tsup/client/mod.d.cts +3 -3
  49. package/dist/tsup/client/mod.d.ts +3 -3
  50. package/dist/tsup/client/mod.js +6 -6
  51. package/dist/tsup/common/log.cjs +3 -3
  52. package/dist/tsup/common/log.js +2 -2
  53. package/dist/tsup/common/websocket.cjs +4 -4
  54. package/dist/tsup/common/websocket.js +3 -3
  55. package/dist/tsup/{config-CZQQ-mso.d.cts → config-CzvopP5m.d.cts} +22 -7
  56. package/dist/tsup/{config-BxWAw3iH.d.ts → config-DZuT7tcp.d.ts} +22 -7
  57. package/dist/tsup/context-CyAdY-aA.d.ts +128 -0
  58. package/dist/tsup/context-sNB28g0N.d.cts +128 -0
  59. package/dist/tsup/dynamic/mod.cjs +2 -2
  60. package/dist/tsup/dynamic/mod.d.cts +2 -2
  61. package/dist/tsup/dynamic/mod.d.ts +2 -2
  62. package/dist/tsup/dynamic/mod.js +1 -1
  63. package/dist/tsup/inspector/mod.cjs +6 -6
  64. package/dist/tsup/inspector/mod.js +5 -5
  65. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  66. package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
  67. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  68. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  69. package/dist/tsup/inspector-tab/mod.js +1 -1
  70. package/dist/tsup/inspector-tab/mod.js.map +1 -1
  71. package/dist/tsup/mod.cjs +292 -276
  72. package/dist/tsup/mod.cjs.map +1 -1
  73. package/dist/tsup/mod.d.cts +4 -4
  74. package/dist/tsup/mod.d.ts +4 -4
  75. package/dist/tsup/mod.js +202 -186
  76. package/dist/tsup/mod.js.map +1 -1
  77. package/dist/tsup/test/mod.cjs +10 -10
  78. package/dist/tsup/test/mod.d.cts +2 -2
  79. package/dist/tsup/test/mod.d.ts +2 -2
  80. package/dist/tsup/test/mod.js +6 -6
  81. package/dist/tsup/{utils-DQosb24I.d.ts → utils-CqDnC_PS.d.cts} +2 -1
  82. package/dist/tsup/{utils-DQosb24I.d.cts → utils-CqDnC_PS.d.ts} +2 -1
  83. package/dist/tsup/utils.cjs +3 -3
  84. package/dist/tsup/utils.d.cts +1 -1
  85. package/dist/tsup/utils.d.ts +1 -1
  86. package/dist/tsup/utils.js +2 -2
  87. package/dist/tsup/workflow/mod.cjs +184 -148
  88. package/dist/tsup/workflow/mod.cjs.map +1 -1
  89. package/dist/tsup/workflow/mod.d.cts +6 -6
  90. package/dist/tsup/workflow/mod.d.ts +6 -6
  91. package/dist/tsup/workflow/mod.js +177 -141
  92. package/dist/tsup/workflow/mod.js.map +1 -1
  93. package/package.json +11 -11
  94. package/src/actor/config.ts +14 -0
  95. package/src/actor/errors.ts +11 -0
  96. package/src/inspector-tab/mod.ts +1 -1
  97. package/src/registry/index.ts +74 -18
  98. package/src/registry/napi-runtime.ts +16 -0
  99. package/src/registry/native.ts +79 -30
  100. package/src/registry/runtime.ts +11 -0
  101. package/src/registry/wasm-runtime.ts +11 -0
  102. package/src/utils/env-vars.ts +31 -0
  103. package/src/workflow/context.ts +675 -244
  104. package/src/workflow/driver.ts +20 -7
  105. package/src/workflow/mod.ts +25 -9
  106. package/dist/tsup/chunk-BRP62GZC.js.map +0 -1
  107. package/dist/tsup/chunk-DPIMKYNB.js.map +0 -1
  108. package/dist/tsup/chunk-DXXJPH55.cjs.map +0 -1
  109. package/dist/tsup/chunk-KORQB2IR.cjs.map +0 -1
  110. package/dist/tsup/chunk-NIY3RSPX.cjs.map +0 -1
  111. package/dist/tsup/chunk-VTTFNQQI.js.map +0 -1
  112. package/dist/tsup/context-Bw7xq8w3.d.cts +0 -92
  113. package/dist/tsup/context-D8QA76sV.d.ts +0 -92
  114. package/src/utils/serve.ts +0 -216
  115. /package/dist/tsup/{chunk-P2GNQ4RN.js.map → chunk-H6VVZMWN.js.map} +0 -0
  116. /package/dist/tsup/{chunk-MEHBWPLJ.js.map → chunk-I35VSLEM.js.map} +0 -0
  117. /package/dist/tsup/{chunk-BEI24WTI.js.map → chunk-JBUZRPY5.js.map} +0 -0
  118. /package/dist/tsup/{chunk-UMZVD6DQ.js.map → chunk-NERUIBOT.js.map} +0 -0
  119. /package/dist/tsup/{chunk-4JDSFJS5.js.map → chunk-PT6OIW5E.js.map} +0 -0
  120. /package/dist/tsup/{chunk-2OTRTA3J.js.map → chunk-R6KPN5EW.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-CZQQ-mso.cjs';
2
- export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as event, a_ as getRunFunction, a$ as getRunInspectorConfig, b0 as getRunMetadata, b1 as isStaticActorDefinition, b2 as isStaticActorInstance, b3 as lookupInRegistry, b4 as queue, b5 as setup, b6 as test } from './config-CZQQ-mso.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-CzvopP5m.cjs';
2
+ export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as disposeRunInspector, a_ as event, a$ as getRunFunction, b0 as getRunInspectorConfig, b1 as getRunMetadata, b2 as isStaticActorDefinition, b3 as isStaticActorInstance, b4 as lookupInRegistry, b5 as queue, b6 as setup, b7 as test } from './config-CzvopP5m.cjs';
3
3
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
4
4
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
5
  import { A as AnyDatabaseProvider } from './config-D49x8NpL.cjs';
6
- export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-DQosb24I.cjs';
6
+ export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-CqDnC_PS.cjs';
7
7
  import { WSContext } from 'hono/ws';
8
8
  export { toUint8Array } from './utils.cjs';
9
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-Bw7xq8w3.cjs';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-sNB28g0N.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-BxWAw3iH.js';
2
- export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as event, a_ as getRunFunction, a$ as getRunInspectorConfig, b0 as getRunMetadata, b1 as isStaticActorDefinition, b2 as isStaticActorInstance, b3 as lookupInRegistry, b4 as queue, b5 as setup, b6 as test } from './config-BxWAw3iH.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-DZuT7tcp.js';
2
+ export { k as ACTOR_CONTEXT_INTERNAL_SYMBOL, l as Actions, m as ActorConfig, n as ActorConfigInput, o as ActorConfigSchema, p as ActorContext, q as ActorContextOf, r as ActorDefinition, s as ActorInspectorConfig, t as ActorInspectorConfigSchema, u as ActorKey, v as ActorKv, w as ActorLogger, x as ActorOptions, y as ActorOptionsInput, z as ActorOptionsSchema, F as ActorQuery, G as ActorQueue, H as ActorSchedule, I as ActorTypes, J as ActorsSchema, K as AnyActorInstance, L as AnyClient, N as AnyConn, O as AnyStaticActorDefinition, P as AnyStaticActorInstance, T as AuthIntent, U as BUILTIN_INSPECTOR_TAB_IDS, V as BaseActorInstance, X as BuiltinInspectorTabIdSchema, Y as CONN_DRIVER_SYMBOL, Z as CONN_STATE_MANAGER_SYMBOL, _ as Client, $ as Conn, a0 as CustomInspectorTabEntrySchema, a1 as DEFAULT_SLEEP_GRACE_PERIOD, a2 as DocActorConfigSchema, a3 as DocActorOptionsSchema, a4 as DocConfigurePoolSchema, a5 as DocEnvoyConfigSchema, a6 as DocRegistryConfigSchema, a7 as DocServerlessConfigSchema, a8 as DocSqliteConfigSchema, a9 as Encoding, aa as FetchHandler, ab as GlobalActorOptions, ac as GlobalActorOptionsInput, ad as GlobalActorOptionsSchema, ae as HideInspectorTabEntrySchema, af as InspectorTabEntrySchema, ag as InspectorUnsubscribe, ah as InstanceActorOptions, ai as InstanceActorOptionsInput, aj as InstanceActorOptionsSchema, ak as QueueEnqueueAndWaitOptions, al as QueueFilterName, am as QueueIterOptions, an as QueueMessageOf, ao as QueueName, ap as QueueNextBatchOptions, aq as QueueNextOptions, ar as QueueResultMessageForName, as as QueueTryNextBatchOptions, at as QueueTryNextOptions, au as QueueWaitOptions, av as RAW_STATE_SYMBOL, aw as RUN_FUNCTION_CONFIG_SYMBOL, ax as Registry, ay as RegistryActors, az as RegistryConfig, aA as RegistryConfigInput, aB as RegistryConfigSchema, aC as RegistryDeps, aD as RegistryRoutes, aE as RunConfig, aF as RunConfigSchema, aG as RunInspectorConfig, aH as RuntimeKind, aI as RuntimeKindSchema, aJ as ServerlessHandler, aK as SqliteBackend, aL as SqliteBackendSchema, aM as SqliteConfig, aN as SqliteConfigSchema, aO as TestConfig, aP as TestConfigSchema, aQ as Type, aR as WasmRuntimeBindings, aS as WasmRuntimeConfig, aT as WasmRuntimeConfigSchema, aU as WasmRuntimeInitInput, aV as WorkflowInspectorConfig, aW as actor, aX as buildActorNames, aY as createClientWithDriver, aZ as disposeRunInspector, a_ as event, a$ as getRunFunction, b0 as getRunInspectorConfig, b1 as getRunMetadata, b2 as isStaticActorDefinition, b3 as isStaticActorInstance, b4 as lookupInRegistry, b5 as queue, b6 as setup, b7 as test } from './config-DZuT7tcp.js';
3
3
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
4
4
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
5
  import { A as AnyDatabaseProvider } from './config-D49x8NpL.js';
6
- export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-DQosb24I.js';
6
+ export { R as ActorError, R as RivetError, a as RivetErrorLike, b as RivetErrorOptions, U as UserError, c as UserErrorOptions, n as noopNext } from './utils-CqDnC_PS.js';
7
7
  import { WSContext } from 'hono/ws';
8
8
  export { toUint8Array } from './utils.js';
9
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-D8QA76sV.js';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-CyAdY-aA.js';
10
10
  import 'zod/v4';
11
11
  import '@rivetkit/rivetkit-wasm';
12
12
  import 'zod';
package/dist/tsup/mod.js CHANGED
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  decodeWorkflowHistoryTransport
3
- } from "./chunk-UMZVD6DQ.js";
3
+ } from "./chunk-NERUIBOT.js";
4
4
  import {
5
5
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
6
6
  ActorConfigSchema,
7
7
  CONN_STATE_MANAGER_SYMBOL,
8
8
  RAW_STATE_SYMBOL,
9
+ disposeRunInspector,
9
10
  getRunFunction,
10
11
  getRunInspectorConfig,
11
12
  getRunMetadata
12
- } from "./chunk-DPIMKYNB.js";
13
+ } from "./chunk-XIX5DOZN.js";
13
14
  import {
14
15
  ALLOWED_PUBLIC_HEADERS,
15
16
  HEADER_CONN_PARAMS,
@@ -19,7 +20,7 @@ import {
19
20
  getDatacenters,
20
21
  tryParseEndpoint,
21
22
  updateRunnerConfig
22
- } from "./chunk-4JDSFJS5.js";
23
+ } from "./chunk-PT6OIW5E.js";
23
24
  import {
24
25
  KEYS,
25
26
  makePrefixedKey,
@@ -32,14 +33,13 @@ import {
32
33
  assertJsonCompatValue,
33
34
  decodeCborCompat,
34
35
  encodeCborCompat
35
- } from "./chunk-2OTRTA3J.js";
36
+ } from "./chunk-R6KPN5EW.js";
36
37
  import "./chunk-JZ7TWV65.js";
37
- import "./chunk-BEI24WTI.js";
38
+ import "./chunk-JBUZRPY5.js";
38
39
  import {
39
40
  LogLevelSchema,
40
41
  VERSION,
41
42
  deconstructError,
42
- detectRuntime,
43
43
  getEnvUniversal,
44
44
  getLogger,
45
45
  getNodeEnv,
@@ -56,12 +56,15 @@ import {
56
56
  getRivetRunEngineVersion,
57
57
  getRivetToken,
58
58
  getRivetTotalSlots,
59
+ getRivetkitPublicDir,
59
60
  getRivetkitRuntime,
61
+ getRivetkitRuntimeMode,
60
62
  isDev,
61
63
  noopNext,
64
+ parsePortEnv,
62
65
  stringifyError,
63
66
  toUint8Array
64
- } from "./chunk-VTTFNQQI.js";
67
+ } from "./chunk-L2X3YFER.js";
65
68
  import {
66
69
  INTERNAL_ERROR_CODE,
67
70
  RivetError,
@@ -69,10 +72,11 @@ import {
69
72
  decodeBridgeRivetError,
70
73
  encodeBridgeRivetError,
71
74
  forbiddenError,
75
+ isActorAbortedError,
72
76
  isRivetErrorLike,
73
77
  toRivetError,
74
78
  unsupportedFeature
75
- } from "./chunk-BRP62GZC.js";
79
+ } from "./chunk-ZZ3WBRPD.js";
76
80
 
77
81
  // src/actor/log.ts
78
82
  function loggerWithoutContext() {
@@ -358,9 +362,6 @@ var InlineWebSocketAdapter = class {
358
362
  }
359
363
  };
360
364
 
361
- // src/registry/index.ts
362
- import { Hono } from "hono";
363
-
364
365
  // src/common/engine.ts
365
366
  var ENGINE_HOST = "127.0.0.1";
366
367
  var ENGINE_PORT = 6420;
@@ -481,145 +482,6 @@ async function configureServerlessPool(config) {
481
482
  throw lastError;
482
483
  }
483
484
 
484
- // src/utils/serve.ts
485
- import getPort from "get-port";
486
- var serveStaticLoaderPromises = {};
487
- async function crossPlatformServe(config, httpPort, app, runtime = detectRuntime()) {
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] = import(
505
- /* webpackIgnore: true */
506
- nodeServeStaticModule
507
- ).then((x) => x.serveStatic);
508
- } else if (runtime === "bun") {
509
- const bunModule = "hono/bun";
510
- serveStaticLoaderPromises[runtime] = import(
511
- /* webpackIgnore: true */
512
- bunModule
513
- ).then((x) => x.serveStatic);
514
- } else if (runtime === "deno") {
515
- const denoModule = "hono/deno";
516
- serveStaticLoaderPromises[runtime] = import(
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 import(
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: stringifyError(err)
539
- });
540
- process.exit(1);
541
- }
542
- const nodeWsModule = "@hono/node-ws";
543
- let createNodeWebSocket;
544
- try {
545
- const dep = await import(
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: stringifyError(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 import(
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: stringifyError(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 import(
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: stringifyError(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
-
623
485
  // src/registry/config/index.ts
624
486
  import { z as z3 } from "zod";
625
487
 
@@ -1340,6 +1202,82 @@ function lastInsertRowIdColumnName(sql) {
1340
1202
  return alias;
1341
1203
  }
1342
1204
 
1205
+ // src/utils/node.ts
1206
+ import { createRequire } from "module";
1207
+ var nodeCrypto;
1208
+ var nodeFsSync;
1209
+ var nodeFs;
1210
+ var nodePath;
1211
+ var nodeOs;
1212
+ var nodeChildProcess;
1213
+ var nodeStream;
1214
+ var nodeUrl;
1215
+ var hasImportedDependencies = false;
1216
+ function getRequireFn() {
1217
+ return createRequire(import.meta.url);
1218
+ }
1219
+ function importNodeDependencies() {
1220
+ if (hasImportedDependencies) return;
1221
+ try {
1222
+ const requireFn = getRequireFn();
1223
+ nodeCrypto = requireFn(
1224
+ /* webpackIgnore: true */
1225
+ "node:crypto"
1226
+ );
1227
+ nodeFsSync = requireFn(
1228
+ /* webpackIgnore: true */
1229
+ "node:fs"
1230
+ );
1231
+ nodeFs = requireFn(
1232
+ /* webpackIgnore: true */
1233
+ "node:fs/promises"
1234
+ );
1235
+ nodePath = requireFn(
1236
+ /* webpackIgnore: true */
1237
+ "node:path"
1238
+ );
1239
+ nodeOs = requireFn(
1240
+ /* webpackIgnore: true */
1241
+ "node:os"
1242
+ );
1243
+ nodeChildProcess = requireFn(
1244
+ /* webpackIgnore: true */
1245
+ "node:child_process"
1246
+ );
1247
+ nodeStream = requireFn(
1248
+ /* webpackIgnore: true */
1249
+ "node:stream/promises"
1250
+ );
1251
+ nodeUrl = requireFn(
1252
+ /* webpackIgnore: true */
1253
+ "node:url"
1254
+ );
1255
+ hasImportedDependencies = true;
1256
+ } catch (err) {
1257
+ console.warn(
1258
+ "Node.js modules not available, file system driver will not work",
1259
+ err
1260
+ );
1261
+ throw err;
1262
+ }
1263
+ }
1264
+ function getNodeFsSync() {
1265
+ if (!nodeFsSync) {
1266
+ throw new Error(
1267
+ "Node fs module not loaded. Ensure importNodeDependencies() has been called."
1268
+ );
1269
+ }
1270
+ return nodeFsSync;
1271
+ }
1272
+ function getNodePath() {
1273
+ if (!nodePath) {
1274
+ throw new Error(
1275
+ "Node path module not loaded. Ensure importNodeDependencies() has been called."
1276
+ );
1277
+ }
1278
+ return nodePath;
1279
+ }
1280
+
1343
1281
  // src/registry/runtime.ts
1344
1282
  function normalizeRuntimeSqlExecuteResult(result) {
1345
1283
  return result;
@@ -1495,6 +1433,16 @@ var NapiCoreRuntime = class {
1495
1433
  config
1496
1434
  );
1497
1435
  }
1436
+ async serveListener(registry, listener, config) {
1437
+ await asNativeRegistry(registry).serveListener(
1438
+ {
1439
+ port: listener.port,
1440
+ host: listener.host,
1441
+ publicDir: listener.publicDir
1442
+ },
1443
+ config
1444
+ );
1445
+ }
1498
1446
  createActorFactory(callbacks, config) {
1499
1447
  return asActorFactoryHandle(
1500
1448
  new this.#bindings.NapiActorFactory(callbacks, config)
@@ -2055,6 +2003,11 @@ var WasmCoreRuntime = class {
2055
2003
  config
2056
2004
  );
2057
2005
  }
2006
+ async serveListener(_registry, _listener, _config) {
2007
+ throw new Error(
2008
+ "registry.listen() is not supported on the wasm runtime; use registry.serve() and mount the handler in your platform's HTTP server instead"
2009
+ );
2010
+ }
2058
2011
  createActorFactory(callbacks, config) {
2059
2012
  return callWasmSync(
2060
2013
  () => asActorFactoryHandle2(
@@ -2451,10 +2404,6 @@ async function loadWasmRuntime(config) {
2451
2404
  };
2452
2405
  }
2453
2406
 
2454
- // src/registry/native.ts
2455
- import nodeFs from "fs";
2456
- import nodePath from "path";
2457
-
2458
2407
  // src/registry/write-through-proxy.ts
2459
2408
  import onChange from "@rivetkit/on-change";
2460
2409
  function createWriteThroughProxy(value, commit, beforeChange) {
@@ -3589,7 +3538,7 @@ var NativeQueueAdapter = class {
3589
3538
  }
3590
3539
  yield message;
3591
3540
  } catch (error) {
3592
- if (isRivetErrorLike(error) && error.group === "actor" && error.code === "aborted") {
3541
+ if (isActorAbortedError(error)) {
3593
3542
  return;
3594
3543
  }
3595
3544
  throw error;
@@ -4397,7 +4346,10 @@ var ActorContextHandleAdapter = class {
4397
4346
  }
4398
4347
  internalKeepAwake(run) {
4399
4348
  const promise = typeof run === "function" ? run() : run;
4400
- const trackedPromise = promise.then(() => null);
4349
+ const trackedPromise = promise.then(
4350
+ () => null,
4351
+ () => null
4352
+ );
4401
4353
  try {
4402
4354
  callNativeSync(
4403
4355
  () => this.#runtime.actorRegisterTask(this.#ctx, trackedPromise)
@@ -4714,7 +4666,7 @@ function withConnContext(runtime, ctx, conn, clientFactory, schemas = {}, databa
4714
4666
  }
4715
4667
  );
4716
4668
  }
4717
- function buildActorConfig(definition, registryConfig) {
4669
+ function buildActorConfig(definition, registryConfig, runtimeKind) {
4718
4670
  const config = definition.config;
4719
4671
  const options = config.options ?? {};
4720
4672
  const canHibernate = options.canHibernateWebSocket;
@@ -4744,10 +4696,10 @@ function buildActorConfig(definition, registryConfig) {
4744
4696
  preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
4745
4697
  preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
4746
4698
  actions: Object.keys(config.actions ?? {}).sort().map((name) => ({ name })),
4747
- inspectorTabs: buildInspectorTabs(config.inspector)
4699
+ inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
4748
4700
  };
4749
4701
  }
4750
- function buildInspectorTabs(inspector) {
4702
+ function buildInspectorTabs(inspector, runtimeKind) {
4751
4703
  if (!inspector || typeof inspector !== "object") return void 0;
4752
4704
  const tabs = inspector.tabs;
4753
4705
  if (!Array.isArray(tabs) || tabs.length === 0) return void 0;
@@ -4756,7 +4708,24 @@ function buildInspectorTabs(inspector) {
4756
4708
  if (entry.hidden === true) {
4757
4709
  return { id: entry.id, hidden: true };
4758
4710
  }
4759
- const resolved = entry.source !== void 0 ? nodePath.resolve(entry.source) : void 0;
4711
+ if (runtimeKind === "wasm") {
4712
+ if (entry.source !== void 0) {
4713
+ logger2().warn(
4714
+ {
4715
+ tabId: entry.id,
4716
+ runtimeKind
4717
+ },
4718
+ "inspector.tabs[].source is not supported on wasm runners (current host: wasm). Tab descriptors will still appear in the dashboard strip but the tab body will render a not-available placeholder."
4719
+ );
4720
+ }
4721
+ return {
4722
+ id: entry.id,
4723
+ label: entry.label,
4724
+ icon: entry.icon,
4725
+ source: void 0
4726
+ };
4727
+ }
4728
+ const resolved = entry.source !== void 0 ? getNodePath().resolve(entry.source) : void 0;
4760
4729
  if (resolved !== void 0) {
4761
4730
  validateInspectorTabSource(entry.id, resolved);
4762
4731
  }
@@ -4769,14 +4738,14 @@ function buildInspectorTabs(inspector) {
4769
4738
  });
4770
4739
  }
4771
4740
  function validateInspectorTabSource(tabId, resolved) {
4772
- if (resolved === nodePath.parse(resolved).root) {
4741
+ if (resolved === getNodePath().parse(resolved).root) {
4773
4742
  throw new Error(
4774
4743
  `inspector.tabs[id="${tabId}"].source resolves to the filesystem root (${resolved}). Point it at the tab's own static-asset directory instead.`
4775
4744
  );
4776
4745
  }
4777
4746
  let stat;
4778
4747
  try {
4779
- stat = nodeFs.statSync(resolved);
4748
+ stat = getNodeFsSync().statSync(resolved);
4780
4749
  } catch (err) {
4781
4750
  const code = err == null ? void 0 : err.code;
4782
4751
  if (code === "ENOENT") {
@@ -4890,13 +4859,16 @@ function buildNativeFactory(runtime, registryConfig, definition) {
4890
4859
  }
4891
4860
  );
4892
4861
  };
4893
- try {
4894
- await runtime.actorVerifyInspectorAuth(
4895
- ctx,
4896
- ((_a2 = jsRequest.headers.get("authorization")) == null ? void 0 : _a2.replace(/^Bearer\s+/i, "")) ?? null
4897
- );
4898
- } catch (error) {
4899
- return errorResponse(error, 401);
4862
+ const isPublicPerActorPath = jsRequest.method === "GET" && (url.pathname === "/inspector/tab-config" || url.pathname.startsWith("/inspector/custom-tabs/"));
4863
+ if (!isPublicPerActorPath) {
4864
+ try {
4865
+ await runtime.actorVerifyInspectorAuth(
4866
+ ctx,
4867
+ ((_a2 = jsRequest.headers.get("authorization")) == null ? void 0 : _a2.replace(/^Bearer\s+/i, "")) ?? null
4868
+ );
4869
+ } catch (error) {
4870
+ return errorResponse(error, 401);
4871
+ }
4900
4872
  }
4901
4873
  const workflowHistory = () => {
4902
4874
  var _a3;
@@ -5337,6 +5309,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5337
5309
  await config.onDestroy(actorCtx);
5338
5310
  }
5339
5311
  } finally {
5312
+ const actorId = callNativeSync(() => runtime.actorId(ctx));
5313
+ nativeRunHandlerActiveByActorId.delete(actorId);
5314
+ disposeRunInspector(config.run, actorId);
5340
5315
  resolveNativeDestroy(runtime, ctx);
5341
5316
  await actorCtx.closeDatabase();
5342
5317
  clearNativeRuntimeState(runtime, ctx);
@@ -5610,7 +5585,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5610
5585
  try {
5611
5586
  await run(actorCtx);
5612
5587
  } finally {
5613
- nativeRunHandlerActiveByActorId.set(actorId, false);
5588
+ nativeRunHandlerActiveByActorId.delete(actorId);
5614
5589
  await actorCtx.dispose();
5615
5590
  }
5616
5591
  }
@@ -5743,7 +5718,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5743
5718
  };
5744
5719
  return runtime.createActorFactory(
5745
5720
  callbacks,
5746
- buildActorConfig(definition, registryConfig)
5721
+ buildActorConfig(definition, registryConfig, runtime.kind)
5747
5722
  );
5748
5723
  }
5749
5724
  async function buildServeConfig(config) {
@@ -5787,6 +5762,9 @@ async function buildRegistryWithRuntime(config, runtime) {
5787
5762
  if (((_a = config.test) == null ? void 0 : _a.enabled) && getEnvUniversal("_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
5788
5763
  trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
5789
5764
  }
5765
+ if (runtime.kind === "napi") {
5766
+ importNodeDependencies();
5767
+ }
5790
5768
  const registry = runtime.createRegistry();
5791
5769
  for (const [name, definition] of Object.entries(config.use)) {
5792
5770
  runtime.registerActor(
@@ -5851,6 +5829,12 @@ var Registry = class {
5851
5829
  prometheusMetrics: (request) => this.#prometheusMetricsRoute(request)
5852
5830
  };
5853
5831
  }
5832
+ /**
5833
+ * Fires `configureServerlessPool` once per process when the registry
5834
+ * config opts into it. Cached on the instance so repeated calls (from
5835
+ * `handler()` and `listen()`) only run the upsert once. The retry loop
5836
+ * inside `configureServerlessPool` tolerates the engine still warming up.
5837
+ */
5854
5838
  #ensureServerlessPoolConfigured(config) {
5855
5839
  if (!config.configurePool) return void 0;
5856
5840
  if (!this.#configureServerlessPoolPromise) {
@@ -6043,13 +6027,15 @@ var Registry = class {
6043
6027
  };
6044
6028
  }
6045
6029
  /**
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).
6030
+ * Bind an HTTP listener provided by the native (Rust) runtime and serve
6031
+ * the registry's serverless endpoints over it. Resolves only after the
6032
+ * registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
6049
6033
  *
6050
- * @param opts.port Port to listen on. Defaults to 3000.
6034
+ * @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
6035
+ * if set, otherwise 3000.
6036
+ * @param opts.host Address to bind. Defaults to `0.0.0.0`.
6051
6037
  * @param opts.publicDir If set, serves static files from this directory
6052
- * before falling through to the registry handler.
6038
+ * as a fallback below the framework routes.
6053
6039
  *
6054
6040
  * @example
6055
6041
  * ```ts
@@ -6058,16 +6044,25 @@ var Registry = class {
6058
6044
  * ```
6059
6045
  */
6060
6046
  async listen(opts = {}) {
6061
- const port = opts.port ?? 3e3;
6047
+ const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
6048
+ const publicDir = opts.publicDir ?? getRivetkitPublicDir();
6062
6049
  const config = this.parseConfig();
6063
- const runtime = detectRuntime();
6064
- const app = new 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);
6050
+ const configuredRegistryPromise = buildConfiguredRegistry(config);
6051
+ this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
6052
+ this.#runtimeServerlessPromise = configuredRegistryPromise;
6053
+ this.#installSignalHandlers(config);
6054
+ this.#printWelcome(config, "serverless", {
6055
+ port,
6056
+ host: opts.host,
6057
+ publicDir
6058
+ });
6059
+ this.#ensureServerlessPoolConfigured(config);
6060
+ const { runtime, registry, serveConfig } = await configuredRegistryPromise;
6061
+ await runtime.serveListener(
6062
+ registry,
6063
+ { port, host: opts.host, publicDir },
6064
+ serveConfig
6065
+ );
6071
6066
  }
6072
6067
  /**
6073
6068
  * Returns a health response suitable for mounting in a user-owned router.
@@ -6313,6 +6308,10 @@ var Registry = class {
6313
6308
  /**
6314
6309
  * Starts the actor envoy for standalone server deployments.
6315
6310
  *
6311
+ * Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
6312
+ * via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
6313
+ * mutually exclusive per registry instance.
6314
+ *
6316
6315
  * @example
6317
6316
  * ```ts
6318
6317
  * const registry = setup({ use: { counter } });
@@ -6320,10 +6319,20 @@ var Registry = class {
6320
6319
  * ```
6321
6320
  */
6322
6321
  start() {
6322
+ if (getRivetkitRuntimeMode() === "serverless") {
6323
+ const publicDir = getRivetkitPublicDir() ?? "/public";
6324
+ this.listen({ publicDir }).catch((error) => {
6325
+ logger2().error({ error }, "auto-listen failed; exiting");
6326
+ if (typeof process !== "undefined" && typeof process.exit === "function") {
6327
+ process.exit(1);
6328
+ }
6329
+ });
6330
+ return;
6331
+ }
6323
6332
  const config = this.parseConfig();
6324
6333
  this.#startEnvoy(config, true);
6325
6334
  }
6326
- #printWelcome(config, kind) {
6335
+ #printWelcome(config, kind, listener) {
6327
6336
  if (config.noWelcome || this.#welcomePrinted) return;
6328
6337
  this.#welcomePrinted = true;
6329
6338
  const logLine = (label, value) => {
@@ -6345,6 +6354,13 @@ var Registry = class {
6345
6354
  logLine("Client", config.publicEndpoint);
6346
6355
  }
6347
6356
  logLine("Actors", Object.keys(config.use).length.toString());
6357
+ if (listener) {
6358
+ const host = listener.host ?? "0.0.0.0";
6359
+ logLine("Listening", `http://${host}:${listener.port}`);
6360
+ if (listener.publicDir) {
6361
+ logLine("Public Dir", listener.publicDir);
6362
+ }
6363
+ }
6348
6364
  console.log();
6349
6365
  }
6350
6366
  };