dsh-lcx-codex 0.4.0-rc.8 → 0.4.1-pre.1

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 CHANGED
@@ -9,7 +9,7 @@ DSH 0.1.1-rc.2 `compaction-basic` defaults to a `0.8` pressure threshold and, on
9
9
  - provider-confirmed context overflow continues to use DSH's original `context-overflow` recovery unchanged;
10
10
  - manual `/compact` remains unchanged.
11
11
 
12
- The pressure wrapper is installed on the actual agent-scoped compaction instance when an agent enters `running`, because DSH's own pre-step listener dynamically dispatches `this.compactIfNeeded()` at event time. The wrapper is restored on plugin cleanup.
12
+ Agent presets may isolate `compaction` and `toolResultPruner` inside entry-local Cordis realms. DSH 0.1.1-rc.2 explicitly documents that these preset services are invisible to both the host and ordinary `agent.ctx`; host-side code must address them through `agentPresets.serviceFor(agent, name)`. LCX therefore observes agent lifecycle events globally, resolves each Agent's real preset-local compaction/pruner through that public resolver, and patches the concrete compaction instance. A root `ctx.inject(['compaction'], ...)` hook remains only for non-preset/non-isolated deployments. Concrete Cordis service identity is used for de-duplication. DSH's own pre-step listener dynamically dispatches `this.compactIfNeeded()` at event time, and the wrapper is restored on plugin cleanup.
13
13
 
14
14
  ## rc.6 search timeout coordination
15
15
 
@@ -17,12 +17,16 @@ The pressure wrapper is installed on the actual agent-scoped compaction instance
17
17
 
18
18
  # Architecture Notes — 0.4 Native Session Refactor / rc.6 Pressure Coordination
19
19
 
20
+ ## rc.11 Native cache identity
21
+
22
+ Native compaction and same-route replay reuse the active DSH/Pi conversation cache identity: the clamped session id is the `prompt_cache_key`, provider `cacheRetention` is respected, and `long` may emit `prompt_cache_retention: 24h` when supported. `cacheRetention: none` omits Native prompt-cache/session affinity. Ordinary Hosted Search remains intentionally isolated under `dsh-lcx-search:<route hash>` so search traffic cannot share the main conversation request/cache namespace.
23
+
20
24
  ## Design invariants
21
25
 
22
26
  1. **DSH owns compaction policy.** LCX never independently decides threshold, compact range, pruning, transaction boundaries or overflow retries.
23
27
  2. **Native success performs one compaction model request.** Basic summary is a failure fallback, not a parallel portable-copy generator.
24
28
  3. **DSH session log is the new checkpoint source of truth.** Opaque Native V2 state lives in `compaction/summary.rawOutput`; v3 sidecar access is legacy read-only.
25
- 4. **Opaque state never crosses an incompatible route.** Provider, model, base URL and session ancestry gate native replay.
29
+ 4. **Opaque state is same-session only.** Provider, model, base URL and exact `sourceSessionId === currentSessionId` gate Native opaque replay. Verified parent/child ancestry authorizes portable migration only; a fork never sends the parent's opaque checkpoint state.
26
30
  5. **Route migration is transparent and transient.** Reconstruct shadowed DSH messages and hand them to the normal adapter; do not persist a second portable history copy.
27
31
  6. **Ordinary search has one model tool.** `web_search` is ordinary search; `websearch_gpt_advanced` exists only for parameters absent from `WebSearchRequest`; Alpha remains its own stateful protocol.
28
32
  7. **Provider-native wire code is isolated.** Direct `/responses` SSE code is limited to Native V2 compaction/replay and Hosted Search protocol calls.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,87 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1-pre.1 - Candidate QA pending / not published
4
+
5
+ - Integrates the accepted Alpha stateful continuation and fail-closed capability work from #20, #21, and #22.
6
+ - Includes accepted compatibility seam isolation (#24), typed protocol-core hardening (#25), unified conservative token budgeting (#26), and the installed-plugin settings lifecycle fix (#36).
7
+ - This is an unpublished candidate for #19 installed-candidate and cross-feature QA; no npm publication, tag, or release is implied.
8
+
9
+ ## 0.4.0 - 2026-08-23
10
+
11
+ ### Stable promotion
12
+
13
+ - Promote the fully validated `0.4.0-rc.13` runtime to the stable `0.4.0` line with no functional/runtime code changes.
14
+ - Make the rc.13 Native V2 hardening, canonical Responses replay/serialization fixes, session isolation, cache continuity, and concurrency/lifecycle fixes the recommended stable release.
15
+ - Preserve `0.3.4` only as historical stable state; `0.4.0` becomes the default npm `latest` after publication.
16
+
17
+ ### Validation
18
+
19
+ - Runtime-sensitive source is required to remain content-identical to the already live-tested rc.13 release.
20
+ - Full suite: 58/58 passed; DSH schema validation: 4/4 passed.
21
+ - Real rc.13 DSH acceptance already covers automatic Native pressure Compact, replay/cache re-warm, restart/resume, real GUI `/compact`, parent/child opaque isolation, and dual-session same-preset ServiceMutex failure cleanup.
22
+ - Stable promotion adds no new runtime behavior; publication is a version/documentation promotion only.
23
+
24
+ ## 0.4.0-rc.13 - 2026-08-23
25
+
26
+ ### Fixed
27
+
28
+ - Restrict opaque Native checkpoint replay to the exact source DSH session. Parent/child ancestry remains valid only for portable migration, so a fork never sends the parent session's opaque Native state.
29
+ - Reconcile Responses replay deltas and terminal output by stable item/call identity instead of `output_index` alone, preventing changed-index duplicate/empty text blocks and keeping terminal-only function calls balanced.
30
+ - Replace the simplified Native message/tool serializer with the public `@earendil-works/pi-ai@0.82.1` OpenAI Responses converters, preserving reasoning/message identities, tool linkage, constrained-tool semantics, deferred-tool transcript semantics, and DSH image boundaries.
31
+ - Match ordinary Pi `openai-responses` system-prompt placement: Native compact/replay now carries the developer/system prelude inside the canonical input prefix rather than introducing a separate top-level `instructions` prefix difference.
32
+ - Restore strict validation of DSH Pi replay-state envelopes before reusing native signatures; mismatched replay metadata degrades to a portable foreign-assistant projection instead of injecting stale provider-native identity.
33
+ - Treat Pi canonical role-only developer/user items as durable retained history and keep image persistence on `dsh_image_attachment` references rather than request image payloads.
34
+ - Use Pi/model or explicitly configured DSH Responses compatibility only; unknown custom routes no longer assume strict tools, grammar tools, or tool-search support.
35
+ - Mirror DSH/OpenAI Responses generation controls into Native compact/replay (`reasoning` + encrypted-reasoning include, temperature, and max output tokens), preventing the real Terra `xhigh` compact path from dropping the envelope used by ordinary Pi requests.
36
+ - Source automatic-compaction generation controls from the matching session request header rather than the Basic compaction summarizer request, so the selected conversation effort (for example Terra `xhigh`) reaches the Native provider request.
37
+ - Declare the DSH `sessions` service as an explicit Cordis runtime injection because checkpoint/replay and automatic-compaction generation parity read the live session/request header.
38
+ - Maintain a deterministic per-session request-header cache from DSH `session/event`; `compaction/start` synchronously refreshes it from the live Session before the Native request, avoiding reliance on async-context propagation for generation parity.
39
+ - Register that cross-session `session/event` observer with Cordis `{ global: true }`, matching DSH system-wide observers so Agent-carrier session events reach the standing plugin scope.
40
+ - Snapshot the exact `agentArg.session.requestHeader()` inside the Native-first pressure wrapper immediately before delegating to Basic compaction; this is the deterministic pressure-path source of generation controls, with the global session-event cache retained only as a secondary path.
41
+ - Seed the request-header cache from already-live sessions at plugin installation, seed newly announced resume/fork sessions, and evict disposed session entries so manual/non-pressure compaction remains restart-safe without retaining stale headers.
42
+ - Match the explicit Remote V2 tool-control contract used by current Codex and mature Responses compaction implementations: Native compact/replay send `tool_choice: "auto"` and `parallel_tool_calls: true` on the plain `openai-responses` route.
43
+ - Preserve only bounded provider machine diagnostics (`code`, `type`, `param`) from `response.failed`; the safe identifiers are included in the generic failure message/log so DSH compaction history can diagnose failures, while provider messages/bodies remain excluded.
44
+ - Persist Pi replay envelope v2 on successful Native replay finish so DSH retains response id/stop reason plus text/reasoning native metadata across post-compact turns.
45
+ - Preserve normal Pi OpenAI function-call identity as `call_id|item_id` for replay deltas and completed tool-call blocks, preventing loss of the provider `fc_*` item id on the next canonical request.
46
+ - Treat the session header `config` as the effective ordinary-request envelope even when DSH marks a value in `adapterDefaults`; those materialized defaults (for example Terra `xhigh` and `maxTokens`) are still sent by normal Pi and therefore must be mirrored by Native compact/replay.
47
+
48
+ ### Validation
49
+
50
+ - `tests/rc13-regressions.test.mjs`: 15/15 passed.
51
+ - Full local suite: 58/58 passed; DSH schema validation: 4/4 passed; `git diff --check` passed.
52
+ - Installed DSH/NewAPI acceptance passed on Terra xhigh: automatic 90% Native V2 compact, continuous replay/cache re-warm, DSH Web restart/resume, real GUI `/compact` plus continuation, and parent→child fork portable isolation all completed without pre-Native stock prune or cross-session opaque replay.
53
+ - This remains a local release candidate only; no npm/GitHub publication or tag is implied.
54
+
55
+ ## 0.4.0-rc.12 - 2026-08-22
56
+
57
+ ### Fixed
58
+
59
+ - Serialize every `compactIfNeeded()` call per concrete preset compaction service so same-generation sessions cannot observe each other’s temporary Native-first pruner/config state; queued calls are abortable and plugin cleanup drains active owners before restoring the original method.
60
+ - Align Native `openai-responses` session affinity with the active Pi adapter: default OpenAI-format routes use `session_id` plus `x-client-request-id`, while OpenRouter-format routes use `x-session-id`; explicit affinity headers remain authoritative.
61
+ - Restrict Basic fallback to allowlisted retryable first-checkpoint failures and fail closed once a Native/legacy checkpoint already exists.
62
+ - Require a real `response.completed` terminal event with `status=completed` for Native compaction/replay and reject orphan `function_call_output` items.
63
+ - Set credential-bearing fetches to `redirect: error` and keep provider response bodies/messages out of surfaced/logged transport errors.
64
+
65
+ ## 0.4.0-rc.11 - 2026-08-22
66
+
67
+ ### Fixed
68
+
69
+ - Restore ERR-051 cache/session affinity semantics that regressed in the rc.8 refactor: Native V2 compaction and same-route replay now use the DSH/Pi conversation session id as the clamped `prompt_cache_key` instead of a route fingerprint, inherit the active provider `cacheRetention`, emit `prompt_cache_retention: 24h` only for supported `long` retention, and omit Native cache affinity when retention is `none`.
70
+ - Keep ordinary Hosted Search on its intentionally separate `dsh-lcx-search:<route hash>` namespace.
71
+
72
+ ## 0.4.0-rc.10 - 2026-08-22
73
+
74
+ ### Fixed
75
+
76
+ - Fix Native-first pressure coordination for DSH 0.1.1-rc.2 Agent presets by using the public `agentPresets.serviceFor(agent, name)` resolver for preset-local `compaction` and `toolResultPruner` instances. This replaces the rc.9 assumption that ordinary `agent.ctx` lookup could see entry-local isolated services.
77
+
78
+ ## 0.4.0-rc.9 - 2026-08-22
79
+
80
+ ### Fixed
81
+
82
+ - Restore the Alpha capability/ref-store interfaces consumed by `lib/index.js`; the rc.8 release package could pass its unit tests but fail immediately at module import with missing `AlphaCapabilityStore` / `AlphaRefStore` exports.
83
+ - Add package-entry import regression coverage so CI fails when the server entry point and internal module exports drift out of sync.
84
+ - Restore Native-first pressure coordination for isolated agent presets using DSH 0.1.1-rc.2's public `agentPresets.serviceFor(agent, name)` resolver. Preset-local `compaction` / `toolResultPruner` services are not visible through ordinary host or `agent.ctx` lookup; the plugin now addresses the actual per-Agent instances before applying the 90% Native / 95% emergency policy. A root service-lifecycle hook remains for non-preset deployments.
3
85
  ## 0.4.0-rc.8
4
86
 
5
87
  - Rebase the plugin on DSH `0.1.1-rc.2`; older DSH releases are no longer a supported runtime target.
package/README.md CHANGED
@@ -1,261 +1,197 @@
1
1
  <div align="center">
2
2
 
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
-
5
- # DSH-LCX-CODEX
6
-
7
- **给 DeepSeek Harness 补上 GPT Responses / Codex 原生能力。**
3
+ <img src="assets/dsh-lcx-codex-banner.png" alt="dsh-lcx-codex — 为 DSH 增加 GPT Hosted Search、Codex 风格网页操作与 Native V2 Compaction" width="100%" />
8
4
 
9
5
  [![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)
6
+ [![CI](https://github.com/kk3ya03-star/dsh-lcx-codex/actions/workflows/publish.yml/badge.svg)](https://github.com/kk3ya03-star/dsh-lcx-codex/actions/workflows/publish.yml)
11
7
  ![DSH](https://img.shields.io/badge/DSH-0.1.1--rc.2-4ea8ff)
12
- ![License](https://img.shields.io/badge/license-MIT-1677ff)
8
+ ![Node](https://img.shields.io/badge/Node-%3E%3D20-2f855a)
9
+ ![License](https://img.shields.io/badge/license-MIT-6b7280)
13
10
 
14
- **简体中文** · [English](README_EN.md)
11
+ **简体中文** · [English](README_EN.md) · [Architecture](ARCHITECTURE.md) · [Changelog](CHANGELOG.md)
15
12
 
16
13
  </div>
17
14
 
18
- ---
19
-
20
- `dsh-lcx-codex` 是一个社区维护的 DSH 插件,面向已经通过 `llm-pi-ai / openai-responses` 接入的 GPT 路由。它尽量复用 DSH 自己的 Agent、Web、Session 和 Compaction 架构,只在缺少 OpenAI/Codex 原生语义的地方补能力。
15
+ > **DSH 仍然是 host。LCX 只补齐 GPT Responses 路径缺失的原生能力,不修改 DSH 核心,也不替换 Agent / Session / Web / Compaction。**
21
16
 
22
- > `LCX` 只是项目名称。本项目不隶属于 OpenAI、DeepSeek、Sub2API 或 NewAPI。
17
+ ## 它解决什么
23
18
 
24
- - **最新版 DSH 图片管线**:Native V2 直接复用 `readImageRequest()` 和当前路由图片预算,避免压缩请求与普通 GPT 请求使用不同的图片版本。
19
+ 如果你的 DSH 已经有一个可工作的 GPT `openai-responses` route,`dsh-lcx-codex` 让这条 route 更完整地使用 GPT Responses 原生能力,同时尽量保持 DSH 原有入口和生命周期不变。
25
20
 
26
- ## 核心能力
21
+ | 场景 | DSH 原有入口 | LCX 增强后 |
22
+ |---|---|---|
23
+ | 普通联网搜索 | DSH `web_search` | **仍然使用同一个 `web_search`**,由 LCX SearchProvider 映射到当前 GPT Hosted Search |
24
+ | Hosted Search 高级参数 | 普通搜索入口保持简洁 | 按需增加 `websearch_gpt_advanced`,提供域名过滤、近似位置、search context、图片搜索等 |
25
+ | 连续网页 / PDF 浏览 | DSH 继续拥有 Web 生命周期 | 按需增加 Codex / Alpha Web Actions:`search → open → find/click → screenshot` |
26
+ | 长会话压缩 | DSH 继续负责 pressure、事务与 recovery | 在现有 compaction seam 上优先请求 Responses Native V2 checkpoint |
27
27
 
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 秒 | 内置 |
28
+ **目标不是再造一套 Agent,而是让 DSH 的 GPT route 用上它本来就应该拥有的原生能力。**
38
29
 
39
- ## rc.8:面向 DSH 0.1.1-rc.2
30
+ ## 三大能力
40
31
 
41
- rc.8 直接面向 **DSH 0.1.1-rc.2**。普通 `web_search` 继续跟随当前 Agent 模型,同时 Native V2 的图片输入改用新版 DSH `readImageRequest()` 管线,不再直接读取 attachment master bytes。
32
+ ### 1. GPT Hosted Search:普通搜索不换入口
42
33
 
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
- ```
34
+ 启用后,模型看到的普通搜索工具依然是 DSH 原生 `web_search`。LCX 替换的是 SearchProvider 路径,而不是再注册一个重复的“普通搜索”工具。
58
35
 
59
- 这不会修改模型看到的 `web_search` schema。
36
+ 需要更细控制时,再单独启用 `websearch_gpt_advanced`。
60
37
 
61
- 没有 Agent 上下文时,才使用设置页里的 **回退 Responses 地址 / 回退 GPT 模型**。
38
+ ### 2. Codex 风格 Web Actions:需要时再打开
62
39
 
63
- ### Search 与会话缓存隔离
64
-
65
- Hosted Search 是一笔独立 Responses 请求,不等于主会话推理。rc.8 继续给搜索使用独立 cache namespace:
40
+ `websearch_alpha` 面向连续浏览和结构化 Web action:
66
41
 
67
42
  ```text
68
- 主会话 replay: dsh-lcx:<route hash>
69
- Hosted Search: dsh-lcx-search:<route hash>
43
+ search → open → find / click → screenshot
70
44
  ```
71
45
 
72
- 因此搜索不会故意与 Native replay 共用同一个 `prompt_cache_key`。NewAPI 后台仍可能看到搜索请求夹在主会话请求之间;它们是不同请求,搜索行本身 cache 较低并不代表 DSH session 被截断。
73
-
74
- ## Native V2 Compaction
46
+ 它默认关闭,并且只有当前 endpoint / provider / model / schema 通过 capability probe 后才注册。未知部署采用 **fail-closed**,不会被误报成“支持 Alpha”。
75
47
 
76
- DSH 本身已经负责:
48
+ ### 3. Native V2 Compaction:保留 DSH 会话语义
77
49
 
78
- - token pressure;
79
- - compactable range selection;
80
- - tool-result pruning;
81
- - durable session transaction;
82
- - `/compact`;
83
- - context-overflow recovery。
50
+ LCX 不创建第二套 compaction engine。DSH 仍然拥有 pressure、compactable range、`/compact`、durable session transaction、tool-result pruning 与 overflow recovery;LCX 只在已有 compaction LLM seam 上请求 Responses Native V2。
84
51
 
85
- 本插件不再造第二套 compaction engine,而是在 DSH 的 `purpose: 'compaction'` LLM seam 上执行 Native V2:
52
+ 默认自动策略:
86
53
 
87
54
  ```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" }]
55
+ 0% ─────────────────── 90% ───── 95% ───── 100%
56
+ normal Native emergency hard cap
57
+ V2 DSH prune
95
58
  ```
96
59
 
97
- Native 成功:不再额外运行 basic summary。
98
-
99
- Native 失败且开启 fallback:才回到 DSH basic compaction。
100
-
101
- ## 为什么压缩后还能记住模型自己说过的话
60
+ - **90%**:优先尝试 Native V2。
61
+ - **95%**:才允许 emergency DSH prune。
62
+ - provider-confirmed context overflow:继续使用 DSH 原有恢复逻辑。
63
+ - 手动 `/compact`:继续使用 DSH 原生会话事务。
102
64
 
103
- 单纯依赖 provider-native opaque compaction 是有损的。真实长会话测试发现,低显著性的 assistant-only 事实可能被压掉,例如:
65
+ 同一 source session 可以继续复用自己的 Native checkpoint;fork 或模型迁移不会跨 session 发送 parent 的 opaque state,而是走 portable migration;重启后从 DSH session log 恢复。
104
66
 
105
- - 模型随机生成的项目代号;
106
- - 搜索后模型给出的具体姓名;
107
- - 只在 assistant 最终回答里出现的数字。
67
+ ## 30 秒开始使用
108
68
 
109
- 因此当前 checkpoint 使用:
69
+ ### 1. 安装
110
70
 
111
- ```text
112
- bounded client-visible history
113
- + bounded assistant-visible answers
114
- + opaque Native V2 compaction item
71
+ ```powershell
72
+ dsh plugin --profile web add dsh-lcx-codex
73
+ dsh web
115
74
  ```
116
75
 
117
- 默认总 explicit retention 预算约 `64k` estimated tokens,其中 assistant-visible answer 最多预留约 `24k`,单条默认最多约 `3k`。不把 reasoning、巨大 tool result、完整搜索正文和运行 telemetry 全塞回来。
76
+ ### 2. 在 DSH Settings 启用
118
77
 
119
- 目标不是“逐字无损”,而是:**删过程,保事实。**
78
+ 第一次使用建议从最小配置开始:
120
79
 
121
- ## 自动压缩策略
80
+ | 设置 | 建议 |
81
+ |---|---:|
82
+ | Enable plugin | **On** |
83
+ | Use GPT Hosted Search | 需要 GPT Hosted Search 时 **On** |
84
+ | Advanced Hosted Search | **Off**,需要高级参数再开 |
85
+ | Alpha Search | **Off**,确认当前 route 支持后再开 |
86
+ | Native V2 remote compaction | 上游实际支持 Native V2 时 **On** |
87
+ | Native-first auto compaction | 使用 Native V2 时 **On** |
122
88
 
123
- rc.8 延续 rc.6 的 Native-first pressure policy:
89
+ **前提条件**
124
90
 
125
- ```text
126
- 0% ─────────────────── 90% ───── 95% ───── 100%
127
- 正常使用 Native emergency hard cap
128
- V2 DSH prune
129
- ```
91
+ - Node.js `>=20`
92
+ - DSH 中已有可工作的 GPT `openai-responses` route
93
+ - 上游 endpoint 实际支持你准备启用的 Hosted Search / Native V2 / Alpha 能力
130
94
 
131
- 默认:
95
+ ### 3. 确认它真的生效
132
96
 
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`:不受阈值影响。
97
+ 不要只看开关是否打开,按能力检查实际行为:
138
98
 
139
- 阈值可在插件设置页调整。
99
+ | 能力 | 应看到什么 |
100
+ |---|---|
101
+ | GPT Hosted Search | 普通工具入口仍是 DSH `web_search`,实际请求走当前 GPT Responses route |
102
+ | Advanced Hosted | 启用后出现 `websearch_gpt_advanced`,高级参数可以单独控制 |
103
+ | Alpha Web Actions | 只有 capability probe 通过时才出现 `websearch_alpha` |
104
+ | Native V2 | compact 时出现 provider-native checkpoint 路径;普通 Basic Compaction 不会被伪装成 Native V2 成功 |
140
105
 
141
- ## 关于“缓存突然断了”
106
+ ## 搜索工具怎么选
142
107
 
143
- 需要区分两件事:
108
+ 三个入口用途不同,**不需要全部开启**:
144
109
 
145
- ```text
146
- cacheRead = 0
147
- ≠
148
- 会话历史被删除
149
- ```
110
+ | 你要做什么 | 使用入口 | 适合场景 |
111
+ |---|---|---|
112
+ | 普通联网搜索 | DSH `web_search` | 找资料、查网页、一般检索 |
113
+ | 控制 Hosted Search 参数 | `websearch_gpt_advanced` | 域名 allow/block、近似位置、search context、图片搜索等 |
114
+ | 连续浏览网页或 PDF | `websearch_alpha` | `search/open/find/click/screenshot` 与结构化 Web actions |
150
115
 
151
- 在真实 NewAPI 日志里,出现过:
116
+ ## 它如何接入 DSH
152
117
 
153
118
  ```text
154
- 某轮:155k uncached / cacheRead 0
155
- 下一轮:~1k new input / ~155k cacheRead
119
+ DSH Agent / Session / Web
120
+ ├─ web_search ──────────> LCX SearchProvider ──> GPT Hosted Search
121
+ ├─ Advanced / Alpha ────> LCX Web tools ───────> GPT Web actions
122
+ └─ compact / replay ────> LCX Native bridge ───> Responses Native V2
156
123
  ```
157
124
 
158
- 这说明上一轮只是 provider prompt-cache miss / eviction,完整上下文仍被重新发送,并没有发生 session compaction 或 surface replacement。
125
+ **DSH 是 host,LCX 是兼容扩展层。** 插件优先复用当前 DSH route 的 `baseURL`、credential reference、headers、模型与 retry policy,而不是维护第二套账号配置。
159
126
 
160
- 真正会主动改变历史前缀的主要情况是:
127
+ checkpoint、canonical replay、Pi serializer、cache identity、fork safety 与 pressure coordination 等实现细节见 [ARCHITECTURE.md](ARCHITECTURE.md)。
161
128
 
162
- 1. `/compact` / 自动 Native compaction;
163
- 2. emergency tool-result pruning;
164
- 3. 换模型 / provider / baseURL;
165
- 4. DSH 自己发生其他 surface replacement。
129
+ ## 兼容性
166
130
 
167
- DSH 重启、长时间 idle、上游 cache TTL/eviction 也可能造成某一轮重新建 cache;插件无法保证第三方网关永不 evict KV cache。
131
+ 当前正式验证组合:
168
132
 
169
- ## 搜索分层
133
+ | Plugin | DSH | DSH host Pi | Plugin Pi | 状态 |
134
+ |---|---|---|---|---|
135
+ | `0.4.0` | `0.1.1-rc.2` | `0.82.1` | `0.82.1` | **VERIFIED** |
170
136
 
171
- ### 1. 普通搜索:`web_search`
137
+ 新的 DSH 版本**不会自动视为兼容**。项目会先检查受影响的 DSH / Pi seam,再按风险运行对应测试;Pi registry 单独出现新版本也不会自动升级插件依赖。
172
138
 
173
- 推荐默认使用。rc.8 会跟随当前 Agent 的 GPT Responses route。
139
+ <details>
140
+ <summary><strong>完整推荐设置</strong></summary>
174
141
 
175
- ### 2. 高级 Hosted:`websearch_gpt_advanced`
142
+ | 设置 | 推荐值 | 说明 |
143
+ |---|---:|---|
144
+ | Enable plugin | On | 启用插件 |
145
+ | Use GPT Hosted Search | 按需 | 让 DSH `web_search` 走 GPT Hosted Search |
146
+ | Advanced Hosted Search | Off | 需要高级 Hosted 参数时再开 |
147
+ | Alpha Search | Off | capability 验证后再开 |
148
+ | Native V2 remote compaction | On* | *上游 route 实际支持 Native V2 时 |
149
+ | Native-first auto compaction | On | 启用自动 pressure 策略 |
150
+ | Native threshold | 90% | 90% 开始优先 Native V2 |
151
+ | Emergency DSH prune | 95% | 95% 才允许 emergency prune |
152
+ | `web_search` timeout | 240 s | 避免长搜索被过早终止 |
176
153
 
177
- 仅在需要这些参数时开启:
154
+ 主要配置字段:`remoteCompaction`、`autoCompaction`、`fallbackToBasicCompaction`、`autoCompactionThresholdPercent`、`emergencyPruneThresholdPercent`、`webSearchTimeoutSeconds`、`advancedHostedSearch`、`alphaSearch`。
178
155
 
179
- - allowed / blocked domains;
180
- - approximate user location;
181
- - `search_context_size`;
182
- - image search;
183
- - external web access;
184
- - return token budget。
156
+ </details>
185
157
 
186
- 开启/关闭额外工具会改变 tool catalog,因此默认关闭以保持主会话 request schema 稳定。
158
+ <details>
159
+ <summary><strong>其他安装方式</strong></summary>
187
160
 
188
- ### 3. Alpha:`websearch_alpha`
189
-
190
- 面向 stateful Codex/Alpha 风格搜索:`search/open/find/click/screenshot` 等。只有 capability probe 与当前 endpoint/provider/model/schema 匹配后才注册。
191
-
192
- ## 安装
193
-
194
- ### npm
195
-
196
- 稳定版:
197
-
198
- ```powershell
199
- dsh plugin --profile web add dsh-lcx-codex
200
- ```
201
-
202
- 预发布版(当前 rc.8):
161
+ **预发布版**
203
162
 
204
163
  ```powershell
205
164
  dsh plugin --profile web add dsh-lcx-codex@next
206
165
  ```
207
166
 
208
- ### 本地 RC
167
+ **本地 tarball**
209
168
 
210
169
  ```powershell
211
170
  dsh plugin --profile web remove dsh-lcx-codex
212
- dsh plugin --profile web add .\dsh-lcx-codex-0.4.0-rc.8.tgz
171
+ dsh plugin --profile web add .\dsh-lcx-codex-0.4.0.tgz
213
172
  dsh web
214
173
  ```
215
174
 
216
- 不要为了升级删除 `$DSH_HOME/storages/lcx-codex/` 或旧 session。v3 sidecar 仍作为只读旧会话兼容层。
175
+ 升级插件时,不要为了“清理”删除 DSH session 或 `$DSH_HOME/storages/lcx-codex/`。旧会话可能仍引用历史兼容数据。
217
176
 
218
- ## 推荐设置
177
+ </details>
219
178
 
220
- ```text
221
- Enable plugin ✅
222
- Use GPT Hosted Search ✅
223
- Advanced Hosted Search ❌
224
- Alpha Search ❌
225
-
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
- ```
179
+ <details>
180
+ <summary><strong>常见情况</strong></summary>
232
181
 
233
- 调试 Native 时可以先关闭 fallback;稳定使用时是否开启 fallback 由你决定。
182
+ **`web_search` 没走 GPT Hosted Search**
183
+ 确认插件和 Hosted Search 已启用,并且当前 Agent 能解析到兼容的 GPT `openai-responses` route。
234
184
 
235
- ## 部署要求
185
+ **`websearch_alpha` 没出现**
186
+ 这是预期的 fail-closed 行为。Alpha 必须对当前 route/schema 完成可信 capability probe 后才注册。
236
187
 
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
247
- ```
188
+ **Native V2 没有生效**
189
+ 确认当前 GPT Responses endpoint 实际支持 `remote_compaction_v2`。插件不会把普通 Basic Compaction 假装成 Native V2 成功。
248
190
 
249
- 插件优先复用 DSH route 的 `baseURL`、credential reference、headers 和 retry policy。
191
+ </details>
250
192
 
251
- ## 发布通道
252
-
253
- - npm stable:正式稳定版本
254
- - npm `next`:`0.4.0-rc.*` 预发布测试版本
255
-
256
- GitHub tag 与 `package.json` version 必须一致;Trusted Publishing workflow 会先跑测试再发布。
257
-
258
- ## 开发
193
+ <details>
194
+ <summary><strong>开发</strong></summary>
259
195
 
260
196
  ```bash
261
197
  npm test
@@ -263,8 +199,14 @@ npm run test:schema
263
199
  npm pack --ignore-scripts
264
200
  ```
265
201
 
266
- 关键设计说明见 [ARCHITECTURE.md](ARCHITECTURE.md),完整版本记录见 [CHANGELOG.md](CHANGELOG.md)。
202
+ - 设计与协议细节:[ARCHITECTURE.md](ARCHITECTURE.md)
203
+ - 版本变化:[CHANGELOG.md](CHANGELOG.md)
204
+ - npm:[`dsh-lcx-codex`](https://www.npmjs.com/package/dsh-lcx-codex)
205
+
206
+ </details>
267
207
 
268
208
  ## License
269
209
 
270
210
  MIT
211
+
212
+ > `LCX` 只是项目名称。本项目是社区项目,不隶属于 OpenAI、DeepSeek、Sub2API 或 NewAPI。