zcode-app-cli 3.11.2-25 → 3.12.3-26

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.
Files changed (39) hide show
  1. package/README.md +22 -8
  2. package/bin/zcode.js +194 -111
  3. package/docs/CONFIGURATION.md +387 -0
  4. package/docs/CONFIGURATION.zh-CN.md +324 -0
  5. package/docs/PROVIDER_CONFIG.md +271 -0
  6. package/docs/PROVIDER_CONFIG.zh-CN.md +245 -0
  7. package/package.json +8 -3
  8. package/provider.example.json +151 -0
  9. package/{config.example.json → setting.example.json} +0 -47
  10. package/vendor/cli-config.cjs +161 -0
  11. package/vendor/extraction.json +17 -4
  12. package/vendor/node_modules/@zcode/tui/dist/index.js +436 -1086
  13. package/vendor/packages/browser-use-plugin/dist/mcp/server.js +35543 -34422
  14. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +2 -2
  15. package/vendor/packages/document-skills-plugin/package.json +4 -4
  16. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +34 -0
  17. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +9 -0
  18. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +11 -0
  19. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +7 -0
  20. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +7 -0
  21. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +10 -1
  22. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +19 -4
  23. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/env_check.sh +6 -2
  24. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup.md +12 -3
  25. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_mac_linux.sh +9 -3
  26. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_windows.ps1 +8 -3
  27. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +30 -6
  28. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +9 -3
  29. package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +33 -0
  30. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup.md +29 -4
  31. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_mac_linux.sh +8 -3
  32. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_windows.ps1 +8 -3
  33. package/vendor/packages/document-skills-plugin/skills/xlsx/quality/pipeline.md +9 -0
  34. package/vendor/packages/document-skills-plugin/skills/xlsx/setup.sh +8 -3
  35. package/vendor/packages/document-skills-plugin/skills/xlsx/xlsx.py +15 -1
  36. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +13 -8
  37. package/vendor/provider/zcode-builtin.json +6296 -0
  38. package/vendor/zcode.cjs +1159 -840
  39. package/zcode-runtime.lock.json +3 -3
@@ -0,0 +1,245 @@
1
+ # Provider 配置字段参考
2
+
3
+ [English](PROVIDER_CONFIG.md) | 简体中文
4
+
5
+ ZCode 桌面端与 CLI 共用 `~/.zcode/v2/provider_config.json`,文件名使用下划线。
6
+ 可通过 `ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` 指定其他文件。终端显示、工具和网络等
7
+ CLI 设置放在 `~/.zcode/cli/setting.json`。
8
+
9
+ [`provider.example.json`](../provider.example.json) 展示当前个人 provider schema 的配置项。
10
+ 它是可以解析的标准 JSON,不包含注释;各字段的含义、可选值及互斥关系由本文说明。
11
+ 本文的“智能配置”对应英文界面的 **Smart configuration**。
12
+
13
+ ## 使用示例文件
14
+
15
+ 示例包含三种用途不同的模型:
16
+
17
+ | 模型 | 用途 |
18
+ | --- | --- |
19
+ | `your-model-id` | 已启用;模型能力和请求参数映射自动继承上游目录 |
20
+ | `overrides-reference` | 已禁用;展示智能配置可以显式覆盖的全部字段 |
21
+ | `manual-reference` | 已禁用;展示完整的手动配置字段 |
22
+
23
+ 另一个已禁用的 provider `coding-plan-example` 用于演示模板继承、Coding Plan API Key
24
+ 类型和内置图标。它不是账号登录示例。
25
+
26
+ 配置实际 provider 时:
27
+
28
+ 1. 选择稳定的 `providerId`,例如 `local`。`providerName` 是显示名称,修改名称不会
29
+ 修改 ID;旧 CLI 配置中 provider 对象的 JSON key 就是 ID。
30
+ 2. 填写 API Key、API 类型和地址。示例中的 **API Key 为空**。
31
+ 3. 将模型列表、模型规则、模型顺序和默认选择中的 `your-model-id` 一起替换。
32
+ 模型 ID 区分大小写,可以包含 `/`。
33
+ 4. 删除不需要的禁用示例 provider、模型及其排序项。只复制实际需要的覆盖字段。
34
+ 5. 已有文件应合并修改,保留其他 provider 和规则。保存后使用 `/model` 刷新目录并选择模型。
35
+
36
+ 示例中的能力值和 Token 上限不是对你的服务器能力的声明。省略字段表示继承目录;
37
+ 显式写入 `false` 或数值会固定该项,后续上游更新不会覆盖它。
38
+
39
+ ## 顶层结构
40
+
41
+ | 路径 | 类型/可选值 | 含义 |
42
+ | --- | --- | --- |
43
+ | `schemaVersion` | `1` | 当前个人配置格式版本,不是 App 版本或目录 revision |
44
+ | `config.providerConfigRules.providerRules` | 数组 | 个人 provider 定义或覆盖项,`providerId` 必须唯一 |
45
+ | `config.modelConfigRules.providerModelRules` | 数组 | 智能配置:在目录基础上覆盖部分模型字段 |
46
+ | `config.modelConfigRules.manualProviderModelRules` | 数组 | 手动配置:完整填写可手动配置的模型字段 |
47
+ | `config.providerOrder` | 可选的 provider ID 数组 | provider 的首选显示顺序 |
48
+ | `config.defaultModelSelection` | 可选对象 | 新会话使用的共享默认模型 |
49
+
50
+ 两种模型规则数组即使没有内容,也保留空数组。同一个 `(providerId, modelId)` 不可
51
+ 同时放在两种数组中。模型规则使用精确 ID,不支持正则表达式。
52
+
53
+ ## Provider 字段
54
+
55
+ 以下路径相对于 `providerRules` 数组中的一个条目。
56
+
57
+ | 路径 | 类型/可选值 | 含义 |
58
+ | --- | --- | --- |
59
+ | `providerId` | 非空字符串 | 模型、默认选择和已保存会话使用的稳定引用 |
60
+ | `providerName` | 可选字符串或 `null` | 显示名称;省略时使用 provider ID |
61
+ | `templateId` | 可选字符串或 `null` | 继承已安装的 provider 模板,示例为 `zai-api` |
62
+ | `enabled` | 可选布尔值 | 启用或禁用 provider,保留其配置 |
63
+ | `config.group` | 可选的 `"standard-personal"` 或 `null` | 个人 provider 所属分组 |
64
+ | `config.logo` | 可选对象或 `null` | 内置显示图标;`null` 清除继承的图标 |
65
+ | `config.logo.type` | `"builtin"` | 当前支持的图标类型 |
66
+ | `config.logo.key` | 非空字符串 | 内置图标 key,例如 `zai`、`bigmodel` |
67
+ | `config.access` | 可选对象或 `null` | API Key 鉴权配置,见下文 |
68
+ | `config.api` | 可选对象或 `null` | 接口配置,见下文 |
69
+ | `config.personalModelIds` | 可选的非空字符串数组或 `null` | 此 provider 下额外添加的模型 |
70
+ | `config.modelOrder` | 可选的非空字符串数组或 `null` | provider 内模型的首选顺序 |
71
+ | `config.visibility` | 可选的 `"visible"`、`"hidden"` 或 `null` | 在模型选择中的可见性 |
72
+
73
+ `templateId` 必须指向已安装上游目录中的模板。目前包括 `zai-api`、`zai-standard-api`、
74
+ `bigmodel-api`、`bigmodel-standard-api` 等,具体以对应版本目录为准。
75
+ 模板已提供的模型 ID 不必再复制到 `personalModelIds`。
76
+
77
+ ### 鉴权
78
+
79
+ | `config.access` 下的字段 | 类型/可选值 | 含义 |
80
+ | --- | --- | --- |
81
+ | `type` | `"api-key"` 或 `"zhipu-coding-plan-api-key"` | 普通 API Key,或 Z.AI/BigModel Coding Plan API Key |
82
+ | `apiKey` | 可选字符串或 `null` | 实际 Key;为空或缺失时不能完成模型请求鉴权 |
83
+ | `apiKeyManagementUrl` | 可选 URL 字符串或 `null` | Key 管理页面地址,不是模型请求地址 |
84
+
85
+ 原生 schema 还有账号鉴权分支:`type: "zhipu-account"`,以及
86
+ `accountType: "zai" | "bigmodel"`、`mode: "start-plan" | "individual-coding-plan" |
87
+ "team-coding-plan" | "off-peak"`、布尔值 `entitled`。这些字段描述 runtime 管理的
88
+ 账号状态,不能用来填写普通 API Key 或自行授予订阅权限。
89
+ 固定的 `account:*` provider **不允许在个人文件中覆盖 `access`**;应使用原生登录和
90
+ 凭证存储。示例不会伪造账号 provider。
91
+
92
+ ### 接口
93
+
94
+ | `config.api` 下的字段 | 类型/可选值 | 含义 |
95
+ | --- | --- | --- |
96
+ | `type` | `"anthropic-messages"`、`"openai-chat-completions"`、`"openai-responses"` | 接口使用的协议 |
97
+ | `baseUrl` | 可选字符串或 `null` | API 根地址;最终生效的配置必须是有效 URL |
98
+ | `headers` | 可选的字符串值对象或 `null` | 附加 HTTP 请求头,例如 `{"X-Client-Name":"zcode-cli"}` |
99
+
100
+ 这些字段可以继承自模板。独立自定义 provider 最终需要有效的 API 类型、地址和鉴权。
101
+ `headers` 是请求头名称到字符串值的映射,不用于填写模型请求体参数。
102
+
103
+ ## 模型字段:智能配置
104
+
105
+ `providerModelRules` 的每个条目包含 `providerId`、`modelId` 和 `config`。
106
+ 其中 `config` 是**部分覆盖**:仅写 `{"enabled": true}` 时,所有能力和参数规格都继承上游。
107
+
108
+ | 模型 `config` 下的路径 | 类型 | 界面字段/含义 |
109
+ | --- | --- | --- |
110
+ | `enabled` | 布尔值 | 启用或禁用模型 |
111
+ | `properties.contextWindow` | 正整数 | 上下文窗口,单位为 Token |
112
+ | `properties.inputFormat.supportsText` | 布尔值 | 文本输入;桌面端编辑器要求保留文本 |
113
+ | `properties.inputFormat.supportsImage` | 布尔值 | 图片输入 |
114
+ | `properties.inputFormat.supportsVideo` | 布尔值 | 视频输入 |
115
+ | `properties.inputFormat.supportsAudio` | 布尔值 | 原生 schema 的音频能力,不代表 CLI 已提供音频附件 UI |
116
+ | `properties.inputFormat.supportsPdf` | 布尔值 | 直接接收 PDF;注意拼写为 `Pdf` |
117
+ | `properties.outputFormat.supportsText` | 布尔值 | 文本输出;当前 schema 唯一的输出类型字段 |
118
+ | `properties.supportsToolCall` | 布尔值 | 工具/函数调用 |
119
+ | `properties.supportsJsonSchemaOutput` | 布尔值 | 结构化输出:接口支持 JSON Schema 输出约束 |
120
+ | `properties.supportsNativeWebSearch` | 布尔值 | 原生联网搜索能力 |
121
+ | `properties.supportsMidConversationSystem` | 布尔值 | 对话中系统消息:允许在初始消息之后插入系统消息 |
122
+ | `properties.requiresMfjsToolSchema` | 布尔值 | runtime 工具 schema 格式的高级兼容选项,通常应继承上游 |
123
+ | `optionSpecs.maxOutputTokens.max` | 正整数 | 最大输出 Token,与上下文窗口不同 |
124
+ | `optionSpecs.maxOutputTokens.map` | 非空表达式字符串 | 将输出 Token 数映射到 API 请求参数 |
125
+ | `optionSpecs.reasoningLevel.values` | 非空、无重复、无空白值的字符串数组 | 从低到高排列的推理等级,具体名称由模型决定 |
126
+ | `optionSpecs.reasoningLevel.map` | 非空表达式字符串 | 将所选推理等级映射到 API 请求参数 |
127
+
128
+ 智能配置中上述字段均可省略。只修改一个嵌套字段时,其余同级字段继续继承。
129
+ 示例把完整字段放在已禁用的 `overrides-reference` 中,避免默认启用的模型被示例数值固定。
130
+
131
+ ### 多模态与三个能力开关
132
+
133
+ 已有的 `local/glm-5.3-flash` 可以用如下覆盖项声明图片、视频和 PDF:
134
+
135
+ ```json
136
+ {
137
+ "providerId": "local",
138
+ "modelId": "glm-5.3-flash",
139
+ "config": {
140
+ "properties": {
141
+ "inputFormat": {
142
+ "supportsImage": true,
143
+ "supportsVideo": true,
144
+ "supportsPdf": true
145
+ },
146
+ "supportsJsonSchemaOutput": false,
147
+ "supportsNativeWebSearch": false,
148
+ "supportsMidConversationSystem": false
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ 只启用后端实际支持的能力。结构化输出不同于仅在提示中要求返回 JSON;原生联网搜索
155
+ 不同于另外配置搜索 MCP;对话中系统消息不同于支持一条初始 system prompt。
156
+
157
+ ### Token 上限与参数映射
158
+
159
+ `properties.contextWindow` 和 `optionSpecs.maxOutputTokens.max` 相互独立。
160
+ 例如 100 万上下文、128000 最大输出,分别填写这两个路径。仅修改数值上限时保留已有的映射。
161
+
162
+ `map` 是**包含原生映射表达式的字符串**,不是 JSON 对象、JavaScript 回调,
163
+ 也不是旧的 `providerOptionsByLevel`。runtime 会校验表达式。
164
+ 两个映射分别使用变量 `reasoningLevel` 和 `maxOutputTokens`。
165
+
166
+ | 接口行为示例 | 映射字符串内容 |
167
+ | --- | --- |
168
+ | Chat Completions 输出参数 | `{"max_tokens": maxOutputTokens}` |
169
+ | 要求 `max_completion_tokens` 的接口 | `{"max_completion_tokens": maxOutputTokens}` |
170
+ | Responses 输出参数 | `{"max_output_tokens": maxOutputTokens}` |
171
+ | 直接使用推理强度参数 | `{"reasoning_effort": reasoningLevel}` |
172
+ | 不附加请求参数 | `{}` |
173
+
174
+ 完整示例还展示条件表达式:
175
+ `reasoningLevel == "disabled" ? {} : {"reasoning_effort": reasoningLevel}`。
176
+ Anthropic 兼容接口可能使用上游目录中的 `thinking`/`output_config` 映射。
177
+ 不能仅根据 API 类型就认定所有模型使用相同的推理字段或等级。
178
+
179
+ ## 模型字段:手动配置
180
+
181
+ 关闭桌面端的**智能配置**后,使用 `manualProviderModelRules`。条目仍然有
182
+ `providerId` 和 `modelId`,但 `config` 使用另一套 schema:
183
+
184
+ - `enabled` 可选。
185
+ - 必须填写 `properties.contextWindow`。
186
+ - `properties.inputFormat` 必须包含布尔值 `supportsImage`、`supportsVideo`、`supportsPdf`。
187
+ - 必须填写布尔值 `properties.supportsJsonSchemaOutput`、`supportsNativeWebSearch`、
188
+ `supportsMidConversationSystem`。
189
+ - `optionSpecs.maxOutputTokens` 必须包含正整数 `max`。
190
+ - `optionSpecs.reasoningLevel` 必须同时包含 `values` 和 `map`。
191
+
192
+ 手动条目不能填写 `supportsText`、`supportsAudio`、`outputFormat`、`supportsToolCall`、
193
+ `requiresMfjsToolSchema` 或 `maxOutputTokens.map`,它们不属于手动 schema。
194
+ 协议层字段仍由目录提供;手动模式固定的是上面列出的可编辑字段。
195
+ 切换配置模式时,应在两种数组之间移动条目,不能把同一模型同时放进两处。
196
+
197
+ ## 默认模型、继承与清除覆盖
198
+
199
+ `config.defaultModelSelection` 的结构为:
200
+
201
+ ```json
202
+ {
203
+ "providerId": "local",
204
+ "modelId": "glm-5.3-flash",
205
+ "options": {
206
+ "reasoningLevel": "high"
207
+ }
208
+ }
209
+ ```
210
+
211
+ `options` 和 `options.reasoningLevel` 都可省略。显式推理等级必须属于该模型最终生效的
212
+ `reasoningLevel.values`;省略 `options` 时由 runtime 使用模型的当前默认值补齐。
213
+ `defaultModelSelection.options` 中没有 `maxOutputTokens` 字段。
214
+
215
+ 缺失字段表示继承。要让某项能力重新跟随上游更新,应删除个人覆盖项。
216
+ 许多 provider 字段和智能模型覆盖字段允许用 `null` 清除值,但 **`null` 不表示自动继承**,
217
+ 而且可能让最终配置缺少必填项。手动模式的必填字段不能这样清除。
218
+ 可使用桌面端的恢复操作,或者删除相应覆盖字段。
219
+
220
+ ## 自动同步上游模型
221
+
222
+ 同步 runtime 时会复制完整的上游 `config/provider/zcode-builtin.json`,包括模型匹配规则、
223
+ 全部能力、Token 上限和请求参数映射。已有的提取目录文件也会更新,不再跳过旧文件。
224
+ 原生 runtime 同时负责正常的目录刷新和 revision 管理。
225
+
226
+ registry 将上游目录与个人文件组合。智能配置模型会自动继承更新后的多模态、
227
+ 工具/联网/系统消息能力、上下文和输出上限、推理等级与映射。显式个人覆盖优先,
228
+ 手动配置的可编辑字段保持固定。刷新不会把最终能力值写回每个个人模型,否则上游值会
229
+ 变成永久覆盖,后续就无法自动更新。
230
+
231
+ 模型解析遵循上游的模型、API 和 provider 站点规则。未知自定义接口可能需要手动覆盖;
232
+ CLI 不会仅凭模型名字猜测它支持图片或原生搜索。使用 `/model` 刷新实时目录。
233
+ 目录更新不会更改已保存的模型 ID 或用户明确选择的推理等级。
234
+
235
+ ## 不属于此文件的字段
236
+
237
+ 个人配置不能直接复制为上游目录格式。以下字段不接受写入此处:`revision`、
238
+ `templateRules`、`templateNameMap`、`builtinModelIds`、`modelRules`、`modelApiRules`、
239
+ `providerSiteRules`、`templateModelRules`、`builtinProviderModelRules`。
240
+ `zai-family` 和 `bigmodel-family` 分组也由原生账号配置声明。
241
+
242
+ 旧版的 `provider`、`model.main`、`model.lite`、`models`、`modalities`、`limit`、
243
+ `modelCatalog` 结构不是新 schema 的字段。CLI 权限模式、Plan 状态、重试、超时、
244
+ 通知、存储路径及 MCP/插件设置同样不属于 `provider_config.json`;参见
245
+ [配置说明](CONFIGURATION.zh-CN.md)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcode-app-cli",
3
- "version": "3.11.2-25",
3
+ "version": "3.12.3-26",
4
4
  "description": "Unofficial terminal client for the ZCode agent runtime",
5
5
  "keywords": [
6
6
  "agent",
@@ -32,7 +32,12 @@
32
32
  "files": [
33
33
  "bin/zcode.js",
34
34
  "vendor",
35
- "config.example.json",
35
+ "setting.example.json",
36
+ "provider.example.json",
37
+ "docs/CONFIGURATION.md",
38
+ "docs/CONFIGURATION.zh-CN.md",
39
+ "docs/PROVIDER_CONFIG.md",
40
+ "docs/PROVIDER_CONFIG.zh-CN.md",
36
41
  "zcode-runtime.lock.json",
37
42
  "README.md",
38
43
  "LICENSE"
@@ -59,7 +64,7 @@
59
64
  "test:runtime": "bun test test/runtime/*.test.ts",
60
65
  "test:tui": "bun run test:tui:component && bun run test:tui:e2e",
61
66
  "test:tui:component": "bun test test/tui/scenario-http.test.ts test/tui/scenario-runtime.test.ts test/tui/scenario-shell.test.ts test/tui/scenario-workspace.test.ts test/tui/terminal-screen.test.ts",
62
- "test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/http-mock.test.ts test/tui/model-resume.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
67
+ "test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/http-mock.test.ts test/tui/model-resume.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/session-rename.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
63
68
  "test:tui:host": "bun test test/tui/scenario-mountx.test.ts",
64
69
  "test:tui:manual": "bun scripts/tui-scenario.ts --manual",
65
70
  "test:tui-scenario": "bun scripts/tui-scenario.ts",
@@ -0,0 +1,151 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "config": {
4
+ "providerConfigRules": {
5
+ "providerRules": [
6
+ {
7
+ "providerId": "custom",
8
+ "templateId": null,
9
+ "providerName": "Custom provider",
10
+ "enabled": true,
11
+ "config": {
12
+ "group": "standard-personal",
13
+ "logo": null,
14
+ "access": {
15
+ "type": "api-key",
16
+ "apiKey": "",
17
+ "apiKeyManagementUrl": "https://api.example.com/api-keys"
18
+ },
19
+ "api": {
20
+ "type": "openai-chat-completions",
21
+ "baseUrl": "https://api.example.com/v1",
22
+ "headers": {}
23
+ },
24
+ "personalModelIds": [
25
+ "your-model-id",
26
+ "overrides-reference",
27
+ "manual-reference"
28
+ ],
29
+ "modelOrder": [
30
+ "your-model-id",
31
+ "overrides-reference",
32
+ "manual-reference"
33
+ ],
34
+ "visibility": "visible"
35
+ }
36
+ },
37
+ {
38
+ "providerId": "coding-plan-example",
39
+ "templateId": "zai-api",
40
+ "providerName": "Coding Plan template example",
41
+ "enabled": false,
42
+ "config": {
43
+ "group": "standard-personal",
44
+ "logo": {
45
+ "type": "builtin",
46
+ "key": "zai"
47
+ },
48
+ "access": {
49
+ "type": "zhipu-coding-plan-api-key",
50
+ "apiKey": "",
51
+ "apiKeyManagementUrl": "https://z.ai/manage-apikey/apikey-list"
52
+ },
53
+ "visibility": "hidden"
54
+ }
55
+ }
56
+ ]
57
+ },
58
+ "modelConfigRules": {
59
+ "providerModelRules": [
60
+ {
61
+ "providerId": "custom",
62
+ "modelId": "your-model-id",
63
+ "config": {
64
+ "enabled": true
65
+ }
66
+ },
67
+ {
68
+ "providerId": "custom",
69
+ "modelId": "overrides-reference",
70
+ "config": {
71
+ "enabled": false,
72
+ "properties": {
73
+ "contextWindow": 200000,
74
+ "inputFormat": {
75
+ "supportsText": true,
76
+ "supportsImage": false,
77
+ "supportsVideo": false,
78
+ "supportsAudio": false,
79
+ "supportsPdf": false
80
+ },
81
+ "outputFormat": {
82
+ "supportsText": true
83
+ },
84
+ "supportsToolCall": true,
85
+ "supportsJsonSchemaOutput": false,
86
+ "supportsNativeWebSearch": false,
87
+ "supportsMidConversationSystem": false,
88
+ "requiresMfjsToolSchema": false
89
+ },
90
+ "optionSpecs": {
91
+ "maxOutputTokens": {
92
+ "max": 32768,
93
+ "map": "{\"max_tokens\": maxOutputTokens}"
94
+ },
95
+ "reasoningLevel": {
96
+ "values": [
97
+ "disabled",
98
+ "low",
99
+ "high"
100
+ ],
101
+ "map": "reasoningLevel == \"disabled\" ? {} : {\"reasoning_effort\": reasoningLevel}"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ],
107
+ "manualProviderModelRules": [
108
+ {
109
+ "providerId": "custom",
110
+ "modelId": "manual-reference",
111
+ "config": {
112
+ "enabled": false,
113
+ "properties": {
114
+ "contextWindow": 200000,
115
+ "inputFormat": {
116
+ "supportsImage": false,
117
+ "supportsVideo": false,
118
+ "supportsPdf": false
119
+ },
120
+ "supportsJsonSchemaOutput": false,
121
+ "supportsNativeWebSearch": false,
122
+ "supportsMidConversationSystem": false
123
+ },
124
+ "optionSpecs": {
125
+ "maxOutputTokens": {
126
+ "max": 32768
127
+ },
128
+ "reasoningLevel": {
129
+ "values": [
130
+ "disabled"
131
+ ],
132
+ "map": "{}"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ]
138
+ },
139
+ "providerOrder": [
140
+ "custom",
141
+ "coding-plan-example"
142
+ ],
143
+ "defaultModelSelection": {
144
+ "providerId": "custom",
145
+ "modelId": "your-model-id",
146
+ "options": {
147
+ "reasoningLevel": "disabled"
148
+ }
149
+ }
150
+ }
151
+ }
@@ -1,47 +1,4 @@
1
1
  {
2
- "provider": {
3
- "zai": {
4
- "kind": "anthropic",
5
- "name": "Z.AI Coding Plan",
6
- "options": {
7
- "apiKeyRequired": true,
8
- "baseURL": "https://api.z.ai/api/anthropic"
9
- },
10
- "headers": {},
11
- "models": {
12
- "glm-5.3": {
13
- "name": "GLM-5.3"
14
- },
15
- "glm-5.3-flash": {
16
- "name": "GLM-5.3-Flash",
17
- "limit": {
18
- "context": 1000000,
19
- "output": 128000
20
- },
21
- "modalities": {
22
- "input": ["text", "image", "video"],
23
- "output": ["text"]
24
- }
25
- },
26
- "glm-5.2": {
27
- "name": "GLM-5.2"
28
- },
29
- "glm-5.1": {
30
- "name": "GLM-5.1"
31
- },
32
- "glm-5-turbo": {
33
- "name": "GLM-5-Turbo"
34
- }
35
- }
36
- }
37
- },
38
- "model": {
39
- "main": "zai/glm-5.2",
40
- "lite": "zai/glm-5-turbo"
41
- },
42
- "modelCatalog": {
43
- "overrides": {}
44
- },
45
2
  "modelStream": {
46
3
  "idleTimeoutMs": 60000
47
4
  },
@@ -63,7 +20,6 @@
63
20
  "compact": true,
64
21
  "rewind": true,
65
22
  "subagent": true,
66
- "memory": true,
67
23
  "skill": true,
68
24
  "mcp": true
69
25
  },
@@ -71,8 +27,6 @@
71
27
  "autoBackgroundMs": 1000
72
28
  },
73
29
  "memory": {
74
- "use": true,
75
- "write": true,
76
30
  "autoConsolidate": true,
77
31
  "summaryMaxBytes": 8192
78
32
  },
@@ -99,7 +53,6 @@
99
53
  "format": "text"
100
54
  },
101
55
  "ui": {
102
- "locale": "auto",
103
56
  "theme": "auto",
104
57
  "tuiMode": "regular",
105
58
  "copyOnSelect": true,
@@ -0,0 +1,161 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_fs = require("node:fs");
3
+ let node_fs_promises = require("node:fs/promises");
4
+ let node_path = require("node:path");
5
+ let node_crypto = require("node:crypto");
6
+ let node_os = require("node:os");
7
+ //#region src/config-paths.ts
8
+ function cliSettingsPath(env = process.env, platform = process.platform, fallbackHome = (0, node_os.homedir)()) {
9
+ const path = platform === "win32" ? node_path.win32 : node_path.posix;
10
+ const home = (platform === "win32" ? env.USERPROFILE : env.HOME)?.trim() || fallbackHome;
11
+ return path.join(home, ".zcode", "cli", "setting.json");
12
+ }
13
+ function desktopSettingsPath(env = process.env) {
14
+ return (0, node_path.join)((0, node_path.dirname)((0, node_path.dirname)(cliSettingsPath(env))), "v2", "setting.json");
15
+ }
16
+ function readDesktopSettings(env = process.env) {
17
+ try {
18
+ const value = JSON.parse((0, node_fs.readFileSync)(desktopSettingsPath(env), "utf8"));
19
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid settings object");
20
+ return value;
21
+ } catch (error) {
22
+ if (error.code === "ENOENT") return {};
23
+ throw new Error("Unable to read Desktop setting.json; the file was left unchanged.");
24
+ }
25
+ }
26
+ function sharedDataBaseDir(env = process.env, platform = process.platform, fallbackHome = (0, node_os.homedir)()) {
27
+ const home = (platform === "win32" ? env.USERPROFILE : env.HOME)?.trim() || fallbackHome;
28
+ const desktop = platform === process.platform ? readDesktopSettings(env).dataBaseDir : void 0;
29
+ return env.ZCODE_DATA_BASE_DIR?.trim() || typeof desktop === "string" && desktop.trim() || home;
30
+ }
31
+ function providerConfigPath(env = process.env, platform = process.platform, fallbackHome = (0, node_os.homedir)()) {
32
+ const path = platform === "win32" ? node_path.win32 : node_path.posix;
33
+ return env.ZCODE_PERSONAL_PROVIDER_CONFIG_FILE?.trim() || path.join(sharedDataBaseDir(env, platform, fallbackHome), ".zcode", "v2", "provider_config.json");
34
+ }
35
+ function legacyCliConfigPath(env = process.env) {
36
+ return (0, node_path.join)((0, node_path.dirname)(cliSettingsPath(env)), "config.json");
37
+ }
38
+ function providerMigrationMarkerPath(env = process.env) {
39
+ const target = (0, node_crypto.createHash)("sha256").update(providerConfigPath(env)).digest("hex").slice(0, 16);
40
+ return (0, node_path.join)((0, node_path.dirname)(cliSettingsPath(env)), "migrations", `provider-registry-${target}.json`);
41
+ }
42
+ //#endregion
43
+ //#region src/runtime-config-bridge.ts
44
+ function record(value) {
45
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
46
+ }
47
+ /** Desktop preferences supply defaults; explicit CLI and project settings still win. */
48
+ function mergeDesktopSettings(value, filePath, env = process.env) {
49
+ const settings = record(value);
50
+ if (!settings || (0, node_path.resolve)(filePath) !== (0, node_path.resolve)(cliSettingsPath(env))) return value;
51
+ const desktop = readDesktopSettings(env);
52
+ const locale = desktop.localePreference;
53
+ const memory = typeof desktop.memoryEnabled === "boolean" ? desktop.memoryEnabled : void 0;
54
+ const memorySettings = {
55
+ ...memory !== void 0 ? {
56
+ use: memory,
57
+ write: memory
58
+ } : {},
59
+ ...record(settings.memory)
60
+ };
61
+ const memoryFeature = typeof memorySettings.use === "boolean" && typeof memorySettings.write === "boolean" ? memorySettings.use || memorySettings.write : memory;
62
+ return {
63
+ ...settings,
64
+ ui: {
65
+ ...typeof locale === "string" ? { locale } : {},
66
+ ...record(settings.ui)
67
+ },
68
+ memory: memorySettings,
69
+ features: {
70
+ ...memoryFeature !== void 0 ? { memory: memoryFeature } : {},
71
+ ...record(settings.features)
72
+ }
73
+ };
74
+ }
75
+ function providerMigrationNeeded(env = process.env) {
76
+ return (0, node_fs.existsSync)(legacyCliConfigPath(env)) && !(0, node_fs.existsSync)(providerMigrationMarkerPath(env));
77
+ }
78
+ /** Uses the upstream parser and file-locked repository, rather than editing shared JSON. */
79
+ async function migrateLegacyProviders(options) {
80
+ const env = options.env ?? process.env;
81
+ if (!providerMigrationNeeded(env)) return;
82
+ let legacy;
83
+ try {
84
+ legacy = record(JSON.parse(await (0, node_fs_promises.readFile)(legacyCliConfigPath(env), "utf8")));
85
+ } catch {
86
+ throw new Error("Legacy provider config could not be read; no provider settings were changed.");
87
+ }
88
+ if (!legacy) throw new Error("Legacy provider config must be an object.");
89
+ const imported = [], skipped = [];
90
+ const candidates = [];
91
+ for (const [id, raw] of Object.entries(record(legacy.provider) ?? {})) {
92
+ const provider = record(raw), key = record(provider?.options)?.apiKey;
93
+ const builtinApi = id === "builtin:zai" || id === "builtin:bigmodel";
94
+ if (!provider || id.startsWith("account:") || id.startsWith("builtin:") && !builtinApi || provider.source !== void 0 && provider.source !== "custom" && !builtinApi || typeof key === "string" && key.startsWith("enc:") || (builtinApi || id.startsWith("default-")) && !(typeof key === "string" && key.trim())) {
95
+ skipped.push(id);
96
+ continue;
97
+ }
98
+ try {
99
+ const candidate = options.importLegacy({ input: { provider: { [id]: provider } } });
100
+ let providers = candidate.providers;
101
+ for (const rule of candidate.providers.rules()) if (typeof provider.enabled === "boolean") providers = providers.setRule({
102
+ ...rule,
103
+ enabled: provider.enabled
104
+ });
105
+ candidates.push({
106
+ ...candidate,
107
+ providers
108
+ });
109
+ } catch {
110
+ skipped.push(id);
111
+ }
112
+ }
113
+ let recovery = false;
114
+ const repository = new options.Repository({
115
+ filePath: providerConfigPath(env),
116
+ pollingIntervalMs: false,
117
+ onRecovery: () => {
118
+ recovery = true;
119
+ }
120
+ });
121
+ try {
122
+ const current = await repository.read();
123
+ if (recovery) throw new Error("The shared provider config needs recovery; it was left unchanged.");
124
+ if (candidates.some((candidate) => candidate.providers.rules().some((rule) => !current.providers.has(rule.providerId)))) await repository.update((snapshot) => {
125
+ let { providers, models } = snapshot;
126
+ for (const candidate of candidates) for (const rule of candidate.providers.rules()) {
127
+ if (providers.has(rule.providerId)) continue;
128
+ providers = providers.setRule(rule);
129
+ for (const model of candidate.models.rules()) if (model.providerId === rule.providerId && !models.getExactRule(model.providerId, model.modelId)) models = models.setExact(model.providerId, model.modelId, model.config);
130
+ imported.push(rule.providerId);
131
+ }
132
+ return {
133
+ ...snapshot,
134
+ providers,
135
+ models
136
+ };
137
+ });
138
+ } finally {
139
+ repository.dispose();
140
+ }
141
+ const marker = providerMigrationMarkerPath(env), temporary = `${marker}.${process.pid}.tmp`;
142
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(marker), {
143
+ recursive: true,
144
+ mode: 448
145
+ });
146
+ try {
147
+ await (0, node_fs_promises.writeFile)(temporary, JSON.stringify({
148
+ schemaVersion: 1,
149
+ imported,
150
+ skipped,
151
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
152
+ }), { mode: 384 });
153
+ await (0, node_fs_promises.rename)(temporary, marker);
154
+ } finally {
155
+ await (0, node_fs_promises.rm)(temporary, { force: true });
156
+ }
157
+ }
158
+ //#endregion
159
+ exports.mergeDesktopSettings = mergeDesktopSettings;
160
+ exports.migrateLegacyProviders = migrateLegacyProviders;
161
+ exports.providerMigrationNeeded = providerMigrationNeeded;