@eddyskywalker/dsh-chatgpt-subscription 0.1.0-alpha.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 (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +148 -0
  4. package/cordis.patch.yml +6 -0
  5. package/lib/client.js +673 -0
  6. package/lib/client.js.map +1 -0
  7. package/lib/index.js +1753 -0
  8. package/lib/types/client/CodexSubscriptionSection.d.ts +15 -0
  9. package/lib/types/client/CodexSubscriptionSection.d.ts.map +1 -0
  10. package/lib/types/client/api.d.ts +17 -0
  11. package/lib/types/client/api.d.ts.map +1 -0
  12. package/lib/types/client/index.d.ts +10 -0
  13. package/lib/types/client/index.d.ts.map +1 -0
  14. package/lib/types/client/locales.d.ts +103 -0
  15. package/lib/types/client/locales.d.ts.map +1 -0
  16. package/lib/types/client/styles.d.ts +2 -0
  17. package/lib/types/client/styles.d.ts.map +1 -0
  18. package/lib/types/compat.d.ts +26 -0
  19. package/lib/types/compat.d.ts.map +1 -0
  20. package/lib/types/host/adapter.d.ts +14 -0
  21. package/lib/types/host/adapter.d.ts.map +1 -0
  22. package/lib/types/host/callback-server.d.ts +22 -0
  23. package/lib/types/host/callback-server.d.ts.map +1 -0
  24. package/lib/types/host/model-catalog.d.ts +6 -0
  25. package/lib/types/host/model-catalog.d.ts.map +1 -0
  26. package/lib/types/host/oauth-service.d.ts +69 -0
  27. package/lib/types/host/oauth-service.d.ts.map +1 -0
  28. package/lib/types/host/responses-client.d.ts +21 -0
  29. package/lib/types/host/responses-client.d.ts.map +1 -0
  30. package/lib/types/host/responses-mapper.d.ts +11 -0
  31. package/lib/types/host/responses-mapper.d.ts.map +1 -0
  32. package/lib/types/host/routes.d.ts +5 -0
  33. package/lib/types/host/routes.d.ts.map +1 -0
  34. package/lib/types/host/token-store-windows.d.ts +10 -0
  35. package/lib/types/host/token-store-windows.d.ts.map +1 -0
  36. package/lib/types/host/token-store.d.ts +23 -0
  37. package/lib/types/host/token-store.d.ts.map +1 -0
  38. package/lib/types/host/usage-service.d.ts +33 -0
  39. package/lib/types/host/usage-service.d.ts.map +1 -0
  40. package/lib/types/host/wire-auth.d.ts +5 -0
  41. package/lib/types/host/wire-auth.d.ts.map +1 -0
  42. package/lib/types/index.d.ts +9 -0
  43. package/lib/types/index.d.ts.map +1 -0
  44. package/lib/types/shared/contracts.d.ts +77 -0
  45. package/lib/types/shared/contracts.d.ts.map +1 -0
  46. package/package.json +105 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.0 - 2026-08-14
4
+
5
+ - 新增 DSH Host/Client 双端插件与一级“Codex 订阅”设置入口。
6
+ - 新增 ChatGPT OAuth PKCE、localhost callback、DPAPI TokenStore、刷新和注销。
7
+ - 新增 `codex-chatgpt` LLM Adapter、固定 Responses SSE、vision、reasoning 与工具调用映射。
8
+ - 新增 401 单次刷新重试、DSH 有界 retry policy、取消与安全工具参数校验。
9
+ - 新增 Wham usage 双 bucket/双窗口解析、缓存、节流、连接测试和可访问进度条。
10
+ - 新增 OAuth、路由、DPAPI、Responses、额度与 Client 注册测试。
11
+ - 修复 OAuth 失败详情被状态刷新清空、旧 keep-alive 回调连接复用,以及 refresh token 失效后重复尝试的问题;token exchange 现在显示脱敏错误标识。
12
+ - 修复工具调用 replay 缺失时仍发送孤立 `function_call_output` 导致 Codex 返回 400;现在会补全调用配对,并安全处理被压缩历史中的孤立结果。
13
+
14
+ 这是首个 prerelease;没有稳定版升级承诺。ChatGPT backend compatibility 可能随上游变化。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH ChatGPT Subscription contributors
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 ADDED
@@ -0,0 +1,148 @@
1
+ # DSH ChatGPT Subscription
2
+
3
+ 让 DSH(DeepSeek Harness)通过 ChatGPT 订阅使用 Gpt 系列模型的插件。
4
+
5
+ 插件注册 `codex-chatgpt` Provider(显示名 **“Codex(ChatGPT 订阅)”**),以当前 Windows 用户的 ChatGPT OAuth 登录态访问模型,并在设置页展示账号信息、连接状态与订阅额度。
6
+
7
+ ## 目录
8
+
9
+ - [功能特性](#功能特性)
10
+ - [模型目录](#模型目录)
11
+ - [环境要求](#环境要求)
12
+ - [安装](#安装)
13
+ - [使用](#使用)
14
+ - [升级、降级与卸载](#升级降级与卸载)
15
+ - [安全边界](#安全边界)
16
+ - [插件路由](#插件路由)
17
+ - [开发与验证](#开发与验证)
18
+ - [故障排查](#故障排查)
19
+
20
+ ## 功能特性
21
+
22
+ **登录与会话**
23
+
24
+ - Authorization Code + PKCE(S256)登录,一次性 localhost 回调;
25
+ - 支持 token 刷新、登录取消与账号注销;
26
+ - token 使用 Windows CurrentUser DPAPI 加密存储,明文不发送给 Client。
27
+
28
+ **模型接入**
29
+
30
+ - 固定 Codex Responses 地址,支持流式文本、reasoning summary、图片输入与工具调用/结果;
31
+ - 429/5xx 由 DSH retry policy 接管;401 只强制刷新并重试一次,支持 `AbortSignal`;
32
+ - Codex 与 Code review 多窗口额度,60 秒缓存、15 秒上游节流并遵守 `Retry-After`。
33
+
34
+ **设置页**
35
+
36
+ - 展示账号(脱敏 email、套餐、账号 ID 后四位)、连接状态与额度;
37
+ - 可访问的进度条、窄窗口/200% 缩放布局、深浅主题与 reduced-motion。
38
+
39
+ ## 模型目录
40
+
41
+ `gpt-5.6-sol`、`gpt-5.6-terra`、`gpt-5.6-luna`、`gpt-5.5`、`gpt-5.4`、`gpt-5.4-mini`、`gpt-5.2`
42
+
43
+ > 目录只用于展示;账号实际可用的模型由 ChatGPT 套餐、workspace 策略与上游兼容状态决定。
44
+
45
+ ## 环境要求
46
+
47
+ - Windows(DPAPI 依赖当前 Windows 用户);
48
+ - 已安装 DSH
49
+ - Node.js 与 npm。
50
+
51
+ ## 安装
52
+
53
+ ### 方式 1:通过 DSH CLI 安装(推荐)
54
+
55
+ 直接从 npm 安装已发布的插件包:
56
+
57
+ ```powershell
58
+ # 如果全局安装了 dsh
59
+ dsh plugin --profile web add @eddyskywalker/dsh-chatgpt-subscription
60
+
61
+ # 或使用 npx 直接运行
62
+ npx @deepseek-ai/dsh plugin --profile web add @eddyskywalker/dsh-chatgpt-subscription
63
+ ```
64
+
65
+ ### 方式 2:通过 DSH 插件市场安装
66
+
67
+ 1. 打开 DSH 界面中的 **插件市场** / **Plugin Market**;
68
+ 2. 搜索 `@eddyskywalker/dsh-chatgpt-subscription` 或 `dsh-chatgpt-subscription`;
69
+ 3. 点击 **安装**。
70
+
71
+ ### 方式 3:本地开发调试(源码软链接)
72
+
73
+ 如需进行二次开发或本地源码调试:
74
+
75
+ ```powershell
76
+ git clone https://github.com/Aa728848/dsh-chatgpt-subscription.git
77
+ cd dsh-chatgpt-subscription
78
+ npm install
79
+ npm run build
80
+ npx @deepseek-ai/dsh plugin --profile web add "link:C:\absolute\path\to\dsh-chatgpt-subscription"
81
+ ```
82
+
83
+ ## 使用
84
+
85
+ 1. 重启 `dsh web`;
86
+ 2. 打开 **设置 → Codex 订阅**;
87
+ 3. 完成 ChatGPT 登录;
88
+ 4. 执行 **测试连接**。
89
+
90
+ DSH 模型选择器应显示 **“Codex(ChatGPT 订阅)”**。
91
+
92
+ 卸载前建议先在设置页点击 **“注销”**,它会删除 DPAPI 凭据和 Host 内存中的额度缓存
93
+
94
+
95
+ 若 DSH 已异常退出,可在确认路径后删除凭据文件 `oauth.dpapi`:
96
+
97
+ - `%DSH_HOME%\storages\dsh-chatgpt-subscription\oauth.dpapi`
98
+ - 未设置 `DSH_HOME` 时为 `%USERPROFILE%\.dsh\storages\dsh-chatgpt-subscription\oauth.dpapi`
99
+
100
+ > 该文件只能由创建它的 Windows 用户通过 DPAPI 解密。
101
+
102
+ ## 安全边界
103
+
104
+ - OAuth 回调固定为 `http://localhost:1455/auth/callback`,登录任务五分钟超时,同一时刻只允许一个;
105
+ - OAuth token 只发送到 `https://auth.openai.com/oauth/token`;
106
+ - 模型与额度地址分别固定为 `https://chatgpt.com/backend-api/codex/responses` 和 `https://chatgpt.com/backend-api/wham/usage`,没有 endpoint override;
107
+ - token bundle 使用 Windows CurrentUser DPAPI;明文只经过 Host 内存和 PowerShell stdin/stdout,不进入命令行参数、浏览器、`settings.yaml` 或日志;
108
+ - 工具调用只有在参数是完整 JSON 对象时才产生可执行的 `block-end`;畸形参数终止本次生成;
109
+ - 所有修改状态的路由只接受同源 JSON POST,并校验 `Origin` 与 `Host`。
110
+
111
+ ## 插件路由
112
+
113
+ 所有路由都以 `/api/dsh-chatgpt-subscription` 为前缀:
114
+
115
+ | 方法 | 路径 | 说明 |
116
+ | --- | --- | --- |
117
+ | GET | `/status` | 查询账号、连接状态与额度 |
118
+ | POST | `/login/start` | 开始 OAuth 登录 |
119
+ | GET | `/login/events?loginId=...` | SSE 订阅登录进度 |
120
+ | POST | `/login/cancel` | 取消登录任务 |
121
+ | POST | `/logout` | 注销并清除凭据与额度缓存 |
122
+ | POST | `/token/refresh` | 刷新 token |
123
+ | POST | `/quota/refresh` | 刷新额度 |
124
+ | POST | `/connection/test` | 测试连接 |
125
+
126
+ 状态响应只包含脱敏 email、套餐、账号 ID 后四位、token 到期时间和额度 DTO。
127
+
128
+ ## 开发与验证
129
+
130
+ ```powershell
131
+ npm run typecheck
132
+ npm test
133
+ npm run build
134
+ npm pack --dry-run
135
+ ```
136
+
137
+ 测试使用 mock OAuth、Responses SSE 和 Wham usage,不需要真实 ChatGPT 凭据。真实账号的端到端登录与生成应在独立 DSH profile 中人工验收,避免影响日常 profile。
138
+
139
+ ## 故障排查
140
+
141
+ | 现象 | 处理 |
142
+ | --- | --- |
143
+ | 1455 端口占用 | 结束旧登录任务或占用该端口的进程后重试;插件卸载会关闭 listener |
144
+ | 登录后仍是 401 | 刷新 token;若刷新 token 已失效,注销并重新登录,不会循环请求 |
145
+ | 额度显示旧数据 | 设置页会保留最后成功值;等待 15 秒节流窗口后手动刷新 |
146
+ | 429 | 插件遵守 `Retry-After`,不会高频轮询;模型请求由 DSH retry policy 有界重试 |
147
+ | 模型不可用 | 检查 ChatGPT 套餐、workspace 权限与当前模型可用性 |
148
+ | DPAPI 读取失败 | 确认 DSH 以创建凭据时的同一 Windows 用户运行;必要时清理凭据后重新登录 |
@@ -0,0 +1,6 @@
1
+ # Add exactly one dual-face plugin row to the DSH web profile. The host half
2
+ # mounts OAuth/status routes; package.json's dsh.client declaration loads the
3
+ # browser half from exports["./client"].
4
+ - insert:
5
+ - id: dsh-chatgpt-subscription
6
+ name: '@eddyskywalker/dsh-chatgpt-subscription'