cdp-tunnel 2.5.20 → 2.5.21

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.
@@ -162,6 +162,8 @@ var SpecialHandler = (function() {
162
162
  function addTabToAutomationGroup(tabId, clientId) {
163
163
  Logger.info('[TabGroup] Starting addTabToAutomationGroup for tabId:', tabId, 'clientId:', clientId);
164
164
 
165
+ WebSocketManager.send({ type: 'tabgroup-debug', tabId: tabId, clientId: clientId, phase: 'start' });
166
+
165
167
  setTimeout(function() {
166
168
  muteTabIfNeeded(tabId);
167
169
  }, 200);
@@ -185,12 +187,20 @@ var SpecialHandler = (function() {
185
187
 
186
188
  function doGroup(tabId, clientId, baseName, retries) {
187
189
  retries = retries || 0;
190
+ Logger.info('[TabGroup] doGroup: tabId=' + tabId + ' clientId=' + (clientId || 'none') + ' baseName=' + baseName + ' retry=' + retries);
188
191
  chrome.tabGroups.query({}, function(allGroups) {
192
+ if (chrome.runtime.lastError) {
193
+ Logger.error('[TabGroup] tabGroups.query failed:', chrome.runtime.lastError.message);
194
+ EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'query', error: chrome.runtime.lastError.message });
195
+ }
196
+ Logger.info('[TabGroup] query result: ' + (allGroups ? allGroups.length : 'null') + ' groups');
189
197
  var existing = CDPUtils.findGroupByName(allGroups, baseName);
190
198
  if (existing) {
199
+ Logger.info('[TabGroup] Found existing group:', existing.id, 'title:', existing.title);
191
200
  chrome.tabs.group({ tabIds: tabId, groupId: existing.id }, function(result) {
192
201
  if (chrome.runtime.lastError) {
193
202
  Logger.error('[TabGroup] Failed to add tab to group:', chrome.runtime.lastError.message, 'retries:', retries);
203
+ EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'addToExisting', error: chrome.runtime.lastError.message, tabId: tabId, groupId: existing.id });
194
204
  if (retries < 3) {
195
205
  setTimeout(function() { doGroup(tabId, clientId, baseName, retries + 1); }, 500);
196
206
  }
@@ -201,14 +211,18 @@ var SpecialHandler = (function() {
201
211
  }
202
212
  });
203
213
  } else {
214
+ Logger.info('[TabGroup] No existing group, creating new one for tab:', tabId);
204
215
  chrome.tabs.group({ tabIds: tabId }, function(groupId) {
205
216
  if (chrome.runtime.lastError) {
206
217
  Logger.error('[TabGroup] Failed to create group:', chrome.runtime.lastError.message, 'retries:', retries);
218
+ EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'createGroup', error: chrome.runtime.lastError.message, tabId: tabId });
207
219
  if (retries < 3) {
208
220
  setTimeout(function() { doGroup(tabId, clientId, baseName, retries + 1); }, 500);
209
221
  }
210
222
  return;
211
223
  }
224
+ Logger.info('[TabGroup] chrome.tabs.group returned groupId:', groupId);
225
+ EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'groupCreated', tabId: tabId, groupId: groupId });
212
226
  if (groupId) {
213
227
  chrome.tabGroups.update(groupId, {
214
228
  title: baseName,
@@ -217,12 +231,15 @@ var SpecialHandler = (function() {
217
231
  }, function() {
218
232
  if (chrome.runtime.lastError) {
219
233
  Logger.error('[TabGroup] Failed to update group:', chrome.runtime.lastError.message);
234
+ EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'updateGroup', error: chrome.runtime.lastError.message, groupId: groupId });
220
235
  } else {
221
236
  State.setGroupIdForClient(clientId, groupId);
222
237
  updateTabGroupName(clientId);
223
238
  Logger.info('[TabGroup] Created new group:', groupId, 'with tab:', tabId);
224
239
  }
225
240
  });
241
+ } else {
242
+ Logger.error('[TabGroup] chrome.tabs.group returned null groupId');
226
243
  }
227
244
  });
228
245
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.5.20",
4
+ "version": "2.5.21",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.5.20",
3
+ "version": "2.5.21",
4
4
  "description": "Bridge Chrome's debugger API to WebSocket — control your existing browser with Playwright/Puppeteer via CDP",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",
@@ -633,11 +633,18 @@ function handlePluginConnection(ws, clientInfo) {
633
633
 
634
634
  console.log(`[PLUGIN MSG] id=${parsed?.id} method=${parsed?.method || 'none'} type=${parsed?.type || 'none'} sessionId=${parsed?.sessionId?.substring(0,8) || 'none'}`);
635
635
 
636
+ if (parsed?.type === 'tabgroup-debug') {
637
+ console.log(`[TABGROUP DEBUG] ${JSON.stringify(parsed)}`);
638
+ }
639
+
636
640
  // 记录所有 PLUGIN -> CLIENT 消息到日志文件
637
641
  logCDP('PLUGIN -> CLIENT', data.toString().substring(0, CONFIG.LOG_MESSAGE_PREVIEW_LENGTH), parsed?.sessionId, ws.pluginType);
638
642
 
639
643
  // 处理 type: 'event' 消息(来自 background.js 的 screencast 等事件)
640
644
  if (parsed && parsed.type === 'event' && parsed.method) {
645
+ if (parsed.method.startsWith('CDPTunnel.')) {
646
+ console.log(`[EXT DEBUG] ${parsed.method}: ${JSON.stringify(parsed.params)}`);
647
+ }
641
648
  // 对于 Target 事件,始终广播给所有客户端
642
649
  const targetEvents = ['Target.targetCreated', 'Target.attachedToTarget', 'Target.targetDestroyed', 'Target.targetInfoChanged'];
643
650
  if (targetEvents.includes(parsed.method)) {