@liyuera/dsh-chrome-browser 0.4.0 → 0.6.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.
Files changed (47) hide show
  1. package/README.md +38 -4
  2. package/extension/icons/icon-128.png +0 -0
  3. package/extension/icons/icon-16.png +0 -0
  4. package/extension/icons/icon-32.png +0 -0
  5. package/extension/icons/icon-48.png +0 -0
  6. package/extension/manifest.json +10 -4
  7. package/extension/service-worker.js +82 -5
  8. package/lib/activity.d.ts +35 -22
  9. package/lib/activity.d.ts.map +1 -1
  10. package/lib/activity.js +68 -28
  11. package/lib/activity.js.map +1 -1
  12. package/lib/backend.d.ts +77 -2
  13. package/lib/backend.d.ts.map +1 -1
  14. package/lib/backend.js +138 -3
  15. package/lib/backend.js.map +1 -1
  16. package/lib/client/BrowserActivity.d.ts +14 -11
  17. package/lib/client/BrowserActivity.d.ts.map +1 -1
  18. package/lib/client/BrowserActivity.js +86 -45
  19. package/lib/client/BrowserActivity.js.map +1 -1
  20. package/lib/client/activity.d.ts +16 -9
  21. package/lib/client/activity.d.ts.map +1 -1
  22. package/lib/client/activity.js +41 -20
  23. package/lib/client/activity.js.map +1 -1
  24. package/lib/client/index.d.ts +2 -2
  25. package/lib/client/index.d.ts.map +1 -1
  26. package/lib/client/index.js +9 -8
  27. package/lib/client/index.js.map +1 -1
  28. package/lib/client.js +195 -73
  29. package/lib/client.js.map +1 -1
  30. package/lib/expressions.d.ts +11 -0
  31. package/lib/expressions.d.ts.map +1 -1
  32. package/lib/expressions.js +25 -0
  33. package/lib/expressions.js.map +1 -1
  34. package/lib/extension-package.d.ts +49 -0
  35. package/lib/extension-package.d.ts.map +1 -1
  36. package/lib/extension-package.js +115 -0
  37. package/lib/extension-package.js.map +1 -1
  38. package/lib/routes.d.ts.map +1 -1
  39. package/lib/routes.js +14 -2
  40. package/lib/routes.js.map +1 -1
  41. package/lib/skill.d.ts.map +1 -1
  42. package/lib/skill.js +5 -4
  43. package/lib/skill.js.map +1 -1
  44. package/lib/tools.d.ts.map +1 -1
  45. package/lib/tools.js +48 -9
  46. package/lib/tools.js.map +1 -1
  47. package/package.json +3 -2
package/README.md CHANGED
@@ -11,7 +11,7 @@ Chrome 浏览器控制插件(host + 浏览器半边):通过 Chrome 扩展桥(默
11
11
  | `chrome_navigate` | 标签页导航到 URL(默认等待 `readyState=complete`) |
12
12
  | `chrome_open` | 新开前台标签页;**默认等加载完成**(`readyState=complete`,上限 `waitLoadMs`)后返回,返回的标题已是加载后的标题。**URL 只接受 http/https/file**,其它 scheme 在开标签页**之前**就报错 |
13
13
  | `chrome_close` | 按 id 关闭一个标签页;**`tabId` 必填,不接受 `active`**——关掉用户正在看的那一页几乎总是错的 |
14
- | `chrome_screenshot` | PNG 截图落盘,返回路径/字节数/视口尺寸;模型用 `read_image` 查看 |
14
+ | `chrome_screenshot` | 截图落盘,返回路径/字节数/mime;模型用 `read_image` 查看。**`fullPage: true` 一次拍完整页**,`selector` 只拍某个元素(等同 DevTools 的「截取节点屏幕截图」) |
15
15
  | `chrome_click` | CSS 选择器 `element.click()`(可选 `all` 批量)。返回**实际派发点击**的元素数(不是匹配到的数量),并报告「存在但不可点」的原因 |
16
16
  | `chrome_hover` | 悬停到元素上,展开只在 hover 时出现的菜单/工具条 |
17
17
  | `chrome_type` | 聚焦输入框并输入文本(默认先全选替换) |
@@ -22,7 +22,20 @@ Chrome 浏览器控制插件(host + 浏览器半边):通过 Chrome 扩展桥(默
22
22
  | `chrome_console` | 采集/读取某个标签页的控制台(`action: start / read / stop`);**必须在页面出问题之前 start**,含浏览器自身抛的错误(资源加载失败、CSP 拦截) |
23
23
  | `chrome_request_help` | 停下来请用户做只有人能做的事(登录、验证码、二次验证),等用户答复;`completed: false` 表示用户跳过了,不要重试 |
24
24
  | `@` 标签页分组 | 在输入框敲 `@` 时列出实时标签页(行内是「标题 + URL」),选中插入一个引用芯片;发送后消息里只有这个引用,标签页的 URL 与 tabId 由宿主注入一条上下文消息给模型 |
25
- | 活动状态条 | 输入框上方,只在**插件正在调用工具时**出现:脉冲点 + Chrome 图标 + 正在做什么(如「点击 · 标签页 7」)。空闲时不渲染任何东西 |
25
+ | **活动状态条**已经改成**会话标题栏末尾常驻的淡色状态胶囊**。之前放在输入框上方的做法是错的:它只在调用期间出现,而 `chrome_*` 调用多数是毫秒级——一条闪 50ms 的提示不是信息,是抖动,用户根本来不及看。
26
+
27
+ 现在它常驻,并且有完整的生命周期:
28
+
29
+ | 状态 | 何时 | 显示 |
30
+ | --- | --- | --- |
31
+ | `Chrome 就绪` | 扩展已连接,空闲 | 淡绿点(最弱的存在感) |
32
+ | `点击 · 标签页 7` | 调用进行中 | 绿色脉冲点 + 当前动作 |
33
+ | `完成` | 调用成功结束后 2.5 秒 | 绿点 |
34
+ | `失败` | 调用失败后 7 秒,悬停显示原因 | 红点 |
35
+ | `Chrome 未连接` | 扩展没连上 | 灰点 |
36
+ | `扩展待更新` | 扩展在跑旧文件 | 黄点 |
37
+
38
+ 失败停留得比成功久(7 秒 vs 2.5 秒),因为它要求被读;连接类状态**优先于**调用结果——在一个断开的桥上显示「完成」是误导。所有尺寸是**内联样式**,因为一个没生效的样式表曾经让内置的 512px 图标按原尺寸渲染,把标题栏撑满了。
26
39
  | `/chrome-browser` skill | 注册一个 agent skill:讲清什么时候用、调用顺序、失败怎么办、有哪些边界。模型通过 `skill` 工具读它,你也可以直接敲 `/chrome-browser`。宿主没有 skill 服务时静默跳过,工具照常可用 |
27
40
 
28
41
  ### chrome_read:两个阅读模式
@@ -206,7 +219,25 @@ chrome_request_help { reason: '请在打开的 example.com 页面里登录,然
206
219
 
207
220
  **默认 = 扩展后端(推荐)**:控制的就是你**日常运行的 Chrome 本身**——不重启、不复制 profile、无额外窗口。扩展的获取与加载步骤见[安装 → 2. 装配套 Chrome 扩展](#2-装配套-chrome-扩展)。
208
221
 
209
- 改了 `extension/` 里的文件后,必须在 `chrome://extensions` 点该扩展的「重新加载」才会生效——Chrome 不会自动重读已加载的解压扩展。
222
+ 改了 `extension/` 里的文件后,**从 0.5.0 起插件会自己让扩展重载**——见下。
223
+
224
+ ### 扩展的自动更新
225
+
226
+ Chrome 不会重读「加载已解压」扩展的文件,所以插件自己补了一条握手:
227
+
228
+ 1. 扩展连上时(以及每 20 秒一次心跳)自报三样东西:「**自己这份代码的指纹**」(`BUILD_HASH`,一个烤进 service worker 的常量)、`manifest.version`、以及它能处理的 op 列表;
229
+ 2. 宿主对**包内 `extension/` 的文件**算出同样的指纹(文件名 + `0x00` + 内容,按名排序);
230
+ 3. 不一致且扩展支持 `reload` → 宿主请它 `chrome.runtime.reload()`,Chrome 从磁盘重读,新代码生效。
231
+
232
+ **为什么指纹必须是常量,不能在扩展里现算**:实测过——`fetch(chrome.runtime.getURL(...))` 在 service worker 里读到的是**磁盘上的文件**,不是 Chrome 已加载的那份。运行时自算指纹会**每次都报新值**:宿主以为扩展是最新的,而用户实际跑着旧代码,毫无迹象。只有随着已加载代码一起被读出来的常量才能说明「现在跑的是哪份」。
233
+
234
+ 指纹由 `npm run extension:stamp` 写入;忘了盖章时 `tests/extension-package.spec.ts` 会直接失败,所以这不是一件需要记的事。**实测过 `chrome.runtime.reload()` 确实从磁盘重读**(不只是 manifest,service worker 也是),而 worker 被 Chrome 唤醒**不会**重读。
235
+
236
+ 于是 **npm 升级插件后不用再碰 `chrome://extensions`**。
237
+
238
+ - **同一个指纹只问一次**:如果某次 `reload` 没能读到新文件(比如目录被换掉),宿主不会反复重载——它会停下并在 `/chrome-browser/ext/status` 里报 `stale: true`、`autoReloadAsked: true`,此时需要手动重载一次。换了一个指纹(又一次升级)则会重新尝试,所以同一进程内的多次升级都能落地。
239
+ - **能力检查**:宿主只会发扩展自报支持的 op。扩展文件比插件旧时直接报「扩展不支持 X,请在 chrome://extensions 重新加载该扩展」,而不是让扩展回一个 `unknown op` 这种看不出原因的内部错误。
240
+ - **首次安装仍需手动**:Chrome 没有以编程方式安装解压扩展的接口,新用户在 `chrome://extensions` 加载一次是绕不过去的(除非上架 Chrome 应用商店)。
210
241
 
211
242
  之后扩展通过本地 WebSocket(`/chrome-browser/ext/ws`)与插件通信:列真实标签页(自带站点图标)、读取/点击/输入/求值/导航/新开/截图。扩展没连上时 `@` 菜单不出现标签页分组,`/chrome-browser/ext/status` 会报 `connected:false`。
212
243
 
@@ -335,7 +366,10 @@ DSH_CHROME_SMOKE=1 npx vitest run tests/smoke.spec.ts # headless Chrome 全链
335
366
  - **页面 CSP 会改变 `chrome_eval` 的执行通道**:`script-src` 里没有 `'unsafe-eval'` 的站点(GitHub 就是)主世界不能 `eval`,插件会自动改走 **`chrome.debugger` 的 `Runtime.evaluate`**(和 CDP 后端同一条路)并在结果里报 `world: "debugger"`。**代价是该标签页会出现调试提示条**,且已打开 DevTools 时无法附着——所以它只是回退,默认仍走无感的普通注入。
336
367
  - **`chrome_eval` 的失败是错误,不是 `null`**:语法错误、运行时异常、CSP 拦截以前都会静默变成 `null`,现在会带着原始信息报错。
337
368
  - **`chrome_open` 拒绝它驱动不了的 scheme**:`data:`、`chrome:`、`devtools:` 这类页面扩展注不进去,以前会**先把标签页建出来再失败**——那个标签页读不了、跑不了 JS、连导航走都不行。现在在创建前就报错,不留僵尸标签页。`file:` 可以开,但**它依赖一个浏览器设置**:扩展默认没有文件访问权限,要在 `chrome://extensions` 里为该扩展打开「允许访问文件网址」;没开的话 `file://` 页面会和 `data:` 一样读不到(本机已开启,实测 `chrome_open file://` + `chrome_read` 正常)。CDP 模式没有这个限制。
369
+ - **`about:blank` 只能开、不能导航过去**:扩展注不进空白页,所以空白标签页读不了、点不了、跑不了 JS。`chrome_open` 允许开一个(当**临时中转页**用,随后 `chrome_navigate` 走),并且**不会等它加载**(没东西可等);但 `chrome_navigate` 拒绝导航到 `about:blank`——那会丢弃页面上原有的内容,只剩一个谁也读不了的标签页。
338
370
  - **`chrome_close` 不猜目标**:`tabId` 是必填的精确 id。省略或写 `active` 都会报错——关掉「用户当前正在看的标签页」几乎总是错的。关闭窗口的最后一个标签页会连带关闭该窗口。
371
+ - **扩展自动更新依赖 `chrome.runtime.reload()` 能读到磁盘上的新文件**:这是该 API 的预期行为,但已加载的解压扩展由 Chrome 缓存,所以插件**只尝试一次**并在失败时明确报告,而不是无限重载。状态见 `/chrome-browser/ext/status`。
372
+ - **`chrome_screenshot` 默认只拍视口**:整页要显式传 `fullPage: true`(一次调用完成,不要靠滚动拼接——拼接会重复固定元素、接缝错位,而且很难对齐)。`selector` 拍单个元素,元素在首屏之下也照样能拍对。
339
373
  - **`chrome_screenshot` 会在该标签页显示调试提示条**:它走 `chrome.debugger` 的 `Page.captureScreenshot`(与 CDP 后端同一条路),因此在标签页处于后台时照样可用,也**不会返回陈旧帧**。代价是 Chrome 在该标签页顶部显示「正在调试」提示条,且已打开 DevTools 时无法附着(会明确报错)。如果该标签页已被 `chrome_console` 采集,则复用同一会话,不产生第二次附着。
340
374
  - ~~截图要求窗口可见~~:旧实现走 `chrome.tabs.captureVisibleTab`,窗口被遮挡时报 `image readback failed`,窗口停止重绘时**返回上一帧**(实测两张相隔数秒的截图逐字节相同,而返回的路径与字节数不会告诉你它是陈旧的)。已改为调试通道。
341
375
  - **活动状态条是轮询的**:客户端每秒发一次本地回环 GET。将来若接入会话事件流可以去掉轮询,目前用的是插件已有的路由机制。
@@ -353,7 +387,7 @@ DSH_CHROME_SMOKE=1 npx vitest run tests/smoke.spec.ts # headless Chrome 全链
353
387
  dsh plugin --profile desktop remove @liyuera/dsh-chrome-browser
354
388
  ```
355
389
 
356
- 再到 `chrome://extensions` 移除 `dsh Chrome Bridge` 扩展。卸载插件不会关闭你的 Chrome(CDP 的 owned 专用实例除外)。
390
+ 再到 `chrome://extensions` 移除 `dsh Chrome Control` 扩展。卸载插件不会关闭你的 Chrome(CDP 的 owned 专用实例除外)。
357
391
 
358
392
  ## 许可
359
393
 
Binary file
Binary file
Binary file
Binary file
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "manifest_version": 3,
3
- "name": "dsh Chrome Bridge",
4
- "description": "Bridges the local dsh agent to this Chrome instance: list tabs, read pages, click/type, run JS, capture screenshots and read console output. Runs on the machine only.",
5
- "version": "0.2.0",
3
+ "name": "dsh Chrome Control",
4
+ "description": "Lets the local dsh agent drive this Chrome: list tabs, read pages, click and type, run JS, capture screenshots, read console output. Talks to dsh on this machine only.",
5
+ "version": "0.4.0",
6
6
  "permissions": [
7
7
  "tabs",
8
8
  "scripting",
@@ -16,5 +16,11 @@
16
16
  "background": {
17
17
  "service_worker": "service-worker.js"
18
18
  },
19
- "minimum_chrome_version": "110"
19
+ "minimum_chrome_version": "110",
20
+ "icons": {
21
+ "16": "icons/icon-16.png",
22
+ "32": "icons/icon-32.png",
23
+ "48": "icons/icon-48.png",
24
+ "128": "icons/icon-128.png"
25
+ }
20
26
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dsh Chrome Bridge service worker: a long-lived WebSocket to the local dsh
2
+ * dsh Chrome Control service worker: a long-lived WebSocket to the local dsh
3
3
  * host. The host pushes commands (list tabs / read / eval / click / type /
4
4
  * navigate / open / screenshot); this worker executes them against the real
5
5
  * browser and pushes results back. The open socket keeps the worker alive,
@@ -44,6 +44,7 @@ function connect() {
44
44
  retryMs = 1000
45
45
  hostOrigin = url.replace(/^ws/u, 'http').replace(/\/chrome-browser\/ext\/ws$/u, '')
46
46
  trace('open ' + url)
47
+ hello()
47
48
  // Chrome suspends this worker when idle, which detaches the debugger and
48
49
  // silently ends console capture. Re-arm whatever was capturing.
49
50
  void rearmConsole()
@@ -71,7 +72,11 @@ function scheduleRetry() {
71
72
  // does not keep this worker alive: a JS heartbeat interval keeps it warm,
72
73
  // and the alarm below wakes a suspended worker so the bridge reconnects.
73
74
  setInterval(() => {
74
- if (socket !== null && socket.readyState === 1) send({ kind: 'heartbeat' })
75
+ if (socket === null || socket.readyState !== 1) return
76
+ send({ kind: 'heartbeat' })
77
+ // Re-introducing here is what lets the host notice that its own files were
78
+ // updated underneath a running extension, without waiting for a reconnect.
79
+ hello()
75
80
  }, 20_000)
76
81
 
77
82
  chrome.alarms.create('dsh-bridge', { periodInMinutes: 0.5 })
@@ -81,6 +86,44 @@ chrome.alarms.onAlarm.addListener(alarm => {
81
86
  chrome.runtime.onStartup.addListener(() => connect())
82
87
  chrome.runtime.onInstalled.addListener(() => connect())
83
88
 
89
+ /**
90
+ * Ops this worker answers, sent to the host on connect and on every heartbeat.
91
+ *
92
+ * Chrome never re-reads an unpacked extension's files, so a host that shipped a
93
+ * new op would otherwise only find out when the extension answered `unknown op`
94
+ * — an internal error with no hint that a reload is what is missing. Comparing
95
+ * this roster, and the version beside it, is what lets the host say so.
96
+ * tests/extension-scope.spec.ts keeps the list equal to the cases in run().
97
+ */
98
+ const SUPPORTED_OPS = [
99
+ 'list-tabs', 'read', 'inventory', 'wait', 'hover', 'press', 'select', 'eval',
100
+ 'click', 'type', 'console-start', 'console-stop', 'close', 'navigate', 'open',
101
+ 'screenshot', 'trace', 'reload',
102
+ ]
103
+
104
+ /**
105
+ * Fingerprint of this extension's own files, written by `npm run extension:stamp`
106
+ * and checked by tests/extension-package.spec.ts.
107
+ *
108
+ * It is a constant rather than a hash computed here on purpose. Measured in a
109
+ * real browser: `fetch(chrome.runtime.getURL('service-worker.js'))` returns the
110
+ * file on DISK, not the copy Chrome loaded, so a runtime self-hash reported the
111
+ * new bytes while the old code was still running — the host saw a match and the
112
+ * user stayed on a stale extension with nothing to show for it. Only a value
113
+ * carried by the loaded code can tell the host which code is loaded.
114
+ */
115
+ const BUILD_HASH = '9dd296539a1d1e347c833f21c3f3c207a4f62f864803aa40151aa280e9b07e37'
116
+
117
+ /** Introduce this worker: what it runs, what it can answer, and which code it is. */
118
+ async function hello() {
119
+ send({
120
+ kind: 'hello',
121
+ version: chrome.runtime.getManifest().version,
122
+ ops: SUPPORTED_OPS,
123
+ build: BUILD_HASH,
124
+ })
125
+ }
126
+
84
127
  function send(payload) {
85
128
  if (socket !== null && socket.readyState === 1) socket.send(JSON.stringify(payload))
86
129
  }
@@ -389,6 +432,12 @@ async function run(command) {
389
432
  return startConsole(command.args.tabId)
390
433
  case 'console-stop':
391
434
  return stopConsole(command.args.tabId)
435
+ case 'reload': {
436
+ // Answer first: `chrome.runtime.reload()` tears this worker down, so a
437
+ // result sent after it would never leave. The delay lets the frame flush.
438
+ setTimeout(() => chrome.runtime.reload(), 50)
439
+ return { reloaded: true }
440
+ }
392
441
  case 'close': {
393
442
  const id = Number(command.args.tabId)
394
443
  if (!Number.isInteger(id)) throw new Error(`无效的标签页 id:${String(command.args.tabId)}`)
@@ -409,7 +458,10 @@ async function run(command) {
409
458
  // failed" while the user is looking at something else — and when the
410
459
  // window merely stops repainting it returns the PREVIOUS frame with no
411
460
  // sign that it did. Page.captureScreenshot has neither problem.
412
- const base64 = await captureViaDebugger(Number(command.args.tabId))
461
+ const base64 = await captureViaDebugger(Number(command.args.tabId), {
462
+ fullPage: command.args.fullPage === true,
463
+ selector: typeof command.args.selector === 'string' ? command.args.selector : undefined,
464
+ })
413
465
  // Image bytes travel back as a plain HTTP POST, never as a WS JSON frame:
414
466
  // an oversized frame closed the bridge right after a successful capture.
415
467
  const blob = await (await fetch('data:image/jpeg;base64,' + base64)).blob()
@@ -432,6 +484,22 @@ async function run(command) {
432
484
  }
433
485
  }
434
486
 
487
+ /**
488
+ * One element's clip rectangle, or a failure naming the selector.
489
+ * @param tabId - the tab to measure in.
490
+ * @param selector - CSS selector of the element to capture.
491
+ * @returns the clip rectangle in page coordinates.
492
+ */
493
+ async function rectOf(tabId, selector) {
494
+ const box = await pageExec(tabId, pageAgent, [{ op: 'rect', selector }])
495
+ if (box === null || typeof box !== 'object' || box.matched !== 1) {
496
+ throw new Error(`截图失败:没有匹配 ${selector} 的元素`)
497
+ }
498
+ const { x, y, width, height } = box
499
+ if (!(width > 0) || !(height > 0)) throw new Error(`截图失败:${selector} 没有可见尺寸(宽 ${width} 高 ${height})`)
500
+ return { x, y, width, height, scale: 1 }
501
+ }
502
+
435
503
  /** JPEG quality the screenshot is encoded at before upload. */
436
504
  const SCREENSHOT_QUALITY = 75
437
505
 
@@ -443,9 +511,15 @@ const SCREENSHOT_QUALITY = 75
443
511
  * answer with a stale frame. It costs the debugger infobar on that tab, which is
444
512
  * why a tab `chrome_console` already attached needs no second attach.
445
513
  */
446
- async function captureViaDebugger(tabId) {
514
+ async function captureViaDebugger(tabId, options) {
447
515
  const id = Number(tabId)
448
516
  if (!Number.isInteger(id)) throw new Error(`无效的标签页 id:${String(tabId)}`)
517
+ const selector = options !== undefined && typeof options.selector === 'string' && options.selector !== ''
518
+ ? options.selector
519
+ : undefined
520
+ // `captureBeyondViewport` is what turns a viewport grab into a whole-page
521
+ // one; a clip needs it too, for any element below the fold.
522
+ const beyond = options !== undefined && (options.fullPage === true || selector !== undefined)
449
523
  const targets = await chrome.debugger.getTargets()
450
524
  const existing = targets.find(target => target.tabId === id && target.attached === true)
451
525
  if (existing !== undefined && existing.extensionId !== chrome.runtime.id) {
@@ -454,10 +528,12 @@ async function captureViaDebugger(tabId) {
454
528
  const ours = existing !== undefined
455
529
  if (!ours) await chrome.debugger.attach({ tabId: id }, '1.3')
456
530
  try {
531
+ const clip = selector === undefined ? undefined : await rectOf(id, selector)
457
532
  const response = await chrome.debugger.sendCommand({ tabId: id }, 'Page.captureScreenshot', {
458
533
  format: 'jpeg',
459
534
  quality: SCREENSHOT_QUALITY,
460
- captureBeyondViewport: false,
535
+ captureBeyondViewport: beyond,
536
+ ...(clip === undefined ? {} : { clip }),
461
537
  })
462
538
  if (response === undefined || typeof response.data !== 'string' || response.data === '') {
463
539
  throw new Error('截图失败:调试通道没有返回图像数据')
@@ -639,6 +715,7 @@ function pageAgent(request) {
639
715
  switch (request.op) {
640
716
  case 'click': return clickSelector(request.selector, request.all === true)
641
717
  case 'inventory': return interactiveInventory()
718
+ case 'rect': return elementRect(request.selector)
642
719
  case 'press': return pressKey(request.key, request.selector)
643
720
  default: return { __dshPageError: '未知的页面操作:' + request.op }
644
721
  }
package/lib/activity.d.ts CHANGED
@@ -1,38 +1,51 @@
1
1
  /**
2
- * What the plugin is doing right now, for the in-page status strip.
2
+ * What the plugin is doing right now, for the persistent header indicator.
3
3
  *
4
4
  * The host half is the only place that knows a call is in flight, so it records
5
5
  * every tool execution here and serves the snapshot over its own route; the
6
- * browser half polls that route and renders a strip only while something is
7
- * running. Nothing is persisted, and nothing crosses into the model's request.
6
+ * browser half polls that route and renders one chip in the Session header.
7
+ * Nothing is persisted, and nothing crosses into the model's request.
8
8
  * @module @liyuera/dsh-chrome-browser/activity
9
9
  */
10
10
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
11
- /** What one in-flight (or most recent) call looks like to the UI. */
11
+ /**
12
+ * How long a settled call stays on screen before the chip returns to idle.
13
+ * Short enough not to linger, long enough that a call finishing between two
14
+ * polls is still seen: the browser half polls at POLL_MS, so a hold shorter
15
+ * than one poll interval can be missed entirely.
16
+ */
17
+ export declare const DONE_HOLD_MS = 2500;
18
+ /** How long a failure stays on screen. Longer: it asks to be read. */
19
+ export declare const ERROR_HOLD_MS = 7000;
20
+ /** Which of the four things the chip can be saying. */
21
+ export type ActivityPhase = 'running' | 'done' | 'error' | 'ready';
22
+ /** What the browser half renders from. */
12
23
  export interface ActivitySnapshot {
13
- /** Whether a call is running right now. */
14
- readonly active: boolean;
15
- /** Name of the running call, when one is running. */
24
+ /** Current phase for the session being asked about. */
25
+ readonly phase: ActivityPhase;
26
+ /** Tool the phase belongs to, when it belongs to a call. */
16
27
  readonly tool?: string;
17
- /** Tab the running call named, when it named one. */
28
+ /** Tab that call named, when it named one. */
18
29
  readonly tabId?: string;
19
- /** Epoch milliseconds the running call started. */
20
- readonly startedAt?: number;
21
- /** Name of the most recently finished call, when one has finished. */
22
- readonly lastTool?: string;
23
- /** Epoch milliseconds the most recent call finished. */
24
- readonly lastAt?: number;
30
+ /** Failure text, shortened, when the phase is `error`. */
31
+ readonly detail?: string;
32
+ /** Epoch milliseconds this phase began, or the last call's start. */
33
+ readonly since: number;
25
34
  }
26
35
  /** Route-facing view of one snapshot. */
27
36
  export type ActivityAnswer = Record<string, string | number | boolean>;
28
37
  /**
29
- * In-flight and last-finished browser calls, keyed by session when the caller
30
- * has one. A session that has never called anything reports inactive, which is
31
- * what the strip needs: absence of a call, not absence of a plugin.
38
+ * In-flight and recently finished browser calls, keyed by session when the
39
+ * caller has one.
40
+ *
41
+ * The tracker holds facts, not timers: `snapshot` decides whether a settled
42
+ * call is still worth showing from the clock alone. That keeps a host tick out
43
+ * of the loop and means a browser that polls late sees the same answer a
44
+ * host-side timer would have produced.
32
45
  */
33
46
  export declare class ActivityTracker {
34
47
  private readonly running;
35
- private readonly finished;
48
+ private readonly settled;
36
49
  /** Session key for a caller with no session identity. */
37
50
  private static readonly ANONYMOUS;
38
51
  /**
@@ -40,20 +53,20 @@ export declare class ActivityTracker {
40
53
  * @param tool - the tool name.
41
54
  * @param tabId - the tab the call named, when it named one.
42
55
  * @param sessionId - the calling session, when the execution carried one.
43
- * @returns the disposer that records the call as finished; idempotent.
56
+ * @returns the disposer that records how the call ended; idempotent.
44
57
  */
45
- begin(tool: string, tabId: string | undefined, sessionId: string | undefined): () => void;
58
+ begin(tool: string, tabId: string | undefined, sessionId: string | undefined): (ok: boolean, detail?: string) => void;
46
59
  /**
47
60
  * The current state for one session.
48
61
  * @param sessionId - the session to report on; omit for the most recent call in any session.
49
- * @returns the snapshot the strip renders from.
62
+ * @returns the snapshot the chip renders from.
50
63
  */
51
64
  snapshot(sessionId?: string): ActivitySnapshot;
52
65
  /** Drop every record; the plugin calls this on unload. */
53
66
  clear(): void;
54
67
  }
55
68
  /**
56
- * Wrap one tool definition so its execution is visible to the status strip.
69
+ * Wrap one tool definition so its execution is visible to the header chip.
57
70
  *
58
71
  * Every other member is carried over untouched: this adds observation, it does
59
72
  * not change what the tool declares or returns.
@@ -1 +1 @@
1
- {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../src/activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH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,0DAA0D;IAC1D,KAAK,IAAI,IAAI;CAId;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,GAAG,cAAc,CAgBlG"}
package/lib/activity.js CHANGED
@@ -1,20 +1,35 @@
1
1
  /**
2
- * What the plugin is doing right now, for the in-page status strip.
2
+ * What the plugin is doing right now, for the persistent header indicator.
3
3
  *
4
4
  * The host half is the only place that knows a call is in flight, so it records
5
5
  * every tool execution here and serves the snapshot over its own route; the
6
- * browser half polls that route and renders a strip only while something is
7
- * running. Nothing is persisted, and nothing crosses into the model's request.
6
+ * browser half polls that route and renders one chip in the Session header.
7
+ * Nothing is persisted, and nothing crosses into the model's request.
8
8
  * @module @liyuera/dsh-chrome-browser/activity
9
9
  */
10
10
  /**
11
- * In-flight and last-finished browser calls, keyed by session when the caller
12
- * has one. A session that has never called anything reports inactive, which is
13
- * what the strip needs: absence of a call, not absence of a plugin.
11
+ * How long a settled call stays on screen before the chip returns to idle.
12
+ * Short enough not to linger, long enough that a call finishing between two
13
+ * polls is still seen: the browser half polls at POLL_MS, so a hold shorter
14
+ * than one poll interval can be missed entirely.
15
+ */
16
+ export const DONE_HOLD_MS = 2_500;
17
+ /** How long a failure stays on screen. Longer: it asks to be read. */
18
+ export const ERROR_HOLD_MS = 7_000;
19
+ /** Longest failure text carried to the chip; the card holds the full one. */
20
+ const DETAIL_LIMIT = 120;
21
+ /**
22
+ * In-flight and recently finished browser calls, keyed by session when the
23
+ * caller has one.
24
+ *
25
+ * The tracker holds facts, not timers: `snapshot` decides whether a settled
26
+ * call is still worth showing from the clock alone. That keeps a host tick out
27
+ * of the loop and means a browser that polls late sees the same answer a
28
+ * host-side timer would have produced.
14
29
  */
15
30
  export class ActivityTracker {
16
31
  running = [];
17
- finished = new Map();
32
+ settled = new Map();
18
33
  /** Session key for a caller with no session identity. */
19
34
  static ANONYMOUS = '';
20
35
  /**
@@ -22,7 +37,7 @@ export class ActivityTracker {
22
37
  * @param tool - the tool name.
23
38
  * @param tabId - the tab the call named, when it named one.
24
39
  * @param sessionId - the calling session, when the execution carried one.
25
- * @returns the disposer that records the call as finished; idempotent.
40
+ * @returns the disposer that records how the call ended; idempotent.
26
41
  */
27
42
  begin(tool, tabId, sessionId) {
28
43
  const entry = {
@@ -33,20 +48,27 @@ export class ActivityTracker {
33
48
  };
34
49
  this.running.push(entry);
35
50
  let ended = false;
36
- return () => {
51
+ return (ok, detail) => {
37
52
  if (ended)
38
53
  return;
39
54
  ended = true;
40
55
  const at = this.running.indexOf(entry);
41
56
  if (at >= 0)
42
57
  this.running.splice(at, 1);
43
- this.finished.set(sessionId ?? ActivityTracker.ANONYMOUS, { tool, at: Date.now() });
58
+ const shortened = detail === undefined ? undefined : detail.slice(0, DETAIL_LIMIT);
59
+ this.settled.set(sessionId ?? ActivityTracker.ANONYMOUS, {
60
+ tool,
61
+ ok,
62
+ at: Date.now(),
63
+ ...(entry.tabId === undefined ? {} : { tabId: entry.tabId }),
64
+ ...(ok || shortened === undefined ? {} : { detail: shortened }),
65
+ });
44
66
  };
45
67
  }
46
68
  /**
47
69
  * The current state for one session.
48
70
  * @param sessionId - the session to report on; omit for the most recent call in any session.
49
- * @returns the snapshot the strip renders from.
71
+ * @returns the snapshot the chip renders from.
50
72
  */
51
73
  snapshot(sessionId) {
52
74
  const key = sessionId ?? ActivityTracker.ANONYMOUS;
@@ -54,23 +76,33 @@ export class ActivityTracker {
54
76
  // one browser, so an unidentified call is still this caller's call.
55
77
  const running = [...this.running].reverse()
56
78
  .find(entry => entry.sessionId === undefined || sessionId === undefined || entry.sessionId === key);
57
- const last = this.finished.get(key);
58
- return {
59
- active: running !== undefined,
60
- ...(running === undefined
61
- ? {}
62
- : {
63
- tool: running.tool,
64
- startedAt: running.startedAt,
65
- ...(running.tabId === undefined ? {} : { tabId: running.tabId }),
66
- }),
67
- ...(last === undefined ? {} : { lastTool: last.tool, lastAt: last.at }),
68
- };
79
+ if (running !== undefined) {
80
+ return {
81
+ phase: 'running',
82
+ tool: running.tool,
83
+ since: running.startedAt,
84
+ ...(running.tabId === undefined ? {} : { tabId: running.tabId }),
85
+ };
86
+ }
87
+ const settled = this.settled.get(key);
88
+ if (settled !== undefined) {
89
+ const hold = settled.ok ? DONE_HOLD_MS : ERROR_HOLD_MS;
90
+ if (Date.now() - settled.at < hold) {
91
+ return {
92
+ phase: settled.ok ? 'done' : 'error',
93
+ tool: settled.tool,
94
+ since: settled.at,
95
+ ...(settled.tabId === undefined ? {} : { tabId: settled.tabId }),
96
+ ...(settled.detail === undefined ? {} : { detail: settled.detail }),
97
+ };
98
+ }
99
+ }
100
+ return { phase: 'ready', since: settled?.at ?? 0 };
69
101
  }
70
102
  /** Drop every record; the plugin calls this on unload. */
71
103
  clear() {
72
104
  this.running.length = 0;
73
- this.finished.clear();
105
+ this.settled.clear();
74
106
  }
75
107
  }
76
108
  /** The tab a call named, as the tracker reads it from frozen arguments. */
@@ -84,8 +116,13 @@ function sessionIdOf(exec) {
84
116
  const id = session?.id;
85
117
  return typeof id === 'string' && id !== '' ? id : undefined;
86
118
  }
119
+ /** A thrown value as one line of text for the chip. */
120
+ function messageOf(error) {
121
+ const text = error instanceof Error ? error.message : String(error);
122
+ return text.replace(/\s+/gu, ' ').trim();
123
+ }
87
124
  /**
88
- * Wrap one tool definition so its execution is visible to the status strip.
125
+ * Wrap one tool definition so its execution is visible to the header chip.
89
126
  *
90
127
  * Every other member is carried over untouched: this adds observation, it does
91
128
  * not change what the tool declares or returns.
@@ -100,10 +137,13 @@ export function withActivity(definition, activity) {
100
137
  async execute(args, exec) {
101
138
  const end = activity.begin(definition.name, tabIdOf(args), sessionIdOf(exec));
102
139
  try {
103
- return await run(args, exec);
140
+ const value = await run(args, exec);
141
+ end(true);
142
+ return value;
104
143
  }
105
- finally {
106
- end();
144
+ catch (error) {
145
+ end(false, messageOf(error));
146
+ throw error;
107
147
  }
108
148
  },
109
149
  };
@@ -1 +1 @@
1
- {"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