dsh-sidebar-reader 0.0.0-stage → 1.1.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/LICENSE +21 -0
- package/README.md +174 -3
- package/README.zh.md +174 -0
- package/cordis.patch.yml +4 -0
- package/lib/client.js +390 -0
- package/lib/index.js +216 -0
- package/package.json +52 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LaFantasque520
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,174 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# dsh-sidebar-reader
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
Let your model read the **current session's** sidebar on demand: the active tab, official right-sidebar tabs, terminal screens, and browser page text.
|
|
6
|
+
|
|
7
|
+
Once installed, just tell the model "read my sidebar" or "show me my terminal" — the model triggers a capture through the plugin's command channel and receives a snapshot within seconds.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
model ──POST /sidebar-reader/command──▶ host route (lib/index.js)
|
|
13
|
+
client polls every 2s
|
|
14
|
+
▼
|
|
15
|
+
client capture (lib/client.js, runs in the Web UI)
|
|
16
|
+
├── active tab (sidebarRight.active(), active pane's active tab)
|
|
17
|
+
├── right-sidebar tabs (sidebarRight.openTabs, current session only)
|
|
18
|
+
├── terminal screens (remote.terminal.attach, first snapshot → ANSI-free,
|
|
19
|
+
│ incremental vs. the previous read)
|
|
20
|
+
└── web page text (webview innerText, desktop only)
|
|
21
|
+
│
|
|
22
|
+
client ──POST /sidebar-reader/latest──▶ host keeps the latest snapshot only
|
|
23
|
+
model ◀──GET /sidebar-reader/latest─── host
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Agent tool (auto-registered)
|
|
27
|
+
|
|
28
|
+
The plugin's host side registers a native agent tool **`sidebar_read`** with the DSH tool registry: it appears in every new session's tool list automatically, and one call returns the full snapshot — no HTTP, no configuration. The "prefer this over pwsh/web_fetch for terminal or page questions" preference is encoded in the tool description itself.
|
|
29
|
+
|
|
30
|
+
The only parameter is `delta` (default `true`): terminal screens are incremental after the first read. Pass `delta: false` when you need every terminal's complete screen again.
|
|
31
|
+
|
|
32
|
+
The HTTP endpoints below remain as a fallback channel.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
| Channel | Source | Notes |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| Active tab | `sidebarRight.active()` | The active pane's active tab (id / kind / title / contentId), plus `expanded` telling whether the column is showing |
|
|
39
|
+
| Right-sidebar tabs | `sidebarRight.openTabs` live snapshot | Every open tab of the current session (`tabId` / `kind` / `contentId`) |
|
|
40
|
+
| Terminal screens | `remote.terminal.attach` first snapshot frame | Full screen including scrollback, ANSI-stripped, then incremental (see below); input control is released right after reading |
|
|
41
|
+
| Web page text | Sidebar browser webview `innerText` | **Desktop (Electron) only**; strict mode, see below |
|
|
42
|
+
|
|
43
|
+
### Three passes on terminal text
|
|
44
|
+
|
|
45
|
+
A raw xterm screen is a poor thing to hand a model: it is full of color/cursor escapes, it repeats the whole scrollback on every read, and it can be arbitrarily long. So every terminal screen goes through three passes in `lib/client.js`:
|
|
46
|
+
|
|
47
|
+
| Pass | What it does | Why |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `stripAnsi` | Drops ANSI/OSC escape sequences and invisible control characters | Escapes are pure token cost and unreadable |
|
|
50
|
+
| `screenDelta` | Remembers each terminal's last reported screen (per terminal id) and returns only the new part; falls back to the common line prefix when the screen was redrawn; returns the whole screen when nothing matches, so text is never lost | Repeated reads cost a fraction of the context |
|
|
51
|
+
| `capScreen` | Keeps only the tail, max 500 lines / 20 000 chars per terminal | Scrollback can be huge; the newest output is at the bottom |
|
|
52
|
+
|
|
53
|
+
Each terminal entry therefore carries `screen` (clean text), `delta` (`false` = this is a complete screen, i.e. the first read of that terminal or an explicit `delta:false`) and `truncated` (`true` = the caps kicked in). `delta:false` also refreshes the delta baseline, so the next incremental read stays consistent.
|
|
54
|
+
|
|
55
|
+
### Strict mode for web page text
|
|
56
|
+
|
|
57
|
+
The page is read only when **the active tab is a browser** *and* **the column is expanded**. Otherwise `page` is `null`.
|
|
58
|
+
|
|
59
|
+
Why: when a sidebar browser tab moves to the background, its webview stays in the DOM with zero width, and the fallback picker would still return it — the model would receive a page the user is not looking at. `null` is better than the wrong page.
|
|
60
|
+
|
|
61
|
+
## What you get
|
|
62
|
+
|
|
63
|
+
| What you are looking at | Readable | Notes |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| A page in the sidebar browser | ✅ title + URL + text | Must be the active browser tab, with the column expanded |
|
|
66
|
+
| A file / document tab | ⚠️ address only | You get its `contentId` (e.g. `dsh-resource://file/...`); read the file by that path |
|
|
67
|
+
| A terminal | ✅ screen text | ANSI-free; first read is the full screen, later reads add only new lines (max 500 lines / 20k chars per terminal) |
|
|
68
|
+
| Plain web build (browser access) | ❌ page text | No webview; tabs and terminals still work |
|
|
69
|
+
|
|
70
|
+
## Snapshot example
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"page": { "title": "…", "url": "https://…", "text": "…", "chars": 1235 },
|
|
75
|
+
"right": {
|
|
76
|
+
"sessionId": "session-…",
|
|
77
|
+
"expanded": true,
|
|
78
|
+
"active": { "id": "tab5", "type": "browser", "title": "Browser", "path": "sidebar://browser/…" },
|
|
79
|
+
"tabs": [
|
|
80
|
+
{ "id": "tab3", "type": "files", "path": "sidebar://files" },
|
|
81
|
+
{ "id": "tab5", "type": "browser", "path": "sidebar://browser/…" }
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"terminals": {
|
|
85
|
+
"sessionId": "session-…",
|
|
86
|
+
"terminals": [
|
|
87
|
+
{ "id": "…", "title": "…", "state": "running", "screen": "…", "delta": false, "truncated": false }
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"commandId": "cmd-…",
|
|
91
|
+
"receivedAt": "2026-11-08T13:11:42.350Z"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Design disciplines:
|
|
96
|
+
|
|
97
|
+
1. **Scope** — everything is filtered to the session on screen before leaving the browser; other sessions are unreadable;
|
|
98
|
+
2. **Never throws** — each channel degrades independently; one failing channel doesn't break the others;
|
|
99
|
+
3. **Transparent** — a toast is shown on every read;
|
|
100
|
+
4. **Revocable** — all side effects live in `ctx.effect` and are cleaned up when the plugin is disabled.
|
|
101
|
+
|
|
102
|
+
## Install
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
# From a plugin market (dshmarket / the official Discover tab, once listed): search "Sidebar Reader"
|
|
106
|
+
# or via CLI:
|
|
107
|
+
dsh plugin --profile <your-profile> add dsh-sidebar-reader
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
On the official DSH Desktop app, install from the app's own **Settings → Plugins** (or clone this repo anywhere and point the plugin manager's local install at the folder).
|
|
111
|
+
|
|
112
|
+
## Requirements
|
|
113
|
+
|
|
114
|
+
- **DSH >= 0.2.1-rc.2** (terminal capture uses `remote.terminal.attach`; on 0.2.0-rc.2 the plugin loads and tabs work, but terminal capture errors out — that version still called it `follow`)
|
|
115
|
+
- **No better-sidebar required** — official services only (`sidebarRight`, `remote.terminal`)
|
|
116
|
+
- Web page text is desktop-only; the web build still gets the active tab, tabs and terminals
|
|
117
|
+
|
|
118
|
+
## Compatibility
|
|
119
|
+
|
|
120
|
+
| Host version | Loads | Active tab | Sidebar tabs | Terminals | Web page text |
|
|
121
|
+
|---|---|---|---|---|---|
|
|
122
|
+
| 0.2.1-rc.2 ~ 0.2.2-rc.3 | ✅ | ✅ | ✅ | ✅ | desktop ✅ / web ❌ |
|
|
123
|
+
| 0.2.0-rc.2 | ✅ | ⚠️ | ✅ | ❌ (API renamed follow→attach) | desktop ✅ / web ❌ |
|
|
124
|
+
|
|
125
|
+
Verified: all four channels on 0.2.1-rc.5 and on 0.2.2-rc.3 (with the incremental terminal read); install + composition + client module registration on 0.2.1-rc.2 and 0.2.2-rc.1 (`scripts/test-plugin.ps1`).
|
|
126
|
+
|
|
127
|
+
## Development & testing
|
|
128
|
+
|
|
129
|
+
Two Windows PowerShell scripts ship with the repo, plus one Node test:
|
|
130
|
+
|
|
131
|
+
```powershell
|
|
132
|
+
# 1) Smoke test against a running GUI port: host route + client polling + snapshot
|
|
133
|
+
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/check-plugin.ps1 -Port 53233
|
|
134
|
+
|
|
135
|
+
# 2) Multi-version compatibility test: isolated directory + DSH_HOME per version
|
|
136
|
+
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test-plugin.ps1 -Version 0.2.1-rc.2 -Port 6123
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
# 3) Unit tests for the terminal text passes (stripAnsi / capScreen / screenDelta)
|
|
141
|
+
node scripts/test-text-helpers.mjs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Two traps worth knowing:
|
|
145
|
+
|
|
146
|
+
- **Client changes require a page refresh**: the host swaps the bundle immediately (rev changes), but a module already loaded in the page is not replaced — HMR graph sync only adds/removes entries, it does not replace an existing one;
|
|
147
|
+
- **The `id` in `__ModuleLoader__.load({ id })` must equal the npm package name** (including scope). DSH's client module system matches registrations by package name; a mismatch fails silently — `sidebar_read` still answers, but every capture times out.
|
|
148
|
+
|
|
149
|
+
## Privacy & security
|
|
150
|
+
|
|
151
|
+
- Reads the current session only; other sessions' data never leaves the browser;
|
|
152
|
+
- Everything stays on your machine: host routes sit on loopback HTTP (`/sidebar-reader/*`), no browser auth, nothing leaves the machine;
|
|
153
|
+
- Every read is announced with a toast — no silent capture;
|
|
154
|
+
- No telemetry, no external requests.
|
|
155
|
+
|
|
156
|
+
## Host routes (prefix `/sidebar-reader`)
|
|
157
|
+
|
|
158
|
+
| Endpoint | Method | Purpose |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `/health` | GET | Self-check: snapshot present? command pending? |
|
|
161
|
+
| `/latest` | GET | Model reads the snapshot (404 when empty) |
|
|
162
|
+
| `/latest` | POST | Client submits a snapshot (replace-only-latest) |
|
|
163
|
+
| `/command` | GET | Client claims a command (consume-on-read) |
|
|
164
|
+
| `/command` | POST | Model issues a command |
|
|
165
|
+
|
|
166
|
+
## Changelog
|
|
167
|
+
|
|
168
|
+
- **1.1.0** — terminal reads are now context-cheap: screens are ANSI-stripped, incremental after the first read (`delta`, with a `delta:false` escape hatch), and capped at 500 lines / 20 000 chars per terminal; added `scripts/test-text-helpers.mjs`; verified end-to-end on DSH 0.2.2-rc.3.
|
|
169
|
+
- **1.0.1** — fixed the client module registration id not matching the package name (previously the client never loaded on any host, surfacing as `capture timed out`); `tabs[].id` now carries the real `tabId`; added `right.active` (the active tab) and `right.expanded`; web page text is now strict mode (`null` unless a browser tab is active and the column is expanded).
|
|
170
|
+
- **1.0.0** — first release.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
[MIT](LICENSE)
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# dsh-sidebar-reader
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
让模型按需读取**当前会话**的侧边栏:当前选中的标签、官方右侧栏标签、终端屏幕、浏览器网页正文。
|
|
6
|
+
|
|
7
|
+
装好后对模型说一句「读一下我的侧边栏」或「看我开着的终端」,模型通过插件的命令通道触发一次采集,几秒内就能拿到快照。
|
|
8
|
+
|
|
9
|
+
## 工作原理
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
模型 ──POST /sidebar-reader/command──▶ 宿主路由 (lib/index.js)
|
|
13
|
+
│ 客户端每 2s 轮询领命令
|
|
14
|
+
▼
|
|
15
|
+
客户端采集 (lib/client.js,跑在 Web UI 里)
|
|
16
|
+
├── 当前选中标签(sidebarRight.active(),活动窗格的活动标签)
|
|
17
|
+
├── 官方右侧栏标签(sidebarRight.openTabs,按当前会话过滤)
|
|
18
|
+
├── 终端屏幕(remote.terminal.attach,取首个全屏快照 → 去 ANSI、
|
|
19
|
+
│ 与上次读取比只留增量)
|
|
20
|
+
└── 网页正文(webview innerText,仅桌面端)
|
|
21
|
+
│
|
|
22
|
+
客户端 ──POST /sidebar-reader/latest──▶ 宿主只保留最新一份
|
|
23
|
+
模型 ◀──GET /sidebar-reader/latest──── 宿主
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 模型工具(自动注册)
|
|
27
|
+
|
|
28
|
+
插件宿主侧会向 DSH 工具注册表注册一个原生 agent 工具 **`sidebar_read`**:每个新会话的工具清单里自动出现,模型一次调用即拿到全量快照,无需任何 HTTP 调用或配置。「读终端/网页先走侧边栏」的偏好直接编码在工具描述里。
|
|
29
|
+
|
|
30
|
+
唯一参数是 `delta`(缺省 `true`):终端屏幕从第二次读取起只回增量。需要重新拿到每个终端的完整屏幕时传 `delta: false`。
|
|
31
|
+
|
|
32
|
+
下方 HTTP 端点保留为兜底通道。
|
|
33
|
+
|
|
34
|
+
## 功能
|
|
35
|
+
|
|
36
|
+
| 采集路 | 来源 | 说明 |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| 当前选中标签 | `sidebarRight.active()` | 活动窗格的活动标签(id / kind / title / contentId),并带 `expanded` 表示侧栏是否展开 |
|
|
39
|
+
| 右侧栏标签 | `sidebarRight.openTabs` 活快照 | 当前会话打开的全部标签(`tabId` / `kind` / `contentId`),**只取当前会话** |
|
|
40
|
+
| 终端屏幕 | `remote.terminal.attach` 首帧快照 | 含滚动缓冲的完整屏幕,去 ANSI 后按增量回传(见下);读完立即断开归还输入权 |
|
|
41
|
+
| 网页正文 | 侧栏浏览器 webview 的 `innerText` | **仅桌面端(Electron)**;严格模式,见下 |
|
|
42
|
+
|
|
43
|
+
### 终端文本的三道处理
|
|
44
|
+
|
|
45
|
+
xterm 的原始屏幕并不适合直接喂模型:夹着大量颜色/光标转义、每次读取都把整屏滚动缓冲重复一遍、长度还可能很长。所以每块屏幕在 `lib/client.js` 里过三道:
|
|
46
|
+
|
|
47
|
+
| 处理 | 做什么 | 为什么 |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `stripAnsi` | 去掉 ANSI/OSC 转义序列与不可见控制符 | 转义纯属 token 浪费,模型也读不懂 |
|
|
50
|
+
| `screenDelta` | 按终端 id 记住上次回传的屏幕,本次只回新增部分;界面重绘时退化为按行的公共前缀;完全对不上就整屏回传(不丢文本) | 连续读取只花原来零头的上下文 |
|
|
51
|
+
| `capScreen` | 只保留尾部,单终端上限 500 行 / 2 万字 | 滚动缓冲可能极长,最新输出在末尾 |
|
|
52
|
+
|
|
53
|
+
因此每个终端条目带三个字段:`screen`(干净文本)、`delta`(`false` = 这是完整屏幕,即该终端首次读取或显式要了全屏)、`truncated`(`true` = 触发了行/字符上限)。`delta:false` 同时会刷新增量基准,下一轮增量仍然对得上。
|
|
54
|
+
|
|
55
|
+
### 网页正文的「严格模式」
|
|
56
|
+
|
|
57
|
+
只有满足两条时才读网页:**当前选中的标签是 browser**,且**侧栏处于展开状态**。否则 `page` 一律为 `null`。
|
|
58
|
+
|
|
59
|
+
原因:侧栏把没选中的浏览器标签收进后台时,webview 仍留在 DOM 里(宽度为 0),兜底逻辑会把它当成「最后一个」读回来——模型就会拿到用户根本没在看的页面。宁可给 `null`,也不给错的那一页。
|
|
60
|
+
|
|
61
|
+
## 能读到什么
|
|
62
|
+
|
|
63
|
+
| 你在看的东西 | 能读到 | 说明 |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| 侧栏浏览器里的网页 | ✅ 标题 + URL + 正文 | 必须是当前选中的 browser 标签,且侧栏展开 |
|
|
66
|
+
| 侧栏里的文件/文档标签 | ⚠️ 只有地址 | 给的是 `contentId`(如 `dsh-resource://file/...`),正文要按路径另外读 |
|
|
67
|
+
| 终端 | ✅ 屏幕文本 | 去 ANSI;首次整屏,之后只回新增行(单终端上限 500 行 / 2 万字) |
|
|
68
|
+
| 纯 Web 版 DSH(浏览器访问) | ❌ 网页正文 | 没有 webview;标签与终端仍可读 |
|
|
69
|
+
|
|
70
|
+
## 快照示例
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"page": { "title": "…", "url": "https://…", "text": "…", "chars": 1235 },
|
|
75
|
+
"right": {
|
|
76
|
+
"sessionId": "session-…",
|
|
77
|
+
"expanded": true,
|
|
78
|
+
"active": { "id": "tab5", "type": "browser", "title": "浏览器", "path": "sidebar://browser/…" },
|
|
79
|
+
"tabs": [
|
|
80
|
+
{ "id": "tab3", "type": "files", "path": "sidebar://files" },
|
|
81
|
+
{ "id": "tab5", "type": "browser", "path": "sidebar://browser/…" }
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"terminals": {
|
|
85
|
+
"sessionId": "session-…",
|
|
86
|
+
"terminals": [
|
|
87
|
+
{ "id": "…", "title": "…", "state": "running", "screen": "…", "delta": false, "truncated": false }
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"commandId": "cmd-…",
|
|
91
|
+
"receivedAt": "2026-11-08T13:11:42.350Z"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
四条设计纪律:
|
|
96
|
+
|
|
97
|
+
1. **作用域**:所有数据先按「屏幕上的会话」过滤才出浏览器,别的会话读不到;
|
|
98
|
+
2. **永不抛错**:各采集路独立降级,一路坏了其余照常返回;
|
|
99
|
+
3. **透明**:每次读取界面都弹 toast,用户看得见;
|
|
100
|
+
4. **可撤销**:所有副作用挂在 `ctx.effect` 上,禁用插件即干净退场。
|
|
101
|
+
|
|
102
|
+
## 安装
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
# 插件市场(dshmarket 或官方发现页收录后)里搜索 Sidebar Reader
|
|
106
|
+
# 或命令行:
|
|
107
|
+
dsh plugin --profile <你的profile> add dsh-sidebar-reader
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
官方 DSH Desktop 桌面端请在应用自身的 **设置 → 插件** 里安装(或把本仓库克隆到任意目录,用插件管理的本地安装指向该目录)。
|
|
111
|
+
|
|
112
|
+
## 要求
|
|
113
|
+
|
|
114
|
+
- **DSH >= 0.2.1-rc.2**(终端读取依赖 `remote.terminal.attach`;0.2.0-rc.2 能加载、侧栏标签可用,但终端采集会报错——该版本的接口还叫 `follow`)
|
|
115
|
+
- **不依赖 better-sidebar**——只用官方服务(`sidebarRight`、`remote.terminal`)
|
|
116
|
+
- 网页正文读取仅桌面端;Web 版(浏览器访问)可用当前选中标签 + 标签列表 + 终端
|
|
117
|
+
|
|
118
|
+
## 兼容性
|
|
119
|
+
|
|
120
|
+
| 宿主版本 | 加载 | 选中标签 | 侧栏标签 | 终端 | 网页正文 |
|
|
121
|
+
|---|---|---|---|---|---|
|
|
122
|
+
| 0.2.1-rc.2 ~ 0.2.2-rc.3 | ✅ | ✅ | ✅ | ✅ | 桌面 ✅ / Web ❌ |
|
|
123
|
+
| 0.2.0-rc.2 | ✅ | ⚠️ | ✅ | ❌(接口改名 follow→attach) | 桌面 ✅ / Web ❌ |
|
|
124
|
+
|
|
125
|
+
实测说明:0.2.1-rc.5 与 0.2.2-rc.3(含终端增量读取)上四路全功能实测通过;0.2.1-rc.2 与 0.2.2-rc.1 完成了安装、组合与客户端模块注册验证(`scripts/test-plugin.ps1`)。
|
|
126
|
+
|
|
127
|
+
## 开发与测试
|
|
128
|
+
|
|
129
|
+
仓库自带两个脚本(Windows PowerShell):
|
|
130
|
+
|
|
131
|
+
```powershell
|
|
132
|
+
# 1) 冒烟测试:对着已经跑起来的 GUI 端口,验证宿主+客户端+快照三件事
|
|
133
|
+
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/check-plugin.ps1 -Port 53233
|
|
134
|
+
|
|
135
|
+
# 2) 多版本兼容测试:每个版本独立目录 + 独立 DSH_HOME,不动你正在用的桌面端
|
|
136
|
+
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test-plugin.ps1 -Version 0.2.1-rc.2 -Port 6123
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
# 3) 终端文本三道处理的单元测试(stripAnsi / capScreen / screenDelta)
|
|
141
|
+
node scripts/test-text-helpers.mjs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
两个容易踩的坑:
|
|
145
|
+
|
|
146
|
+
- **改了客户端代码必须刷新页面**:宿主会立刻换掉 bundle(rev 变化),但页面里已加载的模块不会自己替换——HMR 的图同步只处理「新增/删除 entry」,不处理「已有 entry 替换」;
|
|
147
|
+
- **`lib/client.js` 里 `__ModuleLoader__.load({ id })` 的 id 必须等于 npm 包名**(含 scope)。DSH 的客户端模块系统按包名匹配注册,写错会静默加载失败——表现是 `sidebar_read` 能调、但每次 `capture timed out`。
|
|
148
|
+
|
|
149
|
+
## 隐私与安全
|
|
150
|
+
|
|
151
|
+
- 只读当前会话的数据,跨会话内容不出浏览器;
|
|
152
|
+
- 全部数据只落本机:宿主路由挂在 loopback HTTP(`/sidebar-reader/*`)上,不过浏览器鉴权、不出机器;
|
|
153
|
+
- 每次读取都有 toast 提示,无静默采集;
|
|
154
|
+
- 无遥测、无外部请求。
|
|
155
|
+
|
|
156
|
+
## 宿主路由(前缀 `/sidebar-reader`)
|
|
157
|
+
|
|
158
|
+
| 端点 | 方法 | 用途 |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `/health` | GET | 自检:有无快照、有无待领命令 |
|
|
161
|
+
| `/latest` | GET | 模型读快照(无快照 404) |
|
|
162
|
+
| `/latest` | POST | 客户端交快照(整体替换,只留最新) |
|
|
163
|
+
| `/command` | GET | 客户端领命令(消费即清空,一条命令只执行一次) |
|
|
164
|
+
| `/command` | POST | 模型下发命令 |
|
|
165
|
+
|
|
166
|
+
## 更新日志
|
|
167
|
+
|
|
168
|
+
- **1.1.0** — 终端读取改为省上下文的形态:屏幕去 ANSI、首次之后只回增量(`delta`,可用 `delta:false` 要全屏)、单终端上限 500 行 / 2 万字;新增 `scripts/test-text-helpers.mjs`;在 DSH 0.2.2-rc.3 上端到端实测通过。
|
|
169
|
+
- **1.0.1** — 修复客户端模块注册 id 与包名不一致(此前任何宿主上客户端都不会加载,表现为 `capture timed out`);`tabs[].id` 改用真实 `tabId`;新增 `right.active`(当前选中标签)与 `right.expanded`;网页正文改为严格模式(非 browser 标签或侧栏收起时返回 `null`)。
|
|
170
|
+
- **1.0.0** — 首个版本。
|
|
171
|
+
|
|
172
|
+
## 许可
|
|
173
|
+
|
|
174
|
+
[MIT](LICENSE)
|
package/cordis.patch.yml
ADDED
package/lib/client.js
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// dsh-sidebar-reader · 客户端部分(运行在 GUI 渲染进程页面里)
|
|
3
|
+
//
|
|
4
|
+
// 架构总览(与 lib/index.js 宿主路由配合):
|
|
5
|
+
//
|
|
6
|
+
// 模型 ──POST /sidebar-reader/command──> 宿主路由 ──客户端 2s 轮询领命令──> 本文件
|
|
7
|
+
// ↑ │ 采集
|
|
8
|
+
// └────POST /sidebar-reader/latest─┘
|
|
9
|
+
// 模型 <──GET /sidebar-reader/latest────── 宿主路由(内存里只留最新一份快照)
|
|
10
|
+
//
|
|
11
|
+
// 职责:响应模型的采集命令,一次性抓取三路数据并回传宿主——
|
|
12
|
+
// 1. page 侧栏浏览器 webview 的网页正文(桌面端才有;严格模式:仅当当前
|
|
13
|
+
// 选中的标签就是浏览器时才读,避免把后台标签页当成"当前页面")
|
|
14
|
+
// 2. right 官方右侧栏当前会话打开的标签 + 当前选中标签(sidebarRight 活数据)
|
|
15
|
+
// 3. terminals 本会话每个终端的全屏文本(remote.terminal attach 基线快照)
|
|
16
|
+
//
|
|
17
|
+
// 设计纪律:
|
|
18
|
+
// - 三路采集各自 try/catch 降级,一路失败不影响其他路;
|
|
19
|
+
// - 所有数据先按「当前屏幕上的会话」过滤,其他会话的数据不出浏览器;
|
|
20
|
+
// - 无任何常驻 UI(按钮已移除),每次采集弹 toast 告知用户,保持透明;
|
|
21
|
+
// - 全部副作用(定时器)挂在 ctx.effect 上,插件禁用即自动清理。
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
// 客户端插件加载约定:宿主的模块加载器调用 factory(require),
|
|
25
|
+
// 返回的 { apply, inject } 就是本插件的客户端模块。
|
|
26
|
+
window.__ModuleLoader__.load({
|
|
27
|
+
id: "dsh-sidebar-reader",
|
|
28
|
+
factory: (require) => {
|
|
29
|
+
var module = { exports: {} };
|
|
30
|
+
var exports = module.exports;
|
|
31
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
32
|
+
//#region src/client/inject.ts
|
|
33
|
+
// cordis 注入清单(硬性):声明了才能访问 ctx 上对应属性,否则加载失败。
|
|
34
|
+
// sidebarRight 官方右侧栏服务(@deepseek-ai/dsh-client-ui-sidebar-right)
|
|
35
|
+
// · mounted 快照:当前绘制在屏幕上的会话 id
|
|
36
|
+
// · openTabs 快照:所有已采用会话的打开标签元数据
|
|
37
|
+
// remote 远程命名空间宿主(Typert 网关)
|
|
38
|
+
// remote.terminal 终端远程命名空间(@deepseek-ai/dsh-api-terminal-controller)
|
|
39
|
+
// 注意:不依赖 better-sidebar——全部能力来自官方服务。
|
|
40
|
+
const inject = ["sidebarRight", "remote", "remote.terminal"];
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/client/read-webview.ts
|
|
43
|
+
// 网页正文抓取上限(字符数),与宿主 index.js 的同名常量呼应(双保险截断)。
|
|
44
|
+
const MAX_TEXT_CHARS = 200000;
|
|
45
|
+
// 注入到 <webview> 客户页面里执行的一次性脚本:抓 title/url/innerText。
|
|
46
|
+
// innerText 已是渲染后文本(不含 display:none),对“模型读网页”最合适。
|
|
47
|
+
const READ_SCRIPT = "(() => ({ title: document.title, url: location.href, text: ((document.body ? document.body.innerText : document.documentElement.innerText) || '').slice(0, " + String(MAX_TEXT_CHARS) + "), ready: document.readyState }))()";
|
|
48
|
+
/** 桌面端侧栏浏览器每有一个展示中的 tab 就挂一个 webview。 */
|
|
49
|
+
function findSidebarWebview() {
|
|
50
|
+
// data-sidebar-browser-frame="webview" 是官方 browser 类型 tab 的标记属性。
|
|
51
|
+
const candidates = [...document.querySelectorAll('webview[data-sidebar-browser-frame="webview"]')];
|
|
52
|
+
// 优先取“可见”的那个(用户正在看的页面);全不可见时退而取最后一个。
|
|
53
|
+
return candidates.find((element) => element.clientWidth > 0 && element.clientHeight > 0) ?? candidates.at(-1) ?? null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 读取侧栏浏览器当前网页的 {title, url, text}。
|
|
57
|
+
* 任何一步不满足(无 webview / 非 Electron 环境 / 页面拒绝执行)都返回
|
|
58
|
+
* null——纯 Web 端、未开浏览器 tab 属于常态,不算错误。
|
|
59
|
+
*/
|
|
60
|
+
async function readSidebarPage() {
|
|
61
|
+
const element = findSidebarWebview();
|
|
62
|
+
if (element === null) return null;
|
|
63
|
+
if (typeof element.executeJavaScript !== "function") return null;
|
|
64
|
+
try {
|
|
65
|
+
return await element.executeJavaScript(READ_SCRIPT, false);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/client/sidebar-state.ts
|
|
72
|
+
/**
|
|
73
|
+
* 当前会话 id(官方来源):`sidebarRight.mounted` 是「屏幕上的会话」的
|
|
74
|
+
* 可观察快照,主栏被会话占据时为其 id,否则 undefined。
|
|
75
|
+
* 链式 ?. 全程防御:服务形态变化时安静地返回 null,不抛错。
|
|
76
|
+
*/
|
|
77
|
+
function currentSessionId(ctx) {
|
|
78
|
+
const mounted = ctx.sidebarRight?.mounted?.getSnapshot?.();
|
|
79
|
+
return typeof mounted === "string" && mounted.length > 0 ? mounted : null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 官方右侧栏·当前会话打开的标签。
|
|
83
|
+
* 数据源 `sidebarRight.openTabs`:侧栏自己维护的活标签清单(启动时会用
|
|
84
|
+
* 持久化布局播种,运行中实时更新)。每条记录只有四个字段:
|
|
85
|
+
* {sessionId, tabId, kind, contentId}——没有 title(标题与选中态保存在
|
|
86
|
+
* layout/pane 里,不在这个快照中,别按那些字段取值,否则输出会恒为 null)。
|
|
87
|
+
* 「当前选中哪个」改用官方 ISidebarRight.active():它直接返回活动窗格的
|
|
88
|
+
* 活动标签 TabRecord(带 id/kind/title/contentId),不是猜出来的。
|
|
89
|
+
* 按 sessionId 过滤实现「只读当前会话」——其他会话的标签不出浏览器。
|
|
90
|
+
* 输出字段:
|
|
91
|
+
* active 当前选中的标签(没有会话在屏幕上是 null)
|
|
92
|
+
* tabs 打开的标签:[{ id(tabId), type(kind), path(contentId) }]
|
|
93
|
+
*/
|
|
94
|
+
function rightSidebarState(ctx) {
|
|
95
|
+
try {
|
|
96
|
+
const sessionId = currentSessionId(ctx);
|
|
97
|
+
if (sessionId === null) return { error: "no session is on screen" };
|
|
98
|
+
const all = ctx.sidebarRight.openTabs.getSnapshot();
|
|
99
|
+
const tabs = (Array.isArray(all) ? all : [])
|
|
100
|
+
.filter((tab) => tab !== null && typeof tab === "object" && tab.sessionId === sessionId)
|
|
101
|
+
.map((tab) => ({
|
|
102
|
+
id: typeof tab.tabId === "string" ? tab.tabId : null,
|
|
103
|
+
type: typeof tab.kind === "string" ? tab.kind : null,
|
|
104
|
+
path: typeof tab.contentId === "string" ? tab.contentId : (typeof tab.address === "string" ? tab.address : null)
|
|
105
|
+
}));
|
|
106
|
+
// 当前选中的标签:官方接口直接给,附带 title(openTabs 快照里没有)。
|
|
107
|
+
let active = null;
|
|
108
|
+
try {
|
|
109
|
+
const record = typeof ctx.sidebarRight.active === "function" ? ctx.sidebarRight.active() : void 0;
|
|
110
|
+
if (record !== null && record !== void 0 && typeof record === "object") {
|
|
111
|
+
active = {
|
|
112
|
+
id: typeof record.id === "string" ? record.id : null,
|
|
113
|
+
type: typeof record.kind === "string" ? record.kind : null,
|
|
114
|
+
title: typeof record.title === "string" ? record.title : null,
|
|
115
|
+
path: typeof record.contentId === "string" ? record.contentId : null
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
} catch { active = null; }
|
|
119
|
+
// 侧栏是否展开:收起成侧边栏时,选中标签虽然还在,但屏幕上并没有内容。
|
|
120
|
+
let expanded = null;
|
|
121
|
+
try { expanded = typeof ctx.sidebarRight.isExpanded === "function" ? ctx.sidebarRight.isExpanded() : null; } catch { expanded = null; }
|
|
122
|
+
return { sessionId, expanded, active, tabs };
|
|
123
|
+
} catch (error) {
|
|
124
|
+
// 降级约定:采集函数永不抛错,错误进快照让模型看到原因。
|
|
125
|
+
return { error: String(error && error.message ? error.message : error) };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/client/transport.ts
|
|
130
|
+
/** 相对路径 → 绝对 URL(基于 GUI 页面自身的 origin)。 */
|
|
131
|
+
function base(url) {
|
|
132
|
+
return new URL(url, document.baseURI).href;
|
|
133
|
+
}
|
|
134
|
+
/** 把快照 POST 给宿主路由;失败抛错(由轮询的 try/catch 兜住并告警)。 */
|
|
135
|
+
async function sendSnapshot(payload) {
|
|
136
|
+
const response = await fetch(base("sidebar-reader/latest"), {
|
|
137
|
+
method: "POST",
|
|
138
|
+
headers: { "content-type": "application/json" },
|
|
139
|
+
body: JSON.stringify(payload)
|
|
140
|
+
});
|
|
141
|
+
const body = await response.json().catch(() => ({}));
|
|
142
|
+
if (!response.ok) throw new Error(body.error ?? ("HTTP " + String(response.status)));
|
|
143
|
+
return body;
|
|
144
|
+
}
|
|
145
|
+
/** 向宿主领命令;无命令 / 非法响应一律返回 null(安静空转)。 */
|
|
146
|
+
async function fetchCommand() {
|
|
147
|
+
const response = await fetch(base("sidebar-reader/command"), { cache: "no-store" });
|
|
148
|
+
if (!response.ok) return null;
|
|
149
|
+
return await response.json().catch(() => null);
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/client/text.ts
|
|
153
|
+
// 终端屏文本的三道处理(省上下文,也更好读):
|
|
154
|
+
// 1. stripAnsi 去掉 ANSI/OSC 控制序列——xterm 快照里夹着大量颜色/光标转义,
|
|
155
|
+
// 模型读它们纯属浪费 token;
|
|
156
|
+
// 2. screenDelta 每个终端记住上次回传的屏幕,本次只回新增部分(首次仍是全屏);
|
|
157
|
+
// 3. capScreen 按行/字符双重截断,只保留尾部——滚动缓冲可能很长。
|
|
158
|
+
const TERMINAL_MAX_LINES = 500;
|
|
159
|
+
const TERMINAL_MAX_CHARS = 20000;
|
|
160
|
+
|
|
161
|
+
/** 去掉 ANSI/OSC 控制序列与不可见控制符,只留可读文本。 */
|
|
162
|
+
function stripAnsi(text) {
|
|
163
|
+
return String(text ?? "")
|
|
164
|
+
.replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, "")
|
|
165
|
+
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "")
|
|
166
|
+
.replace(/\u009b[0-?]*[ -/]*[@-~]/g, "")
|
|
167
|
+
.replace(/\u001b[@-Z\\-_]/g, "")
|
|
168
|
+
.replace(/\r\n/g, "\n")
|
|
169
|
+
.replace(/\r/g, "\n")
|
|
170
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, "");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** 按行/字符双重截断,只保留尾部(终端里最新内容在下面)。 */
|
|
174
|
+
function capScreen(text, maxLines, maxChars) {
|
|
175
|
+
let s = String(text ?? "");
|
|
176
|
+
const lines = s.split("\n");
|
|
177
|
+
let truncated = false;
|
|
178
|
+
if (lines.length > maxLines) {
|
|
179
|
+
s = lines.slice(lines.length - maxLines).join("\n");
|
|
180
|
+
truncated = true;
|
|
181
|
+
}
|
|
182
|
+
if (s.length > maxChars) {
|
|
183
|
+
s = "…" + s.slice(s.length - maxChars);
|
|
184
|
+
truncated = true;
|
|
185
|
+
}
|
|
186
|
+
return { text: s, truncated };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 每个终端记住上一次回传的屏幕,本次只回新增部分。
|
|
191
|
+
* 先按整串前缀比;不像追加(如界面重绘、清屏)就退化为按行的公共前缀。
|
|
192
|
+
* 注意 delta 文本一律先算再截断:屏幕本身才参与前缀比较,回传的只是增量。
|
|
193
|
+
*/
|
|
194
|
+
const lastScreens = new Map();
|
|
195
|
+
function screenDelta(terminalId, screen) {
|
|
196
|
+
const prev = lastScreens.get(terminalId) ?? "";
|
|
197
|
+
lastScreens.set(terminalId, screen);
|
|
198
|
+
if (prev.length === 0) return { text: screen, delta: false };
|
|
199
|
+
if (screen.startsWith(prev)) return { text: screen.slice(prev.length), delta: true };
|
|
200
|
+
const a = prev.split("\n");
|
|
201
|
+
const b = screen.split("\n");
|
|
202
|
+
let i = 0;
|
|
203
|
+
while (i < a.length && i < b.length && a[i] === b[i]) i += 1;
|
|
204
|
+
return { text: b.slice(i).join("\n"), delta: true };
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/client/terminals.ts
|
|
208
|
+
/**
|
|
209
|
+
* 只读窥探本会话每个宿主保留的终端:
|
|
210
|
+
* remote.list(sessionId) → [{id, title, state, ...}]
|
|
211
|
+
* remote.attach(sessionId, id, signal) → 帧流(异步可迭代)
|
|
212
|
+
* 第一帧 type:"snapshot" 是全屏基线(含滚动缓冲),拿到即停。
|
|
213
|
+
* 注意事项:
|
|
214
|
+
* - Remote 调用返回 {ok:true,value}|{ok:false,error} 包裹,不抛异常;
|
|
215
|
+
* - attach 的帧可能是裸帧,也可能包一层 {value:帧},两种都兼容;
|
|
216
|
+
* - 读完立即 abort:断开连接释放终端输入权(副作用:GUI 终端视图
|
|
217
|
+
* 会显示「接管输入」按钮,用户点一下即恢复)。
|
|
218
|
+
*
|
|
219
|
+
* 每块屏幕一律先 stripAnsi;options.delta !== false 时再折算成「相对上次
|
|
220
|
+
* 回传的增量」(首次仍是全屏),最后按行/字符截断。屏幕本身(去转义后)
|
|
221
|
+
* 才是 delta 的比较基准,截断只作用于回传文本。
|
|
222
|
+
* @param options - { delta?: boolean },缺省为增量模式。
|
|
223
|
+
*/
|
|
224
|
+
async function terminalScreens(ctx, options) {
|
|
225
|
+
const delta = options === void 0 || options.delta !== false;
|
|
226
|
+
try {
|
|
227
|
+
const sessionId = currentSessionId(ctx);
|
|
228
|
+
if (sessionId === null) return { error: "no session is on screen" };
|
|
229
|
+
const remote = ctx.remote?.terminal;
|
|
230
|
+
if (remote === undefined || typeof remote.list !== "function" || typeof remote.attach !== "function")
|
|
231
|
+
return { sessionId, error: "terminal remote namespace unavailable" };
|
|
232
|
+
const listed = await remote.list(sessionId);
|
|
233
|
+
if (listed === null || listed === void 0 || listed.ok !== true || !Array.isArray(listed.value))
|
|
234
|
+
return { sessionId, error: "terminal list failed" };
|
|
235
|
+
const terminals = [];
|
|
236
|
+
for (const info of listed.value) {
|
|
237
|
+
if (info === null || typeof info !== "object" || typeof info.id !== "string") continue;
|
|
238
|
+
// 每个终端一个 4 秒超时:防止某个终端不吐首帧拖死整轮采集。
|
|
239
|
+
const controller = new AbortController();
|
|
240
|
+
const timer = setTimeout(() => controller.abort(), 4000);
|
|
241
|
+
try {
|
|
242
|
+
for await (const frame of remote.attach(sessionId, info.id, controller.signal)) {
|
|
243
|
+
// 帧形状归一:裸帧或 {value:帧} 包裹都unwrap成裸帧再判 type。
|
|
244
|
+
const unwrapped = frame !== null && typeof frame === "object" && frame.value !== null && typeof frame.value === "object" && "type" in frame.value ? frame.value : frame;
|
|
245
|
+
if (unwrapped !== null && typeof unwrapped === "object" && unwrapped.type === "snapshot") {
|
|
246
|
+
const raw = typeof unwrapped.screen === "string" ? unwrapped.screen : null;
|
|
247
|
+
const clean = raw === null ? null : stripAnsi(raw);
|
|
248
|
+
let part = { text: clean, delta: false };
|
|
249
|
+
if (clean !== null) {
|
|
250
|
+
if (delta) part = screenDelta(info.id, clean);
|
|
251
|
+
else lastScreens.set(info.id, clean); // 全屏模式也要刷新基准,下一轮增量才对得上
|
|
252
|
+
}
|
|
253
|
+
const capped = clean === null ? { text: null, truncated: false } : capScreen(part.text, TERMINAL_MAX_LINES, TERMINAL_MAX_CHARS);
|
|
254
|
+
terminals.push({
|
|
255
|
+
id: info.id,
|
|
256
|
+
title: typeof info.title === "string" ? info.title : null,
|
|
257
|
+
state: typeof info.state === "string" ? info.state : null,
|
|
258
|
+
screen: capped.text, // 已去 ANSI;增量模式下只有自上次读取以来的新增部分
|
|
259
|
+
delta: part.delta, // false = 这一屏是完整屏幕(首次读取,或模型显式要全屏)
|
|
260
|
+
truncated: capped.truncated // true = 超出行/字符上限,只保留了尾部
|
|
261
|
+
});
|
|
262
|
+
break; // 只取基线快照,后续增量帧不消费
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} catch (error) {
|
|
266
|
+
// 单个终端失败记录原因,不影响其余终端。
|
|
267
|
+
terminals.push({
|
|
268
|
+
id: info.id,
|
|
269
|
+
title: typeof info.title === "string" ? info.title : null,
|
|
270
|
+
error: String(error && error.message ? error.message : error)
|
|
271
|
+
});
|
|
272
|
+
} finally {
|
|
273
|
+
clearTimeout(timer);
|
|
274
|
+
controller.abort(); // 无条件断开:归还终端输入权
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return { sessionId, terminals };
|
|
278
|
+
} catch (error) {
|
|
279
|
+
return { error: String(error && error.message ? error.message : error) };
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/client/capture.ts
|
|
284
|
+
/**
|
|
285
|
+
* 采集编排:三路数据串行抓取(耗时主要是终端 attach,并行收益小)。
|
|
286
|
+
*
|
|
287
|
+
* 网页通道用「严格模式」:只有当前选中的标签就是浏览器、且侧栏处于展开状态时才读
|
|
288
|
+
* webview 正文。原因:侧栏把没选中的浏览器标签收进后台时,webview 仍留在 DOM 里
|
|
289
|
+
* (宽度为 0),findSidebarWebview 的兜底会把它当成"最后一个"读回来——于是模型会
|
|
290
|
+
* 拿到用户并没有在看的页面。宁可在非浏览器标签/收起状态下给 null,也不给错的那一页。
|
|
291
|
+
*/
|
|
292
|
+
async function capture(ctx, commandId, options) {
|
|
293
|
+
const right = rightSidebarState(ctx);
|
|
294
|
+
const activeType = right !== null && typeof right === "object" && right.active !== null && typeof right.active === "object"
|
|
295
|
+
? right.active.type
|
|
296
|
+
: null;
|
|
297
|
+
// 只有明确收到 expanded === false 才当作收起;接口缺失(老宿主)按展开处理,
|
|
298
|
+
// 免得把一个"不知道"变成"永远读不到"。
|
|
299
|
+
const collapsed = right !== null && typeof right === "object" && right.expanded === false;
|
|
300
|
+
const page = !collapsed && activeType === "browser" ? await readSidebarPage() : null;
|
|
301
|
+
const payload = {
|
|
302
|
+
page: page === null ? null : {
|
|
303
|
+
title: page.title,
|
|
304
|
+
url: page.url,
|
|
305
|
+
text: page.text
|
|
306
|
+
},
|
|
307
|
+
right,
|
|
308
|
+
terminals: await terminalScreens(ctx, options),
|
|
309
|
+
commandId: commandId ?? null // 带回命令 id,模型可核对命令-快照对应关系
|
|
310
|
+
};
|
|
311
|
+
const receipt = await sendSnapshot(payload);
|
|
312
|
+
return { payload, receipt };
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/client/toast.ts
|
|
316
|
+
/** 屏幕中下方的临时提示条(2.6s 后淡出)。透明性设计:每次采集用户可见。 */
|
|
317
|
+
function toast(message, ok) {
|
|
318
|
+
const node = document.createElement("div");
|
|
319
|
+
node.textContent = message;
|
|
320
|
+
for (const [key, value] of Object.entries({
|
|
321
|
+
position: "fixed",
|
|
322
|
+
left: "50%",
|
|
323
|
+
bottom: "72px",
|
|
324
|
+
transform: "translateX(-50%)",
|
|
325
|
+
zIndex: "2147483646",
|
|
326
|
+
maxWidth: "60vw",
|
|
327
|
+
padding: "7px 14px",
|
|
328
|
+
borderRadius: "8px",
|
|
329
|
+
font: "12px/1.5 system-ui, sans-serif",
|
|
330
|
+
color: ok ? "#0f0" : "#ffd7a0",
|
|
331
|
+
background: ok ? "rgba(20,60,30,.92)" : "rgba(70,40,10,.92)",
|
|
332
|
+
border: "1px solid rgba(255,255,255,.18)",
|
|
333
|
+
boxShadow: "0 4px 18px rgba(0,0,0,.35)",
|
|
334
|
+
pointerEvents: "none",
|
|
335
|
+
transition: "opacity .35s ease"
|
|
336
|
+
})) node.style[key] = value;
|
|
337
|
+
document.body.append(node);
|
|
338
|
+
setTimeout(() => {
|
|
339
|
+
node.style.opacity = "0";
|
|
340
|
+
setTimeout(() => node.remove(), 400);
|
|
341
|
+
}, 2600);
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/client/command-poll.ts
|
|
345
|
+
const COMMAND_POLL_MS = 2000;
|
|
346
|
+
/**
|
|
347
|
+
* 命令轮询主循环:模型 POST 一条命令 → 宿主挂起 → 这里 2s 内领走并执行。
|
|
348
|
+
* 防抖:
|
|
349
|
+
* - inFlight:上一轮未结束不叠加(采集含网络等待,可能超过轮询间隔);
|
|
350
|
+
* - visibilityState === "hidden":GUI 隐藏/最小化时跳过,不白跑。
|
|
351
|
+
* 返回清理函数(clearInterval),由 apply 的 ctx.effect 托管。
|
|
352
|
+
*/
|
|
353
|
+
function startCommandPoll(ctx) {
|
|
354
|
+
let inFlight = false;
|
|
355
|
+
const timer = setInterval(async () => {
|
|
356
|
+
if (inFlight || document.visibilityState === "hidden") return;
|
|
357
|
+
inFlight = true;
|
|
358
|
+
try {
|
|
359
|
+
const command = await fetchCommand();
|
|
360
|
+
if (command === null || command === void 0 || command.id === null || command.id === void 0) return;
|
|
361
|
+
// 命令里带 delta(缺省 true):模型要全屏时宿主下发的就是 false。
|
|
362
|
+
const { payload } = await capture(ctx, command.id, { delta: command.delta !== false });
|
|
363
|
+
const tabCount = Array.isArray(payload.right?.tabs) ? payload.right.tabs.length : 0;
|
|
364
|
+
toast("模型读取了侧边栏(" + String(tabCount) + " 个标签页" + (payload.page ? ",含网页" : "") + ")", true);
|
|
365
|
+
} catch (error) {
|
|
366
|
+
// 单轮失败只告警不清场:inFlight 在 finally 里复位,下轮继续。
|
|
367
|
+
console.warn("[sidebar-reader] command capture failed", error);
|
|
368
|
+
} finally {
|
|
369
|
+
inFlight = false;
|
|
370
|
+
}
|
|
371
|
+
}, COMMAND_POLL_MS);
|
|
372
|
+
return () => clearInterval(timer);
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/client/apply.ts
|
|
376
|
+
/**
|
|
377
|
+
* cordis 入口:挂载命令轮询;返回的清理函数随 effect 撤销,
|
|
378
|
+
* 插件禁用/卸载时定时器自动移除。(早期版本还有手动浮动按钮,
|
|
379
|
+
* 命令通道稳定后已移除——现在采集完全由模型发起。)
|
|
380
|
+
* @param ctx - 所属上下文,effect 随插件生命周期自动清理。
|
|
381
|
+
*/
|
|
382
|
+
function apply(ctx) {
|
|
383
|
+
ctx.effect(() => startCommandPoll(ctx), "ui-sidebar-reader: model command poll");
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
exports.apply = apply;
|
|
387
|
+
exports.inject = inject;
|
|
388
|
+
return module.exports;
|
|
389
|
+
}
|
|
390
|
+
});
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// dsh-sidebar-reader · 宿主部分(运行在 DSH 宿主进程)
|
|
3
|
+
//
|
|
4
|
+
// 职责:维护两块内存状态 + 四个 HTTP 端点 + 一个原生 agent 工具,
|
|
5
|
+
// 充当「模型 ↔ 客户端」的信箱。
|
|
6
|
+
// latest 最新一份侧边栏快照(客户端 POST 上来,模型 GET 走;
|
|
7
|
+
// GET /latest?refresh=1 会自动触发一轮采集并等它回来——模型一次 GET 拿新数据)
|
|
8
|
+
// pendingCommand 待执行的采集命令(POST /command 或 GET /latest?refresh=1 下发,客户端轮询领走)
|
|
9
|
+
// sidebar_read 原生 agent 工具:模型在工具清单里直接看到并调用,进程内触发采集。
|
|
10
|
+
// 「读终端/网页先走侧边栏」的偏好编码在工具描述里,不依赖书面规则。
|
|
11
|
+
//
|
|
12
|
+
// 路由挂在 loopback webServer 上、不过浏览器鉴权(同皮肤资源路由的待遇),
|
|
13
|
+
// 因此模型可以用普通 HTTP 工具(curl/irm)直接读写——这是本插件存在的意义:
|
|
14
|
+
// 让模型用最平凡的 GET/POST 完成对 GUI 内部状态的观察。
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
// 快照里网页正文的截断上限(字符),与客户端 client.js 的同名常量呼应。
|
|
18
|
+
const MAX_TEXT_CHARS = 200000;
|
|
19
|
+
|
|
20
|
+
/** 最新快照;整体替换是该存储的唯一写语义(没有历史、没有合并)。 */
|
|
21
|
+
let latest = null;
|
|
22
|
+
|
|
23
|
+
/** 待执行命令;客户端领走即清空(consume-on-read,一条命令只执行一次)。 */
|
|
24
|
+
let pendingCommand = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 原生 agent 工具定义(照 @deepseek-ai/dsh-tools 注册表接受的裸定义形状手搓,零依赖):
|
|
28
|
+
* register() 只硬性要求 output {schema, render};parameters 为 JSON Schema 对象根。
|
|
29
|
+
* execute 进程内触发一轮采集并等它回来,与 GET /latest?refresh=1 同一逻辑。
|
|
30
|
+
*/
|
|
31
|
+
const SIDEBAR_READ_TOOL = {
|
|
32
|
+
name: "sidebar_read",
|
|
33
|
+
description:
|
|
34
|
+
"Read the current session's live UI state in one call: the official right-sidebar tabs " +
|
|
35
|
+
"(files, folders, documents, browser and terminal tabs), terminal screens (xterm snapshots " +
|
|
36
|
+
"including scrollback), and the sidebar browser web page text. Use this BEFORE shelling out " +
|
|
37
|
+
"via pwsh or web_fetch whenever the user asks about their terminal or a page they opened in " +
|
|
38
|
+
"the sidebar browser. Reads only the current session; data never leaves this machine; the " +
|
|
39
|
+
"user sees a toast on every read. Web page text is desktop-only (null in a plain browser). " +
|
|
40
|
+
"Terminal screens come back ANSI-free and incremental: after the first read of a terminal, " +
|
|
41
|
+
"each screen holds only the lines added since the previous read (delta:true), capped at 500 " +
|
|
42
|
+
"lines / 20000 chars; pass delta:false to get complete screens again.",
|
|
43
|
+
parameters: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
delta: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description:
|
|
49
|
+
"Terminal screens are incremental by default: after the first read of a terminal, each " +
|
|
50
|
+
"screen contains only the lines added since the previous read. Pass false to force a " +
|
|
51
|
+
"complete screen for every terminal (use it when you lost track of earlier output, or " +
|
|
52
|
+
"after the screen was cleared)."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
output: { schema: { type: "string" }, render: (_args, value) => [{ type: "text", text: value }] },
|
|
57
|
+
timeoutMs: 20000,
|
|
58
|
+
async execute(args, exec) {
|
|
59
|
+
// 与 GET /latest?refresh=1 同一逻辑:下发命令 → 轮询 latest.commandId 对上 → 返回快照。
|
|
60
|
+
const id = "cmd-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8);
|
|
61
|
+
// delta 缺省开:首次读取本来就是全屏,之后只回新增部分(省上下文)。
|
|
62
|
+
const delta = !(args !== void 0 && args !== null && args.delta === false);
|
|
63
|
+
pendingCommand = { id, action: "capture", delta, at: new Date().toISOString() };
|
|
64
|
+
const deadline = Date.now() + 15000;
|
|
65
|
+
while (Date.now() < deadline) {
|
|
66
|
+
exec.signal.throwIfAborted();
|
|
67
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
68
|
+
if (latest !== null && latest.commandId === id) break;
|
|
69
|
+
}
|
|
70
|
+
exec.signal.throwIfAborted();
|
|
71
|
+
if (latest === null) throw new Error("sidebar-reader: capture timed out — is the GUI window visible?");
|
|
72
|
+
return JSON.stringify(latest);
|
|
73
|
+
},
|
|
74
|
+
presentCall: (args) => ({ card: "generic", title: "Read sidebar", kind: "read", rawInput: args })
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** 统一 JSON 响应:no-store 防缓存,HEAD 只给头不给体。 */
|
|
78
|
+
function json(res, req, status, body) {
|
|
79
|
+
const payload = JSON.stringify(body);
|
|
80
|
+
res.writeHead(status, {
|
|
81
|
+
"content-type": "application/json; charset=utf-8",
|
|
82
|
+
"cache-control": "no-store",
|
|
83
|
+
"content-length": Buffer.byteLength(payload)
|
|
84
|
+
});
|
|
85
|
+
res.end(req.method === "HEAD" ? void 0 : payload);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** 读取并解析 JSON 请求体;超限 413、非法 JSON 400,失败返回 undefined(响应已写)。 */
|
|
89
|
+
async function readBody(req, res, limitBytes) {
|
|
90
|
+
const chunks = [];
|
|
91
|
+
let bytes = 0;
|
|
92
|
+
for await (const chunk of req) {
|
|
93
|
+
bytes += chunk.length;
|
|
94
|
+
if (bytes > limitBytes) {
|
|
95
|
+
json(res, req, 413, { error: "payload too large" });
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
chunks.push(chunk);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
102
|
+
} catch {
|
|
103
|
+
json(res, req, 400, { error: "body must be JSON" });
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 注册快照存储与命令通道路由(插件启用期间有效)。
|
|
110
|
+
* @param ctx - 所属上下文,effect 撤销时路由自动注销。
|
|
111
|
+
*/
|
|
112
|
+
function apply(ctx) {
|
|
113
|
+
// 注册原生 agent 工具:register() 返回注销器,包进 effect——插件禁用即自动注销。
|
|
114
|
+
// 「tools」服务由宿主提供(plugin_market 等官方插件同款注册途径)。
|
|
115
|
+
ctx.inject(["tools"], (toolsCtx) => {
|
|
116
|
+
const tools = toolsCtx.get("tools") ?? toolsCtx.tools;
|
|
117
|
+
toolsCtx.effect(() => tools.register(SIDEBAR_READ_TOOL), "sidebar-reader: sidebar_read agent tool");
|
|
118
|
+
});
|
|
119
|
+
// 等宿主的 webServer 服务就绪再注册路由(注入保证时序)。
|
|
120
|
+
ctx.inject(["webServer"], (webCtx) => {
|
|
121
|
+
const server = webCtx.get("webServer");
|
|
122
|
+
// kind:"prefix" 接管 /sidebar-reader 下所有路径,一个 handler 内按路径分发。
|
|
123
|
+
webCtx.effect(() => server.register({
|
|
124
|
+
kind: "prefix",
|
|
125
|
+
path: "/sidebar-reader",
|
|
126
|
+
handler: async (req, res) => {
|
|
127
|
+
const pathname = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
128
|
+
if (req.method === "GET" || req.method === "HEAD") {
|
|
129
|
+
if (pathname === "/sidebar-reader/health") {
|
|
130
|
+
// 自检端点:模型先探这里判断插件是否活着、状态如何。
|
|
131
|
+
json(res, req, 200, { ok: true, hasSnapshot: latest !== null, hasCommand: pendingCommand !== null });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (pathname === "/sidebar-reader/latest") {
|
|
135
|
+
// 模型读取快照。带 ?refresh=1 时自动触发一轮采集并等它回来:
|
|
136
|
+
// 下发命令 → 每 300ms 检查 latest.commandId 是否对上 → 对上即返回新快照。
|
|
137
|
+
// 模型因此只需一次 GET;不带 refresh 保持原语义(立即返回现有快照)。
|
|
138
|
+
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
139
|
+
const refresh = params.get("refresh") === "1";
|
|
140
|
+
if (!refresh) {
|
|
141
|
+
if (latest === null) json(res, req, 404, { error: "nothing captured yet; add ?refresh=1 to trigger a capture" });
|
|
142
|
+
else json(res, req, 200, latest);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const id = "cmd-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8);
|
|
146
|
+
// delta 同样缺省开;?delta=0 表示这次要全屏。
|
|
147
|
+
pendingCommand = { id, action: "capture", delta: params.get("delta") !== "0", at: new Date().toISOString() };
|
|
148
|
+
const deadline = Date.now() + 10000;
|
|
149
|
+
while (Date.now() < deadline) {
|
|
150
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
151
|
+
if (latest !== null && latest.commandId === id) break;
|
|
152
|
+
}
|
|
153
|
+
// 等到新快照原样返回;超时则返回现有快照并标 stale(模型可据此重试)。
|
|
154
|
+
if (latest === null) json(res, req, 404, { error: "capture timed out; is the GUI window visible?" });
|
|
155
|
+
else json(res, req, 200, { ...latest, stale: latest.commandId !== id });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (pathname === "/sidebar-reader/command") {
|
|
159
|
+
// 客户端领命令:consume-on-read——取出即清空,
|
|
160
|
+
// 保证一条命令恰好被一个轮询周期执行一次。
|
|
161
|
+
const command = pendingCommand;
|
|
162
|
+
pendingCommand = null;
|
|
163
|
+
json(res, req, 200, command ?? { id: null });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
json(res, req, 404, { error: "unknown path; use /latest, /command or /health" });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (req.method === "POST" && pathname === "/sidebar-reader/command") {
|
|
170
|
+
// 模型下发采集命令:本体内容无关紧要,id 才是关键——
|
|
171
|
+
// 客户端执行后把它放进快照,模型据此核对命令↔快照对应。
|
|
172
|
+
const body = await readBody(req, res, 4096);
|
|
173
|
+
if (body === void 0) return;
|
|
174
|
+
pendingCommand = {
|
|
175
|
+
id: "cmd-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8),
|
|
176
|
+
action: "capture",
|
|
177
|
+
// body.delta === false 时才要全屏;缺省增量。
|
|
178
|
+
delta: !(body !== null && body !== void 0 && typeof body === "object" && body.delta === false),
|
|
179
|
+
at: new Date().toISOString()
|
|
180
|
+
};
|
|
181
|
+
json(res, req, 200, { ok: true, id: pendingCommand.id });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (req.method === "POST" && pathname === "/sidebar-reader/latest") {
|
|
185
|
+
// 客户端交快照:逐字段校验/截断后替换 latest。
|
|
186
|
+
// 上限 = 正文上限 ×4(JSON 转义膨胀余量)+ 终端屏文本的空间。
|
|
187
|
+
const body = await readBody(req, res, (MAX_TEXT_CHARS + 4096) * 4);
|
|
188
|
+
if (body === void 0) return;
|
|
189
|
+
const page = body.page !== null && typeof body.page === "object" ? body.page : null;
|
|
190
|
+
const text = page !== null && typeof page.text === "string" ? page.text.slice(0, MAX_TEXT_CHARS) : "";
|
|
191
|
+
latest = {
|
|
192
|
+
page: page === null ? null : {
|
|
193
|
+
title: typeof page.title === "string" ? page.title : "",
|
|
194
|
+
url: typeof page.url === "string" ? page.url : "",
|
|
195
|
+
text,
|
|
196
|
+
chars: text.length
|
|
197
|
+
},
|
|
198
|
+
sidebar: body.sidebar !== null && typeof body.sidebar === "object" ? body.sidebar : null, // 兼容旧版 better-sidebar 工作列字段
|
|
199
|
+
right: body.right !== null && typeof body.right === "object" ? body.right : null,
|
|
200
|
+
terminals: body.terminals !== null && typeof body.terminals === "object" ? body.terminals : null,
|
|
201
|
+
commandId: typeof body.commandId === "string" ? body.commandId : null,
|
|
202
|
+
receivedAt: new Date().toISOString()
|
|
203
|
+
};
|
|
204
|
+
// 回执摘要:客户端 toast 与模型调试都用得上。
|
|
205
|
+
const tabs = latest.sidebar !== null && Array.isArray(latest.sidebar.tabs) ? latest.sidebar.tabs.length : 0;
|
|
206
|
+
const rightSessions = latest.right !== null ? Object.keys(latest.right).length : 0;
|
|
207
|
+
json(res, req, 200, { ok: true, tabs, rightSessions, hasPage: latest.page !== null, chars: latest.page?.chars ?? 0 });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
json(res, req, 405, { error: "use GET/POST /latest, GET/POST /command, GET /health" });
|
|
211
|
+
}
|
|
212
|
+
}), "sidebar-reader: snapshot + command routes");
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { apply };
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-sidebar-reader",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-sidebar-reader",
|
|
3
|
+
"description": "Let the model read the current session's sidebar on demand: the active tab, official right-sidebar tabs, terminal screens and browser page text.",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "LaFantasque520",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/LaFantasque520/dsh-sidebar-reader.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/LaFantasque520/dsh-sidebar-reader#readme",
|
|
14
|
+
"bugs": "https://github.com/LaFantasque520/dsh-sidebar-reader/issues",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"dsh",
|
|
17
|
+
"deepseek-harness",
|
|
18
|
+
"sidebar",
|
|
19
|
+
"terminal",
|
|
20
|
+
"reader"
|
|
21
|
+
],
|
|
22
|
+
"files": [
|
|
23
|
+
"lib",
|
|
24
|
+
"cordis.patch.yml",
|
|
25
|
+
"README.md",
|
|
26
|
+
"README.zh.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./lib/index.js",
|
|
31
|
+
"./client": "./lib/client.js",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"dsh": {
|
|
35
|
+
"bundle": {
|
|
36
|
+
"patch": "./cordis.patch.yml"
|
|
37
|
+
},
|
|
38
|
+
"client": {
|
|
39
|
+
"inject": ["@deepseek-ai/dsh-client-ui-layout", "@deepseek-ai/dsh-api-gateway"],
|
|
40
|
+
"platform": "web"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
45
|
+
"@deepseek-ai/dsh": ">=0.2.1-rc.2 <0.2.2-0 || >=0.2.2-rc.1 <0.3.0-0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@deepseek-ai/dsh": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|