rivetkit 0.0.0-sqlite-profiling-compat.87d61c0 → 0.0.0-sqlite-sync-3x-release.a00b07f

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 (277) hide show
  1. package/dist/browser/client.d.ts +1317 -765
  2. package/dist/browser/client.js +1457 -737
  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 +2042 -228
  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 -1
  10. package/dist/tsup/actor/errors.d.ts +1 -1
  11. package/dist/tsup/actor/errors.js +5 -1
  12. package/dist/tsup/agent-os/index.cjs +3 -2367
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +1 -2277
  15. package/dist/tsup/agent-os/index.d.ts +1 -2277
  16. package/dist/tsup/agent-os/index.js +3 -2367
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-E4LNLI3W.cjs → chunk-2MOLY6AM.cjs} +444 -29
  19. package/dist/tsup/chunk-2MOLY6AM.cjs.map +1 -0
  20. package/dist/tsup/{chunk-OAUFXOG7.js → chunk-3DONDAMG.js} +2 -2
  21. package/dist/tsup/{chunk-XIX5DOZN.js → chunk-6FEYCVZC.js} +196 -20
  22. package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
  23. package/dist/tsup/chunk-6KXVLIXL.cjs +14 -0
  24. package/dist/tsup/chunk-6KXVLIXL.cjs.map +1 -0
  25. package/dist/tsup/chunk-73RNTXHB.cjs +243 -0
  26. package/dist/tsup/chunk-73RNTXHB.cjs.map +1 -0
  27. package/dist/tsup/{chunk-HXUEHHJF.js → chunk-A2CF6PFH.js} +19 -11
  28. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  29. package/dist/tsup/{chunk-EFU4JW3T.js → chunk-BRH4PQS5.js} +436 -21
  30. package/dist/tsup/chunk-BRH4PQS5.js.map +1 -0
  31. package/dist/tsup/{chunk-GM45LG7L.cjs → chunk-BTSDFFDC.cjs} +18 -11
  32. package/dist/tsup/chunk-BTSDFFDC.cjs.map +1 -0
  33. package/dist/tsup/{chunk-B3GLD4IN.js → chunk-D5WUPE47.js} +50 -3
  34. package/dist/tsup/chunk-D5WUPE47.js.map +1 -0
  35. package/dist/tsup/{chunk-O3ZUMAN7.js → chunk-DJUBJQEQ.js} +3 -3
  36. package/dist/tsup/chunk-DJUBJQEQ.js.map +1 -0
  37. package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-HDVZ6YZG.cjs} +197 -21
  38. package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
  39. package/dist/tsup/{chunk-JZ7TWV65.js → chunk-JTHHCZCZ.js} +24 -1
  40. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  41. package/dist/tsup/{chunk-D363DMNH.cjs → chunk-JUHXV3HF.cjs} +3 -3
  42. package/dist/tsup/chunk-JUHXV3HF.cjs.map +1 -0
  43. package/dist/tsup/chunk-JUWMP5O3.js +14 -0
  44. package/dist/tsup/chunk-JUWMP5O3.js.map +1 -0
  45. package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-KVFIONKQ.cjs} +25 -2
  46. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  47. package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
  48. package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
  49. package/dist/tsup/{chunk-BWERJMV6.cjs → chunk-OTVJYZ2L.cjs} +1139 -470
  50. package/dist/tsup/chunk-OTVJYZ2L.cjs.map +1 -0
  51. package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-RTWH3AX3.cjs} +18 -10
  52. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  53. package/dist/tsup/{chunk-DTRDGPHU.cjs → chunk-TM76Z7XT.cjs} +7 -7
  54. package/dist/tsup/chunk-TM76Z7XT.cjs.map +1 -0
  55. package/dist/tsup/{chunk-3GVMLSND.js → chunk-TRUHDXOU.js} +1023 -354
  56. package/dist/tsup/chunk-TRUHDXOU.js.map +1 -0
  57. package/dist/tsup/{chunk-PT7AC5PC.js → chunk-TSQTI6H6.js} +16 -9
  58. package/dist/tsup/chunk-TSQTI6H6.js.map +1 -0
  59. package/dist/tsup/{chunk-FNAXD5BQ.cjs → chunk-Z7E2G3JZ.cjs} +52 -5
  60. package/dist/tsup/chunk-Z7E2G3JZ.cjs.map +1 -0
  61. package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
  62. package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
  63. package/dist/tsup/chunk-ZYK4B5WV.js +243 -0
  64. package/dist/tsup/chunk-ZYK4B5WV.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 +32 -6
  68. package/dist/tsup/client/mod.d.ts +32 -6
  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-BR1Nn0QQ.d.ts → config-B4erdavw.d.ts} +571 -65
  79. package/dist/tsup/{config-B0LNDrLY.d.cts → config-BfG1qpYz.d.cts} +80 -14
  80. package/dist/tsup/{config-B0LNDrLY.d.ts → config-BfG1qpYz.d.ts} +80 -14
  81. package/dist/tsup/{config-tCvkwzyN.d.cts → config-DK144OAw.d.cts} +571 -65
  82. package/dist/tsup/{context-D4WDwf9m.d.cts → context-Cvnf3BRe.d.cts} +3 -2
  83. package/dist/tsup/{context-oc9zhA3x.d.ts → context-Oxi6YWcG.d.ts} +3 -2
  84. package/dist/tsup/db/drizzle.cjs +127 -67
  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 +127 -67
  89. package/dist/tsup/db/drizzle.js.map +1 -1
  90. package/dist/tsup/db/mod.cjs +6 -126
  91. package/dist/tsup/db/mod.cjs.map +1 -1
  92. package/dist/tsup/db/mod.d.cts +8 -4
  93. package/dist/tsup/db/mod.d.ts +8 -4
  94. package/dist/tsup/db/mod.js +5 -125
  95. package/dist/tsup/db/mod.js.map +1 -1
  96. package/dist/tsup/dynamic/mod.cjs +2 -2
  97. package/dist/tsup/dynamic/mod.cjs.map +1 -1
  98. package/dist/tsup/dynamic/mod.d.cts +6 -4
  99. package/dist/tsup/dynamic/mod.d.ts +6 -4
  100. package/dist/tsup/dynamic/mod.js +1 -1
  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 +2 -13
  114. package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
  115. package/dist/tsup/inspector-tab/mod.d.cts +9 -17
  116. package/dist/tsup/inspector-tab/mod.d.ts +9 -17
  117. package/dist/tsup/inspector-tab/mod.js +1 -12
  118. package/dist/tsup/inspector-tab/mod.js.map +1 -1
  119. package/dist/tsup/mod.cjs +2724 -611
  120. package/dist/tsup/mod.cjs.map +1 -1
  121. package/dist/tsup/mod.d.cts +9 -7
  122. package/dist/tsup/mod.d.ts +9 -7
  123. package/dist/tsup/mod.js +2641 -528
  124. package/dist/tsup/mod.js.map +1 -1
  125. package/dist/tsup/test/mod.cjs +19 -17
  126. package/dist/tsup/test/mod.cjs.map +1 -1
  127. package/dist/tsup/test/mod.d.cts +6 -4
  128. package/dist/tsup/test/mod.d.ts +6 -4
  129. package/dist/tsup/test/mod.js +18 -16
  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-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
  138. package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -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 +260 -200
  147. package/dist/tsup/workflow/mod.cjs.map +1 -1
  148. package/dist/tsup/workflow/mod.d.cts +8 -6
  149. package/dist/tsup/workflow/mod.d.ts +8 -6
  150. package/dist/tsup/workflow/mod.js +249 -189
  151. package/dist/tsup/workflow/mod.js.map +1 -1
  152. package/package.json +34 -14
  153. package/src/actor/actions.ts +155 -0
  154. package/src/actor/config.ts +403 -43
  155. package/src/actor/definition.ts +26 -7
  156. package/src/actor/errors.ts +87 -5
  157. package/src/actor/keys.ts +86 -0
  158. package/src/actor/mod.ts +15 -1
  159. package/src/actor/tracing.ts +28 -0
  160. package/src/agent-os/index.ts +5 -65
  161. package/src/client/actor-common.ts +8 -15
  162. package/src/client/actor-conn.ts +135 -8
  163. package/src/client/actor-handle.ts +180 -42
  164. package/src/client/actor-query.ts +8 -1
  165. package/src/client/auth.ts +37 -0
  166. package/src/client/client.ts +89 -21
  167. package/src/client/config.ts +27 -2
  168. package/src/client/errors.ts +2 -1
  169. package/src/client/lifecycle-errors.ts +16 -1
  170. package/src/client/mod.ts +9 -0
  171. package/src/client/outbound-telemetry.ts +66 -0
  172. package/src/client/query.ts +2 -0
  173. package/src/client/queue.ts +3 -0
  174. package/src/client/raw-utils.ts +37 -8
  175. package/src/client/resolve-gateway-target.ts +2 -0
  176. package/src/client/retry-budget.ts +78 -0
  177. package/src/client/token-provider.ts +93 -0
  178. package/src/client/utils.ts +16 -2
  179. package/src/common/actor-router-consts.ts +5 -0
  180. package/src/common/actor-telemetry-context.ts +19 -0
  181. package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
  182. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  183. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  184. package/src/common/bare/transport/v1.ts +36 -0
  185. package/src/common/database/config.ts +108 -15
  186. package/src/common/database/mod.ts +247 -76
  187. package/src/common/database/native-database.ts +433 -23
  188. package/src/common/database/shared.ts +24 -0
  189. package/src/common/encoding.ts +31 -21
  190. package/src/common/fetch-like.ts +63 -0
  191. package/src/common/inspector-transport.ts +12 -2
  192. package/src/common/log.ts +14 -8
  193. package/src/common/otel-context.ts +99 -0
  194. package/src/common/router.ts +1 -1
  195. package/src/common/utils.ts +7 -19
  196. package/src/db/drizzle.ts +182 -80
  197. package/src/db/mod.ts +2 -0
  198. package/src/dynamic/isolate-runtime.ts +0 -2
  199. package/src/engine-api/actors.ts +3 -3
  200. package/src/engine-client/actor-http-client.ts +29 -20
  201. package/src/engine-client/actor-websocket-client.ts +6 -3
  202. package/src/engine-client/api-endpoints.ts +72 -14
  203. package/src/engine-client/driver.ts +8 -15
  204. package/src/engine-client/mod.ts +248 -112
  205. package/src/inspector/client.browser.ts +134 -16
  206. package/src/inspector/mod.ts +1 -1
  207. package/src/inspector/workflow.ts +61 -0
  208. package/src/inspector-tab/mod.ts +1 -15
  209. package/src/registry/config/envoy.ts +2 -18
  210. package/src/registry/config/index.ts +53 -61
  211. package/src/registry/index.ts +311 -21
  212. package/src/registry/napi-runtime.ts +583 -39
  213. package/src/registry/native-http.ts +225 -0
  214. package/src/registry/native.ts +1365 -414
  215. package/src/registry/run-handler-coordinator.ts +219 -0
  216. package/src/registry/runtime.ts +372 -7
  217. package/src/registry/wasm-runtime.ts +490 -21
  218. package/src/registry/write-through-proxy.ts +101 -0
  219. package/src/test/mod.ts +1 -19
  220. package/src/test/ready.ts +22 -0
  221. package/src/unstable/migrations.ts +141 -0
  222. package/src/utils/env-vars.ts +15 -6
  223. package/src/utils/node.ts +44 -28
  224. package/src/utils.ts +3 -0
  225. package/src/workflow/context.ts +9 -27
  226. package/src/workflow/driver.ts +253 -116
  227. package/src/workflow/inspector.ts +23 -24
  228. package/src/workflow/mod.ts +50 -72
  229. package/dist/tsup/chunk-3GVMLSND.js.map +0 -1
  230. package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
  231. package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
  232. package/dist/tsup/chunk-B3GLD4IN.js.map +0 -1
  233. package/dist/tsup/chunk-BWERJMV6.cjs.map +0 -1
  234. package/dist/tsup/chunk-D363DMNH.cjs.map +0 -1
  235. package/dist/tsup/chunk-DTRDGPHU.cjs.map +0 -1
  236. package/dist/tsup/chunk-E4LNLI3W.cjs.map +0 -1
  237. package/dist/tsup/chunk-EFU4JW3T.js.map +0 -1
  238. package/dist/tsup/chunk-FNAXD5BQ.cjs.map +0 -1
  239. package/dist/tsup/chunk-GM45LG7L.cjs.map +0 -1
  240. package/dist/tsup/chunk-HXUEHHJF.js.map +0 -1
  241. package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
  242. package/dist/tsup/chunk-O3ZUMAN7.js.map +0 -1
  243. package/dist/tsup/chunk-P6F5MEWX.cjs +0 -382
  244. package/dist/tsup/chunk-P6F5MEWX.cjs.map +0 -1
  245. package/dist/tsup/chunk-PT7AC5PC.js.map +0 -1
  246. package/dist/tsup/chunk-UV7INX3N.js +0 -382
  247. package/dist/tsup/chunk-UV7INX3N.js.map +0 -1
  248. package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
  249. package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
  250. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
  251. package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
  252. package/src/actor/driver.ts +0 -141
  253. package/src/actor/instance/mod.ts +0 -2484
  254. package/src/actor/keys.test.ts +0 -275
  255. package/src/actor/utils.test.ts +0 -48
  256. package/src/agent-os/actor/cron.ts +0 -84
  257. package/src/agent-os/actor/db.ts +0 -54
  258. package/src/agent-os/actor/filesystem.ts +0 -131
  259. package/src/agent-os/actor/index.ts +0 -285
  260. package/src/agent-os/actor/network.ts +0 -58
  261. package/src/agent-os/actor/preview.ts +0 -190
  262. package/src/agent-os/actor/process.ts +0 -177
  263. package/src/agent-os/actor/session.ts +0 -518
  264. package/src/agent-os/actor/shell.ts +0 -60
  265. package/src/agent-os/config.ts +0 -79
  266. package/src/agent-os/fs/database-vfs.ts +0 -624
  267. package/src/agent-os/types.ts +0 -148
  268. package/src/client/test.ts +0 -44
  269. package/src/common/database/mod.test.ts +0 -137
  270. package/src/common/database/native-database.test.ts +0 -211
  271. package/src/common/inline-websocket-adapter.test.ts +0 -51
  272. package/src/drivers/engine/actor-driver.ts +0 -2473
  273. package/src/registry/process-metrics.ts +0 -250
  274. package/src/registry/runtime.test.ts +0 -50
  275. package/src/utils/endpoint-parser.test.ts +0 -206
  276. package/src/utils.test.ts +0 -34
  277. /package/dist/tsup/{chunk-OAUFXOG7.js.map → chunk-3DONDAMG.js.map} +0 -0
@@ -1,12 +1,6 @@
1
- import type {
2
- ActorContext as WasmActorContext,
3
- ActorFactory as WasmActorFactory,
4
- CancellationToken as WasmCancellationToken,
5
- ConnHandle as WasmConnHandle,
6
- CoreRegistry as WasmCoreRegistry,
7
- WebSocketHandle as WasmWebSocketHandle,
8
- } from "@rivetkit/rivetkit-wasm";
1
+ import type { WorkflowSpan } from "@/actor/config";
9
2
  import { decodeBridgeRivetError, RivetError } from "@/actor/errors";
3
+ import type { ActorInvocationTraceContext } from "@/common/actor-telemetry-context";
10
4
  import type {
11
5
  WasmRuntimeBindings,
12
6
  WasmRuntimeConfig,
@@ -15,18 +9,23 @@ import type {
15
9
  import type {
16
10
  ActorContextHandle,
17
11
  ActorFactoryHandle,
12
+ ActorStateTransactionHandle,
18
13
  CancellationTokenHandle,
19
14
  ConnHandle,
20
15
  CoreRuntime,
21
16
  RegistryHandle,
22
17
  RuntimeActorConfig,
23
18
  RuntimeActorKeySegment,
19
+ RuntimeApplicationListenerConfig,
24
20
  RuntimeBytes,
21
+ RuntimeCronFire,
22
+ RuntimeCronJobInfo,
25
23
  RuntimeHttpRequest,
26
24
  RuntimeInspectorSnapshot,
27
25
  RuntimeKvEntry,
28
26
  RuntimeKvListOptions,
29
27
  RuntimeListenerConfig,
28
+ RuntimeOutboundCall,
30
29
  RuntimeQueueEnqueueAndWaitOptions,
31
30
  RuntimeQueueInspectMessage,
32
31
  RuntimeQueueMessage,
@@ -35,10 +34,12 @@ import type {
35
34
  RuntimeQueueWaitOptions,
36
35
  RuntimeRegistryRouteResponse,
37
36
  RuntimeRequestSaveOpts,
37
+ RuntimeScheduledEventInfo,
38
38
  RuntimeServeConfig,
39
39
  RuntimeServerlessRequest,
40
40
  RuntimeServerlessResponseHead,
41
41
  RuntimeServerlessStreamCallback,
42
+ RuntimeSqlBatchStatement,
42
43
  RuntimeSqlBindParams,
43
44
  RuntimeSqlDatabase,
44
45
  RuntimeSqlExecResult,
@@ -47,6 +48,8 @@ import type {
47
48
  RuntimeSqlRunResult,
48
49
  RuntimeStateDeltaPayload,
49
50
  RuntimeWebSocketEvent,
51
+ RuntimeWorkflowKvWrite,
52
+ SqliteTransactionHandle,
50
53
  WebSocketHandle,
51
54
  } from "./runtime";
52
55
  import { normalizeRuntimeSqlExecuteResult } from "./runtime";
@@ -55,6 +58,37 @@ type WasmBindings = WasmRuntimeBindings;
55
58
  export type WasmInitInput = WasmRuntimeInitInput;
56
59
  type AnyFunction = (...args: unknown[]) => unknown;
57
60
  type WasmRuntimeLoadConfig = Pick<WasmRuntimeConfig, "bindings" | "initInput">;
61
+ type WasmActorContext = object;
62
+ type WasmActorFactory = object;
63
+ type WasmConnHandle = object;
64
+ type WasmWebSocketHandle = object;
65
+
66
+ interface WasmCancellationToken {
67
+ aborted(): boolean;
68
+ cancel(): void;
69
+ onCancelled(callback: (...args: unknown[]) => unknown): {
70
+ release(): void;
71
+ };
72
+ }
73
+
74
+ interface WasmCoreRegistry {
75
+ register(name: string, factory: WasmActorFactory): void;
76
+ serve(config: RuntimeServeConfig): Promise<void>;
77
+ shutdown(): Promise<void>;
78
+ }
79
+
80
+ interface WasmConstructors {
81
+ CoreRegistry: new () => WasmCoreRegistry;
82
+ ActorFactory: new (
83
+ callbacks: object,
84
+ config: RuntimeActorConfig | undefined | null,
85
+ ) => WasmActorFactory;
86
+ CancellationToken: new () => WasmCancellationToken;
87
+ }
88
+
89
+ function asWasmConstructors(bindings: WasmBindings): WasmConstructors {
90
+ return bindings as unknown as WasmConstructors;
91
+ }
58
92
 
59
93
  function asWasmRegistry(handle: RegistryHandle): WasmCoreRegistry {
60
94
  return handle as unknown as WasmCoreRegistry;
@@ -116,6 +150,18 @@ function wasmNumber(value: number | bigint): number {
116
150
  return typeof value === "bigint" ? Number(value) : value;
117
151
  }
118
152
 
153
+ function synchronousSqliteUnavailable(): never {
154
+ throw new RivetError(
155
+ "sqlite",
156
+ "sync_unsupported",
157
+ "Synchronous SQLite is unavailable because the actor runs on the wasm runtime.",
158
+ {
159
+ public: true,
160
+ metadata: { runtime: "wasm" },
161
+ },
162
+ );
163
+ }
164
+
119
165
  function normalizeKvEntry(entry: RuntimeKvEntry): RuntimeKvEntry {
120
166
  return {
121
167
  key: toBytes(entry.key),
@@ -228,11 +274,11 @@ function childHandle<T>(handle: unknown, name: string): T {
228
274
  export class WasmCoreRuntime implements CoreRuntime {
229
275
  readonly kind = "wasm";
230
276
 
231
- #bindings: WasmBindings;
277
+ #constructors: WasmConstructors;
232
278
  #sql = new WeakMap<WasmActorContext, RuntimeSqlDatabase>();
233
279
 
234
280
  constructor(bindings: WasmBindings) {
235
- this.#bindings = bindings;
281
+ this.#constructors = asWasmConstructors(bindings);
236
282
  }
237
283
 
238
284
  #actorSql(ctx: ActorContextHandle): RuntimeSqlDatabase {
@@ -247,7 +293,7 @@ export class WasmCoreRuntime implements CoreRuntime {
247
293
 
248
294
  createRegistry(): RegistryHandle {
249
295
  return callWasmSync(() =>
250
- asRegistryHandle(new this.#bindings.CoreRegistry()),
296
+ asRegistryHandle(new this.#constructors.CoreRegistry()),
251
297
  );
252
298
  }
253
299
 
@@ -268,6 +314,12 @@ export class WasmCoreRuntime implements CoreRuntime {
268
314
  await callWasm(() => asWasmRegistry(registry).serve(config));
269
315
  }
270
316
 
317
+ async waitRegistryReady(): Promise<void> {
318
+ throw new Error(
319
+ "registry.startAndWait() is not supported by the WASM runtime",
320
+ );
321
+ }
322
+
271
323
  async shutdownRegistry(registry: RegistryHandle): Promise<void> {
272
324
  await callWasm(() => asWasmRegistry(registry).shutdown());
273
325
  }
@@ -313,13 +365,31 @@ export class WasmCoreRuntime implements CoreRuntime {
313
365
  );
314
366
  }
315
367
 
368
+ async serveApplicationListener(
369
+ _registry: RegistryHandle,
370
+ _listener: RuntimeApplicationListenerConfig,
371
+ _config: RuntimeServeConfig,
372
+ ): Promise<void> {
373
+ throw new Error(
374
+ "registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead",
375
+ );
376
+ }
377
+
316
378
  createActorFactory(
317
379
  callbacks: object,
318
380
  config?: RuntimeActorConfig | undefined | null,
319
381
  ): ActorFactoryHandle {
382
+ if (config?.sqliteDeferredCommits) {
383
+ throw new RivetError(
384
+ "sqlite",
385
+ "deferred_commits_unsupported",
386
+ "SQLite deferred commits require local native SQLite, but the wasm runtime uses remote SQLite.",
387
+ { metadata: { runtime: "wasm" } },
388
+ );
389
+ }
320
390
  return callWasmSync(() =>
321
391
  asActorFactoryHandle(
322
- new this.#bindings.ActorFactory(callbacks, config),
392
+ new this.#constructors.ActorFactory(callbacks, config),
323
393
  ),
324
394
  );
325
395
  }
@@ -327,7 +397,7 @@ export class WasmCoreRuntime implements CoreRuntime {
327
397
  createCancellationToken(): CancellationTokenHandle {
328
398
  return callWasmSync(
329
399
  () =>
330
- new this.#bindings.CancellationToken() as unknown as CancellationTokenHandle,
400
+ new this.#constructors.CancellationToken() as unknown as CancellationTokenHandle,
331
401
  );
332
402
  }
333
403
 
@@ -342,10 +412,11 @@ export class WasmCoreRuntime implements CoreRuntime {
342
412
  onCancellationTokenCancelled(
343
413
  token: CancellationTokenHandle,
344
414
  callback: (...args: unknown[]) => unknown,
345
- ): void {
346
- callWasmSync(() =>
415
+ ): () => void {
416
+ const listener = callWasmSync(() =>
347
417
  asWasmCancellationToken(token).onCancelled(callback),
348
418
  );
419
+ return () => callWasmSync(() => listener.release());
349
420
  }
350
421
 
351
422
  actorState(ctx: ActorContextHandle): RuntimeBytes {
@@ -376,6 +447,17 @@ export class WasmCoreRuntime implements CoreRuntime {
376
447
  );
377
448
  }
378
449
 
450
+ async actorSetRunWakeAt(
451
+ ctx: ActorContextHandle,
452
+ timestampMs?: number | undefined | null,
453
+ ): Promise<void> {
454
+ await callHandleAsync(
455
+ asWasmActorContext(ctx),
456
+ "setRunWakeAt",
457
+ optionalWasmNumber(timestampMs),
458
+ );
459
+ }
460
+
379
461
  actorRequestSave(
380
462
  ctx: ActorContextHandle,
381
463
  opts?: RuntimeRequestSaveOpts | undefined | null,
@@ -464,10 +546,58 @@ export class WasmCoreRuntime implements CoreRuntime {
464
546
  await callHandleAsync(asWasmActorContext(ctx), "saveState", payload);
465
547
  }
466
548
 
549
+ async actorSaveStateAndWorkflowBatch(
550
+ ctx: ActorContextHandle,
551
+ writes: RuntimeWorkflowKvWrite[],
552
+ ): Promise<void> {
553
+ await callHandleAsync(
554
+ asWasmActorContext(ctx),
555
+ "saveStateAndWorkflowBatch",
556
+ writes,
557
+ );
558
+ }
559
+
467
560
  actorId(ctx: ActorContextHandle): string {
468
561
  return callHandle(asWasmActorContext(ctx), "actorId");
469
562
  }
470
563
 
564
+ runWithActorInvocationContext<T>(
565
+ _ctx: ActorContextHandle,
566
+ run: () => T,
567
+ ): T {
568
+ return run();
569
+ }
570
+
571
+ actorInvocationTraceContext(
572
+ _ctx: ActorContextHandle,
573
+ ): ActorInvocationTraceContext | undefined {
574
+ return undefined;
575
+ }
576
+
577
+ startCallSpan(
578
+ _ctx: ActorContextHandle,
579
+ _actorName: string,
580
+ _actionName: string,
581
+ ): RuntimeOutboundCall | undefined {
582
+ return undefined;
583
+ }
584
+
585
+ async startWorkflowSpan(_ctx: ActorContextHandle): Promise<WorkflowSpan> {
586
+ return {
587
+ run: (body) => body(),
588
+ startStep: () => undefined,
589
+ finish: async () => {},
590
+ };
591
+ }
592
+
593
+ runOutsideActorInvocationContext<T>(run: () => T): T {
594
+ return run();
595
+ }
596
+
597
+ currentInvocationScope(): object | undefined {
598
+ return undefined;
599
+ }
600
+
471
601
  actorName(ctx: ActorContextHandle): string {
472
602
  return callHandle(asWasmActorContext(ctx), "name");
473
603
  }
@@ -690,6 +820,13 @@ export class WasmCoreRuntime implements CoreRuntime {
690
820
  return await callWasm(() => this.#actorSql(ctx).exec(sql));
691
821
  }
692
822
 
823
+ actorSqlExecSync(
824
+ _ctx: ActorContextHandle,
825
+ _sql: string,
826
+ ): RuntimeSqlExecResult {
827
+ return synchronousSqliteUnavailable();
828
+ }
829
+
693
830
  async actorSqlExecute(
694
831
  ctx: ActorContextHandle,
695
832
  sql: string,
@@ -701,6 +838,172 @@ export class WasmCoreRuntime implements CoreRuntime {
701
838
  return normalizeRuntimeSqlExecuteResult(result);
702
839
  }
703
840
 
841
+ actorSqlExecuteSync(
842
+ _ctx: ActorContextHandle,
843
+ _sql: string,
844
+ _params?: RuntimeSqlBindParams,
845
+ ): RuntimeSqlExecuteResult {
846
+ return synchronousSqliteUnavailable();
847
+ }
848
+
849
+ async actorSqlExecuteBatch(
850
+ ctx: ActorContextHandle,
851
+ statements: RuntimeSqlBatchStatement[],
852
+ ): Promise<RuntimeSqlExecuteResult[]> {
853
+ const results = await callWasm(() =>
854
+ this.#actorSql(ctx).executeBatch(statements),
855
+ );
856
+ return results.map(normalizeRuntimeSqlExecuteResult);
857
+ }
858
+
859
+ async actorSqlBeginTransaction(
860
+ ctx: ActorContextHandle,
861
+ timeoutMs?: number,
862
+ name?: string,
863
+ ): Promise<SqliteTransactionHandle> {
864
+ return (await callWasm(() =>
865
+ this.#actorSql(ctx).beginTransaction(timeoutMs, name),
866
+ )) as unknown as SqliteTransactionHandle;
867
+ }
868
+
869
+ actorSqlBeginTransactionSync(
870
+ _ctx: ActorContextHandle,
871
+ _timeoutMs?: number,
872
+ _name?: string,
873
+ ): SqliteTransactionHandle {
874
+ return synchronousSqliteUnavailable();
875
+ }
876
+
877
+ async actorSqlTransactionExec(
878
+ transaction: SqliteTransactionHandle,
879
+ sql: string,
880
+ ): Promise<RuntimeSqlExecResult> {
881
+ return await callWasm(() =>
882
+ (
883
+ transaction as unknown as {
884
+ exec(sql: string): Promise<RuntimeSqlExecResult>;
885
+ }
886
+ ).exec(sql),
887
+ );
888
+ }
889
+
890
+ actorSqlTransactionExecSync(
891
+ _transaction: SqliteTransactionHandle,
892
+ _sql: string,
893
+ ): RuntimeSqlExecResult {
894
+ return synchronousSqliteUnavailable();
895
+ }
896
+
897
+ async actorSqlTransactionExecute(
898
+ transaction: SqliteTransactionHandle,
899
+ sql: string,
900
+ params?: RuntimeSqlBindParams,
901
+ ): Promise<RuntimeSqlExecuteResult> {
902
+ const result = await callWasm(() =>
903
+ (
904
+ transaction as unknown as {
905
+ execute(
906
+ sql: string,
907
+ params?: RuntimeSqlBindParams,
908
+ ): Promise<RuntimeSqlExecuteResult>;
909
+ }
910
+ ).execute(sql, params),
911
+ );
912
+ return normalizeRuntimeSqlExecuteResult(result);
913
+ }
914
+
915
+ actorSqlTransactionExecuteSync(
916
+ _transaction: SqliteTransactionHandle,
917
+ _sql: string,
918
+ _params?: RuntimeSqlBindParams,
919
+ ): RuntimeSqlExecuteResult {
920
+ return synchronousSqliteUnavailable();
921
+ }
922
+
923
+ async actorSqlTransactionCommit(
924
+ transaction: SqliteTransactionHandle,
925
+ ): Promise<void> {
926
+ await callWasm(() =>
927
+ (transaction as unknown as { commit(): Promise<void> }).commit(),
928
+ );
929
+ }
930
+
931
+ actorSqlTransactionCommitSync(_transaction: SqliteTransactionHandle): void {
932
+ synchronousSqliteUnavailable();
933
+ }
934
+
935
+ async actorSqlTransactionRollback(
936
+ transaction: SqliteTransactionHandle,
937
+ ): Promise<void> {
938
+ await callWasm(() =>
939
+ (
940
+ transaction as unknown as { rollback(): Promise<void> }
941
+ ).rollback(),
942
+ );
943
+ }
944
+
945
+ actorSqlTransactionRollbackSync(
946
+ _transaction: SqliteTransactionHandle,
947
+ ): void {
948
+ synchronousSqliteUnavailable();
949
+ }
950
+
951
+ async actorBeginStateTransaction(
952
+ ctx: ActorContextHandle,
953
+ timeoutMs?: number,
954
+ ): Promise<ActorStateTransactionHandle> {
955
+ return (await callWasm(() =>
956
+ (
957
+ asWasmActorContext(ctx) as unknown as {
958
+ beginStateTransaction(
959
+ timeoutMs?: number,
960
+ ): Promise<ActorStateTransactionHandle>;
961
+ }
962
+ ).beginStateTransaction(timeoutMs),
963
+ )) as ActorStateTransactionHandle;
964
+ }
965
+
966
+ async actorStateTransactionExecute(
967
+ transaction: ActorStateTransactionHandle,
968
+ sql: string,
969
+ params?: RuntimeSqlBindParams,
970
+ ): Promise<RuntimeSqlExecuteResult> {
971
+ const result = await callWasm(() =>
972
+ (
973
+ transaction as unknown as {
974
+ execute(
975
+ sql: string,
976
+ params?: RuntimeSqlBindParams,
977
+ ): Promise<RuntimeSqlExecuteResult>;
978
+ }
979
+ ).execute(sql, params),
980
+ );
981
+ return normalizeRuntimeSqlExecuteResult(result);
982
+ }
983
+
984
+ async actorStateTransactionCommit(
985
+ transaction: ActorStateTransactionHandle,
986
+ payload: RuntimeStateDeltaPayload,
987
+ ): Promise<void> {
988
+ await callWasm(() =>
989
+ (
990
+ transaction as unknown as {
991
+ commit(payload: RuntimeStateDeltaPayload): Promise<void>;
992
+ }
993
+ ).commit(payload),
994
+ );
995
+ }
996
+
997
+ async actorStateTransactionRollback(
998
+ transaction: ActorStateTransactionHandle,
999
+ ): Promise<void> {
1000
+ await callWasm(() =>
1001
+ (
1002
+ transaction as unknown as { rollback(): Promise<void> }
1003
+ ).rollback(),
1004
+ );
1005
+ }
1006
+
704
1007
  async actorSqlQuery(
705
1008
  ctx: ActorContextHandle,
706
1009
  sql: string,
@@ -725,6 +1028,25 @@ export class WasmCoreRuntime implements CoreRuntime {
725
1028
  return this.#actorSql(ctx).takeLastKvError?.() ?? null;
726
1029
  }
727
1030
 
1031
+ async actorSqlOpen(_ctx: ActorContextHandle): Promise<void> {
1032
+ // Remote SQLite opens on the engine side with each request.
1033
+ }
1034
+
1035
+ actorSqlCommitTicket(_ctx: ActorContextHandle): number {
1036
+ return synchronousSqliteUnavailable();
1037
+ }
1038
+
1039
+ actorSqlAbortGeneration(_ctx: ActorContextHandle, _reason: string): void {
1040
+ synchronousSqliteUnavailable();
1041
+ }
1042
+
1043
+ async actorSqlWhenDurable(
1044
+ _ctx: ActorContextHandle,
1045
+ _ticket: number,
1046
+ ): Promise<void> {
1047
+ synchronousSqliteUnavailable();
1048
+ }
1049
+
728
1050
  async actorSqlClose(ctx: ActorContextHandle): Promise<void> {
729
1051
  const wasmCtx = asWasmActorContext(ctx);
730
1052
  const database = this.#sql.get(wasmCtx);
@@ -736,6 +1058,20 @@ export class WasmCoreRuntime implements CoreRuntime {
736
1058
  await callWasm(() => database.close());
737
1059
  }
738
1060
 
1061
+ async actorRuntimeSocketProvision(
1062
+ _ctx: ActorContextHandle,
1063
+ ): Promise<never> {
1064
+ throw new RivetError(
1065
+ "actor_runtime_socket",
1066
+ "unsupported",
1067
+ "Actor Runtime Socket is only available on Unix native runtimes.",
1068
+ {
1069
+ public: true,
1070
+ metadata: { runtime: "wasm" },
1071
+ },
1072
+ );
1073
+ }
1074
+
739
1075
  async actorQueueSend(
740
1076
  ctx: ActorContextHandle,
741
1077
  name: string,
@@ -796,6 +1132,22 @@ export class WasmCoreRuntime implements CoreRuntime {
796
1132
  );
797
1133
  }
798
1134
 
1135
+ async actorQueueCompletePersisted(
1136
+ ctx: ActorContextHandle,
1137
+ messageId: bigint,
1138
+ expectedName: string,
1139
+ response?: RuntimeBytes | undefined | null,
1140
+ ): Promise<boolean> {
1141
+ const queue = childHandle(asWasmActorContext(ctx), "queue");
1142
+ return await callHandleAsync(
1143
+ queue,
1144
+ "completePersisted",
1145
+ messageId,
1146
+ expectedName,
1147
+ response,
1148
+ );
1149
+ }
1150
+
799
1151
  async actorQueueEnqueueAndWait(
800
1152
  ctx: ActorContextHandle,
801
1153
  name: string,
@@ -840,24 +1192,141 @@ export class WasmCoreRuntime implements CoreRuntime {
840
1192
  return await callHandleAsync(queue, "inspectMessages");
841
1193
  }
842
1194
 
843
- actorScheduleAfter(
1195
+ async actorQueueReset(ctx: ActorContextHandle): Promise<void> {
1196
+ const queue = childHandle(asWasmActorContext(ctx), "queue");
1197
+ await callHandleAsync(queue, "reset");
1198
+ }
1199
+
1200
+ async actorScheduleAfter(
844
1201
  ctx: ActorContextHandle,
845
1202
  durationMs: number | bigint,
846
1203
  actionName: string,
847
1204
  args: RuntimeBytes,
848
- ): void {
1205
+ ): Promise<string> {
849
1206
  const schedule = childHandle(asWasmActorContext(ctx), "schedule");
850
- callHandle(schedule, "after", wasmNumber(durationMs), actionName, args);
1207
+ return await callHandleAsync<string>(
1208
+ schedule,
1209
+ "after",
1210
+ wasmNumber(durationMs),
1211
+ actionName,
1212
+ args,
1213
+ );
851
1214
  }
852
1215
 
853
- actorScheduleAt(
1216
+ async actorScheduleAt(
854
1217
  ctx: ActorContextHandle,
855
1218
  timestampMs: number | bigint,
856
1219
  actionName: string,
857
1220
  args: RuntimeBytes,
858
- ): void {
1221
+ ): Promise<string> {
1222
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1223
+ return await callHandleAsync<string>(
1224
+ schedule,
1225
+ "at",
1226
+ wasmNumber(timestampMs),
1227
+ actionName,
1228
+ args,
1229
+ );
1230
+ }
1231
+
1232
+ async actorScheduleCancel(ctx: ActorContextHandle, id: string) {
1233
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1234
+ return await callHandleAsync<boolean>(schedule, "cancel", id);
1235
+ }
1236
+
1237
+ async actorScheduleGet(ctx: ActorContextHandle, id: string) {
1238
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1239
+ return await callHandleAsync<RuntimeScheduledEventInfo | undefined>(
1240
+ schedule,
1241
+ "get",
1242
+ id,
1243
+ );
1244
+ }
1245
+
1246
+ async actorScheduleList(ctx: ActorContextHandle) {
1247
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1248
+ return await callHandleAsync<RuntimeScheduledEventInfo[]>(
1249
+ schedule,
1250
+ "list",
1251
+ );
1252
+ }
1253
+
1254
+ async actorCronSet(
1255
+ ctx: ActorContextHandle,
1256
+ name: string,
1257
+ expression: string,
1258
+ timezone: string | undefined,
1259
+ actionName: string,
1260
+ args: RuntimeBytes,
1261
+ maxHistory: number | undefined,
1262
+ ) {
859
1263
  const schedule = childHandle(asWasmActorContext(ctx), "schedule");
860
- callHandle(schedule, "at", wasmNumber(timestampMs), actionName, args);
1264
+ await callHandleAsync(
1265
+ schedule,
1266
+ "cronSet",
1267
+ name,
1268
+ expression,
1269
+ timezone,
1270
+ actionName,
1271
+ args,
1272
+ maxHistory,
1273
+ );
1274
+ }
1275
+
1276
+ async actorCronEvery(
1277
+ ctx: ActorContextHandle,
1278
+ name: string,
1279
+ intervalMs: number,
1280
+ actionName: string,
1281
+ args: RuntimeBytes,
1282
+ maxHistory: number | undefined,
1283
+ ) {
1284
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1285
+ await callHandleAsync(
1286
+ schedule,
1287
+ "cronEvery",
1288
+ name,
1289
+ intervalMs,
1290
+ actionName,
1291
+ args,
1292
+ maxHistory,
1293
+ );
1294
+ }
1295
+
1296
+ async actorCronGet(ctx: ActorContextHandle, name: string) {
1297
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1298
+ return await callHandleAsync<RuntimeCronJobInfo | undefined>(
1299
+ schedule,
1300
+ "cronGet",
1301
+ name,
1302
+ );
1303
+ }
1304
+
1305
+ async actorCronList(ctx: ActorContextHandle) {
1306
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1307
+ return await callHandleAsync<RuntimeCronJobInfo[]>(
1308
+ schedule,
1309
+ "cronList",
1310
+ );
1311
+ }
1312
+
1313
+ async actorCronDelete(ctx: ActorContextHandle, name: string) {
1314
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1315
+ return await callHandleAsync<boolean>(schedule, "cronDelete", name);
1316
+ }
1317
+
1318
+ async actorCronHistory(
1319
+ ctx: ActorContextHandle,
1320
+ name: string,
1321
+ limit: number | undefined,
1322
+ ) {
1323
+ const schedule = childHandle(asWasmActorContext(ctx), "schedule");
1324
+ return await callHandleAsync<RuntimeCronFire[]>(
1325
+ schedule,
1326
+ "cronHistory",
1327
+ name,
1328
+ limit,
1329
+ );
861
1330
  }
862
1331
 
863
1332
  connId(conn: ConnHandle): string {