dsh-coding-subscription-oauth 0.7.0 → 0.8.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +312 -296
  2. package/CONTRIBUTING.md +138 -138
  3. package/INSTALL.md +267 -261
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +309 -303
  7. package/README.es.md +310 -304
  8. package/README.fr.md +310 -304
  9. package/README.ja.md +310 -304
  10. package/README.ko.md +310 -304
  11. package/README.md +327 -321
  12. package/README.pt-BR.md +310 -304
  13. package/README.ru.md +310 -304
  14. package/README.zh-CN.md +325 -319
  15. package/compatibility/dsh-bom.json +36 -36
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +213 -213
  18. package/docs/02-architecture.md +143 -142
  19. package/docs/02-architecture.zh-CN.md +143 -142
  20. package/lib/adapter.d.ts.map +1 -1
  21. package/lib/bin.js +13 -6
  22. package/lib/bin.js.map +3 -3
  23. package/lib/client.js +3 -3
  24. package/lib/client.js.map +4 -4
  25. package/lib/gateway-auth.d.ts +1 -0
  26. package/lib/gateway-auth.d.ts.map +1 -1
  27. package/lib/gateway-config.d.ts +4 -0
  28. package/lib/gateway-config.d.ts.map +1 -1
  29. package/lib/gateway-http.d.ts +5 -0
  30. package/lib/gateway-http.d.ts.map +1 -1
  31. package/lib/gateway-opencode-go.d.ts +22 -0
  32. package/lib/gateway-opencode-go.d.ts.map +1 -0
  33. package/lib/gateway.d.ts +2 -0
  34. package/lib/gateway.d.ts.map +1 -1
  35. package/lib/index.js +278 -63
  36. package/lib/index.js.map +4 -4
  37. package/lib/invariant.js.map +1 -1
  38. package/package.json +229 -226
  39. package/patches/dsh-agy@0.1.2.patch +25 -25
  40. package/scripts/release.mjs +187 -187
  41. package/scripts/smoke-deployed-routes.mjs +146 -146
  42. package/scripts/verify-adapter-host.mjs +70 -0
  43. package/scripts/verify-deployed-catalog.mjs +87 -87
package/INSTALL.md CHANGED
@@ -1,261 +1,267 @@
1
- # 安装与使用 · dsh-coding-subscription-oauth
2
-
3
- 本仓库原名 **`dsh-grok-build`**。普通用户请使用已发布的 npm 版本:
4
-
5
- ```bash
6
- dsh plugin --profile web add dsh-coding-subscription-oauth@0.7.0
7
- ```
8
-
9
- CLI 新命令是 `dsh-coding-oauth`(旧命令 `dsh-grok-build` 仍可用)。为兼容已有 profile,Cordis id 仍是 `llm-grok-build-oauth`,设置页 HTTP 路径仍是 `/plugins/dsh-grok-build/*`,凭据文件名不变。
10
-
11
- 第一次公开发布是 **`0.4.1`**。`0.6.1` 从未正式发布或打包,其未发布改动已合入当前推荐的 **`0.6.3`**:
12
-
13
- ```bash
14
- dsh plugin --profile web add dsh-coding-subscription-oauth@0.7.0
15
- dsh plugin --profile web update dsh-coding-subscription-oauth
16
- ```
17
-
18
- ## 前置条件
19
-
20
- - DeepSeek Harness `0.1.1-rc.2`(精确已验证 BOM,见 `compatibility/dsh-bom.json`)
21
- - Node.js 22.19+
22
- - 需要使用的个人编码订阅;没有 Claude/Google 账号也可以先安装路由
23
- - 部分网络需要 HTTP/HTTPS 代理
24
-
25
- `0.1.2-alpha.*` 与 `0.1.5-rc.1` 可作为 BOM **未验证候选**出现,但不是生产 pin。在把候选提升为 `verified` 之前,不要把它们当作正式兼容声明。面向 `0.1.5-rc.1` 的客户端 inject 已不再要求 `@deepseek-ai/dsh-client-runtime`(该包在候选宿主上不存在);缺失的可选 inject 仍为 soft diagnostic。
26
-
27
- ## 安装
28
-
29
- ```bash
30
- # 普通用户:当前 npm 发布版
31
- dsh plugin --profile web add dsh-coding-subscription-oauth@0.7.0
32
-
33
- # 开发 / 备用:从 GitHub
34
- dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
35
-
36
- # 本地开发目录(备用)
37
- # dsh plugin --profile web add ./dsh-coding-subscription-oauth
38
-
39
- # Google Antigravity 可选依赖,固定版本
40
- dsh plugin --profile web add dsh-agy@0.1.2
41
- ```
42
-
43
- 安装后重启现有 DSH Web 进程;不要另起一个端口相同的服务器。
44
-
45
- ## 升级注意事项
46
-
47
- - 本版按 DSH `0.1.1-rc.2` 的精确兼容矩阵发布;生产环境应锁定已验证的 BOM,不要用 `*` 或未验证的宽泛 peer range。候选宿主(如 `0.1.5-rc.1`)只记在 `candidates[]`,须经隔离冒烟后再考虑提升。
48
- - 从 `0.6.0` 升级到 `0.6.2` 后再重启:`0.6.0` 在严格 Cordis 注入检查下可能因读取尚未注入的可选服务而拖垮插件树。这个补丁不迁移或重置 OAuth 凭据、Gateway、模型/适配器 ID 与缓存。
49
- - 从 `0.6.3` 升级到 `0.6.4`:统一固定 `dsh-coding-oauth-core@0.1.2` 与 `undici@7.29.0`;无配置、凭据、数据或路由迁移。
50
- - 从 `0.6.5` 升级到 `0.7.0`:AuthDocument v2 多账号与 Accounts UI;去掉 `@deepseek-ai/dsh-client-runtime` inject;BOM 记录未验证候选 `0.1.5-rc.1`(verified 仍为 `0.1.1-rc.2`);无配置/凭据/路由破坏性迁移。
51
- - 从 `0.6.4` 升级到 `0.6.5`:Gateway key reveal/rotate 仅限 `accessMode === "loopback"`(与 Settings UI 一致);无配置、凭据、数据或路由迁移。npm 包不再附带 `src/`,运行时仍为生成的 `lib/`。
52
- - 宿主边界(无需操作者迁移):客户端 classic-script 不再 inject `@deepseek-ai/dsh-client-runtime`;`ClientContext` `@deepseek-ai/cordis` 解析。这与 Hub 在 `0.1.5-rc.1` 上的适配一致,避免陈旧 inject 诊断。
53
- - 在同一个 **web profile** 中先保证 `dsh-coding-oauth-core@0.1.2` 可从 npm 解析,再安装 Subscription `0.7.0`(以及需要的 `dsh-hub-oauth-gateway@1.12.0`)。Core 只是共享 npm 依赖,不是单独的 DSH 插件,用户不需要执行 `dsh plugin add dsh-coding-oauth-core`。
54
- - 共装 Hub Subscription 时,先安装 `dsh-hub-oauth-gateway@1.12.0` Subscription `0.7.0`,完成后只重启一次现有 DSH Web 进程;Hub 提供完整用量中心,Subscription 显示紧凑状态入口。只升级 Subscription 仍可独立工作。
55
- - 升级会保留既有 Cordis id、OAuth 凭据文件、模型/适配器 ID、Gateway 配置和模型缓存;不要为了“清理旧版本”删除这些文件。若旧包名 `dsh-grok-build` 仍在 profile 中,只移除那条旧插件记录,再安装当前包,避免重复路由。
56
- - 回滚时恢复上一个插件版本并重启一次,保留凭据和配置;先查看兼容性诊断与失败原因,不要用清空凭据来代替回滚。
57
- - DSH Web 与本地 Gateway 继续只绑定 loopback。远程 Settings 只能走 SSH 隧道或满足 owner proof、精确 Origin 和 CSRF proof 的 HTTPS 反向代理;升级不会放宽到 `0.0.0.0`。
58
-
59
- 本地 API 网关默认关闭。需要时在 profile 里打开(只绑 loopback):
60
-
61
- ```yaml
62
- gateway:
63
- enabled: true
64
- bind: 127.0.0.1
65
- port: 18080
66
- ```
67
-
68
- 或在 Settings → Coding OAuth → Gateway 标签页打开。Bearer key 存在 `$DSH_HOME/.coding-oauth-gateway.json`。不要绑定 `0.0.0.0`。
69
-
70
- ## 安全访问远程 Settings
71
-
72
- DSH Web 仍应只绑定 loopback。远程浏览器必须通过 SSH 隧道,或通过已经完成属主认证的 HTTPS 反向代理访问;不能把 DSH 或本插件直接监听到 `0.0.0.0`。
73
-
74
- 插件优先采用 DSH 提供的 `ownerRequestPolicy` 宿主能力。宿主尚未提供该能力时,可启用严格 fallback:
75
-
76
- ```yaml
77
- - id: llm-grok-build-oauth
78
- config:
79
- ownerRequest:
80
- loopbackAccessMode: ssh-tunnel
81
- trustedProxy:
82
- peers: [<反向代理的实际 TCP 来源地址>]
83
- origins: [https://dsh.example.com]
84
- ownerProof: <由本机密钥管理或部署模板注入>
85
- csrfToken: <独立于 ownerProof 的本机密钥>
86
- ```
87
-
88
- 上面的尖括号内容是占位符,不可原样使用;真实 proof 只放在被 Git 忽略的本机部署配置或密钥注入层。反向代理必须保留公开 `Host`,在完成属主认证后向上游注入 `X-DSH-Owner-Proof`,并为变更请求注入独立的 `X-DSH-CSRF-Token`。插件同时核验实际 TCP peer、精确 HTTPS `Origin`/`Host` 和 `Sec-Fetch-Site: same-origin`;`X-Forwarded-*` 不能授权。任一项缺失都会 fail closed。
89
-
90
- 若把同机反向代理的 loopback 地址列为 `peers`,来自该地址的所有请求都会按代理流量校验,不能再回退为本地请求。这是防止反代改写 `Host` 后绕过 proof 的安全边界;配置前应保留独立的 SSH 修复通道。
91
-
92
- ## Antigravity 安全配置
93
-
94
- `dsh-agy@0.1.2` `/agy` standalone dashboard 没有自己的认证,并包含凭据导出接口。Web 服务带 trusted-host 或反向代理时,建议在 profile 最终 `cordis.patch.yml` 禁用该 dashboard:
95
-
96
- ```yaml
97
- - id: dsh-agy-web
98
- disabled: true
99
- ```
100
-
101
- 这不会禁用 `agy` LLM route 或 profile 内的 `dsh-agy` CLI。
102
-
103
- Google OAuth 后续可用:
104
-
105
- ```bash
106
- NODE_USE_ENV_PROXY=1 \
107
- HTTPS_PROXY=http://127.0.0.1:7890 \
108
- dsh plugin --profile web exec dsh-agy login --headless
109
- ```
110
-
111
- 仅在当前网络确实需要代理时设置 `NODE_USE_ENV_PROXY` / `HTTPS_PROXY`;其他环境直接执行最后一行即可。不要把 Google credential export 粘贴到聊天或日志。
112
-
113
- ## 代理配置
114
-
115
- 推荐在 profile 的最终 patch 里配置常驻服务:
116
-
117
- ```yaml
118
- - id: llm-grok-build-oauth
119
- config:
120
- proxy: http://127.0.0.1:7890
121
- proxyKimi: false
122
- ```
123
-
124
- 解析优先级:`config.proxy` `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY` / `HTTP_PROXY`。
125
-
126
- 默认进入代理的域名组:
127
-
128
- - xAI/Grok Build
129
- - OpenAI Codex
130
- - Claude/Anthropic
131
- - Google OAuth/Cloud Code
132
-
133
- Kimi Code 中国流量默认直连;只有 `proxyKimi: true` 才代理。
134
-
135
- ## 弹性重试
136
-
137
- OAuth access token 会在本地记录过期时间前 5 分钟主动刷新。服务端若仍以 401/403 拒绝一个本地尚未过期的令牌,插件会把凭据 `expires` 回写到过去,重试的 step 先刷新再发请求。瞬时故障(429/5xx/超时/网络)和 AUTH 默认最多重试 5 次(5 s → 10 s → 20 s → 40 s → 80 s,约 155 s 叠加时常,10% jitter)。xAI「at capacity」等文案会重映射为 `RATE_LIMIT` 后再退避。配额耗尽和 refresh token 失效不重试。
138
-
139
- 部署级覆盖(可选):
140
-
141
- ```yaml
142
- - id: llm-grok-build-oauth
143
- config:
144
- retryPolicy:
145
- mode: normal
146
- maxRetries: 5
147
- retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
148
- backoff: { initialDelayMs: 5000, maxDelayMs: 80000, jitterRatio: 0.1 }
149
- ```
150
-
151
- ## 登录
152
-
153
- ### 设置页
154
-
155
- 打开 **设置 → 编码 OAuth**:
156
-
157
- - **Grok Build**:授权码或设备码
158
- - **OpenAI Codex**:远程部署推荐设备码;浏览器 PKCE 支持粘贴 redirect URL
159
- - **Kimi Code**:设备码
160
- - **Claude Code**:浏览器 PKCE,远程访问时粘贴完整 localhost redirect URL
161
-
162
- 设置页会**只读发现**白名单内的官方 Grok / Codex / Kimi / Claude CLI OAuth 文件。同步是显式的单向**拉取**(不是自动导入):发现 → 预览 → 冲突/指纹核对 → 确认覆盖。官方 CLI 文件从不被写入。读取会拒绝符号链接、非普通文件、非属主文件、组/其他人可读,以及超大文档(`O_NOFOLLOW`)。预览票据一次性、五分钟过期、最多 32 张。CLI 的 `dsh-coding-oauth import` 仍只支持 Grok。
163
-
164
- 登录过程只交换授权 code;状态接口不返回 access/refresh token。
165
-
166
- ### 可选能力
167
-
168
- 设置页的八项订阅能力开关默认全部关闭,打开后立即生效(无需重启):`codexSearch`、`codexImages`、`codexImageEdits`、`codexImagesAnyModel`、`codexUsage`、`codexFast`、`grokImagineImage`、`grokImagineVideo`。`codexImagesAnyModel` 仅放宽调用模型路由限制;仍要求已登录 Codex、开启对应图像能力,并保留当前会话附件归属和编辑授权检查。
169
-
170
- 数值控制为 `searchResults`(1–20,默认 5)、`imageCount`(1–4,默认 1)、`videoArtifactTtlMs`(1 小时–7 天,默认 7 天;界面以 1–168 小时显示)。降低视频保留时间会立即缩短并清理已有产物;提高只影响之后生成的产物。管理员可在插件配置的 `capabilities` 下提供不含秘密的 composition 默认值;`coding-subscription-oauth` 设置区中的用户值会覆盖该 base,省略时所有开关仍默认关闭。
171
-
172
- `codex-oauth-fast` 仅在最新一次 live catalog 标明至少有一个 `priority` 可用模型后才会出现。请求发送 `service_tier: priority` 和路由提示;界面写 **已请求 Fast**,不保证延迟或上游兑现。Codex 搜索/用量/图像是需打开的私有 `chatgpt.com/backend-api` 端点;图像固定 `gpt-image-2`;编辑只接受当前会话顶层、本会话持有的附件。
173
-
174
- Grok Imagine 只走官方 `https://api.x.ai`(`grok-imagine-image-2.0` / `grok-imagine-video-1.5`),凭据是独立的 DSH 引用 `XAI_API_KEY`——不用 Grok OAuth,也不回退进程环境变量。下载受 MIME / 大小 / 超时 / 重定向 / DNS 控制,冻结主机为 `imgen.x.ai`、`videogen.x.ai`、`vidgen.x.ai`;私有产物库的单件与唯一对象总量均硬限 256 MiB、最长七天;只通过同源 loopback 路由提供。
175
-
176
- ### CLI
177
-
178
- ```bash
179
- # Grok(`dsh-grok-build` 仍是同一条命令的别名)
180
- dsh-coding-oauth login
181
- dsh-coding-oauth login --pkce
182
- dsh-coding-oauth import
183
-
184
- # Codex / Kimi / Claude
185
- dsh-coding-oauth login codex --device-auth
186
- dsh-coding-oauth login codex --browser
187
- dsh-coding-oauth login kimi
188
- dsh-coding-oauth login claude
189
-
190
- # 状态/登出
191
- dsh-coding-oauth status all
192
- dsh-coding-oauth logout kimi
193
- ```
194
-
195
- ## 模型路由
196
-
197
- - `grok-build/<model>`
198
- - `codex-oauth/<model>`
199
- - `codex-oauth-fast/<model>`(可选;仅在最新 live catalog 标明 `priority` 可用后出现,界面为 已请求 Fast)
200
- - `kimi-code-oauth/<model>`
201
- - `claude-code-oauth/<model>`
202
- - `agy/<model>`(安装 dsh-agy 后)
203
-
204
- 这些别名专门避免与已有的 `xai`、`openai`、`kimi-coding` API-key routes 冲突。插件不会修改现有默认模型设置。未认证的 OAuth route 不向模型选择器返回任何模型;认证后供应商名显示为 `(OAuth)`,登录/登出会立即触发目录刷新。
205
-
206
- ## 凭据与缓存
207
-
208
- OAuth 凭据:
209
-
210
- ```text
211
- $DSH_HOME/.grok-build-auth.json
212
- $DSH_HOME/.codex-oauth-auth.json
213
- $DSH_HOME/.kimi-code-oauth-auth.json
214
- $DSH_HOME/.claude-code-oauth-auth.json
215
- ```
216
-
217
- 均为 `0600`、原子写、文件锁保护。模型缓存为对应的 `*-models.json`,不含 token。Grok Imagine 使用 DSH 凭据引用 `XAI_API_KEY`,与上述 OAuth 文件分离;视频产物存入 `$DSH_HOME/.dsh-coding-subscription-oauth-media/`(目录 `0700`、文件 `0600`),按保留设置自动清理。
218
-
219
- ## 卸载
220
-
221
- ```bash
222
- dsh plugin --profile web remove dsh-agy dsh-coding-subscription-oauth
223
- rm -f ~/.dsh/.grok-build-auth.json ~/.dsh/.codex-oauth-auth.json \
224
- ~/.dsh/.kimi-code-oauth-auth.json ~/.dsh/.claude-code-oauth-auth.json
225
- rm -f ~/.dsh/.grok-build-models.json ~/.dsh/.codex-oauth-models.json \
226
- ~/.dsh/.kimi-code-oauth-models.json ~/.dsh/.claude-code-oauth-models.json
227
- ```
228
-
229
- 只有在确认不再需要账号后才删除凭据文件。
230
-
231
- ## 部署验收
232
-
233
- 以下命令面向维护者,需要在源码 checkout 中运行;通过 npm 安装的用户无需执行。
234
-
235
- ```bash
236
- pnpm run verify:deployed
237
-
238
- DSH_RESTORE_PROVIDER=openai \
239
- DSH_RESTORE_MODEL=gpt-5.6-sol \
240
- DSH_RESTORE_REASONING=max \
241
- pnpm run smoke:deployed
242
- ```
243
-
244
- 第一条命令验证真实模型目录的认证门禁和 `(OAuth)` 标签。第二条会通过运行中的 DSH 分别执行 Codex/Kimi 的 tool-call 与第二个用户 turn(覆盖 `INVALID_REPLAY_STATE` 回归),随后恢复显式指定的默认模型并归档测试会话;为避免覆盖现有默认设置,不提供 `DSH_RESTORE_*` 时脚本拒绝运行。
245
-
246
- ## 故障排查
247
-
248
- | 现象 | 处理 |
249
- |---|---|
250
- | 还在搜 / 装着 `dsh-grok-build` | 仓库已更名为 `dsh-coding-subscription-oauth`;旧 GitHub 仓库已删除。请改用 npm 包或 `github:lninghaha/dsh-coding-subscription-oauth` |
251
- | Codex localhost callback 打不开 | 改用设备码,或把完整 redirect URL 粘贴回设置页 |
252
- | Claude localhost callback 在远端浏览器 | 把完整 redirect URL 粘贴回设置页 |
253
- | Kimi 401/403 | 重新登录并确认 Kimi Code 会员有效;不要改成 moonshot.cn OAuth |
254
- | OAuth refresh failed | 对应账号重新登录;插件不会回退到其他账号或 API key |
255
- | 模型 route 重复 | 保留本插件的 `*-oauth` alias,移除冲突的第三方 OAuth 插件 |
256
- | Antigravity 页面 404 | 安全配置默认禁用了 `dsh-agy-web`;使用 CLI |
257
- | Google/Claude/OpenAI 网络不可达 | 检查插件 scoped proxy;不要重启或修改系统网络服务 |
258
-
259
- ## 合规提示
260
-
261
- 订阅 OAuth 接入第三方 harness 可能违反或触及供应商服务条款。仅供个人账号使用,自行承担配额和账号风险;商用请使用官方 API-key 通道。
1
+ # 安装与使用 · dsh-coding-subscription-oauth
2
+
3
+ 本仓库原名 **`dsh-grok-build`**。普通用户请使用已发布的 npm 版本:
4
+
5
+ ```bash
6
+ dsh plugin --profile web add dsh-coding-subscription-oauth@0.8.0
7
+ ```
8
+
9
+ CLI 新命令是 `dsh-coding-oauth`(旧命令 `dsh-grok-build` 仍可用)。为兼容已有 profile,Cordis id 仍是 `llm-grok-build-oauth`,设置页 HTTP 路径仍是 `/plugins/dsh-grok-build/*`,凭据文件名不变。
10
+
11
+ 第一次公开发布是 **`0.4.1`**。`0.6.1` 从未正式发布或打包,其未发布改动已合入当前推荐的 **`0.6.3`**:
12
+
13
+ ```bash
14
+ dsh plugin --profile web add dsh-coding-subscription-oauth@0.8.0
15
+ dsh plugin --profile web update dsh-coding-subscription-oauth
16
+ ```
17
+
18
+ ## 前置条件
19
+
20
+ - DeepSeek Harness `0.1.1-rc.2`(精确已验证 BOM,见 `compatibility/dsh-bom.json`)
21
+ - Node.js 22.19+
22
+ - 需要使用的个人编码订阅;没有 Claude/Google 账号也可以先安装路由
23
+ - 部分网络需要 HTTP/HTTPS 代理
24
+
25
+ `0.1.2-alpha.*` 与 `0.1.5-rc.1` 可作为 BOM **未验证候选**出现,但不是生产 pin。在把候选提升为 `verified` 之前,不要把它们当作正式兼容声明。面向 `0.1.5-rc.1` 的客户端 inject 已不再要求 `@deepseek-ai/dsh-client-runtime`(该包在候选宿主上不存在);缺失的可选 inject 仍为 soft diagnostic。OAuth provider profile 会初始化空的 `modelErrors` map,避免候选宿主在模型解析时对 undefined 调用 `.get`(见 `#38`)。
26
+
27
+ ## 安装
28
+
29
+ ```bash
30
+ # 普通用户:当前 npm 发布版
31
+ dsh plugin --profile web add dsh-coding-subscription-oauth@0.8.0
32
+
33
+ # 开发 / 备用:从 GitHub
34
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
35
+
36
+ # 本地开发目录(备用)
37
+ # dsh plugin --profile web add ./dsh-coding-subscription-oauth
38
+
39
+ # Google Antigravity 可选依赖,固定版本
40
+ dsh plugin --profile web add dsh-agy@0.1.2
41
+ ```
42
+
43
+ 安装后重启现有 DSH Web 进程;不要另起一个端口相同的服务器。
44
+
45
+ ## 升级注意事项
46
+
47
+ - 本版按 DSH `0.1.1-rc.2` 的精确兼容矩阵发布;生产环境应锁定已验证的 BOM,不要用 `*` 或未验证的宽泛 peer range。候选宿主(如 `0.1.5-rc.1`)只记在 `candidates[]`,须经隔离冒烟后再考虑提升。
48
+ - 从 `0.6.0` 升级到 `0.6.2` 后再重启:`0.6.0` 在严格 Cordis 注入检查下可能因读取尚未注入的可选服务而拖垮插件树。这个补丁不迁移或重置 OAuth 凭据、Gateway、模型/适配器 ID 与缓存。
49
+ - 从 `0.6.3` 升级到 `0.6.4`:统一固定 `dsh-coding-oauth-core@0.1.2` 与 `undici@7.29.0`;无配置、凭据、数据或路由迁移。
50
+ - 从 `0.7.1` 升级到 `0.8.0`:可选 OpenCode Go 兼容(`gateway.opencodeGo.enabled`,默认关);无配置/凭据/路由迁移。
51
+ - 从 `0.7.0` 升级到 `0.7.1`:OAuth profile 初始化空 `modelErrors`,修复 DSH `0.1.5-rc.1` 选模型时 `Cannot read properties of undefined (reading 'get')`(`#38`);无配置/凭据/路由迁移。
52
+ - `0.6.5` 升级到 `0.7.0`:AuthDocument v2 多账号与 Accounts UI;去掉 `@deepseek-ai/dsh-client-runtime` inject;BOM 记录未验证候选 `0.1.5-rc.1`(verified 仍为 `0.1.1-rc.2`);无配置/凭据/路由破坏性迁移。
53
+ - `0.6.4` 升级到 `0.6.5`:Gateway key 的 reveal/rotate 仅限 `accessMode === "loopback"`(与 Settings UI 一致);无配置、凭据、数据或路由迁移。npm 包不再附带 `src/`,运行时仍为生成的 `lib/`。
54
+ - 宿主边界(无需操作者迁移):客户端 classic-script 不再 inject `@deepseek-ai/dsh-client-runtime`;`ClientContext` 从 `@deepseek-ai/cordis` 解析。这与 Hub `0.1.5-rc.1` 上的适配一致,避免陈旧 inject 诊断。
55
+ - 在同一个 **web profile** 中先保证 `dsh-coding-oauth-core@0.1.2` 可从 npm 解析,再安装 Subscription `0.8.0`(以及需要的 `dsh-hub-oauth-gateway@1.13.0`)。Core 只是共享 npm 依赖,不是单独的 DSH 插件,用户不需要执行 `dsh plugin add dsh-coding-oauth-core`。
56
+ - 共装 Hub 与 Subscription 时,先安装 `dsh-hub-oauth-gateway@1.13.0` 与 Subscription `0.8.0`,完成后只重启一次现有 DSH Web 进程;Hub 提供完整用量中心,Subscription 显示紧凑状态入口。只升级 Subscription 仍可独立工作。
57
+ - 升级会保留既有 Cordis id、OAuth 凭据文件、模型/适配器 ID、Gateway 配置和模型缓存;不要为了“清理旧版本”删除这些文件。若旧包名 `dsh-grok-build` 仍在 profile 中,只移除那条旧插件记录,再安装当前包,避免重复路由。
58
+ - 回滚时恢复上一个插件版本并重启一次,保留凭据和配置;先查看兼容性诊断与失败原因,不要用清空凭据来代替回滚。
59
+ - DSH Web 与本地 Gateway 继续只绑定 loopback。远程 Settings 只能走 SSH 隧道或满足 owner proof、精确 Origin 和 CSRF proof 的 HTTPS 反向代理;升级不会放宽到 `0.0.0.0`。
60
+
61
+ 本地 API 网关默认关闭。需要时在 profile 里打开(只绑 loopback):
62
+
63
+ ```yaml
64
+ gateway:
65
+ enabled: true
66
+ bind: 127.0.0.1
67
+ port: 18080
68
+ opencodeGo:
69
+ enabled: false
70
+ ```
71
+
72
+ 或在 Settings Coding OAuth Gateway 标签页打开。Bearer key 存在 `$DSH_HOME/.coding-oauth-gateway.json`。不要绑定 `0.0.0.0`。
73
+
74
+ 可选的 **OpenCode Go** 兼容(`gateway.opencodeGo.enabled`,默认关)可在 Gateway 标签页单独打开:开启后 `POST /v1/chat/completions` 会转发到固定的 `https://opencode.ai/zen/go/v1/chat/completions`,并注入粘性 `x-opencode-session`,用于兼容未带 OpenCode 会话粘性的客户端(否则常见 `MissingSessionID`)。会话 id 优先级:`x-deepseek-harness-session-id` → `x-opencode-session` → `x-session-id` → body `session_id` → 生成 UUID。此时请把网关 Bearer key 设为你的 OpenCode API key;无需重启即可切换。
75
+
76
+ ## 安全访问远程 Settings
77
+
78
+ DSH Web 仍应只绑定 loopback。远程浏览器必须通过 SSH 隧道,或通过已经完成属主认证的 HTTPS 反向代理访问;不能把 DSH 或本插件直接监听到 `0.0.0.0`。
79
+
80
+ 插件优先采用 DSH 提供的 `ownerRequestPolicy` 宿主能力。宿主尚未提供该能力时,可启用严格 fallback:
81
+
82
+ ```yaml
83
+ - id: llm-grok-build-oauth
84
+ config:
85
+ ownerRequest:
86
+ loopbackAccessMode: ssh-tunnel
87
+ trustedProxy:
88
+ peers: [<反向代理的实际 TCP 来源地址>]
89
+ origins: [https://dsh.example.com]
90
+ ownerProof: <由本机密钥管理或部署模板注入>
91
+ csrfToken: <独立于 ownerProof 的本机密钥>
92
+ ```
93
+
94
+ 上面的尖括号内容是占位符,不可原样使用;真实 proof 只放在被 Git 忽略的本机部署配置或密钥注入层。反向代理必须保留公开 `Host`,在完成属主认证后向上游注入 `X-DSH-Owner-Proof`,并为变更请求注入独立的 `X-DSH-CSRF-Token`。插件同时核验实际 TCP peer、精确 HTTPS `Origin`/`Host` `Sec-Fetch-Site: same-origin`;`X-Forwarded-*` 不能授权。任一项缺失都会 fail closed。
95
+
96
+ 若把同机反向代理的 loopback 地址列为 `peers`,来自该地址的所有请求都会按代理流量校验,不能再回退为本地请求。这是防止反代改写 `Host` 后绕过 proof 的安全边界;配置前应保留独立的 SSH 修复通道。
97
+
98
+ ## Antigravity 安全配置
99
+
100
+ `dsh-agy@0.1.2` 的 `/agy` standalone dashboard 没有自己的认证,并包含凭据导出接口。Web 服务带 trusted-host 或反向代理时,建议在 profile 最终 `cordis.patch.yml` 禁用该 dashboard:
101
+
102
+ ```yaml
103
+ - id: dsh-agy-web
104
+ disabled: true
105
+ ```
106
+
107
+ 这不会禁用 `agy` LLM route 或 profile 内的 `dsh-agy` CLI。
108
+
109
+ Google OAuth 后续可用:
110
+
111
+ ```bash
112
+ NODE_USE_ENV_PROXY=1 \
113
+ HTTPS_PROXY=http://127.0.0.1:7890 \
114
+ dsh plugin --profile web exec dsh-agy login --headless
115
+ ```
116
+
117
+ 仅在当前网络确实需要代理时设置 `NODE_USE_ENV_PROXY` / `HTTPS_PROXY`;其他环境直接执行最后一行即可。不要把 Google credential export 粘贴到聊天或日志。
118
+
119
+ ## 代理配置
120
+
121
+ 推荐在 profile 的最终 patch 里配置常驻服务:
122
+
123
+ ```yaml
124
+ - id: llm-grok-build-oauth
125
+ config:
126
+ proxy: http://127.0.0.1:7890
127
+ proxyKimi: false
128
+ ```
129
+
130
+ 解析优先级:`config.proxy` → `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY` / `HTTP_PROXY`。
131
+
132
+ 默认进入代理的域名组:
133
+
134
+ - xAI/Grok Build
135
+ - OpenAI Codex
136
+ - Claude/Anthropic
137
+ - Google OAuth/Cloud Code
138
+
139
+ Kimi Code 中国流量默认直连;只有 `proxyKimi: true` 才代理。
140
+
141
+ ## 弹性重试
142
+
143
+ OAuth access token 会在本地记录过期时间前 5 分钟主动刷新。服务端若仍以 401/403 拒绝一个本地尚未过期的令牌,插件会把凭据 `expires` 回写到过去,重试的 step 先刷新再发请求。瞬时故障(429/5xx/超时/网络)和 AUTH 默认最多重试 5 次(5 s → 10 s → 20 s → 40 s → 80 s,约 155 s 叠加时常,10% jitter)。xAI「at capacity」等文案会重映射为 `RATE_LIMIT` 后再退避。配额耗尽和 refresh token 失效不重试。
144
+
145
+ 部署级覆盖(可选):
146
+
147
+ ```yaml
148
+ - id: llm-grok-build-oauth
149
+ config:
150
+ retryPolicy:
151
+ mode: normal
152
+ maxRetries: 5
153
+ retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
154
+ backoff: { initialDelayMs: 5000, maxDelayMs: 80000, jitterRatio: 0.1 }
155
+ ```
156
+
157
+ ## 登录
158
+
159
+ ### 设置页
160
+
161
+ 打开 **设置 → 编码 OAuth**:
162
+
163
+ - **Grok Build**:授权码或设备码
164
+ - **OpenAI Codex**:远程部署推荐设备码;浏览器 PKCE 支持粘贴 redirect URL
165
+ - **Kimi Code**:设备码
166
+ - **Claude Code**:浏览器 PKCE,远程访问时粘贴完整 localhost redirect URL
167
+
168
+ 设置页会**只读发现**白名单内的官方 Grok / Codex / Kimi / Claude CLI OAuth 文件。同步是显式的单向**拉取**(不是自动导入):发现 → 预览 → 冲突/指纹核对 → 确认覆盖。官方 CLI 文件从不被写入。读取会拒绝符号链接、非普通文件、非属主文件、组/其他人可读,以及超大文档(`O_NOFOLLOW`)。预览票据一次性、五分钟过期、最多 32 张。CLI 的 `dsh-coding-oauth import` 仍只支持 Grok。
169
+
170
+ 登录过程只交换授权 code;状态接口不返回 access/refresh token。
171
+
172
+ ### 可选能力
173
+
174
+ 设置页的八项订阅能力开关默认全部关闭,打开后立即生效(无需重启):`codexSearch`、`codexImages`、`codexImageEdits`、`codexImagesAnyModel`、`codexUsage`、`codexFast`、`grokImagineImage`、`grokImagineVideo`。`codexImagesAnyModel` 仅放宽调用模型路由限制;仍要求已登录 Codex、开启对应图像能力,并保留当前会话附件归属和编辑授权检查。
175
+
176
+ 数值控制为 `searchResults`(1–20,默认 5)、`imageCount`(1–4,默认 1)、`videoArtifactTtlMs`(1 小时–7 天,默认 7 天;界面以 1–168 小时显示)。降低视频保留时间会立即缩短并清理已有产物;提高只影响之后生成的产物。管理员可在插件配置的 `capabilities` 下提供不含秘密的 composition 默认值;`coding-subscription-oauth` 设置区中的用户值会覆盖该 base,省略时所有开关仍默认关闭。
177
+
178
+ `codex-oauth-fast` 仅在最新一次 live catalog 标明至少有一个 `priority` 可用模型后才会出现。请求发送 `service_tier: priority` 和路由提示;界面写 **已请求 Fast**,不保证延迟或上游兑现。Codex 搜索/用量/图像是需打开的私有 `chatgpt.com/backend-api` 端点;图像固定 `gpt-image-2`;编辑只接受当前会话顶层、本会话持有的附件。
179
+
180
+ Grok Imagine 只走官方 `https://api.x.ai`(`grok-imagine-image-2.0` / `grok-imagine-video-1.5`),凭据是独立的 DSH 引用 `XAI_API_KEY`——不用 Grok OAuth,也不回退进程环境变量。下载受 MIME / 大小 / 超时 / 重定向 / DNS 控制,冻结主机为 `imgen.x.ai`、`videogen.x.ai`、`vidgen.x.ai`;私有产物库的单件与唯一对象总量均硬限 256 MiB、最长七天;只通过同源 loopback 路由提供。
181
+
182
+ ### CLI
183
+
184
+ ```bash
185
+ # Grok(`dsh-grok-build` 仍是同一条命令的别名)
186
+ dsh-coding-oauth login
187
+ dsh-coding-oauth login --pkce
188
+ dsh-coding-oauth import
189
+
190
+ # Codex / Kimi / Claude
191
+ dsh-coding-oauth login codex --device-auth
192
+ dsh-coding-oauth login codex --browser
193
+ dsh-coding-oauth login kimi
194
+ dsh-coding-oauth login claude
195
+
196
+ # 状态/登出
197
+ dsh-coding-oauth status all
198
+ dsh-coding-oauth logout kimi
199
+ ```
200
+
201
+ ## 模型路由
202
+
203
+ - `grok-build/<model>`
204
+ - `codex-oauth/<model>`
205
+ - `codex-oauth-fast/<model>`(可选;仅在最新 live catalog 标明 `priority` 可用后出现,界面为 已请求 Fast)
206
+ - `kimi-code-oauth/<model>`
207
+ - `claude-code-oauth/<model>`
208
+ - `agy/<model>`(安装 dsh-agy 后)
209
+
210
+ 这些别名专门避免与已有的 `xai`、`openai`、`kimi-coding` API-key routes 冲突。插件不会修改现有默认模型设置。未认证的 OAuth route 不向模型选择器返回任何模型;认证后供应商名显示为 `(OAuth)`,登录/登出会立即触发目录刷新。
211
+
212
+ ## 凭据与缓存
213
+
214
+ OAuth 凭据:
215
+
216
+ ```text
217
+ $DSH_HOME/.grok-build-auth.json
218
+ $DSH_HOME/.codex-oauth-auth.json
219
+ $DSH_HOME/.kimi-code-oauth-auth.json
220
+ $DSH_HOME/.claude-code-oauth-auth.json
221
+ ```
222
+
223
+ 均为 `0600`、原子写、文件锁保护。模型缓存为对应的 `*-models.json`,不含 token。Grok Imagine 使用 DSH 凭据引用 `XAI_API_KEY`,与上述 OAuth 文件分离;视频产物存入 `$DSH_HOME/.dsh-coding-subscription-oauth-media/`(目录 `0700`、文件 `0600`),按保留设置自动清理。
224
+
225
+ ## 卸载
226
+
227
+ ```bash
228
+ dsh plugin --profile web remove dsh-agy dsh-coding-subscription-oauth
229
+ rm -f ~/.dsh/.grok-build-auth.json ~/.dsh/.codex-oauth-auth.json \
230
+ ~/.dsh/.kimi-code-oauth-auth.json ~/.dsh/.claude-code-oauth-auth.json
231
+ rm -f ~/.dsh/.grok-build-models.json ~/.dsh/.codex-oauth-models.json \
232
+ ~/.dsh/.kimi-code-oauth-models.json ~/.dsh/.claude-code-oauth-models.json
233
+ ```
234
+
235
+ 只有在确认不再需要账号后才删除凭据文件。
236
+
237
+ ## 部署验收
238
+
239
+ 以下命令面向维护者,需要在源码 checkout 中运行;通过 npm 安装的用户无需执行。
240
+
241
+ ```bash
242
+ pnpm run verify:deployed
243
+
244
+ DSH_RESTORE_PROVIDER=openai \
245
+ DSH_RESTORE_MODEL=gpt-5.6-sol \
246
+ DSH_RESTORE_REASONING=max \
247
+ pnpm run smoke:deployed
248
+ ```
249
+
250
+ 第一条命令验证真实模型目录的认证门禁和 `(OAuth)` 标签。第二条会通过运行中的 DSH 分别执行 Codex/Kimi tool-call 与第二个用户 turn(覆盖 `INVALID_REPLAY_STATE` 回归),随后恢复显式指定的默认模型并归档测试会话;为避免覆盖现有默认设置,不提供 `DSH_RESTORE_*` 时脚本拒绝运行。
251
+
252
+ ## 故障排查
253
+
254
+ | 现象 | 处理 |
255
+ |---|---|
256
+ | 还在搜 / 装着 `dsh-grok-build` | 仓库已更名为 `dsh-coding-subscription-oauth`;旧 GitHub 仓库已删除。请改用 npm 包或 `github:lninghaha/dsh-coding-subscription-oauth` |
257
+ | Codex localhost callback 打不开 | 改用设备码,或把完整 redirect URL 粘贴回设置页 |
258
+ | Claude localhost callback 在远端浏览器 | 把完整 redirect URL 粘贴回设置页 |
259
+ | Kimi 401/403 | 重新登录并确认 Kimi Code 会员有效;不要改成 moonshot.cn OAuth |
260
+ | OAuth refresh failed | 对应账号重新登录;插件不会回退到其他账号或 API key |
261
+ | 模型 route 重复 | 保留本插件的 `*-oauth` alias,移除冲突的第三方 OAuth 插件 |
262
+ | Antigravity 页面 404 | 安全配置默认禁用了 `dsh-agy-web`;使用 CLI |
263
+ | Google/Claude/OpenAI 网络不可达 | 检查插件 scoped proxy;不要重启或修改系统网络服务 |
264
+
265
+ ## 合规提示
266
+
267
+ 订阅 OAuth 接入第三方 harness 可能违反或触及供应商服务条款。仅供个人账号使用,自行承担配额和账号风险;商用请使用官方 API-key 通道。
package/LICENSE CHANGED
@@ -1,19 +1,19 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- Copyright 2026 dsh-xai contributors
8
-
9
- Licensed under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License.
11
- You may obtain a copy of the License at
12
-
13
- http://www.apache.org/licenses/LICENSE-2.0
14
-
15
- Unless required by applicable law or agreed to in writing, software
16
- distributed under the License is distributed on an "AS IS" BASIS,
17
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- See the License for the specific language governing permissions and
19
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ Copyright 2026 dsh-xai contributors
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
package/NOTICE CHANGED
@@ -1,11 +1,11 @@
1
- NOTICE
2
- ======
3
-
4
- dsh-coding-subscription-oauth (formerly dsh-grok-build) — coding-subscription OAuth for DeepSeek Harness
5
- Copyright 2026 lninghaha
6
-
7
- This product includes software developed by the dsh-xai project
8
- (https://github.com/MirDie/dsh-xai), licensed under the Apache License,
9
- Version 2.0. Portions of src/store.ts, src/session.ts, src/grok-import.ts,
10
- src/redact.ts, src/invariant.ts, src/adapter.ts, src/auth.ts, src/bin.ts and
11
- the build scaffolding are derived from that work.
1
+ NOTICE
2
+ ======
3
+
4
+ dsh-coding-subscription-oauth (formerly dsh-grok-build) — coding-subscription OAuth for DeepSeek Harness
5
+ Copyright 2026 lninghaha
6
+
7
+ This product includes software developed by the dsh-xai project
8
+ (https://github.com/MirDie/dsh-xai), licensed under the Apache License,
9
+ Version 2.0. Portions of src/store.ts, src/session.ts, src/grok-import.ts,
10
+ src/redact.ts, src/invariant.ts, src/adapter.ts, src/auth.ts, src/bin.ts and
11
+ the build scaffolding are derived from that work.