devframe 0.9.11 → 0.9.13

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 (55) hide show
  1. package/dist/adapters/build.d.mts +4 -5
  2. package/dist/adapters/build.mjs +2 -2
  3. package/dist/adapters/cac.d.mts +4 -4
  4. package/dist/adapters/cac.mjs +1 -1
  5. package/dist/adapters/dev.d.mts +4 -4
  6. package/dist/adapters/dev.mjs +1 -1
  7. package/dist/adapters/embedded.d.mts +3 -4
  8. package/dist/adapters/initiate.d.mts +7 -8
  9. package/dist/adapters/initiate.mjs +1 -1
  10. package/dist/adapters/mcp.d.mts +4 -4
  11. package/dist/adapters/mcp.mjs +9 -15
  12. package/dist/cli/main.d.mts +2 -3
  13. package/dist/client/index.d.mts +133 -35
  14. package/dist/client/index.mjs +231 -57
  15. package/dist/constants.d.mts +20 -21
  16. package/dist/{context-Bq27SDK-.mjs → context-Cdj9z9m2.mjs} +39 -21
  17. package/dist/{dev-B32EVw5w.mjs → dev-SPZzBTrH.mjs} +2 -2
  18. package/dist/in-page-channel/index.d.mts +75 -37
  19. package/dist/in-page-channel/index.mjs +56 -22
  20. package/dist/index.d.mts +4 -4
  21. package/dist/{instance-shell-BWh0JQuo.d.mts → instance-shell-BUyYrKlu.d.mts} +9 -2
  22. package/dist/{instance-shell-DvYCwrDy.mjs → instance-shell-xuu6jg51.mjs} +7 -2
  23. package/dist/internal/index.d.mts +12 -12
  24. package/dist/internal/index.mjs +1 -1
  25. package/dist/node/index.d.mts +5 -5
  26. package/dist/node/index.mjs +1 -1
  27. package/dist/nostics-DD6gsDZA.mjs +108 -0
  28. package/dist/recipes/common-rpc-functions.d.mts +6 -7
  29. package/dist/recipes/interactive-auth.d.mts +36 -11
  30. package/dist/recipes/interactive-auth.mjs +47 -4
  31. package/dist/rpc/client.d.mts +2 -3
  32. package/dist/rpc/dump.d.mts +16 -17
  33. package/dist/rpc/dump.mjs +1 -1
  34. package/dist/rpc/server.d.mts +2 -3
  35. package/dist/rpc/transports/sse-server.d.mts +4 -5
  36. package/dist/rpc/transports/ws-bun.d.mts +5 -6
  37. package/dist/rpc/transports/ws-deno.d.mts +4 -5
  38. package/dist/{shared-state-CaxB1q0h.mjs → shared-state-eQVYHNqA.mjs} +4 -1
  39. package/dist/utils/agent-tool-name.d.mts +2 -3
  40. package/dist/utils/colors.d.mts +4 -5
  41. package/dist/utils/crypto-token.d.mts +4 -5
  42. package/dist/utils/events.d.mts +2 -3
  43. package/dist/utils/hash.d.mts +2 -3
  44. package/dist/utils/launch-editor.d.mts +2 -3
  45. package/dist/utils/nanoid.d.mts +2 -3
  46. package/dist/utils/open.d.mts +2 -3
  47. package/dist/utils/remote-assets.d.mts +2 -3
  48. package/dist/utils/serve-static.d.mts +6 -7
  49. package/dist/utils/shared-state.mjs +1 -1
  50. package/dist/utils/simple-schema.d.mts +17 -18
  51. package/dist/utils/streaming-channel.mjs +4 -1
  52. package/dist/utils/structured-clone.d.mts +5 -6
  53. package/dist/utils/when.d.mts +6 -7
  54. package/dist/{write-BuLCrn9h.mjs → write-D2AJqVT8.mjs} +1 -1
  55. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
1
  import { F as DevframeDefinition, V as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-BBWPLDHh.mjs";
2
2
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
3
3
  //#region src/adapters/build.d.ts
4
- interface CreateBuildOptions {
4
+ export interface CreateBuildOptions {
5
5
  /** Output directory. Defaults to `dist-static`. */
6
6
  outDir?: string;
7
7
  /**
@@ -37,7 +37,7 @@ interface CreateBuildOptions {
37
37
  * output is mount-path agnostic, so the same bundle works at `/`,
38
38
  * `/devframe/`, or any base, no rewriting required.
39
39
  */
40
- declare function createBuild(d: DevframeDefinition, options?: CreateBuildOptions): Promise<void>;
40
+ export declare function createBuild(d: DevframeDefinition, options?: CreateBuildOptions): Promise<void>;
41
41
  /**
42
42
  * Attach a `dump` to each {@link DevframeRpcOptions.snapshot} target so the
43
43
  * static collector bakes it, even though the (service-owned) definition
@@ -46,6 +46,5 @@ declare function createBuild(d: DevframeDefinition, options?: CreateBuildOptions
46
46
  * argument-tuple by running the target's own handler, with the first tuple's
47
47
  * output as the fallback.
48
48
  */
49
- declare function applySnapshotRpc(ctx: DevframeNodeContext, entries: readonly DevframeSnapshotRpcEntry[] | undefined): void;
50
- //#endregion
51
- export { CreateBuildOptions, applySnapshotRpc, createBuild };
49
+ export declare function applySnapshotRpc(ctx: DevframeNodeContext, entries: readonly DevframeSnapshotRpcEntry[] | undefined): void;
50
+ //#endregion
@@ -1,9 +1,9 @@
1
1
  import { s as colors } from "../nostics-D0PvLZsn.mjs";
2
2
  import { t as resolveClientAssets } from "../client-assets-DNdhagGm.mjs";
3
3
  import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
4
- import { n as collectStaticRpcDump, t as writeStaticRpcDump } from "../write-BuLCrn9h.mjs";
4
+ import { n as collectStaticRpcDump, t as writeStaticRpcDump } from "../write-D2AJqVT8.mjs";
5
5
  import { t as diagnostics } from "../diagnostics-DZA6KQ_Z.mjs";
6
- import { t as createHostContext } from "../context-Bq27SDK-.mjs";
6
+ import { t as createHostContext } from "../context-Cdj9z9m2.mjs";
7
7
  import { t as resolveStaticAssetsSource } from "../remote-assets-DMFzLSoH.mjs";
8
8
  import { t as createH3DevframeHost } from "../host-h3-BROI6SQ4.mjs";
9
9
  import fs from "node:fs/promises";
@@ -2,7 +2,7 @@ import { Dt as InferCliFlags, Et as CliFlagsSchema, F as DevframeDefinition, Ot
2
2
  import { CAC } from "cac";
3
3
  import { H3 } from "h3";
4
4
  //#region src/adapters/cac.d.ts
5
- interface CreateCacOptions {
5
+ export interface CreateCacOptions {
6
6
  /** Default port for `dev` (default: 9999). */
7
7
  defaultPort?: number;
8
8
  /**
@@ -32,7 +32,7 @@ interface CreateCacOptions {
32
32
  app: H3;
33
33
  }) => void | Promise<void>;
34
34
  }
35
- interface CacHandle {
35
+ export interface CacHandle {
36
36
  /**
37
37
  * Raw CAC instance. Mutate before calling `parse()` for last-mile
38
38
  * flag or command additions that don't fit `configureCli`.
@@ -46,6 +46,6 @@ interface CacHandle {
46
46
  *
47
47
  * Requires the optional `cac` peer dependency.
48
48
  */
49
- declare function createCac(d: DevframeDefinition, options?: CreateCacOptions): CacHandle;
49
+ export declare function createCac(d: DevframeDefinition, options?: CreateCacOptions): CacHandle;
50
50
  //#endregion
51
- export { CacHandle, type CliFlagsSchema, CreateCacOptions, type InferCliFlags, createCac, defineCliFlags, parseCliFlags };
51
+ export { type CliFlagsSchema, type InferCliFlags, defineCliFlags, parseCliFlags };
@@ -1,7 +1,7 @@
1
1
  import { s as colors } from "../nostics-D0PvLZsn.mjs";
2
2
  import { i as resolveDevServerPort, s as importRuntimeModule } from "../_shared-U8D-xzrp.mjs";
3
3
  import { createBuild } from "./build.mjs";
4
- import { t as createDevServer } from "../dev-B32EVw5w.mjs";
4
+ import { t as createDevServer } from "../dev-SPZzBTrH.mjs";
5
5
  import process from "node:process";
6
6
  import cac$1 from "cac";
7
7
  //#region src/adapters/flags.ts
@@ -1,11 +1,11 @@
1
1
  import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../ws-server-D2nv68Hg.mjs";
2
2
  import { F as DevframeDefinition, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, q as McpSetting, s as DevframeNodeRpcSession } from "../context-BBWPLDHh.mjs";
3
3
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
4
- import { c as StartedServer } from "../instance-shell-BWh0JQuo.mjs";
4
+ import { c as StartedServer } from "../instance-shell-BUyYrKlu.mjs";
5
5
  import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-DEAMiPfH.mjs";
6
6
  import { H3 } from "h3";
7
7
  //#region src/adapters/dev.d.ts
8
- interface CreateDevServerOptions {
8
+ export interface CreateDevServerOptions {
9
9
  /** Bind host. Default: `def.cli?.host ?? 'localhost'`. */
10
10
  host?: string;
11
11
  /**
@@ -131,6 +131,6 @@ interface CreateDevServerOptions {
131
131
  * framework (commander, yargs, hand-rolled CAC). For the all-in-one
132
132
  * `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
133
133
  */
134
- declare function createDevServer(def: DevframeDefinition, options?: CreateDevServerOptions): Promise<StartedServer>;
134
+ export declare function createDevServer(def: DevframeDefinition, options?: CreateDevServerOptions): Promise<StartedServer>;
135
135
  //#endregion
136
- export { CreateDevServerOptions, type ResolveDevServerPortOptions, createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
136
+ export { type ResolveDevServerPortOptions, resolveDevServerPort, resolveMcpConnectionMeta };
@@ -1,3 +1,3 @@
1
1
  import { i as resolveDevServerPort, o as resolveMcpConnectionMeta } from "../_shared-U8D-xzrp.mjs";
2
- import { t as createDevServer } from "../dev-B32EVw5w.mjs";
2
+ import { t as createDevServer } from "../dev-SPZzBTrH.mjs";
3
3
  export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
@@ -1,6 +1,6 @@
1
1
  import { F as DevframeDefinition, o as DevframeNodeContext } from "../context-BBWPLDHh.mjs";
2
2
  //#region src/adapters/embedded.d.ts
3
- interface CreateEmbeddedOptions {
3
+ export interface CreateEmbeddedOptions {
4
4
  /** Target context the devframe is registered into. Required. */
5
5
  ctx: DevframeNodeContext;
6
6
  }
@@ -13,6 +13,5 @@ interface CreateEmbeddedOptions {
13
13
  * The host owns the mount path; when a hosted mount is needed the
14
14
  * effective default follows the hosted rule of `def.basePath ?? '/__<id>/'`.
15
15
  */
16
- declare function createEmbedded(d: DevframeDefinition, options: CreateEmbeddedOptions): Promise<void>;
17
- //#endregion
18
- export { CreateEmbeddedOptions, createEmbedded };
16
+ export declare function createEmbedded(d: DevframeDefinition, options: CreateEmbeddedOptions): Promise<void>;
17
+ //#endregion
@@ -1,13 +1,13 @@
1
1
  import { c as DevframeNodeRpcSessionMeta, l as DevframeRpcConnection, n as WsOriginRegistry } from "../ws-server-D2nv68Hg.mjs";
2
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-BBWPLDHh.mjs";
3
3
  import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
4
- import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-BWh0JQuo.mjs";
4
+ import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-BUyYrKlu.mjs";
5
5
  import { Buffer } from "node:buffer";
6
6
  import { IncomingMessage, Server, ServerResponse } from "node:http";
7
7
  import { Duplex } from "node:stream";
8
8
  import { H3 } from "h3";
9
9
  //#region src/adapters/initiate.d.ts
10
- interface InitDevframeOptions {
10
+ export interface InitDevframeOptions {
11
11
  /**
12
12
  * Mount base the handler answers under (e.g. `/__my-tool/`), required so
13
13
  * the mount path is explicit at the call site. A handler is by definition
@@ -137,7 +137,7 @@ interface InitDevframeOptions {
137
137
  */
138
138
  onPeerDisconnect?: (connection: DevframeRpcConnection, meta: DevframeNodeRpcSessionMeta) => void;
139
139
  }
140
- interface DevframeInstance {
140
+ export interface DevframeInstance {
141
141
  /**
142
142
  * The normalized mount base this instance answers under (leading and
143
143
  * trailing slash, e.g. `/__my-tool/`). Reference it when wiring the mount
@@ -198,14 +198,14 @@ interface DevframeInstance {
198
198
  *
199
199
  * @internal
200
200
  */
201
- interface DevframeInstanceInternals {
201
+ export interface DevframeInstanceInternals {
202
202
  /** The bound HTTP+WS server handle backing the side-car / shared-server WS tiers. */
203
203
  readonly started?: StartedServer;
204
204
  /** The resolved auth handler when the gate is active. */
205
205
  readonly authHandler?: DevframeAuthHandler;
206
206
  }
207
207
  /** @internal */
208
- declare function getInstanceInternals(handler: object): DevframeInstanceInternals;
208
+ export declare function getInstanceInternals(handler: object): DevframeInstanceInternals;
209
209
  /**
210
210
  * Serve a devframe through one framework-agnostic, web-standard handler:
211
211
  * the SPA, `__connection.json` discovery, the WebSocket RPC endpoint, the
@@ -223,6 +223,5 @@ declare function getInstanceInternals(handler: object): DevframeInstanceInternal
223
223
  * transport to an external server. `__connection.json` reflects whichever
224
224
  * combination is active.
225
225
  */
226
- declare function initDevframe(def: DevframeDefinition, options: InitDevframeOptions): DevframeInstance;
227
- //#endregion
228
- export { DevframeInstance, DevframeInstanceInternals, InitDevframeOptions, getInstanceInternals, initDevframe };
226
+ export declare function initDevframe(def: DevframeDefinition, options: InitDevframeOptions): DevframeInstance;
227
+ //#endregion
@@ -1,2 +1,2 @@
1
- import { n as getInstanceInternals, r as initDevframe } from "../dev-B32EVw5w.mjs";
1
+ import { n as getInstanceInternals, r as initDevframe } from "../dev-SPZzBTrH.mjs";
2
2
  export { getInstanceInternals, initDevframe };
@@ -33,7 +33,7 @@ interface McpServerHandle {
33
33
  * Build an MCP server over the agent surface of a devframe definition.
34
34
  * Currently supports `stdio` transport only.
35
35
  */
36
- declare function createMcpServer(definition: DevframeDefinition, options?: CreateMcpServerOptions): Promise<McpServerHandle>;
36
+ export declare function createMcpServer(definition: DevframeDefinition, options?: CreateMcpServerOptions): Promise<McpServerHandle>;
37
37
  //#endregion
38
38
  //#region src/adapters/mcp/fetch.d.ts
39
39
  interface CreateMcpFetchHandlerOptions {
@@ -97,7 +97,7 @@ interface McpFetchHandler {
97
97
  * calling (a missing/invalid credential gets `401` with a
98
98
  * `WWW-Authenticate: Bearer` challenge).
99
99
  */
100
- declare function createMcpFetchHandler(ctx: DevframeNodeContext, options: CreateMcpFetchHandlerOptions): McpFetchHandler;
100
+ export declare function createMcpFetchHandler(ctx: DevframeNodeContext, options: CreateMcpFetchHandlerOptions): McpFetchHandler;
101
101
  //#endregion
102
102
  //#region src/adapters/mcp/http.d.ts
103
103
  interface MountMcpHttpOptions extends CreateMcpFetchHandlerOptions {}
@@ -118,6 +118,6 @@ interface MountedMcpHttp {
118
118
  * falls through to the next handler" rule (which would otherwise hand the
119
119
  * request to the SPA static catch-all).
120
120
  */
121
- declare function mountMcpHttp(app: H3, ctx: DevframeNodeContext, path: string, options: MountMcpHttpOptions): MountedMcpHttp;
121
+ export declare function mountMcpHttp(app: H3, ctx: DevframeNodeContext, path: string, options: MountMcpHttpOptions): MountedMcpHttp;
122
122
  //#endregion
123
- export { type CreateMcpFetchHandlerOptions, type CreateMcpServerOptions, type McpFetchHandler, type McpServerHandle, type MountMcpHttpOptions, type MountedMcpHttp, createMcpFetchHandler, createMcpServer, mountMcpHttp };
123
+ export type { CreateMcpFetchHandlerOptions, CreateMcpServerOptions, McpFetchHandler, McpServerHandle, MountMcpHttpOptions, MountedMcpHttp };
@@ -3,7 +3,7 @@ import { t as DEVFRAME_EVENTS } from "../events-BV4Dj59a.mjs";
3
3
  import { t as isAllowedOrigin } from "../origin-DZit9g29.mjs";
4
4
  import { r as timingSafeEqual } from "../crypto-token-TVbGGFuj.mjs";
5
5
  import { t as diagnostics } from "../diagnostics-DZA6KQ_Z.mjs";
6
- import { t as createHostContext } from "../context-Bq27SDK-.mjs";
6
+ import { t as createHostContext } from "../context-Cdj9z9m2.mjs";
7
7
  import { t as toAgentToolName } from "../agent-tool-name-DGzeuWcO.mjs";
8
8
  import { join } from "pathe";
9
9
  import process from "node:process";
@@ -126,11 +126,8 @@ function returnToJsonSchema(schema) {
126
126
  */
127
127
  function argsToJsonSchema(args) {
128
128
  if (!args || args.length === 0) return {
129
- schema: {
130
- type: "object",
131
- properties: {}
132
- },
133
- unwrapped: false
129
+ type: "object",
130
+ properties: {}
134
131
  };
135
132
  const properties = {};
136
133
  const required = [];
@@ -140,13 +137,10 @@ function argsToJsonSchema(args) {
140
137
  required.push(key);
141
138
  }
142
139
  return {
143
- schema: {
144
- type: "object",
145
- properties,
146
- required,
147
- additionalProperties: false
148
- },
149
- unwrapped: false
140
+ type: "object",
141
+ properties,
142
+ required,
143
+ additionalProperties: false
150
144
  };
151
145
  }
152
146
  //#endregion
@@ -443,7 +437,7 @@ function projectTool(name, tool, ctx) {
443
437
  };
444
438
  }
445
439
  function computeInputSchema(tool, ctx) {
446
- if (tool.kind === "tool") return argsToJsonSchema(tool.args).schema;
440
+ if (tool.kind === "tool") return argsToJsonSchema(tool.args);
447
441
  if (tool.kind !== "rpc" || !tool.rpcName) return {
448
442
  type: "object",
449
443
  properties: {}
@@ -454,7 +448,7 @@ function computeInputSchema(tool, ctx) {
454
448
  properties: {}
455
449
  };
456
450
  const args = def.args;
457
- return argsToJsonSchema(args).schema;
451
+ return argsToJsonSchema(args);
458
452
  }
459
453
  function computeOutputSchema(tool, ctx) {
460
454
  if (tool.kind !== "rpc" || !tool.rpcName) return void 0;
@@ -4,6 +4,5 @@
4
4
  * CLI shells authors build with `createCac(definition)`. It hosts the
5
5
  * app-independent commands; today that is `connect`, the MCP connector.
6
6
  */
7
- declare function runDevframeCli(argv?: string[]): Promise<void>;
8
- //#endregion
9
- export { runDevframeCli };
7
+ export declare function runDevframeCli(argv?: string[]): Promise<void>;
8
+ //#endregion
@@ -5,7 +5,7 @@ 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";
7
7
  //#region src/client/connection.d.ts
8
- interface DevframeConnection {
8
+ export interface DevframeConnection {
9
9
  /** Server-advertised transport and serialization metadata. */
10
10
  connectionMeta: ConnectionMeta;
11
11
  /**
@@ -17,7 +17,7 @@ interface DevframeConnection {
17
17
  /** Previously issued bearer token, when the connection is already trusted. */
18
18
  authToken?: string;
19
19
  }
20
- interface SetupDevframeConnectionOptions {
20
+ export interface SetupDevframeConnectionOptions {
21
21
  /** Reuse a complete connection prepared in another viewer or JavaScript realm. */
22
22
  connection?: DevframeConnection;
23
23
  /** Use a pre-known descriptor while deriving its source URL from `baseURL`. */
@@ -32,18 +32,18 @@ interface SetupDevframeConnectionOptions {
32
32
  * the Devframe host. Returns `false` if the host did not provide an origin
33
33
  * registration token.
34
34
  */
35
- declare function registerDevframeViewerOrigin(connection: DevframeConnection, origin?: any): Promise<boolean>;
35
+ export declare function registerDevframeViewerOrigin(connection: DevframeConnection, origin?: any): Promise<boolean>;
36
36
  /**
37
37
  * Return connection information previously prepared in this window or an
38
38
  * accessible parent window.
39
39
  */
40
- declare function getDevframeConnection(): DevframeConnection | undefined;
40
+ export declare function getDevframeConnection(): DevframeConnection | undefined;
41
41
  /**
42
42
  * Prepare the connection information shared by a devframe client and external
43
43
  * viewers. Reuses an explicit or previously prepared connection before
44
44
  * fetching `__connection.json` from the configured base URLs.
45
45
  */
46
- declare function setupDevframeConnection(options?: SetupDevframeConnectionOptions): Promise<DevframeConnection>;
46
+ export declare function setupDevframeConnection(options?: SetupDevframeConnectionOptions): Promise<DevframeConnection>;
47
47
  /**
48
48
  * The connection lifecycle of a devframe client, as a single value a UI can
49
49
  * render from. Derived from the transport (WebSocket open/close/error) and the
@@ -64,21 +64,21 @@ declare function setupDevframeConnection(options?: SetupDevframeConnectionOption
64
64
  * A `static` backend has no live socket, so it reports `connected` for its
65
65
  * whole life.
66
66
  */
67
- type DevframeConnectionStatus = 'connecting' | 'connected' | 'unauthorized' | 'disconnected' | 'error';
67
+ export type DevframeConnectionStatus = 'connecting' | 'connected' | 'unauthorized' | 'disconnected' | 'error';
68
68
  /**
69
69
  * What kind of failure a {@link DevframeConnectionError} describes:
70
70
  * - `connection`: the transport dropped, errored, or never opened.
71
71
  * - `auth`: the server rejected trust for this client.
72
72
  * - `timeout`: a call exceeded its {@link DevframeRpcClientOptions.callTimeout}.
73
73
  */
74
- type DevframeConnectionErrorKind = 'connection' | 'auth' | 'timeout';
74
+ export type DevframeConnectionErrorKind = 'connection' | 'auth' | 'timeout';
75
75
  /**
76
76
  * The error rejected from `rpc.call(...)` (and carried on
77
77
  * `rpc.connectionError`) when a call cannot be served because the connection is
78
78
  * down, the client is unauthorized, or a call timed out. Its `kind` lets a UI
79
79
  * tailor its message and recovery affordance without string-matching.
80
80
  */
81
- declare class DevframeConnectionError extends Error {
81
+ export declare class DevframeConnectionError extends Error {
82
82
  name: string;
83
83
  readonly kind: DevframeConnectionErrorKind;
84
84
  constructor(kind: DevframeConnectionErrorKind, message: string, options?: {
@@ -90,14 +90,14 @@ declare class DevframeConnectionError extends Error {
90
90
  * the transport queues outgoing calls until the socket opens; the terminal
91
91
  * failure states short-circuit calls so a stuck socket never hangs the UI.
92
92
  */
93
- declare function isCallableStatus(status: DevframeConnectionStatus): boolean;
93
+ export declare function isCallableStatus(status: DevframeConnectionStatus): boolean;
94
94
  //#endregion
95
95
  //#region src/client/rpc-streaming.d.ts
96
- interface StreamingSubscribeOptions {
96
+ export interface StreamingSubscribeOptions {
97
97
  /** Maximum buffered chunks before the oldest is dropped. Default 256. */
98
98
  highWaterMark?: number;
99
99
  }
100
- interface RpcStreamingClientHost {
100
+ export interface RpcStreamingClientHost {
101
101
  /**
102
102
  * Subscribe to a server-side stream by channel + id. Returns a reader
103
103
  * that's both an `AsyncIterable<T>` (`for await`) and exposes
@@ -120,7 +120,7 @@ interface RpcStreamingClientHost {
120
120
  * registers the two `:chunk` / `:end` event handlers once, then per-stream
121
121
  * state lives in a `Map<streamKey, StreamReader>`.
122
122
  */
123
- declare function createRpcStreamingClientHost(rpc: DevframeRpcClient): RpcStreamingClientHost;
123
+ export declare function createRpcStreamingClientHost(rpc: DevframeRpcClient): RpcStreamingClientHost;
124
124
  //#endregion
125
125
  //#region src/client/scope.d.ts
126
126
  type AnyRpcFn = (...args: any[]) => any;
@@ -128,7 +128,7 @@ type AnyRpcFn = (...args: any[]) => any;
128
128
  * Client-side streaming host scoped to a namespace. Channel names are
129
129
  * auto-prefixed with `<namespace>:`.
130
130
  */
131
- interface DevframeScopedClientStreamingHost {
131
+ export interface DevframeScopedClientStreamingHost {
132
132
  subscribe: <T = unknown>(channel: string, id: string, options?: StreamingSubscribeOptions) => StreamReader<T>;
133
133
  upload: <T = unknown>(channel: string, id: string) => StreamSink<T>;
134
134
  }
@@ -137,7 +137,7 @@ interface DevframeScopedClientStreamingHost {
137
137
  * `client.scope('my-plugin').rpc`. IDs and keys you pass are
138
138
  * auto-namespaced with `my-plugin:`.
139
139
  */
140
- interface DevframeScopedClientRpc<NS extends string = string> {
140
+ export interface DevframeScopedClientRpc<NS extends string = string> {
141
141
  /** The namespace this surface is scoped to. */
142
142
  readonly namespace: NS;
143
143
  /**
@@ -176,7 +176,7 @@ interface DevframeScopedClientRpc<NS extends string = string> {
176
176
  * `client.scope('my-plugin')`. Replaces `rpc` with the auto-namespaced
177
177
  * surface and adds a top-level `settings` store.
178
178
  */
179
- interface DevframeScopedClientContext<NS extends string = string, Settings extends Record<string, any> = Record<string, any>> {
179
+ export interface DevframeScopedClientContext<NS extends string = string, Settings extends Record<string, any> = Record<string, any>> {
180
180
  /** The namespace this context is scoped to. */
181
181
  readonly namespace: NS;
182
182
  /** The underlying unscoped client. */
@@ -195,7 +195,7 @@ interface DevframeScopedClientContext<NS extends string = string, Settings exten
195
195
  * id, shared-state key, and streaming channel passed through the returned
196
196
  * `rpc` surface is auto-namespaced with `<namespace>:`.
197
197
  */
198
- declare function createScopedClientContext<NS extends string = string>(rpc: DevframeRpcClient, namespace: NS): DevframeScopedClientContext<NS>;
198
+ export declare function createScopedClientContext<NS extends string = string>(rpc: DevframeRpcClient, namespace: NS): DevframeScopedClientContext<NS>;
199
199
  //#endregion
200
200
  //#region src/client/rpc-services.d.ts
201
201
  /**
@@ -237,14 +237,14 @@ interface DevframeServicesClient {
237
237
  }
238
238
  //#endregion
239
239
  //#region src/client/rpc.d.ts
240
- interface DevframeRpcContext {
240
+ export interface DevframeRpcContext {
241
241
  /**
242
242
  * The RPC client to interact with the server
243
243
  */
244
244
  readonly rpc: DevframeRpcClient;
245
245
  }
246
- type DevframeClientRpcHost = RpcFunctionsCollector<DevframeRpcClientFunctions, DevframeRpcContext>;
247
- interface RpcClientEvents {
246
+ export type DevframeClientRpcHost = RpcFunctionsCollector<DevframeRpcClientFunctions, DevframeRpcContext>;
247
+ export interface RpcClientEvents {
248
248
  'rpc:is-trusted:updated': (isTrusted: boolean) => void;
249
249
  /**
250
250
  * The connection status changed. Carries the new status and the previous one
@@ -262,7 +262,7 @@ interface RpcClientEvents {
262
262
  */
263
263
  'rpc:error': (error: Error, method: string) => void;
264
264
  }
265
- interface DevframeRpcClientOptions extends SetupDevframeConnectionOptions {
265
+ export interface DevframeRpcClientOptions extends SetupDevframeConnectionOptions {
266
266
  /**
267
267
  * The auth token to use for the client
268
268
  */
@@ -311,6 +311,18 @@ interface DevframeRpcClientOptions extends SetupDevframeConnectionOptions {
311
311
  sseOptions?: Partial<SseRpcChannelOptions>;
312
312
  rpcOptions?: Partial<BirpcOptions<DevframeRpcServerFunctions, DevframeRpcClientFunctions, boolean>>;
313
313
  cacheOptions?: boolean | Partial<RpcCacheOptions>;
314
+ /**
315
+ * Mirror `agent`-flagged client RPC functions (functions registered on
316
+ * `rpc.client` with an `agent` field) onto the page's WebMCP model
317
+ * context (`document.modelContext` / `navigator.modelContext`) as
318
+ * callable tools, so in-page and browser-integrated agents can invoke
319
+ * them; see `registerWebMcpTools`. Applies only when the browser
320
+ * provides a model context. Set `false` to keep the browser side off
321
+ * the WebMCP surface.
322
+ *
323
+ * @default true
324
+ */
325
+ webmcp?: boolean;
314
326
  /**
315
327
  * Reject a pending `rpc.call(...)` if the server hasn't answered within this
316
328
  * many milliseconds, with a {@link DevframeConnectionError} of kind
@@ -320,10 +332,10 @@ interface DevframeRpcClientOptions extends SetupDevframeConnectionOptions {
320
332
  */
321
333
  callTimeout?: number;
322
334
  }
323
- type DevframeRpcClientCall = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$call'];
324
- type DevframeRpcClientCallEvent = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callEvent'];
325
- type DevframeRpcClientCallOptional = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callOptional'];
326
- interface DevframeRpcClient {
335
+ export type DevframeRpcClientCall = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$call'];
336
+ export type DevframeRpcClientCallEvent = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callEvent'];
337
+ export type DevframeRpcClientCallOptional = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callOptional'];
338
+ export interface DevframeRpcClient {
327
339
  /**
328
340
  * The events of the client
329
341
  */
@@ -446,7 +458,7 @@ interface DevframeRpcClient {
446
458
  */
447
459
  close?: () => void;
448
460
  }
449
- interface DevframeRpcClientMode {
461
+ export interface DevframeRpcClientMode {
450
462
  /**
451
463
  * The transport this mode speaks. Optional so a mode implemented before
452
464
  * this field existed (a custom transport, a hand-typed mock) still
@@ -477,8 +489,8 @@ interface DevframeRpcClientMode {
477
489
  * present; an explicit `'websocket'` / `'sse'` pins that transport and
478
490
  * throws when the server doesn't advertise it.
479
491
  */
480
- declare function resolveClientTransport(requested: 'auto' | 'websocket' | 'sse', meta: ConnectionMeta): 'websocket' | 'sse' | 'static';
481
- declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
492
+ export declare function resolveClientTransport(requested: 'auto' | 'websocket' | 'sse', meta: ConnectionMeta): 'websocket' | 'sse' | 'static';
493
+ export declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
482
494
  //#endregion
483
495
  //#region src/client/otp.d.ts
484
496
  /**
@@ -486,14 +498,14 @@ declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promi
486
498
  * fragment, without side effects. Returns `undefined` when the parameter is
487
499
  * absent.
488
500
  */
489
- declare function readOtpFromUrl(param?: string): string | undefined;
501
+ export declare function readOtpFromUrl(param?: string): string | undefined;
490
502
  /**
491
503
  * Read the one-time code from the page URL fragment and remove it from the
492
504
  * address bar (and the current history entry), so the single-use code isn't
493
505
  * left in the URL, browser history, or a `Referer`. Returns the code, or
494
506
  * `undefined` when absent.
495
507
  */
496
- declare function consumeOtpFromUrl(param?: string): string | undefined;
508
+ export declare function consumeOtpFromUrl(param?: string): string | undefined;
497
509
  /**
498
510
  * Consume a one-time code from the page URL (see {@link consumeOtpFromUrl}) and
499
511
  * exchange it for a token via the client. Resolves `true` when the client is
@@ -504,7 +516,7 @@ declare function consumeOtpFromUrl(param?: string): string | undefined;
504
516
  * authentication UI can disable `connectDevframe`'s built-in handling with
505
517
  * `otpParam: false` and call this (or {@link consumeOtpFromUrl}) themselves.
506
518
  */
507
- declare function authenticateWithUrlOtp(rpc: Pick<DevframeRpcClient, 'isTrusted' | 'requestTrustWithCode'>, options?: {
519
+ export declare function authenticateWithUrlOtp(rpc: Pick<DevframeRpcClient, 'isTrusted' | 'requestTrustWithCode'>, options?: {
508
520
  param?: string;
509
521
  }): Promise<boolean>;
510
522
  //#endregion
@@ -528,7 +540,7 @@ interface WsUrlLocation {
528
540
  * `port`/`host` (or a full `ws(s)://` URL string) opts into a cross-origin
529
541
  * endpoint, e.g. a side-car server on its own port.
530
542
  */
531
- declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUrl: string, loc: WsUrlLocation): string;
543
+ export declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUrl: string, loc: WsUrlLocation): string;
532
544
  //#endregion
533
545
  //#region src/client/rpc-sse.d.ts
534
546
  /**
@@ -539,16 +551,102 @@ declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUr
539
551
  * hostname), while an explicit `port`/`host` (or a full `http(s)://` URL
540
552
  * string) opts into a cross-origin endpoint.
541
553
  */
542
- declare function resolveSseUrl(sse: ConnectionMeta['sse'], metaBaseUrl: string, loc: WsUrlLocation): string;
554
+ export declare function resolveSseUrl(sse: ConnectionMeta['sse'], metaBaseUrl: string, loc: WsUrlLocation): string;
543
555
  //#endregion
544
556
  //#region src/client/settings.d.ts
545
557
  /**
546
558
  * Build the client-side `settings` surface for a scope namespace. Mirrors
547
559
  * the node-side stores over the shared-state sync protocol.
548
560
  */
549
- declare function createClientSettings<T extends Record<string, any> = Record<string, any>>(rpc: DevframeRpcClient, namespace: string): DevframeSettings<T>;
561
+ export declare function createClientSettings<T extends Record<string, any> = Record<string, any>>(rpc: DevframeRpcClient, namespace: string): DevframeSettings<T>;
562
+ //#endregion
563
+ //#region src/client/webmcp.d.ts
564
+ /**
565
+ * Result a WebMCP tool's `execute` resolves with; mirrors the MCP
566
+ * `CallToolResult` text shape the [WebMCP](https://github.com/webmachinelearning/webmcp)
567
+ * proposal adopts.
568
+ */
569
+ export interface WebMcpToolResult {
570
+ content: {
571
+ type: 'text';
572
+ text: string;
573
+ }[];
574
+ isError?: boolean;
575
+ }
576
+ /** A tool descriptor as passed to {@link WebMcpModelContext.registerTool}. */
577
+ export interface WebMcpToolDescriptor {
578
+ name: string;
579
+ description: string;
580
+ inputSchema?: unknown;
581
+ annotations?: {
582
+ title?: string;
583
+ readOnlyHint?: boolean;
584
+ destructiveHint?: boolean;
585
+ };
586
+ execute: (args: Record<string, unknown>) => Promise<WebMcpToolResult>;
587
+ }
588
+ /**
589
+ * A tool as reported by {@link WebMcpModelContext.getTools}: the
590
+ * serializable descriptor fields plus the registering `origin`. The
591
+ * browser may attach more members (e.g. the owner `window`); pass the
592
+ * object through unchanged to {@link WebMcpModelContext.executeTool}.
593
+ */
594
+ export interface WebMcpRegisteredTool {
595
+ name: string;
596
+ description?: string;
597
+ inputSchema?: unknown;
598
+ origin?: string;
599
+ }
600
+ /**
601
+ * Structural subset of the experimental WebMCP model context
602
+ * (`document.modelContext` / `navigator.modelContext`). The current draft
603
+ * unregisters a tool by aborting the passed `AbortSignal` and returns a
604
+ * promise; earlier drafts returned a handle with `unregister()`. Typed to
605
+ * accept both generations. `getTools` / `executeTool` are the draft's
606
+ * discovery/execution surface for in-page agents; absent on older drafts.
607
+ */
608
+ export interface WebMcpModelContext {
609
+ registerTool: (tool: WebMcpToolDescriptor, options?: {
610
+ signal?: AbortSignal;
611
+ }) => void | {
612
+ unregister?: () => void;
613
+ } | Promise<unknown>;
614
+ getTools?: (options?: {
615
+ fromOrigins?: string[];
616
+ }) => Promise<WebMcpRegisteredTool[]>;
617
+ /**
618
+ * The spec draft takes the args as a dictionary; Chromium's current
619
+ * build takes (and returns) JSON strings instead, hence the union.
620
+ */
621
+ executeTool?: (tool: WebMcpRegisteredTool, args: Record<string, unknown> | string, options?: {
622
+ signal?: AbortSignal;
623
+ }) => Promise<unknown>;
624
+ }
625
+ /**
626
+ * The page's WebMCP model context, when the browser (or a polyfill)
627
+ * provides one. Checks `document.modelContext` (current draft) first,
628
+ * then `navigator.modelContext` (earlier drafts and polyfills).
629
+ */
630
+ export declare function resolveWebMcpModelContext(): WebMcpModelContext | undefined;
631
+ export interface RegisterWebMcpToolsOptions {
632
+ /**
633
+ * Model context to register tools on. Defaults to the one the page
634
+ * provides (see {@link resolveWebMcpModelContext}); when neither is
635
+ * given, registration is a no-op.
636
+ */
637
+ modelContext?: WebMcpModelContext;
638
+ }
639
+ /**
640
+ * Mirror the `agent`-flagged RPC functions of a browser-side collector
641
+ * (`rpc.client`) onto the page's WebMCP model context as callable tools,
642
+ * using the same `agent` signature, wire names, and `arg0`/`arg1`/… input
643
+ * schema as the node-side MCP adapter. Functions without an `agent` field
644
+ * stay unexposed (default-deny), and the tool set follows later
645
+ * `register`/`update` calls. Returns a dispose that unregisters every tool.
646
+ */
647
+ export declare function registerWebMcpTools<LocalFunctions, SetupContext>(clientRpc: RpcFunctionsCollector<LocalFunctions, SetupContext>, options?: RegisterWebMcpToolsOptions): () => void;
550
648
  //#endregion
551
649
  //#region src/client/index.d.ts
552
- declare const connectDevframe: typeof getDevframeRpcClient;
650
+ export declare const connectDevframe: typeof getDevframeRpcClient;
553
651
  //#endregion
554
- export { DevframeClientRpcHost, DevframeConnection, DevframeConnectionError, DevframeConnectionErrorKind, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientCall, DevframeRpcClientCallEvent, DevframeRpcClientCallOptional, DevframeRpcClientMode, DevframeRpcClientOptions, DevframeRpcContext, DevframeScopedClientContext, DevframeScopedClientRpc, DevframeScopedClientStreamingHost, type DevframeServiceClientHandle, type DevframeServicesClient, RpcClientEvents, RpcStreamingClientHost, SetupDevframeConnectionOptions, StreamingSubscribeOptions, type WsUrlLocation, authenticateWithUrlOtp, connectDevframe, consumeOtpFromUrl, createClientSettings, createRpcStreamingClientHost, createScopedClientContext, getDevframeConnection, getDevframeRpcClient, isCallableStatus, readOtpFromUrl, registerDevframeViewerOrigin, resolveClientTransport, resolveSseUrl, resolveWsUrl, setupDevframeConnection };
652
+ export type { DevframeServiceClientHandle, DevframeServicesClient, WsUrlLocation };