dsh-coding-subscription-oauth 0.6.4 → 0.6.5

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 (144) hide show
  1. package/CHANGELOG.md +280 -255
  2. package/CONTRIBUTING.md +138 -129
  3. package/INSTALL.md +256 -255
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +303 -303
  7. package/README.es.md +304 -304
  8. package/README.fr.md +304 -304
  9. package/README.ja.md +304 -304
  10. package/README.ko.md +304 -304
  11. package/README.md +320 -320
  12. package/README.pt-BR.md +304 -304
  13. package/README.ru.md +304 -304
  14. package/README.zh-CN.md +318 -318
  15. package/compatibility/dsh-bom.json +30 -30
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +212 -212
  18. package/docs/02-architecture.md +141 -137
  19. package/docs/02-architecture.zh-CN.md +141 -137
  20. package/lib/bin.js.map +1 -1
  21. package/lib/client.js +1 -1
  22. package/lib/client.js.map +1 -1
  23. package/lib/gateway-protocol.d.ts +3 -46
  24. package/lib/gateway-protocol.d.ts.map +1 -1
  25. package/lib/gateway-routes.d.ts.map +1 -1
  26. package/lib/grok-errors.d.ts +2 -12
  27. package/lib/grok-errors.d.ts.map +1 -1
  28. package/lib/grok-imagine/client.d.ts +73 -0
  29. package/lib/grok-imagine/client.d.ts.map +1 -0
  30. package/lib/grok-imagine/index.d.ts +8 -0
  31. package/lib/grok-imagine/index.d.ts.map +1 -0
  32. package/lib/grok-imagine/net.d.ts +10 -0
  33. package/lib/grok-imagine/net.d.ts.map +1 -0
  34. package/lib/grok-imagine/parse.d.ts +20 -0
  35. package/lib/grok-imagine/parse.d.ts.map +1 -0
  36. package/lib/grok-imagine/types.d.ts +191 -0
  37. package/lib/grok-imagine/types.d.ts.map +1 -0
  38. package/lib/grok-imagine.d.ts +3 -263
  39. package/lib/grok-imagine.d.ts.map +1 -1
  40. package/lib/http-json.d.ts +2 -9
  41. package/lib/http-json.d.ts.map +1 -1
  42. package/lib/index.js +57 -37
  43. package/lib/index.js.map +4 -4
  44. package/lib/invariant.js.map +1 -1
  45. package/lib/kimi-errors.d.ts +2 -12
  46. package/lib/kimi-errors.d.ts.map +1 -1
  47. package/lib/runtime/gateway-protocol.d.ts +47 -0
  48. package/lib/runtime/gateway-protocol.d.ts.map +1 -0
  49. package/lib/runtime/grok-errors.d.ts +13 -0
  50. package/lib/runtime/grok-errors.d.ts.map +1 -0
  51. package/lib/runtime/http-json.d.ts +10 -0
  52. package/lib/runtime/http-json.d.ts.map +1 -0
  53. package/lib/runtime/kimi-errors.d.ts +13 -0
  54. package/lib/runtime/kimi-errors.d.ts.map +1 -0
  55. package/media/en/settings_accounts.png +0 -0
  56. package/media/en/settings_capabilities.png +0 -0
  57. package/media/en/settings_gateway.png +0 -0
  58. package/media/settings_accounts.png +0 -0
  59. package/media/settings_capabilities.png +0 -0
  60. package/media/settings_gateway.png +0 -0
  61. package/media/settings_overview.png +0 -0
  62. package/media/zh-CN/settings_accounts.png +0 -0
  63. package/media/zh-CN/settings_capabilities.png +0 -0
  64. package/media/zh-CN/settings_gateway.png +0 -0
  65. package/package.json +225 -220
  66. package/patches/dsh-agy@0.1.2.patch +25 -25
  67. package/scripts/release.mjs +187 -186
  68. package/scripts/smoke-deployed-routes.mjs +146 -146
  69. package/scripts/verify-deployed-catalog.mjs +87 -87
  70. package/src/adapter.ts +0 -348
  71. package/src/alias-adapter.ts +0 -147
  72. package/src/auth-routes.ts +0 -921
  73. package/src/auth.ts +0 -67
  74. package/src/bin.ts +0 -350
  75. package/src/capability-routes.ts +0 -279
  76. package/src/capability-runtime.ts +0 -314
  77. package/src/capability-settings.ts +0 -671
  78. package/src/capability-tools.ts +0 -685
  79. package/src/catalog.ts +0 -271
  80. package/src/client/GrokBuildSettings.tsx +0 -771
  81. package/src/client/api.ts +0 -88
  82. package/src/client/components/AboutTab.tsx +0 -30
  83. package/src/client/components/AccountsTab.tsx +0 -241
  84. package/src/client/components/Badge.tsx +0 -33
  85. package/src/client/components/CapabilitiesTab.tsx +0 -265
  86. package/src/client/components/CliPullPreview.tsx +0 -116
  87. package/src/client/components/CopyButton.tsx +0 -57
  88. package/src/client/components/GatewayTab.tsx +0 -469
  89. package/src/client/components/NoticeBanner.tsx +0 -46
  90. package/src/client/components/ProgressBar.tsx +0 -53
  91. package/src/client/components/ProviderCard.tsx +0 -606
  92. package/src/client/components/SettingsTabs.tsx +0 -75
  93. package/src/client/components/ToggleSwitch.tsx +0 -71
  94. package/src/client/constants.ts +0 -230
  95. package/src/client/display.ts +0 -61
  96. package/src/client/dshClientAdapter.ts +0 -127
  97. package/src/client/gatewaySnippets.ts +0 -37
  98. package/src/client/index.tsx +0 -156
  99. package/src/client/locales.ts +0 -540
  100. package/src/client/microStyles.ts +0 -52
  101. package/src/client/parsers.ts +0 -398
  102. package/src/client/styles.ts +0 -325
  103. package/src/client/types.ts +0 -199
  104. package/src/codex-http.ts +0 -447
  105. package/src/codex-images.ts +0 -503
  106. package/src/codex-model-capabilities.ts +0 -320
  107. package/src/codex-search.ts +0 -245
  108. package/src/codex-usage.ts +0 -263
  109. package/src/compatibility.ts +0 -55
  110. package/src/dsh-host-adapter.ts +0 -173
  111. package/src/gateway-anthropic-messages.ts +0 -84
  112. package/src/gateway-auth.ts +0 -102
  113. package/src/gateway-backend.ts +0 -274
  114. package/src/gateway-body.ts +0 -49
  115. package/src/gateway-config.ts +0 -76
  116. package/src/gateway-http.ts +0 -104
  117. package/src/gateway-openai-chat.ts +0 -124
  118. package/src/gateway-openai-responses.ts +0 -53
  119. package/src/gateway-parse.ts +0 -224
  120. package/src/gateway-protocol.ts +0 -52
  121. package/src/gateway-routes.ts +0 -158
  122. package/src/gateway.ts +0 -258
  123. package/src/grok-errors.ts +0 -24
  124. package/src/grok-imagine.ts +0 -1627
  125. package/src/grok-import.ts +0 -151
  126. package/src/http-json.ts +0 -82
  127. package/src/ids.ts +0 -59
  128. package/src/imagine-routes.ts +0 -463
  129. package/src/index.ts +0 -735
  130. package/src/invariant.ts +0 -17
  131. package/src/kimi-errors.ts +0 -26
  132. package/src/media-store.ts +0 -927
  133. package/src/oauth-import-routes.ts +0 -324
  134. package/src/oauth-providers.ts +0 -152
  135. package/src/oauth-session.ts +0 -183
  136. package/src/oauth-sources.ts +0 -1104
  137. package/src/oauth.ts +0 -620
  138. package/src/provider.ts +0 -128
  139. package/src/proxy.ts +0 -11
  140. package/src/redact.ts +0 -72
  141. package/src/session.ts +0 -218
  142. package/src/store.ts +0 -217
  143. package/src/web-origin.ts +0 -296
  144. package/src/web-routes.ts +0 -38
package/INSTALL.md CHANGED
@@ -1,256 +1,257 @@
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.6.4
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.6.4
15
- dsh plugin --profile web update dsh-coding-subscription-oauth
16
- ```
17
-
18
- ## 前置条件
19
-
20
- - DeepSeek Harness 0.1.1-rc.2(精确已验证 BOM)
21
- - Node.js 22.19+
22
- - 需要使用的个人编码订阅;没有 Claude/Google 账号也可以先安装路由
23
- - 部分网络需要 HTTP/HTTPS 代理
24
-
25
- ## 安装
26
-
27
- ```bash
28
- # 普通用户:当前 npm 发布版
29
- dsh plugin --profile web add dsh-coding-subscription-oauth@0.6.4
30
-
31
- # 开发 / 备用:从 GitHub
32
- dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
33
-
34
- # 本地开发目录(备用)
35
- # dsh plugin --profile web add ./dsh-coding-subscription-oauth
36
-
37
- # Google Antigravity 可选依赖,固定版本
38
- dsh plugin --profile web add dsh-agy@0.1.2
39
- ```
40
-
41
- 安装后重启现有 DSH Web 进程;不要另起一个端口相同的服务器。
42
-
43
- ## 升级注意事项
44
-
45
- - 本版按 DSH `0.1.1-rc.2` 的精确兼容矩阵发布;生产环境应锁定已验证的 BOM,不要用 `*` 或未验证的宽泛 peer range。
46
- - 从 `0.6.0` 升级到 `0.6.2` 后再重启:`0.6.0` 在严格 Cordis 注入检查下可能因读取尚未注入的可选服务而拖垮插件树。这个补丁不迁移或重置 OAuth 凭据、Gateway、模型/适配器 ID 与缓存。
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.6.5
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.6.5
15
+ dsh plugin --profile web update dsh-coding-subscription-oauth
16
+ ```
17
+
18
+ ## 前置条件
19
+
20
+ - DeepSeek Harness 0.1.1-rc.2(精确已验证 BOM)
21
+ - Node.js 22.19+
22
+ - 需要使用的个人编码订阅;没有 Claude/Google 账号也可以先安装路由
23
+ - 部分网络需要 HTTP/HTTPS 代理
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ # 普通用户:当前 npm 发布版
29
+ dsh plugin --profile web add dsh-coding-subscription-oauth@0.6.5
30
+
31
+ # 开发 / 备用:从 GitHub
32
+ dsh plugin --profile web add github:lninghaha/dsh-coding-subscription-oauth
33
+
34
+ # 本地开发目录(备用)
35
+ # dsh plugin --profile web add ./dsh-coding-subscription-oauth
36
+
37
+ # Google Antigravity 可选依赖,固定版本
38
+ dsh plugin --profile web add dsh-agy@0.1.2
39
+ ```
40
+
41
+ 安装后重启现有 DSH Web 进程;不要另起一个端口相同的服务器。
42
+
43
+ ## 升级注意事项
44
+
45
+ - 本版按 DSH `0.1.1-rc.2` 的精确兼容矩阵发布;生产环境应锁定已验证的 BOM,不要用 `*` 或未验证的宽泛 peer range。
46
+ - 从 `0.6.0` 升级到 `0.6.2` 后再重启:`0.6.0` 在严格 Cordis 注入检查下可能因读取尚未注入的可选服务而拖垮插件树。这个补丁不迁移或重置 OAuth 凭据、Gateway、模型/适配器 ID 与缓存。
47
47
  - 从 `0.6.3` 升级到 `0.6.4`:统一固定 `dsh-coding-oauth-core@0.1.1` 与 `undici@7.29.0`;无配置、凭据、数据或路由迁移。
48
- - 在同一个 **web profile** 中先保证 `dsh-coding-oauth-core@0.1.1` 可从 npm 解析,再安装 Subscription `0.6.4`(以及需要的 `dsh-hub-oauth-gateway@1.11.1`)。Core 只是共享 npm 依赖,不是单独的 DSH 插件,用户不需要执行 `dsh plugin add dsh-coding-oauth-core`。
49
- - 共装 Hub Subscription 时,先安装 `dsh-hub-oauth-gateway@1.11.1` Subscription `0.6.4`,完成后只重启一次现有 DSH Web 进程;Hub 提供完整用量中心,Subscription 显示紧凑状态入口。只升级 Subscription 仍可独立工作。
50
- - 升级会保留既有 Cordis id、OAuth 凭据文件、模型/适配器 ID、Gateway 配置和模型缓存;不要为了“清理旧版本”删除这些文件。若旧包名 `dsh-grok-build` 仍在 profile 中,只移除那条旧插件记录,再安装当前包,避免重复路由。
51
- - 回滚时恢复上一个插件版本并重启一次,保留凭据和配置;先查看兼容性诊断与失败原因,不要用清空凭据来代替回滚。
52
- - DSH Web 与本地 Gateway 继续只绑定 loopback。远程 Settings 只能走 SSH 隧道或满足 owner proof、精确 Origin 和 CSRF proof 的 HTTPS 反向代理;升级不会放宽到 `0.0.0.0`。
53
-
54
- 本地 API 网关默认关闭。需要时在 profile 里打开(只绑 loopback):
55
-
56
- ```yaml
57
- gateway:
58
- enabled: true
59
- bind: 127.0.0.1
60
- port: 18080
61
- ```
62
-
63
- 或在 Settings → Coding OAuth → Gateway 标签页打开。Bearer key 存在 `$DSH_HOME/.coding-oauth-gateway.json`。不要绑定 `0.0.0.0`。
64
-
65
- ## 安全访问远程 Settings
66
-
67
- DSH Web 仍应只绑定 loopback。远程浏览器必须通过 SSH 隧道,或通过已经完成属主认证的 HTTPS 反向代理访问;不能把 DSH 或本插件直接监听到 `0.0.0.0`。
68
-
69
- 插件优先采用 DSH 提供的 `ownerRequestPolicy` 宿主能力。宿主尚未提供该能力时,可启用严格 fallback:
70
-
71
- ```yaml
72
- - id: llm-grok-build-oauth
73
- config:
74
- ownerRequest:
75
- loopbackAccessMode: ssh-tunnel
76
- trustedProxy:
77
- peers: [<反向代理的实际 TCP 来源地址>]
78
- origins: [https://dsh.example.com]
79
- ownerProof: <由本机密钥管理或部署模板注入>
80
- csrfToken: <独立于 ownerProof 的本机密钥>
81
- ```
82
-
83
- 上面的尖括号内容是占位符,不可原样使用;真实 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。
84
-
85
- 若把同机反向代理的 loopback 地址列为 `peers`,来自该地址的所有请求都会按代理流量校验,不能再回退为本地请求。这是防止反代改写 `Host` 后绕过 proof 的安全边界;配置前应保留独立的 SSH 修复通道。
86
-
87
- ## Antigravity 安全配置
88
-
89
- `dsh-agy@0.1.2` 的 `/agy` standalone dashboard 没有自己的认证,并包含凭据导出接口。Web 服务带 trusted-host 或反向代理时,建议在 profile 最终 `cordis.patch.yml` 禁用该 dashboard:
90
-
91
- ```yaml
92
- - id: dsh-agy-web
93
- disabled: true
94
- ```
95
-
96
- 这不会禁用 `agy` LLM route 或 profile 内的 `dsh-agy` CLI。
97
-
98
- Google OAuth 后续可用:
99
-
100
- ```bash
101
- NODE_USE_ENV_PROXY=1 \
102
- HTTPS_PROXY=http://127.0.0.1:7890 \
103
- dsh plugin --profile web exec dsh-agy login --headless
104
- ```
105
-
106
- 仅在当前网络确实需要代理时设置 `NODE_USE_ENV_PROXY` / `HTTPS_PROXY`;其他环境直接执行最后一行即可。不要把 Google credential export 粘贴到聊天或日志。
107
-
108
- ## 代理配置
109
-
110
- 推荐在 profile 的最终 patch 里配置常驻服务:
111
-
112
- ```yaml
113
- - id: llm-grok-build-oauth
114
- config:
115
- proxy: http://127.0.0.1:7890
116
- proxyKimi: false
117
- ```
118
-
119
- 解析优先级:`config.proxy` → `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY` / `HTTP_PROXY`。
120
-
121
- 默认进入代理的域名组:
122
-
123
- - xAI/Grok Build
124
- - OpenAI Codex
125
- - Claude/Anthropic
126
- - Google OAuth/Cloud Code
127
-
128
- Kimi Code 中国流量默认直连;只有 `proxyKimi: true` 才代理。
129
-
130
- ## 弹性重试
131
-
132
- 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 失效不重试。
133
-
134
- 部署级覆盖(可选):
135
-
136
- ```yaml
137
- - id: llm-grok-build-oauth
138
- config:
139
- retryPolicy:
140
- mode: normal
141
- maxRetries: 5
142
- retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
143
- backoff: { initialDelayMs: 5000, maxDelayMs: 80000, jitterRatio: 0.1 }
144
- ```
145
-
146
- ## 登录
147
-
148
- ### 设置页
149
-
150
- 打开 **设置 → 编码 OAuth**:
151
-
152
- - **Grok Build**:授权码或设备码
153
- - **OpenAI Codex**:远程部署推荐设备码;浏览器 PKCE 支持粘贴 redirect URL
154
- - **Kimi Code**:设备码
155
- - **Claude Code**:浏览器 PKCE,远程访问时粘贴完整 localhost redirect URL
156
-
157
- 设置页会**只读发现**白名单内的官方 Grok / Codex / Kimi / Claude CLI OAuth 文件。同步是显式的单向**拉取**(不是自动导入):发现 → 预览 → 冲突/指纹核对 → 确认覆盖。官方 CLI 文件从不被写入。读取会拒绝符号链接、非普通文件、非属主文件、组/其他人可读,以及超大文档(`O_NOFOLLOW`)。预览票据一次性、五分钟过期、最多 32 张。CLI 的 `dsh-coding-oauth import` 仍只支持 Grok。
158
-
159
- 登录过程只交换授权 code;状态接口不返回 access/refresh token。
160
-
161
- ### 可选能力
162
-
163
- 设置页的八项订阅能力开关默认全部关闭,打开后立即生效(无需重启):`codexSearch`、`codexImages`、`codexImageEdits`、`codexImagesAnyModel`、`codexUsage`、`codexFast`、`grokImagineImage`、`grokImagineVideo`。`codexImagesAnyModel` 仅放宽调用模型路由限制;仍要求已登录 Codex、开启对应图像能力,并保留当前会话附件归属和编辑授权检查。
164
-
165
- 数值控制为 `searchResults`(1–20,默认 5)、`imageCount`(1–4,默认 1)、`videoArtifactTtlMs`(1 小时–7 天,默认 7 天;界面以 1–168 小时显示)。降低视频保留时间会立即缩短并清理已有产物;提高只影响之后生成的产物。管理员可在插件配置的 `capabilities` 下提供不含秘密的 composition 默认值;`coding-subscription-oauth` 设置区中的用户值会覆盖该 base,省略时所有开关仍默认关闭。
166
-
167
- `codex-oauth-fast` 仅在最新一次 live catalog 标明至少有一个 `priority` 可用模型后才会出现。请求发送 `service_tier: priority` 和路由提示;界面写 **已请求 Fast**,不保证延迟或上游兑现。Codex 搜索/用量/图像是需打开的私有 `chatgpt.com/backend-api` 端点;图像固定 `gpt-image-2`;编辑只接受当前会话顶层、本会话持有的附件。
168
-
169
- 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 路由提供。
170
-
171
- ### CLI
172
-
173
- ```bash
174
- # Grok(`dsh-grok-build` 仍是同一条命令的别名)
175
- dsh-coding-oauth login
176
- dsh-coding-oauth login --pkce
177
- dsh-coding-oauth import
178
-
179
- # Codex / Kimi / Claude
180
- dsh-coding-oauth login codex --device-auth
181
- dsh-coding-oauth login codex --browser
182
- dsh-coding-oauth login kimi
183
- dsh-coding-oauth login claude
184
-
185
- # 状态/登出
186
- dsh-coding-oauth status all
187
- dsh-coding-oauth logout kimi
188
- ```
189
-
190
- ## 模型路由
191
-
192
- - `grok-build/<model>`
193
- - `codex-oauth/<model>`
194
- - `codex-oauth-fast/<model>`(可选;仅在最新 live catalog 标明 `priority` 可用后出现,界面为 已请求 Fast)
195
- - `kimi-code-oauth/<model>`
196
- - `claude-code-oauth/<model>`
197
- - `agy/<model>`(安装 dsh-agy 后)
198
-
199
- 这些别名专门避免与已有的 `xai`、`openai`、`kimi-coding` API-key routes 冲突。插件不会修改现有默认模型设置。未认证的 OAuth route 不向模型选择器返回任何模型;认证后供应商名显示为 `(OAuth)`,登录/登出会立即触发目录刷新。
200
-
201
- ## 凭据与缓存
202
-
203
- OAuth 凭据:
204
-
205
- ```text
206
- $DSH_HOME/.grok-build-auth.json
207
- $DSH_HOME/.codex-oauth-auth.json
208
- $DSH_HOME/.kimi-code-oauth-auth.json
209
- $DSH_HOME/.claude-code-oauth-auth.json
210
- ```
211
-
212
- 均为 `0600`、原子写、文件锁保护。模型缓存为对应的 `*-models.json`,不含 token。Grok Imagine 使用 DSH 凭据引用 `XAI_API_KEY`,与上述 OAuth 文件分离;视频产物存入 `$DSH_HOME/.dsh-coding-subscription-oauth-media/`(目录 `0700`、文件 `0600`),按保留设置自动清理。
213
-
214
- ## 卸载
215
-
216
- ```bash
217
- dsh plugin --profile web remove dsh-agy dsh-coding-subscription-oauth
218
- rm -f ~/.dsh/.grok-build-auth.json ~/.dsh/.codex-oauth-auth.json \
219
- ~/.dsh/.kimi-code-oauth-auth.json ~/.dsh/.claude-code-oauth-auth.json
220
- rm -f ~/.dsh/.grok-build-models.json ~/.dsh/.codex-oauth-models.json \
221
- ~/.dsh/.kimi-code-oauth-models.json ~/.dsh/.claude-code-oauth-models.json
222
- ```
223
-
224
- 只有在确认不再需要账号后才删除凭据文件。
225
-
226
- ## 部署验收
227
-
228
- 以下命令面向维护者,需要在源码 checkout 中运行;通过 npm 安装的用户无需执行。
229
-
230
- ```bash
231
- pnpm run verify:deployed
232
-
233
- DSH_RESTORE_PROVIDER=openai \
234
- DSH_RESTORE_MODEL=gpt-5.6-sol \
235
- DSH_RESTORE_REASONING=max \
236
- pnpm run smoke:deployed
237
- ```
238
-
239
- 第一条命令验证真实模型目录的认证门禁和 `(OAuth)` 标签。第二条会通过运行中的 DSH 分别执行 Codex/Kimi 的 tool-call 与第二个用户 turn(覆盖 `INVALID_REPLAY_STATE` 回归),随后恢复显式指定的默认模型并归档测试会话;为避免覆盖现有默认设置,不提供 `DSH_RESTORE_*` 时脚本拒绝运行。
240
-
241
- ## 故障排查
242
-
243
- | 现象 | 处理 |
244
- |---|---|
245
- | 还在搜 / 装着 `dsh-grok-build` | 仓库已更名为 `dsh-coding-subscription-oauth`;旧 GitHub 仓库已删除。请改用 npm 包或 `github:lninghaha/dsh-coding-subscription-oauth` |
246
- | Codex localhost callback 打不开 | 改用设备码,或把完整 redirect URL 粘贴回设置页 |
247
- | Claude localhost callback 在远端浏览器 | 把完整 redirect URL 粘贴回设置页 |
248
- | Kimi 401/403 | 重新登录并确认 Kimi Code 会员有效;不要改成 moonshot.cn OAuth |
249
- | OAuth refresh failed | 对应账号重新登录;插件不会回退到其他账号或 API key |
250
- | 模型 route 重复 | 保留本插件的 `*-oauth` alias,移除冲突的第三方 OAuth 插件 |
251
- | Antigravity 页面 404 | 安全配置默认禁用了 `dsh-agy-web`;使用 CLI |
252
- | Google/Claude/OpenAI 网络不可达 | 检查插件 scoped proxy;不要重启或修改系统网络服务 |
253
-
254
- ## 合规提示
255
-
256
- 订阅 OAuth 接入第三方 harness 可能违反或触及供应商服务条款。仅供个人账号使用,自行承担配额和账号风险;商用请使用官方 API-key 通道。
48
+ - `0.6.4` 升级到 `0.6.5`:Gateway key 的 reveal/rotate 仅限 `accessMode === "loopback"`(与 Settings UI 一致);无配置、凭据、数据或路由迁移。npm 包不再附带 `src/`,运行时仍为生成的 `lib/`。
49
+ - 在同一个 **web profile** 中先保证 `dsh-coding-oauth-core@0.1.1` 可从 npm 解析,再安装 Subscription `0.6.5`(以及需要的 `dsh-hub-oauth-gateway@1.11.1`)。Core 只是共享 npm 依赖,不是单独的 DSH 插件,用户不需要执行 `dsh plugin add dsh-coding-oauth-core`。
50
+ - 共装 Hub Subscription 时,先安装 `dsh-hub-oauth-gateway@1.11.1` Subscription `0.6.5`,完成后只重启一次现有 DSH Web 进程;Hub 提供完整用量中心,Subscription 显示紧凑状态入口。只升级 Subscription 仍可独立工作。
51
+ - 升级会保留既有 Cordis id、OAuth 凭据文件、模型/适配器 ID、Gateway 配置和模型缓存;不要为了“清理旧版本”删除这些文件。若旧包名 `dsh-grok-build` 仍在 profile 中,只移除那条旧插件记录,再安装当前包,避免重复路由。
52
+ - 回滚时恢复上一个插件版本并重启一次,保留凭据和配置;先查看兼容性诊断与失败原因,不要用清空凭据来代替回滚。
53
+ - DSH Web 与本地 Gateway 继续只绑定 loopback。远程 Settings 只能走 SSH 隧道或满足 owner proof、精确 Origin 和 CSRF proof 的 HTTPS 反向代理;升级不会放宽到 `0.0.0.0`。
54
+
55
+ 本地 API 网关默认关闭。需要时在 profile 里打开(只绑 loopback):
56
+
57
+ ```yaml
58
+ gateway:
59
+ enabled: true
60
+ bind: 127.0.0.1
61
+ port: 18080
62
+ ```
63
+
64
+ 或在 Settings → Coding OAuth → Gateway 标签页打开。Bearer key 存在 `$DSH_HOME/.coding-oauth-gateway.json`。不要绑定 `0.0.0.0`。
65
+
66
+ ## 安全访问远程 Settings
67
+
68
+ DSH Web 仍应只绑定 loopback。远程浏览器必须通过 SSH 隧道,或通过已经完成属主认证的 HTTPS 反向代理访问;不能把 DSH 或本插件直接监听到 `0.0.0.0`。
69
+
70
+ 插件优先采用 DSH 提供的 `ownerRequestPolicy` 宿主能力。宿主尚未提供该能力时,可启用严格 fallback:
71
+
72
+ ```yaml
73
+ - id: llm-grok-build-oauth
74
+ config:
75
+ ownerRequest:
76
+ loopbackAccessMode: ssh-tunnel
77
+ trustedProxy:
78
+ peers: [<反向代理的实际 TCP 来源地址>]
79
+ origins: [https://dsh.example.com]
80
+ ownerProof: <由本机密钥管理或部署模板注入>
81
+ csrfToken: <独立于 ownerProof 的本机密钥>
82
+ ```
83
+
84
+ 上面的尖括号内容是占位符,不可原样使用;真实 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。
85
+
86
+ 若把同机反向代理的 loopback 地址列为 `peers`,来自该地址的所有请求都会按代理流量校验,不能再回退为本地请求。这是防止反代改写 `Host` 后绕过 proof 的安全边界;配置前应保留独立的 SSH 修复通道。
87
+
88
+ ## Antigravity 安全配置
89
+
90
+ `dsh-agy@0.1.2` 的 `/agy` standalone dashboard 没有自己的认证,并包含凭据导出接口。Web 服务带 trusted-host 或反向代理时,建议在 profile 最终 `cordis.patch.yml` 禁用该 dashboard:
91
+
92
+ ```yaml
93
+ - id: dsh-agy-web
94
+ disabled: true
95
+ ```
96
+
97
+ 这不会禁用 `agy` LLM route 或 profile 内的 `dsh-agy` CLI。
98
+
99
+ Google OAuth 后续可用:
100
+
101
+ ```bash
102
+ NODE_USE_ENV_PROXY=1 \
103
+ HTTPS_PROXY=http://127.0.0.1:7890 \
104
+ dsh plugin --profile web exec dsh-agy login --headless
105
+ ```
106
+
107
+ 仅在当前网络确实需要代理时设置 `NODE_USE_ENV_PROXY` / `HTTPS_PROXY`;其他环境直接执行最后一行即可。不要把 Google credential export 粘贴到聊天或日志。
108
+
109
+ ## 代理配置
110
+
111
+ 推荐在 profile 的最终 patch 里配置常驻服务:
112
+
113
+ ```yaml
114
+ - id: llm-grok-build-oauth
115
+ config:
116
+ proxy: http://127.0.0.1:7890
117
+ proxyKimi: false
118
+ ```
119
+
120
+ 解析优先级:`config.proxy` → `CODING_OAUTH_PROXY` → `GROK_BUILD_PROXY` → `HTTPS_PROXY` / `HTTP_PROXY`。
121
+
122
+ 默认进入代理的域名组:
123
+
124
+ - xAI/Grok Build
125
+ - OpenAI Codex
126
+ - Claude/Anthropic
127
+ - Google OAuth/Cloud Code
128
+
129
+ Kimi Code 中国流量默认直连;只有 `proxyKimi: true` 才代理。
130
+
131
+ ## 弹性重试
132
+
133
+ 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 失效不重试。
134
+
135
+ 部署级覆盖(可选):
136
+
137
+ ```yaml
138
+ - id: llm-grok-build-oauth
139
+ config:
140
+ retryPolicy:
141
+ mode: normal
142
+ maxRetries: 5
143
+ retryableCodes: [EMPTY_RESPONSE, RATE_LIMIT, SERVER, TIMEOUT, TRANSPORT, AUTH]
144
+ backoff: { initialDelayMs: 5000, maxDelayMs: 80000, jitterRatio: 0.1 }
145
+ ```
146
+
147
+ ## 登录
148
+
149
+ ### 设置页
150
+
151
+ 打开 **设置 → 编码 OAuth**:
152
+
153
+ - **Grok Build**:授权码或设备码
154
+ - **OpenAI Codex**:远程部署推荐设备码;浏览器 PKCE 支持粘贴 redirect URL
155
+ - **Kimi Code**:设备码
156
+ - **Claude Code**:浏览器 PKCE,远程访问时粘贴完整 localhost redirect URL
157
+
158
+ 设置页会**只读发现**白名单内的官方 Grok / Codex / Kimi / Claude CLI OAuth 文件。同步是显式的单向**拉取**(不是自动导入):发现 → 预览 → 冲突/指纹核对 → 确认覆盖。官方 CLI 文件从不被写入。读取会拒绝符号链接、非普通文件、非属主文件、组/其他人可读,以及超大文档(`O_NOFOLLOW`)。预览票据一次性、五分钟过期、最多 32 张。CLI 的 `dsh-coding-oauth import` 仍只支持 Grok。
159
+
160
+ 登录过程只交换授权 code;状态接口不返回 access/refresh token。
161
+
162
+ ### 可选能力
163
+
164
+ 设置页的八项订阅能力开关默认全部关闭,打开后立即生效(无需重启):`codexSearch`、`codexImages`、`codexImageEdits`、`codexImagesAnyModel`、`codexUsage`、`codexFast`、`grokImagineImage`、`grokImagineVideo`。`codexImagesAnyModel` 仅放宽调用模型路由限制;仍要求已登录 Codex、开启对应图像能力,并保留当前会话附件归属和编辑授权检查。
165
+
166
+ 数值控制为 `searchResults`(1–20,默认 5)、`imageCount`(1–4,默认 1)、`videoArtifactTtlMs`(1 小时–7 天,默认 7 天;界面以 1–168 小时显示)。降低视频保留时间会立即缩短并清理已有产物;提高只影响之后生成的产物。管理员可在插件配置的 `capabilities` 下提供不含秘密的 composition 默认值;`coding-subscription-oauth` 设置区中的用户值会覆盖该 base,省略时所有开关仍默认关闭。
167
+
168
+ `codex-oauth-fast` 仅在最新一次 live catalog 标明至少有一个 `priority` 可用模型后才会出现。请求发送 `service_tier: priority` 和路由提示;界面写 **已请求 Fast**,不保证延迟或上游兑现。Codex 搜索/用量/图像是需打开的私有 `chatgpt.com/backend-api` 端点;图像固定 `gpt-image-2`;编辑只接受当前会话顶层、本会话持有的附件。
169
+
170
+ 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 路由提供。
171
+
172
+ ### CLI
173
+
174
+ ```bash
175
+ # Grok(`dsh-grok-build` 仍是同一条命令的别名)
176
+ dsh-coding-oauth login
177
+ dsh-coding-oauth login --pkce
178
+ dsh-coding-oauth import
179
+
180
+ # Codex / Kimi / Claude
181
+ dsh-coding-oauth login codex --device-auth
182
+ dsh-coding-oauth login codex --browser
183
+ dsh-coding-oauth login kimi
184
+ dsh-coding-oauth login claude
185
+
186
+ # 状态/登出
187
+ dsh-coding-oauth status all
188
+ dsh-coding-oauth logout kimi
189
+ ```
190
+
191
+ ## 模型路由
192
+
193
+ - `grok-build/<model>`
194
+ - `codex-oauth/<model>`
195
+ - `codex-oauth-fast/<model>`(可选;仅在最新 live catalog 标明 `priority` 可用后出现,界面为 已请求 Fast)
196
+ - `kimi-code-oauth/<model>`
197
+ - `claude-code-oauth/<model>`
198
+ - `agy/<model>`(安装 dsh-agy 后)
199
+
200
+ 这些别名专门避免与已有的 `xai`、`openai`、`kimi-coding` API-key routes 冲突。插件不会修改现有默认模型设置。未认证的 OAuth route 不向模型选择器返回任何模型;认证后供应商名显示为 `(OAuth)`,登录/登出会立即触发目录刷新。
201
+
202
+ ## 凭据与缓存
203
+
204
+ OAuth 凭据:
205
+
206
+ ```text
207
+ $DSH_HOME/.grok-build-auth.json
208
+ $DSH_HOME/.codex-oauth-auth.json
209
+ $DSH_HOME/.kimi-code-oauth-auth.json
210
+ $DSH_HOME/.claude-code-oauth-auth.json
211
+ ```
212
+
213
+ 均为 `0600`、原子写、文件锁保护。模型缓存为对应的 `*-models.json`,不含 token。Grok Imagine 使用 DSH 凭据引用 `XAI_API_KEY`,与上述 OAuth 文件分离;视频产物存入 `$DSH_HOME/.dsh-coding-subscription-oauth-media/`(目录 `0700`、文件 `0600`),按保留设置自动清理。
214
+
215
+ ## 卸载
216
+
217
+ ```bash
218
+ dsh plugin --profile web remove dsh-agy dsh-coding-subscription-oauth
219
+ rm -f ~/.dsh/.grok-build-auth.json ~/.dsh/.codex-oauth-auth.json \
220
+ ~/.dsh/.kimi-code-oauth-auth.json ~/.dsh/.claude-code-oauth-auth.json
221
+ rm -f ~/.dsh/.grok-build-models.json ~/.dsh/.codex-oauth-models.json \
222
+ ~/.dsh/.kimi-code-oauth-models.json ~/.dsh/.claude-code-oauth-models.json
223
+ ```
224
+
225
+ 只有在确认不再需要账号后才删除凭据文件。
226
+
227
+ ## 部署验收
228
+
229
+ 以下命令面向维护者,需要在源码 checkout 中运行;通过 npm 安装的用户无需执行。
230
+
231
+ ```bash
232
+ pnpm run verify:deployed
233
+
234
+ DSH_RESTORE_PROVIDER=openai \
235
+ DSH_RESTORE_MODEL=gpt-5.6-sol \
236
+ DSH_RESTORE_REASONING=max \
237
+ pnpm run smoke:deployed
238
+ ```
239
+
240
+ 第一条命令验证真实模型目录的认证门禁和 `(OAuth)` 标签。第二条会通过运行中的 DSH 分别执行 Codex/Kimi 的 tool-call 与第二个用户 turn(覆盖 `INVALID_REPLAY_STATE` 回归),随后恢复显式指定的默认模型并归档测试会话;为避免覆盖现有默认设置,不提供 `DSH_RESTORE_*` 时脚本拒绝运行。
241
+
242
+ ## 故障排查
243
+
244
+ | 现象 | 处理 |
245
+ |---|---|
246
+ | 还在搜 / 装着 `dsh-grok-build` | 仓库已更名为 `dsh-coding-subscription-oauth`;旧 GitHub 仓库已删除。请改用 npm 包或 `github:lninghaha/dsh-coding-subscription-oauth` |
247
+ | Codex localhost callback 打不开 | 改用设备码,或把完整 redirect URL 粘贴回设置页 |
248
+ | Claude localhost callback 在远端浏览器 | 把完整 redirect URL 粘贴回设置页 |
249
+ | Kimi 401/403 | 重新登录并确认 Kimi Code 会员有效;不要改成 moonshot.cn OAuth |
250
+ | OAuth refresh failed | 对应账号重新登录;插件不会回退到其他账号或 API key |
251
+ | 模型 route 重复 | 保留本插件的 `*-oauth` alias,移除冲突的第三方 OAuth 插件 |
252
+ | Antigravity 页面 404 | 安全配置默认禁用了 `dsh-agy-web`;使用 CLI |
253
+ | Google/Claude/OpenAI 网络不可达 | 检查插件 scoped proxy;不要重启或修改系统网络服务 |
254
+
255
+ ## 合规提示
256
+
257
+ 订阅 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.