rivetkit 2.3.0-rc.9 → 2.3.0
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.
- package/dist/browser/client.d.ts +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -0,0 +1,315 @@
|
|
|
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 {
|
|
41
|
+
ActorInspectorConfigSchema,
|
|
42
|
+
BUILTIN_INSPECTOR_TAB_IDS,
|
|
43
|
+
BuiltinInspectorTabIdSchema,
|
|
44
|
+
CustomInspectorTabEntrySchema,
|
|
45
|
+
HideInspectorTabEntrySchema,
|
|
46
|
+
InspectorTabEntrySchema,
|
|
47
|
+
} from "../actor/config";
|
|
48
|
+
export type { ActorInspectorConfig } 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
|
+
/** `GET /inspector/tab-config` response shape. */
|
|
284
|
+
export const InspectorTabConfigResponseSchema = z.object({
|
|
285
|
+
tabs: z.array(
|
|
286
|
+
z.object({
|
|
287
|
+
id: z.string(),
|
|
288
|
+
label: z.string().optional(),
|
|
289
|
+
icon: z.string().nullable().optional(),
|
|
290
|
+
hidden: z.boolean().optional(),
|
|
291
|
+
}),
|
|
292
|
+
),
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
export type InspectorStateResponse = z.infer<
|
|
296
|
+
typeof InspectorStateResponseSchema
|
|
297
|
+
>;
|
|
298
|
+
export type InspectorActionRequest = z.infer<
|
|
299
|
+
typeof InspectorActionRequestSchema
|
|
300
|
+
>;
|
|
301
|
+
export type InspectorActionResponse = z.infer<
|
|
302
|
+
typeof InspectorActionResponseSchema
|
|
303
|
+
>;
|
|
304
|
+
export type InspectorRpcsResponse = z.infer<typeof InspectorRpcsResponseSchema>;
|
|
305
|
+
export type InspectorConnection = z.infer<typeof InspectorConnectionSchema>;
|
|
306
|
+
export type InspectorConnectionsResponse = z.infer<
|
|
307
|
+
typeof InspectorConnectionsResponseSchema
|
|
308
|
+
>;
|
|
309
|
+
export type InspectorQueueMessage = z.infer<typeof InspectorQueueMessageSchema>;
|
|
310
|
+
export type InspectorQueueResponse = z.infer<
|
|
311
|
+
typeof InspectorQueueResponseSchema
|
|
312
|
+
>;
|
|
313
|
+
export type InspectorTabConfigResponse = z.infer<
|
|
314
|
+
typeof InspectorTabConfigResponseSchema
|
|
315
|
+
>;
|
|
@@ -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 {
|
|
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
|
|
|
@@ -226,6 +226,27 @@ export const RegistryConfigSchema = z
|
|
|
226
226
|
* Starts the full Rust engine process locally.
|
|
227
227
|
*/
|
|
228
228
|
startEngine: z.boolean().default(() => getRivetRunEngine()),
|
|
229
|
+
/**
|
|
230
|
+
* @experimental
|
|
231
|
+
*
|
|
232
|
+
* Host to bind the spawned local engine process to.
|
|
233
|
+
*/
|
|
234
|
+
engineHost: z
|
|
235
|
+
.string()
|
|
236
|
+
.optional()
|
|
237
|
+
.default(() => getRivetRunEngineHost() ?? ENGINE_HOST),
|
|
238
|
+
/**
|
|
239
|
+
* @experimental
|
|
240
|
+
*
|
|
241
|
+
* Port to bind the spawned local engine process to.
|
|
242
|
+
*/
|
|
243
|
+
enginePort: z
|
|
244
|
+
.number()
|
|
245
|
+
.int()
|
|
246
|
+
.min(1)
|
|
247
|
+
.max(65_535)
|
|
248
|
+
.optional()
|
|
249
|
+
.default(() => getRivetRunEnginePort() ?? ENGINE_PORT),
|
|
229
250
|
/** @experimental */
|
|
230
251
|
engineVersion: z
|
|
231
252
|
.string()
|
|
@@ -267,13 +288,9 @@ export const RegistryConfigSchema = z
|
|
|
267
288
|
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
268
289
|
* engine-provided actor stop threshold once the envoy connects.
|
|
269
290
|
*
|
|
270
|
-
* Must be
|
|
291
|
+
* Must be long enough for rivetkit-core to drain the envoy.
|
|
271
292
|
*/
|
|
272
|
-
gracePeriodMs: z
|
|
273
|
-
.number()
|
|
274
|
-
.int()
|
|
275
|
-
.min(1_000)
|
|
276
|
-
.optional(),
|
|
293
|
+
gracePeriodMs: z.number().int().min(1_000).optional(),
|
|
277
294
|
/**
|
|
278
295
|
* If true, rivetkit will not install SIGINT/SIGTERM handlers.
|
|
279
296
|
* Use when the host application owns signal policy and will
|
|
@@ -318,7 +335,9 @@ export const RegistryConfigSchema = z
|
|
|
318
335
|
})
|
|
319
336
|
: undefined;
|
|
320
337
|
|
|
321
|
-
//
|
|
338
|
+
// RIVET_ENDPOINT configures what RivetKit connects to. Use
|
|
339
|
+
// engineHost/enginePort (or RIVET_RUN_ENGINE_HOST/PORT) to control the
|
|
340
|
+
// spawned local engine bind address.
|
|
322
341
|
if (config.startEngine && parsedEndpoint) {
|
|
323
342
|
ctx.addIssue({
|
|
324
343
|
code: "custom",
|
|
@@ -335,12 +354,17 @@ export const RegistryConfigSchema = z
|
|
|
335
354
|
});
|
|
336
355
|
}
|
|
337
356
|
|
|
338
|
-
// Flatten the endpoint and apply defaults for namespace/token
|
|
339
|
-
|
|
357
|
+
// Flatten the endpoint and apply defaults for namespace/token.
|
|
358
|
+
const localEngineEndpoint = buildEngineEndpoint(
|
|
359
|
+
config.engineHost,
|
|
360
|
+
config.enginePort,
|
|
361
|
+
);
|
|
340
362
|
const endpoint = config.startEngine
|
|
341
|
-
?
|
|
363
|
+
? localEngineEndpoint
|
|
342
364
|
: (parsedEndpoint?.endpoint ??
|
|
343
|
-
(isDevEnv
|
|
365
|
+
(isDevEnv
|
|
366
|
+
? buildEngineEndpoint(ENGINE_HOST, ENGINE_PORT)
|
|
367
|
+
: undefined));
|
|
344
368
|
const validateServerlessEndpoint = Boolean(
|
|
345
369
|
config.startEngine || parsedEndpoint,
|
|
346
370
|
);
|
|
@@ -373,7 +397,7 @@ export const RegistryConfigSchema = z
|
|
|
373
397
|
// In dev mode, clients connect directly to the local Rivet Engine.
|
|
374
398
|
const publicEndpoint =
|
|
375
399
|
parsedPublicEndpoint?.endpoint ??
|
|
376
|
-
(isDevEnv && config.startEngine ?
|
|
400
|
+
(isDevEnv && config.startEngine ? endpoint : undefined);
|
|
377
401
|
// We extract publicNamespace to validate that it matches the backend
|
|
378
402
|
// namespace (see validation above), not for functional use.
|
|
379
403
|
const publicNamespace = parsedPublicEndpoint?.namespace;
|