dsh-lcx-codex 0.5.2 → 0.6.0-pre.2
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 +16 -9
- package/THIRD_PARTY_NOTICES.md +3 -2
- package/icon.svg +1 -0
- package/lib/abort-error.js +12 -1
- package/lib/client.js +137 -39
- package/lib/compact-v2.js +16 -56
- package/lib/defaults.js +15 -0
- package/lib/dsh-compat.js +15 -76
- package/lib/dsh-responses.js +172 -71
- package/lib/grok-native-search.js +1 -3
- package/lib/index.js +228 -78
- package/lib/model-catalog.js +5 -7
- package/lib/native-checkpoint.js +57 -182
- package/lib/pi-responses-runtime.js +140 -50
- package/lib/provider-headers.js +31 -0
- package/lib/responses-request.js +4 -12
- package/lib/responses-stream.js +116 -218
- package/lib/route.js +169 -75
- package/lib/search-accounting.js +19 -21
- package/lib/token-budget.js +6 -41
- package/lib/tool-surface.js +106 -0
- package/lib/transport.js +89 -107
- package/lib/types/client/search-media.d.ts +0 -2
- package/lib/types/index.d.ts +4 -0
- package/lib/util.js +21 -0
- package/lib/web-run-output.js +0 -3
- package/lib/web-search-alpha.js +22 -27
- package/lib/web-search-capability.js +1 -3
- package/lib/web-search-hosted.js +2 -2
- package/lib/web-search-ref-store.js +1 -3
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +37 -32
- package/lib/pi086-responses-allowlist.js +0 -131
package/README.md
CHANGED
|
@@ -37,16 +37,22 @@ 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` 及以后 |
|
|
40
|
+
| `0.2.1-alpha.2` 及以后 | `0.6.0-pre.2`(预发布版) | `@prelatest` |
|
|
41
41
|
| `0.2.0` 系列(`0.2.0-rc.2`,早于 `0.2.1-alpha.2`) | `0.5.2`(稳定版) | `@latest` |
|
|
42
42
|
| `0.1.6` 系列(`0.1.6-alpha.2` 及以后) | `0.4.4-pre.1`(旧预发布版) | `@0.4.4-pre.1` |
|
|
43
43
|
| `0.1.5` 系列(`0.1.5-rc.1` 及以后) | `0.4.3`(稳定版) | `@0.4.3` |
|
|
44
44
|
|
|
45
|
-
请务必按表格选择:几个版本互不兼容,装错版本时安装命令可能只给出依赖警告,但插件可能无法正常工作。`@latest` 是稳定版 `0.5.2`(发布基线 DSH `0.2.0-rc.2`,host / plugin Pi `0.87.1
|
|
45
|
+
请务必按表格选择:几个版本互不兼容,装错版本时安装命令可能只给出依赖警告,但插件可能无法正常工作。`@latest` 是稳定版 `0.5.2`(发布基线 DSH `0.2.0-rc.2`,host / plugin Pi `0.87.1`),DSH `0.1.5` 用户请固定安装 `@0.4.3`。
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
`0.6.0-pre.2` 是预发布版,面向 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 `1.1.0`),请不要据此认为其他 DSH 版本受支持。
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
本版本开始适配 DSH `0.2.1` 的插件相关新能力:
|
|
50
|
+
|
|
51
|
+
- **增量工具更新(只增不改)**:在 DSH 声明支持该模式的 GPT Responses 路由上,会话中途新增工具(例如打开联网搜索、启用 MCP 或技能)时,请求里的工具列表保持不变,新增的工具以历史项的形式声明,因此不再改变已缓存的前缀。设置卡片里有“增量工具更新”开关,默认开启,关闭后每次请求都发送完整的当前工具列表。删除工具或同名重定义仍会让缓存失效一次。Grok、自定义命名路由、分叉与路由迁移的回放、压缩检查点仍然发送完整工具列表。
|
|
52
|
+
- **程序化工具调用里的搜索**:在 `run_code` 程序里调用 `web_search` / `websearch_gpt_advanced` 时,搜索用量和返回的图片也会计入并显示。
|
|
53
|
+
- **插件管理页卡片**:LCX 在插件管理页显示自己的名称(LCX Codex)、简介和图标。
|
|
54
|
+
|
|
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`。
|
|
50
56
|
|
|
51
57
|
### 2. 安装并启动
|
|
52
58
|
|
|
@@ -94,6 +100,7 @@ dsh web
|
|
|
94
100
|
| **使用 GPT Hosted Search 作为 DSH web_search 后端** | GPT 联网搜索 | 需要联网时打开 |
|
|
95
101
|
| **启用高级 Hosted 工具** | 图片搜索、限定网站、指定位置等(需先打开上一项) | 按需 |
|
|
96
102
|
| **启用 Alpha command** | 实验功能:让 GPT 继续打开、查找搜索结果中的页面 | 日常不需要 |
|
|
103
|
+
| **增量工具更新(addition-only)** | 会话中途新增工具时保持请求前缀不变以保护缓存,仅对 DSH 声明支持的 GPT 路由生效;关闭后每次请求都发送完整工具列表 | 默认开启,一般不用改 |
|
|
97
104
|
|
|
98
105
|
**Grok 原生搜索**(与“启用 LCX”相互独立)
|
|
99
106
|
|
|
@@ -124,11 +131,11 @@ dsh web
|
|
|
124
131
|
|
|
125
132
|
## 从旧版本升级
|
|
126
133
|
|
|
127
|
-
- **DSH 升级到 `0.2.1-alpha.2` 或更新版本**:把插件换成 `@prelatest`(`0.6.
|
|
134
|
+
- **DSH 升级到 `0.2.1-alpha.2` 或更新版本**:把插件换成 `@prelatest`(`0.6.0-pre.2`),稳定版 `0.5.x` 没有在这些 DSH 版本上验证。
|
|
128
135
|
- **DSH 升级到 `0.2.0` 系列**:把插件换成 `@latest`(`0.5.2`),旧版 `0.4.x` 不支持 DSH `0.2`。
|
|
129
136
|
- **DSH `0.1.6` 系列**:继续使用 `@0.4.4-pre.1`。
|
|
130
137
|
- **DSH `0.1.5` 系列**:继续使用 `@0.4.3`;`@latest` 现在指向支持 DSH `0.2` 的 `0.5.2`。
|
|
131
|
-
- **已装了 `0.5.0
|
|
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`。
|
|
132
139
|
- **升级后建议新建会话**:旧版本保存的压缩状态不保证兼容。DSH `0.2` 迁移过的旧长会话如果带有旧版 LCX 压缩检查点,LCX 会提示 `LCX_CHECKPOINT_UNSUPPORTED`,新建会话即可;其他模型不受影响。
|
|
133
140
|
|
|
134
141
|
## 停用与卸载
|
|
@@ -148,8 +155,8 @@ dsh web
|
|
|
148
155
|
- **Alpha 仍是实验功能**:连续打开/查找页面在已测试的 OAuth 类上游上可用;API Key 类上游账号不在支持范围内。目标页面抓取失败时会提示 `LCX_ALPHA_PAGE_FETCH_FAILED`,模型可以换一个结果继续。
|
|
149
156
|
- **Markdown 图片换行**:为避免 DSH `0.2` 中图片后的文字挤到图片右侧,LCX 会让回答里的 Markdown 图片单独占一行,这一点与“搜索媒体预览”开关无关;句中的小图也会因此换行。
|
|
150
157
|
- **DSH `0.1.5` + LCX `0.4.3`**:在插件设置中启用或停用 LCX 后,已打开的浏览器页面可能需要刷新。
|
|
151
|
-
- **DSH `0.2.1`
|
|
152
|
-
-
|
|
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.2` 的验证基线只有 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.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`。同一安装范围内其他后续版本仍需单独评估,遇到问题欢迎反馈。
|
|
153
160
|
|
|
154
161
|
## 常见问题
|
|
155
162
|
|
|
@@ -166,7 +173,7 @@ dsh web
|
|
|
166
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`。
|
|
167
174
|
|
|
168
175
|
**刚发布新版时 `@latest` / `@prelatest` 装到了旧版本?**
|
|
169
|
-
包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.5.2`。
|
|
176
|
+
包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.6.0-pre.2` 或 `dsh-lcx-codex@0.5.2`。
|
|
170
177
|
|
|
171
178
|
## 反馈问题
|
|
172
179
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -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
|
|
5
|
+
## @earendil-works/pi-ai 1.1.0
|
|
6
6
|
|
|
7
|
-
Upstream source: https://github.com/earendil-works/pi/tree/
|
|
7
|
+
Upstream source: https://github.com/earendil-works/pi/tree/v1.1.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
|
|
package/icon.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="36" height="36" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" stroke-width="1"><circle cx="6.9" cy="6.9" r="5.4" stroke="#658EFF"></circle><path d="M10.9 10.9L14.8 14.8" stroke="#658EFF" stroke-linecap="round"></path><path d="M6.9 3.9L7.8 6L9.9 6.9L7.8 7.8L6.9 9.9L6 7.8L3.9 6.9L6 6Z" stroke="#658EFF" stroke-linejoin="round"></path></svg>
|
package/lib/abort-error.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
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
|
@@ -398,16 +398,18 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
398
398
|
return { ...group[0], sources: group.map((value) => value.url) };
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
|
+
var CHAT_FLOW_SLOT = "conversation.chat.flow";
|
|
401
402
|
var activeDialogByDocument = /* @__PURE__ */ new WeakMap();
|
|
402
403
|
function inlineMediaAnswer(marker) {
|
|
403
404
|
const row = marker.closest('[data-chat-flow-kind="lcx-search-media"]');
|
|
404
405
|
const ElementClass = marker.ownerDocument.defaultView?.HTMLElement;
|
|
405
406
|
if (!ElementClass || !row || !row.dataset.chatTurn) return null;
|
|
406
407
|
const group = row.closest("[data-chat-group-key][data-step-process]");
|
|
407
|
-
const
|
|
408
|
-
|
|
408
|
+
const siblings = group?.parentElement;
|
|
409
|
+
const column = siblings?.dataset.slot === CHAT_FLOW_SLOT ? siblings.parentElement : null;
|
|
410
|
+
if (!group || !(siblings instanceof ElementClass) || !(column instanceof ElementClass) || !column.hasAttribute("data-chat-flow") || group.dataset.chatTurn !== row.dataset.chatTurn) return null;
|
|
409
411
|
let answer = null;
|
|
410
|
-
for (const child of
|
|
412
|
+
for (const child of siblings.children) {
|
|
411
413
|
if (child === group) break;
|
|
412
414
|
if (child instanceof ElementClass && child.dataset.chatFlowKind === "assistant-step" && child.dataset.chatGroupPart === "response" && child.dataset.chatTurn === row.dataset.chatTurn) {
|
|
413
415
|
answer = child;
|
|
@@ -806,10 +808,16 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
806
808
|
var object = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
807
809
|
var count = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
|
|
808
810
|
var isSearchTool = (name) => name === "web_search" || name === "websearch_gpt_advanced";
|
|
811
|
+
var NESTED_SETTLE_EVENT = "tool/ptc-dispatch";
|
|
812
|
+
function searchSettlementOf(event, pendingName) {
|
|
813
|
+
if (!object(event) || !object(event.data) || !object(event.data.meta)) return;
|
|
814
|
+
const name = event.type === NESTED_SETTLE_EVENT ? event.data.name : event.type === "tool/result" ? pendingName : void 0;
|
|
815
|
+
return isSearchTool(name) ? { name, meta: event.data.meta } : void 0;
|
|
816
|
+
}
|
|
809
817
|
function auxiliaryUsageOf(event, toolName) {
|
|
810
|
-
|
|
811
|
-
if (!
|
|
812
|
-
const raw =
|
|
818
|
+
const settled = searchSettlementOf(event, toolName);
|
|
819
|
+
if (!settled) return [];
|
|
820
|
+
const raw = settled.meta.auxiliaryUsage;
|
|
813
821
|
if (!Array.isArray(raw)) return [];
|
|
814
822
|
const ids = /* @__PURE__ */ new Set(), result = [];
|
|
815
823
|
for (const item of raw) {
|
|
@@ -822,32 +830,75 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
822
830
|
return result;
|
|
823
831
|
}
|
|
824
832
|
|
|
833
|
+
// src/client/nested-calls.ts
|
|
834
|
+
function createCallTurns(limit = 4096) {
|
|
835
|
+
const turns = /* @__PURE__ */ new Map();
|
|
836
|
+
let lastSeq = -Infinity;
|
|
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
|
+
},
|
|
849
|
+
remember(callId, turn) {
|
|
850
|
+
if (typeof callId !== "string" || !Number.isSafeInteger(turn)) return;
|
|
851
|
+
turns.delete(callId);
|
|
852
|
+
turns.set(callId, turn);
|
|
853
|
+
if (turns.size > limit) turns.delete(turns.keys().next().value);
|
|
854
|
+
},
|
|
855
|
+
turnOf(callId) {
|
|
856
|
+
return typeof callId === "string" ? turns.get(callId) : void 0;
|
|
857
|
+
},
|
|
858
|
+
clear() {
|
|
859
|
+
turns.clear();
|
|
860
|
+
lastSeq = -Infinity;
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
|
|
825
865
|
// src/client/search-usage-ui.ts
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
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;
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
var searchUsageDefinition = createSearchUsageDefinition();
|
|
851
902
|
function tokenCount(value) {
|
|
852
903
|
return String(value);
|
|
853
904
|
}
|
|
@@ -940,10 +991,11 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
940
991
|
"alphaSearch",
|
|
941
992
|
"grokNativeWebSearch",
|
|
942
993
|
"grokNativeXSearch",
|
|
943
|
-
"searchMediaPreview"
|
|
994
|
+
"searchMediaPreview",
|
|
995
|
+
"incrementalToolUpdates"
|
|
944
996
|
];
|
|
945
997
|
const DEFAULTS = Object.fromEntries(
|
|
946
|
-
FIELDS.map((field) => [field,
|
|
998
|
+
FIELDS.map((field) => [field, field === "incrementalToolUpdates"])
|
|
947
999
|
);
|
|
948
1000
|
const css = `.lcx-card{border:1px solid var(--dsw-alias-border-l2);border-radius:8px;list-style:none}.lcx-head{width:100%;display:flex;justify-content:space-between;padding:14px 16px;border:0;background:transparent;color:inherit}.lcx-body{border-top:1px solid var(--dsw-alias-border-l2);padding:12px 16px}.lcx-row{display:flex;gap:9px;padding:8px 0}.lcx-row small,.lcx-help{display:block;font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary)}.lcx-group{border-top:1px solid var(--dsw-alias-border-l2);margin-top:10px;padding-top:14px}.lcx-group strong{font-size:14px}.lcx-foot{display:flex;justify-content:flex-end;gap:8px;margin-top:10px}.lcx-foot button{padding:6px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:inherit}.lcx-search-usage{display:inline-flex;align-items:center;gap:4px;margin:2px 0;color:var(--dsw-alias-label-tertiary);font:12px/18px system-ui}.lcx-search-usage-session{padding:0 4px}.lcx-search-usage-turn{padding:0 6px}` + inlineMediaCss + nativeMarkdownImageCss;
|
|
949
1001
|
function mountCss() {
|
|
@@ -971,6 +1023,8 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
971
1023
|
advancedHelp: "\u53EA\u5728\u9700\u8981\u57DF\u540D\u8FC7\u6EE4\u3001\u4F4D\u7F6E\u3001search context\u3001\u56FE\u7247\u7B49\u539F\u751F Hosted \u53C2\u6570\u65F6\u4F7F\u7528\uFF1B\u9ED8\u8BA4\u5173\u95ED\u4EE5\u4FDD\u6301\u5DE5\u5177 schema \u7A33\u5B9A\u3002",
|
|
972
1024
|
alpha: "\u542F\u7528 Alpha command\uFF08websearch_alpha\uFF09",
|
|
973
1025
|
alphaHelp: "\u4EC5 capability probe \u5BF9\u5F53\u524D route/schema \u9A8C\u8BC1\u901A\u8FC7\u540E\u624D\u771F\u6B63\u6CE8\u518C\u3002",
|
|
1026
|
+
tools: "\u589E\u91CF\u5DE5\u5177\u66F4\u65B0\uFF08addition-only\uFF09",
|
|
1027
|
+
toolsHelp: "\u4F1A\u8BDD\u4E2D\u9014\u65B0\u589E\u5DE5\u5177\u65F6\u4FDD\u6301\u8BF7\u6C42\u524D\u7F00\u4E0D\u53D8\u4EE5\u4FDD\u62A4 prompt \u7F13\u5B58\uFF0C\u65B0\u589E\u5DE5\u5177\u4F5C\u4E3A\u5386\u53F2\u9879\u58F0\u660E\u3002\u4EC5\u5BF9\u652F\u6301\u7684 GPT Responses \u6A21\u578B\u751F\u6548\uFF1B\u5173\u95ED\u540E\u6BCF\u6B21\u8BF7\u6C42\u53D1\u9001\u5B8C\u6574\u5DE5\u5177\u5217\u8868\uFF08\u56DE\u9000\u6216\u5BF9\u7167\u7528\uFF09\u3002\u5220\u9664\u6216\u4FEE\u6539\u5DE5\u5177\u4ECD\u4F1A\u91CD\u7F6E\u4E00\u6B21\u7F13\u5B58\u3002",
|
|
974
1028
|
mediaPreview: "\u641C\u7D22\u5A92\u4F53\u9884\u89C8",
|
|
975
1029
|
mediaPreviewHelp: "\u5728\u56DE\u7B54\u4E0B\u65B9\u663E\u793A\u641C\u7D22\u8FD4\u56DE\u7684\u56FE\u7247\u3001\u56DE\u7B54\u91CC\u7684\u56FE\u7247\u76F4\u94FE\uFF0C\u4EE5\u53CA\u53EF\u76F4\u63A5\u64AD\u653E\u7684\u89C6\u9891\u76F4\u94FE\uFF1B\u70B9\u51FB\u653E\u5927\u6216\u64AD\u653E\u3002\u56DE\u7B54\u6B63\u6587\u91CC\u7684 Markdown \u56FE\u7247\u7531 DSH \u539F\u751F\u6E32\u67D3\uFF0C\u666E\u901A\u7F51\u9875\u94FE\u63A5\u4FDD\u6301\u4E3A\u94FE\u63A5\u3002\u6B64\u8BBE\u7F6E\u53EA\u6539\u53D8\u754C\u9762\u663E\u793A\u3002",
|
|
976
1030
|
mediaTitle: "\u89C6\u9891\u9884\u89C8",
|
|
@@ -1009,6 +1063,8 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
1009
1063
|
advancedHelp: "Only for native Hosted controls such as domains, location, context size and image search; off by default for stable tool schemas.",
|
|
1010
1064
|
alpha: "Enable Alpha command (websearch_alpha)",
|
|
1011
1065
|
alphaHelp: "Registered only after a matching capability probe.",
|
|
1066
|
+
tools: "Incremental tool updates (addition-only)",
|
|
1067
|
+
toolsHelp: "When a tool is added mid-session, keep the request prefix unchanged to protect the prompt cache; the new tool is declared in history. Applies only to supporting GPT Responses models. Off sends the complete tool list on every request (rollback or comparison). Removing or redefining a tool still resets the cache once.",
|
|
1012
1068
|
mediaPreview: "Search media previews",
|
|
1013
1069
|
mediaPreviewHelp: "Show images returned by search, direct image links in the answer and directly playable video links below the answer; click to enlarge or play. Markdown images in the answer are rendered natively by DSH, and ordinary page links stay links. This setting changes presentation only.",
|
|
1014
1070
|
mediaTitle: "Video preview",
|
|
@@ -1041,19 +1097,32 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
1041
1097
|
return {
|
|
1042
1098
|
...DEFAULTS,
|
|
1043
1099
|
...Object.fromEntries(
|
|
1044
|
-
FIELDS.map((field) => [
|
|
1100
|
+
FIELDS.map((field) => [
|
|
1101
|
+
field,
|
|
1102
|
+
value[field] === void 0 ? DEFAULTS[field] : Boolean(value[field])
|
|
1103
|
+
])
|
|
1045
1104
|
)
|
|
1046
1105
|
};
|
|
1047
1106
|
}
|
|
1048
1107
|
const hostedMediaTool = (value) => value === "web_search" || value === "websearch_gpt_advanced";
|
|
1108
|
+
const callTurns = createCallTurns();
|
|
1049
1109
|
const searchMediaDefinition = {
|
|
1050
1110
|
kind: SEARCH_MEDIA_KIND,
|
|
1051
1111
|
target: "chat",
|
|
1052
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);
|
|
1053
1116
|
if (event.type === "turn/start")
|
|
1054
1117
|
return { id: String(event.data.turn), role: "start" };
|
|
1118
|
+
if (event.type === "tool/call")
|
|
1119
|
+
callTurns.remember(event.data.callId, event.data.turn);
|
|
1055
1120
|
if (event.type === "tool/result" || event.type === "tool/call")
|
|
1056
1121
|
return { id: String(event.data.turn), role: "update" };
|
|
1122
|
+
if (event.type === NESTED_SETTLE_EVENT) {
|
|
1123
|
+
const turn = callTurns.turnOf(event.data.rootCallId);
|
|
1124
|
+
return turn === void 0 ? null : { id: String(turn), role: "update" };
|
|
1125
|
+
}
|
|
1057
1126
|
if (event.type !== "assistant/message" || event.surfaceOp !== "append" || event.data.interrupted === true)
|
|
1058
1127
|
return null;
|
|
1059
1128
|
const source = event.data.message.source;
|
|
@@ -1086,6 +1155,17 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
1086
1155
|
}
|
|
1087
1156
|
};
|
|
1088
1157
|
}
|
|
1158
|
+
if (match.event.type === NESTED_SETTLE_EVENT) {
|
|
1159
|
+
const { name, meta } = match.event.data;
|
|
1160
|
+
if (!hostedMediaTool(name)) return context.state;
|
|
1161
|
+
return {
|
|
1162
|
+
...context.state,
|
|
1163
|
+
structuredItems: mergeSearchMedia(
|
|
1164
|
+
context.state.structuredItems,
|
|
1165
|
+
structuredSearchMedia(meta, name)
|
|
1166
|
+
)
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1089
1169
|
if (match.event.type === "tool/result") {
|
|
1090
1170
|
const callId = match.event.data.message.source.callId;
|
|
1091
1171
|
const tool = context.state.pending[callId];
|
|
@@ -1355,6 +1435,14 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
1355
1435
|
disabled: disabled || !s.enabled.value,
|
|
1356
1436
|
onChange: (value) => props.edit("alphaSearch", value)
|
|
1357
1437
|
}),
|
|
1438
|
+
React.createElement(Row, {
|
|
1439
|
+
id: "lcx-tools",
|
|
1440
|
+
label: t("tools"),
|
|
1441
|
+
help: t("toolsHelp"),
|
|
1442
|
+
checked: s.incrementalToolUpdates.value,
|
|
1443
|
+
disabled,
|
|
1444
|
+
onChange: (value) => props.edit("incrementalToolUpdates", value)
|
|
1445
|
+
}),
|
|
1358
1446
|
React.createElement(
|
|
1359
1447
|
"section",
|
|
1360
1448
|
{ className: "lcx-group" },
|
|
@@ -1441,15 +1529,25 @@ a.lcx-media-chip:hover{text-decoration:underline;text-underline-offset:2px}
|
|
|
1441
1529
|
function apply(ctx) {
|
|
1442
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");
|
|
1443
1531
|
if (!slots || !svc || !locale || !uiConversation) return;
|
|
1444
|
-
ctx.effect(() =>
|
|
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");
|
|
1445
1540
|
ctx.effect(() => installUsageSlots(slots, React.createElement), "lcx search billing slots");
|
|
1446
1541
|
ctx.effect(mountCss, "lcx-codex styles");
|
|
1447
1542
|
for (const language of ["zh", "en"])
|
|
1448
1543
|
ctx.effect(() => locale.register(NAMESPACE, language, copy[language]), `lcx-codex ${language} dictionary`);
|
|
1449
|
-
ctx.effect(
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
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");
|
|
1453
1551
|
const installSlot = (name, label, register) => ctx.effect(() => {
|
|
1454
1552
|
const cleanup = slots.inject(name, register);
|
|
1455
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
|
-
|
|
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 (!
|
|
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 =
|
|
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 =
|
|
71
|
+
const outputDetails = isRecord(raw.output_tokens_details)
|
|
100
72
|
? raw.output_tokens_details
|
|
101
|
-
:
|
|
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) =>
|
|
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 (!
|
|
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 (!
|
|
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 (!
|
|
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
|
-
?
|
|
161
|
+
? isRecord(event.response)
|
|
199
162
|
? event.response.error
|
|
200
163
|
: undefined
|
|
201
164
|
: event.error;
|
|
202
|
-
const upstream =
|
|
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 ?? (
|
|
215
|
-
e.status = Number(upstream.status ?? (
|
|
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 =
|
|
191
|
+
terminal = isRecord(event.response) ? event.response : undefined;
|
|
229
192
|
}, options);
|
|
230
|
-
if (!
|
|
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,
|
package/lib/defaults.js
ADDED
|
@@ -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
|
+
});
|