vite-plugin-aipanel 1.2.3 → 1.2.5
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/es/core/mcp-proxy.mjs +4 -3
- package/es/endpoints/context.mjs +6 -1
- package/es/endpoints/mcp.mjs +4 -1
- package/lib/client.js +2014 -2015
- package/lib/core/mcp-proxy.cjs +4 -3
- package/lib/endpoints/context.cjs +6 -1
- package/lib/endpoints/mcp.cjs +4 -1
- package/package.json +5 -5
package/es/core/mcp-proxy.mjs
CHANGED
|
@@ -55,9 +55,10 @@ class McpProxy {
|
|
|
55
55
|
"--auto-connect",
|
|
56
56
|
"--no-usage-statistics",
|
|
57
57
|
"--no-performance-crux",
|
|
58
|
-
// chrome-devtools-mcp >=1.8.0
|
|
59
|
-
//
|
|
60
|
-
|
|
58
|
+
// chrome-devtools-mcp >=1.8.0 默认开启 pageIdRouting(要求每个页面级工具都传 pageId)。
|
|
59
|
+
// 代理层已自行校验 pageId 并用 select_page 选中目标页面后再转发,故显式关闭,
|
|
60
|
+
// 避免底层工具 schema 强制必填 pageId 导致转发时的参数校验失败。
|
|
61
|
+
"--no-page-id-routing"
|
|
61
62
|
]);
|
|
62
63
|
__privateSet(this, _idleTimeout, options.idleTimeout ?? 0);
|
|
63
64
|
this.sessionId = crypto.randomUUID();
|
package/es/endpoints/context.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CONTEXT_API_PATH } from "@aipanel/core";
|
|
2
2
|
import { RequestContext, createLogger } from "@aipanel/core/node";
|
|
3
|
+
import { ensureNodeId } from "@aipanel/core";
|
|
3
4
|
const log = createLogger("Endpoints:Context");
|
|
4
5
|
function setupContextEndpoint(server, ctx) {
|
|
5
6
|
server.middlewares.use(CONTEXT_API_PATH, async (req, res) => {
|
|
@@ -56,13 +57,17 @@ function setupContextEndpoint(server, ctx) {
|
|
|
56
57
|
const data = JSON.parse(body);
|
|
57
58
|
const tabId = data.tabId != null ? String(data.tabId) : "default";
|
|
58
59
|
const existing = ctx.getPageContext();
|
|
60
|
+
const selectedElements = data.selectedElements || [];
|
|
61
|
+
selectedElements.forEach((el) => {
|
|
62
|
+
if (el && typeof el === "object") ensureNodeId(el);
|
|
63
|
+
});
|
|
59
64
|
const newCtx = {
|
|
60
65
|
url: data.url || "",
|
|
61
66
|
title: data.title || "",
|
|
62
67
|
sessionId: data.sessionId,
|
|
63
68
|
tabId: data.tabId ?? existing.tabId,
|
|
64
69
|
tabIndex: data.tabIndex ?? existing.tabIndex,
|
|
65
|
-
selectedElements
|
|
70
|
+
selectedElements
|
|
66
71
|
};
|
|
67
72
|
ctx.setPageContext(tabId, newCtx);
|
|
68
73
|
if (data.active) {
|
package/es/endpoints/mcp.mjs
CHANGED
|
@@ -342,11 +342,14 @@ async function handleDevTool(res, id, mcp, mapped, args, projectOrigins, toolNam
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
+
await mcp.callChromeDevTool("select_page", { pageId, bringToFront: false });
|
|
346
|
+
const forwardArgs = { ...args };
|
|
347
|
+
delete forwardArgs["pageId"];
|
|
345
348
|
const forwardBody = JSON.stringify({
|
|
346
349
|
jsonrpc: "2.0",
|
|
347
350
|
id,
|
|
348
351
|
method: "tools/call",
|
|
349
|
-
params: { name: mapped, arguments:
|
|
352
|
+
params: { name: mapped, arguments: forwardArgs }
|
|
350
353
|
});
|
|
351
354
|
const responseText = await mcp.forward(forwardBody);
|
|
352
355
|
log.debug("MCP response", { mapped, response: responseText.substring(0, 100) });
|