@linxin666/dsh-client-ui-browser-view 0.0.0-stage → 0.4.10
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 +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +77 -2
- package/README.zh.md +78 -0
- package/cordis.patch.yml +7 -0
- package/lib/client.js +974 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +10555 -0
- package/lib/types/client/guide-icon.d.ts +21 -0
- package/lib/types/client/index.d.ts +51 -0
- package/lib/types/client/live-title.d.ts +39 -0
- package/lib/types/client/locales.d.ts +37 -0
- package/lib/types/client/panel.d.ts +28 -0
- package/lib/types/client/semantic.d.ts +37 -0
- package/lib/types/client/socket.d.ts +114 -0
- package/lib/types/client/tab-title.d.ts +17 -0
- package/lib/types/client/tab-type.d.ts +59 -0
- package/lib/types/core/actions.d.ts +112 -0
- package/lib/types/core/cdp.d.ts +95 -0
- package/lib/types/core/chrome.d.ts +209 -0
- package/lib/types/core/protocol.d.ts +179 -0
- package/lib/types/core/snapshot.d.ts +106 -0
- package/lib/types/core/tabs.d.ts +229 -0
- package/lib/types/host/auth.d.ts +52 -0
- package/lib/types/host/loopback.d.ts +64 -0
- package/lib/types/host/routes.d.ts +73 -0
- package/lib/types/host/service.d.ts +395 -0
- package/lib/types/host/tools.d.ts +64 -0
- package/lib/types/index.d.ts +31 -0
- package/package.json +81 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
+
README.md: b6c760a30f95ca01bc83e3f92039e5f4b269efd9
|
|
6
|
+
README.zh.md: e9b466b7d035cce4ff51a8e2e35f64fff6ac693e
|
package/README.md
CHANGED
|
@@ -1,3 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-browser-view · Live Browser View for DeepSeek Harness (DSH)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
7
|
+
|
|
8
|
+
<img src="https://img.shields.io/badge/license-BSD--3--Clause-blue?style=flat-square" alt="License">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
> A browser the agent drives, watched from a tab beside the chat. The host half owns a dedicated Chromium over the devtools protocol; the browser half contributes one right-sidebar tab type, so the page stays in view while the agent verifies it.
|
|
12
|
+
|
|
13
|
+
This package is an external plugin for DeepSeek Harness (DSH), structured as a cordis bundle: `src/index.ts` is the host half (Chrome process, CDP sessions, tab registry, WebSocket fan-out, agent tools) and `src/client/` is the browser half (the sidebar tab body and its chip).
|
|
14
|
+
|
|
15
|
+
## What it does
|
|
16
|
+
|
|
17
|
+
- **A live tab, not a screenshot poll**: CDP `Page.startScreencast` frames arrive over one WebSocket and are painted as they come. The tab shows the active page, its URL and title, and what the agent last did.
|
|
18
|
+
- **Eleven agent tools**: `browser_navigate`, `browser_click`, `browser_type`, `browser_press`, `browser_scroll`, `browser_snapshot`, `browser_screenshot`, `browser_console`, `browser_network`, `browser_tabs`, `browser_close` (closes only the tabs this session opened).
|
|
19
|
+
- **Evidence in the conversation**: every `browser_screenshot` result carries the image, so the transcript keeps the picture the agent acted on instead of only a sentence about it.
|
|
20
|
+
- **One dedicated browser**: the plugin launches its own Chromium with a throwaway profile. It never attaches to a browser you are signed into.
|
|
21
|
+
- **Signs itself in to this host's own GUI**: a fresh profile has no session cookie, so the viewer would only ever see the 401 challenge. When a navigation lands on that challenge over loopback, the plugin asks the host's connection service for the same ticketed URL `dsh web` printed, and retries once. The cookie that mints lives in the throwaway profile and dies with it.
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
agent tool call ──► host half ──► CDP ──► dedicated Chromium
|
|
27
|
+
│
|
|
28
|
+
└─ screencast frames ──► WebSocket ──► sidebar tab body
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The host half starts Chrome lazily on the first tool call or the first tab mount, pins a viewport, and keeps a ring of console entries and network requests per tab so a verification can be read back without re-running the page. A top-level document replacement clears both rings; a same-document navigation (hash, query, SPA pushState) keeps them.
|
|
32
|
+
|
|
33
|
+
## Interface seats
|
|
34
|
+
|
|
35
|
+
| Seat | Kind | What lands there |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `sidebar.right.pane.tab` | keyed, session | the tab body |
|
|
38
|
+
| `sidebar.right.pane.tab.title` | keyed, session | the chip text and glyph |
|
|
39
|
+
|
|
40
|
+
The conversation header carries no entry for this tab: the column's own tab strip and the guide capsule already open it, and a third place to click was only crowding that row.
|
|
41
|
+
|
|
42
|
+
The tab type is registered with `ctx.sidebarRightTabs.register` and opened with `ctx.sidebarRight.openTabIn`. Its kind is `browser-view`, deliberately **not** `browser`: the shipped `@deepseek-ai/dsh-client-ui-sidebar-browser` owns that kind, and a second registration in the extension band takes a kind over, which would shadow the shipped tab out of existence.
|
|
43
|
+
|
|
44
|
+
The single-occupant `rightbar` / `rightbar.session` seats are still not touched: they belong to the column itself, not to the tabs inside it.
|
|
45
|
+
|
|
46
|
+
## Security model
|
|
47
|
+
|
|
48
|
+
- **Loopback only**: the panel socket is fenced to loopback requests; a non-local client is rejected before the upgrade.
|
|
49
|
+
- **Throwaway profile**: Chrome runs on a fresh `--user-data-dir` under the system temp directory with a random debugging port, so no cookie, session or extension of the user's real browser is reachable.
|
|
50
|
+
- **Headless by default**: nothing pops up on the desktop; the tab is the only view.
|
|
51
|
+
- **Process lifetime**: the Chromium child is killed when the plugin disposes. Nothing is left running behind a closed session.
|
|
52
|
+
- **Token handling**: the launch token is minted per navigation, held in memory, and never written to disk; the retry only happens on a loopback target whose document is DSH's own challenge, so no other local service is ever handed the token.
|
|
53
|
+
|
|
54
|
+
## Known limits
|
|
55
|
+
|
|
56
|
+
- The tab is a **view**. Input comes from the agent through the tools; it does not forward your mouse or keyboard.
|
|
57
|
+
- The tab lives inside the right sidebar, so it needs that column; a layout that hides the column hides the tab.
|
|
58
|
+
- Frames are produced when the page changes, so a static page holds the last frame instead of streaming duplicates.
|
|
59
|
+
- Switching chips keeps the body mounted (`keepMounted`), so the socket survives; the frame still waits for the next change.
|
|
60
|
+
- The token top-up only covers the site root, because DSH answers the challenge with a 303 to `./` for `GET /` alone.
|
|
61
|
+
- One browser process per host; tabs are isolated CDP targets, not separate profiles.
|
|
62
|
+
- Chrome must be installed at a standard location (or named by `CHROME_PATH`).
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
dsh plugin --profile web add link:<this repo>/packages/dsh-browser-view
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The plugin row is read at startup, so a DSH restart is required after installing or changing it.
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view typecheck
|
|
76
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view test
|
|
77
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view build
|
|
78
|
+
```
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# dsh-browser-view · DSH Web GUI 的实时浏览器视图
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
7
|
+
|
|
8
|
+
<img src="https://img.shields.io/badge/license-BSD--3--Clause-blue?style=flat-square" alt="License">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
> agent 驱动的那个浏览器,从对话旁边的标签页里看着。宿主半区用 devtools 协议掌管一个独立 Chromium,浏览器半区贡献一个右侧栏标签页类型,于是页面在验证的当下就在眼前。
|
|
12
|
+
|
|
13
|
+
本包是 DeepSeek Harness(DSH)的外部插件,形态是 cordis bundle:`src/index.ts` 是宿主半区(Chrome 进程、CDP 会话、标签页登记、WebSocket 分发、agent 工具),`src/client/` 是浏览器半区(右栏标签页内容与它的 chip)。
|
|
14
|
+
|
|
15
|
+
## 它能做什么
|
|
16
|
+
|
|
17
|
+
- **实时标签页,不是定时截图**:CDP `Page.startScreencast` 的帧经一条 WebSocket 送来,来一帧画一帧。标签页显示当前页面、URL 与标题,以及 agent 最近做了什么。
|
|
18
|
+
- **十一个 agent 工具**:`browser_navigate`、`browser_click`、`browser_type`、`browser_press`、`browser_scroll`、`browser_snapshot`、`browser_screenshot`、`browser_console`、`browser_network`、`browser_tabs`、`browser_close`(只关本会话自己打开的标签页)。
|
|
19
|
+
- **证据留在对话里**:每次 `browser_screenshot` 的结果都带图,于是对话记录保留的是 agent 真正看到的那一屏,而不只是一句转述。
|
|
20
|
+
- **一个专用浏览器**:插件自己拉起 Chromium,用一次性 profile。它不会接管你已经登录的浏览器。
|
|
21
|
+
- **能进这台机器自己的 GUI**:全新 profile 没有会话 cookie,本来只会看到 401 提示页。当导航落在 loopback 上的那页提示时,插件向宿主的连接服务要一条与 `dsh web` 启动时打印的同样的带票 URL,补一次。种下的 cookie 只活在这个一次性 profile 里,随它一起销毁。
|
|
22
|
+
|
|
23
|
+
## 工作原理
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
agent 工具调用 ──► 宿主半区 ──► CDP ──► 专用 Chromium
|
|
27
|
+
│
|
|
28
|
+
└─ 投屏帧 ──► WebSocket ──► 右栏标签页内容
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
宿主半区在第一次工具调用或第一次挂载标签页时才懒启动 Chrome,钉住视口尺寸,并按标签页保留控制台与网络请求的环形记录,因此一次验证不必重跑页面就能回读。顶层文档被替换时两份记录都会清空;同文档导航(hash、query、SPA pushState)则保留。
|
|
32
|
+
|
|
33
|
+
## 界面席位
|
|
34
|
+
|
|
35
|
+
| 席位 | 类型 | 放什么 |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| `sidebar.right.pane.tab` | keyed,session | 标签页内容 |
|
|
38
|
+
| `sidebar.right.pane.tab.title` | keyed,session | chip 的文字与图标 |
|
|
39
|
+
|
|
40
|
+
会话头部不再为该标签页提供入口:右栏自己的 tab strip 与 guide 胶囊已经能打开它,再加第三个入口只是挤占那一行。
|
|
41
|
+
|
|
42
|
+
标签页类型经 `ctx.sidebarRightTabs.register` 注册,用 `ctx.sidebarRight.openTabIn` 打开。它的 kind 是 `browser-view`,**刻意不是** `browser`:官方 `@deepseek-ai/dsh-client-ui-sidebar-browser` 占用了那个 kind,而 extension 档位会接管同名 kind,复用等于把官方那个标签页顶掉。
|
|
43
|
+
|
|
44
|
+
单占位的 `rightbar` / `rightbar.session` 仍然不碰:它们属于那一栏本身,不属于栏里的标签页。
|
|
45
|
+
|
|
46
|
+
## 安全模型
|
|
47
|
+
|
|
48
|
+
- **仅限 loopback**:面板 socket 以 loopback 围栏,非本机来源在升级之前就被拒绝。
|
|
49
|
+
- **一次性 profile**:Chrome 跑在系统临时目录下全新的 `--user-data-dir` 上,调试端口随机,用户真实浏览器的 cookie、会话与扩展都够不着。
|
|
50
|
+
- **默认无头**:桌面上不会弹出窗口,标签页是唯一的可见视图。
|
|
51
|
+
- **进程寿命**:插件卸载时杀掉 Chromium 子进程。会话关掉之后不会留下还在跑的东西。
|
|
52
|
+
- **令牌处理**:启动令牌每次导航现取、只在内存里,从不落盘;补票只发生在 loopback 目标且文档确实是 DSH 自己的鉴权页时,因此令牌不会被交给别的本地服务。
|
|
53
|
+
|
|
54
|
+
## 已知限制
|
|
55
|
+
|
|
56
|
+
- 标签页只是**视图**。输入来自 agent 的工具调用,不转发你的鼠标与键盘。
|
|
57
|
+
- 标签页住在右侧栏里,因此需要那一栏存在;布局把栏收起来时它也一起不可见。
|
|
58
|
+
- 帧在页面变化时才产生,静态页面停留在最后一帧,而不是重复推流。
|
|
59
|
+
- 切换 chip 时内容保持挂载(`keepMounted`),socket 不会断;画面仍等下一次变化。
|
|
60
|
+
- 补票只覆盖站点根地址,因为 DSH 只在 `GET /` 时以 303 回应鉴权提示。
|
|
61
|
+
- 一个宿主一个浏览器进程;标签页是相互隔离的 CDP target,不是独立 profile。
|
|
62
|
+
- Chrome 需装在标准位置,或用 `CHROME_PATH` 指定。
|
|
63
|
+
|
|
64
|
+
## 安装
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
dsh plugin --profile web add link:<this repo>/packages/dsh-browser-view
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
插件行只在启动时读取,因此安装或改动之后需要重启一次 DSH。
|
|
71
|
+
|
|
72
|
+
## 开发
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view typecheck
|
|
76
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view test
|
|
77
|
+
pnpm --filter @linxin666/dsh-client-ui-browser-view build
|
|
78
|
+
```
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# bundle patch for the browser-view plugin: inserts its plugin row into the web
|
|
2
|
+
# profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
|
|
3
|
+
# manifest field); install with
|
|
4
|
+
# `dsh plugin --profile web add link:<this repo>/packages/dsh-browser-view`.
|
|
5
|
+
- insert:
|
|
6
|
+
- id: ui-browser-view
|
|
7
|
+
name: '@linxin666/dsh-client-ui-browser-view'
|