You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Client-side registration (for server→client calls) goes through `rpc.client.register()` — the mirror API of `ctx.rpc.register()`.
179
179
180
+
## Type-safe client registry
181
+
182
+
Devframe exposes two augmentable interfaces — `DevToolsRpcServerFunctions` (client→server calls) and `DevToolsRpcClientFunctions` (server→client calls) — so each registered RPC name shows up on the typed client. Augment them once per devframe via `declare module 'devframe'`.
183
+
184
+
The recommended pattern collects every server-side definition into a const array and feeds it through `RpcDefinitionsToFunctions`:
Protocol adapters (the [MCP adapter](./agent-native), for example) use this to surface shared state as dynamic resources.
139
139
140
+
## Type-safe keys
141
+
142
+
Augment `DevToolsRpcSharedStates` to type each shared-state key once, then both server and client lookups stay typed without per-call generics:
143
+
144
+
```ts
145
+
declaremodule'devframe' {
146
+
interfaceDevToolsRpcSharedStates {
147
+
'my-devframe:state': {
148
+
count:number
149
+
items: { id:string, name:string }[]
150
+
}
151
+
}
152
+
}
153
+
```
154
+
155
+
After this declaration, `ctx.rpc.sharedState.get('my-devframe:state')` and `rpc.sharedState.get('my-devframe:state')` both return a host typed to the declared shape.
0 commit comments