vite-plugin-opencode-assistant 1.1.25 → 1.1.26
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-chrome.d.ts +43 -0
- package/es/core/mcp-chrome.mjs +147 -0
- package/es/endpoints/context.d.ts +0 -35
- package/es/endpoints/context.mjs +0 -119
- package/es/endpoints/mcp-tools.d.ts +2 -1
- package/es/endpoints/mcp-tools.mjs +370 -176
- package/es/endpoints/mcp.mjs +200 -169
- package/lib/core/mcp-chrome.cjs +174 -0
- package/lib/core/mcp-chrome.d.ts +43 -0
- package/lib/endpoints/context.cjs +0 -123
- package/lib/endpoints/context.d.ts +0 -35
- package/lib/endpoints/mcp-tools.cjs +368 -176
- package/lib/endpoints/mcp-tools.d.ts +2 -1
- package/lib/endpoints/mcp.cjs +193 -169
- package/package.json +5 -5
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Chrome 页面相关工具
|
|
3
|
+
*
|
|
4
|
+
* 专注于 Chrome DevTools 页面匹配与解析逻辑
|
|
5
|
+
*/
|
|
6
|
+
import type { ViteDevServer } from "vite";
|
|
7
|
+
import type { McpProxy } from "./mcp-proxy";
|
|
8
|
+
/** 从 Vite 服务器解析的所有 URL 中提取项目 origin 列表 */
|
|
9
|
+
export declare function getProjectOrigins(server: ViteDevServer): string[];
|
|
10
|
+
/** 判断页面 URL 是否属于项目的某个 origin */
|
|
11
|
+
export declare function isProjectPage(url: string, origins: string[]): boolean;
|
|
12
|
+
export interface PageInfo {
|
|
13
|
+
pageId: number;
|
|
14
|
+
url: string;
|
|
15
|
+
title: string;
|
|
16
|
+
/** Chrome DevTools 当前选中的页面 */
|
|
17
|
+
selected: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** 解析 list_pages 返回的文本。格式:"56: Title (URL) [selected]" */
|
|
20
|
+
export declare function parseListPages(text: string): PageInfo[];
|
|
21
|
+
/** 从 evaluate_script 返回的格式化文本中提取 JSON 值 */
|
|
22
|
+
export declare function extractEvalValue(text: string | undefined): string | undefined;
|
|
23
|
+
type PageIdResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
pageId: number;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 通过 MCP 解析当前页面对应的 Chrome DevTools pageId
|
|
32
|
+
*
|
|
33
|
+
* 策略:
|
|
34
|
+
* 1. list_pages → 解析每行的 "pageId: title (URL)" 格式
|
|
35
|
+
* 2. 优先用 sessionId 匹配(跨导航可靠,遍历所有页面 evaluate_script)
|
|
36
|
+
* 3. 无 sessionId 时降级为 URL 精确匹配
|
|
37
|
+
*
|
|
38
|
+
* 失败时返回具体原因,由调用方透传给 Agent。
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveChromePageId(mcp: McpProxy | undefined, url: string, title: string, projectOrigins: string[], sessionId?: string, pages?: PageInfo[],
|
|
41
|
+
/** Chrome 当前选中的 pageId(调用方传入,避免过滤后丢失非项目页面信息) */
|
|
42
|
+
chromeSelectedPageId?: number): Promise<PageIdResult>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { createLogger } from "@vite-plugin-opencode-assistant/shared/node";
|
|
22
|
+
const log = createLogger("McpChrome");
|
|
23
|
+
function getProjectOrigins(server) {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
const local = (_b = (_a = server.resolvedUrls) == null ? void 0 : _a.local) != null ? _b : [];
|
|
26
|
+
const network = (_d = (_c = server.resolvedUrls) == null ? void 0 : _c.network) != null ? _d : [];
|
|
27
|
+
const origins = [...new Set([...local, ...network].map((u) => new URL(u).origin))];
|
|
28
|
+
log.debug("project origins", { origins });
|
|
29
|
+
return origins;
|
|
30
|
+
}
|
|
31
|
+
function isProjectPage(url, origins) {
|
|
32
|
+
return origins.some((origin) => url.startsWith(origin));
|
|
33
|
+
}
|
|
34
|
+
function parseListPages(text) {
|
|
35
|
+
const pages = [];
|
|
36
|
+
for (const line of text.split("\n")) {
|
|
37
|
+
const match = line.match(/^(\d+):\s*(.+?)\s*\((\S+)\)/);
|
|
38
|
+
if (match) {
|
|
39
|
+
pages.push({
|
|
40
|
+
pageId: parseInt(match[1], 10),
|
|
41
|
+
title: match[2].replace(/\s*\.{3}$/, "").trim(),
|
|
42
|
+
url: match[3],
|
|
43
|
+
selected: /\[selected\]/i.test(line)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return pages;
|
|
48
|
+
}
|
|
49
|
+
function extractEvalValue(text) {
|
|
50
|
+
if (!text) return void 0;
|
|
51
|
+
const marker = "```json\n";
|
|
52
|
+
const startIdx = text.indexOf(marker);
|
|
53
|
+
if (startIdx < 0) return text.trim();
|
|
54
|
+
const contentStart = startIdx + marker.length;
|
|
55
|
+
const endIdx = text.indexOf("\n```", contentStart);
|
|
56
|
+
const jsonStr = endIdx < 0 ? text.substring(contentStart) : text.substring(contentStart, endIdx);
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(jsonStr.trim());
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return jsonStr.trim();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function resolveChromePageId(mcp, url, title, projectOrigins, sessionId, pages, chromeSelectedPageId) {
|
|
64
|
+
return __async(this, null, function* () {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
66
|
+
if (!mcp || !mcp.isRunning) {
|
|
67
|
+
const reason = !mcp ? "MCP \u6A21\u5757\u672A\u521D\u59CB\u5316" : "Chrome DevTools MCP \u8FDB\u7A0B\u672A\u542F\u52A8";
|
|
68
|
+
log.debug(`resolveChromePageId: ${reason}`);
|
|
69
|
+
return { ok: false, error: reason };
|
|
70
|
+
}
|
|
71
|
+
if (!url) {
|
|
72
|
+
return { ok: false, error: "\u9875\u9762 URL \u4E3A\u7A7A\uFF0C\u5C1A\u672A\u6536\u5230\u4E0A\u4E0B\u6587\u4FE1\u606F" };
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
if (!pages) {
|
|
76
|
+
const listResult = yield mcp.callChromeDevTool("list_pages", {});
|
|
77
|
+
const text = (_c = (_b = (_a = listResult == null ? void 0 : listResult.result) == null ? void 0 : _a.content) == null ? void 0 : _b[0]) == null ? void 0 : _c.text;
|
|
78
|
+
if (!text) {
|
|
79
|
+
return { ok: false, error: "\u65E0\u6CD5\u83B7\u53D6 Chrome \u9875\u9762\u5217\u8868\uFF0C\u8BF7\u786E\u8BA4\u5DF2\u6253\u5F00\u76EE\u6807\u9875\u9762" };
|
|
80
|
+
}
|
|
81
|
+
const allPages = parseListPages(text);
|
|
82
|
+
chromeSelectedPageId = (_d = allPages.find((p) => p.selected)) == null ? void 0 : _d.pageId;
|
|
83
|
+
pages = allPages.filter((p) => isProjectPage(p.url, projectOrigins));
|
|
84
|
+
}
|
|
85
|
+
log.debug("resolveChromePageId: list_pages result", {
|
|
86
|
+
pages: pages.map((p) => ({ id: p.pageId, url: p.url, title: p.title.substring(0, 40) })),
|
|
87
|
+
target: { url, title }
|
|
88
|
+
});
|
|
89
|
+
const normalizeUrl = (u) => u.replace(/\/$/, "");
|
|
90
|
+
const targetUrl = normalizeUrl(url);
|
|
91
|
+
if (sessionId) {
|
|
92
|
+
let matchedPageId = null;
|
|
93
|
+
for (const page of pages) {
|
|
94
|
+
yield mcp.callChromeDevTool("select_page", { pageId: page.pageId, bringToFront: false });
|
|
95
|
+
const evalResult = yield mcp.callChromeDevTool("evaluate_script", {
|
|
96
|
+
function: "() => sessionStorage.getItem('_opencode_pk')"
|
|
97
|
+
});
|
|
98
|
+
const rawText = (_g = (_f = (_e = evalResult == null ? void 0 : evalResult.result) == null ? void 0 : _e.content) == null ? void 0 : _f[0]) == null ? void 0 : _g.text;
|
|
99
|
+
const extracted = extractEvalValue(rawText);
|
|
100
|
+
if (extracted === sessionId) {
|
|
101
|
+
matchedPageId = page.pageId;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (chromeSelectedPageId != null && chromeSelectedPageId !== matchedPageId) {
|
|
106
|
+
yield mcp.callChromeDevTool("select_page", {
|
|
107
|
+
pageId: chromeSelectedPageId,
|
|
108
|
+
bringToFront: false
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (matchedPageId != null) {
|
|
112
|
+
return { ok: true, pageId: matchedPageId };
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
error: `\u672A\u80FD\u901A\u8FC7\u4F1A\u8BDD\u6807\u8BC6\u627E\u5230\u76EE\u6807\u9875\u9762\uFF0C\u8BF7\u786E\u8BA4\u76EE\u6807\u9875\u9762\u5DF2\u6253\u5F00`
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const matches = pages.filter((p) => normalizeUrl(p.url) === targetUrl);
|
|
120
|
+
if (matches.length === 0) {
|
|
121
|
+
return {
|
|
122
|
+
ok: false,
|
|
123
|
+
error: `Chrome \u4E2D\u672A\u627E\u5230\u5339\u914D\u7684\u9875\u9762 (${targetUrl})\uFF0C\u8BF7\u786E\u8BA4\u672C\u5730\u5F00\u53D1\u9875\u9762\u5DF2\u5728 Chrome DevTools \u4E2D\u6253\u5F00`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (matches.length === 1) {
|
|
127
|
+
log.debug("resolveChromePageId: URL matched", { pageId: matches[0].pageId });
|
|
128
|
+
return { ok: true, pageId: matches[0].pageId };
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
error: `\u5B58\u5728 ${matches.length} \u4E2A\u540C URL \u7684\u9875\u9762\uFF0C\u7F3A\u5C11\u9875\u9762\u6807\u8BC6\u65E0\u6CD5\u533A\u5206\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5`
|
|
133
|
+
};
|
|
134
|
+
} catch (err) {
|
|
135
|
+
const msg = `MCP \u8C03\u7528\u5931\u8D25: ${err.message}`;
|
|
136
|
+
log.debug("Failed to resolve pageId via MCP", { error: err.message });
|
|
137
|
+
return { ok: false, error: msg };
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
extractEvalValue,
|
|
143
|
+
getProjectOrigins,
|
|
144
|
+
isProjectPage,
|
|
145
|
+
parseListPages,
|
|
146
|
+
resolveChromePageId
|
|
147
|
+
};
|
|
@@ -1,38 +1,3 @@
|
|
|
1
1
|
import type { ViteDevServer } from "vite";
|
|
2
|
-
import type { McpProxy } from "../core/mcp-proxy";
|
|
3
2
|
import type { EndpointContext } from "./types";
|
|
4
|
-
/** 从页面 URL 提取项目 origin(protocol + host + port) */
|
|
5
|
-
export declare function getProjectOrigin(pageUrl: string): string | null;
|
|
6
|
-
export interface PageInfo {
|
|
7
|
-
pageId: number;
|
|
8
|
-
url: string;
|
|
9
|
-
title: string;
|
|
10
|
-
/** Chrome DevTools 当前选中的页面 */
|
|
11
|
-
selected: boolean;
|
|
12
|
-
}
|
|
13
|
-
/** 解析 list_pages 返回的文本。格式:"56: Title (URL) [selected]" */
|
|
14
|
-
export declare function parseListPages(text: string): PageInfo[];
|
|
15
|
-
/** 从 evaluate_script 返回的格式化文本中提取 JSON 值 */
|
|
16
|
-
export declare function extractEvalValue(text: string | undefined): string | undefined;
|
|
17
|
-
type PageIdResult = {
|
|
18
|
-
ok: true;
|
|
19
|
-
pageId: number;
|
|
20
|
-
} | {
|
|
21
|
-
ok: false;
|
|
22
|
-
error: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* 通过 MCP 解析当前页面对应的 Chrome DevTools pageId
|
|
26
|
-
*
|
|
27
|
-
* 策略:
|
|
28
|
-
* 1. list_pages → 解析每行的 "pageId: title (URL)" 格式
|
|
29
|
-
* 2. 优先用 sessionId 匹配(跨导航可靠,遍历所有页面 evaluate_script)
|
|
30
|
-
* 3. 无 sessionId 时降级为 URL 精确匹配
|
|
31
|
-
*
|
|
32
|
-
* 失败时返回具体原因,由调用方透传给 Agent。
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveChromePageId(mcp: McpProxy | undefined, url: string, title: string, sessionId?: string, pages?: PageInfo[],
|
|
35
|
-
/** Chrome 当前选中的 pageId(调用方传入,避免过滤后丢失非项目页面信息) */
|
|
36
|
-
chromeSelectedPageId?: number): Promise<PageIdResult>;
|
|
37
3
|
export declare function setupContextEndpoint(server: ViteDevServer, ctx: EndpointContext): void;
|
|
38
|
-
export {};
|
package/es/endpoints/context.mjs
CHANGED
|
@@ -21,121 +21,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
import { CONTEXT_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
22
22
|
import { RequestContext, createLogger } from "@vite-plugin-opencode-assistant/shared/node";
|
|
23
23
|
const log = createLogger("Endpoints:Context");
|
|
24
|
-
function getProjectOrigin(pageUrl) {
|
|
25
|
-
try {
|
|
26
|
-
return new URL(pageUrl).origin;
|
|
27
|
-
} catch (e) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function parseListPages(text) {
|
|
32
|
-
const pages = [];
|
|
33
|
-
for (const line of text.split("\n")) {
|
|
34
|
-
const match = line.match(/^(\d+):\s*(.+?)\s*\((\S+)\)/);
|
|
35
|
-
if (match) {
|
|
36
|
-
pages.push({
|
|
37
|
-
pageId: parseInt(match[1], 10),
|
|
38
|
-
title: match[2].replace(/\s*\.{3}$/, "").trim(),
|
|
39
|
-
url: match[3],
|
|
40
|
-
selected: /\[selected\]/i.test(line)
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return pages;
|
|
45
|
-
}
|
|
46
|
-
function extractEvalValue(text) {
|
|
47
|
-
if (!text) return void 0;
|
|
48
|
-
const marker = "```json\n";
|
|
49
|
-
const startIdx = text.indexOf(marker);
|
|
50
|
-
if (startIdx < 0) return text.trim();
|
|
51
|
-
const contentStart = startIdx + marker.length;
|
|
52
|
-
const endIdx = text.indexOf("\n```", contentStart);
|
|
53
|
-
const jsonStr = endIdx < 0 ? text.substring(contentStart) : text.substring(contentStart, endIdx);
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(jsonStr.trim());
|
|
56
|
-
} catch (e) {
|
|
57
|
-
return jsonStr.trim();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function resolveChromePageId(mcp, url, title, sessionId, pages, chromeSelectedPageId) {
|
|
61
|
-
return __async(this, null, function* () {
|
|
62
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
63
|
-
if (!mcp || !mcp.isRunning) {
|
|
64
|
-
const reason = !mcp ? "MCP \u6A21\u5757\u672A\u521D\u59CB\u5316" : "Chrome DevTools MCP \u8FDB\u7A0B\u672A\u542F\u52A8";
|
|
65
|
-
log.debug(`resolveChromePageId: ${reason}`);
|
|
66
|
-
return { ok: false, error: reason };
|
|
67
|
-
}
|
|
68
|
-
if (!url) {
|
|
69
|
-
return { ok: false, error: "\u9875\u9762 URL \u4E3A\u7A7A\uFF0C\u5C1A\u672A\u6536\u5230\u4E0A\u4E0B\u6587\u4FE1\u606F" };
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
if (!pages) {
|
|
73
|
-
const listResult = yield mcp.callChromeDevTool("list_pages", {});
|
|
74
|
-
const text = (_c = (_b = (_a = listResult == null ? void 0 : listResult.result) == null ? void 0 : _a.content) == null ? void 0 : _b[0]) == null ? void 0 : _c.text;
|
|
75
|
-
if (!text) {
|
|
76
|
-
return { ok: false, error: "\u65E0\u6CD5\u83B7\u53D6 Chrome \u9875\u9762\u5217\u8868\uFF0C\u8BF7\u786E\u8BA4\u5DF2\u6253\u5F00\u76EE\u6807\u9875\u9762" };
|
|
77
|
-
}
|
|
78
|
-
const allPages = parseListPages(text);
|
|
79
|
-
chromeSelectedPageId = (_d = allPages.find((p) => p.selected)) == null ? void 0 : _d.pageId;
|
|
80
|
-
const projectOrigin = getProjectOrigin(url);
|
|
81
|
-
pages = projectOrigin ? allPages.filter((p) => p.url.startsWith(projectOrigin)) : allPages;
|
|
82
|
-
}
|
|
83
|
-
log.debug("resolveChromePageId: list_pages result", {
|
|
84
|
-
pages: pages.map((p) => ({ id: p.pageId, url: p.url, title: p.title.substring(0, 40) })),
|
|
85
|
-
target: { url, title }
|
|
86
|
-
});
|
|
87
|
-
const normalizeUrl = (u) => u.replace(/\/$/, "");
|
|
88
|
-
const targetUrl = normalizeUrl(url);
|
|
89
|
-
if (sessionId) {
|
|
90
|
-
let matchedPageId = null;
|
|
91
|
-
for (const page of pages) {
|
|
92
|
-
yield mcp.callChromeDevTool("select_page", { pageId: page.pageId, bringToFront: false });
|
|
93
|
-
const evalResult = yield mcp.callChromeDevTool("evaluate_script", {
|
|
94
|
-
function: "() => sessionStorage.getItem('_opencode_pk')"
|
|
95
|
-
});
|
|
96
|
-
const rawText = (_g = (_f = (_e = evalResult == null ? void 0 : evalResult.result) == null ? void 0 : _e.content) == null ? void 0 : _f[0]) == null ? void 0 : _g.text;
|
|
97
|
-
const extracted = extractEvalValue(rawText);
|
|
98
|
-
if (extracted === sessionId) {
|
|
99
|
-
matchedPageId = page.pageId;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (chromeSelectedPageId != null && chromeSelectedPageId !== matchedPageId) {
|
|
104
|
-
yield mcp.callChromeDevTool("select_page", {
|
|
105
|
-
pageId: chromeSelectedPageId,
|
|
106
|
-
bringToFront: false
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if (matchedPageId != null) {
|
|
110
|
-
return { ok: true, pageId: matchedPageId };
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
ok: false,
|
|
114
|
-
error: `\u672A\u80FD\u901A\u8FC7\u4F1A\u8BDD\u6807\u8BC6\u627E\u5230\u76EE\u6807\u9875\u9762\uFF0C\u8BF7\u786E\u8BA4\u76EE\u6807\u9875\u9762\u5DF2\u6253\u5F00`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
const matches = pages.filter((p) => normalizeUrl(p.url) === targetUrl);
|
|
118
|
-
if (matches.length === 0) {
|
|
119
|
-
return {
|
|
120
|
-
ok: false,
|
|
121
|
-
error: `Chrome \u4E2D\u672A\u627E\u5230\u5339\u914D\u7684\u9875\u9762 (${targetUrl})\uFF0C\u8BF7\u786E\u8BA4\u672C\u5730\u5F00\u53D1\u9875\u9762\u5DF2\u5728 Chrome DevTools \u4E2D\u6253\u5F00`
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
if (matches.length === 1) {
|
|
125
|
-
log.debug("resolveChromePageId: URL matched", { pageId: matches[0].pageId });
|
|
126
|
-
return { ok: true, pageId: matches[0].pageId };
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
ok: false,
|
|
130
|
-
error: `\u5B58\u5728 ${matches.length} \u4E2A\u540C URL \u7684\u9875\u9762\uFF0C\u7F3A\u5C11\u9875\u9762\u6807\u8BC6\u65E0\u6CD5\u533A\u5206\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5`
|
|
131
|
-
};
|
|
132
|
-
} catch (err) {
|
|
133
|
-
const msg = `MCP \u8C03\u7528\u5931\u8D25: ${err.message}`;
|
|
134
|
-
log.debug("Failed to resolve pageId via MCP", { error: err.message });
|
|
135
|
-
return { ok: false, error: msg };
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
24
|
function setupContextEndpoint(server, ctx) {
|
|
140
25
|
server.middlewares.use(CONTEXT_API_PATH, (req, res) => __async(null, null, function* () {
|
|
141
26
|
const reqCtx = new RequestContext(req.method || "GET", CONTEXT_API_PATH);
|
|
@@ -241,9 +126,5 @@ function setupContextEndpoint(server, ctx) {
|
|
|
241
126
|
}));
|
|
242
127
|
}
|
|
243
128
|
export {
|
|
244
|
-
extractEvalValue,
|
|
245
|
-
getProjectOrigin,
|
|
246
|
-
parseListPages,
|
|
247
|
-
resolveChromePageId,
|
|
248
129
|
setupContextEndpoint
|
|
249
130
|
};
|