devframe 0.9.19 → 0.10.0
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-B2PZsp-J.mjs +191 -0
- package/dist/{_shared-BIUet_Jh.d.mts → _shared-Dy1UBMUN.d.mts} +13 -14
- package/dist/adapters/build.d.mts +3 -4
- package/dist/adapters/build.mjs +4 -5
- package/dist/adapters/cac.d.mts +3 -4
- package/dist/adapters/cac.mjs +3 -3
- package/dist/adapters/dev.d.mts +8 -8
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +8 -8
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +4 -123
- package/dist/adapters/mcp.mjs +1 -589
- package/dist/agentic-D4QQQUjE.d.mts +30 -0
- package/dist/cli/main.mjs +12 -260
- package/dist/client/index.d.mts +6 -6
- package/dist/client/index.mjs +3 -4
- package/dist/constants.d.mts +2 -1
- package/dist/constants.mjs +2 -1
- package/dist/{context-BA5FPz7K.d.mts → context-B4BKPuaa.d.mts} +1 -1
- package/dist/{context-BLXXjoBW.mjs → context-C141q8H4.mjs} +5 -5
- package/dist/{context-jXO5vzjH.mjs → context-CHpyLX8W.mjs} +1 -1
- package/dist/{context-BLHBDQcZ.d.mts → context-CTAxz9ec.d.mts} +108 -47
- package/dist/{dev-DbWecpjA.mjs → dev-DM1mIlgi.mjs} +16 -24
- package/dist/{diagnostics-DZA6KQ_Z.mjs → diagnostics-Cx4_VjlG.mjs} +11 -3
- package/dist/dist-Bw3EbMj4.mjs +305 -0
- package/dist/dist-CO98PBnQ.mjs +265 -0
- package/dist/{host-agent-C3MBpNCd.mjs → host-agent-ZSKgzMVu.mjs} +2 -7
- package/dist/import-runtime-module-BzlEQ9PI.mjs +24 -0
- package/dist/in-page-channel/index.d.mts +2 -7
- package/dist/in-page-channel/index.mjs +1 -4
- package/dist/index-Bia1vKjL.d.mts +218 -0
- package/dist/{index-r6NstVmM.d.mts → index-CcPSKbxb.d.mts} +2 -2
- package/dist/index-CeEtxDmK.d.mts +78 -0
- package/dist/{index-CiA6C705.d.mts → index-DuEm0sDH.d.mts} +1 -1
- package/dist/index.d.mts +4 -11
- package/dist/index.mjs +1 -10
- package/dist/{instance-registry-DCq762YJ.mjs → instance-registry-DtvYxc0Y.mjs} +1 -1
- package/dist/{instance-shell-C6Vg97lg.d.mts → instance-shell-DOZSxst6.d.mts} +31 -5
- package/dist/{instance-shell-370Oee9K.mjs → instance-shell-wC2sfEU_.mjs} +6 -6
- package/dist/interactive-auth-BCa_iamv.mjs +384 -0
- package/dist/internal/index.d.mts +66 -22
- package/dist/internal/index.mjs +143 -8
- package/dist/mrmime-40h5OOIp.mjs +448 -0
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +2 -4
- package/dist/node/index.mjs +2 -2
- package/dist/{nostics-0sKe5HIj.d.mts → nostics-DWvukRwa.d.mts} +11 -2
- package/dist/{origin-DGDH8BI9.d.mts → origin-CY6BBHOy.d.mts} +14 -1
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +1 -231
- package/dist/{remote-assets-D0StJVLp.mjs → remote-assets-B9MeWmW6.mjs} +2 -2
- package/dist/rpc/client.d.mts +1 -1
- package/dist/rpc/client.mjs +1 -1
- package/dist/rpc/dump.d.mts +2 -1
- package/dist/rpc/index.d.mts +3 -2
- package/dist/rpc/server.d.mts +1 -1
- package/dist/rpc/server.mjs +1 -1
- package/dist/rpc/transports/sse-client.d.mts +1 -1
- package/dist/rpc/transports/sse-server.d.mts +3 -3
- package/dist/rpc/transports/ws-bun.d.mts +2 -2
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-deno.d.mts +2 -2
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/{rpc-core-CvkU23bQ.mjs → rpc-core-BXyMjbKG.mjs} +1 -1
- package/dist/{rpc-core-BlL-Ip8n.d.mts → rpc-core-rLrwFEcw.d.mts} +4 -4
- package/dist/{services-install-Ben4yh52.mjs → services-install-D5YUwFXW.mjs} +17 -1
- package/dist/{sse-client-BcbYwXdD.d.mts → sse-client-DNdscfu_.d.mts} +2 -2
- package/dist/{storage-B70AXK64.mjs → storage-CHD1IkqU.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-D2vGd7-2.d.mts → types-BmDbfHCx.d.mts} +2 -3
- package/dist/utils/debounce.d.mts +50 -0
- package/dist/utils/debounce.mjs +88 -0
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/launch-editor.d.mts +8 -0
- package/dist/utils/launch-editor.mjs +36 -1
- package/dist/utils/nostics.d.mts +2 -2
- package/dist/utils/origin.d.mts +2 -2
- package/dist/utils/origin.mjs +21 -1
- package/dist/utils/remote-assets.mjs +1 -1
- package/dist/utils/serve-static.mjs +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/simple-schema.d.mts +3 -2
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/utils/url.d.mts +31 -0
- package/dist/utils/url.mjs +58 -0
- package/dist/{ws-client-CNpP6Ium.d.mts → ws-client-6Mrz6eC4.d.mts} +2 -2
- package/dist/{ws-server-BB8jhxeT.d.mts → ws-server-y2R76aSW.d.mts} +2 -2
- package/package.json +10 -11
- package/dist/_shared-U8D-xzrp.mjs +0 -115
- package/dist/agent-tool-name-DGzeuWcO.mjs +0 -31
- package/dist/client-assets-DNdhagGm.mjs +0 -16
- package/dist/nostics-DD6gsDZA.mjs +0 -108
- package/dist/recipes/common-rpc-functions.d.mts +0 -70
- package/dist/recipes/common-rpc-functions.mjs +0 -115
- package/dist/simple-schema-Bi40l-P6.mjs +0 -154
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import "./constants.mjs";
|
|
2
|
+
import { t as diagnostics } from "./diagnostics-Cx4_VjlG.mjs";
|
|
3
|
+
import { n as getPort } from "./dist-CZXfGEkd.mjs";
|
|
4
|
+
import { n as isRuntimeModuleResolvable, t as importRuntimeModule } from "./import-runtime-module-BzlEQ9PI.mjs";
|
|
5
|
+
//#region src/utils/url.ts
|
|
6
|
+
/**
|
|
7
|
+
* URL path-joining and slash-normalization helpers shared by the adapters,
|
|
8
|
+
* the RPC clients, and the hub's mount-path plumbing. In-house replacements
|
|
9
|
+
* for the handful of `ufo` functions devframe used, kept dependency-free and
|
|
10
|
+
* browser-safe (pure string operations, no `node:` imports).
|
|
11
|
+
*/
|
|
12
|
+
/** Matches an explicit protocol prefix: `http://`, `wss://`, `file://`, … */
|
|
13
|
+
const PROTOCOL_RE = /^[\w+.-]{2,}:\/\//;
|
|
14
|
+
/** `input` with a leading `/` added when missing. */
|
|
15
|
+
function withLeadingSlash(input) {
|
|
16
|
+
return input.startsWith("/") ? input : `/${input}`;
|
|
17
|
+
}
|
|
18
|
+
/** `input` with a leading `/` removed; a bare `/` stays `/`. */
|
|
19
|
+
function withoutLeadingSlash(input) {
|
|
20
|
+
return (input.startsWith("/") ? input.slice(1) : input) || "/";
|
|
21
|
+
}
|
|
22
|
+
/** `input` with a trailing `/` added when missing. */
|
|
23
|
+
function withTrailingSlash(input) {
|
|
24
|
+
return input.endsWith("/") ? input : `${input}/`;
|
|
25
|
+
}
|
|
26
|
+
/** `input` with a trailing `/` removed; a bare `/` stays `/`. */
|
|
27
|
+
function withoutTrailingSlash(input) {
|
|
28
|
+
return (input.endsWith("/") ? input.slice(0, -1) : input) || "/";
|
|
29
|
+
}
|
|
30
|
+
/** Collapses runs of `/` in every path portion, preserving `://`. */
|
|
31
|
+
function cleanDoubleSlashes(input) {
|
|
32
|
+
return input.split("://").map((part) => part.replace(/\/{2,}/g, "/")).join("://");
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Joins path segments onto `base` with exactly one `/` at each seam.
|
|
36
|
+
* A segment's leading `/` or `./` is dropped; empty and bare-`/` segments
|
|
37
|
+
* are skipped; the last segment's trailing slash is preserved.
|
|
38
|
+
*/
|
|
39
|
+
function joinURL(base, ...segments) {
|
|
40
|
+
let url = base;
|
|
41
|
+
for (const segment of segments) {
|
|
42
|
+
if (!segment || segment === "/") continue;
|
|
43
|
+
url = url ? withTrailingSlash(url) + segment.replace(/^\.?\//, "") : segment;
|
|
44
|
+
}
|
|
45
|
+
return url;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Prefixes `input` with `base` unless it already carries the prefix or is an
|
|
49
|
+
* absolute URL with a protocol. An empty or `/` base is a no-op.
|
|
50
|
+
*/
|
|
51
|
+
function withBase(input, base) {
|
|
52
|
+
if (!base || base === "/" || PROTOCOL_RE.test(input)) return input;
|
|
53
|
+
const prefix = withoutTrailingSlash(base);
|
|
54
|
+
return input.startsWith(prefix) ? input : joinURL(prefix, input);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/node/agentic.ts
|
|
58
|
+
const AGENTIC_PACKAGE = "@devframes/agentic";
|
|
59
|
+
/**
|
|
60
|
+
* Whether `@devframes/agentic` is resolvable from devframe's own location
|
|
61
|
+
* (where its optional peer is linked). A pure `require.resolve` probe: no
|
|
62
|
+
* module is loaded, so the `'auto'` miss path stays zero-cost.
|
|
63
|
+
*/
|
|
64
|
+
function isAgenticInstalled(pkg = AGENTIC_PACKAGE) {
|
|
65
|
+
return isRuntimeModuleResolvable(`${pkg}/package.json`);
|
|
66
|
+
}
|
|
67
|
+
let warnedMissing = false;
|
|
68
|
+
/** Report DF0078 (agent surface without `@devframes/agentic`) once per process. */
|
|
69
|
+
function warnAgenticMcpMissingOnce() {
|
|
70
|
+
if (warnedMissing) return;
|
|
71
|
+
warnedMissing = true;
|
|
72
|
+
diagnostics.DF0078();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Load the MCP adapter from `@devframes/agentic/mcp`, mapping a failed load
|
|
76
|
+
* (typically: the optional peer is not installed) to a thrown `DF0079`.
|
|
77
|
+
* Loads through `importRuntimeModule`, so the adapter and the MCP SDK behind
|
|
78
|
+
* it never enter a consumer's bundle graph.
|
|
79
|
+
*/
|
|
80
|
+
async function importAgenticMcp(specifier = `${AGENTIC_PACKAGE}/mcp`) {
|
|
81
|
+
try {
|
|
82
|
+
return await importRuntimeModule(specifier);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
85
|
+
throw diagnostics.DF0079({
|
|
86
|
+
reason,
|
|
87
|
+
cause: error
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/adapters/_shared.ts
|
|
93
|
+
const DEFAULT_PORT = 9999;
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the mount base path for a devframe's SPA. Hosted adapters
|
|
96
|
+
* (`vite`, `embedded`) default to `/__<id>/` so they don't collide
|
|
97
|
+
* with the host app; standalone adapters (`cli`, `build`)
|
|
98
|
+
* default to `/` because they own the origin.
|
|
99
|
+
*
|
|
100
|
+
* The devframe author can override with `basePath` on the definition.
|
|
101
|
+
*/
|
|
102
|
+
function resolveBasePath(def, kind) {
|
|
103
|
+
if (def.basePath) return normalizeBasePath(def.basePath);
|
|
104
|
+
return kind === "standalone" ? "/" : `/__${def.id}/`;
|
|
105
|
+
}
|
|
106
|
+
function normalizeBasePath(base) {
|
|
107
|
+
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolve the listening port for `createDevServer` (and `createHandler`'s
|
|
111
|
+
* side-car tiers), honoring the definition's `cli.port` / `cli.portRange` /
|
|
112
|
+
* `cli.random` settings. Exposed separately so authors who run their own
|
|
113
|
+
* argv parsing can resolve a port up-front (to print it, log it, etc.)
|
|
114
|
+
* before starting the server.
|
|
115
|
+
*/
|
|
116
|
+
async function resolveDevServerPort(def, options = {}) {
|
|
117
|
+
const host = options.host ?? def.cli?.host ?? "localhost";
|
|
118
|
+
const portOptions = {
|
|
119
|
+
port: options.defaultPort ?? def.cli?.port ?? DEFAULT_PORT,
|
|
120
|
+
host
|
|
121
|
+
};
|
|
122
|
+
if (def.cli?.portRange) portOptions.portRange = def.cli.portRange;
|
|
123
|
+
if (def.cli?.random) portOptions.random = def.cli.random;
|
|
124
|
+
return getPort(portOptions);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Normalize an *explicit* `mcp` setting into a fully-resolved config, or
|
|
128
|
+
* `undefined` when the MCP route is disabled. `'auto'` also resolves to
|
|
129
|
+
* `undefined` here: whether it mounts depends on the live agent surface,
|
|
130
|
+
* which only the mounting adapter can consult (through
|
|
131
|
+
* {@link loadAutoMcpAdapter}) - static resolvers like
|
|
132
|
+
* `resolveMcpConnectionMeta` treat it as unadvertisable.
|
|
133
|
+
*
|
|
134
|
+
* An enabled route trusts same-machine callers by default: the authorization
|
|
135
|
+
* resolves to origin-only (`false`) unless the object config opts into a
|
|
136
|
+
* bearer/callback identity check. An empty-string bearer is treated as no
|
|
137
|
+
* bearer (origin-only) rather than a usable credential.
|
|
138
|
+
*/
|
|
139
|
+
function resolveMcpConfig(mcp) {
|
|
140
|
+
if (!mcp || mcp === "auto") return void 0;
|
|
141
|
+
if (mcp === true) return { authorization: false };
|
|
142
|
+
const authorization = typeof mcp.authorization === "string" && mcp.authorization.length === 0 ? false : mcp.authorization ?? false;
|
|
143
|
+
return {
|
|
144
|
+
...mcp.path !== void 0 ? { path: mcp.path } : {},
|
|
145
|
+
...mcp.allowedOrigins !== void 0 ? { allowedOrigins: mcp.allowedOrigins } : {},
|
|
146
|
+
authorization
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Resolve the `mcp: 'auto'` default at mount time: import the MCP adapter
|
|
151
|
+
* from the optional `@devframes/agentic` peer when the devframe's agent
|
|
152
|
+
* surface is non-empty, or return `undefined` (mount nothing) when the
|
|
153
|
+
* surface is empty - the zero-cost path, loading no MCP code at all. A
|
|
154
|
+
* non-empty surface with the peer absent also mounts nothing, reporting a
|
|
155
|
+
* one-time DF0078 warning instead. The adapter (and the MCP SDK behind it)
|
|
156
|
+
* loads through `importRuntimeModule`, so it never enters a consumer's
|
|
157
|
+
* bundle graph.
|
|
158
|
+
*/
|
|
159
|
+
async function loadAutoMcpAdapter(agent) {
|
|
160
|
+
if (!agent.hasSurface()) return void 0;
|
|
161
|
+
if (!isAgenticInstalled()) {
|
|
162
|
+
warnAgenticMcpMissingOnce();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
return await importAgenticMcp();
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Resolve the `mcp` entry a `__connection.json` should advertise for a dev
|
|
169
|
+
* server started with the given `mcp` option, or `undefined` when the route
|
|
170
|
+
* is disabled. `'auto'` (the omitted default) resolves at mount time against
|
|
171
|
+
* the live agent surface, so hand-rolled meta advertises it only for an
|
|
172
|
+
* explicit setting; the adapters advertise the actually-mounted route
|
|
173
|
+
* themselves.
|
|
174
|
+
*
|
|
175
|
+
* Hosted bridges that hand-roll their connection meta pass the side-car
|
|
176
|
+
* `port`: the advertised path becomes absolute (the side-car mounts at `/`)
|
|
177
|
+
* and the client dials `<page-host>:<port><path>`. Without `port` the path
|
|
178
|
+
* stays relative, resolved against `__connection.json`'s own location (the
|
|
179
|
+
* same-server default).
|
|
180
|
+
*/
|
|
181
|
+
function resolveMcpConnectionMeta(mcp, port) {
|
|
182
|
+
const config = resolveMcpConfig(mcp);
|
|
183
|
+
if (!config) return void 0;
|
|
184
|
+
const route = withoutLeadingSlash(config.path ?? "__mcp");
|
|
185
|
+
return port != null ? {
|
|
186
|
+
path: withLeadingSlash(route),
|
|
187
|
+
port
|
|
188
|
+
} : { path: route };
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
export { resolveMcpConfig as a, joinURL as c, withoutLeadingSlash as d, withoutTrailingSlash as f, resolveDevServerPort as i, withBase as l, normalizeBasePath as n, resolveMcpConnectionMeta as o, resolveBasePath as r, importAgenticMcp as s, loadAutoMcpAdapter as t, withLeadingSlash as u };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as DevframeDefinition, Q as McpSetting, V as DevframeDeploymentKind, Wt as DevframeAgentHost, X as McpAuthorization, t as ConnectionMeta } from "./context-CTAxz9ec.mjs";
|
|
2
|
+
import { t as AgenticMcpModule } from "./agentic-D4QQQUjE.mjs";
|
|
2
3
|
//#region src/adapters/_shared.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Resolve the mount base path for a devframe's SPA. Hosted adapters
|
|
@@ -53,21 +54,19 @@ interface ResolvedMcpConfig {
|
|
|
53
54
|
declare function resolveMcpConfig(mcp: McpSetting | undefined): ResolvedMcpConfig | undefined;
|
|
54
55
|
/**
|
|
55
56
|
* Resolve the `mcp: 'auto'` default at mount time: import the MCP adapter
|
|
56
|
-
* when the devframe's agent
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* no type-level dependency on the MCP adapter.
|
|
57
|
+
* from the optional `@devframes/agentic` peer when the devframe's agent
|
|
58
|
+
* surface is non-empty, or return `undefined` (mount nothing) when the
|
|
59
|
+
* surface is empty - the zero-cost path, loading no MCP code at all. A
|
|
60
|
+
* non-empty surface with the peer absent also mounts nothing, reporting a
|
|
61
|
+
* one-time DF0078 warning instead. The adapter (and the MCP SDK behind it)
|
|
62
|
+
* loads through `importRuntimeModule`, so it never enters a consumer's
|
|
63
|
+
* bundle graph.
|
|
64
64
|
*/
|
|
65
|
-
declare function loadAutoMcpAdapter
|
|
65
|
+
declare function loadAutoMcpAdapter(agent: Pick<DevframeAgentHost, 'hasSurface'>): Promise<AgenticMcpModule | undefined>;
|
|
66
66
|
/**
|
|
67
67
|
* Resolve the `mcp` entry a `__connection.json` should advertise for a dev
|
|
68
|
-
* server started with the given `mcp` option
|
|
69
|
-
*
|
|
70
|
-
* disabled. `'auto'` (the omitted default) resolves at mount time against
|
|
68
|
+
* server started with the given `mcp` option, or `undefined` when the route
|
|
69
|
+
* is disabled. `'auto'` (the omitted default) resolves at mount time against
|
|
71
70
|
* the live agent surface, so hand-rolled meta advertises it only for an
|
|
72
71
|
* explicit setting; the adapters advertise the actually-mounted route
|
|
73
72
|
* themselves.
|
|
@@ -78,6 +77,6 @@ declare function loadAutoMcpAdapter<T>(agent: Pick<DevframeAgentHost, 'hasSurfac
|
|
|
78
77
|
* stays relative, resolved against `__connection.json`'s own location (the
|
|
79
78
|
* same-server default).
|
|
80
79
|
*/
|
|
81
|
-
declare function resolveMcpConnectionMeta(
|
|
80
|
+
declare function resolveMcpConnectionMeta(mcp: McpSetting | undefined, port?: number): ConnectionMeta['mcp'];
|
|
82
81
|
//#endregion
|
|
83
82
|
export { resolveBasePath as a, resolveMcpConnectionMeta as c, normalizeBasePath as i, ResolvedMcpConfig as n, resolveDevServerPort as o, loadAutoMcpAdapter as r, resolveMcpConfig as s, ResolveDevServerPortOptions as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as DevframeDefinition, K as DevframeSnapshotRpcEntry, o as DevframeNodeContext } from "../context-CTAxz9ec.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 {
|
|
@@ -7,9 +7,8 @@ export interface CreateBuildOptions {
|
|
|
7
7
|
/**
|
|
8
8
|
* Override the SPA dist to copy into `outDir`: a local directory or a
|
|
9
9
|
* remote-assets declaration (materialized in full at build time). When
|
|
10
|
-
* omitted the adapter reads `devframe.clientAssets
|
|
11
|
-
*
|
|
12
|
-
* definition itself.
|
|
10
|
+
* omitted the adapter reads `devframe.clientAssets`; authors typically set
|
|
11
|
+
* this once on the definition itself.
|
|
13
12
|
*/
|
|
14
13
|
distDir?: StaticAssetsSource;
|
|
15
14
|
/**
|
package/dist/adapters/build.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { s as colors } from "../nostics-D0PvLZsn.mjs";
|
|
2
|
-
import { t as resolveClientAssets } from "../client-assets-DNdhagGm.mjs";
|
|
3
2
|
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
|
|
4
3
|
import { n as collectStaticRpcDump, t as writeStaticRpcDump } from "../write-DoXJzGUH.mjs";
|
|
5
|
-
import { t as diagnostics } from "../diagnostics-
|
|
6
|
-
import { t as createHostContext } from "../context-
|
|
7
|
-
import { t as resolveStaticAssetsSource } from "../remote-assets-
|
|
4
|
+
import { t as diagnostics } from "../diagnostics-Cx4_VjlG.mjs";
|
|
5
|
+
import { t as createHostContext } from "../context-C141q8H4.mjs";
|
|
6
|
+
import { t as resolveStaticAssetsSource } from "../remote-assets-B9MeWmW6.mjs";
|
|
8
7
|
import { t as createH3DevframeHost } from "../host-h3-BROI6SQ4.mjs";
|
|
9
8
|
import fs from "node:fs/promises";
|
|
10
9
|
import { resolve } from "pathe";
|
|
@@ -25,7 +24,7 @@ import { existsSync } from "node:fs";
|
|
|
25
24
|
async function createBuild(d, options = {}) {
|
|
26
25
|
if (d.capabilities?.build === false && !options.force) throw diagnostics.DF0042({ id: d.id });
|
|
27
26
|
const outDir = resolve(options.outDir ?? "dist-static");
|
|
28
|
-
const distSource = options.distDir ??
|
|
27
|
+
const distSource = options.distDir ?? d.clientAssets;
|
|
29
28
|
if (!distSource) throw new Error(`[devframe] createBuild: no client assets for "${d.id}". Set \`clientAssets\` on the definition or pass it as an option.`);
|
|
30
29
|
if (existsSync(outDir)) await fs.rm(outDir, { recursive: true });
|
|
31
30
|
await fs.mkdir(outDir, { recursive: true });
|
package/dist/adapters/cac.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as DevframeDefinition, Mt as InferCliFlags, Nt as defineCliFlags, Pt as parseCliFlags, Q as McpSetting, jt as CliFlagsSchema } from "../context-CTAxz9ec.mjs";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
//#region src/adapters/cac.d.ts
|
|
@@ -9,9 +9,8 @@ export interface CreateCacOptions {
|
|
|
9
9
|
* Expose a route-based MCP server alongside the dev server, speaking the
|
|
10
10
|
* MCP Streamable-HTTP transport at `<base>__mcp`. Whether to expose MCP is
|
|
11
11
|
* a hosting decision made at the CLI assembly stage, so it lives here rather
|
|
12
|
-
* than on the definition. When unset, falls back to the
|
|
13
|
-
*
|
|
14
|
-
* surface is non-empty). See {@link McpSetting}.
|
|
12
|
+
* than on the definition. When unset, falls back to the `'auto'` default
|
|
13
|
+
* (mount once the agent surface is non-empty). See {@link McpSetting}.
|
|
15
14
|
*
|
|
16
15
|
* The `--mcp` / `--no-mcp` flags override this per run.
|
|
17
16
|
*/
|
package/dist/adapters/cac.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as colors } from "../nostics-D0PvLZsn.mjs";
|
|
2
|
-
import { i as resolveDevServerPort, s as
|
|
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-DM1mIlgi.mjs";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import cac$1 from "cac";
|
|
7
7
|
//#region src/adapters/flags.ts
|
|
@@ -125,7 +125,7 @@ function createCac(d, options = {}) {
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
cli.command("mcp", "Start an MCP server exposing agent-facing tools (stdio)").action(async () => {
|
|
128
|
-
const { createMcpServer } = await
|
|
128
|
+
const { createMcpServer } = await importAgenticMcp();
|
|
129
129
|
await createMcpServer(d, {
|
|
130
130
|
transport: "stdio",
|
|
131
131
|
/** Deliberately go to stderr: stdout is the MCP transport. */
|
package/dist/adapters/dev.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as DevframeAuthHandler, B as DevframeDefinition, J as DevframeSseOptions, Q as McpSetting, Y as DevframeWsOptions, s as DevframeNodeRpcSession } from "../context-CTAxz9ec.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
|
-
import { n as WsOriginRegistry } from "../ws-server-
|
|
5
|
-
import { c as StartedServer } from "../instance-shell-
|
|
6
|
-
import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-
|
|
4
|
+
import { n as WsOriginRegistry } from "../ws-server-y2R76aSW.mjs";
|
|
5
|
+
import { c as StartedServer } from "../instance-shell-DOZSxst6.mjs";
|
|
6
|
+
import { c as resolveMcpConnectionMeta, o as resolveDevServerPort, t as ResolveDevServerPortOptions } from "../_shared-Dy1UBMUN.mjs";
|
|
7
7
|
import { H3 } from "h3";
|
|
8
8
|
//#region src/adapters/dev.d.ts
|
|
9
9
|
export interface CreateDevServerOptions {
|
|
@@ -22,7 +22,7 @@ export interface CreateDevServerOptions {
|
|
|
22
22
|
*/
|
|
23
23
|
flags?: Record<string, unknown>;
|
|
24
24
|
/**
|
|
25
|
-
* Override the definition's `clientAssets
|
|
25
|
+
* Override the definition's `clientAssets`.
|
|
26
26
|
* When neither this option nor the definition's client assets are set, the
|
|
27
27
|
* dev server runs in **bridge mode**: only `__connection.json` and the WS
|
|
28
28
|
* endpoint are mounted; the SPA is expected to be hosted elsewhere (e.g. by
|
|
@@ -82,9 +82,9 @@ export interface CreateDevServerOptions {
|
|
|
82
82
|
auth?: boolean | DevframeAuthHandler;
|
|
83
83
|
/**
|
|
84
84
|
* Expose a route-based MCP server on the dev server (Streamable-HTTP).
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
85
|
+
* `undefined` falls through to the `'auto'` default (mount once the agent
|
|
86
|
+
* surface is non-empty). `false` disables the route regardless. See
|
|
87
|
+
* {@link McpSetting}.
|
|
88
88
|
*/
|
|
89
89
|
mcp?: McpSetting;
|
|
90
90
|
/**
|
package/dist/adapters/dev.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as resolveDevServerPort, o as resolveMcpConnectionMeta } from "../_shared-
|
|
2
|
-
import { t as createDevServer } from "../dev-
|
|
1
|
+
import { i as resolveDevServerPort, o as resolveMcpConnectionMeta } from "../_shared-B2PZsp-J.mjs";
|
|
2
|
+
import { t as createDevServer } from "../dev-DM1mIlgi.mjs";
|
|
3
3
|
export { createDevServer, resolveDevServerPort, resolveMcpConnectionMeta };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as DevframeDefinition, o as DevframeNodeContext } from "../context-CTAxz9ec.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 {
|
|
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-CTAxz9ec.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
|
-
import { n as WsOriginRegistry } from "../ws-server-
|
|
5
|
-
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-
|
|
4
|
+
import { n as WsOriginRegistry } from "../ws-server-y2R76aSW.mjs";
|
|
5
|
+
import { c as StartedServer, f as DevframeInstanceRecord } from "../instance-shell-DOZSxst6.mjs";
|
|
6
6
|
import { H3 } from "h3";
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
8
8
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
@@ -19,8 +19,8 @@ export interface InitDevframeOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
base: string;
|
|
21
21
|
/**
|
|
22
|
-
* Override the definition's `clientAssets
|
|
23
|
-
* When
|
|
22
|
+
* Override the definition's `clientAssets`.
|
|
23
|
+
* When it is unset (or `false` is passed to suppress the definition's
|
|
24
24
|
* own client assets), the handler runs in **bridge mode**: only
|
|
25
25
|
* `__connection.json`, the WS endpoint, and the MCP route (when enabled) are
|
|
26
26
|
* served; the SPA is hosted elsewhere.
|
|
@@ -73,9 +73,9 @@ export interface InitDevframeOptions {
|
|
|
73
73
|
auth?: boolean | DevframeAuthHandler;
|
|
74
74
|
/**
|
|
75
75
|
* Expose a route-based MCP server (Streamable-HTTP) at `<base>__mcp` and
|
|
76
|
-
* advertise it in `__connection.json`.
|
|
77
|
-
* `
|
|
78
|
-
*
|
|
76
|
+
* advertise it in `__connection.json`. `undefined` falls through to the
|
|
77
|
+
* `'auto'` default (mount once the agent surface is non-empty). See
|
|
78
|
+
* {@link McpSetting}.
|
|
79
79
|
*/
|
|
80
80
|
mcp?: McpSetting;
|
|
81
81
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getInstanceInternals, r as initDevframe } from "../dev-
|
|
1
|
+
import { n as getInstanceInternals, r as initDevframe } from "../dev-DM1mIlgi.mjs";
|
|
2
2
|
export { getInstanceInternals, initDevframe };
|
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -1,123 +1,4 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
import {
|
|
3
|
-
import "@
|
|
4
|
-
|
|
5
|
-
interface CreateMcpServerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Transport to use. `createMcpServer` itself runs `'stdio'` (a standalone
|
|
8
|
-
* process with its own host context); the Streamable-HTTP transport is
|
|
9
|
-
* served route-based by the dev server instead; see `mountMcpHttp` and
|
|
10
|
-
* the `mcp` option on `createDevServer` / `createCac`'s `--mcp` flag.
|
|
11
|
-
*/
|
|
12
|
-
transport?: 'stdio';
|
|
13
|
-
/**
|
|
14
|
-
* Expose shared-state keys as MCP resources.
|
|
15
|
-
* - `true` (default): every key the host publishes
|
|
16
|
-
* - `false`: none
|
|
17
|
-
* - `(key) => boolean`: filter
|
|
18
|
-
*/
|
|
19
|
-
exposeSharedState?: boolean | ((key: string) => boolean);
|
|
20
|
-
/** Override the name reported in the MCP handshake. */
|
|
21
|
-
serverName?: string;
|
|
22
|
-
/** Override the version reported in the MCP handshake. Defaults to `definition.version ?? '0.0.0'`. */
|
|
23
|
-
serverVersion?: string;
|
|
24
|
-
/** Called once the transport is connected. */
|
|
25
|
-
onReady?: (info: {
|
|
26
|
-
transport: 'stdio';
|
|
27
|
-
}) => void;
|
|
28
|
-
}
|
|
29
|
-
interface McpServerHandle {
|
|
30
|
-
stop: () => Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Build an MCP server over the agent surface of a devframe definition.
|
|
34
|
-
* Currently supports `stdio` transport only.
|
|
35
|
-
*/
|
|
36
|
-
export declare function createMcpServer(definition: DevframeDefinition, options?: CreateMcpServerOptions): Promise<McpServerHandle>;
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/adapters/mcp/fetch.d.ts
|
|
39
|
-
interface CreateMcpFetchHandlerOptions {
|
|
40
|
-
/** Name reported in the MCP handshake. */
|
|
41
|
-
serverName: string;
|
|
42
|
-
/** Version reported in the MCP handshake. */
|
|
43
|
-
serverVersion: string;
|
|
44
|
-
/** Expose shared-state keys as MCP resources; see `buildMcpServerFromContext`. */
|
|
45
|
-
exposeSharedState: boolean | ((key: string) => boolean);
|
|
46
|
-
/**
|
|
47
|
-
* Optional identity check, layered on top of the origin gate and checked
|
|
48
|
-
* **after** it: a bearer token string (matched in constant time against
|
|
49
|
-
* `Authorization: Bearer <token>`), a `(request) => boolean` callback, or
|
|
50
|
-
* `false` (the default) for origin-only, trusting same-machine callers. A
|
|
51
|
-
* callback governs identity only and cannot relax the origin gate. See
|
|
52
|
-
* {@link McpAuthorization}.
|
|
53
|
-
*/
|
|
54
|
-
authorization?: McpAuthorization;
|
|
55
|
-
/**
|
|
56
|
-
* Origin allow-list beyond the loopback default. `false` disables the
|
|
57
|
-
* origin gate entirely. Default: loopback-only.
|
|
58
|
-
*
|
|
59
|
-
* Unlike the WS transport, the MCP route does **not** allow `Origin`-less
|
|
60
|
-
* requests: a route-based endpoint is reachable by any local process, so a
|
|
61
|
-
* request must carry an `Origin` that passes the gate. Native clients
|
|
62
|
-
* (e.g. `devframe connect`) send their loopback origin explicitly.
|
|
63
|
-
*/
|
|
64
|
-
allowedOrigins?: readonly string[] | false;
|
|
65
|
-
}
|
|
66
|
-
interface McpFetchHandler {
|
|
67
|
-
/**
|
|
68
|
-
* WHATWG-`fetch` handler for the MCP endpoint. Hand every method
|
|
69
|
-
* (POST/GET/DELETE) on the endpoint's path to it; routing by path is the
|
|
70
|
-
* host's job.
|
|
71
|
-
*/
|
|
72
|
-
fetch: (request: Request) => Promise<Response>;
|
|
73
|
-
/** Tear down the handler (aborts in-flight exchanges, drops the change bridge). */
|
|
74
|
-
dispose: () => Promise<void>;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Build a framework-agnostic MCP endpoint over a devframe context: a
|
|
78
|
-
* web-standard `Request → Response` handler any host can mount: h3 (see
|
|
79
|
-
* `mountMcpHttp`), a Next.js App Router route, or any other fetch-shaped
|
|
80
|
-
* server.
|
|
81
|
-
*
|
|
82
|
-
* The endpoint is **stateless**: it serves the 2026-07-28 revision per request
|
|
83
|
-
* through the SDK's {@link createMcpHandler}, which builds a fresh MCP server
|
|
84
|
-
* (from the shared, live `ctx` via `buildMcpServerFromContext`) for each
|
|
85
|
-
* request: no `Mcp-Session-Id` registry, no session-local routing, no
|
|
86
|
-
* GET/DELETE teardown protocol. 2025-era clients are still served through the
|
|
87
|
-
* SDK's default stateless legacy path. `list_changed` events reach modern
|
|
88
|
-
* `subscriptions/listen` streams through the handler's `notify` bus.
|
|
89
|
-
*
|
|
90
|
-
* The origin gate guards every request: loopback-default DNS-rebinding
|
|
91
|
-
* protection that (unlike the WS upgrade's `isAllowedOrigin`) also rejects
|
|
92
|
-
* `Origin`-less requests, so a route-based endpoint isn't reachable by a
|
|
93
|
-
* browser or a remote host (a disallowed origin gets `403`). It trusts
|
|
94
|
-
* same-machine callers by default. When that isn't your trust boundary, add
|
|
95
|
-
* an optional identity gate ({@link CreateMcpFetchHandlerOptions.authorization}),
|
|
96
|
-
* checked after the origin gate: a bearer/callback check that proves *who* is
|
|
97
|
-
* calling (a missing/invalid credential gets `401` with a
|
|
98
|
-
* `WWW-Authenticate: Bearer` challenge).
|
|
99
|
-
*/
|
|
100
|
-
export declare function createMcpFetchHandler(ctx: DevframeNodeContext, options: CreateMcpFetchHandlerOptions): McpFetchHandler;
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/adapters/mcp/http.d.ts
|
|
103
|
-
interface MountMcpHttpOptions extends CreateMcpFetchHandlerOptions {}
|
|
104
|
-
interface MountedMcpHttp {
|
|
105
|
-
/** Tear down the MCP handler (aborts in-flight exchanges, drops the change bridge). */
|
|
106
|
-
dispose: () => Promise<void>;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Mount a stateless MCP endpoint on an h3 app at `path`: the h3 binding over
|
|
110
|
-
* {@link createMcpFetchHandler}, which owns the per-request serving, the
|
|
111
|
-
* origin gate, and the transport plumbing.
|
|
112
|
-
*
|
|
113
|
-
* The handler is web-standard: it takes the h3 event's web `Request` and
|
|
114
|
-
* returns a web `Response` (an SSE `ReadableStream` body for a
|
|
115
|
-
* `subscriptions/listen` stream). We copy that response onto `event.res` and
|
|
116
|
-
* return its body rather than returning the `Response` object directly, so an
|
|
117
|
-
* MCP error response (e.g. a 4xx) isn't swallowed by h3's "Response-with-404
|
|
118
|
-
* falls through to the next handler" rule (which would otherwise hand the
|
|
119
|
-
* request to the SPA static catch-all).
|
|
120
|
-
*/
|
|
121
|
-
export declare function mountMcpHttp(app: H3, ctx: DevframeNodeContext, path: string, options: MountMcpHttpOptions): MountedMcpHttp;
|
|
122
|
-
//#endregion
|
|
123
|
-
export type { CreateMcpFetchHandlerOptions, CreateMcpServerOptions, McpFetchHandler, McpServerHandle, MountMcpHttpOptions, MountedMcpHttp };
|
|
1
|
+
import { F as CreateMcpServerOptions, I as McpConnectionInfo, L as McpFetchHandler, P as CreateMcpFetchHandlerOptions, R as McpServerHandle } from "../context-CTAxz9ec.mjs";
|
|
2
|
+
import { n as MountMcpHttpOptions, r as MountedMcpHttp } from "../agentic-D4QQQUjE.mjs";
|
|
3
|
+
import { createMcpFetchHandler, createMcpServer, mountMcpHttp } from "@devframes/agentic/mcp";
|
|
4
|
+
export { type CreateMcpFetchHandlerOptions, type CreateMcpServerOptions, type McpConnectionInfo, type McpFetchHandler, type McpServerHandle, type MountMcpHttpOptions, type MountedMcpHttp, createMcpFetchHandler, createMcpServer, mountMcpHttp };
|