zcode-pro 1.11.0 → 1.12.0

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.
@@ -16,7 +16,7 @@
16
16
  // - 仓库内 PowerShell 脚本(install.ps1 等)必须保存为带 BOM 的 UTF-8。
17
17
  import { execFileSync } from 'node:child_process';
18
18
  import { accessSync, chmodSync, constants as fsConstants, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
19
- import { basename, dirname, join, sep } from 'node:path';
19
+ import { basename, delimiter, dirname, join, sep } from 'node:path';
20
20
  import { homedir, platform } from 'node:os';
21
21
  import { fileURLToPath } from 'node:url';
22
22
  import { resolveZcodeExecutable } from './paths.mjs';
@@ -29,7 +29,10 @@ const SUPPORTED = ['linux', 'win32', 'darwin'];
29
29
  // —— PATH 中的 zcode-pro 命令 ——
30
30
 
31
31
  function commandInPath(plat) {
32
- const pathSep = plat === 'win32' ? ';' : ':';
32
+ // process.env.PATH 是宿主机的环境变量,分隔符跟着宿主机走(Linux/':'、Windows/';'),
33
+ // 只有“找哪个文件名”跟目标平台走。按目标平台的分隔符切宿主机的 PATH,
34
+ // Windows 上模拟 Linux 流程时会被盘符里的冒号切碎(C:\… 切成 'C' 和 '\…')
35
+ const pathSep = delimiter;
33
36
  // Windows 上 npm 会生成 zcode-pro.cmd / zcode-pro.ps1,pip 生成 zcode-pro.exe,
34
37
  // 只有 .cmd / .exe 能被 wscript 的 sh.Run 直接运行
35
38
  const names = plat === 'win32' ? ['zcode-pro.cmd', 'zcode-pro.exe'] : ['zcode-pro'];
@@ -100,11 +103,22 @@ function windowsPaths() {
100
103
  }
101
104
 
102
105
  // 经 Base64(UTF-16LE) 的 -EncodedCommand 执行 PowerShell:中文不经过命令行与
103
- // 文件编码,任何系统代码页下都安全。返回 stdout;非零退出码抛错
104
- function runPowerShell(script) {
106
+ // 文件编码,任何系统代码页下都安全。返回 stdout;非零退出码抛错,报错附上
107
+ // stdout/stderr——PowerShell 的错误记录会序列化成 CLIXML 走这两路输出,
108
+ // 丢掉它们就只剩一个退出码,排查无从下手(导出仅供测试)
109
+ export function runPowerShell(script) {
105
110
  const b64 = Buffer.from(script, 'utf16le').toString('base64');
106
- return execFileSync('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', b64],
107
- { stdio: ['ignore', 'pipe', 'ignore'], encoding: 'utf8' });
111
+ try {
112
+ return execFileSync('powershell', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', b64],
113
+ { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' });
114
+ } catch (err) {
115
+ const tail = (t) => (t.length > 2000 ? t.slice(0, 2000) + '…' : t);
116
+ const out = String(err.stdout || '').trim();
117
+ const errOut = String(err.stderr || '').trim();
118
+ throw new Error(String(err.message || err)
119
+ + (out ? `\nstdout: ${tail(out)}` : '')
120
+ + (errOut ? `\nstderr: ${tail(errOut)}` : ''));
121
+ }
108
122
  }
109
123
 
110
124
  // WSH 是否可用:复现 vbs 的启动调用(WScript.Shell.Run 隐藏窗口执行)。
@@ -212,7 +226,10 @@ export function windowsShortcutPlan(cmd, desktop = false, wshOk = true, menuLnk
212
226
  '$lnk.Save()',
213
227
  ] : []),
214
228
  ...(desktop ? [
215
- "$desk = Join-Path ([Environment]::GetFolderPath('Desktop')) 'ZCode Pro.lnk'",
229
+ "$deskBase = [Environment]::GetFolderPath('Desktop')",
230
+ "# 桌面目录解析不出来(目录不存在等)时不能把快捷方式写进工作目录:跳过桌面快捷方式",
231
+ "if (-not $deskBase) { Write-Output 'DESKTOP_UNRESOLVED'; exit 0 }",
232
+ "$desk = Join-Path $deskBase 'ZCode Pro.lnk'",
216
233
  '$dl = $wsh.CreateShortcut($desk)',
217
234
  '# 已存在且非本功能创建(Arguments 无归属标记)时不覆盖',
218
235
  `if (-not (Test-Path $desk) -or (${ownsExpr('$dl')})) {`,
@@ -391,7 +408,7 @@ const shortcutItem = {
391
408
  mkdirSync(plan.vbsDir, { recursive: true });
392
409
  writeFileSync(plan.vbsPath, plan.vbsContent);
393
410
  }
394
- runPowerShell(plan.psScript);
411
+ const psOut = runPowerShell(plan.psScript);
395
412
  const how = wshOk
396
413
  ? `silent launch via ${plan.vbsPath}`
397
414
  : 'WSH unavailable on this machine; minimized cmd launch (console flashes briefly on start)';
@@ -399,7 +416,11 @@ const shortcutItem = {
399
416
  parts.push(menuForeign
400
417
  ? `start menu ${plan.lnkPath} exists (created elsewhere), not overwritten`
401
418
  : `created ${plan.lnkPath}`);
402
- if (opts.desktop) parts.push(deskForeign ? `desktop ${deskPath} exists (created elsewhere), not overwritten` : 'desktop shortcut created');
419
+ if (opts.desktop) parts.push(deskForeign
420
+ ? `desktop ${deskPath} exists (created elsewhere), not overwritten`
421
+ : String(psOut).includes('DESKTOP_UNRESOLVED')
422
+ ? 'desktop skipped (desktop folder not resolvable)'
423
+ : 'desktop shortcut created');
403
424
  return { detail: `${parts.join('; ')} (${how})` };
404
425
  },
405
426
 
@@ -496,11 +517,15 @@ const shortcutItem = {
496
517
  '$wsh = New-Object -ComObject WScript.Shell',
497
518
  `$lnk = $wsh.CreateShortcut('${psQuote(paths.lnkPath)}')`,
498
519
  `if (${ownsExpr('$lnk')}) { Remove-Item -LiteralPath '${psQuote(paths.lnkPath)}' -Force }`,
499
- // setup --desktop 建的桌面 .lnk 一并清理(归属校验同开始菜单)
500
- "$desk = Join-Path ([Environment]::GetFolderPath('Desktop')) 'ZCode Pro.lnk'",
501
- 'if (Test-Path $desk) {',
502
- ' $dl = $wsh.CreateShortcut($desk)',
503
- ` if (${ownsExpr('$dl')}) { Remove-Item -LiteralPath $desk -Force }`,
520
+ // setup --desktop 建的桌面 .lnk 一并清理(归属校验同开始菜单)。
521
+ // 桌面目录解析不出来时跳过这一段,不能让整个卸载脚本报错(.lnk 会被误留)
522
+ "$deskBase = [Environment]::GetFolderPath('Desktop')",
523
+ 'if ($deskBase) {',
524
+ " $desk = Join-Path $deskBase 'ZCode Pro.lnk'",
525
+ ' if (Test-Path $desk) {',
526
+ ' $dl = $wsh.CreateShortcut($desk)',
527
+ ` if (${ownsExpr('$dl')}) { Remove-Item -LiteralPath $desk -Force }`,
528
+ ' }',
504
529
  '}',
505
530
  ].join('\r\n'));
506
531
  verified = true;
@@ -593,7 +593,7 @@ export async function listSessionTurnUsage(dataRoot, sessionId) {
593
593
  + ` input_tokens, output_tokens, reasoning_tokens, cache_read_input_tokens, cache_creation_input_tokens, computed_total_tokens`
594
594
  + ` FROM turn_usage WHERE session_id = ${esc(sid)} AND status = 'completed' AND completed_at IS NOT NULL`
595
595
  + ` AND (coalesce(input_tokens, 0) + coalesce(output_tokens, 0)) > 0 ORDER BY started_at ASC`;
596
- const useSql = `SELECT completed_at, duration_ms, time_to_first_token_ms, input_tokens, output_tokens, cache_read_input_tokens`
596
+ const useSql = `SELECT completed_at, duration_ms, time_to_first_token_ms, input_tokens, output_tokens, reasoning_tokens, cache_read_input_tokens`
597
597
  + ` FROM model_usage WHERE session_id = ${esc(sid)} AND query_source = 'main_turn'`
598
598
  + ` AND status = 'completed' AND completed_at IS NOT NULL ORDER BY completed_at ASC`;
599
599
  try {
@@ -617,7 +617,7 @@ export async function listSessionTurnUsage(dataRoot, sessionId) {
617
617
  usages = JSON.parse(runCli(dbFile,
618
618
  `SELECT coalesce(json_group_array(json_object('completed_at', completed_at, 'duration_ms', duration_ms,`
619
619
  + ` 'time_to_first_token_ms', time_to_first_token_ms, 'input_tokens', input_tokens, 'output_tokens', output_tokens,`
620
- + ` 'cache_read_input_tokens', cache_read_input_tokens)), '[]') FROM (${useSql});`
620
+ + ` 'reasoning_tokens', reasoning_tokens, 'cache_read_input_tokens', cache_read_input_tokens)), '[]') FROM (${useSql});`
621
621
  ).stdout.trim() || '[]');
622
622
  }
623
623
  if (!turns.length) return null;
@@ -641,6 +641,9 @@ export async function listSessionTurnUsage(dataRoot, sessionId) {
641
641
  out: num(t.output_tokens),
642
642
  total: num(t.computed_total_tokens),
643
643
  reasoning: num(t.reasoning_tokens),
644
+ // 首 token 延迟:一轮取首个请求的值(turn_usage 自己记的就是首请求时机),
645
+ // 缺失记 0,注入侧据此隐藏该段
646
+ ttft: num(t.time_to_first_token_ms),
644
647
  cacheRead,
645
648
  cacheWrite: num(t.cache_creation_input_tokens),
646
649
  hitRate: inp > 0 ? cacheRead / inp : null,
@@ -681,6 +684,8 @@ export async function listSessionTurnUsage(dataRoot, sessionId) {
681
684
  at,
682
685
  in: num(u.input_tokens),
683
686
  out: num(u.output_tokens),
687
+ reasoning: num(u.reasoning_tokens),
688
+ ttft: num(u.time_to_first_token_ms),
684
689
  cacheRead: num(u.cache_read_input_tokens),
685
690
  genMs: genMs || 0,
686
691
  tpsOut: genMs ? num(u.output_tokens) : 0,
@@ -6,8 +6,9 @@
6
6
  // 2. 已装插件的清单(插件缓存里的 .mcp.json 与 .zcode-plugin/plugin.json);
7
7
  // 3. ZCode 安装目录的源包清单(packages/<插件>/.mcp.json 等,插件安装时从这里生成缓存)。
8
8
  // ZCode 升级、插件更新会把键名改回长名,所以 helper 每次启动都对一次;设置页按钮可手动跑。
9
- import { copyFileSync, existsSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
10
- import { join } from 'node:path';
9
+ import { createHash } from 'node:crypto';
10
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
11
+ import { basename, join } from 'node:path';
11
12
 
12
13
  function readJson(file) {
13
14
  try {
@@ -18,12 +19,32 @@ function readJson(file) {
18
19
  }
19
20
  }
20
21
 
21
- // 原子写 + 覆盖前留 .zcodepro-backup(与同步导入、headroom 开关同款做法)
22
- function writeJsonWithBackup(file, obj) {
23
- try { copyFileSync(file, file + '.zcodepro-backup'); } catch { /* 备份失败不阻塞 */ }
24
- const tmp = `${file}.${process.pid}.${Date.now().toString(36)}.tmp`; // 防多写者共用同一 .tmp 撕裂
25
- writeFileSync(tmp, JSON.stringify(obj, null, 2) + '\n', { encoding: 'utf8', mode: 0o600 });
26
- renameSync(tmp, file);
22
+ // 写 JSON:覆盖前留备份,再“临时文件 + 改名”原子写。临时文件建不出来时
23
+ //(EACCES/EPERM:目录属于 root、建不了新文件——ZCode 自带插件在 /opt 下就是这种,
24
+ // 但文件本身往往开放写)改成直接覆盖写目标文件;直接写也不行(文件本身只读)才抛错,
25
+ // 由调用方记成“写不了的文件”。直接覆盖写不保证原子(崩溃可能留半截文件),所以备份
26
+ // 先留住:同目录建不了(同样因为目录只读)就写到数据根的 tool-name-backups/ 下
27
+ function writeJsonWithBackup(file, obj, dataRoot) {
28
+ const text = JSON.stringify(obj, null, 2) + '\n';
29
+ let backed = false;
30
+ try { copyFileSync(file, file + '.zcodepro-backup'); backed = true; } catch { /* 同目录建不了备份:换地方 */ }
31
+ if (!backed && dataRoot) {
32
+ try {
33
+ const dir = join(dataRoot, 'tool-name-backups');
34
+ mkdirSync(dir, { recursive: true });
35
+ copyFileSync(file, join(dir, `${createHash('sha1').update(file).digest('hex').slice(0, 8)}-${basename(file)}`));
36
+ } catch { /* 两处都留不下备份不阻塞:改写内容可由映射表反推 */ }
37
+ }
38
+ try {
39
+ const tmp = `${file}.${process.pid}.${Date.now().toString(36)}.tmp`; // 防多写者共用同一 .tmp 撕裂
40
+ writeFileSync(tmp, text, { encoding: 'utf8', mode: 0o600 });
41
+ renameSync(tmp, file);
42
+ return;
43
+ } catch (err) {
44
+ // 目录不可写导致临时文件建不出来才走直接写;其他错误(磁盘满等)直接抛
45
+ if (!err || !['EACCES', 'EPERM'].includes(err.code)) throw err;
46
+ }
47
+ writeFileSync(file, text, { encoding: 'utf8' }); // 目标文件本身开放写(如 666)时能写成功
27
48
  }
28
49
 
29
50
  // 把 servers 表里的长键名换成短名:目标短名已被占用就不动(不覆盖别人的服务器),
@@ -72,12 +93,15 @@ function collectManifestFiles({ dataRoot, sourcePackagesDir }) {
72
93
  return files.filter((f) => existsSync(f));
73
94
  }
74
95
 
75
- // 跑一轮检查:返回 { scanned, changed: [文件 + from/to], warnings }。
96
+ // 跑一轮检查:返回 { scanned, changed: [文件 + from/to], warnings, unwritable }。
97
+ // unwritable 是想改但写不进去的文件(典型:ZCode 自带插件在安装目录下,目录属于 root):
98
+ // 跳过它继续处理别的文件,由调用方决定怎么提示。
76
99
  // dryRun=true 只看不改(设置页“检查”用)。
77
100
  export function applyToolNameMaps({ dataRoot, zcodeConfigFile, maps, sourcePackagesDir = '', dryRun = false } = {}) {
78
101
  const scanned = [];
79
102
  const changed = [];
80
103
  const warnings = [];
104
+ const unwritable = [];
81
105
  const table = (maps && typeof maps === 'object' && !Array.isArray(maps)) ? maps : {};
82
106
  // 映射为空也照样扫一遍:报告“扫了 N 个文件、无需改动”,而不是给个 0 让用户以为没查到
83
107
  if (!Object.keys(table).length) warnings.push('没有配置工具名映射,只扫描未改动');
@@ -97,7 +121,10 @@ export function applyToolNameMaps({ dataRoot, zcodeConfigFile, maps, sourcePacka
97
121
  if (!dryRun) {
98
122
  mcp.servers = servers;
99
123
  cfg.mcp = mcp;
100
- try { writeJsonWithBackup(zcodeConfigFile, cfg); } catch (err) { warnings.push(`${zcodeConfigFile} 写入失败(${err?.message || err})`); }
124
+ try { writeJsonWithBackup(zcodeConfigFile, cfg, dataRoot); } catch (err) {
125
+ warnings.push(`${zcodeConfigFile} 写入失败(${err?.message || err})`);
126
+ unwritable.push({ file: zcodeConfigFile, error: String(err?.message || err), renames: hits });
127
+ }
101
128
  }
102
129
  for (const h of hits) changed.push({ file: zcodeConfigFile, ...h });
103
130
  }
@@ -116,11 +143,15 @@ export function applyToolNameMaps({ dataRoot, zcodeConfigFile, maps, sourcePacka
116
143
  if (!hits.length) continue;
117
144
  if (!dryRun) {
118
145
  doc.mcpServers = servers;
119
- try { writeJsonWithBackup(file, doc); } catch (err) { warnings.push(`${file} 写入失败(${err?.message || err})`); continue; }
146
+ try { writeJsonWithBackup(file, doc, dataRoot); } catch (err) {
147
+ warnings.push(`${file} 写入失败(${err?.message || err})`);
148
+ unwritable.push({ file, error: String(err?.message || err), renames: hits });
149
+ continue;
150
+ }
120
151
  }
121
152
  for (const h of hits) changed.push({ file, ...h });
122
153
  }
123
- return { scanned: scanned.length, changed, warnings };
154
+ return { scanned: scanned.length, changed, warnings, unwritable };
124
155
  }
125
156
 
126
157
  // 一行结果文案(设置页按钮下方显示)
@@ -325,7 +325,7 @@ function openaiUrl(baseUrl) {
325
325
  // - anthropic 协议:换算成思考预算(max_tokens 必须大于预算)
326
326
  // - 智谱 openai 兼容端点:只认思考开/关,任何非 off 档位都发 enabled
327
327
  // - 其他 openai 兼容端点:原样发 reasoning_effort(low/high/max 等由厂商定义)
328
- function applyThinking(body, format, baseUrl, level) {
328
+ export function applyThinking(body, format, baseUrl, level) {
329
329
  const isBigmodel = /bigmodel\.cn/.test(baseUrl);
330
330
  const off = !level || level === 'off';
331
331
  if (off) {
@@ -82,6 +82,8 @@ export const DEFAULT_TURN_ITEMS = [
82
82
  { id: 'turnOut', on: true }, // 输出
83
83
  { id: 'turnTps', on: true }, // TPS(输出 ÷ 净生成秒数,官方口径)
84
84
  { id: 'turnCache', on: true }, // 缓存命中率
85
+ { id: 'turnTtft', on: true }, // 首 token 延迟(本轮首个请求)
86
+ { id: 'turnReasoning', on: true }, // 思考 token(含在输出里)
85
87
  ];
86
88
 
87
89
  export const DEFAULT_STATUS_ITEMS = [
@@ -139,7 +141,7 @@ const zh = {
139
141
  tabProxy: '代理',
140
142
  tabBehavior: '行为',
141
143
  tabAgents: '全局提示词',
142
- tabZcode: 'ZCode CLI',
144
+ tabZcode: '运行时',
143
145
  zcodeDesc: 'ZCode 自身的行为配置(写入 ~/.zcode/cli/config.json),保存后对新会话生效。',
144
146
  zcodeStatsTitle: '技能清单检查',
145
147
  zcodeStatsCounts: '技能 {total} 个(本地 {user} · 插件 {plugin})',
@@ -177,6 +179,18 @@ const zh = {
177
179
  agentsSave: '保存',
178
180
  agentsSaved: '全局提示词已保存',
179
181
  agentsLoadFailed: '读取全局提示词失败',
182
+ injectTitle: '提示词注入',
183
+ injectDesc: '转发请求时把下面这段文字追加到系统提示词末尾,每一轮对话都带着它。与上面的全局提示词不同,它进的是系统层而不是对话层。只对开启了本机转发的供应商生效;开启注入时会自动为已启用的供应商打开转发。',
184
+ injectPlaceholder: '填写希望模型每一轮都遵守的规则;清空并保存即停止注入',
185
+ injectEnable: '启用注入',
186
+ injectDisable: '停用注入',
187
+ injectSaved: '提示词注入已保存',
188
+ injectChars: '{n} 字符',
189
+ injectLongHint: '内容较长,会明显占用对话上下文',
190
+ injectSubagents: '也注入子代理',
191
+ // 接在 injectChainHint 后面的三种状态,句读包含在文案里,拼起来是一句完整的话
192
+ injectChainStatus: ',已生效 {active}/{providers} 个供应商',
193
+ injectChainNone: ',没有已启用的供应商',
180
194
  proxyDesc: '为 ZCode Pro 本地助手发起的网络访问设置 HTTP 代理:插件市场的更新与安装、插件依赖软件的安装与升级、WebDAV 同步都可走该代理,用下方开关选择生效范围。不影响 ZCode 应用本身与模型请求。',
181
195
  proxyPlaceholder: 'http://127.0.0.1:7890',
182
196
  proxySave: '保存',
@@ -193,9 +207,84 @@ const zh = {
193
207
  proxyScopeSync: '同步',
194
208
  proxyScopeSyncDesc: 'WebDAV 上传与下载走代理。',
195
209
  proxySubSoftware: '软件代理',
196
- proxySubVendor: '供应商代理',
197
- proxyVendorDesc: '按供应商单独设置:打开后该供应商的模型请求先到本机转发端口,再经指定代理发出;关闭时保持原地址直连。不改 ZCode 全局代理,也不影响其他供应商。代理地址留空 = 跟随全局代理。',
210
+ proxySubVendor: '代理链',
211
+ proxyVendorDesc: '按供应商单独设置:打开后该供应商的模型请求先到本机转发端口,再按卡片里的代理链逐级发出;关闭时保持原地址直连。不改 ZCode 全局代理,也不影响其他供应商。',
198
212
  proxyVendorEmpty: '还没有添加供应商代理。点下方“添加供应商”选择要走代理的供应商,添加后才会生效。',
213
+ proxySharedTitle: '共享代理',
214
+ proxySharedDesc: '在这里定义几个常用代理,下面每个供应商的代理链里可以直接选用。改这里的地址会连带影响所有引用它的供应商。',
215
+ proxySharedEmpty: '还没有共享代理。',
216
+ proxySharedAdd: '添加共享代理',
217
+ proxySharedDelete: '删除',
218
+ proxySharedName: '名称',
219
+ proxySharedInvalid: '代理地址需形如 http://127.0.0.1:7890',
220
+ chainDesc: '代理链按节点顺序处理请求:headroom 压缩 → 提示词注入 → 自定义代理出网。一条链可关联多个供应商,共用一份配置和一个转发器。出网代理(如 clash)建议放链的最后:普通代理通常不转发本机端口,放在 headroom 之前会失败。',
221
+ chainMasterSwitch: '代理链总开关',
222
+ chainMasterSwitchDesc: '关:一键还原。链配置保留,所有勾选供应商的地址还原为真实上游、停止转发。开:勾选的供应商由链接管地址。',
223
+ chainMasterOffHint: '总开关已关闭:链配置保留,勾选的供应商都已还原为直连。',
224
+ chainGoCompat: 'OpenCode Go 兼容',
225
+ chainGoCompatDesc: '供应商走链时,发往 OpenCode Go 端点的请求由 zcode-pro 补上会话请求头。关掉后 OpenCode Go 套餐的供应商经链会被拒绝,只能直连。',
226
+ chainDeleteConfirmTitle: '删除这条链?',
227
+ chainDeleteConfirmDesc: '链上勾选的 {n} 家供应商会还原成直连,并退出 headroom 压缩。',
228
+ chainDeleteConfirmDescEmpty: '这条链上没有勾选的供应商。',
229
+ chainDeleteConfirmGo: '删除',
230
+ injectGoChain: '去代理链勾选',
231
+ injectChainHint: '只对在“代理 → 代理链”里勾选的供应商生效',
232
+ chainProvidersHint: '勾选=经过 zcode-pro(压缩、注入、代理),地址由链管理;取消勾选=还原为直连并保持。',
233
+ chainManualEditHint: '地址被改成别的值(在 ZCode 里手动改的,或从别的设备同步来的)会自动退出链、保持改后的地址,右下角有提示。',
234
+ noticeAutoUncheckedTitle: '有供应商自动退出了代理链',
235
+ noticeAutoUncheckedDesc: '这些供应商勾选在链上,但地址变了(在 ZCode 里手动改的,或从别的设备同步来的)。已自动退出链,不再经过压缩和提示词注入:',
236
+ noticeAutoUncheckedItem: '{name} → {url}(原在“{chain}”链)',
237
+ noticeAutoUncheckedHow: '想让它们重新经过压缩和提示词注入,到“设置 → 代理 → 代理链”重新勾选。',
238
+ noticeGoChain: '去代理链',
239
+ // 巡检发现问题时的右下角卡片(转发器不在监听 / 走链的 headroom 实例不在监听)
240
+ noticeHealthTitle: '代理链巡检发现异常',
241
+ noticeHealthDesc: '每 30 秒一次的巡检发现问题,已经自动处理:',
242
+ noticeHealthForwarder: '转发器 127.0.0.1:{ports} 不在监听,已重新对齐',
243
+ noticeHealthForwarderDown: ',仍未恢复',
244
+ noticeHealthInstance: 'Headroom 压缩实例 127.0.0.1:{ports} 不在监听,已让 headroom 补起',
245
+ noticeHealthRouter: 'Headroom 压缩路由 127.0.0.1:{ports} 不在监听,已让 headroom 重启',
246
+ noticeHealthInstanceFailed: ',处理失败:{error}',
247
+ noticeHealthHint: '压缩实例补起来要十几秒,这期间经过压缩路由的请求可能失败,稍后重试即可。',
248
+ noticeHealthGoHeadroom: '去 Headroom 页',
249
+ // 任务名生成失败的右下角卡片(title-gen-notice.json)
250
+ noticeTitleGenTitle: '任务名生成失败',
251
+ noticeTitleGenDesc: '新会话开始时让模型起名字,这次没有成功,会话名还是 ZCode 默认的名字。',
252
+ noticeTitleGenItem: '{provider} 的 {model}:{error}',
253
+ noticeTitleGenSession: '会话用的供应商',
254
+ noticeTitleGenHow: '到“设置 → 全局提示词 → 自动重命名”换一个接口支持的供应商或模型。',
255
+ noticeTitleGenGo: '去自动重命名设置',
256
+ // 工具名检查有文件改不了的右下角卡片(tool-name-notice.json)
257
+ noticeToolNameTitle: '工具名合规检查:有文件改不了',
258
+ noticeToolNameDesc: '这些文件里的服务器名没能改短,其他文件照常处理:',
259
+ noticeToolNameItem: '{file}(想把 {changes} 改短):{error}',
260
+ noticeToolNameNoPerm: '没有写入权限',
261
+ noticeToolNameFix: '文件只读(在系统安装目录里,多属于 root)。把下面这行复制到终端运行,加上写权限:',
262
+ noticeToolNameFixNoCmd: '文件只读(在系统安装目录里)。用管理员权限给这些文件加上写权限,每次启动都会再试一次。',
263
+ noticeToolNameAfter: '加上权限后每次启动都会自动改短;ZCode 更新若把权限改回,重复运行这行即可。',
264
+ noticeToolNameGo: '去运行时设置',
265
+ chainAutoUnchecked: '地址被手动改过,已自动退出链:{list}',
266
+ chainEmpty: '还没有代理链。点下方“新建代理链”开始,默认带提示词注入节点(装了 headroom 插件还带压缩节点)。',
267
+ chainAdd: '新建代理链',
268
+ chainDefaultName: '新代理链',
269
+ chainNodePinned: '这一节由链上顺序决定,用上下箭头调整',
270
+ chainSwitchHint: '关掉后整条链不生效',
271
+ chainProvidersLabel: '关联的供应商',
272
+ chainNoProviders: '供应商列表还没加载出来',
273
+ chainOwnedByOther: '已关联到别的链',
274
+ chainForwardPort: '转发端口',
275
+ proxyChainInjection: '提示词注入',
276
+ proxyChainUpstream: '上游',
277
+ proxyChainCustom: '自定义',
278
+ proxyChainUseShared: '用共享',
279
+ proxyChainAddNode: '添加代理',
280
+ proxyChainOnChain: '在链上',
281
+ proxyChainNotInstalled: '未启用',
282
+ proxyChainPinnedHint: '这一环由对应功能决定,在代理页改不了',
283
+ proxyChainSwitchHint: '关掉后整条代理链不生效',
284
+ proxyChainHeadroomBlocksProxy: 'headroom 在链上时,自定义代理暂不生效(请求由 headroom 直接发往上游)',
285
+ proxyChainMultiNotEffective: '第 2 个起暂不生效(多级代理尚未支持)',
286
+ proxyChainUpstreamViaHeadroom: '由 headroom 决定',
287
+ proxyChainSharedGone: '引用的共享代理已被删除',
199
288
  proxyVendorAdd: '添加供应商',
200
289
  proxyVendorRemove: '删除',
201
290
  proxyVendorUseGlobal: '跟随全局代理',
@@ -530,6 +619,8 @@ const zh = {
530
619
  sbLabelOut: '输出',
531
620
  sbLabelCache: '缓存',
532
621
  sbLabelTps: '输出 tok/s',
622
+ sbLabelTtft: '首字',
623
+ sbLabelReasoning: '思考',
533
624
  sbLabelInOut: '输入/输出',
534
625
  sbLabelHit: '平均命中',
535
626
  turnUsageTitle: '本轮 token',
@@ -537,6 +628,8 @@ const zh = {
537
628
  sbItemTodayTokens: '今日 token',
538
629
  sbItemTasks: '任务总数',
539
630
  sbLabelCtx: '上下文',
631
+ sbTipTools: '工具定义',
632
+ sbTipToolCount: ' 个工具',
540
633
  sbLabelTurns: '调用',
541
634
  sbLabelToday: '今日',
542
635
  sbLabelTasks: '任务',
@@ -690,13 +783,15 @@ const zh = {
690
783
  acEnabled: '启用',
691
784
  acPrompt: '继续提示词',
692
785
  acMaxRetries: '最多继续次数',
693
- acMaxRetriesHint: '30 分钟内自动继续的累计上限,防止故障反复时刷屏',
694
- acCooldown: '密集失败退避基数(秒)',
695
- acCooldownHint: '2 分钟内已继续过就视为密集失败,间隔按 2 倍递增、上限 60 秒;单次失败只等 3 秒界面稳定',
696
- acStuckAfterMin: '卡死判定(分钟)',
697
- acStuckAfterMinHint: '后台终端任务、子代理或主回合多久没有动静才弹卡提示;会话本身也要静默同样久',
698
- acFailedAfterMin: '失败后自动续接(分钟)',
699
- acFailedAfterMinHint: '回合失败多久后自动继续;会先等 60 秒跳过失败后的清理事件',
786
+ acMaxRetriesHint: '30 分钟内最多自动继续几次,到上限就停',
787
+ acContinueDelay: '继续前等待(秒)',
788
+ acContinueDelayHint: '回合失败后先等这么久再发继续,让供应商的临时故障自己过去',
789
+ acContinueDelayFactor: '连续失败翻倍倍数',
790
+ acContinueDelayFactorHint: '连续失败时等待时间按此倍数增长,如 1.3 就是 2 分钟、2.6 分钟、3.4 分钟;填 1 表示固定不增长',
791
+ acStuckAfterMin: '卡死提示(分钟)',
792
+ acStuckAfterMinHint: '后台任务、子代理或主回合静默这么久后,弹提示卡片提醒你',
793
+ acFailedAfterMin: '失败后多久自动续(分钟)',
794
+ acFailedAfterMinHint: '回合失败后,静默这么久仍没人处理就自动继续',
700
795
  acLoadFailed: '读取自动继续配置失败',
701
796
  acCardKindSubagent: '子代理卡死',
702
797
  acCardKindTurn: '主轮卡死',
@@ -792,6 +887,23 @@ const zh = {
792
887
  headroomStatusTitle: '运行状态',
793
888
  hrInstRunning: '运行中',
794
889
  hrInstStopped: '未运行',
890
+ hrInstChain: '链',
891
+ hrInstUpstreams: '上游',
892
+ hrInstVia: '出网',
893
+ hrInstProviders: '供应商',
894
+ hrInstRestore: '还原',
895
+ hrRestoreFailed: '还原失败',
896
+ hrRestoreDone: '已还原为直连',
897
+ hrRestoreHint: '还原这些供应商的 API 地址:在链上可选还原到链地址或直连(退出链)',
898
+ hrRestoreConfirmTitle: '还原地址?',
899
+ hrRestoreConfirmDesc: '将处理:{names}',
900
+ hrRestoreNext: '下一步',
901
+ hrRestoreChooseTitle: '还原到哪里?',
902
+ hrRestoreChooseDesc: '{names} 在代理链上',
903
+ hrRestoreOptChain: '还原为链地址(保留在链上)',
904
+ hrRestoreOptDirect: '直连真实地址(同时退出链)',
905
+ hrRestoreChainDone: '地址已归位到链入口',
906
+ chainLeaveHint: '退出压缩时清理 headroom 登记失败(重新勾选可恢复)',
795
907
  headroomStatusLoadFailed: '读取运行状态失败',
796
908
  headroomProxyUp: '代理运行中',
797
909
  headroomProxyDown: '代理未运行',
@@ -918,7 +1030,7 @@ const en = {
918
1030
  tabProxy: 'Proxy',
919
1031
  tabBehavior: 'Behavior',
920
1032
  tabAgents: 'Global Prompt',
921
- tabZcode: 'ZCode CLI',
1033
+ tabZcode: 'Runtime',
922
1034
  zcodeDesc: 'ZCode behavior settings (written to ~/.zcode/cli/config.json); takes effect for new sessions.',
923
1035
  zcodeStatsTitle: 'Skill listing check',
924
1036
  zcodeStatsCounts: '{total} skills ({user} local · {plugin} from plugins)',
@@ -956,6 +1068,17 @@ const en = {
956
1068
  agentsSave: 'Save',
957
1069
  agentsSaved: 'Global prompt saved.',
958
1070
  agentsLoadFailed: 'Failed to load the global prompt',
1071
+ injectTitle: 'Prompt injection',
1072
+ injectDesc: 'Appended to the end of the system prompt as requests are forwarded, so it rides along with every turn. Unlike the global prompt above, this lands in the system layer rather than the conversation layer. It only applies to providers whose requests are forwarded locally; enabling injection turns forwarding on for every enabled provider.',
1073
+ injectPlaceholder: 'Rules the model should follow on every turn; leave empty and save to stop injecting',
1074
+ injectEnable: 'Enable injection',
1075
+ injectDisable: 'Disable injection',
1076
+ injectSaved: 'Prompt injection saved.',
1077
+ injectChars: '{n} characters',
1078
+ injectLongHint: 'This is long and will take a noticeable bite out of the conversation context.',
1079
+ injectSubagents: 'Also inject into subagents',
1080
+ injectChainStatus: ', active on {active} of {providers} providers',
1081
+ injectChainNone: ', no enabled providers yet',
959
1082
  proxyDesc: 'Set an HTTP proxy for network access made by the local helper: plugin marketplace updates and installs, plugin dependency installs and upgrades, and WebDAV sync can all use it — pick the scopes with the toggles below. Does not affect the ZCode app itself or model requests.',
960
1083
  proxyPlaceholder: 'http://127.0.0.1:7890',
961
1084
  proxySave: 'Save',
@@ -972,9 +1095,81 @@ const en = {
972
1095
  proxyScopeSync: 'Sync',
973
1096
  proxyScopeSyncDesc: 'WebDAV upload and download go through the proxy.',
974
1097
  proxySubSoftware: 'Software proxy',
975
- proxySubVendor: 'Provider proxies',
976
- proxyVendorDesc: 'Per provider: when on, that provider\'s model requests hit a local forward port and leave through the chosen proxy; when off, its address stays as-is. Does not change ZCode\'s global proxy or affect other providers. Leave the proxy address empty to follow the global proxy.',
1098
+ proxySubVendor: 'Proxy chains',
1099
+ proxyVendorDesc: 'Per provider: when on, that provider\'s model requests hit a local forward port and then leave through the proxy chain shown on its card; when off, its address stays as-is. Does not change ZCode\'s global proxy or affect other providers.',
977
1100
  proxyVendorEmpty: 'No provider proxies added yet. Use “Add provider” below to pick a provider; it takes effect once added.',
1101
+ proxySharedTitle: 'Shared proxies',
1102
+ proxySharedDesc: 'Define a few proxies here, then pick them inside each provider\'s proxy chain below. Changing an address here affects every provider that references it.',
1103
+ proxySharedEmpty: 'No shared proxies yet.',
1104
+ proxySharedAdd: 'Add shared proxy',
1105
+ proxySharedDelete: 'Delete',
1106
+ proxySharedName: 'Name',
1107
+ proxySharedInvalid: 'The proxy address must look like http://127.0.0.1:7890',
1108
+ chainDesc: 'A proxy chain processes each request through its nodes in order: headroom compression, prompt injection, custom proxy for egress. One chain can be linked to several providers, which share its settings and a single forwarder. Egress proxies (e.g. clash) belong at the end of the chain: ordinary proxies usually refuse to forward to local ports, so placing one before headroom will fail.',
1109
+ chainMasterSwitch: 'Proxy chain master switch',
1110
+ chainMasterSwitchDesc: 'Off: one-click restore. Chain settings are kept; all checked providers go back to their real upstream addresses and forwarding stops. On: checked providers are managed by their chain.',
1111
+ chainMasterOffHint: 'Master switch is off: chain settings are kept and checked providers are back on direct connections.',
1112
+ chainGoCompat: 'OpenCode Go compatibility',
1113
+ chainGoCompatDesc: 'When a provider goes through a chain, zcode-pro adds the session header required by the OpenCode Go endpoint. Turn it off and OpenCode Go providers will be rejected through a chain; keep them direct instead.',
1114
+ chainDeleteConfirmTitle: 'Delete this chain?',
1115
+ chainDeleteConfirmDesc: 'The {n} checked providers will be restored to direct connections and leave headroom compression.',
1116
+ chainDeleteConfirmDescEmpty: 'No providers are checked in this chain.',
1117
+ chainDeleteConfirmGo: 'Delete',
1118
+ injectGoChain: 'Open proxy chains',
1119
+ injectChainHint: 'Only takes effect on providers checked under “Proxy → Proxy chains”',
1120
+ chainProvidersHint: 'Checked = requests go through zcode-pro (compression, injection, proxies) and the address is managed by the chain; unchecked = restored to a direct connection and kept.',
1121
+ chainManualEditHint: 'If the address changes to another value (edited in ZCode or synced from another device), the provider automatically leaves the chain and keeps the new address; a card appears in the corner.',
1122
+ noticeAutoUncheckedTitle: 'Providers left the proxy chain automatically',
1123
+ noticeAutoUncheckedDesc: 'These providers were checked in a chain, but their address changed (edited in ZCode or synced from another device). They left the chain and no longer go through compression or prompt injection:',
1124
+ noticeAutoUncheckedItem: '{name} → {url} (was in the “{chain}” chain)',
1125
+ noticeAutoUncheckedHow: 'To send them through compression and prompt injection again, check them again under “Settings → Proxy → Proxy chains”.',
1126
+ noticeGoChain: 'Open proxy chains',
1127
+ noticeHealthTitle: 'Proxy chain health check found a problem',
1128
+ noticeHealthDesc: 'The 30-second health check found a problem and handled it automatically:',
1129
+ noticeHealthForwarder: 'Forwarder 127.0.0.1:{ports} is not listening; realigned',
1130
+ noticeHealthForwarderDown: ', still down',
1131
+ noticeHealthInstance: 'Headroom instance 127.0.0.1:{ports} is not listening; asked headroom to restart it',
1132
+ noticeHealthRouter: 'The Headroom compression router 127.0.0.1:{ports} is not listening; asked headroom to restart it',
1133
+ noticeHealthInstanceFailed: ', failed: {error}',
1134
+ noticeHealthHint: 'Restarting the compression instance takes about ten seconds; requests through the compression router may fail meanwhile. Retry later.',
1135
+ noticeHealthGoHeadroom: 'Open Headroom',
1136
+ noticeTitleGenTitle: 'Task title generation failed',
1137
+ noticeTitleGenDesc: 'The model call that names a new session did not succeed, so the session keeps the default ZCode name.',
1138
+ noticeTitleGenItem: '{provider} with {model}: {error}',
1139
+ noticeTitleGenSession: 'the session provider',
1140
+ noticeTitleGenHow: 'Switch to a provider or model the endpoint supports under “Settings → Global Prompt → Auto rename”.',
1141
+ noticeTitleGenGo: 'Open auto rename settings',
1142
+ noticeToolNameTitle: 'Tool name check: some files could not be changed',
1143
+ noticeToolNameDesc: 'The server names in these files were not shortened; other files were handled as usual:',
1144
+ noticeToolNameItem: '{file} (wanted to shorten {changes}): {error}',
1145
+ noticeToolNameNoPerm: 'no write permission',
1146
+ noticeToolNameFix: 'The files are read-only (in the system install folder, usually owned by root). Copy this line into a terminal to grant write permission:',
1147
+ noticeToolNameFixNoCmd: 'The files are read-only (in the system install folder). Grant write permission to them with administrator rights; the check retries on every launch.',
1148
+ noticeToolNameAfter: 'With permission granted they are shortened automatically on every launch; if a ZCode update restores the permissions, run this line again.',
1149
+ noticeToolNameGo: 'Open runtime settings',
1150
+ chainAutoUnchecked: 'Address was changed manually; left the chain automatically: {list}',
1151
+ chainEmpty: 'No proxy chains yet. Use “New proxy chain” below; it starts with a prompt-injection node (plus a headroom node when the headroom plugin is installed).',
1152
+ chainAdd: 'New proxy chain',
1153
+ chainDefaultName: 'New chain',
1154
+ chainNodePinned: 'This hop is ordered by the chain; use the arrows to move it',
1155
+ chainSwitchHint: 'Turning this off disables the whole chain',
1156
+ chainProvidersLabel: 'Linked providers',
1157
+ chainNoProviders: 'The provider list has not loaded yet',
1158
+ chainOwnedByOther: 'Already linked to another chain',
1159
+ chainForwardPort: 'Forward port',
1160
+ proxyChainInjection: 'Prompt injection',
1161
+ proxyChainUpstream: 'Upstream',
1162
+ proxyChainCustom: 'Custom',
1163
+ proxyChainUseShared: 'Shared',
1164
+ proxyChainAddNode: 'Add proxy',
1165
+ proxyChainOnChain: 'on chain',
1166
+ proxyChainNotInstalled: 'not enabled',
1167
+ proxyChainPinnedHint: 'This hop is decided by its own feature; it cannot be changed here',
1168
+ proxyChainSwitchHint: 'Turning this off disables the whole chain',
1169
+ proxyChainHeadroomBlocksProxy: 'While headroom is on the chain, custom proxies do not take effect (headroom sends the request upstream itself)',
1170
+ proxyChainMultiNotEffective: 'Only the first proxy takes effect; chained proxies are not supported yet',
1171
+ proxyChainUpstreamViaHeadroom: 'decided by headroom',
1172
+ proxyChainSharedGone: 'The referenced shared proxy was deleted',
978
1173
  proxyVendorAdd: 'Add provider',
979
1174
  proxyVendorRemove: 'Remove',
980
1175
  proxyVendorUseGlobal: 'Follow the global proxy',
@@ -1308,6 +1503,8 @@ const en = {
1308
1503
  sbLabelOut: 'out',
1309
1504
  sbLabelCache: 'cache',
1310
1505
  sbLabelTps: 'out tok/s',
1506
+ sbLabelTtft: 'ttft',
1507
+ sbLabelReasoning: 'think',
1311
1508
  sbLabelInOut: 'in/out',
1312
1509
  sbLabelHit: 'avg hit',
1313
1510
  turnUsageTitle: 'Turn tokens',
@@ -1315,6 +1512,8 @@ const en = {
1315
1512
  sbItemTodayTokens: 'Tokens today',
1316
1513
  sbItemTasks: 'Tasks',
1317
1514
  sbLabelCtx: 'ctx',
1515
+ sbTipTools: 'tool schemas',
1516
+ sbTipToolCount: ' tools',
1318
1517
  sbLabelTurns: 'calls',
1319
1518
  sbLabelToday: 'today',
1320
1519
  sbLabelTasks: 'tasks',
@@ -1468,13 +1667,15 @@ const en = {
1468
1667
  acEnabled: 'Enable',
1469
1668
  acPrompt: 'Continue prompt',
1470
1669
  acMaxRetries: 'Max auto-continues',
1471
- acMaxRetriesHint: 'Cap on auto-continues within 30 minutes, to avoid flooding on repeated failures',
1472
- acCooldown: 'Backoff base for burst failures (s)',
1473
- acCooldownHint: 'A continue within 2 minutes counts as a burst: interval doubles up to 60s; a single failure only waits 3s for the UI to settle',
1474
- acStuckAfterMin: 'Stuck threshold (min)',
1475
- acStuckAfterMinHint: 'How long a background terminal task, subagent or main turn may stay silent before the card appears; the session itself must also be silent this long',
1670
+ acMaxRetriesHint: 'How many times auto-continue may fire within 30 minutes; stops at the cap',
1671
+ acContinueDelay: 'Wait before continue (s)',
1672
+ acContinueDelayHint: 'After a failed turn, wait this long before sending continue so transient provider errors can clear',
1673
+ acContinueDelayFactor: 'Growth factor for repeat failures',
1674
+ acContinueDelayFactorHint: 'Each consecutive failure grows the wait by this factor (1.3 → 2 min, 2.6 min, 3.4 min…); 1 = stay fixed',
1675
+ acStuckAfterMin: 'Stuck alert (min)',
1676
+ acStuckAfterMinHint: 'A background task, subagent or main turn silent this long raises the reminder card',
1476
1677
  acFailedAfterMin: 'Auto-continue after failure (min)',
1477
- acFailedAfterMinHint: 'How long after a failed turn to continue automatically; waits 60s first to skip post-failure cleanup events',
1678
+ acFailedAfterMinHint: 'Resume automatically when a failed turn has stayed silent this long',
1478
1679
  acLoadFailed: 'Failed to load the auto-continue config',
1479
1680
  acCardKindSubagent: 'Subagent stuck',
1480
1681
  acCardKindTurn: 'Main turn stuck',
@@ -1570,6 +1771,23 @@ const en = {
1570
1771
  headroomStatusTitle: 'Status',
1571
1772
  hrInstRunning: 'running',
1572
1773
  hrInstStopped: 'down',
1774
+ hrInstChain: 'chain',
1775
+ hrInstUpstreams: 'upstreams',
1776
+ hrInstVia: 'via',
1777
+ hrInstProviders: 'providers',
1778
+ hrInstRestore: 'Restore',
1779
+ hrRestoreFailed: 'Restore failed',
1780
+ hrRestoreDone: 'Restored to direct',
1781
+ hrRestoreHint: 'Restore these providers API address: on chains choose chain entry or direct (leaving chains)',
1782
+ hrRestoreConfirmTitle: 'Restore address?',
1783
+ hrRestoreConfirmDesc: 'Providers: {names}',
1784
+ hrRestoreNext: 'Next',
1785
+ hrRestoreChooseTitle: 'Restore to where?',
1786
+ hrRestoreChooseDesc: '{names} are on proxy chains',
1787
+ hrRestoreOptChain: 'Chain address (stay on chains)',
1788
+ hrRestoreOptDirect: 'Direct to real upstream (leave chains)',
1789
+ hrRestoreChainDone: 'Address restored to chain entry',
1790
+ chainLeaveHint: 'Failed to clean headroom registry on leaving (re-check to restore)',
1573
1791
  headroomStatusLoadFailed: 'Failed to load the status',
1574
1792
  headroomProxyUp: 'Proxy running',
1575
1793
  headroomProxyDown: 'Proxy down',
@@ -1806,6 +2024,9 @@ const errEn = {
1806
2024
  'translate-empty': 'The translation model returned no text',
1807
2025
  'proxy-invalid': 'The proxy must be a URL like http://127.0.0.1:7890, or be empty',
1808
2026
  'provider-proxy-invalid': 'Provider proxy setting is invalid: the proxy must be a URL like http://127.0.0.1:7890 (or empty to follow the global proxy)',
2027
+ 'shared-proxy-invalid': 'Shared proxies contain an invalid entry: name cannot be empty, the address must be a URL like http://127.0.0.1:7890, and ids must be unique',
2028
+ 'proxy-chain-invalid': 'A proxy chain entry is invalid: each chain needs an id, nodes must be headroom / inject / custom proxy, and a custom proxy address must be a URL like http://127.0.0.1:7890',
2029
+ 'headroom-restore': 'Failed to restore providers from the chain (check headroom.json)',
1809
2030
  'headroom-proxy-invalid': 'The headroom upstream proxy must be a URL like http://127.0.0.1:7890, or be empty',
1810
2031
  'tool-name-check': 'Tool name compliance check failed',
1811
2032
  'proxy-not-set': 'Set the proxy address first',