devframe 0.10.0 → 0.10.1
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-Dy1UBMUN.d.mts → _shared-D1ebaX_J.d.mts} +2 -2
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/build.mjs +1 -1
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +1 -1
- package/dist/adapters/dev.d.mts +3 -3
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +2 -2
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +2 -2
- package/dist/{agentic-D4QQQUjE.d.mts → agentic-DLqHMOyN.d.mts} +1 -1
- package/dist/browser-agent-Pu-FLk6I.mjs +26 -0
- package/dist/browser-agent-rpc-BXhoSh1z.mjs +70 -0
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +11 -85
- package/dist/{context-CTAxz9ec.d.mts → context--tVkJw3W.d.mts} +19 -0
- package/dist/{context-C141q8H4.mjs → context-BqpgC5tq.mjs} +51 -1
- package/dist/{context-B4BKPuaa.d.mts → context-D3qBv0IX.d.mts} +1 -1
- package/dist/{dev-DM1mIlgi.mjs → dev-BTbLJekh.mjs} +1 -1
- package/dist/{host-agent-ZSKgzMVu.mjs → host-agent-mIbQ6Qi5.mjs} +12 -6
- package/dist/in-page-channel/index.d.mts +16 -7
- package/dist/in-page-channel/index.mjs +42 -11
- package/dist/{index-CcPSKbxb.d.mts → index-D-2IdY1I.d.mts} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/{instance-shell-DOZSxst6.d.mts → instance-shell-CXnpSuK7.d.mts} +2 -2
- package/dist/internal/index.d.mts +5 -5
- package/dist/internal/index.mjs +1 -1
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/rpc/transports/ws-bun.d.mts +1 -1
- package/dist/rpc/transports/ws-deno.d.mts +1 -1
- package/dist/{rpc-core-rLrwFEcw.d.mts → rpc-core-B6n9MQsc.d.mts} +2 -2
- package/dist/{dist-Bw3EbMj4.mjs → tool-input-BAQXvvqL.mjs} +89 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as DevframeDefinition, Q as McpSetting, V as DevframeDeploymentKind, Wt as DevframeAgentHost, X as McpAuthorization, t as ConnectionMeta } from "./context
|
|
2
|
-
import { t as AgenticMcpModule } from "./agentic-
|
|
1
|
+
import { B as DevframeDefinition, Q as McpSetting, V as DevframeDeploymentKind, Wt as DevframeAgentHost, X as McpAuthorization, t as ConnectionMeta } from "./context--tVkJw3W.mjs";
|
|
2
|
+
import { t as AgenticMcpModule } from "./agentic-DLqHMOyN.mjs";
|
|
3
3
|
//#region src/adapters/_shared.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Resolve the mount base path for a devframe's SPA. Hosted adapters
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DevframeDefinition, K as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context
|
|
1
|
+
import { B as DevframeDefinition, K as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context--tVkJw3W.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 {
|
package/dist/adapters/build.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { s as colors } from "../nostics-D0PvLZsn.mjs";
|
|
|
2
2
|
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
|
|
3
3
|
import { n as collectStaticRpcDump, t as writeStaticRpcDump } from "../write-DoXJzGUH.mjs";
|
|
4
4
|
import { t as diagnostics } from "../diagnostics-Cx4_VjlG.mjs";
|
|
5
|
-
import { t as createHostContext } from "../context-
|
|
5
|
+
import { t as createHostContext } from "../context-BqpgC5tq.mjs";
|
|
6
6
|
import { t as resolveStaticAssetsSource } from "../remote-assets-B9MeWmW6.mjs";
|
|
7
7
|
import { t as createH3DevframeHost } from "../host-h3-BROI6SQ4.mjs";
|
|
8
8
|
import fs from "node:fs/promises";
|
package/dist/adapters/cac.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DevframeDefinition, Mt as InferCliFlags, Nt as defineCliFlags, Pt as parseCliFlags, Q as McpSetting, jt as CliFlagsSchema } from "../context
|
|
1
|
+
import { B as DevframeDefinition, Mt as InferCliFlags, Nt as defineCliFlags, Pt as parseCliFlags, Q as McpSetting, jt as CliFlagsSchema } from "../context--tVkJw3W.mjs";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
//#region src/adapters/cac.d.ts
|
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 importAgenticMcp } from "../_shared-B2PZsp-J.mjs";
|
|
3
3
|
import { createBuild } from "./build.mjs";
|
|
4
|
-
import { t as createDevServer } from "../dev-
|
|
4
|
+
import { t as createDevServer } from "../dev-BTbLJekh.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,9 +1,9 @@
|
|
|
1
|
-
import { At as DevframeAuthHandler, B as DevframeDefinition, J as DevframeSseOptions, Q as McpSetting, Y as DevframeWsOptions, s as DevframeNodeRpcSession } from "../context
|
|
1
|
+
import { At as DevframeAuthHandler, B as DevframeDefinition, J as DevframeSseOptions, Q as McpSetting, Y as DevframeWsOptions, s as DevframeNodeRpcSession } from "../context--tVkJw3W.mjs";
|
|
2
2
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
|
|
3
3
|
import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
|
|
4
4
|
import { n as WsOriginRegistry } from "../ws-server-y2R76aSW.mjs";
|
|
5
|
-
import { c as StartedServer } from "../instance-shell-
|
|
6
|
-
import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-
|
|
5
|
+
import { c as StartedServer } from "../instance-shell-CXnpSuK7.mjs";
|
|
6
|
+
import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-D1ebaX_J.mjs";
|
|
7
7
|
import { H3 } from "h3";
|
|
8
8
|
//#region src/adapters/dev.d.ts
|
|
9
9
|
export interface CreateDevServerOptions {
|
package/dist/adapters/dev.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { i as resolveDevServerPort, o as resolveMcpConnectionMeta } from "../_shared-B2PZsp-J.mjs";
|
|
2
|
-
import { t as createDevServer } from "../dev-
|
|
2
|
+
import { t as createDevServer } from "../dev-BTbLJekh.mjs";
|
|
3
3
|
export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DevframeDefinition, o as DevframeNodeContext } from "../context
|
|
1
|
+
import { B as DevframeDefinition, o as DevframeNodeContext } from "../context--tVkJw3W.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,8 +1,8 @@
|
|
|
1
|
-
import { At as DevframeAuthHandler, B as DevframeDefinition, Dt as DevframeStorageScope, J as DevframeSseOptions, Q as McpSetting, Y as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta } from "../context
|
|
1
|
+
import { At as DevframeAuthHandler, B as DevframeDefinition, Dt as DevframeStorageScope, J as DevframeSseOptions, Q as McpSetting, Y as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta } from "../context--tVkJw3W.mjs";
|
|
2
2
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "../session-r6PDixP6.mjs";
|
|
3
3
|
import { o as StaticAssetsSource } from "../remote-assets-eBvSKZMS.mjs";
|
|
4
4
|
import { n as WsOriginRegistry } from "../ws-server-y2R76aSW.mjs";
|
|
5
|
-
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-
|
|
5
|
+
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-CXnpSuK7.mjs";
|
|
6
6
|
import { H3 } from "h3";
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
8
8
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getInstanceInternals, r as initDevframe } from "../dev-
|
|
1
|
+
import { n as getInstanceInternals, r as initDevframe } from "../dev-BTbLJekh.mjs";
|
|
2
2
|
export { getInstanceInternals, initDevframe };
|
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as CreateMcpServerOptions, I as McpConnectionInfo, L as McpFetchHandler, P as CreateMcpFetchHandlerOptions, R as McpServerHandle } from "../context
|
|
2
|
-
import { n as MountMcpHttpOptions, r as MountedMcpHttp } from "../agentic-
|
|
1
|
+
import { F as CreateMcpServerOptions, I as McpConnectionInfo, L as McpFetchHandler, P as CreateMcpFetchHandlerOptions, R as McpServerHandle } from "../context--tVkJw3W.mjs";
|
|
2
|
+
import { n as MountMcpHttpOptions, r as MountedMcpHttp } from "../agentic-DLqHMOyN.mjs";
|
|
3
3
|
import { createMcpFetchHandler, createMcpServer, mountMcpHttp } from "@devframes/agentic/mcp";
|
|
4
4
|
export { type CreateMcpFetchHandlerOptions, type CreateMcpServerOptions, type McpConnectionInfo, type McpFetchHandler, type McpServerHandle, type MountMcpHttpOptions, type MountedMcpHttp, createMcpFetchHandler, createMcpServer, mountMcpHttp };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as DevframeDefinition, F as CreateMcpServerOptions, L as McpFetchHandler, P as CreateMcpFetchHandlerOptions, R as McpServerHandle, o as DevframeNodeContext } from "./context
|
|
1
|
+
import { B as DevframeDefinition, F as CreateMcpServerOptions, L as McpFetchHandler, P as CreateMcpFetchHandlerOptions, R as McpServerHandle, o as DevframeNodeContext } from "./context--tVkJw3W.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
//#region src/node/agentic.d.ts
|
|
4
4
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/client/browser-agent.ts
|
|
2
|
+
const REGISTRY_KEY = Symbol.for("devframe:browser-agent-registry");
|
|
3
|
+
const { tools, listeners } = globalThis[REGISTRY_KEY] ??= {
|
|
4
|
+
tools: /* @__PURE__ */ new Map(),
|
|
5
|
+
listeners: /* @__PURE__ */ new Set()
|
|
6
|
+
};
|
|
7
|
+
function notifyChanged() {
|
|
8
|
+
for (const listener of listeners) listener();
|
|
9
|
+
}
|
|
10
|
+
function registerBrowserAgentTool(tool) {
|
|
11
|
+
const key = Symbol(tool.id);
|
|
12
|
+
tools.set(key, tool);
|
|
13
|
+
notifyChanged();
|
|
14
|
+
return () => {
|
|
15
|
+
if (tools.delete(key)) notifyChanged();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function listBrowserAgentTools() {
|
|
19
|
+
return [...tools.values()];
|
|
20
|
+
}
|
|
21
|
+
function onBrowserAgentToolsChanged(listener) {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => listeners.delete(listener);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { onBrowserAgentToolsChanged as n, registerBrowserAgentTool as r, listBrowserAgentTools as t };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { nanoid } from "./utils/nanoid.mjs";
|
|
2
|
+
import { n as onBrowserAgentToolsChanged, t as listBrowserAgentTools } from "./browser-agent-Pu-FLk6I.mjs";
|
|
3
|
+
//#region src/client/client-id.ts
|
|
4
|
+
const CLIENT_ID_STORAGE_KEY = "devframe:client-id";
|
|
5
|
+
let memoryClientId;
|
|
6
|
+
/**
|
|
7
|
+
* This browser tab's stable client id: one nanoid per tab, persisted in
|
|
8
|
+
* `sessionStorage` so it survives page reloads and RPC reconnects. The node
|
|
9
|
+
* side uses it to tell connected tabs apart across reconnects (see #394).
|
|
10
|
+
*
|
|
11
|
+
* Tab duplication copies `sessionStorage`, so two tabs can briefly share an id
|
|
12
|
+
* until per-tab disambiguation lands with the wider tab-metadata work.
|
|
13
|
+
*/
|
|
14
|
+
function resolveClientId(win = globalThis.window) {
|
|
15
|
+
try {
|
|
16
|
+
const storage = win?.sessionStorage;
|
|
17
|
+
if (storage) {
|
|
18
|
+
let id = storage.getItem(CLIENT_ID_STORAGE_KEY);
|
|
19
|
+
if (!id) {
|
|
20
|
+
id = nanoid();
|
|
21
|
+
storage.setItem(CLIENT_ID_STORAGE_KEY, id);
|
|
22
|
+
}
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
} catch {}
|
|
26
|
+
memoryClientId ??= nanoid();
|
|
27
|
+
return memoryClientId;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/client/browser-agent-rpc.ts
|
|
31
|
+
/** Mirror this document's browser-agent registry over its existing RPC connection. */
|
|
32
|
+
function setupBrowserAgentRpcBridge(rpc) {
|
|
33
|
+
rpc.client.register({
|
|
34
|
+
name: "devframe:agent:invoke-client-tool",
|
|
35
|
+
type: "action",
|
|
36
|
+
jsonSerializable: true,
|
|
37
|
+
handler: async (id, args) => {
|
|
38
|
+
const tool = listBrowserAgentTools().find((tool) => tool.id === id);
|
|
39
|
+
if (!tool) throw new Error(`[devframe/agent] browser tool "${id}" not found`);
|
|
40
|
+
return await tool.invoke(args);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
let queued = false;
|
|
44
|
+
let disposed = false;
|
|
45
|
+
let lastSyncedCount = 0;
|
|
46
|
+
const sync = () => {
|
|
47
|
+
if (queued || disposed) return;
|
|
48
|
+
queued = true;
|
|
49
|
+
queueMicrotask(async () => {
|
|
50
|
+
queued = false;
|
|
51
|
+
if (disposed) return;
|
|
52
|
+
const manifests = listBrowserAgentTools().map(({ invoke: _, ...manifest }) => manifest);
|
|
53
|
+
if (manifests.length === 0 && lastSyncedCount === 0) return;
|
|
54
|
+
lastSyncedCount = manifests.length;
|
|
55
|
+
await rpc.callOptional("devframe:agent:sync-client-tools", resolveClientId(), manifests).catch(() => {});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const stopTools = onBrowserAgentToolsChanged(sync);
|
|
59
|
+
const stopConnection = rpc.events.on("connection:status", (status) => {
|
|
60
|
+
if (status === "connected") sync();
|
|
61
|
+
});
|
|
62
|
+
sync();
|
|
63
|
+
return () => {
|
|
64
|
+
disposed = true;
|
|
65
|
+
stopTools();
|
|
66
|
+
stopConnection();
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { setupBrowserAgentRpcBridge };
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as BirpcReturn, r as BirpcOptions } from "../index-Bia1vKjL.mjs";
|
|
2
2
|
import { f as RpcCacheManager, p as RpcCacheOptions } from "../index-DuEm0sDH.mjs";
|
|
3
3
|
import { h as RpcFunctionDefinition, w as RpcFunctionsCollector } from "../types-BmDbfHCx.mjs";
|
|
4
|
-
import { Ct as DevframeRpcClientFunctions, Kt as EventEmitter, at as DevframeServiceScopeOf, b as StreamSink, bt as ScopedSharedStates, d as RpcSharedStateHost, k as SharedState, lt as DevframeServicesState, pt as DevframeSettings, rt as DevframeServiceMeta, t as ConnectionMeta, u as RpcSharedStateGetOptions, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, y as StreamReader, yt as ScopedServerFunctions } from "../context
|
|
4
|
+
import { Ct as DevframeRpcClientFunctions, Kt as EventEmitter, at as DevframeServiceScopeOf, b as StreamSink, bt as ScopedSharedStates, d as RpcSharedStateHost, k as SharedState, lt as DevframeServicesState, pt as DevframeSettings, rt as DevframeServiceMeta, t as ConnectionMeta, u as RpcSharedStateGetOptions, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, y as StreamReader, yt as ScopedServerFunctions } from "../context--tVkJw3W.mjs";
|
|
5
5
|
import { t as SseRpcChannelOptions } from "../sse-client-DNdscfu_.mjs";
|
|
6
6
|
import { t as WsRpcChannelOptions } from "../ws-client-6Mrz6eC4.mjs";
|
|
7
7
|
//#region src/client/connection.d.ts
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as defineDiagnostics, i as createBirpc, n as argsToJsonSchema, o as DEVFRAME_EVENTS, r as resolveAgentSafety, t as toolInputToRpcArgs } from "../tool-input-BAQXvvqL.mjs";
|
|
2
2
|
import { t as hash } from "../hash-DdPnc4k3.mjs";
|
|
3
3
|
import { createEventEmitter } from "../utils/events.mjs";
|
|
4
4
|
import { withBase, withProtocol } from "../utils/url.mjs";
|
|
@@ -1669,83 +1669,6 @@ function createScopedClientContext(rpc, namespace) {
|
|
|
1669
1669
|
};
|
|
1670
1670
|
}
|
|
1671
1671
|
//#endregion
|
|
1672
|
-
//#region src/agent/to-json-schema.ts
|
|
1673
|
-
const FALLBACK_OBJECT_SCHEMA = Object.freeze({
|
|
1674
|
-
type: "object",
|
|
1675
|
-
additionalProperties: true
|
|
1676
|
-
});
|
|
1677
|
-
/**
|
|
1678
|
-
* Convert a Standard Schema to JSON Schema for the agent/MCP surface.
|
|
1679
|
-
*
|
|
1680
|
-
* Devframe stays validator-neutral, so conversion uses the schema's own
|
|
1681
|
-
* [Standard JSON Schema](https://standardschema.dev/) converter
|
|
1682
|
-
* (`~standard.jsonSchema`) when the validator provides one; zod 4 does,
|
|
1683
|
-
* for example. Validators without a native converter (e.g. valibot) degrade
|
|
1684
|
-
* to a permissive object schema rather than pulling in a converter library.
|
|
1685
|
-
*/
|
|
1686
|
-
function safeToJsonSchema(schema) {
|
|
1687
|
-
const standard = schema["~standard"];
|
|
1688
|
-
if (standard.jsonSchema) try {
|
|
1689
|
-
return standard.jsonSchema.input({ target: "draft-2020-12" });
|
|
1690
|
-
} catch {
|
|
1691
|
-
return FALLBACK_OBJECT_SCHEMA;
|
|
1692
|
-
}
|
|
1693
|
-
return FALLBACK_OBJECT_SCHEMA;
|
|
1694
|
-
}
|
|
1695
|
-
/**
|
|
1696
|
-
* JSON Schema for an RPC function's positional args on the agent/MCP
|
|
1697
|
-
* surface. Each positional arg is advertised under `arg0` / `arg1` / …,
|
|
1698
|
-
* matching how the agent bridge coerces the incoming object payload back
|
|
1699
|
-
* into positional arguments.
|
|
1700
|
-
*
|
|
1701
|
-
* Returns `{ type: 'object', properties: {} }` when there are no args.
|
|
1702
|
-
* @internal
|
|
1703
|
-
*/
|
|
1704
|
-
function argsToJsonSchema(args) {
|
|
1705
|
-
if (!args || args.length === 0) return {
|
|
1706
|
-
type: "object",
|
|
1707
|
-
properties: {}
|
|
1708
|
-
};
|
|
1709
|
-
const properties = {};
|
|
1710
|
-
const required = [];
|
|
1711
|
-
for (let i = 0; i < args.length; i++) {
|
|
1712
|
-
const key = `arg${i}`;
|
|
1713
|
-
properties[key] = safeToJsonSchema(args[i]);
|
|
1714
|
-
required.push(key);
|
|
1715
|
-
}
|
|
1716
|
-
return {
|
|
1717
|
-
type: "object",
|
|
1718
|
-
properties,
|
|
1719
|
-
required,
|
|
1720
|
-
additionalProperties: false
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
//#endregion
|
|
1724
|
-
//#region src/tool-input.ts
|
|
1725
|
-
/**
|
|
1726
|
-
* Convert an object-shaped tool input into positional arguments.
|
|
1727
|
-
*
|
|
1728
|
-
* Tool schemas expose positional parameters as `arg0`, `arg1`, and so on.
|
|
1729
|
-
* Arrays pass through for callers that already provide positional arguments.
|
|
1730
|
-
*/
|
|
1731
|
-
function collectPositionalArgs(input, argumentCount) {
|
|
1732
|
-
if (Array.isArray(input)) return input;
|
|
1733
|
-
if (input === void 0 || input === null) return [];
|
|
1734
|
-
if (typeof input !== "object") return void 0;
|
|
1735
|
-
const record = input;
|
|
1736
|
-
if (argumentCount != null) return Array.from({ length: argumentCount }, (_, index) => record[`arg${index}`]);
|
|
1737
|
-
if ("arg0" in record) {
|
|
1738
|
-
const positional = [];
|
|
1739
|
-
while (`arg${positional.length}` in record) positional.push(record[`arg${positional.length}`]);
|
|
1740
|
-
return positional;
|
|
1741
|
-
}
|
|
1742
|
-
return Object.keys(record).length === 0 ? [] : void 0;
|
|
1743
|
-
}
|
|
1744
|
-
/** Convert tool input for an RPC, preserving an untyped payload as arg 0. */
|
|
1745
|
-
function toolInputToRpcArgs(input, argumentCount) {
|
|
1746
|
-
return collectPositionalArgs(input, argumentCount) ?? [input];
|
|
1747
|
-
}
|
|
1748
|
-
//#endregion
|
|
1749
1672
|
//#region src/client/webmcp.ts
|
|
1750
1673
|
/**
|
|
1751
1674
|
* The page's WebMCP model context, when the browser (or a polyfill)
|
|
@@ -1786,14 +1709,15 @@ function registerWebMcpTools(clientRpc, options = {}) {
|
|
|
1786
1709
|
return;
|
|
1787
1710
|
}
|
|
1788
1711
|
const controller = new AbortController();
|
|
1712
|
+
const safety = resolveAgentSafety(def.type, agent);
|
|
1789
1713
|
const result = modelContext.registerTool({
|
|
1790
1714
|
name,
|
|
1791
1715
|
description: agent.description,
|
|
1792
1716
|
inputSchema: argsToJsonSchema(def.args),
|
|
1793
1717
|
annotations: {
|
|
1794
1718
|
title: agent.title ?? def.name,
|
|
1795
|
-
readOnlyHint:
|
|
1796
|
-
destructiveHint:
|
|
1719
|
+
readOnlyHint: safety === "read",
|
|
1720
|
+
destructiveHint: safety === "destructive"
|
|
1797
1721
|
},
|
|
1798
1722
|
execute: (args) => executeRpcTool(def, clientRpc.context, args)
|
|
1799
1723
|
}, { signal: controller.signal });
|
|
@@ -1823,11 +1747,6 @@ function registerWebMcpTools(clientRpc, options = {}) {
|
|
|
1823
1747
|
registered.clear();
|
|
1824
1748
|
};
|
|
1825
1749
|
}
|
|
1826
|
-
function resolveSafety(def, agent) {
|
|
1827
|
-
if (agent.safety) return agent.safety;
|
|
1828
|
-
const type = def.type ?? "query";
|
|
1829
|
-
return type === "static" || type === "query" ? "read" : "action";
|
|
1830
|
-
}
|
|
1831
1750
|
async function executeRpcTool(def, context, args) {
|
|
1832
1751
|
try {
|
|
1833
1752
|
const positional = toolInputToRpcArgs(args, def.args?.length);
|
|
@@ -1902,6 +1821,8 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
1902
1821
|
const context = { rpc: void 0 };
|
|
1903
1822
|
const clientRpc = new RpcFunctionsCollectorBase(context);
|
|
1904
1823
|
const disposeWebMcp = options.webmcp === false ? void 0 : registerWebMcpTools(clientRpc);
|
|
1824
|
+
let disposeBrowserAgentBridge;
|
|
1825
|
+
let closed = false;
|
|
1905
1826
|
async function fetchJsonFromBases(path) {
|
|
1906
1827
|
const candidates = [resolvedBaseURL, ...bases.filter((base) => base !== resolvedBaseURL)].filter((x) => x != null);
|
|
1907
1828
|
const errors = [];
|
|
@@ -1956,7 +1877,9 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
1956
1877
|
}
|
|
1957
1878
|
/** Release authentication and transport resources even if another disposer fails. */
|
|
1958
1879
|
function closeRpcClient() {
|
|
1880
|
+
closed = true;
|
|
1959
1881
|
try {
|
|
1882
|
+
disposeBrowserAgentBridge?.();
|
|
1960
1883
|
disposeWebMcp?.();
|
|
1961
1884
|
} finally {
|
|
1962
1885
|
try {
|
|
@@ -2067,6 +1990,9 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
2067
1990
|
}, () => {
|
|
2068
1991
|
bootstrapAuthSettled = true;
|
|
2069
1992
|
});
|
|
1993
|
+
if (connectionMeta.mcp) import("../browser-agent-rpc-BXhoSh1z.mjs").then(({ setupBrowserAgentRpcBridge }) => {
|
|
1994
|
+
if (!closed) disposeBrowserAgentBridge = setupBrowserAgentRpcBridge(rpc);
|
|
1995
|
+
}).catch(() => {});
|
|
2070
1996
|
if (authChannel) authChannel.onmessage = (event) => {
|
|
2071
1997
|
if (event.data?.type === "auth-update" && event.data.authToken) rpc.requestTrustWithToken(event.data.authToken);
|
|
2072
1998
|
};
|
|
@@ -500,11 +500,23 @@ interface DevframeHost {
|
|
|
500
500
|
*/
|
|
501
501
|
type DevframeStorageScope = 'workspace' | 'project' | 'global';
|
|
502
502
|
//#endregion
|
|
503
|
+
//#region src/client/browser-agent.d.ts
|
|
504
|
+
interface BrowserAgentToolManifest {
|
|
505
|
+
id: string;
|
|
506
|
+
title?: string;
|
|
507
|
+
description: string;
|
|
508
|
+
safety: 'read' | 'action' | 'destructive';
|
|
509
|
+
tags?: readonly string[];
|
|
510
|
+
inputSchema?: unknown;
|
|
511
|
+
}
|
|
512
|
+
//#endregion
|
|
503
513
|
//#region src/types/rpc-augments.d.ts
|
|
504
514
|
/**
|
|
505
515
|
* To be extended
|
|
506
516
|
*/
|
|
507
517
|
interface DevframeRpcClientFunctions {
|
|
518
|
+
/** Invoke a tool registered in this browser document. @internal */
|
|
519
|
+
'devframe:agent:invoke-client-tool': (id: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
508
520
|
/**
|
|
509
521
|
* Server→client notification that this connection's auth token has been
|
|
510
522
|
* revoked. The client drops to untrusted on receipt. Broadcast by
|
|
@@ -556,6 +568,8 @@ interface DevframeRpcClientFunctions {
|
|
|
556
568
|
* To be extended
|
|
557
569
|
*/
|
|
558
570
|
interface DevframeRpcServerFunctions {
|
|
571
|
+
/** Replace this connection's browser-agent tool manifest, tagged with the calling tab's stable client id. @internal */
|
|
572
|
+
'devframe:agent:sync-client-tools': (clientId: string, tools: BrowserAgentToolManifest[]) => Promise<void>;
|
|
559
573
|
/**
|
|
560
574
|
* Authenticate a connection with a previously-issued bearer token; resolves
|
|
561
575
|
* whether the connection is now trusted. The interactive handler is provided
|
|
@@ -1400,6 +1414,11 @@ interface DevframeDockDefaults {
|
|
|
1400
1414
|
* host wiring; a URL or bare specifier passes through untouched.
|
|
1401
1415
|
*/
|
|
1402
1416
|
clientScript?: {
|
|
1417
|
+
/**
|
|
1418
|
+
* Initialize after RPC trust without waiting for dock activation.
|
|
1419
|
+
* @default false
|
|
1420
|
+
*/
|
|
1421
|
+
eager?: boolean;
|
|
1403
1422
|
/** An absolute filesystem path, a served URL, or a bare npm specifier. */
|
|
1404
1423
|
importFrom: string;
|
|
1405
1424
|
/**
|
|
@@ -5,7 +5,7 @@ import { defineRpcFunction } from "./index.mjs";
|
|
|
5
5
|
import { t as DEVFRAME_EVENTS } from "./events-BV4Dj59a.mjs";
|
|
6
6
|
import { DEVFRAME_SERVICES_STATE_KEY } from "./constants.mjs";
|
|
7
7
|
import { t as diagnostics$1 } from "./diagnostics-Cx4_VjlG.mjs";
|
|
8
|
-
import { r as createEventEmitter, t as DevframeAgentHost } from "./host-agent-
|
|
8
|
+
import { r as createEventEmitter, t as DevframeAgentHost } from "./host-agent-mIbQ6Qi5.mjs";
|
|
9
9
|
import { n as createDebug, t as resolveStaticAssetsSource } from "./remote-assets-B9MeWmW6.mjs";
|
|
10
10
|
import { a as satisfiesVersionRange, n as expandResolveFrom, r as importServicePackage, t as deepMergeOptionSets } from "./services-install-D5YUwFXW.mjs";
|
|
11
11
|
import { t as createStorage } from "./storage-CHD1IkqU.mjs";
|
|
@@ -32,6 +32,46 @@ var DevframeDiagnosticsHost = class {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/node/client-agent.ts
|
|
36
|
+
const states = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
function getState(context) {
|
|
38
|
+
let state = states.get(context);
|
|
39
|
+
if (state) return state;
|
|
40
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
41
|
+
state = {
|
|
42
|
+
sessions,
|
|
43
|
+
notifyChanged: context.agent.registerToolProvider(() => {
|
|
44
|
+
const tools = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const { session, tools: manifests } of sessions.values()) for (const manifest of manifests) {
|
|
46
|
+
if (tools.has(manifest.id)) continue;
|
|
47
|
+
tools.set(manifest.id, {
|
|
48
|
+
...manifest,
|
|
49
|
+
handler: (args) => session.rpc.$callRaw({
|
|
50
|
+
method: "devframe:agent:invoke-client-tool",
|
|
51
|
+
args: [manifest.id, args]
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return [...tools.values()];
|
|
56
|
+
}).notifyChanged
|
|
57
|
+
};
|
|
58
|
+
states.set(context, state);
|
|
59
|
+
return state;
|
|
60
|
+
}
|
|
61
|
+
function syncClientAgentTools(context, session, clientId, tools) {
|
|
62
|
+
const state = getState(context);
|
|
63
|
+
state.sessions.set(session.meta, {
|
|
64
|
+
session,
|
|
65
|
+
clientId,
|
|
66
|
+
tools
|
|
67
|
+
});
|
|
68
|
+
state.notifyChanged();
|
|
69
|
+
}
|
|
70
|
+
function removeClientAgentSession(context, meta) {
|
|
71
|
+
const state = states.get(context);
|
|
72
|
+
if (state?.sessions.delete(meta)) state.notifyChanged();
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
35
75
|
//#region src/node/rpc-shared-state.ts
|
|
36
76
|
const debug$2 = createDebug("devframe:rpc:state:changed");
|
|
37
77
|
const debugSubscribe = createDebug("devframe:rpc:state:subscribe");
|
|
@@ -764,6 +804,7 @@ var RpcFunctionsHostImpl = class extends RpcFunctionsCollectorBase {
|
|
|
764
804
|
*/
|
|
765
805
|
_emitSessionDisconnected(meta) {
|
|
766
806
|
this.streaming._onSessionDisconnected(meta);
|
|
807
|
+
removeClientAgentSession(this.context, meta);
|
|
767
808
|
}
|
|
768
809
|
async invokeLocal(method, ...args) {
|
|
769
810
|
if (!this.definitions.has(method)) throw diagnostics$1.DF0006({ name: String(method) });
|
|
@@ -1124,6 +1165,15 @@ const BUILTIN_AGENT_RPC = [
|
|
|
1124
1165
|
return await ctx.agent.read(id);
|
|
1125
1166
|
} };
|
|
1126
1167
|
}
|
|
1168
|
+
}),
|
|
1169
|
+
defineRpcFunction({
|
|
1170
|
+
name: "devframe:agent:sync-client-tools",
|
|
1171
|
+
type: "action",
|
|
1172
|
+
jsonSerializable: true,
|
|
1173
|
+
setup: (context) => ({ handler(clientId, tools) {
|
|
1174
|
+
const session = context.rpc.getCurrentRpcSession();
|
|
1175
|
+
if (session) syncClientAgentTools(context, session, clientId, tools);
|
|
1176
|
+
} })
|
|
1127
1177
|
})
|
|
1128
1178
|
];
|
|
1129
1179
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as SharedState, o as DevframeNodeContext } from "./context
|
|
1
|
+
import { k as SharedState, o as DevframeNodeContext } from "./context--tVkJw3W.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 { DEVFRAME_CONNECTION_META_FILENAME } from "./constants.mjs";
|
|
2
2
|
import { t as diagnostics } from "./diagnostics-Cx4_VjlG.mjs";
|
|
3
|
-
import { t as createHostContext } from "./context-
|
|
3
|
+
import { t as createHostContext } from "./context-BqpgC5tq.mjs";
|
|
4
4
|
import { t as resolveStaticAssetsSource } from "./remote-assets-B9MeWmW6.mjs";
|
|
5
5
|
import { a as resolveMcpConfig, c as joinURL, d as withoutLeadingSlash, i as resolveDevServerPort, l as withBase, n as normalizeBasePath, r as resolveBasePath, s as importAgenticMcp, t as loadAutoMcpAdapter } from "./_shared-B2PZsp-J.mjs";
|
|
6
6
|
import { t as createH3DevframeHost } from "./host-h3-BROI6SQ4.mjs";
|
|
@@ -39,6 +39,17 @@ function createEventEmitter() {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
+
//#region src/agent/safety.ts
|
|
43
|
+
/**
|
|
44
|
+
* An agent tool's safety classification: the explicit `agent.safety`, else
|
|
45
|
+
* inferred from the function `type` (`static`/`query` are read-only, the rest
|
|
46
|
+
* mutate). Shared by every agent surface (MCP host, WebMCP, in-page bridge).
|
|
47
|
+
*/
|
|
48
|
+
function resolveAgentSafety(type, agent) {
|
|
49
|
+
if (agent.safety) return agent.safety;
|
|
50
|
+
return type === "static" || type === "query" || type == null ? "read" : "action";
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
42
53
|
//#region src/tool-input.ts
|
|
43
54
|
/**
|
|
44
55
|
* Convert an object-shaped tool input into positional arguments.
|
|
@@ -243,8 +254,7 @@ var DevframeAgentHost = class {
|
|
|
243
254
|
const agent = def.agent;
|
|
244
255
|
if (!agent) continue;
|
|
245
256
|
if (!agent.description || typeof agent.description !== "string") throw diagnostics.DF0014({ name });
|
|
246
|
-
const
|
|
247
|
-
const safety = agent.safety ?? inferSafety(type);
|
|
257
|
+
const safety = resolveAgentSafety(def.type, agent);
|
|
248
258
|
out.push({
|
|
249
259
|
id: name,
|
|
250
260
|
kind: "rpc",
|
|
@@ -263,9 +273,5 @@ var DevframeAgentHost = class {
|
|
|
263
273
|
if (def?.agent) return def;
|
|
264
274
|
}
|
|
265
275
|
};
|
|
266
|
-
function inferSafety(type) {
|
|
267
|
-
if (type === "static" || type === "query") return "read";
|
|
268
|
-
return "action";
|
|
269
|
-
}
|
|
270
276
|
//#endregion
|
|
271
277
|
export { toolInputToCommandArgs as n, createEventEmitter as r, DevframeAgentHost as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as InferArgsType, E as Thenable, O as InferReturnType, T as RpcReturnSchema, n as RpcArgsSchema } from "../types-BmDbfHCx.mjs";
|
|
2
|
-
import { Kt as EventEmitter, k as SharedState } from "../context
|
|
1
|
+
import { D as InferArgsType, E as Thenable, O as InferReturnType, T as RpcReturnSchema, m as RpcFunctionAgentOptions, n as RpcArgsSchema } from "../types-BmDbfHCx.mjs";
|
|
2
|
+
import { Kt as EventEmitter, k as SharedState } from "../context--tVkJw3W.mjs";
|
|
3
3
|
//#region src/in-page-channel/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The shared contract of one in-page channel, declared once (usually in a
|
|
@@ -48,11 +48,15 @@ type ProtocolHandler<F> = F extends ((...args: any[]) => any) ? (...args: FnArgs
|
|
|
48
48
|
* fan-out), `action` performs, `query` requests data (the default).
|
|
49
49
|
*/
|
|
50
50
|
type InPageFunctionType = 'action' | 'event' | 'query';
|
|
51
|
-
interface
|
|
51
|
+
interface InPageDefinitionBase<NAME extends string> {
|
|
52
52
|
name: NAME;
|
|
53
53
|
jsonSerializable?: boolean;
|
|
54
54
|
}
|
|
55
|
-
interface
|
|
55
|
+
interface InPageFunctionDefinitionBase<NAME extends string> extends InPageDefinitionBase<NAME> {
|
|
56
|
+
/** Expose this function through DevFrame's browser-to-node agent bridge. */
|
|
57
|
+
agent?: RpcFunctionAgentOptions;
|
|
58
|
+
}
|
|
59
|
+
interface InPageEventFunctionDefinition<NAME extends string, HANDLER> extends InPageDefinitionBase<NAME> {
|
|
56
60
|
type: 'event';
|
|
57
61
|
handler?: HANDLER;
|
|
58
62
|
}
|
|
@@ -79,7 +83,8 @@ type InPageFunctionDefinitionHandler<ARGS extends any[], RETURN, AS extends RpcA
|
|
|
79
83
|
* An in-page channel function definition: the `defineRpcFunction` authoring
|
|
80
84
|
* shape (`name`, `type`, Standard-Schema `args`/`returns`,
|
|
81
85
|
* `jsonSerializable`, `handler`) narrowed to the browser: there is no
|
|
82
|
-
* `dump`/`snapshot`/`cacheable
|
|
86
|
+
* `dump`/`snapshot`/`cacheable`. An optional `agent` exposes the function to
|
|
87
|
+
* DevFrame's browser-to-node agent bridge. When `jsonSerializable` is `true`,
|
|
83
88
|
* payloads are strictly validated at the receiving endpoint and misshapen
|
|
84
89
|
* values reject the call with a descriptive `InPageChannelError` instead of
|
|
85
90
|
* a cryptic `DataCloneError` in the port. Event definitions may omit their
|
|
@@ -91,14 +96,18 @@ type InPageFunctionDefinition<NAME extends string, TYPE extends InPageFunctionTy
|
|
|
91
96
|
*
|
|
92
97
|
* @internal
|
|
93
98
|
*/
|
|
94
|
-
interface
|
|
99
|
+
interface InPageDefinitionOptionBase {
|
|
95
100
|
/** Optional Standard Schema array validating the arguments. */
|
|
96
101
|
args?: RpcArgsSchema;
|
|
97
102
|
/** Optional Standard Schema validating the resolved return value. */
|
|
98
103
|
returns?: RpcReturnSchema;
|
|
99
104
|
jsonSerializable?: boolean;
|
|
100
105
|
}
|
|
101
|
-
interface
|
|
106
|
+
interface InPageFunctionOptionBase extends InPageDefinitionOptionBase {
|
|
107
|
+
/** Expose this function through DevFrame's browser-to-node agent bridge. */
|
|
108
|
+
agent?: RpcFunctionAgentOptions;
|
|
109
|
+
}
|
|
110
|
+
interface InPageEventFunctionOption<F> extends InPageDefinitionOptionBase {
|
|
102
111
|
type?: 'event';
|
|
103
112
|
handler?: ProtocolHandler<F>;
|
|
104
113
|
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as defineDiagnostics, i as createBirpc, n as argsToJsonSchema, o as DEVFRAME_EVENTS, r as resolveAgentSafety, t as toolInputToRpcArgs } from "../tool-input-BAQXvvqL.mjs";
|
|
2
2
|
import { createEventEmitter } from "../utils/events.mjs";
|
|
3
3
|
import { t as createSharedState } from "../shared-state-eQVYHNqA.mjs";
|
|
4
4
|
import { nanoid } from "../utils/nanoid.mjs";
|
|
5
|
+
import { r as registerBrowserAgentTool } from "../browser-agent-Pu-FLk6I.mjs";
|
|
5
6
|
//#region src/in-page-channel/diagnostics.ts
|
|
6
7
|
const diagnostics = /* #__PURE__ */ defineDiagnostics({
|
|
7
8
|
docsBase: "https://devfra.me/errors",
|
|
8
|
-
codes: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
codes: {
|
|
10
|
+
DF0077: {
|
|
11
|
+
why: (p) => `In-page channel function "${p.name}" is not registered on this endpoint.`,
|
|
12
|
+
fix: "Declare the function in this endpoint's `functions` option."
|
|
13
|
+
},
|
|
14
|
+
DF0080: {
|
|
15
|
+
why: (p) => `In-page channel function "${p.name}" has \`agent\` set but \`jsonSerializable\` is \`false\`; MCP requires JSON-serializable data.`,
|
|
16
|
+
fix: "Remove `jsonSerializable: false`, or remove `agent` to keep it channel-only."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
});
|
|
13
20
|
//#endregion
|
|
14
21
|
//#region src/in-page-channel/protocol.ts
|
|
@@ -172,17 +179,16 @@ function channelMethod(type, name) {
|
|
|
172
179
|
return `devframe:in-page:${type === "event" ? "event" : "function"}:${name}`;
|
|
173
180
|
}
|
|
174
181
|
const FUNCTION_METHOD_PREFIX = channelMethod("function", "");
|
|
175
|
-
/**
|
|
176
|
-
* An endpoint's local function table, resolved by name when the remote side
|
|
177
|
-
* calls in. Each handler is wrapped with the receive pipeline: deserialize
|
|
178
|
-
* hook, `jsonSerializable` enforcement, Standard-Schema argument validation,
|
|
179
|
-
* then serialize hook + `jsonSerializable` enforcement on the result.
|
|
180
|
-
*/
|
|
181
182
|
function createLocalFunctionRegistry(codec) {
|
|
182
183
|
const definitions = /* @__PURE__ */ new Map();
|
|
183
184
|
const listeners = /* @__PURE__ */ new Map();
|
|
184
185
|
return {
|
|
186
|
+
definitions,
|
|
185
187
|
register(definition) {
|
|
188
|
+
if ("agent" in definition && definition.agent) {
|
|
189
|
+
if (definition.jsonSerializable === false) throw diagnostics.DF0080({ name: definition.name });
|
|
190
|
+
definition.jsonSerializable = true;
|
|
191
|
+
}
|
|
186
192
|
definitions.set(channelMethod(definition.type, definition.name), definition);
|
|
187
193
|
},
|
|
188
194
|
registerInternal(method, handler) {
|
|
@@ -236,6 +242,27 @@ function resolveLocalHandler(name, registries) {
|
|
|
236
242
|
throw diagnostics.DF0077({ name: name.slice(FUNCTION_METHOD_PREFIX.length) });
|
|
237
243
|
};
|
|
238
244
|
}
|
|
245
|
+
/** Register an endpoint's local agent functions for browser-backed transports. */
|
|
246
|
+
function registerInPageAgentTools(channelName, registry) {
|
|
247
|
+
const disposals = [];
|
|
248
|
+
for (const definition of registry.definitions.values()) {
|
|
249
|
+
if (definition.type === "event" || !("agent" in definition) || !definition.agent) continue;
|
|
250
|
+
const agent = definition.agent;
|
|
251
|
+
disposals.push(registerBrowserAgentTool({
|
|
252
|
+
id: `${channelName}:${definition.name}`,
|
|
253
|
+
title: agent.title ?? definition.name,
|
|
254
|
+
description: agent.description,
|
|
255
|
+
safety: resolveAgentSafety(definition.type, agent),
|
|
256
|
+
tags: agent.tags,
|
|
257
|
+
inputSchema: argsToJsonSchema(definition.args),
|
|
258
|
+
invoke: (args) => {
|
|
259
|
+
const positional = toolInputToRpcArgs(args, definition.args?.length);
|
|
260
|
+
return registry.resolve(channelMethod(definition.type, definition.name))(...positional);
|
|
261
|
+
}
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
return () => disposals.forEach((dispose) => dispose());
|
|
265
|
+
}
|
|
239
266
|
function wrapPostError(error) {
|
|
240
267
|
if (error instanceof DOMException && error.name === "DataCloneError") return new InPageChannelError("not-cloneable", `a payload could not be structured-cloned across the in-page channel: ${error.message}. Strip non-cloneable values (functions, DOM nodes, framework reactivity proxies) before sending: declare the function \`jsonSerializable: true\` for a precise error, or provide a \`serialize\` hook.`, { cause: error });
|
|
241
268
|
return error;
|
|
@@ -512,6 +539,7 @@ function createPageScriptChannel(options) {
|
|
|
512
539
|
name: eventName,
|
|
513
540
|
type: "event"
|
|
514
541
|
});
|
|
542
|
+
const disposeAgentTools = registerInPageAgentTools(name, registry);
|
|
515
543
|
const stateHost = createPageScriptStateHost(function* () {
|
|
516
544
|
for (const peer of peers.values()) yield {
|
|
517
545
|
subscribedStates: peer.subscribedStates,
|
|
@@ -637,6 +665,7 @@ function createPageScriptChannel(options) {
|
|
|
637
665
|
close: () => {
|
|
638
666
|
if (closed) return;
|
|
639
667
|
closed = true;
|
|
668
|
+
disposeAgentTools();
|
|
640
669
|
win?.removeEventListener("message", onWindowMessage);
|
|
641
670
|
for (const id of [...peers.keys()]) removePeer(id, {
|
|
642
671
|
bye: true,
|
|
@@ -687,6 +716,7 @@ function connectPanelChannel(options) {
|
|
|
687
716
|
name: eventName,
|
|
688
717
|
type: "event"
|
|
689
718
|
});
|
|
719
|
+
const disposeAgentTools = registerInPageAgentTools(name, registry);
|
|
690
720
|
let status = "connecting";
|
|
691
721
|
let attached;
|
|
692
722
|
let pageScriptInfo;
|
|
@@ -870,6 +900,7 @@ function connectPanelChannel(options) {
|
|
|
870
900
|
close: () => {
|
|
871
901
|
if (status === "closed") return;
|
|
872
902
|
setStatus("closed");
|
|
903
|
+
disposeAgentTools();
|
|
873
904
|
stopTimers();
|
|
874
905
|
win?.removeEventListener("message", onWindowMessage);
|
|
875
906
|
attached?.dispose({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context
|
|
2
|
-
import { n as InternalAnonymousAuthStorage } from "./context-
|
|
1
|
+
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context--tVkJw3W.mjs";
|
|
2
|
+
import { n as InternalAnonymousAuthStorage } from "./context-D3qBv0IX.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,5 +1,5 @@
|
|
|
1
1
|
import { C as RpcFunctionType, T as RpcReturnSchema, h as RpcFunctionDefinition, m as RpcFunctionAgentOptions, n as RpcArgsSchema } from "./types-BmDbfHCx.mjs";
|
|
2
|
-
import { $ as DevframeServiceDefinition, B as DevframeDefinition, Bt as AgentTool, Ct as DevframeRpcClientFunctions, Dt as DevframeStorageScope, Et as DevframeHost, F as CreateMcpServerOptions, Ft as AgentHandle, G as DevframeSetupInfo, Gt as DevframeAgentHostEvents, H as DevframeDockDefaults, Ht as AgentToolProvider, I as McpConnectionInfo, It as AgentManifest, J as DevframeSseOptions, Jt as EventsMap, K as DevframeSnapshotRpcEntry, Kt as EventEmitter, L as McpFetchHandler, Lt as AgentResource, Ot as DevframeDiagnosticsHost, P as CreateMcpFetchHandlerOptions, Q as McpSetting, R as McpServerHandle, Rt as AgentResourceContent, St as DevframeViewHost, Tt as DevframeRpcSharedStates, U as DevframeDuplicationStrategy, Ut as AgentToolProviderHandle, V as DevframeDeploymentKind, Vt as AgentToolInput, W as DevframeRpcOptions, Wt as DevframeAgentHost, X as McpAuthorization, Y as DevframeWsOptions, Z as McpRouteOptions, _t as ScopedClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeServiceScopeOf, bt as ScopedSharedStates, c as RpcBroadcastOptions, ct as DevframeServicesScopeRegistry, d as RpcSharedStateHost, dt as DevframeScopedNodeRpc, et as DevframeServiceDescriptor, f as RpcStreamingChannel, ft as DevframeScopedStreamingHost, gt as ScopedBroadcastOptions, ht as DevframeSettingsStore, i as DevframeCapabilities, it as DevframeServiceOf, kt as DevframeDiagnosticsLogger, l as RpcFunctionsHost, lt as DevframeServicesState, m as RpcStreamingHost, mt as DevframeSettingsRegistry, n as ConnectionMetaSse, nt as DevframeServiceInput, o as DevframeNodeContext, ot as DevframeServicesHost, p as RpcStreamingChannelOptions, pt as DevframeSettings, q as DevframeSnapshotRpcInputs, qt as EventUnsubscribe, r as ConnectionMetaWebsocket, rt as DevframeServiceMeta, s as DevframeNodeRpcSession, st as DevframeServicesRegistry, t as ConnectionMeta, tt as DevframeServiceId, u as RpcSharedStateGetOptions, ut as DevframeScopedNodeContext, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, yt as ScopedServerFunctions, z as DevframeCliOptions, zt as AgentResourceInput } from "./context
|
|
2
|
+
import { $ as DevframeServiceDefinition, B as DevframeDefinition, Bt as AgentTool, Ct as DevframeRpcClientFunctions, Dt as DevframeStorageScope, Et as DevframeHost, F as CreateMcpServerOptions, Ft as AgentHandle, G as DevframeSetupInfo, Gt as DevframeAgentHostEvents, H as DevframeDockDefaults, Ht as AgentToolProvider, I as McpConnectionInfo, It as AgentManifest, J as DevframeSseOptions, Jt as EventsMap, K as DevframeSnapshotRpcEntry, Kt as EventEmitter, L as McpFetchHandler, Lt as AgentResource, Ot as DevframeDiagnosticsHost, P as CreateMcpFetchHandlerOptions, Q as McpSetting, R as McpServerHandle, Rt as AgentResourceContent, St as DevframeViewHost, Tt as DevframeRpcSharedStates, U as DevframeDuplicationStrategy, Ut as AgentToolProviderHandle, V as DevframeDeploymentKind, Vt as AgentToolInput, W as DevframeRpcOptions, Wt as DevframeAgentHost, X as McpAuthorization, Y as DevframeWsOptions, Z as McpRouteOptions, _t as ScopedClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeServiceScopeOf, bt as ScopedSharedStates, c as RpcBroadcastOptions, ct as DevframeServicesScopeRegistry, d as RpcSharedStateHost, dt as DevframeScopedNodeRpc, et as DevframeServiceDescriptor, f as RpcStreamingChannel, ft as DevframeScopedStreamingHost, gt as ScopedBroadcastOptions, ht as DevframeSettingsStore, i as DevframeCapabilities, it as DevframeServiceOf, kt as DevframeDiagnosticsLogger, l as RpcFunctionsHost, lt as DevframeServicesState, m as RpcStreamingHost, mt as DevframeSettingsRegistry, n as ConnectionMetaSse, nt as DevframeServiceInput, o as DevframeNodeContext, ot as DevframeServicesHost, p as RpcStreamingChannelOptions, pt as DevframeSettings, q as DevframeSnapshotRpcInputs, qt as EventUnsubscribe, r as ConnectionMetaWebsocket, rt as DevframeServiceMeta, s as DevframeNodeRpcSession, st as DevframeServicesRegistry, t as ConnectionMeta, tt as DevframeServiceId, u as RpcSharedStateGetOptions, ut as DevframeScopedNodeContext, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, yt as ScopedServerFunctions, z as DevframeCliOptions, zt as AgentResourceInput } from "./context--tVkJw3W.mjs";
|
|
3
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-DWvukRwa.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as BirpcGroup } from "./index-Bia1vKjL.mjs";
|
|
2
|
-
import { At as DevframeAuthHandler, Ct as DevframeRpcClientFunctions, J as DevframeSseOptions, Y as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta, wt as DevframeRpcServerFunctions } from "./context
|
|
2
|
+
import { At as DevframeAuthHandler, Ct as DevframeRpcClientFunctions, J as DevframeSseOptions, Y as DevframeWsOptions, o as DevframeNodeContext, s as DevframeNodeRpcSession, t as ConnectionMeta, wt as DevframeRpcServerFunctions } from "./context--tVkJw3W.mjs";
|
|
3
3
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
|
|
4
4
|
import { n as WsOriginRegistry } from "./ws-server-y2R76aSW.mjs";
|
|
5
|
-
import "./index-
|
|
5
|
+
import "./index-D-2IdY1I.mjs";
|
|
6
6
|
import { H3 } from "h3";
|
|
7
7
|
import { NodeAdapter } from "crossws/adapters/node";
|
|
8
8
|
import { Buffer } from "node:buffer";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as StandardSchemaV1 } from "../index-CeEtxDmK.mjs";
|
|
2
2
|
import { g as RpcFunctionDefinitionAny } from "../types-BmDbfHCx.mjs";
|
|
3
|
-
import { Bt as AgentTool, Et as DevframeHost, Ft as AgentHandle, Gt as DevframeAgentHostEvents, Ht as AgentToolProvider, It as AgentManifest, Kt as EventEmitter, Lt as AgentResource, Rt as AgentResourceContent, Ut as AgentToolProviderHandle, Vt as AgentToolInput, Wt as DevframeAgentHost$1, o as DevframeNodeContext, zt as AgentResourceInput } from "../context
|
|
3
|
+
import { Bt as AgentTool, Et as DevframeHost, Ft as AgentHandle, Gt as DevframeAgentHostEvents, Ht as AgentToolProvider, It as AgentManifest, Kt as EventEmitter, Lt as AgentResource, Rt as AgentResourceContent, Ut as AgentToolProviderHandle, Vt as AgentToolInput, Wt as DevframeAgentHost$1, o as DevframeNodeContext, zt as AgentResourceInput } from "../context--tVkJw3W.mjs";
|
|
4
4
|
import { a as RemoteAssetsStore } from "../remote-assets-eBvSKZMS.mjs";
|
|
5
|
-
import { a as InstanceShellInit, c as StartedServer, d as samePath, f as DevframeInstanceRecord, g as registerDevframeInstance, h as probeDevframeOrigin, 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-
|
|
6
|
-
import { i as importAgenticMcp, n as MountMcpHttpOptions, r as MountedMcpHttp, t as AgenticMcpModule } from "../agentic-
|
|
7
|
-
import { a as resolveBasePath, i as normalizeBasePath, n as ResolvedMcpConfig, r as loadAutoMcpAdapter, s as resolveMcpConfig } from "../_shared-
|
|
8
|
-
import { n as CreateContextRpcServerOptions, r as createContextRpcServer, t as ContextRpcServer } from "../rpc-core-
|
|
5
|
+
import { a as InstanceShellInit, c as StartedServer, d as samePath, f as DevframeInstanceRecord, g as registerDevframeInstance, h as probeDevframeOrigin, 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-CXnpSuK7.mjs";
|
|
6
|
+
import { i as importAgenticMcp, n as MountMcpHttpOptions, r as MountedMcpHttp, t as AgenticMcpModule } from "../agentic-DLqHMOyN.mjs";
|
|
7
|
+
import { a as resolveBasePath, i as normalizeBasePath, n as ResolvedMcpConfig, r as loadAutoMcpAdapter, s as resolveMcpConfig } from "../_shared-D1ebaX_J.mjs";
|
|
8
|
+
import { n as CreateContextRpcServerOptions, r as createContextRpcServer, t as ContextRpcServer } from "../rpc-core-B6n9MQsc.mjs";
|
|
9
9
|
//#region src/agent/stringify.d.ts
|
|
10
10
|
/**
|
|
11
11
|
* JSON-coercing serializer for MCP text payloads.
|
package/dist/internal/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Diagnostic } from "../nostics-D0PvLZsn.mjs";
|
|
2
2
|
import { n as peekRpcWireFrame, t as createRpcWireCodec } from "../wire-codec-B1W3zH3L.mjs";
|
|
3
3
|
import { t as diagnostics } from "../diagnostics-Cx4_VjlG.mjs";
|
|
4
|
-
import { n as toolInputToCommandArgs, t as DevframeAgentHost } from "../host-agent-
|
|
4
|
+
import { n as toolInputToCommandArgs, t as DevframeAgentHost } from "../host-agent-mIbQ6Qi5.mjs";
|
|
5
5
|
import { a as resolveMcpConfig, n as normalizeBasePath, r as resolveBasePath, s as importAgenticMcp, t as loadAutoMcpAdapter } from "../_shared-B2PZsp-J.mjs";
|
|
6
6
|
import { t as importRuntimeModule } from "../import-runtime-module-BzlEQ9PI.mjs";
|
|
7
7
|
import { t as createH3DevframeHost } from "../host-h3-BROI6SQ4.mjs";
|
package/dist/node/auth.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { At as DevframeAuthHandler } from "../context
|
|
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-
|
|
1
|
+
import { At as DevframeAuthHandler } from "../context--tVkJw3W.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-D-2IdY1I.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-
|
|
2
|
-
import { a as resolveBasePath, i as normalizeBasePath } from "../_shared-
|
|
1
|
+
import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-D3qBv0IX.mjs";
|
|
2
|
+
import { a as resolveBasePath, i as normalizeBasePath } from "../_shared-D1ebaX_J.mjs";
|
|
3
3
|
export { type DevframeInternalContext, type InternalAnonymousAuthStorage, type RemoteTokenRecord, getInternalContext, internalContextMap, normalizeBasePath, resolveBasePath };
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as RpcFunctionDefinitionAny } from "../types-BmDbfHCx.mjs";
|
|
2
|
-
import { Et as DevframeHost, k as SharedState, l as RpcFunctionsHost, o as DevframeNodeContext } from "../context
|
|
2
|
+
import { Et as DevframeHost, k as SharedState, l as RpcFunctionsHost, o as DevframeNodeContext } from "../context--tVkJw3W.mjs";
|
|
3
3
|
//#region src/node/context.d.ts
|
|
4
4
|
export interface CreateHostContextOptions {
|
|
5
5
|
cwd: string;
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { At as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "../context
|
|
2
|
-
import "../index-
|
|
1
|
+
import { At as DevframeAuthHandler, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "../context--tVkJw3W.mjs";
|
|
2
|
+
import "../index-D-2IdY1I.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,5 @@
|
|
|
1
1
|
import { n as WsOriginRegistry } from "../../ws-server-y2R76aSW.mjs";
|
|
2
|
-
import { t as ContextRpcServer } from "../../rpc-core-
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-B6n9MQsc.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
1
|
import { n as WsOriginRegistry } from "../../ws-server-y2R76aSW.mjs";
|
|
2
|
-
import { t as ContextRpcServer } from "../../rpc-core-
|
|
2
|
+
import { t as ContextRpcServer } from "../../rpc-core-B6n9MQsc.mjs";
|
|
3
3
|
//#region src/rpc/transports/ws-deno.d.ts
|
|
4
4
|
export interface AttachDenoWsTransportOptions {
|
|
5
5
|
/** Same contract as `WsRpcTransportOptions.allowedOrigins`. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as BirpcGroup, o as EventOptions } from "./index-Bia1vKjL.mjs";
|
|
2
|
-
import { At as DevframeAuthHandler, Ct as DevframeRpcClientFunctions, o as DevframeNodeContext, s as DevframeNodeRpcSession, wt as DevframeRpcServerFunctions } from "./context
|
|
2
|
+
import { At as DevframeAuthHandler, Ct as DevframeRpcClientFunctions, o as DevframeNodeContext, s as DevframeNodeRpcSession, wt as DevframeRpcServerFunctions } from "./context--tVkJw3W.mjs";
|
|
3
3
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-r6PDixP6.mjs";
|
|
4
4
|
import "./ws-server-y2R76aSW.mjs";
|
|
5
|
-
import "./index-
|
|
5
|
+
import "./index-D-2IdY1I.mjs";
|
|
6
6
|
//#region src/node/rpc-core.d.ts
|
|
7
7
|
interface CreateContextRpcServerOptions {
|
|
8
8
|
context: DevframeNodeContext;
|
|
@@ -302,4 +302,92 @@ function createBirpc($functions, options) {
|
|
|
302
302
|
return rpc;
|
|
303
303
|
}
|
|
304
304
|
//#endregion
|
|
305
|
-
|
|
305
|
+
//#region src/agent/safety.ts
|
|
306
|
+
/**
|
|
307
|
+
* An agent tool's safety classification: the explicit `agent.safety`, else
|
|
308
|
+
* inferred from the function `type` (`static`/`query` are read-only, the rest
|
|
309
|
+
* mutate). Shared by every agent surface (MCP host, WebMCP, in-page bridge).
|
|
310
|
+
*/
|
|
311
|
+
function resolveAgentSafety(type, agent) {
|
|
312
|
+
if (agent.safety) return agent.safety;
|
|
313
|
+
return type === "static" || type === "query" || type == null ? "read" : "action";
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/agent/to-json-schema.ts
|
|
317
|
+
const FALLBACK_OBJECT_SCHEMA = Object.freeze({
|
|
318
|
+
type: "object",
|
|
319
|
+
additionalProperties: true
|
|
320
|
+
});
|
|
321
|
+
/**
|
|
322
|
+
* Convert a Standard Schema to JSON Schema for the agent/MCP surface.
|
|
323
|
+
*
|
|
324
|
+
* Devframe stays validator-neutral, so conversion uses the schema's own
|
|
325
|
+
* [Standard JSON Schema](https://standardschema.dev/) converter
|
|
326
|
+
* (`~standard.jsonSchema`) when the validator provides one; zod 4 does,
|
|
327
|
+
* for example. Validators without a native converter (e.g. valibot) degrade
|
|
328
|
+
* to a permissive object schema rather than pulling in a converter library.
|
|
329
|
+
*/
|
|
330
|
+
function safeToJsonSchema(schema) {
|
|
331
|
+
const standard = schema["~standard"];
|
|
332
|
+
if (standard.jsonSchema) try {
|
|
333
|
+
return standard.jsonSchema.input({ target: "draft-2020-12" });
|
|
334
|
+
} catch {
|
|
335
|
+
return FALLBACK_OBJECT_SCHEMA;
|
|
336
|
+
}
|
|
337
|
+
return FALLBACK_OBJECT_SCHEMA;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* JSON Schema for an RPC function's positional args on the agent/MCP
|
|
341
|
+
* surface. Each positional arg is advertised under `arg0` / `arg1` / …,
|
|
342
|
+
* matching how the agent bridge coerces the incoming object payload back
|
|
343
|
+
* into positional arguments.
|
|
344
|
+
*
|
|
345
|
+
* Returns `{ type: 'object', properties: {} }` when there are no args.
|
|
346
|
+
* @internal
|
|
347
|
+
*/
|
|
348
|
+
function argsToJsonSchema(args) {
|
|
349
|
+
if (!args || args.length === 0) return {
|
|
350
|
+
type: "object",
|
|
351
|
+
properties: {}
|
|
352
|
+
};
|
|
353
|
+
const properties = {};
|
|
354
|
+
const required = [];
|
|
355
|
+
for (let i = 0; i < args.length; i++) {
|
|
356
|
+
const key = `arg${i}`;
|
|
357
|
+
properties[key] = safeToJsonSchema(args[i]);
|
|
358
|
+
required.push(key);
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
type: "object",
|
|
362
|
+
properties,
|
|
363
|
+
required,
|
|
364
|
+
additionalProperties: false
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/tool-input.ts
|
|
369
|
+
/**
|
|
370
|
+
* Convert an object-shaped tool input into positional arguments.
|
|
371
|
+
*
|
|
372
|
+
* Tool schemas expose positional parameters as `arg0`, `arg1`, and so on.
|
|
373
|
+
* Arrays pass through for callers that already provide positional arguments.
|
|
374
|
+
*/
|
|
375
|
+
function collectPositionalArgs(input, argumentCount) {
|
|
376
|
+
if (Array.isArray(input)) return input;
|
|
377
|
+
if (input === void 0 || input === null) return [];
|
|
378
|
+
if (typeof input !== "object") return void 0;
|
|
379
|
+
const record = input;
|
|
380
|
+
if (argumentCount != null) return Array.from({ length: argumentCount }, (_, index) => record[`arg${index}`]);
|
|
381
|
+
if ("arg0" in record) {
|
|
382
|
+
const positional = [];
|
|
383
|
+
while (`arg${positional.length}` in record) positional.push(record[`arg${positional.length}`]);
|
|
384
|
+
return positional;
|
|
385
|
+
}
|
|
386
|
+
return Object.keys(record).length === 0 ? [] : void 0;
|
|
387
|
+
}
|
|
388
|
+
/** Convert tool input for an RPC, preserving an untyped payload as arg 0. */
|
|
389
|
+
function toolInputToRpcArgs(input, argumentCount) {
|
|
390
|
+
return collectPositionalArgs(input, argumentCount) ?? [input];
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
export { defineDiagnostics$1 as a, createBirpc as i, argsToJsonSchema as n, DEVFRAME_EVENTS as o, resolveAgentSafety as r, toolInputToRpcArgs as t };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as RpcFunctionAgentOptions } from "../types-BmDbfHCx.mjs";
|
|
2
|
-
import { $ as DevframeServiceDefinition, B as DevframeDefinition, Bt as AgentTool, Ct as DevframeRpcClientFunctions, Dt as DevframeStorageScope, Et as DevframeHost, F as CreateMcpServerOptions, Ft as AgentHandle, G as DevframeSetupInfo, Gt as DevframeAgentHostEvents, H as DevframeDockDefaults, Ht as AgentToolProvider, I as McpConnectionInfo, It as AgentManifest, J as DevframeSseOptions, Jt as EventsMap, K as DevframeSnapshotRpcEntry, Kt as EventEmitter, L as McpFetchHandler, Lt as AgentResource, Ot as DevframeDiagnosticsHost, P as CreateMcpFetchHandlerOptions, Q as McpSetting, R as McpServerHandle, Rt as AgentResourceContent, St as DevframeViewHost, Tt as DevframeRpcSharedStates, U as DevframeDuplicationStrategy, Ut as AgentToolProviderHandle, V as DevframeDeploymentKind, Vt as AgentToolInput, W as DevframeRpcOptions, Wt as DevframeAgentHost, X as McpAuthorization, Y as DevframeWsOptions, Z as McpRouteOptions, _t as ScopedClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeServiceScopeOf, bt as ScopedSharedStates, c as RpcBroadcastOptions, ct as DevframeServicesScopeRegistry, d as RpcSharedStateHost, dt as DevframeScopedNodeRpc, et as DevframeServiceDescriptor, f as RpcStreamingChannel, ft as DevframeScopedStreamingHost, gt as ScopedBroadcastOptions, ht as DevframeSettingsStore, i as DevframeCapabilities, it as DevframeServiceOf, kt as DevframeDiagnosticsLogger, l as RpcFunctionsHost, lt as DevframeServicesState, m as RpcStreamingHost, mt as DevframeSettingsRegistry, n as ConnectionMetaSse, nt as DevframeServiceInput, o as DevframeNodeContext, ot as DevframeServicesHost, p as RpcStreamingChannelOptions, pt as DevframeSettings, q as DevframeSnapshotRpcInputs, qt as EventUnsubscribe, r as ConnectionMetaWebsocket, rt as DevframeServiceMeta, s as DevframeNodeRpcSession, st as DevframeServicesRegistry, t as ConnectionMeta, tt as DevframeServiceId, u as RpcSharedStateGetOptions, ut as DevframeScopedNodeContext, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, yt as ScopedServerFunctions, z as DevframeCliOptions, zt as AgentResourceInput } from "../context
|
|
2
|
+
import { $ as DevframeServiceDefinition, B as DevframeDefinition, Bt as AgentTool, Ct as DevframeRpcClientFunctions, Dt as DevframeStorageScope, Et as DevframeHost, F as CreateMcpServerOptions, Ft as AgentHandle, G as DevframeSetupInfo, Gt as DevframeAgentHostEvents, H as DevframeDockDefaults, Ht as AgentToolProvider, I as McpConnectionInfo, It as AgentManifest, J as DevframeSseOptions, Jt as EventsMap, K as DevframeSnapshotRpcEntry, Kt as EventEmitter, L as McpFetchHandler, Lt as AgentResource, Ot as DevframeDiagnosticsHost, P as CreateMcpFetchHandlerOptions, Q as McpSetting, R as McpServerHandle, Rt as AgentResourceContent, St as DevframeViewHost, Tt as DevframeRpcSharedStates, U as DevframeDuplicationStrategy, Ut as AgentToolProviderHandle, V as DevframeDeploymentKind, Vt as AgentToolInput, W as DevframeRpcOptions, Wt as DevframeAgentHost, X as McpAuthorization, Y as DevframeWsOptions, Z as McpRouteOptions, _t as ScopedClientFunctions, a as DevframeConnectionConfigsRegistry, at as DevframeServiceScopeOf, bt as ScopedSharedStates, c as RpcBroadcastOptions, ct as DevframeServicesScopeRegistry, d as RpcSharedStateHost, dt as DevframeScopedNodeRpc, et as DevframeServiceDescriptor, f as RpcStreamingChannel, ft as DevframeScopedStreamingHost, gt as ScopedBroadcastOptions, ht as DevframeSettingsStore, i as DevframeCapabilities, it as DevframeServiceOf, kt as DevframeDiagnosticsLogger, l as RpcFunctionsHost, lt as DevframeServicesState, m as RpcStreamingHost, mt as DevframeSettingsRegistry, n as ConnectionMetaSse, nt as DevframeServiceInput, o as DevframeNodeContext, ot as DevframeServicesHost, p as RpcStreamingChannelOptions, pt as DevframeSettings, q as DevframeSnapshotRpcInputs, qt as EventUnsubscribe, r as ConnectionMetaWebsocket, rt as DevframeServiceMeta, s as DevframeNodeRpcSession, st as DevframeServicesRegistry, t as ConnectionMeta, tt as DevframeServiceId, u as RpcSharedStateGetOptions, ut as DevframeScopedNodeContext, vt as ScopedRpcFn, wt as DevframeRpcServerFunctions, xt as SettingsForNamespace, yt as ScopedServerFunctions, z as DevframeCliOptions, zt as AgentResourceInput } from "../context--tVkJw3W.mjs";
|
|
3
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-DWvukRwa.mjs";
|
package/dist/utils/events.d.mts
CHANGED
|
@@ -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
|
|
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--tVkJw3W.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
|
|
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--tVkJw3W.mjs";
|
|
2
2
|
export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devframe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
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",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"skills"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@devframes/agentic": "0.10.
|
|
80
|
+
"@devframes/agentic": "0.10.1",
|
|
81
81
|
"cac": "^7.0.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"pathe": "^2.0.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@devframes/agentic": "0.10.
|
|
98
|
+
"@devframes/agentic": "0.10.1",
|
|
99
99
|
"@standard-schema/spec": "^1.1.0",
|
|
100
100
|
"birpc": "^4.2.0",
|
|
101
101
|
"cac": "^7.0.0",
|