devframe 0.7.16 → 0.8.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/bin/devframe.mjs +8 -0
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/build.mjs +4 -4
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +1 -1
- package/dist/adapters/cli.d.mts +1 -1
- package/dist/adapters/cli.mjs +1 -1
- package/dist/adapters/dev.d.mts +2 -2
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/mcp.d.mts +51 -3
- package/dist/adapters/mcp.mjs +2 -2
- package/dist/agent-tool-name-C3b5vEwJ.mjs +34 -0
- package/dist/{cac-CPaOy3LD.mjs → cac-B1LM3zit.mjs} +18 -13
- package/dist/cli/main.d.mts +11 -0
- package/dist/cli/main.mjs +284 -0
- package/dist/client/index.d.mts +40 -11
- package/dist/client/index.mjs +129 -19
- package/dist/constants.d.mts +13 -6
- package/dist/constants.mjs +13 -6
- package/dist/{context-DY72brRI.mjs → context-CQefP2jR.mjs} +3 -2
- package/dist/{context-CzqPrJSz.d.mts → context-DFzmxCLa.d.mts} +1 -1
- package/dist/{revoke-BtQDKTp7.mjs → crypto-token-XCqTSMg9.mjs} +1 -35
- package/dist/{dev-BCeaQuGE.mjs → dev-BSHFZGZr.mjs} +22 -11
- package/dist/{devframe-Ckhf3kFw.d.mts → devframe-qgCKL683.d.mts} +77 -15
- package/dist/diagnostics-B5-qHeqD.mjs +94 -0
- package/dist/{diagnostics-BXwBQmoN.mjs → diagnostics-hwjXp_UV.mjs} +8 -0
- package/dist/{dump-Cz7yVvsB.mjs → dump-CgZShDRB.mjs} +82 -6
- package/dist/fetch-CK0S253E.mjs +534 -0
- package/dist/helpers/vite.d.mts +15 -14
- package/dist/helpers/vite.mjs +8 -8
- package/dist/{host-h3-CgOetlNE.mjs → host-h3-Kz7t5Xab.mjs} +83 -28
- package/dist/http-Dvgxujcu.mjs +38 -0
- package/dist/{index-8dndvIxR.d.mts → index-B7RgLw--.d.mts} +11 -6
- package/dist/{index-DgsLFhZg.d.mts → index-Dbw1p5ch.d.mts} +27 -3
- package/dist/{index-YDSJgsyG.d.mts → index-vAX6bYuc.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/instance-registry-D6fxYu36.mjs +190 -0
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/auth.mjs +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +1 -1
- package/dist/node/index.d.mts +124 -6
- package/dist/node/index.mjs +5 -4
- package/dist/recipes/common-rpc-functions.d.mts +33 -33
- package/dist/recipes/common-rpc-functions.mjs +6 -6
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +23 -15
- package/dist/revoke-DZbJ7Cl0.mjs +35 -0
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +3 -3
- package/dist/rpc/index.mjs +4 -4
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +1 -1
- package/dist/rpc/transports/ws-server.d.mts +2 -2
- package/dist/rpc/transports/ws-server.mjs +50 -3
- package/dist/{serialization-DpLXCy13.mjs → serialization-C8Mnw9hK.mjs} +1 -1
- package/dist/{server-DykHCza_.mjs → server-CXaDDUl0.mjs} +2 -2
- package/dist/{server-B0wiP_Oi.d.mts → server-E9z4ZWbd.d.mts} +4 -3
- package/dist/simple-schema-BDzLeJDk.d.mts +102 -0
- package/dist/simple-schema-DQPZrAaZ.mjs +154 -0
- package/dist/{state-WX3HT5a3.mjs → state-BeUHDDjk.mjs} +13 -6
- package/dist/{storage-gEnj9ASQ.mjs → storage-Dzoc3NVC.mjs} +2 -66
- package/dist/{transports-BmDVn4SF.mjs → transports-vhizgqXM.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-CrzNxXKq.d.mts → types-CnJSgRVa.d.mts} +33 -19
- package/dist/utils/agent-tool-name.d.mts +27 -0
- package/dist/utils/agent-tool-name.mjs +34 -0
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/simple-schema.d.mts +2 -0
- package/dist/utils/simple-schema.mjs +154 -0
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{ws-client-DSXiI2h7.d.mts → ws-client-B6Tnr0ic.d.mts} +1 -1
- package/dist/{ws-server-9-wn7MNQ.d.mts → ws-server-J-zkiOyp.d.mts} +24 -3
- package/package.json +18 -7
- package/skills/devframe/SKILL.md +4 -3
- package/dist/build-server-C7vTKjiQ.mjs +0 -359
- package/dist/http-_pPbryTQ.mjs +0 -114
package/dist/http-_pPbryTQ.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { isAllowedOrigin } from "./rpc/transports/ws-server.mjs";
|
|
2
|
-
import { t as buildMcpServerFromContext } from "./build-server-C7vTKjiQ.mjs";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { defineHandler } from "h3";
|
|
5
|
-
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
-
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
7
|
-
//#region src/adapters/mcp/http.ts
|
|
8
|
-
/**
|
|
9
|
-
* Mount an MCP Streamable-HTTP endpoint on an h3 app at `path`.
|
|
10
|
-
*
|
|
11
|
-
* Each MCP session gets its own {@link WebStandardStreamableHTTPServerTransport}
|
|
12
|
-
* and MCP server (built from the shared, live `ctx` via
|
|
13
|
-
* `buildMcpServerFromContext`), correlated by the `Mcp-Session-Id` header:
|
|
14
|
-
* an `initialize` POST spins up a session; later requests route to it; a
|
|
15
|
-
* `DELETE` (or client disconnect) tears it down.
|
|
16
|
-
*
|
|
17
|
-
* The transport is web-standard — its `handleRequest` takes the h3 event's
|
|
18
|
-
* web `Request` and returns a web `Response` (an SSE `ReadableStream` body
|
|
19
|
-
* for the server→client stream). We copy that response onto `event.res` and
|
|
20
|
-
* return its body rather than returning the `Response` object directly, so a
|
|
21
|
-
* legitimate MCP 404 (unknown session) isn't swallowed by h3's
|
|
22
|
-
* "Response-with-404 falls through to the next handler" rule (which would
|
|
23
|
-
* otherwise hand the request to the SPA static catch-all).
|
|
24
|
-
*
|
|
25
|
-
* @experimental
|
|
26
|
-
*/
|
|
27
|
-
function mountMcpHttp(app, ctx, path, options) {
|
|
28
|
-
const sessions = /* @__PURE__ */ new Map();
|
|
29
|
-
const allowedOrigins = options.allowedOrigins;
|
|
30
|
-
function drop(sessionId) {
|
|
31
|
-
const session = sessions.get(sessionId);
|
|
32
|
-
if (!session) return;
|
|
33
|
-
sessions.delete(sessionId);
|
|
34
|
-
session.dispose();
|
|
35
|
-
}
|
|
36
|
-
async function createSession() {
|
|
37
|
-
let session;
|
|
38
|
-
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
39
|
-
sessionIdGenerator: () => randomUUID(),
|
|
40
|
-
onsessioninitialized: (id) => {
|
|
41
|
-
sessions.set(id, session);
|
|
42
|
-
},
|
|
43
|
-
onsessionclosed: (id) => {
|
|
44
|
-
drop(id);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
const { server, dispose } = buildMcpServerFromContext(ctx, {
|
|
48
|
-
serverName: options.serverName,
|
|
49
|
-
serverVersion: options.serverVersion,
|
|
50
|
-
exposeSharedState: options.exposeSharedState
|
|
51
|
-
});
|
|
52
|
-
session = {
|
|
53
|
-
transport,
|
|
54
|
-
dispose: async () => {
|
|
55
|
-
dispose();
|
|
56
|
-
await server.close();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
transport.onclose = () => {
|
|
60
|
-
if (transport.sessionId) drop(transport.sessionId);
|
|
61
|
-
};
|
|
62
|
-
await server.connect(transport);
|
|
63
|
-
return session;
|
|
64
|
-
}
|
|
65
|
-
app.use(path, defineHandler(async (event) => {
|
|
66
|
-
const req = event.req;
|
|
67
|
-
const origin = req.headers.get("origin") ?? void 0;
|
|
68
|
-
if (allowedOrigins !== false && !isAllowedOrigin(origin, allowedOrigins ?? [])) {
|
|
69
|
-
event.res.status = 403;
|
|
70
|
-
return "Forbidden: origin not allowed";
|
|
71
|
-
}
|
|
72
|
-
const sessionId = req.headers.get("mcp-session-id") ?? void 0;
|
|
73
|
-
let session = sessionId ? sessions.get(sessionId) : void 0;
|
|
74
|
-
if (!session && req.method === "POST") {
|
|
75
|
-
let body;
|
|
76
|
-
try {
|
|
77
|
-
body = await req.json();
|
|
78
|
-
} catch {
|
|
79
|
-
body = void 0;
|
|
80
|
-
}
|
|
81
|
-
if (!sessionId && isInitializeRequest(body)) session = await createSession();
|
|
82
|
-
else {
|
|
83
|
-
event.res.status = sessionId ? 404 : 400;
|
|
84
|
-
return sessionId ? "Not Found: unknown MCP session" : "Bad Request: no valid session ID and not an initialize request";
|
|
85
|
-
}
|
|
86
|
-
return respond(event, await session.transport.handleRequest(req, { parsedBody: body }));
|
|
87
|
-
}
|
|
88
|
-
if (!session) {
|
|
89
|
-
event.res.status = sessionId ? 404 : 400;
|
|
90
|
-
return sessionId ? "Not Found: unknown MCP session" : "Bad Request: missing MCP session ID";
|
|
91
|
-
}
|
|
92
|
-
return respond(event, await session.transport.handleRequest(req));
|
|
93
|
-
}));
|
|
94
|
-
return { dispose: async () => {
|
|
95
|
-
const live = [...sessions.values()];
|
|
96
|
-
sessions.clear();
|
|
97
|
-
await Promise.all(live.map((session) => session.dispose()));
|
|
98
|
-
} };
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Copy a web `Response` from the MCP transport onto the h3 event's response
|
|
102
|
-
* and return its body. Returning the body (a `ReadableStream` or `null`)
|
|
103
|
-
* rather than the `Response` object avoids h3's 404-fall-through behavior.
|
|
104
|
-
*/
|
|
105
|
-
function respond(event, response) {
|
|
106
|
-
event.res.status = response.status;
|
|
107
|
-
event.res.statusText = response.statusText;
|
|
108
|
-
response.headers.forEach((value, key) => {
|
|
109
|
-
event.res.headers.set(key, value);
|
|
110
|
-
});
|
|
111
|
-
return response.body ?? "";
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
export { mountMcpHttp };
|