zcode-app-cli 3.18.1-46 → 3.18.2-47
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/bin/zcode.js +101 -1
- package/docs/CONFIGURATION.md +17 -4
- package/docs/CONFIGURATION.zh-CN.md +12 -3
- package/docs/HEADLESS.md +25 -0
- package/docs/HOST_INTEGRATION.md +10 -4
- package/package.json +2 -2
- package/vendor/cli-config.cjs +170 -1
- package/vendor/extraction.json +9 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +250 -21
- package/vendor/packages/node-repl-host/dist/build-identity.json +1 -1
- package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
- package/vendor/zcode.cjs +1021 -1022
- package/zcode-runtime.lock.json +3 -3
package/bin/zcode.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFile, spawn } from "node:child_process";
|
|
3
|
-
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { appendFileSync, chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeSync } from "node:fs";
|
|
4
4
|
import { constants, homedir } from "node:os";
|
|
5
5
|
import { basename, dirname, join, posix, resolve, win32 } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -8,6 +8,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
8
8
|
import { access, link, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
9
9
|
import { parseArgs, promisify } from "node:util";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
+
import { isatty } from "node:tty";
|
|
11
12
|
import { StringDecoder } from "node:string_decoder";
|
|
12
13
|
import { createInterface } from "node:readline/promises";
|
|
13
14
|
//#region setting.example.json
|
|
@@ -356,6 +357,105 @@ async function clearSetupPending(env = process.env) {
|
|
|
356
357
|
promisify(execFile);
|
|
357
358
|
new AsyncLocalStorage();
|
|
358
359
|
//#endregion
|
|
360
|
+
//#region src/runtime-keychain-recovery.ts
|
|
361
|
+
function recoveryError(message, cause) {
|
|
362
|
+
return Object.assign(new Error(message, { cause }), { code: "CREDENTIAL_SECURE_STORAGE_UNAVAILABLE" });
|
|
363
|
+
}
|
|
364
|
+
function interactionRequired(error) {
|
|
365
|
+
return error instanceof Error && /user interaction is not allowed|interaction (?:is )?not allowed|keychain (?:is )?locked|errSecInteractionNotAllowed|(?:^|\D)-25308(?:\D|$)/iu.test(error.message);
|
|
366
|
+
}
|
|
367
|
+
async function unlockKeychainInTerminal() {
|
|
368
|
+
if (process.stdin.isRaw) throw recoveryError("The keychain needs unlocking. Unlock it with security unlock-keychain in another terminal, then retry the operation in this session.");
|
|
369
|
+
let terminal;
|
|
370
|
+
try {
|
|
371
|
+
terminal = openSync("/dev/tty", "r+");
|
|
372
|
+
} catch (cause) {
|
|
373
|
+
throw recoveryError("The keychain needs unlocking, but no controlling terminal is available. Run security unlock-keychain in an interactive SSH session or configure a managed credential secret.", cause);
|
|
374
|
+
}
|
|
375
|
+
const wasFlowing = process.stdin.isTTY && process.stdin.readableFlowing === true;
|
|
376
|
+
try {
|
|
377
|
+
if (!isatty(terminal)) throw recoveryError("Keychain unlock requires a controlling terminal.");
|
|
378
|
+
if (wasFlowing) process.stdin.pause();
|
|
379
|
+
writeSync(terminal, "\nThe macOS keychain needs unlocking to continue. Enter its password below (Ctrl-C to cancel).\n");
|
|
380
|
+
await new Promise((resolve, reject) => {
|
|
381
|
+
const child = spawn("/usr/bin/security", ["unlock-keychain"], { stdio: [
|
|
382
|
+
terminal,
|
|
383
|
+
terminal,
|
|
384
|
+
terminal
|
|
385
|
+
] });
|
|
386
|
+
const handlers = [
|
|
387
|
+
"SIGINT",
|
|
388
|
+
"SIGTERM",
|
|
389
|
+
"SIGHUP"
|
|
390
|
+
].map((signal) => {
|
|
391
|
+
const hadListeners = process.listenerCount(signal) > 0;
|
|
392
|
+
const forward = () => {
|
|
393
|
+
child.kill(signal);
|
|
394
|
+
if (!hadListeners) {
|
|
395
|
+
process.off(signal, forward);
|
|
396
|
+
process.kill(process.pid, signal);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
process.prependListener(signal, forward);
|
|
400
|
+
return {
|
|
401
|
+
signal,
|
|
402
|
+
forward
|
|
403
|
+
};
|
|
404
|
+
});
|
|
405
|
+
const cleanup = () => {
|
|
406
|
+
for (const { signal, forward } of handlers) process.off(signal, forward);
|
|
407
|
+
};
|
|
408
|
+
child.once("error", (cause) => {
|
|
409
|
+
cleanup();
|
|
410
|
+
reject(recoveryError("Could not start the system keychain unlock tool.", cause));
|
|
411
|
+
});
|
|
412
|
+
child.once("close", (code, signal) => {
|
|
413
|
+
cleanup();
|
|
414
|
+
if (code === 0) resolve();
|
|
415
|
+
else reject(recoveryError(signal ? `Keychain unlock was cancelled (${signal}); no credentials were changed.` : "Keychain unlock failed; no credentials were changed. Retry the operation to try again."));
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
writeSync(terminal, "Keychain unlocked; continuing the pending credential operation.\n");
|
|
419
|
+
} finally {
|
|
420
|
+
closeSync(terminal);
|
|
421
|
+
if (wasFlowing) process.stdin.resume();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function createKeychainRecovery(options = {}) {
|
|
425
|
+
const platform = options.platform ?? process.platform;
|
|
426
|
+
const unlock = options.unlock ?? unlockKeychainInTerminal;
|
|
427
|
+
let pending;
|
|
428
|
+
let generation = 0;
|
|
429
|
+
let lastFailure;
|
|
430
|
+
return async (operation) => {
|
|
431
|
+
const started = generation;
|
|
432
|
+
try {
|
|
433
|
+
return await operation();
|
|
434
|
+
} catch (error) {
|
|
435
|
+
if (platform !== "darwin" || !interactionRequired(error)) throw error;
|
|
436
|
+
if (started === generation) {
|
|
437
|
+
if (!pending) pending = Promise.resolve().then(unlock).then(() => {
|
|
438
|
+
lastFailure = void 0;
|
|
439
|
+
}, (cause) => {
|
|
440
|
+
lastFailure = cause;
|
|
441
|
+
throw cause;
|
|
442
|
+
}).finally(() => {
|
|
443
|
+
generation++;
|
|
444
|
+
pending = void 0;
|
|
445
|
+
});
|
|
446
|
+
await pending;
|
|
447
|
+
} else if (lastFailure !== void 0) throw lastFailure;
|
|
448
|
+
try {
|
|
449
|
+
return await operation();
|
|
450
|
+
} catch (cause) {
|
|
451
|
+
if (interactionRequired(cause)) throw recoveryError("Keychain unlock completed, but credential access is still denied. Check the keychain item's access controls in a local macOS session.", cause);
|
|
452
|
+
throw cause;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
createKeychainRecovery();
|
|
458
|
+
//#endregion
|
|
359
459
|
//#region src/runtime-config-bridge.ts
|
|
360
460
|
function providerMigrationNeeded(env = process.env) {
|
|
361
461
|
return existsSync(legacyCliConfigPath(env)) && !existsSync(providerMigrationMarkerPath(env));
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -11,7 +11,7 @@ permissions and other general runtime settings live in the CLI's `setting.json`.
|
|
|
11
11
|
| File | Purpose |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `~/.zcode/cli/setting.json` | MCP servers, hooks, plugins, permissions, network, storage and CLI display settings |
|
|
14
|
-
| `~/.zcode/v2/setting.json` | Existing Desktop language and
|
|
14
|
+
| `~/.zcode/v2/setting.json` | Existing Desktop language, memory and reasoning-display preferences, read without modification |
|
|
15
15
|
| `~/.zcode/v2/provider_config.json` | Providers, model metadata overrides and the default model |
|
|
16
16
|
| `~/.zcode/v2/credentials.json` | Credentials persisted by the native runtime |
|
|
17
17
|
|
|
@@ -109,14 +109,18 @@ reported rather than replaced by old settings.
|
|
|
109
109
|
| `/new` | Reads the current shared default |
|
|
110
110
|
| Resume/restart | Restores the session's model and reasoning options |
|
|
111
111
|
| Language and memory | Reads Desktop `localePreference` / `memoryEnabled`; explicit CLI settings override these values |
|
|
112
|
+
| TUI reasoning text | Reads and updates Desktop `messageStreamShowReasoning` from `/settings` |
|
|
112
113
|
| Theme, terminal layout, copy-on-select and notifications | CLI `setting.json` |
|
|
113
114
|
| MCP servers | CLI `setting.json` → `mcp.servers`; [MCP precedence](#project-settings-and-plugins) applies to project and plugin servers |
|
|
114
115
|
| Tool permissions, retries, stream timeout, hooks, plugins and other runtime settings | CLI `setting.json`, with native project/environment precedence |
|
|
115
116
|
| Update cache, diagnostic logs and migration state | Operational files beneath the CLI directory |
|
|
116
117
|
|
|
117
|
-
The CLI does not add keys to Desktop's `setting.json`. Notification
|
|
118
|
-
changes write only the CLI file.
|
|
119
|
-
|
|
118
|
+
The CLI does not add CLI-specific keys to Desktop's `setting.json`. Notification
|
|
119
|
+
and CLI-only display changes write only the CLI file. `/settings` updates the
|
|
120
|
+
shared Desktop `messageStreamShowReasoning` preference, so the CLI and Desktop
|
|
121
|
+
use the same saved value. When enabled, the interactive CLI TUI shows all
|
|
122
|
+
reasoning text; when disabled, it keeps the first thought in each turn visible.
|
|
123
|
+
It does not change model reasoning effort or machine-readable headless output.
|
|
120
124
|
|
|
121
125
|
## MCP servers
|
|
122
126
|
|
|
@@ -344,6 +348,15 @@ environments without an available system store must configure either
|
|
|
344
348
|
32–4096 bytes; do not set both. Keep the same secret source for login and later
|
|
345
349
|
requests so existing credentials remain decryptable.
|
|
346
350
|
|
|
351
|
+
On macOS over SSH, a locked keychain can be unlocked without restarting the CLI.
|
|
352
|
+
When credential access requires interaction and a controlling terminal is
|
|
353
|
+
available, the CLI runs `security unlock-keychain` with a hidden password prompt
|
|
354
|
+
and retries only the pending credential operation in the same process. It does
|
|
355
|
+
not change the encryption key or replay completed tasks. See
|
|
356
|
+
[macOS keychain over SSH](HEADLESS.md#macos-keychain-over-ssh) for unattended and
|
|
357
|
+
non-interactive limits. Configuring a new managed secret does not migrate
|
|
358
|
+
existing OS-keychain-encrypted credentials.
|
|
359
|
+
|
|
347
360
|
Start Plan uses the same ZCode OAuth login as Coding Plan; there is no second
|
|
348
361
|
Start Plan sign-in. An existing Desktop session works without another login.
|
|
349
362
|
Choose `account:zai-start-plan/<model>` or `account:bigmodel-start-plan/<model>`
|
|
@@ -11,7 +11,7 @@ CLI 跟随当前 ZCode runtime 的 provider registry schema。Provider 和模型
|
|
|
11
11
|
| 文件 | 用途 |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `~/.zcode/cli/setting.json` | MCP、hooks、插件、权限、网络、存储和 CLI 显示设置 |
|
|
14
|
-
| `~/.zcode/v2/setting.json` |
|
|
14
|
+
| `~/.zcode/v2/setting.json` | 桌面端已有的语言、记忆和思考文本显示偏好,CLI 只读不修改 |
|
|
15
15
|
| `~/.zcode/v2/provider_config.json` | Provider、模型元数据覆盖和默认模型 |
|
|
16
16
|
| `~/.zcode/v2/credentials.json` | 原生 runtime 持久化的凭证 |
|
|
17
17
|
|
|
@@ -91,13 +91,16 @@ CLI 专属字段迁移到 `~/.zcode/cli/setting.json`,省略 provider、main/l
|
|
|
91
91
|
| `/new` | 读取当前共享默认模型 |
|
|
92
92
|
| 恢复会话/重启 | 恢复该会话保存的模型和推理选项 |
|
|
93
93
|
| 语言与记忆 | 读取桌面端 `localePreference`/`memoryEnabled`,显式 CLI 设置优先 |
|
|
94
|
+
| TUI 思考文本 | 从 `/settings` 读取和更新桌面端 `messageStreamShowReasoning` |
|
|
94
95
|
| 主题、终端布局、选中复制、通知 | CLI `setting.json` |
|
|
95
96
|
| MCP 服务器 | CLI `setting.json` → `mcp.servers`;项目与插件服务器的合并规则见 [项目配置与插件](#项目配置与插件) |
|
|
96
97
|
| 工具权限、重试、流超时、hooks、插件等运行设置 | CLI `setting.json`,保留原生项目和环境配置优先级 |
|
|
97
98
|
| 更新缓存、诊断日志、迁移状态 | CLI 目录下的运行文件 |
|
|
98
99
|
|
|
99
|
-
CLI 不向桌面端的 `setting.json`
|
|
100
|
-
|
|
100
|
+
CLI 不向桌面端的 `setting.json` 写入 CLI 专属字段。通知和 CLI 专属显示设置只写 CLI 文件;
|
|
101
|
+
`/settings` 中的思考文本选项会直接更新桌面端共享的 `messageStreamShowReasoning`,让 CLI 与
|
|
102
|
+
桌面端使用同一个保存值。开启时交互式 TUI 显示全部思考内容;关闭时每轮仍显示第一条思考,隐藏后续
|
|
103
|
+
思考内容。该偏好不改变模型推理强度,也不影响机器可读的无头输出。
|
|
101
104
|
|
|
102
105
|
## MCP 服务器
|
|
103
106
|
|
|
@@ -291,6 +294,12 @@ Runtime 使用操作系统凭据仓库保护凭据。无可用系统凭据仓库
|
|
|
291
294
|
`ZCODE_CREDENTIAL_SECRET` 或可读取的 `ZCODE_CREDENTIAL_SECRET_FILE`(文件长度 32–4096 字节),
|
|
292
295
|
两者不可同时设置。登录及后续请求应使用相同的密钥来源,否则已有凭据无法解密。
|
|
293
296
|
|
|
297
|
+
macOS SSH 会话中,钥匙串锁定不要求重启 CLI。当凭据访问需要用户交互且存在控制终端时,
|
|
298
|
+
CLI 会调用系统的 `security unlock-keychain`,通过隐藏输入提示读取密码;解锁后在原进程中
|
|
299
|
+
只重试待完成的凭据操作,不更换加密密钥,也不重放已完成的任务。无人值守或无交互终端时的
|
|
300
|
+
限制见[无头模式指南](HEADLESS.md#macos-keychain-over-ssh)。配置新的托管密钥不会自动迁移
|
|
301
|
+
已有的系统钥匙串加密凭据。
|
|
302
|
+
|
|
294
303
|
Start Plan 与 Coding Plan 共用同一次 ZCode OAuth 登录,不需要第二次套餐授权;已有桌面端
|
|
295
304
|
会话也无需再次登录。在 `/model` 中选择 `account:zai-start-plan/<model>` 或
|
|
296
305
|
`account:bigmodel-start-plan/<model>`,也可以通过 `--model` 指定。Start Plan 请求直接使用
|
package/docs/HEADLESS.md
CHANGED
|
@@ -38,6 +38,31 @@ Record the PID and exit status in your supervisor if you need reliable
|
|
|
38
38
|
cancellation and completion tracking. Configure permissions deliberately;
|
|
39
39
|
headless execution does not provide the TUI's interactive approval experience.
|
|
40
40
|
|
|
41
|
+
## macOS keychain over SSH
|
|
42
|
+
|
|
43
|
+
Headless mode does not require a separate credential secret when the macOS
|
|
44
|
+
keychain is available. If credential access fails because the keychain requires
|
|
45
|
+
user interaction, the CLI pauses that credential operation and runs the system
|
|
46
|
+
`security unlock-keychain` tool in the controlling terminal. Enter the keychain
|
|
47
|
+
password at its hidden prompt. After a successful unlock, the same process
|
|
48
|
+
retries the pending credential operation and continues; restarting the CLI or
|
|
49
|
+
logging in again is not required. Existing credentials and encryption keys are
|
|
50
|
+
not replaced, and completed tasks or tool calls are not replayed.
|
|
51
|
+
|
|
52
|
+
Use an interactive SSH terminal (`ssh -t user@host`) for this flow. The password
|
|
53
|
+
is handled by the system tool, not passed in arguments or environment variables,
|
|
54
|
+
and prompts go to `/dev/tty`, not task stdin or JSON/JSONL stdout. Concurrent
|
|
55
|
+
credential requests share one unlock attempt. A failed unlock or persistent
|
|
56
|
+
keychain item access-control failure stops the operation rather than prompting
|
|
57
|
+
indefinitely. With a raw-mode terminal UI, unlock in a separate terminal and
|
|
58
|
+
retry the operation in the existing session instead.
|
|
59
|
+
|
|
60
|
+
Without a controlling terminal (for example, an unattended service), the CLI
|
|
61
|
+
cannot prompt. Unlock the keychain in an appropriate interactive session or
|
|
62
|
+
configure a stable `ZCODE_CREDENTIAL_SECRET_FILE` before login. Changing secret
|
|
63
|
+
sources does not decrypt or migrate existing `enc:v2:os:` credentials; keep the
|
|
64
|
+
original keychain accessible or use a separate data directory and log in again.
|
|
65
|
+
|
|
41
66
|
## Regression coverage and limits
|
|
42
67
|
|
|
43
68
|
Local HTTP fixtures and real Node child processes exercise:
|
package/docs/HOST_INTEGRATION.md
CHANGED
|
@@ -93,16 +93,22 @@ these variables.
|
|
|
93
93
|
### Herdr plugin
|
|
94
94
|
|
|
95
95
|
`integrations/herdr` is a ZCode plugin marketplace that keeps the pane's agent
|
|
96
|
-
state current while a session runs.
|
|
96
|
+
state current while a session runs. The plugin requires **Herdr 0.9.5 or newer**;
|
|
97
|
+
older versions are not supported. Upgrade both the Herdr CLI and the running
|
|
98
|
+
daemon before enabling the plugin. Check the CLI version with `herdr --version`.
|
|
99
|
+
|
|
100
|
+
Install it from this checkout: in ZCode open
|
|
97
101
|
**Settings → Plugins → Add marketplace**, select `integrations/herdr`, then
|
|
98
102
|
install and enable `herdr-zcode`.
|
|
99
103
|
|
|
100
104
|
The plugin reports `idle` at session start and stop, `working` when a prompt is
|
|
101
105
|
submitted or a tool finishes, and `blocked` when ZCode asks for a permission
|
|
102
106
|
decision. It also sends the session ID and `zcode --resume <session-id>` so the
|
|
103
|
-
host can restore the conversation.
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
host can restore the conversation. The resume command is passed after `--`, as
|
|
108
|
+
supported by Herdr 0.9.5's `pane report-agent` interface. The plugin does not
|
|
109
|
+
fall back to state-only reports for older Herdr versions. Reports run as a
|
|
110
|
+
detached child with no terminal streams and every failure is ignored, so the
|
|
111
|
+
plugin cannot interrupt ZCode. Prompt and tool contents are never forwarded.
|
|
106
112
|
|
|
107
113
|
Outside Herdr the hooks exit without running anything. Nothing here is required
|
|
108
114
|
to use ZCode with another orchestrator.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcode-app-cli",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.2-47",
|
|
4
4
|
"description": "Unofficial terminal client for the ZCode agent runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"test:unit": "bun test test/*.test.ts",
|
|
70
70
|
"test:runtime": "bun test test/runtime/*.test.ts",
|
|
71
71
|
"test:runtime:compat": "bun test test/runtime/launcher.test.ts test/runtime/network-retry.test.ts test/runtime/app-server-auth.test.ts",
|
|
72
|
-
"test:node": "node --test test/node/*.test.cjs",
|
|
72
|
+
"test:node": "node --test test/node/*.test.cjs integrations/herdr/tests/*.test.mjs",
|
|
73
73
|
"test:tui": "bun test test/tui/*.test.ts",
|
|
74
74
|
"test:tui:manual": "bun scripts/tui-scenario.ts --manual",
|
|
75
75
|
"test:tui-scenario": "bun scripts/tui-scenario.ts",
|
package/vendor/cli-config.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
4
|
let node_crypto = require("node:crypto");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
6
|
let node_os = require("node:os");
|
|
7
7
|
let node_child_process = require("node:child_process");
|
|
8
8
|
let node_util = require("node:util");
|
|
9
9
|
let node_async_hooks = require("node:async_hooks");
|
|
10
10
|
let node_buffer = require("node:buffer");
|
|
11
|
+
let node_tty = require("node:tty");
|
|
11
12
|
//#region src/config-paths.ts
|
|
12
13
|
function homeCliSettingsPath(env, platform, fallbackHome) {
|
|
13
14
|
const path = platform === "win32" ? node_path.win32 : node_path.posix;
|
|
@@ -1197,10 +1198,172 @@ async function withHeadlessPromptLifecycle(output, run) {
|
|
|
1197
1198
|
}
|
|
1198
1199
|
}
|
|
1199
1200
|
//#endregion
|
|
1201
|
+
//#region src/runtime-keychain-recovery.ts
|
|
1202
|
+
function recoveryError(message, cause) {
|
|
1203
|
+
return Object.assign(new Error(message, { cause }), { code: "CREDENTIAL_SECURE_STORAGE_UNAVAILABLE" });
|
|
1204
|
+
}
|
|
1205
|
+
function interactionRequired(error) {
|
|
1206
|
+
return error instanceof Error && /user interaction is not allowed|interaction (?:is )?not allowed|keychain (?:is )?locked|errSecInteractionNotAllowed|(?:^|\D)-25308(?:\D|$)/iu.test(error.message);
|
|
1207
|
+
}
|
|
1208
|
+
async function unlockKeychainInTerminal() {
|
|
1209
|
+
if (process.stdin.isRaw) throw recoveryError("The keychain needs unlocking. Unlock it with security unlock-keychain in another terminal, then retry the operation in this session.");
|
|
1210
|
+
let terminal;
|
|
1211
|
+
try {
|
|
1212
|
+
terminal = (0, node_fs.openSync)("/dev/tty", "r+");
|
|
1213
|
+
} catch (cause) {
|
|
1214
|
+
throw recoveryError("The keychain needs unlocking, but no controlling terminal is available. Run security unlock-keychain in an interactive SSH session or configure a managed credential secret.", cause);
|
|
1215
|
+
}
|
|
1216
|
+
const wasFlowing = process.stdin.isTTY && process.stdin.readableFlowing === true;
|
|
1217
|
+
try {
|
|
1218
|
+
if (!(0, node_tty.isatty)(terminal)) throw recoveryError("Keychain unlock requires a controlling terminal.");
|
|
1219
|
+
if (wasFlowing) process.stdin.pause();
|
|
1220
|
+
(0, node_fs.writeSync)(terminal, "\nThe macOS keychain needs unlocking to continue. Enter its password below (Ctrl-C to cancel).\n");
|
|
1221
|
+
await new Promise((resolve, reject) => {
|
|
1222
|
+
const child = (0, node_child_process.spawn)("/usr/bin/security", ["unlock-keychain"], { stdio: [
|
|
1223
|
+
terminal,
|
|
1224
|
+
terminal,
|
|
1225
|
+
terminal
|
|
1226
|
+
] });
|
|
1227
|
+
const handlers = [
|
|
1228
|
+
"SIGINT",
|
|
1229
|
+
"SIGTERM",
|
|
1230
|
+
"SIGHUP"
|
|
1231
|
+
].map((signal) => {
|
|
1232
|
+
const hadListeners = process.listenerCount(signal) > 0;
|
|
1233
|
+
const forward = () => {
|
|
1234
|
+
child.kill(signal);
|
|
1235
|
+
if (!hadListeners) {
|
|
1236
|
+
process.off(signal, forward);
|
|
1237
|
+
process.kill(process.pid, signal);
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
process.prependListener(signal, forward);
|
|
1241
|
+
return {
|
|
1242
|
+
signal,
|
|
1243
|
+
forward
|
|
1244
|
+
};
|
|
1245
|
+
});
|
|
1246
|
+
const cleanup = () => {
|
|
1247
|
+
for (const { signal, forward } of handlers) process.off(signal, forward);
|
|
1248
|
+
};
|
|
1249
|
+
child.once("error", (cause) => {
|
|
1250
|
+
cleanup();
|
|
1251
|
+
reject(recoveryError("Could not start the system keychain unlock tool.", cause));
|
|
1252
|
+
});
|
|
1253
|
+
child.once("close", (code, signal) => {
|
|
1254
|
+
cleanup();
|
|
1255
|
+
if (code === 0) resolve();
|
|
1256
|
+
else reject(recoveryError(signal ? `Keychain unlock was cancelled (${signal}); no credentials were changed.` : "Keychain unlock failed; no credentials were changed. Retry the operation to try again."));
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1259
|
+
(0, node_fs.writeSync)(terminal, "Keychain unlocked; continuing the pending credential operation.\n");
|
|
1260
|
+
} finally {
|
|
1261
|
+
(0, node_fs.closeSync)(terminal);
|
|
1262
|
+
if (wasFlowing) process.stdin.resume();
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function createKeychainRecovery(options = {}) {
|
|
1266
|
+
const platform = options.platform ?? process.platform;
|
|
1267
|
+
const unlock = options.unlock ?? unlockKeychainInTerminal;
|
|
1268
|
+
let pending;
|
|
1269
|
+
let generation = 0;
|
|
1270
|
+
let lastFailure;
|
|
1271
|
+
return async (operation) => {
|
|
1272
|
+
const started = generation;
|
|
1273
|
+
try {
|
|
1274
|
+
return await operation();
|
|
1275
|
+
} catch (error) {
|
|
1276
|
+
if (platform !== "darwin" || !interactionRequired(error)) throw error;
|
|
1277
|
+
if (started === generation) {
|
|
1278
|
+
if (!pending) pending = Promise.resolve().then(unlock).then(() => {
|
|
1279
|
+
lastFailure = void 0;
|
|
1280
|
+
}, (cause) => {
|
|
1281
|
+
lastFailure = cause;
|
|
1282
|
+
throw cause;
|
|
1283
|
+
}).finally(() => {
|
|
1284
|
+
generation++;
|
|
1285
|
+
pending = void 0;
|
|
1286
|
+
});
|
|
1287
|
+
await pending;
|
|
1288
|
+
} else if (lastFailure !== void 0) throw lastFailure;
|
|
1289
|
+
try {
|
|
1290
|
+
return await operation();
|
|
1291
|
+
} catch (cause) {
|
|
1292
|
+
if (interactionRequired(cause)) throw recoveryError("Keychain unlock completed, but credential access is still denied. Check the keychain item's access controls in a local macOS session.", cause);
|
|
1293
|
+
throw cause;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
const recoverKeychain = createKeychainRecovery();
|
|
1299
|
+
function createRecoverableSystemKeyStore(entry, unavailable, recover = recoverKeychain) {
|
|
1300
|
+
const attempt = async (operation) => {
|
|
1301
|
+
try {
|
|
1302
|
+
return await recover(operation);
|
|
1303
|
+
} catch (cause) {
|
|
1304
|
+
if (cause instanceof Error && "code" in cause && cause.code === "CREDENTIAL_SECURE_STORAGE_UNAVAILABLE") throw cause;
|
|
1305
|
+
const error = unavailable();
|
|
1306
|
+
error.cause = cause;
|
|
1307
|
+
throw error;
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
return {
|
|
1311
|
+
get: () => attempt(async () => {
|
|
1312
|
+
const secret = await (await entry()).getSecret();
|
|
1313
|
+
return secret === null ? null : new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(secret));
|
|
1314
|
+
}),
|
|
1315
|
+
set: (value) => attempt(async () => {
|
|
1316
|
+
await (await entry()).setPassword(value);
|
|
1317
|
+
})
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
function cacheCredentialKey(cache, path, pending) {
|
|
1321
|
+
const tracked = pending.catch((error) => {
|
|
1322
|
+
if (cache.get(path) === tracked) cache.delete(path);
|
|
1323
|
+
throw error;
|
|
1324
|
+
});
|
|
1325
|
+
cache.set(path, tracked);
|
|
1326
|
+
return tracked;
|
|
1327
|
+
}
|
|
1328
|
+
//#endregion
|
|
1200
1329
|
//#region src/runtime-config-bridge.ts
|
|
1201
1330
|
function record(value) {
|
|
1202
1331
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
1203
1332
|
}
|
|
1333
|
+
function readTuiShowReasoning(env = process.env) {
|
|
1334
|
+
const desktopPreference = readDesktopSettings(env).messageStreamShowReasoning;
|
|
1335
|
+
return typeof desktopPreference === "boolean" ? desktopPreference : true;
|
|
1336
|
+
}
|
|
1337
|
+
async function writeTuiShowReasoning(value, env = process.env) {
|
|
1338
|
+
const filePath = desktopSettingsPath(env);
|
|
1339
|
+
let settings = {};
|
|
1340
|
+
try {
|
|
1341
|
+
const existing = record(JSON.parse(await (0, node_fs_promises.readFile)(filePath, "utf8")));
|
|
1342
|
+
if (!existing) throw new Error("Desktop setting.json must contain an object.");
|
|
1343
|
+
settings = existing;
|
|
1344
|
+
} catch (error) {
|
|
1345
|
+
if (error.code !== "ENOENT") throw new Error("Unable to read Desktop setting.json; the file was left unchanged.", { cause: error });
|
|
1346
|
+
}
|
|
1347
|
+
const directory = (0, node_path.dirname)(filePath);
|
|
1348
|
+
const temporaryPath = (0, node_path.join)(directory, `.${(0, node_path.basename)(filePath)}.${process.pid}.${(0, node_crypto.randomUUID)()}.tmp`);
|
|
1349
|
+
await (0, node_fs_promises.mkdir)(directory, {
|
|
1350
|
+
recursive: true,
|
|
1351
|
+
mode: 448
|
|
1352
|
+
});
|
|
1353
|
+
try {
|
|
1354
|
+
await (0, node_fs_promises.writeFile)(temporaryPath, `${JSON.stringify({
|
|
1355
|
+
...settings,
|
|
1356
|
+
messageStreamShowReasoning: value
|
|
1357
|
+
}, null, 2)}\n`, {
|
|
1358
|
+
flag: "wx",
|
|
1359
|
+
mode: 384
|
|
1360
|
+
});
|
|
1361
|
+
await (0, node_fs_promises.rename)(temporaryPath, filePath);
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
await (0, node_fs_promises.rm)(temporaryPath, { force: true }).catch(() => {});
|
|
1364
|
+
throw new Error("Unable to save Desktop reasoning visibility; the setting was left unchanged.", { cause: error });
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1204
1367
|
/** Desktop preferences supply defaults; explicit CLI and project settings still win. */
|
|
1205
1368
|
function mergeDesktopSettings(value, filePath, env = process.env) {
|
|
1206
1369
|
const settings = record(value);
|
|
@@ -1317,6 +1480,9 @@ exports.appServerRegistryOptions = appServerRegistryOptions;
|
|
|
1317
1480
|
exports.assertResumableSession = assertResumableSession;
|
|
1318
1481
|
exports.assertSessionModelReady = assertSessionModelReady;
|
|
1319
1482
|
exports.browserOpenCommand = browserOpenCommand;
|
|
1483
|
+
exports.cacheCredentialKey = cacheCredentialKey;
|
|
1484
|
+
exports.createKeychainRecovery = createKeychainRecovery;
|
|
1485
|
+
exports.createRecoverableSystemKeyStore = createRecoverableSystemKeyStore;
|
|
1320
1486
|
exports.createTuiWorkflowManagement = createTuiWorkflowManagement;
|
|
1321
1487
|
exports.ensureSessionForTitle = ensureSessionForTitle;
|
|
1322
1488
|
exports.exchangeBigmodelOAuthCode = exchangeBigmodelOAuthCode;
|
|
@@ -1332,13 +1498,16 @@ exports.readSessionModelState = readSessionModelState;
|
|
|
1332
1498
|
exports.readSessionResumeTarget = readSessionResumeTarget;
|
|
1333
1499
|
exports.readStartPlanSession = readStartPlanSession;
|
|
1334
1500
|
exports.readTuiRuntimeProjection = readTuiRuntimeProjection;
|
|
1501
|
+
exports.readTuiShowReasoning = readTuiShowReasoning;
|
|
1335
1502
|
exports.refreshStandaloneStartPlanRequest = refreshStandaloneStartPlanRequest;
|
|
1336
1503
|
exports.restoreTuiBackgroundTasks = restoreTuiBackgroundTasks;
|
|
1337
1504
|
exports.sendTuiBackgroundTaskMessage = sendTuiBackgroundTaskMessage;
|
|
1338
1505
|
exports.sharedOAuthCredentialReader = sharedOAuthCredentialReader;
|
|
1339
1506
|
exports.sqliteRecoveryStats = sqliteRecoveryStats;
|
|
1340
1507
|
exports.startTuiSavedWorkflow = startTuiSavedWorkflow;
|
|
1508
|
+
exports.unlockKeychainInTerminal = unlockKeychainInTerminal;
|
|
1341
1509
|
exports.withHeadlessPromptLifecycle = withHeadlessPromptLifecycle;
|
|
1342
1510
|
exports.withRecursiveWorkspacePathSuggestions = withRecursiveWorkspacePathSuggestions;
|
|
1343
1511
|
exports.writeConfigurationDoctor = writeConfigurationDoctor;
|
|
1512
|
+
exports.writeTuiShowReasoning = writeTuiShowReasoning;
|
|
1344
1513
|
exports.zaiBusinessAccessToken = zaiBusinessAccessToken;
|
package/vendor/extraction.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"appVersion": "3.18.
|
|
2
|
+
"appVersion": "3.18.2",
|
|
3
3
|
"cliVersion": "0.17.1",
|
|
4
|
-
"extractedAt": "2026-11-
|
|
5
|
-
"sha512": "
|
|
6
|
-
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.18.
|
|
4
|
+
"extractedAt": "2026-11-14T15:13:00.578Z",
|
|
5
|
+
"sha512": "awE4sRAH1TPBhvLGWoFJxhn5PyL0Ji4kfMf3+YW/w1BvGWJaE4biHaBg7QR/UZNXYPtYPvsuYTdyYgYyFgyMsw==",
|
|
6
|
+
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.18.2/linux-x64/ZCode-3.18.2-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
8
8
|
"schemaVersion": 1,
|
|
9
9
|
"cli": {
|
|
@@ -273,6 +273,11 @@
|
|
|
273
273
|
"requirement": "required",
|
|
274
274
|
"status": "applied"
|
|
275
275
|
},
|
|
276
|
+
{
|
|
277
|
+
"id": "terminal-keychain-recovery",
|
|
278
|
+
"requirement": "required",
|
|
279
|
+
"status": "applied"
|
|
280
|
+
},
|
|
276
281
|
{
|
|
277
282
|
"id": "start-plan-standalone",
|
|
278
283
|
"requirement": "optional",
|