dsh-lcx-codex 0.3.4 → 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,164 +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 插件:让任意 DSH 主模型通过单独配置的 GPT Responses 路由调用 Hosted/Alpha Search,并为兼容 OpenAI Responses/Codex 协议的 GPT 主模型增加 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: Hosted 和 Alpha 可由任意 DSH 主模型调用,经已配置的 GPT openai-responses 路由发送;启用 Hosted 时插件接管 DSH 搜索 provider,关闭后恢复原 provider。Native V2 Compact 只作用于当前兼容 GPT 路由。
20
+ `dsh-lcx-codex` 是一个社区维护的 DSH 插件,面向已经通过 `llm-pi-ai / openai-responses` 接入的 GPT 路由。它尽量复用 DSH 自己的 Agent、Web、Session 和 Compaction 架构,只在缺少 OpenAI/Codex 原生语义的地方补能力。
24
21
 
25
- dsh_session([任意 DSH 主模型]) --> search_route[当前兼容 GPT 路由<br/>否则使用插件配置的 GPT 路由]
26
- gpt_session([兼容 GPT 主模型]) --> compact_route[复用当前 provider、model、baseURL 和凭据]
22
+ > `LCX` 只是项目名称。本项目不隶属于 OpenAI、DeepSeek、Sub2API NewAPI。
27
23
 
28
- subgraph plugin_capabilities ["dsh-lcx-codex"]
29
- hosted_search[Hosted Search<br/>POST /responses + web_search]
30
- alpha_gate{Alpha capability 匹配?}
31
- alpha_search[Alpha Search<br/>POST /alpha/search]
32
- alpha_disabled([Alpha 不注册])
33
- native_compact[Native V2 Compact<br/>stream + compaction_trigger]
34
- end
24
+ - **最新版 DSH 图片管线**:Native V2 直接复用 `readImageRequest()` 和当前路由图片预算,避免压缩请求与普通 GPT 请求使用不同的图片版本。
35
25
 
36
- search_route --> hosted_search
37
- search_route --> alpha_gate
38
- compact_route --> native_compact
39
- alpha_gate -->|是| alpha_search
40
- alpha_gate -->|否| alpha_disabled
26
+ ## 核心能力
41
27
 
42
- hosted_search --> transport[受控鉴权、超时、重试和响应大小]
43
- alpha_search --> transport
44
- 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 秒 | 内置 |
45
38
 
46
- transport --> deployment{部署路径}
47
- deployment -->|直连| sub2api[Sub2API]
48
- deployment -->|中转| newapi[NewAPI 兼容渠道]
49
- sub2api --> upstream([OpenAI Responses/Codex-compatible upstream])
50
- newapi --> upstream
39
+ ## rc.8:面向 DSH 0.1.1-rc.2
51
40
 
52
- upstream -.->|compaction output| checkpoint[(Checkpoint v3)]
53
- checkpoint -->|同路由| opaque_replay[Opaque native replay]
54
- checkpoint -->|路由或模型变化| portable_migration[Portable migration]
55
- opaque_replay --> transport
56
- 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
57
57
  ```
58
58
 
59
- 本项目不隶属于 OpenAI,也不是 OpenAI 官方发布的插件或 OAuth 客户端。
59
+ 这不会修改模型看到的 `web_search` schema。
60
60
 
61
- ## 功能
61
+ 没有 Agent 上下文时,才使用设置页里的 **回退 Responses 地址 / 回退 GPT 模型**。
62
62
 
63
- | 功能 | 工具或协议 | 说明 |
64
- |---|---|---|
65
- | Hosted Web Search | `websearch_gpt` | 任意主模型可调用;经 GPT Responses 路由执行 `/responses` + `web_search`,返回正文、来源和 citations |
66
- | Alpha Search | `websearch_alpha` | 任意主模型可调用;经已验证的 GPT 路由执行 `/alpha/search`,支持 search、open/find/click、PDF screenshot、image、finance、weather、sports 和 time |
67
- | Native V2 Compact | `/responses` + `compaction_trigger` | 保存 checkpoint v3,支持同路由回放、模型迁移、fork/tree、重启和图片 attachment |
63
+ ### Search 与会话缓存隔离
68
64
 
69
- Alpha 只有在 capability 记录与搜索后端的 endpoint、provider、model 和 schema 匹配时才会启用。Hosted Alpha 是两条独立协议,不会互相静默降级。启用 Hosted 时,DSH 会临时切换为插件搜索 provider,原始 provider 不再处理搜索;关闭 Hosted 或卸载插件后恢复启用前的 provider。
65
+ Hosted Search 是一笔独立 Responses 请求,不等于主会话推理。rc.8 继续给搜索使用独立 cache namespace:
70
66
 
71
- ## 安装
67
+ ```text
68
+ 主会话 replay: dsh-lcx:<route hash>
69
+ Hosted Search: dsh-lcx-search:<route hash>
70
+ ```
72
71
 
73
- 推荐从 npm 安装:
72
+ 因此搜索不会故意与 Native replay 共用同一个 `prompt_cache_key`。NewAPI 后台仍可能看到搜索请求夹在主会话请求之间;它们是不同请求,搜索行本身 cache 较低并不代表 DSH session 被截断。
74
73
 
75
- ```powershell
76
- 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" }]
77
95
  ```
78
96
 
79
- 也可以下载 GitHub Release 中的 `.tgz` 安装指定版本:
97
+ Native 成功:不再额外运行 basic summary。
80
98
 
81
- ```powershell
82
- dsh plugin --profile web add .\dsh-lcx-codex-0.3.4.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
83
115
  ```
84
116
 
85
- 安装后启动 DSH:
117
+ 默认总 explicit retention 预算约 `64k` estimated tokens,其中 assistant-visible answer 最多预留约 `24k`,单条默认最多约 `3k`。不把 reasoning、巨大 tool result、完整搜索正文和运行 telemetry 全塞回来。
86
118
 
87
- ```powershell
88
- 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
+ 会话历史被删除
89
149
  ```
90
150
 
91
- 打开 `设置 -> 插件 -> LCX / Codex 能力`,按需启用 Hosted、Alpha 或 Native Compact。插件默认关闭。
151
+ 在真实 NewAPI 日志里,出现过:
92
152
 
93
- ## 要求
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。
94
174
 
95
- - Node.js 20 或更高版本
96
- - DSH `0.1.0-rc.8` 或兼容版本
97
- - 已在 DSH 中添加并能正常对话的主模型;调用 Hosted/Alpha 的主模型不限于 GPT
98
- - 已配置一个可用的 GPT `openai-responses` provider,供 Hosted/Alpha 作为独立搜索后端;Native Compact 则要求当前主模型本身使用该类路由
175
+ ### 2. 高级 Hosted:`websearch_gpt_advanced`
99
176
 
100
- Hosted/Alpha 在当前主模型本身是兼容 GPT Responses 路由时复用该路由,否则使用插件设置中的 GPT Responses 路由。Native Compact 只复用当前 GPT 主模型的 provider、model、Responses 地址、凭据引用、headers 和 retry policy。凭据由 DSH credentials service 解析,正常运行不需要再给插件配置一份 `LCX_API_KEY`。
177
+ 仅在需要这些参数时开启:
101
178
 
102
- 界面中的 provider、endpoint 和 model 字段用于搜索回退路由,以及旧版直连配置兼容;当前主模型不是兼容 GPT 路由时,Hosted/Alpha 使用这里选择的 GPT 路由。同名 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。
103
185
 
104
- ## Alpha probe
186
+ 开启/关闭额外工具会改变 tool catalog,因此默认关闭以保持主会话 request schema 稳定。
105
187
 
106
- Alpha 能力按部署记录为 `native`、`command-capable`、`emulated-search-only`、`unsupported` 或 `unknown`。HTTP 200 本身不能证明 action 是原生能力。
188
+ ### 3. Alpha:`websearch_alpha`
107
189
 
108
- 探针是 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
+ 稳定版:
109
197
 
110
198
  ```powershell
111
- $dshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $env:USERPROFILE '.dsh' }
112
- $env:LCX_API_KEY_FILE = 'C:\path\to\local-key.txt'
113
- $env:LCX_MODEL = '实际模型名'
114
- node (Join-Path $dshHome 'profiles\web\node_modules\dsh-lcx-codex\scripts\probe-alpha.mjs')
199
+ dsh plugin --profile web add dsh-lcx-codex
115
200
  ```
116
201
 
117
- 要同时探测 image、finance、weather、sports 和 time:
202
+ 预发布版(当前 rc.8):
118
203
 
119
204
  ```powershell
120
- $env:LCX_ALPHA_PROBE_STRUCTURED = '1'
121
- 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
122
206
  ```
123
207
 
124
- 探针不会输出 key 或完整响应正文。完成后重启 DSH,或关闭再开启 Alpha 设置。
208
+ ### 本地 RC
125
209
 
126
- ## 数据与限制
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
+ ```
127
215
 
128
- - 搜索网络目标优先由当前兼容的 DSH `openai-responses` provider 决定,否则由插件设置中的 GPT provider 决定;不固定到 LCX 或其他域名,且只在该地址下调用 `/responses` 和 `/alpha/search`
129
- - 凭据名称取自最终选中的 GPT provider 的 `apiKeyEnv`,并由 DSH credentials service 解析;插件不会自行保存 API key
130
- - 启用 Hosted 时插件将 `ctx.web.searchProviderId` 临时切换为插件搜索 provider;关闭 Hosted 或卸载插件时恢复启用前的原 provider
131
- - Checkpoint:`$DSH_HOME/storages/lcx-codex/checkpoints-v3.json`
132
- - Alpha capability:`$DSH_HOME/storages/lcx-codex/web-alpha-capabilities.json`
133
- - Alpha refs:`$DSH_HOME/storages/lcx-codex/web-alpha-refs.json`
134
- - 只支持 Native remote-compaction V2,不调用 `/responses/compact`
135
- - 同路由 replay 会复用 DSH session 的 `prompt_cache_key` 并保持已有请求前缀稳定;短期缓存过期后仍可能出现单次冷请求,不能用会话累计命中率判断插件是否破坏缓存
136
- - Sub2API 的 Codex OAuth 转换层会删除上游不支持的 `prompt_cache_retention`,因此经该路径设置 `24h` 不会延长缓存;以实际连续请求的 `cached_tokens` 为准
137
- - Checkpoint 不保存图片原始字节或 data URL
138
- - Opaque checkpoint 不跨不兼容 provider、model、base URL、session 或 lineage 回放
139
- - 不包含图片生成功能
216
+ 不要为了升级删除 `$DSH_HOME/storages/lcx-codex/` 或旧 session。v3 sidecar 仍作为只读旧会话兼容层。
140
217
 
141
- 不要把 API key、OAuth token、Authorization header、账户 ID、session cookie 或运行时 sidecar 提交到 GitHub。
218
+ ## 推荐设置
142
219
 
143
- ## 更新与卸载
220
+ ```text
221
+ Enable plugin ✅
222
+ Use GPT Hosted Search ✅
223
+ Advanced Hosted Search ❌
224
+ Alpha Search ❌
144
225
 
145
- ```powershell
146
- dsh plugin --profile web update dsh-lcx-codex
147
- 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
148
247
  ```
149
248
 
150
- 卸载不会删除 `$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 会先跑测试再发布。
151
257
 
152
258
  ## 开发
153
259
 
154
- ```powershell
155
- npm install
260
+ ```bash
156
261
  npm test
157
262
  npm run test:schema
263
+ npm pack --ignore-scripts
158
264
  ```
159
265
 
160
- 真实 E2E 和 Alpha probe 只应读取本机忽略文件或环境变量中的测试凭据。
266
+ 关键设计说明见 [ARCHITECTURE.md](ARCHITECTURE.md),完整版本记录见 [CHANGELOG.md](CHANGELOG.md)。
161
267
 
162
268
  ## License
163
269
 
164
- [MIT](LICENSE)
270
+ MIT