devframe 0.9.15 → 0.9.17

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 (35) hide show
  1. package/dist/{_shared-Bf2FcfJ4.d.mts → _shared-CkLpdx6I.d.mts} +1 -1
  2. package/dist/adapters/build.d.mts +1 -1
  3. package/dist/adapters/cac.d.mts +1 -1
  4. package/dist/adapters/dev.d.mts +5 -4
  5. package/dist/adapters/embedded.d.mts +1 -1
  6. package/dist/adapters/initiate.d.mts +5 -4
  7. package/dist/adapters/mcp.d.mts +1 -1
  8. package/dist/client/index.d.mts +1 -1
  9. package/dist/{context-CIsx_QnV.d.mts → context-3y_PeZKl.d.mts} +1 -1
  10. package/dist/{context-B7411Bem.d.mts → context-DLzIyQCZ.d.mts} +1 -1
  11. package/dist/in-page-channel/index.d.mts +33 -27
  12. package/dist/in-page-channel/index.mjs +55 -25
  13. package/dist/{index--pZ3fdAq.d.mts → index-Ces7aTOQ.d.mts} +2 -2
  14. package/dist/index.d.mts +3 -3
  15. package/dist/{instance-shell-B-FE8NY5.d.mts → instance-shell-BQXr8n68.d.mts} +5 -4
  16. package/dist/internal/index.d.mts +4 -4
  17. package/dist/node/auth.d.mts +2 -2
  18. package/dist/node/hub-internals.d.mts +2 -2
  19. package/dist/node/index.d.mts +1 -1
  20. package/dist/recipes/common-rpc-functions.d.mts +1 -1
  21. package/dist/recipes/interactive-auth.d.mts +2 -2
  22. package/dist/rpc/transports/sse-server.d.mts +2 -1
  23. package/dist/rpc/transports/ws-bun.d.mts +2 -2
  24. package/dist/rpc/transports/ws-deno.d.mts +2 -2
  25. package/dist/rpc/transports/ws-server.d.mts +3 -2
  26. package/dist/{rpc-core-D7WvbvK0.d.mts → rpc-core-Clo3kHfo.d.mts} +4 -3
  27. package/dist/session-r6PDixP6.d.mts +111 -0
  28. package/dist/types/index.d.mts +3 -3
  29. package/dist/utils/events.d.mts +1 -1
  30. package/dist/utils/serve-static.d.mts +1 -1
  31. package/dist/utils/shared-state.d.mts +1 -1
  32. package/dist/utils/streaming-channel.d.mts +1 -1
  33. package/dist/{ws-server-D2nv68Hg.d.mts → ws-server-9ztvkeJ0.d.mts} +3 -70
  34. package/package.json +2 -1
  35. package/skills/devframe/SKILL.md +1 -1
@@ -1,4 +1,4 @@
1
- import { F as DevframeDefinition, G as McpAuthorization, I as DevframeDeploymentKind, q as McpSetting, t as ConnectionMeta, zt as DevframeAgentHost } from "./context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, G as McpAuthorization, I as DevframeDeploymentKind, q as McpSetting, t as ConnectionMeta, zt as DevframeAgentHost } from "./context-DLzIyQCZ.mjs";
2
2
  //#region src/adapters/_shared.d.ts
3
3
  /**
4
4
  * Resolve the mount base path for a devframe's SPA. Hosted adapters
@@ -1,4 +1,4 @@
1
- import { F as DevframeDefinition, V as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, V as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-DLzIyQCZ.mjs";
2
2
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
3
3
  //#region src/adapters/build.d.ts
4
4
  export interface CreateBuildOptions {
@@ -1,4 +1,4 @@
1
- import { Dt as InferCliFlags, Et as CliFlagsSchema, F as DevframeDefinition, Ot as defineCliFlags, kt as parseCliFlags, q as McpSetting } from "../context-B7411Bem.mjs";
1
+ import { Dt as InferCliFlags, Et as CliFlagsSchema, F as DevframeDefinition, Ot as defineCliFlags, kt as parseCliFlags, q as McpSetting } from "../context-DLzIyQCZ.mjs";
2
2
  import { CAC } from "cac";
3
3
  import { H3 } from "h3";
4
4
  //#region src/adapters/cac.d.ts
@@ -1,8 +1,9 @@
1
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../ws-server-D2nv68Hg.mjs";
2
- import { F as DevframeDefinition, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, q as McpSetting, s as DevframeNodeRpcSession } from "../context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, q as McpSetting, s as DevframeNodeRpcSession } from "../context-DLzIyQCZ.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
3
3
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
4
- import { c as StartedServer } from "../instance-shell-B-FE8NY5.mjs";
5
- import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-Bf2FcfJ4.mjs";
4
+ import { n as WsOriginRegistry } from "../ws-server-9ztvkeJ0.mjs";
5
+ import { c as StartedServer } from "../instance-shell-BQXr8n68.mjs";
6
+ import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-CkLpdx6I.mjs";
6
7
  import { H3 } from "h3";
7
8
  //#region src/adapters/dev.d.ts
8
9
  export interface CreateDevServerOptions {
@@ -1,4 +1,4 @@
1
- import { F as DevframeDefinition, o as DevframeNodeContext } from "../context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, o as DevframeNodeContext } from "../context-DLzIyQCZ.mjs";
2
2
  //#region src/adapters/embedded.d.ts
3
3
  export interface CreateEmbeddedOptions {
4
4
  /** Target context the devframe is registered into. Required. */
@@ -1,11 +1,12 @@
1
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../ws-server-D2nv68Hg.mjs";
2
- import { F as DevframeDefinition, St as DevframeStorageScope, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, o as DevframeNodeContext, q as McpSetting, s as DevframeNodeRpcSession, t as ConnectionMeta } from "../context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, St as DevframeStorageScope, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, o as DevframeNodeContext, q as McpSetting, s as DevframeNodeRpcSession, t as ConnectionMeta } from "../context-DLzIyQCZ.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
3
3
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
4
- import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-B-FE8NY5.mjs";
4
+ import { n as WsOriginRegistry } from "../ws-server-9ztvkeJ0.mjs";
5
+ import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-BQXr8n68.mjs";
6
+ import { H3 } from "h3";
5
7
  import { Buffer } from "node:buffer";
6
8
  import { IncomingMessage, Server, ServerResponse } from "node:http";
7
9
  import { Duplex } from "node:stream";
8
- import { H3 } from "h3";
9
10
  //#region src/adapters/initiate.d.ts
10
11
  export interface InitDevframeOptions {
11
12
  /**
@@ -1,4 +1,4 @@
1
- import { F as DevframeDefinition, G as McpAuthorization, o as DevframeNodeContext } from "../context-B7411Bem.mjs";
1
+ import { F as DevframeDefinition, G as McpAuthorization, o as DevframeNodeContext } from "../context-DLzIyQCZ.mjs";
2
2
  import { H3 } from "h3";
3
3
  import "@modelcontextprotocol/server";
4
4
  //#region src/adapters/mcp/build-server.d.ts
@@ -1,6 +1,6 @@
1
1
  import { f as RpcCacheManager, p as RpcCacheOptions } from "../index-pIVt92jP.mjs";
2
2
  import { _ as RpcFunctionDefinition, w as RpcFunctionsCollector } from "../types-Dq4i156u.mjs";
3
- import { Q as DevframeServiceMeta, Vt as EventEmitter, b as StreamSink, ct as DevframeSettings, d as RpcSharedStateHost, et as DevframeServiceScopeOf, gt as SettingsForNamespace, ht as ScopedSharedStates, it as DevframeServicesState, k as SharedState, mt as ScopedServerFunctions, pt as ScopedRpcFn, t as ConnectionMeta, u as RpcSharedStateGetOptions, vt as DevframeRpcClientFunctions, y as StreamReader, yt as DevframeRpcServerFunctions } from "../context-B7411Bem.mjs";
3
+ import { Q as DevframeServiceMeta, Vt as EventEmitter, b as StreamSink, ct as DevframeSettings, d as RpcSharedStateHost, et as DevframeServiceScopeOf, gt as SettingsForNamespace, ht as ScopedSharedStates, it as DevframeServicesState, k as SharedState, mt as ScopedServerFunctions, pt as ScopedRpcFn, t as ConnectionMeta, u as RpcSharedStateGetOptions, vt as DevframeRpcClientFunctions, y as StreamReader, yt as DevframeRpcServerFunctions } from "../context-DLzIyQCZ.mjs";
4
4
  import { t as SseRpcChannelOptions } from "../sse-client-BQ4jS3eO.mjs";
5
5
  import { t as WsRpcChannelOptions } from "../ws-client-Xpxt0oPA.mjs";
6
6
  import { BirpcOptions, BirpcReturn } from "birpc";
@@ -1,4 +1,4 @@
1
- import { k as SharedState, o as DevframeNodeContext } from "./context-B7411Bem.mjs";
1
+ import { k as SharedState, o as DevframeNodeContext } from "./context-DLzIyQCZ.mjs";
2
2
  //#region src/node/hub-internals/context.d.ts
3
3
  interface InternalAnonymousAuthStorage {
4
4
  trusted: Record<string, {
@@ -1,6 +1,6 @@
1
1
  import { d as RpcFunctionsCollectorBase } from "./index-pIVt92jP.mjs";
2
2
  import { _ as RpcFunctionDefinition, v as RpcFunctionDefinitionAny } from "./types-Dq4i156u.mjs";
3
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection } from "./ws-server-D2nv68Hg.mjs";
3
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
4
4
  import { a as RemoteAssetsStore, o as StaticAssetsSource } from "./remote-assets-eBvSKZMS.mjs";
5
5
  import { m as defineDiagnostics } from "./nostics-0sKe5HIj.mjs";
6
6
  import { BirpcReturn } from "birpc";
@@ -1,5 +1,5 @@
1
1
  import { D as InferArgsType, E as Thenable, O as InferReturnType, T as RpcReturnSchema, i as RpcArgsSchema } from "../types-Dq4i156u.mjs";
2
- import { Vt as EventEmitter, k as SharedState } from "../context-B7411Bem.mjs";
2
+ import { Vt as EventEmitter, k as SharedState } from "../context-DLzIyQCZ.mjs";
3
3
  import { BirpcReturn } from "birpc";
4
4
  //#region src/in-page-channel/types.d.ts
5
5
  /**
@@ -9,10 +9,18 @@ import { BirpcReturn } from "birpc";
9
9
  * channel-name constant declared next to it.
10
10
  */
11
11
  interface InPageChannelProtocol {
12
- /** Functions and events received by the page script. */
13
- pageScript?: Record<string, (...args: any[]) => any>;
14
- /** Functions and events received by panels. */
15
- panel?: Record<string, (...args: any[]) => any>;
12
+ functions?: {
13
+ /** Functions implemented by the page script. */
14
+ pageScript?: Record<string, (...args: any[]) => any>;
15
+ /** Functions implemented by panels. */
16
+ panel?: Record<string, (...args: any[]) => any>;
17
+ };
18
+ events?: {
19
+ /** Events emitted by panels and received by the page script. */
20
+ pageScript?: Record<string, (...args: any[]) => void>;
21
+ /** Events emitted by the page script and received by panels. */
22
+ panel?: Record<string, (...args: any[]) => void>;
23
+ };
16
24
  /**
17
25
  * Shared-state slots. The page script is the authority: it owns the
18
26
  * canonical value; panels are seeded on connect and converge through
@@ -21,21 +29,14 @@ interface InPageChannelProtocol {
21
29
  sharedStates?: Record<string, object>;
22
30
  }
23
31
  type SideFunctions<S> = S extends Record<string, (...args: any[]) => any> ? S : Record<string, never>;
24
- type PageScriptFunctions<P extends InPageChannelProtocol> = SideFunctions<NonNullable<P['pageScript']>>;
25
- type PanelFunctions<P extends InPageChannelProtocol> = SideFunctions<NonNullable<P['panel']>>;
32
+ type SideDeclarations<P extends InPageChannelProtocol, Kind extends 'functions' | 'events', Side extends 'pageScript' | 'panel'> = Kind extends keyof P ? Side extends keyof NonNullable<P[Kind]> ? SideFunctions<NonNullable<NonNullable<P[Kind]>[Side]>> : Record<string, never> : Record<string, never>;
33
+ type PageScriptFunctions<P extends InPageChannelProtocol> = SideDeclarations<P, 'functions', 'pageScript'>;
34
+ type PanelFunctions<P extends InPageChannelProtocol> = SideDeclarations<P, 'functions', 'panel'>;
26
35
  type SharedStates<P extends InPageChannelProtocol> = P['sharedStates'] extends Record<string, object> ? P['sharedStates'] : Record<string, never>;
27
36
  type FnArgs<F> = F extends ((...args: infer A) => any) ? A : never;
28
37
  type FnReturn<F> = F extends ((...args: any[]) => infer R) ? Awaited<R> : never;
29
- /**
30
- * Page-script functions whose resolved return type marks an event.
31
- * @internal
32
- */
33
- type PageScriptFunctionsEvents<P extends InPageChannelProtocol> = { [K in keyof PageScriptFunctions<P> as FnReturn<PageScriptFunctions<P>[K]> extends void ? K : never]: PageScriptFunctions<P>[K]; };
34
- /**
35
- * Panel functions whose resolved return type marks an event.
36
- * @internal
37
- */
38
- type PanelFunctionsEvents<P extends InPageChannelProtocol> = { [K in keyof PanelFunctions<P> as FnReturn<PanelFunctions<P>[K]> extends void ? K : never]: PanelFunctions<P>[K]; };
38
+ type PageScriptEvents<P extends InPageChannelProtocol> = SideDeclarations<P, 'events', 'pageScript'>;
39
+ type PanelEvents<P extends InPageChannelProtocol> = SideDeclarations<P, 'events', 'panel'>;
39
40
  /**
40
41
  * Converts a protocol function to its accepted endpoint handler.
41
42
  *
@@ -99,9 +100,10 @@ interface InPageFunctionOptionBase {
99
100
  jsonSerializable?: boolean;
100
101
  }
101
102
  interface InPageEventFunctionOption<F> extends InPageFunctionOptionBase {
102
- type: 'event';
103
+ type?: 'event';
103
104
  handler?: ProtocolHandler<F>;
104
105
  }
106
+ type InPageEventOption<F> = [F] extends [never] ? never : InPageEventFunctionOption<F>;
105
107
  interface InPageQueryFunctionOption<F> extends InPageFunctionOptionBase {
106
108
  type?: 'query';
107
109
  handler: ProtocolHandler<F>;
@@ -110,7 +112,7 @@ interface InPageActionFunctionOption<F> extends InPageFunctionOptionBase {
110
112
  type: 'action';
111
113
  handler: ProtocolHandler<F>;
112
114
  }
113
- type InPageFunctionOption<F> = InPageEventFunctionOption<F> | InPageQueryFunctionOption<F> | InPageActionFunctionOption<F>;
115
+ type InPageFunctionOption<F> = InPageQueryFunctionOption<F> | InPageActionFunctionOption<F>;
114
116
  /**
115
117
  * Functions implemented by {@link createPageScriptChannel}.
116
118
  *
@@ -173,8 +175,10 @@ interface InPageChannelCommonOptions {
173
175
  }
174
176
  /** Options for {@link createPageScriptChannel}. */
175
177
  interface CreatePageScriptChannelOptions<Protocol extends InPageChannelProtocol = InPageChannelProtocol> extends InPageChannelCommonOptions {
176
- /** Every page-script function declaration; event handlers may use `channel.on()`. */
178
+ /** Every page-script function declaration, with a required handler. */
177
179
  functions: CreatePageScriptChannelOptionsFunctions<Protocol>;
180
+ /** Optional metadata or handlers for incoming events. Listeners may instead subscribe through `channel.on()`. */
181
+ events?: { [NAME in keyof PageScriptEvents<Protocol> & string]?: InPageEventOption<PageScriptEvents<Protocol>[NAME]>; };
178
182
  /**
179
183
  * Window whose `message` events carry panel hellos. Defaults to the
180
184
  * global `window`; pass `false` to skip the handshake listener entirely
@@ -184,8 +188,10 @@ interface CreatePageScriptChannelOptions<Protocol extends InPageChannelProtocol
184
188
  }
185
189
  /** Options for {@link connectPanelChannel}. */
186
190
  interface ConnectPanelChannelOptions<Protocol extends InPageChannelProtocol = InPageChannelProtocol> extends InPageChannelCommonOptions {
187
- /** Every panel function declaration; event handlers may use `channel.on()`. */
191
+ /** Every panel function declaration, with a required handler. */
188
192
  functions: ConnectPanelChannelOptionsFunctions<Protocol>;
193
+ /** Optional metadata or handlers for incoming events. Listeners may instead subscribe through `channel.on()`. */
194
+ events?: { [NAME in keyof PanelEvents<Protocol> & string]?: InPageEventOption<PanelEvents<Protocol>[NAME]>; };
189
195
  /**
190
196
  * The panel's own window (listens for the handshake grant). Defaults to
191
197
  * the global `window`; pass `false` with `transport` to skip the handshake.
@@ -262,11 +268,11 @@ interface PageScriptChannel<P extends InPageChannelProtocol> {
262
268
  readonly panels: readonly PanelPeer<P>[];
263
269
  readonly events: Pick<EventEmitter<PageScriptChannelEvents<P>>, 'on' | 'once'>;
264
270
  /** Fan an event out to every connected panel. */
265
- emit: <K extends keyof PanelFunctionsEvents<P> & string>(name: K, ...args: FnArgs<PanelFunctionsEvents<P>[K]>) => void;
271
+ emit: <K extends keyof PanelEvents<P> & string>(name: K, ...args: FnArgs<PanelEvents<P>[K]>) => void;
266
272
  /** @deprecated Use `emit()` instead. */
267
- callEvent: <K extends keyof PanelFunctionsEvents<P> & string>(name: K, ...args: FnArgs<PanelFunctionsEvents<P>[K]>) => void;
273
+ callEvent: <K extends keyof PanelEvents<P> & string>(name: K, ...args: FnArgs<PanelEvents<P>[K]>) => void;
268
274
  /** Subscribe to an event emitted by a panel. Returns an unsubscribe function. */
269
- on: <K extends keyof PageScriptFunctionsEvents<P> & string>(name: K, listener: (...args: FnArgs<PageScriptFunctionsEvents<P>[K]>) => void) => () => void;
275
+ on: <K extends keyof PageScriptEvents<P> & string>(name: K, listener: (...args: FnArgs<PageScriptEvents<P>[K]>) => void) => () => void;
270
276
  /** Page-script-authoritative shared states, replayed to joining panels. */
271
277
  readonly sharedState: InPageSharedStateHost<P>;
272
278
  /** Adopt a pre-established port as a panel peer (bring-your-own transport). */
@@ -307,11 +313,11 @@ interface PanelChannel<P extends InPageChannelProtocol> {
307
313
  * Emit an event to the page script. While `connecting` the event is buffered
308
314
  * (up to `eventBufferLimit`) and flushed on connect.
309
315
  */
310
- emit: <K extends keyof PageScriptFunctionsEvents<P> & string>(name: K, ...args: FnArgs<PageScriptFunctionsEvents<P>[K]>) => void;
316
+ emit: <K extends keyof PageScriptEvents<P> & string>(name: K, ...args: FnArgs<PageScriptEvents<P>[K]>) => void;
311
317
  /** @deprecated Use `emit()` instead. */
312
- callEvent: <K extends keyof PageScriptFunctionsEvents<P> & string>(name: K, ...args: FnArgs<PageScriptFunctionsEvents<P>[K]>) => void;
318
+ callEvent: <K extends keyof PageScriptEvents<P> & string>(name: K, ...args: FnArgs<PageScriptEvents<P>[K]>) => void;
313
319
  /** Subscribe to an event emitted by the page script. Returns an unsubscribe function. */
314
- on: <K extends keyof PanelFunctionsEvents<P> & string>(name: K, listener: (...args: FnArgs<PanelFunctionsEvents<P>[K]>) => void) => () => void;
320
+ on: <K extends keyof PanelEvents<P> & string>(name: K, listener: (...args: FnArgs<PanelEvents<P>[K]>) => void) => () => void;
315
321
  /** Shared states mirrored from the page-script authority. */
316
322
  readonly sharedState: InPageSharedStateHost<P>;
317
323
  /** Tear the endpoint down permanently. */
@@ -8,7 +8,7 @@ const diagnostics = /* #__PURE__ */ defineDiagnostics({
8
8
  docsBase: "https://devfra.me/errors",
9
9
  codes: { DF0077: {
10
10
  why: (p) => `In-page channel function "${p.name}" is not registered on this endpoint.`,
11
- fix: "Declare the function in this endpoint's `functions` option before subscribing with `on()`."
11
+ fix: "Declare the function in this endpoint's `functions` option."
12
12
  } }
13
13
  });
14
14
  //#endregion
@@ -169,6 +169,10 @@ function serializeArgs(codec, args) {
169
169
  function deserializeResult(codec, result) {
170
170
  return codec.deserialize && result !== void 0 ? codec.deserialize(result) : result;
171
171
  }
172
+ function channelMethod(type, name) {
173
+ return `devframe:in-page:${type === "event" ? "event" : "function"}:${name}`;
174
+ }
175
+ const FUNCTION_METHOD_PREFIX = channelMethod("function", "");
172
176
  /**
173
177
  * An endpoint's local function table, resolved by name when the remote side
174
178
  * calls in. Each handler is wrapped with the receive pipeline: deserialize
@@ -180,32 +184,38 @@ function createLocalFunctionRegistry(codec) {
180
184
  const listeners = /* @__PURE__ */ new Map();
181
185
  return {
182
186
  register(definition) {
183
- definitions.set(definition.name, definition);
187
+ definitions.set(channelMethod(definition.type, definition.name), definition);
184
188
  },
185
189
  on(name, listener) {
186
- if (!definitions.has(name)) throw diagnostics.DF0077({ name });
187
- let registered = listeners.get(name);
190
+ const key = channelMethod("event", name);
191
+ let registered = listeners.get(key);
188
192
  if (!registered) {
189
193
  registered = /* @__PURE__ */ new Set();
190
- listeners.set(name, registered);
194
+ listeners.set(key, registered);
191
195
  }
192
196
  registered.add(listener);
193
197
  return () => {
194
198
  registered.delete(listener);
195
- if (registered.size === 0) listeners.delete(name);
199
+ if (registered.size === 0) listeners.delete(key);
196
200
  };
197
201
  },
198
202
  resolve(name) {
199
203
  const definition = definitions.get(name);
200
204
  const registered = listeners.get(name);
201
- if (!definition && !registered?.size) return void 0;
205
+ if (!definition && !registered?.size) {
206
+ if (name.startsWith(FUNCTION_METHOD_PREFIX)) return () => {
207
+ throw diagnostics.DF0077({ name: name.slice(FUNCTION_METHOD_PREFIX.length) });
208
+ };
209
+ return;
210
+ }
202
211
  return async (...rawArgs) => {
203
212
  const args = codec.deserialize ? rawArgs.map(codec.deserialize) : rawArgs;
204
213
  if (definition?.jsonSerializable) assertJsonSerializable(args, "its arguments", definition.name);
205
214
  if (definition?.args?.length) await validateArgs(definition.name, definition.args, args);
206
215
  const result = await definition?.handler?.(...args);
207
216
  for (const listener of [...listeners.get(name) ?? []]) listener(...args);
208
- if (definition?.jsonSerializable) assertJsonSerializable(result, "its return value", definition.name);
217
+ if (definition?.type === "event") return void 0;
218
+ if (definition?.jsonSerializable && result !== void 0) assertJsonSerializable(result, "its return value", definition.name);
209
219
  return codec.serialize && result !== void 0 ? codec.serialize(result) : result;
210
220
  };
211
221
  }
@@ -482,13 +492,18 @@ function createPageScriptChannel(options) {
482
492
  ...definition,
483
493
  name: fnName
484
494
  });
495
+ for (const [eventName, definition] of Object.entries(options.events ?? {})) registry.register({
496
+ ...definition,
497
+ name: eventName,
498
+ type: "event"
499
+ });
485
500
  const stateHost = createPageScriptStateHost(function* () {
486
501
  for (const peer of peers.values()) yield {
487
502
  subscribedStates: peer.subscribedStates,
488
503
  callEventRaw: (method, args) => {
489
504
  peer.attached.rpc.$callRaw({
490
505
  method,
491
- args,
506
+ args: serializeArgs(codec, args),
492
507
  event: true,
493
508
  optional: true
494
509
  }).catch(() => {});
@@ -517,14 +532,19 @@ function createPageScriptChannel(options) {
517
532
  callEventRaw: (method, args) => {
518
533
  internal.attached.rpc.$callRaw({
519
534
  method,
520
- args,
535
+ args: serializeArgs(codec, args),
521
536
  event: true,
522
537
  optional: true
523
538
  }).catch(() => {});
524
539
  }
525
540
  });
541
+ const stateRegistry = createLocalFunctionRegistry(codec);
542
+ for (const [name, handler] of Object.entries(internal.internalHandlers)) stateRegistry.register({
543
+ name,
544
+ handler
545
+ });
526
546
  internal.attached = attachChannelPort(port, {
527
- resolveLocal: (fnName) => internal.internalHandlers[fnName] ?? registry.resolve(fnName),
547
+ resolveLocal: (fnName) => stateRegistry.resolve(fnName) ?? registry.resolve(fnName),
528
548
  onControl: (kind) => {
529
549
  if (kind === "ping") internal.attached.postControl("pong");
530
550
  },
@@ -532,7 +552,7 @@ function createPageScriptChannel(options) {
532
552
  });
533
553
  internal.peer = {
534
554
  id,
535
- call: (fnName, ...args) => withCallDeadline(internal.attached.rpc.$call(fnName, ...serializeArgs(codec, args)).then((result) => deserializeResult(codec, result)), callTimeoutMs, () => `in-page channel "${name}": call "${fnName}" to panel "${id}" timed out after ${callTimeoutMs}ms`),
555
+ call: (fnName, ...args) => withCallDeadline(internal.attached.rpc.$call(channelMethod("function", fnName), ...serializeArgs(codec, args)).then((result) => deserializeResult(codec, result)), callTimeoutMs, () => `in-page channel "${name}": call "${fnName}" to panel "${id}" timed out after ${callTimeoutMs}ms`),
536
556
  close: () => removePeer(id, {
537
557
  bye: true,
538
558
  reason: "the page script closed this panel"
@@ -550,8 +570,8 @@ function createPageScriptChannel(options) {
550
570
  if (closed) return;
551
571
  const data = event.data;
552
572
  if (!isHandshakeMessage(data) || data.kind !== "hello" || data.name !== name) return;
553
- if (data.v !== 1) {
554
- warnOnce(`in-page channel "${name}": ignoring a hello with protocol version ${data.v} (this side speaks 1); align the devframe versions of the page script and the panel`);
573
+ if (data.v !== 2) {
574
+ warnOnce(`in-page channel "${name}": ignoring a hello with protocol version ${data.v} (this side speaks 2); align the devframe versions of the page script and the panel`);
555
575
  return;
556
576
  }
557
577
  if (!allowedOrigins.includes("*") && !allowedOrigins.includes(event.origin)) {
@@ -565,7 +585,7 @@ function createPageScriptChannel(options) {
565
585
  addPeer(messageChannel.port1, data.panelId);
566
586
  const grant = {
567
587
  channel: IN_PAGE_CHANNEL_TAG,
568
- v: 1,
588
+ v: 2,
569
589
  kind: "grant",
570
590
  name,
571
591
  panelId: data.panelId,
@@ -582,7 +602,7 @@ function createPageScriptChannel(options) {
582
602
  const emit = (fnName, ...args) => {
583
603
  const wireArgs = serializeArgs(codec, args);
584
604
  for (const peer of peers.values()) peer.attached.rpc.$callRaw({
585
- method: fnName,
605
+ method: channelMethod("event", fnName),
586
606
  args: wireArgs,
587
607
  event: true,
588
608
  optional: true
@@ -651,6 +671,11 @@ function connectPanelChannel(options) {
651
671
  ...definition,
652
672
  name: fnName
653
673
  });
674
+ for (const [eventName, definition] of Object.entries(options.events ?? {})) registry.register({
675
+ ...definition,
676
+ name: eventName,
677
+ type: "event"
678
+ });
654
679
  let status = "connecting";
655
680
  let attached;
656
681
  let pageScriptInfo;
@@ -668,8 +693,13 @@ function connectPanelChannel(options) {
668
693
  }
669
694
  const stateHost = createPanelStateHost({
670
695
  isConnected: () => status === "connected",
671
- callEvent: (method, args) => sendEvent(method, args),
672
- call: (method, args) => enqueueCall(method, args)
696
+ callEvent: (method, args) => sendEvent(method, serializeArgs(codec, args)),
697
+ call: (method, args) => enqueueCall(method, serializeArgs(codec, args))
698
+ });
699
+ const stateRegistry = createLocalFunctionRegistry(codec);
700
+ for (const [name, handler] of Object.entries(stateHost.handlers)) stateRegistry.register({
701
+ name,
702
+ handler
673
703
  });
674
704
  function sendEventNow(method, args) {
675
705
  attached?.rpc.$callRaw({
@@ -716,7 +746,7 @@ function connectPanelChannel(options) {
716
746
  reason: "the panel adopted a newer port"
717
747
  });
718
748
  attached = attachChannelPort(port, {
719
- resolveLocal: (fnName) => stateHost.handlers[fnName] ?? registry.resolve(fnName),
749
+ resolveLocal: (fnName) => stateRegistry.resolve(fnName) ?? registry.resolve(fnName),
720
750
  onControl: (kind) => {
721
751
  if (kind === "ping") attached?.postControl("pong");
722
752
  },
@@ -761,7 +791,7 @@ function connectPanelChannel(options) {
761
791
  const tick = () => {
762
792
  const hello = {
763
793
  channel: IN_PAGE_CHANNEL_TAG,
764
- v: 1,
794
+ v: 2,
765
795
  kind: "hello",
766
796
  name,
767
797
  panelId,
@@ -779,8 +809,8 @@ function connectPanelChannel(options) {
779
809
  if (status === "closed") return;
780
810
  const data = event.data;
781
811
  if (!isHandshakeMessage(data) || data.kind !== "grant" || data.name !== name || data.panelId !== panelId) return;
782
- if (data.v !== 1) {
783
- warnOnce(`in-page channel "${name}": ignoring a grant with protocol version ${data.v} (this side speaks 1); align the devframe versions of the page script and the panel`);
812
+ if (data.v !== 2) {
813
+ warnOnce(`in-page channel "${name}": ignoring a grant with protocol version ${data.v} (this side speaks 2); align the devframe versions of the page script and the panel`);
784
814
  return;
785
815
  }
786
816
  if (!allowedOrigins.includes("*") && !allowedOrigins.includes(event.origin)) {
@@ -825,9 +855,9 @@ function connectPanelChannel(options) {
825
855
  }, timeoutMs);
826
856
  });
827
857
  },
828
- call: (fnName, ...args) => enqueueCall(fnName, serializeArgs(codec, args)),
829
- emit: (fnName, ...args) => sendEvent(fnName, serializeArgs(codec, args)),
830
- callEvent: (fnName, ...args) => sendEvent(fnName, serializeArgs(codec, args)),
858
+ call: (fnName, ...args) => enqueueCall(channelMethod("function", fnName), serializeArgs(codec, args)),
859
+ emit: (fnName, ...args) => sendEvent(channelMethod("event", fnName), serializeArgs(codec, args)),
860
+ callEvent: (fnName, ...args) => sendEvent(channelMethod("event", fnName), serializeArgs(codec, args)),
831
861
  on: (fnName, listener) => registry.on(fnName, listener),
832
862
  sharedState: stateHost,
833
863
  close: () => {
@@ -1,5 +1,5 @@
1
- import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-B7411Bem.mjs";
2
- import { n as InternalAnonymousAuthStorage } from "./context-CIsx_QnV.mjs";
1
+ import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-DLzIyQCZ.mjs";
2
+ import { n as InternalAnonymousAuthStorage } from "./context-3y_PeZKl.mjs";
3
3
  //#region src/node/auth/revoke.d.ts
4
4
  /**
5
5
  * Flip `isTrusted` to false on any live WS clients connected with `token`
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./index-pIVt92jP.mjs";
2
2
  import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-Dq4i156u.mjs";
3
- import { c as DevframeNodeRpcSessionMeta, d as DevframeRpcTransportKind, l as DevframeRpcConnection, u as DevframeRpcConnectionRequest } from "./ws-server-D2nv68Hg.mjs";
4
- import { $ as DevframeServiceOf, At as AgentHandle, B as DevframeSetupInfo, Bt as DevframeAgentHostEvents, Ct as DevframeDiagnosticsHost, F as DevframeDefinition, Ft as AgentTool, G as McpAuthorization, H as DevframeSnapshotRpcInputs, Ht as EventUnsubscribe, I as DevframeDeploymentKind, It as AgentToolInput, J as DevframeServiceDefinition, K as McpRouteOptions, L as DevframeDockDefaults, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, P as DevframeCliOptions, Pt as AgentResourceInput, Q as DevframeServiceMeta, R as DevframeDuplicationStrategy, Rt as AgentToolProviderHandle, St as DevframeStorageScope, U as DevframeSseOptions, Ut as EventsMap, V as DevframeSnapshotRpcEntry, Vt as EventEmitter, W as DevframeWsOptions, X as DevframeServiceId, Y as DevframeServiceDescriptor, Z as DevframeServiceInput, _t as DevframeViewHost, a as DevframeConnectionConfigsRegistry, at as DevframeScopedNodeContext, bt as DevframeRpcSharedStates, c as RpcBroadcastOptions, ct as DevframeSettings, d as RpcSharedStateHost, dt as ScopedBroadcastOptions, et as DevframeServiceScopeOf, f as RpcStreamingChannel, ft as ScopedClientFunctions, gt as SettingsForNamespace, ht as ScopedSharedStates, i as DevframeCapabilities, it as DevframeServicesState, jt as AgentManifest, l as RpcFunctionsHost, lt as DevframeSettingsRegistry, m as RpcStreamingHost, mt as ScopedServerFunctions, n as ConnectionMetaSse, nt as DevframeServicesRegistry, o as DevframeNodeContext, ot as DevframeScopedNodeRpc, p as RpcStreamingChannelOptions, pt as ScopedRpcFn, q as McpSetting, r as ConnectionMetaWebsocket, rt as DevframeServicesScopeRegistry, s as DevframeNodeRpcSession, st as DevframeScopedStreamingHost, t as ConnectionMeta, tt as DevframeServicesHost, u as RpcSharedStateGetOptions, ut as DevframeSettingsStore, vt as DevframeRpcClientFunctions, wt as DevframeDiagnosticsLogger, xt as DevframeHost, yt as DevframeRpcServerFunctions, z as DevframeRpcOptions, zt as DevframeAgentHost } from "./context-B7411Bem.mjs";
3
+ import { $ as DevframeServiceOf, At as AgentHandle, B as DevframeSetupInfo, Bt as DevframeAgentHostEvents, Ct as DevframeDiagnosticsHost, F as DevframeDefinition, Ft as AgentTool, G as McpAuthorization, H as DevframeSnapshotRpcInputs, Ht as EventUnsubscribe, I as DevframeDeploymentKind, It as AgentToolInput, J as DevframeServiceDefinition, K as McpRouteOptions, L as DevframeDockDefaults, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, P as DevframeCliOptions, Pt as AgentResourceInput, Q as DevframeServiceMeta, R as DevframeDuplicationStrategy, Rt as AgentToolProviderHandle, St as DevframeStorageScope, U as DevframeSseOptions, Ut as EventsMap, V as DevframeSnapshotRpcEntry, Vt as EventEmitter, W as DevframeWsOptions, X as DevframeServiceId, Y as DevframeServiceDescriptor, Z as DevframeServiceInput, _t as DevframeViewHost, a as DevframeConnectionConfigsRegistry, at as DevframeScopedNodeContext, bt as DevframeRpcSharedStates, c as RpcBroadcastOptions, ct as DevframeSettings, d as RpcSharedStateHost, dt as ScopedBroadcastOptions, et as DevframeServiceScopeOf, f as RpcStreamingChannel, ft as ScopedClientFunctions, gt as SettingsForNamespace, ht as ScopedSharedStates, i as DevframeCapabilities, it as DevframeServicesState, jt as AgentManifest, l as RpcFunctionsHost, lt as DevframeSettingsRegistry, m as RpcStreamingHost, mt as ScopedServerFunctions, n as ConnectionMetaSse, nt as DevframeServicesRegistry, o as DevframeNodeContext, ot as DevframeScopedNodeRpc, p as RpcStreamingChannelOptions, pt as ScopedRpcFn, q as McpSetting, r as ConnectionMetaWebsocket, rt as DevframeServicesScopeRegistry, s as DevframeNodeRpcSession, st as DevframeScopedStreamingHost, t as ConnectionMeta, tt as DevframeServicesHost, u as RpcSharedStateGetOptions, ut as DevframeSettingsStore, vt as DevframeRpcClientFunctions, wt as DevframeDiagnosticsLogger, xt as DevframeHost, yt as DevframeRpcServerFunctions, z as DevframeRpcOptions, zt as DevframeAgentHost } from "./context-DLzIyQCZ.mjs";
4
+ import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
5
5
  import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "./remote-assets-eBvSKZMS.mjs";
6
6
  import { i as DevframeDefineDiagnosticsOptions } from "./nostics-0sKe5HIj.mjs";
7
7
  //#region src/define.d.ts
@@ -18,4 +18,4 @@ export declare function defineDevframe(d: DevframeDefinition): DevframeDefinitio
18
18
  */
19
19
  export declare function resolveClientAssets(d: DevframeDefinition): StaticAssetsSource | undefined;
20
20
  //#endregion
21
- export type { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcConnection, DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
21
+ export type { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcConnection, DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, DevframeWsPeer, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
@@ -1,12 +1,13 @@
1
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "./ws-server-D2nv68Hg.mjs";
2
- import { Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta, vt as DevframeRpcClientFunctions, yt as DevframeRpcServerFunctions } from "./context-B7411Bem.mjs";
3
- import "./index--pZ3fdAq.mjs";
1
+ import { Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta, vt as DevframeRpcClientFunctions, yt as DevframeRpcServerFunctions } from "./context-DLzIyQCZ.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
3
+ import { n as WsOriginRegistry } from "./ws-server-9ztvkeJ0.mjs";
4
+ import "./index-Ces7aTOQ.mjs";
4
5
  import { BirpcGroup } from "birpc";
6
+ import { H3 } from "h3";
5
7
  import { NodeAdapter } from "crossws/adapters/node";
6
8
  import { Buffer } from "node:buffer";
7
9
  import { IncomingMessage, Server, ServerResponse } from "node:http";
8
10
  import { Duplex } from "node:stream";
9
- import { H3 } from "h3";
10
11
  //#region src/node/instance-registry.d.ts
11
12
  /**
12
13
  * One running devframe instance, as recorded in the instance registry.
@@ -1,9 +1,9 @@
1
1
  import { v as RpcFunctionDefinitionAny } from "../types-Dq4i156u.mjs";
2
- import { At as AgentHandle, Bt as DevframeAgentHostEvents, F as DevframeDefinition, Ft as AgentTool, It as AgentToolInput, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, Pt as AgentResourceInput, Rt as AgentToolProviderHandle, Vt as EventEmitter, jt as AgentManifest, o as DevframeNodeContext, xt as DevframeHost, zt as DevframeAgentHost$1 } from "../context-B7411Bem.mjs";
2
+ import { At as AgentHandle, Bt as DevframeAgentHostEvents, F as DevframeDefinition, Ft as AgentTool, It as AgentToolInput, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, Pt as AgentResourceInput, Rt as AgentToolProviderHandle, Vt as EventEmitter, jt as AgentManifest, o as DevframeNodeContext, xt as DevframeHost, zt as DevframeAgentHost$1 } from "../context-DLzIyQCZ.mjs";
3
3
  import { a as RemoteAssetsStore, o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
4
- import { a as InstanceShellInit, c as StartedServer, d as samePath, f as DevframeInstanceRecord, h as registerDevframeInstance, i as InstanceShellApi, l as createInstanceShell, m as listLiveDevframeInstances, n as InstanceRegisterConfig, o as InstanceShellInternals, p as DevframeInstanceRegistration, r as InstanceShell, s as InstanceWsTier, t as CreateInstanceShellOptions, u as resolveInstanceRegister } from "../instance-shell-B-FE8NY5.mjs";
5
- import { a as resolveBasePath, i as normalizeBasePath, n as ResolvedMcpConfig, r as loadAutoMcpAdapter, s as resolveMcpConfig } from "../_shared-Bf2FcfJ4.mjs";
6
- import { n as CreateContextRpcServerOptions, r as createContextRpcServer, t as ContextRpcServer } from "../rpc-core-D7WvbvK0.mjs";
4
+ import { a as InstanceShellInit, c as StartedServer, d as samePath, f as DevframeInstanceRecord, h as registerDevframeInstance, i as InstanceShellApi, l as createInstanceShell, m as listLiveDevframeInstances, n as InstanceRegisterConfig, o as InstanceShellInternals, p as DevframeInstanceRegistration, r as InstanceShell, s as InstanceWsTier, t as CreateInstanceShellOptions, u as resolveInstanceRegister } from "../instance-shell-BQXr8n68.mjs";
5
+ import { a as resolveBasePath, i as normalizeBasePath, n as ResolvedMcpConfig, r as loadAutoMcpAdapter, s as resolveMcpConfig } from "../_shared-CkLpdx6I.mjs";
6
+ import { n as CreateContextRpcServerOptions, r as createContextRpcServer, t as ContextRpcServer } from "../rpc-core-Clo3kHfo.mjs";
7
7
  //#region src/client-assets.d.ts
8
8
  /**
9
9
  * Resolve a definition's client assets source: the built SPA served as its
@@ -1,3 +1,3 @@
1
- import { Tt as DevframeAuthHandler } from "../context-B7411Bem.mjs";
2
- import { a as getTempAuthCodeInfo, c as revokeActiveConnectionsForToken, i as getTempAuthCode, l as revokeAuthToken, n as describeUA, o as refreshTempAuthCode, r as exchangeTempAuthCode, s as verifyAuthToken, t as buildOtpAuthUrl } from "../index--pZ3fdAq.mjs";
1
+ import { Tt as DevframeAuthHandler } from "../context-DLzIyQCZ.mjs";
2
+ import { a as getTempAuthCodeInfo, c as revokeActiveConnectionsForToken, i as getTempAuthCode, l as revokeAuthToken, n as describeUA, o as refreshTempAuthCode, r as exchangeTempAuthCode, s as verifyAuthToken, t as buildOtpAuthUrl } from "../index-Ces7aTOQ.mjs";
3
3
  export { DevframeAuthHandler, buildOtpAuthUrl, describeUA, exchangeTempAuthCode, getTempAuthCode, getTempAuthCodeInfo, refreshTempAuthCode, revokeActiveConnectionsForToken, revokeAuthToken, verifyAuthToken };
@@ -1,3 +1,3 @@
1
- import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-CIsx_QnV.mjs";
2
- import { a as resolveBasePath, i as normalizeBasePath } from "../_shared-Bf2FcfJ4.mjs";
1
+ import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-3y_PeZKl.mjs";
2
+ import { a as resolveBasePath, i as normalizeBasePath } from "../_shared-CkLpdx6I.mjs";
3
3
  export { type DevframeInternalContext, type InternalAnonymousAuthStorage, type RemoteTokenRecord, getInternalContext, internalContextMap, normalizeBasePath, resolveBasePath };
@@ -1,6 +1,6 @@
1
1
  import "../index-pIVt92jP.mjs";
2
2
  import { v as RpcFunctionDefinitionAny } from "../types-Dq4i156u.mjs";
3
- import { k as SharedState, l as RpcFunctionsHost, o as DevframeNodeContext, xt as DevframeHost } from "../context-B7411Bem.mjs";
3
+ import { k as SharedState, l as RpcFunctionsHost, o as DevframeNodeContext, xt as DevframeHost } from "../context-DLzIyQCZ.mjs";
4
4
  import { BirpcGroup } from "birpc";
5
5
  //#region src/node/context.d.ts
6
6
  export interface CreateHostContextOptions {
@@ -1,6 +1,6 @@
1
1
  import "../index-pIVt92jP.mjs";
2
2
  import { E as Thenable, S as RpcFunctionSetupResult, c as RpcDump, g as RpcFunctionAgentOptions } from "../types-Dq4i156u.mjs";
3
- import "../context-B7411Bem.mjs";
3
+ import "../context-DLzIyQCZ.mjs";
4
4
  import { SimpleSchema } from "../utils/simple-schema.mjs";
5
5
  //#region src/recipes/common-rpc-functions.d.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { Tt as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "../context-B7411Bem.mjs";
2
- import "../index--pZ3fdAq.mjs";
1
+ import { Tt as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "../context-DLzIyQCZ.mjs";
2
+ import "../index-Ces7aTOQ.mjs";
3
3
  import { ColorFn } from "../utils/colors.mjs";
4
4
  //#region src/recipes/interactive-auth.d.ts
5
5
  export interface CreateInteractiveAuthOptions {
@@ -1,5 +1,6 @@
1
1
  import { v as RpcFunctionDefinitionAny } from "../../types-Dq4i156u.mjs";
2
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../../session-r6PDixP6.mjs";
3
+ import { n as WsOriginRegistry } from "../../ws-server-9ztvkeJ0.mjs";
3
4
  import { BirpcGroup } from "birpc";
4
5
  //#region src/rpc/transports/sse-server.d.ts
5
6
  export interface SseRpcTransportOptions {
@@ -1,5 +1,5 @@
1
- import { n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
2
- import { t as ContextRpcServer } from "../../rpc-core-D7WvbvK0.mjs";
1
+ import { n as WsOriginRegistry } from "../../ws-server-9ztvkeJ0.mjs";
2
+ import { t as ContextRpcServer } from "../../rpc-core-Clo3kHfo.mjs";
3
3
  //#region src/rpc/transports/ws-bun.d.ts
4
4
  export interface AttachBunWsTransportOptions {
5
5
  /** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
@@ -1,5 +1,5 @@
1
- import { n as WsOriginRegistry } from "../../ws-server-D2nv68Hg.mjs";
2
- import { t as ContextRpcServer } from "../../rpc-core-D7WvbvK0.mjs";
1
+ import { n as WsOriginRegistry } from "../../ws-server-9ztvkeJ0.mjs";
2
+ import { t as ContextRpcServer } from "../../rpc-core-Clo3kHfo.mjs";
3
3
  //#region src/rpc/transports/ws-deno.d.ts
4
4
  export interface AttachDenoWsTransportOptions {
5
5
  /** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
@@ -1,3 +1,4 @@
1
- import { a as attachWsRpcTransport, c as DevframeNodeRpcSessionMeta, d as DevframeRpcTransportKind, i as WsRpcTransportOptions, l as DevframeRpcConnection, n as WsOriginRegistry, o as createWsOriginRegistry, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions, u as DevframeRpcConnectionRequest } from "../../ws-server-D2nv68Hg.mjs";
1
+ import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../../session-r6PDixP6.mjs";
2
2
  import { n as isLoopbackHostname, t as isAllowedOrigin } from "../../origin-DGDH8BI9.mjs";
3
- export { CreateWsOriginRegistryOptions, type DevframeNodeRpcSessionMeta, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcTransportKind, WsOriginRegistry, WsRpcTransport, WsRpcTransportOptions, attachWsRpcTransport, createWsOriginRegistry, createWsRpcPeerHooks, isAllowedOrigin, isLoopbackHostname };
3
+ import { a as attachWsRpcTransport, i as WsRpcTransportOptions, n as WsOriginRegistry, o as createWsOriginRegistry, r as WsRpcTransport, s as createWsRpcPeerHooks, t as CreateWsOriginRegistryOptions } from "../../ws-server-9ztvkeJ0.mjs";
4
+ export { CreateWsOriginRegistryOptions, type DevframeNodeRpcSessionMeta, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcTransportKind, type DevframeWsPeer, WsOriginRegistry, WsRpcTransport, WsRpcTransportOptions, attachWsRpcTransport, createWsOriginRegistry, createWsRpcPeerHooks, isAllowedOrigin, isLoopbackHostname };
@@ -1,6 +1,7 @@
1
- import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection } from "./ws-server-D2nv68Hg.mjs";
2
- import { Tt as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession, vt as DevframeRpcClientFunctions, yt as DevframeRpcServerFunctions } from "./context-B7411Bem.mjs";
3
- import "./index--pZ3fdAq.mjs";
1
+ import { Tt as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession, vt as DevframeRpcClientFunctions, yt as DevframeRpcServerFunctions } from "./context-DLzIyQCZ.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
3
+ import "./ws-server-9ztvkeJ0.mjs";
4
+ import "./index-Ces7aTOQ.mjs";
4
5
  import { BirpcGroup, EventOptions } from "birpc";
5
6
  //#region src/node/rpc-core.d.ts
6
7
  interface CreateContextRpcServerOptions {
@@ -0,0 +1,111 @@
1
+ //#region src/rpc/transports/session.d.ts
2
+ /**
3
+ * Structural view of the crossws `Peer` backing a WebSocket RPC connection:
4
+ * the transport-independent slice of its API (identity, send, pub/sub,
5
+ * close, backpressure), typed locally so the `devframe/types` declaration
6
+ * graph never imports `crossws`, whose own declarations require the DOM,
7
+ * Bun, and Cloudflare type libs a plain Node consumer doesn't load. Every
8
+ * member mirrors its crossws counterpart; for the full API (the upgrade
9
+ * `request`, raw `websocket`, connected `peers`), import `Peer` from
10
+ * `crossws` and cast, which opts your compilation into crossws's lib
11
+ * requirements.
12
+ */
13
+ interface DevframeWsPeer {
14
+ /** Unique random uuid v4 identifier for the peer. */
15
+ readonly id: string;
16
+ /** IP address of the peer. */
17
+ readonly remoteAddress: string | undefined;
18
+ /** All topics this peer has been subscribed to. */
19
+ readonly topics: Set<string>;
20
+ /** Bytes queued for transmission but not yet flushed to the client. */
21
+ readonly bufferedAmount: number;
22
+ /** Wait until the send buffer drains to `threshold` bytes (default `0`). */
23
+ waitForDrain: (opts?: {
24
+ threshold?: number;
25
+ pollInterval?: number;
26
+ }) => Promise<void>;
27
+ /** Send a message to the peer. */
28
+ send: (data: unknown, options?: {
29
+ compress?: boolean;
30
+ }) => number | void | undefined;
31
+ /** Send a message to subscribers of a topic. */
32
+ publish: (topic: string, data: unknown, options?: {
33
+ compress?: boolean;
34
+ }) => void;
35
+ /** Subscribe to a topic. */
36
+ subscribe: (topic: string) => void;
37
+ /** Unsubscribe from a topic. */
38
+ unsubscribe: (topic: string) => void;
39
+ /** Close the connection. */
40
+ close: (code?: number, reason?: string) => void;
41
+ /** Abruptly close the connection. */
42
+ terminate: () => void;
43
+ }
44
+ /**
45
+ * Which wire transport produced an RPC connection. Every transport speaks
46
+ * the same birpc channel protocol; the kind only matters to code that needs
47
+ * transport-specific behavior (e.g. reaching the WS escape hatch on
48
+ * {@link DevframeRpcConnection.peer}).
49
+ */
50
+ type DevframeRpcTransportKind = 'websocket' | 'sse';
51
+ /**
52
+ * Structural view of the connect-time HTTP request behind an RPC connection:
53
+ * the WS upgrade request, or the request opening an SSE stream. Shaped to
54
+ * match both the web `Request` a crossws peer exposes and a plain
55
+ * `node:http` request wrapper, so auth hooks can read the bearer-token
56
+ * query param and the `Origin` header without caring which transport (or
57
+ * runtime) produced the connection.
58
+ */
59
+ interface DevframeRpcConnectionRequest {
60
+ /** Request URL (may be path-only, e.g. `/__ws?devframe_auth_token=…`). */
61
+ url?: string;
62
+ /** Header lookup, `Headers`-style. */
63
+ headers?: {
64
+ get: (name: string) => string | null | undefined;
65
+ };
66
+ }
67
+ /**
68
+ * A live RPC connection, independent of the transport that carries it. One
69
+ * exists per connected client; transport bindings construct it alongside the
70
+ * session meta and hand both to the connect/disconnect hooks
71
+ * (`onPeerConnect` / `onPeerDisconnect`, {@link DevframeAuthHandler.onConnect}).
72
+ */
73
+ interface DevframeRpcConnection {
74
+ /** Session id, the same value as the session meta's `id`. */
75
+ id: number;
76
+ /** The transport carrying this connection. */
77
+ transport: DevframeRpcTransportKind;
78
+ /** The connect-time HTTP request (upgrade request / stream request). */
79
+ request?: DevframeRpcConnectionRequest;
80
+ /** Send a raw wire frame to this client. Prefer the birpc channel. */
81
+ send?: (data: string) => void;
82
+ /** Terminate the connection from the server side. */
83
+ close?: (code?: number, reason?: string) => void;
84
+ /**
85
+ * The crossws peer backing a `websocket` connection: the WS-specific
86
+ * escape hatch (pub/sub, raw socket access). Absent on other transports.
87
+ */
88
+ peer?: DevframeWsPeer;
89
+ }
90
+ interface DevframeNodeRpcSessionMeta {
91
+ id: number;
92
+ /** The crossws peer backing this session's socket (WS transport only). */
93
+ peer?: DevframeWsPeer;
94
+ clientAuthToken?: string;
95
+ isTrusted?: boolean;
96
+ subscribedStates: Set<string>;
97
+ /**
98
+ * Streams this session has subscribed to via
99
+ * `rpc.streaming.subscribe(channel, id)`. Tracked here for O(1) cleanup
100
+ * on disconnect; the wire format is `${channel}\x1F${id}`.
101
+ */
102
+ subscribedStreams?: Set<string>;
103
+ /**
104
+ * Inbound streams this session is currently uploading to (via
105
+ * `rpc.streaming.upload(channel, id)`). Tracked for cleanup on
106
+ * disconnect; same wire format as `subscribedStreams`.
107
+ */
108
+ uploadingStreams?: Set<string>;
109
+ }
110
+ //#endregion
111
+ export { DevframeWsPeer as a, DevframeRpcTransportKind as i, DevframeRpcConnection as n, DevframeRpcConnectionRequest as r, DevframeNodeRpcSessionMeta as t };
@@ -1,6 +1,6 @@
1
1
  import { g as RpcFunctionAgentOptions } from "../types-Dq4i156u.mjs";
2
- import { c as DevframeNodeRpcSessionMeta, d as DevframeRpcTransportKind, l as DevframeRpcConnection, u as DevframeRpcConnectionRequest } from "../ws-server-D2nv68Hg.mjs";
3
- import { $ as DevframeServiceOf, At as AgentHandle, B as DevframeSetupInfo, Bt as DevframeAgentHostEvents, Ct as DevframeDiagnosticsHost, F as DevframeDefinition, Ft as AgentTool, G as McpAuthorization, H as DevframeSnapshotRpcInputs, Ht as EventUnsubscribe, I as DevframeDeploymentKind, It as AgentToolInput, J as DevframeServiceDefinition, K as McpRouteOptions, L as DevframeDockDefaults, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, P as DevframeCliOptions, Pt as AgentResourceInput, Q as DevframeServiceMeta, R as DevframeDuplicationStrategy, Rt as AgentToolProviderHandle, St as DevframeStorageScope, U as DevframeSseOptions, Ut as EventsMap, V as DevframeSnapshotRpcEntry, Vt as EventEmitter, W as DevframeWsOptions, X as DevframeServiceId, Y as DevframeServiceDescriptor, Z as DevframeServiceInput, _t as DevframeViewHost, a as DevframeConnectionConfigsRegistry, at as DevframeScopedNodeContext, bt as DevframeRpcSharedStates, c as RpcBroadcastOptions, ct as DevframeSettings, d as RpcSharedStateHost, dt as ScopedBroadcastOptions, et as DevframeServiceScopeOf, f as RpcStreamingChannel, ft as ScopedClientFunctions, gt as SettingsForNamespace, ht as ScopedSharedStates, i as DevframeCapabilities, it as DevframeServicesState, jt as AgentManifest, l as RpcFunctionsHost, lt as DevframeSettingsRegistry, m as RpcStreamingHost, mt as ScopedServerFunctions, n as ConnectionMetaSse, nt as DevframeServicesRegistry, o as DevframeNodeContext, ot as DevframeScopedNodeRpc, p as RpcStreamingChannelOptions, pt as ScopedRpcFn, q as McpSetting, r as ConnectionMetaWebsocket, rt as DevframeServicesScopeRegistry, s as DevframeNodeRpcSession, st as DevframeScopedStreamingHost, t as ConnectionMeta, tt as DevframeServicesHost, u as RpcSharedStateGetOptions, ut as DevframeSettingsStore, vt as DevframeRpcClientFunctions, wt as DevframeDiagnosticsLogger, xt as DevframeHost, yt as DevframeRpcServerFunctions, z as DevframeRpcOptions, zt as DevframeAgentHost } from "../context-B7411Bem.mjs";
2
+ import { $ as DevframeServiceOf, At as AgentHandle, B as DevframeSetupInfo, Bt as DevframeAgentHostEvents, Ct as DevframeDiagnosticsHost, F as DevframeDefinition, Ft as AgentTool, G as McpAuthorization, H as DevframeSnapshotRpcInputs, Ht as EventUnsubscribe, I as DevframeDeploymentKind, It as AgentToolInput, J as DevframeServiceDefinition, K as McpRouteOptions, L as DevframeDockDefaults, Lt as AgentToolProvider, Mt as AgentResource, Nt as AgentResourceContent, P as DevframeCliOptions, Pt as AgentResourceInput, Q as DevframeServiceMeta, R as DevframeDuplicationStrategy, Rt as AgentToolProviderHandle, St as DevframeStorageScope, U as DevframeSseOptions, Ut as EventsMap, V as DevframeSnapshotRpcEntry, Vt as EventEmitter, W as DevframeWsOptions, X as DevframeServiceId, Y as DevframeServiceDescriptor, Z as DevframeServiceInput, _t as DevframeViewHost, a as DevframeConnectionConfigsRegistry, at as DevframeScopedNodeContext, bt as DevframeRpcSharedStates, c as RpcBroadcastOptions, ct as DevframeSettings, d as RpcSharedStateHost, dt as ScopedBroadcastOptions, et as DevframeServiceScopeOf, f as RpcStreamingChannel, ft as ScopedClientFunctions, gt as SettingsForNamespace, ht as ScopedSharedStates, i as DevframeCapabilities, it as DevframeServicesState, jt as AgentManifest, l as RpcFunctionsHost, lt as DevframeSettingsRegistry, m as RpcStreamingHost, mt as ScopedServerFunctions, n as ConnectionMetaSse, nt as DevframeServicesRegistry, o as DevframeNodeContext, ot as DevframeScopedNodeRpc, p as RpcStreamingChannelOptions, pt as ScopedRpcFn, q as McpSetting, r as ConnectionMetaWebsocket, rt as DevframeServicesScopeRegistry, s as DevframeNodeRpcSession, st as DevframeScopedStreamingHost, t as ConnectionMeta, tt as DevframeServicesHost, u as RpcSharedStateGetOptions, ut as DevframeSettingsStore, vt as DevframeRpcClientFunctions, wt as DevframeDiagnosticsLogger, xt as DevframeHost, yt as DevframeRpcServerFunctions, z as DevframeRpcOptions, zt as DevframeAgentHost } from "../context-DLzIyQCZ.mjs";
3
+ import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
4
4
  import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "../remote-assets-eBvSKZMS.mjs";
5
5
  import { i as DevframeDefineDiagnosticsOptions } from "../nostics-0sKe5HIj.mjs";
6
- export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
6
+ export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, type DevframeWsPeer, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpRouteOptions, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
@@ -1,4 +1,4 @@
1
- import { Ut as EventsMap, Vt as EventEmitter } from "../context-B7411Bem.mjs";
1
+ import { Ut as EventsMap, Vt as EventEmitter } from "../context-DLzIyQCZ.mjs";
2
2
  //#region src/utils/events.d.ts
3
3
  /**
4
4
  * Create event emitter.
@@ -1,6 +1,6 @@
1
1
  import { a as RemoteAssetsStore } from "../remote-assets-eBvSKZMS.mjs";
2
- import { IncomingMessage, ServerResponse } from "node:http";
3
2
  import { EventHandler, H3 } from "h3";
3
+ import { IncomingMessage, ServerResponse } from "node:http";
4
4
  //#region src/utils/serve-static.d.ts
5
5
  /**
6
6
  * What the static-serving engine accepts: a local directory, or a resolved
@@ -1,2 +1,2 @@
1
- import { A as SharedStateEvents, D as ImmutableObject, E as ImmutableMap, M as SharedStatePatch, N as createSharedState, O as ImmutableSet, T as ImmutableArray, j as SharedStateOptions, k as SharedState, w as Immutable } from "../context-B7411Bem.mjs";
1
+ import { A as SharedStateEvents, D as ImmutableObject, E as ImmutableMap, M as SharedStatePatch, N as createSharedState, O as ImmutableSet, T as ImmutableArray, j as SharedStateOptions, k as SharedState, w as Immutable } from "../context-DLzIyQCZ.mjs";
2
2
  export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
@@ -1,2 +1,2 @@
1
- import { C as createStreamSink, S as createStreamReader, _ as CreateStreamSinkOptions, b as StreamSink, g as CreateStreamReaderOptions, h as BufferedChunk, v as StreamErrorPayload, x as StreamSinkEvents, y as StreamReader } from "../context-B7411Bem.mjs";
1
+ import { C as createStreamSink, S as createStreamReader, _ as CreateStreamSinkOptions, b as StreamSink, g as CreateStreamReaderOptions, h as BufferedChunk, v as StreamErrorPayload, x as StreamSinkEvents, y as StreamReader } from "../context-DLzIyQCZ.mjs";
2
2
  export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
@@ -1,80 +1,13 @@
1
1
  import { v as RpcFunctionDefinitionAny } from "./types-Dq4i156u.mjs";
2
+ import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
2
3
  import { BirpcGroup, ChannelOptions } from "birpc";
3
- import { Hooks, Peer } from "crossws";
4
+ import { Hooks } from "crossws";
4
5
  import { NodeAdapter } from "crossws/adapters/node";
5
6
  import { Buffer } from "node:buffer";
6
7
  import { IncomingMessage, Server } from "node:http";
7
8
  import { Server as Server$1, ServerOptions } from "node:https";
8
9
  import { AddressInfo } from "node:net";
9
10
  import { Duplex } from "node:stream";
10
- //#region src/rpc/transports/session.d.ts
11
- /**
12
- * Which wire transport produced an RPC connection. Every transport speaks
13
- * the same birpc channel protocol; the kind only matters to code that needs
14
- * transport-specific behavior (e.g. reaching the WS escape hatch on
15
- * {@link DevframeRpcConnection.peer}).
16
- */
17
- type DevframeRpcTransportKind = 'websocket' | 'sse';
18
- /**
19
- * Structural view of the connect-time HTTP request behind an RPC connection:
20
- * the WS upgrade request, or the request opening an SSE stream. Shaped to
21
- * match both the web `Request` a crossws peer exposes and a plain
22
- * `node:http` request wrapper, so auth hooks can read the bearer-token
23
- * query param and the `Origin` header without caring which transport (or
24
- * runtime) produced the connection.
25
- */
26
- interface DevframeRpcConnectionRequest {
27
- /** Request URL (may be path-only, e.g. `/__ws?devframe_auth_token=…`). */
28
- url?: string;
29
- /** Header lookup, `Headers`-style. */
30
- headers?: {
31
- get: (name: string) => string | null | undefined;
32
- };
33
- }
34
- /**
35
- * A live RPC connection, independent of the transport that carries it. One
36
- * exists per connected client; transport bindings construct it alongside the
37
- * session meta and hand both to the connect/disconnect hooks
38
- * (`onPeerConnect` / `onPeerDisconnect`, {@link DevframeAuthHandler.onConnect}).
39
- */
40
- interface DevframeRpcConnection {
41
- /** Session id, the same value as the session meta's `id`. */
42
- id: number;
43
- /** The transport carrying this connection. */
44
- transport: DevframeRpcTransportKind;
45
- /** The connect-time HTTP request (upgrade request / stream request). */
46
- request?: DevframeRpcConnectionRequest;
47
- /** Send a raw wire frame to this client. Prefer the birpc channel. */
48
- send?: (data: string) => void;
49
- /** Terminate the connection from the server side. */
50
- close?: (code?: number, reason?: string) => void;
51
- /**
52
- * The crossws peer backing a `websocket` connection: the WS-specific
53
- * escape hatch (pub/sub, raw socket access). Absent on other transports.
54
- */
55
- peer?: Peer;
56
- }
57
- interface DevframeNodeRpcSessionMeta {
58
- id: number;
59
- /** The crossws peer backing this session's socket (WS transport only). */
60
- peer?: Peer;
61
- clientAuthToken?: string;
62
- isTrusted?: boolean;
63
- subscribedStates: Set<string>;
64
- /**
65
- * Streams this session has subscribed to via
66
- * `rpc.streaming.subscribe(channel, id)`. Tracked here for O(1) cleanup
67
- * on disconnect; the wire format is `${channel}\x1F${id}`.
68
- */
69
- subscribedStreams?: Set<string>;
70
- /**
71
- * Inbound streams this session is currently uploading to (via
72
- * `rpc.streaming.upload(channel, id)`). Tracked for cleanup on
73
- * disconnect; same wire format as `subscribedStreams`.
74
- */
75
- uploadingStreams?: Set<string>;
76
- }
77
- //#endregion
78
11
  //#region src/rpc/transports/ws-server.d.ts
79
12
  interface WsRpcTransportOptions {
80
13
  /**
@@ -216,4 +149,4 @@ declare function createWsRpcPeerHooks<ClientFunctions extends object, ServerFunc
216
149
  */
217
150
  declare function attachWsRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: WsRpcTransportOptions): WsRpcTransport;
218
151
  //#endregion
219
- export { attachWsRpcTransport as a, DevframeNodeRpcSessionMeta as c, DevframeRpcTransportKind as d, WsRpcTransportOptions as i, DevframeRpcConnection as l, WsOriginRegistry as n, createWsOriginRegistry as o, WsRpcTransport as r, createWsRpcPeerHooks as s, CreateWsOriginRegistryOptions as t, DevframeRpcConnectionRequest as u };
152
+ export { attachWsRpcTransport as a, WsRpcTransportOptions as i, WsOriginRegistry as n, createWsOriginRegistry as o, WsRpcTransport as r, createWsRpcPeerHooks as s, CreateWsOriginRegistryOptions as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "devframe",
3
3
  "type": "module",
4
- "version": "0.9.15",
4
+ "version": "0.9.17",
5
5
  "description": "Framework for building one portable devtool integration that runs in any viewer.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -112,6 +112,7 @@
112
112
  "structured-clone-es": "^2.0.1",
113
113
  "tinyglobby": "^0.2.17",
114
114
  "tsdown": "^0.23.0",
115
+ "typescript": "^6.0.3",
115
116
  "ua-parser-modern": "^0.1.1",
116
117
  "valibot": "^1.4.2",
117
118
  "whenexpr": "^0.1.2",
@@ -438,7 +438,7 @@ Use `my.rpc.sharedState(key)` for observable state, `my.rpc.register(...)` to re
438
438
 
439
439
  ### In-page channel (page script ↔ panel, server-free)
440
440
 
441
- For a live inspect-the-page loop, `devframe/in-page-channel` connects a devframe's **page script** (in the user app's page) to its **panels** entirely in the browser — no server, so it works identically in dev and static builds. Declare one shared protocol type; the page script is `createPageScriptChannel<P>({ name, functions })`, each panel `connectPanelChannel<P>({ name })`. Functions use `defineChannelFunction` (the `defineRpcFunction` shape: `type: 'event'` fans out to every panel, `query`/`action` are request/response); `channel.sharedState.get(key)` mirrors `rpc.sharedState` with the page script as authority (panels get automatic replay). The handshake is panel-initiated with retry — boot order and reloads don't matter — and panels expose `status`/`whenConnected(ms)` for "page script not loaded" fallbacks. Channel names follow `devframes:plugin:<slug>`. The a11y inspector's scan/highlight loop is the reference use.
441
+ For a live inspect-the-page loop, `devframe/in-page-channel` connects a devframe's **page script** (in the user app's page) to its **panels** entirely in the browser, in both dev and static builds. Declare a shared protocol type with separate `functions` and `events` sections, each with `pageScript` and `panel` maps naming the receiving direction. Both `createPageScriptChannel<P>()` and `connectPanelChannel<P>()` require `{ name, functions }` and accept optional `events`: function declarations require handlers; event declarations accept optional handlers or `{}` for dynamic `channel.on()` subscriptions. `call()` awaits functions, including void actions; `emit()` sends declared events. `channel.sharedState.get(key)` mirrors `rpc.sharedState` with the page script as authority and automatic replay to panels. The handshake retries across boot order and reloads; panels expose `status`/`whenConnected(ms)` for page-script availability fallbacks. Channel names follow `devframes:plugin:<slug>`. The a11y inspector's scan/highlight loop is the reference use.
442
442
 
443
443
  ## The Hub
444
444