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/ARCHITECTURE.md +93 -0
- package/CHANGELOG.md +143 -41
- package/README.md +208 -100
- package/README_EN.md +133 -101
- package/assets/dsh-lcx-codex-banner.jpg +0 -0
- package/cordis.patch.yml +10 -4
- package/lib/client.js +117 -194
- package/lib/compact-v2.js +124 -273
- package/lib/dsh-responses.js +299 -0
- package/lib/index.js +548 -1593
- package/lib/json-store.js +34 -0
- package/lib/legacy-v3.js +20 -0
- package/lib/native-checkpoint.js +93 -0
- package/lib/responses-replay.js +281 -0
- package/lib/route.js +222 -0
- package/lib/service-mutex.js +72 -0
- package/lib/transport.js +59 -380
- package/lib/web-run-output.js +13 -152
- package/lib/web-search-alpha.js +26 -448
- package/lib/web-search-capability.js +8 -10
- package/lib/web-search-hosted.js +22 -372
- package/lib/web-search-ref-store.js +7 -7
- package/package.json +20 -14
- package/scripts/probe-alpha.mjs +28 -76
- package/scripts/validate-dsh-schema.mjs +31 -0
- package/lib/checkpoint-store-v3.js +0 -459
- package/lib/compact.js +0 -752
- package/lib/dsh-pi-responses.js +0 -339
- package/lib/private-file.js +0 -18
- package/lib/session-lease.js +0 -70
- package/lib/web-search-store.js +0 -181
package/README.md
CHANGED
|
@@ -1,162 +1,270 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
[](LICENSE)
|
|
5
|
+
# DSH-LCX-CODEX
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
**给 DeepSeek Harness 补上 GPT Responses / Codex 原生能力。**
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/dsh-lcx-codex)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
**简体中文** · [English](README_EN.md)
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
</div>
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
- 使用 NewAPI 中转的 GPT 模型(也就是第三方中转);NewAPI 的上游渠道连接 Sub2API。
|
|
18
|
+
---
|
|
19
19
|
|
|
20
|
-
|
|
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
|
-
|
|
22
|
+
> `LCX` 只是项目名称。本项目不隶属于 OpenAI、DeepSeek、Sub2API 或 NewAPI。
|
|
26
23
|
|
|
27
|
-
|
|
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
|
-
|
|
36
|
-
resolve_route --> alpha_gate
|
|
37
|
-
resolve_route --> native_compact
|
|
38
|
-
alpha_gate -->|是| alpha_search
|
|
39
|
-
alpha_gate -->|否| alpha_disabled
|
|
26
|
+
## 核心能力
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
+
因此搜索不会故意与 Native replay 共用同一个 `prompt_cache_key`。NewAPI 后台仍可能看到搜索请求夹在主会话请求之间;它们是不同请求,搜索行本身 cache 较低并不代表 DSH session 被截断。
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
97
|
+
Native 成功:不再额外运行 basic summary。
|
|
79
98
|
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
117
|
+
默认总 explicit retention 预算约 `64k` estimated tokens,其中 assistant-visible answer 最多预留约 `24k`,单条默认最多约 `3k`。不把 reasoning、巨大 tool result、完整搜索正文和运行 telemetry 全塞回来。
|
|
85
118
|
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
177
|
+
仅在需要这些参数时开启:
|
|
100
178
|
|
|
101
|
-
|
|
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
|
-
|
|
186
|
+
开启/关闭额外工具会改变 tool catalog,因此默认关闭以保持主会话 request schema 稳定。
|
|
104
187
|
|
|
105
|
-
|
|
188
|
+
### 3. Alpha:`websearch_alpha`
|
|
106
189
|
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
202
|
+
预发布版(当前 rc.8):
|
|
117
203
|
|
|
118
204
|
```powershell
|
|
119
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
218
|
+
## 推荐设置
|
|
140
219
|
|
|
141
|
-
|
|
220
|
+
```text
|
|
221
|
+
Enable plugin ✅
|
|
222
|
+
Use GPT Hosted Search ✅
|
|
223
|
+
Advanced Hosted Search ❌
|
|
224
|
+
Alpha Search ❌
|
|
142
225
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
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
|
-
|
|
266
|
+
关键设计说明见 [ARCHITECTURE.md](ARCHITECTURE.md),完整版本记录见 [CHANGELOG.md](CHANGELOG.md)。
|
|
159
267
|
|
|
160
268
|
## License
|
|
161
269
|
|
|
162
|
-
|
|
270
|
+
MIT
|