rivetkit 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.4e59a38

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 (253) hide show
  1. package/dist/browser/client.d.ts +561 -89
  2. package/dist/browser/client.js +1063 -430
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +22 -2
  5. package/dist/browser/inspector/client.js +1036 -232
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +6 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -74
  10. package/dist/tsup/actor/errors.d.ts +1 -74
  11. package/dist/tsup/actor/errors.js +5 -1
  12. package/dist/tsup/agent-os/index.cjs +2218 -2082
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +556 -85
  15. package/dist/tsup/agent-os/index.d.ts +556 -85
  16. package/dist/tsup/agent-os/index.js +2220 -2084
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/{chunk-NFC5VU36.cjs → chunk-3GC3EP6D.cjs} +18 -10
  19. package/dist/tsup/chunk-3GC3EP6D.cjs.map +1 -0
  20. package/dist/tsup/{chunk-7MRGNVSR.js → chunk-3GLNEWGY.js} +78 -6
  21. package/dist/tsup/chunk-3GLNEWGY.js.map +1 -0
  22. package/dist/tsup/{chunk-V3QNBJ7N.cjs → chunk-4FC7TVS6.cjs} +35 -10
  23. package/dist/tsup/chunk-4FC7TVS6.cjs.map +1 -0
  24. package/dist/tsup/{chunk-POTPHU3P.cjs → chunk-62LSMTP2.cjs} +3 -3
  25. package/dist/tsup/{chunk-POTPHU3P.cjs.map → chunk-62LSMTP2.cjs.map} +1 -1
  26. package/dist/tsup/{chunk-OIKOPSXQ.js → chunk-7IVUT2JT.js} +12 -4
  27. package/dist/tsup/chunk-7IVUT2JT.js.map +1 -0
  28. package/dist/tsup/{chunk-22XU3BVY.cjs → chunk-GEYQLGXC.cjs} +925 -328
  29. package/dist/tsup/chunk-GEYQLGXC.cjs.map +1 -0
  30. package/dist/tsup/{chunk-D2TLG75Y.cjs → chunk-GMN45CQ6.cjs} +10 -10
  31. package/dist/tsup/chunk-GMN45CQ6.cjs.map +1 -0
  32. package/dist/tsup/{chunk-3BFYSYRU.js → chunk-HXUEHHJF.js} +3 -2
  33. package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
  34. package/dist/tsup/{chunk-IOYKCB6Y.cjs → chunk-I336PMWT.cjs} +44 -9
  35. package/dist/tsup/chunk-I336PMWT.cjs.map +1 -0
  36. package/dist/tsup/{chunk-RZEJJJKU.js → chunk-IB73AMGJ.js} +42 -7
  37. package/dist/tsup/chunk-IB73AMGJ.js.map +1 -0
  38. package/dist/tsup/{chunk-4ZIWB4CQ.js → chunk-ITWJ6Y7G.js} +2 -2
  39. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
  40. package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
  41. package/dist/tsup/{chunk-W54QCENI.js → chunk-KTNBYGRU.js} +134 -20
  42. package/dist/tsup/chunk-KTNBYGRU.js.map +1 -0
  43. package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-OAPVVVTX.cjs} +79 -7
  44. package/dist/tsup/chunk-OAPVVVTX.cjs.map +1 -0
  45. package/dist/tsup/{chunk-TPBHXFB2.cjs → chunk-OUDV3ITX.cjs} +138 -24
  46. package/dist/tsup/chunk-OUDV3ITX.cjs.map +1 -0
  47. package/dist/tsup/{chunk-XNZR7UD2.cjs → chunk-PRXTIERO.cjs} +90 -65
  48. package/dist/tsup/chunk-PRXTIERO.cjs.map +1 -0
  49. package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-VE2X4KMG.cjs} +3 -2
  50. package/dist/tsup/chunk-VE2X4KMG.cjs.map +1 -0
  51. package/dist/tsup/{chunk-KSG2COSQ.js → chunk-WRZEVVLL.js} +6 -6
  52. package/dist/tsup/chunk-WRZEVVLL.js.map +1 -0
  53. package/dist/tsup/{chunk-LNMB25HW.js → chunk-XAIMHUPG.js} +780 -183
  54. package/dist/tsup/chunk-XAIMHUPG.js.map +1 -0
  55. package/dist/tsup/{chunk-D4TSTM6C.js → chunk-XZ62SWSC.js} +83 -58
  56. package/dist/tsup/chunk-XZ62SWSC.js.map +1 -0
  57. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
  58. package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
  59. package/dist/tsup/{chunk-K34B3OVG.js → chunk-ZZ3WBRPD.js} +34 -9
  60. package/dist/tsup/chunk-ZZ3WBRPD.js.map +1 -0
  61. package/dist/tsup/client/mod.cjs +9 -9
  62. package/dist/tsup/client/mod.cjs.map +1 -1
  63. package/dist/tsup/client/mod.d.cts +8 -9
  64. package/dist/tsup/client/mod.d.ts +8 -9
  65. package/dist/tsup/client/mod.js +8 -8
  66. package/dist/tsup/common/log.cjs +5 -3
  67. package/dist/tsup/common/log.cjs.map +1 -1
  68. package/dist/tsup/common/log.d.cts +5 -1
  69. package/dist/tsup/common/log.d.ts +5 -1
  70. package/dist/tsup/common/log.js +6 -4
  71. package/dist/tsup/common/websocket.cjs +4 -4
  72. package/dist/tsup/common/websocket.js +3 -3
  73. package/dist/tsup/{config-CRdGwwbr.d.cts → config-CxG53eQo.d.cts} +577 -36
  74. package/dist/tsup/{config-kxXbtrJU.d.ts → config-DLOxy81E.d.cts} +5 -5
  75. package/dist/tsup/{config-kxXbtrJU.d.cts → config-DLOxy81E.d.ts} +5 -5
  76. package/dist/tsup/{config-DIpBWm5C.d.ts → config-Ds6DCRhV.d.ts} +577 -36
  77. package/dist/tsup/context-8KlcOYIs.d.cts +129 -0
  78. package/dist/tsup/context-Cfbm4QLr.d.ts +129 -0
  79. package/dist/tsup/db/drizzle.cjs +151 -79
  80. package/dist/tsup/db/drizzle.cjs.map +1 -1
  81. package/dist/tsup/db/drizzle.d.cts +2 -2
  82. package/dist/tsup/db/drizzle.d.ts +2 -2
  83. package/dist/tsup/db/drizzle.js +151 -79
  84. package/dist/tsup/db/drizzle.js.map +1 -1
  85. package/dist/tsup/db/mod.cjs +79 -24
  86. package/dist/tsup/db/mod.cjs.map +1 -1
  87. package/dist/tsup/db/mod.d.cts +2 -2
  88. package/dist/tsup/db/mod.d.ts +2 -2
  89. package/dist/tsup/db/mod.js +78 -23
  90. package/dist/tsup/db/mod.js.map +1 -1
  91. package/dist/tsup/dynamic/mod.cjs +24 -0
  92. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  93. package/dist/tsup/dynamic/mod.d.cts +37 -0
  94. package/dist/tsup/dynamic/mod.d.ts +37 -0
  95. package/dist/tsup/dynamic/mod.js +24 -0
  96. package/dist/tsup/dynamic/mod.js.map +1 -0
  97. package/dist/tsup/inspector/mod.cjs +47 -12
  98. package/dist/tsup/inspector/mod.cjs.map +1 -1
  99. package/dist/tsup/inspector/mod.d.cts +37 -15
  100. package/dist/tsup/inspector/mod.d.ts +37 -15
  101. package/dist/tsup/inspector/mod.js +46 -11
  102. package/dist/tsup/inspector/mod.js.map +1 -1
  103. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  104. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  105. package/dist/tsup/inspector-tab/mod.d.cts +240 -0
  106. package/dist/tsup/inspector-tab/mod.d.ts +240 -0
  107. package/dist/tsup/inspector-tab/mod.js +162 -0
  108. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  109. package/dist/tsup/mod.cjs +1078 -479
  110. package/dist/tsup/mod.cjs.map +1 -1
  111. package/dist/tsup/mod.d.cts +5 -6
  112. package/dist/tsup/mod.d.ts +5 -6
  113. package/dist/tsup/mod.js +996 -397
  114. package/dist/tsup/mod.js.map +1 -1
  115. package/dist/tsup/test/mod.cjs +21 -18
  116. package/dist/tsup/test/mod.cjs.map +1 -1
  117. package/dist/tsup/test/mod.d.cts +4 -5
  118. package/dist/tsup/test/mod.d.ts +4 -5
  119. package/dist/tsup/test/mod.js +18 -15
  120. package/dist/tsup/test/mod.js.map +1 -1
  121. package/dist/tsup/utils-CqDnC_PS.d.cts +104 -0
  122. package/dist/tsup/utils-CqDnC_PS.d.ts +104 -0
  123. package/dist/tsup/utils.cjs +3 -3
  124. package/dist/tsup/utils.d.cts +1 -1
  125. package/dist/tsup/utils.d.ts +1 -1
  126. package/dist/tsup/utils.js +2 -2
  127. package/dist/tsup/workflow/mod.cjs +386 -322
  128. package/dist/tsup/workflow/mod.cjs.map +1 -1
  129. package/dist/tsup/workflow/mod.d.cts +8 -9
  130. package/dist/tsup/workflow/mod.d.ts +8 -9
  131. package/dist/tsup/workflow/mod.js +363 -299
  132. package/dist/tsup/workflow/mod.js.map +1 -1
  133. package/package.json +35 -14
  134. package/src/actor/config.ts +188 -59
  135. package/src/actor/contexts/index.ts +7 -2
  136. package/src/actor/definition.ts +17 -19
  137. package/src/actor/driver.ts +3 -3
  138. package/src/actor/errors.ts +70 -7
  139. package/src/actor/instance/mod.ts +39 -56
  140. package/src/actor/keys.ts +2 -1
  141. package/src/actor/mod.ts +22 -20
  142. package/src/actor/schema.ts +2 -2
  143. package/src/agent-os/actor/index.ts +38 -18
  144. package/src/agent-os/actor/preview.ts +1 -2
  145. package/src/agent-os/actor/session.ts +2 -2
  146. package/src/agent-os/config.ts +1 -1
  147. package/src/agent-os/fs/database-vfs.ts +1 -1
  148. package/src/agent-os/index.ts +16 -15
  149. package/src/client/actor-common.ts +88 -62
  150. package/src/client/actor-conn.ts +58 -63
  151. package/src/client/actor-handle.ts +125 -71
  152. package/src/client/actor-query.ts +5 -5
  153. package/src/client/config.ts +3 -3
  154. package/src/client/errors.ts +2 -1
  155. package/src/client/lifecycle-errors.ts +2 -4
  156. package/src/client/query.ts +1 -1
  157. package/src/client/queue.ts +8 -3
  158. package/src/client/raw-utils.ts +10 -10
  159. package/src/client/resolve-gateway-target.ts +1 -1
  160. package/src/client/utils.ts +34 -10
  161. package/src/common/actor-router-consts.ts +7 -4
  162. package/src/common/actor-websocket.ts +3 -1
  163. package/src/common/bare/actor-persist/v1.ts +205 -163
  164. package/src/common/bare/actor-persist/v2.ts +265 -213
  165. package/src/common/bare/actor-persist/v3.ts +176 -172
  166. package/src/common/bare/actor-persist/v4.ts +254 -253
  167. package/src/common/bare/generated/client-protocol/v4.ts +599 -0
  168. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  169. package/src/common/bare/transport/v1.ts +694 -542
  170. package/src/common/client-protocol-versioned.ts +176 -67
  171. package/src/common/client-protocol-zod.ts +7 -0
  172. package/src/common/client-protocol.ts +1 -1
  173. package/src/common/database/config.ts +16 -5
  174. package/src/common/database/mod.test.ts +83 -16
  175. package/src/common/database/mod.ts +86 -30
  176. package/src/common/database/native-database.test.ts +35 -22
  177. package/src/common/database/native-database.ts +26 -10
  178. package/src/common/database/shared.ts +1 -0
  179. package/src/common/encoding.ts +250 -16
  180. package/src/common/engine.ts +28 -1
  181. package/src/common/eventsource.ts +1 -1
  182. package/src/common/inline-websocket-adapter.ts +14 -13
  183. package/src/common/log.ts +15 -8
  184. package/src/common/router.ts +49 -23
  185. package/src/common/utils.ts +10 -202
  186. package/src/common/websocket-interface.ts +1 -1
  187. package/src/db/drizzle.ts +173 -96
  188. package/src/db/mod.ts +1 -1
  189. package/src/devtools-loader/index.ts +4 -7
  190. package/src/devtools-loader/serve-devtools.ts +26 -0
  191. package/src/drivers/engine/actor-driver.ts +76 -73
  192. package/src/dynamic/instance.ts +32 -0
  193. package/src/dynamic/internal.ts +50 -0
  194. package/src/dynamic/isolate-runtime.ts +66 -0
  195. package/src/dynamic/mod.ts +32 -0
  196. package/src/engine-client/actor-http-client.ts +6 -9
  197. package/src/engine-client/actor-websocket-client.ts +14 -13
  198. package/src/engine-client/api-endpoints.ts +51 -2
  199. package/src/engine-client/api-utils.ts +2 -2
  200. package/src/engine-client/driver.ts +3 -4
  201. package/src/engine-client/mod.ts +17 -10
  202. package/src/engine-client/ws-proxy.ts +9 -4
  203. package/src/inspector/client.browser.ts +66 -15
  204. package/src/inspector/mod.ts +2 -4
  205. package/src/inspector-tab/mod.ts +300 -0
  206. package/src/registry/config/envoy.ts +1 -2
  207. package/src/registry/config/index.ts +46 -20
  208. package/src/registry/index.ts +364 -87
  209. package/src/registry/napi-runtime.ts +97 -8
  210. package/src/registry/native-validation.ts +10 -12
  211. package/src/registry/native.ts +592 -343
  212. package/src/registry/process-metrics.ts +250 -0
  213. package/src/registry/runtime.ts +85 -6
  214. package/src/registry/wasm-runtime.ts +72 -3
  215. package/src/registry/write-through-proxy.ts +40 -0
  216. package/src/serde.ts +2 -2
  217. package/src/serverless/configure.ts +19 -8
  218. package/src/test/mod.ts +11 -8
  219. package/src/utils/crypto.ts +14 -0
  220. package/src/utils/endpoint-parser.ts +1 -1
  221. package/src/utils/env-vars.ts +37 -0
  222. package/src/utils/router.ts +1 -1
  223. package/src/utils.ts +1 -2
  224. package/src/workflow/context.ts +703 -240
  225. package/src/workflow/driver.ts +23 -12
  226. package/src/workflow/inspector.ts +12 -3
  227. package/src/workflow/mod.ts +37 -23
  228. package/dist/tsup/chunk-22XU3BVY.cjs.map +0 -1
  229. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  230. package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
  231. package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
  232. package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
  233. package/dist/tsup/chunk-D2TLG75Y.cjs.map +0 -1
  234. package/dist/tsup/chunk-D4TSTM6C.js.map +0 -1
  235. package/dist/tsup/chunk-IOYKCB6Y.cjs.map +0 -1
  236. package/dist/tsup/chunk-K34B3OVG.js.map +0 -1
  237. package/dist/tsup/chunk-KSG2COSQ.js.map +0 -1
  238. package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
  239. package/dist/tsup/chunk-LNMB25HW.js.map +0 -1
  240. package/dist/tsup/chunk-NFC5VU36.cjs.map +0 -1
  241. package/dist/tsup/chunk-OIKOPSXQ.js.map +0 -1
  242. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  243. package/dist/tsup/chunk-RZEJJJKU.js.map +0 -1
  244. package/dist/tsup/chunk-TPBHXFB2.cjs.map +0 -1
  245. package/dist/tsup/chunk-V3QNBJ7N.cjs.map +0 -1
  246. package/dist/tsup/chunk-W54QCENI.js.map +0 -1
  247. package/dist/tsup/chunk-XNZR7UD2.cjs.map +0 -1
  248. package/dist/tsup/context-B7G6sk7x.d.ts +0 -92
  249. package/dist/tsup/context-DzMRHkjC.d.cts +0 -92
  250. package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
  251. package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
  252. package/src/utils/serve.ts +0 -217
  253. /package/dist/tsup/{chunk-4ZIWB4CQ.js.map → chunk-ITWJ6Y7G.js.map} +0 -0
@@ -0,0 +1,300 @@
1
+ /**
2
+ * Type and schema declarations for custom Rivet inspector tabs.
3
+ *
4
+ * Everything here is **derived from runtime Zod schemas** that the
5
+ * dashboard and rivetkit itself use, so the published types cannot
6
+ * drift from the wire format. There are three sources of truth:
7
+ *
8
+ * 1. The `inspector.tabs[]` actor-config Zod schemas in
9
+ * `../actor/config.ts` — re-exported below. These validate the
10
+ * authoring surface (`defineActor({ inspector: { tabs: [...] } })`).
11
+ * 2. The dashboard ↔ tab postMessage envelopes defined in this file.
12
+ * The inspector-ui SPA (`frontend/apps/inspector-ui/src/bridge.ts`)
13
+ * imports the same schemas to validate messages at runtime, so any
14
+ * change here lands on both ends in lockstep.
15
+ * 3. The inspector HTTP endpoint response schemas defined in this
16
+ * file. The dashboard parses every response through them; if the
17
+ * Rust handler ever emits a different shape, the dashboard fails
18
+ * loudly at the parse step instead of silently casting `unknown`.
19
+ *
20
+ * Tab bundles import these types for autocomplete and compile-time
21
+ * safety:
22
+ *
23
+ * ```ts
24
+ * import type {
25
+ * ShellToTabMessage,
26
+ * TabToShellMessage,
27
+ * V1Init,
28
+ * InspectorStateResponse,
29
+ * } from "rivetkit/inspector-tab";
30
+ * ```
31
+ */
32
+
33
+ import { z } from "zod";
34
+
35
+ // ============================================================================
36
+ // Re-exported from `../actor/config.ts` — the authoring schema for
37
+ // `defineActor({ inspector: { tabs: [...] } })`.
38
+ // ============================================================================
39
+
40
+ export type { ActorInspectorConfig } from "../actor/config";
41
+ export {
42
+ ActorInspectorConfigSchema,
43
+ BUILTIN_INSPECTOR_TAB_IDS,
44
+ BuiltinInspectorTabIdSchema,
45
+ CustomInspectorTabEntrySchema,
46
+ HideInspectorTabEntrySchema,
47
+ InspectorTabEntrySchema,
48
+ } from "../actor/config";
49
+
50
+ import type {
51
+ CustomInspectorTabEntrySchema,
52
+ HideInspectorTabEntrySchema,
53
+ InspectorTabEntrySchema,
54
+ } from "../actor/config";
55
+
56
+ /** One entry in the actor's `inspector.tabs[]` declaration. */
57
+ export type ActorInspectorTabEntry = z.input<typeof InspectorTabEntrySchema>;
58
+ /** A custom-tab entry — adds a new tab to the dashboard strip. */
59
+ export type ActorCustomInspectorTabEntry = z.input<
60
+ typeof CustomInspectorTabEntrySchema
61
+ >;
62
+ /** A hide modifier — removes a built-in tab from the strip. */
63
+ export type ActorHideInspectorTabEntry = z.input<
64
+ typeof HideInspectorTabEntrySchema
65
+ >;
66
+ /** Union of the six built-in inspector tab ids. */
67
+ export type BuiltinInspectorTabId =
68
+ | "workflow"
69
+ | "database"
70
+ | "state"
71
+ | "queue"
72
+ | "connections"
73
+ | "console";
74
+
75
+ // ============================================================================
76
+ // Dashboard ↔ tab postMessage envelope (source of truth).
77
+ //
78
+ // These Zod schemas are imported by `frontend/apps/inspector-ui/src/bridge.ts`
79
+ // and used to validate inbound messages at runtime. Changes here flow to
80
+ // both sides in a single commit.
81
+ // ============================================================================
82
+
83
+ /** Public tab descriptor that crosses the dashboard ↔ inspector-ui bridge. */
84
+ export const InspectorTabDescriptorSchema = z.object({
85
+ id: z.string(),
86
+ label: z.string(),
87
+ icon: z.string(),
88
+ /**
89
+ * `true` for author-shipped custom tabs; absent or `false` for
90
+ * built-in tabs the SPA renders. Lets the dashboard route the
91
+ * iframe `src` to `/inspector/custom-tabs/<id>/` for custom tabs and
92
+ * `/inspector/ui/` for built-ins without the dashboard needing to
93
+ * know which ids are built-in.
94
+ */
95
+ isCustom: z.boolean().optional(),
96
+ });
97
+
98
+ /**
99
+ * Initial handshake from the dashboard. Sent on first mount and again on
100
+ * every token refresh. Tabs MUST accept late `init` messages and replace
101
+ * the cached token.
102
+ */
103
+ export const V1InitSchema = z.object({
104
+ type: z.literal("init"),
105
+ v: z.literal(1),
106
+ /** The actor this tab is mounted for. */
107
+ actorId: z.string(),
108
+ /**
109
+ * Per-actor inspector bearer token. Tabs include it as
110
+ * `Authorization: Bearer ${authToken}` on every authenticated fetch.
111
+ */
112
+ authToken: z.string(),
113
+ /**
114
+ * Outer Rivet API token. Optional; not required for inspector HTTP
115
+ * routes but available to tabs that want to call the engine REST API.
116
+ */
117
+ rivetToken: z.string().optional(),
118
+ /**
119
+ * The tab id the dashboard wants active at mount time. Multi-view
120
+ * tabs may read this to seed their initial route; most tabs ignore it.
121
+ */
122
+ activeTab: z.string().optional(),
123
+ /**
124
+ * Dashboard's currently active theme. Tabs that use the shared
125
+ * stylesheet (`/inspector/tab.css`) mirror it by toggling the `dark`
126
+ * class on `<html>`. Optional for backwards compatibility — tabs
127
+ * should default to `"dark"` if absent (the dashboard pinned dark
128
+ * mode before this field was added).
129
+ */
130
+ theme: z.enum(["light", "dark"]).optional(),
131
+ });
132
+
133
+ /**
134
+ * Dashboard tells the inspector-ui SPA which built-in tab to render. Not
135
+ * sent to custom tabs — when the user activates a custom tab the
136
+ * dashboard navigates the outer iframe to a different `src`.
137
+ */
138
+ export const V1SetActiveTabSchema = z.object({
139
+ type: z.literal("set-active-tab"),
140
+ v: z.literal(1),
141
+ tab: z.string(),
142
+ });
143
+
144
+ /**
145
+ * Tab → dashboard. Sent once after the message listener is registered.
146
+ * The dashboard hides the "Connecting to inspector…" overlay on receipt;
147
+ * if it never arrives the overlay times out after 8 s.
148
+ */
149
+ export const V1ReadySchema = z.object({
150
+ type: z.literal("ready"),
151
+ v: z.literal(1),
152
+ });
153
+
154
+ /**
155
+ * Tab → dashboard. Sent when the tab gets a 401 on an inspector data
156
+ * call. The dashboard refreshes the token and re-issues `v1Init`.
157
+ */
158
+ export const V1TokenRefreshNeededSchema = z.object({
159
+ type: z.literal("token-refresh-needed"),
160
+ v: z.literal(1),
161
+ });
162
+
163
+ /**
164
+ * Emitted by the inspector-ui SPA to tell the dashboard which tabs to
165
+ * render in the strip. Custom tab bundles do NOT emit this — only the
166
+ * SPA does.
167
+ */
168
+ export const V1TabsAvailableSchema = z.object({
169
+ type: z.literal("tabs-available"),
170
+ v: z.literal(1),
171
+ tabs: z.array(InspectorTabDescriptorSchema),
172
+ });
173
+
174
+ /** Discriminated union of messages a tab can RECEIVE from the dashboard. */
175
+ export const ShellToTabMessageSchema = z.discriminatedUnion("type", [
176
+ V1InitSchema,
177
+ V1SetActiveTabSchema,
178
+ ]);
179
+
180
+ /** Discriminated union of messages a tab can SEND to the dashboard. */
181
+ export const TabToShellMessageSchema = z.discriminatedUnion("type", [
182
+ V1ReadySchema,
183
+ V1TabsAvailableSchema,
184
+ V1TokenRefreshNeededSchema,
185
+ ]);
186
+
187
+ export type InspectorTabDescriptor = z.infer<
188
+ typeof InspectorTabDescriptorSchema
189
+ >;
190
+ export type V1Init = z.infer<typeof V1InitSchema>;
191
+ export type V1SetActiveTab = z.infer<typeof V1SetActiveTabSchema>;
192
+ export type V1Ready = z.infer<typeof V1ReadySchema>;
193
+ export type V1TokenRefreshNeeded = z.infer<typeof V1TokenRefreshNeededSchema>;
194
+ export type V1TabsAvailable = z.infer<typeof V1TabsAvailableSchema>;
195
+ export type ShellToTabMessage = z.infer<typeof ShellToTabMessageSchema>;
196
+ export type TabToShellMessage = z.infer<typeof TabToShellMessageSchema>;
197
+
198
+ /** Stable envelope protocol version. Bump only when introducing a v2 shape. */
199
+ export const POSTMESSAGE_PROTOCOL_VERSION = 1;
200
+
201
+ /** URL query parameters the dashboard sets on the tab iframe `src`. */
202
+ export const SHELL_ORIGIN_PARAM = "shellOrigin";
203
+ export const ACTOR_ID_PARAM = "actorId";
204
+
205
+ // ============================================================================
206
+ // Inspector HTTP endpoint response schemas (source of truth).
207
+ //
208
+ // The dashboard parses every authenticated inspector response through
209
+ // these schemas (`frontend/src/components/actors/actor-inspector-context.tsx`).
210
+ // If the Rust handler emits a different shape the parse fails and the
211
+ // dashboard surfaces an error — drift is loud.
212
+ // ============================================================================
213
+
214
+ /** `GET /inspector/state` response shape. */
215
+ export const InspectorStateResponseSchema = z.object({
216
+ /** Current actor state (whatever shape the actor declared). */
217
+ state: z.unknown(),
218
+ /**
219
+ * `false` when the actor did not declare any state — `state` is then
220
+ * `null` and `PATCH /inspector/state` returns an error.
221
+ */
222
+ isStateEnabled: z.boolean(),
223
+ });
224
+
225
+ /** `POST /inspector/action/<name>` request body. */
226
+ export const InspectorActionRequestSchema = z
227
+ .object({
228
+ /** Positional arguments. Mutually exclusive with `properties`. */
229
+ args: z.array(z.unknown()).optional(),
230
+ /** Keyed arguments. Mutually exclusive with `args`. */
231
+ properties: z.record(z.string(), z.unknown()).optional(),
232
+ })
233
+ .refine(
234
+ (body) => !(body.args !== undefined && body.properties !== undefined),
235
+ "Use either `args` or `properties`, not both",
236
+ );
237
+
238
+ /** `POST /inspector/action/<name>` response shape. */
239
+ export const InspectorActionResponseSchema = z.object({
240
+ output: z.unknown(),
241
+ });
242
+
243
+ /** `GET /inspector/rpcs` response shape — the list of action names. */
244
+ export const InspectorRpcsResponseSchema = z.object({
245
+ rpcs: z.array(z.string()),
246
+ });
247
+
248
+ /** One connection record in `GET /inspector/connections`. */
249
+ export const InspectorConnectionSchema = z.object({
250
+ connectionType: z.string().nullable(),
251
+ id: z.string(),
252
+ details: z.object({
253
+ connectionType: z.string().nullable(),
254
+ params: z.unknown(),
255
+ stateEnabled: z.boolean(),
256
+ state: z.unknown(),
257
+ subscriptions: z.number(),
258
+ isHibernatable: z.boolean(),
259
+ }),
260
+ });
261
+
262
+ /** `GET /inspector/connections` response shape. */
263
+ export const InspectorConnectionsResponseSchema = z.object({
264
+ connections: z.array(InspectorConnectionSchema),
265
+ });
266
+
267
+ /** One queued message in `GET /inspector/queue`. */
268
+ export const InspectorQueueMessageSchema = z.object({
269
+ id: z.string(),
270
+ name: z.string(),
271
+ createdAtMs: z.number(),
272
+ });
273
+
274
+ /** `GET /inspector/queue` response shape. */
275
+ export const InspectorQueueResponseSchema = z.object({
276
+ size: z.number(),
277
+ maxSize: z.number(),
278
+ /** `true` if `?limit=N` truncated the message list below `size`. */
279
+ truncated: z.boolean(),
280
+ messages: z.array(InspectorQueueMessageSchema),
281
+ });
282
+
283
+ export type InspectorStateResponse = z.infer<
284
+ typeof InspectorStateResponseSchema
285
+ >;
286
+ export type InspectorActionRequest = z.infer<
287
+ typeof InspectorActionRequestSchema
288
+ >;
289
+ export type InspectorActionResponse = z.infer<
290
+ typeof InspectorActionResponseSchema
291
+ >;
292
+ export type InspectorRpcsResponse = z.infer<typeof InspectorRpcsResponseSchema>;
293
+ export type InspectorConnection = z.infer<typeof InspectorConnectionSchema>;
294
+ export type InspectorConnectionsResponse = z.infer<
295
+ typeof InspectorConnectionsResponseSchema
296
+ >;
297
+ export type InspectorQueueMessage = z.infer<typeof InspectorQueueMessageSchema>;
298
+ export type InspectorQueueResponse = z.infer<
299
+ typeof InspectorQueueResponseSchema
300
+ >;
@@ -1,11 +1,10 @@
1
1
  import { z } from "zod/v4";
2
2
  import { getLogger } from "@/common/log";
3
3
  import {
4
- isDev,
5
4
  getNodeEnv,
5
+ getRivetEnvoyVersion,
6
6
  getRivetPool,
7
7
  getRivetTotalSlots,
8
- getRivetEnvoyVersion,
9
8
  } from "@/utils/env-vars";
10
9
 
11
10
  let warnedMissingVersion = false;
@@ -10,7 +10,7 @@ import {
10
10
  queueMetadataKey,
11
11
  workflowStoragePrefix,
12
12
  } from "@/actor/keys";
13
- import { ENGINE_ENDPOINT } from "@/common/engine";
13
+ import { buildEngineEndpoint, ENGINE_HOST, ENGINE_PORT } from "@/common/engine";
14
14
  import { type Logger, LogLevelSchema } from "@/common/log";
15
15
  import { VERSION } from "@/utils";
16
16
  import { tryParseEndpoint } from "@/utils/endpoint-parser";
@@ -20,6 +20,8 @@ import {
20
20
  getRivetkitRuntime,
21
21
  getRivetNamespace,
22
22
  getRivetRunEngine,
23
+ getRivetRunEngineHost,
24
+ getRivetRunEnginePort,
23
25
  getRivetRunEngineVersion,
24
26
  getRivetToken,
25
27
  isDev,
@@ -33,9 +35,7 @@ import {
33
35
 
34
36
  export const ActorsSchema = z.record(
35
37
  z.string(),
36
- z.custom<
37
- BaseActorDefinition<any, any, any, any, any, any, any, any, any>
38
- >(),
38
+ z.custom<AnyActorDefinition>(),
39
39
  );
40
40
  export type RegistryActors = z.infer<typeof ActorsSchema>;
41
41
 
@@ -97,6 +97,9 @@ export const RegistryConfigSchema = z
97
97
  /** @experimental */
98
98
  maxOutgoingMessageSize: z.number().optional().default(1_048_576),
99
99
 
100
+ /** Enables the experimental per-actor Unix socket API. */
101
+ experimentalActorUds: z.boolean().optional().default(false),
102
+
100
103
  // MARK: Runtime
101
104
  /**
102
105
  * @experimental
@@ -226,6 +229,27 @@ export const RegistryConfigSchema = z
226
229
  * Starts the full Rust engine process locally.
227
230
  */
228
231
  startEngine: z.boolean().default(() => getRivetRunEngine()),
232
+ /**
233
+ * @experimental
234
+ *
235
+ * Host to bind the spawned local engine process to.
236
+ */
237
+ engineHost: z
238
+ .string()
239
+ .optional()
240
+ .default(() => getRivetRunEngineHost() ?? ENGINE_HOST),
241
+ /**
242
+ * @experimental
243
+ *
244
+ * Port to bind the spawned local engine process to.
245
+ */
246
+ enginePort: z
247
+ .number()
248
+ .int()
249
+ .min(1)
250
+ .max(65_535)
251
+ .optional()
252
+ .default(() => getRivetRunEnginePort() ?? ENGINE_PORT),
229
253
  /** @experimental */
230
254
  engineVersion: z
231
255
  .string()
@@ -264,17 +288,12 @@ export const RegistryConfigSchema = z
264
288
  .object({
265
289
  /**
266
290
  * Wait this many milliseconds for the serve promise to resolve
267
- * after calling `CoreRegistry::shutdown()`. Defaults to 30s,
268
- * matching Kubernetes `terminationGracePeriodSeconds`.
291
+ * after calling `CoreRegistry::shutdown()`. Defaults to the
292
+ * engine-provided actor stop threshold once the envoy connects.
269
293
  *
270
- * Must be >= rivetkit-core's drain timeout (20s) + margin.
294
+ * Must be long enough for rivetkit-core to drain the envoy.
271
295
  */
272
- gracePeriodMs: z
273
- .number()
274
- .int()
275
- .min(1_000)
276
- .optional()
277
- .default(30_000),
296
+ gracePeriodMs: z.number().int().min(1_000).optional(),
278
297
  /**
279
298
  * If true, rivetkit will not install SIGINT/SIGTERM handlers.
280
299
  * Use when the host application owns signal policy and will
@@ -284,7 +303,6 @@ export const RegistryConfigSchema = z
284
303
  })
285
304
  .optional()
286
305
  .default(() => ({
287
- gracePeriodMs: 30_000,
288
306
  disableSignalHandlers: false,
289
307
  })),
290
308
  })
@@ -320,7 +338,9 @@ export const RegistryConfigSchema = z
320
338
  })
321
339
  : undefined;
322
340
 
323
- // Can't start a local engine and connect to a remote endpoint.
341
+ // RIVET_ENDPOINT configures what RivetKit connects to. Use
342
+ // engineHost/enginePort (or RIVET_RUN_ENGINE_HOST/PORT) to control the
343
+ // spawned local engine bind address.
324
344
  if (config.startEngine && parsedEndpoint) {
325
345
  ctx.addIssue({
326
346
  code: "custom",
@@ -337,12 +357,17 @@ export const RegistryConfigSchema = z
337
357
  });
338
358
  }
339
359
 
340
- // Flatten the endpoint and apply defaults for namespace/token
341
- // If startEngine is enabled, set endpoint to the engine endpoint.
360
+ // Flatten the endpoint and apply defaults for namespace/token.
361
+ const localEngineEndpoint = buildEngineEndpoint(
362
+ config.engineHost,
363
+ config.enginePort,
364
+ );
342
365
  const endpoint = config.startEngine
343
- ? ENGINE_ENDPOINT
366
+ ? localEngineEndpoint
344
367
  : (parsedEndpoint?.endpoint ??
345
- (isDevEnv ? ENGINE_ENDPOINT : undefined));
368
+ (isDevEnv
369
+ ? buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT)
370
+ : undefined));
346
371
  const validateServerlessEndpoint = Boolean(
347
372
  config.startEngine || parsedEndpoint,
348
373
  );
@@ -375,7 +400,7 @@ export const RegistryConfigSchema = z
375
400
  // In dev mode, clients connect directly to the local Rivet Engine.
376
401
  const publicEndpoint =
377
402
  parsedPublicEndpoint?.endpoint ??
378
- (isDevEnv && config.startEngine ? ENGINE_ENDPOINT : undefined);
403
+ (isDevEnv && config.startEngine ? endpoint : undefined);
379
404
  // We extract publicNamespace to validate that it matches the backend
380
405
  // namespace (see validation above), not for functional use.
381
406
  const publicNamespace = parsedPublicEndpoint?.namespace;
@@ -423,6 +448,7 @@ export function buildActorNames(
423
448
  Array.from(KEYS.PERSIST_DATA),
424
449
  Array.from(KEYS.INSPECTOR_TOKEN),
425
450
  Array.from(queueMetadataKey()),
451
+ Array.from(KEYS.LAST_PUSHED_ALARM),
426
452
  ],
427
453
  prefixes: [
428
454
  {