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

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.
@@ -0,0 +1,89 @@
1
+
2
+ ## rc.6 pressure coordination
3
+
4
+ DSH 0.1.1-rc.2 `compaction-basic` defaults to a `0.8` pressure threshold and, once pressure qualifies, runs `toolResultPruner` before summary compaction. Real long-session traces showed that a large prune can reduce the measured surface below 80%, preventing the Native summarizer from running while still rewriting an old request prefix and invalidating cache. rc.6 coordinates the existing engine instead of replacing it:
5
+
6
+ - for a compatible GPT Responses route with Native auto-compaction enabled, `compactIfNeeded(..., "pressure")` returns `null` below the configured Native threshold (default 90%), so the stock 80% path does not mutate history;
7
+ - from 90% up to the emergency threshold, the existing engine still owns range selection and the durable transaction, but `toolResultPruner.pruneSession()` is temporarily suppressed for that call; the engine's summary transport therefore reaches the existing `purpose=compaction` Native V2 override first;
8
+ - at the emergency threshold (default 95%) or above, the pruner is no longer suppressed and DSH may shrink oversized tool results before attempting summary compaction;
9
+ - provider-confirmed context overflow continues to use DSH's original `context-overflow` recovery unchanged;
10
+ - manual `/compact` remains unchanged.
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.
13
+
14
+ ## rc.6 search timeout coordination
15
+
16
+ `dsh-tool-web` stores the cooperative search deadline only in `ToolDefinition.timeoutMs`; timeout metadata is explicitly not sent to the model. rc.6 adjusts the visible `web_search` definition's timeout to 240 seconds by default and restores the original value on cleanup. This avoids the observed 60-second false timeout while leaving the model-visible tool schema byte-stable.
17
+
18
+ # Architecture Notes — 0.4 Native Session Refactor / rc.6 Pressure Coordination
19
+
20
+ ## Design invariants
21
+
22
+ 1. **DSH owns compaction policy.** LCX never independently decides threshold, compact range, pruning, transaction boundaries or overflow retries.
23
+ 2. **Native success performs one compaction model request.** Basic summary is a failure fallback, not a parallel portable-copy generator.
24
+ 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.
26
+ 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
+ 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
+ 7. **Provider-native wire code is isolated.** Direct `/responses` SSE code is limited to Native V2 compaction/replay and Hosted Search protocol calls.
29
+
30
+ ## Why not subclass `BasicCompactionEngine`
31
+
32
+ `BasicCompactionEngine.summarize()` is the intended subclass customization hook, but a subclass is a new `ctx.compaction` service provider. The shipped DSH profile already mounts `dsh-compaction-basic`; mounting a second engine would duplicate service ownership/listeners unless the profile explicitly replaces the existing row.
33
+
34
+ The stock summarizer already routes through `ctx.llm.stream({ purpose: 'compaction' })`. For an out-of-tree optional plugin that must install without rewriting the base profile, narrowly intercepting that purpose is the less invasive integration.
35
+
36
+ If DSH later adds a public **summarizer provider registry** (distinct from the compaction engine service), LCX should migrate to it.
37
+
38
+ ## Why not inline opaque JSON in checkpoint text
39
+
40
+ Inlining `encrypted_content` makes the session self-contained, but also exposes a large opaque string to DSH's visible surface/token accounting. Using a non-text block in `compaction/summary.rawOutput` keeps the session self-contained without turning provider state into prompt text.
41
+
42
+ ## Remaining deliberate low-level seams
43
+
44
+ ### Native Responses replay
45
+
46
+ Generic DSH/Pi messages do not expose an input type for OpenAI `compaction` items. Same-route resume therefore builds the Responses request directly. This is a bounded compatibility adapter, not a second general LLM stack.
47
+
48
+ ### Runtime Web SearchProvider selection
49
+
50
+ DSH 0.1.1-rc.2 pins `deepseek-official` and has no public live setter. LCX uses an isolated compatibility write to the 0.1.1-rc.2 runtime field so the settings toggle works without restart. A future DSH public setter/configuration hook should replace this shim.
51
+
52
+ ## Cache expectations
53
+
54
+ - Stable ordinary tool schema improves prefix stability versus exposing two ordinary search tools.
55
+ - Enabling/disabling Advanced or Alpha changes tools and may reset provider prefix cache.
56
+ - Compaction necessarily changes visible history and therefore starts a new post-checkpoint prefix.
57
+ - `prompt_cache_key` remains stable per exact route/session across Native compaction and native replay.
58
+ - Remote-first avoids an otherwise redundant large-prefix local summary call.
59
+
60
+ ## Native V2 retained-history invariant
61
+
62
+ Current Codex V2 retains selected client messages and appends the opaque compaction item. Real DSH testing showed an additional product-level fidelity problem: a low-salience fact that existed only in an assistant answer can be omitted by the opaque state. LCX rc.5 therefore keeps the Native ordering but adds a bounded assistant-visible protection layer:
63
+
64
+ ```text
65
+ selected user/developer/system message items
66
+ + selected assistant visible output_text items
67
+ → opaque compaction item
68
+ → later DSH-retained / post-compaction messages
69
+ ```
70
+
71
+ The fidelity prefix is capped at an estimated 64k tokens total. Up to 24k is reserved for assistant-visible answers; each retained assistant answer is capped at about 3k tokens. Assistant copies deliberately exclude reasoning, response IDs, tool calls, tool outputs, and provider-private state. The opaque item remains the only durable representation of those process details.
72
+
73
+ The DSH surface still stores only the short checkpoint marker. The retained wire items and opaque compaction state remain log-only in `compaction/summary.rawOutput`, so they do not inflate DSH's visible token-meter surface. They do, intentionally, increase the post-compaction provider request relative to an opaque-only checkpoint; the total explicit retention ceiling prevents this protection from defeating compaction.
74
+
75
+ Compatibility:
76
+
77
+ - `0.4.0-rc.3`: v4 checkpoint could contain only the opaque item.
78
+ - `0.4.0-rc.4`: v4 checkpoint retained client messages but not assistant-visible answers.
79
+ - `0.4.0-rc.5`: writes `lcx-native-compaction-v5`; when replaying a v4 checkpoint it reconstructs the shadowed DSH transcript and derives the v5 fidelity prefix before reusing the original opaque state.
80
+
81
+
82
+
83
+ ## rc.7 active-Agent Hosted Search routing
84
+
85
+ DSH intentionally keeps `SearchProvider.search()` small: the provider receives the normalized search request and cancellation signal, not the calling Agent. Ordinary Hosted Search still needs the exact active GPT Responses route, especially when a user switches between Sol/Luna or multiple proxy routes.
86
+
87
+ rc.7 therefore captures route identity at the model-facing `tools/execute` boundary for `web_search` and propagates it through Node `AsyncLocalStorage` only for the lifetime of that tool execution. `LcxResponsesSearchProvider.search()` resolves the route from that async context and falls back to the plugin-configured route only when no compatible active Agent route exists. No fields are added to the DSH `web_search` schema.
88
+
89
+ Hosted Search uses a dedicated stable cache namespace (`dsh-lcx-search:<route fingerprint>`) rather than the Native replay namespace (`dsh-lcx:<route fingerprint>`). The two requests have different prefixes and should not be intentionally co-routed under one prompt-cache key.
package/CHANGELOG.md CHANGED
@@ -1,65 +1,106 @@
1
1
  # Changelog
2
2
 
3
- 本项目遵循语义化版本。未通过真实验收的能力只记录在Unreleased,不作为已发布功能。
3
+ ## 0.4.0-rc.8
4
4
 
5
- ## Unreleased
5
+ - Rebase the plugin on DSH `0.1.1-rc.2`; older DSH releases are no longer a supported runtime target.
6
+ - Native V2 compaction image replay now uses DSH `attachments.readImageRequest()` with the active `llm-pi-ai` route's request-image pixel/byte policy instead of reading normalized master bytes directly.
7
+ - Native image requests use DSH's deterministic `offloadRequestImagesWithPolicy()` projection before serialization, matching the current request-size behavior for long image-heavy sessions.
8
+ - Keep rc.7 active-Agent Hosted Search routing, isolated search cache namespace, 240s search timeout, rc.5 conversation-fidelity checkpointing, and rc.6 90% Native-first / 95% emergency pressure policy unchanged.
9
+ - CI installs against current declared DSH packages instead of enforcing the stale rc.8 lockfile.
6
10
 
7
- ## 0.3.3 - 2026-08-21
11
+ ## 0.4.0-rc.7 - 2026-08-22
8
12
 
9
13
  ### Fixed
10
14
 
11
- - Native V2 checkpoint 现在由客户端按 64K token 预算保留最近真实 user messages,再追加 exactly-one compaction item;不再错误假设上游 `response.output` 会返回 retained messages。旧的 compaction-only v3 checkpoint 会从 portable history 安全补全,运行时上下文注入不会进入 replacement history。
15
+ - Ordinary DSH `web_search` now follows the active Agent `provider/model` instead of always using the plugin fallback GPT model. A Luna conversation now searches with Luna; a Sol conversation searches with Sol.
16
+ - Added an AsyncLocalStorage route bridge at the DSH `tools/execute` boundary so the provider-only `ctx.web.search()` seam can receive Agent route context without changing the model-visible `web_search` schema.
17
+ - Hosted Search now uses a separate stable `dsh-lcx-search:<route hash>` `prompt_cache_key`, avoiding intentional cache-key sharing with Native conversation replay.
18
+ - The settings UI now labels the configured Responses endpoint/model as **fallback** values, matching their actual rc.7 role.
12
19
 
13
- ### Documentation
20
+ ### Kept from rc.6
14
21
 
15
- - 记录 installed `0.3.2` 的 compact + 三次 replay 缓存实测,并说明 Sub2API Codex OAuth 路径会删除上游不支持的 `prompt_cache_retention`;短缓存过期后的单次冷请求不等于插件改变了稳定前缀。
16
- - 增加连续 replay 的前缀稳定性回归断言,区分缓存生命周期与 replacement-history 保真问题。
22
+ - 240-second default DSH `web_search` deadline.
23
+ - Native-first automatic pressure policy: 90% Native V2, 95% emergency DSH prune.
24
+ - rc.5 conversation-fidelity checkpoints and restart-safe DSH session-log persistence.
17
25
 
18
- ## 0.3.2 - 2026-08-21
26
+ ### Docs / release
19
27
 
20
- ### Fixed
28
+ - Reworked the README around the current architecture and real cache observations.
29
+ - Added a blue/white DSH-LCX-CODEX hero banner for GitHub/npm.
30
+ - GitHub trusted publishing is wired through `.github/workflows/publish.yml`: pre-release tags publish to npm dist-tag `next`; stable tags publish to `latest`.
21
31
 
22
- - Native V2 compact 与同路由 replay 现在和 DSH/Pi 普通 Responses 请求复用相同的 session `prompt_cache_key`、缓存 retention 与会话 header,避免压缩边界额外切换 NewAPI/Sub2API 的缓存和账号粘性域;`cacheRetention: none` 时同时省略这些缓存信号。
23
- - 移除未被插件直接导入或注入的 `@deepseek-ai/dsh-compaction-basic` peer 声明,避免 DSH/pnpm 安装时出现误导性的宿主依赖警告;Basic fallback 继续通过 DSH `llm/stream` 的 `next()` 链调用宿主实现。
32
+ ## 0.4.0-rc.6
24
33
 
25
- ## 0.3.1 - 2026-08-21
34
+ - Added Native-first automatic pressure coordination for GPT Responses sessions: below the configured Native threshold the plugin suppresses DSH's stock 80% pressure compaction/prune path; at the default 90% threshold it lets compaction proceed while temporarily suppressing tool-result pruning so Native V2 runs first.
35
+ - Added a separate emergency prune threshold (default 95%). At or above this zone, DSH's replay-safe tool-result pruner is allowed to run before compaction as overflow protection.
36
+ - Added adjustable `web_search` tool deadline, default 240 seconds (30–600s). This mutates only DSH's non-model-visible `ToolDefinition.timeoutMs`, so the model tool schema and prompt-cache prefix do not change.
37
+ - Added Settings UI controls for automatic compaction, Native threshold, emergency prune threshold, and web search timeout.
38
+ - Kept the rc.5 checkpoint/fidelity format unchanged (`lcx-native-compaction-v5`); rc.6 is a pressure/timeout coordination release, not another checkpoint migration.
26
39
 
27
- ### Fixed
40
+ ## 0.4.0-rc.5
28
41
 
29
- - 删除未被 DSH 官方识别、且错误写死旧域名与 `LCX_API_KEY` `dshhub` 权限块;README 改为声明网络目标和凭据由当前 `openai-responses` provider 动态决定。
30
- - 添加 npm DSH 社区检索使用的标准关键词,其中包括 `dsh-plugin` GitHub topic 对应关键词。
31
- - 新增独立英文用户文档 `README_EN.md`,并与中文 README 互相链接。
42
+ - Adds a bounded conversation-fidelity layer after real DSH testing showed assistant-only facts could be lost by opaque Native V2 compaction.
43
+ - New `lcx-native-compaction-v5` checkpoints retain selected user/developer/system messages plus user-visible assistant final answers before the opaque compaction item.
44
+ - Keeps explicit retained history within an estimated 64k-token ceiling; defaults reserve at most 24k for assistant answers and cap one retained answer at about 3k tokens.
45
+ - Does not copy reasoning, tool calls/results, raw search payloads, or telemetry into the fidelity prefix.
46
+ - Repairs rc.3/rc.4 v4 checkpoints from append-only `shadowedSeqs`, including assistant-visible answers when the original DSH events still exist.
47
+ - Stores only the single opaque compaction output item, ignoring unrelated terminal output items from nonstandard proxies.
48
+ - Route compatibility now accepts both native checkpoint versions 4 and 5.
49
+ - Adds regression coverage for the exact assistant-only anchor failure (`Cobalt-Sparrow-604` / `81736`) and the 64k retention ceiling.
32
50
 
33
- ## 0.3.0 - 2026-08-21
51
+ ## 0.4.0-rc.4
34
52
 
35
- ### Changed
53
+ - Fixes a Native V2 replay fidelity bug found by real DSH session-log testing.
54
+ - Native checkpoints now persist the retained client-authored Responses messages before the opaque `compaction` item, matching current OpenAI Codex remote-compaction V2 replacement-history semantics.
55
+ - Existing rc.3 opaque-only v4 checkpoints are repaired on replay by reconstructing the missing shadowed user history from the DSH append-only session log.
56
+ - Adds replay/retention regression coverage and an explicit Native success diagnostic.
57
+ - Keeps the rc.3 search-provider, remote-first fallback, and session-log-native checkpoint architecture unchanged.
36
58
 
37
- - 收紧 npm/DSH 安装包,只保留运行时代码、Alpha 运维探针、许可证和用户文档;开发测试与 schema 校验脚本继续保留在源码仓库。
38
- - README 和包元数据明确 `LCX` 只是插件名称;支持 Sub2API 反代或 NewAPI 中转的 GPT 模型,不隶属于 OpenAI;Alpha 能力继续按部署 fingerprint 与可信 provenance 分类,不作全局 native 承诺。
39
- - 明确 Alpha 经过 NewAPI 时渠道类型必须为 `Sub2API`,不能使用普通 `OpenAI` 渠道。
40
- - README 改为面向用户的中文文档,提供经 DSH/pnpm 帮助核对的 GitHub URL、Release 包、更新和卸载命令;本地 `link:` 安装明确归入源码开发流程。
59
+ ## 0.4.0-rc.3
41
60
 
42
- ### Added
61
+ - Fix Cordis external-package loading: all `ctx.web`/`ctx.llm` service access now occurs inside an explicit `ctx.inject(['llm', 'web'], ...)` scope.
62
+ - This fixes `cannot get property "web" without inject` when DSH loads the plugin from a profile-installed `.tgz`.
63
+ - No protocol or checkpoint-format changes from rc.2.
43
64
 
44
- - Hosted Search 完整结构化参数与 citation/source/image 输出。
45
- - 独立 `websearch_alpha`,支持 search、image、open/find/click、PDF screenshot、finance、weather、sports 和 time;capability/ref sidecar 按 route 与 session 隔离。
46
- - Native V2 checkpoint v3、同路由 replay、Sol/Luna portable migration、fork/tree/restart generation lease 与 durable-image migration。
65
+ ## 0.4.0-rc.2 - 2026-08-21
47
66
 
48
- ### Fixed
67
+ - Packaging-only fix over rc.1: remove unnecessary `@deepseek-ai/dsh-compaction-basic` and `@deepseek-ai/dsh-web` peer declarations.
68
+ - The plugin consumes DSH runtime services through injected `ctx.*` seams and does not import or mount either package directly.
69
+ - Avoids misleading pnpm "missing peer" warnings and, importantly, avoids encouraging users to install a second compaction backend.
70
+
71
+ ## 0.4.0-rc.1 - 2026-08-21
72
+
73
+ ### Architecture
74
+
75
+ - Keep DSH `compaction-basic` as the sole compaction service owner; use only its documented/interceptable `purpose=compaction` `llm/stream` summarizer seam.
76
+ - Replace parallel local+remote compaction with remote-first fallback.
77
+ - Persist new Native V2 opaque state in DSH `compaction/summary.rawOutput` using `lcx-native-compaction-v4`; the model-visible replacement stays short.
78
+ - Remove new-checkpoint writes to the v3 JSON sidecar. The v3 sidecar is now read-only compatibility for old sessions.
79
+ - Reconstruct portable history for route migration from DSH append-only `shadowedSeqs` instead of duplicating every checkpoint's portable history.
80
+ - Preserve same-route fork replay through DSH session ancestry.
81
+ - Centralize the remaining direct Responses-native transport in `compact-v2.js` and `responses-replay.js`.
82
+
83
+ ### Search
84
+
85
+ - Make `ctx.web` / DSH `web_search` the ordinary Hosted Search entry point.
86
+ - Remove the ambiguous ordinary `websearch_gpt` tool.
87
+ - Add opt-in `websearch_gpt_advanced` for Hosted-only controls that DSH `WebSearchRequest` cannot express.
88
+ - Keep `websearch_alpha` independent and capability-gated.
89
+ - Isolate the DSH rc.8 runtime SearchProvider-selection compatibility shim.
90
+
91
+ ### Reliability
92
+
93
+ - Rehydrate DSH image attachment references when replaying legacy v3 checkpoints.
94
+ - Resolve startup settings into runtime route config immediately instead of waiting for the first settings change.
95
+ - Do not assume `events[seq]` is always the event whose `event.seq === seq`; use a safe fallback lookup.
96
+ - Add protocol, session persistence, migration and architecture regression tests.
97
+
98
+ ### Compatibility
99
+
100
+ - Node.js >= 20.
101
+ - Target DSH `0.1.1-rc.2` only.
102
+ - Existing 0.3.x v3 marker sessions remain best-effort readable through the old sidecar.
103
+
104
+ ## 0.3.1
49
105
 
50
- - Hosted Search 与 Alpha Search 现在和 Native V2 Compact 一样,复用 DSH 已添加的 `openai-responses` provider 路由、凭据引用、headers 与 retry policy;不再要求用户为插件重复配置 `LCX_API_KEY`。
51
- - README 将插件运行时凭据与运行在 DSH 外的 Alpha 探针/E2E 测试凭据明确分开。
52
- - README 改为简短的用户手册,以 npm 安装为主;Alpha 提示前置,并按 NewAPI 当前源码区分 4 种中转渠道类型与 Sub2API 直连,共 5 种部署路径。
53
- - Native replay and portable migration no longer depend on the nonexistent `GenerateOptions.branchId`; fork safety uses public session ancestry and derived marker history while preserving existing v3 fingerprint compatibility.
54
- - README 的本地 link 安装示例不再包含开发机绝对路径。
55
- - Alpha 从 rc.8 公共 `session.requestContext()` 读取 active route,避免模型切换后的 capability 误判。
56
- - Alpha 对 HTTP 200 内的函数调用语义错误 fail closed,并修正 sports action 的 wire 字段。
57
- - Responses SSE 去重、usage、工具配对、并发 sidecar、Windows ACL、图片 offload/hydrate 和 remote/local summary 边界。
58
-
59
- ## 0.2.0
60
-
61
- - Hosted Responses query-only Web Search。
62
- - Native Remote Compaction V2,拒绝legacy transport。
63
- - checkpoint v3、同route replay和第一批portable model migration。
64
- - 图片同route attachment hydrate,portable image migration保持fail closed。
65
- - 协议、大小、超时、重试、redirect和日志脱敏基础测试。
106
+ - Previous Hosted/Alpha Search and Native V2 checkpoint-v3 implementation.
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.8.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