dsh-lcx-codex 0.3.3 → 0.4.0-rc.13

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/README.md CHANGED
@@ -1,162 +1,270 @@
1
- # dsh-lcx-codex
1
+ <div align="center">
2
2
 
3
- **简体中文** | [English](README_EN.md)
3
+ <img src="https://raw.githubusercontent.com/kk3ya03-star/dsh-lcx-codex/main/assets/dsh-lcx-codex-banner.jpg" alt="DSH-LCX-CODEX" width="100%" />
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/dsh-lcx-codex.svg)](https://www.npmjs.com/package/dsh-lcx-codex)
6
- [![license](https://img.shields.io/npm/l/dsh-lcx-codex.svg)](LICENSE)
5
+ # DSH-LCX-CODEX
7
6
 
8
- 社区维护的 DSH 插件,为兼容 OpenAI Responses/Codex 协议的 GPT 模型增加 Hosted Web Search、Alpha Search 和 Native V2 远程压缩。
7
+ **给 DeepSeek Harness 补上 GPT Responses / Codex 原生能力。**
9
8
 
10
- > [!IMPORTANT]
11
- > Alpha Search 有 5 种可用部署路径:Sub2API 直连,以及经 NewAPI 的 4 种渠道类型:`Sub2API`、`New API`、`ChatGPT Subscription (Codex)`、`Advanced Custom`。普通 `OpenAI` 渠道不支持 `/v1/alpha/search`,会在 NewAPI 内被拒绝。
9
+ [![npm](https://img.shields.io/npm/v/dsh-lcx-codex?color=1677ff&label=npm)](https://www.npmjs.com/package/dsh-lcx-codex)
10
+ ![Node](https://img.shields.io/badge/Node-%3E%3D20-1677ff)
11
+ ![DSH](https://img.shields.io/badge/DSH-0.1.1--rc.2-4ea8ff)
12
+ ![License](https://img.shields.io/badge/license-MIT-1677ff)
12
13
 
13
- 这份名单来自 NewAPI 当前主分支的 [`AlphaSearchHelper`](https://github.com/QuantumNous/new-api/blob/f116414284162ad15d8925f7bca494c109b83e93/relay/alpha_search_handler.go)。不同版本的 NewAPI 可能有差异,最终以实际 capability probe 为准。
14
+ **简体中文** · [English](README_EN.md)
14
15
 
15
- `LCX` 只是插件名称,不是服务商或协议。本插件支持:
16
+ </div>
16
17
 
17
- - 直接使用 Sub2API 反代的 GPT 模型。
18
- - 使用 NewAPI 中转的 GPT 模型(也就是第三方中转);NewAPI 的上游渠道连接 Sub2API。
18
+ ---
19
19
 
20
- ```mermaid
21
- flowchart LR
22
- accTitle: dsh-lcx-codex 技术路线
23
- accDescr: 插件复用当前 DSH openai-responses 模型的路由和凭据,将 Hosted Search、capability-gated Alpha Search 与 Native V2 Compact 请求经受控传输发送到 Sub2API 直连或 NewAPI 中转部署。
20
+ `dsh-lcx-codex` 是一个社区维护的 DSH 插件,面向已经通过 `llm-pi-ai / openai-responses` 接入的 GPT 路由。它尽量复用 DSH 自己的 Agent、Web、Session 和 Compaction 架构,只在缺少 OpenAI/Codex 原生语义的地方补能力。
24
21
 
25
- dsh_session([DSH GPT 会话]) --> resolve_route[复用 providermodelbaseURL 和凭据]
22
+ > `LCX` 只是项目名称。本项目不隶属于 OpenAIDeepSeekSub2API 或 NewAPI。
26
23
 
27
- subgraph plugin_capabilities ["dsh-lcx-codex"]
28
- hosted_search[Hosted Search<br/>POST /responses + web_search]
29
- alpha_gate{Alpha capability 匹配?}
30
- alpha_search[Alpha Search<br/>POST /alpha/search]
31
- alpha_disabled([Alpha 不注册])
32
- native_compact[Native V2 Compact<br/>stream + compaction_trigger]
33
- end
24
+ - **最新版 DSH 图片管线**:Native V2 直接复用 `readImageRequest()` 和当前路由图片预算,避免压缩请求与普通 GPT 请求使用不同的图片版本。
34
25
 
35
- resolve_route --> hosted_search
36
- resolve_route --> alpha_gate
37
- resolve_route --> native_compact
38
- alpha_gate -->|是| alpha_search
39
- alpha_gate -->|否| alpha_disabled
26
+ ## 核心能力
40
27
 
41
- hosted_search --> transport[受控鉴权、超时、重试和响应大小]
42
- alpha_search --> transport
43
- native_compact --> transport
28
+ | 能力 | 说明 | 默认 |
29
+ |---|---|---:|
30
+ | **DSH 原生 `web_search` → GPT Hosted Search** | 不新增重复的普通搜索工具;rc.7+ 自动跟随当前 Agent 的 GPT Responses 模型 | 可开启 |
31
+ | **Advanced Hosted Search** | 域名过滤、location、search context、图片搜索等 OpenAI Hosted 参数 | 关闭 |
32
+ | **Alpha Search** | `search/open/find/click/screenshot` 等 Codex/Alpha 风格命令;能力探针通过后才注册 | 关闭 |
33
+ | **Native Remote Compaction V2** | 通过 Responses `compaction_trigger` 获取 provider-native opaque checkpoint | 可开启 |
34
+ | **Conversation fidelity retention** | 显式保留 bounded user / assistant 可见事实,避免只记得“问过什么”却忘记“答了什么” | 内置 |
35
+ | **Session-native checkpoint** | checkpoint 存在 DSH append-only session log,不再以 sidecar 作为新会话真相源 | 内置 |
36
+ | **Native-first 自动压缩** | 90% 主动 Native V2,95% emergency 才允许 DSH prune;阈值可调 | 可开启 |
37
+ | **长搜索超时** | DSH `web_search` 外层 timeout 默认提升到 240 秒,可调 30–600 秒 | 内置 |
44
38
 
45
- transport --> deployment{部署路径}
46
- deployment -->|直连| sub2api[Sub2API]
47
- deployment -->|中转| newapi[NewAPI 兼容渠道]
48
- sub2api --> upstream([OpenAI Responses/Codex-compatible upstream])
49
- newapi --> upstream
39
+ ## rc.8:面向 DSH 0.1.1-rc.2
50
40
 
51
- upstream -.->|compaction output| checkpoint[(Checkpoint v3)]
52
- checkpoint -->|同路由| opaque_replay[Opaque native replay]
53
- checkpoint -->|路由或模型变化| portable_migration[Portable migration]
54
- opaque_replay --> transport
55
- portable_migration --> transport
41
+ rc.8 直接面向 **DSH 0.1.1-rc.2**。普通 `web_search` 继续跟随当前 Agent 模型,同时 Native V2 的图片输入改用新版 DSH `readImageRequest()` 管线,不再直接读取 attachment master bytes。
42
+
43
+ 搜索路由仍通过 **DSH `tools/execute` → SearchProvider** 运行时上下文传递:
44
+
45
+ ```text
46
+ Agent: lcx / gpt-5.6-luna
47
+
48
+ └─ DSH web_search
49
+
50
+ └─ Hosted Search: lcx / gpt-5.6-luna
51
+
52
+ Agent: lcx / gpt-5.6-sol
53
+
54
+ └─ DSH web_search
55
+
56
+ └─ Hosted Search: lcx / gpt-5.6-sol
56
57
  ```
57
58
 
58
- 本项目不隶属于 OpenAI,也不是 OpenAI 官方发布的插件或 OAuth 客户端。
59
+ 这不会修改模型看到的 `web_search` schema。
59
60
 
60
- ## 功能
61
+ 没有 Agent 上下文时,才使用设置页里的 **回退 Responses 地址 / 回退 GPT 模型**。
61
62
 
62
- | 功能 | 工具或协议 | 说明 |
63
- |---|---|---|
64
- | Hosted Web Search | `websearch_gpt` | `/responses` + `web_search`,返回正文、来源和 citations |
65
- | Alpha Search | `websearch_alpha` | `/alpha/search`,支持 search、open/find/click、PDF screenshot、image、finance、weather、sports 和 time |
66
- | Native V2 Compact | `/responses` + `compaction_trigger` | 保存 checkpoint v3,支持同路由回放、模型迁移、fork/tree、重启和图片 attachment |
63
+ ### Search 与会话缓存隔离
67
64
 
68
- Alpha 只有在 capability 记录与当前 endpoint、provider、model schema 匹配时才会启用。Hosted 与 Alpha 是两条独立协议,不会互相静默降级。
65
+ Hosted Search 是一笔独立 Responses 请求,不等于主会话推理。rc.8 继续给搜索使用独立 cache namespace:
69
66
 
70
- ## 安装
67
+ ```text
68
+ 主会话 replay: dsh-lcx:<route hash>
69
+ Hosted Search: dsh-lcx-search:<route hash>
70
+ ```
71
71
 
72
- 推荐从 npm 安装:
72
+ 因此搜索不会故意与 Native replay 共用同一个 `prompt_cache_key`。NewAPI 后台仍可能看到搜索请求夹在主会话请求之间;它们是不同请求,搜索行本身 cache 较低并不代表 DSH session 被截断。
73
73
 
74
- ```powershell
75
- dsh plugin --profile web add dsh-lcx-codex
74
+ ## Native V2 Compaction
75
+
76
+ DSH 本身已经负责:
77
+
78
+ - token pressure;
79
+ - compactable range selection;
80
+ - tool-result pruning;
81
+ - durable session transaction;
82
+ - `/compact`;
83
+ - context-overflow recovery。
84
+
85
+ 本插件不再造第二套 compaction engine,而是在 DSH 的 `purpose: 'compaction'` LLM seam 上执行 Native V2:
86
+
87
+ ```text
88
+ DSH compaction transaction
89
+
90
+ └─ purpose=compaction
91
+
92
+ └─ POST /responses
93
+ x-codex-beta-features: remote_compaction_v2
94
+ input: [...history, { type: "compaction_trigger" }]
76
95
  ```
77
96
 
78
- 也可以下载 GitHub Release 中的 `.tgz` 安装指定版本:
97
+ Native 成功:不再额外运行 basic summary。
79
98
 
80
- ```powershell
81
- dsh plugin --profile web add .\dsh-lcx-codex-0.3.2.tgz
99
+ Native 失败且开启 fallback:才回到 DSH basic compaction。
100
+
101
+ ## 为什么压缩后还能记住模型自己说过的话
102
+
103
+ 单纯依赖 provider-native opaque compaction 是有损的。真实长会话测试发现,低显著性的 assistant-only 事实可能被压掉,例如:
104
+
105
+ - 模型随机生成的项目代号;
106
+ - 搜索后模型给出的具体姓名;
107
+ - 只在 assistant 最终回答里出现的数字。
108
+
109
+ 因此当前 checkpoint 使用:
110
+
111
+ ```text
112
+ bounded client-visible history
113
+ + bounded assistant-visible answers
114
+ + opaque Native V2 compaction item
82
115
  ```
83
116
 
84
- 安装后启动 DSH:
117
+ 默认总 explicit retention 预算约 `64k` estimated tokens,其中 assistant-visible answer 最多预留约 `24k`,单条默认最多约 `3k`。不把 reasoning、巨大 tool result、完整搜索正文和运行 telemetry 全塞回来。
85
118
 
86
- ```powershell
87
- dsh web
119
+ 目标不是“逐字无损”,而是:**删过程,保事实。**
120
+
121
+ ## 自动压缩策略
122
+
123
+ rc.8 延续 rc.6 的 Native-first pressure policy:
124
+
125
+ ```text
126
+ 0% ─────────────────── 90% ───── 95% ───── 100%
127
+ 正常使用 Native emergency hard cap
128
+ V2 DSH prune
129
+ ```
130
+
131
+ 默认:
132
+
133
+ - `< 90%`:不让 DSH 原来的 80% pressure prune 提前改写历史;
134
+ - `90%–95%`:优先 Native V2;
135
+ - `>= 95%`:允许 DSH replay-safe tool-result pruner 救场;
136
+ - provider 明确返回 context overflow:仍保留 DSH 原生 recovery;
137
+ - 手动 `/compact`:不受阈值影响。
138
+
139
+ 阈值可在插件设置页调整。
140
+
141
+ ## 关于“缓存突然断了”
142
+
143
+ 需要区分两件事:
144
+
145
+ ```text
146
+ cacheRead = 0
147
+
148
+ 会话历史被删除
88
149
  ```
89
150
 
90
- 打开 `设置 -> 插件 -> LCX / Codex 能力`,按需启用 Hosted、Alpha 或 Native Compact。插件默认关闭。
151
+ 在真实 NewAPI 日志里,出现过:
91
152
 
92
- ## 要求
153
+ ```text
154
+ 某轮:155k uncached / cacheRead 0
155
+ 下一轮:~1k new input / ~155k cacheRead
156
+ ```
157
+
158
+ 这说明上一轮只是 provider prompt-cache miss / eviction,完整上下文仍被重新发送,并没有发生 session compaction 或 surface replacement。
159
+
160
+ 真正会主动改变历史前缀的主要情况是:
161
+
162
+ 1. `/compact` / 自动 Native compaction;
163
+ 2. emergency tool-result pruning;
164
+ 3. 换模型 / provider / baseURL;
165
+ 4. DSH 自己发生其他 surface replacement。
166
+
167
+ DSH 重启、长时间 idle、上游 cache TTL/eviction 也可能造成某一轮重新建 cache;插件无法保证第三方网关永不 evict KV cache。
168
+
169
+ ## 搜索分层
170
+
171
+ ### 1. 普通搜索:`web_search`
172
+
173
+ 推荐默认使用。rc.8 会跟随当前 Agent 的 GPT Responses route。
93
174
 
94
- - Node.js 20 或更高版本
95
- - DSH `0.1.0-rc.8` 或兼容版本
96
- - 已在 DSH 中添加并能正常对话的 GPT 模型
97
- - 模型使用 `llm-pi-ai` 的 `openai-responses` provider
175
+ ### 2. 高级 Hosted:`websearch_gpt_advanced`
98
176
 
99
- 插件复用当前 DSH 模型的 provider、model、Responses 地址、凭据引用、headers 和 retry policy,并通过 DSH credentials service 取凭据。正常运行不需要再给插件配置一份 `LCX_API_KEY`。
177
+ 仅在需要这些参数时开启:
100
178
 
101
- 界面中的 endpoint model 字段用于没有活动会话路由时的默认选择,以及旧版直连配置兼容;同名 DSH provider 已存在时,以 DSH provider 配置为准。
179
+ - allowed / blocked domains;
180
+ - approximate user location;
181
+ - `search_context_size`;
182
+ - image search;
183
+ - external web access;
184
+ - return token budget。
102
185
 
103
- ## Alpha probe
186
+ 开启/关闭额外工具会改变 tool catalog,因此默认关闭以保持主会话 request schema 稳定。
104
187
 
105
- Alpha 能力按部署记录为 `native`、`command-capable`、`emulated-search-only`、`unsupported` 或 `unknown`。HTTP 200 本身不能证明 action 是原生能力。
188
+ ### 3. Alpha:`websearch_alpha`
106
189
 
107
- 探针是 DSH runtime 外的独立 Node.js 脚本,不能调用 DSH credentials service,因此探针需要本机 key 文件;插件运行时不需要重复配置。
190
+ 面向 stateful Codex/Alpha 风格搜索:`search/open/find/click/screenshot` 等。只有 capability probe 与当前 endpoint/provider/model/schema 匹配后才注册。
191
+
192
+ ## 安装
193
+
194
+ ### npm
195
+
196
+ 稳定版:
108
197
 
109
198
  ```powershell
110
- $dshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $env:USERPROFILE '.dsh' }
111
- $env:LCX_API_KEY_FILE = 'C:\path\to\local-key.txt'
112
- $env:LCX_MODEL = '实际模型名'
113
- node (Join-Path $dshHome 'profiles\web\node_modules\dsh-lcx-codex\scripts\probe-alpha.mjs')
199
+ dsh plugin --profile web add dsh-lcx-codex
114
200
  ```
115
201
 
116
- 要同时探测 image、finance、weather、sports 和 time:
202
+ 预发布版(当前 rc.8):
117
203
 
118
204
  ```powershell
119
- $env:LCX_ALPHA_PROBE_STRUCTURED = '1'
120
- node (Join-Path $dshHome 'profiles\web\node_modules\dsh-lcx-codex\scripts\probe-alpha.mjs')
205
+ dsh plugin --profile web add dsh-lcx-codex@next
121
206
  ```
122
207
 
123
- 探针不会输出 key 或完整响应正文。完成后重启 DSH,或关闭再开启 Alpha 设置。
208
+ ### 本地 RC
124
209
 
125
- ## 数据与限制
210
+ ```powershell
211
+ dsh plugin --profile web remove dsh-lcx-codex
212
+ dsh plugin --profile web add .\dsh-lcx-codex-0.4.0-rc.13.tgz
213
+ dsh web
214
+ ```
126
215
 
127
- - 网络目标由当前活动 DSH `openai-responses` provider `baseURL` 决定,不固定到 LCX 或其他域名;插件只在该地址下调用 `/responses` 和 `/alpha/search`
128
- - 凭据名称取自同一 provider 的 `apiKeyEnv`,并由 DSH credentials service 解析;插件不会自行保存 API key
129
- - Checkpoint:`$DSH_HOME/storages/lcx-codex/checkpoints-v3.json`
130
- - Alpha capability:`$DSH_HOME/storages/lcx-codex/web-alpha-capabilities.json`
131
- - Alpha refs:`$DSH_HOME/storages/lcx-codex/web-alpha-refs.json`
132
- - 只支持 Native remote-compaction V2,不调用 `/responses/compact`
133
- - 同路由 replay 会复用 DSH session 的 `prompt_cache_key` 并保持已有请求前缀稳定;短期缓存过期后仍可能出现单次冷请求,不能用会话累计命中率判断插件是否破坏缓存
134
- - Sub2API 的 Codex OAuth 转换层会删除上游不支持的 `prompt_cache_retention`,因此经该路径设置 `24h` 不会延长缓存;以实际连续请求的 `cached_tokens` 为准
135
- - Checkpoint 不保存图片原始字节或 data URL
136
- - Opaque checkpoint 不跨不兼容 provider、model、base URL、session 或 lineage 回放
137
- - 不包含图片生成功能
216
+ 不要为了升级删除 `$DSH_HOME/storages/lcx-codex/` 或旧 session。v3 sidecar 仍作为只读旧会话兼容层。
138
217
 
139
- 不要把 API key、OAuth token、Authorization header、账户 ID、session cookie 或运行时 sidecar 提交到 GitHub。
218
+ ## 推荐设置
140
219
 
141
- ## 更新与卸载
220
+ ```text
221
+ Enable plugin ✅
222
+ Use GPT Hosted Search ✅
223
+ Advanced Hosted Search ❌
224
+ Alpha Search ❌
142
225
 
143
- ```powershell
144
- dsh plugin --profile web update dsh-lcx-codex
145
- dsh plugin --profile web remove dsh-lcx-codex
226
+ Native V2 remote compaction ✅
227
+ Native-first auto compaction ✅
228
+ Native threshold 90%
229
+ Emergency DSH prune 95%
230
+ web_search timeout 240s
231
+ ```
232
+
233
+ 调试 Native 时可以先关闭 fallback;稳定使用时是否开启 fallback 由你决定。
234
+
235
+ ## 部署要求
236
+
237
+ - Node.js `>=20`
238
+ - DSH `0.1.1-rc.2`
239
+ - DSH 中已经能正常使用的 GPT `openai-responses` route
240
+ - upstream 实际支持你启用的 Hosted Search / Native V2 / Alpha 能力
241
+
242
+ 典型路径:
243
+
244
+ ```text
245
+ DSH → llm-pi-ai/openai-responses → Sub2API
246
+ DSH → llm-pi-ai/openai-responses → NewAPI → upstream
146
247
  ```
147
248
 
148
- 卸载不会删除 `$DSH_HOME/storages/lcx-codex/`。如果会话仍引用 checkpoint marker,不要单独删除对应 sidecar
249
+ 插件优先复用 DSH route `baseURL`、credential reference、headers 和 retry policy
250
+
251
+ ## 发布通道
252
+
253
+ - npm stable:正式稳定版本
254
+ - npm `next`:`0.4.0-rc.*` 预发布测试版本
255
+
256
+ GitHub tag 与 `package.json` version 必须一致;Trusted Publishing workflow 会先跑测试再发布。
149
257
 
150
258
  ## 开发
151
259
 
152
- ```powershell
153
- npm install
260
+ ```bash
154
261
  npm test
155
262
  npm run test:schema
263
+ npm pack --ignore-scripts
156
264
  ```
157
265
 
158
- 真实 E2E 和 Alpha probe 只应读取本机忽略文件或环境变量中的测试凭据。
266
+ 关键设计说明见 [ARCHITECTURE.md](ARCHITECTURE.md),完整版本记录见 [CHANGELOG.md](CHANGELOG.md)。
159
267
 
160
268
  ## License
161
269
 
162
- [MIT](LICENSE)
270
+ MIT