vite-plugin-aipanel 1.2.9 → 1.2.10

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.
Files changed (56) hide show
  1. package/es/core/chrome-project.d.ts +15 -0
  2. package/es/core/chrome-project.mjs +13 -0
  3. package/es/core/mcp-chrome.d.ts +12 -8
  4. package/es/core/mcp-chrome.mjs +52 -10
  5. package/es/core/mcp-proxy.d.ts +14 -1
  6. package/es/core/mcp-proxy.mjs +49 -10
  7. package/es/core/mcp-tools.d.ts +51 -3
  8. package/es/core/mcp-tools.mjs +109 -659
  9. package/es/core/official-meta.d.ts +9 -0
  10. package/es/core/official-meta.mjs +62 -0
  11. package/es/core/official-tools.d.ts +7 -0
  12. package/es/core/official-tools.mjs +54 -0
  13. package/es/core/service.mjs +4 -5
  14. package/es/endpoints/context.mjs +2 -2
  15. package/es/endpoints/host-events.mjs +1 -2
  16. package/es/endpoints/index.d.ts +2 -2
  17. package/es/endpoints/index.mjs +2 -2
  18. package/es/endpoints/mcp.d.ts +2 -2
  19. package/es/endpoints/mcp.mjs +116 -87
  20. package/es/endpoints/sse.mjs +3 -3
  21. package/es/endpoints/vue-devtools.d.ts +5 -2
  22. package/es/endpoints/vue-devtools.mjs +3 -4
  23. package/es/index.mjs +21 -4
  24. package/lib/client.js +2322 -2310
  25. package/lib/core/chrome-project.cjs +36 -0
  26. package/lib/core/chrome-project.d.ts +15 -0
  27. package/lib/core/mcp-chrome.cjs +64 -10
  28. package/lib/core/mcp-chrome.d.ts +12 -8
  29. package/lib/core/mcp-proxy.cjs +50 -10
  30. package/lib/core/mcp-proxy.d.ts +14 -1
  31. package/lib/core/mcp-tools.cjs +124 -660
  32. package/lib/core/mcp-tools.d.ts +51 -3
  33. package/lib/core/official-meta.cjs +85 -0
  34. package/lib/core/official-meta.d.ts +9 -0
  35. package/lib/core/official-tools.cjs +70 -0
  36. package/lib/core/official-tools.d.ts +7 -0
  37. package/lib/core/service.cjs +4 -5
  38. package/lib/endpoints/context.cjs +1 -1
  39. package/lib/endpoints/host-events.cjs +0 -1
  40. package/lib/endpoints/index.cjs +2 -2
  41. package/lib/endpoints/index.d.ts +2 -2
  42. package/lib/endpoints/mcp.cjs +114 -85
  43. package/lib/endpoints/mcp.d.ts +2 -2
  44. package/lib/endpoints/sse.cjs +2 -2
  45. package/lib/endpoints/vue-devtools.cjs +4 -5
  46. package/lib/endpoints/vue-devtools.d.ts +5 -2
  47. package/lib/index.cjs +22 -5
  48. package/package.json +10 -7
  49. package/es/utils/format-bridge.d.ts +0 -9
  50. package/es/utils/format-bridge.mjs +0 -87
  51. package/es/utils/system.d.ts +0 -3
  52. package/es/utils/system.mjs +0 -76
  53. package/lib/utils/format-bridge.cjs +0 -103
  54. package/lib/utils/format-bridge.d.ts +0 -9
  55. package/lib/utils/system.cjs +0 -110
  56. package/lib/utils/system.d.ts +0 -3
@@ -1,8 +1,7 @@
1
1
  import { createLogger } from "@aipanel/core/node";
2
- import { VUE_DEVTOOLS_ACTIONS } from "@aipanel/core";
2
+ import { VUE_DEVTOOLS_ACTIONS, VUE_DEVTOOLS_API_PATH } from "@aipanel/core";
3
3
  import { getProjectOrigins, validatePageId } from "../core/mcp-chrome.mjs";
4
4
  const log = createLogger("Endpoints:VueDevtools");
5
- const VUE_DEVTOOLS_API_PATH = "/__aipanel_vue_devtools__";
6
5
  function setupVueDevtoolsEndpoint(server, mcp) {
7
6
  server.middlewares.use(VUE_DEVTOOLS_API_PATH, async (req, res) => {
8
7
  res.setHeader("Content-Type", "application/json");
@@ -39,9 +38,9 @@ async function executeAction(action, args, mcp, projectOrigins) {
39
38
  }
40
39
  const validation = await validatePageId(mcp, pageId, projectOrigins);
41
40
  if (!validation.valid) {
42
- log.error("pageId \u65E0\u6548\u6216\u975E\u9879\u76EE\u9875\u9762", {
41
+ log.error("pageId \u65E0\u6548\u6216\u4E0D\u5728\u53EF\u64CD\u4F5C\u8303\u56F4", {
43
42
  pageId,
44
- projectPageIds: validation.projectPages.map((p) => p.pageId)
43
+ allowedPageIds: validation.allowedPages.map((p) => p.pageId)
45
44
  });
46
45
  throw new Error(validation.error);
47
46
  }
package/es/index.mjs CHANGED
@@ -15,18 +15,19 @@ import { injectWidget } from "./core/injector.mjs";
15
15
  import { loadProvider } from "./core/provider-loader.mjs";
16
16
  import { AIPanelService } from "./core/service.mjs";
17
17
  import { McpProxy } from "./core/mcp-proxy.mjs";
18
+ import { configureToolScope, extraToolFlag } from "./core/mcp-tools.mjs";
18
19
  import {
19
20
  resolveWidgetPath,
20
21
  resolveWidgetStylePath,
21
22
  resolveVueDevtoolsBridgePath
22
23
  } from "./utils/paths.mjs";
23
- import { findGitRoot } from "./utils/system.mjs";
24
+ import { findGitRoot } from "@aipanel/core/node";
24
25
  const DEVTOOLS_BRIDGE_IMPORTEE = "virtual:aipanel-vue-devtools-bridge";
25
26
  const DEVTOOLS_BRIDGE_QUERY = "aipanel_vue_devtools_bridge";
26
27
  const BRIDGE_SOURCE_PATH = resolveVueDevtoolsBridgePath();
27
28
  const SILENT_CONTEXT_SCRIPT = `<script>
28
29
  (function () {
29
- var API = "/__aipanel_context__";
30
+ var API = "${CONTEXT_API_PATH}";
30
31
  var last = "";
31
32
  function report(force) {
32
33
  if (document.visibilityState !== "visible") return;
@@ -92,11 +93,26 @@ function createAIPanelPlugin(options = {}) {
92
93
  let activeTabId = DEFAULT_TAB;
93
94
  const serviceInstanceId = crypto.randomUUID();
94
95
  const sseClients = /* @__PURE__ */ new Set();
96
+ const chromeProjectOptions = config.chromeMcp?.project;
97
+ configureToolScope(
98
+ chromeProjectOptions?.tools?.extra ?? [],
99
+ chromeProjectOptions?.tools?.deny ?? [],
100
+ (msg) => log.warn(msg)
101
+ );
102
+ const chromeManagedArgs = [];
103
+ for (const short of chromeProjectOptions?.tools?.extra ?? []) {
104
+ const flag = extraToolFlag(short);
105
+ if (flag && !chromeManagedArgs.includes(flag)) chromeManagedArgs.push(flag);
106
+ }
107
+ if (chromeProjectOptions?.includeExtensionPages) {
108
+ chromeManagedArgs.push("--experimental-include-all-pages");
109
+ }
95
110
  const mcpProxy = new McpProxy({
96
111
  idleTimeout: 5 * 60 * 1e3,
97
112
  // 用户 chrome MCP 透传:追加 args/env(核心受保护参数不可覆盖,由 McpProxy 过滤)
98
113
  userArgs: config.chromeMcp?.args,
99
- env: config.chromeMcp?.env
114
+ env: config.chromeMcp?.env,
115
+ managedArgs: chromeManagedArgs
100
116
  });
101
117
  let provider = null;
102
118
  const service = new AIPanelService(
@@ -188,7 +204,8 @@ function createAIPanelPlugin(options = {}) {
188
204
  retryWarmupChromeMcp: () => service.retryWarmupChromeMcp()
189
205
  },
190
206
  mcpProxy,
191
- config.logFiles
207
+ config.logFiles,
208
+ chromeProjectOptions
192
209
  );
193
210
  if (!config.mcpOnly) {
194
211
  try {