dsh-chrome-use 0.16.0 → 0.16.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/CHANGELOG.md +19 -0
- package/PRIVACY.md +3 -1
- package/docs/chrome-session-debugging.md +2 -2
- package/extension/background.js +36 -3
- package/extension/controller.js +83 -10
- package/extension/manifest.json +3 -2
- package/package.json +1 -1
- package/src/bridge.js +28 -2
- package/src/client.js +1 -1
- package/docs/chrome-store-draft.md +0 -79
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [0.16.2] - 2026-11-26
|
|
4
|
+
|
|
5
|
+
### 变更
|
|
6
|
+
|
|
7
|
+
- `npm run check` 现在会扫描已提交的文本文件,发现合并冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)就让检查失败,并按 `文件:行号` 报出每一处,提示解决冲突后再提交。`node_modules`、`dist`、`lib` 等构建目录和二进制文件会跳过,避免误报。
|
|
8
|
+
|
|
9
|
+
## [0.16.1] - 2026-11-26
|
|
10
|
+
|
|
11
|
+
### 修复
|
|
12
|
+
|
|
13
|
+
- `chrome_claim` 被另一个扩展的 `chrome-extension://` 内嵌 frame 拦住时,错误信息会列出这些 frame 的 URL、frameId、parentFrameId 和扩展 ID,并给出 `chrome://extensions/?id=...` 方便定位;读不到 frame 树时会说明原因。Chromium 只要页面里任意一个 frame 属于别的扩展就拒绝 DevTools attach,不需要整页被接管。
|
|
14
|
+
- Chrome 主动 detach(例如 `target_closed`)不再立刻释放标签页租约:标签页还在、只是调试目标被丢弃或窗口被移动时,原会话保留 ownership,可重新 claim,其他会话仍然拿不到;标签页真的消失或主动 release 时才释放。
|
|
15
|
+
- detach 提示会翻译原因(DevTools 打开了、别的扩展抢占了调试器、用户取消了调试提示、标签页被关闭),标签页由本扩展关闭时还带上关闭方:`idle`、`chat <port>`、`cleanup <port>`、`disconnect <port>`。
|
|
16
|
+
- `chrome_doctor` 在标签页尚未 attach 时不再只报 `TAB_NOT_ATTACHED`:会返回标签页是否存在、是否已被 Chrome discard、能读到的其他扩展 frame 列表和下一步说明。
|
|
17
|
+
|
|
18
|
+
### 文档
|
|
19
|
+
|
|
20
|
+
- `docs/chrome-session-debugging.md` 补充 frame 诊断、租约保留和 detach 原因说明。
|
|
21
|
+
|
|
3
22
|
## [0.16.0] - 2026-11-24
|
|
4
23
|
|
|
5
24
|
### 新增
|
package/PRIVACY.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## 访问范围
|
|
4
4
|
|
|
5
|
-
dsh-chrome-use 用于让你配置的 DeepSeek Harness 操作本机 Chrome。扩展需要 `debugger`、`tabs`、`tabGroups`、`storage`、`alarms` 和 `
|
|
5
|
+
dsh-chrome-use 用于让你配置的 DeepSeek Harness 操作本机 Chrome。扩展需要 `debugger`、`tabs`、`tabGroups`、`storage`、`alarms`、`downloads` 和 `webNavigation` 权限,分别用于调试网页、选择标签页、把新页面放进同名标签页组、保存配对状态、恢复连接、读取下载记录,以及诊断调试器附加失败。
|
|
6
|
+
|
|
7
|
+
`webNavigation` 只在调试器附加失败、且 Chrome 提示页面中存在其他扩展的页面时使用:读取当前标签页的 frame 列表(URL、frameId、parentFrameId),用于告诉你哪个扩展的哪个 frame 拦截了调试。其他时候不读取,也不记录浏览历史。
|
|
6
8
|
|
|
7
9
|
连接后,Harness 可以读取和操作所有普通 HTTP(S) 标签页,包括已登录的网站。只有 AI 接管的页面才会开启调试和日志采集。Chrome 调试提示条会显示当前调试状态;你可以在扩展弹窗点击“断开全部连接”。
|
|
8
10
|
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
|
|
46
46
|
`chrome_claim` 和 `chrome_open` 失败时报 `ATTACH_FAILED at <阶段>: tab <id> (<协议>://<域名>) <Chrome 原始原因>`。阶段是 `attach`,或者 `Page.enable` 这类 CDP 域名启用步骤;括号里是插件当时解析到的标签页位置,只保留协议和域名,不含路径和查询串,用来判断这个 id 是否还指向你列出的页面。
|
|
47
47
|
|
|
48
|
-
- `Cannot access a chrome-extension:// URL of different extension`:Chrome 拒绝调试,因为这个标签页暴露了另一个扩展的 URL。可能是整页由别的扩展接管(PDF
|
|
48
|
+
- `Cannot access a chrome-extension:// URL of different extension`:Chrome 拒绝调试,因为这个标签页暴露了另一个扩展的 URL。可能是整页由别的扩展接管(PDF 阅读器、替换新标签页的扩展),也可能只是内嵌的扩展页面。插件会用 `chrome.webNavigation.getAllFrames` 找出最多 5 个属于其他扩展的 frame,把 `frameId`、`parentFrameId`、URL 和扩展 ID 写进错误,并给出 `chrome://extensions/?id=<id>` 定位地址;按这个地址停用对应扩展后刷新页面再 claim,或改用没装该扩展的 Chrome 配置。如果 Chrome 没暴露 frame 树(例如标签页刚被关闭),错误会说明 frame 列表读不到。`chrome_doctor` 在未 attach 时也会返回同样的 `extensionFrames`,不必先 claim。
|
|
49
49
|
- `Another debugger is already attached`:这个标签页已被别的调试会话占用。先关掉 DevTools 或另一个扩展的调试会话。
|
|
50
50
|
未占用标签页有两个检查层级,错误码不同,处理方式一样(先 `chrome_tabs` 确认页面还在,再 `chrome_claim`):
|
|
51
51
|
|
|
52
|
-
- `TAB_NOT_OWNED: claim the tab first`:Harness 自己的占用表里没有这个标签页——从未 claim,或已经 `chrome_release`。这是“未 claim 或 release 后继续操作”的预期错误码。消息可能带诊断后缀 `(Chrome detached this tab <n>s ago:
|
|
52
|
+
- `TAB_NOT_OWNED: claim the tab first`:Harness 自己的占用表里没有这个标签页——从未 claim,或已经 `chrome_release`。这是“未 claim 或 release 后继续操作”的预期错误码。消息可能带诊断后缀 `(Chrome detached this tab <n>s ago: <说明>)`,说明由 Chrome 原因翻译而来:`target_closed` 加标签页已关闭时会写 `the tab was closed by <来源>`,来源可能是 `idle`、`chat <port>`、`cleanup <port>` 或 `disconnect <port>`;标签页还开着时会写 target 被丢弃但 tab 仍在、占用仍保留,重新 claim 即可;`replaced_with_devtools` 会写 DevTools 打开并接管了调试会话,`replaced_with_devtools_extension` 会写另一个扩展 attach 了调试器,`canceled_by_user` 会写用户取消了调试提示。插件自己 release 时写 `released`。
|
|
53
53
|
- `TAB_NOT_LEASED: claim the tab first`:Harness 认为仍然持有这个标签页,但扩展侧的租约已经丢失,例如重载扩展之后旧连接还留着。看到它同样先确认页面、再重新 claim。
|
|
54
54
|
- 已经 claim 的页面刷新后使用旧 `ref`,报 `STALE_ELEMENT`;被另一个 Harness 占用的页面报 `TAB_OWNED_BY_ANOTHER_HARNESS`。
|
|
55
55
|
- 失败的命令不会留下占用,可以直接重新 `chrome_claim`。
|
package/extension/background.js
CHANGED
|
@@ -70,11 +70,39 @@ async function applyMode() {
|
|
|
70
70
|
controller.foregroundMode = foregroundMode !== false;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
// Closing a tab discards its debugger state without an onDetach callback, so
|
|
74
|
+
// remember which path closed it. A later failure on the same tab can then say
|
|
75
|
+
// whether this extension closed it and where the close came from.
|
|
76
|
+
const recentCloses = new Map();
|
|
77
|
+
const CLOSE_NOTE_MS = 60000;
|
|
78
|
+
function noteClose(tabId, source) {
|
|
79
|
+
recentCloses.delete(tabId);
|
|
80
|
+
recentCloses.set(tabId, { source, at: Date.now() });
|
|
81
|
+
if (recentCloses.size > 100) recentCloses.delete(recentCloses.keys().next().value);
|
|
82
|
+
}
|
|
83
|
+
function closeSourceFor(tabId) {
|
|
84
|
+
const note = recentCloses.get(tabId);
|
|
85
|
+
if (!note) return null;
|
|
86
|
+
if (Date.now() - note.at > CLOSE_NOTE_MS) { recentCloses.delete(tabId); return null; }
|
|
87
|
+
return note.source;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const controller = new BrowserController(chrome, (tabId, reason, details = {}) => {
|
|
74
91
|
const owner = leases.get(tabId)?.client;
|
|
75
|
-
|
|
92
|
+
if (!owner) return;
|
|
93
|
+
// A removed tab can never be reused. Every other detach may only mean Chrome
|
|
94
|
+
// dropped the target of a tab that is still open (discard, window move), so
|
|
95
|
+
// keep the lease and let the same session re-claim instead of handing a live
|
|
96
|
+
// tab to another session mid-task.
|
|
97
|
+
if (details.tabExists === false || reason === 'released') leases.release(tabId, owner);
|
|
98
|
+
const closeSource = closeSourceFor(tabId);
|
|
76
99
|
if (owner?.connected && owner.socket?.readyState === WebSocket.OPEN) {
|
|
77
|
-
owner.socket.send(JSON.stringify({
|
|
100
|
+
owner.socket.send(JSON.stringify({
|
|
101
|
+
type: 'detached', tabId,
|
|
102
|
+
...(reason ? { reason: String(reason).slice(0, 40) } : {}),
|
|
103
|
+
...(details.tabExists === undefined ? {} : { tabExists: details.tabExists }),
|
|
104
|
+
...(closeSource ? { closeSource } : {}),
|
|
105
|
+
}));
|
|
78
106
|
}
|
|
79
107
|
});
|
|
80
108
|
const idleTabs = createIdleTabs(chrome.storage.session);
|
|
@@ -343,6 +371,7 @@ async function sweepIdleTabs() {
|
|
|
343
371
|
try {
|
|
344
372
|
// This close is opt-in through the popup switch, so it does not ask the
|
|
345
373
|
// page's beforeunload guard. Manual chrome_close still follows its own setting.
|
|
374
|
+
noteClose(tabId, 'idle');
|
|
346
375
|
await controller.closeTab(tabId, undefined, { force: true, attachIfNeeded: true });
|
|
347
376
|
clients.get(record.port)?.opened.delete(tabId);
|
|
348
377
|
await idleTabs.forget(tabId);
|
|
@@ -383,6 +412,7 @@ async function drainClient(client, { closeOpened = false } = {}) {
|
|
|
383
412
|
const wasOpened = closeOpened && client.opened.has(tabId);
|
|
384
413
|
if (wasOpened) {
|
|
385
414
|
// Close before detaching so the beforeunload event is still visible.
|
|
415
|
+
noteClose(tabId, `disconnect ${client.port}`);
|
|
386
416
|
try { await controller.closeTab(tabId, undefined, { force: forceClose, attachIfNeeded: true }); }
|
|
387
417
|
catch (error) {
|
|
388
418
|
const message = String(error?.message ?? error).slice(0, 2000);
|
|
@@ -423,6 +453,7 @@ async function drainClient(client, { closeOpened = false } = {}) {
|
|
|
423
453
|
if (owner && owner !== client) { client.opened.delete(tabId); continue; }
|
|
424
454
|
// A detached tab has no dialog listener, so closeTab briefly reattaches
|
|
425
455
|
// for the forced close; a failure still falls back to plain removal.
|
|
456
|
+
noteClose(tabId, `disconnect ${client.port}`);
|
|
426
457
|
try { await controller.closeTab(tabId, undefined, { force: forceClose, attachIfNeeded: true }); }
|
|
427
458
|
catch (error) {
|
|
428
459
|
const message = String(error?.message ?? error).slice(0, 2000);
|
|
@@ -734,6 +765,7 @@ async function cleanupOpenedTabs(client, args, signal) {
|
|
|
734
765
|
// Close while the debugger session is still attached so a beforeunload
|
|
735
766
|
// prompt can be accepted. closeTab removes the tab and drops local state;
|
|
736
767
|
// the lease is released explicitly below.
|
|
768
|
+
noteClose(tabId, `cleanup ${client.port}`);
|
|
737
769
|
await controller.closeTab(tabId, signal, { force: forceClose, attachIfNeeded: true });
|
|
738
770
|
leases.release(tabId, client);
|
|
739
771
|
client.opened.delete(tabId);
|
|
@@ -847,6 +879,7 @@ async function handleCommand(client, message) {
|
|
|
847
879
|
const commandArgs = action === 'close' && args.force === undefined
|
|
848
880
|
? { ...args, force: await forceCloseBeforeUnload() }
|
|
849
881
|
: args;
|
|
882
|
+
if (action === 'close' && tabId !== undefined) noteClose(tabId, `chat ${client.port}`);
|
|
850
883
|
response = { result: action === 'cleanup' ? await cleanupOpenedTabs(client, args, cancellation.signal) : await controller.execute(action, commandArgs, cancellation.signal, options) };
|
|
851
884
|
if (action === 'close' && tabId !== undefined) { client.opened.delete(tabId); forgetIdleTab(tabId); }
|
|
852
885
|
} catch (error) {
|
package/extension/controller.js
CHANGED
|
@@ -25,13 +25,25 @@ export function tabLocation(value) {
|
|
|
25
25
|
} catch { return 'unparseable'; }
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// Chrome refuses a tab that exposes another extension's URL, and the usual
|
|
29
|
+
// cause is one injected iframe. Name the frame and the owning extension so the
|
|
30
|
+
// caller does not have to guess which extension to disable.
|
|
31
|
+
export function extensionHint(frames) {
|
|
32
|
+
if (frames === undefined) {
|
|
33
|
+
return '; Chrome blocked debugging because the tab exposes another extension\'s URL, possibly from an embedded frame; the frame list could not be read, so check chrome://extensions and reload the page after disabling the extension';
|
|
34
|
+
}
|
|
35
|
+
if (!frames.length) {
|
|
36
|
+
return '; Chrome blocked debugging because the tab exposes another extension\'s URL, but the frame list no longer shows that frame; it may have navigated away, so reload the page and retry';
|
|
37
|
+
}
|
|
38
|
+
const listed = frames.map(frame => `${frame.url} (frame ${frame.frameId}, parent ${frame.parentFrameId})`).join('; ');
|
|
39
|
+
const ids = [...new Set(frames.map(frame => frame.extensionId).filter(Boolean))];
|
|
40
|
+
const owners = ids.length ? `; extension${ids.length > 1 ? 's' : ''} ${ids.join(', ')}` : '';
|
|
41
|
+
return `; Chrome blocked debugging because an embedded frame belongs to another extension: ${listed}${owners}; open chrome://extensions/?id=${ids[0] ?? ''} and disable it, or claim the tab in a Chrome profile without that extension`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function attachFailure(error, tabId, url, stage = 'attach', frames) {
|
|
29
45
|
const reason = clip(error?.message ?? error, 300);
|
|
30
|
-
|
|
31
|
-
// embedded frame as well as the top-level page, so do not name the owner.
|
|
32
|
-
const hint = /chrome-extension:\/\/ URL of different extension/i.test(reason)
|
|
33
|
-
? '; Chrome blocked debugging because the tab exposes another extension\'s URL, which can also come from an embedded frame; open the page in a normal tab and claim that one'
|
|
34
|
-
: '';
|
|
46
|
+
const hint = /chrome-extension:\/\/ URL of different extension/i.test(reason) ? extensionHint(frames) : '';
|
|
35
47
|
return new Error(`ATTACH_FAILED at ${stage}: tab ${tabId} (${tabLocation(url)}) ${reason}${hint}`);
|
|
36
48
|
}
|
|
37
49
|
|
|
@@ -202,20 +214,62 @@ export class BrowserController {
|
|
|
202
214
|
this.chooserPendingMs = 30000;
|
|
203
215
|
this.chooserWaitMs = 500;
|
|
204
216
|
this.attached = new Map();
|
|
217
|
+
// Tabs whose Chrome target vanished while the tab stayed open. Chrome does
|
|
218
|
+
// not announce their later close with another detach, so onRemoved must
|
|
219
|
+
// finish that notification without double-reporting an explicit release.
|
|
220
|
+
this.liveDetached = new Set();
|
|
205
221
|
// Native Chrome promises outlive our timeouts. Do not attach a new session
|
|
206
222
|
// while a previous native cleanup can still detach it.
|
|
207
223
|
this.pendingCleanup = new Map();
|
|
208
224
|
api.debugger.onDetach.addListener(({ tabId }, reason) => {
|
|
209
225
|
clearTimeout(this.attached.get(tabId)?.chooserTimer);
|
|
210
|
-
if (this.attached.delete(tabId))
|
|
226
|
+
if (!this.attached.delete(tabId)) return;
|
|
227
|
+
// Detach is not always a close: Chrome drops the target when it discards a
|
|
228
|
+
// tab or moves it between windows. Tell the owner whether the tab still
|
|
229
|
+
// exists, so a live tab keeps its lease and the same chat can re-claim it.
|
|
230
|
+
const notify = tabExists => {
|
|
231
|
+
if (tabExists) this.liveDetached.add(tabId);
|
|
232
|
+
try { detached(tabId, reason, { tabExists }); } catch {}
|
|
233
|
+
};
|
|
234
|
+
this.api.tabs.get(tabId).then(() => notify(true), () => notify(false));
|
|
211
235
|
});
|
|
212
236
|
api.tabs.onRemoved.addListener(tabId => {
|
|
213
237
|
clearTimeout(this.attached.get(tabId)?.chooserTimer);
|
|
214
|
-
|
|
238
|
+
const wasAttached = this.attached.delete(tabId);
|
|
239
|
+
const wasLive = this.liveDetached.delete(tabId);
|
|
240
|
+
// A removed tab can never be reclaimed. Report it when it was attached or
|
|
241
|
+
// when an earlier detach kept its lease for a still-open tab.
|
|
242
|
+
if (!wasAttached && !wasLive) return;
|
|
243
|
+
try { detached(tabId, 'target_closed', { tabExists: false }); } catch {}
|
|
215
244
|
});
|
|
216
245
|
api.debugger.onEvent.addListener((target, method, params) => this.event(target, method, params));
|
|
217
246
|
}
|
|
218
247
|
|
|
248
|
+
// Frames are the only reliable way to name the blocker: chrome.debugger
|
|
249
|
+
// targets carry no tabId for iframes. Read them lazily after a failed attach
|
|
250
|
+
// and bound the read so diagnostics never delay the real error for long.
|
|
251
|
+
async extensionFrames(tabId) {
|
|
252
|
+
const getAllFrames = this.api.webNavigation?.getAllFrames;
|
|
253
|
+
if (typeof getAllFrames !== 'function') return undefined;
|
|
254
|
+
let frames;
|
|
255
|
+
try {
|
|
256
|
+
const call = async () => getAllFrames({ tabId });
|
|
257
|
+
frames = await bounded(call(), undefined, 'webNavigation.getAllFrames', 800);
|
|
258
|
+
} catch { return undefined; }
|
|
259
|
+
if (!Array.isArray(frames)) return undefined;
|
|
260
|
+
const own = this.api.runtime?.id;
|
|
261
|
+
const found = [];
|
|
262
|
+
for (const frame of frames) {
|
|
263
|
+
let url;
|
|
264
|
+
try { url = new URL(frame?.url); } catch { continue; }
|
|
265
|
+
if (url.protocol !== 'chrome-extension:') continue;
|
|
266
|
+
if (own && url.host === own) continue;
|
|
267
|
+
found.push({ frameId: frame.frameId, parentFrameId: frame.parentFrameId, url: clip(`${url.protocol}//${url.host}${url.pathname}`, 160), extensionId: url.host });
|
|
268
|
+
if (found.length === 5) break;
|
|
269
|
+
}
|
|
270
|
+
return found;
|
|
271
|
+
}
|
|
272
|
+
|
|
219
273
|
trackCleanup(tabId, promise) {
|
|
220
274
|
this.pendingCleanup.set(tabId, promise);
|
|
221
275
|
promise.then(() => {
|
|
@@ -330,9 +384,12 @@ export class BrowserController {
|
|
|
330
384
|
try { await bounded(attachment, signal, 'attach'); }
|
|
331
385
|
catch (error) {
|
|
332
386
|
this.trackCleanup(tabId, attachment.then(() => this.api.debugger.detach({ tabId }), () => {}));
|
|
333
|
-
|
|
387
|
+
const blocked = /chrome-extension:\/\/ URL of different extension/i.test(String(error?.message ?? error));
|
|
388
|
+
const frames = blocked && !signal?.aborted ? await this.extensionFrames(tabId) : undefined;
|
|
389
|
+
throw attachFailure(error, tabId, currentUrl, 'attach', frames);
|
|
334
390
|
}
|
|
335
391
|
this.attached.set(tabId, { refs: new Map(), revision: 0, logs: [], logSeq: 0, requests: [], dialog: null, chooser: null, chooserTimer: null, loadResolve: null, lastNetworkActivity: Date.now(), networkInFlight: 0, networkRequests: new Map(), mainFrameId: null, actions: [], actionSeq: 0, challenge: null, emulation: null, acceptBeforeUnload: false });
|
|
392
|
+
this.liveDetached.delete(tabId);
|
|
336
393
|
let stage = 'attach';
|
|
337
394
|
try {
|
|
338
395
|
for (const domain of ['Page', 'DOM', 'Accessibility', 'Runtime', 'Network']) {
|
|
@@ -838,7 +895,23 @@ export class BrowserController {
|
|
|
838
895
|
if (action === 'doctor') {
|
|
839
896
|
if (tabId === undefined) return { tabId: null, attached: false, note: 'No tab given: this reports host-side checks only.' };
|
|
840
897
|
const state = this.attached.get(tabId);
|
|
841
|
-
if (!state)
|
|
898
|
+
if (!state) {
|
|
899
|
+
// An unattached tab is exactly when this report is most useful: name
|
|
900
|
+
// the extension frames that can block the next claim instead of only
|
|
901
|
+
// failing the call.
|
|
902
|
+
let tab;
|
|
903
|
+
try { tab = await bounded(this.api.tabs.get(tabId), signal, 'tabs.get'); }
|
|
904
|
+
catch (error) {
|
|
905
|
+
if (signal.aborted) throw error;
|
|
906
|
+
return { tabId, exists: false, attached: false, note: 'This tab no longer exists. Claim another tab; if the page reopened, Chrome gave it a new tab id.' };
|
|
907
|
+
}
|
|
908
|
+
const frames = await this.extensionFrames(tabId);
|
|
909
|
+
return {
|
|
910
|
+
tabId, exists: true, url: clip(tab.url, 4096), title: clip(tab.title, 300), attached: false,
|
|
911
|
+
discarded: Boolean(tab.discarded), extensionFrames: frames ?? null,
|
|
912
|
+
note: 'This tab is not attached to the debugger. Claim it again. Embedded frames owned by another extension block attach; extensionFrames lists them when Chrome exposes the frame tree.',
|
|
913
|
+
};
|
|
914
|
+
}
|
|
842
915
|
const tab = await bounded(this.api.tabs.get(tabId), signal, 'tabs.get');
|
|
843
916
|
let page = null;
|
|
844
917
|
try {
|
package/extension/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "dsh-chrome-use",
|
|
4
4
|
"description": "Let DeepSeek Harness control Chrome tabs, with several agent sessions working in parallel.",
|
|
5
|
-
"version": "0.16.
|
|
5
|
+
"version": "0.16.2",
|
|
6
6
|
"minimum_chrome_version": "120",
|
|
7
7
|
"permissions": [
|
|
8
8
|
"debugger",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"tabGroups",
|
|
11
11
|
"storage",
|
|
12
12
|
"alarms",
|
|
13
|
-
"downloads"
|
|
13
|
+
"downloads",
|
|
14
|
+
"webNavigation"
|
|
14
15
|
],
|
|
15
16
|
"background": {
|
|
16
17
|
"service_worker": "background.js",
|
package/package.json
CHANGED
package/src/bridge.js
CHANGED
|
@@ -20,6 +20,21 @@ const portValue = value => {
|
|
|
20
20
|
return Number.isSafeInteger(port) && port >= 1024 && port <= 65535 ? String(port) : undefined;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// Chrome reasons are short codes. Explain what each one means for the tab, so a
|
|
24
|
+
// later failure says whether to retry, re-claim, or give up on this tab.
|
|
25
|
+
function describeDetach({ reason, tabExists, closeSource }) {
|
|
26
|
+
if (reason === 'released') return 'this chat released it';
|
|
27
|
+
if (reason === 'target_closed') {
|
|
28
|
+
if (tabExists === false) return `the tab was closed${closeSource ? ` by ${closeSource}` : ' outside this extension'}`;
|
|
29
|
+
if (tabExists === true) return 'Chrome dropped the debug target but the tab is still open (discarded or moved between windows); this chat still holds it, claim it again';
|
|
30
|
+
return 'Chrome closed the debug target';
|
|
31
|
+
}
|
|
32
|
+
if (reason === 'replaced_with_devtools') return 'DevTools opened on this tab and took the debugger session';
|
|
33
|
+
if (reason === 'replaced_with_devtools_extension') return 'another extension attached its debugger to this tab';
|
|
34
|
+
if (reason === 'canceled_by_user') return 'the user canceled the debugging prompt';
|
|
35
|
+
return reason ? `reason ${reason}` : 'the reason is unknown';
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
export class Bridge {
|
|
24
39
|
constructor({ port = PORT, auto = false, portCandidates, baseStateDir, stateDir, name, probe = probePort, deadlineMs = DEADLINE_MS, claimWaitMs = CLAIM_WAIT_MS } = {}) {
|
|
25
40
|
// Optional label the agent side shows in the popup so the user can tell
|
|
@@ -264,9 +279,14 @@ export class Bridge {
|
|
|
264
279
|
return;
|
|
265
280
|
}
|
|
266
281
|
if (message.type === 'detached' && Number.isSafeInteger(message.tabId)) {
|
|
267
|
-
|
|
282
|
+
// The extension keeps the lease when the tab still exists (Chrome
|
|
283
|
+
// dropped the target for a discard or a window move). Keep the claim
|
|
284
|
+
// too, so the same chat can inspect and re-claim the tab it still owns.
|
|
285
|
+
if (!(message.tabExists === true && message.reason !== 'released')) this.claims.delete(message.tabId);
|
|
268
286
|
this.lastDetach.set(message.tabId, {
|
|
269
287
|
reason: typeof message.reason === 'string' ? message.reason.slice(0, 40) : null,
|
|
288
|
+
...(typeof message.tabExists === 'boolean' ? { tabExists: message.tabExists } : {}),
|
|
289
|
+
...(typeof message.closeSource === 'string' ? { closeSource: message.closeSource.slice(0, 80) } : {}),
|
|
270
290
|
at: Date.now(),
|
|
271
291
|
});
|
|
272
292
|
if (this.lastDetach.size > 200) this.lastDetach.delete(this.lastDetach.keys().next().value);
|
|
@@ -361,7 +381,7 @@ export class Bridge {
|
|
|
361
381
|
const last = this.lastDetach.get(tabId);
|
|
362
382
|
if (!last || Date.now() - last.at > 60000) return '';
|
|
363
383
|
const age = Math.max(0, Math.round((Date.now() - last.at) / 1000));
|
|
364
|
-
return ` (Chrome detached this tab ${age}s ago
|
|
384
|
+
return ` (Chrome detached this tab ${age}s ago: ${describeDetach(last)})`;
|
|
365
385
|
}
|
|
366
386
|
|
|
367
387
|
rejectWaiters(tabId, error) {
|
|
@@ -455,6 +475,12 @@ export class Bridge {
|
|
|
455
475
|
acquired = true;
|
|
456
476
|
}
|
|
457
477
|
if (action === 'release') this.releaseClaim(args.tabId, owner);
|
|
478
|
+
// A doctor run right after a failure should explain why the tab detached,
|
|
479
|
+
// not just report that it is not attached.
|
|
480
|
+
if (action === 'doctor' && tabId !== undefined) {
|
|
481
|
+
const note = this.lastDetach.get(tabId);
|
|
482
|
+
if (note && Date.now() - note.at <= 60000) result.detach = { ...note };
|
|
483
|
+
}
|
|
458
484
|
if (action === 'messages') {
|
|
459
485
|
// Reading consumes the hint; the result already carries the text.
|
|
460
486
|
const unread = Number.isSafeInteger(result?.unread) && result.unread > 0 ? result.unread : 0;
|
package/src/client.js
CHANGED
|
@@ -179,7 +179,7 @@ async function checkRelease(current, fetcher = fetch) {
|
|
|
179
179
|
} finally { clearTimeout(timer); }
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
const packageVersion = "0.16.
|
|
182
|
+
const packageVersion = "0.16.2";
|
|
183
183
|
// Wrapped by scripts/build-client.mjs for the Harness browser module loader.
|
|
184
184
|
const React = require('react');
|
|
185
185
|
const { createElement: h, useState, useEffect, useRef } = React;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# Chrome 扩展商店
|
|
2
|
-
|
|
3
|
-
## 商店地址
|
|
4
|
-
|
|
5
|
-
https://chromewebstore.google.com/detail/anobmlnjdeahldefeikjdmmnckphpdhc
|
|
6
|
-
|
|
7
|
-
## 名称与简介
|
|
8
|
-
|
|
9
|
-
名称:dsh-chrome-use
|
|
10
|
-
|
|
11
|
-
简介:操纵你正在使用的 Chrome:新建或复用已登录标签页,读取页面、点击、填写、拖拽、滚动、截图,查看控制台与网络日志。多个 Agent 会话可同时操作不同标签页,同一标签页自动排队。商店安装,8 位配对码连接,自动选择可用端口。
|
|
12
|
-
|
|
13
|
-
## 详细介绍
|
|
14
|
-
|
|
15
|
-
操纵你正在使用的 Chrome 浏览器:新建或复用已登录的标签页,让模型读取页面、点击、填写、拖拽页面元素、滚动、截图,新建标签页并分组、关闭本会话打开的标签页,查看控制台与网络日志、按需读取单条响应体、查看下载记录,调试浏览器等。多个 Agent 会话可以同时操作不同的标签页,同一标签页会排队执行。扩展从 Chrome 应用商店安装,用 8 位配对码连接;配对码可能含字母,并包含实际端口。
|
|
16
|
-
|
|
17
|
-
它把 Chrome 接到本机 DeepSeek Harness,不用复制链接,也不用重复登录;首次配对后保存连接凭据,后续自动重连。
|
|
18
|
-
|
|
19
|
-
能做什么
|
|
20
|
-
|
|
21
|
-
• 点击、双击、右键、悬停、拖拽页面元素、下拉选择
|
|
22
|
-
• 填写表单,按 Enter、Tab、Esc、Home、End、PageUp、PageDown,以及 meta+a、ctrl+shift+k 等组合键
|
|
23
|
-
• 一次上传一个或多个文件
|
|
24
|
-
• 等待元素出现、文字出现、网址变化或网络空闲
|
|
25
|
-
• 刷新、后退、前进,把标签页切到前台
|
|
26
|
-
• 新建标签页并放进同名标签页组;关闭本会话打开的标签页
|
|
27
|
-
• 滚动到指定元素,也支持内部滚动容器
|
|
28
|
-
• 截取视口、整页或单个元素
|
|
29
|
-
• 把页面导出为 PDF
|
|
30
|
-
• 处理 alert、confirm、prompt 对话框
|
|
31
|
-
• 读取页面结构、控制台、JavaScript 错误和网络状态
|
|
32
|
-
• 操作开放 Shadow DOM 内的元素
|
|
33
|
-
|
|
34
|
-
并发与协调
|
|
35
|
-
|
|
36
|
-
• 多个 Harness 会话(Agent)可以同时操作不同的标签页,读取、等待和截图互不阻塞
|
|
37
|
-
• 多个 Harness 进程可以用不同端口同时连接;每个进程独立配对,标签页占用由扩展统一协调
|
|
38
|
-
• 同一 Harness 内,同一标签页同一时间只执行一条命令;其他会话申请时按先来后到排队,最多等 10 秒
|
|
39
|
-
• 不同 Harness 之间不排队:标签页已被另一个 Harness 占用时立即返回 `TAB_OWNED_BY_ANOTHER_HARNESS`
|
|
40
|
-
• 点击、输入、拖拽、关闭、激活等会切换前台的操作自动排队,避免中途抢走焦点
|
|
41
|
-
• 取消或超时后,等扩展确认清理完成才释放占用;超过 8 秒仍未清理会断开连接,避免旧操作影响下一个会话
|
|
42
|
-
• 这些锁只协调本插件发出的操作,不能阻止你手动切换页面、其他扩展或网页脚本改变焦点
|
|
43
|
-
|
|
44
|
-
首次配对后保存连接凭据,后续自动重连。连接后,AI 可以选择所有普通 HTTP(S) 标签页,不需要逐页授权。
|
|
45
|
-
|
|
46
|
-
调试时 Chrome 会显示调试提示,点击时页面会短暂显示蓝色箭头。扩展弹窗列出每个端口的连接状态,可单独连接或忘记,也可以随时断开全部连接。
|
|
47
|
-
|
|
48
|
-
使用前
|
|
49
|
-
|
|
50
|
-
需要在同一台电脑安装 DeepSeek Harness 和本仓库提供的 Harness 插件。扩展不提供模型服务,不包含模型 API Key。你选择的模型服务可能处理工具返回的网页内容。
|
|
51
|
-
|
|
52
|
-
## 单一用途
|
|
53
|
-
|
|
54
|
-
为用户配置的本机 DeepSeek Harness 提供 Chrome 页面操作和调试能力。
|
|
55
|
-
|
|
56
|
-
## 权限用途
|
|
57
|
-
|
|
58
|
-
| 权限 | 用途 |
|
|
59
|
-
|---|---|
|
|
60
|
-
| `debugger` | 读取页面结构,执行浏览器输入、截图和网页调试 |
|
|
61
|
-
| `tabs` | 列出和选择标签页,读取目标页标题及 URL |
|
|
62
|
-
| `tabGroups` | 把 chrome_open 打开的标签页放进同名标签页组 |
|
|
63
|
-
| `storage` | 保存配对令牌和自动重连状态 |
|
|
64
|
-
| `alarms` | 在 Harness 重启或连接中断后尝试重连 |
|
|
65
|
-
| `downloads` | 按用户要求列出下载记录,确认文件是否保存成功;不修改下载内容 |
|
|
66
|
-
|
|
67
|
-
## 数据披露依据
|
|
68
|
-
|
|
69
|
-
以仓库 [PRIVACY.md](../PRIVACY.md) 为准。作者没有页面数据接收服务器。工具结果会进入用户的 Harness 会话,并可能发送给用户选择的模型提供方。截图和配对数据保存在本机。
|
|
70
|
-
|
|
71
|
-
调试工具可按用户要求在页面执行 JavaScript。商店的代码执行及数据披露问卷需要与上述内容保持一致,审核政策变化时同步复核。
|
|
72
|
-
|
|
73
|
-
## 上架状态
|
|
74
|
-
|
|
75
|
-
扩展已在 Chrome 应用商店公开,用户可以直接从上面的商店地址安装,并由 Chrome 自动更新。
|
|
76
|
-
|
|
77
|
-
本页内容供维护者更新商店条目时参考,普通用户直接按 README 使用即可。
|
|
78
|
-
|
|
79
|
-
仓库发布不会改变商店版本:仓库里的扩展版本更新后,需要把新的扩展包重新上传到商店,审核通过后用户才会收到更新。扩展包和本页描述要一起更新。目前没有准备 Edge 商店版本。
|