rivetkit 0.0.0-main.41efcce → 0.0.0-main.49693dc

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 (299) hide show
  1. package/dist/browser/client.d.ts +939 -104
  2. package/dist/browser/client.js +1867 -900
  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 +2079 -233
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +6 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -74
  10. package/dist/tsup/actor/errors.d.ts +1 -74
  11. package/dist/tsup/actor/errors.js +5 -1
  12. package/dist/tsup/agent-os/index.cjs +2408 -2029
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +932 -114
  15. package/dist/tsup/agent-os/index.d.ts +932 -114
  16. package/dist/tsup/agent-os/index.js +2412 -2033
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-J27CEW6F.js → chunk-2OBVQZX6.js} +6 -6
  19. package/dist/tsup/chunk-2OBVQZX6.js.map +1 -0
  20. package/dist/tsup/chunk-3ZWHWMFJ.js +14 -0
  21. package/dist/tsup/chunk-3ZWHWMFJ.js.map +1 -0
  22. package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-4KGXFC6M.cjs} +238 -22
  23. package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
  24. package/dist/tsup/{chunk-CVHUXINE.js → chunk-5IU3MI7X.js} +594 -72
  25. package/dist/tsup/chunk-5IU3MI7X.js.map +1 -0
  26. package/dist/tsup/{chunk-VD7AZIBR.js → chunk-6CXQMHZR.js} +1161 -361
  27. package/dist/tsup/chunk-6CXQMHZR.js.map +1 -0
  28. package/dist/tsup/{chunk-SBEFJ4IQ.js → chunk-6W2UIH3X.js} +70 -8
  29. package/dist/tsup/chunk-6W2UIH3X.js.map +1 -0
  30. package/dist/tsup/{chunk-7MRGNVSR.js → chunk-6W5VGLFT.js} +237 -21
  31. package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
  32. package/dist/tsup/{chunk-RF3MEJV6.cjs → chunk-B73TBMMG.cjs} +18 -11
  33. package/dist/tsup/chunk-B73TBMMG.cjs.map +1 -0
  34. package/dist/tsup/chunk-D6TORRA4.js +243 -0
  35. package/dist/tsup/chunk-D6TORRA4.js.map +1 -0
  36. package/dist/tsup/{chunk-PXLJOMJD.js → chunk-FXT3HN32.js} +2 -2
  37. package/dist/tsup/{chunk-ZGWSH7YV.js → chunk-IXBD7BXC.js} +48 -72
  38. package/dist/tsup/chunk-IXBD7BXC.js.map +1 -0
  39. package/dist/tsup/{chunk-3BFYSYRU.js → chunk-JI6GZ2C2.js} +4 -12
  40. package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
  41. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  42. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  43. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  44. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  45. package/dist/tsup/{chunk-SPMMF6TR.cjs → chunk-LGOWPZJ5.cjs} +3 -3
  46. package/dist/tsup/chunk-LGOWPZJ5.cjs.map +1 -0
  47. package/dist/tsup/chunk-LYNWTX6R.cjs +14 -0
  48. package/dist/tsup/chunk-LYNWTX6R.cjs.map +1 -0
  49. package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-MYWZCDML.cjs} +4 -12
  50. package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
  51. package/dist/tsup/{chunk-XSC2WWXD.js → chunk-NYDZLWHZ.js} +16 -9
  52. package/dist/tsup/chunk-NYDZLWHZ.js.map +1 -0
  53. package/dist/tsup/{chunk-AV54CVAG.cjs → chunk-RB7WUDX6.cjs} +1290 -490
  54. package/dist/tsup/chunk-RB7WUDX6.cjs.map +1 -0
  55. package/dist/tsup/{chunk-JTL6Y2UN.cjs → chunk-SPJORZMM.cjs} +49 -73
  56. package/dist/tsup/chunk-SPJORZMM.cjs.map +1 -0
  57. package/dist/tsup/chunk-SSMKIYEX.cjs +243 -0
  58. package/dist/tsup/chunk-SSMKIYEX.cjs.map +1 -0
  59. package/dist/tsup/{chunk-TQSL4NJ3.cjs → chunk-TQ4HSX2U.cjs} +72 -10
  60. package/dist/tsup/chunk-TQ4HSX2U.cjs.map +1 -0
  61. package/dist/tsup/{chunk-EVADNK6Z.cjs → chunk-U6ZQELGJ.cjs} +10 -10
  62. package/dist/tsup/chunk-U6ZQELGJ.cjs.map +1 -0
  63. package/dist/tsup/chunk-XLBMKZD3.cjs +1257 -0
  64. package/dist/tsup/chunk-XLBMKZD3.cjs.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 +18 -7
  68. package/dist/tsup/client/mod.d.ts +18 -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.cjs.map +1 -1
  77. package/dist/tsup/common/websocket.js +3 -3
  78. package/dist/tsup/{config-B3RIidaJ.d.ts → config-BXSV17G7.d.cts} +987 -72
  79. package/dist/tsup/{config-D6WxBYjV.d.cts → config-Bi1r6gI7.d.ts} +987 -72
  80. package/dist/tsup/{config-B9qUIHX4.d.ts → config-ey2I2zz5.d.cts} +82 -15
  81. package/dist/tsup/{config-B9qUIHX4.d.cts → config-ey2I2zz5.d.ts} +82 -15
  82. package/dist/tsup/context-4fJemY0D.d.cts +129 -0
  83. package/dist/tsup/context-D4sNYboo.d.ts +129 -0
  84. package/dist/tsup/db/drizzle.cjs +168 -103
  85. package/dist/tsup/db/drizzle.cjs.map +1 -1
  86. package/dist/tsup/db/drizzle.d.cts +8 -4
  87. package/dist/tsup/db/drizzle.d.ts +8 -4
  88. package/dist/tsup/db/drizzle.js +170 -105
  89. package/dist/tsup/db/drizzle.js.map +1 -1
  90. package/dist/tsup/db/mod.cjs +6 -163
  91. package/dist/tsup/db/mod.cjs.map +1 -1
  92. package/dist/tsup/db/mod.d.cts +12 -4
  93. package/dist/tsup/db/mod.d.ts +12 -4
  94. package/dist/tsup/db/mod.js +5 -162
  95. package/dist/tsup/db/mod.js.map +1 -1
  96. package/dist/tsup/dynamic/mod.cjs +24 -0
  97. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  98. package/dist/tsup/dynamic/mod.d.cts +38 -0
  99. package/dist/tsup/dynamic/mod.d.ts +38 -0
  100. package/dist/tsup/dynamic/mod.js +24 -0
  101. package/dist/tsup/dynamic/mod.js.map +1 -0
  102. package/dist/tsup/inspector/mod.cjs +47 -12
  103. package/dist/tsup/inspector/mod.cjs.map +1 -1
  104. package/dist/tsup/inspector/mod.d.cts +26 -136
  105. package/dist/tsup/inspector/mod.d.ts +26 -136
  106. package/dist/tsup/inspector/mod.js +46 -11
  107. package/dist/tsup/inspector/mod.js.map +1 -1
  108. package/dist/tsup/inspector/workflow.cjs +21 -0
  109. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  110. package/dist/tsup/inspector/workflow.d.cts +144 -0
  111. package/dist/tsup/inspector/workflow.d.ts +144 -0
  112. package/dist/tsup/inspector/workflow.js +21 -0
  113. package/dist/tsup/inspector/workflow.js.map +1 -0
  114. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  115. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  116. package/dist/tsup/inspector-tab/mod.d.cts +241 -0
  117. package/dist/tsup/inspector-tab/mod.d.ts +241 -0
  118. package/dist/tsup/inspector-tab/mod.js +162 -0
  119. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  120. package/dist/tsup/mod.cjs +4268 -944
  121. package/dist/tsup/mod.cjs.map +1 -1
  122. package/dist/tsup/mod.d.cts +9 -8
  123. package/dist/tsup/mod.d.ts +9 -8
  124. package/dist/tsup/mod.js +4229 -905
  125. package/dist/tsup/mod.js.map +1 -1
  126. package/dist/tsup/test/mod.cjs +26 -21
  127. package/dist/tsup/test/mod.cjs.map +1 -1
  128. package/dist/tsup/test/mod.d.cts +7 -6
  129. package/dist/tsup/test/mod.d.ts +7 -6
  130. package/dist/tsup/test/mod.js +25 -20
  131. package/dist/tsup/test/mod.js.map +1 -1
  132. package/dist/tsup/unstable/migrations.cjs +101 -0
  133. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  134. package/dist/tsup/unstable/migrations.d.cts +29 -0
  135. package/dist/tsup/unstable/migrations.d.ts +29 -0
  136. package/dist/tsup/unstable/migrations.js +101 -0
  137. package/dist/tsup/unstable/migrations.js.map +1 -0
  138. package/dist/tsup/utils-Bbz-3411.d.cts +162 -0
  139. package/dist/tsup/utils-BqdWVlzm.d.ts +162 -0
  140. package/dist/tsup/utils-vvJQyygr.d.cts +109 -0
  141. package/dist/tsup/utils-vvJQyygr.d.ts +109 -0
  142. package/dist/tsup/utils.cjs +7 -3
  143. package/dist/tsup/utils.cjs.map +1 -1
  144. package/dist/tsup/utils.d.cts +4 -147
  145. package/dist/tsup/utils.d.ts +4 -147
  146. package/dist/tsup/utils.js +6 -2
  147. package/dist/tsup/workflow/mod.cjs +517 -412
  148. package/dist/tsup/workflow/mod.cjs.map +1 -1
  149. package/dist/tsup/workflow/mod.d.cts +11 -10
  150. package/dist/tsup/workflow/mod.d.ts +11 -10
  151. package/dist/tsup/workflow/mod.js +511 -406
  152. package/dist/tsup/workflow/mod.js.map +1 -1
  153. package/package.json +62 -14
  154. package/src/actor/actions.ts +119 -0
  155. package/src/actor/config.test.ts +78 -0
  156. package/src/actor/config.ts +518 -96
  157. package/src/actor/contexts/index.ts +7 -2
  158. package/src/actor/definition.ts +38 -26
  159. package/src/actor/errors.ts +101 -89
  160. package/src/actor/keys.ts +2 -1
  161. package/src/actor/mod.ts +32 -21
  162. package/src/actor/schema.ts +2 -2
  163. package/src/agent-os/actor/cron.ts +37 -2
  164. package/src/agent-os/actor/index.ts +39 -19
  165. package/src/agent-os/actor/preview.ts +1 -2
  166. package/src/agent-os/actor/session.ts +2 -2
  167. package/src/agent-os/config.ts +1 -1
  168. package/src/agent-os/fs/database-vfs.ts +1 -1
  169. package/src/agent-os/index.ts +16 -15
  170. package/src/agent-os/types.ts +11 -0
  171. package/src/client/actor-common.ts +106 -53
  172. package/src/client/actor-conn.ts +94 -45
  173. package/src/client/actor-handle.ts +198 -79
  174. package/src/client/actor-query.ts +13 -6
  175. package/src/client/client.ts +43 -15
  176. package/src/client/config.ts +8 -0
  177. package/src/client/errors.ts +4 -2
  178. package/src/client/lifecycle-errors.ts +28 -4
  179. package/src/client/mod.ts +9 -4
  180. package/src/client/query.ts +3 -1
  181. package/src/client/queue.ts +8 -3
  182. package/src/client/raw-utils.ts +24 -16
  183. package/src/client/resolve-gateway-target.ts +3 -1
  184. package/src/client/utils.ts +36 -10
  185. package/src/common/actor-router-consts.ts +7 -0
  186. package/src/common/actor-websocket.ts +3 -1
  187. package/src/common/bare/actor-persist/v1.ts +205 -163
  188. package/src/common/bare/actor-persist/v2.ts +265 -213
  189. package/src/common/bare/actor-persist/v3.ts +176 -172
  190. package/src/common/bare/actor-persist/v4.ts +254 -253
  191. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  192. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  193. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  194. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  195. package/src/common/bare/transport/v1.ts +694 -542
  196. package/src/common/client-protocol-versioned.ts +176 -67
  197. package/src/common/client-protocol-zod.ts +7 -0
  198. package/src/common/client-protocol.ts +1 -1
  199. package/src/common/database/config.ts +103 -10
  200. package/src/common/database/mod.test.ts +364 -0
  201. package/src/common/database/mod.ts +278 -149
  202. package/src/common/database/native-database.test.ts +220 -0
  203. package/src/common/database/native-database.ts +394 -58
  204. package/src/common/database/shared.ts +25 -0
  205. package/src/common/encoding.ts +302 -38
  206. package/src/common/engine.ts +28 -1
  207. package/src/common/eventsource.ts +1 -1
  208. package/src/common/fetch-like.ts +49 -0
  209. package/src/common/inline-websocket-adapter.ts +14 -13
  210. package/src/common/inspector-transport.ts +12 -2
  211. package/src/common/log.ts +117 -14
  212. package/src/common/router.ts +49 -23
  213. package/src/common/utils.ts +23 -203
  214. package/src/common/websocket-interface.ts +1 -1
  215. package/src/db/drizzle.test.ts +164 -0
  216. package/src/db/drizzle.ts +207 -121
  217. package/src/db/mod.ts +6 -1
  218. package/src/devtools-loader/index.ts +4 -7
  219. package/src/devtools-loader/serve-devtools.ts +26 -0
  220. package/src/dynamic/instance.ts +32 -0
  221. package/src/dynamic/internal.ts +50 -0
  222. package/src/dynamic/isolate-runtime.ts +64 -0
  223. package/src/dynamic/mod.ts +32 -0
  224. package/src/engine-client/actor-http-client.ts +23 -4
  225. package/src/engine-client/actor-websocket-client.ts +32 -5
  226. package/src/engine-client/api-endpoints.ts +52 -2
  227. package/src/engine-client/api-utils.ts +2 -2
  228. package/src/engine-client/driver.ts +21 -17
  229. package/src/engine-client/mod.ts +116 -64
  230. package/src/engine-client/ws-proxy.ts +9 -4
  231. package/src/globals.d.ts +4 -0
  232. package/src/inspector/client.browser.ts +127 -15
  233. package/src/inspector/mod.ts +2 -4
  234. package/src/inspector/workflow.ts +61 -0
  235. package/src/inspector-tab/mod.ts +301 -0
  236. package/src/registry/config/envoy.ts +1 -2
  237. package/src/registry/config/index.ts +160 -53
  238. package/src/registry/config/serverless.ts +7 -1
  239. package/src/registry/index.ts +659 -96
  240. package/src/registry/napi-runtime.ts +1154 -0
  241. package/src/registry/native-validation.ts +10 -12
  242. package/src/registry/native.ts +2005 -955
  243. package/src/registry/process-metrics.ts +250 -0
  244. package/src/registry/run-handler-coordinator.test.ts +252 -0
  245. package/src/registry/run-handler-coordinator.ts +219 -0
  246. package/src/registry/runtime.test.ts +50 -0
  247. package/src/registry/runtime.ts +839 -0
  248. package/src/registry/wasm-runtime.ts +1283 -0
  249. package/src/registry/write-through-proxy.ts +141 -0
  250. package/src/serde.ts +8 -2
  251. package/src/serverless/configure.ts +102 -49
  252. package/src/test/mod.ts +2 -17
  253. package/src/test/ready.ts +22 -0
  254. package/src/unstable/migrations.test.ts +170 -0
  255. package/src/unstable/migrations.ts +141 -0
  256. package/src/utils/crypto.ts +14 -0
  257. package/src/utils/endpoint-parser.ts +1 -1
  258. package/src/utils/env-vars.ts +39 -0
  259. package/src/utils/node.ts +44 -28
  260. package/src/utils/router.ts +1 -1
  261. package/src/utils.ts +4 -2
  262. package/src/workflow/context.ts +683 -242
  263. package/src/workflow/driver.test.ts +62 -0
  264. package/src/workflow/driver.ts +246 -119
  265. package/src/workflow/inspector.ts +24 -24
  266. package/src/workflow/mod.ts +76 -84
  267. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  268. package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
  269. package/dist/tsup/chunk-6AVUJ52Q.cjs +0 -253
  270. package/dist/tsup/chunk-6AVUJ52Q.cjs.map +0 -1
  271. package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
  272. package/dist/tsup/chunk-7X7RVTFF.cjs +0 -735
  273. package/dist/tsup/chunk-7X7RVTFF.cjs.map +0 -1
  274. package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
  275. package/dist/tsup/chunk-AV54CVAG.cjs.map +0 -1
  276. package/dist/tsup/chunk-CVHUXINE.js.map +0 -1
  277. package/dist/tsup/chunk-EVADNK6Z.cjs.map +0 -1
  278. package/dist/tsup/chunk-J27CEW6F.js.map +0 -1
  279. package/dist/tsup/chunk-JTL6Y2UN.cjs.map +0 -1
  280. package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
  281. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  282. package/dist/tsup/chunk-RF3MEJV6.cjs.map +0 -1
  283. package/dist/tsup/chunk-SB4MXRN2.js +0 -253
  284. package/dist/tsup/chunk-SB4MXRN2.js.map +0 -1
  285. package/dist/tsup/chunk-SBEFJ4IQ.js.map +0 -1
  286. package/dist/tsup/chunk-SPMMF6TR.cjs.map +0 -1
  287. package/dist/tsup/chunk-TQSL4NJ3.cjs.map +0 -1
  288. package/dist/tsup/chunk-VD7AZIBR.js.map +0 -1
  289. package/dist/tsup/chunk-XSC2WWXD.js.map +0 -1
  290. package/dist/tsup/chunk-ZGWSH7YV.js.map +0 -1
  291. package/dist/tsup/context-BxvHh9wi.d.cts +0 -92
  292. package/dist/tsup/context-CNIZBIKl.d.ts +0 -92
  293. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  294. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  295. package/src/actor/driver.ts +0 -141
  296. package/src/actor/instance/mod.ts +0 -2501
  297. package/src/drivers/engine/actor-driver.ts +0 -2470
  298. package/src/utils/serve.ts +0 -217
  299. /package/dist/tsup/{chunk-PXLJOMJD.js.map → chunk-FXT3HN32.js.map} +0 -0
@@ -0,0 +1,839 @@
1
+ import type {
2
+ SqliteNativeMetrics,
3
+ SqliteProfilingOptions,
4
+ } from "@/common/database/config";
5
+ import { stringifyError } from "@/common/utils";
6
+ import type { RegistryConfig } from "./config";
7
+ import { logger } from "./log";
8
+
9
+ declare const handleBrand: unique symbol;
10
+
11
+ type OpaqueHandle<Name extends string> = {
12
+ readonly [handleBrand]: Name;
13
+ };
14
+
15
+ export type RegistryHandle = OpaqueHandle<"registry">;
16
+ export type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
17
+ export type ActorContextHandle = OpaqueHandle<"actorContext">;
18
+ export type ConnHandle = OpaqueHandle<"conn">;
19
+ export type WebSocketHandle = OpaqueHandle<"webSocket">;
20
+ export type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
21
+ export type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
22
+ export type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
23
+
24
+ export type RuntimeBytes = Uint8Array;
25
+
26
+ export interface RuntimeActorKeySegment {
27
+ kind: string;
28
+ stringValue?: string;
29
+ numberValue?: number;
30
+ }
31
+
32
+ export interface RuntimeHttpRequest {
33
+ method: string;
34
+ uri: string;
35
+ headers?: Record<string, string>;
36
+ body?: RuntimeBytes;
37
+ }
38
+
39
+ export interface RuntimeHttpResponse {
40
+ status?: number;
41
+ headers?: Record<string, string>;
42
+ body?: RuntimeBytes;
43
+ }
44
+
45
+ export interface RuntimeStateDeltaPayload {
46
+ state?: RuntimeBytes;
47
+ connHibernation: Array<{
48
+ connId: string;
49
+ bytes: RuntimeBytes;
50
+ }>;
51
+ connHibernationRemoved: string[];
52
+ }
53
+
54
+ export interface RuntimeWorkflowKvWrite {
55
+ key: RuntimeBytes;
56
+ value: RuntimeBytes;
57
+ }
58
+
59
+ export interface RuntimeRequestSaveOpts {
60
+ immediate?: boolean;
61
+ maxWaitMs?: number;
62
+ }
63
+
64
+ export interface RuntimeInspectorSnapshot {
65
+ stateRevision: number;
66
+ connectionsRevision: number;
67
+ queueRevision: number;
68
+ activeConnections: number;
69
+ queueSize: number;
70
+ connectedClients: number;
71
+ }
72
+
73
+ export interface RuntimeQueueMessage {
74
+ id(): bigint;
75
+ name(): string;
76
+ body(): RuntimeBytes;
77
+ createdAt(): number;
78
+ isCompletable(): boolean;
79
+ complete(response?: RuntimeBytes | undefined | null): Promise<void>;
80
+ }
81
+
82
+ export interface RuntimeQueueInspectMessage {
83
+ id: number;
84
+ name: string;
85
+ createdAtMs: number;
86
+ }
87
+
88
+ export interface RuntimeQueueSendResult {
89
+ status: string;
90
+ response?: RuntimeBytes;
91
+ }
92
+
93
+ export interface RuntimeScheduledEventInfo {
94
+ id: string;
95
+ action: string;
96
+ args: RuntimeBytes;
97
+ runAt: number;
98
+ }
99
+
100
+ export interface RuntimeCronJobInfo {
101
+ name: string;
102
+ kind: "cron" | "every";
103
+ action: string;
104
+ args: RuntimeBytes;
105
+ nextRunAt: number;
106
+ lastRunAt?: number;
107
+ expression?: string;
108
+ timezone?: string;
109
+ intervalMs?: number;
110
+ maxHistory: number;
111
+ }
112
+
113
+ export interface RuntimeScheduleErrorInfo {
114
+ group: string;
115
+ code: string;
116
+ message: string;
117
+ metadata?: unknown;
118
+ }
119
+
120
+ export interface RuntimeCronFire {
121
+ action: string;
122
+ scheduledAt: number;
123
+ firedAt: number;
124
+ finishedAt?: number;
125
+ result: "running" | "ok" | "error" | "skipped";
126
+ error?: RuntimeScheduleErrorInfo;
127
+ }
128
+
129
+ export interface RuntimeScheduledFireInfo {
130
+ kind: "at" | "cron" | "every";
131
+ id: string;
132
+ name?: string;
133
+ scheduledAt: number;
134
+ firedAt: number;
135
+ }
136
+
137
+ export interface RuntimeQueueNextBatchOptions {
138
+ names?: string[];
139
+ count?: number;
140
+ timeoutMs?: number;
141
+ completable?: boolean;
142
+ }
143
+
144
+ export interface RuntimeQueueWaitOptions {
145
+ timeoutMs?: number;
146
+ completable?: boolean;
147
+ }
148
+
149
+ export interface RuntimeQueueEnqueueAndWaitOptions {
150
+ timeoutMs?: number;
151
+ }
152
+
153
+ export interface RuntimeQueueTryNextBatchOptions {
154
+ names?: string[];
155
+ count?: number;
156
+ completable?: boolean;
157
+ }
158
+
159
+ export interface RuntimeKvListOptions {
160
+ reverse?: boolean;
161
+ limit?: number;
162
+ }
163
+
164
+ export interface RuntimeKvEntry {
165
+ key: RuntimeBytes;
166
+ value: RuntimeBytes;
167
+ }
168
+
169
+ type RuntimeSqlBindNoValues = {
170
+ intValue?: never;
171
+ floatValue?: never;
172
+ textValue?: never;
173
+ blobValue?: never;
174
+ };
175
+
176
+ export type RuntimeSqlBindParam =
177
+ | ({ kind: "null" } & RuntimeSqlBindNoValues)
178
+ | {
179
+ kind: "int";
180
+ intValue: number;
181
+ floatValue?: never;
182
+ textValue?: never;
183
+ blobValue?: never;
184
+ }
185
+ | {
186
+ kind: "float";
187
+ intValue?: never;
188
+ floatValue: number;
189
+ textValue?: never;
190
+ blobValue?: never;
191
+ }
192
+ | {
193
+ kind: "text";
194
+ intValue?: never;
195
+ floatValue?: never;
196
+ textValue: string;
197
+ blobValue?: never;
198
+ }
199
+ | {
200
+ kind: "blob";
201
+ intValue?: never;
202
+ floatValue?: never;
203
+ textValue?: never;
204
+ blobValue: RuntimeBytes;
205
+ };
206
+
207
+ export type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
208
+
209
+ export interface RuntimeActorRuntimeSocketEndpointInfo {
210
+ path: string;
211
+ }
212
+
213
+ export interface RuntimeSqlQueryResult {
214
+ columns: string[];
215
+ rows: unknown[][];
216
+ }
217
+
218
+ export type RuntimeSqlExecResult = RuntimeSqlQueryResult;
219
+
220
+ export interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
221
+ changes: number;
222
+ lastInsertRowId?: number | null;
223
+ }
224
+
225
+ export interface RuntimeSqlBatchStatement {
226
+ sql: string;
227
+ params?: RuntimeSqlBindParams;
228
+ }
229
+
230
+ export function normalizeRuntimeSqlExecuteResult(
231
+ result: RuntimeSqlQueryResult & {
232
+ changes: number;
233
+ lastInsertRowId?: number | null;
234
+ },
235
+ ): RuntimeSqlExecuteResult {
236
+ return result;
237
+ }
238
+
239
+ export interface RuntimeSqlRunResult {
240
+ changes: number;
241
+ }
242
+
243
+ export interface RuntimeSqlDatabase {
244
+ exec(sql: string): Promise<RuntimeSqlExecResult>;
245
+ execute(
246
+ sql: string,
247
+ params?: RuntimeSqlBindParams,
248
+ ): Promise<RuntimeSqlExecuteResult>;
249
+ executeBatch(
250
+ statements: RuntimeSqlBatchStatement[],
251
+ ): Promise<RuntimeSqlExecuteResult[]>;
252
+ query(
253
+ sql: string,
254
+ params?: RuntimeSqlBindParams,
255
+ ): Promise<RuntimeSqlQueryResult>;
256
+ run(
257
+ sql: string,
258
+ params?: RuntimeSqlBindParams,
259
+ ): Promise<RuntimeSqlRunResult>;
260
+ beginTransaction(
261
+ timeoutMs?: number,
262
+ name?: string,
263
+ ): Promise<RuntimeSqlTransactionDatabase>;
264
+ metrics?(): SqliteNativeMetrics | null;
265
+ takeLastKvError?(): string | null;
266
+ close(): Promise<void>;
267
+ }
268
+
269
+ export interface RuntimeSqlTransactionDatabase {
270
+ exec(sql: string): Promise<RuntimeSqlExecResult>;
271
+ execute(
272
+ sql: string,
273
+ params?: RuntimeSqlBindParams,
274
+ ): Promise<RuntimeSqlExecuteResult>;
275
+ commit(): Promise<void>;
276
+ rollback(): Promise<void>;
277
+ }
278
+
279
+ export interface RuntimeActorConfig {
280
+ name?: string;
281
+ icon?: string;
282
+ hasDatabase?: boolean;
283
+ remoteSqlite?: boolean;
284
+ sqliteProfiling?: SqliteProfilingOptions;
285
+ enableActorRuntimeSocket?: boolean;
286
+ hasState?: boolean;
287
+ canHibernateWebsocket?: boolean;
288
+ stateSaveIntervalMs?: number;
289
+ createStateTimeoutMs?: number;
290
+ onCreateTimeoutMs?: number;
291
+ createVarsTimeoutMs?: number;
292
+ createConnStateTimeoutMs?: number;
293
+ onBeforeConnectTimeoutMs?: number;
294
+ onConnectTimeoutMs?: number;
295
+ onMigrateTimeoutMs?: number;
296
+ onWakeTimeoutMs?: number;
297
+ onBeforeActorStartTimeoutMs?: number;
298
+ actionTimeoutMs?: number;
299
+ onRequestTimeoutMs?: number;
300
+ sleepTimeoutMs?: number;
301
+ noSleep?: boolean;
302
+ sleepGracePeriodMs?: number;
303
+ connectionLivenessTimeoutMs?: number;
304
+ connectionLivenessIntervalMs?: number;
305
+ maxQueueSize?: number;
306
+ maxSchedules?: number;
307
+ maxQueueMessageSize?: number;
308
+ maxIncomingMessageSize?: number;
309
+ maxOutgoingMessageSize?: number;
310
+ preloadMaxWorkflowBytes?: number;
311
+ preloadMaxConnectionsBytes?: number;
312
+ actions?: Array<{ name: string }>;
313
+ inspectorTabs?: Array<RuntimeInspectorTabEntry>;
314
+ }
315
+
316
+ export interface RuntimeInspectorTabEntry {
317
+ id: string;
318
+ /** Required for custom entries; omitted for built-in hides. */
319
+ label?: string;
320
+ /**
321
+ * Required for custom entries — absolute path to the source directory.
322
+ * Resolved on the TS side before being handed to the runtime.
323
+ */
324
+ source?: string;
325
+ /** Optional icon id for custom entries. */
326
+ icon?: string;
327
+ /** Set to true for built-in hide entries. */
328
+ hidden?: boolean;
329
+ }
330
+
331
+ export interface RuntimeServeConfig {
332
+ version: number;
333
+ endpoint: string;
334
+ token?: string;
335
+ namespace: string;
336
+ poolName: string;
337
+ engineBinaryPath?: string;
338
+ engineHost?: string;
339
+ enginePort?: number;
340
+ handleInspectorHttpInRuntime?: boolean;
341
+ inspectorTestToken?: string;
342
+ serverlessBasePath?: string;
343
+ serverlessPackageVersion: string;
344
+ serverlessClientEndpoint?: string;
345
+ serverlessClientNamespace?: string;
346
+ serverlessClientToken?: string;
347
+ serverlessValidateEndpoint: boolean;
348
+ serverlessMaxStartPayloadBytes: number;
349
+ }
350
+
351
+ export interface RuntimeListenerConfig {
352
+ port: number;
353
+ host?: string;
354
+ publicDir?: string;
355
+ application?: RuntimeApplicationFetch;
356
+ }
357
+
358
+ export interface RuntimeServerlessRequest {
359
+ method: string;
360
+ url: string;
361
+ headers: Record<string, string>;
362
+ body: RuntimeBytes;
363
+ }
364
+
365
+ export interface RuntimeApplicationResponse {
366
+ status: number;
367
+ headers: Record<string, string>;
368
+ body: RuntimeBytes;
369
+ }
370
+
371
+ export type RuntimeApplicationFetch = (
372
+ request: RuntimeServerlessRequest,
373
+ ) => Promise<RuntimeApplicationResponse>;
374
+
375
+ export interface RuntimeApplicationListenerConfig
376
+ extends RuntimeListenerConfig {
377
+ application: RuntimeApplicationFetch;
378
+ }
379
+
380
+ export interface RuntimeServerlessResponseHead {
381
+ status: number;
382
+ headers: Record<string, string>;
383
+ }
384
+
385
+ export interface RuntimeRegistryRouteResponse {
386
+ status: number;
387
+ headers: Record<string, string>;
388
+ body: RuntimeBytes;
389
+ }
390
+
391
+ export type RuntimeServerlessStreamEvent =
392
+ | {
393
+ kind: "chunk";
394
+ chunk?: RuntimeBytes;
395
+ }
396
+ | {
397
+ kind: "end";
398
+ error?: {
399
+ group: string;
400
+ code: string;
401
+ message: string;
402
+ };
403
+ };
404
+
405
+ export type RuntimeServerlessStreamCallback = (
406
+ error: unknown,
407
+ event?: RuntimeServerlessStreamEvent,
408
+ ) => unknown;
409
+
410
+ export type RuntimeWebSocketEvent =
411
+ | {
412
+ kind: "message";
413
+ data: string | RuntimeBytes;
414
+ binary: boolean;
415
+ messageIndex?: number;
416
+ }
417
+ | {
418
+ kind: "close";
419
+ code: number;
420
+ reason: string;
421
+ wasClean: boolean;
422
+ };
423
+
424
+ export interface CoreRuntime {
425
+ readonly kind: "napi" | "wasm";
426
+
427
+ createRegistry(): RegistryHandle;
428
+ registerActor(
429
+ registry: RegistryHandle,
430
+ name: string,
431
+ factory: ActorFactoryHandle,
432
+ ): void;
433
+ serveRegistry(
434
+ registry: RegistryHandle,
435
+ config: RuntimeServeConfig,
436
+ ): Promise<void>;
437
+ waitRegistryReady(registry: RegistryHandle): Promise<void>;
438
+ shutdownRegistry(registry: RegistryHandle): Promise<void>;
439
+ registryActorStopThresholdMs?(
440
+ registry: RegistryHandle,
441
+ ): Promise<number | undefined>;
442
+ handleServerlessRequest(
443
+ registry: RegistryHandle,
444
+ req: RuntimeServerlessRequest,
445
+ onStreamEvent: RuntimeServerlessStreamCallback,
446
+ cancelToken: CancellationTokenHandle,
447
+ config: RuntimeServeConfig,
448
+ ): Promise<RuntimeServerlessResponseHead>;
449
+ serveListener(
450
+ registry: RegistryHandle,
451
+ listener: RuntimeListenerConfig,
452
+ config: RuntimeServeConfig,
453
+ ): Promise<void>;
454
+ serveApplicationListener(
455
+ registry: RegistryHandle,
456
+ listener: RuntimeApplicationListenerConfig,
457
+ config: RuntimeServeConfig,
458
+ ): Promise<void>;
459
+ registryHealth?(
460
+ registry: RegistryHandle,
461
+ ): Promise<RuntimeRegistryRouteResponse>;
462
+ registryMetadata?(
463
+ registry: RegistryHandle,
464
+ ): Promise<RuntimeRegistryRouteResponse>;
465
+ registryMetrics?(
466
+ registry: RegistryHandle,
467
+ ): Promise<RuntimeRegistryRouteResponse>;
468
+ createActorFactory(
469
+ callbacks: object,
470
+ config?: RuntimeActorConfig | undefined | null,
471
+ ): ActorFactoryHandle;
472
+
473
+ createCancellationToken(): CancellationTokenHandle;
474
+ cancellationTokenAborted(token: CancellationTokenHandle): boolean;
475
+ cancelCancellationToken(token: CancellationTokenHandle): void;
476
+ onCancellationTokenCancelled(
477
+ token: CancellationTokenHandle,
478
+ callback: (...args: unknown[]) => unknown,
479
+ ): void;
480
+
481
+ actorState(ctx: ActorContextHandle): RuntimeBytes;
482
+ actorBeginOnStateChange(ctx: ActorContextHandle): void;
483
+ actorEndOnStateChange(ctx: ActorContextHandle): void;
484
+ actorSetAlarm(
485
+ ctx: ActorContextHandle,
486
+ timestampMs?: number | undefined | null,
487
+ ): void;
488
+ actorSetRunWakeAt(
489
+ ctx: ActorContextHandle,
490
+ timestampMs?: number | undefined | null,
491
+ ): Promise<void>;
492
+ actorRequestSave(
493
+ ctx: ActorContextHandle,
494
+ opts?: RuntimeRequestSaveOpts | undefined | null,
495
+ ): void;
496
+ actorRequestSaveAndWait(
497
+ ctx: ActorContextHandle,
498
+ opts?: RuntimeRequestSaveOpts | undefined | null,
499
+ ): Promise<void>;
500
+ actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
501
+ actorDecodeInspectorRequest(
502
+ ctx: ActorContextHandle,
503
+ bytes: RuntimeBytes,
504
+ advertisedVersion: number,
505
+ ): RuntimeBytes;
506
+ actorEncodeInspectorResponse(
507
+ ctx: ActorContextHandle,
508
+ bytes: RuntimeBytes,
509
+ targetVersion: number,
510
+ ): RuntimeBytes;
511
+ actorVerifyInspectorAuth(
512
+ ctx: ActorContextHandle,
513
+ bearerToken?: string | undefined | null,
514
+ ): Promise<void>;
515
+ actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
516
+ actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
517
+ actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
518
+ actorSaveState(
519
+ ctx: ActorContextHandle,
520
+ payload: RuntimeStateDeltaPayload,
521
+ ): Promise<void>;
522
+ actorSaveStateAndWorkflowBatch(
523
+ ctx: ActorContextHandle,
524
+ writes: RuntimeWorkflowKvWrite[],
525
+ ): Promise<void>;
526
+ actorId(ctx: ActorContextHandle): string;
527
+ actorName(ctx: ActorContextHandle): string;
528
+ actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
529
+ actorRegion(ctx: ActorContextHandle): string;
530
+ actorSleep(ctx: ActorContextHandle): void;
531
+ actorDestroy(ctx: ActorContextHandle): void;
532
+ actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
533
+ actorConns(ctx: ActorContextHandle): ConnHandle[];
534
+ actorConnectConn(
535
+ ctx: ActorContextHandle,
536
+ params: RuntimeBytes,
537
+ request?: RuntimeHttpRequest | undefined | null,
538
+ ): Promise<ConnHandle>;
539
+ actorBroadcast(
540
+ ctx: ActorContextHandle,
541
+ name: string,
542
+ args: RuntimeBytes,
543
+ ): void;
544
+ actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
545
+ actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
546
+ actorWaitForTrackedShutdownWorkUnbounded(
547
+ ctx: ActorContextHandle,
548
+ ): Promise<void>;
549
+ actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
550
+ actorBeginKeepAwake(ctx: ActorContextHandle): number;
551
+ actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
552
+ actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
553
+ actorRuntimeState(ctx: ActorContextHandle): object;
554
+ actorClearRuntimeState(ctx: ActorContextHandle): void;
555
+ actorRestartRunHandler(ctx: ActorContextHandle): void;
556
+ actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
557
+ actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
558
+
559
+ actorKvGet(
560
+ ctx: ActorContextHandle,
561
+ key: RuntimeBytes,
562
+ ): Promise<RuntimeBytes | null>;
563
+ actorKvPut(
564
+ ctx: ActorContextHandle,
565
+ key: RuntimeBytes,
566
+ value: RuntimeBytes,
567
+ ): Promise<void>;
568
+ actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
569
+ actorKvDeleteRange(
570
+ ctx: ActorContextHandle,
571
+ start: RuntimeBytes,
572
+ end: RuntimeBytes,
573
+ ): Promise<void>;
574
+ actorKvListPrefix(
575
+ ctx: ActorContextHandle,
576
+ prefix: RuntimeBytes,
577
+ options?: RuntimeKvListOptions | undefined | null,
578
+ ): Promise<RuntimeKvEntry[]>;
579
+ actorKvListRange(
580
+ ctx: ActorContextHandle,
581
+ start: RuntimeBytes,
582
+ end: RuntimeBytes,
583
+ options?: RuntimeKvListOptions | undefined | null,
584
+ ): Promise<RuntimeKvEntry[]>;
585
+ actorKvBatchGet(
586
+ ctx: ActorContextHandle,
587
+ keys: RuntimeBytes[],
588
+ ): Promise<Array<RuntimeBytes | undefined | null>>;
589
+ actorKvBatchPut(
590
+ ctx: ActorContextHandle,
591
+ entries: RuntimeKvEntry[],
592
+ ): Promise<void>;
593
+ actorKvBatchDelete(
594
+ ctx: ActorContextHandle,
595
+ keys: RuntimeBytes[],
596
+ ): Promise<void>;
597
+
598
+ actorSqlExec(
599
+ ctx: ActorContextHandle,
600
+ sql: string,
601
+ ): Promise<RuntimeSqlExecResult>;
602
+ actorSqlExecute(
603
+ ctx: ActorContextHandle,
604
+ sql: string,
605
+ params?: RuntimeSqlBindParams,
606
+ ): Promise<RuntimeSqlExecuteResult>;
607
+ actorSqlExecuteBatch(
608
+ ctx: ActorContextHandle,
609
+ statements: RuntimeSqlBatchStatement[],
610
+ ): Promise<RuntimeSqlExecuteResult[]>;
611
+ actorSqlBeginTransaction(
612
+ ctx: ActorContextHandle,
613
+ timeoutMs?: number,
614
+ name?: string,
615
+ ): Promise<SqliteTransactionHandle>;
616
+ actorSqlTransactionExec(
617
+ transaction: SqliteTransactionHandle,
618
+ sql: string,
619
+ ): Promise<RuntimeSqlExecResult>;
620
+ actorSqlTransactionExecute(
621
+ transaction: SqliteTransactionHandle,
622
+ sql: string,
623
+ params?: RuntimeSqlBindParams,
624
+ ): Promise<RuntimeSqlExecuteResult>;
625
+ actorSqlTransactionCommit(
626
+ transaction: SqliteTransactionHandle,
627
+ ): Promise<void>;
628
+ actorSqlTransactionRollback(
629
+ transaction: SqliteTransactionHandle,
630
+ ): Promise<void>;
631
+ actorBeginStateTransaction(
632
+ ctx: ActorContextHandle,
633
+ timeoutMs?: number,
634
+ ): Promise<ActorStateTransactionHandle>;
635
+ actorStateTransactionExecute(
636
+ transaction: ActorStateTransactionHandle,
637
+ sql: string,
638
+ params?: RuntimeSqlBindParams,
639
+ ): Promise<RuntimeSqlExecuteResult>;
640
+ actorStateTransactionCommit(
641
+ transaction: ActorStateTransactionHandle,
642
+ payload: RuntimeStateDeltaPayload,
643
+ ): Promise<void>;
644
+ actorStateTransactionRollback(
645
+ transaction: ActorStateTransactionHandle,
646
+ ): Promise<void>;
647
+ actorSqlQuery(
648
+ ctx: ActorContextHandle,
649
+ sql: string,
650
+ params?: RuntimeSqlBindParams,
651
+ ): Promise<RuntimeSqlQueryResult>;
652
+ actorSqlRun(
653
+ ctx: ActorContextHandle,
654
+ sql: string,
655
+ params?: RuntimeSqlBindParams,
656
+ ): Promise<RuntimeSqlRunResult>;
657
+ actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
658
+ actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
659
+ actorSqlClose(ctx: ActorContextHandle): Promise<void>;
660
+ actorRuntimeSocketProvision(
661
+ ctx: ActorContextHandle,
662
+ ): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
663
+
664
+ actorQueueSend(
665
+ ctx: ActorContextHandle,
666
+ name: string,
667
+ body: RuntimeBytes,
668
+ ): Promise<RuntimeQueueMessage>;
669
+ actorQueueNextBatch(
670
+ ctx: ActorContextHandle,
671
+ options?: RuntimeQueueNextBatchOptions | undefined | null,
672
+ signal?: CancellationTokenHandle | undefined | null,
673
+ ): Promise<RuntimeQueueMessage[]>;
674
+ actorQueueWaitForNames(
675
+ ctx: ActorContextHandle,
676
+ names: string[],
677
+ options?: RuntimeQueueWaitOptions | undefined | null,
678
+ signal?: CancellationTokenHandle | undefined | null,
679
+ ): Promise<RuntimeQueueMessage>;
680
+ actorQueueWaitForNamesAvailable(
681
+ ctx: ActorContextHandle,
682
+ names: string[],
683
+ options?: RuntimeQueueWaitOptions | undefined | null,
684
+ signal?: CancellationTokenHandle | undefined | null,
685
+ ): Promise<void>;
686
+ actorQueueCompletePersisted(
687
+ ctx: ActorContextHandle,
688
+ messageId: bigint,
689
+ expectedName: string,
690
+ response?: RuntimeBytes | undefined | null,
691
+ ): Promise<boolean>;
692
+ actorQueueEnqueueAndWait(
693
+ ctx: ActorContextHandle,
694
+ name: string,
695
+ body: RuntimeBytes,
696
+ options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null,
697
+ signal?: CancellationTokenHandle | undefined | null,
698
+ ): Promise<RuntimeBytes | null>;
699
+ actorQueueTryNextBatch(
700
+ ctx: ActorContextHandle,
701
+ options?: RuntimeQueueTryNextBatchOptions | undefined | null,
702
+ ): RuntimeQueueMessage[];
703
+ actorQueueMaxSize(ctx: ActorContextHandle): number;
704
+ actorQueueInspectMessages(
705
+ ctx: ActorContextHandle,
706
+ ): Promise<RuntimeQueueInspectMessage[]>;
707
+ actorQueueReset(ctx: ActorContextHandle): Promise<void>;
708
+
709
+ actorScheduleAfter(
710
+ ctx: ActorContextHandle,
711
+ durationMs: number,
712
+ actionName: string,
713
+ args: RuntimeBytes,
714
+ ): Promise<string>;
715
+ actorScheduleAt(
716
+ ctx: ActorContextHandle,
717
+ timestampMs: number,
718
+ actionName: string,
719
+ args: RuntimeBytes,
720
+ ): Promise<string>;
721
+ actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
722
+ actorScheduleGet(
723
+ ctx: ActorContextHandle,
724
+ id: string,
725
+ ): Promise<RuntimeScheduledEventInfo | undefined>;
726
+ actorScheduleList(
727
+ ctx: ActorContextHandle,
728
+ ): Promise<RuntimeScheduledEventInfo[]>;
729
+ actorCronSet(
730
+ ctx: ActorContextHandle,
731
+ name: string,
732
+ expression: string,
733
+ timezone: string | undefined,
734
+ actionName: string,
735
+ args: RuntimeBytes,
736
+ maxHistory: number | undefined,
737
+ ): Promise<void>;
738
+ actorCronEvery(
739
+ ctx: ActorContextHandle,
740
+ name: string,
741
+ intervalMs: number,
742
+ actionName: string,
743
+ args: RuntimeBytes,
744
+ maxHistory: number | undefined,
745
+ ): Promise<void>;
746
+ actorCronGet(
747
+ ctx: ActorContextHandle,
748
+ name: string,
749
+ ): Promise<RuntimeCronJobInfo | undefined>;
750
+ actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
751
+ actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
752
+ actorCronHistory(
753
+ ctx: ActorContextHandle,
754
+ name: string,
755
+ limit: number | undefined,
756
+ ): Promise<RuntimeCronFire[]>;
757
+
758
+ connId(conn: ConnHandle): string;
759
+ connParams(conn: ConnHandle): RuntimeBytes;
760
+ connState(conn: ConnHandle): RuntimeBytes;
761
+ connSetState(conn: ConnHandle, state: RuntimeBytes): void;
762
+ connIsHibernatable(conn: ConnHandle): boolean;
763
+ connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
764
+ connDisconnect(
765
+ conn: ConnHandle,
766
+ reason?: string | undefined | null,
767
+ ): Promise<void>;
768
+
769
+ webSocketSend(
770
+ ws: WebSocketHandle,
771
+ data: RuntimeBytes,
772
+ binary: boolean,
773
+ ): void;
774
+ webSocketClose(
775
+ ws: WebSocketHandle,
776
+ code?: number | undefined | null,
777
+ reason?: string | undefined | null,
778
+ ): Promise<void>;
779
+ webSocketSetEventCallback(
780
+ ws: WebSocketHandle,
781
+ callback: (event: RuntimeWebSocketEvent) => void,
782
+ ): void;
783
+ }
784
+
785
+ export interface RuntimeBundle {
786
+ runtime: CoreRuntime;
787
+ }
788
+
789
+ export async function buildServeConfig(
790
+ config: RegistryConfig,
791
+ loadEnginePath: () => Promise<string>,
792
+ version: string,
793
+ ): Promise<RuntimeServeConfig> {
794
+ if (!config.endpoint) {
795
+ throw new Error("registry endpoint is required");
796
+ }
797
+
798
+ const serveConfig: RuntimeServeConfig = {
799
+ version: config.envoy.version,
800
+ endpoint: config.endpoint,
801
+ token: config.token,
802
+ namespace: config.namespace,
803
+ poolName: config.envoy.poolName,
804
+ handleInspectorHttpInRuntime: true,
805
+ serverlessBasePath: config.serverless.basePath,
806
+ serverlessPackageVersion: version,
807
+ serverlessClientEndpoint: config.publicEndpoint,
808
+ serverlessClientNamespace: config.publicNamespace,
809
+ serverlessClientToken: config.publicToken,
810
+ serverlessValidateEndpoint: config.validateServerlessEndpoint,
811
+ serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes,
812
+ };
813
+
814
+ // Always best-effort resolve the engine binary path and hand it to the core.
815
+ // The core alone decides whether to actually spawn a local engine, so JS must
816
+ // not duplicate that decision here. `loadEnginePath` throws when no binary is
817
+ // available (remote-only install, unsupported platform, optional deps
818
+ // skipped); in that case leave it unset and let the core report
819
+ // `engine.binary_unavailable` only if it actually needs one.
820
+ try {
821
+ serveConfig.engineBinaryPath = await loadEnginePath();
822
+ } catch (error) {
823
+ // The engine binary could not be resolved. The core still decides whether
824
+ // it needs to spawn a local engine; if it does, it will fail with
825
+ // engine.binary_unavailable (auto-download is off in the napi runtime).
826
+ logger().warn({
827
+ msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable — set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
828
+ error: stringifyError(error),
829
+ });
830
+ }
831
+ serveConfig.engineHost = config.engineHost;
832
+ serveConfig.enginePort = config.enginePort;
833
+ if (config.test?.enabled) {
834
+ serveConfig.inspectorTestToken =
835
+ process.env._RIVET_TEST_INSPECTOR_TOKEN ?? "token";
836
+ }
837
+
838
+ return serveConfig;
839
+ }