dsh-chrome-use 0.19.1 → 0.20.0
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 +13 -0
- package/README.md +23 -0
- package/extension/background.js +26 -1
- package/extension/idle-tabs.js +14 -2
- package/extension/manifest.json +1 -1
- package/extension/popup.html +5 -4
- package/extension/popup.js +14 -2
- package/package.json +1 -1
- package/src/client.js +1 -1
- package/src/skill.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [0.20.0] - 2026-11-30
|
|
4
|
+
|
|
5
|
+
### 变更
|
|
6
|
+
|
|
7
|
+
- 空闲标签页自动关闭改为默认开启:以前 `autoCloseIdleTabs` 未设置时按关闭处理,绝大多数人从没勾选过,于是 Agent 用 `chrome_open` 打开的标签页在任务结束后一直累积。现在未设置时视为开启,只有显式存了 `false` 才关闭(读不到设置时仍然按关闭处理,避免在无法判断时执行破坏性清扫)。
|
|
8
|
+
- 清扫时新增 pinned 判断:用户把标签页固定(pinned)视为明确要保留,扩展会忘掉这条记录而不是每分钟重试,也绝不关闭。
|
|
9
|
+
- 弹窗「空闲标签页」一栏新增诊断行:显示正在跟踪的标签页数量与最早到期时间;`chrome_status` 消息回复新增 `idle` 字段(`enabled`、`tracked`、`timeoutSeconds`、`nextDueAt`)。
|
|
10
|
+
- `extension/idle-tabs.js` 导出 `normalizeActivity()` 并新增 `summary()`,便于单测覆盖记录归一化和诊断数据。
|
|
11
|
+
|
|
12
|
+
### 修复
|
|
13
|
+
|
|
14
|
+
- 标签页已经被手动关掉时,清扫会静默忘掉记录,不再把它当成错误写进 `lastError`。
|
|
15
|
+
|
|
3
16
|
## [0.19.1] - 2026-11-30
|
|
4
17
|
|
|
5
18
|
### 修复
|
package/README.md
CHANGED
|
@@ -128,6 +128,17 @@ Let DeepSeek Harness read, operate and debug the Google Chrome on your machine.
|
|
|
128
128
|
|
|
129
129
|
The same extension and data channel also work for Codex, OpenCode, Workbody and other harnesses: this package targets DeepSeek Harness, and other harnesses attach to the same bridge through the standalone JSON runner, with identical permissions, ports and tab rules.
|
|
130
130
|
|
|
131
|
+
### 9. 空闲标签页自动关闭(默认开启)
|
|
132
|
+
|
|
133
|
+
Agent 用 `chrome_open` 打开的标签页,在任务结束、连接断开后可能一直留着。现在默认会在空闲超时后自动关闭:
|
|
134
|
+
|
|
135
|
+
- 默认 30 分钟,弹窗里可以改成 1 秒到 600 分钟。
|
|
136
|
+
- 只处理 Agent 打开、已经不在调试、也没有被占用的标签页;你自己开的标签页、正在调试的、被 claim/lease 的、固定(pinned)的都不会被关。
|
|
137
|
+
- 连接断开(Harness 退出或崩溃)时,该连接打开过的标签页仍会立刻关闭,不用等超时。
|
|
138
|
+
- 弹窗的「空闲标签页」一栏会显示正在跟踪几个标签页、最早什么时候到期,便于确认清理确实在跑。
|
|
139
|
+
- 不想要就取消弹窗里的勾选,设置会保存下来,清理由 `chrome_cleanup` 手动做。
|
|
140
|
+
- 自动关闭始终直接关,不弹网页的「离开此网站?」确认(清扫等不了人工点击);手动 `chrome_close` 仍按「关闭时不再确认」的开关执行。
|
|
141
|
+
|
|
131
142
|
## Install
|
|
132
143
|
|
|
133
144
|
> **Install the Harness plugin first, then the Chrome extension, then pair them.** The plugin can be installed in three ways; pick one and copy the command.
|
|
@@ -243,3 +254,15 @@ ssh -L 18791:127.0.0.1:18791 user@server
|
|
|
243
254
|
- `npm run smoke` loads the unpacked extension in headless Chrome and checks that its service worker registers; the `Real Chrome smoke` CI job runs the same script.
|
|
244
255
|
- `npm run publish:store` uploads `dist/dsh-chrome-use-<version>.zip` to the Chrome Web Store and submits it for review. It reads `CWS_CLIENT_ID`, `CWS_CLIENT_SECRET`, `CWS_REFRESH_TOKEN` and `CWS_APP_ID` from the environment only. `.github/workflows/publish-store.yml` keeps those secrets in the `chrome-web-store` environment and requires the `release-v<version>` tag to point at main.
|
|
245
256
|
- The store build and the npm package share `package.json`'s `version`; run `npm run package` before publishing and add the matching row to the version table in `CHROMEWEBSTORE.md`.
|
|
257
|
+
|
|
258
|
+
### 9. Idle tabs close automatically (on by default)
|
|
259
|
+
|
|
260
|
+
Tabs an agent opened with `chrome_open` used to outlive the task and pile up. They are now closed once idle:
|
|
261
|
+
|
|
262
|
+
- 30 minutes by default; the popup accepts anything from 1 second to 600 minutes.
|
|
263
|
+
- Only tabs this extension opened, with no debugger attached and no lease, are closed. Your own tabs, tabs under the debugger, claimed/leased tabs and pinned tabs are never closed.
|
|
264
|
+
- When a connection drops (Harness exits or crashes), the tabs that connection opened are still closed immediately rather than waiting for the timeout.
|
|
265
|
+
- The popup shows how many tabs are tracked and when the oldest one is due, so cleanup is visible.
|
|
266
|
+
- Clear the checkbox in the popup to keep tabs instead; that choice is stored, and `chrome_cleanup` remains available for manual cleanup.
|
|
267
|
+
- The sweep always closes without the page's "Leave site?" prompt (nobody is there to answer it); manual `chrome_close` still follows the "close without confirming" setting.
|
|
268
|
+
|
package/extension/background.js
CHANGED
|
@@ -287,10 +287,14 @@ async function forceCloseBeforeUnload() {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
// On unless the user turned it off. A task that ends without a disconnect used
|
|
291
|
+
// to leave its tabs behind forever because the switch defaulted to off. A
|
|
292
|
+
// stored false still wins, and an unreadable setting falls back to off so a
|
|
293
|
+
// destructive sweep never runs on a guess.
|
|
290
294
|
async function idleCloseEnabled() {
|
|
291
295
|
try {
|
|
292
296
|
const stored = await chrome.storage.local.get(IDLE_SETTING);
|
|
293
|
-
return stored[IDLE_SETTING]
|
|
297
|
+
return stored[IDLE_SETTING] !== false;
|
|
294
298
|
} catch {
|
|
295
299
|
return false;
|
|
296
300
|
}
|
|
@@ -309,6 +313,20 @@ async function idleCloseTimeoutMs() {
|
|
|
309
313
|
}
|
|
310
314
|
}
|
|
311
315
|
|
|
316
|
+
// Reported by chrome_status so a user can see that cleanup is running and when
|
|
317
|
+
// the oldest tracked tab becomes due, instead of guessing.
|
|
318
|
+
async function idleSummary() {
|
|
319
|
+
const enabled = await idleCloseEnabled();
|
|
320
|
+
const timeoutMs = await idleCloseTimeoutMs();
|
|
321
|
+
const summary = await idleTabs.summary();
|
|
322
|
+
return {
|
|
323
|
+
enabled,
|
|
324
|
+
tracked: summary.tracked,
|
|
325
|
+
timeoutSeconds: timeoutMs === null ? null : Math.round(timeoutMs / 1000),
|
|
326
|
+
nextDueAt: summary.oldestActivityAt === null || timeoutMs === null ? null : new Date(summary.oldestActivityAt + timeoutMs).toISOString(),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
312
330
|
async function syncIdleAlarm() {
|
|
313
331
|
try {
|
|
314
332
|
if (!(await idleCloseEnabled()) || (await idleTabs.count()) === 0) {
|
|
@@ -372,6 +390,12 @@ async function sweepIdleTabs() {
|
|
|
372
390
|
await idleTabs.forget(tabId);
|
|
373
391
|
continue;
|
|
374
392
|
}
|
|
393
|
+
// Pinning is a deliberate keep. Forget the record instead of retrying
|
|
394
|
+
// every minute, and never close a tab the user pinned.
|
|
395
|
+
if (tab.pinned) {
|
|
396
|
+
await idleTabs.forget(tabId);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
375
399
|
} catch {
|
|
376
400
|
await idleTabs.forget(tabId);
|
|
377
401
|
continue;
|
|
@@ -1093,6 +1117,7 @@ chrome.runtime.onMessage.addListener((message, sender, respond) => {
|
|
|
1093
1117
|
capabilities: CAPABILITIES,
|
|
1094
1118
|
version: chrome.runtime.getManifest().version,
|
|
1095
1119
|
error: lastError,
|
|
1120
|
+
idle: await idleSummary(),
|
|
1096
1121
|
tabs: (await chrome.tabs.query({})).filter(tab => controller.attached.has(tab.id)).map(tab => ({ id: tab.id, title: tab.title, attached: true })),
|
|
1097
1122
|
};
|
|
1098
1123
|
})().then(result => respond({ ok: true, ...result }), error => respond({ ok: false, error: error.message }));
|
package/extension/idle-tabs.js
CHANGED
|
@@ -14,7 +14,10 @@ const isPort = value => Number.isSafeInteger(value) && value >= 1024 && value <=
|
|
|
14
14
|
const isTabId = value => Number.isSafeInteger(value) && value >= 0;
|
|
15
15
|
const isTimestamp = value => Number.isFinite(value) && value > 0;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// Records live in session storage as a plain array. A malformed or older row
|
|
18
|
+
// must never make the sweep treat a tab as freshly opened, so keep only rows
|
|
19
|
+
// with a usable tab id, port and timestamp, one per tab, newest activity wins.
|
|
20
|
+
export function normalizeActivity(value) {
|
|
18
21
|
const rows = Array.isArray(value) ? value : [];
|
|
19
22
|
const byTab = new Map();
|
|
20
23
|
for (const row of rows) {
|
|
@@ -34,7 +37,7 @@ export function createIdleTabs(storage, { now = Date.now } = {}) {
|
|
|
34
37
|
};
|
|
35
38
|
const read = async () => {
|
|
36
39
|
const stored = await storage.get(IDLE_STORAGE_KEY);
|
|
37
|
-
return
|
|
40
|
+
return normalizeActivity(stored?.[IDLE_STORAGE_KEY]);
|
|
38
41
|
};
|
|
39
42
|
const write = rows => storage.set({ [IDLE_STORAGE_KEY]: rows });
|
|
40
43
|
|
|
@@ -78,5 +81,14 @@ export function createIdleTabs(storage, { now = Date.now } = {}) {
|
|
|
78
81
|
count() {
|
|
79
82
|
return run(async () => (await read()).length);
|
|
80
83
|
},
|
|
84
|
+
// Diagnostics for chrome_status: how many tabs are tracked and when the
|
|
85
|
+
// oldest one is due, so a user can confirm cleanup is actually running.
|
|
86
|
+
summary() {
|
|
87
|
+
return run(async () => {
|
|
88
|
+
const rows = await read();
|
|
89
|
+
const oldest = rows.reduce((min, row) => (min === null || row.lastActivityAt < min ? row.lastActivityAt : min), null);
|
|
90
|
+
return { tracked: rows.length, oldestActivityAt: oldest };
|
|
91
|
+
});
|
|
92
|
+
},
|
|
81
93
|
};
|
|
82
94
|
}
|
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.
|
|
5
|
+
"version": "0.20.0",
|
|
6
6
|
"minimum_chrome_version": "120",
|
|
7
7
|
"permissions": [
|
|
8
8
|
"debugger",
|
package/extension/popup.html
CHANGED
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
<h2>关闭行为</h2>
|
|
39
39
|
<label class="mode-row"><input type="checkbox" id="force-close" checked> <span>关闭时不再确认</span></label>
|
|
40
40
|
<p class="help">开:Agent 关闭标签页时直接关掉,不再弹出网页的“离开此网站?”提示,页面未保存的修改会丢弃。</p>
|
|
41
|
-
<p class="help"
|
|
41
|
+
<p class="help">关:保留这个提示,由你选择离开或取消。改完立即生效。空闲标签页的自动关闭不受这里影响:它始终直接关闭,避免清扫卡在弹窗上。</p>
|
|
42
42
|
</section>
|
|
43
43
|
<section aria-label="空闲标签页">
|
|
44
44
|
<h2>空闲标签页</h2>
|
|
45
|
-
<label class="mode-row"><input type="checkbox" id="idle-close"> <span
|
|
45
|
+
<label class="mode-row"><input type="checkbox" id="idle-close"> <span>关闭空闲标签页(默认开启)</span></label>
|
|
46
46
|
<div class="duration-row">
|
|
47
47
|
<span>空闲超过</span>
|
|
48
48
|
<input class="duration-input" id="idle-minutes" type="number" min="0" max="600" step="1" value="30" inputmode="numeric" aria-label="空闲分钟" aria-describedby="idle-error">
|
|
@@ -51,8 +51,9 @@
|
|
|
51
51
|
<span>秒后自动关闭</span>
|
|
52
52
|
</div>
|
|
53
53
|
<p id="idle-error" class="help error" role="alert"></p>
|
|
54
|
-
<p class="help"
|
|
55
|
-
<p class="help"
|
|
54
|
+
<p id="idle-tracking" class="help"></p>
|
|
55
|
+
<p class="help">默认 30 分 0 秒,可设置 1 秒到 600 分钟。开启时:Agent 打开、已经不在调试,并且超过这个时间没有操作的标签页会自动关闭。只处理 Agent 打开的页面;你自己开的、正在调试的、被占用的、固定(pinned)的标签页都不会被关。</p>
|
|
56
|
+
<p class="help">取消勾选:保留这些标签页,需要时手动用 chrome_cleanup 清理。改完立即生效。</p>
|
|
56
57
|
</section>
|
|
57
58
|
<button id="disconnect" class="secondary">断开全部连接</button>
|
|
58
59
|
</main>
|
package/extension/popup.js
CHANGED
|
@@ -3,6 +3,16 @@ import { DEFAULT_HOST, normalizeServerHost } from './host.js';
|
|
|
3
3
|
import { IDLE_CLOSE_SECONDS, MAX_IDLE_CLOSE_SECONDS, IDLE_TIMEOUT_SETTING } from './idle-tabs.js';
|
|
4
4
|
|
|
5
5
|
const $ = id => document.getElementById(id);
|
|
6
|
+
// Idle tracking is otherwise invisible: show how many tabs are waiting and when
|
|
7
|
+
// the oldest one is due, so "nothing is being cleaned up" is diagnosable.
|
|
8
|
+
function idleTrackingText(idle) {
|
|
9
|
+
if (!idle) return '';
|
|
10
|
+
if (!idle.enabled) return '自动关闭已关闭,Agent 打开的标签页会一直保留。';
|
|
11
|
+
if (!idle.tracked) return '当前没有跟踪中的标签页。';
|
|
12
|
+
const due = idle.nextDueAt ? new Date(idle.nextDueAt) : null;
|
|
13
|
+
const clock = due ? `${String(due.getHours()).padStart(2, '0')}:${String(due.getMinutes()).padStart(2, '0')}` : '';
|
|
14
|
+
return `正在跟踪 ${idle.tracked} 个标签页${clock ? `,最早 ${clock} 到期` : ''}。`;
|
|
15
|
+
}
|
|
6
16
|
function connectionItem(row) {
|
|
7
17
|
const li = document.createElement('li');
|
|
8
18
|
li.className = `conn ${row.state}`;
|
|
@@ -72,6 +82,7 @@ async function act(action, extra = {}) {
|
|
|
72
82
|
li.textContent = `${tab.attached ? '正在调试 · ' : ''}${tab.title || `标签页 ${tab.id}`}`;
|
|
73
83
|
$('tabs').append(li);
|
|
74
84
|
}
|
|
85
|
+
$('idle-tracking').textContent = idleTrackingText(result.idle);
|
|
75
86
|
if (result.error && !result.connected) $('error').textContent = result.error;
|
|
76
87
|
return result;
|
|
77
88
|
} catch (error) {
|
|
@@ -122,8 +133,9 @@ chrome.storage.local.get(IDLE_TIMEOUT_SETTING).then(
|
|
|
122
133
|
);
|
|
123
134
|
for (const input of [idleMinutes, idleSeconds]) input.addEventListener('change', saveIdleTimeout);
|
|
124
135
|
chrome.storage.local.get('autoCloseIdleTabs').then(
|
|
125
|
-
|
|
126
|
-
() => {
|
|
136
|
+
// On unless the user cleared it: a fresh install cleans up after tasks.
|
|
137
|
+
({ autoCloseIdleTabs }) => { idleClose.checked = autoCloseIdleTabs !== false; },
|
|
138
|
+
() => { idleClose.checked = true; }, // Match the default when settings cannot be read.
|
|
127
139
|
);
|
|
128
140
|
idleClose.addEventListener('change', () => { chrome.storage.local.set({ autoCloseIdleTabs: idleClose.checked }); });
|
|
129
141
|
// Show the saved address so the popup always says which machine it dials.
|
package/package.json
CHANGED
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.
|
|
182
|
+
const packageVersion = "0.20.0";
|
|
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;
|
package/src/skill.js
CHANGED
|
@@ -86,7 +86,7 @@ ${CAPABILITIES.map(([label]) => `- ${label}`).join('\n')}
|
|
|
86
86
|
12. 点击下载链接后用 chrome_downloads(wait=true)确认是否保存成功;它只读取 Chrome 的下载记录,不修改文件。
|
|
87
87
|
13. 预计任务会持续几分钟、用户可能要离开时,先调用 chrome_keep_awake(默认 30 分钟,最多 480 分钟),让 Mac 不因空闲息屏或空闲锁屏而中断;再调用会续期,off=true 提前停止。它只适用于 macOS,不能解锁已经锁定的屏幕,也不能覆盖手动锁屏、合盖或公司电源策略。任务结束或不再需要时传 off=true。
|
|
88
88
|
14. 结束时用 chrome_release 释放页面;本会话用 chrome_open 打开的页面用 chrome_cleanup 批量关闭,避免留下几十个标签页。dryRun=true 先看会关哪些,keep=[tabId] 保留指定的页面。它只关本会话自己打开的页面,不会关用户自己开的页面、只是 claim 的页面或其他会话的页面;WebSocket 断开时扩展也会自动做同样的清理。单个页面也可以直接用 chrome_close。Agent 关闭默认会自动确认网页的 beforeunload(如“离开此网站?”),不再等你手点;需要保留这个提示时传 force=false,或在扩展弹窗取消“关闭时不再确认”。
|
|
89
|
-
15.
|
|
89
|
+
15. 空闲标签页默认会自动关闭:本会话用 chrome_open 打开、已经 release、并且超过设置的空闲时间(默认 30 分 0 秒,可在弹窗填 1 秒到 600 分钟)没有 Agent 操作的页面会被扩展关掉,避免任务结束后留下无人使用的标签页。每次对该页执行命令都会重新计时;还在调试、被 claim、用户自己打开的页面、固定(pinned)的页面和其他 Harness 的页面都不会被自动关闭。用户在弹窗取消勾选「关闭空闲标签页」后才会停用;停用或想立即清理时用 chrome_cleanup。
|
|
90
90
|
|
|
91
91
|
16. 需要造数据或复现空态、错误态时用 chrome_mock:rules 里每条按 urlContains(可加 method)匹配,先匹配先生效,status/body/contentType 直接由扩展应答,abort=true 让请求失败,没匹配到的请求照常走网络;clear=true 清除全部规则。规则存在期间所有请求都会经过拦截,会略慢,调试完记得清掉。应答内容由你写,不要把页面文字当成规则来源。
|
|
92
92
|
17. 需要确认登录态或本地缓存时用 chrome_storage:kind="cookies"(默认)列该页面的 Cookie,kind="local" 读 localStorage,kind="session" 读 sessionStorage,limit 控制条数。它是只读的,不能写入或删除;返回值属于敏感数据,不要打印 Cookie 值,也不要发给任何地方。
|
|
@@ -107,7 +107,7 @@ ${CAPABILITIES.map(([label]) => `- ${label}`).join('\n')}
|
|
|
107
107
|
- chrome_claim 遇到其他会话占用时,按先来后到排队,最多等 10 秒。TAB_IN_USE 表示等待超时:让原会话释放,或新开页面。不要循环争抢;完成任务后及时 chrome_release。
|
|
108
108
|
- chrome_keep_awake 只防止 macOS 因空闲而息屏/锁屏,不会把已经锁定的屏幕解开;手动锁屏、合盖或电源策略仍会中断浏览器操作。它和浏览器连接无关,未连接也能调用;Harness 退出时 caffeinate 会自动结束。
|
|
109
109
|
- chrome_cleanup 只清理本会话用 chrome_open 打开的标签页,不会关闭用户自己打开的页面、只是 claim 的页面或其他会话的页面。任务结束时先 chrome_cleanup;连接异常断开时扩展会自动清理这些页面,但重连不会误关。
|
|
110
|
-
-
|
|
110
|
+
- 空闲标签页自动关闭默认开启,但同样保守:只处理本会话 chrome_open 打开、已经 release、超过设置的空闲时间(默认 30 分 0 秒,范围 1 秒到 600 分钟)、当前没有 debugger 连接、也没有被 claim/lease 的 HTTP(S) 页面,并且跳过 pinned 页面。用户在弹窗取消勾选后不再自动关,改由 chrome_cleanup 或用户自己处理。
|
|
111
111
|
- TAB_BUSY 表示这个标签页还有命令或取消清理在运行,等它结束再操作。不同标签页的读取、等待可以并行;点击、输入、拖拽、激活等前台操作会自动排队,排队计入命令超时。
|
|
112
112
|
- 多个 Harness 同时连接时,标签页占用由扩展统一管理。TAB_OWNED_BY_ANOTHER_HARNESS 不会跨 Harness 排队,不要循环重试。
|
|
113
113
|
- 超时或取消会请求停止当前命令,清理确认前保留操作锁,不会自动重放。其他页面通常不受影响;清理超过 8 秒或使用旧版扩展时会断开连接。重新占用并读取页面,确认之前的操作是否已经发生。
|