dsh-deepseek-webchat 0.0.0-stage → 0.4.7

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 Ckarefulon
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,414 @@
1
- # Temporary Holding Version
1
+ # dsh-deepseek-webchat
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 [DSH](https://github.com/deepseek-ai) sidebar plugin that shows the **real
4
+ [chat.deepseek.com](https://chat.deepseek.com/) web app** next to your session,
5
+ binds one DeepSeek conversation to each DSH Session, and lets you push selected
6
+ messages into the DeepSeek composer as a blockquote — which you then send
7
+ yourself.
8
+
9
+ No API key, no proxy, no scraping. It embeds the actual website through the
10
+ desktop shell's native browser guest, the same channel DSH's built-in side-card
11
+ browser uses.
12
+
13
+ - [What it does](#what-it-does)
14
+ - [Install](#install)
15
+ - [Using it](#using-it)
16
+ - [Privacy](#privacy)
17
+ - [Known limitations](#known-limitations)
18
+ - [How it works](#how-it-works)
19
+ - [Development](#development)
20
+
21
+ ## What it does
22
+
23
+ | | |
24
+ |---|---|
25
+ | **Real web app** | `chat.deepseek.com` itself, in a sidebar tab. Not an iframe, not the API. |
26
+ | **Login persists** | Sign in once; the plugin restores your session on later launches. |
27
+ | **One conversation per DSH Session** | Each DSH Session gets its own DeepSeek conversation, remembered by id. |
28
+ | **Follows the session you switch to** | Switch DSH Sessions and the sidebar follows to that Session's conversation. |
29
+ | **Manual context push** | Tick rows, add a question, preview it, then fill and send. |
30
+ | **Questions included** | The agent's questions to you, their options, and your answers are quotable too. |
31
+ | **Todo list included** | The agent's todo list is quotable without turning anything on. |
32
+ | **One click to send** | 「填入并发送」 fills the composer and submits it; 「仅填入」 stops there. |
33
+ | **Bulk selection** | Select all, clear, or take the last 5/10/20/50 rows in one click. |
34
+ | **Advanced opt-in** | A switch reveals thinking, tool calls and results — off by default. |
35
+ | **Explained context** | An optional note tells DeepSeek what the quotes are and where they came from. |
36
+ | **No back-flow** | DeepSeek's answers are never written back into your DSH conversation. |
37
+
38
+ ## Install
39
+
40
+ Requires DSH Desktop **0.2.0-rc.1 or newer**, and a profile that is already
41
+ initialised (the `desktop` profile is created by the app on first run).
42
+
43
+ ```bash
44
+ dsh plugin --profile desktop add dsh-deepseek-webchat
45
+ ```
46
+
47
+ Then restart DSH Desktop. The tab appears in the sidebar column's guide, and a
48
+ chat icon in the conversation header opens it directly.
49
+
50
+ `lib/` is committed to this repository on purpose, and there is no `prepare`
51
+ script, so the install needs **no build step and no pnpm `allowBuilds`
52
+ approval**.
53
+
54
+ <details>
55
+ <summary>Installing from a local clone instead</summary>
56
+
57
+ ```bash
58
+ git clone https://github.com/Ckarefulon/dsh-deepseek-webchat
59
+ dsh plugin --profile desktop add /absolute/path/to/dsh-deepseek-webchat
60
+ ```
61
+ </details>
62
+
63
+ <details>
64
+ <summary>Uninstalling</summary>
65
+
66
+ ```bash
67
+ dsh plugin --profile desktop remove dsh-deepseek-webchat
68
+ ```
69
+
70
+ Your bindings and saved login live in `~/.dsh/dsh-deepseek-webchat/` and are
71
+ left in place; delete that directory to remove them too.
72
+ </details>
73
+
74
+ <details>
75
+ <summary>Troubleshooting: DSH will not start after installing</summary>
76
+
77
+ DSH shows **"The application could not start or stopped unexpectedly"** and
78
+ refuses to open. The crash log (the path is shown in the dialog, under
79
+ `%APPDATA%\@deepseek-ai\dsh-desktop\logs\`) contains
80
+ `client-modules: client bundle not found`.
81
+
82
+ That means the installed copy's `exports["./client"]` does not point at a real
83
+ file. Fix it by reinstalling the plugin from a commit that has the flat layout:
84
+
85
+ ```bash
86
+ dsh plugin --profile desktop remove dsh-deepseek-webchat
87
+ dsh plugin --profile desktop add dsh-deepseek-webchat
88
+ ```
89
+
90
+ To confirm the layout before restarting, from the installed package directory:
91
+
92
+ ```bash
93
+ node -e "const p=require('./package.json');const r=p.exports['./client'].default;console.log(r, require('fs').existsSync(r))"
94
+ ```
95
+
96
+ It must print `./lib/client.js true`. If it prints `false`, do not restart DSH —
97
+ the boot will abort again.
98
+
99
+ The dialog's *"Disable third-party plugins, back up profile patch, and
100
+ restart"* button also works: it starts DSH with third-party plugins unmounted
101
+ and saves your profile patch alongside as `cordis.patch.yml.bak-<timestamp>`.
102
+ That backup is your configuration, not the plugin, so keep it.
103
+ </details>
104
+
105
+ ## Using it
106
+
107
+ 1. **Open the tab.** Click the chat icon in the conversation header, or pick
108
+ 「DeepSeek 网页版」 from the sidebar column's guide.
109
+ 2. **Sign in** to DeepSeek the first time. It is a normal browser login, inside
110
+ the panel.
111
+ 3. **Send one message** in the DeepSeek page. DeepSeek creates a conversation
112
+ lazily, so this is the moment its id exists — the plugin notices and binds it
113
+ to the current DSH Session. The toolbar dot turns green.
114
+ 4. **Quote context.** Press 「引用上下文」. The list opens scrolled to the newest
115
+ rows. Tick what you want — or use 「全选」, 「清除」, or the number box plus
116
+ 「选末尾」 to take the last few in one go — optionally type a question or
117
+ instruction, and check the preview. The list holds your turns, the assistant's
118
+ replies, **the agent's todo list**, **the questions it asked you** (with the
119
+ options it offered), and **your answers** to them.
120
+ 5. **Press 「填入并发送」.** The text goes into DeepSeek's composer and is
121
+ submitted for you; the panel returns to the page and the selection clears, so
122
+ the next push starts from a clean slate. Use 「仅填入」 instead if you would
123
+ rather read it over in the composer first.
124
+ 6. **That is the send.** The plugin watches the composer to confirm it went out,
125
+ and says so — or tells you plainly that it did not, so you can press Enter
126
+ there yourself.
127
+
128
+ The toolbar also has 「刷新」 (reload the page) and 「解除绑定」 (forget this
129
+ Session's conversation, so the next visit starts a new one).
130
+
131
+ Switching to a different DSH Session moves the panel to *that* Session's
132
+ conversation automatically.
133
+
134
+ ### What gets sent, and how
135
+
136
+ Every push is still something you asked for: the plugin fills the composer and
137
+ submits it **only** when you click 「填入并发送」. There is no timer, no
138
+ background upload, and nothing is sent merely because the panel is open.
139
+
140
+ Sending goes through DeepSeek's own composer handler rather than a synthetic
141
+ shortcut invented here. Its composer runs an `onKeyDown` that, for a plain
142
+ Enter, calls the same function its send button calls — so the plugin dispatches
143
+ a bubbling Enter at the textarea and lets DeepSeek do the rest. (Its button's
144
+ class name is a build-time hash, so guessing at it would break on any rebuild.)
145
+
146
+ Because a synthetic key press could in principle be ignored, the plugin does not
147
+ assume it worked. DeepSeek clears its textarea once a send is accepted, so the
148
+ plugin reads the composer back: cleared means sent. If it still holds text, the
149
+ plugin falls back to clicking DeepSeek's own send button, and if that fails too
150
+ it says so instead of pretending — leaving the text sitting in the composer for
151
+ you to send by hand.
152
+
153
+ **「附上说明」** (on by default) puts a short note in front of the quoted rows:
154
+
155
+ > 以下是我在另一个 AI 助手(DSH)里的对话片段,引用给你作为背景参考。以「> 」
156
+ > 开头的行是原文,【】里标出的是这段内容属于谁…
157
+
158
+ Without it, DeepSeek receives a wall of quotes and 【】 labels with no
159
+ explanation of what they are. Turn it off if you would rather send the raw
160
+ quotes.
161
+
162
+ ### The advanced switch
163
+
164
+ By default the picker lists the conversation as a person reads it, plus the
165
+ agent's todo list. Tick **「高级:包含思考过程与工具调用」** to also list the
166
+ machinery behind it: the model's reasoning blocks, its tool calls, the tool
167
+ results, slash commands, and compaction summaries — including tool output that
168
+ may contain file contents. It is off on every open, and the host does the
169
+ filtering, so an advanced row is never even sent to the browser unless you asked
170
+ for it.
171
+
172
+ Each row is marked with an icon from the shell's own icon set plus a short
173
+ label, so a quoted answer and a quoted tool result stay distinguishable in the
174
+ blockquote:
175
+
176
+ ```
177
+ > 【提问】Confirm:Which layout?
178
+ > · Sidebar — right column
179
+ > · Center
180
+ > 【回答】Sidebar, please
181
+ > 【待办】[x] write the picker
182
+ > [~] test it
183
+ ```
184
+
185
+ ## Privacy
186
+
187
+ This plugin is built so that **nothing leaves your machine unless you press a
188
+ button**, and so that the things you would least want to leak are never even
189
+ offered.
190
+
191
+ **What is sent, and when.** Only the rows you tick, and only when you click
192
+ 「填入并发送」 (or 「仅填入」, which stops at the composer). Both are explicit
193
+ actions; the plugin has no timer and no background upload.
194
+
195
+ **What is never offered.** The host half filters the session log before it
196
+ reaches the picker, dropping in **both** modes:
197
+
198
+ - `system/message` and `developer/message` events,
199
+ - **injected `user/message` events** — agent instructions, skill catalogs, goal
200
+ rounds, time context, compaction checkpoints, team and webhook deliveries,
201
+ which DSH records as user messages but which you never typed. Only events whose
202
+ `source.kind` is `user` (your turns) or `user-question-reply` (your answers to
203
+ the agent) are treated as yours,
204
+ - approval records, request headers, model and sandbox selections.
205
+
206
+ **What is off by default.** The model's private reasoning blocks, tool calls and
207
+ tool results are **not** offered until you turn on the advanced switch. When you
208
+ do, remember that a tool result can contain file contents the agent read — that
209
+ is exactly the kind of thing the default set keeps out, and the switch is your
210
+ explicit say-so. A todo list is the exception: it is the agent's own plan, which
211
+ you are already reading on screen, so it is offered by default.
212
+
213
+ So a system prompt, an API key in your environment, or a file the agent read
214
+ cannot be quoted by accident.
215
+
216
+ **What is stored locally.** Two JSON files in `~/.dsh/dsh-deepseek-webchat/`:
217
+
218
+ - `bindings.json` — the DSH Session id → DeepSeek conversation id map. No message
219
+ content, ever.
220
+ - `session.json` — the guest's DeepSeek login state (its site storage and
221
+ non-HttpOnly cookie string), so you stay signed in. This is a **credential**;
222
+ treat the file as you would a browser profile. It is written with the same
223
+ permissions as any other file your user creates.
224
+
225
+ **No telemetry.** The plugin makes no network request of its own. The only
226
+ traffic is the DeepSeek web app talking to DeepSeek, inside its own guest.
227
+
228
+ **The page runs sandboxed.** The desktop shell approves the guest with
229
+ `nodeIntegration: false`, `contextIsolation: true`, `sandbox: true` and
230
+ `webSecurity: true`, and refuses every permission request. The page cannot reach
231
+ your files or your DSH process.
232
+
233
+ ## Known limitations
234
+
235
+ These are real, and worth knowing before you rely on the plugin.
236
+
237
+ **HttpOnly cookies cannot be restored.** The DSH Host runs as a separate Node
238
+ child process, not inside Electron, so the plugin cannot reach Electron's cookie
239
+ store. It can only read `document.cookie` from inside the guest, and HttpOnly
240
+ cookies are invisible there by design. In practice DeepSeek keeps its credential
241
+ in `localStorage.userToken` and sends it as a bearer token, so replaying site
242
+ storage is what restores your login — but if DeepSeek ever moves its credential
243
+ to an HttpOnly cookie, this plugin will start asking you to sign in again after
244
+ each restart.
245
+
246
+ **The guest partition is per-run.** The shell hands out a process-lifetime
247
+ session partition and the plugin cannot ask for a different one. Login survival
248
+ is therefore the snapshot-and-replay above, not a persistent browser profile.
249
+
250
+ **One DeepSeek login, shared.** Every DSH Session shares a single DeepSeek
251
+ account and browser session; the per-Session split is the conversation, not the
252
+ login. Separate DSH Sessions do **not** get separate DeepSeek accounts.
253
+
254
+ **Binding happens on the first message.** DeepSeek creates a conversation only
255
+ when you send something, so a DSH Session stays unbound until you send at least
256
+ one message in the page. Until then the toolbar dot is hollow.
257
+
258
+ **DeepSeek can change its page.** The composer fill targets
259
+ `textarea.ds-textarea__textarea`, and the conversation id is read from DeepSeek's
260
+ `/a/<agent>/s/<id>` route. If DeepSeek redesigns either, the fill or the binding
261
+ stops working until this plugin is updated. The rest of the plugin — embedding,
262
+ login, per-Session tabs — is unaffected.
263
+
264
+ **Desktop only.** The embedded page needs the desktop browser guest channel. In
265
+ a plain `dsh web` profile the panel says so instead of falling back to an iframe
266
+ (which DeepSeek would refuse anyway, via `frame-ancestors 'none'`).
267
+
268
+ **One DeepSeek tab per DSH Session.** The tab kind is single-instance, so you
269
+ cannot open two DeepSeek panels side by side for the same Session.
270
+
271
+ ## How it works
272
+
273
+ <details>
274
+ <summary>Architecture</summary>
275
+
276
+ Two halves, as DSH plugins are:
277
+
278
+ **Host half** (`lib/index.js`, exports `.`) runs in the DSH Host process and
279
+ serves five routes under `/api/dsh-deepseek-webchat/`:
280
+
281
+ | Route | Purpose |
282
+ |---|---|
283
+ | `state` | What the panel needs to describe itself. |
284
+ | `messages?sessionId=[&advanced=1]` | The Session's quotable rows, filtered. |
285
+ | `binding` | Read/write/forget the DSH→DeepSeek conversation map. |
286
+ | `session/restore` | Hand back the saved login state. |
287
+ | `session/save` | Store the guest's login state. |
288
+
289
+ It reads messages through `ctx.sessionQuery.readSession()`, which is
290
+ live-preferred, and reduces the raw event log with the same text-extraction
291
+ rules the harness itself uses.
292
+
293
+ The `advanced` flag is honoured **host-side**, so the default response never
294
+ contains a reasoning or tool row at all — the browser half cannot accidentally
295
+ reveal one it was never given. The picker re-requests the list when the switch
296
+ flips rather than filtering locally.
297
+
298
+ Rows carry a `kind` alongside `role`: `user` and `assistant` for dialogue,
299
+ `question` and `answer` for the agent's questions and your replies (default),
300
+ then `reasoning`, `tool-call`, `tool-result`, `todo`, `command` and `summary`
301
+ (advanced). A `question` row is read from the `tool/call` event whose
302
+ `name === 'ask_user_question'`, parsed with the same `questionsOf` shape the
303
+ harness's own user-questions service uses; the answer arrives as an ordinary
304
+ `user/message` tagged `source.kind === 'user-question-reply'`, which the plain
305
+ human filter would otherwise drop.
306
+
307
+ **Browser half** (`lib/client.js`, exports `./client`) registers the sidebar tab
308
+ type, its body, and a header door.
309
+
310
+ **The guest, and why it is not an iframe.** `chat.deepseek.com` sends
311
+ `Content-Security-Policy: frame-ancestors 'none'`, so an `<iframe>` is refused by
312
+ the page. Instead the bundle asks `globalThis.dshDesktop.browser.acquire(...)`
313
+ for a reservation and attaches a `<webview>` whose `src` is `about:blank#<lease>`
314
+ and whose `partition` is the issued one. The shell's `will-attach-webview`
315
+ matches the lease, applies hardened preferences, and lets the navigation
316
+ through.
317
+
318
+ **Why the guest lives outside React.** A `<webview>` is destroyed when it leaves
319
+ the document, so a slot-owned guest would reload on every tab switch — losing a
320
+ half-typed question. The element instead lives in a container the plugin owns at
321
+ the document root, and the panel body only measures its area; the guest is
322
+ positioned onto that rectangle while the tab shows and hidden when it does not.
323
+ The tab type declares `keepMounted: true` so the body survives switches.
324
+
325
+ **Why the conversation URL works.** DeepSeek's own routes are
326
+ `/a/:agentId/s/:sessionId`, and the default agent is `chat`, so a conversation is
327
+ addressable as `https://chat.deepseek.com/a/chat/s/<id>` — no in-page JavaScript
328
+ is needed to reopen one.
329
+ </details>
330
+
331
+ ## Development
332
+
333
+ Plain JavaScript ESM. No TypeScript, no bundler, no dependencies.
334
+
335
+ ```bash
336
+ npm run build # copy src/ -> lib/
337
+ npm test # node --test
338
+ ```
339
+
340
+ `lib/` is a byte-for-byte copy of `src/` and **is committed**, because a
341
+ git-hosted plugin must not need a build step on install. `npm test` asserts the
342
+ two still match, so they cannot drift.
343
+
344
+ After editing `src/`, run `npm run build` and commit both trees.
345
+
346
+ ```
347
+ src/index.js host half -> lib/index.js
348
+ src/client/index.js browser half -> lib/client.js (note: flat, not lib/client/index.js)
349
+ scripts/build.mjs the copy
350
+ test/index.test.js host: urls, message filtering, bindings, snapshot, mirror
351
+ test/routes.test.js host: every HTTP route, driven through apply()
352
+ test/client.test.js browser: bundle load, registrations, fill + send, row icons
353
+ ```
354
+
355
+ ### Two checks worth running before a restart
356
+
357
+ A broken manifest does not fail loudly at build time — it aborts the Host boot,
358
+ so DSH simply never opens. Both checks are standalone: no dependencies, no
359
+ `node_modules`, nothing to install.
360
+
361
+ ```bash
362
+ npm run check:bundle # this repo
363
+ node scripts/check-client-bundle.mjs <packageRoot> # any DSH plugin
364
+ node scripts/check-profile-patch.mjs <patch.yml>
365
+ ```
366
+
367
+ **`check-client-bundle.mjs`** replicates `resolveMeta()` from
368
+ `@deepseek-ai/dsh-client-modules` verbatim: it joins `exports["./client"]` onto
369
+ the package root and calls `statSync` on the result, with no extension
370
+ completion and no directory-index fallback. A missing file throws
371
+ `MissingClientBundleError`, and because `modules` is a required plugin the whole
372
+ Host boot aborts. It also checks the neighbouring invariants — that the bundle
373
+ declares its own `module`/`exports` (the loader passes `require` only), returns
374
+ `module.exports`, and registers its own id. This is the check that reproduces
375
+ the startup abort on the old `lib/client/index.js` layout.
376
+
377
+ **`check-profile-patch.mjs`** parses a profile `cordis.patch.yml` the way the
378
+ loader must: YAML with the `!!js` custom tag treated as an opaque scalar. It
379
+ prints every entry id, so a patch can be reviewed before it is trusted — which
380
+ is what you need after DSH's crash dialog has replaced a full patch with a
381
+ minimal one. js-yaml is not a dependency of this repo; it is resolved from an
382
+ installed DSH profile, or point `DSH_JS_YAML` at one.
383
+
384
+ ### Why the browser half is `lib/client.js` and not `lib/client/index.js`
385
+
386
+ This is load-bearing, and getting it wrong makes DSH fail to start at all.
387
+
388
+ DSH resolves a package's browser half by joining `exports["./client"]` onto the
389
+ package root and reading the result as an **exact file path** — there is no
390
+ extension and no directory-index fallback. If the manifest says
391
+ `./lib/client.js` while the build writes `./lib/client/index.js`, the client
392
+ module registry throws `MissingClientBundleError` while the Host is starting,
393
+ and because that registry is a *required* plugin the whole boot aborts. The
394
+ window shows "The application could not start or stopped unexpectedly" and
395
+ names `client-hmr` as waiting on `clientModules`; the crash log reports:
396
+
397
+ ```
398
+ client-modules: client bundle not found; run `pnpm run build` before launch:
399
+ package: <name>
400
+ path: .../lib/client.js
401
+ ```
402
+
403
+ Every package DSH ships uses the flat `./lib/client.js` form. `npm test` asserts
404
+ that every path in `exports` exists and is a regular file, so this cannot
405
+ regress.
406
+
407
+ If you hit that dialog, your installed copy is stale. Reinstall (see
408
+ [Install](#install)) after pulling the fixed commit.
409
+
410
+ ## License
411
+
412
+ MIT. See [LICENSE](LICENSE).
413
+
414
+ Not affiliated with DeepSeek. "DeepSeek" is a trademark of its owner.
@@ -0,0 +1,20 @@
1
+ # dsh-deepseek-webchat bundle patch: inserts the dual-face plugin row into a
2
+ # profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
3
+ # manifest field) over dsh-base; activate by adding this package to the
4
+ # profile's `dsh.profile.bundles`, or with
5
+ # dsh plugin --profile desktop add dsh-deepseek-webchat
6
+ #
7
+ # The row is a bare plugin by package name: the node half (exports ".") runs in
8
+ # the Host process and serves this plugin's /api/dsh-deepseek-webchat routes,
9
+ # and the `dsh.client` declaration in package.json makes the browser half
10
+ # (exports "./client", served at /plugins/<id>/client.js) load in the Web GUI as
11
+ # the sidebar tab type and its panel. `name` must be this package's manifest
12
+ # name verbatim (scoped names included) — dsh-client-modules keys every browser
13
+ # row by it, and lib/client.js registers its factory under the same id.
14
+ # `id` is the profile entry id; keep it stable because DSH also uses it as the
15
+ # settings-form namespace. It must be unique per profile: a second package
16
+ # inserting the same `deepseek-webchat` id cannot be installed alongside this
17
+ # one — the duplicate is rejected at boot.
18
+ - insert:
19
+ - id: deepseek-webchat
20
+ name: 'dsh-deepseek-webchat'