dsh-gpt-adapter 0.2.2 → 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 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,9 +23,19 @@ 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 package has not been published to npm.
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
- Requires Node.js `>=24.9.0` and pnpm.
28
+ Requires Node.js `>=24.9.0` and DSH. Source builds also require pnpm.
29
+
30
+ Install the published package in the web profile:
31
+
32
+ ```sh
33
+ dsh plugin --profile web add dsh-gpt-adapter@0.2.4
34
+ ```
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.
37
+
38
+ To install from source for development or verification:
28
39
 
29
40
  ```sh
30
41
  git clone https://github.com/lxjmaster/dsh-gpt-adapter.git
@@ -32,17 +43,16 @@ cd dsh-gpt-adapter
32
43
  pnpm install --frozen-lockfile
33
44
  mkdir -p artifacts
34
45
  pnpm pack --pack-destination artifacts
35
- dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.2.tgz
46
+ dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.4.tgz
36
47
  ```
37
48
 
38
- `pnpm pack` runs the production build. Restart the DSH host after upgrading the installed package.
49
+ `pnpm pack` runs the production build.
39
50
 
40
51
  ## Automated releases
41
52
 
42
53
  The `Release` workflow runs on pushes to `main` and manual dispatches. For a formal `X.Y.Z` version, it runs the test suite, creates `vX.Y.Z`, creates the matching GitHub Release, and publishes the package to npm. Prerelease versions are skipped, and existing tags or npm versions are reused safely.
43
54
 
44
- Add an npm access token as the repository secret `NPM_TOKEN` before the first release.
45
- Configure GPT connections as usual under **Settings → Models**. The plugin extends the existing native settings and conversation controls.
55
+ Maintainers must provide the npm access token as the repository secret `NPM_TOKEN` for this workflow.
46
56
 
47
57
  ## Codex environment reuse
48
58
 
@@ -58,12 +68,14 @@ Codex compatibility is enabled by default. The root is the plugin's `codexHome`
58
68
  | Codex skills | Discover `skills/` and `skills/.system/`; bodies load on demand |
59
69
  | Shared/project skills | Retain native discovery and include `.agents/skills` at every directory from cwd to repository root; nearer project skills take precedence |
60
70
  | Skill enablement | Honor ordered `skills.config` name/path selectors and `skills.bundled.enabled` |
61
- | Enabled plugins | Read declared skill roots and inline or file-referenced `mcpServers`; disabled plugins stay disabled |
71
+ | Enabled plugins | Support portable root `plugin.json` / `mcp.json` and legacy declarations; disabled plugins stay disabled |
62
72
 
63
73
  The compatibility layer reads project instructions through DSH's filesystem, selects candidates using Codex precedence, and replaces native messages only for covered scopes. Additional nested instruction updates remain applicable. It does not import Codex's built-in system prompt. Configured fallback filenames such as `CLAUDE.md` are used only when supplied in Codex configuration. Instructions are recorded as ordinary user context with a bounded byte budget, including an explicit zero budget; they do not override system, developer, or direct user instructions. Existing conversation history is retained when the plugin is removed.
64
74
 
65
75
  Plugin resources are resolved from the configured local marketplace, or the newest locally cached version in the matching marketplace. Nothing is downloaded automatically. Plugin skills use `<plugin>-<skill>` names to fit DSH's skill-name format and avoid cross-plugin collisions. Original skill paths and relative resources remain intact.
66
76
 
77
+ Portable Agent Plugins use fixed `skills/` and `mcp.json` components, regardless of legacy `skills` or `mcpServers` declarations. OpenAI settings come from the root manifest's `extensions.com.openai` object, including an empty object; only when absent does `.codex-plugin/plugin.json` supply the overlay. Plugin identity always comes from the root manifest.
78
+
67
79
  ## MCP compatibility
68
80
 
69
81
  The plugin automatically starts enabled MCP commands and connects configured HTTP endpoints for each Agent session. It imports `mcp_servers` and the MCP resources declared by enabled plugins. Trusted project overrides apply within that Agent's scope; concurrent sessions do not share imported tool registrations. Untrusted project configuration is skipped.
@@ -77,6 +89,14 @@ Supported configuration includes:
77
89
 
78
90
  Global server names are retained where DSH permits them. Plugin servers use a plugin prefix. Unchanged connections are preserved. Changed or removed connections are disposed before replacement. Invalid configuration retains the last working snapshot, including individually invalid server entries. With automatic refresh enabled, failed startup retries with exponential backoff for up to ten attempts; a manual refresh resets that budget. The default two-second refresh detects configuration and plugin-resource changes; native skill watchers detect skill file changes.
79
91
 
92
+ Plugin-scoped `plugins.<plugin>.mcp_servers.<server>` policies apply `enabled`, `enabled_tools`, `disabled_tools`, and per-tool disabling without overriding the plugin's executable, transport, or credentials. When plugin files are invalid, retained connections still receive current disabling and filtering restrictions; old restrictions are not relaxed until a valid declaration is available again.
93
+
94
+ Stdio servers default to their Agent's project working directory and reconnect when that directory changes. An explicit `cwd` takes precedence. Without an explicit `cwd`, relative executable paths still resolve from the config or plugin root, independently of the process working directory. Plugin paths support `${PLUGIN_ROOT}`, `${CODEX_PLUGIN_ROOT}`, and `${CLAUDE_PLUGIN_ROOT}`.
95
+
96
+ Imported MCP tools carry the current DSH session and turn in `tools/call` metadata under `_meta["x-codex-turn-metadata"]`. `session_id` is the Agent session ID; `turn_id` is `<session ID>:<turn/start event sequence>`. Calls in one turn share the same identity, new turns read a fresh boundary, and asynchronous sessions remain isolated. Diagnostic calls outside an active turn do not invent identities. These fields are transport metadata, never model-supplied tool arguments.
97
+
98
+ The path is DSH Agent → imported tool execution context → MCP `tools/call` metadata → `node_repl` → browser service. This bridge addresses `Missing required Codex turn metadata: session_id, turn_id`; the browser extension, authentication, and App-specific services must still be available on the host. Unloading the plugin removes the bridge, and ordinary DSH MCP calls do not receive these fields.
99
+
80
100
  Credentials are not copied into DSH settings, plugin caches, or this repository. Status responses contain only resource names, states, and sanitized reason codes. Missing environment variables must exist in the DSH host environment to be inherited.
81
101
 
82
102
  This is environment compatibility, not a replacement Codex runtime. Codex OAuth/keychain sessions, Codex App IPC services, hooks, app components, permission policies, and proprietary commands are not automatically reproduced. Standard MCPs using configured headers/environment can be reused; servers requiring unavailable runtime authentication or services report a connection failure. Plugin hooks/apps/commands are reported as unsupported rather than executed. DSH retains its own approval and sandbox behavior.
@@ -106,6 +126,27 @@ An empty `mcpAllowlist` imports all enabled declared servers. A nonempty list fi
106
126
 
107
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.
108
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
+
109
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.
110
151
 
111
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,9 +23,19 @@
22
23
 
23
24
  ## 兼容性与安装
24
25
 
25
- 原生集成面向 DSH `0.2.2-rc.1`、Cordis `4.1.0`,并校验适配器源码指纹。开发依赖固定 Pi AI `1.3.0`。插件不会修改已安装的第三方包文件,目前未发布到 npm。
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
- 需要 Node.js `>=24.9.0` 和 pnpm。
28
+ 需要 Node.js `>=24.9.0` 和 DSH。源码构建另外需要 pnpm。
29
+
30
+ 在 `web` 配置档(profile)中安装已发布的 npm 包:
31
+
32
+ ```sh
33
+ dsh plugin --profile web add dsh-gpt-adapter@0.2.4
34
+ ```
35
+
36
+ 安装或升级后重启 DSH 宿主。在「设置 → 模型」中配置 GPT 连接;Codex 环境复用默认开启。插件扩展现有原生设置与对话控件。
37
+
38
+ 如需从源码安装进行开发或验证:
28
39
 
29
40
  ```sh
30
41
  git clone https://github.com/lxjmaster/dsh-gpt-adapter.git
@@ -32,17 +43,16 @@ cd dsh-gpt-adapter
32
43
  pnpm install --frozen-lockfile
33
44
  mkdir -p artifacts
34
45
  pnpm pack --pack-destination artifacts
35
- dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.2.tgz
46
+ dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.4.tgz
36
47
  ```
37
48
 
38
- `pnpm pack` 会自动执行生产构建。升级安装包后重启 DSH 宿主。
49
+ `pnpm pack` 会自动执行生产构建。
39
50
 
40
51
  ## 自动发布
41
52
 
42
53
  `Release` 工作流会在推送到 `main` 或手动运行时执行。版本号为正式的 `X.Y.Z` 时,工作流会运行测试、创建 `vX.Y.Z` 标签、创建对应的 GitHub Release,并将包发布到 npm。预发布版本会跳过;已有标签或 npm 版本会安全复用。
43
54
 
44
- 首次发布前,请在仓库 Secrets 中添加 npm 访问令牌 `NPM_TOKEN`。
45
- 在「设置 → 模型」中照常配置 GPT 连接;插件扩展现有原生设置与对话控件。
55
+ 维护者需要在仓库 Secrets 中提供 npm 访问令牌 `NPM_TOKEN`,工作流才能发布。
46
56
 
47
57
  ## 复用 Codex 环境
48
58
 
@@ -58,12 +68,14 @@ dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.2.tgz
58
68
  | Codex 技能 | 发现 `skills/` 和 `skills/.system/`,正文按需加载 |
59
69
  | 共享与项目技能 | 保留原生发现机制,并补齐当前目录到仓库根每一级 `.agents/skills`;更近的项目技能优先 |
60
70
  | 技能开关 | 遵循有序的 `skills.config` 名称/路径选择器,以及 `skills.bundled.enabled` |
61
- | 已启用插件 | 读取声明的技能目录和内联或文件引用形式的 `mcpServers`;禁用插件不加载 |
71
+ | 已启用插件 | 支持新版根目录 `plugin.json`、`mcp.json` 和旧版声明;禁用插件不加载 |
62
72
 
63
73
  兼容层通过 DSH 文件系统读取项目指令,按 Codex 优先级选择候选文件,只替换已覆盖作用域内的原生指令消息;额外发现的子目录指令更新仍然保留。它不会导入 Codex 内置系统提示词。`CLAUDE.md` 等后备文件仅在 Codex 配置明确声明时使用。指令以有字节预算的普通用户上下文写入会话,明确配置的零预算也会生效;指令不覆盖系统、开发者或用户直接指令。移除插件不会删除已有会话历史。
64
74
 
65
75
  插件资源优先来自已配置的本地市场目录,否则使用匹配市场中最新的本地缓存版本,不会自动下载。插件技能使用 `<插件名>-<技能名>`,以符合 DSH 命名格式并避免跨插件冲突。技能原始路径和相对资源引用保持不变。
66
76
 
77
+ 新版 Agent Plugins 使用固定的 `skills/` 与 `mcp.json`,不受旧版 `skills`、`mcpServers` 声明改写。OpenAI 扩展优先使用根清单的 `extensions.com.openai` 对象(包括空对象),缺省时才使用 `.codex-plugin/plugin.json`;插件名称仍取自根清单。
78
+
67
79
  ## MCP 兼容
68
80
 
69
81
  插件会为每个会话代理(Agent)自动启动已启用的 MCP 命令并连接已配置的 HTTP 端点。导入来源包括 `mcp_servers` 和已启用插件声明的 MCP 资源。受信任项目的覆盖配置只在该会话代理的作用域内生效,并行会话不会共用导入工具的注册;未受信任项目的配置会跳过。
@@ -77,6 +89,14 @@ dsh plugin --profile web add ./artifacts/dsh-gpt-adapter-0.2.2.tgz
77
89
 
78
90
  全局服务器名称在 DSH 允许时原样保留,插件服务器增加插件名前缀。未变化的连接继续复用;变更或删除的连接先卸载再替换。配置损坏时保留上一份有效快照,单个服务器配置无效时也会保留其可用连接。开启自动刷新时,启动失败会按指数退避间隔重试,最多尝试十次;手动刷新会重置次数。默认每两秒检查配置与插件资源变化,技能文件变化由原生监视器处理。
79
91
 
92
+ 插件级 `plugins.<插件>.mcp_servers.<服务器>` 的 `enabled`、`enabled_tools`、`disabled_tools` 和单工具禁用设置会覆盖声明中的策略,但不能改写插件的命令、传输或凭证。插件文件损坏时,保留的旧连接仍应用最新禁用和过滤限制;有效声明恢复前,不会放宽旧快照已有的限制。
93
+
94
+ stdio 服务器默认从所属 Agent 的项目工作目录启动,切换项目时重建连接;显式 `cwd` 配置优先。未显式配置 `cwd` 时,相对可执行文件路径仍按配置或插件根目录解析,避免与运行目录混淆。插件根目录替换同时支持 `${PLUGIN_ROOT}`、`${CODEX_PLUGIN_ROOT}` 和 `${CLAUDE_PLUGIN_ROOT}`。
95
+
96
+ 导入的 MCP 工具会在 `tools/call` 的 `_meta["x-codex-turn-metadata"]` 中携带当前 DSH 会话和轮次信息。`session_id` 使用 Agent 的会话 ID,`turn_id` 使用 `<会话 ID>:<turn/start 事件序号>`;同一轮的调用保持一致,新轮次重新读取,异步并发会话相互隔离。没有活动轮次的诊断调用不生成虚假标识。这些字段不进入工具参数,也不要求模型填写。
97
+
98
+ 调用链为:DSH Agent → 导入工具的异步调用上下文 → MCP `tools/call` 元数据 → `node_repl` → 浏览器服务。此桥接修复浏览器服务因缺少 `session_id`、`turn_id` 抛出的 `Missing required Codex turn metadata`;浏览器扩展、认证和 App 专属服务仍需在宿主可用。插件卸载时撤销桥接,普通 DSH MCP 调用不注入这些字段。
99
+
80
100
  凭证不会复制到 DSH 设置、插件缓存或本仓库。状态接口只返回资源名、状态和经过脱敏的原因代码。需要继承的环境变量必须存在于 DSH 宿主环境中。
81
101
 
82
102
  本插件提供环境兼容,不会重新实现 Codex 运行时。Codex 的 OAuth/钥匙串会话、App 专属进程通信服务、Hooks、应用组件、权限策略和专用命令不会自动重现。使用配置中的请求头或环境变量认证的标准 MCP 可以复用;依赖缺失认证或运行时服务的服务器会报告连接失败。插件的 Hooks、应用和命令明确标为不支持,不会自动执行。审批和沙箱仍由 DSH 自身管理。
@@ -106,6 +126,27 @@ codexCompatibility:
106
126
 
107
127
  能力优先级为用户覆盖、上游明确元数据、外部能力目录、预设。能力目录请求不携带提供商 API 密钥;模型列表可以不包含能力元数据。Responses 使用 `reasoning.effort`,Chat Completions 使用 `reasoning_effort`,保留用户选定的协议。
108
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
+
109
150
  思考预设只投影到原生界面,不写入原生模型配置。关闭 GPT 自动适配后恢复原生值和参数结构。速度选择按会话持久化。同步失败保留旧快照,失效模型保留到主动清理。
110
151
 
111
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;
@@ -8,6 +8,7 @@ export type CompatibilityItem = {
8
8
  export type CodexMcpConfig = {
9
9
  serverName: string;
10
10
  source: string;
11
+ originalName?: string;
11
12
  transport: 'stdio' | 'streamable-http';
12
13
  command?: string;
13
14
  args?: string[];
@@ -47,7 +48,7 @@ export declare function projectText(path: string, fs?: ProjectFileSystem, signal
47
48
  /** Repository root to cwd; without a repository only cwd participates. */
48
49
  export declare function projectDirectories(cwd: string, fs?: ProjectFileSystem, signal?: AbortSignal): Promise<string[]>;
49
50
  export declare function readCodexConfig(home: string, cwd?: string, fs?: ProjectFileSystem, signal?: AbortSignal): Promise<JsonObject>;
50
- export declare function normalizeCodexMcp(name: string, value: unknown, source: string, base: string, environment?: NodeJS.ProcessEnv): CodexMcpConfig | undefined;
51
+ export declare function normalizeCodexMcp(name: string, value: unknown, source: string, base: string, environment?: NodeJS.ProcessEnv, defaultCwd?: string): CodexMcpConfig | undefined;
51
52
  export declare function discoverCodexSnapshot(home: string, options: {
52
53
  importPluginResources: boolean;
53
54
  mcpAllowlist: string[];
@@ -0,0 +1,12 @@
1
+ export type CodexTurnMetadata = {
2
+ session_id: string;
3
+ turn_id: string;
4
+ };
5
+ /**
6
+ * DSH 0.2.2-rc.1 has no per-call MCP metadata hook. Scope the SDK seam to
7
+ * imported tool executions so its native lifecycle and result handling remain intact.
8
+ */
9
+ export declare function installCodexMcpMetadata(): {
10
+ run<T>(metadata: CodexTurnMetadata | undefined, operation: () => T): T;
11
+ dispose(): void;
12
+ };
@@ -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;
@@ -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 declare function projectModel(provider: string, model: JsonObject, resolve: CapabilityResolver, profile?: JsonObject): JsonObject;
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 {};