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
@@ -0,0 +1,224 @@
1
+ type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
2
+ interface ActorMetricsLike {
3
+ totalKvReads: number;
4
+ totalKvWrites: number;
5
+ trackSql(query: string, durationMs: number): void;
6
+ }
7
+ type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
8
+ type SqliteBindings = unknown[] | Record<string, unknown>;
9
+ interface SqliteQueryResult {
10
+ columns: string[];
11
+ rows: unknown[][];
12
+ }
13
+ interface SqliteExecuteResult extends SqliteQueryResult {
14
+ changes: number;
15
+ lastInsertRowId?: number | null;
16
+ }
17
+ interface SqliteBatchStatement {
18
+ sql: string;
19
+ params?: SqliteBindings;
20
+ }
21
+ interface SqliteTransactionOptions {
22
+ /** Static operation name used to aggregate transaction performance. */
23
+ name?: string;
24
+ /** Deadlock-safety timeout in milliseconds. */
25
+ timeout?: number;
26
+ /** @experimental */
27
+ experimental?: {
28
+ /**
29
+ * Atomically includes actor and hibernatable connection state.
30
+ * Only single-statement `execute` calls are supported in the transaction.
31
+ * Concurrent actions that try to mutate state while the transaction is
32
+ * active fail with `actor.state_transaction_conflict`.
33
+ */
34
+ includeState?: boolean;
35
+ };
36
+ }
37
+ /**
38
+ * SQLite profiling configuration.
39
+ *
40
+ * @experimental This entire configuration surface is experimental and subject
41
+ * to change without notice.
42
+ */
43
+ interface SqliteProfilingOptions {
44
+ /** Exact SQL filter. Union with filterQueryFingerprints; both empty means all queries. */
45
+ filterQueries?: string[];
46
+ /** Fingerprint filter, including transaction fingerprints. Filters metrics, not diagnostic logs. */
47
+ filterQueryFingerprints?: string[];
48
+ /** Metric defaults apply even when omitted. Disabled metrics allocate no series. */
49
+ metrics?: SqliteProfilingMetricsOptions;
50
+ /** Duration buckets in seconds. Default [0.01, 0.1, 1]. Positive, finite, strictly increasing.
51
+ * All actors in a process enabling the duration histogram must use identical buckets. */
52
+ durationHistogramBucketsSeconds?: number[];
53
+ /** Maximum distinct statement fingerprints per process. Default: 512. */
54
+ maxTrackedStatementFingerprints?: number;
55
+ maxTrackedTransactionFingerprints?: number;
56
+ maxPrometheusSeries?: number;
57
+ maxStatementsPerTransactionTrace?: number;
58
+ maxGetPagesRequestsPerTrace?: number;
59
+ maxTransactionNameBytes?: number;
60
+ slowOperationThresholdMs?: number;
61
+ baselineSampleRate?: number;
62
+ maxDiagnosticEventsPerMinute?: number;
63
+ diagnosticEventQueueCapacity?: number;
64
+ }
65
+ /** SQLite profiling metrics. Physical-request metrics and gauges have no query labels. */
66
+ interface SqliteProfilingMetricsOptions {
67
+ /** Execution count and cumulative seconds. Uses histogram count/sum when enabled, otherwise counters. Default: true. */
68
+ duration?: boolean;
69
+ /** Execution duration histogram. Only applies when duration is enabled. Default: true. */
70
+ durationHistogram?: boolean;
71
+ /** Outcome counters, including success and errors. Default: true. */
72
+ outcomes?: boolean;
73
+ /** Per-query timing phase histograms. Default: false. */
74
+ phaseDurationHistogram?: boolean;
75
+ /** Storage round trips per operation histogram. Default: false. */
76
+ getPagesRoundTripsHistogram?: boolean;
77
+ /** Statements per transaction histogram. Default: false. */
78
+ transactionStatementCountHistogram?: boolean;
79
+ /** Per-query pages returned from storage, including returned prefetch pages. Default: true. */
80
+ pagesFetched?: boolean;
81
+ /** Actor-level page counters by page kind (no query labels). Default: false. */
82
+ localPages?: boolean;
83
+ /** Actor-level byte counters by byte kind (no query labels). Default: false. */
84
+ localBytes?: boolean;
85
+ /** Actor-level physical storage request duration histogram. Default: false. */
86
+ getPagesDurationHistogram?: boolean;
87
+ /** Actor-level pages per storage request histograms, by page kind. Default: false. */
88
+ getPagesPagesHistogram?: boolean;
89
+ /** Actor-level storage response byte histogram. Default: false. */
90
+ getPagesResponseBytesHistogram?: boolean;
91
+ /** Actor-level missing response page counter. Default: false. */
92
+ getPagesMissingPages?: boolean;
93
+ /** Queued SQLite work, aggregated by actor name. Default: true. */
94
+ workerQueueDepth?: boolean;
95
+ /** Executing SQLite work, aggregated by actor name. Default: true. */
96
+ workerInflight?: boolean;
97
+ /** Transaction waiters, aggregated by actor name. Default: true. */
98
+ coordinatorQueueDepth?: boolean;
99
+ /** Counts observations exceeding fingerprint or series limits. Default: true. */
100
+ fingerprintOverflow?: boolean;
101
+ /** Counts diagnostic events dropped by rate limits or backpressure. Default: true. */
102
+ eventDropped?: boolean;
103
+ }
104
+ interface SqliteNativeMetrics {
105
+ requestBuildNs: number;
106
+ serializeNs: number;
107
+ transportNs: number;
108
+ stateUpdateNs: number;
109
+ totalNs: number;
110
+ commitCount: number;
111
+ pageCacheEntries: number;
112
+ pageCacheWeightedSize: number;
113
+ pageCacheCapacityPages: number;
114
+ writeBufferDirtyPages: number;
115
+ dbSizePages: number;
116
+ }
117
+ interface SqliteDatabase {
118
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
119
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
120
+ executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
121
+ beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
122
+ run(sql: string, params?: SqliteBindings): Promise<void>;
123
+ query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
124
+ nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
125
+ close(): Promise<void>;
126
+ }
127
+ interface SqliteTransactionDatabase {
128
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
129
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
130
+ commit(): Promise<void>;
131
+ rollback(): Promise<void>;
132
+ }
133
+ /**
134
+ * Provider for opening native databases from the active runtime.
135
+ */
136
+ interface NativeDatabaseProvider {
137
+ open(actorId: string): Promise<SqliteDatabase>;
138
+ }
139
+ /**
140
+ * Context provided to database providers for creating database clients
141
+ */
142
+ interface DatabaseProviderContext {
143
+ /**
144
+ * Actor ID
145
+ */
146
+ actorId: string;
147
+ /**
148
+ * Override the default Drizzle database client (optional).
149
+ * If not provided, a KV-backed client will be constructed.
150
+ */
151
+ overrideDrizzleDatabaseClient?: () => Promise<DrizzleDatabaseClient | undefined>;
152
+ /** KV operations exposed for custom database providers. */
153
+ kv: {
154
+ batchPut: (entries: [Uint8Array, Uint8Array][]) => Promise<void>;
155
+ batchGet: (keys: Uint8Array[]) => Promise<(Uint8Array | null)[]>;
156
+ batchDelete: (keys: Uint8Array[]) => Promise<void>;
157
+ deleteRange: (start: Uint8Array, end: Uint8Array) => Promise<void>;
158
+ };
159
+ /**
160
+ * Actor metrics instance. When provided, KV and SQL operations are tracked.
161
+ */
162
+ metrics?: ActorMetricsLike;
163
+ /**
164
+ * Logger for debug output. When provided, SQL queries are logged with
165
+ * duration and KV call count.
166
+ */
167
+ log?: {
168
+ debug(obj: Record<string, unknown>): void;
169
+ };
170
+ /**
171
+ * Provider for opening native databases from the active runtime.
172
+ */
173
+ nativeDatabaseProvider?: NativeDatabaseProvider;
174
+ }
175
+ type DatabaseProvider<DB extends RawAccess> = {
176
+ /**
177
+ * Local SQLite profiling controls consumed by the actor runtime.
178
+ *
179
+ * @experimental This entire configuration surface is experimental and
180
+ * subject to change without notice.
181
+ */
182
+ sqliteProfiling?: SqliteProfilingOptions;
183
+ /**
184
+ * Creates a new database client for the actor.
185
+ * The result is passed to the actor context as `c.db`.
186
+ * @experimental
187
+ */
188
+ createClient: (ctx: DatabaseProviderContext) => Promise<DB>;
189
+ /**
190
+ * Runs before the actor has started.
191
+ * Use this to run migrations or other setup tasks.
192
+ * @experimental
193
+ */
194
+ onMigrate: (client: DB) => void | Promise<void>;
195
+ };
196
+ /**
197
+ * Raw database client with basic exec method
198
+ */
199
+ interface RawDatabaseClient {
200
+ exec: <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]> | TRow[];
201
+ }
202
+ /**
203
+ * Drizzle database client interface (will be extended by drizzle-orm types)
204
+ */
205
+ type DrizzleDatabaseClient = {};
206
+ type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
207
+ type RawAccess = {
208
+ /**
209
+ * Executes a raw SQL query.
210
+ */
211
+ execute: ExecuteFunction;
212
+ /** Runs a callback in an isolated SQLite transaction. */
213
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
214
+ /**
215
+ * Returns native SQLite metrics when the active runtime supports them.
216
+ */
217
+ nativeMetrics?: () => SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
218
+ /**
219
+ * Closes the database connection and releases resources.
220
+ */
221
+ close: () => Promise<void>;
222
+ };
223
+
224
+ export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R, SqliteTransactionOptions as S, SqliteProfilingOptions as a, DatabaseProviderContext as b, RawDatabaseClient as c, SqliteBindings as d, SqliteDatabase as e, SqliteNativeMetrics as f, SqliteProfilingMetricsOptions as g, SqliteQueryResult as h };
@@ -0,0 +1,224 @@
1
+ type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
2
+ interface ActorMetricsLike {
3
+ totalKvReads: number;
4
+ totalKvWrites: number;
5
+ trackSql(query: string, durationMs: number): void;
6
+ }
7
+ type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
8
+ type SqliteBindings = unknown[] | Record<string, unknown>;
9
+ interface SqliteQueryResult {
10
+ columns: string[];
11
+ rows: unknown[][];
12
+ }
13
+ interface SqliteExecuteResult extends SqliteQueryResult {
14
+ changes: number;
15
+ lastInsertRowId?: number | null;
16
+ }
17
+ interface SqliteBatchStatement {
18
+ sql: string;
19
+ params?: SqliteBindings;
20
+ }
21
+ interface SqliteTransactionOptions {
22
+ /** Static operation name used to aggregate transaction performance. */
23
+ name?: string;
24
+ /** Deadlock-safety timeout in milliseconds. */
25
+ timeout?: number;
26
+ /** @experimental */
27
+ experimental?: {
28
+ /**
29
+ * Atomically includes actor and hibernatable connection state.
30
+ * Only single-statement `execute` calls are supported in the transaction.
31
+ * Concurrent actions that try to mutate state while the transaction is
32
+ * active fail with `actor.state_transaction_conflict`.
33
+ */
34
+ includeState?: boolean;
35
+ };
36
+ }
37
+ /**
38
+ * SQLite profiling configuration.
39
+ *
40
+ * @experimental This entire configuration surface is experimental and subject
41
+ * to change without notice.
42
+ */
43
+ interface SqliteProfilingOptions {
44
+ /** Exact SQL filter. Union with filterQueryFingerprints; both empty means all queries. */
45
+ filterQueries?: string[];
46
+ /** Fingerprint filter, including transaction fingerprints. Filters metrics, not diagnostic logs. */
47
+ filterQueryFingerprints?: string[];
48
+ /** Metric defaults apply even when omitted. Disabled metrics allocate no series. */
49
+ metrics?: SqliteProfilingMetricsOptions;
50
+ /** Duration buckets in seconds. Default [0.01, 0.1, 1]. Positive, finite, strictly increasing.
51
+ * All actors in a process enabling the duration histogram must use identical buckets. */
52
+ durationHistogramBucketsSeconds?: number[];
53
+ /** Maximum distinct statement fingerprints per process. Default: 512. */
54
+ maxTrackedStatementFingerprints?: number;
55
+ maxTrackedTransactionFingerprints?: number;
56
+ maxPrometheusSeries?: number;
57
+ maxStatementsPerTransactionTrace?: number;
58
+ maxGetPagesRequestsPerTrace?: number;
59
+ maxTransactionNameBytes?: number;
60
+ slowOperationThresholdMs?: number;
61
+ baselineSampleRate?: number;
62
+ maxDiagnosticEventsPerMinute?: number;
63
+ diagnosticEventQueueCapacity?: number;
64
+ }
65
+ /** SQLite profiling metrics. Physical-request metrics and gauges have no query labels. */
66
+ interface SqliteProfilingMetricsOptions {
67
+ /** Execution count and cumulative seconds. Uses histogram count/sum when enabled, otherwise counters. Default: true. */
68
+ duration?: boolean;
69
+ /** Execution duration histogram. Only applies when duration is enabled. Default: true. */
70
+ durationHistogram?: boolean;
71
+ /** Outcome counters, including success and errors. Default: true. */
72
+ outcomes?: boolean;
73
+ /** Per-query timing phase histograms. Default: false. */
74
+ phaseDurationHistogram?: boolean;
75
+ /** Storage round trips per operation histogram. Default: false. */
76
+ getPagesRoundTripsHistogram?: boolean;
77
+ /** Statements per transaction histogram. Default: false. */
78
+ transactionStatementCountHistogram?: boolean;
79
+ /** Per-query pages returned from storage, including returned prefetch pages. Default: true. */
80
+ pagesFetched?: boolean;
81
+ /** Actor-level page counters by page kind (no query labels). Default: false. */
82
+ localPages?: boolean;
83
+ /** Actor-level byte counters by byte kind (no query labels). Default: false. */
84
+ localBytes?: boolean;
85
+ /** Actor-level physical storage request duration histogram. Default: false. */
86
+ getPagesDurationHistogram?: boolean;
87
+ /** Actor-level pages per storage request histograms, by page kind. Default: false. */
88
+ getPagesPagesHistogram?: boolean;
89
+ /** Actor-level storage response byte histogram. Default: false. */
90
+ getPagesResponseBytesHistogram?: boolean;
91
+ /** Actor-level missing response page counter. Default: false. */
92
+ getPagesMissingPages?: boolean;
93
+ /** Queued SQLite work, aggregated by actor name. Default: true. */
94
+ workerQueueDepth?: boolean;
95
+ /** Executing SQLite work, aggregated by actor name. Default: true. */
96
+ workerInflight?: boolean;
97
+ /** Transaction waiters, aggregated by actor name. Default: true. */
98
+ coordinatorQueueDepth?: boolean;
99
+ /** Counts observations exceeding fingerprint or series limits. Default: true. */
100
+ fingerprintOverflow?: boolean;
101
+ /** Counts diagnostic events dropped by rate limits or backpressure. Default: true. */
102
+ eventDropped?: boolean;
103
+ }
104
+ interface SqliteNativeMetrics {
105
+ requestBuildNs: number;
106
+ serializeNs: number;
107
+ transportNs: number;
108
+ stateUpdateNs: number;
109
+ totalNs: number;
110
+ commitCount: number;
111
+ pageCacheEntries: number;
112
+ pageCacheWeightedSize: number;
113
+ pageCacheCapacityPages: number;
114
+ writeBufferDirtyPages: number;
115
+ dbSizePages: number;
116
+ }
117
+ interface SqliteDatabase {
118
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
119
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
120
+ executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
121
+ beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
122
+ run(sql: string, params?: SqliteBindings): Promise<void>;
123
+ query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
124
+ nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
125
+ close(): Promise<void>;
126
+ }
127
+ interface SqliteTransactionDatabase {
128
+ exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
129
+ execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
130
+ commit(): Promise<void>;
131
+ rollback(): Promise<void>;
132
+ }
133
+ /**
134
+ * Provider for opening native databases from the active runtime.
135
+ */
136
+ interface NativeDatabaseProvider {
137
+ open(actorId: string): Promise<SqliteDatabase>;
138
+ }
139
+ /**
140
+ * Context provided to database providers for creating database clients
141
+ */
142
+ interface DatabaseProviderContext {
143
+ /**
144
+ * Actor ID
145
+ */
146
+ actorId: string;
147
+ /**
148
+ * Override the default Drizzle database client (optional).
149
+ * If not provided, a KV-backed client will be constructed.
150
+ */
151
+ overrideDrizzleDatabaseClient?: () => Promise<DrizzleDatabaseClient | undefined>;
152
+ /** KV operations exposed for custom database providers. */
153
+ kv: {
154
+ batchPut: (entries: [Uint8Array, Uint8Array][]) => Promise<void>;
155
+ batchGet: (keys: Uint8Array[]) => Promise<(Uint8Array | null)[]>;
156
+ batchDelete: (keys: Uint8Array[]) => Promise<void>;
157
+ deleteRange: (start: Uint8Array, end: Uint8Array) => Promise<void>;
158
+ };
159
+ /**
160
+ * Actor metrics instance. When provided, KV and SQL operations are tracked.
161
+ */
162
+ metrics?: ActorMetricsLike;
163
+ /**
164
+ * Logger for debug output. When provided, SQL queries are logged with
165
+ * duration and KV call count.
166
+ */
167
+ log?: {
168
+ debug(obj: Record<string, unknown>): void;
169
+ };
170
+ /**
171
+ * Provider for opening native databases from the active runtime.
172
+ */
173
+ nativeDatabaseProvider?: NativeDatabaseProvider;
174
+ }
175
+ type DatabaseProvider<DB extends RawAccess> = {
176
+ /**
177
+ * Local SQLite profiling controls consumed by the actor runtime.
178
+ *
179
+ * @experimental This entire configuration surface is experimental and
180
+ * subject to change without notice.
181
+ */
182
+ sqliteProfiling?: SqliteProfilingOptions;
183
+ /**
184
+ * Creates a new database client for the actor.
185
+ * The result is passed to the actor context as `c.db`.
186
+ * @experimental
187
+ */
188
+ createClient: (ctx: DatabaseProviderContext) => Promise<DB>;
189
+ /**
190
+ * Runs before the actor has started.
191
+ * Use this to run migrations or other setup tasks.
192
+ * @experimental
193
+ */
194
+ onMigrate: (client: DB) => void | Promise<void>;
195
+ };
196
+ /**
197
+ * Raw database client with basic exec method
198
+ */
199
+ interface RawDatabaseClient {
200
+ exec: <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]> | TRow[];
201
+ }
202
+ /**
203
+ * Drizzle database client interface (will be extended by drizzle-orm types)
204
+ */
205
+ type DrizzleDatabaseClient = {};
206
+ type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
207
+ type RawAccess = {
208
+ /**
209
+ * Executes a raw SQL query.
210
+ */
211
+ execute: ExecuteFunction;
212
+ /** Runs a callback in an isolated SQLite transaction. */
213
+ transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
214
+ /**
215
+ * Returns native SQLite metrics when the active runtime supports them.
216
+ */
217
+ nativeMetrics?: () => SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
218
+ /**
219
+ * Closes the database connection and releases resources.
220
+ */
221
+ close: () => Promise<void>;
222
+ };
223
+
224
+ export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R, SqliteTransactionOptions as S, SqliteProfilingOptions as a, DatabaseProviderContext as b, RawDatabaseClient as c, SqliteBindings as d, SqliteDatabase as e, SqliteNativeMetrics as f, SqliteProfilingMetricsOptions as g, SqliteQueryResult as h };