@thinkingos/vsl-mcp-server 1.3.1 → 1.3.2
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/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3071,6 +3071,7 @@ function countObjects(objects) {
|
|
|
3071
3071
|
function buildSemanticMap(elements) {
|
|
3072
3072
|
const map = /* @__PURE__ */ new Map();
|
|
3073
3073
|
function visit(el) {
|
|
3074
|
+
if (!el || typeof el !== "object") return;
|
|
3074
3075
|
const elem = el;
|
|
3075
3076
|
if (!elem.indexPath) return;
|
|
3076
3077
|
if (elem.role || elem.ariaLabel || elem.ariaLabelledBy) {
|
|
@@ -3083,6 +3084,7 @@ function buildSemanticMap(elements) {
|
|
|
3083
3084
|
}
|
|
3084
3085
|
if (elem.children && Array.isArray(elem.children)) {
|
|
3085
3086
|
for (const child of elem.children) {
|
|
3087
|
+
if (!child || typeof child !== "object") continue;
|
|
3086
3088
|
visit(child);
|
|
3087
3089
|
}
|
|
3088
3090
|
}
|
|
@@ -3374,7 +3376,15 @@ async function handleGetSnapshot(args, browser, session, _config, sessionId) {
|
|
|
3374
3376
|
const viewport = extraction.viewport;
|
|
3375
3377
|
const url = args.url || await browser.evaluate(() => window.location.href, sessionId);
|
|
3376
3378
|
const title = await browser.evaluate(() => document.title, sessionId);
|
|
3377
|
-
|
|
3379
|
+
let semanticMap = /* @__PURE__ */ new Map();
|
|
3380
|
+
let snapshotWarning;
|
|
3381
|
+
try {
|
|
3382
|
+
semanticMap = buildSemanticMap(extractedElements);
|
|
3383
|
+
} catch (error) {
|
|
3384
|
+
const msg = `buildSemanticMap failed (graceful degradation): ${error instanceof Error ? error.message : String(error)}`;
|
|
3385
|
+
console.error("[VSL]", msg, error);
|
|
3386
|
+
snapshotWarning = msg;
|
|
3387
|
+
}
|
|
3378
3388
|
const iframeElementsRaw = await browser.evaluate(extractIframesInBrowser, sessionId);
|
|
3379
3389
|
const iframeElements = Array.isArray(iframeElementsRaw) ? iframeElementsRaw : [];
|
|
3380
3390
|
if (iframeElements.length > 0) {
|
|
@@ -3452,7 +3462,13 @@ async function handleGetSnapshot(args, browser, session, _config, sessionId) {
|
|
|
3452
3462
|
await injectVslIdsIntoFrame(browser, iframeInfo.frame, iframeInfo.doc.objects, semanticMap);
|
|
3453
3463
|
}
|
|
3454
3464
|
}
|
|
3455
|
-
|
|
3465
|
+
try {
|
|
3466
|
+
await injectVslIdsIntoDom(browser, currentDoc.objects, semanticMap, sessionId);
|
|
3467
|
+
} catch (error) {
|
|
3468
|
+
const msg = `injectVslIdsIntoDom failed (graceful degradation): ${error instanceof Error ? error.message : String(error)}`;
|
|
3469
|
+
console.error("[VSL]", msg, error);
|
|
3470
|
+
snapshotWarning = snapshotWarning ? `${snapshotWarning}; ${msg}` : msg;
|
|
3471
|
+
}
|
|
3456
3472
|
const scrollContext = session.getScrollContext();
|
|
3457
3473
|
const win = computeVisibleWindow(currentDoc.canvas.viewport, scrollContext);
|
|
3458
3474
|
const scrollable = computeScrollable(currentDoc.canvas.viewport, scrollContext);
|
|
@@ -3478,7 +3494,8 @@ async function handleGetSnapshot(args, browser, session, _config, sessionId) {
|
|
|
3478
3494
|
total_objects_count: totalObjectsCount,
|
|
3479
3495
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3480
3496
|
execution_time_ms: executionTimeMs,
|
|
3481
|
-
scrollable
|
|
3497
|
+
scrollable,
|
|
3498
|
+
...snapshotWarning ? { warning: snapshotWarning } : {}
|
|
3482
3499
|
};
|
|
3483
3500
|
if (ttl > 0) {
|
|
3484
3501
|
const cacheKey = args.url || "current";
|
|
@@ -5022,7 +5039,9 @@ async function handleReadPage(args, browser, session, _config, sessionId) {
|
|
|
5022
5039
|
readableApplied: httpResult.readableApplied,
|
|
5023
5040
|
detail_level: detailLevel,
|
|
5024
5041
|
...computeVslMetrics(fullSnapshot),
|
|
5025
|
-
scrollable
|
|
5042
|
+
scrollable,
|
|
5043
|
+
id_scheme: "counter",
|
|
5044
|
+
warning: "HTTP path: IDs are sequential counters (e.g., btn_0, inp_1). These IDs are NOT compatible with vsl_execute_action. For interactive actions, use vsl_get_snapshot to get browser DOM IDs."
|
|
5026
5045
|
}
|
|
5027
5046
|
};
|
|
5028
5047
|
return {
|
|
@@ -5423,7 +5442,7 @@ var VSL_TOOLS = [
|
|
|
5423
5442
|
},
|
|
5424
5443
|
{
|
|
5425
5444
|
name: "vsl_get_visual",
|
|
5426
|
-
description: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C visual fragment (\u0441\u043A\u0440\u0438\u043D\u0448\u043E\u0442) \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64 WebP. \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0434\u043B\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u043B\u043E\u0436\u043D\u043E \u043A\u043B\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u0442\u0435\u043A\u0441\u0442\u0443 (\u0438\u043A\u043E\u043D\u043A\u0438, \u0433\u0440\u0430\u0444\u0438\u043A\u0438, \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u044B\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044B). \u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 {mediaType:image/webp, data:base64data}. \u041F\u0440\u0438\u043C\u0435\u0440: {element_id: img_5}. \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 auto_refresh=true \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0435\u0442 snapshot \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0438\u0441\u043A\u043E\u043C \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430.",
|
|
5445
|
+
description: "\u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C visual fragment (\u0441\u043A\u0440\u0438\u043D\u0448\u043E\u0442) \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64 WebP. \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0434\u043B\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u043B\u043E\u0436\u043D\u043E \u043A\u043B\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u043E \u0442\u0435\u043A\u0441\u0442\u0443 (\u0438\u043A\u043E\u043D\u043A\u0438, \u0433\u0440\u0430\u0444\u0438\u043A\u0438, \u043A\u0430\u0441\u0442\u043E\u043C\u043D\u044B\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044B). \u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 {mediaType:image/webp, data:base64data}. \u041F\u0440\u0438\u043C\u0435\u0440: {element_id: img_5}. \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 auto_refresh=true \u0430\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u0435\u0441\u043A\u0438 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0435\u0442 snapshot \u043F\u0435\u0440\u0435\u0434 \u043F\u043E\u0438\u0441\u043A\u043E\u043C \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430. \u0412\u0410\u0416\u041D\u041E: \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0441 ID \u0438\u0437 vsl_get_snapshot (browser DOM). \u041D\u0415 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0441 ID \u0438\u0437 vsl_read_page (semantic IDs) \u2014 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 vsl_get_snapshot \u0434\u043B\u044F \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u0441\u043E\u0432\u043C\u0435\u0441\u0442\u0438\u043C\u044B\u0445 ID.",
|
|
5427
5446
|
inputSchema: {
|
|
5428
5447
|
type: "object",
|
|
5429
5448
|
properties: {
|
|
@@ -6409,7 +6428,7 @@ var SessionManager = class {
|
|
|
6409
6428
|
};
|
|
6410
6429
|
|
|
6411
6430
|
// src/version.ts
|
|
6412
|
-
var VSL_MCP_SERVER_VERSION = "1.3.
|
|
6431
|
+
var VSL_MCP_SERVER_VERSION = "1.3.2";
|
|
6413
6432
|
|
|
6414
6433
|
// src/index.ts
|
|
6415
6434
|
async function main() {
|