dsh-lcx-codex 0.6.0-pre.1 → 0.6.0

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,6 +1,6 @@
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.svg" alt="LCX Codex" width="100%" />
3
+ <img src="https://raw.githubusercontent.com/kk3ya03-star/dsh-lcx-codex/stable/0.6.x/assets/dsh-lcx-codex-banner.svg" alt="LCX Codex" width="100%" />
4
4
 
5
5
  # LCX Codex
6
6
 
@@ -8,9 +8,9 @@
8
8
 
9
9
  [![npm latest](https://img.shields.io/npm/v/dsh-lcx-codex/latest?label=latest)](https://www.npmjs.com/package/dsh-lcx-codex)
10
10
  [![npm prelatest](https://img.shields.io/npm/v/dsh-lcx-codex/prelatest?label=prelatest&color=orange)](https://www.npmjs.com/package/dsh-lcx-codex?activeTab=versions)
11
- [![License](https://img.shields.io/badge/license-MIT-555)](LICENSE)
11
+ [![License](https://img.shields.io/badge/license-MIT-555)](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/LICENSE)
12
12
 
13
- **简体中文** · [English](README_EN.md) · [更新日志](CHANGELOG.md) · [问题反馈](https://github.com/kk3ya03-star/dsh-lcx-codex/issues)
13
+ **简体中文** · [English](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/README_EN.md) · [更新日志](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/CHANGELOG.md) · [问题反馈](https://github.com/kk3ya03-star/dsh-lcx-codex/issues)
14
14
 
15
15
  </div>
16
16
 
@@ -37,39 +37,56 @@ LCX Codex 是 [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness
37
37
 
38
38
  | 你的 DSH 版本 | 安装的 LCX 版本 | 安装命令中的标签 |
39
39
  | --- | --- | --- |
40
- | `0.2.1-alpha.2` 及以后 | `0.6.0-pre.1`(预发布版) | `@prelatest` |
41
- | `0.2.0` 系列(`0.2.0-rc.2`,早于 `0.2.1-alpha.2`) | `0.5.1`(稳定版) | `@latest` |
40
+ | `0.2.2-alpha.3` 及以后(DSH `0.2.2` 预发布系列) | `0.7.0-pre.1`(预发布版) | `@prelatest` |
41
+ | `0.2.1` 系列(`0.2.1-rc.5` 及以后的 `0.2.1` 版本,DSH `latest` 通道) | `0.6.0`(稳定版) | `@latest` |
42
+ | `0.2.0` 系列(`0.2.0-rc.2`,早于 `0.2.1-alpha.2`) | `0.5.2`(旧稳定版) | `@0.5.2` |
42
43
  | `0.1.6` 系列(`0.1.6-alpha.2` 及以后) | `0.4.4-pre.1`(旧预发布版) | `@0.4.4-pre.1` |
43
44
  | `0.1.5` 系列(`0.1.5-rc.1` 及以后) | `0.4.3`(稳定版) | `@0.4.3` |
44
45
 
45
- 请务必按表格选择:几个版本互不兼容,装错版本时安装命令可能只给出依赖警告,但插件可能无法正常工作。`@latest` 是稳定版 `0.5.1`(发布基线 DSH `0.2.0-rc.2`,host / plugin Pi `0.87.1`),DSH `0.1.5` 用户请固定安装 `@0.4.3`。
46
+ 请务必按表格选择:几个版本互不兼容,装错版本时安装命令可能只给出依赖警告,但插件可能无法正常工作。`@latest` 是稳定版 `0.6.0`(发布基线 DSH `0.2.1-rc.5`,host / plugin Pi `1.5.0`);DSH `0.2.0` 用户请固定安装 `@0.5.2`,DSH `0.1.5` 用户请固定安装 `@0.4.3`。历史说明:`0.6.0-pre.2` 是面向 DSH `0.2.1-alpha.2` 的历史预发布版,只在 DSH `0.2.1-alpha.2` 上验证过;`0.2.1-rc.5` 之前的其他早期 `0.2.1` 构建都没有经过验证。使用早期 `0.2.1` 构建时,请把 DSH 升级到 `0.2.1-rc.5`,再安装 `0.6.0`(`@latest`)。DSH `0.2.2-alpha.1` / `0.2.2-alpha.2` 没有经过验证的 LCX 版本,请升级到 `0.2.2-alpha.3` 或更新版本。
46
47
 
47
- `0.6.0-pre.1` 是预发布版,面向 DSH `0.2.1-alpha.2`。它的安装范围**只有下限**(`>=0.2.1-alpha.2`),没有上限:更新的 DSH 版本也能装上,但**没有经过验证**。本次预发布的验证基线只有 DSH `0.2.1-alpha.2`(host Pi `1.1.0`,plugin Pi `0.87.1`),请不要据此认为其他 DSH 版本受支持。
48
+ 稳定版 `0.6.0` 的安装范围是 `>=0.2.1-rc.5 <0.2.2-0`:之后的 DSH `0.2.1` 版本也能装上,但**没有经过验证**;上限写成 `<0.2.2-0` 是为了不放行 DSH `0.2.2` 的预发布版。本版本的验证基线只有 DSH `0.2.1-rc.5`(host Pi `1.5.0`,plugin Pi `1.5.0`)。
48
49
 
49
- 本版本开始适配 DSH `0.2.1` 的插件相关新能力:
50
+ `0.7.0-pre.1` 是预发布版,面向 DSH `0.2.2` 预发布系列(从 `0.2.2-alpha.3` 起)。它的安装范围**只有下限**(`>=0.2.2-alpha.3`),没有上限:更新的 DSH 版本也能装上,但**没有经过验证**。本次预发布的验证基线只有 DSH `0.2.2-alpha.3`(host Pi `1.5.0`,plugin Pi `1.5.0`),请不要据此认为其他 DSH 版本受支持。
51
+
52
+ `0.6.0` 和 `0.7.0-pre.1` 的主要变化(详见[更新日志](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/CHANGELOG.md)):
53
+
54
+ - **内置 Pi 跟随 DSH 升级到 `1.5.0`**:GPT-5.6 / GPT-6 系列模型的工具声明与 DSH 自己的发送方式一致(全部以 `additional_tools` 形式声明,不再发送顶层 `tools`),会话中途新增或删除工具、重启、分叉和压缩之后也保持一致。
55
+ - **切换推理强度不再让缓存失效**:在 `openai` 的 GPT-6 系列模型上,会话中途切换推理强度会保留已缓存的前缀,与 DSH 自己的处理一致。
56
+ - **自动审查修复**:GPT 路由上 DSH 自动审查(auto-review)的请求现在会带上它自己的系统提示词,不再以 `AUTO_REVIEW_FAILED` 失败。
57
+ - **仅 `0.7.0-pre.1`**:适配 DSH `0.2.2` 的插件接口;LCX 发出的 GPT 请求也会应用其他插件通过 `llm-pi-ai/request-headers` 提供的请求头,但这些插件不能替换凭据、会话亲和和请求关联相关的请求头。
58
+
59
+ 从 `0.6.0-pre` 系列开始适配的 DSH `0.2.1` 插件新能力(`0.6.0` 和 `0.7.0-pre.1` 都包含):
50
60
 
51
61
  - **增量工具更新(只增不改)**:在 DSH 声明支持该模式的 GPT Responses 路由上,会话中途新增工具(例如打开联网搜索、启用 MCP 或技能)时,请求里的工具列表保持不变,新增的工具以历史项的形式声明,因此不再改变已缓存的前缀。设置卡片里有“增量工具更新”开关,默认开启,关闭后每次请求都发送完整的当前工具列表。删除工具或同名重定义仍会让缓存失效一次。Grok、自定义命名路由、分叉与路由迁移的回放、压缩检查点仍然发送完整工具列表。
52
62
  - **程序化工具调用里的搜索**:在 `run_code` 程序里调用 `web_search` / `websearch_gpt_advanced` 时,搜索用量和返回的图片也会计入并显示。
53
63
  - **插件管理页卡片**:LCX 在插件管理页显示自己的名称(LCX Codex)、简介和图标。
54
64
 
55
- > 注意:稳定版 `0.5.x` 的安装范围写作 `>=0.2.0-rc.2 <0.2.1`,按 DSH 的版本范围规则,`0.2.1` 的预发布版(如 `0.2.1-alpha.2`)也可能被放行安装,但这些版本**不在** `0.5.x` 的支持和验证范围内;DSH `0.2.1-alpha.2` 及以后请使用 `@prelatest`。
65
+ > 注意:旧稳定版 `0.5.x` 的安装范围写作 `>=0.2.0-rc.2 <0.2.1`,按 DSH 的版本范围规则,`0.2.1` 的预发布版(如 `0.2.1-rc.5`)也可能被放行安装,但这些版本**不在** `0.5.x` 的支持和验证范围内;DSH `0.2.1-rc.5` 及以后的 `0.2.1` 版本请使用 `@latest`(`0.6.0`),DSH `0.2.2-alpha.3` 及以后请使用 `@prelatest`。
56
66
 
57
67
  ### 2. 安装并启动
58
68
 
59
- DSH `0.2.1-alpha.2` 及以后(预发布版):
69
+ DSH `0.2.2-alpha.3` 及以后(预发布版):
60
70
 
61
71
  ```sh
62
72
  dsh plugin --profile web add dsh-lcx-codex@prelatest
63
73
  dsh web
64
74
  ```
65
75
 
66
- DSH `0.2.0` 系列(稳定版):
76
+ DSH `0.2.1` 系列(`0.2.1-rc.5` 及以后,稳定版;更早的 `0.2.1` 构建请先把 DSH 升级到 `0.2.1-rc.5`):
67
77
 
68
78
  ```sh
69
79
  dsh plugin --profile web add dsh-lcx-codex@latest
70
80
  dsh web
71
81
  ```
72
82
 
83
+ DSH `0.2.0` 系列(注意固定版本号,不要用 `@latest`):
84
+
85
+ ```sh
86
+ dsh plugin --profile web add dsh-lcx-codex@0.5.2
87
+ dsh web
88
+ ```
89
+
73
90
  DSH `0.1.6` 系列:
74
91
 
75
92
  ```sh
@@ -90,7 +107,7 @@ dsh web
90
107
 
91
108
  打开 DSH Web 的插件页面,在 LCX 的配置卡片 **Responses / Codex 能力** 中按需打开下列开关,然后点击 **保存**。
92
109
 
93
- <img src="https://raw.githubusercontent.com/kk3ya03-star/dsh-lcx-codex/main/assets/settings-card.png" alt="LCX 插件配置卡片" width="720" />
110
+ <img src="https://raw.githubusercontent.com/kk3ya03-star/dsh-lcx-codex/stable/0.6.x/assets/settings-card.png" alt="LCX 插件配置卡片" width="720" />
94
111
 
95
112
  **GPT**
96
113
 
@@ -131,11 +148,12 @@ dsh web
131
148
 
132
149
  ## 从旧版本升级
133
150
 
134
- - **DSH 升级到 `0.2.1-alpha.2` 或更新版本**:把插件换成 `@prelatest`(`0.6.0-pre.1`),稳定版 `0.5.x` 没有在这些 DSH 版本上验证。
135
- - **DSH 升级到 `0.2.0` 系列**:把插件换成 `@latest`(`0.5.1`),旧版 `0.4.x` 不支持 DSH `0.2`。
151
+ - **DSH 升级到 `0.2.2-alpha.3` 或更新版本(DSH `0.2.2` 预发布系列)**:把插件换成 `@prelatest`(`0.7.0-pre.1`),`0.6.x` 没有在这些 DSH 版本上验证。
152
+ - **DSH 升级到 `0.2.1-rc.5`(DSH `latest` 通道)**:把插件换成 `@latest`(`0.6.0`);已装 `0.6.0-pre.2` 的用户也用这条命令换到稳定版。
153
+ - **DSH `0.2.0` 系列**:继续使用 `@0.5.2`;`@latest` 现在指向支持 DSH `0.2.1` 的 `0.6.0`,旧版 `0.4.x` 不支持 DSH `0.2`。
136
154
  - **DSH `0.1.6` 系列**:继续使用 `@0.4.4-pre.1`。
137
- - **DSH `0.1.5` 系列**:继续使用 `@0.4.3`;`@latest` 现在指向支持 DSH `0.2` 的 `0.5.1`。
138
- - **已装了 `0.5.0-pre.1`**:DSH `0.2.0` 系列重新运行 `@latest` 的 `add` 命令即可升到稳定版(`0.5.0-pre.1` 与 `0.5.0` 运行时代码一致);DSH `0.2.1-alpha.2` 及以后用 `@prelatest`。
155
+ - **DSH `0.1.5` 系列**:继续使用 `@0.4.3`;`@latest` 现在指向支持 DSH `0.2.1` 的 `0.6.0`。
156
+ - **已装了 `0.5.0`、`0.5.1` 或 `0.5.0-pre.1`**:DSH `0.2.0` 系列运行 `@0.5.2` 的 `add` 命令即可升到 `0.5.2`(只包含缺陷修复,安装范围不变)。
139
157
  - **升级后建议新建会话**:旧版本保存的压缩状态不保证兼容。DSH `0.2` 迁移过的旧长会话如果带有旧版 LCX 压缩检查点,LCX 会提示 `LCX_CHECKPOINT_UNSUPPORTED`,新建会话即可;其他模型不受影响。
140
158
 
141
159
  ## 停用与卸载
@@ -150,13 +168,14 @@ dsh web
150
168
  ## 已知限制
151
169
 
152
170
  - **网关能力因人而异**:搜索、压缩、Alpha 都依赖对应的服务端能力,不同网关支持程度不同。
153
- - **Grok**:支持 API Key / API 网关路由,不支持 xAI OAuth / SuperGrok 登录。原生 X Search 目前只在 `grok-4.6` 上验证过。
171
+ - **Grok**:支持 API Key / API 网关路由,不支持 xAI OAuth / SuperGrok 登录。本次发布的真实运行验证了 `grok-4.6` 的原生 Web Search;原生 X Search 没有在本次发布的真实运行中单独重新验证(上一次单独验证是 `0.4.4-pre.1` 在 `grok-4.6` 上)。`grok-4.7` 在本次发布的测试网关上没有可用渠道,原生搜索没有在它上面验证。
172
+ - **Grok 的 `maxTokens` 设置(DSH `0.2.2`)**:如果 provider 配置里 Grok 模型的 `maxTokens` 等于 `contextWindow`,DSH `0.2.2` 不允许在会话中从其他模型切换到这个 Grok 模型(这是 DSH 的行为,DSH `0.2.1` 只给出警告)。请把 `maxTokens` 设得明显小于 `contextWindow`,为输入上下文和 DSH 的压缩预留留出空间;只是比 `contextWindow` 小一点,并不能保证可以切换过去。
154
173
  - **Grok 长对话压力**:xAI 的智能体调用会把多次内部请求的用量累加计费。LCX 在服务端返回完整的实时上下文数据时,用它来判断何时压缩,缺失时退回估算;计费数字本身保持不变。
155
174
  - **Alpha 仍是实验功能**:连续打开/查找页面在已测试的 OAuth 类上游上可用;API Key 类上游账号不在支持范围内。目标页面抓取失败时会提示 `LCX_ALPHA_PAGE_FETCH_FAILED`,模型可以换一个结果继续。
156
175
  - **Markdown 图片换行**:为避免 DSH `0.2` 中图片后的文字挤到图片右侧,LCX 会让回答里的 Markdown 图片单独占一行,这一点与“搜索媒体预览”开关无关;句中的小图也会因此换行。
157
176
  - **DSH `0.1.5` + LCX `0.4.3`**:在插件设置中启用或停用 LCX 后,已打开的浏览器页面可能需要刷新。
158
- - **DSH `0.2.1` 的工具更新**:增量工具更新只在 DSH 声明“只增不改”的 GPT Responses 路由上生效;当 DSH 的工具历史或模型信息缺失、路由不支持或设置卡片里关闭了开关时,LCX 回到每次发送完整工具列表。删除工具或同名重定义仍会让缓存失效一次。缓存命中受上游影响有波动:在 `openai/gpt-6-sol` 上用同一操作序列对比,开启时新增工具后的首个请求约 80% 命中缓存,关闭时为 0%。LCX 自带的模型目录冻结在 Pi `0.86`,目录里没有的新模型(如 `gpt-6-sol`)按 DSH 的声明处理。
159
- - **验证范围**:`0.6.0-pre.1` 的验证基线只有 DSH `0.2.1-alpha.2`(预发布,host Pi `1.1.0`),安装范围没有上限,更新的 DSH 版本未经验证;该基线上的真实运行验证覆盖 GPT 路由、搜索、压缩、增量工具更新、`run_code` 内的搜索和插件管理页卡片等主要场景;其中 `run_code` 的实机检查在隔离环境里使用了完全访问的权限模式(DSH 的 Windows 文件沙箱在该机器上无法启动 `run_code`),程序只做了搜索调用。Grok 原生搜索和用户图片输入只做了有限的回归检查,Alpha 搜索和自然触发的压缩压力档位没有在这一轮覆盖。稳定版 `0.5.1` 的发布基线为 DSH `0.2.0-rc.2`(`0.5.0` 同);`0.4.4-pre.1` 在 DSH `0.1.6-alpha.2` 上完整验证;`0.4.3` 的稳定发布基线是 DSH `0.1.5-rc.1`,并已另外验证 DSH `0.1.5-rc.2`。同一安装范围内其他后续版本仍需单独评估,遇到问题欢迎反馈。
177
+ - **DSH `0.2.1` 的工具更新**:增量工具更新只在 DSH 声明“只增不改”的 GPT Responses 路由上生效;当 DSH 的工具历史或模型信息缺失、路由不支持或设置卡片里关闭了开关时,LCX 回到每次发送完整工具列表。删除工具或同名重定义仍会让缓存失效一次。缓存命中受上游影响有波动:在 `openai/gpt-6-sol` 上用同一操作序列对比,开启时新增工具后的首个请求约 80% 命中缓存,关闭时为 0%。LCX 内置与 DSH 相同的 Pi `1.5.0` 模型目录,目录里没有的更新模型按 DSH 的声明处理。GPT-5.6 / GPT-6 系列模型的工具全部以 `additional_tools` 形式声明(与 DSH 一致),网关需要支持这种请求格式。
178
+ - **验证范围**:`0.6.0` 的验证基线只有 DSH `0.2.1-rc.5`,`0.7.0-pre.1` 的验证基线只有 DSH `0.2.2-alpha.3`(两者都是 host / plugin Pi `1.5.0`);各自安装范围内更新的 DSH 版本未经验证。两个基线上的真实运行验证覆盖 GPT 路由(`gpt-6-sol`、`gpt-6.1-sol`)、联网搜索(含高级搜索和 `run_code` 内的搜索)、手动压缩和自然触发的压缩压力档位、重启恢复、分叉与路由迁移、推理强度切换、自动审查、搜索媒体预览、插件管理页卡片和 `grok-4.6` 原生 Web Search。以下情况没有单独的完整实机验证:`gpt-5.6-sol` 的首轮对话、`gpt-5.4` / `gpt-5.5` 这类不带推理档的模型、`gpt-6-sol` 上的推理强度切换(切换验证在 `gpt-6.1-sol` 上进行)、从 GPT 切换到非 GPT 模型时的压缩、需要生成摘要的 GPT 到 GPT 模型切换、在当前 Grok 配置下从 GPT 切换到 Grok 的实际对话,以及 Alpha 搜索。旧版本:`0.6.0-pre.2` 的验证基线为 DSH `0.2.1-alpha.2`;稳定版 `0.5.2` 的发布基线为 DSH `0.2.0-rc.2`(`0.5.0` 同);`0.4.4-pre.1` 在 DSH `0.1.6-alpha.2` 上完整验证;`0.4.3` 的稳定发布基线是 DSH `0.1.5-rc.1`,并已另外验证 DSH `0.1.5-rc.2`。同一安装范围内其他后续版本仍需单独评估,遇到问题欢迎反馈。
160
179
 
161
180
  ## 常见问题
162
181
 
@@ -170,10 +189,10 @@ dsh web
170
189
  通常是 DSH 版本和插件版本不匹配,按[上面的表格](#1-按-dsh-版本选择插件版本)重新选择。
171
190
 
172
191
  **升级到 DSH 0.2 后插件“导入失败”(failed to import)?**
173
- 从较早版本一路升级上来的配置目录里可能残留旧的依赖包。先停止 `dsh web`,把 DSH 主目录(默认 `~/.dsh`,或 `DSH_HOME` 指定的目录)下 `profiles/web/` 里的 `node_modules` 和 `pnpm-lock.yaml` 移走或删除,再重新运行对应的 `dsh plugin --profile web add dsh-lcx-codex@latest`(DSH `0.2.1-alpha.2` 及以后用 `@prelatest`),然后启动 `dsh web`。
192
+ 从较早版本一路升级上来的配置目录里可能残留旧的依赖包。先停止 `dsh web`,把 DSH 主目录(默认 `~/.dsh`,或 `DSH_HOME` 指定的目录)下 `profiles/web/` 里的 `node_modules` 和 `pnpm-lock.yaml` 移走或删除,再按[上面的表格](#1-按-dsh-版本选择插件版本)重新运行对应的 `dsh plugin --profile web add` 命令,然后启动 `dsh web`。
174
193
 
175
194
  **刚发布新版时 `@latest` / `@prelatest` 装到了旧版本?**
176
- 包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.6.0-pre.1` 或 `dsh-lcx-codex@0.5.1`。
195
+ 包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.6.0` 或 `dsh-lcx-codex@0.7.0-pre.1`。
177
196
 
178
197
  ## 反馈问题
179
198
 
@@ -183,11 +202,11 @@ dsh web
183
202
 
184
203
  ## 更多
185
204
 
186
- - [更新日志](CHANGELOG.md)
187
- - [架构说明](ARCHITECTURE.md)
188
- - [第三方许可](THIRD_PARTY_NOTICES.md)
189
- - [参与贡献](CONTRIBUTING.md)
205
+ - [更新日志](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/CHANGELOG.md)
206
+ - [架构说明](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/ARCHITECTURE.md)
207
+ - [第三方许可](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/THIRD_PARTY_NOTICES.md)
208
+ - [参与贡献](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/CONTRIBUTING.md)
190
209
 
191
210
  ## 许可证
192
211
 
193
- [MIT](LICENSE)。独立社区插件,与 OpenAI、xAI、DeepSeek、Sub2API、NewAPI 无隶属关系,也未获得其官方背书。
212
+ [MIT](https://github.com/kk3ya03-star/dsh-lcx-codex/blob/stable/0.6.x/LICENSE)。独立社区插件,与 OpenAI、xAI、DeepSeek、Sub2API、NewAPI 无隶属关系,也未获得其官方背书。
@@ -2,9 +2,9 @@
2
2
 
3
3
  `lib/pi-responses-runtime.js` is generated from public exports of the packages below. The build recipe in `scripts/build-pi-runtime.mjs` verifies that no other third-party package contributes output bytes.
4
4
 
5
- ## @earendil-works/pi-ai 0.85.1
5
+ ## @earendil-works/pi-ai 1.5.0
6
6
 
7
- Upstream source: https://github.com/earendil-works/pi/tree/v0.85.1/packages/ai
7
+ Upstream source: https://github.com/earendil-works/pi/tree/v1.5.0/packages/ai
8
8
 
9
9
  Included public Responses helpers and model catalogs:
10
10
 
@@ -12,6 +12,7 @@ Included public Responses helpers and model catalogs:
12
12
  - `api/constrained-sampling`
13
13
  - `api/openai-prompt-cache`
14
14
  - `utils/event-stream`
15
+ - `utils/transcript`
15
16
  - model helpers from the package root
16
17
  - Responses-bearing catalogs for `cloudflare-ai-gateway`, `github-copilot`, `openai`, `opencode`, `opencode-go`, and `xai`
17
18
 
@@ -1,4 +1,15 @@
1
- // @ts-check
1
+ /**
2
+ * DSH cancels with plain-object `AgentCancelCause` values — `{ kind: "user" }`,
3
+ * `{ kind: "parent" }`, `{ kind: "disposed" }`, `{ kind: "hook", reason }` — and exposes
4
+ * that same object as the runtime `AbortSignal.reason`. Propagating it raw reaches DSH's
5
+ * `errorMessage()`, which falls back to `String(value)`, so a cancelled in-flight call
6
+ * persists `Error: [object Object]` as model-facing tool-result text.
7
+ *
8
+ * Every LCX transport/stream abort site normalizes through here instead. An `Error`
9
+ * reason is preserved exactly — including `TimeoutError`, which failure classification
10
+ * still reads off the signal — and any other reason becomes a stable `AbortError` that
11
+ * keeps the original value as diagnostic `cause`. DSH's cancel cause is never mutated.
12
+ */
2
13
  const ABORT_MESSAGE = "The operation was aborted";
3
14
  function abortInstance() {
4
15
  if (typeof DOMException === "function")
package/lib/client.js CHANGED
@@ -406,7 +406,7 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
406
406
  if (!ElementClass || !row || !row.dataset.chatTurn) return null;
407
407
  const group = row.closest("[data-chat-group-key][data-step-process]");
408
408
  const siblings = group?.parentElement;
409
- const column = siblings?.dataset.slot === CHAT_FLOW_SLOT ? siblings.parentElement : siblings;
409
+ const column = siblings?.dataset.slot === CHAT_FLOW_SLOT ? siblings.parentElement : null;
410
410
  if (!group || !(siblings instanceof ElementClass) || !(column instanceof ElementClass) || !column.hasAttribute("data-chat-flow") || group.dataset.chatTurn !== row.dataset.chatTurn) return null;
411
411
  let answer = null;
412
412
  for (const child of siblings.children) {
@@ -833,7 +833,19 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
833
833
  // src/client/nested-calls.ts
834
834
  function createCallTurns(limit = 4096) {
835
835
  const turns = /* @__PURE__ */ new Map();
836
+ let lastSeq = -Infinity;
836
837
  return {
838
+ observe(seq) {
839
+ if (typeof seq !== "number" || !Number.isFinite(seq)) return;
840
+ if (seq < lastSeq) turns.clear();
841
+ lastSeq = seq;
842
+ },
843
+ openTurn(turn) {
844
+ for (const [callId, remembered] of turns) if (remembered !== turn) turns.delete(callId);
845
+ },
846
+ closeTurn(turn) {
847
+ for (const [callId, remembered] of turns) if (remembered === turn) turns.delete(callId);
848
+ },
837
849
  remember(callId, turn) {
838
850
  if (typeof callId !== "string" || !Number.isSafeInteger(turn)) return;
839
851
  turns.delete(callId);
@@ -842,42 +854,51 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
842
854
  },
843
855
  turnOf(callId) {
844
856
  return typeof callId === "string" ? turns.get(callId) : void 0;
857
+ },
858
+ clear() {
859
+ turns.clear();
860
+ lastSeq = -Infinity;
845
861
  }
846
862
  };
847
863
  }
848
864
 
849
865
  // src/client/search-usage-ui.ts
850
- var callTurns = createCallTurns();
851
- var searchUsageDefinition = {
852
- kind: "lcx-search-usage",
853
- match(event) {
854
- if (event.type === "turn/start") return { id: String(event.data.turn), role: "start" };
855
- if (event.type === "tool/call") callTurns.remember(event.data.callId, event.data.turn);
856
- if (event.type === "turn/end" || event.type === "tool/result" || event.type === "tool/call") return { id: String(event.data.turn), role: "update" };
857
- if (event.type === NESTED_SETTLE_EVENT) {
858
- const turn = callTurns.turnOf(event.data.rootCallId);
859
- return turn === void 0 ? null : { id: String(turn), role: "update" };
866
+ function createSearchUsageDefinition(callTurns = createCallTurns()) {
867
+ return {
868
+ kind: "lcx-search-usage",
869
+ match(event) {
870
+ if (event.type !== "assistant/live-chunk") callTurns.observe(event.seq);
871
+ if (event.type === "turn/start") callTurns.openTurn(event.data.turn);
872
+ if (event.type === "turn/end") callTurns.closeTurn(event.data.turn);
873
+ if (event.type === "turn/start") return { id: String(event.data.turn), role: "start" };
874
+ if (event.type === "tool/call") callTurns.remember(event.data.callId, event.data.turn);
875
+ if (event.type === "turn/end" || event.type === "tool/result" || event.type === "tool/call") return { id: String(event.data.turn), role: "update" };
876
+ if (event.type === NESTED_SETTLE_EVENT) {
877
+ const turn = callTurns.turnOf(event.data.rootCallId);
878
+ return turn === void 0 ? null : { id: String(turn), role: "update" };
879
+ }
880
+ return null;
881
+ },
882
+ start(_context, match) {
883
+ if (match.event.type !== "turn/start") throw new Error("LCX billing requires a complete turn");
884
+ return { turn: match.event.data.turn, records: [], pending: {}, complete: false };
885
+ },
886
+ update(context, match) {
887
+ const event = match.event, state = context.state, pending = { ...state.pending };
888
+ if (event.type === "tool/call" && isSearchTool(event.data.name)) pending[event.data.callId] = event.data.name;
889
+ const callId = event.type === "tool/result" ? event.data.message.source.callId : void 0;
890
+ const extra = auxiliaryUsageOf(event, callId ? pending[callId] : void 0);
891
+ if (callId) delete pending[callId];
892
+ return { ...state, pending, records: [...state.records, ...extra], complete: event.type === "turn/end" };
893
+ },
894
+ publication: (match) => match.event.type === "turn/end" ? "immediate" : "none",
895
+ buildLocationData(context, scope) {
896
+ const s = context.state;
897
+ return scope === "turn" && s?.complete ? { kind: "turn", turn: s.turn, key: "lcx-search-usage", value: s.records } : null;
860
898
  }
861
- return null;
862
- },
863
- start(_context, match) {
864
- if (match.event.type !== "turn/start") throw new Error("LCX billing requires a complete turn");
865
- return { turn: match.event.data.turn, records: [], pending: {}, complete: false };
866
- },
867
- update(context, match) {
868
- const event = match.event, state = context.state, pending = { ...state.pending };
869
- if (event.type === "tool/call" && isSearchTool(event.data.name)) pending[event.data.callId] = event.data.name;
870
- const callId = event.type === "tool/result" ? event.data.message.source.callId : void 0;
871
- const extra = auxiliaryUsageOf(event, callId ? pending[callId] : void 0);
872
- if (callId) delete pending[callId];
873
- return { ...state, pending, records: [...state.records, ...extra], complete: event.type === "turn/end" };
874
- },
875
- publication: (match) => match.event.type === "turn/end" ? "immediate" : "none",
876
- buildLocationData(context, scope) {
877
- const s = context.state;
878
- return scope === "turn" && s?.complete ? { kind: "turn", turn: s.turn, key: "lcx-search-usage", value: s.records } : null;
879
- }
880
- };
899
+ };
900
+ }
901
+ var searchUsageDefinition = createSearchUsageDefinition();
881
902
  function tokenCount(value) {
882
903
  return String(value);
883
904
  }
@@ -1084,19 +1105,22 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
1084
1105
  };
1085
1106
  }
1086
1107
  const hostedMediaTool = (value) => value === "web_search" || value === "websearch_gpt_advanced";
1087
- const callTurns2 = createCallTurns();
1108
+ const callTurns = createCallTurns();
1088
1109
  const searchMediaDefinition = {
1089
1110
  kind: SEARCH_MEDIA_KIND,
1090
1111
  target: "chat",
1091
1112
  match(event) {
1113
+ if (event.type !== "assistant/live-chunk") callTurns.observe(event.seq);
1114
+ if (event.type === "turn/start") callTurns.openTurn(event.data.turn);
1115
+ if (event.type === "turn/end") callTurns.closeTurn(event.data.turn);
1092
1116
  if (event.type === "turn/start")
1093
1117
  return { id: String(event.data.turn), role: "start" };
1094
1118
  if (event.type === "tool/call")
1095
- callTurns2.remember(event.data.callId, event.data.turn);
1119
+ callTurns.remember(event.data.callId, event.data.turn);
1096
1120
  if (event.type === "tool/result" || event.type === "tool/call")
1097
1121
  return { id: String(event.data.turn), role: "update" };
1098
1122
  if (event.type === NESTED_SETTLE_EVENT) {
1099
- const turn = callTurns2.turnOf(event.data.rootCallId);
1123
+ const turn = callTurns.turnOf(event.data.rootCallId);
1100
1124
  return turn === void 0 ? null : { id: String(turn), role: "update" };
1101
1125
  }
1102
1126
  if (event.type !== "assistant/message" || event.surfaceOp !== "append" || event.data.interrupted === true)
@@ -1505,15 +1529,25 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
1505
1529
  function apply(ctx) {
1506
1530
  const slots = ctx.slots ?? ctx.get("slots"), svc = ctx.configForms ?? ctx.get("configForms"), locale = ctx.locale ?? ctx.get("locale"), uiConversation = ctx.uiConversation ?? ctx.get("uiConversation");
1507
1531
  if (!slots || !svc || !locale || !uiConversation) return;
1508
- ctx.effect(() => uiConversation.events.register(searchUsageDefinition), "lcx search billing data");
1532
+ ctx.effect(() => {
1533
+ const usageTurns = createCallTurns();
1534
+ const unregister = uiConversation.events.register(createSearchUsageDefinition(usageTurns));
1535
+ return () => {
1536
+ if (typeof unregister === "function") unregister();
1537
+ usageTurns.clear();
1538
+ };
1539
+ }, "lcx search billing data");
1509
1540
  ctx.effect(() => installUsageSlots(slots, React.createElement), "lcx search billing slots");
1510
1541
  ctx.effect(mountCss, "lcx-codex styles");
1511
1542
  for (const language of ["zh", "en"])
1512
1543
  ctx.effect(() => locale.register(NAMESPACE, language, copy[language]), `lcx-codex ${language} dictionary`);
1513
- ctx.effect(
1514
- () => uiConversation.events.register(searchMediaDefinition),
1515
- "lcx-codex search media definition"
1516
- );
1544
+ ctx.effect(() => {
1545
+ const unregister = uiConversation.events.register(searchMediaDefinition);
1546
+ return () => {
1547
+ if (typeof unregister === "function") unregister();
1548
+ callTurns.clear();
1549
+ };
1550
+ }, "lcx-codex search media definition");
1517
1551
  const installSlot = (name, label, register) => ctx.effect(() => {
1518
1552
  const cleanup = slots.inject(name, register);
1519
1553
  return () => {
package/lib/compact-v2.js CHANGED
@@ -1,33 +1,15 @@
1
1
  import { consumeSse, fetchSseWithRetry } from "./transport.js";
2
2
  import { buildCompactionResponsesBody, responsesGenerationEnvelope as standardGenerationEnvelope, } from "./responses-request.js";
3
+ import { isRecord, codedError } from "./util.js";
3
4
  export const REMOTE_COMPACTION_V2_FEATURE = "remote_compaction_v2";
4
- /**
5
- * @param {unknown} value
6
- * @returns {value is UnknownRecord}
7
- */
8
- function isObject(value) {
9
- return value !== null && typeof value === "object" && !Array.isArray(value);
10
- }
11
- /**
12
- * @param {string} message
13
- * @param {string} [code]
14
- * @returns {LcxError}
15
- */
16
5
  function fail(message, code = "LCX_COMPACT_INVALID_RESPONSE") {
17
- const e = new Error(message);
18
- e.code = code;
19
- return e;
6
+ return codedError(message, code);
20
7
  }
21
- /** @param {unknown} value */
22
8
  function safeMachineField(value) {
23
9
  if (typeof value !== "string" || value.length === 0 || value.length > 96)
24
10
  return undefined;
25
11
  return /^[A-Za-z0-9_.:\[\]-]+$/u.test(value) ? value : undefined;
26
12
  }
27
- /**
28
- * @param {HeaderMap} [headers]
29
- * @returns {HeaderMap}
30
- */
31
13
  export function mergeFeatureHeader(headers = {}) {
32
14
  const result = { ...headers };
33
15
  const key = Object.keys(result).find((name) => name.toLowerCase() === "x-codex-beta-features");
@@ -40,10 +22,6 @@ export function mergeFeatureHeader(headers = {}) {
40
22
  result[key ?? "x-codex-beta-features"] = values.join(",");
41
23
  return result;
42
24
  }
43
- /**
44
- * @param {GenerationControls} [controls]
45
- * @returns {GenerationEnvelope}
46
- */
47
25
  export function responsesGenerationEnvelope(controls = {}) {
48
26
  return standardGenerationEnvelope({
49
27
  model: "unknown",
@@ -52,10 +30,6 @@ export function responsesGenerationEnvelope(controls = {}) {
52
30
  maxTokens: controls.maxTokens,
53
31
  });
54
32
  }
55
- /**
56
- * @param {NativeCompactionBodyOptions} options
57
- * @returns {NativeCompactionBody}
58
- */
59
33
  export function buildNativeCompactionBody({ model, modelDescriptor, input, tools, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, }) {
60
34
  return buildCompactionResponsesBody({
61
35
  model: modelDescriptor ?? model,
@@ -72,16 +46,14 @@ export function buildNativeCompactionBody({ model, modelDescriptor, input, tools
72
46
  }
73
47
  /**
74
48
  * Provider usage stays unknown until the object guard and numeric normalization.
75
- * @param {unknown} raw
76
- * @returns {CanonicalUsage | undefined}
77
49
  */
78
50
  function usageFrom(raw) {
79
- if (!isObject(raw))
51
+ if (!isRecord(raw))
80
52
  return undefined;
81
53
  const inputTotal = Number(raw.input_tokens ?? 0);
82
54
  const output = Number(raw.output_tokens ?? 0);
83
55
  const detailsValue = raw.input_tokens_details ?? raw.input_token_details ?? raw.prompt_tokens_details;
84
- const details = isObject(detailsValue) ? detailsValue : {};
56
+ const details = isRecord(detailsValue) ? detailsValue : {};
85
57
  const cacheRead = Number(details.cached_tokens ?? 0);
86
58
  const cacheWrite = Number(details.cache_write_tokens ?? 0);
87
59
  const result = {
@@ -96,9 +68,9 @@ function usageFrom(raw) {
96
68
  result.cacheReadTokens = cacheRead;
97
69
  if (Number.isFinite(cacheWrite) && cacheWrite > 0)
98
70
  result.cacheWriteTokens = cacheWrite;
99
- const outputDetails = isObject(raw.output_tokens_details)
71
+ const outputDetails = isRecord(raw.output_tokens_details)
100
72
  ? raw.output_tokens_details
101
- : isObject(raw.output_token_details)
73
+ : isRecord(raw.output_token_details)
102
74
  ? raw.output_token_details
103
75
  : {};
104
76
  const reasoning = Number(outputDetails.reasoning_tokens ?? 0);
@@ -106,26 +78,20 @@ function usageFrom(raw) {
106
78
  result.reasoningTokens = reasoning;
107
79
  return Object.values(result).some((v) => Number(v) > 0) ? result : undefined;
108
80
  }
109
- /**
110
- * @param {unknown} output
111
- * @returns {{ output: ValidatedOutputItem[], compaction: CompactionItem }}
112
- */
113
81
  function validateOutput(output) {
114
82
  if (!Array.isArray(output) || output.length === 0)
115
83
  throw fail("native compaction output is empty");
116
- const compactions = output.filter((item) => isObject(item) && item.type === "compaction");
84
+ const compactions = output.filter((item) => isRecord(item) && item.type === "compaction");
117
85
  if (compactions.length !== 1)
118
86
  throw fail(`native compaction must return exactly one compaction item, got ${compactions.length}`);
119
87
  const compact = compactions[0];
120
88
  if (typeof compact.encrypted_content !== "string" ||
121
89
  compact.encrypted_content.length === 0)
122
90
  throw fail("native compaction item has no encrypted_content");
123
- /** @type {Set<string>} */
124
91
  const calls = new Set();
125
- /** @type {Set<string>} */
126
92
  const results = new Set();
127
93
  for (const item of output) {
128
- if (!isObject(item) || typeof item.type !== "string")
94
+ if (!isRecord(item) || typeof item.type !== "string")
129
95
  throw fail("native compaction output contains a malformed item");
130
96
  if (item.type === "function_call") {
131
97
  if (typeof item.call_id !== "string" ||
@@ -155,16 +121,13 @@ function validateOutput(output) {
155
121
  }
156
122
  /**
157
123
  * Provider SSE events enter as unknown; response.completed remains authoritative.
158
- * @param {Response} response
159
- * @param {SseParseOptions} [options]
160
- * @returns {Promise<NativeCompactionResult>}
161
124
  */
162
125
  export async function parseNativeCompactionSse(response, options = {}) {
163
126
  const byIndex = new Map();
164
127
  const byId = new Map();
165
128
  let terminal;
166
129
  const mergeItem = (event) => {
167
- if (!isObject(event.item))
130
+ if (!isRecord(event.item))
168
131
  return;
169
132
  const index = Number.isInteger(event.output_index)
170
133
  ? Number(event.output_index)
@@ -189,17 +152,17 @@ export async function parseNativeCompactionSse(response, options = {}) {
189
152
  byId.set(id, record);
190
153
  };
191
154
  await consumeSse(response, (event) => {
192
- if (!isObject(event))
155
+ if (!isRecord(event))
193
156
  return;
194
157
  if (event.type === "error" ||
195
158
  event.type === "response.failed" ||
196
159
  event.type === "response.incomplete") {
197
160
  const upstreamValue = event.type === "response.failed"
198
- ? isObject(event.response)
161
+ ? isRecord(event.response)
199
162
  ? event.response.error
200
163
  : undefined
201
164
  : event.error;
202
- const upstream = isObject(upstreamValue) ? upstreamValue : {};
165
+ const upstream = isRecord(upstreamValue) ? upstreamValue : {};
203
166
  const providerCode = safeMachineField(upstream.code);
204
167
  const providerType = safeMachineField(upstream.type);
205
168
  const providerParam = safeMachineField(upstream.param);
@@ -211,8 +174,8 @@ export async function parseNativeCompactionSse(response, options = {}) {
211
174
  .filter(Boolean)
212
175
  .join(" ");
213
176
  const e = fail(`native compaction ended with ${event.type}${diagnostics ? ` ${diagnostics}` : ""}`, "LCX_COMPACT_UPSTREAM_ERROR");
214
- if (Number.isInteger(upstream.status ?? (isObject(event.error) ? event.error.status : undefined)))
215
- e.status = Number(upstream.status ?? (isObject(event.error) ? event.error.status : undefined));
177
+ if (Number.isInteger(upstream.status ?? (isRecord(event.error) ? event.error.status : undefined)))
178
+ e.status = Number(upstream.status ?? (isRecord(event.error) ? event.error.status : undefined));
216
179
  if (providerCode)
217
180
  e.providerCode = providerCode;
218
181
  if (providerType)
@@ -225,9 +188,9 @@ export async function parseNativeCompactionSse(response, options = {}) {
225
188
  event.type === "response.output_item.done")
226
189
  mergeItem(event);
227
190
  if (event.type === "response.completed")
228
- terminal = isObject(event.response) ? event.response : undefined;
191
+ terminal = isRecord(event.response) ? event.response : undefined;
229
192
  }, options);
230
- if (!isObject(terminal))
193
+ if (!isRecord(terminal))
231
194
  throw fail("native compaction stream ended without response.completed", "LCX_COMPACT_INCOMPLETE_SSE");
232
195
  if (terminal.status !== "completed")
233
196
  throw fail("native compaction response.completed did not carry completed status", "LCX_COMPACT_INCOMPLETE_SSE");
@@ -243,9 +206,6 @@ export async function parseNativeCompactionSse(response, options = {}) {
243
206
  usage: usageFrom(terminal.usage),
244
207
  };
245
208
  }
246
- /**
247
- * @param {NativeCompactionRequestOptions} options
248
- */
249
209
  export async function requestNativeCompaction({ baseURL, model, modelDescriptor, input, tools, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, idempotencyKey, headers, signal, timeoutMs, maxAttempts, maxResponseBytes, }) {
250
210
  const body = buildNativeCompactionBody({
251
211
  model,
@@ -0,0 +1,15 @@
1
+ export const DEFAULTS = Object.freeze({
2
+ requestTimeoutMs: 300_000,
3
+ streamIdleTimeoutMs: 300_000,
4
+ maxResponseBytes: 8 * 1024 * 1024,
5
+ maxAttempts: 3,
6
+ maxAttemptsCap: 6,
7
+ alphaMaxOutputTokens: 2500,
8
+ alphaMaxOutputTokensCap: 32_000,
9
+ webMaxResults: 8,
10
+ webSearchProvider: "lcx-responses",
11
+ portableReplayMaxChars: 80_000,
12
+ nativeRetentionTokenBudget: 64_000,
13
+ assistantRetentionTokenReserve: 24_000,
14
+ assistantRetentionPerMessageTokenCap: 3_000,
15
+ });