dsh-lcx-codex 0.5.1 → 0.5.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 +11 -11
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/lib/dsh-responses.js +7 -13
- package/lib/index.js +48 -13
- package/lib/model-catalog.js +48 -0
- package/lib/pi-responses-runtime.js +4 -0
- package/lib/responses-stream.js +7 -1
- package/lib/route.js +44 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,16 +37,16 @@ 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` 及以后 |
|
|
41
|
-
| `0.2.0` 系列(`0.2.0-rc.2`,早于 `0.2.1-alpha.2`) | `0.5.
|
|
40
|
+
| `0.2.1-alpha.2` 及以后 | 最新预发布版(`0.6.x` 预发布线) | `@prelatest` |
|
|
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.
|
|
45
|
+
请务必按表格选择:几个版本互不兼容,装错版本时安装命令可能只给出依赖警告,但插件可能无法正常工作。`@latest` 是稳定版 `0.5.2`(发布基线 DSH `0.2.0-rc.2`,host / plugin Pi `0.87.1`;相对 `0.5.0` 只包含缺陷修复),DSH `0.1.5` 用户请固定安装 `@0.4.3`。
|
|
46
46
|
|
|
47
|
-
`0.
|
|
47
|
+
`@prelatest` 指向 `0.6.x` 预发布线的最新预发布版,面向 DSH `0.2.1-alpha.2` 及以后。它的安装范围**只有下限**(`>=0.2.1-alpha.2`),没有上限:更新的 DSH 版本也能装上,但**没有经过验证**。每个预发布版只验证其发布说明里写明的 DSH 基线(目前为 DSH `0.2.1-alpha.2`),请不要据此认为其他 DSH 版本受支持。
|
|
48
48
|
|
|
49
|
-
> 注意:稳定版 `0.5.
|
|
49
|
+
> 注意:稳定版 `0.5.2` 的安装范围写作 `>=0.2.0-rc.2 <0.2.1`,按 DSH 的版本范围规则,`0.2.1` 的预发布版(如 `0.2.1-alpha.2`)也可能被放行安装,但这些版本**不在** `0.5.2` 的支持和验证范围内;DSH `0.2.1-alpha.2` 及以后请使用 `@prelatest`。
|
|
50
50
|
|
|
51
51
|
### 2. 安装并启动
|
|
52
52
|
|
|
@@ -124,11 +124,11 @@ dsh web
|
|
|
124
124
|
|
|
125
125
|
## 从旧版本升级
|
|
126
126
|
|
|
127
|
-
- **DSH 升级到 `0.2.1-alpha.2` 或更新版本**:把插件换成 `@prelatest`(`0.
|
|
128
|
-
- **DSH 升级到 `0.2.0` 系列**:把插件换成 `@latest`(`0.5.
|
|
127
|
+
- **DSH 升级到 `0.2.1-alpha.2` 或更新版本**:把插件换成 `@prelatest`(`0.6.x` 预发布线),稳定版 `0.5.2` 没有在这些 DSH 版本上验证。
|
|
128
|
+
- **DSH 升级到 `0.2.0` 系列**:把插件换成 `@latest`(`0.5.2`),旧版 `0.4.x` 不支持 DSH `0.2`。
|
|
129
129
|
- **DSH `0.1.6` 系列**:继续使用 `@0.4.4-pre.1`。
|
|
130
|
-
- **DSH `0.1.5` 系列**:继续使用 `@0.4.3`;`@latest` 现在指向支持 DSH `0.2` 的 `0.5.
|
|
131
|
-
- **已装了 `0.5.0` 或 `0.5.0-pre.1`**:DSH `0.2.0` 系列重新运行 `@latest` 的 `add` 命令即可升到 `0.5.
|
|
130
|
+
- **DSH `0.1.5` 系列**:继续使用 `@0.4.3`;`@latest` 现在指向支持 DSH `0.2` 的 `0.5.2`。
|
|
131
|
+
- **已装了 `0.5.0`、`0.5.1` 或 `0.5.0-pre.1`**:DSH `0.2.0` 系列重新运行 `@latest` 的 `add` 命令即可升到 `0.5.2`(修复了缺陷,安装范围不变,详见 CHANGELOG;`0.5.2` 修复了 profile 里没写 `api` 时 `gpt-6-sol` 等模型报 `NO_ADAPTER` 的问题);DSH `0.2.1-alpha.2` 及以后用 `@prelatest`。
|
|
132
132
|
- **升级后建议新建会话**:旧版本保存的压缩状态不保证兼容。DSH `0.2` 迁移过的旧长会话如果带有旧版 LCX 压缩检查点,LCX 会提示 `LCX_CHECKPOINT_UNSUPPORTED`,新建会话即可;其他模型不受影响。
|
|
133
133
|
|
|
134
134
|
## 停用与卸载
|
|
@@ -149,7 +149,7 @@ dsh web
|
|
|
149
149
|
- **Markdown 图片换行**:为避免 DSH `0.2` 中图片后的文字挤到图片右侧,LCX 会让回答里的 Markdown 图片单独占一行,这一点与“搜索媒体预览”开关无关;句中的小图也会因此换行。
|
|
150
150
|
- **DSH `0.1.5` + LCX `0.4.3`**:在插件设置中启用或停用 LCX 后,已打开的浏览器页面可能需要刷新。
|
|
151
151
|
- **DSH `0.2.1` 的工具更新**:DSH `0.2.1` 的“只增不改”增量工具更新没有实现,LCX 仍然每次请求都发送完整的当前工具列表;这一变化带来的缓存收益不在声明范围内。
|
|
152
|
-
-
|
|
152
|
+
- **验证范围**:`@prelatest`(`0.6.x` 预发布线)只验证其发布说明里写明的 DSH 基线(目前为 DSH `0.2.1-alpha.2`),安装范围没有上限,更新的 DSH 版本未经验证;具体验证覆盖范围见对应预发布版的 CHANGELOG 和发布说明。`0.5.2` 的发布基线为 DSH `0.2.0-rc.2`(host / plugin Pi `0.87.1`);`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
153
|
|
|
154
154
|
## 常见问题
|
|
155
155
|
|
|
@@ -166,7 +166,7 @@ dsh web
|
|
|
166
166
|
从较早版本一路升级上来的配置目录里可能残留旧的依赖包。先停止 `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
167
|
|
|
168
168
|
**刚发布新版时 `@latest` / `@prelatest` 装到了旧版本?**
|
|
169
|
-
包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.5.
|
|
169
|
+
包管理器的缓存可能还没刷新,DSH 会因版本不兼容拒绝安装。稍等几分钟重试,或直接指定版本号,例如 `dsh-lcx-codex@0.5.2`。
|
|
170
170
|
|
|
171
171
|
## 反馈问题
|
|
172
172
|
|
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 0.
|
|
5
|
+
## @earendil-works/pi-ai 0.87.1
|
|
6
6
|
|
|
7
|
-
Upstream source: https://github.com/earendil-works/pi/tree/v0.
|
|
7
|
+
Upstream source: https://github.com/earendil-works/pi/tree/v0.87.1/packages/ai
|
|
8
8
|
|
|
9
9
|
Included public Responses helpers and model catalogs:
|
|
10
10
|
|
package/lib/dsh-responses.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IMAGE_OFFLOAD_REQUIRED_CODE, LlmError, offloadedImageText, projectOffloadedImages, requiredImageOffload, requestImageHandleText, resolveImageAttachmentAccess, } from "@deepseek-ai/dsh-llm";
|
|
2
2
|
import { requestImageDimensions } from "@deepseek-ai/dsh-attachment";
|
|
3
|
-
import { convertResponsesMessages, convertResponsesTools, createGrammarToolInputProperties,
|
|
4
|
-
import {
|
|
3
|
+
import { convertResponsesMessages, convertResponsesTools, createGrammarToolInputProperties, normalizeContext, } from "./pi-responses-runtime.js";
|
|
4
|
+
import { resolveCatalogModel } from "./model-catalog.js";
|
|
5
5
|
const DEFAULT_MAX_REQUEST_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
6
6
|
const DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET = 2048 * 2048;
|
|
7
7
|
const DEFAULT_REQUEST_IMAGE_MAX_BYTES = 1024 * 1024;
|
|
@@ -76,7 +76,7 @@ function imageAccess(ctx, attachments, ref) {
|
|
|
76
76
|
export async function resolveRouteModelFacts(ctx, route, signal) {
|
|
77
77
|
const llm = ctx?.llm;
|
|
78
78
|
if (llm === undefined)
|
|
79
|
-
return { imageSupport: "unknown", reasoning: undefined, resolved: false };
|
|
79
|
+
return { imageSupport: "unknown", reasoning: undefined, contextWindow: undefined, resolved: false };
|
|
80
80
|
try {
|
|
81
81
|
const info = await llm.resolveModelInfo(stringValue(route.provider), stringValue(route.model), signal);
|
|
82
82
|
const modalities = info.inputModalities;
|
|
@@ -89,11 +89,12 @@ export async function resolveRouteModelFacts(ctx, route, signal) {
|
|
|
89
89
|
reasoning: info.reasoning === undefined
|
|
90
90
|
? undefined
|
|
91
91
|
: { efforts: info.reasoning.efforts.map((effort) => String(effort.id)) },
|
|
92
|
+
contextWindow: positiveSafeInteger(info.context?.contextWindow, 0) || undefined,
|
|
92
93
|
resolved: true,
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
catch {
|
|
96
|
-
return { imageSupport: "unknown", reasoning: undefined, resolved: false };
|
|
97
|
+
return { imageSupport: "unknown", reasoning: undefined, contextWindow: undefined, resolved: false };
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
export async function resolveModelImageSupport(ctx, route, signal) {
|
|
@@ -420,15 +421,8 @@ async function dshToPiMessages(messages, ctx, options, imageMap, requestImages)
|
|
|
420
421
|
return result;
|
|
421
422
|
}
|
|
422
423
|
function builtinResponsesModel(provider, modelId) {
|
|
423
|
-
//
|
|
424
|
-
|
|
425
|
-
return undefined;
|
|
426
|
-
try {
|
|
427
|
-
return getBuiltinModels(provider).find((model) => model.id === modelId && model.api === "openai-responses");
|
|
428
|
-
}
|
|
429
|
-
catch {
|
|
430
|
-
return undefined;
|
|
431
|
-
}
|
|
424
|
+
// The exact bundled catalog entry (see `resolveCatalogModel`): the same descriptor the route resolution reads.
|
|
425
|
+
return resolveCatalogModel(provider, modelId).descriptor;
|
|
432
426
|
}
|
|
433
427
|
export function resolvePiResponsesModel(options) {
|
|
434
428
|
const route = isObject(options.route) ? options.route : {};
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,8 @@ import { getSupportedThinkingLevels } from "./pi-responses-runtime.js";
|
|
|
14
14
|
import { fetchJsonWithRetry } from "./transport.js";
|
|
15
15
|
import { agentSessionId, agentUsesSession, compactionConfigState, compactionPatchCandidate, installCompactionPatch, patchCompactionConfig, patchToolResultPruner, readAgentRouteState, readSelectedAgentRouteState, recordAgentRouteEvent, resolveAgentService, resolveContextService, resolveScopedService, restoreCompactionConfig, restoreCompactionPatches, restoreToolResultPruner, sessionFor, sessionFromAgent, scopedToolRuntime, onScopedToolExecute, tokenMeterTotal, toolResultPrunerState, } from "./dsh-compat.js";
|
|
16
16
|
import { InvocationPolicyScope } from "./invocation-policy-scope.js";
|
|
17
|
-
import {
|
|
17
|
+
import { resolveCatalogModel } from "./model-catalog.js";
|
|
18
|
+
import { authenticatedGrokHeaders, authenticatedHeaders, currentRoute, generationControlsFromSession, grokPromptCacheSessionId, promptCacheKey, promptCacheRetention, promptCacheSessionId, diagnoseResponsesRoute, resolveGrokResponsesRouteConfig, resolveResponsesRouteConfig, routeFingerprint, } from "./route.js";
|
|
18
19
|
import { DEFAULT_MAX_REQUEST_IMAGE_BYTES, DEFAULT_REQUEST_IMAGE_PIXEL_BUDGET, DEFAULT_REQUEST_IMAGE_MAX_BYTES, assertAggregateImageBudget, hydrateNativeImageReferences, inputImageBase64Lengths, resolveRouteModelFacts, responseInputItems, serializeDshMessages, } from "./dsh-responses.js";
|
|
19
20
|
import { mergeFeatureHeader, requestNativeCompaction } from "./compact-v2.js";
|
|
20
21
|
import { buildResponsesBody } from "./responses-request.js";
|
|
@@ -550,17 +551,19 @@ function mergeMap(target, source) {
|
|
|
550
551
|
target.set(key, value);
|
|
551
552
|
}
|
|
552
553
|
/**
|
|
553
|
-
* The
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
* being assumed to reason.
|
|
554
|
+
* The model facts a GPT route serializes and sends with. What DSH reported for the exact routed model
|
|
555
|
+
* (reasoning capability, context window) wins over the bundled catalog entry, and a profile's declared
|
|
556
|
+
* `reasoningEfforts` (wire mapping, or `false` for a non-reasoning model) wins over both. A model with no
|
|
557
|
+
* catalog entry follows what DSH itself resolved for it instead of being assumed to reason.
|
|
557
558
|
*/
|
|
558
559
|
function gptModelOverride(routeConfig, facts) {
|
|
559
|
-
if (routeConfig.modelControls !== undefined)
|
|
560
|
-
return { ...routeConfig.modelControls };
|
|
561
560
|
if (!facts.resolved)
|
|
562
|
-
return undefined;
|
|
563
|
-
return {
|
|
561
|
+
return routeConfig.modelControls === undefined ? undefined : { ...routeConfig.modelControls };
|
|
562
|
+
return {
|
|
563
|
+
reasoning: facts.reasoning !== undefined,
|
|
564
|
+
...(facts.contextWindow === undefined ? {} : { contextWindow: facts.contextWindow }),
|
|
565
|
+
...routeConfig.modelControls,
|
|
566
|
+
};
|
|
564
567
|
}
|
|
565
568
|
/** Refuse an effort DSH does not offer for this model, the way the DSH adapter and the Grok route do. */
|
|
566
569
|
function assertSupportedReasoningEffort(effort, facts) {
|
|
@@ -571,9 +574,28 @@ function assertSupportedReasoningEffort(effort, facts) {
|
|
|
571
574
|
return;
|
|
572
575
|
throw Object.assign(new Error(`Responses route does not support reasoning effort "${String(effort)}"`), { code: "LCX_RESPONSES_UNSUPPORTED_OPTION" });
|
|
573
576
|
}
|
|
577
|
+
const reportedCatalogGaps = new Set();
|
|
578
|
+
/**
|
|
579
|
+
* Say once per route model that LCX's bundled Pi catalog does not describe it, so its wire capabilities
|
|
580
|
+
* (strict tools, grammar tools, cache mode) come from the profile and from what DSH declares instead.
|
|
581
|
+
*/
|
|
582
|
+
function reportCatalogGap(ctx, route) {
|
|
583
|
+
const source = resolveCatalogModel(route.provider, route.model, true).source;
|
|
584
|
+
if (source !== "catalog-provider-default" && source !== "frozen-pi086")
|
|
585
|
+
return;
|
|
586
|
+
const key = `${route.provider}/${route.model}`;
|
|
587
|
+
if (reportedCatalogGaps.has(key))
|
|
588
|
+
return;
|
|
589
|
+
if (reportedCatalogGaps.size >= 256)
|
|
590
|
+
reportedCatalogGaps.clear();
|
|
591
|
+
reportedCatalogGaps.add(key);
|
|
592
|
+
ctx.logger?.debug?.(`[lcx-codex] ${key} is not described by LCX's bundled model catalog; its wire capabilities follow the profile and what DSH declares for the model`);
|
|
593
|
+
}
|
|
574
594
|
async function serializeNativeAware(messages, route, routeConfig, ctx, options) {
|
|
575
595
|
const session = sessionFor(ctx, route.sessionId);
|
|
576
596
|
const modelFacts = await resolveRouteModelFacts(ctx, route, options.signal);
|
|
597
|
+
if (options.grokNativeReplayRoute === undefined)
|
|
598
|
+
reportCatalogGap(ctx, route);
|
|
577
599
|
const { imageSupport } = modelFacts;
|
|
578
600
|
const modelOverride = options.grokNativeReplayRoute === undefined
|
|
579
601
|
? gptModelOverride(routeConfig, modelFacts)
|
|
@@ -1110,8 +1132,21 @@ async function* managedGrokNativeSearchStream(options, routeConfig, nativeSearch
|
|
|
1110
1132
|
function isGptLifecycleTarget(options) {
|
|
1111
1133
|
return /^gpt-/iu.test(String(options.model ?? ""));
|
|
1112
1134
|
}
|
|
1113
|
-
async function* unavailableManagedRouteStream(options) {
|
|
1114
|
-
|
|
1135
|
+
async function* unavailableManagedRouteStream(options, diagnosis = "incomplete") {
|
|
1136
|
+
// Say what to change: the profile's models list leaves the model out, or no protocol can be inferred for it.
|
|
1137
|
+
const notConfigured = diagnosis === "model-not-configured";
|
|
1138
|
+
const apiUnresolved = diagnosis === "api-unresolved";
|
|
1139
|
+
yield managedFailureChunk(Object.assign(new Error(notConfigured
|
|
1140
|
+
? "LCX is enabled but the selected model is not configured for this provider: the provider profile lists other models. Add the model to the profile's models list or select a listed model"
|
|
1141
|
+
: apiUnresolved
|
|
1142
|
+
? "LCX could not determine the wire protocol of the selected GPT route: the provider profile sets no api and the model is unknown to the catalog. Add api: openai-responses to the provider profile, or select a model DSH recognizes"
|
|
1143
|
+
: "LCX is enabled but the selected DSH route cannot be resolved as an authenticated OpenAI Responses wire route"), {
|
|
1144
|
+
code: notConfigured
|
|
1145
|
+
? "LCX_RESPONSES_MODEL_NOT_CONFIGURED"
|
|
1146
|
+
: apiUnresolved
|
|
1147
|
+
? "LCX_RESPONSES_API_UNRESOLVED"
|
|
1148
|
+
: "LCX_RESPONSES_ROUTE_UNAVAILABLE",
|
|
1149
|
+
}), options.signal);
|
|
1115
1150
|
}
|
|
1116
1151
|
function installInjected(ctx, configInput) {
|
|
1117
1152
|
installSearchUsage(ctx);
|
|
@@ -1227,11 +1262,11 @@ function installInjected(ctx, configInput) {
|
|
|
1227
1262
|
const routeConfig = resolveResponsesRouteConfig(ctx, options, runtimeConfig);
|
|
1228
1263
|
if (options.purpose === "compaction") {
|
|
1229
1264
|
if (!routeConfig)
|
|
1230
|
-
return unavailableManagedRouteStream(options);
|
|
1265
|
+
return unavailableManagedRouteStream(options, diagnoseResponsesRoute(ctx, options));
|
|
1231
1266
|
return remoteCompactionStream(options, routeWithPolicies(routeConfig, runtimeConfig), ctx, next);
|
|
1232
1267
|
}
|
|
1233
1268
|
if (!routeConfig)
|
|
1234
|
-
return unavailableManagedRouteStream(options);
|
|
1269
|
+
return unavailableManagedRouteStream(options, diagnoseResponsesRoute(ctx, options));
|
|
1235
1270
|
return managedResponsesStream(options, routeWithPolicies(routeConfig, runtimeConfig), ctx);
|
|
1236
1271
|
});
|
|
1237
1272
|
ctx.effect?.(() => async () => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getCatalogModels } from "./pi-responses-runtime.js";
|
|
2
|
+
import { wasPi086ResponsesModel } from "./pi086-responses-allowlist.js";
|
|
3
|
+
const providerDefaultsCache = new Map();
|
|
4
|
+
function sharedValue(values) {
|
|
5
|
+
const distinct = new Set(values);
|
|
6
|
+
const [only] = distinct;
|
|
7
|
+
return distinct.size === 1 && typeof only === "string" && only.length > 0 ? only : undefined;
|
|
8
|
+
}
|
|
9
|
+
function providerDefaults(provider) {
|
|
10
|
+
const cached = providerDefaultsCache.get(provider);
|
|
11
|
+
if (cached !== undefined)
|
|
12
|
+
return cached;
|
|
13
|
+
const models = getCatalogModels(provider);
|
|
14
|
+
const defaults = {
|
|
15
|
+
api: sharedValue(models.map((model) => model.api)),
|
|
16
|
+
baseUrl: sharedValue(models.map((model) => model.baseUrl)),
|
|
17
|
+
};
|
|
18
|
+
providerDefaultsCache.set(provider, defaults);
|
|
19
|
+
return defaults;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a route model's protocol, endpoint and catalog descriptor from the bundled Pi catalog.
|
|
23
|
+
* @param declaredByProfile the provider profile lists this model in `models`; only then does DSH serve a model
|
|
24
|
+
* its catalog does not describe, so only then may the provider-wide default apply.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveCatalogModel(provider, modelId, declaredByProfile = false) {
|
|
27
|
+
const providerName = String(provider ?? "");
|
|
28
|
+
const id = String(modelId ?? "");
|
|
29
|
+
const exact = getCatalogModels(providerName).find((model) => model.id === id);
|
|
30
|
+
if (exact !== undefined)
|
|
31
|
+
return {
|
|
32
|
+
source: "catalog-model",
|
|
33
|
+
api: exact.api,
|
|
34
|
+
baseUrl: exact.baseUrl,
|
|
35
|
+
descriptor: exact.api === "openai-responses" ? exact : undefined,
|
|
36
|
+
};
|
|
37
|
+
const defaults = providerDefaults(providerName);
|
|
38
|
+
if (declaredByProfile && defaults.api !== undefined)
|
|
39
|
+
return {
|
|
40
|
+
source: "catalog-provider-default",
|
|
41
|
+
api: defaults.api,
|
|
42
|
+
baseUrl: defaults.baseUrl,
|
|
43
|
+
descriptor: undefined,
|
|
44
|
+
};
|
|
45
|
+
if (wasPi086ResponsesModel(providerName, id))
|
|
46
|
+
return { source: "frozen-pi086", api: "openai-responses", baseUrl: undefined, descriptor: undefined };
|
|
47
|
+
return { source: "unknown", api: undefined, baseUrl: undefined, descriptor: undefined };
|
|
48
|
+
}
|
|
@@ -1705,6 +1705,9 @@ var models = {
|
|
|
1705
1705
|
"opencode-go": responsesOnly(RESPONSE_CATALOGS["opencode-go"]),
|
|
1706
1706
|
xai: responsesOnly(RESPONSE_CATALOGS.xai)
|
|
1707
1707
|
};
|
|
1708
|
+
function getCatalogModels(provider) {
|
|
1709
|
+
return Object.hasOwn(RESPONSE_CATALOGS, provider) ? Object.values(RESPONSE_CATALOGS[provider]) : [];
|
|
1710
|
+
}
|
|
1708
1711
|
function getBuiltinProviders() {
|
|
1709
1712
|
return providers;
|
|
1710
1713
|
}
|
|
@@ -1719,6 +1722,7 @@ export {
|
|
|
1719
1722
|
createGrammarToolInputProperties,
|
|
1720
1723
|
getBuiltinModels,
|
|
1721
1724
|
getBuiltinProviders,
|
|
1725
|
+
getCatalogModels,
|
|
1722
1726
|
getSupportedThinkingLevels,
|
|
1723
1727
|
normalizeContext,
|
|
1724
1728
|
processResponsesStream
|
package/lib/responses-stream.js
CHANGED
|
@@ -210,6 +210,8 @@ export function managedFailure(error, signal, upstream) {
|
|
|
210
210
|
else if (sourceCodes.has("LCX_GROK_NATIVE_PROTOCOL_ERROR"))
|
|
211
211
|
code = "GROK_NATIVE_PROTOCOL_ERROR";
|
|
212
212
|
else if (sourceCodes.has("LCX_RESPONSES_ROUTE_UNAVAILABLE") ||
|
|
213
|
+
sourceCodes.has("LCX_RESPONSES_API_UNRESOLVED") ||
|
|
214
|
+
sourceCodes.has("LCX_RESPONSES_MODEL_NOT_CONFIGURED") ||
|
|
213
215
|
sourceCodes.has("LCX_RESPONSES_MODEL_UNAVAILABLE"))
|
|
214
216
|
code = "NO_ADAPTER";
|
|
215
217
|
else if (sourceCodes.has("LCX_INSUFFICIENT_QUOTA"))
|
|
@@ -253,7 +255,11 @@ export function managedFailure(error, signal, upstream) {
|
|
|
253
255
|
AUTH: "Responses request was rejected by authentication",
|
|
254
256
|
INSUFFICIENT_QUOTA: "服务商额度不足或未满足请求预留额度,请检查中转额度(并非 API 密钥无效) / Provider quota is insufficient for this request",
|
|
255
257
|
UNSUPPORTED_OPTION: "LCX Responses does not support this request option",
|
|
256
|
-
NO_ADAPTER: "
|
|
258
|
+
NO_ADAPTER: sourceCodes.has("LCX_RESPONSES_MODEL_NOT_CONFIGURED")
|
|
259
|
+
? "LCX is enabled but the selected model is not configured for this provider (the provider profile lists other models); add it to the profile's models list or select a listed model"
|
|
260
|
+
: sourceCodes.has("LCX_RESPONSES_API_UNRESOLVED")
|
|
261
|
+
? "LCX could not determine the wire protocol of the selected GPT route (the provider profile sets no api and the model is unknown to the catalog); add api: openai-responses to the provider profile or select a model DSH recognizes"
|
|
262
|
+
: "LCX could not resolve the selected Responses route",
|
|
257
263
|
RATE_LIMIT: "Responses provider rate limit was reached",
|
|
258
264
|
SERVER: "Responses provider returned a server failure",
|
|
259
265
|
INVALID_REQUEST: sourceCodes.has("LCX_CHECKPOINT_UNSUPPORTED")
|
package/lib/route.js
CHANGED
|
@@ -3,8 +3,7 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
|
3
3
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
4
4
|
import "@deepseek-ai/dsh-settings";
|
|
5
5
|
import { attributionHeaders, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
6
|
-
import {
|
|
7
|
-
import { wasPi086ResponsesModel } from "./pi086-responses-allowlist.js";
|
|
6
|
+
import { resolveCatalogModel } from "./model-catalog.js";
|
|
8
7
|
/** @param {unknown} value */
|
|
9
8
|
function isRecord(value) {
|
|
10
9
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -125,17 +124,6 @@ function copyResponsesCompat(target, source) {
|
|
|
125
124
|
Object.assign(target, { [field]: value });
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
|
-
/** @param {unknown} provider @param {unknown} modelId */
|
|
129
|
-
function builtinResponsesModel(provider, modelId) {
|
|
130
|
-
const providerName = String(provider ?? "");
|
|
131
|
-
// A newer plugin-Pi catalog must not grant LCX a route that Pi 0.86 lacked.
|
|
132
|
-
if (!wasPi086ResponsesModel(providerName, String(modelId ?? "")))
|
|
133
|
-
return undefined;
|
|
134
|
-
const builtinProvider = getBuiltinProviders().find((candidate) => candidate === providerName);
|
|
135
|
-
if (builtinProvider === undefined)
|
|
136
|
-
return undefined;
|
|
137
|
-
return getBuiltinModels(builtinProvider).find((model) => model.id === String(modelId ?? "") && model.api === "openai-responses");
|
|
138
|
-
}
|
|
139
127
|
function modelDescriptorDefaults(model) {
|
|
140
128
|
if (!model)
|
|
141
129
|
return undefined;
|
|
@@ -144,6 +132,18 @@ function modelDescriptorDefaults(model) {
|
|
|
144
132
|
thinkingLevelMap: model.thinkingLevelMap,
|
|
145
133
|
};
|
|
146
134
|
}
|
|
135
|
+
/** The profile lists this model in `models`: the one way DSH serves a model its catalog does not describe. */
|
|
136
|
+
function profileDeclaresModel(profile, modelId) {
|
|
137
|
+
return Array.isArray(profile?.models) && profile.models.some((entry) => String(entry?.id ?? "") === String(modelId));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A nonempty `models` list replaces the served catalog: DSH serves exactly the listed models, and LCX answers
|
|
141
|
+
* `llm/stream` before DSH's adapter does, so a claim here would send a request DSH itself refuses.
|
|
142
|
+
*/
|
|
143
|
+
function profileExcludesModel(profile, modelId) {
|
|
144
|
+
return Array.isArray(profile?.models) && profile.models.length > 0 &&
|
|
145
|
+
!profile.models.some((entry) => String(entry?.id ?? "") === String(modelId));
|
|
146
|
+
}
|
|
147
147
|
function configuredModelProfile(profile, modelId) {
|
|
148
148
|
const configuredModels = Array.isArray(profile?.models) ? profile.models : [];
|
|
149
149
|
return configuredModels.length > 0
|
|
@@ -227,11 +227,15 @@ export function resolveResponsesRouteConfig(ctx, options, policy) {
|
|
|
227
227
|
if (!isRecord(profile))
|
|
228
228
|
return undefined;
|
|
229
229
|
const configured = profile;
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
if (profileExcludesModel(configured, model))
|
|
231
|
+
return undefined;
|
|
232
|
+
// Protocol and endpoint: the profile, then what DSH resolves for the model (see `resolveCatalogModel`).
|
|
233
|
+
const catalog = resolveCatalogModel(provider, model, profileDeclaresModel(configured, model));
|
|
234
|
+
const builtin = catalog.descriptor;
|
|
235
|
+
const api = configured.api ?? catalog.api;
|
|
232
236
|
if (api !== "openai-responses")
|
|
233
237
|
return undefined;
|
|
234
|
-
const baseURL = configured.baseURL ??
|
|
238
|
+
const baseURL = configured.baseURL ?? catalog.baseUrl;
|
|
235
239
|
const apiKeyEnv = configured.apiKeyEnv;
|
|
236
240
|
if (typeof baseURL !== "string" || !normalizeBaseURL(baseURL) || typeof apiKeyEnv !== "string" || !apiKeyEnv.trim())
|
|
237
241
|
return undefined;
|
|
@@ -239,7 +243,7 @@ export function resolveResponsesRouteConfig(ctx, options, policy) {
|
|
|
239
243
|
copyResponsesCompat(responsesCompat, builtin?.compat);
|
|
240
244
|
copyResponsesCompat(responsesCompat, lcxCapabilityRoute ? policy.responsesCompat : undefined);
|
|
241
245
|
copyResponsesCompat(responsesCompat, configuredResponsesCompat(configured, model));
|
|
242
|
-
const promptCacheModel = lcxCapabilityRoute && policy.supportsExplicitPromptCacheMode === true ?
|
|
246
|
+
const promptCacheModel = lcxCapabilityRoute && policy.supportsExplicitPromptCacheMode === true ? resolveCatalogModel("openai", model).descriptor : undefined;
|
|
243
247
|
const promptCacheRaw = promptCacheModel;
|
|
244
248
|
const promptCacheCompat = isRecord(promptCacheRaw)
|
|
245
249
|
? promptCacheRaw.compat
|
|
@@ -277,6 +281,23 @@ export function resolveResponsesRouteConfig(ctx, options, policy) {
|
|
|
277
281
|
requestImageMaxBytes: isPositiveInteger(configured.requestImageMaxBytes) ? configured.requestImageMaxBytes : policy.requestImageMaxBytes,
|
|
278
282
|
};
|
|
279
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Name the reason `resolveResponsesRouteConfig` returned nothing, so the failure can tell the user what to
|
|
286
|
+
* change: `api-unresolved` means neither the profile nor the model catalog names a protocol for this model.
|
|
287
|
+
*/
|
|
288
|
+
export function diagnoseResponsesRoute(ctx, options) {
|
|
289
|
+
const provider = String(options?.provider ?? "");
|
|
290
|
+
const model = String(options?.model ?? "");
|
|
291
|
+
const profile = provider.trim() ? configuredProviderProfile(ctx, provider) : undefined;
|
|
292
|
+
if (!isRecord(profile))
|
|
293
|
+
return "no-profile";
|
|
294
|
+
if (profileExcludesModel(profile, model))
|
|
295
|
+
return "model-not-configured";
|
|
296
|
+
const api = profile.api ?? resolveCatalogModel(provider, model, profileDeclaresModel(profile, model)).api;
|
|
297
|
+
if (api === undefined)
|
|
298
|
+
return "api-unresolved";
|
|
299
|
+
return api === "openai-responses" ? "incomplete" : "api-not-responses";
|
|
300
|
+
}
|
|
280
301
|
/** Resolve a Grok-prefixed model through its selected DSH Responses profile. */
|
|
281
302
|
export function resolveGrokResponsesRouteConfig(ctx, options, policy) {
|
|
282
303
|
const provider = String(options?.provider ?? "");
|
|
@@ -286,11 +307,14 @@ export function resolveGrokResponsesRouteConfig(ctx, options, policy) {
|
|
|
286
307
|
const configured = configuredProviderProfile(ctx, provider);
|
|
287
308
|
if (!isRecord(configured))
|
|
288
309
|
return undefined;
|
|
289
|
-
|
|
290
|
-
|
|
310
|
+
if (profileExcludesModel(configured, model))
|
|
311
|
+
return undefined;
|
|
312
|
+
const catalog = resolveCatalogModel(provider, model, profileDeclaresModel(configured, model));
|
|
313
|
+
const selectedBuiltin = catalog.descriptor;
|
|
314
|
+
const api = configured.api ?? catalog.api;
|
|
291
315
|
if (api !== "openai-responses")
|
|
292
316
|
return undefined;
|
|
293
|
-
const baseURL = configured.baseURL ??
|
|
317
|
+
const baseURL = configured.baseURL ?? catalog.baseUrl;
|
|
294
318
|
const apiKeyEnv = configured.apiKeyEnv;
|
|
295
319
|
if (typeof baseURL !== "string" ||
|
|
296
320
|
!normalizeBaseURL(baseURL) ||
|
package/package.json
CHANGED