@tianyulinfeng1/dsh-plugin-deepseek-chat 0.0.0-stage → 1.1.1
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/CHANGELOG.md +67 -0
- package/LICENSE +21 -0
- package/README.en.md +166 -0
- package/README.md +186 -3
- package/cordis.patch.yml +6 -0
- package/docs/RELEASE_NOTES_v1.1.1.md +64 -0
- package/docs/login-persistence.md +187 -0
- package/docs/screenshot.png +0 -0
- package/icon.svg +11 -0
- package/lib/client.js +942 -0
- package/lib/index.js +9 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +67 -6
- package/scripts/patch-dsh-persistent-partition.cjs +174 -0
- package/scripts/patch-dsh-persistent-partition.mjs +16 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
## 1.1.1 — 2026-11-09
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Switching panels/sessions no longer asks for a fresh QR scan.** v1.1.0 keyed the
|
|
10
|
+
desktop guest partition to the asynchronous DSH account probe. DSH's
|
|
11
|
+
`getState()` can transiently fail during a reconnect, so the partition changed
|
|
12
|
+
and handed the panel a brand-new cookie jar. The guest workspace is now the
|
|
13
|
+
constant `panel:deepseek-chat` and the conversation key is the constant
|
|
14
|
+
`dsh-plugin-deepseek-chat:last-url`.
|
|
15
|
+
- The DSH account status strip is now **display only**: it never feeds the lease
|
|
16
|
+
identity, an epoch, or the guest lifecycle. A transient `unknown` is ignored;
|
|
17
|
+
only a confirmed `signed-out` updates the strip.
|
|
18
|
+
- The guest starts on mount immediately instead of waiting for the async account
|
|
19
|
+
Remote, so a failed/late probe never blocks chat.
|
|
20
|
+
|
|
21
|
+
### Documentation
|
|
22
|
+
|
|
23
|
+
- Documented, with source evidence, why a pure plugin **cannot** make
|
|
24
|
+
`chat.deepseek.com` reuse the already-signed-in DSH account: the two use
|
|
25
|
+
different credentials (Platform `x-dsh-auth-token` vs the site's own Token),
|
|
26
|
+
the renderer bridge exposes no token/cookie API, and the archive has no SSO or
|
|
27
|
+
cookie-injection entry point.
|
|
28
|
+
- Reworked `docs/login-persistence.md` around the upstream
|
|
29
|
+
`docs/patch-dsh-persistent-partition.cjs`: DSH `0.2.1-rc.3+` (including
|
|
30
|
+
`0.2.2-rc.1`) ships per-file SHA256 **ASAR integrity**, so the patch must
|
|
31
|
+
recompute and sync `lib/main.js`'s hash. A byte-only replacement would crash
|
|
32
|
+
DSH on restart with "ASAR Integrity Violation".
|
|
33
|
+
- Added `scripts/patch-dsh-persistent-partition.cjs` (upstream script: equal-length
|
|
34
|
+
replacement, integrity re-sync, full-archive verification, `--dry-run`,
|
|
35
|
+
idempotency, automatic backup). The earlier byte-only `.mjs` script is
|
|
36
|
+
deprecated and now fails loudly.
|
|
37
|
+
|
|
38
|
+
### Verification
|
|
39
|
+
|
|
40
|
+
- Offline self-check: 35 cases, all passing (fixed partition, no rebuild on
|
|
41
|
+
account-state churn, partition reuse across panel switches, envelope parsing,
|
|
42
|
+
crash containment, popup allowlist).
|
|
43
|
+
- `app.asar` patch verified independently: 20519 files, 0 integrity failures;
|
|
44
|
+
`lib/main.js` header hash matches the actual SHA256 of the patched bytes.
|
|
45
|
+
|
|
46
|
+
### Packaging
|
|
47
|
+
|
|
48
|
+
- Published to npm as **`@tianyulinfeng1/dsh-plugin-deepseek-chat`** (the
|
|
49
|
+
registry name this project owns). `package.json` and `cordis.patch.yml` now
|
|
50
|
+
carry that scoped package name so an npm-installed copy mounts under the same
|
|
51
|
+
`deepseek-chat` bundle id; the GitHub install routes (`github:sweet560/...`)
|
|
52
|
+
are unchanged.
|
|
53
|
+
|
|
54
|
+
## 1.1.0 — 2026-11-09
|
|
55
|
+
|
|
56
|
+
- Added support for DSH `0.2.2-rc.1` (`engines.dsh >=0.2.2-rc.1`).
|
|
57
|
+
- Added a DSH account status strip via the official `ctx.remote.account` Remote
|
|
58
|
+
(correct generated `{ ok, value }` envelope parsing).
|
|
59
|
+
- Tightened conversation and popup URL validation; removed the dead guest element
|
|
60
|
+
before showing Retry.
|
|
61
|
+
- **Note:** keyed the guest partition to account state, which broke login
|
|
62
|
+
persistence. Fixed in 1.1.1.
|
|
63
|
+
|
|
64
|
+
## 1.0.0
|
|
65
|
+
|
|
66
|
+
First local release: sidebar entry, full-width embedded chat, last-conversation
|
|
67
|
+
memory, and crash containment.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sweet560
|
|
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.en.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# dsh-plugin-deepseek-chat
|
|
2
|
+
|
|
3
|
+
English | [中文](README.md)
|
|
4
|
+
|
|
5
|
+
> **Current version: v1.1.1** | Targets DSH **0.2.2-rc.1**
|
|
6
|
+
|
|
7
|
+
Adds a **DeepSeek Chat** entry to the **DeepSeek Harness (DSH) desktop** sidebar. Clicking it opens `chat.deepseek.com` full-width in the main area, remembers the last conversation, and shows the current DSH account state.
|
|
8
|
+
|
|
9
|
+
> Repository: [GitHub](https://github.com/sweet560/dsh-plugin-deepseek-chat) | [Gitee mirror](https://gitee.com/wtt520wyl/dsh-plugin-deepseek-chat)
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Sidebar icon entry, placed between **Plugins** and **Scheduled tasks**.
|
|
16
|
+
- Full-width embedded `https://chat.deepseek.com/` (Electron `<webview>` through the desktop guest-lease bridge `window.dshDesktop.browser`).
|
|
17
|
+
- **Last-conversation memory**: switching panels/sessions or restarting the app reopens the conversation you left, not a new chat.
|
|
18
|
+
- Auth pages never overwrite that memory; a dead conversation falls back to the site root.
|
|
19
|
+
- **Stable login session (fixed in v1.1.1)**: the guest partition is the constant `panel:deepseek-chat`; switching panels/sessions back no longer rebuilds the partition or asks for a fresh QR scan.
|
|
20
|
+
- **DSH account status**: a strip shows "Synced with the DSH account · name" / "No account" / "Account state unavailable" via the official `ctx.remote.account` Remote. **Display only — it never participates in the guest lifecycle.**
|
|
21
|
+
- **Crash containment**: if the embedded page's process dies, is destroyed, or never starts, the panel shows a Retry card — the app window no longer goes blank (fixed in v0.4.0).
|
|
22
|
+
- Inert on the plain Web surface (`dsh web`): the site sends `frame-ancestors 'none'`, so an iframe cannot carry it, and the guest bridge only exists in the desktop shell.
|
|
23
|
+
|
|
24
|
+
## Requirements
|
|
25
|
+
|
|
26
|
+
| Item | Requirement |
|
|
27
|
+
|---|---|
|
|
28
|
+
| DSH | Desktop `0.2.2-rc.1` or newer |
|
|
29
|
+
| Platform | Windows / macOS / Linux desktop shell |
|
|
30
|
+
| git | Only for the GitHub install route (pnpm fetches the repository) |
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
npm package: **`@tianyulinfeng1/dsh-plugin-deepseek-chat`** (the GitHub repository is still named `dsh-plugin-deepseek-chat`).
|
|
35
|
+
|
|
36
|
+
### Option 1 — npm (recommended)
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
dsh plugin --profile desktop add @tianyulinfeng1/dsh-plugin-deepseek-chat
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
You can also enter the package name `@tianyulinfeng1/dsh-plugin-deepseek-chat` in the Plugins page.
|
|
43
|
+
|
|
44
|
+
### Option 2 — Plugins page (GitHub)
|
|
45
|
+
|
|
46
|
+
1. Open DSH desktop and click **Plugins** in the sidebar.
|
|
47
|
+
2. Click **Install a third-party plugin** above the list.
|
|
48
|
+
3. Enter:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
github:sweet560/dsh-plugin-deepseek-chat
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`https://github.com/sweet560/dsh-plugin-deepseek-chat` works too.
|
|
55
|
+
4. Click **Install** and wait for pnpm to finish.
|
|
56
|
+
5. The plugin is enabled automatically; **DeepSeek Chat** appears in the sidebar.
|
|
57
|
+
|
|
58
|
+
### Option 3 — CLI (GitHub)
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
dsh plugin --profile desktop add github:sweet560/dsh-plugin-deepseek-chat
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then open **Plugins → Installed plugins** and make sure **DeepSeek Chat** is switched on (the CLI only installs the package).
|
|
65
|
+
|
|
66
|
+
### Option 4 — local checkout (development)
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
dsh plugin --profile desktop add file:"<absolute path to this repository>"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Why the web chat cannot reuse the DSH sign-in
|
|
73
|
+
|
|
74
|
+
**A pure plugin cannot make chat.deepseek.com reuse the already-signed-in DSH account.** This is an architecture limit of DSH 0.2.2-rc.1, verified against its source:
|
|
75
|
+
|
|
76
|
+
| | DSH desktop account | chat.deepseek.com web |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| Credential | platform.deepseek.com `x-dsh-auth-token` (Host-only `getPlatformSession()`) | the site's own Token (`api/v0/users/current` returns `40002 Missing Token` without it) |
|
|
79
|
+
| Storage | Host credential store | httpOnly cookie in the guest session |
|
|
80
|
+
| Exchange | **None** — zero `chat.deepseek.com` references, no SSO, no cookie injection in the whole archive | — |
|
|
81
|
+
|
|
82
|
+
- The renderer bridge `globalThis.dshDesktop` exposes only `browser.acquire/release/onOpenRequested` etc. — **no** `getAuthToken`, cookie write, or "open Platform to fetch token" API. `getAuthToken()` exists only in the desktop shell's embedded Platform view (`usage` / `top_up`) preload, main-frame + origin restricted.
|
|
83
|
+
- The `browserAcquire` IPC only allocates a partition/lease by workspace string; `configureSession()` sets permissions and download interception, **it injects no credentials**. The guest is forced to `sandbox / contextIsolation / webSecurity`.
|
|
84
|
+
- So the DSH account state can only be **displayed**; it cannot become a web-session login. One manual QR sign-in is still required.
|
|
85
|
+
|
|
86
|
+
**What went wrong in v1.1.0 (fixed in v1.1.1)**: the guest partition had been keyed to the asynchronous account probe. DSH's `getState()` can transiently fail during a reconnect or session switch; changing the partition hands the panel a brand-new cookie jar → a fresh QR scan every time you switched back. Now:
|
|
87
|
+
|
|
88
|
+
- `acquire()`'s workspace is the constant `panel:deepseek-chat`, and the conversation key is the constant `dsh-plugin-deepseek-chat:last-url`;
|
|
89
|
+
- account state changes only update the strip — no epoch, no guest rebuild, no partition change;
|
|
90
|
+
- a transient `unknown` is ignored; only a confirmed `signed-out` updates the display;
|
|
91
|
+
- the guest starts on mount immediately, without waiting for the async Remote (a failed probe never blocks chat);
|
|
92
|
+
- popup navigation is allowlisted to `chat.deepseek.com` and `platform.deepseek.com` (HTTPS, default port).
|
|
93
|
+
|
|
94
|
+
> To also avoid re-scanning **after restarting DSH**, run [scripts/patch-dsh-persistent-partition.cjs](scripts/patch-dsh-persistent-partition.cjs) per [docs/login-persistence.md](docs/login-persistence.md) to change DSH's random in-memory partition into a deterministic `persist:` one (an `app.asar` edit — modifying the installed app, at your own risk). **It also syncs the per-file SHA256 ASAR integrity required by 0.2.2-rc.1** — a byte-only replacement (the deprecated `.mjs` script) would crash DSH on restart. It requires fully exiting DSH first. That patch preserves web cookies across restarts; it does not make the web chat reuse the DSH token.
|
|
95
|
+
|
|
96
|
+
## Usage
|
|
97
|
+
|
|
98
|
+
- The first visit shows the chat.deepseek.com sign-in page; sign in once.
|
|
99
|
+
- Within one app run, switching panels or sessions keeps you signed in (fixed partition since v1.1.1).
|
|
100
|
+
- **Sign in again after restarting DSH**: DSH currently gives embedded browsers a random in-memory partition (`dsh-sidebar-browser-<uuid>`, no `persist:` prefix), so cookies are dropped when the process exits. This plugin does not modify DSH's installation files; to sign in once and stay signed in, apply the equal-length byte patch described in **[docs/login-persistence.md](docs/login-persistence.md)**.
|
|
101
|
+
- The conversation URL is stored under the fixed key `dsh-plugin-deepseek-chat:last-url`, so the last conversation is restored after a restart (while signed in and while it still exists).
|
|
102
|
+
|
|
103
|
+
## Persistent login (optional)
|
|
104
|
+
|
|
105
|
+
DSH hands embedded browsers an **in-memory partition** (`dsh-sidebar-browser-${randomUUID()}`, no `persist:` prefix), so every app restart drops the cookies. To sign in once and stay signed in, replace that partition with a fixed `persist:` one inside `resources/app.asar` — the two statements are the same length, so the archive can be patched byte-for-byte in place.
|
|
106
|
+
|
|
107
|
+
Cause, script, verification, rollback and per-platform paths:
|
|
108
|
+
|
|
109
|
+
**→ [docs/login-persistence.md](docs/login-persistence.md)**
|
|
110
|
+
|
|
111
|
+
Note: this modifies the installed application and is outside DSH's support; a DSH update overwrites `app.asar` and the patch must be re-applied (the `Partitions` data survives). Back up first and proceed at your own risk.
|
|
112
|
+
|
|
113
|
+
## Known limitations
|
|
114
|
+
|
|
115
|
+
- chat.deepseek.com detects the Electron embedding and occasionally shows a "usage environment is abnormal" notice. That is site-side behaviour, unrelated to this plugin.
|
|
116
|
+
- Desktop only; `dsh web` in a browser shows no entry.
|
|
117
|
+
- If the site changes its conversation URL scheme (currently `/a/chat/s/<id>`), the memory falls back to the site root.
|
|
118
|
+
- The DSH account status is display-only; it cannot turn the DSH OAuth token into a chat.deepseek.com web session, so the web chat still needs one manual sign-in on first use.
|
|
119
|
+
- `getProfile()` is used only for the display name. If it is temporarily unavailable the strip may lag briefly, but it **never** affects the guest or the login state.
|
|
120
|
+
- Restarting DSH still requires a fresh web sign-in unless the persistent-partition patch in [docs/login-persistence.md](docs/login-persistence.md) is applied.
|
|
121
|
+
|
|
122
|
+
## Crash containment (v0.4.0)
|
|
123
|
+
|
|
124
|
+
Earlier versions could leave the whole app a blank window a second or two after opening the panel, with no crash dialog and no `crash-*.log`.
|
|
125
|
+
|
|
126
|
+
Root cause: React runs effect cleanups after it has removed the DOM, and Electron's `<webview>` throws from `getURL()` once detached. DSH treats any uncaught plugin error as `slot entry crashed in 'root'` and unmounts the root slot — the entire UI.
|
|
127
|
+
|
|
128
|
+
The current implementation guards every guest call behind an `isConnected` check and `try/catch`, reads the URL before removing the element, wraps every event handler, puts a React error boundary around the panel, listens for `render-process-gone` / `destroyed` / `did-fail-load`, and has a 15-second start watchdog. On failure the dead guest element is removed **before** the Retry card, so retrying cannot stack webviews; a listener-registration failure never starts a guest, and popup URLs are allowlisted (v1.1.0).
|
|
129
|
+
|
|
130
|
+
## Version history
|
|
131
|
+
|
|
132
|
+
| Version | Changes |
|
|
133
|
+
|---|---|
|
|
134
|
+
| **1.1.1** | **Fixes the "scan the QR code again on every panel switch" regression**: the guest partition and conversation key are constants; account state is display-only and never touches the guest lifecycle; a transient `unknown` is ignored; the guest no longer waits for the async probe; self-check now asserts a fixed partition and no rebuild on state churn (35 cases). Documents why a pure plugin cannot reuse the DSH token. |
|
|
135
|
+
| 1.1.0 | DSH `0.2.2-rc.1`: DSH account status strip; correct generated Remote envelope parsing; stricter conversation and popup URL validation; dead guest removal on failure. **This release keyed the partition to account state and broke login persistence (fixed in 1.1.1).** |
|
|
136
|
+
| 1.0.0 | First local release: sidebar entry, full-width chat, conversation memory, crash containment. |
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
```powershell
|
|
141
|
+
git clone https://github.com/sweet560/dsh-plugin-deepseek-chat.git
|
|
142
|
+
cd dsh-plugin-deepseek-chat
|
|
143
|
+
node test/check-client.mjs
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`test/check-client.mjs` loads `lib/client.js` in a `node:vm` sandbox with fake React/DOM/bridge objects and checks registration, Remote envelope parsing, a fixed partition/key, no rebuild on account-state churn, partition reuse across panel switches, conversation memory, lease release, popup allowlisting and crash containment.
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
lib/index.js host half (empty; it only gives the client bundle a Loader entry)
|
|
150
|
+
lib/client.js browser half: entry, panel, account status strip, webview lifecycle, crash containment
|
|
151
|
+
cordis.patch.yml bundle patch that inserts this plugin's Loader row
|
|
152
|
+
locale/{zh,en}.json Plugins-page title/description
|
|
153
|
+
icon.svg Plugins-page icon
|
|
154
|
+
docs/login-persistence.md optional byte patch for DSH's in-memory browser partition
|
|
155
|
+
test/check-client.mjs offline self-check
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Uninstall
|
|
159
|
+
|
|
160
|
+
```powershell
|
|
161
|
+
dsh plugin --profile desktop remove @tianyulinfeng1/dsh-plugin-deepseek-chat
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,3 +1,186 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# dsh-plugin-deepseek-chat
|
|
2
|
+
|
|
3
|
+
[English](README.en.md) | 中文
|
|
4
|
+
|
|
5
|
+
> **当前版本:v1.1.1** |适配 DSH **0.2.2-rc.1**
|
|
6
|
+
|
|
7
|
+
在 **DeepSeek Harness(DSH)桌面版**的左侧栏加入 **DeepSeek 聊天** 入口,点开后 `chat.deepseek.com` 直接占满主内容区,记住上次所在的会话,并显示当前 DSH 账号状态。
|
|
8
|
+
|
|
9
|
+
> 仓库:[GitHub](https://github.com/sweet560/dsh-plugin-deepseek-chat) | [Gitee 镜像](https://gitee.com/wtt520wyl/dsh-plugin-deepseek-chat)
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## 功能
|
|
14
|
+
|
|
15
|
+
- 左侧栏图标入口,排在「插件」和「自动化任务」之间。
|
|
16
|
+
- 主内容区全宽内嵌 `https://chat.deepseek.com/`(Electron `<webview>`,走桌面壳的 guest 租约桥 `window.dshDesktop.browser`)。
|
|
17
|
+
- **记住上次会话**:切到别的面板、切换会话、重启 App 后再进来,直接回到上次那条对话,而不是新对话。
|
|
18
|
+
- 登录/鉴权页不会覆盖记忆;记住的会话失效或打不开时自动回退到首页。
|
|
19
|
+
- **稳定的登录会话(v1.1.1 修复)**:guest 分区固定为 `panel:deepseek-chat`,切换面板/会话回来不会重建分区、不会重新要求扫码。
|
|
20
|
+
- **DSH 账号状态展示**:面板顶部条显示「已与 DSH 登录账号同步 · 昵称」/「未登录」/「账号状态不可用」,通过官方 `ctx.remote.account` 读取;**仅作展示,绝不参与 guest 生命周期**。
|
|
21
|
+
- **崩溃隔离**:内嵌页进程退出、被销毁或启动超时,只在面板里显示「重试」,不会再出现整个 App 变空白窗口的问题(v0.4.0 修复,见下文)。
|
|
22
|
+
- 纯 Web 表层(`dsh web` 在浏览器里打开)自动不注册——该站点 `frame-ancestors 'none'`,iframe 嵌不了,guest 租约桥也只有桌面壳提供。
|
|
23
|
+
|
|
24
|
+
## 环境要求
|
|
25
|
+
|
|
26
|
+
| 项 | 要求 |
|
|
27
|
+
|---|---|
|
|
28
|
+
| DSH | 桌面版 `0.2.2-rc.1` 或更新 |
|
|
29
|
+
| 平台 | Windows / macOS / Linux 桌面壳 |
|
|
30
|
+
| git | 仅「GitHub 安装」方式需要(pnpm 通过 git 拉取仓库) |
|
|
31
|
+
|
|
32
|
+
## 安装
|
|
33
|
+
|
|
34
|
+
npm 包名:**`@tianyulinfeng1/dsh-plugin-deepseek-chat`**(GitHub 仓库名仍是 `dsh-plugin-deepseek-chat`)。
|
|
35
|
+
|
|
36
|
+
### 方式一:npm(推荐)
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
dsh plugin --profile desktop add @tianyulinfeng1/dsh-plugin-deepseek-chat
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
插件页的「安装第三方插件」里也可以直接填包名 `@tianyulinfeng1/dsh-plugin-deepseek-chat`。
|
|
43
|
+
|
|
44
|
+
### 方式二:插件页安装(GitHub)
|
|
45
|
+
|
|
46
|
+
1. 打开 DSH 桌面版,左侧栏点 **插件**。
|
|
47
|
+
2. 点列表上方的 **安装第三方插件**。
|
|
48
|
+
3. 在「包名或地址」里填入:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
github:sweet560/dsh-plugin-deepseek-chat
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
也可以填 `https://github.com/sweet560/dsh-plugin-deepseek-chat`。
|
|
55
|
+
4. 点 **安装**,等 pnpm 跑完(首次会拉取仓库并安装依赖)。
|
|
56
|
+
5. 安装完成后插件自动启用,左侧栏出现 **DeepSeek 聊天**。
|
|
57
|
+
|
|
58
|
+
### 方式三:命令行(GitHub)
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
dsh plugin --profile desktop add github:sweet560/dsh-plugin-deepseek-chat
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
装完打开 **插件 → 已安装插件**,确认「DeepSeek 聊天」处于启用状态(命令行只负责装依赖,启用状态以插件页为准)。
|
|
65
|
+
|
|
66
|
+
### 方式四:本地目录(二次开发)
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
dsh plugin --profile desktop add file:"<本仓库绝对路径>"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 关于「免扫码 / 与 DSH 账号同步」的真相
|
|
73
|
+
|
|
74
|
+
**纯插件做不到让 chat.deepseek.com 直接复用 DSH 已登录的账号**,这不是实现遗漏,而是 DSH 的架构限制(已在 0.2.2-rc.1 源码中逐项核对):
|
|
75
|
+
|
|
76
|
+
| 项 | DSH 桌面版账号 | chat.deepseek.com 网页版 |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| 凭据 | platform.deepseek.com 的 `x-dsh-auth-token`(Host-only `getPlatformSession()`) | 站点自带的 Token(`api/v0/users/current` 无 token 返回 `40002 Missing Token`) |
|
|
79
|
+
| 存放 | Host 进程凭据存储 | guest session 的 httpOnly cookie |
|
|
80
|
+
| 兑换入口 | **无**;归档中 `chat.deepseek.com` 零引用,无 SSO、无 cookie 注入 | — |
|
|
81
|
+
|
|
82
|
+
- 渲染层桥 `globalThis.dshDesktop` 只有 `browser.acquire/release/onOpenRequested` 等,**没有** `getAuthToken`、写 cookie、打开 Platform 取 token 的 API;`getAuthToken()` 只存在于桌面壳内嵌 Platform 页(`usage` / `top_up`)的专用 preload,且受主帧 + origin 限制。
|
|
83
|
+
- `browserAcquire` IPC 只按 workspace 字符串分配分区/租约,`configureSession()` 只设权限与下载拦截,**不注入任何凭据**;guest 被强制 `sandbox/contextIsolation/webSecurity`。
|
|
84
|
+
- 因此:DSH 账号状态只能**显示**在面板上,无法换成网页版登录态;首次仍需在网页里扫码一次。
|
|
85
|
+
|
|
86
|
+
**v1.1.0 的教训(v1.1.1 已修复)**:曾把 guest 分区绑到异步账号探测结果上。DSH 的 `getState()` 在重连/切会话时会瞬时失败,分区一变就等于换了个全新 cookie 罐 → 每次切回面板都要求重新扫码。现在:
|
|
87
|
+
|
|
88
|
+
- `acquire()` 的 workspace 恒为 `panel:deepseek-chat`,会话记忆 key 恒为 `dsh-plugin-deepseek-chat:last-url`;
|
|
89
|
+
- 账号状态变化只更新显示条,不 bump epoch、不重建 guest、不换分区;
|
|
90
|
+
- 瞬时 `unknown` 被忽略,只有明确的 `signed-out` 才更新显示;
|
|
91
|
+
- guest 在挂载时立即启动,不再等待异步 Remote 探测(探测失败也不阻塞聊天);
|
|
92
|
+
- 弹窗导航只放行 `chat.deepseek.com` 与 `platform.deepseek.com`(HTTPS、默认端口)。
|
|
93
|
+
|
|
94
|
+
> 想做到「重启 DSH 后也不用重新扫码」,需要按 [docs/login-persistence.md](docs/login-persistence.md) 把 DSH 的随机内存分区改成**确定性的 `persist:` 分区**(运行 [scripts/patch-dsh-persistent-partition.cjs](scripts/patch-dsh-persistent-partition.cjs),属修改已安装应用,风险自负)。**该脚本会同步 `0.2.2-rc.1` 的 ASAR 逐文件 SHA256 integrity**,纯字节替换会让 DSH 重启崩溃,切勿使用废弃的 `.mjs` 版本。补丁要求完全退出 DSH 后才能写入 `app.asar`,且只解决「重启后保留网页 cookie」,不能让网页复用 DSH token。
|
|
95
|
+
|
|
96
|
+
## 使用
|
|
97
|
+
|
|
98
|
+
- 第一次打开会停在 chat.deepseek.com 的登录页,登录一次即可。
|
|
99
|
+
- 本次 App 运行期间,切换面板/会话**不需要**重新登录(v1.1.1 起分区固定)。
|
|
100
|
+
- **重启 DSH 后仍需要重新登录一次**:DSH 目前给内嵌浏览器的是随机内存分区(`dsh-sidebar-browser-<uuid>`,没有 `persist:` 前缀),进程退出即清空 cookie。本插件不修改 DSH 的安装文件;想做到「登录一次、长期免登录」,可按 **[docs/login-persistence.md](docs/login-persistence.md)** 做一次等长字节替换(含脚本、验证与回滚)。
|
|
101
|
+
- 会话链接记在 App 的 localStorage(固定 key `dsh-plugin-deepseek-chat:last-url`),重启后仍会打开上次的会话(前提是已登录且该会话仍存在)。
|
|
102
|
+
|
|
103
|
+
## 登录态持久化(可选,免登录)
|
|
104
|
+
|
|
105
|
+
DSH 目前给内嵌浏览器分配的是**内存分区**(`dsh-sidebar-browser-${randomUUID()}`,无 `persist:` 前缀),所以每次重启 App 都会清空 cookie。想做到「登录一次、以后不再登录」,需要把桌面主进程里的那行分区名改成固定且带 `persist:` 前缀的值——两条语句**字节数相同**,可以直接在 `resources/app.asar` 里原地替换。
|
|
106
|
+
|
|
107
|
+
完整原因、脚本、验证步骤、回滚方式和各平台路径都整理在这里:
|
|
108
|
+
|
|
109
|
+
**→ [docs/login-persistence.md](docs/login-persistence.md)**
|
|
110
|
+
|
|
111
|
+
注意:这属于对已安装应用的修改,不在 DSH 支持范围内;DSH 升级会覆盖 `app.asar`,需要重新打补丁(`Partitions` 里的登录数据不会丢)。请先备份,风险自负。
|
|
112
|
+
|
|
113
|
+
## 已知限制
|
|
114
|
+
|
|
115
|
+
- chat.deepseek.com 会检测 Electron 内嵌环境,偶尔弹出「使用环境异常…建议使用官方产品」的提示;这是站点侧行为,与本插件无关。
|
|
116
|
+
- 仅桌面版有效;`dsh web` 在浏览器里打开时不显示入口。
|
|
117
|
+
- 站点若调整会话 URL 规则(当前识别 `/a/chat/s/<id>` 形式),「记住会话」可能失效并回退到首页。
|
|
118
|
+
- DSH 账号状态只作展示,不能把 DSH 的 OAuth token 兑换成 chat.deepseek.com 的网页会话;首次仍需在该网页登录一次(见上文)。
|
|
119
|
+
- `getProfile()` 只用于显示昵称;该接口暂不可用时显示状态可能短暂滞后,但**绝不影响** guest 与登录态。
|
|
120
|
+
- 重启 DSH 后仍需重新登录网页版 chat,除非按 [docs/login-persistence.md](docs/login-persistence.md) 打持久分区补丁。
|
|
121
|
+
|
|
122
|
+
## 崩溃隔离(v0.4.0)
|
|
123
|
+
|
|
124
|
+
早期版本出现过:点开面板、聊天页正常显示 1~2 秒后**整个 App 变成空白窗口**(只剩原生菜单和窗口按钮),没有崩溃对话框也没有 `crash-*.log`。
|
|
125
|
+
|
|
126
|
+
根因是 React 卸载面板时**先移除 DOM、后执行 effect 清理**,而 Electron 的 `<webview>` 一旦脱离文档,`getURL()` 就会抛错;DSH 把插件里任何未捕获异常都当作 `slot entry crashed in 'root'`,直接卸载 `root` slot —— 整个 App UI 因此消失。
|
|
127
|
+
|
|
128
|
+
现在的实现:
|
|
129
|
+
|
|
130
|
+
- 所有 guest 调用先判断 `element.isConnected` 再 `try/catch`,清理阶段「先读 URL、再移除元素」;
|
|
131
|
+
- 每个事件处理器都包 `try/catch`,异常只落在面板自己的状态里;
|
|
132
|
+
- 面板外包一层 React 错误边界;
|
|
133
|
+
- 监听 `render-process-gone` / `destroyed` / `did-fail-load`,失败时**先移除失效的 guest 元素**再显示「重试」,避免重试叠加 webview;
|
|
134
|
+
- 15 秒启动看门狗,guest 一直不 `dom-ready` 就转重试卡片;
|
|
135
|
+
- 事件监听器若注册失败则不启动 guest;弹窗 URL 走白名单校验(v1.1.0)。
|
|
136
|
+
|
|
137
|
+
## 版本历史
|
|
138
|
+
|
|
139
|
+
| 版本 | 内容 |
|
|
140
|
+
|---|---|
|
|
141
|
+
| **1.1.1** | **修复每次切回面板/重启都要重新扫码的回归**:guest 分区与会话 key 固定为常量,账号状态仅作展示、不参与 guest 生命周期;瞬时 `unknown` 被忽略;guest 不再等待异步账号探测;自检改为验证固定分区与状态抖动不重建(35 项)。明确记录「纯插件无法免扫码复用 DSH token」的源码结论。 |
|
|
142
|
+
| 1.1.0 | 支持 DSH `0.2.2-rc.1`:新增 DSH 账号状态条;修正生成式 Remote 信封解析;收紧会话 URL 与弹窗 URL 校验;失败时移除失效 guest。**此版把分区绑到账号状态,导致登录态抖动(已由 1.1.1 修复)**。 |
|
|
143
|
+
| 1.0.0 | 首个本地版本:侧栏入口、全宽内嵌聊天、会话记忆、崩溃隔离。 |
|
|
144
|
+
|
|
145
|
+
## 开发
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
git clone https://github.com/sweet560/dsh-plugin-deepseek-chat.git
|
|
149
|
+
cd dsh-plugin-deepseek-chat
|
|
150
|
+
node test/check-client.mjs
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`test/check-client.mjs` 是离线自检:在 `node:vm` 里加载 `lib/client.js`,用假的 React/DOM/租约桥验证注册、Remote 信封解析、固定分区与会话 key、状态抖动不重建 guest、切换面板复用分区、会话记忆、租约释放、弹窗白名单和崩溃隔离。
|
|
154
|
+
|
|
155
|
+
目录:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
lib/index.js 宿主半侧(空实现,只为让 client bundle 有 Loader 入口)
|
|
159
|
+
lib/client.js 浏览器半侧:入口、面板、账号状态展示、webview 生命周期、崩溃隔离
|
|
160
|
+
cordis.patch.yml bundle 补丁:插入本插件的 Loader 行
|
|
161
|
+
locale/zh.json 插件页显示名称/描述(中文)
|
|
162
|
+
locale/en.json 插件页显示名称/描述(英文)
|
|
163
|
+
icon.svg 插件页图标
|
|
164
|
+
docs/login-persistence.md 可选:DSH 内存分区改持久分区的字节补丁
|
|
165
|
+
test/check-client.mjs 离线自检
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 卸载
|
|
169
|
+
|
|
170
|
+
```powershell
|
|
171
|
+
dsh plugin --profile desktop remove @tianyulinfeng1/dsh-plugin-deepseek-chat
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 作者
|
|
175
|
+
|
|
176
|
+
- **作者**:伍悦匿匿
|
|
177
|
+
- **联系方式**:437830488@qq.com
|
|
178
|
+
- **GitHub**:https://github.com/sweet560
|
|
179
|
+
- **博客园**:https://www.cnblogs.com/wuyuenini/
|
|
180
|
+
- **CSDN**:https://blog.csdn.net/weixin_42076389
|
|
181
|
+
- **Gitee**:https://gitee.com/wtt520wyl
|
|
182
|
+
- **Gitee 镜像仓库**:https://gitee.com/wtt520wyl/dsh-plugin-deepseek-chat
|
|
183
|
+
|
|
184
|
+
## 许可证
|
|
185
|
+
|
|
186
|
+
[MIT](LICENSE)
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# @tianyulinfeng1/dsh-plugin-deepseek-chat bundle patch: one insert registers
|
|
2
|
+
# this plugin. insert.name must be the package name (the scoped npm name);
|
|
3
|
+
# insert.id must be unique across the composed loader tree.
|
|
4
|
+
- insert:
|
|
5
|
+
- id: deepseek-chat
|
|
6
|
+
name: '@tianyulinfeng1/dsh-plugin-deepseek-chat'
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# dsh-plugin-deepseek-chat v1.1.1
|
|
2
|
+
|
|
3
|
+
**DeepSeek Chat panel for DeepSeek Harness Desktop — stable login session, DSH account status, and full ASAR integrity support for the restart-free login patch.**
|
|
4
|
+
|
|
5
|
+
- Requires DSH Desktop **0.2.2-rc.1** or newer.
|
|
6
|
+
- Requires Node >= 20.
|
|
7
|
+
|
|
8
|
+
## What's fixed
|
|
9
|
+
|
|
10
|
+
- **No more QR scan on every panel/session switch.** The guest partition is now a
|
|
11
|
+
fixed constant (`panel:deepseek-chat`) instead of being derived from the async
|
|
12
|
+
DSH account probe. DSH caches one session per workspace string for the process
|
|
13
|
+
lifetime, so a stable string preserves the chat login.
|
|
14
|
+
- The DSH account state strip is display-only and never rebuilds the guest.
|
|
15
|
+
- The guest starts immediately, without waiting for the account Remote.
|
|
16
|
+
|
|
17
|
+
## Restart-free login (the important part)
|
|
18
|
+
|
|
19
|
+
DSH `0.2.1-rc.3+` (including `0.2.2-rc.1`) records a SHA256 **integrity** for
|
|
20
|
+
every file in `app.asar`. A byte-only replacement of the in-memory partition name
|
|
21
|
+
would crash DSH on restart with "ASAR Integrity Violation".
|
|
22
|
+
|
|
23
|
+
This release ships `scripts/patch-dsh-persistent-partition.cjs` (from upstream),
|
|
24
|
+
which:
|
|
25
|
+
|
|
26
|
+
1. Replaces `dsh-sidebar-browser-${randomUUID()}` with the equal-length
|
|
27
|
+
`persist:dsh-sidebar-browser-chat-v1`;
|
|
28
|
+
2. Recomputes `lib/main.js`'s SHA256 and syncs the ASAR header `hash`/`blocks`;
|
|
29
|
+
3. Verifies every file/block hash before and after writing (verified on
|
|
30
|
+
0.2.2-rc.1: **20519 files, 0 failures**);
|
|
31
|
+
4. Creates a timestamped backup and supports `--dry-run` and idempotent reruns.
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
# Exit DSH completely from the tray first!
|
|
35
|
+
node scripts/patch-dsh-persistent-partition.cjs "F:\DeepSeek Harness\resources\app.asar" --dry-run
|
|
36
|
+
node scripts/patch-dsh-persistent-partition.cjs "F:\DeepSeek Harness\resources\app.asar"
|
|
37
|
+
# Restart DSH, sign in to chat.deepseek.com ONCE, then restart again — no more scans.
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
See [docs/login-persistence.md](docs/login-persistence.md) for the full
|
|
41
|
+
procedure, rollback, and per-platform paths.
|
|
42
|
+
|
|
43
|
+
## Honest limitation
|
|
44
|
+
|
|
45
|
+
A pure plugin still **cannot** make the web chat reuse the already-signed-in DSH
|
|
46
|
+
account: DSH uses a Platform `x-dsh-auth-token`, `chat.deepseek.com` uses its own
|
|
47
|
+
Token, the renderer bridge exposes no token/cookie API, and there is no official
|
|
48
|
+
SSO/exchange. One manual sign-in is required; the patch then keeps that session
|
|
49
|
+
permanently.
|
|
50
|
+
|
|
51
|
+
## Assets
|
|
52
|
+
|
|
53
|
+
- `dsh-plugin-deepseek-chat-1.1.1.tgz` — the complete installable npm/bundle
|
|
54
|
+
package (`npm pack` output). Install from the Plugins page via
|
|
55
|
+
`github:sweet560/dsh-plugin-deepseek-chat`, or with
|
|
56
|
+
`dsh plugin --profile desktop add file:"<path to tgz>"`.
|
|
57
|
+
- `Source code (zip/tar.gz)` — generated by GitHub/Gitee automatically.
|
|
58
|
+
|
|
59
|
+
## Verification
|
|
60
|
+
|
|
61
|
+
- Offline self-check: 35/35 passing (`node test/check-client.mjs`).
|
|
62
|
+
- `lib/client.js` and the patch script pass `node --check`.
|
|
63
|
+
- `app.asar` patch independently verified: header integrity hash equals the
|
|
64
|
+
actual SHA256 of the patched `lib/main.js` bytes; archive size unchanged.
|