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.
@@ -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 pageIdRouting pageId 路由页面级工具,默认开启。
59
- // 显式声明强制开启,代理层校验 pageId 后原样转发,由底层工具按 pageId 路由目标页面。
60
- "--page-id-routing"
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();
@@ -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: data.selectedElements || []
70
+ selectedElements
66
71
  };
67
72
  ctx.setPageContext(tabId, newCtx);
68
73
  if (data.active) {
@@ -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: args }
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) });