devframe 0.9.12 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_shared-DEAMiPfH.d.mts → _shared-Bf2FcfJ4.d.mts} +1 -1
- package/dist/adapters/build.d.mts +5 -6
- package/dist/adapters/build.mjs +2 -2
- package/dist/adapters/cac.d.mts +5 -5
- package/dist/adapters/cac.mjs +1 -1
- package/dist/adapters/dev.d.mts +6 -6
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +4 -5
- package/dist/adapters/initiate.d.mts +10 -11
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +5 -5
- package/dist/adapters/mcp.mjs +1 -1
- package/dist/cli/main.d.mts +2 -3
- package/dist/client/index.d.mts +144 -36
- package/dist/client/index.mjs +223 -34
- package/dist/constants.d.mts +20 -21
- package/dist/{context-BBWPLDHh.d.mts → context-B7411Bem.d.mts} +25 -5
- package/dist/{context-_temOGDB.d.mts → context-CIsx_QnV.d.mts} +1 -1
- package/dist/{context-DwGevWqT.mjs → context-Cdj9z9m2.mjs} +9 -2
- package/dist/{dev-CZ1fu4J1.mjs → dev-DpfkCVqo.mjs} +2 -2
- package/dist/in-page-channel/index.d.mts +76 -38
- package/dist/in-page-channel/index.mjs +56 -22
- package/dist/{index-1ezCLThh.d.mts → index--pZ3fdAq.d.mts} +23 -3
- package/dist/index.d.mts +5 -5
- package/dist/{instance-shell-xuu6jg51.mjs → instance-shell-370Oee9K.mjs} +4 -12
- package/dist/{instance-shell-BUyYrKlu.d.mts → instance-shell-B-FE8NY5.d.mts} +5 -5
- package/dist/internal/index.d.mts +15 -15
- package/dist/internal/index.mjs +1 -1
- package/dist/node/auth.d.mts +3 -3
- package/dist/node/auth.mjs +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/index.d.mts +6 -6
- package/dist/node/index.mjs +1 -1
- package/dist/nostics-DD6gsDZA.mjs +108 -0
- package/dist/recipes/common-rpc-functions.d.mts +7 -8
- package/dist/recipes/interactive-auth.d.mts +32 -22
- package/dist/recipes/interactive-auth.mjs +58 -18
- package/dist/rpc/client.d.mts +2 -3
- package/dist/rpc/dump.d.mts +16 -17
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/server.d.mts +2 -3
- package/dist/rpc/transports/sse-server.d.mts +4 -5
- package/dist/rpc/transports/ws-bun.d.mts +6 -7
- package/dist/rpc/transports/ws-deno.d.mts +5 -6
- package/dist/{rpc-core-DiCr5etS.d.mts → rpc-core-D7WvbvK0.d.mts} +2 -2
- package/dist/{shared-state-CaxB1q0h.mjs → shared-state-eQVYHNqA.mjs} +4 -1
- package/dist/{state-Mwt6--el.mjs → state-W4wI6X5X.mjs} +14 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/utils/agent-tool-name.d.mts +2 -3
- package/dist/utils/colors.d.mts +4 -5
- package/dist/utils/crypto-token.d.mts +4 -5
- package/dist/utils/events.d.mts +3 -4
- package/dist/utils/hash.d.mts +2 -3
- package/dist/utils/launch-editor.d.mts +2 -3
- package/dist/utils/nanoid.d.mts +2 -3
- package/dist/utils/open.d.mts +2 -3
- package/dist/utils/remote-assets.d.mts +2 -3
- package/dist/utils/serve-static.d.mts +6 -7
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/shared-state.mjs +1 -1
- package/dist/utils/simple-schema.d.mts +17 -18
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/streaming-channel.mjs +4 -1
- package/dist/utils/structured-clone.d.mts +5 -6
- package/dist/utils/when.d.mts +6 -7
- package/dist/{write-BuLCrn9h.mjs → write-D2AJqVT8.mjs} +1 -1
- package/package.json +4 -4
|
@@ -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-
|
|
1
|
+
import { F as DevframeDefinition, G as McpAuthorization, I as DevframeDeploymentKind, q as McpSetting, t as ConnectionMeta, zt as DevframeAgentHost } from "./context-B7411Bem.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,7 +1,7 @@
|
|
|
1
|
-
import { F as DevframeDefinition, V as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-
|
|
1
|
+
import { F as DevframeDefinition, V as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-B7411Bem.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
|
package/dist/adapters/build.mjs
CHANGED
|
@@ -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-
|
|
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-
|
|
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";
|
package/dist/adapters/cac.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Dt as InferCliFlags, Et as CliFlagsSchema, F as DevframeDefinition, Ot as defineCliFlags, kt as parseCliFlags, q as McpSetting } from "../context-
|
|
1
|
+
import { Dt as InferCliFlags, Et as CliFlagsSchema, F as DevframeDefinition, Ot as defineCliFlags, kt as parseCliFlags, q as McpSetting } from "../context-B7411Bem.mjs";
|
|
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 {
|
|
51
|
+
export { type CliFlagsSchema, type InferCliFlags, defineCliFlags, parseCliFlags };
|
package/dist/adapters/cac.mjs
CHANGED
|
@@ -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-
|
|
4
|
+
import { t as createDevServer } from "../dev-DpfkCVqo.mjs";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import cac$1 from "cac";
|
|
7
7
|
//#region src/adapters/flags.ts
|
package/dist/adapters/dev.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
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-
|
|
2
|
+
import { F as DevframeDefinition, Tt as DevframeAuthHandler, U as DevframeSseOptions, W as DevframeWsOptions, q as McpSetting, s as DevframeNodeRpcSession } from "../context-B7411Bem.mjs";
|
|
3
3
|
import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
|
|
4
|
-
import { c as StartedServer } from "../instance-shell-
|
|
5
|
-
import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-
|
|
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";
|
|
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 {
|
|
136
|
+
export { type ResolveDevServerPortOptions, resolveDevServerPort, resolveMcpConnectionMeta };
|
package/dist/adapters/dev.mjs
CHANGED
|
@@ -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-
|
|
2
|
+
import { t as createDevServer } from "../dev-DpfkCVqo.mjs";
|
|
3
3
|
export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as DevframeDefinition, o as DevframeNodeContext } from "../context-
|
|
1
|
+
import { F as DevframeDefinition, o as DevframeNodeContext } from "../context-B7411Bem.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
|
-
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-
|
|
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";
|
|
3
3
|
import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
|
|
4
|
-
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-
|
|
4
|
+
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-B-FE8NY5.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
|
|
@@ -63,8 +63,8 @@ interface InitDevframeOptions {
|
|
|
63
63
|
* Authentication for the RPC endpoint. A handler mounted inside an app
|
|
64
64
|
* server is reachable by anything that can open its socket, so it **gates
|
|
65
65
|
* by default**: when unset (or `true`), devframe's interactive OTP handler
|
|
66
|
-
* is wired and its code/link banner prints
|
|
67
|
-
*
|
|
66
|
+
* is wired and its code/link banner prints when an untrusted client asks
|
|
67
|
+
* for a code (the client's `requestAuthCode()`). Pass a
|
|
68
68
|
* {@link DevframeAuthHandler} for a custom scheme, or `false` to opt out
|
|
69
69
|
* for a single-user localhost setup that owns the trust boundary another
|
|
70
70
|
* way. Ignored for the `ws.url` tier, since the server behind that URL owns auth.
|
|
@@ -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-
|
|
1
|
+
import { n as getInstanceInternals, r as initDevframe } from "../dev-DpfkCVqo.mjs";
|
|
2
2
|
export { getInstanceInternals, initDevframe };
|
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as DevframeDefinition, G as McpAuthorization, o as DevframeNodeContext } from "../context-
|
|
1
|
+
import { F as DevframeDefinition, G as McpAuthorization, o as DevframeNodeContext } from "../context-B7411Bem.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
import "@modelcontextprotocol/server";
|
|
4
4
|
//#region src/adapters/mcp/build-server.d.ts
|
|
@@ -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 {
|
|
123
|
+
export type { CreateMcpFetchHandlerOptions, CreateMcpServerOptions, McpFetchHandler, McpServerHandle, MountMcpHttpOptions, MountedMcpHttp };
|
package/dist/adapters/mcp.mjs
CHANGED
|
@@ -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-
|
|
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";
|
package/dist/cli/main.d.mts
CHANGED
|
@@ -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
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
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";
|
|
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";
|
|
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
|
*/
|
|
@@ -382,6 +394,15 @@ interface DevframeRpcClient {
|
|
|
382
394
|
* authenticated.
|
|
383
395
|
*/
|
|
384
396
|
requestTrustWithCode: (code: string) => Promise<boolean>;
|
|
397
|
+
/**
|
|
398
|
+
* Ask the server to print its one-time code banner in the terminal, e.g.
|
|
399
|
+
* when a custom auth UI is shown. Pass `reissue: true` to rotate the code
|
|
400
|
+
* first (a "re-issue" button), guaranteeing a freshly-valid code; without
|
|
401
|
+
* it the server prints each code at most once.
|
|
402
|
+
*/
|
|
403
|
+
requestAuthCode: (options?: {
|
|
404
|
+
reissue?: boolean;
|
|
405
|
+
}) => Promise<void>;
|
|
385
406
|
/**
|
|
386
407
|
* Call a RPC function on the server
|
|
387
408
|
*/
|
|
@@ -446,7 +467,7 @@ interface DevframeRpcClient {
|
|
|
446
467
|
*/
|
|
447
468
|
close?: () => void;
|
|
448
469
|
}
|
|
449
|
-
interface DevframeRpcClientMode {
|
|
470
|
+
export interface DevframeRpcClientMode {
|
|
450
471
|
/**
|
|
451
472
|
* The transport this mode speaks. Optional so a mode implemented before
|
|
452
473
|
* this field existed (a custom transport, a hand-typed mock) still
|
|
@@ -464,6 +485,7 @@ interface DevframeRpcClientMode {
|
|
|
464
485
|
* token on success (for the caller to persist), or `null` on failure.
|
|
465
486
|
*/
|
|
466
487
|
requestTrustWithCode: (code: string) => Promise<string | null>;
|
|
488
|
+
requestAuthCode: DevframeRpcClient['requestAuthCode'];
|
|
467
489
|
call: DevframeRpcClient['call'];
|
|
468
490
|
callEvent: DevframeRpcClient['callEvent'];
|
|
469
491
|
callOptional: DevframeRpcClient['callOptional'];
|
|
@@ -477,8 +499,8 @@ interface DevframeRpcClientMode {
|
|
|
477
499
|
* present; an explicit `'websocket'` / `'sse'` pins that transport and
|
|
478
500
|
* throws when the server doesn't advertise it.
|
|
479
501
|
*/
|
|
480
|
-
declare function resolveClientTransport(requested: 'auto' | 'websocket' | 'sse', meta: ConnectionMeta): 'websocket' | 'sse' | 'static';
|
|
481
|
-
declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
|
|
502
|
+
export declare function resolveClientTransport(requested: 'auto' | 'websocket' | 'sse', meta: ConnectionMeta): 'websocket' | 'sse' | 'static';
|
|
503
|
+
export declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
|
|
482
504
|
//#endregion
|
|
483
505
|
//#region src/client/otp.d.ts
|
|
484
506
|
/**
|
|
@@ -486,14 +508,14 @@ declare function getDevframeRpcClient(options?: DevframeRpcClientOptions): Promi
|
|
|
486
508
|
* fragment, without side effects. Returns `undefined` when the parameter is
|
|
487
509
|
* absent.
|
|
488
510
|
*/
|
|
489
|
-
declare function readOtpFromUrl(param?: string): string | undefined;
|
|
511
|
+
export declare function readOtpFromUrl(param?: string): string | undefined;
|
|
490
512
|
/**
|
|
491
513
|
* Read the one-time code from the page URL fragment and remove it from the
|
|
492
514
|
* address bar (and the current history entry), so the single-use code isn't
|
|
493
515
|
* left in the URL, browser history, or a `Referer`. Returns the code, or
|
|
494
516
|
* `undefined` when absent.
|
|
495
517
|
*/
|
|
496
|
-
declare function consumeOtpFromUrl(param?: string): string | undefined;
|
|
518
|
+
export declare function consumeOtpFromUrl(param?: string): string | undefined;
|
|
497
519
|
/**
|
|
498
520
|
* Consume a one-time code from the page URL (see {@link consumeOtpFromUrl}) and
|
|
499
521
|
* exchange it for a token via the client. Resolves `true` when the client is
|
|
@@ -504,7 +526,7 @@ declare function consumeOtpFromUrl(param?: string): string | undefined;
|
|
|
504
526
|
* authentication UI can disable `connectDevframe`'s built-in handling with
|
|
505
527
|
* `otpParam: false` and call this (or {@link consumeOtpFromUrl}) themselves.
|
|
506
528
|
*/
|
|
507
|
-
declare function authenticateWithUrlOtp(rpc: Pick<DevframeRpcClient, 'isTrusted' | 'requestTrustWithCode'>, options?: {
|
|
529
|
+
export declare function authenticateWithUrlOtp(rpc: Pick<DevframeRpcClient, 'isTrusted' | 'requestTrustWithCode'>, options?: {
|
|
508
530
|
param?: string;
|
|
509
531
|
}): Promise<boolean>;
|
|
510
532
|
//#endregion
|
|
@@ -528,7 +550,7 @@ interface WsUrlLocation {
|
|
|
528
550
|
* `port`/`host` (or a full `ws(s)://` URL string) opts into a cross-origin
|
|
529
551
|
* endpoint, e.g. a side-car server on its own port.
|
|
530
552
|
*/
|
|
531
|
-
declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUrl: string, loc: WsUrlLocation): string;
|
|
553
|
+
export declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUrl: string, loc: WsUrlLocation): string;
|
|
532
554
|
//#endregion
|
|
533
555
|
//#region src/client/rpc-sse.d.ts
|
|
534
556
|
/**
|
|
@@ -539,16 +561,102 @@ declare function resolveWsUrl(websocket: ConnectionMeta['websocket'], metaBaseUr
|
|
|
539
561
|
* hostname), while an explicit `port`/`host` (or a full `http(s)://` URL
|
|
540
562
|
* string) opts into a cross-origin endpoint.
|
|
541
563
|
*/
|
|
542
|
-
declare function resolveSseUrl(sse: ConnectionMeta['sse'], metaBaseUrl: string, loc: WsUrlLocation): string;
|
|
564
|
+
export declare function resolveSseUrl(sse: ConnectionMeta['sse'], metaBaseUrl: string, loc: WsUrlLocation): string;
|
|
543
565
|
//#endregion
|
|
544
566
|
//#region src/client/settings.d.ts
|
|
545
567
|
/**
|
|
546
568
|
* Build the client-side `settings` surface for a scope namespace. Mirrors
|
|
547
569
|
* the node-side stores over the shared-state sync protocol.
|
|
548
570
|
*/
|
|
549
|
-
declare function createClientSettings<T extends Record<string, any> = Record<string, any>>(rpc: DevframeRpcClient, namespace: string): DevframeSettings<T>;
|
|
571
|
+
export declare function createClientSettings<T extends Record<string, any> = Record<string, any>>(rpc: DevframeRpcClient, namespace: string): DevframeSettings<T>;
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/client/webmcp.d.ts
|
|
574
|
+
/**
|
|
575
|
+
* Result a WebMCP tool's `execute` resolves with; mirrors the MCP
|
|
576
|
+
* `CallToolResult` text shape the [WebMCP](https://github.com/webmachinelearning/webmcp)
|
|
577
|
+
* proposal adopts.
|
|
578
|
+
*/
|
|
579
|
+
export interface WebMcpToolResult {
|
|
580
|
+
content: {
|
|
581
|
+
type: 'text';
|
|
582
|
+
text: string;
|
|
583
|
+
}[];
|
|
584
|
+
isError?: boolean;
|
|
585
|
+
}
|
|
586
|
+
/** A tool descriptor as passed to {@link WebMcpModelContext.registerTool}. */
|
|
587
|
+
export interface WebMcpToolDescriptor {
|
|
588
|
+
name: string;
|
|
589
|
+
description: string;
|
|
590
|
+
inputSchema?: unknown;
|
|
591
|
+
annotations?: {
|
|
592
|
+
title?: string;
|
|
593
|
+
readOnlyHint?: boolean;
|
|
594
|
+
destructiveHint?: boolean;
|
|
595
|
+
};
|
|
596
|
+
execute: (args: Record<string, unknown>) => Promise<WebMcpToolResult>;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* A tool as reported by {@link WebMcpModelContext.getTools}: the
|
|
600
|
+
* serializable descriptor fields plus the registering `origin`. The
|
|
601
|
+
* browser may attach more members (e.g. the owner `window`); pass the
|
|
602
|
+
* object through unchanged to {@link WebMcpModelContext.executeTool}.
|
|
603
|
+
*/
|
|
604
|
+
export interface WebMcpRegisteredTool {
|
|
605
|
+
name: string;
|
|
606
|
+
description?: string;
|
|
607
|
+
inputSchema?: unknown;
|
|
608
|
+
origin?: string;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Structural subset of the experimental WebMCP model context
|
|
612
|
+
* (`document.modelContext` / `navigator.modelContext`). The current draft
|
|
613
|
+
* unregisters a tool by aborting the passed `AbortSignal` and returns a
|
|
614
|
+
* promise; earlier drafts returned a handle with `unregister()`. Typed to
|
|
615
|
+
* accept both generations. `getTools` / `executeTool` are the draft's
|
|
616
|
+
* discovery/execution surface for in-page agents; absent on older drafts.
|
|
617
|
+
*/
|
|
618
|
+
export interface WebMcpModelContext {
|
|
619
|
+
registerTool: (tool: WebMcpToolDescriptor, options?: {
|
|
620
|
+
signal?: AbortSignal;
|
|
621
|
+
}) => void | {
|
|
622
|
+
unregister?: () => void;
|
|
623
|
+
} | Promise<unknown>;
|
|
624
|
+
getTools?: (options?: {
|
|
625
|
+
fromOrigins?: string[];
|
|
626
|
+
}) => Promise<WebMcpRegisteredTool[]>;
|
|
627
|
+
/**
|
|
628
|
+
* The spec draft takes the args as a dictionary; Chromium's current
|
|
629
|
+
* build takes (and returns) JSON strings instead, hence the union.
|
|
630
|
+
*/
|
|
631
|
+
executeTool?: (tool: WebMcpRegisteredTool, args: Record<string, unknown> | string, options?: {
|
|
632
|
+
signal?: AbortSignal;
|
|
633
|
+
}) => Promise<unknown>;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* The page's WebMCP model context, when the browser (or a polyfill)
|
|
637
|
+
* provides one. Checks `document.modelContext` (current draft) first,
|
|
638
|
+
* then `navigator.modelContext` (earlier drafts and polyfills).
|
|
639
|
+
*/
|
|
640
|
+
export declare function resolveWebMcpModelContext(): WebMcpModelContext | undefined;
|
|
641
|
+
export interface RegisterWebMcpToolsOptions {
|
|
642
|
+
/**
|
|
643
|
+
* Model context to register tools on. Defaults to the one the page
|
|
644
|
+
* provides (see {@link resolveWebMcpModelContext}); when neither is
|
|
645
|
+
* given, registration is a no-op.
|
|
646
|
+
*/
|
|
647
|
+
modelContext?: WebMcpModelContext;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Mirror the `agent`-flagged RPC functions of a browser-side collector
|
|
651
|
+
* (`rpc.client`) onto the page's WebMCP model context as callable tools,
|
|
652
|
+
* using the same `agent` signature, wire names, and `arg0`/`arg1`/… input
|
|
653
|
+
* schema as the node-side MCP adapter. Functions without an `agent` field
|
|
654
|
+
* stay unexposed (default-deny), and the tool set follows later
|
|
655
|
+
* `register`/`update` calls. Returns a dispose that unregisters every tool.
|
|
656
|
+
*/
|
|
657
|
+
export declare function registerWebMcpTools<LocalFunctions, SetupContext>(clientRpc: RpcFunctionsCollector<LocalFunctions, SetupContext>, options?: RegisterWebMcpToolsOptions): () => void;
|
|
550
658
|
//#endregion
|
|
551
659
|
//#region src/client/index.d.ts
|
|
552
|
-
declare const connectDevframe: typeof getDevframeRpcClient;
|
|
660
|
+
export declare const connectDevframe: typeof getDevframeRpcClient;
|
|
553
661
|
//#endregion
|
|
554
|
-
export {
|
|
662
|
+
export type { DevframeServiceClientHandle, DevframeServicesClient, WsUrlLocation };
|