dsh-gpt-adapter 0.2.3 → 0.2.4
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 +25 -3
- package/README.zh-CN.md +25 -3
- package/dist/src/client/context-window.d.ts +9 -0
- package/dist/src/context-window.d.ts +25 -0
- package/dist/src/host.d.ts +15 -0
- package/dist/src/settings-overlay.d.ts +14 -2
- package/lib/client.js +282 -61
- package/lib/core.js +28 -1
- package/lib/index.js +343 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Install one plugin to reuse local Codex instructions, skills, enabled plugin res
|
|
|
12
12
|
|
|
13
13
|
- Discover upstream models with `GET /models` and retain stale entries until explicit cleanup.
|
|
14
14
|
- Provide the GPT reasoning preset `low / medium / high / xhigh / max / ultra` through the native Models page and conversation menu.
|
|
15
|
+
- Provide per-model Default, 516K, 1M, and Custom context windows, with the effective capacity and its source shown in settings.
|
|
15
16
|
- Offer independent Standard and Fast speed choices. Fast sends `service_tier: "priority"`; Ultrafast requires an explicit upstream declaration or override.
|
|
16
17
|
- Preserve optional function arguments on GPT Responses requests by setting missing `strict` values to `false`.
|
|
17
18
|
- Read Codex instruction files and refresh them at the next model step without repeating unchanged baselines.
|
|
@@ -22,14 +23,14 @@ Reasoning and speed presets are requests to the configured gateway, not guarante
|
|
|
22
23
|
|
|
23
24
|
## Compatibility and installation
|
|
24
25
|
|
|
25
|
-
The native integration targets DSH `0.2.2-rc.1`, Cordis `4.1.0`, and the pinned adapter source hash. The development dependency uses Pi AI `1.3.0`. Installed third-party package files are never edited. The
|
|
26
|
+
The native integration targets DSH `0.2.2-rc.1`, Cordis `4.1.0`, and the pinned adapter source hash. The development dependency uses Pi AI `1.3.0`. Installed third-party package files are never edited. The package version is `dsh-gpt-adapter@0.2.4`.
|
|
26
27
|
|
|
27
28
|
Requires Node.js `>=24.9.0` and DSH. Source builds also require pnpm.
|
|
28
29
|
|
|
29
30
|
Install the published package in the web profile:
|
|
30
31
|
|
|
31
32
|
```sh
|
|
32
|
-
dsh plugin --profile web add dsh-gpt-adapter@0.2.
|
|
33
|
+
dsh plugin --profile web add dsh-gpt-adapter@0.2.4
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
Restart the DSH host after installing or upgrading. Configure GPT connections under **Settings → Models**; Codex environment reuse is enabled by default. The plugin extends the existing native settings and conversation controls.
|
|
@@ -42,7 +43,7 @@ cd dsh-gpt-adapter
|
|
|
42
43
|
pnpm install --frozen-lockfile
|
|
43
44
|
mkdir -p artifacts
|
|
44
45
|
pnpm pack --pack-destination artifacts
|
|
45
|
-
dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.
|
|
46
|
+
dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.4.tgz
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
`pnpm pack` runs the production build.
|
|
@@ -125,6 +126,27 @@ An empty `mcpAllowlist` imports all enabled declared servers. A nonempty list fi
|
|
|
125
126
|
|
|
126
127
|
Capability precedence is user override, explicit upstream metadata, external catalog, then preset. Catalog requests never receive the provider API key. Model-list responses may omit capability metadata. Reasoning is sent as `reasoning.effort` for Responses and `reasoning_effort` for Chat Completions; the selected protocol is preserved.
|
|
127
128
|
|
|
129
|
+
### Context windows
|
|
130
|
+
|
|
131
|
+
Under **Settings → Models**, expand **Context window** in the provider's GPT adaptation section. Each managed GPT model has four choices:
|
|
132
|
+
|
|
133
|
+
| Choice | Capacity in tokens |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| Default | Resolve automatically for this model and provider. |
|
|
136
|
+
| 516K | `516000` |
|
|
137
|
+
| 1M | `1000000` |
|
|
138
|
+
| Custom | A positive safe integer entered by the user. |
|
|
139
|
+
|
|
140
|
+
These use decimal units. The displayed capacity includes its source. Default uses a distinguishable explicit provider default, upstream model metadata, the configured capability catalog, the shipped exact-model preset, then the native catalog/DSH fallback. A native fallback is labeled as such. Shipped presets are dated data, not a live fetch from OpenAI: `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, `gpt-6-luna`, and `gpt-5.4` use `1050000`; `gpt-4.1` uses `1047576`; `gpt-4o` uses `128000`. Only documented snapshot aliases share these presets. References and verification dates are in [the preset table](src/context-window.ts).
|
|
141
|
+
|
|
142
|
+
Existing native per-model values, including catalog `modelOverrides`, and legacy JSON context overrides remain effective until deliberately edited. Saving a preset uses the native model field and clears only that model's legacy context override; Default removes both per-model overrides while retaining provider defaults and other settings. Saving unrelated settings or discovering models does not turn automatic values into manual overrides. Identical model IDs on different providers are independent. Saving Custom at a preset's exact value shows that preset after saving or reloading.
|
|
143
|
+
|
|
144
|
+
Providers using native catalog `modelOverrides` keep their catalog configuration during synchronization. Discovery and stale cleanup update the plugin snapshot without creating an incompatible explicit `models` list or deleting native overrides.
|
|
145
|
+
|
|
146
|
+
Native forms reject stale drafts when their automatic capacities change; refresh the form before retrying. The preset controls retain drafts across unrelated saves. If the same model changes, review its current value and use the keep-draft action before saving again.
|
|
147
|
+
|
|
148
|
+
Changes apply to the next prepared call; calls already prepared retain their captured capacity. Model information, the inference model, overflow detection, and native compaction use the same effective window. Maximum output tokens and DSH's compaction policy remain independent. A larger local window does not increase the gateway's accepted limit.
|
|
149
|
+
|
|
128
150
|
Preset reasoning fields are projected into the native UI rather than persisted into native model configuration. Disabling GPT adaptation restores the native model values and schema. Speed selections are persisted per session. Synchronization failures retain the previous snapshot; absent models remain stale until explicit cleanup.
|
|
129
151
|
|
|
130
152
|
GPT model snapshots and speed selections are stored under `$DSH_HOME/storages/gpt-adapter`. Codex source files and imported MCP credentials are not copied there. The DSH host owns normal session transcripts and logs.
|
package/README.zh-CN.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
- 通过 `GET /models` 发现上游模型;失效模型保留到用户主动清理。
|
|
14
14
|
- 在原生模型设置页和对话菜单中提供 `low / medium / high / xhigh / max / ultra` 六档思考预设。
|
|
15
|
+
- 为每个模型提供「默认、516K、1M、自定义」四档上下文窗口,展示实际容量与来源。
|
|
15
16
|
- 提供独立的 Standard 和 Fast 速度选择。Fast 发送 `service_tier: "priority"`;Ultrafast 由上游明确声明或用户覆盖提供。
|
|
16
17
|
- 为 GPT Responses 函数工具补齐缺失的 `strict: false`,保留可选参数。
|
|
17
18
|
- 读取 Codex 指令,在下一模型步骤更新;内容不变时不重复注入。
|
|
@@ -22,14 +23,14 @@
|
|
|
22
23
|
|
|
23
24
|
## 兼容性与安装
|
|
24
25
|
|
|
25
|
-
原生集成面向 DSH `0.2.2-rc.1`、Cordis `4.1.0`,并校验适配器源码指纹。开发依赖固定 Pi AI `1.3.0
|
|
26
|
+
原生集成面向 DSH `0.2.2-rc.1`、Cordis `4.1.0`,并校验适配器源码指纹。开发依赖固定 Pi AI `1.3.0`。插件不会修改已安装的第三方包文件。插件版本为 `dsh-gpt-adapter@0.2.4`。
|
|
26
27
|
|
|
27
28
|
需要 Node.js `>=24.9.0` 和 DSH。源码构建另外需要 pnpm。
|
|
28
29
|
|
|
29
30
|
在 `web` 配置档(profile)中安装已发布的 npm 包:
|
|
30
31
|
|
|
31
32
|
```sh
|
|
32
|
-
dsh plugin --profile web add dsh-gpt-adapter@0.2.
|
|
33
|
+
dsh plugin --profile web add dsh-gpt-adapter@0.2.4
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
安装或升级后重启 DSH 宿主。在「设置 → 模型」中配置 GPT 连接;Codex 环境复用默认开启。插件扩展现有原生设置与对话控件。
|
|
@@ -42,7 +43,7 @@ cd dsh-gpt-adapter
|
|
|
42
43
|
pnpm install --frozen-lockfile
|
|
43
44
|
mkdir -p artifacts
|
|
44
45
|
pnpm pack --pack-destination artifacts
|
|
45
|
-
dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.
|
|
46
|
+
dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.4.tgz
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
`pnpm pack` 会自动执行生产构建。
|
|
@@ -125,6 +126,27 @@ codexCompatibility:
|
|
|
125
126
|
|
|
126
127
|
能力优先级为用户覆盖、上游明确元数据、外部能力目录、预设。能力目录请求不携带提供商 API 密钥;模型列表可以不包含能力元数据。Responses 使用 `reasoning.effort`,Chat Completions 使用 `reasoning_effort`,保留用户选定的协议。
|
|
127
128
|
|
|
129
|
+
### 上下文窗口
|
|
130
|
+
|
|
131
|
+
在「设置 → 模型」中,展开提供商卡片的 GPT 自动适配区域内的「上下文窗口」,即可逐个模型设置:
|
|
132
|
+
|
|
133
|
+
| 选项 | 容量(词元数) |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| 默认 | 根据当前模型与提供商自动解析。 |
|
|
136
|
+
| 516K | `516000` |
|
|
137
|
+
| 1M | `1000000` |
|
|
138
|
+
| 自定义 | 用户输入的正安全整数。 |
|
|
139
|
+
|
|
140
|
+
固定档使用十进制单位。界面展示实际容量和来源。「默认」依次采用可辨识的显式提供商默认值、上游模型元数据、已配置的能力目录、插件内置的精确模型预设、原生目录或 DSH 后备值;后备值会如实标注来源。内置预设是带核验日期的数据,不会实时抓取 OpenAI 页面:`gpt-6-astra`、`gpt-6.1-sol`、`gpt-6.1-terra`、`gpt-6-luna`、`gpt-5.4` 为 `1050000`,`gpt-4.1` 为 `1047576`,`gpt-4o` 为 `128000`;仅为有文档依据的快照别名复用预设。参考页面和核验日期见[预设表](src/context-window.ts)。
|
|
141
|
+
|
|
142
|
+
已有原生模型数值(包括目录模型的 `modelOverrides`)和旧版 JSON 上下文覆盖继续生效,直到用户主动编辑。保存预设会使用原生模型字段,并仅清除该模型的旧版上下文覆盖;选择「默认」会删除两处逐模型覆盖,保留提供商默认值和其他设置。保存无关设置或发现模型不会把自动值固化为手动覆盖。同名模型在不同提供商下独立设置。自定义数值若恰好等于固定档,保存或重新加载后会显示对应固定档。
|
|
143
|
+
|
|
144
|
+
使用原生目录 `modelOverrides` 的提供商在同步时保留目录配置。模型发现和失效清理只更新插件快照,不会生成不兼容的显式 `models` 列表,也不会删除原生覆盖。
|
|
145
|
+
|
|
146
|
+
原生表单的自动容量变化后,过期草稿会被拒绝,刷新表单再保存即可。预设控件会在其他模型保存后保留草稿并续用新版本;同一模型发生变化时,先核对当前值,再点击「保留草稿继续编辑」后重新保存。
|
|
147
|
+
|
|
148
|
+
修改对下一次准备的调用生效,已准备的调用继续使用原有容量。模型信息、推理模型、溢出判断和原生上下文压缩采用同一有效窗口;最大输出词元设置与 DSH 原生压缩策略保持独立。扩大本地窗口不会提高网关实际接受的上限。
|
|
149
|
+
|
|
128
150
|
思考预设只投影到原生界面,不写入原生模型配置。关闭 GPT 自动适配后恢复原生值和参数结构。速度选择按会话持久化。同步失败保留旧快照,失效模型保留到主动清理。
|
|
129
151
|
|
|
130
152
|
GPT 模型快照与速度选择保存在 `$DSH_HOME/storages/gpt-adapter`。Codex 源文件和导入的 MCP 凭证不会复制到该位置。正常会话记录和日志由 DSH 宿主管理。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ContextWindowResolution } from '../context-window.js';
|
|
2
|
+
export declare function ContextWindowControl({ provider, modelId, value, revision, busy, save, }: {
|
|
3
|
+
provider: string;
|
|
4
|
+
modelId: string;
|
|
5
|
+
value: ContextWindowResolution;
|
|
6
|
+
revision: number;
|
|
7
|
+
busy: boolean;
|
|
8
|
+
save(args: Record<string, unknown>): Promise<boolean | undefined>;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ContextWindowMode = 'default' | '516k' | '1m' | 'custom';
|
|
2
|
+
export type ContextWindowSource = 'legacy-override' | 'native-user' | 'provider-default' | 'upstream' | 'capability-catalog' | 'official-preset' | 'native-default';
|
|
3
|
+
export type ContextWindowResolution = {
|
|
4
|
+
mode: ContextWindowMode;
|
|
5
|
+
effectiveTokens: number;
|
|
6
|
+
defaultTokens: number;
|
|
7
|
+
source: ContextWindowSource;
|
|
8
|
+
};
|
|
9
|
+
export declare const OFFICIAL_CONTEXT_WINDOWS: Record<string, {
|
|
10
|
+
tokens: number;
|
|
11
|
+
url: string;
|
|
12
|
+
verifiedAt: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function validContextWindow(value: unknown): value is number;
|
|
15
|
+
export declare function contextWindowMode(tokens: number): ContextWindowMode;
|
|
16
|
+
export declare function contextWindowTokens(mode: ContextWindowMode, customTokens?: number): number | undefined;
|
|
17
|
+
export declare function resolveContextWindow(options: {
|
|
18
|
+
modelId: string;
|
|
19
|
+
legacy?: unknown;
|
|
20
|
+
native?: unknown;
|
|
21
|
+
providerDefault?: unknown;
|
|
22
|
+
upstream?: unknown;
|
|
23
|
+
catalog?: unknown;
|
|
24
|
+
nativeDefault?: unknown;
|
|
25
|
+
}): ContextWindowResolution;
|
package/dist/src/host.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Service, type Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
3
|
import { bindTypertRemote } from '@deepseek-ai/dsh-typert-protocol';
|
|
4
4
|
import type { SessionId } from '@deepseek-ai/dsh-client-connection/client';
|
|
5
|
+
import { type ContextWindowMode, type ContextWindowResolution } from './context-window.js';
|
|
6
|
+
import { type ContextWindowEdit, type ContextWindowWriter } from './settings-overlay.js';
|
|
5
7
|
import { type CodexCompatibilityConfig, type CodexCompatibilityRuntime } from './codex.js';
|
|
6
8
|
import type { ModelCapabilities, ServiceTier } from './types.js';
|
|
7
9
|
type RouteOptions = {
|
|
@@ -51,6 +53,7 @@ export declare class GptModels extends Service {
|
|
|
51
53
|
private readonly options;
|
|
52
54
|
private readonly settingsNs;
|
|
53
55
|
codex?: CodexCompatibilityRuntime;
|
|
56
|
+
contextWriter: ContextWindowWriter | undefined;
|
|
54
57
|
readonly typertRemote: ReturnType<typeof bindTypertRemote>;
|
|
55
58
|
private readonly runners;
|
|
56
59
|
private readonly snapshots;
|
|
@@ -85,12 +88,24 @@ export declare class GptModels extends Service {
|
|
|
85
88
|
capabilities: {
|
|
86
89
|
[x: string]: ModelCapabilities;
|
|
87
90
|
};
|
|
91
|
+
contextWindows: {
|
|
92
|
+
[k: string]: ContextWindowResolution;
|
|
93
|
+
};
|
|
94
|
+
contextRevision: number;
|
|
88
95
|
options: RouteOptions;
|
|
89
96
|
};
|
|
90
97
|
configure(provider: string, enabled: boolean): Promise<void>;
|
|
91
98
|
updateOptions(provider: string, refreshIntervalMs: number, capabilityCatalogUrl: string, overridesJSON: string): Promise<void>;
|
|
92
99
|
refresh(provider: string): Promise<void>;
|
|
93
100
|
removeStale(provider: string): Promise<void>;
|
|
101
|
+
/** Resolve raw metadata separately from merged capabilities and cached overrides. */
|
|
102
|
+
contextWindow(provider: string, modelId: string, nativeDefault?: number): ContextWindowResolution;
|
|
103
|
+
contextWriteRevision(): number | undefined;
|
|
104
|
+
/** Public form revisions also cover changes to projected model capacities. */
|
|
105
|
+
private modelsRevision;
|
|
106
|
+
/** Remove only legacy context fields after the matching native save commits. */
|
|
107
|
+
clearLegacyContext(edits: ContextWindowEdit[], expected?: number): Promise<void>;
|
|
108
|
+
setContextWindow(provider: string, modelId: string, mode: ContextWindowMode, customTokens?: number, expectedRevision?: number): Promise<void>;
|
|
94
109
|
setSpeed(sessionId: SessionId, provider: string, modelId: string, tier: ServiceTier): Promise<void>;
|
|
95
110
|
speed(sessionId: SessionId, provider: string, modelId: string): {
|
|
96
111
|
selected: ServiceTier;
|
|
@@ -5,9 +5,21 @@ type SettingsLike = {
|
|
|
5
5
|
write?: (ns: string, change: (current: any, base: any, schema: any) => any, expected?: number, paths?: string[][]) => Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
export type CapabilityResolver = (provider: string, model: JsonObject, profile?: JsonObject) => ModelCapabilities | undefined;
|
|
8
|
-
export
|
|
8
|
+
export type ContextWindowEdit = {
|
|
9
|
+
provider: string;
|
|
10
|
+
modelId: string;
|
|
11
|
+
previousTokens: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
type ContextWrites = {
|
|
14
|
+
revision(): number | undefined;
|
|
15
|
+
saved(edits: ContextWindowEdit[], revision: number | undefined): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export type ContextWindowWriter = (provider: string, modelId: string, tokens: number | undefined, expected?: number) => Promise<void>;
|
|
18
|
+
export declare function projectModel(provider: string, model: JsonObject, resolve: CapabilityResolver, profile?: JsonObject, includeContext?: boolean): JsonObject;
|
|
9
19
|
/** A view of native configuration; the original object and its stored fields stay intact. */
|
|
10
20
|
export declare function projectConfiguration(value: JsonObject | undefined, resolve: CapabilityResolver): JsonObject | undefined;
|
|
11
21
|
/** Dispose returns the native settings page to its original schema and values. */
|
|
12
|
-
export declare function installSettingsOverlay(settings: SettingsLike, resolve: CapabilityResolver): () => void
|
|
22
|
+
export declare function installSettingsOverlay(settings: SettingsLike, resolve: CapabilityResolver, contextWrites?: ContextWrites): (() => void) & {
|
|
23
|
+
setContextWindow: ContextWindowWriter;
|
|
24
|
+
};
|
|
13
25
|
export {};
|