rivetkit 0.0.0-active-actors-fix-active-count.253e406 → 0.0.0-bisect-sync-sqlite-1.910d1c7

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 (303) hide show
  1. package/dist/browser/client.d.ts +1286 -89
  2. package/dist/browser/client.js +1699 -704
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2083 -236
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +8 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -1
  10. package/dist/tsup/actor/errors.d.ts +1 -1
  11. package/dist/tsup/actor/errors.js +7 -1
  12. package/dist/tsup/agent-os/index.cjs +3 -2289
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +1 -1813
  15. package/dist/tsup/agent-os/index.d.ts +1 -1813
  16. package/dist/tsup/agent-os/index.js +3 -2289
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
  19. package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
  20. package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
  21. package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
  22. package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
  23. package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
  24. package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
  25. package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
  26. package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
  27. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
  28. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  29. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
  30. package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
  31. package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
  32. package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
  33. package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
  34. package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
  35. package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
  36. package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
  37. package/dist/tsup/chunk-HYIVSH5X.js +244 -0
  38. package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
  39. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
  40. package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
  41. package/dist/tsup/chunk-IWACVNN5.js +14 -0
  42. package/dist/tsup/chunk-IWACVNN5.js.map +1 -0
  43. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  44. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  45. package/dist/tsup/{chunk-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
  46. package/dist/tsup/chunk-K3AJOPSF.js.map +1 -0
  47. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  48. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  49. package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
  50. package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
  51. package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
  52. package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
  53. package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
  54. package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
  55. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
  56. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  57. package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
  58. package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
  59. package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
  60. package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
  61. package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
  62. package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
  63. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
  64. package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +33 -7
  68. package/dist/tsup/client/mod.d.ts +33 -7
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.js +3 -3
  77. package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
  78. package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
  79. package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
  80. package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
  81. package/dist/tsup/context-hyVakgnU.d.ts +136 -0
  82. package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
  83. package/dist/tsup/db/drizzle.cjs +127 -67
  84. package/dist/tsup/db/drizzle.cjs.map +1 -1
  85. package/dist/tsup/db/drizzle.d.cts +8 -4
  86. package/dist/tsup/db/drizzle.d.ts +8 -4
  87. package/dist/tsup/db/drizzle.js +127 -67
  88. package/dist/tsup/db/drizzle.js.map +1 -1
  89. package/dist/tsup/db/mod.cjs +6 -124
  90. package/dist/tsup/db/mod.cjs.map +1 -1
  91. package/dist/tsup/db/mod.d.cts +12 -4
  92. package/dist/tsup/db/mod.d.ts +12 -4
  93. package/dist/tsup/db/mod.js +5 -123
  94. package/dist/tsup/db/mod.js.map +1 -1
  95. package/dist/tsup/dynamic/mod.cjs +24 -0
  96. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  97. package/dist/tsup/dynamic/mod.d.cts +39 -0
  98. package/dist/tsup/dynamic/mod.d.ts +39 -0
  99. package/dist/tsup/dynamic/mod.js +24 -0
  100. package/dist/tsup/dynamic/mod.js.map +1 -0
  101. package/dist/tsup/inspector/mod.cjs +47 -12
  102. package/dist/tsup/inspector/mod.cjs.map +1 -1
  103. package/dist/tsup/inspector/mod.d.cts +26 -136
  104. package/dist/tsup/inspector/mod.d.ts +26 -136
  105. package/dist/tsup/inspector/mod.js +46 -11
  106. package/dist/tsup/inspector/mod.js.map +1 -1
  107. package/dist/tsup/inspector/workflow.cjs +21 -0
  108. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  109. package/dist/tsup/inspector/workflow.d.cts +144 -0
  110. package/dist/tsup/inspector/workflow.d.ts +144 -0
  111. package/dist/tsup/inspector/workflow.js +21 -0
  112. package/dist/tsup/inspector/workflow.js.map +1 -0
  113. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  114. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  115. package/dist/tsup/inspector-tab/mod.d.cts +242 -0
  116. package/dist/tsup/inspector-tab/mod.d.ts +242 -0
  117. package/dist/tsup/inspector-tab/mod.js +162 -0
  118. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  119. package/dist/tsup/mod.cjs +3527 -753
  120. package/dist/tsup/mod.cjs.map +1 -1
  121. package/dist/tsup/mod.d.cts +11 -7
  122. package/dist/tsup/mod.d.ts +11 -7
  123. package/dist/tsup/mod.js +3468 -694
  124. package/dist/tsup/mod.js.map +1 -1
  125. package/dist/tsup/test/mod.cjs +26 -21
  126. package/dist/tsup/test/mod.cjs.map +1 -1
  127. package/dist/tsup/test/mod.d.cts +7 -5
  128. package/dist/tsup/test/mod.d.ts +7 -5
  129. package/dist/tsup/test/mod.js +25 -20
  130. package/dist/tsup/test/mod.js.map +1 -1
  131. package/dist/tsup/unstable/migrations.cjs +101 -0
  132. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  133. package/dist/tsup/unstable/migrations.d.cts +29 -0
  134. package/dist/tsup/unstable/migrations.d.ts +29 -0
  135. package/dist/tsup/unstable/migrations.js +101 -0
  136. package/dist/tsup/unstable/migrations.js.map +1 -0
  137. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
  138. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
  139. package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
  140. package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
  141. package/dist/tsup/utils.cjs +7 -3
  142. package/dist/tsup/utils.cjs.map +1 -1
  143. package/dist/tsup/utils.d.cts +4 -147
  144. package/dist/tsup/utils.d.ts +4 -147
  145. package/dist/tsup/utils.js +6 -2
  146. package/dist/tsup/workflow/mod.cjs +557 -410
  147. package/dist/tsup/workflow/mod.cjs.map +1 -1
  148. package/dist/tsup/workflow/mod.d.cts +11 -9
  149. package/dist/tsup/workflow/mod.d.ts +11 -9
  150. package/dist/tsup/workflow/mod.js +551 -404
  151. package/dist/tsup/workflow/mod.js.map +1 -1
  152. package/package.json +67 -18
  153. package/src/actor/actions.ts +155 -0
  154. package/src/actor/config.ts +679 -101
  155. package/src/actor/contexts/index.ts +9 -2
  156. package/src/actor/definition.ts +75 -26
  157. package/src/actor/errors.ts +107 -8
  158. package/src/actor/keys.ts +87 -1
  159. package/src/actor/mod.ts +36 -20
  160. package/src/actor/schema.ts +6 -2
  161. package/src/actor/tracing.ts +28 -0
  162. package/src/agent-os/index.ts +5 -64
  163. package/src/client/actor-common.ts +84 -54
  164. package/src/client/actor-conn.ts +231 -68
  165. package/src/client/actor-handle.ts +283 -89
  166. package/src/client/actor-query.ts +13 -6
  167. package/src/client/auth.ts +37 -0
  168. package/src/client/client.ts +182 -21
  169. package/src/client/config.ts +28 -3
  170. package/src/client/errors.ts +15 -2
  171. package/src/client/lifecycle-errors.ts +63 -5
  172. package/src/client/mod.ts +10 -0
  173. package/src/client/outbound-telemetry.ts +66 -0
  174. package/src/client/query.ts +3 -1
  175. package/src/client/queue.ts +13 -3
  176. package/src/client/raw-utils.ts +59 -14
  177. package/src/client/resolve-gateway-target.ts +3 -1
  178. package/src/client/retry-budget.ts +81 -0
  179. package/src/client/token-provider.ts +93 -0
  180. package/src/client/utils.ts +22 -9
  181. package/src/common/actor-router-consts.ts +6 -0
  182. package/src/common/actor-telemetry-context.ts +19 -0
  183. package/src/common/actor-websocket.ts +3 -1
  184. package/src/common/bare/actor-persist/v1.ts +205 -163
  185. package/src/common/bare/actor-persist/v2.ts +265 -213
  186. package/src/common/bare/actor-persist/v3.ts +176 -172
  187. package/src/common/bare/actor-persist/v4.ts +254 -253
  188. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  189. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  190. package/src/common/bare/transport/v1.ts +694 -542
  191. package/src/common/client-protocol-versioned.ts +66 -64
  192. package/src/common/database/config.ts +175 -9
  193. package/src/common/database/mod.ts +262 -77
  194. package/src/common/database/native-database.ts +442 -20
  195. package/src/common/database/shared.ts +25 -0
  196. package/src/common/encoding.ts +278 -34
  197. package/src/common/engine.ts +28 -1
  198. package/src/common/eventsource.ts +1 -1
  199. package/src/common/fetch-like.ts +63 -0
  200. package/src/common/inline-websocket-adapter.ts +14 -13
  201. package/src/common/inspector-transport.ts +12 -2
  202. package/src/common/log.ts +15 -8
  203. package/src/common/otel-context.ts +99 -0
  204. package/src/common/router.ts +14 -18
  205. package/src/common/utils.ts +8 -169
  206. package/src/common/websocket-interface.ts +1 -1
  207. package/src/db/drizzle.ts +182 -80
  208. package/src/db/mod.ts +5 -1
  209. package/src/devtools-loader/index.ts +4 -7
  210. package/src/devtools-loader/serve-devtools.ts +26 -0
  211. package/src/dynamic/instance.ts +32 -0
  212. package/src/dynamic/internal.ts +50 -0
  213. package/src/dynamic/isolate-runtime.ts +64 -0
  214. package/src/dynamic/mod.ts +32 -0
  215. package/src/engine-api/actors.ts +15 -3
  216. package/src/engine-client/actor-http-client.ts +37 -22
  217. package/src/engine-client/actor-websocket-client.ts +37 -9
  218. package/src/engine-client/api-endpoints.ts +128 -5
  219. package/src/engine-client/api-utils.ts +2 -2
  220. package/src/engine-client/driver.ts +21 -16
  221. package/src/engine-client/mod.ts +280 -111
  222. package/src/engine-client/ws-proxy.ts +9 -4
  223. package/src/inspector/client.browser.ts +127 -15
  224. package/src/inspector/mod.ts +2 -4
  225. package/src/inspector/workflow.ts +61 -0
  226. package/src/inspector-tab/mod.ts +301 -0
  227. package/src/registry/config/envoy.ts +3 -20
  228. package/src/registry/config/index.ts +91 -74
  229. package/src/registry/index.ts +702 -80
  230. package/src/registry/napi-runtime.ts +643 -42
  231. package/src/registry/native-http.ts +225 -0
  232. package/src/registry/native-validation.ts +10 -12
  233. package/src/registry/native.ts +1881 -582
  234. package/src/registry/run-handler-coordinator.ts +219 -0
  235. package/src/registry/runtime.ts +441 -7
  236. package/src/registry/wasm-runtime.ts +516 -23
  237. package/src/registry/write-through-proxy.ts +141 -0
  238. package/src/serde.ts +2 -2
  239. package/src/serverless/configure.ts +18 -7
  240. package/src/test/mod.ts +2 -17
  241. package/src/test/ready.ts +22 -0
  242. package/src/unstable/migrations.ts +141 -0
  243. package/src/utils/endpoint-parser.ts +1 -1
  244. package/src/utils/env-vars.ts +50 -2
  245. package/src/utils/node.ts +44 -28
  246. package/src/utils/router.ts +1 -1
  247. package/src/utils.ts +4 -2
  248. package/src/workflow/context.ts +703 -242
  249. package/src/workflow/driver.ts +284 -125
  250. package/src/workflow/inspector.ts +24 -24
  251. package/src/workflow/mod.ts +76 -84
  252. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  253. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  254. package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
  255. package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
  256. package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
  257. package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
  258. package/dist/tsup/chunk-AGBP757I.js.map +0 -1
  259. package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
  260. package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
  261. package/dist/tsup/chunk-JGIPV3QU.js +0 -268
  262. package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
  263. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  264. package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
  265. package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
  266. package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
  267. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  268. package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
  269. package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
  270. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  271. package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
  272. package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
  273. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  274. package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
  275. package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
  276. package/dist/tsup/context-88opQsfZ.d.cts +0 -92
  277. package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
  278. package/src/actor/driver.ts +0 -141
  279. package/src/actor/instance/mod.ts +0 -2492
  280. package/src/actor/keys.test.ts +0 -275
  281. package/src/actor/utils.test.ts +0 -48
  282. package/src/agent-os/actor/cron.ts +0 -84
  283. package/src/agent-os/actor/db.ts +0 -54
  284. package/src/agent-os/actor/filesystem.ts +0 -131
  285. package/src/agent-os/actor/index.ts +0 -265
  286. package/src/agent-os/actor/network.ts +0 -58
  287. package/src/agent-os/actor/preview.ts +0 -191
  288. package/src/agent-os/actor/process.ts +0 -177
  289. package/src/agent-os/actor/session.ts +0 -518
  290. package/src/agent-os/actor/shell.ts +0 -60
  291. package/src/agent-os/config.ts +0 -79
  292. package/src/agent-os/fs/database-vfs.ts +0 -624
  293. package/src/agent-os/types.ts +0 -148
  294. package/src/client/test.ts +0 -44
  295. package/src/common/database/mod.test.ts +0 -137
  296. package/src/common/database/native-database.test.ts +0 -211
  297. package/src/common/inline-websocket-adapter.test.ts +0 -51
  298. package/src/drivers/engine/actor-driver.ts +0 -2460
  299. package/src/registry/runtime.test.ts +0 -50
  300. package/src/utils/endpoint-parser.test.ts +0 -206
  301. package/src/utils/serve.ts +0 -217
  302. package/src/utils.test.ts +0 -34
  303. /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
@@ -1,31 +1,29 @@
1
1
  import { z } from "zod/v4";
2
- import type { UniversalWebSocket } from "@/common/websocket-interface";
2
+ import type { Client } from "@/client/client";
3
3
  import type {
4
4
  AnyDatabaseProvider,
5
5
  InferDatabaseClient,
6
- RawDatabaseClient,
7
- DrizzleDatabaseClient,
8
- NativeDatabaseProvider,
9
6
  } from "@/common/database/config";
10
- import type { Client } from "@/client/client";
7
+ import type { UniversalWebSocket } from "@/common/websocket-interface";
8
+ import type { WorkflowState } from "@/inspector/workflow";
11
9
  import type { Registry } from "@/registry";
10
+ import { flattenActionHandlers } from "./actions";
12
11
  import type { BaseActorDefinition } from "./definition";
13
12
  import type {
14
13
  EventSchemaConfig,
15
- PrimitiveSchema,
16
- QueueSchemaConfig,
17
- } from "./schema";
18
- import type {
19
- InferEventArgs,
20
14
  InferQueueCompleteMap,
21
15
  InferSchemaMap,
16
+ PrimitiveSchema,
17
+ QueueSchemaConfig,
22
18
  } from "./schema";
19
+ import type { ActionSampleRates, ActorTracingOptions } from "./tracing";
23
20
 
24
21
  export const DEFAULT_SLEEP_GRACE_PERIOD = 15_000;
25
22
 
26
23
  export const ACTOR_CONTEXT_INTERNAL_SYMBOL = Symbol(
27
24
  "rivetkit.actor_context_internal",
28
25
  );
26
+ export const RAW_STATE_SYMBOL = Symbol("rivetkit.raw_state");
29
27
  export const CONN_DRIVER_SYMBOL = Symbol("rivetkit.conn_driver");
30
28
  export const CONN_STATE_MANAGER_SYMBOL = Symbol("rivetkit.conn_state_manager");
31
29
 
@@ -67,6 +65,7 @@ type ActorKvListOptions<
67
65
 
68
66
  type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
69
67
 
68
+ /** @deprecated Actor KV was deprecated in 3.0 and will be removed in a future version. Store data in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/kv */
70
69
  export interface ActorKv {
71
70
  get<T extends ActorKvValueType = "text">(
72
71
  key: Uint8Array | string,
@@ -97,19 +96,119 @@ export interface ActorKv {
97
96
  end: Uint8Array | string,
98
97
  options?: ActorKvListOptions<T, K>,
99
98
  ): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
100
- list<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(
99
+ list<
100
+ T extends ActorKvValueType = "text",
101
+ K extends ActorKvKeyType = "text",
102
+ >(
101
103
  prefix: Uint8Array | string,
102
104
  options?: ActorKvListOptions<T, K>,
103
105
  ): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
104
106
  [key: string]: any;
105
107
  }
106
108
 
109
+ /** One individual actor fork behind an actor, as `c.forkChain` lists it. */
110
+ export interface ActorForkLink {
111
+ /** The source actor's ID. */
112
+ actorId: string;
113
+ /** The source actor's key. */
114
+ key: string[];
115
+ /** When the fork was made, in milliseconds since the epoch. */
116
+ forkedAt: number;
117
+ }
118
+
119
+ /** The fork an `onFork` hook runs for: the newest entry of `c.forkChain` and the fork input. */
120
+ export interface ActorFork extends ActorForkLink {
121
+ /**
122
+ * The `input` passed to `client.<actor>.fork`, or `undefined`. It comes from the caller that
123
+ * forked the actor, so validate it like any client input.
124
+ */
125
+ input: unknown;
126
+ }
127
+
107
128
  export interface ActorSchedule {
108
- after(duration: number, action: string, ...args: unknown[]): Promise<void>;
109
- at(timestamp: number, action: string, ...args: unknown[]): Promise<void>;
129
+ after(
130
+ duration: number,
131
+ action: string,
132
+ ...args: unknown[]
133
+ ): Promise<string>;
134
+ at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
135
+ cancel(id: string): Promise<boolean>;
136
+ get(id: string): Promise<ScheduledEventInfo | undefined>;
137
+ list(): Promise<ScheduledEventInfo[]>;
138
+ [key: string]: any;
139
+ }
140
+
141
+ export interface ActorCronSetOptions {
142
+ name: string;
143
+ expression: string;
144
+ action: string;
145
+ args?: unknown[];
146
+ timezone?: string;
147
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
148
+ maxHistory?: number;
149
+ }
150
+
151
+ export interface ActorCronEveryOptions {
152
+ name: string;
153
+ /** Fixed interval in milliseconds. Minimum 5,000. */
154
+ interval: number;
155
+ action: string;
156
+ args?: unknown[];
157
+ /** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
158
+ maxHistory?: number;
159
+ }
160
+
161
+ export interface ActorCron {
162
+ set(options: ActorCronSetOptions): Promise<void>;
163
+ every(options: ActorCronEveryOptions): Promise<void>;
164
+ get(name: string): Promise<CronJobInfo | undefined>;
165
+ list(): Promise<CronJobInfo[]>;
166
+ delete(name: string): Promise<boolean>;
167
+ history(name: string, options?: { limit?: number }): Promise<CronFire[]>;
110
168
  [key: string]: any;
111
169
  }
112
170
 
171
+ export interface ScheduledEventInfo {
172
+ id: string;
173
+ action: string;
174
+ args: unknown[];
175
+ runAt: number;
176
+ }
177
+
178
+ export type CronJobInfo = {
179
+ name: string;
180
+ action: string;
181
+ args: unknown[];
182
+ nextRunAt: number;
183
+ lastRunAt?: number;
184
+ maxHistory: number;
185
+ } & (
186
+ | { kind: "cron"; expression: string; timezone: string }
187
+ | { kind: "every"; interval: number }
188
+ );
189
+
190
+ export interface ScheduledFireInfo {
191
+ kind: "at" | "cron" | "every";
192
+ id: string;
193
+ name?: string;
194
+ scheduledAt: number;
195
+ firedAt: number;
196
+ }
197
+
198
+ export interface CronFire {
199
+ action: string;
200
+ scheduledAt: number;
201
+ firedAt: number;
202
+ finishedAt?: number;
203
+ result: "running" | "ok" | "error" | "skipped";
204
+ error?: {
205
+ group: string;
206
+ code: string;
207
+ message: string;
208
+ metadata?: unknown;
209
+ };
210
+ }
211
+
113
212
  export type QueueMessageOf<Name extends string, Body> = {
114
213
  id: number | bigint;
115
214
  name: Name;
@@ -118,7 +217,8 @@ export type QueueMessageOf<Name extends string, Body> = {
118
217
  [key: string]: unknown;
119
218
  };
120
219
 
121
- export type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
220
+ export type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues &
221
+ string;
122
222
  export type QueueFilterName<TQueues extends QueueSchemaConfig> =
123
223
  keyof TQueues extends never ? string : QueueName<TQueues>;
124
224
 
@@ -228,7 +328,10 @@ export interface QueueIterOptions<
228
328
  completable?: TCompletable;
229
329
  }
230
330
 
231
- export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
331
+ /** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
332
+ export interface ActorQueue<
333
+ TQueues extends QueueSchemaConfig = Record<never, never>,
334
+ > {
232
335
  send<TName extends QueueFilterName<TQueues>>(
233
336
  name: TName,
234
337
  body: QueueMessageForName<TQueues, TName>["body"],
@@ -236,15 +339,11 @@ export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, ne
236
339
  next<
237
340
  const TName extends QueueFilterName<TQueues>,
238
341
  const TCompletable extends boolean = false,
239
- >(
240
- opts?: QueueNextOptions<TName, TCompletable>,
241
- ): Promise<any>;
342
+ >(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
242
343
  nextBatch<
243
344
  const TName extends QueueFilterName<TQueues>,
244
345
  const TCompletable extends boolean = false,
245
- >(
246
- opts?: QueueNextBatchOptions<TName, TCompletable>,
247
- ): Promise<any[]>;
346
+ >(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
248
347
  waitForNames<
249
348
  const TName extends QueueFilterName<TQueues>,
250
349
  const TCompletable extends boolean = false,
@@ -252,6 +351,16 @@ export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, ne
252
351
  names: readonly TName[],
253
352
  opts?: QueueWaitOptions<TCompletable>,
254
353
  ): Promise<any>;
354
+ /** @experimental */
355
+ waitForAvailable<const TName extends QueueFilterName<TQueues>>(
356
+ names?: readonly TName[],
357
+ opts?: Omit<QueueWaitOptions<false>, "completable">,
358
+ ): Promise<void>;
359
+ /** @experimental */
360
+ complete<const TName extends QueueFilterName<TQueues>>(
361
+ message: { id: number | bigint; name: TName },
362
+ ...args: QueueCompleteArgsForName<TQueues, TName>
363
+ ): Promise<void>;
255
364
  enqueueAndWait<const TName extends QueueFilterName<TQueues>>(
256
365
  name: TName,
257
366
  body: QueueMessageForName<TQueues, TName>["body"],
@@ -260,36 +369,31 @@ export interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, ne
260
369
  tryNext<
261
370
  const TName extends QueueFilterName<TQueues>,
262
371
  const TCompletable extends boolean = false,
263
- >(
264
- opts?: QueueTryNextOptions<TName, TCompletable>,
265
- ): Promise<any>;
372
+ >(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
266
373
  tryNextBatch<
267
374
  const TName extends QueueFilterName<TQueues>,
268
375
  const TCompletable extends boolean = false,
269
- >(
270
- opts?: QueueTryNextBatchOptions<TName, TCompletable>,
271
- ): Promise<any[]>;
376
+ >(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
272
377
  iter<
273
378
  const TName extends QueueFilterName<TQueues>,
274
379
  const TCompletable extends boolean = false,
275
- >(
276
- opts?: QueueIterOptions<TName, TCompletable>,
277
- ): AsyncIterable<any>;
380
+ >(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
278
381
  [key: string]: any;
279
382
  }
280
383
 
281
384
  export interface Conn<
282
- TState = unknown,
385
+ _TState = unknown,
283
386
  TConnParams = unknown,
284
387
  TConnState = unknown,
285
- TVars = unknown,
286
- TInput = unknown,
287
- TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider,
288
- TEvents extends EventSchemaConfig = Record<never, never>,
289
- TQueues extends QueueSchemaConfig = Record<never, never>,
388
+ _TVars = unknown,
389
+ _TInput = unknown,
390
+ _TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider,
391
+ _TEvents extends EventSchemaConfig = Record<never, never>,
392
+ _TQueues extends QueueSchemaConfig = Record<never, never>,
290
393
  > {
291
394
  id: string;
292
395
  params: TConnParams;
396
+ /** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
293
397
  state: TConnState;
294
398
  isHibernatable: boolean;
295
399
  send(name: string, ...args: any[]): void;
@@ -310,28 +414,60 @@ export interface ActorContext<
310
414
  TQueues extends QueueSchemaConfig = Record<never, never>,
311
415
  > {
312
416
  [ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
417
+ /** Returns the raw unwrapped state without the write-through proxy. */
418
+ [RAW_STATE_SYMBOL](): TState;
419
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
313
420
  state: TState;
314
421
  vars: TVars;
422
+ /** @deprecated Actor KV was deprecated in 3.0 and will be removed in a future version. Store data in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/kv */
315
423
  readonly kv: ActorKv;
316
424
  readonly db: InferDatabaseClient<TDatabase>;
317
425
  readonly schedule: ActorSchedule;
426
+ readonly cron: ActorCron;
427
+ /** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
318
428
  readonly queue: ActorQueue<TQueues>;
429
+ /** @experimental */
430
+ readonly run: ActorRun;
319
431
  readonly actorId: string;
320
432
  readonly name: string;
321
433
  readonly key: string[];
434
+ /**
435
+ * The individual actor forks behind this actor, oldest first; empty when it was never
436
+ * forked. Namespace forks are not listed.
437
+ */
438
+ readonly forkChain: ActorForkLink[];
322
439
  readonly region: string;
323
- readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
440
+ /**
441
+ * The name of the namespace the actor runs in. After a namespace fork it differs from the
442
+ * source actor's namespace while the actor id stays the same, so an actor that owns an
443
+ * external resource can store this to detect that it was copied.
444
+ */
445
+ readonly namespace: string;
446
+ readonly conns: Map<
447
+ string,
448
+ Conn<
449
+ TState,
450
+ TConnParams,
451
+ TConnState,
452
+ TVars,
453
+ TInput,
454
+ TDatabase,
455
+ TEvents,
456
+ TQueues
457
+ >
458
+ >;
324
459
  readonly log: ActorLogger;
325
460
  readonly abortSignal: AbortSignal;
326
461
  readonly aborted: boolean;
327
462
  readonly request?: Request;
328
- /** @deprecated No-op. Always returns `false`. Use `keepAwake(promise)` or `waitUntil(promise)` instead. Will be removed in 2.2.0. */
463
+ /** @deprecated `preventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op that always returns `false`. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
329
464
  readonly preventSleep: boolean;
330
465
  broadcast(name: string, ...args: any[]): void;
466
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
331
467
  saveState(opts?: { immediate?: boolean; maxWait?: number }): Promise<void>;
332
468
  keepAwake<T>(promise: Promise<T>): Promise<T>;
333
469
  waitUntil(promise: Promise<unknown>): void;
334
- /** @deprecated No-op. Use `keepAwake(promise)` to hold the actor awake for a specific promise. Will be removed in 2.2.0. */
470
+ /** @deprecated `setPreventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
335
471
  setPreventSleep(preventSleep: boolean): void;
336
472
  sleep(): void;
337
473
  destroy(): void;
@@ -339,6 +475,53 @@ export interface ActorContext<
339
475
  [key: string]: any;
340
476
  }
341
477
 
478
+ /** @experimental How one run of a workflow function ended. */
479
+ export type WorkflowOutcome =
480
+ | "completed"
481
+ | "sleeping"
482
+ | "evicted"
483
+ | "failed"
484
+ | "cancelled";
485
+
486
+ /** @experimental How one workflow step attempt ended. `retry` will be tried again, `failed` will not. */
487
+ export type WorkflowStepOutcome = "ok" | "retry" | "failed";
488
+
489
+ /** @experimental One open run of a workflow function, traced as its own invocation. */
490
+ export interface WorkflowSpan {
491
+ /** Runs `body` attributed to this run. */
492
+ run<T>(body: () => Promise<T>): Promise<T>;
493
+ /**
494
+ * Called by a workflow engine before each attempt at a step. Returns
495
+ * nothing when tracing is off.
496
+ */
497
+ startStep(name: string, attempt: number): WorkflowStepSpan | undefined;
498
+ finish(outcome: WorkflowOutcome): Promise<void>;
499
+ }
500
+
501
+ /** @experimental One open attempt at one workflow step. */
502
+ export interface WorkflowStepSpan {
503
+ /** Runs `body` attributed to this attempt. */
504
+ run<T>(body: () => Promise<T>): Promise<T>;
505
+ /** `error` is what the step callback threw. */
506
+ finish(outcome: WorkflowStepOutcome, error?: unknown): void;
507
+ }
508
+
509
+ /** @experimental */
510
+ export interface ActorRun {
511
+ /**
512
+ * @experimental Sets or clears the durable Unix-millisecond deadline that
513
+ * ensures this actor's run handler is active, starting it if inactive.
514
+ */
515
+ setWakeAt(timestamp: number | null): Promise<void>;
516
+ /** @experimental Called by a workflow engine each time it runs the workflow function. */
517
+ startWorkflowSpan(): Promise<WorkflowSpan>;
518
+ /**
519
+ * @experimental Runs `body` outside the current workflow run, so a workflow
520
+ * engine's own history storage stays out of the trace.
521
+ */
522
+ runOutsideWorkflowSpan<T>(body: () => T): T;
523
+ }
524
+
342
525
  export type ActionContext<
343
526
  TState,
344
527
  TConnParams,
@@ -358,6 +541,8 @@ export type ActionContext<
358
541
  TEvents,
359
542
  TQueues
360
543
  > & {
544
+ /** Present only when a durable schedule or cron invokes this action. */
545
+ readonly scheduledFire?: ScheduledFireInfo;
361
546
  conn: Conn<
362
547
  TState,
363
548
  TConnParams,
@@ -428,6 +613,7 @@ export type ConnectContext<
428
613
  TQueues
429
614
  >;
430
615
 
616
+ /** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
431
617
  export type CreateConnStateContext<
432
618
  TState,
433
619
  TVars,
@@ -571,6 +757,7 @@ export type SleepContext<
571
757
  TQueues
572
758
  >;
573
759
 
760
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. See https://rivet.dev/actors/docs/deprecated/state */
574
761
  export type StateChangeContext<
575
762
  TState,
576
763
  TConnParams,
@@ -651,7 +838,9 @@ export type WebSocketContext<
651
838
  TQueues
652
839
  >;
653
840
 
654
- export type ActorContextOf<AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, any>> =
841
+ export type ActorContextOf<
842
+ AD extends BaseActorDefinition<any, any, any, any, any, any, any, any, any>,
843
+ > =
655
844
  AD extends BaseActorDefinition<
656
845
  infer TState,
657
846
  infer TConnParams,
@@ -696,22 +885,55 @@ const zFunction = <
696
885
  T extends (...args: any[]) => any = (...args: unknown[]) => unknown,
697
886
  >() => z.custom<T>((val) => typeof val === "function");
698
887
 
888
+ const zActionTree = z
889
+ .custom<Record<string, unknown>>((value) => {
890
+ if (
891
+ typeof value !== "object" ||
892
+ value === null ||
893
+ Array.isArray(value)
894
+ ) {
895
+ return false;
896
+ }
897
+ const prototype = Object.getPrototypeOf(value);
898
+ return prototype === Object.prototype || prototype === null;
899
+ })
900
+ .superRefine((actions, ctx) => {
901
+ try {
902
+ flattenActionHandlers(actions);
903
+ } catch (error) {
904
+ ctx.addIssue({
905
+ code: "custom",
906
+ message:
907
+ error instanceof Error
908
+ ? error.message
909
+ : "Invalid action definition",
910
+ });
911
+ }
912
+ });
913
+
699
914
  export type InspectorUnsubscribe = () => void;
700
915
 
916
+ /** @experimental */
701
917
  export interface WorkflowInspectorConfig<THistory = unknown> {
702
918
  getHistory: () => THistory | null;
919
+ getState?: () => Promise<WorkflowState | null>;
703
920
  onHistoryUpdated?: (
704
921
  listener: (history: THistory) => void,
705
922
  ) => InspectorUnsubscribe;
706
923
  replayFromStep?: (entryId?: string) => Promise<THistory | null>;
707
924
  }
708
925
 
926
+ /** @experimental */
709
927
  export interface RunInspectorConfig<THistory = unknown> {
710
928
  workflow?: WorkflowInspectorConfig<THistory>;
711
929
  }
712
930
 
713
931
  const WorkflowInspectorConfigSchema = z.object({
714
932
  getHistory: zFunction<WorkflowInspectorConfig<unknown>["getHistory"]>(),
933
+ getState:
934
+ zFunction<
935
+ NonNullable<WorkflowInspectorConfig<unknown>["getState"]>
936
+ >().optional(),
715
937
  onHistoryUpdated:
716
938
  zFunction<
717
939
  NonNullable<WorkflowInspectorConfig<unknown>["onHistoryUpdated"]>
@@ -728,6 +950,89 @@ const RunInspectorConfigSchema = z
728
950
  })
729
951
  .optional();
730
952
 
953
+ /**
954
+ * Built-in inspector tabs the dashboard ships. Used to validate
955
+ * `hidden: true` entries and reject custom-tab ids that collide with
956
+ * a built-in.
957
+ */
958
+ export const BUILTIN_INSPECTOR_TAB_IDS = [
959
+ "workflow",
960
+ "database",
961
+ "state",
962
+ "queue",
963
+ "schedules",
964
+ "connections",
965
+ "console",
966
+ ] as const;
967
+
968
+ export const BuiltinInspectorTabIdSchema = z.enum(BUILTIN_INSPECTOR_TAB_IDS);
969
+
970
+ // Custom tab id grammar — mirrored in Rust at
971
+ // `rivetkit-rust/packages/rivetkit-core/src/inspector/tabs.rs`. Slashes are
972
+ // forbidden because the runtime splits `/inspector/custom-tabs/<id>/<rest>`
973
+ // on the first `/`.
974
+ const CUSTOM_INSPECTOR_TAB_ID_RE = /^[A-Za-z0-9_-]+$/;
975
+
976
+ export const CustomInspectorTabEntrySchema = z
977
+ .object({
978
+ id: z
979
+ .string()
980
+ .regex(
981
+ CUSTOM_INSPECTOR_TAB_ID_RE,
982
+ "inspector.tabs[].id must contain only letters, digits, underscore, or dash",
983
+ ),
984
+ label: z.string().min(1),
985
+ source: z.string().min(1),
986
+ /**
987
+ * Optional icon id. The dashboard maps strings to glyphs (see its
988
+ * icon registry); unknown ids fall back to a generic icon.
989
+ */
990
+ icon: z.string().min(1).optional(),
991
+ hidden: z.literal(false).optional(),
992
+ })
993
+ .strict();
994
+
995
+ export const HideInspectorTabEntrySchema = z
996
+ .object({
997
+ id: BuiltinInspectorTabIdSchema,
998
+ hidden: z.literal(true),
999
+ })
1000
+ .strict();
1001
+
1002
+ export const InspectorTabEntrySchema = z.union([
1003
+ CustomInspectorTabEntrySchema,
1004
+ HideInspectorTabEntrySchema,
1005
+ ]);
1006
+
1007
+ export const ActorInspectorConfigSchema = z
1008
+ .object({
1009
+ tabs: z.array(InspectorTabEntrySchema).default(() => []),
1010
+ })
1011
+ .strict()
1012
+ .refine(
1013
+ (data) => {
1014
+ const ids = data.tabs.map((t) => t.id);
1015
+ return new Set(ids).size === ids.length;
1016
+ },
1017
+ { message: "Duplicate id in inspector.tabs", path: ["tabs"] },
1018
+ )
1019
+ .refine(
1020
+ (data) => {
1021
+ // A custom entry's id must not collide with a built-in id.
1022
+ const builtinSet = new Set(BUILTIN_INSPECTOR_TAB_IDS);
1023
+ return data.tabs.every(
1024
+ (t) => t.hidden === true || !builtinSet.has(t.id as any),
1025
+ );
1026
+ },
1027
+ {
1028
+ message:
1029
+ "Custom inspector tab id collides with a built-in (use hidden: true to hide a built-in)",
1030
+ path: ["tabs"],
1031
+ },
1032
+ );
1033
+
1034
+ export type ActorInspectorConfig = z.input<typeof ActorInspectorConfigSchema>;
1035
+
731
1036
  // Schema for run handler with metadata
732
1037
  export const RunConfigSchema = z.object({
733
1038
  /** Display name for the actor in the Inspector UI. */
@@ -775,21 +1080,143 @@ type AnyRunConfig = RunConfig<
775
1080
  any
776
1081
  >;
777
1082
 
778
- export const RUN_FUNCTION_CONFIG_SYMBOL = Symbol.for(
779
- "rivetkit.run_function_config",
780
- );
1083
+ const RUN_FUNCTION_CONFIG_SYMBOL = Symbol.for("rivetkit.run_function_config");
1084
+
1085
+ /** @experimental */
1086
+ export type RunInspectorKind = "workflow";
1087
+
1088
+ /** @experimental */
1089
+ export interface RunWithInactiveOptions {
1090
+ /** Restart the run handler before releasing the exclusive gate on success. */
1091
+ restartOnSuccess?: boolean;
1092
+ }
1093
+
1094
+ /** @experimental */
1095
+ export interface RunControl {
1096
+ run: {
1097
+ /**
1098
+ * Executes only while no run handler is active or waiting to start.
1099
+ *
1100
+ * This is a non-blocking acquisition: concurrent replay/control requests
1101
+ * fail instead of waiting behind an active run.
1102
+ */
1103
+ withInactive<T>(
1104
+ options: RunWithInactiveOptions,
1105
+ callback: () => T | Promise<T>,
1106
+ ): Promise<T>;
1107
+ };
1108
+ }
1109
+
1110
+ /** @experimental */
1111
+ export interface RunInspectorFactoryContext {
1112
+ actorId: string;
1113
+ control: RunControl;
1114
+ }
1115
+
1116
+ /** @experimental */
1117
+ export interface RunInspectorFactoryResult<THistory = unknown> {
1118
+ inspector: {
1119
+ workflow: Required<WorkflowInspectorConfig<THistory>> & {
1120
+ getState: () => Promise<WorkflowState | null>;
1121
+ };
1122
+ };
1123
+ /** Releases actor-specific listeners and encoded history. */
1124
+ dispose?: () => void;
1125
+ }
1126
+
1127
+ interface RunHandlerDisplayOptions {
1128
+ name?: string;
1129
+ icon?: string;
1130
+ }
1131
+
1132
+ /** @experimental */
1133
+ export type DefineRunHandlerOptions<THistory = unknown> =
1134
+ RunHandlerDisplayOptions &
1135
+ (
1136
+ | {
1137
+ inspectorKind?: never;
1138
+ createInspector?: never;
1139
+ }
1140
+ | {
1141
+ /** Static metadata used to install Inspector callbacks at registry build time. */
1142
+ inspectorKind: RunInspectorKind;
1143
+ /** Creates one Inspector adapter for each live actor. */
1144
+ createInspector: (
1145
+ context: RunInspectorFactoryContext,
1146
+ ) => RunInspectorFactoryResult<THistory>;
1147
+ }
1148
+ );
781
1149
 
782
1150
  interface RunFunctionConfig {
783
1151
  name?: string;
784
1152
  icon?: string;
785
1153
  inspector?: RunInspectorConfig;
786
1154
  inspectorFactory?: (actor: unknown) => RunInspectorConfig | undefined;
1155
+ /** Release any per-actor inspector state held for this actor id. */
1156
+ disposeInspector?: (actorId: string) => void;
1157
+ inspectorKind?: RunInspectorKind;
1158
+ createInspector?: (
1159
+ context: RunInspectorFactoryContext,
1160
+ ) => RunInspectorFactoryResult;
787
1161
  }
788
1162
 
789
1163
  type RunFunctionWithConfig = ((...args: any[]) => any) & {
790
1164
  [RUN_FUNCTION_CONFIG_SYMBOL]?: RunFunctionConfig;
791
1165
  };
792
1166
 
1167
+ /**
1168
+ * @experimental Adds supported RivetKit run metadata while preserving the function's exact
1169
+ * callable type.
1170
+ */
1171
+ export function defineRunHandler<
1172
+ TRun extends (...args: any[]) => any,
1173
+ THistory = unknown,
1174
+ >(run: TRun, options: DefineRunHandlerOptions<THistory>): TRun {
1175
+ if (
1176
+ (options.inspectorKind === undefined) !==
1177
+ (options.createInspector === undefined)
1178
+ ) {
1179
+ throw new TypeError(
1180
+ "defineRunHandler requires inspectorKind and createInspector together",
1181
+ );
1182
+ }
1183
+
1184
+ Object.defineProperty(run, RUN_FUNCTION_CONFIG_SYMBOL, {
1185
+ configurable: false,
1186
+ enumerable: false,
1187
+ writable: false,
1188
+ value: {
1189
+ name: options.name,
1190
+ icon: options.icon,
1191
+ inspectorKind: options.inspectorKind,
1192
+ createInspector:
1193
+ options.createInspector as RunFunctionConfig["createInspector"],
1194
+ } satisfies RunFunctionConfig,
1195
+ });
1196
+
1197
+ return run;
1198
+ }
1199
+
1200
+ /** @internal */
1201
+ export function getRunInspectorKind(
1202
+ run: ((...args: any[]) => any) | AnyRunConfig | undefined,
1203
+ ): RunInspectorKind | undefined {
1204
+ if (!run || typeof run !== "function") return undefined;
1205
+ return (run as RunFunctionWithConfig)[RUN_FUNCTION_CONFIG_SYMBOL]
1206
+ ?.inspectorKind;
1207
+ }
1208
+
1209
+ /** @internal */
1210
+ export function createRunInspector(
1211
+ run: ((...args: any[]) => any) | AnyRunConfig | undefined,
1212
+ context: RunInspectorFactoryContext,
1213
+ ): RunInspectorFactoryResult | undefined {
1214
+ if (!run || typeof run !== "function") return undefined;
1215
+ return (run as RunFunctionWithConfig)[
1216
+ RUN_FUNCTION_CONFIG_SYMBOL
1217
+ ]?.createInspector?.(context);
1218
+ }
1219
+
793
1220
  // Run can be either a function or an object with name/icon/run
794
1221
  const zRunHandler = z.union([zFunction(), RunConfigSchema]).optional();
795
1222
 
@@ -834,6 +1261,33 @@ export function getRunInspectorConfig(
834
1261
  return run.inspector;
835
1262
  }
836
1263
 
1264
+ /** @internal */
1265
+ export function hasRunInspectorConfig(
1266
+ run: ((...args: any[]) => any) | AnyRunConfig | undefined,
1267
+ ): boolean {
1268
+ if (!run) return false;
1269
+ if (typeof run !== "function") return run.inspector !== undefined;
1270
+ const config = (run as RunFunctionWithConfig)[RUN_FUNCTION_CONFIG_SYMBOL];
1271
+ return (
1272
+ config?.inspectorKind !== undefined ||
1273
+ config?.createInspector !== undefined ||
1274
+ config?.inspector !== undefined ||
1275
+ config?.inspectorFactory !== undefined
1276
+ );
1277
+ }
1278
+
1279
+ /** Release per-actor inspector state for a destroyed actor, if the run handler registered a disposer. */
1280
+ export function disposeRunInspector(
1281
+ run: ((...args: any[]) => any) | AnyRunConfig | undefined,
1282
+ actorId: string,
1283
+ ): void {
1284
+ if (!run || typeof run !== "function") {
1285
+ return;
1286
+ }
1287
+ const config = (run as RunFunctionWithConfig)[RUN_FUNCTION_CONFIG_SYMBOL];
1288
+ config?.disposeInspector?.(actorId);
1289
+ }
1290
+
837
1291
  // This schema is used to validate the input at runtime. The generic types are defined below in `ActorConfig`.
838
1292
  //
839
1293
  // We don't use Zod generics with `z.custom` because:
@@ -846,9 +1300,9 @@ const GlobalActorOptionsBaseSchema = z
846
1300
  /** Icon for the actor in the Inspector UI. Can be an emoji or FontAwesome icon name. */
847
1301
  icon: z.string().optional(),
848
1302
  /**
849
- * Can hibernate WebSockets for onWebSocket.
850
- *
851
- * WebSockets using actions/events are hibernatable by default.
1303
+ * Can hibernate WebSockets, both client connections for actions and
1304
+ * events and WebSockets for onWebSocket. A WebSocket that does not
1305
+ * hibernate closes when the actor sleeps, and the client reconnects.
852
1306
  *
853
1307
  * @experimental
854
1308
  **/
@@ -868,6 +1322,7 @@ export type GlobalActorOptionsInput = z.input<typeof GlobalActorOptionsSchema>;
868
1322
  const InstanceActorOptionsBaseSchema = z
869
1323
  .object({
870
1324
  createVarsTimeout: z.number().positive().default(5000),
1325
+ /** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
871
1326
  createConnStateTimeout: z.number().positive().default(5000),
872
1327
  onBeforeConnectTimeout: z.number().positive().default(5000),
873
1328
  onConnectTimeout: z.number().positive().default(5000),
@@ -876,25 +1331,30 @@ const InstanceActorOptionsBaseSchema = z
876
1331
  .number()
877
1332
  .positive()
878
1333
  .default(DEFAULT_SLEEP_GRACE_PERIOD),
879
- /** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
1334
+ /** @deprecated `onDestroyTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 3.2.0. */
880
1335
  onDestroyTimeout: z.number().positive().optional(),
881
- /** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0. */
1336
+ /** @deprecated `waitUntilTimeout` is folded into `sleepGracePeriod`, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 3.2.0. */
882
1337
  waitUntilTimeout: z.number().positive().optional(),
1338
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
883
1339
  stateSaveInterval: z.number().positive().default(1_000),
884
1340
  actionTimeout: z.number().positive().default(60_000),
885
1341
  connectionLivenessTimeout: z.number().positive().default(2500),
886
1342
  connectionLivenessInterval: z.number().positive().default(5000),
887
- /** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 2.2.0. */
1343
+ /** @deprecated Use `c.keepAwake(promise)` to scope keep-awake to a specific operation, or keep `noSleep` for actors that must stay awake indefinitely. Will be removed in 3.2.0. */
888
1344
  noSleep: z.boolean().default(false),
889
1345
  sleepTimeout: z.number().positive().default(30_000),
1346
+ /** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
890
1347
  maxQueueSize: z.number().positive().default(1000),
1348
+ /** Maximum pending one-shot and recurring schedules. */
1349
+ maxSchedules: z.number().int().nonnegative().default(1000),
1350
+ /** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
891
1351
  maxQueueMessageSize: z
892
1352
  .number()
893
1353
  .positive()
894
1354
  .default(64 * 1024),
895
- /** Override RivetKit's workflow preload budget for this actor. Set to 0 to disable workflow preloading. */
1355
+ /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 3.2.0. */
896
1356
  preloadMaxWorkflowBytes: z.number().nonnegative().optional(),
897
- /** Override RivetKit's connections preload budget for this actor. Set to 0 to disable connections preloading. */
1357
+ /** @deprecated Internal storage moved to SQLite and no longer uses KV preloading, so this option is ignored. Will be removed in 3.2.0. */
898
1358
  preloadMaxConnectionsBytes: z.number().nonnegative().optional(),
899
1359
  })
900
1360
  .strict();
@@ -916,12 +1376,19 @@ export const ActorOptionsSchema = GlobalActorOptionsBaseSchema.extend(
916
1376
  export type ActorOptions = z.infer<typeof ActorOptionsSchema>;
917
1377
  export type ActorOptionsInput = z.input<typeof ActorOptionsSchema>;
918
1378
 
1379
+ const zSampleRate = z.number().min(0).max(1);
1380
+
1381
+ const zActionSampleRates: z.ZodType<ActionSampleRates> = z.lazy(() =>
1382
+ z.record(z.string(), z.union([zSampleRate, zActionSampleRates])),
1383
+ );
1384
+
919
1385
  export const ActorConfigSchema = z
920
1386
  .object({
921
1387
  onCreate: zFunction().optional(),
922
1388
  onDestroy: zFunction().optional(),
923
1389
  onMigrate: zFunction().optional(),
924
1390
  onWake: zFunction().optional(),
1391
+ onFork: zFunction().optional(),
925
1392
  onSleep: zFunction().optional(),
926
1393
  run: zRunHandler,
927
1394
  onStateChange: zFunction().optional(),
@@ -931,8 +1398,15 @@ export const ActorConfigSchema = z
931
1398
  onBeforeActionResponse: zFunction().optional(),
932
1399
  onRequest: zFunction().optional(),
933
1400
  onWebSocket: zFunction().optional(),
934
- actions: z.record(z.string(), zFunction()).default(() => ({})),
1401
+ actions: zActionTree.default(() => ({})),
935
1402
  actionInputSchemas: z.record(z.string(), z.any()).optional(),
1403
+ tracing: z
1404
+ .object({
1405
+ sampler: zSampleRate.optional(),
1406
+ actions: zActionSampleRates.optional(),
1407
+ })
1408
+ .strict()
1409
+ .optional(),
936
1410
  connParamsSchema: z.any().optional(),
937
1411
  events: z.record(z.string(), z.any()).optional(),
938
1412
  queues: z.record(z.string(), z.any()).optional(),
@@ -944,6 +1418,7 @@ export const ActorConfigSchema = z
944
1418
  db: z.any().optional(),
945
1419
  createVars: zFunction().optional(),
946
1420
  options: ActorOptionsSchema,
1421
+ inspector: ActorInspectorConfigSchema.optional(),
947
1422
  })
948
1423
  .strict()
949
1424
  .refine(
@@ -979,16 +1454,20 @@ export const ActorConfigSchema = z
979
1454
  // Data returned from this handler will be available on `c.state`.
980
1455
  type CreateState<
981
1456
  TState,
982
- TConnParams,
983
- TConnState,
984
- TVars,
1457
+ _TConnParams,
1458
+ _TConnState,
1459
+ _TVars,
985
1460
  TInput,
986
1461
  TDatabase extends AnyDatabaseProvider,
987
1462
  TEvents extends EventSchemaConfig,
988
1463
  TQueues extends QueueSchemaConfig,
989
1464
  > =
990
- | { state: TState }
991
1465
  | {
1466
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
1467
+ state: TState;
1468
+ }
1469
+ | {
1470
+ /** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
992
1471
  createState: (
993
1472
  c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>,
994
1473
  input: TInput,
@@ -1012,8 +1491,12 @@ type CreateConnState<
1012
1491
  TEvents extends EventSchemaConfig,
1013
1492
  TQueues extends QueueSchemaConfig,
1014
1493
  > =
1015
- | { connState: TConnState }
1016
1494
  | {
1495
+ /** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
1496
+ connState: TConnState;
1497
+ }
1498
+ | {
1499
+ /** @deprecated Connection state was deprecated in 3.0 and will be removed in a future version. Track live connections in `c.vars` from `onConnect` and `onDisconnect`, and store durable per-connection data in SQLite. See https://rivet.dev/actors/docs/deprecated/state#connection-state */
1017
1500
  createConnState: (
1018
1501
  c: CreateConnStateContext<
1019
1502
  TState,
@@ -1036,8 +1519,8 @@ type CreateConnState<
1036
1519
  */
1037
1520
  type CreateVars<
1038
1521
  TState,
1039
- TConnParams,
1040
- TConnState,
1522
+ _TConnParams,
1523
+ _TConnState,
1041
1524
  TVars,
1042
1525
  TInput,
1043
1526
  TDatabase extends AnyDatabaseProvider,
@@ -1077,19 +1560,34 @@ export interface Actions<
1077
1560
  TEvents extends EventSchemaConfig = Record<never, never>,
1078
1561
  TQueues extends QueueSchemaConfig = Record<never, never>,
1079
1562
  > {
1080
- [Action: string]: (
1081
- c: ActionContext<
1082
- TState,
1083
- TConnParams,
1084
- TConnState,
1085
- TVars,
1086
- TInput,
1087
- TDatabase,
1088
- TEvents,
1089
- TQueues
1090
- >,
1091
- ...args: any[]
1092
- ) => any;
1563
+ [Action: string]:
1564
+ | ((
1565
+ c: ActionContext<
1566
+ TState,
1567
+ TConnParams,
1568
+ TConnState,
1569
+ TVars,
1570
+ TInput,
1571
+ TDatabase,
1572
+ TEvents,
1573
+ TQueues
1574
+ >,
1575
+ ...args: any[]
1576
+ ) => any)
1577
+ | Actions<
1578
+ TState,
1579
+ TConnParams,
1580
+ TConnState,
1581
+ TVars,
1582
+ TInput,
1583
+ TDatabase,
1584
+ TEvents,
1585
+ TQueues
1586
+ >;
1587
+ }
1588
+
1589
+ export interface ActionInputSchemas {
1590
+ [Action: string]: PrimitiveSchema | ActionInputSchemas;
1093
1591
  }
1094
1592
 
1095
1593
  //export type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthData> = BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TAuthData> &
@@ -1169,6 +1667,49 @@ interface BaseActorConfig<
1169
1667
  isNew: boolean,
1170
1668
  ) => void | Promise<void>;
1171
1669
 
1670
+ /**
1671
+ * Called once at the first start of an actor made by forking another actor
1672
+ * (`client.<actor>.fork`), after its state loads and before `onWake` and any
1673
+ * overdue schedule events run. `createState` and `onCreate` do not run for a fork.
1674
+ *
1675
+ * Use this hook to cancel schedules the fork inherited, drop resources copied
1676
+ * from the source, or record the fork input. `c.forkChain` already ends with
1677
+ * this fork. A throw fails the start, and the hook runs again on the next start.
1678
+ * Forks of a whole namespace do not call it.
1679
+ *
1680
+ * State edits made in this hook are saved in one commit with the record that the
1681
+ * fork ran, so a start that finds the fork recorded also finds the hook's final
1682
+ * state. On native SQLite the hook's `c.db` writes and any save it starts itself
1683
+ * join that commit too, and a failed start drops them. Two limits apply:
1684
+ *
1685
+ * - On remote SQLite (wasm runtimes), `c.db` writes, and state the hook writes
1686
+ * itself in a transaction (for example `c.db.transaction` with
1687
+ * `experimental.includeState`), are committed at once, without the fork record.
1688
+ * A `c.saveState` call is not such a write: the startup save carries its
1689
+ * state. Only state the hook leaves to the startup save is atomic with it. A
1690
+ * crash or a failed start before the record lands runs the hook again on top
1691
+ * of those writes, so the hook must be idempotent there.
1692
+ * - On native SQLite the hook's writes must fit one commit (32,768 pages, 128 MiB
1693
+ * at the default page size). A transaction that would take them past it fails as
1694
+ * too large instead of committing part of them early; a hook that lets the error
1695
+ * throw fails the start, and nothing it wrote lands. Move a backfill that large
1696
+ * into later actions.
1697
+ * `onCreate` differs: its writes held so far are committed early instead.
1698
+ */
1699
+ onFork?: (
1700
+ c: WakeContext<
1701
+ TState,
1702
+ TConnParams,
1703
+ TConnState,
1704
+ TVars,
1705
+ TInput,
1706
+ TDatabase,
1707
+ TEvents,
1708
+ TQueues
1709
+ >,
1710
+ fork: ActorFork,
1711
+ ) => void | Promise<void>;
1712
+
1172
1713
  /**
1173
1714
  * Called when the actor is started and ready to receive connections and action.
1174
1715
  *
@@ -1238,6 +1779,12 @@ interface BaseActorConfig<
1238
1779
  *
1239
1780
  * Can be either a function or a RunConfig object with optional name/icon metadata.
1240
1781
  *
1782
+ * Passing a plain function was deprecated in 3.0 and will be removed in a
1783
+ * future version; it logs a warning at startup. Start background work from
1784
+ * `onWake` with `c.keepAwake` and track it in `c.vars` instead.
1785
+ * `run: workflow(...)` is not deprecated. See
1786
+ * https://rivet.dev/actors/docs/deprecated/run
1787
+ *
1241
1788
  * @returns Void or a Promise.
1242
1789
  */
1243
1790
  run?:
@@ -1274,6 +1821,7 @@ interface BaseActorConfig<
1274
1821
  * another onStateChange call, preventing infinite recursion.
1275
1822
  *
1276
1823
  * @param newState The updated state
1824
+ * @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state
1277
1825
  */
1278
1826
  onStateChange?: (
1279
1827
  c: StateChangeContext<
@@ -1457,9 +2005,16 @@ interface BaseActorConfig<
1457
2005
  actions?: TActions;
1458
2006
 
1459
2007
  /**
1460
- * Optional schema map for validating action argument tuples in native runtimes.
2008
+ * Optional schemas for validating action argument tuples in native runtimes.
2009
+ * May mirror nested action groups or use dot-separated low-level action names.
1461
2010
  */
1462
- actionInputSchemas?: Record<string, PrimitiveSchema>;
2011
+ actionInputSchemas?: ActionInputSchemas;
2012
+
2013
+ /**
2014
+ * How much of this actor's work is recorded in traces. Defaults to the
2015
+ * process sampler from `OTEL_TRACES_SAMPLER`.
2016
+ */
2017
+ tracing?: ActorTracingOptions<TActions>;
1463
2018
 
1464
2019
  /**
1465
2020
  * Optional schema for validating connection params in native runtimes.
@@ -1473,6 +2028,8 @@ interface BaseActorConfig<
1473
2028
 
1474
2029
  /**
1475
2030
  * Schema map for queue payloads sent by this actor.
2031
+ *
2032
+ * @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues
1476
2033
  */
1477
2034
  queues?: TQueues;
1478
2035
  }
@@ -1498,6 +2055,25 @@ export type ActorConfig<
1498
2055
  TDatabase extends AnyDatabaseProvider,
1499
2056
  TEvents extends EventSchemaConfig = Record<never, never>,
1500
2057
  TQueues extends QueueSchemaConfig = Record<never, never>,
2058
+ TActions extends Actions<
2059
+ TState,
2060
+ TConnParams,
2061
+ TConnState,
2062
+ TVars,
2063
+ TInput,
2064
+ TDatabase,
2065
+ TEvents,
2066
+ TQueues
2067
+ > = Actions<
2068
+ TState,
2069
+ TConnParams,
2070
+ TConnState,
2071
+ TVars,
2072
+ TInput,
2073
+ TDatabase,
2074
+ TEvents,
2075
+ TQueues
2076
+ >,
1501
2077
  > = Omit<
1502
2078
  z.infer<typeof ActorConfigSchema>,
1503
2079
  | "actions"
@@ -1507,6 +2083,7 @@ export type ActorConfig<
1507
2083
  | "onDestroy"
1508
2084
  | "onMigrate"
1509
2085
  | "onWake"
2086
+ | "onFork"
1510
2087
  | "onSleep"
1511
2088
  | "run"
1512
2089
  | "onStateChange"
@@ -1533,16 +2110,7 @@ export type ActorConfig<
1533
2110
  TDatabase,
1534
2111
  TEvents,
1535
2112
  TQueues,
1536
- Actions<
1537
- TState,
1538
- TConnParams,
1539
- TConnState,
1540
- TVars,
1541
- TInput,
1542
- TDatabase,
1543
- TEvents,
1544
- TQueues
1545
- >
2113
+ TActions
1546
2114
  > &
1547
2115
  CreateState<
1548
2116
  TState,
@@ -1608,12 +2176,14 @@ export type ActorConfigInput<
1608
2176
  } & Omit<
1609
2177
  z.input<typeof ActorConfigSchema>,
1610
2178
  | "actions"
2179
+ | "tracing"
1611
2180
  | "events"
1612
2181
  | "queues"
1613
2182
  | "onCreate"
1614
2183
  | "onDestroy"
1615
2184
  | "onMigrate"
1616
2185
  | "onWake"
2186
+ | "onFork"
1617
2187
  | "onSleep"
1618
2188
  | "run"
1619
2189
  | "onStateChange"
@@ -1779,13 +2349,13 @@ export const DocActorOptionsSchema = z
1779
2349
  .number()
1780
2350
  .optional()
1781
2351
  .describe(
1782
- "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0.",
2352
+ "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 3.2.0.",
1783
2353
  ),
1784
2354
  waitUntilTimeout: z
1785
2355
  .number()
1786
2356
  .optional()
1787
2357
  .describe(
1788
- "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 2.2.0.",
2358
+ "Deprecated. Folded into sleepGracePeriod, which now bounds the entire graceful shutdown window for both sleep and destroy. Will be removed in 3.2.0.",
1789
2359
  ),
1790
2360
  stateSaveInterval: z
1791
2361
  .number()
@@ -1827,29 +2397,25 @@ export const DocActorOptionsSchema = z
1827
2397
  .describe(
1828
2398
  "Maximum number of queue messages before rejecting new messages. Default: 1000",
1829
2399
  ),
1830
- maxQueueMessageSize: z
2400
+ maxSchedules: z
1831
2401
  .number()
2402
+ .int()
2403
+ .nonnegative()
1832
2404
  .optional()
1833
2405
  .describe(
1834
- "Maximum size of each queue message in bytes. Default: 65536",
1835
- ),
1836
- canHibernateWebSocket: z
1837
- .boolean()
1838
- .optional()
1839
- .describe(
1840
- "Whether WebSockets using onWebSocket can be hibernated. WebSockets using actions/events are hibernatable by default. Default: false",
2406
+ "Maximum pending one-shot and recurring schedules before rejecting new schedules. Default: 1000",
1841
2407
  ),
1842
- preloadMaxWorkflowBytes: z
2408
+ maxQueueMessageSize: z
1843
2409
  .number()
1844
2410
  .optional()
1845
2411
  .describe(
1846
- "Override RivetKit's workflow preload budget for this actor. Set to 0 to disable workflow preloading.",
2412
+ "Maximum size of each queue message in bytes. Default: 65536",
1847
2413
  ),
1848
- preloadMaxConnectionsBytes: z
1849
- .number()
2414
+ canHibernateWebSocket: z
2415
+ .boolean()
1850
2416
  .optional()
1851
2417
  .describe(
1852
- "Override RivetKit's connections preload budget for this actor. Set to 0 to disable connections preloading.",
2418
+ "Whether WebSockets can be hibernated, both client connections for actions and events and WebSockets using onWebSocket. A WebSocket that does not hibernate closes when the actor sleeps. Default: false",
1853
2419
  ),
1854
2420
  })
1855
2421
  .describe("Actor options for timeouts and behavior configuration.");
@@ -1918,6 +2484,12 @@ export const DocActorConfigSchema = z
1918
2484
  .describe(
1919
2485
  "Called when the actor wakes up and is ready to receive connections and actions.",
1920
2486
  ),
2487
+ onFork: z
2488
+ .unknown()
2489
+ .optional()
2490
+ .describe(
2491
+ "Called once at the first start of an actor made by forking another actor, before onWake. Receives the source actor, the fork time and the fork input.",
2492
+ ),
1921
2493
  onSleep: z
1922
2494
  .unknown()
1923
2495
  .optional()
@@ -1974,13 +2546,19 @@ export const DocActorConfigSchema = z
1974
2546
  .record(z.string(), z.unknown())
1975
2547
  .optional()
1976
2548
  .describe(
1977
- "Map of action name to handler function. Defaults to an empty object.",
2549
+ "Tree of action names or nested groups to handler functions. Nested paths use dot-separated low-level action names. Defaults to an empty object.",
1978
2550
  ),
1979
2551
  actionInputSchemas: z
1980
2552
  .record(z.string(), z.unknown())
1981
2553
  .optional()
1982
2554
  .describe(
1983
- "Optional schema map for validating action argument tuples in native runtimes.",
2555
+ "Optional schemas for validating action argument tuples in native runtimes. May mirror nested action groups or use dot-separated low-level action names.",
2556
+ ),
2557
+ tracing: z
2558
+ .unknown()
2559
+ .optional()
2560
+ .describe(
2561
+ "Trace sampling for this actor: `sampler` is the share of its invocations that are recorded, from 0 to 1, with optional per-action rates under `actions`. A rate lowers what is recorded and never raises it. Defaults to the process sampler from OTEL_TRACES_SAMPLER.",
1984
2562
  ),
1985
2563
  connParamsSchema: z
1986
2564
  .unknown()