@restregular/dsh-visual-browser 0.0.0-stage → 0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RestRegular
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,124 @@
1
- # Temporary Holding Version
1
+ # dsh-visual-browser
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A DeepSeek Harness plugin that gives the Agent a **real Chrome** and gives you a **window into it**.
4
+
5
+ - The Agent never reads the DOM. It reads a numbered list of *visible interactive
6
+ elements* plus a short text excerpt — a few hundred tokens per page instead of a
7
+ full snapshot.
8
+ - Every action the Agent takes (click, type, key, scroll, navigation) is mirrored
9
+ into a **面板 (panel)** with the page frame, an operation timeline you can replay,
10
+ and a picture you can click to take over the browser yourself.
11
+ - Cookies persist across restarts (one dedicated Chrome profile), so a login the
12
+ Agent performs once keeps working.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ # The plugin is a normal DSH bundle; install it from the registry
18
+ dsh plugin add @restregular/dsh-visual-browser
19
+ ```
20
+
21
+ Or from the Harness UI: **Plugins → Add → `@restregular/dsh-visual-browser`**.
22
+
23
+ Requirements: Google Chrome, Microsoft Edge, or Chromium on the machine
24
+ (auto-detected), and Node.js 22 or newer (the plugin ships no runtime
25
+ dependencies; it talks CDP over the built-in WebSocket).
26
+
27
+ ## Use
28
+
29
+ 1. Click the **浏览器 / Browser** icon in the sidebar to open the panel.
30
+ 2. Ask the Agent something that needs a website, for example
31
+ *"打开 example.com 看看首页写了什么"*. The Agent calls `browser_open`.
32
+ 3. Watch the frame update. Click the picture to click the page; wheel over it to
33
+ scroll; use the toolbar for back / forward / reload / live view / stop.
34
+
35
+ ## Tools the Agent gets
36
+
37
+ | Tool | Purpose |
38
+ | --- | --- |
39
+ | `browser_open` | Open a URL (launches Chrome on first use) and return the numbered view. |
40
+ | `browser_see` | Fresh numbered view of the current page. |
41
+ | `browser_act` | `click` / `type` / `key` / `hover` / `scroll` / `select` / `back` / `forward` / `reload` / `wait` / `close`, then return the new view. |
42
+ | `browser_text` | Read text of the page or of one element (a link also returns its `href`). |
43
+ | `browser_screenshot` | Save a PNG/JPEG to disk and return the path (feed it to `read_image`). |
44
+
45
+ ### What the Agent sees
46
+
47
+ ```
48
+ URL: https://example.com/login
49
+ TITLE: 登录 - Example
50
+ VIEW: 1280x800 scroll 0/2400 · 4/6 interactive
51
+ [1] textbox "手机号" value=13800000000
52
+ [2] textbox "密码" value=••••••
53
+ [3] button "登录"
54
+ [4] link "忘记密码" → /forgot
55
+ HEADINGS: 用户登录 | 没有账号?
56
+ TEXT: 用户登录 手机号 密码 登录 忘记密码
57
+ ACTIVE: [1] textbox "手机号"
58
+ ```
59
+
60
+ Numbers are reassigned on every view, so an action always uses the newest
61
+ numbers; a stale one fails with a clear "take a fresh snapshot" message instead
62
+ of clicking the wrong element.
63
+
64
+ ## Configuration
65
+
66
+ Row config (in the profile's `cordis.patch.yml`, override by row id
67
+ `dsh-visual-browser`):
68
+
69
+ ```yaml
70
+ - id: dsh-visual-browser
71
+ config:
72
+ headless: true # false = visible Chrome window
73
+ executablePath: '' # explicit chrome.exe path
74
+ userDataDir: '' # default: ~/.dsh/visual-browser/chrome-profile
75
+ viewport:
76
+ width: 1280
77
+ height: 800
78
+ maxElements: 100 # cap on the numbered list
79
+ maxTextChars: 320 # cap on the text excerpt
80
+ frameQuality: 62 # JPEG quality of panel frames
81
+ timelineFrames: 24 # replayable frames kept in memory
82
+ allowUserControl: true # allow clicks from the panel
83
+ actionTimeoutMs: 12000
84
+ navigationTimeoutMs: 30000
85
+ ```
86
+
87
+ ## How it works
88
+
89
+ - **Host** (`index.js`, `lib/`): launches Chrome with
90
+ `--remote-debugging-port=0 --user-data-dir=<profile>`, parses the DevTools
91
+ endpoint from stderr, attaches one flattened CDP session, and exposes:
92
+ - five tools through the `tools` service (registration is effect-scoped),
93
+ - a same-origin prefix route `/visual-browser/api` (`/state`, `/frame`,
94
+ `/live`, `/start`, `/stop`, `/capture`, `/click`, `/wheel`, `/key`, `/nav`)
95
+ that the panel polls and posts to.
96
+ - **Snapshot** (`lib/page-scripts.js`): one serialized function runs in the page,
97
+ filters interactive elements to the viewport, assigns `data-dsh-vb-ref`
98
+ numbers, and returns structured JSON. Nothing else about the DOM leaves the
99
+ page.
100
+ - **Frames** stay on the host: the panel displays the newest JPEG by sequence
101
+ number, so a live picture costs no session tokens. The timeline holds the last
102
+ N frames; clicking a row replays that moment.
103
+ - **One code path**: panel clicks, wheel events and keys run the same
104
+ `BrowserManager` methods the tools use.
105
+
106
+ Chrome is killed with its process tree when the plugin unloads.
107
+
108
+ ## Notes and limits
109
+
110
+ - Cross-origin iframes are counted but not inspected; open the direct URL when a
111
+ flow lives inside a frame.
112
+ - Blocking JS dialogs are auto-accepted and logged in the timeline.
113
+ - The panel route is served by the Harness web server on its existing origin;
114
+ it performs no extra authentication, matching the other local panel routes.
115
+ - Headless mode is the default. Some sites behave differently headless; set
116
+ `headless: false` when a site insists on a window.
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ npm test # syntax checks + snapshot/format/route/package smoke tests
122
+ ```
123
+
124
+ MIT © RestRegular