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.
- package/es/core/chrome-project.d.ts +15 -0
- package/es/core/chrome-project.mjs +13 -0
- package/es/core/mcp-chrome.d.ts +12 -8
- package/es/core/mcp-chrome.mjs +52 -10
- package/es/core/mcp-proxy.d.ts +14 -1
- package/es/core/mcp-proxy.mjs +49 -10
- package/es/core/mcp-tools.d.ts +51 -3
- package/es/core/mcp-tools.mjs +109 -659
- package/es/core/official-meta.d.ts +9 -0
- package/es/core/official-meta.mjs +62 -0
- package/es/core/official-tools.d.ts +7 -0
- package/es/core/official-tools.mjs +54 -0
- package/es/core/service.mjs +4 -5
- package/es/endpoints/context.mjs +2 -2
- package/es/endpoints/host-events.mjs +1 -2
- package/es/endpoints/index.d.ts +2 -2
- package/es/endpoints/index.mjs +2 -2
- package/es/endpoints/mcp.d.ts +2 -2
- package/es/endpoints/mcp.mjs +116 -87
- package/es/endpoints/sse.mjs +3 -3
- package/es/endpoints/vue-devtools.d.ts +5 -2
- package/es/endpoints/vue-devtools.mjs +3 -4
- package/es/index.mjs +21 -4
- package/lib/client.js +2322 -2310
- package/lib/core/chrome-project.cjs +36 -0
- package/lib/core/chrome-project.d.ts +15 -0
- package/lib/core/mcp-chrome.cjs +64 -10
- package/lib/core/mcp-chrome.d.ts +12 -8
- package/lib/core/mcp-proxy.cjs +50 -10
- package/lib/core/mcp-proxy.d.ts +14 -1
- package/lib/core/mcp-tools.cjs +124 -660
- package/lib/core/mcp-tools.d.ts +51 -3
- package/lib/core/official-meta.cjs +85 -0
- package/lib/core/official-meta.d.ts +9 -0
- package/lib/core/official-tools.cjs +70 -0
- package/lib/core/official-tools.d.ts +7 -0
- package/lib/core/service.cjs +4 -5
- package/lib/endpoints/context.cjs +1 -1
- package/lib/endpoints/host-events.cjs +0 -1
- package/lib/endpoints/index.cjs +2 -2
- package/lib/endpoints/index.d.ts +2 -2
- package/lib/endpoints/mcp.cjs +114 -85
- package/lib/endpoints/mcp.d.ts +2 -2
- package/lib/endpoints/sse.cjs +2 -2
- package/lib/endpoints/vue-devtools.cjs +4 -5
- package/lib/endpoints/vue-devtools.d.ts +5 -2
- package/lib/index.cjs +22 -5
- package/package.json +10 -7
- package/es/utils/format-bridge.d.ts +0 -9
- package/es/utils/format-bridge.mjs +0 -87
- package/es/utils/system.d.ts +0 -3
- package/es/utils/system.mjs +0 -76
- package/lib/utils/format-bridge.cjs +0 -103
- package/lib/utils/format-bridge.d.ts +0 -9
- package/lib/utils/system.cjs +0 -110
- 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\
|
|
41
|
+
log.error("pageId \u65E0\u6548\u6216\u4E0D\u5728\u53EF\u64CD\u4F5C\u8303\u56F4", {
|
|
43
42
|
pageId,
|
|
44
|
-
|
|
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 "
|
|
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 = "
|
|
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 {
|