@thinkingos/vsl-mcp-server 1.2.15 → 1.2.16
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/README.md +10 -0
- package/dist/index.js +43 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -347,6 +347,16 @@ Agent: vsl_get_snapshot(full=true)
|
|
|
347
347
|
│ ├── Diff Engine → VslDiff │
|
|
348
348
|
│ └── Vision Classifier (LLM flash models) │
|
|
349
349
|
└─────────────────────────────────────────────┘
|
|
350
|
+
## Исправления (Bug Fixes)
|
|
351
|
+
|
|
352
|
+
> **ID Stability после fill action** — элементы сохраняют свои короткие ID после изменений DOM.
|
|
353
|
+
|
|
354
|
+
> **Iframe ID Resolution** — исправлен резолв ID для элементов внутри iframe (используется полный `target_id` с префиксом `iframe_N:`).
|
|
355
|
+
|
|
356
|
+
> **Lazy Text Loading** — тексты длиннее ~200 символов автоматически заменяются на `txt_preview` + `txt_ref` для экономии токенов.
|
|
357
|
+
|
|
358
|
+
> **Lazy Navigation** — автоматическая навигация на URL перед выполнением действий, если браузер не на нужной странице.
|
|
359
|
+
|
|
350
360
|
## Требования
|
|
351
361
|
|
|
352
362
|
- Node.js ≥ 18
|
package/dist/index.js
CHANGED
|
@@ -232,36 +232,61 @@ function extractTag(longId) {
|
|
|
232
232
|
function toBase36(n) {
|
|
233
233
|
return n.toString(36);
|
|
234
234
|
}
|
|
235
|
-
function buildIdMap(objects) {
|
|
235
|
+
function buildIdMap(objects, previousReverseIdMap) {
|
|
236
236
|
const map = /* @__PURE__ */ new Map();
|
|
237
237
|
const counters = /* @__PURE__ */ new Map();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
counters.set(prefix, counter + 1);
|
|
243
|
-
const shortId = framePrefix ? `${framePrefix}:${prefix}_${toBase36(counter)}` : `${prefix}_${toBase36(counter)}`;
|
|
244
|
-
map.set(shortId, obj.id);
|
|
238
|
+
const assignedShortIds = /* @__PURE__ */ new Set();
|
|
239
|
+
const elementsWithPrefix = [];
|
|
240
|
+
function collect(obj, framePrefix) {
|
|
241
|
+
elementsWithPrefix.push({ obj, framePrefix });
|
|
245
242
|
if (obj.ch) {
|
|
246
243
|
for (const child of obj.ch) {
|
|
247
|
-
|
|
244
|
+
collect(child, framePrefix);
|
|
248
245
|
}
|
|
249
246
|
}
|
|
250
247
|
if (obj.iframe?.vsl?.objects) {
|
|
251
248
|
const frameIndex = obj.iframe.frameId;
|
|
252
249
|
const iframeFramePrefix = `iframe_${frameIndex}`;
|
|
253
250
|
for (const iframeObj of obj.iframe.vsl.objects) {
|
|
254
|
-
|
|
251
|
+
collect(iframeObj, iframeFramePrefix);
|
|
255
252
|
}
|
|
256
253
|
}
|
|
257
254
|
}
|
|
258
255
|
for (const obj of objects) {
|
|
259
|
-
|
|
256
|
+
collect(obj);
|
|
257
|
+
}
|
|
258
|
+
if (previousReverseIdMap) {
|
|
259
|
+
for (const { obj, framePrefix } of elementsWithPrefix) {
|
|
260
|
+
const oldShortId = previousReverseIdMap.get(obj.id);
|
|
261
|
+
if (oldShortId && !assignedShortIds.has(oldShortId)) {
|
|
262
|
+
const expectedPrefix = framePrefix ? `${framePrefix}:` : "";
|
|
263
|
+
if (oldShortId.startsWith(expectedPrefix) || !framePrefix && !oldShortId.includes(":")) {
|
|
264
|
+
map.set(oldShortId, obj.id);
|
|
265
|
+
assignedShortIds.add(oldShortId);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
for (const { obj, framePrefix } of elementsWithPrefix) {
|
|
271
|
+
if (map.has(framePrefix ? `${framePrefix}:${obj.id}` : obj.id)) continue;
|
|
272
|
+
const alreadyAssigned = Array.from(map.entries()).some(([_, longId]) => longId === obj.id);
|
|
273
|
+
if (alreadyAssigned) continue;
|
|
274
|
+
const tag = extractTag(obj.id);
|
|
275
|
+
const prefix = tagPrefix(tag);
|
|
276
|
+
let counter = counters.get(prefix) ?? 0;
|
|
277
|
+
let shortId;
|
|
278
|
+
do {
|
|
279
|
+
shortId = framePrefix ? `${framePrefix}:${prefix}_${toBase36(counter)}` : `${prefix}_${toBase36(counter)}`;
|
|
280
|
+
counter++;
|
|
281
|
+
} while (assignedShortIds.has(shortId));
|
|
282
|
+
counters.set(prefix, counter);
|
|
283
|
+
assignedShortIds.add(shortId);
|
|
284
|
+
map.set(shortId, obj.id);
|
|
260
285
|
}
|
|
261
286
|
return map;
|
|
262
287
|
}
|
|
263
|
-
function buildReverseIdMap(objects) {
|
|
264
|
-
const forward = buildIdMap(objects);
|
|
288
|
+
function buildReverseIdMap(objects, previousReverseIdMap) {
|
|
289
|
+
const forward = buildIdMap(objects, previousReverseIdMap);
|
|
265
290
|
const reverse = /* @__PURE__ */ new Map();
|
|
266
291
|
for (const [shortId, longId] of forward) {
|
|
267
292
|
reverse.set(longId, shortId);
|
|
@@ -1249,7 +1274,7 @@ async function handleExecuteAction(args, browser, session) {
|
|
|
1249
1274
|
}
|
|
1250
1275
|
}
|
|
1251
1276
|
const idMap = session.getIdMap();
|
|
1252
|
-
const resolvedId = idMap.get(
|
|
1277
|
+
const resolvedId = idMap.get(args.target_id) || localShortId;
|
|
1253
1278
|
const localId = resolvedId;
|
|
1254
1279
|
const selector = `[data-vsl-id="${localId}"], #${localId}, .${localId}`;
|
|
1255
1280
|
const page = await browser.getPage();
|
|
@@ -3030,16 +3055,17 @@ var ServerSession = class {
|
|
|
3030
3055
|
this.currentDocument = doc;
|
|
3031
3056
|
this.version += 1;
|
|
3032
3057
|
this.scrollContext = input.scroll ? { ...input.scroll } : null;
|
|
3058
|
+
const prevReverseIdMap = this.reverseIdMap;
|
|
3033
3059
|
const currentObjects = doc.objects ?? [];
|
|
3034
3060
|
const previousObjects = this.previousDocument?.objects ?? [];
|
|
3035
3061
|
const unionObjects = [...currentObjects, ...previousObjects];
|
|
3036
3062
|
if (currentObjects.length > 0) {
|
|
3037
|
-
this.idMap = buildIdMap(currentObjects);
|
|
3063
|
+
this.idMap = buildIdMap(currentObjects, prevReverseIdMap);
|
|
3038
3064
|
} else {
|
|
3039
3065
|
this.idMap = /* @__PURE__ */ new Map();
|
|
3040
3066
|
}
|
|
3041
3067
|
if (unionObjects.length > 0) {
|
|
3042
|
-
this.reverseIdMap = buildReverseIdMap(unionObjects);
|
|
3068
|
+
this.reverseIdMap = buildReverseIdMap(unionObjects, prevReverseIdMap);
|
|
3043
3069
|
} else {
|
|
3044
3070
|
this.reverseIdMap = /* @__PURE__ */ new Map();
|
|
3045
3071
|
}
|
|
@@ -3293,7 +3319,7 @@ var SessionManager = class {
|
|
|
3293
3319
|
};
|
|
3294
3320
|
|
|
3295
3321
|
// src/version.ts
|
|
3296
|
-
var VSL_MCP_SERVER_VERSION = "1.2.
|
|
3322
|
+
var VSL_MCP_SERVER_VERSION = "1.2.16";
|
|
3297
3323
|
|
|
3298
3324
|
// src/index.ts
|
|
3299
3325
|
async function main() {
|