@thinkingos/vsl-mcp-server 1.2.10 → 1.2.11

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 CHANGED
@@ -447,6 +447,7 @@ function filterDiffByViewport(diff, nextDoc, prevDoc, win) {
447
447
  // src/tools/getSnapshot.ts
448
448
  var DEFAULT_SNAPSHOT_TTL_MS = 5e3;
449
449
  var snapshotCache = /* @__PURE__ */ new Map();
450
+ var iframeFrameRegistry = /* @__PURE__ */ new Map();
450
451
  function countObjects(objects) {
451
452
  let count = 0;
452
453
  for (const obj of objects) {
@@ -741,6 +742,7 @@ async function handleGetSnapshot(args, browser, session, _config) {
741
742
  frame
742
743
  // сохраняем PlaywrightFrame для injectVslIdsIntoFrame
743
744
  });
745
+ iframeFrameRegistry.set(iframeSubDocs.length - 1, iframeInfo.url);
744
746
  console.log(`[VSL] \u2705 Successfully extracted DOM from iframe: ${iframeInfo.url} (${iframeDoc.objects.length} objects)`);
745
747
  } catch (error) {
746
748
  console.warn(`[VSL] \u274C Failed to extract iframe ${iframeInfo.url}:`, error);
@@ -1124,12 +1126,22 @@ async function handleExecuteAction(args, browser, session) {
1124
1126
  if (frameMatch) {
1125
1127
  const frameIndex = parseInt(frameMatch[1], 10);
1126
1128
  localId = frameMatch[2];
1129
+ const frameUrl = iframeFrameRegistry.get(frameIndex);
1130
+ if (!frameUrl) {
1131
+ return {
1132
+ status: "error",
1133
+ error: `Frame iframe_${frameIndex} not found in registry. Call vsl_get_snapshot first.`
1134
+ };
1135
+ }
1127
1136
  const frames = await browser.getFrames();
1128
- targetFrame = frames[frameIndex + 1] || null;
1137
+ targetFrame = frames.find((f) => {
1138
+ const u = f.url();
1139
+ return u === frameUrl || u.includes(frameUrl) || frameUrl.includes(u);
1140
+ }) || null;
1129
1141
  if (!targetFrame) {
1130
1142
  return {
1131
1143
  status: "error",
1132
- error: `Frame iframe_${frameIndex} not found. Available frames: ${frames.length}`
1144
+ error: `Frame with URL "${frameUrl}" not found. Available frames: ${frames.map((f) => f.url()).join(", ")}`
1133
1145
  };
1134
1146
  }
1135
1147
  }
@@ -3107,7 +3119,7 @@ var SessionManager = class {
3107
3119
  };
3108
3120
 
3109
3121
  // src/version.ts
3110
- var VSL_MCP_SERVER_VERSION = "1.2.10";
3122
+ var VSL_MCP_SERVER_VERSION = "1.2.11";
3111
3123
 
3112
3124
  // src/index.ts
3113
3125
  async function main() {