rivetkit 2.3.0-rc.5 → 2.3.0-rc.6

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 (113) hide show
  1. package/dist/browser/client.d.ts +21 -18
  2. package/dist/browser/client.js +735 -170
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +4 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -74
  9. package/dist/tsup/actor/errors.d.ts +1 -74
  10. package/dist/tsup/actor/errors.js +3 -1
  11. package/dist/tsup/agent-os/index.cjs +1 -1
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +18 -7
  14. package/dist/tsup/agent-os/index.d.ts +18 -7
  15. package/dist/tsup/agent-os/index.js +1 -1
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-2GANBXVP.cjs → chunk-2G64KSZQ.cjs} +10 -10
  18. package/dist/tsup/{chunk-2GANBXVP.cjs.map → chunk-2G64KSZQ.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-N2DQSJIW.js → chunk-6S25NVAP.js} +13 -46
  20. package/dist/tsup/chunk-6S25NVAP.js.map +1 -0
  21. package/dist/tsup/{chunk-NATOT3ET.js → chunk-CAF6JDJE.js} +4 -4
  22. package/dist/tsup/{chunk-PGYEMIOE.js → chunk-DEO7MMWQ.js} +2 -2
  23. package/dist/tsup/{chunk-SULB574D.js → chunk-EMO6E3PJ.js} +3 -3
  24. package/dist/tsup/{chunk-FTZIZ3JG.cjs → chunk-ENK7C66G.cjs} +838 -236
  25. package/dist/tsup/chunk-ENK7C66G.cjs.map +1 -0
  26. package/dist/tsup/{chunk-JY73X7VU.js → chunk-FLODVLYW.js} +690 -88
  27. package/dist/tsup/chunk-FLODVLYW.js.map +1 -0
  28. package/dist/tsup/{chunk-OVJX4IFY.cjs → chunk-HTR4YLNT.cjs} +4 -4
  29. package/dist/tsup/{chunk-OVJX4IFY.cjs.map → chunk-HTR4YLNT.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-LELRJK66.cjs → chunk-JALSAX7Z.cjs} +3 -3
  31. package/dist/tsup/{chunk-LELRJK66.cjs.map → chunk-JALSAX7Z.cjs.map} +1 -1
  32. package/dist/tsup/{chunk-JRCZDHXT.cjs → chunk-K5BA2LEO.cjs} +19 -52
  33. package/dist/tsup/chunk-K5BA2LEO.cjs.map +1 -0
  34. package/dist/tsup/{chunk-K34B3OVG.js → chunk-KIWH5H3K.js} +30 -9
  35. package/dist/tsup/chunk-KIWH5H3K.js.map +1 -0
  36. package/dist/tsup/{chunk-NW2J4SOL.cjs → chunk-LIXXFXVR.cjs} +5 -5
  37. package/dist/tsup/{chunk-NW2J4SOL.cjs.map → chunk-LIXXFXVR.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-HR547GVH.cjs → chunk-M5C7YNI5.cjs} +8 -8
  39. package/dist/tsup/{chunk-HR547GVH.cjs.map → chunk-M5C7YNI5.cjs.map} +1 -1
  40. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-QAZLM4WT.cjs} +31 -10
  41. package/dist/tsup/chunk-QAZLM4WT.cjs.map +1 -0
  42. package/dist/tsup/{chunk-LDTT6WKJ.js → chunk-RTC2AZGB.js} +2 -2
  43. package/dist/tsup/{chunk-UXTP4EBU.js → chunk-ZI5QJMKO.js} +2 -2
  44. package/dist/tsup/client/mod.cjs +7 -7
  45. package/dist/tsup/client/mod.d.cts +3 -4
  46. package/dist/tsup/client/mod.d.ts +3 -4
  47. package/dist/tsup/client/mod.js +6 -6
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{config-CvQUtDp9.d.ts → config-0Ta55UV0.d.ts} +10 -9
  53. package/dist/tsup/{config-C-a9vrke.d.cts → config-Ca8dN4cS.d.cts} +10 -9
  54. package/dist/tsup/{context-A7R0bsZL.d.ts → context-B_IWbWne.d.ts} +1 -1
  55. package/dist/tsup/{context-CA3r-pf2.d.cts → context-CUrQ9MHc.d.cts} +1 -1
  56. package/dist/tsup/inspector/mod.cjs +6 -6
  57. package/dist/tsup/inspector/mod.js +5 -5
  58. package/dist/tsup/mod.cjs +252 -207
  59. package/dist/tsup/mod.cjs.map +1 -1
  60. package/dist/tsup/mod.d.cts +4 -5
  61. package/dist/tsup/mod.d.ts +4 -5
  62. package/dist/tsup/mod.js +183 -138
  63. package/dist/tsup/mod.js.map +1 -1
  64. package/dist/tsup/test/mod.cjs +10 -10
  65. package/dist/tsup/test/mod.d.cts +2 -3
  66. package/dist/tsup/test/mod.d.ts +2 -3
  67. package/dist/tsup/test/mod.js +6 -6
  68. package/dist/tsup/utils-DVekpm4I.d.cts +103 -0
  69. package/dist/tsup/utils-DVekpm4I.d.ts +103 -0
  70. package/dist/tsup/utils.cjs +3 -3
  71. package/dist/tsup/utils.d.cts +1 -1
  72. package/dist/tsup/utils.d.ts +1 -1
  73. package/dist/tsup/utils.js +2 -2
  74. package/dist/tsup/workflow/mod.cjs +9 -9
  75. package/dist/tsup/workflow/mod.d.cts +4 -5
  76. package/dist/tsup/workflow/mod.d.ts +4 -5
  77. package/dist/tsup/workflow/mod.js +5 -5
  78. package/package.json +8 -8
  79. package/src/actor/errors.ts +53 -7
  80. package/src/client/actor-conn.ts +52 -29
  81. package/src/client/actor-handle.ts +57 -23
  82. package/src/client/errors.ts +2 -1
  83. package/src/client/raw-utils.ts +2 -4
  84. package/src/client/utils.ts +32 -3
  85. package/src/common/actor-router-consts.ts +4 -0
  86. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  87. package/src/common/client-protocol-versioned.ts +125 -18
  88. package/src/common/client-protocol-zod.ts +7 -0
  89. package/src/common/client-protocol.ts +1 -1
  90. package/src/common/database/native-database.test.ts +35 -0
  91. package/src/common/database/native-database.ts +8 -4
  92. package/src/common/router.ts +38 -8
  93. package/src/common/utils.ts +9 -52
  94. package/src/drivers/engine/actor-driver.ts +18 -17
  95. package/src/registry/config/index.ts +3 -5
  96. package/src/registry/index.ts +156 -19
  97. package/src/registry/napi-runtime.ts +44 -6
  98. package/src/registry/native.ts +5 -152
  99. package/src/registry/runtime.ts +16 -5
  100. package/src/registry/wasm-runtime.ts +22 -2
  101. package/dist/tsup/chunk-FTZIZ3JG.cjs.map +0 -1
  102. package/dist/tsup/chunk-JRCZDHXT.cjs.map +0 -1
  103. package/dist/tsup/chunk-JY73X7VU.js.map +0 -1
  104. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  105. package/dist/tsup/chunk-N2DQSJIW.js.map +0 -1
  106. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  107. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  108. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  109. /package/dist/tsup/{chunk-NATOT3ET.js.map → chunk-CAF6JDJE.js.map} +0 -0
  110. /package/dist/tsup/{chunk-PGYEMIOE.js.map → chunk-DEO7MMWQ.js.map} +0 -0
  111. /package/dist/tsup/{chunk-SULB574D.js.map → chunk-EMO6E3PJ.js.map} +0 -0
  112. /package/dist/tsup/{chunk-LDTT6WKJ.js.map → chunk-RTC2AZGB.js.map} +0 -0
  113. /package/dist/tsup/{chunk-UXTP4EBU.js.map → chunk-ZI5QJMKO.js.map} +0 -0
@@ -1,13 +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-C-a9vrke.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 ActorKey, t as ActorKv, u as ActorLogger, v as ActorOptions, w as ActorOptionsInput, x as ActorOptionsSchema, y as ActorQuery, z as ActorQueue, F as ActorSchedule, G as ActorTypes, H as ActorsSchema, I as AnyActorInstance, J as AnyClient, K as AnyConn, L as AnyStaticActorDefinition, N as AnyStaticActorInstance, O as AuthIntent, P as BaseActorInstance, T as CONN_DRIVER_SYMBOL, U as CONN_STATE_MANAGER_SYMBOL, V as Client, X as Conn, Y as DEFAULT_SLEEP_GRACE_PERIOD, Z as DocActorConfigSchema, _ as DocActorOptionsSchema, $ as DocConfigurePoolSchema, a0 as DocEnvoyConfigSchema, a1 as DocRegistryConfigSchema, a2 as DocServerlessConfigSchema, a3 as DocSqliteConfigSchema, a4 as Encoding, a5 as FetchHandler, a6 as GlobalActorOptions, a7 as GlobalActorOptionsInput, a8 as GlobalActorOptionsSchema, a9 as InspectorUnsubscribe, aa as InstanceActorOptions, ab as InstanceActorOptionsInput, ac as InstanceActorOptionsSchema, ad as QueueEnqueueAndWaitOptions, ae as QueueFilterName, af as QueueIterOptions, ag as QueueMessageOf, ah as QueueName, ai as QueueNextBatchOptions, aj as QueueNextOptions, ak as QueueResultMessageForName, al as QueueTryNextBatchOptions, am as QueueTryNextOptions, an as QueueWaitOptions, ao as RUN_FUNCTION_CONFIG_SYMBOL, ap as Registry, aq as RegistryActors, ar as RegistryConfig, as as RegistryConfigInput, at as RegistryConfigSchema, au as RegistryDiagnostics, av as RunConfig, aw as RunConfigSchema, ax as RunInspectorConfig, ay as RuntimeKind, az as RuntimeKindSchema, aA as ServerlessHandler, aB as SqliteBackend, aC as SqliteBackendSchema, aD as SqliteConfig, aE as SqliteConfigSchema, aF as TestConfig, aG as TestConfigSchema, aH as Type, aI as WasmRuntimeBindings, aJ as WasmRuntimeConfig, aK as WasmRuntimeConfigSchema, aL as WasmRuntimeInitInput, aM as WorkflowInspectorConfig, aN as actor, aO as buildActorNames, aP as createClientWithDriver, aQ as event, aR as getRunFunction, aS as getRunInspectorConfig, aT as getRunMetadata, aU as isStaticActorDefinition, aV as isStaticActorInstance, aW as lookupInRegistry, aX as queue, aY as setup, aZ as test } from './config-C-a9vrke.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-Ca8dN4cS.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 ActorKey, t as ActorKv, u as ActorLogger, v as ActorOptions, w as ActorOptionsInput, x as ActorOptionsSchema, y as ActorQuery, z as ActorQueue, F as ActorSchedule, G as ActorTypes, H as ActorsSchema, I as AnyActorInstance, J as AnyClient, K as AnyConn, L as AnyStaticActorDefinition, N as AnyStaticActorInstance, O as AuthIntent, P as BaseActorInstance, T as CONN_DRIVER_SYMBOL, U as CONN_STATE_MANAGER_SYMBOL, V as Client, X as Conn, Y as DEFAULT_SLEEP_GRACE_PERIOD, Z as DocActorConfigSchema, _ as DocActorOptionsSchema, $ as DocConfigurePoolSchema, a0 as DocEnvoyConfigSchema, a1 as DocRegistryConfigSchema, a2 as DocServerlessConfigSchema, a3 as DocSqliteConfigSchema, a4 as Encoding, a5 as FetchHandler, a6 as GlobalActorOptions, a7 as GlobalActorOptionsInput, a8 as GlobalActorOptionsSchema, a9 as InspectorUnsubscribe, aa as InstanceActorOptions, ab as InstanceActorOptionsInput, ac as InstanceActorOptionsSchema, ad as QueueEnqueueAndWaitOptions, ae as QueueFilterName, af as QueueIterOptions, ag as QueueMessageOf, ah as QueueName, ai as QueueNextBatchOptions, aj as QueueNextOptions, ak as QueueResultMessageForName, al as QueueTryNextBatchOptions, am as QueueTryNextOptions, an as QueueWaitOptions, ao as RUN_FUNCTION_CONFIG_SYMBOL, ap as Registry, aq as RegistryActors, ar as RegistryConfig, as as RegistryConfigInput, at as RegistryConfigSchema, au as RegistryRoutes, av as RunConfig, aw as RunConfigSchema, ax as RunInspectorConfig, ay as RuntimeKind, az as RuntimeKindSchema, aA as ServerlessHandler, aB as SqliteBackend, aC as SqliteBackendSchema, aD as SqliteConfig, aE as SqliteConfigSchema, aF as TestConfig, aG as TestConfigSchema, aH as Type, aI as WasmRuntimeBindings, aJ as WasmRuntimeConfig, aK as WasmRuntimeConfigSchema, aL as WasmRuntimeInitInput, aM as WorkflowInspectorConfig, aN as actor, aO as buildActorNames, aP as createClientWithDriver, aQ as event, aR as getRunFunction, aS as getRunInspectorConfig, aT as getRunMetadata, aU as isStaticActorDefinition, aV as isStaticActorInstance, aW as lookupInRegistry, aX as queue, aY as setup, aZ as test } from './config-Ca8dN4cS.cjs';
3
3
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
4
4
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
- export { ActorError, ActorError as RivetError, UserError, UserErrorOptions } from './actor/errors.cjs';
5
+ export { R as ActorError, R as RivetError, U as UserError, a as UserErrorOptions, n as noopNext } from './utils-DVekpm4I.cjs';
6
6
  import { A as AnyDatabaseProvider } from './config-CxjGYf4K.cjs';
7
7
  import { WSContext } from 'hono/ws';
8
- export { n as noopNext } from './utils-fwx3o3K9.cjs';
9
8
  export { toUint8Array } from './utils.cjs';
10
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-CA3r-pf2.cjs';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-CUrQ9MHc.cjs';
11
10
  import 'zod/v4';
12
11
  import '@rivetkit/rivetkit-wasm';
13
12
  import 'zod';
@@ -1,13 +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-CvQUtDp9.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 ActorKey, t as ActorKv, u as ActorLogger, v as ActorOptions, w as ActorOptionsInput, x as ActorOptionsSchema, y as ActorQuery, z as ActorQueue, F as ActorSchedule, G as ActorTypes, H as ActorsSchema, I as AnyActorInstance, J as AnyClient, K as AnyConn, L as AnyStaticActorDefinition, N as AnyStaticActorInstance, O as AuthIntent, P as BaseActorInstance, T as CONN_DRIVER_SYMBOL, U as CONN_STATE_MANAGER_SYMBOL, V as Client, X as Conn, Y as DEFAULT_SLEEP_GRACE_PERIOD, Z as DocActorConfigSchema, _ as DocActorOptionsSchema, $ as DocConfigurePoolSchema, a0 as DocEnvoyConfigSchema, a1 as DocRegistryConfigSchema, a2 as DocServerlessConfigSchema, a3 as DocSqliteConfigSchema, a4 as Encoding, a5 as FetchHandler, a6 as GlobalActorOptions, a7 as GlobalActorOptionsInput, a8 as GlobalActorOptionsSchema, a9 as InspectorUnsubscribe, aa as InstanceActorOptions, ab as InstanceActorOptionsInput, ac as InstanceActorOptionsSchema, ad as QueueEnqueueAndWaitOptions, ae as QueueFilterName, af as QueueIterOptions, ag as QueueMessageOf, ah as QueueName, ai as QueueNextBatchOptions, aj as QueueNextOptions, ak as QueueResultMessageForName, al as QueueTryNextBatchOptions, am as QueueTryNextOptions, an as QueueWaitOptions, ao as RUN_FUNCTION_CONFIG_SYMBOL, ap as Registry, aq as RegistryActors, ar as RegistryConfig, as as RegistryConfigInput, at as RegistryConfigSchema, au as RegistryDiagnostics, av as RunConfig, aw as RunConfigSchema, ax as RunInspectorConfig, ay as RuntimeKind, az as RuntimeKindSchema, aA as ServerlessHandler, aB as SqliteBackend, aC as SqliteBackendSchema, aD as SqliteConfig, aE as SqliteConfigSchema, aF as TestConfig, aG as TestConfigSchema, aH as Type, aI as WasmRuntimeBindings, aJ as WasmRuntimeConfig, aK as WasmRuntimeConfigSchema, aL as WasmRuntimeInitInput, aM as WorkflowInspectorConfig, aN as actor, aO as buildActorNames, aP as createClientWithDriver, aQ as event, aR as getRunFunction, aS as getRunInspectorConfig, aT as getRunMetadata, aU as isStaticActorDefinition, aV as isStaticActorInstance, aW as lookupInRegistry, aX as queue, aY as setup, aZ as test } from './config-CvQUtDp9.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-0Ta55UV0.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 ActorKey, t as ActorKv, u as ActorLogger, v as ActorOptions, w as ActorOptionsInput, x as ActorOptionsSchema, y as ActorQuery, z as ActorQueue, F as ActorSchedule, G as ActorTypes, H as ActorsSchema, I as AnyActorInstance, J as AnyClient, K as AnyConn, L as AnyStaticActorDefinition, N as AnyStaticActorInstance, O as AuthIntent, P as BaseActorInstance, T as CONN_DRIVER_SYMBOL, U as CONN_STATE_MANAGER_SYMBOL, V as Client, X as Conn, Y as DEFAULT_SLEEP_GRACE_PERIOD, Z as DocActorConfigSchema, _ as DocActorOptionsSchema, $ as DocConfigurePoolSchema, a0 as DocEnvoyConfigSchema, a1 as DocRegistryConfigSchema, a2 as DocServerlessConfigSchema, a3 as DocSqliteConfigSchema, a4 as Encoding, a5 as FetchHandler, a6 as GlobalActorOptions, a7 as GlobalActorOptionsInput, a8 as GlobalActorOptionsSchema, a9 as InspectorUnsubscribe, aa as InstanceActorOptions, ab as InstanceActorOptionsInput, ac as InstanceActorOptionsSchema, ad as QueueEnqueueAndWaitOptions, ae as QueueFilterName, af as QueueIterOptions, ag as QueueMessageOf, ah as QueueName, ai as QueueNextBatchOptions, aj as QueueNextOptions, ak as QueueResultMessageForName, al as QueueTryNextBatchOptions, am as QueueTryNextOptions, an as QueueWaitOptions, ao as RUN_FUNCTION_CONFIG_SYMBOL, ap as Registry, aq as RegistryActors, ar as RegistryConfig, as as RegistryConfigInput, at as RegistryConfigSchema, au as RegistryRoutes, av as RunConfig, aw as RunConfigSchema, ax as RunInspectorConfig, ay as RuntimeKind, az as RuntimeKindSchema, aA as ServerlessHandler, aB as SqliteBackend, aC as SqliteBackendSchema, aD as SqliteConfig, aE as SqliteConfigSchema, aF as TestConfig, aG as TestConfigSchema, aH as Type, aI as WasmRuntimeBindings, aJ as WasmRuntimeConfig, aK as WasmRuntimeConfigSchema, aL as WasmRuntimeInitInput, aM as WorkflowInspectorConfig, aN as actor, aO as buildActorNames, aP as createClientWithDriver, aQ as event, aR as getRunFunction, aS as getRunInspectorConfig, aT as getRunMetadata, aU as isStaticActorDefinition, aV as isStaticActorInstance, aW as lookupInRegistry, aX as queue, aY as setup, aZ as test } from './config-0Ta55UV0.js';
3
3
  import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
4
4
  export { RivetCloseEvent, RivetEvent, RivetMessageEvent, UniversalWebSocket } from '@rivetkit/virtual-websocket';
5
- export { ActorError, ActorError as RivetError, UserError, UserErrorOptions } from './actor/errors.js';
5
+ export { R as ActorError, R as RivetError, U as UserError, a as UserErrorOptions, n as noopNext } from './utils-DVekpm4I.js';
6
6
  import { A as AnyDatabaseProvider } from './config-CxjGYf4K.js';
7
7
  import { WSContext } from 'hono/ws';
8
- export { n as noopNext } from './utils-fwx3o3K9.js';
9
8
  export { toUint8Array } from './utils.js';
10
- export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-A7R0bsZL.js';
9
+ export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from './context-B_IWbWne.js';
11
10
  import 'zod/v4';
12
11
  import '@rivetkit/rivetkit-wasm';
13
12
  import 'zod';
package/dist/tsup/mod.js CHANGED
@@ -8,21 +8,17 @@ import {
8
8
  } from "./chunk-T6YVRM4K.js";
9
9
  import {
10
10
  decodeWorkflowHistoryTransport
11
- } from "./chunk-PGYEMIOE.js";
11
+ } from "./chunk-DEO7MMWQ.js";
12
12
  import {
13
13
  ALLOWED_PUBLIC_HEADERS,
14
- CURRENT_VERSION,
15
14
  HEADER_CONN_PARAMS,
16
- HEADER_ENCODING,
17
- HTTP_RESPONSE_ERROR_VERSIONED,
18
- HttpResponseErrorSchema,
19
15
  RemoteEngineControlClient,
20
16
  convertRegistryConfigToClientConfig,
21
17
  createClientWithDriver,
22
18
  getDatacenters,
23
19
  tryParseEndpoint,
24
20
  updateRunnerConfig
25
- } from "./chunk-JY73X7VU.js";
21
+ } from "./chunk-FLODVLYW.js";
26
22
  import {
27
23
  KEYS,
28
24
  makePrefixedKey,
@@ -32,14 +28,12 @@ import {
32
28
  workflowStoragePrefix
33
29
  } from "./chunk-3YY5S6TV.js";
34
30
  import {
35
- contentTypeForEncoding,
36
31
  decodeCborCompat,
37
32
  decodeCborJsonCompat,
38
- encodeCborCompat,
39
- serializeWithEncoding
40
- } from "./chunk-LDTT6WKJ.js";
33
+ encodeCborCompat
34
+ } from "./chunk-RTC2AZGB.js";
41
35
  import "./chunk-PCBNKI2J.js";
42
- import "./chunk-UXTP4EBU.js";
36
+ import "./chunk-ZI5QJMKO.js";
43
37
  import {
44
38
  LogLevelSchema,
45
39
  VERSION,
@@ -63,7 +57,7 @@ import {
63
57
  noopNext,
64
58
  stringifyError,
65
59
  toUint8Array
66
- } from "./chunk-N2DQSJIW.js";
60
+ } from "./chunk-6S25NVAP.js";
67
61
  import {
68
62
  INTERNAL_ERROR_CODE,
69
63
  RivetError,
@@ -74,7 +68,7 @@ import {
74
68
  isRivetErrorLike,
75
69
  toRivetError,
76
70
  unsupportedFeature
77
- } from "./chunk-K34B3OVG.js";
71
+ } from "./chunk-KIWH5H3K.js";
78
72
 
79
73
  // src/actor/log.ts
80
74
  function loggerWithoutContext() {
@@ -706,12 +700,12 @@ var RegistryConfigSchema = z3.object({
706
700
  shutdown: z3.object({
707
701
  /**
708
702
  * Wait this many milliseconds for the serve promise to resolve
709
- * after calling `CoreRegistry::shutdown()`. Defaults to 30s,
710
- * matching Kubernetes `terminationGracePeriodSeconds`.
703
+ * after calling `CoreRegistry::shutdown()`. Defaults to the
704
+ * engine-provided actor stop threshold once the envoy connects.
711
705
  *
712
706
  * Must be >= rivetkit-core's drain timeout (20s) + margin.
713
707
  */
714
- gracePeriodMs: z3.number().int().min(1e3).optional().default(3e4),
708
+ gracePeriodMs: z3.number().int().min(1e3).optional(),
715
709
  /**
716
710
  * If true, rivetkit will not install SIGINT/SIGTERM handlers.
717
711
  * Use when the host application owns signal policy and will
@@ -719,7 +713,6 @@ var RegistryConfigSchema = z3.object({
719
713
  */
720
714
  disableSignalHandlers: z3.boolean().optional().default(false)
721
715
  }).optional().default(() => ({
722
- gracePeriodMs: 3e4,
723
716
  disableSignalHandlers: false
724
717
  }))
725
718
  }).transform((config, ctx) => {
@@ -930,7 +923,8 @@ function shouldAttachNativeKvError(message) {
930
923
  }
931
924
  function enrichNativeDatabaseError(database, error) {
932
925
  var _a;
933
- const bridged = typeof error === "string" ? decodeBridgeRivetError(error) : error instanceof Error ? decodeBridgeRivetError(error.message) : void 0;
926
+ const bridgeReason = typeof error === "string" ? error : error instanceof Error ? error.message : void 0;
927
+ const bridged = bridgeReason === void 0 ? void 0 : decodeBridgeRivetError(bridgeReason);
934
928
  if (bridged) {
935
929
  throw bridged;
936
930
  }
@@ -1280,11 +1274,31 @@ var NapiCoreRuntime = class {
1280
1274
  async shutdownRegistry(registry) {
1281
1275
  await asNativeRegistry(registry).shutdown();
1282
1276
  }
1283
- async registryDiagnostics(registry) {
1284
- const diagnostics = await asNativeRegistry(registry).diagnostics();
1277
+ async registryActorStopThresholdMs(registry) {
1278
+ return await asNativeRegistry(registry).actorStopThresholdMs() ?? void 0;
1279
+ }
1280
+ async registryHealth(registry) {
1281
+ const response = await asNativeRegistry(registry).health();
1282
+ return {
1283
+ status: response.status,
1284
+ headers: response.headers,
1285
+ body: response.body
1286
+ };
1287
+ }
1288
+ async registryMetadata(registry) {
1289
+ const response = asNativeRegistry(registry).metadata();
1290
+ return {
1291
+ status: response.status,
1292
+ headers: response.headers,
1293
+ body: response.body
1294
+ };
1295
+ }
1296
+ async registryMetrics(registry) {
1297
+ const response = asNativeRegistry(registry).metrics();
1285
1298
  return {
1286
- mode: diagnostics.mode,
1287
- envoyActiveActorCount: diagnostics.envoyActiveActorCount
1299
+ status: response.status,
1300
+ headers: response.headers,
1301
+ body: response.body
1288
1302
  };
1289
1303
  }
1290
1304
  async handleServerlessRequest(registry, req, onStreamEvent, cancelToken, config) {
@@ -1407,6 +1421,9 @@ var NapiCoreRuntime = class {
1407
1421
  actorWaitUntil(ctx, promise) {
1408
1422
  asNativeActorContext(ctx).waitUntil(promise);
1409
1423
  }
1424
+ async actorWaitForTrackedShutdownWork(ctx) {
1425
+ return await asNativeActorContext(ctx).waitForTrackedShutdownWork();
1426
+ }
1410
1427
  actorKeepAwake(ctx, promise) {
1411
1428
  asNativeActorContext(ctx).keepAwake(promise);
1412
1429
  }
@@ -1824,8 +1841,18 @@ var WasmCoreRuntime = class {
1824
1841
  async shutdownRegistry(registry) {
1825
1842
  await callWasm(() => asWasmRegistry(registry).shutdown());
1826
1843
  }
1827
- async registryDiagnostics() {
1828
- return { mode: "wasm", envoyActiveActorCount: null };
1844
+ async registryHealth() {
1845
+ return {
1846
+ status: 200,
1847
+ headers: { "content-type": "application/json" },
1848
+ body: new TextEncoder().encode(
1849
+ JSON.stringify({
1850
+ status: "ok",
1851
+ runtime: "rivetkit",
1852
+ version: "wasm"
1853
+ })
1854
+ )
1855
+ };
1829
1856
  }
1830
1857
  async handleServerlessRequest(registry, req, onStreamEvent, cancelToken, config) {
1831
1858
  return await callHandleAsync(
@@ -1974,6 +2001,12 @@ var WasmCoreRuntime = class {
1974
2001
  actorWaitUntil(ctx, promise) {
1975
2002
  callHandle(asWasmActorContext(ctx), "waitUntil", promise);
1976
2003
  }
2004
+ async actorWaitForTrackedShutdownWork(ctx) {
2005
+ return await callHandle(
2006
+ asWasmActorContext(ctx),
2007
+ "waitForTrackedShutdownWork"
2008
+ );
2009
+ }
1977
2010
  actorKeepAwake(ctx, promise) {
1978
2011
  const wasmCtx = asWasmActorContext(ctx);
1979
2012
  const regionId = callHandle(wasmCtx, "beginKeepAwake");
@@ -2420,20 +2453,11 @@ function clearNativeRuntimeState(runtime, ctx) {
2420
2453
  callNativeSync(() => runtime.actorClearRuntimeState(ctx));
2421
2454
  }
2422
2455
  async function cleanupNativeSleepRuntimeState(runtime, ctx) {
2456
+ await runtime.actorWaitForTrackedShutdownWork(ctx);
2423
2457
  await closeNativeDatabaseClient(runtime, ctx);
2424
2458
  await closeNativeSqlDatabase(runtime, ctx);
2425
2459
  clearNativeRuntimeState(runtime, ctx);
2426
2460
  }
2427
- async function cleanupDeferredNativeSleepRuntimeState(runtime, ctx, runtimeState) {
2428
- runtimeState.deferSleepCleanupUntilKeepAwakeIdle = false;
2429
- const actorCtx = runtimeState.deferredSleepCleanupActorCtx;
2430
- runtimeState.deferredSleepCleanupActorCtx = void 0;
2431
- try {
2432
- await cleanupNativeSleepRuntimeState(runtime, ctx);
2433
- } finally {
2434
- await (actorCtx == null ? void 0 : actorCtx.dispose());
2435
- }
2436
- }
2437
2461
  function closeNativeSqlDatabase(runtime, ctx) {
2438
2462
  const runtimeState = getNativeRuntimeState(runtime, ctx);
2439
2463
  const database = runtimeState.sql;
@@ -2570,27 +2594,7 @@ function isStructuredBridgeError(error) {
2570
2594
  return isRivetErrorLike(error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
2571
2595
  }
2572
2596
  function encodeNativeCallbackError(error) {
2573
- const structuredError = isStructuredBridgeError(error) ? error : deconstructError(error, logger2(), {
2574
- bridge: "native_callback"
2575
- });
2576
- let stack;
2577
- if (error instanceof Error) {
2578
- try {
2579
- stack = error.stack;
2580
- } catch {
2581
- stack = void 0;
2582
- }
2583
- }
2584
- logger2().warn({
2585
- msg: "native callback error encoded for bridge",
2586
- group: structuredError.group,
2587
- code: structuredError.code,
2588
- message: structuredError.message,
2589
- metadata: structuredError.metadata,
2590
- originalError: stringifyError(error),
2591
- stack,
2592
- bridge: "native_callback"
2593
- });
2597
+ const structuredError = isStructuredBridgeError(error) ? error : deconstructError(error, true);
2594
2598
  const bridgeError = new Error(encodeBridgeRivetError(structuredError), {
2595
2599
  cause: error instanceof Error ? error : void 0
2596
2600
  });
@@ -4119,40 +4123,17 @@ var ActorContextHandleAdapter = class {
4119
4123
  });
4120
4124
  }
4121
4125
  keepAwake(promise) {
4122
- const runtimeState = getNativeRuntimeState(this.#runtime, this.#ctx);
4123
- runtimeState.keepAwakeCount = (runtimeState.keepAwakeCount ?? 0) + 1;
4124
- let registered = false;
4125
4126
  const trackedPromise = Promise.resolve(promise).catch((error) => {
4126
4127
  logger2().warn({
4127
4128
  msg: "keepAwake promise rejected",
4128
4129
  error: stringifyError(error)
4129
4130
  });
4130
- }).finally(async () => {
4131
- if (!registered) {
4132
- return;
4133
- }
4134
- runtimeState.keepAwakeCount = Math.max(
4135
- (runtimeState.keepAwakeCount ?? 1) - 1,
4136
- 0
4137
- );
4138
- if (runtimeState.keepAwakeCount === 0 && runtimeState.deferSleepCleanupUntilKeepAwakeIdle) {
4139
- await cleanupDeferredNativeSleepRuntimeState(
4140
- this.#runtime,
4141
- this.#ctx,
4142
- runtimeState
4143
- );
4144
- }
4145
4131
  }).then(() => null);
4146
4132
  try {
4147
4133
  callNativeSync(
4148
4134
  () => this.#runtime.actorKeepAwake(this.#ctx, trackedPromise)
4149
4135
  );
4150
- registered = true;
4151
4136
  } catch (error) {
4152
- runtimeState.keepAwakeCount = Math.max(
4153
- (runtimeState.keepAwakeCount ?? 1) - 1,
4154
- 0
4155
- );
4156
4137
  if (!isClosedTaskRegistrationError(error)) {
4157
4138
  throw error;
4158
4139
  }
@@ -4459,39 +4440,6 @@ function withConnContext(runtime, ctx, conn, clientFactory, schemas = {}, databa
4459
4440
  }
4460
4441
  );
4461
4442
  }
4462
- function buildNativeRequestErrorResponse(encoding, path, error) {
4463
- const { statusCode, group, code, message, metadata } = deconstructError(
4464
- error,
4465
- logger2(),
4466
- {
4467
- path,
4468
- runtime: "native"
4469
- },
4470
- false
4471
- );
4472
- const body = serializeWithEncoding(
4473
- encoding,
4474
- { group, code, message, metadata },
4475
- HTTP_RESPONSE_ERROR_VERSIONED,
4476
- CURRENT_VERSION,
4477
- HttpResponseErrorSchema,
4478
- (value) => value,
4479
- (value) => ({
4480
- group: value.group,
4481
- code: value.code,
4482
- message: value.message,
4483
- metadata: value.metadata === void 0 ? null : runtimeBytesToArrayBuffer(
4484
- encodeCborCompat(value.metadata)
4485
- )
4486
- })
4487
- );
4488
- return new Response(body, {
4489
- status: statusCode,
4490
- headers: {
4491
- "Content-Type": contentTypeForEncoding(encoding)
4492
- }
4493
- });
4494
- }
4495
4443
  function buildActorConfig(definition, registryConfig) {
4496
4444
  const config = definition.config;
4497
4445
  const options = config.options ?? {};
@@ -5014,12 +4962,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5014
4962
  }
5015
4963
  }
5016
4964
  } finally {
5017
- const runtimeState = getNativeRuntimeState(runtime, ctx);
5018
- if ((runtimeState.keepAwakeCount ?? 0) > 0) {
5019
- runtimeState.deferSleepCleanupUntilKeepAwakeIdle = true;
5020
- runtimeState.deferredSleepCleanupActorCtx = actorCtx;
5021
- } else {
4965
+ try {
5022
4966
  await cleanupNativeSleepRuntimeState(runtime, ctx);
4967
+ } finally {
5023
4968
  await actorCtx.dispose();
5024
4969
  }
5025
4970
  }
@@ -5260,17 +5205,6 @@ function buildNativeFactory(runtime, registryConfig, definition) {
5260
5205
  );
5261
5206
  }
5262
5207
  return await toRuntimeHttpResponse(response);
5263
- } catch (error2) {
5264
- const encodingHeader = jsRequest.headers.get(HEADER_ENCODING);
5265
- const encoding = encodingHeader === "cbor" || encodingHeader === "bare" ? encodingHeader : "json";
5266
- const path = new URL(jsRequest.url).pathname;
5267
- return await toRuntimeHttpResponse(
5268
- buildNativeRequestErrorResponse(
5269
- encoding,
5270
- path,
5271
- error2
5272
- )
5273
- );
5274
5208
  } finally {
5275
5209
  await (requestCtx == null ? void 0 : requestCtx.dispose());
5276
5210
  if (conn) {
@@ -5511,8 +5445,23 @@ async function buildConfiguredRegistry(config) {
5511
5445
  }
5512
5446
 
5513
5447
  // src/registry/index.ts
5448
+ function signalExitCode(signal) {
5449
+ switch (signal) {
5450
+ case "SIGINT":
5451
+ return 130;
5452
+ case "SIGTERM":
5453
+ return 143;
5454
+ }
5455
+ }
5456
+ function finishShutdownSignal(signal) {
5457
+ if (process.pid === 1) {
5458
+ process.exit(signalExitCode(signal));
5459
+ }
5460
+ process.kill(process.pid, signal);
5461
+ }
5514
5462
  var Registry = class {
5515
5463
  #config;
5464
+ routes;
5516
5465
  get config() {
5517
5466
  return this.#config;
5518
5467
  }
@@ -5529,6 +5478,11 @@ var Registry = class {
5529
5478
  #signalHandlers = {};
5530
5479
  constructor(config) {
5531
5480
  this.#config = config;
5481
+ this.routes = {
5482
+ health: () => this.#healthRoute(),
5483
+ metadata: () => this.#metadataRoute(),
5484
+ prometheusMetrics: (request) => this.#prometheusMetricsRoute(request)
5485
+ };
5532
5486
  }
5533
5487
  #ensureServerlessPoolConfigured(config) {
5534
5488
  if (!config.configurePool) return void 0;
@@ -5721,20 +5675,89 @@ var Registry = class {
5721
5675
  fetch: (request) => this.handler(request)
5722
5676
  };
5723
5677
  }
5724
- async diagnostics() {
5725
- var _a;
5678
+ /**
5679
+ * Returns a health response suitable for mounting in a user-owned router.
5680
+ */
5681
+ async #healthRoute() {
5682
+ const configured = await this.#activeConfiguredRegistry();
5683
+ if (!configured) {
5684
+ return jsonRouteResponse(503, {
5685
+ status: "not_started",
5686
+ runtime: "rivetkit",
5687
+ version: VERSION
5688
+ });
5689
+ }
5690
+ const { runtime, registry } = configured;
5691
+ if (!runtime.registryHealth) {
5692
+ return jsonRouteResponse(501, {
5693
+ status: "unsupported",
5694
+ runtime: "rivetkit",
5695
+ version: VERSION
5696
+ });
5697
+ }
5698
+ const response = await runtime.registryHealth(registry);
5699
+ return new Response(new Uint8Array(response.body), {
5700
+ status: response.status,
5701
+ headers: response.headers
5702
+ });
5703
+ }
5704
+ /**
5705
+ * Returns serverless metadata suitable for mounting in a user-owned router.
5706
+ */
5707
+ async #metadataRoute() {
5708
+ const configured = await this.#activeConfiguredRegistry();
5709
+ if (!configured) {
5710
+ return new Response("registry not started\n", {
5711
+ status: 503,
5712
+ headers: { "content-type": "text/plain; charset=utf-8" }
5713
+ });
5714
+ }
5715
+ const { runtime, registry } = configured;
5716
+ if (!runtime.registryMetadata) {
5717
+ return new Response("metadata is not supported by this runtime\n", {
5718
+ status: 501,
5719
+ headers: { "content-type": "text/plain; charset=utf-8" }
5720
+ });
5721
+ }
5722
+ const response = await runtime.registryMetadata(registry);
5723
+ return new Response(new Uint8Array(response.body), {
5724
+ status: response.status,
5725
+ headers: response.headers
5726
+ });
5727
+ }
5728
+ /**
5729
+ * Returns a Prometheus metrics response suitable for mounting in a user-owned router.
5730
+ */
5731
+ async #prometheusMetricsRoute(_request) {
5732
+ const configured = await this.#activeConfiguredRegistry();
5733
+ if (!configured) {
5734
+ return new Response("registry not started\n", {
5735
+ status: 503,
5736
+ headers: { "content-type": "text/plain; charset=utf-8" }
5737
+ });
5738
+ }
5739
+ const { runtime, registry } = configured;
5740
+ if (!runtime.registryMetrics) {
5741
+ return new Response("metrics are not supported by this runtime\n", {
5742
+ status: 501,
5743
+ headers: { "content-type": "text/plain; charset=utf-8" }
5744
+ });
5745
+ }
5746
+ const response = await runtime.registryMetrics(registry);
5747
+ return new Response(new Uint8Array(response.body), {
5748
+ status: response.status,
5749
+ headers: response.headers
5750
+ });
5751
+ }
5752
+ async #activeConfiguredRegistry() {
5726
5753
  const candidates = [
5727
5754
  this.#runtimeServerlessPromise,
5728
5755
  this.#runtimeServeConfiguredPromise
5729
5756
  ].filter(
5730
5757
  (candidate) => candidate !== void 0
5731
5758
  );
5732
- for (const candidate of candidates) {
5733
- const { runtime, registry } = await candidate;
5734
- const diagnostics = await ((_a = runtime.registryDiagnostics) == null ? void 0 : _a.call(runtime, registry));
5735
- if (diagnostics) return diagnostics;
5736
- }
5737
- return { mode: "not_started", envoyActiveActorCount: null };
5759
+ if (candidates.length === 0) return void 0;
5760
+ return await candidates[0];
5738
5761
  }
5739
5762
  /**
5740
5763
  * Starts an actor envoy for standalone server deployments.
@@ -5777,7 +5800,7 @@ var Registry = class {
5777
5800
  #onShutdownSignal(signal, config, configuredRegistryPromise) {
5778
5801
  if (this.#shutdownInFlight !== null) {
5779
5802
  this.#removeSignalHandlers();
5780
- process.kill(process.pid, signal);
5803
+ finishShutdownSignal(signal);
5781
5804
  return;
5782
5805
  }
5783
5806
  this.#shutdownInFlight = this.#runShutdown(
@@ -5790,7 +5813,7 @@ var Registry = class {
5790
5813
  }
5791
5814
  async #runShutdown(signal, config, configuredRegistryPromise) {
5792
5815
  var _a;
5793
- const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? 3e4;
5816
+ const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? await this.#actorStopThresholdMs(configuredRegistryPromise) ?? 30 * 60 * 1e3;
5794
5817
  const drain = async () => {
5795
5818
  const registries = [
5796
5819
  (async () => {
@@ -5837,7 +5860,23 @@ var Registry = class {
5837
5860
  )
5838
5861
  ]);
5839
5862
  this.#removeSignalHandlers();
5840
- process.kill(process.pid, signal);
5863
+ finishShutdownSignal(signal);
5864
+ }
5865
+ async #actorStopThresholdMs(configuredRegistryPromise) {
5866
+ var _a;
5867
+ try {
5868
+ const { runtime, registry } = await configuredRegistryPromise;
5869
+ const thresholdMs = await ((_a = runtime.registryActorStopThresholdMs) == null ? void 0 : _a.call(runtime, registry));
5870
+ if (thresholdMs !== void 0 && Number.isFinite(thresholdMs) && thresholdMs > 0) {
5871
+ return thresholdMs;
5872
+ }
5873
+ } catch (err) {
5874
+ logger2().warn(
5875
+ { err },
5876
+ "failed to read actor stop threshold for shutdown grace"
5877
+ );
5878
+ }
5879
+ return void 0;
5841
5880
  }
5842
5881
  #removeSignalHandlers() {
5843
5882
  for (const [signal, handler] of Object.entries(
@@ -5900,6 +5939,12 @@ function isServerlessMetadataRequest(request, basePath) {
5900
5939
  const normalizedBase = basePath === "/" ? "" : `/${basePath.replace(/^\/+|\/+$/g, "")}`;
5901
5940
  return parsed.pathname === `${normalizedBase}/metadata`;
5902
5941
  }
5942
+ function jsonRouteResponse(status, body) {
5943
+ return new Response(JSON.stringify(body), {
5944
+ status,
5945
+ headers: { "content-type": "application/json" }
5946
+ });
5947
+ }
5903
5948
  function setup(input) {
5904
5949
  return new Registry(input);
5905
5950
  }