rivetkit 2.0.42 → 2.1.0-rc.1

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 (322) hide show
  1. package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
  2. package/dist/browser/client.js +5182 -0
  3. package/dist/browser/client.js.map +1 -0
  4. package/dist/browser/inspector/client.d.ts +130 -0
  5. package/dist/browser/inspector/client.js +2854 -0
  6. package/dist/browser/inspector/client.js.map +1 -0
  7. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  8. package/dist/schemas/actor-inspector/v2.ts +796 -0
  9. package/dist/schemas/actor-inspector/v3.ts +899 -0
  10. package/dist/schemas/actor-persist/v4.ts +406 -0
  11. package/dist/schemas/client-protocol/v3.ts +554 -0
  12. package/dist/schemas/persist/v1.ts +781 -0
  13. package/dist/schemas/transport/v1.ts +697 -0
  14. package/dist/tsup/actor/errors.cjs +27 -3
  15. package/dist/tsup/actor/errors.cjs.map +1 -1
  16. package/dist/tsup/actor/errors.d.cts +37 -1
  17. package/dist/tsup/actor/errors.d.ts +37 -1
  18. package/dist/tsup/actor/errors.js +26 -1
  19. package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
  20. package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
  21. package/dist/tsup/chunk-424PT5DM.js +23 -0
  22. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  23. package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
  24. package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
  25. package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
  26. package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
  27. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  28. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  29. package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
  30. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  31. package/dist/tsup/chunk-7K4CYDGD.js +630 -0
  32. package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
  33. package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
  34. package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
  35. package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
  36. package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
  37. package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
  38. package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
  39. package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
  40. package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
  41. package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
  42. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  43. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  44. package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
  45. package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
  46. package/dist/tsup/chunk-IVG73YCW.js +534 -0
  47. package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
  48. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  49. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  50. package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
  51. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  52. package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
  53. package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
  54. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  55. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  56. package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
  57. package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
  58. package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
  59. package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
  60. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  61. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  62. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  63. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  64. package/dist/tsup/chunk-OMEPCQK2.js +649 -0
  65. package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
  66. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  67. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  68. package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
  69. package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
  70. package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
  71. package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
  72. package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
  73. package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
  74. package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
  75. package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
  76. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  77. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  78. package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
  79. package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
  80. package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
  81. package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
  82. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  83. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  84. package/dist/tsup/client/mod.cjs +9 -10
  85. package/dist/tsup/client/mod.cjs.map +1 -1
  86. package/dist/tsup/client/mod.d.cts +11 -5
  87. package/dist/tsup/client/mod.d.ts +11 -5
  88. package/dist/tsup/client/mod.js +8 -8
  89. package/dist/tsup/common/log.cjs +4 -4
  90. package/dist/tsup/common/log.d.cts +2 -2
  91. package/dist/tsup/common/log.d.ts +2 -2
  92. package/dist/tsup/common/log.js +3 -2
  93. package/dist/tsup/common/websocket.cjs +5 -5
  94. package/dist/tsup/common/websocket.js +4 -3
  95. package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
  96. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  97. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  98. package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
  99. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  100. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  101. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  102. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  103. package/dist/tsup/db/drizzle/mod.js +49 -0
  104. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  105. package/dist/tsup/db/mod.cjs +9 -0
  106. package/dist/tsup/db/mod.cjs.map +1 -0
  107. package/dist/tsup/db/mod.d.cts +9 -0
  108. package/dist/tsup/db/mod.d.ts +9 -0
  109. package/dist/tsup/db/mod.js +9 -0
  110. package/dist/tsup/db/mod.js.map +1 -0
  111. package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
  112. package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
  113. package/dist/tsup/driver-helpers/mod.cjs +12 -6
  114. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  115. package/dist/tsup/driver-helpers/mod.d.cts +12 -5
  116. package/dist/tsup/driver-helpers/mod.d.ts +12 -5
  117. package/dist/tsup/driver-helpers/mod.js +12 -5
  118. package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
  119. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  120. package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
  121. package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
  122. package/dist/tsup/driver-test-suite/mod.js +2093 -838
  123. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  124. package/dist/tsup/inspector/mod.cjs +29 -3
  125. package/dist/tsup/inspector/mod.cjs.map +1 -1
  126. package/dist/tsup/inspector/mod.d.cts +124 -3
  127. package/dist/tsup/inspector/mod.d.ts +124 -3
  128. package/dist/tsup/inspector/mod.js +72 -45
  129. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  130. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  131. package/dist/tsup/mod.cjs +16 -10
  132. package/dist/tsup/mod.cjs.map +1 -1
  133. package/dist/tsup/mod.d.cts +26 -14
  134. package/dist/tsup/mod.d.ts +26 -14
  135. package/dist/tsup/mod.js +20 -13
  136. package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
  137. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  138. package/dist/tsup/serve-test-suite/mod.js +1114 -29
  139. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  140. package/dist/tsup/test/mod.cjs +84 -11
  141. package/dist/tsup/test/mod.cjs.map +1 -1
  142. package/dist/tsup/test/mod.d.cts +10 -5
  143. package/dist/tsup/test/mod.d.ts +10 -5
  144. package/dist/tsup/test/mod.js +85 -11
  145. package/dist/tsup/test/mod.js.map +1 -1
  146. package/dist/tsup/utils.cjs +10 -4
  147. package/dist/tsup/utils.cjs.map +1 -1
  148. package/dist/tsup/utils.d.cts +72 -2
  149. package/dist/tsup/utils.d.ts +72 -2
  150. package/dist/tsup/utils.js +9 -2
  151. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  152. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  153. package/dist/tsup/workflow/mod.cjs +16 -0
  154. package/dist/tsup/workflow/mod.cjs.map +1 -0
  155. package/dist/tsup/workflow/mod.d.cts +83 -0
  156. package/dist/tsup/workflow/mod.d.ts +83 -0
  157. package/dist/tsup/workflow/mod.js +16 -0
  158. package/dist/tsup/workflow/mod.js.map +1 -0
  159. package/package.json +62 -5
  160. package/src/actor/config.ts +478 -68
  161. package/src/actor/conn/mod.ts +68 -16
  162. package/src/actor/conn/state-manager.ts +2 -2
  163. package/src/actor/contexts/action.ts +20 -12
  164. package/src/actor/contexts/base/actor.ts +137 -7
  165. package/src/actor/contexts/base/conn-init.ts +27 -7
  166. package/src/actor/contexts/base/conn.ts +27 -18
  167. package/src/actor/contexts/before-action-response.ts +9 -2
  168. package/src/actor/contexts/before-connect.ts +7 -2
  169. package/src/actor/contexts/connect.ts +9 -2
  170. package/src/actor/contexts/create-conn-state.ts +7 -2
  171. package/src/actor/contexts/create-vars.ts +16 -3
  172. package/src/actor/contexts/create.ts +16 -3
  173. package/src/actor/contexts/destroy.ts +9 -3
  174. package/src/actor/contexts/disconnect.ts +10 -4
  175. package/src/actor/contexts/index.ts +4 -3
  176. package/src/actor/contexts/request.ts +23 -6
  177. package/src/actor/contexts/run.ts +47 -0
  178. package/src/actor/contexts/sleep.ts +9 -3
  179. package/src/actor/contexts/state-change.ts +9 -3
  180. package/src/actor/contexts/wake.ts +9 -3
  181. package/src/actor/contexts/websocket.ts +23 -6
  182. package/src/actor/database.ts +8 -18
  183. package/src/actor/definition.ts +20 -6
  184. package/src/actor/driver.ts +32 -3
  185. package/src/actor/errors.ts +127 -0
  186. package/src/actor/instance/connection-manager.ts +183 -80
  187. package/src/actor/instance/event-manager.ts +26 -15
  188. package/src/actor/instance/keys.ts +117 -0
  189. package/src/actor/instance/mod.ts +784 -174
  190. package/src/actor/instance/queue-manager.ts +603 -0
  191. package/src/actor/instance/queue.ts +287 -0
  192. package/src/actor/instance/schedule-manager.ts +49 -7
  193. package/src/actor/instance/state-manager.ts +35 -11
  194. package/src/actor/instance/traces-driver.ts +128 -0
  195. package/src/actor/mod.ts +26 -2
  196. package/src/actor/protocol/old.ts +28 -13
  197. package/src/actor/protocol/serde.ts +1 -1
  198. package/src/actor/router-endpoints.ts +177 -21
  199. package/src/actor/router-websocket-endpoints.ts +18 -29
  200. package/src/actor/router.ts +177 -0
  201. package/src/actor/schema.ts +291 -0
  202. package/src/actor/utils.ts +40 -0
  203. package/src/client/actor-common.ts +1 -1
  204. package/src/client/actor-conn.ts +100 -33
  205. package/src/client/actor-handle.ts +61 -33
  206. package/src/client/client.ts +2 -4
  207. package/src/client/config.ts +1 -1
  208. package/src/client/mod.browser.ts +2 -0
  209. package/src/client/mod.ts +1 -4
  210. package/src/client/queue.ts +146 -0
  211. package/src/client/utils.ts +1 -1
  212. package/src/common/log.ts +1 -1
  213. package/src/common/utils.ts +3 -3
  214. package/src/db/config.ts +100 -0
  215. package/src/db/drizzle/mod.ts +226 -0
  216. package/src/db/drizzle/sqlite-core.ts +22 -0
  217. package/src/db/mod.ts +125 -0
  218. package/src/db/shared.ts +92 -0
  219. package/src/db/sqlite-vfs.ts +12 -0
  220. package/src/driver-helpers/mod.ts +1 -0
  221. package/src/driver-test-suite/mod.ts +69 -43
  222. package/src/driver-test-suite/tests/access-control.ts +218 -0
  223. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  224. package/src/driver-test-suite/tests/actor-db.ts +394 -0
  225. package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
  226. package/src/driver-test-suite/tests/actor-kv.ts +41 -20
  227. package/src/driver-test-suite/tests/actor-queue.ts +324 -0
  228. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  229. package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
  230. package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
  231. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  232. package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
  233. package/src/driver-test-suite/tests/manager-driver.ts +11 -0
  234. package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
  235. package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
  236. package/src/drivers/default.ts +7 -2
  237. package/src/drivers/engine/actor-driver.ts +45 -37
  238. package/src/drivers/engine/config.ts +1 -1
  239. package/src/drivers/file-system/actor.ts +20 -2
  240. package/src/drivers/file-system/global-state.ts +569 -258
  241. package/src/drivers/file-system/kv-limits.ts +70 -0
  242. package/src/drivers/file-system/manager.ts +22 -6
  243. package/src/drivers/file-system/mod.ts +39 -16
  244. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  245. package/src/inspector/actor-inspector.ts +224 -102
  246. package/src/inspector/config.ts +1 -1
  247. package/src/inspector/handler.ts +102 -20
  248. package/src/inspector/mod.browser.ts +8 -0
  249. package/src/inspector/mod.ts +2 -0
  250. package/src/inspector/serve-ui.ts +40 -0
  251. package/src/inspector/transport.ts +18 -0
  252. package/src/inspector/utils.ts +5 -39
  253. package/src/manager/gateway.ts +1 -1
  254. package/src/manager/protocol/mod.ts +1 -1
  255. package/src/manager/protocol/query.ts +1 -1
  256. package/src/manager/router-schema.ts +1 -1
  257. package/src/manager/router.ts +38 -12
  258. package/src/manager-api/actors.ts +1 -1
  259. package/src/manager-api/common.ts +1 -1
  260. package/src/registry/config/driver.ts +1 -1
  261. package/src/registry/config/index.ts +212 -43
  262. package/src/registry/config/legacy-runner.ts +1 -1
  263. package/src/registry/config/runner.ts +1 -1
  264. package/src/registry/config/serverless.ts +1 -1
  265. package/src/registry/index.ts +7 -5
  266. package/src/remote-manager-driver/api-utils.ts +1 -1
  267. package/src/schemas/actor-inspector/mod.ts +1 -1
  268. package/src/schemas/actor-inspector/versioned.ts +195 -8
  269. package/src/schemas/actor-persist/versioned.ts +87 -7
  270. package/src/schemas/client-protocol/mod.ts +1 -1
  271. package/src/schemas/client-protocol/versioned.ts +127 -11
  272. package/src/schemas/client-protocol-zod/mod.ts +16 -1
  273. package/src/schemas/persist/mod.ts +1 -0
  274. package/src/schemas/transport/mod.ts +1 -0
  275. package/src/serde.ts +1 -1
  276. package/src/serve-test-suite/mod.ts +10 -9
  277. package/src/test/mod.ts +15 -56
  278. package/src/utils/endpoint-parser.test.ts +1 -1
  279. package/src/utils/endpoint-parser.ts +1 -1
  280. package/src/utils/env-vars.ts +12 -1
  281. package/src/utils/node.ts +15 -2
  282. package/src/utils.test.ts +34 -0
  283. package/src/utils.ts +140 -6
  284. package/src/workflow/constants.ts +2 -0
  285. package/src/workflow/context.ts +532 -0
  286. package/src/workflow/driver.ts +191 -0
  287. package/src/workflow/inspector.ts +268 -0
  288. package/src/workflow/mod.ts +122 -0
  289. package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
  290. package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
  291. package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
  292. package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
  293. package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
  294. package/dist/tsup/chunk-AQFSQMBG.js +0 -114
  295. package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
  296. package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
  297. package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
  298. package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
  299. package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
  300. package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
  301. package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
  302. package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
  303. package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
  304. package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
  305. package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
  306. package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
  307. package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
  308. package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
  309. package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
  310. package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
  311. package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
  312. package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
  313. package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
  314. package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
  315. package/dist/tsup/chunk-TCOEBUUE.js +0 -278
  316. package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
  317. package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
  318. package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
  319. package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
  320. package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
  321. package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
  322. /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
@@ -1,363 +1,264 @@
1
- import { describe } from "vitest";
1
+ import { describe, expect, test } from "vitest";
2
2
  import type { DriverTestConfig } from "../mod";
3
+ import { setupDriverTest } from "../utils";
3
4
 
4
5
  export function runActorInspectorTests(driverTestConfig: DriverTestConfig) {
5
- // TODO: Add back
6
- describe.skip("Actor Inspector Tests", () => {
7
- // describe("Actor Inspector", () => {
8
- // test("should handle actor not found", async (c) => {
9
- // const { endpoint } = await setupDriverTest(c, driverTestConfig);
10
- // const actorId = "non-existing";
11
- // const http = createActorInspectorClient(
12
- // `${endpoint}/actors/inspect`,
13
- // {
14
- // headers: {
15
- // Authorization: `Bearer token`,
16
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
17
- // getForId: { name: "counter", actorId },
18
- // } satisfies ActorQuery),
19
- // },
20
- // },
21
- // );
22
- // const response = await http.ping.$get();
23
- // expect(response.ok).toBe(false);
24
- // });
25
- // test("should respond to ping", async (c) => {
26
- // const { client, endpoint } = await setupDriverTest(
27
- // c,
28
- // driverTestConfig,
29
- // );
30
- // const handle = await client.counter.create(["test-ping"]);
31
- // const actorId = await handle.resolve();
32
- // const http = createActorInspectorClient(
33
- // `${endpoint}/actors/inspect`,
34
- // {
35
- // headers: {
36
- // Authorization: `Bearer token`,
37
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
38
- // getForId: { name: "counter", actorId },
39
- // } satisfies ActorQuery),
40
- // },
41
- // },
42
- // );
43
- // const response = await http.ping.$get();
44
- // expect(response.status).toBe(200);
45
- // const data = await response.json();
46
- // expect(data).toEqual({ message: "pong" });
47
- // });
48
- // test("should get actor state", async (c) => {
49
- // const { client, endpoint } = await setupDriverTest(
50
- // c,
51
- // driverTestConfig,
52
- // );
53
- // const handle = await client.counter.create(["test-state"]);
54
- // const actorId = await handle.resolve();
55
- // // Increment the counter to set some state
56
- // await handle.increment(5);
57
- // const http = createActorInspectorClient(
58
- // `${endpoint}/actors/inspect`,
59
- // {
60
- // headers: {
61
- // Authorization: `Bearer token`,
62
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
63
- // getForId: { name: "counter", actorId },
64
- // } satisfies ActorQuery),
65
- // },
66
- // },
67
- // );
68
- // const response = await http.state.$get();
69
- // expect(response.status).toBe(200);
70
- // const data = await response.json();
71
- // expect(data).toEqual({
72
- // enabled: true,
73
- // state: expect.objectContaining({
74
- // count: 5,
75
- // }),
76
- // });
77
- // });
78
- // test("should update actor state with replace", async (c) => {
79
- // const { client, endpoint } = await setupDriverTest(
80
- // c,
81
- // driverTestConfig,
82
- // );
83
- // const handle = await client.counter.create([
84
- // "test-state-replace",
85
- // ]);
86
- // const actorId = await handle.resolve();
87
- // const http = createActorInspectorClient(
88
- // `${endpoint}/actors/inspect`,
89
- // {
90
- // headers: {
91
- // Authorization: `Bearer token`,
92
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
93
- // getForId: { name: "counter", actorId },
94
- // } satisfies ActorQuery),
95
- // },
96
- // },
97
- // );
98
- // // Replace the entire state
99
- // const response = await http.state.$patch({
100
- // json: {
101
- // replace: { count: 10 },
102
- // },
103
- // });
104
- // expect(response.status).toBe(200);
105
- // const data = await response.json();
106
- // expect(data).toEqual({
107
- // enabled: true,
108
- // state: { count: 10 },
109
- // });
110
- // });
111
- // test("should update actor state with patch", async (c) => {
112
- // const { client, endpoint } = await setupDriverTest(
113
- // c,
114
- // driverTestConfig,
115
- // );
116
- // const handle = await client.counter.create([
117
- // "test-state-patch",
118
- // ]);
119
- // const actorId = await handle.resolve();
120
- // // Set initial state
121
- // await handle.increment(3);
122
- // const http = createActorInspectorClient(
123
- // `${endpoint}/actors/inspect`,
124
- // {
125
- // headers: {
126
- // Authorization: `Bearer token`,
127
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
128
- // getForId: { name: "counter", actorId },
129
- // } satisfies ActorQuery),
130
- // },
131
- // },
132
- // );
133
- // // Patch the state
134
- // const response = await http.state.$patch({
135
- // json: {
136
- // patch: [
137
- // {
138
- // op: "replace",
139
- // path: "/count",
140
- // value: 7,
141
- // },
142
- // ],
143
- // },
144
- // });
145
- // expect(response.status).toBe(200);
146
- // const data = await response.json();
147
- // expect(data).toEqual({
148
- // enabled: true,
149
- // state: expect.objectContaining({
150
- // count: 7,
151
- // }),
152
- // });
153
- // });
154
- // test("should get actor connections", async (c) => {
155
- // const { client, endpoint } = await setupDriverTest(
156
- // c,
157
- // driverTestConfig,
158
- // );
159
- // const handle = await client.counter.create([
160
- // "test-connections",
161
- // ]);
162
- // const actorId = await handle.resolve();
163
- // handle.connect();
164
- // await handle.increment(10);
165
- // const http = createActorInspectorClient(
166
- // `${endpoint}/actors/inspect`,
167
- // {
168
- // headers: {
169
- // Authorization: `Bearer token`,
170
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
171
- // getForId: { name: "counter", actorId },
172
- // } satisfies ActorQuery),
173
- // },
174
- // },
175
- // );
176
- // const response = await http.connections.$get();
177
- // expect(response.status).toBe(200);
178
- // const data = await response.json();
179
- // expect(data.connections).toEqual(
180
- // expect.arrayContaining([
181
- // expect.objectContaining({
182
- // id: expect.any(String),
183
- // }),
184
- // ]),
185
- // );
186
- // });
187
- // test("should get actor events", async (c) => {
188
- // const { client, endpoint } = await setupDriverTest(
189
- // c,
190
- // driverTestConfig,
191
- // );
192
- // const handle = await client.counter.create(["test-events"]);
193
- // const actorId = await handle.resolve();
194
- // handle.connect();
195
- // await handle.increment(10);
196
- // const http = createActorInspectorClient(
197
- // `${endpoint}/actors/inspect`,
198
- // {
199
- // headers: {
200
- // Authorization: `Bearer token`,
201
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
202
- // getForId: { name: "counter", actorId },
203
- // } satisfies ActorQuery),
204
- // },
205
- // },
206
- // );
207
- // const response = await http.events.$get();
208
- // expect(response.status).toBe(200);
209
- // const data = await response.json();
210
- // expect(data.events).toEqual(
211
- // expect.arrayContaining([
212
- // expect.objectContaining({
213
- // type: "broadcast",
214
- // id: expect.any(String),
215
- // }),
216
- // ]),
217
- // );
218
- // });
219
- // test("should clear actor events", async (c) => {
220
- // const { client, endpoint } = await setupDriverTest(
221
- // c,
222
- // driverTestConfig,
223
- // );
224
- // const handle = await client.counter.create([
225
- // "test-events-clear",
226
- // ]);
227
- // const actorId = await handle.resolve();
228
- // handle.connect();
229
- // await handle.increment(10);
230
- // const http = createActorInspectorClient(
231
- // `${endpoint}/actors/inspect`,
232
- // {
233
- // headers: {
234
- // Authorization: `Bearer token`,
235
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
236
- // getForId: { name: "counter", actorId },
237
- // } satisfies ActorQuery),
238
- // },
239
- // },
240
- // );
241
- // {
242
- // const response = await http.events.$get();
243
- // expect(response.status).toBe(200);
244
- // const data = await response.json();
245
- // expect(data.events).toEqual(
246
- // expect.arrayContaining([
247
- // expect.objectContaining({
248
- // type: "broadcast",
249
- // id: expect.any(String),
250
- // }),
251
- // ]),
252
- // );
253
- // }
254
- // const response = await http.events.clear.$post();
255
- // expect(response.status).toBe(200);
256
- // });
257
- // test("should get actor rpcs", async (c) => {
258
- // const { client, endpoint } = await setupDriverTest(
259
- // c,
260
- // driverTestConfig,
261
- // );
262
- // const handle = await client.counter.create(["test-rpcs"]);
263
- // const actorId = await handle.resolve();
264
- // const http = createActorInspectorClient(
265
- // `${endpoint}/actors/inspect`,
266
- // {
267
- // headers: {
268
- // Authorization: `Bearer token`,
269
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
270
- // getForId: { name: "counter", actorId },
271
- // } satisfies ActorQuery),
272
- // },
273
- // },
274
- // );
275
- // const response = await http.rpcs.$get();
276
- // expect(response.status).toBe(200);
277
- // const data = await response.json();
278
- // expect(data).toEqual(
279
- // expect.objectContaining({
280
- // rpcs: expect.arrayContaining(["increment", "getCount"]),
281
- // }),
282
- // );
283
- // });
284
- // // database is not officially supported yet
285
- // test.skip("should get actor database info", async (c) => {
286
- // const { client, endpoint } = await setupDriverTest(
287
- // c,
288
- // driverTestConfig,
289
- // );
290
- // const handle = await client.counter.create(["test-db"]);
291
- // const actorId = await handle.resolve();
292
- // const http = createActorInspectorClient(
293
- // `${endpoint}/actors/inspect`,
294
- // {
295
- // headers: {
296
- // Authorization: `Bearer token`,
297
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
298
- // getForId: { name: "counter", actorId },
299
- // } satisfies ActorQuery),
300
- // },
301
- // },
302
- // );
303
- // const response = await http.db.$get();
304
- // expect(response.status).toBe(200);
305
- // const data = await response.json();
306
- // // Database might be enabled or disabled depending on actor configuration
307
- // expect(data).toHaveProperty("enabled");
308
- // expect(typeof data.enabled).toBe("boolean");
309
- // if (data.enabled) {
310
- // expect(data).toHaveProperty("db");
311
- // expect(Array.isArray(data.db)).toBe(true);
312
- // } else {
313
- // expect(data.db).toBe(null);
314
- // }
315
- // });
316
- // test.skip("should execute database query when database is enabled", async (c) => {
317
- // const { client, endpoint } = await setupDriverTest(
318
- // c,
319
- // driverTestConfig,
320
- // );
321
- // const handle = await client.counter.create(["test-db-query"]);
322
- // const actorId = await handle.resolve();
323
- // const http = createActorInspectorClient(
324
- // `${endpoint}/actors/inspect`,
325
- // {
326
- // headers: {
327
- // Authorization: `Bearer token`,
328
- // [HEADER_ACTOR_QUERY]: JSON.stringify({
329
- // getForId: { name: "counter", actorId },
330
- // } satisfies ActorQuery),
331
- // },
332
- // },
333
- // );
334
- // // First check if database is enabled
335
- // const dbInfoResponse = await http.db.$get();
336
- // const dbInfo = await dbInfoResponse.json();
337
- // if (dbInfo.enabled) {
338
- // // Execute a simple query
339
- // const queryResponse = await http.db.$post({
340
- // json: {
341
- // query: "SELECT 1 as test",
342
- // params: [],
343
- // },
344
- // });
345
- // expect(queryResponse.status).toBe(200);
346
- // const queryData = await queryResponse.json();
347
- // expect(queryData).toHaveProperty("result");
348
- // } else {
349
- // // If database is not enabled, the POST should return enabled: false
350
- // const queryResponse = await http.db.$post({
351
- // json: {
352
- // query: "SELECT 1 as test",
353
- // params: [],
354
- // },
355
- // });
356
- // expect(queryResponse.status).toBe(200);
357
- // const queryData = await queryResponse.json();
358
- // expect(queryData).toEqual({ enabled: false });
359
- // }
360
- // });
361
- // });
6
+ describe("Actor Inspector HTTP API", () => {
7
+ test("GET /inspector/state returns actor state", async (c) => {
8
+ const { client } = await setupDriverTest(c, driverTestConfig);
9
+ const handle = client.counter.getOrCreate(["inspector-state"]);
10
+
11
+ // Set some state first
12
+ await handle.increment(5);
13
+
14
+ const gatewayUrl = await handle.getGatewayUrl();
15
+ const response = await fetch(`${gatewayUrl}/inspector/state`, {
16
+ headers: { Authorization: "Bearer token" },
17
+ });
18
+ expect(response.status).toBe(200);
19
+ const data = await response.json();
20
+ expect(data).toEqual({ state: { count: 5 } });
21
+ });
22
+
23
+ test("PATCH /inspector/state updates actor state", async (c) => {
24
+ const { client } = await setupDriverTest(c, driverTestConfig);
25
+ const handle = client.counter.getOrCreate([
26
+ "inspector-set-state",
27
+ ]);
28
+
29
+ await handle.increment(5);
30
+
31
+ const gatewayUrl = await handle.getGatewayUrl();
32
+
33
+ // Replace state
34
+ const patchResponse = await fetch(
35
+ `${gatewayUrl}/inspector/state`,
36
+ {
37
+ method: "PATCH",
38
+ headers: {
39
+ "Content-Type": "application/json",
40
+ Authorization: "Bearer token",
41
+ },
42
+ body: JSON.stringify({ state: { count: 42 } }),
43
+ },
44
+ );
45
+ expect(patchResponse.status).toBe(200);
46
+ const patchData = await patchResponse.json();
47
+ expect(patchData).toEqual({ ok: true });
48
+
49
+ // Verify via action
50
+ const count = await handle.getCount();
51
+ expect(count).toBe(42);
52
+ });
53
+
54
+ test("GET /inspector/connections returns connections list", async (c) => {
55
+ const { client } = await setupDriverTest(c, driverTestConfig);
56
+ const handle = client.counter.getOrCreate([
57
+ "inspector-connections",
58
+ ]);
59
+
60
+ // Ensure actor exists
61
+ await handle.increment(0);
62
+
63
+ const gatewayUrl = await handle.getGatewayUrl();
64
+ const response = await fetch(
65
+ `${gatewayUrl}/inspector/connections`,
66
+ {
67
+ headers: { Authorization: "Bearer token" },
68
+ },
69
+ );
70
+ expect(response.status).toBe(200);
71
+ const data = (await response.json()) as {
72
+ connections: unknown[];
73
+ };
74
+ expect(data).toHaveProperty("connections");
75
+ expect(Array.isArray(data.connections)).toBe(true);
76
+ });
77
+
78
+ test("GET /inspector/rpcs returns available actions", async (c) => {
79
+ const { client } = await setupDriverTest(c, driverTestConfig);
80
+ const handle = client.counter.getOrCreate(["inspector-rpcs"]);
81
+
82
+ // Ensure actor exists
83
+ await handle.increment(0);
84
+
85
+ const gatewayUrl = await handle.getGatewayUrl();
86
+ const response = await fetch(`${gatewayUrl}/inspector/rpcs`, {
87
+ headers: { Authorization: "Bearer token" },
88
+ });
89
+ expect(response.status).toBe(200);
90
+ const data = (await response.json()) as { rpcs: string[] };
91
+ expect(data).toHaveProperty("rpcs");
92
+ expect(data.rpcs).toContain("increment");
93
+ expect(data.rpcs).toContain("getCount");
94
+ expect(data.rpcs).toContain("setCount");
95
+ });
96
+
97
+ test("POST /inspector/action/:name executes an action", async (c) => {
98
+ const { client } = await setupDriverTest(c, driverTestConfig);
99
+ const handle = client.counter.getOrCreate([
100
+ "inspector-action",
101
+ ]);
102
+
103
+ await handle.increment(10);
104
+
105
+ const gatewayUrl = await handle.getGatewayUrl();
106
+ const response = await fetch(
107
+ `${gatewayUrl}/inspector/action/increment`,
108
+ {
109
+ method: "POST",
110
+ headers: {
111
+ "Content-Type": "application/json",
112
+ Authorization: "Bearer token",
113
+ },
114
+ body: JSON.stringify({ args: [5] }),
115
+ },
116
+ );
117
+ expect(response.status).toBe(200);
118
+ const data = (await response.json()) as { output: number };
119
+ expect(data.output).toBe(15);
120
+
121
+ // Verify via normal action
122
+ const count = await handle.getCount();
123
+ expect(count).toBe(15);
124
+ });
125
+
126
+ test("GET /inspector/queue returns queue status", async (c) => {
127
+ const { client } = await setupDriverTest(c, driverTestConfig);
128
+ const handle = client.counter.getOrCreate(["inspector-queue"]);
129
+
130
+ // Ensure actor exists
131
+ await handle.increment(0);
132
+
133
+ const gatewayUrl = await handle.getGatewayUrl();
134
+ const response = await fetch(
135
+ `${gatewayUrl}/inspector/queue?limit=10`,
136
+ {
137
+ headers: { Authorization: "Bearer token" },
138
+ },
139
+ );
140
+ expect(response.status).toBe(200);
141
+ const data = (await response.json()) as {
142
+ size: number;
143
+ maxSize: number;
144
+ truncated: boolean;
145
+ messages: unknown[];
146
+ };
147
+ expect(data).toHaveProperty("size");
148
+ expect(data).toHaveProperty("maxSize");
149
+ expect(data).toHaveProperty("truncated");
150
+ expect(data).toHaveProperty("messages");
151
+ expect(typeof data.size).toBe("number");
152
+ expect(typeof data.maxSize).toBe("number");
153
+ expect(typeof data.truncated).toBe("boolean");
154
+ expect(Array.isArray(data.messages)).toBe(true);
155
+ });
156
+
157
+ test("GET /inspector/traces returns trace data", async (c) => {
158
+ const { client } = await setupDriverTest(c, driverTestConfig);
159
+ const handle = client.counter.getOrCreate([
160
+ "inspector-traces",
161
+ ]);
162
+
163
+ // Perform an action to generate traces
164
+ await handle.increment(1);
165
+
166
+ const gatewayUrl = await handle.getGatewayUrl();
167
+ const response = await fetch(
168
+ `${gatewayUrl}/inspector/traces?startMs=0&endMs=${Date.now() + 60000}&limit=100`,
169
+ {
170
+ headers: { Authorization: "Bearer token" },
171
+ },
172
+ );
173
+ expect(response.status).toBe(200);
174
+ const data = (await response.json()) as {
175
+ otlp: unknown;
176
+ clamped: boolean;
177
+ };
178
+ expect(data).toHaveProperty("otlp");
179
+ expect(data).toHaveProperty("clamped");
180
+ expect(typeof data.clamped).toBe("boolean");
181
+ });
182
+
183
+ test("GET /inspector/workflow-history returns workflow status", async (c) => {
184
+ const { client } = await setupDriverTest(c, driverTestConfig);
185
+ const handle = client.counter.getOrCreate([
186
+ "inspector-workflow",
187
+ ]);
188
+
189
+ // Ensure actor exists
190
+ await handle.increment(0);
191
+
192
+ const gatewayUrl = await handle.getGatewayUrl();
193
+ const response = await fetch(
194
+ `${gatewayUrl}/inspector/workflow-history`,
195
+ {
196
+ headers: { Authorization: "Bearer token" },
197
+ },
198
+ );
199
+ expect(response.status).toBe(200);
200
+ const data = (await response.json()) as {
201
+ history: unknown;
202
+ isWorkflowEnabled: boolean;
203
+ };
204
+ expect(data).toHaveProperty("history");
205
+ expect(data).toHaveProperty("isWorkflowEnabled");
206
+ // Counter actor has no workflow, so it should be disabled
207
+ expect(data.isWorkflowEnabled).toBe(false);
208
+ expect(data.history).toBeNull();
209
+ });
210
+
211
+ test("GET /inspector/summary returns full actor snapshot", async (c) => {
212
+ const { client } = await setupDriverTest(c, driverTestConfig);
213
+ const handle = client.counter.getOrCreate([
214
+ "inspector-summary",
215
+ ]);
216
+
217
+ await handle.increment(7);
218
+
219
+ const gatewayUrl = await handle.getGatewayUrl();
220
+ const response = await fetch(
221
+ `${gatewayUrl}/inspector/summary`,
222
+ {
223
+ headers: { Authorization: "Bearer token" },
224
+ },
225
+ );
226
+ expect(response.status).toBe(200);
227
+ const data = (await response.json()) as {
228
+ state: { count: number };
229
+ connections: unknown[];
230
+ rpcs: string[];
231
+ queueSize: number;
232
+ isStateEnabled: boolean;
233
+ isDatabaseEnabled: boolean;
234
+ isWorkflowEnabled: boolean;
235
+ workflowHistory: unknown;
236
+ };
237
+ expect(data.state).toEqual({ count: 7 });
238
+ expect(Array.isArray(data.connections)).toBe(true);
239
+ expect(data.rpcs).toContain("increment");
240
+ expect(typeof data.queueSize).toBe("number");
241
+ expect(data.isStateEnabled).toBe(true);
242
+ expect(typeof data.isDatabaseEnabled).toBe("boolean");
243
+ expect(data.isWorkflowEnabled).toBe(false);
244
+ expect(data.workflowHistory).toBeNull();
245
+ });
246
+
247
+ test("inspector endpoints require auth in non-dev mode", async (c) => {
248
+ const { client } = await setupDriverTest(c, driverTestConfig);
249
+ const handle = client.counter.getOrCreate([
250
+ "inspector-auth",
251
+ ]);
252
+
253
+ await handle.increment(0);
254
+
255
+ const gatewayUrl = await handle.getGatewayUrl();
256
+
257
+ // Request with wrong token should fail
258
+ const response = await fetch(`${gatewayUrl}/inspector/state`, {
259
+ headers: { Authorization: "Bearer wrong-token" },
260
+ });
261
+ expect(response.status).toBe(401);
262
+ });
362
263
  });
363
264
  }