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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/dist/browser/client.d.ts +1286 -89
  2. package/dist/browser/client.js +1699 -704
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2083 -236
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +8 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -1
  10. package/dist/tsup/actor/errors.d.ts +1 -1
  11. package/dist/tsup/actor/errors.js +7 -1
  12. package/dist/tsup/agent-os/index.cjs +3 -2289
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +1 -1813
  15. package/dist/tsup/agent-os/index.d.ts +1 -1813
  16. package/dist/tsup/agent-os/index.js +3 -2289
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
  19. package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
  20. package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
  21. package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
  22. package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
  23. package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
  24. package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
  25. package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
  26. package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
  27. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
  28. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  29. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
  30. package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
  31. package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
  32. package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
  33. package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
  34. package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
  35. package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
  36. package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
  37. package/dist/tsup/chunk-HYIVSH5X.js +244 -0
  38. package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
  39. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
  40. package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
  41. package/dist/tsup/chunk-IWACVNN5.js +14 -0
  42. package/dist/tsup/chunk-IWACVNN5.js.map +1 -0
  43. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  44. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  45. package/dist/tsup/{chunk-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
  46. package/dist/tsup/chunk-K3AJOPSF.js.map +1 -0
  47. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  48. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  49. package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
  50. package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
  51. package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
  52. package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
  53. package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
  54. package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
  55. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
  56. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  57. package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
  58. package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
  59. package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
  60. package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
  61. package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
  62. package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
  63. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
  64. package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +33 -7
  68. package/dist/tsup/client/mod.d.ts +33 -7
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.js +3 -3
  77. package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
  78. package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
  79. package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
  80. package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
  81. package/dist/tsup/context-hyVakgnU.d.ts +136 -0
  82. package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
  83. package/dist/tsup/db/drizzle.cjs +127 -67
  84. package/dist/tsup/db/drizzle.cjs.map +1 -1
  85. package/dist/tsup/db/drizzle.d.cts +8 -4
  86. package/dist/tsup/db/drizzle.d.ts +8 -4
  87. package/dist/tsup/db/drizzle.js +127 -67
  88. package/dist/tsup/db/drizzle.js.map +1 -1
  89. package/dist/tsup/db/mod.cjs +6 -124
  90. package/dist/tsup/db/mod.cjs.map +1 -1
  91. package/dist/tsup/db/mod.d.cts +12 -4
  92. package/dist/tsup/db/mod.d.ts +12 -4
  93. package/dist/tsup/db/mod.js +5 -123
  94. package/dist/tsup/db/mod.js.map +1 -1
  95. package/dist/tsup/dynamic/mod.cjs +24 -0
  96. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  97. package/dist/tsup/dynamic/mod.d.cts +39 -0
  98. package/dist/tsup/dynamic/mod.d.ts +39 -0
  99. package/dist/tsup/dynamic/mod.js +24 -0
  100. package/dist/tsup/dynamic/mod.js.map +1 -0
  101. package/dist/tsup/inspector/mod.cjs +47 -12
  102. package/dist/tsup/inspector/mod.cjs.map +1 -1
  103. package/dist/tsup/inspector/mod.d.cts +26 -136
  104. package/dist/tsup/inspector/mod.d.ts +26 -136
  105. package/dist/tsup/inspector/mod.js +46 -11
  106. package/dist/tsup/inspector/mod.js.map +1 -1
  107. package/dist/tsup/inspector/workflow.cjs +21 -0
  108. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  109. package/dist/tsup/inspector/workflow.d.cts +144 -0
  110. package/dist/tsup/inspector/workflow.d.ts +144 -0
  111. package/dist/tsup/inspector/workflow.js +21 -0
  112. package/dist/tsup/inspector/workflow.js.map +1 -0
  113. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  114. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  115. package/dist/tsup/inspector-tab/mod.d.cts +242 -0
  116. package/dist/tsup/inspector-tab/mod.d.ts +242 -0
  117. package/dist/tsup/inspector-tab/mod.js +162 -0
  118. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  119. package/dist/tsup/mod.cjs +3527 -753
  120. package/dist/tsup/mod.cjs.map +1 -1
  121. package/dist/tsup/mod.d.cts +11 -7
  122. package/dist/tsup/mod.d.ts +11 -7
  123. package/dist/tsup/mod.js +3468 -694
  124. package/dist/tsup/mod.js.map +1 -1
  125. package/dist/tsup/test/mod.cjs +26 -21
  126. package/dist/tsup/test/mod.cjs.map +1 -1
  127. package/dist/tsup/test/mod.d.cts +7 -5
  128. package/dist/tsup/test/mod.d.ts +7 -5
  129. package/dist/tsup/test/mod.js +25 -20
  130. package/dist/tsup/test/mod.js.map +1 -1
  131. package/dist/tsup/unstable/migrations.cjs +101 -0
  132. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  133. package/dist/tsup/unstable/migrations.d.cts +29 -0
  134. package/dist/tsup/unstable/migrations.d.ts +29 -0
  135. package/dist/tsup/unstable/migrations.js +101 -0
  136. package/dist/tsup/unstable/migrations.js.map +1 -0
  137. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
  138. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
  139. package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
  140. package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
  141. package/dist/tsup/utils.cjs +7 -3
  142. package/dist/tsup/utils.cjs.map +1 -1
  143. package/dist/tsup/utils.d.cts +4 -147
  144. package/dist/tsup/utils.d.ts +4 -147
  145. package/dist/tsup/utils.js +6 -2
  146. package/dist/tsup/workflow/mod.cjs +557 -410
  147. package/dist/tsup/workflow/mod.cjs.map +1 -1
  148. package/dist/tsup/workflow/mod.d.cts +11 -9
  149. package/dist/tsup/workflow/mod.d.ts +11 -9
  150. package/dist/tsup/workflow/mod.js +551 -404
  151. package/dist/tsup/workflow/mod.js.map +1 -1
  152. package/package.json +67 -18
  153. package/src/actor/actions.ts +155 -0
  154. package/src/actor/config.ts +679 -101
  155. package/src/actor/contexts/index.ts +9 -2
  156. package/src/actor/definition.ts +75 -26
  157. package/src/actor/errors.ts +107 -8
  158. package/src/actor/keys.ts +87 -1
  159. package/src/actor/mod.ts +36 -20
  160. package/src/actor/schema.ts +6 -2
  161. package/src/actor/tracing.ts +28 -0
  162. package/src/agent-os/index.ts +5 -64
  163. package/src/client/actor-common.ts +84 -54
  164. package/src/client/actor-conn.ts +231 -68
  165. package/src/client/actor-handle.ts +283 -89
  166. package/src/client/actor-query.ts +13 -6
  167. package/src/client/auth.ts +37 -0
  168. package/src/client/client.ts +182 -21
  169. package/src/client/config.ts +28 -3
  170. package/src/client/errors.ts +15 -2
  171. package/src/client/lifecycle-errors.ts +63 -5
  172. package/src/client/mod.ts +10 -0
  173. package/src/client/outbound-telemetry.ts +66 -0
  174. package/src/client/query.ts +3 -1
  175. package/src/client/queue.ts +13 -3
  176. package/src/client/raw-utils.ts +59 -14
  177. package/src/client/resolve-gateway-target.ts +3 -1
  178. package/src/client/retry-budget.ts +81 -0
  179. package/src/client/token-provider.ts +93 -0
  180. package/src/client/utils.ts +22 -9
  181. package/src/common/actor-router-consts.ts +6 -0
  182. package/src/common/actor-telemetry-context.ts +19 -0
  183. package/src/common/actor-websocket.ts +3 -1
  184. package/src/common/bare/actor-persist/v1.ts +205 -163
  185. package/src/common/bare/actor-persist/v2.ts +265 -213
  186. package/src/common/bare/actor-persist/v3.ts +176 -172
  187. package/src/common/bare/actor-persist/v4.ts +254 -253
  188. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  189. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  190. package/src/common/bare/transport/v1.ts +694 -542
  191. package/src/common/client-protocol-versioned.ts +66 -64
  192. package/src/common/database/config.ts +175 -9
  193. package/src/common/database/mod.ts +262 -77
  194. package/src/common/database/native-database.ts +442 -20
  195. package/src/common/database/shared.ts +25 -0
  196. package/src/common/encoding.ts +278 -34
  197. package/src/common/engine.ts +28 -1
  198. package/src/common/eventsource.ts +1 -1
  199. package/src/common/fetch-like.ts +63 -0
  200. package/src/common/inline-websocket-adapter.ts +14 -13
  201. package/src/common/inspector-transport.ts +12 -2
  202. package/src/common/log.ts +15 -8
  203. package/src/common/otel-context.ts +99 -0
  204. package/src/common/router.ts +14 -18
  205. package/src/common/utils.ts +8 -169
  206. package/src/common/websocket-interface.ts +1 -1
  207. package/src/db/drizzle.ts +182 -80
  208. package/src/db/mod.ts +5 -1
  209. package/src/devtools-loader/index.ts +4 -7
  210. package/src/devtools-loader/serve-devtools.ts +26 -0
  211. package/src/dynamic/instance.ts +32 -0
  212. package/src/dynamic/internal.ts +50 -0
  213. package/src/dynamic/isolate-runtime.ts +64 -0
  214. package/src/dynamic/mod.ts +32 -0
  215. package/src/engine-api/actors.ts +15 -3
  216. package/src/engine-client/actor-http-client.ts +37 -22
  217. package/src/engine-client/actor-websocket-client.ts +37 -9
  218. package/src/engine-client/api-endpoints.ts +128 -5
  219. package/src/engine-client/api-utils.ts +2 -2
  220. package/src/engine-client/driver.ts +21 -16
  221. package/src/engine-client/mod.ts +280 -111
  222. package/src/engine-client/ws-proxy.ts +9 -4
  223. package/src/inspector/client.browser.ts +127 -15
  224. package/src/inspector/mod.ts +2 -4
  225. package/src/inspector/workflow.ts +61 -0
  226. package/src/inspector-tab/mod.ts +301 -0
  227. package/src/registry/config/envoy.ts +3 -20
  228. package/src/registry/config/index.ts +91 -74
  229. package/src/registry/index.ts +702 -80
  230. package/src/registry/napi-runtime.ts +643 -42
  231. package/src/registry/native-http.ts +225 -0
  232. package/src/registry/native-validation.ts +10 -12
  233. package/src/registry/native.ts +1881 -582
  234. package/src/registry/run-handler-coordinator.ts +219 -0
  235. package/src/registry/runtime.ts +441 -7
  236. package/src/registry/wasm-runtime.ts +516 -23
  237. package/src/registry/write-through-proxy.ts +141 -0
  238. package/src/serde.ts +2 -2
  239. package/src/serverless/configure.ts +18 -7
  240. package/src/test/mod.ts +2 -17
  241. package/src/test/ready.ts +22 -0
  242. package/src/unstable/migrations.ts +141 -0
  243. package/src/utils/endpoint-parser.ts +1 -1
  244. package/src/utils/env-vars.ts +50 -2
  245. package/src/utils/node.ts +44 -28
  246. package/src/utils/router.ts +1 -1
  247. package/src/utils.ts +4 -2
  248. package/src/workflow/context.ts +703 -242
  249. package/src/workflow/driver.ts +284 -125
  250. package/src/workflow/inspector.ts +24 -24
  251. package/src/workflow/mod.ts +76 -84
  252. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  253. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  254. package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
  255. package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
  256. package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
  257. package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
  258. package/dist/tsup/chunk-AGBP757I.js.map +0 -1
  259. package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
  260. package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
  261. package/dist/tsup/chunk-JGIPV3QU.js +0 -268
  262. package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
  263. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  264. package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
  265. package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
  266. package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
  267. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  268. package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
  269. package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
  270. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  271. package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
  272. package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
  273. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  274. package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
  275. package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
  276. package/dist/tsup/context-88opQsfZ.d.cts +0 -92
  277. package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
  278. package/src/actor/driver.ts +0 -141
  279. package/src/actor/instance/mod.ts +0 -2492
  280. package/src/actor/keys.test.ts +0 -275
  281. package/src/actor/utils.test.ts +0 -48
  282. package/src/agent-os/actor/cron.ts +0 -84
  283. package/src/agent-os/actor/db.ts +0 -54
  284. package/src/agent-os/actor/filesystem.ts +0 -131
  285. package/src/agent-os/actor/index.ts +0 -265
  286. package/src/agent-os/actor/network.ts +0 -58
  287. package/src/agent-os/actor/preview.ts +0 -191
  288. package/src/agent-os/actor/process.ts +0 -177
  289. package/src/agent-os/actor/session.ts +0 -518
  290. package/src/agent-os/actor/shell.ts +0 -60
  291. package/src/agent-os/config.ts +0 -79
  292. package/src/agent-os/fs/database-vfs.ts +0 -624
  293. package/src/agent-os/types.ts +0 -148
  294. package/src/client/test.ts +0 -44
  295. package/src/common/database/mod.test.ts +0 -137
  296. package/src/common/database/native-database.test.ts +0 -211
  297. package/src/common/inline-websocket-adapter.test.ts +0 -51
  298. package/src/drivers/engine/actor-driver.ts +0 -2460
  299. package/src/registry/runtime.test.ts +0 -50
  300. package/src/utils/endpoint-parser.test.ts +0 -206
  301. package/src/utils/serve.ts +0 -217
  302. package/src/utils.test.ts +0 -34
  303. /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
@@ -1,275 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import {
3
- deserializeActorKey,
4
- EMPTY_KEY,
5
- KEY_SEPARATOR,
6
- serializeActorKey,
7
- } from "./keys";
8
-
9
- describe("Key serialization and deserialization", () => {
10
- // Test serialization
11
- describe("serializeActorKey", () => {
12
- test("serializes empty key array", () => {
13
- expect(serializeActorKey([])).toBe(EMPTY_KEY);
14
- });
15
-
16
- test("serializes single key", () => {
17
- expect(serializeActorKey(["test"])).toBe("test");
18
- });
19
-
20
- test("serializes multiple keys", () => {
21
- expect(serializeActorKey(["a", "b", "c"])).toBe(
22
- `a${KEY_SEPARATOR}b${KEY_SEPARATOR}c`,
23
- );
24
- });
25
-
26
- test("escapes forward slashes in keys", () => {
27
- expect(serializeActorKey(["a/b"])).toBe("a\\/b");
28
- expect(serializeActorKey(["a/b", "c"])).toBe(
29
- `a\\/b${KEY_SEPARATOR}c`,
30
- );
31
- });
32
-
33
- test("escapes empty key marker in keys", () => {
34
- expect(serializeActorKey([EMPTY_KEY])).toBe(`\\${EMPTY_KEY}`);
35
- });
36
-
37
- test("handles complex keys", () => {
38
- expect(serializeActorKey(["a/b", EMPTY_KEY, "c/d"])).toBe(
39
- `a\\/b${KEY_SEPARATOR}\\${EMPTY_KEY}${KEY_SEPARATOR}c\\/d`,
40
- );
41
- });
42
- });
43
-
44
- // Test deserialization
45
- describe("deserializeActorKey", () => {
46
- test("deserializes empty string", () => {
47
- expect(deserializeActorKey("")).toEqual([]);
48
- });
49
-
50
- test("deserializes undefined/null", () => {
51
- expect(deserializeActorKey(undefined as unknown as string)).toEqual(
52
- [],
53
- );
54
- expect(deserializeActorKey(null as unknown as string)).toEqual([]);
55
- });
56
-
57
- test("deserializes empty key marker", () => {
58
- expect(deserializeActorKey(EMPTY_KEY)).toEqual([]);
59
- });
60
-
61
- test("deserializes single key", () => {
62
- expect(deserializeActorKey("test")).toEqual(["test"]);
63
- });
64
-
65
- test("deserializes multiple keys", () => {
66
- expect(
67
- deserializeActorKey(`a${KEY_SEPARATOR}b${KEY_SEPARATOR}c`),
68
- ).toEqual(["a", "b", "c"]);
69
- });
70
-
71
- test("deserializes keys with escaped forward slashes", () => {
72
- expect(deserializeActorKey("a\\/b")).toEqual(["a/b"]);
73
- expect(deserializeActorKey(`a\\/b${KEY_SEPARATOR}c`)).toEqual([
74
- "a/b",
75
- "c",
76
- ]);
77
- });
78
-
79
- test("deserializes keys with escaped empty key marker", () => {
80
- expect(deserializeActorKey(`\\${EMPTY_KEY}`)).toEqual([EMPTY_KEY]);
81
- });
82
-
83
- test("deserializes complex keys", () => {
84
- expect(
85
- deserializeActorKey(
86
- `a\\/b${KEY_SEPARATOR}\\${EMPTY_KEY}${KEY_SEPARATOR}c\\/d`,
87
- ),
88
- ).toEqual(["a/b", EMPTY_KEY, "c/d"]);
89
- });
90
- });
91
-
92
- // Test edge cases
93
- describe("edge cases", () => {
94
- test("handles empty string parts", () => {
95
- const testCases: Array<[string[], string]> = [
96
- [[""], "\\0"],
97
- [["a", "", "b"], "a/\\0/b"],
98
- [["", "a"], "\\0/a"],
99
- [["a", ""], "a/\\0"],
100
- [["", "", ""], "\\0/\\0/\\0"],
101
- [["", "a", "", "b", ""], "\\0/a/\\0/b/\\0"],
102
- [[], "/"],
103
- [["test"], "test"],
104
- [["a", "b", "c"], "a/b/c"],
105
- [["a/b", "c"], "a\\/b/c"],
106
- [[EMPTY_KEY], "\\/"],
107
- [["a/b", EMPTY_KEY, "c/d"], "a\\/b/\\//c\\/d"],
108
- [
109
- ["special\\chars", "more:complex,keys", "final key"],
110
- "special\\\\chars/more:complex,keys/final key",
111
- ],
112
- ];
113
-
114
- for (const [key, expectedSerialized] of testCases) {
115
- const serialized = serializeActorKey(key);
116
- expect(serialized).toBe(expectedSerialized);
117
- const deserialized = deserializeActorKey(serialized);
118
- expect(deserialized).toEqual(key);
119
- }
120
- });
121
-
122
- test("differentiates empty array from array with empty string", () => {
123
- const emptyArray: string[] = [];
124
- const arrayWithEmptyString = [""];
125
-
126
- const serialized1 = serializeActorKey(emptyArray);
127
- const serialized2 = serializeActorKey(arrayWithEmptyString);
128
-
129
- expect(serialized1).toBe(EMPTY_KEY); // Should be "/"
130
- expect(serialized2).not.toBe(EMPTY_KEY); // Should NOT be "/"
131
- expect(serialized2).toBe("\\0"); // Empty string becomes \0 marker
132
-
133
- expect(deserializeActorKey(serialized1)).toEqual(emptyArray);
134
- expect(deserializeActorKey(serialized2)).toEqual(
135
- arrayWithEmptyString,
136
- );
137
- });
138
-
139
- test("handles mix of empty strings and forward slash (EMPTY_KEY)", () => {
140
- const testCases: Array<[string[], string]> = [
141
- [["", EMPTY_KEY, ""], "\\0/\\//\\0"],
142
- [[EMPTY_KEY, ""], "\\//\\0"],
143
- [["", EMPTY_KEY], "\\0/\\/"],
144
- [["a", "", EMPTY_KEY, "", "b"], "a/\\0/\\//\\0/b"],
145
- ];
146
-
147
- for (const [key, expectedSerialized] of testCases) {
148
- const serialized = serializeActorKey(key);
149
- expect(serialized).toBe(expectedSerialized);
150
- const deserialized = deserializeActorKey(serialized);
151
- expect(deserialized).toEqual(key);
152
- }
153
- });
154
-
155
- test("handles literal backslash-zero string", () => {
156
- const testCases: Array<[string[], string]> = [
157
- [["\\0"], "\\\\0"], // Literal \0 string
158
- [["a\\0b"], "a\\\\0b"], // Literal \0 in middle
159
- [["\\0", ""], "\\\\0/\\0"], // Literal \0 with empty string
160
- [["", "\\0"], "\\0/\\\\0"], // Empty string with literal \0
161
- ];
162
-
163
- for (const [key, expectedSerialized] of testCases) {
164
- const serialized = serializeActorKey(key);
165
- expect(serialized).toBe(expectedSerialized);
166
- const deserialized = deserializeActorKey(serialized);
167
- expect(deserialized).toEqual(key);
168
- }
169
- });
170
-
171
- test("handles backslash at the end", () => {
172
- const key = ["abc\\"];
173
- const serialized = serializeActorKey(key);
174
- expect(serialized).toBe("abc\\\\");
175
- const deserialized = deserializeActorKey(serialized);
176
- expect(deserialized).toEqual(key);
177
- });
178
-
179
- test("handles backslashes in middle of string", () => {
180
- const testCases: Array<[string[], string]> = [
181
- [["abc\\def"], "abc\\\\def"],
182
- [["abc\\\\def"], "abc\\\\\\\\def"],
183
- [["path\\to\\file"], "path\\\\to\\\\file"],
184
- ];
185
-
186
- for (const [key, expectedSerialized] of testCases) {
187
- const serialized = serializeActorKey(key);
188
- expect(serialized).toBe(expectedSerialized);
189
- const deserialized = deserializeActorKey(serialized);
190
- expect(deserialized).toEqual(key);
191
- }
192
- });
193
-
194
- test("handles forward slashes at the end of strings", () => {
195
- const serialized = serializeActorKey(["abc\\/"]);
196
- expect(deserializeActorKey(serialized)).toEqual(["abc\\/"]);
197
- });
198
-
199
- test("handles mixed backslashes and forward slashes", () => {
200
- const testCases: Array<[string[], string]> = [
201
- [["path\\to\\file/dir"], "path\\\\to\\\\file\\/dir"],
202
- [["file\\with/slash"], "file\\\\with\\/slash"],
203
- [
204
- ["path\\to\\file", "with/slash"],
205
- "path\\\\to\\\\file/with\\/slash",
206
- ],
207
- ];
208
-
209
- for (const [key, expectedSerialized] of testCases) {
210
- const serialized = serializeActorKey(key);
211
- expect(serialized).toBe(expectedSerialized);
212
- const deserialized = deserializeActorKey(serialized);
213
- expect(deserialized).toEqual(key);
214
- }
215
- });
216
-
217
- test("handles multiple consecutive forward slashes", () => {
218
- const key = ["a//b"];
219
- const serialized = serializeActorKey(key);
220
- expect(serialized).toBe("a\\/\\/b");
221
- const deserialized = deserializeActorKey(serialized);
222
- expect(deserialized).toEqual(key);
223
- });
224
-
225
- test("handles special characters", () => {
226
- const key = ["a💻b", "c🔑d"];
227
- const serialized = serializeActorKey(key);
228
- expect(serialized).toBe("a💻b/c🔑d");
229
- const deserialized = deserializeActorKey(serialized);
230
- expect(deserialized).toEqual(key);
231
- });
232
-
233
- test("handles escaped forward slashes immediately after separator", () => {
234
- const key = ["abc", "/def"];
235
- const serialized = serializeActorKey(key);
236
- expect(serialized).toBe(`abc${KEY_SEPARATOR}\\/def`);
237
- expect(deserializeActorKey(serialized)).toEqual(key);
238
- });
239
- });
240
-
241
- // Test exact key matching
242
- describe("exact key matching", () => {
243
- test("differentiates [a,b] from [a,b,c]", () => {
244
- const key1 = ["a", "b"];
245
- const key2 = ["a", "b", "c"];
246
-
247
- const serialized1 = serializeActorKey(key1);
248
- const serialized2 = serializeActorKey(key2);
249
-
250
- expect(serialized1).not.toBe(serialized2);
251
- });
252
-
253
- test("differentiates [a,b] from [a]", () => {
254
- const key1 = ["a", "b"];
255
- const key2 = ["a"];
256
-
257
- const serialized1 = serializeActorKey(key1);
258
- const serialized2 = serializeActorKey(key2);
259
-
260
- expect(serialized1).not.toBe(serialized2);
261
- });
262
-
263
- test("differentiates [a/b] from [a,b]", () => {
264
- const key1 = ["a/b"];
265
- const key2 = ["a", "b"];
266
-
267
- const serialized1 = serializeActorKey(key1);
268
- const serialized2 = serializeActorKey(key2);
269
-
270
- expect(serialized1).not.toBe(serialized2);
271
- expect(deserializeActorKey(serialized1)).toEqual(key1);
272
- expect(deserializeActorKey(serialized2)).toEqual(key2);
273
- });
274
- });
275
- });
@@ -1,48 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { isConnStatePath, isStatePath } from "./utils";
3
-
4
- describe("isStatePath", () => {
5
- test("matches exact state", () => {
6
- expect(isStatePath("state")).toBe(true);
7
- });
8
-
9
- test("matches nested state paths", () => {
10
- expect(isStatePath("state.foo")).toBe(true);
11
- expect(isStatePath("state.foo.bar")).toBe(true);
12
- });
13
-
14
- test("does not match other paths", () => {
15
- expect(isStatePath("connections")).toBe(false);
16
- expect(isStatePath("stateX")).toBe(false);
17
- expect(isStatePath("mystate")).toBe(false);
18
- });
19
- });
20
-
21
- describe("isConnStatePath", () => {
22
- test("matches connection state paths", () => {
23
- expect(isConnStatePath("connections.0.state")).toBe(true);
24
- expect(isConnStatePath("connections.123.state")).toBe(true);
25
- });
26
-
27
- test("matches nested connection state paths", () => {
28
- expect(isConnStatePath("connections.0.state.foo")).toBe(true);
29
- expect(isConnStatePath("connections.5.state.bar.baz")).toBe(true);
30
- });
31
-
32
- test("does not match non-state connection paths", () => {
33
- expect(isConnStatePath("connections.0.params")).toBe(false);
34
- expect(isConnStatePath("connections.0.token")).toBe(false);
35
- expect(isConnStatePath("connections.0")).toBe(false);
36
- });
37
-
38
- test("does not match other paths", () => {
39
- expect(isConnStatePath("state")).toBe(false);
40
- expect(isConnStatePath("connections")).toBe(false);
41
- expect(isConnStatePath("other.0.state")).toBe(false);
42
- });
43
-
44
- test("does not match malformed paths", () => {
45
- expect(isConnStatePath("connections.state")).toBe(false);
46
- expect(isConnStatePath("connections.0.stateX")).toBe(false);
47
- });
48
- });
@@ -1,84 +0,0 @@
1
- import type { CronAction, CronJobInfo } from "@rivet-dev/agent-os-core";
2
- import type { AgentOsActorConfig } from "../config";
3
- import type {
4
- AgentOsActionContext,
5
- SerializableCronAction,
6
- SerializableCronJobInfo,
7
- SerializableCronJobOptions,
8
- } from "../types";
9
- import { ensureVm } from "./index";
10
-
11
- function serializeCronAction(action: CronAction): SerializableCronAction {
12
- switch (action.type) {
13
- case "session":
14
- return {
15
- type: "session",
16
- agentType: action.agentType,
17
- prompt: action.prompt,
18
- cwd: action.options?.cwd,
19
- };
20
- case "exec":
21
- return {
22
- type: "exec",
23
- command: action.command,
24
- args: action.args,
25
- };
26
- case "callback":
27
- throw new TypeError("callback cron actions are not serializable");
28
- }
29
- }
30
-
31
- function serializeCronJob(job: CronJobInfo): SerializableCronJobInfo {
32
- return {
33
- id: job.id,
34
- schedule: job.schedule,
35
- action: serializeCronAction(job.action),
36
- overlap: job.overlap,
37
- lastRun: job.lastRun?.toISOString(),
38
- nextRun: job.nextRun?.toISOString(),
39
- runCount: job.runCount,
40
- running: job.running,
41
- };
42
- }
43
-
44
- // Build cron scheduling actions for the actor factory.
45
- export function buildCronActions<TConnParams>(
46
- config: AgentOsActorConfig<TConnParams>,
47
- ) {
48
- return {
49
- scheduleCron: async (
50
- c: AgentOsActionContext<TConnParams>,
51
- options: SerializableCronJobOptions,
52
- ): Promise<{ id: string }> => {
53
- const agentOs = await ensureVm(c, config);
54
- const job = agentOs.scheduleCron({
55
- id: options.id,
56
- schedule: options.schedule,
57
- action: options.action as CronAction,
58
- overlap: options.overlap,
59
- });
60
- c.log.info({
61
- msg: "agent-os cron job scheduled",
62
- jobId: job.id,
63
- schedule: options.schedule,
64
- });
65
- return { id: job.id };
66
- },
67
-
68
- listCronJobs: async (
69
- c: AgentOsActionContext<TConnParams>,
70
- ): Promise<SerializableCronJobInfo[]> => {
71
- const agentOs = await ensureVm(c, config);
72
- return agentOs.listCronJobs().map(serializeCronJob);
73
- },
74
-
75
- cancelCronJob: async (
76
- c: AgentOsActionContext<TConnParams>,
77
- id: string,
78
- ): Promise<void> => {
79
- const agentOs = await ensureVm(c, config);
80
- agentOs.cancelCronJob(id);
81
- c.log.info({ msg: "agent-os cron job cancelled", jobId: id });
82
- },
83
- };
84
- }
@@ -1,54 +0,0 @@
1
- import type { RawAccess } from "@/common/database/config";
2
-
3
- export async function migrateAgentOsTables(db: RawAccess): Promise<void> {
4
- await db.execute(`
5
- CREATE TABLE IF NOT EXISTS agent_os_preview_tokens (
6
- token TEXT PRIMARY KEY,
7
- port INTEGER NOT NULL,
8
- created_at INTEGER NOT NULL,
9
- expires_at INTEGER NOT NULL
10
- );
11
-
12
- CREATE INDEX IF NOT EXISTS idx_preview_tokens_expires_at
13
- ON agent_os_preview_tokens(expires_at);
14
-
15
- CREATE TABLE IF NOT EXISTS agent_os_fs_entries (
16
- path TEXT PRIMARY KEY,
17
- is_directory INTEGER NOT NULL DEFAULT 0,
18
- content BLOB,
19
- mode INTEGER NOT NULL DEFAULT 33188,
20
- uid INTEGER NOT NULL DEFAULT 0,
21
- gid INTEGER NOT NULL DEFAULT 0,
22
- size INTEGER NOT NULL DEFAULT 0,
23
- atime_ms INTEGER NOT NULL,
24
- mtime_ms INTEGER NOT NULL,
25
- ctime_ms INTEGER NOT NULL,
26
- birthtime_ms INTEGER NOT NULL,
27
- symlink_target TEXT,
28
- nlink INTEGER NOT NULL DEFAULT 1
29
- );
30
-
31
- CREATE INDEX IF NOT EXISTS idx_fs_entries_parent
32
- ON agent_os_fs_entries(path);
33
-
34
- CREATE TABLE IF NOT EXISTS agent_os_sessions (
35
- session_id TEXT PRIMARY KEY,
36
- agent_type TEXT NOT NULL,
37
- capabilities TEXT NOT NULL,
38
- agent_info TEXT,
39
- created_at INTEGER NOT NULL
40
- );
41
-
42
- CREATE TABLE IF NOT EXISTS agent_os_session_events (
43
- id INTEGER PRIMARY KEY AUTOINCREMENT,
44
- session_id TEXT NOT NULL,
45
- seq INTEGER NOT NULL,
46
- event TEXT NOT NULL,
47
- created_at INTEGER NOT NULL,
48
- FOREIGN KEY (session_id) REFERENCES agent_os_sessions(session_id) ON DELETE CASCADE
49
- );
50
-
51
- CREATE INDEX IF NOT EXISTS idx_session_events_session_seq
52
- ON agent_os_session_events(session_id, seq);
53
- `);
54
- }
@@ -1,131 +0,0 @@
1
- import type {
2
- AgentRegistryEntry,
3
- BatchReadResult,
4
- BatchWriteEntry,
5
- BatchWriteResult,
6
- DirEntry,
7
- ReaddirRecursiveOptions,
8
- } from "@rivet-dev/agent-os-core";
9
- import type { AgentOsActorConfig } from "../config";
10
- import type { AgentOsActionContext } from "../types";
11
- import { ensureVm } from "./index";
12
-
13
- // Infer types from AgentOs methods since @secure-exec/core is not a direct dep.
14
- type VirtualStat = Awaited<
15
- ReturnType<import("@rivet-dev/agent-os-core").AgentOs["stat"]>
16
- >;
17
- type DeleteOptions = Parameters<
18
- import("@rivet-dev/agent-os-core").AgentOs["delete"]
19
- >[1];
20
-
21
- // Build filesystem and agent registry actions for the actor factory.
22
- export function buildFilesystemActions<TConnParams>(
23
- config: AgentOsActorConfig<TConnParams>,
24
- ) {
25
- return {
26
- readFile: async (
27
- c: AgentOsActionContext<TConnParams>,
28
- path: string,
29
- ): Promise<Uint8Array> => {
30
- const agentOs = await ensureVm(c, config);
31
- return agentOs.readFile(path);
32
- },
33
-
34
- writeFile: async (
35
- c: AgentOsActionContext<TConnParams>,
36
- path: string,
37
- content: string | Uint8Array,
38
- ): Promise<void> => {
39
- const agentOs = await ensureVm(c, config);
40
- await agentOs.writeFile(path, content);
41
- },
42
-
43
- readFiles: async (
44
- c: AgentOsActionContext<TConnParams>,
45
- paths: string[],
46
- ): Promise<BatchReadResult[]> => {
47
- const agentOs = await ensureVm(c, config);
48
- return agentOs.readFiles(paths);
49
- },
50
-
51
- writeFiles: async (
52
- c: AgentOsActionContext<TConnParams>,
53
- entries: BatchWriteEntry[],
54
- ): Promise<BatchWriteResult[]> => {
55
- const agentOs = await ensureVm(c, config);
56
- return agentOs.writeFiles(entries);
57
- },
58
-
59
- mkdir: async (
60
- c: AgentOsActionContext<TConnParams>,
61
- path: string,
62
- options?: { recursive?: boolean },
63
- ): Promise<void> => {
64
- const agentOs = await ensureVm(c, config);
65
- await agentOs.mkdir(path, options);
66
- },
67
-
68
- readdir: async (
69
- c: AgentOsActionContext<TConnParams>,
70
- path: string,
71
- ): Promise<string[]> => {
72
- const agentOs = await ensureVm(c, config);
73
- return agentOs.readdir(path);
74
- },
75
-
76
- readdirRecursive: async (
77
- c: AgentOsActionContext<TConnParams>,
78
- path: string,
79
- options?: ReaddirRecursiveOptions,
80
- ): Promise<DirEntry[]> => {
81
- const agentOs = await ensureVm(c, config);
82
- return agentOs.readdirRecursive(path, options);
83
- },
84
-
85
- stat: async (
86
- c: AgentOsActionContext<TConnParams>,
87
- path: string,
88
- ): Promise<VirtualStat> => {
89
- const agentOs = await ensureVm(c, config);
90
- return agentOs.stat(path);
91
- },
92
-
93
- exists: async (
94
- c: AgentOsActionContext<TConnParams>,
95
- path: string,
96
- ): Promise<boolean> => {
97
- const agentOs = await ensureVm(c, config);
98
- return agentOs.exists(path);
99
- },
100
-
101
- move: async (
102
- c: AgentOsActionContext<TConnParams>,
103
- from: string,
104
- to: string,
105
- ): Promise<void> => {
106
- const agentOs = await ensureVm(c, config);
107
- await agentOs.move(from, to);
108
- },
109
-
110
- deleteFile: async (
111
- c: AgentOsActionContext<TConnParams>,
112
- path: string,
113
- options?: DeleteOptions,
114
- ): Promise<void> => {
115
- const agentOs = await ensureVm(c, config);
116
- await agentOs.delete(path, options);
117
- },
118
-
119
- // TODO: mountFs and unmountFs are not exposed as actor actions because
120
- // filesystem drivers (VirtualFileSystem) are not serializable over the
121
- // network. Mount filesystems via the `options.mounts` config in agentOs()
122
- // instead. See: https://github.com/rivet-dev/rivet/issues/XXXX
123
-
124
- listAgents: async (
125
- c: AgentOsActionContext<TConnParams>,
126
- ): Promise<AgentRegistryEntry[]> => {
127
- const agentOs = await ensureVm(c, config);
128
- return agentOs.listAgents();
129
- },
130
- };
131
- }